Skip to content

Commit

Permalink
Amendments made in response to 3rd round of PR requests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbreweric committed Feb 9, 2024
2 parents a369b89 + 4d75b2e commit bf7f859
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
24 changes: 24 additions & 0 deletions R/antimalarial_resistance.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ get_antimalarial_resistance_parameters <- function(parameters, drugs, timestep)
stop("Error: Antimalarial resistance has not been parameterised; antimalarial_resistance = FALSE")
}

<<<<<<< HEAD
empty_vector <- numeric(length = length(drugs))
artemisinin_resistance_proportion <- empty_vector
partner_drug_resistance_proportion <- empty_vector
Expand All @@ -108,6 +109,15 @@ get_antimalarial_resistance_parameters <- function(parameters, drugs, timestep)
late_clinical_failure_probability <- empty_vector
late_parasitological_failure_probability <- empty_vector
reinfection_during_prophylaxis_probability <- empty_vector
=======
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))
>>>>>>> 4d75b2eb152ccb7a56e74322e6d733e21a32ee7f
dt_slow_parasite_clearance <- rep(parameters$dt, length = length(drugs))

for(i in seq_along(parameters$antimalarial_resistance_drug)) {
Expand All @@ -134,6 +144,20 @@ 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

<<<<<<< HEAD
=======
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")
}

>>>>>>> 4d75b2eb152ccb7a56e74322e6d733e21a32ee7f
return(resistance_parameters)

}
19 changes: 17 additions & 2 deletions R/human_infection.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ calculate_infections <- function(

# calculate vaccine efficacy
vaccine_efficacy <- rep(0, length(source_vector))
vaccine_times <- variables$pev_timestep$get_values(source_vector)
vaccinated <- vaccine_times > -1
vaccine_times <- variables$last_eff_pev_timestep$get_values(source_vector)
pev_profile <- variables$pev_profile$get_values(source_vector)
# get vector of individuals who have received their 3rd dose
vaccinated <- vaccine_times > -1
pev_profile <- pev_profile[vaccinated]
if (length(vaccinated) > 0) {
antibodies <- calculate_pev_antibodies(
Expand Down Expand Up @@ -304,17 +305,31 @@ 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]
<<<<<<< HEAD
} else {
susceptible_to_treatment <- seek_treatment
}

n_early_treatment_failure <- n_treat - susceptible_to_treatment$size()
=======
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)
}

>>>>>>> 4d75b2eb152ccb7a56e74322e6d733e21a32ee7f
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)
<<<<<<< HEAD

renderer$render('n_early_treatment_failure', n_early_treatment_failure, timestep)
=======
>>>>>>> 4d75b2eb152ccb7a56e74322e6d733e21a32ee7f
renderer$render('n_treat_eff_fail', n_treat_eff_fail, timestep)
renderer$render('n_treat_success', successfully_treated$size(), timestep)

Expand Down
13 changes: 13 additions & 0 deletions vignettes/Antimalarial_Resistance.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ knitr::opts_chunk$set(


```{r setup}
<<<<<<< HEAD
# Load the requisite packages:
library(malariasimulation)
# Set colour palette:
cols <- c("#E69F00", "#56B4E9", "#009E73", "#CC79A7","#F0E442", "#0072B2", "#D55E00")
=======
# 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")
# Set colour palette:
cols <- c("#E69F00", "#56B4E9", "#009E73", "#CC79A7","#F0E442", "#0072B2", "#D55E00")
>>>>>>> 4d75b2eb152ccb7a56e74322e6d733e21a32ee7f
```

## Introduction
Expand Down

0 comments on commit bf7f859

Please sign in to comment.