-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vivax competing hazards main drugs #330
base: dev
Are you sure you want to change the base?
Changes from 1 commit
a24ebdd
8ebc04e
9ad598f
8930897
fb7c893
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,95 @@ | ||
#' @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 | ||
#' @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 | ||
#' @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 | ||
#' @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 | ||
#' @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 | ||
#' @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. | ||
#' @details Use a vector of preset parameters for the CQ-PQ drug (chloroquine and primaquine) acting on P. vivax | ||
#' @details Default parameters, from L to R, are: drug_efficacy: 0.948, drug_rel_c: 0.5, drug_prophylaxis_shape: 5, drug_prophylaxis_scale: 20, | ||
#' drug_hypnozoite_efficacy: 0.713, drug_hypnozoite_prophylaxis_shape: 10, drug_hypnozoite_prophylaxis_scale: 5.5 | ||
#' @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 | ||
#' @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. | ||
#' @details Use a vector of preset parameters for the CQ-TQ drug (chloroquine and tafenoquine) acting on P. vivax | ||
#' @details Default parameters, from L to R, are: drug_efficacy: 1, drug_rel_c: 0.5, drug_prophylaxis_shape: 5, drug_prophylaxis_scale: 20, | ||
#' drug_hypnozoite_efficacy: 0.713, drug_hypnozoite_prophylaxis_shape: 5.5, drug_hypnozoite_prophylaxis_scale: 30 | ||
CQ_TQ_params_vivax <- c(1, 0.5, 5, 20, 0.713, 5, 30) | ||
|
||
#' @title Parameterise drugs to use in the model | ||
#' | ||
#' @param parameters the model parameters | ||
#' @param drugs a list of drug parameters, can be set using presets | ||
#' @export | ||
set_drugs <- function(parameters, drugs) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any validation we could do here to validate if parameters$parasite == vivax that the correct drugs are used? Or do all drugs make sense for all parasites? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I spoke with Pete about this a while ago, and we came to a place of hoping that people would use their good sense to choose which parameter sets to apply for each species. While drug parameters are parasite-specific, there might be circumstances where someone would want to see what happens if the same drug is applied to both species. I've added a few warnings to flag where people might do something strange while maintaining flexibility. I could change some of the warnings to errors (e.g., the length of the parameter inputs) if we think that's important. |
||
stopifnot(is.list(drugs)) | ||
stopifnot("is.list(drugs) is not TRUE" = is.list(drugs)) | ||
keys <- c( | ||
'drug_efficacy', | ||
'drug_rel_c', | ||
'drug_prophylaxis_shape', | ||
'drug_prophylaxis_scale' | ||
'drug_prophylaxis_scale', | ||
# hypnozoite parameters | ||
'drug_hypnozoite_efficacy', | ||
'drug_hypnozoite_prophylaxis_shape', | ||
'drug_hypnozoite_prophylaxis_scale' | ||
) | ||
|
||
for (drug in seq_along(drugs)) { | ||
for (i in seq_along(drugs[[drug]])) { | ||
parameters[[keys[[i]]]] <- c(parameters[[keys[[i]]]], drugs[[drug]][[i]]) | ||
parameters[[keys[[i]]]][drug] <- drugs[[drug]][[i]] | ||
} | ||
} | ||
parameters | ||
} | ||
|
||
#' @title Parameterise clinical treatment | ||
#' | ||
#' @param parameters the model parameters | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -519,13 +519,33 @@ 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]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect this to fail? Since
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you're saying. An issue is that some of ls_drug will be 0 (if no drugs have been assigned to the individual), which means that |
||||||
|
||||||
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] | ||||||
) | ||||||
} | ||||||
} | ||||||
|
||||||
# make sure batches are capped | ||||||
current_batches <- variables$hypnozoites$get_values(bite_infections) | ||||||
new_hypnozoite_batch_formed <- bitset_at(bite_infections, bernoulli_multi_p(1 - ls_prophylaxis)) | ||||||
current_batches <- variables$hypnozoites$get_values(new_hypnozoite_batch_formed) | ||||||
new_batch_number <- pmin(current_batches + 1, parameters$kmax) | ||||||
|
||||||
variables$hypnozoites$queue_update( | ||||||
new_batch_number, | ||||||
bite_infections | ||||||
new_hypnozoite_batch_formed | ||||||
) | ||||||
} | ||||||
} | ||||||
|
@@ -729,6 +749,15 @@ calculate_treated <- function( | |||||
) | ||||||
} | ||||||
|
||||||
# Update liver stage drug effects | ||||||
if(length(parameters$drug_hynozoite_efficacy) > 0){ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way I've coded it means that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be avoidable if all vivax drugs have that parameter (see other comment)? |
||||||
if(successfully_treated$successfully_treated_hypnozoites$size() > 0){ | ||||||
variables$hypnozoites$queue_update(0, successfully_treated$successfully_treated_hypnozoites) | ||||||
variables$ls_drug$queue_update(drug, successfully_treated$successfully_treated_hypnozoites) | ||||||
variables$ls_drug_time$queue_update(timestep, successfully_treated$successfully_treated_hypnozoites) | ||||||
} | ||||||
} | ||||||
|
||||||
successfully_treated$successfully_treated | ||||||
|
||||||
} | ||||||
|
@@ -808,6 +837,16 @@ calculate_successful_treatments <- function( | |||||
successfully_treated = successfully_treated) | ||||||
|
||||||
} | ||||||
|
||||||
if(length(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( | ||||||
successfully_treated_list, | ||||||
successfully_treated_hypnozoites = successfully_treated_hypnozoites | ||||||
) | ||||||
} | ||||||
|
||||||
successfully_treated_list | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,5 @@ create_pmc_process <- function( | |
timestep, | ||
drug | ||
) | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to keep the non-species specific drugs? Backward compatability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would lean towards keeping AL_params and removing AL_params_falciparum. Bumping the version and getting everyone to change their code is not convenient