Skip to content

Commit

Permalink
Fixes following the 3rd round of comments on the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
tbreweric committed Feb 9, 2024
1 parent c71e9b0 commit a369b89
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
26 changes: 8 additions & 18 deletions R/antimalarial_resistance.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ get_antimalarial_resistance_parameters <- function(parameters, drugs, timestep)
stop("Error: Antimalarial resistance has not been parameterised; antimalarial_resistance = FALSE")
}

artemisinin_resistance_proportion <- numeric(length = length(drugs))
partner_drug_resistance_proportion <- numeric(length = length(drugs))
slow_parasite_clearance_probability <- numeric(length = length(drugs))
early_treatment_failure_probability <- numeric(length = length(drugs))
late_clinical_failure_probability <- numeric(length = length(drugs))
late_parasitological_failure_probability <- numeric(length = length(drugs))
reinfection_during_prophylaxis_probability <- numeric(length = length(drugs))
empty_vector <- numeric(length = length(drugs))
artemisinin_resistance_proportion <- empty_vector
partner_drug_resistance_proportion <- empty_vector
slow_parasite_clearance_probability <- empty_vector
early_treatment_failure_probability <- empty_vector
late_clinical_failure_probability <- empty_vector
late_parasitological_failure_probability <- empty_vector
reinfection_during_prophylaxis_probability <- empty_vector
dt_slow_parasite_clearance <- rep(parameters$dt, length = length(drugs))

for(i in seq_along(parameters$antimalarial_resistance_drug)) {
Expand All @@ -133,17 +134,6 @@ get_antimalarial_resistance_parameters <- function(parameters, drugs, timestep)
resistance_parameters$reinfection_during_prophylaxis_probability <- reinfection_during_prophylaxis_probability
resistance_parameters$dt_slow_parasite_clearance <- dt_slow_parasite_clearance

if(any(c(length(resistance_parameters$artemisinin_resistance_proportion),
length(resistance_parameters$partner_drug_resistance_proportion),
length(resistance_parameters$slow_parasite_clearance_probability),
length(resistance_parameters$early_treatment_failure_probability),
length(resistance_parameters$late_clinical_failure_probability),
length(resistance_parameters$late_parasitological_failure_probability),
length(resistance_parameters$reinfection_during_prophylaxis_probability),
length(resistance_parameters$dt_slow_parasite_clearance)) != length(drugs))) {
stop("Length of one or more resistance parameter vectors does not match length of drugs vector")
}

return(resistance_parameters)

}
7 changes: 3 additions & 4 deletions R/human_infection.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,18 +304,17 @@ calculate_treated <- function(
susceptible_to_treatment_index <- bernoulli_multi_p(p = 1 - unsuccessful_treatment_probability)
susceptible_to_treatment <- bitset_at(seek_treatment, susceptible_to_treatment_index)
drugs <- drugs[susceptible_to_treatment_index]
n_early_treatment_failure <- n_treat - susceptible_to_treatment$size()
renderer$render('n_early_treatment_failure', n_early_treatment_failure, timestep)
} else {
susceptible_to_treatment <- seek_treatment
n_early_treatment_failure <- n_treat - susceptible_to_treatment$size()
renderer$render('n_early_treatment_failure', n_early_treatment_failure, timestep)
}

n_early_treatment_failure <- n_treat - susceptible_to_treatment$size()
successfully_treated_index <- bernoulli_multi_p(parameters$drug_efficacy[drugs])
successfully_treated <- bitset_at(susceptible_to_treatment, successfully_treated_index)
successfully_treated_drugs <- drugs[successfully_treated_index]
n_treat_eff_fail <- susceptible_to_treatment$size() - length(successfully_treated_index)

renderer$render('n_early_treatment_failure', n_early_treatment_failure, timestep)
renderer$render('n_treat_eff_fail', n_treat_eff_fail, timestep)
renderer$render('n_treat_success', successfully_treated$size(), timestep)

Expand Down
7 changes: 1 addition & 6 deletions vignettes/Antimalarial_Resistance.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ knitr::opts_chunk$set(


```{r setup}
# Load the requisite packages:
#library(malariasimulation)
# Use devtools to load the updated malariasimulation:
devtools::load_all("C:/Users/trb216/OneDrive - Imperial College London/Desktop/malariasimulation/malariasimulation.Rproj")
library(malariasimulation)
# Set colour palette:
cols <- c("#E69F00", "#56B4E9", "#009E73", "#CC79A7","#F0E442", "#0072B2", "#D55E00")
```

## Introduction
Expand Down

0 comments on commit a369b89

Please sign in to comment.