Skip to content

Commit

Permalink
Drug names for falciparum are consistent for backwards compatability.…
Browse files Browse the repository at this point in the history
… Warnings added to set_drugs function for correct parasite drug parameter attribution. Tests to make sure liver stage prophylaxis is correct.
  • Loading branch information
RJSheppard committed Oct 31, 2024
1 parent a24ebdd commit 8ebc04e
Show file tree
Hide file tree
Showing 25 changed files with 196 additions and 166 deletions.
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# Generated by roxygen2: do not edit by hand

export(AL_params)
export(AL_params_falciparum)
export(CQ_PQ_params_vivax)
export(CQ_params_vivax)
export(DHA_PQP_params)
export(DHA_PQP_params_falciparum)
export(SP_AQ_params)
export(SP_AQ_params_falciparum)
export(arab_params)
export(create_pev_profile)
export(fun_params)
Expand Down
59 changes: 33 additions & 26 deletions R/drug_parameters.R
Original file line number Diff line number Diff line change
@@ -1,52 +1,32 @@
#' @title Preset parameters for the DHA-PQP drug
#' @description From SI of Commun. 5:5606 doi: 10.1038/ncomms6606 (2014)
#' @details Use a vector of preset parameters for the DHA-PQP drug (dihydroartemisinin-piperaquine)
#' @details Default parameters, from L to R, are: drug_efficacy: 0.95, drug_rel_c: 0.09434, drug_prophylaxis_shape: 4.4, drug_prophylaxis_scale: 28.1
#' @export
DHA_PQP_params_falciparum <- c(.95, 0.09434, 4.4, 28.1)

#' @title Preset parameters for the DHA-PQP drug
#' @title Preset parameters for the DHA-PQP drug (P. falciparum)
#' @description From SI of Commun. 5:5606 doi: 10.1038/ncomms6606 (2014)
#' @details Use a vector of preset parameters for the DHA-PQP drug (dihydroartemisinin-piperaquine)
#' @details Default parameters, from L to R, are: drug_efficacy: 0.95, drug_rel_c: 0.09434, drug_prophylaxis_shape: 4.4, drug_prophylaxis_scale: 28.1
#' @export
DHA_PQP_params <- c(.95, 0.09434, 4.4, 28.1)

#' @title Preset parameters for the AL drug
#' @description From SI of Commun. 5:5606 doi: 10.1038/ncomms6606 (2014)
#' @details Use a vector of preset parameters for the AL drug (artemether-lumefantrine)
#' @details Default parameters, from L to R, are: drug_efficacy: 0.95, drug_rel_c: 0.05094, drug_prophylaxis_shape: 11.3, drug_prophylaxis_scale: 10.6
#' @export
AL_params_falciparum <- c(.95, 0.05094, 11.3, 10.6)

#' @title Preset parameters for the AL drug
#' @title Preset parameters for the AL drug (P. falciparum)
#' @description From SI of Commun. 5:5606 doi: 10.1038/ncomms6606 (2014)
#' @details Use a vector of preset parameters for the AL drug (artemether-lumefantrine)
#' @details Default parameters, from L to R, are: drug_efficacy: 0.95, drug_rel_c: 0.05094, drug_prophylaxis_shape: 11.3, drug_prophylaxis_scale: 10.6
#' @export
AL_params <- c(.95, 0.05094, 11.3, 10.6)

#' @title Preset parameters for the SP-AQ drug
#' @details Use a vector of preset parameters for the SP-AQ drug (sulphadoxine-pyrimethamine and amodiaquine)
#' @details Default parameters, from L to R, are: drug_efficacy: 0.9, drug_rel_c: 0.32, drug_prophylaxis_shape: 4.3, drug_prophylaxis_scale: 38.1
#' @export
SP_AQ_params_falciparum <- c(0.9, 0.32, 4.3, 38.1)

#' @title Preset parameters for the SP-AQ drug
#' @title Preset parameters for the SP-AQ drug (P. falciparum)
#' @details Use a vector of preset parameters for the SP-AQ drug (sulphadoxine-pyrimethamine and amodiaquine)
#' @details Default parameters, from L to R, are: drug_efficacy: 0.9, drug_rel_c: 0.32, drug_prophylaxis_shape: 4.3, drug_prophylaxis_scale: 38.1
#' @export
SP_AQ_params <- c(0.9, 0.32, 4.3, 38.1)

#' @title Preset parameters for the CQ drug acting on P. vivax
#' @title Preset parameters for the CQ drug (P. vivax)
#' @description Efficacy from SI of Nekkab et al., DOI: 10.1371/journal.pmed.1003535 (2021),
#' shape and scale consistent with a longer prophylaxis time: 28 days, decreasing gradually
#' @details Use a vector of preset parameters for the CQ drug (chloroquine) acting on P. vivax
#' @details Default parameters, from L to R, are: drug_efficacy: 0.899, drug_rel_c: 0.5, drug_prophylaxis_shape: 20, drug_prophylaxis_scale: 5
#' @export
CQ_params_vivax <- c(0.899, 0.5, 5, 20)

#' @title Preset parameters for the CQ-PQ drug acting on P. vivax
#' @title Preset parameters for the CQ-PQ drug (P. vivax)
#' @description Efficacy from SI of Nekkab et al., DOI: 10.1371/journal.pmed.1003535 (2021),
#' BS shape and scale consistent with a longer prophylaxis time: 28 days, decreasing gradually,
#' LS shape are scale consistent with a 7 day PQ treatment, with rapid decay.
Expand All @@ -56,7 +36,7 @@ CQ_params_vivax <- c(0.899, 0.5, 5, 20)
#' @export
CQ_PQ_params_vivax <- c(0.948, 0.5, 5, 20, 0.713, 10, 5.5)

#' @title Preset parameters for the CQ-TQ drug acting on P. vivax
#' @title Preset parameters for the CQ-TQ drug (P. vivax)
#' @description Efficacy from SI of Nekkab et al., DOI: 10.1371/journal.pmed.1003535 (2021),
#' BS shape and scale consistent with a longer prophylaxis time: 28 days, decreasing gradually,
#' LS shape are scale consistent with a single TQ treatment, with longer prophylaxis: 45 days.
Expand All @@ -83,6 +63,33 @@ set_drugs <- function(parameters, drugs) {
'drug_hypnozoite_prophylaxis_scale'
)

if(parameters$parasite == "falciparum"){
for (drug in seq_along(drugs)) {
if(length(drugs[[drug]]) != 4){
warning(paste0("Drug ", drug, " has incorrect number of P. falciparum drug parameters. The number of parameters should be 4."),
call. = FALSE)
} else if (
all(drugs[[drug]] == CQ_params_vivax)){
warning("P. vivax drug parameters are being applied to P. falciparum",
call. = FALSE)
}
}
} else if (parameters$parasite == "vivax"){
for (drug in seq_along(drugs)) {
if(!length(drugs[[drug]]) %in% c(4, 7)){
warning(paste0("Drug ", drug, " has incorrect number of P. vivax drug parameters. The number of parameters should be 4, for blood stage treatment only, or 7, for radical cure."),
call. = FALSE)
} else if(length(drugs[[drug]]) == 4){
if(all(drugs[[drug]] == AL_params) |
all(drugs[[drug]] == DHA_PQP_params) |
all(drugs[[drug]] == SP_AQ_params)){
warning("P. falciparum drug parameters are being applied to P. vivax.",
call. = FALSE)
}
}
}
}

for (drug in seq_along(drugs)) {
for (i in seq_along(drugs[[drug]])) {
parameters[[keys[[i]]]][drug] <- drugs[[drug]][[i]]
Expand Down
60 changes: 42 additions & 18 deletions R/human_infection.R
Original file line number Diff line number Diff line change
Expand Up @@ -519,24 +519,12 @@ relapse_bite_infection_hazard_resolution <- function(
## all bitten humans with an infectious bite (incorporating prophylaxis) get a new batch of hypnozoites
if(bite_infections$size()>0){

## drug prophylaxis may limit formation of new hypnozoite batches
ls_prophylaxis <- rep(0, bite_infections$size())
if(length(parameters$drug_hypnozoite_efficacy) > 0){

ls_drug <- variables$ls_drug$get_values(bite_infections)
ls_medicated <- (ls_drug > 0)
ls_medicated[ls_drug > 0] <- !is.na(parameters$drug_hypnozoite_efficacy[ls_drug])

if (any(ls_medicated)) {
ls_drug <- ls_drug[ls_medicated]
ls_drug_time <- variables$ls_drug_time$get_values(bite_infections)[ls_medicated]
ls_prophylaxis[ls_medicated] <- weibull_survival(
timestep - ls_drug_time,
parameters$drug_hypnozoite_prophylaxis_shape[ls_drug],
parameters$drug_hypnozoite_prophylaxis_scale[ls_drug]
)
}
}
ls_prophylaxis <- ls_treatment_prophylaxis_efficacy(
bite_infections,
variables,
parameters,
timestep
)

# make sure batches are capped
new_hypnozoite_batch_formed <- bitset_at(bite_infections, bernoulli_multi_p(1 - ls_prophylaxis))
Expand All @@ -550,6 +538,42 @@ relapse_bite_infection_hazard_resolution <- function(
}
}

#' @title Calculate protection from formation of new hypnozoite batches due to liver stage drug prophylaxis
#' @description This function calculates the probability that liver stage drug prophylaxis will
#' protect each individual from the formation of new hynozoite batches
#' @param bite_infections a vector of individuals with prospective formation of new hypnozoite batches
#' @param variables a list of all of the model variables
#' @param parameters model parameters
#' @param timestep current timestep
#' @noRd
ls_treatment_prophylaxis_efficacy <- function(
bite_infections,
variables,
parameters,
timestep
){

## drug prophylaxis may limit formation of new hypnozoite batches
ls_prophylaxis <- rep(0, bite_infections$size())
if(length(parameters$drug_hypnozoite_efficacy) > 0){

ls_drug <- variables$ls_drug$get_values(bite_infections)
ls_medicated <- ls_drug > 0
ls_medicated[ls_medicated] <- !is.na(parameters$drug_hypnozoite_efficacy[ls_drug])

if (any(ls_medicated)) {
ls_drug <- ls_drug[ls_medicated]
ls_drug_time <- variables$ls_drug_time$get_values(bite_infections)[ls_medicated]
ls_prophylaxis[ls_medicated] <- weibull_survival(
timestep - ls_drug_time,
parameters$drug_hypnozoite_prophylaxis_shape[ls_drug],
parameters$drug_hypnozoite_prophylaxis_scale[ls_drug]
)
}
}

ls_prophylaxis
}
#' @title Calculate light microscopy detectable infections (p.v only)
#' @description
#' Sample light microscopy detectable infections from all infections
Expand Down
2 changes: 1 addition & 1 deletion man/AL_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions man/AL_params_falciparum.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/CQ_PQ_params_vivax.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/CQ_TQ_params_vivax.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/CQ_params_vivax.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/DHA_PQP_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions man/DHA_PQP_params_falciparum.Rd

This file was deleted.

4 changes: 2 additions & 2 deletions man/SP_AQ_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions man/SP_AQ_params_falciparum.Rd

This file was deleted.

Loading

0 comments on commit 8ebc04e

Please sign in to comment.