-
Notifications
You must be signed in to change notification settings - Fork 15
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
Antimalarial Resistance: Slow Parasite Clearance #289
Conversation
…ty_process function to include parameters as an input
…arance to the vignette
…alarial_resistance and get_antimalarial_resistance_parameters, then made additional changes to documentation where necessary to reflect changes. Fixed the effects of the changes on unit tests
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.
This is incredible! I've requested a few stylistic changes.
Thank you so much
Thanks @giovannic! I've gone through and made all of the changes - just re-running the checks now but shall commit/push the changes shortly! |
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.
Thanks @tbreweric - this looks really nice! 🥳
I've left one key point regarding rates/probs
Interested to know what others think about the very clear but long variable names.
I wondered if I'd gone too far the other way after we talked about naming clarity / length as we'd discussed it during one of our early code reviews. Happy to change them! |
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.
My requested changes have been addressed. Thanks!
Integrating Slow Parasite Clearance into the Antimalarial Resistance Model
Introduction
In this PR, I have added slow parasite clearance (SPC) as an outcome of malaria infections that are resistant to the artemisinin component of the artemisinin combination therapy (ACT) an individual is treated with. SPC is the phenomenon in which resistant malaria parasites remain in the blood beyond the usual 3 day period taken for the artemisinin component to remove malaria parasites from the patients' blood stream. The parasites are eventually removed by the ACT and the patient successfully treated.
Explanation of Slow Parasite Clearance Code Changes
We have captured SPC by increasing the average time individuals with a clinical infection treated with an ACT spend in the treated compartment. This has involved making changes to eight core model functions, which I will describe below:
set_antimalarial_resistance()
:slow_parasite_clearance_probability
(formerlyslow_parasite_clearance_prob
) has been removed from the test for undeveloped model features. The names of the resistance parameters have also been amended to make them clearer (e.g.reinfection_prob
toreinfection_during_prophylaxis_probability
.get_parameters()
: The documentation and entries for the resistance parameters have been to updated to reflect the changes to some of their names.create_variables()
: If parameters$antimalarial_resistance == TRUEdt
is set up as a variable, initialised withparameters$dt
for all individuals, and appended it to the variables list. A line has also been added to the documentation that explains the new dt variable.create_progression_process()
: The originalcreate_progression_process()
function was only used when the rate at which individuals transition from thefrom_state
to theto_state
was a single parameter value. Whenparameters$antimalarial_resistance == TRUE
, the rate at which individuals move from the treated compartment to the susceptible compartment becomes a variable. When the rate becomes a variable an additional step is required to subset the variable values corresponding to the individuals in thefrom_state
. Thecreate_progression_process()
has been amended to first retrieve and store the indices of all individuals infrom_state
. Iflength(rate) > 1
, telling the function that the rate is a variable rather than a parameter, the rate is overwritten with only the values of the individuals in thefrom_state
in the current timestep. These individual-specific rates are then used to determine which individuals will move from thefrom_state
to theto_state
in the current timestep.create_processes()
: I’ve replaced the create_progression_process() that governs the disease state transition from Tr to S. The updated version stores the parameters$dt as the dt_input and overwrites this with variables$dt if antimalarial_resistance == TRUE. The input for the create_progression_process() is then dt_input.calculate_treated()
: The major change in this PR is within thecalculate_treated()
function. The updated version can simulate both ETF and SPC as outcomes of antimalarial resistance. In the updated version, there are four possible outcomes for individuals that receive treatment:variables$state
updated to D)variables$state
updated to D)variables$state
updated to Tr,variables$dt
updated toparameters$slow_parasite_clearance_time
)variables$state
updated to Tr,variables$dt
updated toparameters$dt
)The order of events has been updated. Once the drugs have been assigned to each individual in
seek_treatment
, the drug efficacy test is performed, with individuals who pass the drug efficacy step stored in the Bitseteffectively_treated
and the drugs vector updated to filter out the drugs of individuals who failed treatment due to drug efficacy.If
parameters$antimalarial_resistance == TRUE
, theget_antimalarial_resistance_parameters()
function is called to retrieve the resistance parameters associated with the drug administered to each individual ineffectively_treated
the current timestep (stored in object calledresistance_parameters
). Each individuals' probability of experiencing early treatment failure is calculated by multiplying theartemisinin_resistance_proportion
andearly_treatment_failure_probability
corresponding to the drug they were administered and the current timestep. These probabilities are used bybernoulli_multi_p()
to determine which individuals are successfully treated (avoid treatment failure due to drug efficacy or drug resistance) and their indices are stored in the Bitsetsuccessfully_treated
. Thedrugs
anddt_slow_parasite_clearance
vector (stored inresistance_parameters
) are subsetted to include only those individuals who have been successfully treated.For each of the
successfully_treated
individuals, a final test is performed to see whether they will experience slow parasite clearance (again viabernoulli_multi_p()
). Additional Bitsets are created to store individuals who will (slow_parasite_clearance_individuals
) and will not experience slow parasite clearance (non_slow_parasite_clearance_individuals
).For the
queue_update
operations, thesuccessfully_treated
Bitset is used to queue updates to the state, infectivity, drug, anddrug_time
variables. Fornon_slow_parasite_clearance
individuals, thedt
variable is updated with the default/non-resistantparameters$dt
. For theslow_parasite_clearance_individuals
, thedt
variable is updated to theparameters$dt_slow_parasite_clearance
value for the drug the individual was administered (fromresistance_parameters$dt_slow_parasite_clearance
).When
parameters$antimalarial_resistance == TRUE
, additional outputs are rendered to capture the number of people who received treatment (n_treated
), the number of individuals who failed treatment due to drug efficacy (n_drug_efficacy_failures
) or early treatment failure (n_early_treatment_failures
), the number of people who experienced slow parasite clearance (n_slow_parasite_clearance
), and the number of individuals who were successfully treated (n_successfully_treated
). Note thatn_successfully_treated
includes individuals with slow parasite clearance as, although they will spend longer in the Tr compartment, they do transition to Tr and eventually S.If
parameters$antimalarial_resistance == FALSE
, the drug resistance steps are skipped, theeffectively_treated
Bitset is copied intosuccessfully_treated
, and only thequeue_update
steps forstate
,infectivity
,drug
, anddrug_time
are performed.reset_target()
: Whenparameters$antimalarial_resistance == TRUE
, a new variabledt
is created. Thereset_target()
function has been amended to accept theparameters
list as an input and reset thedt
variable toparameters$dt
when!is.null(variables$dt)
.run_simulation()
: I have added entries to therun_simulation()
documentation to describe the new model outputs associated with antimalarial resistance. Whenparameters$antimalarial_resistance == TRUE
, the function will now render the following outputs:-
n_treated
: number of individuals that were given an ACT in the current timestep-
n_drug_efficacy_failures
: number of individuals who failed treatment due to the drug efficacy in the current timestep-
n_early_treatment_failures
: number of individuals who failed treatment due to early treatment failure in the current timestep-
n_slow_parasite_clearance
: number of individuals who will experience slow parasite clearance in the current timestep-
n_successfully_treated
: number of individuals who were successfully treated in the current timestep. Note that this includes individuals with SPC (n_slow_parasite_clearance
) as they progress to the Tr compartment and will be successfully treated after an increased residency in the compartment. To calculate the number of non-resistant successfully treated individuals the user can simply don_successfully_treated
-n_slow_parasite_clearance
. Furthermore, of the new parameters,n_drug_efficacy_failures
,n_early_treatment_failures
, andn_successfully_treated
sum ton_treated
.Antimalarial_resistance.Rmd
: I have amended the antimalarial resistance vignette to capture the changes in the names of the resistance parameter inputs forset_antimalarial_resistance()
and references to them in the text. I have also added an example of simulations with multiple resistance outcomes - comparing a no-intervention baseline scenario with treatment-only, ETF-only, SPC-only, and combined ETF and SPC simulations.Additional Changes
simparams
toparameters
in unit tests for consistency with other tests.