Skip to content

Commit

Permalink
Liver stage drug parameters (the final three on vivax parameter set) …
Browse files Browse the repository at this point in the history
…are now set explicitly. The vivax drug set must now therefore by a vector of 7, 4 is not allowed. When there is not a liver-stage efficacy or prophylaxis effect, we set the final three parameters to 0.
  • Loading branch information
RJSheppard committed Dec 9, 2024
1 parent 8930897 commit fb7c893
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 35 deletions.
18 changes: 4 additions & 14 deletions R/drug_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ SP_AQ_params <- c(0.9, 0.32, 4.3, 38.1)
#' @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)
CQ_params_vivax <- c(0.899, 0.5, 5, 20, 0, 0, 0)


#' @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),
Expand Down Expand Up @@ -69,24 +70,13 @@ set_drugs <- function(parameters, 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."),
if(length(drugs[[drug]]) != 7){
warning(paste0("Drug ", drug, " has incorrect number of P. vivax drug parameters. The number of parameters should be 7 for radical cure. To assign a blood stage drug only, set the liver stage drug parameters to 0: see CQ_params_vivax for an example."),
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)
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions R/human_infection.R
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ relapse_bite_infection_hazard_resolution <- function(
timestep
){

if(variables$hypnozoites$get_index_of(0)$not(T)$and(infected_humans)$size()>0){
if(variables$hypnozoites$get_index_of(0)$not(T)$and(infected_humans)$size() > 0){

hypnozoite_humans <- variables$hypnozoites$get_index_of(0)$not(T)
potential_relapse_index <- bitset_index(hypnozoite_humans, infected_humans)
Expand Down Expand Up @@ -555,7 +555,7 @@ ls_treatment_prophylaxis_efficacy <- function(

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

ls_drug <- variables$ls_drug$get_values(bite_infections)
ls_medicated <- ls_drug > 0
Expand Down Expand Up @@ -861,7 +861,7 @@ calculate_successful_treatments <- function(

}

if(length(parameters$drug_hypnozoite_efficacy) > 0){
if(any(parameters$drug_hypnozoite_efficacy > 0)){
effectively_treated_hypnozoites_index <- bernoulli_multi_p(parameters$drug_hypnozoite_efficacy[drugs])
successfully_treated_hypnozoites <- bitset_at(target, effectively_treated_hypnozoites_index)
successfully_treated_list <- c(
Expand Down
2 changes: 1 addition & 1 deletion R/mda_processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ update_mass_drug_admin <- function(
}

# Update liver stage drug effects
if(length(parameters$drug_hypnozoite_efficacy) > 0){
if(any(parameters$drug_hypnozoite_efficacy > 0)){
if(target$successfully_treated_hypnozoites$size() > 0){
variables$hypnozoites$queue_update(0, target$successfully_treated_hypnozoites)
variables$ls_drug$queue_update(drug, target$successfully_treated_hypnozoites)
Expand Down
2 changes: 1 addition & 1 deletion R/variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ create_variables <- function(parameters) {
drug <- individual::IntegerVariable$new(rep(0, size))
drug_time <- individual::IntegerVariable$new(rep(-1, size))

if(length(parameters$drug_hypnozoite_efficacy) > 0){
if(any(parameters$drug_hypnozoite_efficacy > 0)){
ls_drug <- individual::IntegerVariable$new(rep(0, size))
ls_drug_time <- individual::IntegerVariable$new(rep(-1, size))
}
Expand Down
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.

16 changes: 1 addition & 15 deletions tests/testthat/test-vivax.R
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ test_that('relapses are recognised with division between bite infections and rel
})

test_that('Drug functions provide warnings if applied incorrectly', {

expect_warning(
get_parameters(parasite = "falciparum") |>
set_drugs(drugs = list(c(1,2,3,4,5))),
Expand All @@ -326,21 +325,8 @@ test_that('Drug functions provide warnings if applied incorrectly', {
expect_warning(
get_parameters(parasite = "vivax") |>
set_drugs(drugs = list(c(1,2,3,4,5))),
"Drug 1 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."
)

expect_warning(
get_parameters(parasite = "falciparum") |>
set_drugs(drugs = list(CQ_params_vivax)),
regexp = "P. vivax drug parameters are being applied to P. falciparum"
"Drug 1 has incorrect number of P. vivax drug parameters. The number of parameters should be 7 for radical cure. To assign a blood stage drug only, set the liver stage drug parameters to 0: see CQ_params_vivax for an example."
)

expect_warning(
get_parameters(parasite = "vivax") |>
set_drugs(drugs = list(AL_params)),
"P. falciparum drug parameters are being applied to P. vivax"
)

})

test_that('Liver stage prophylaxis functions correctly', {
Expand Down

0 comments on commit fb7c893

Please sign in to comment.