Skip to content

Commit

Permalink
p.f models blood immunity impact on new infections, while p.v does no…
Browse files Browse the repository at this point in the history
…t. An if statement is added to the human_infection.R code to reflect this.

IB immunity is therefore also redundant, these variable assignments, immunity decay, boosts and rendering are removed when parasite == "vivax".

The blood immunity parameters have now been removed from the vivax parameter list, and documentation has been adjusted to reflect this.
  • Loading branch information
RJSheppard committed Jul 30, 2024
1 parent 1557b4e commit 78d5819
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 34 deletions.
25 changes: 17 additions & 8 deletions R/human_infection.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ simulate_infection <- function(
infection_outcome
) {
if (bitten_humans$size() > 0) {
boost_immunity(
variables$ib,
bitten_humans,
variables$last_boosted_ib,
timestep,
parameters$ub
)
if(parameters$parasite == "falciparum"){
boost_immunity(
variables$ib,
bitten_humans,
variables$last_boosted_ib,
timestep,
parameters$ub
)
}
}

# Calculate Infected
Expand Down Expand Up @@ -61,7 +63,14 @@ calculate_infections <- function(
source_humans <- variables$state$get_index_of(
c('S', 'A', 'U'))$and(bitten_humans)

b <- blood_immunity(variables$ib$get_values(source_humans), parameters)
if(parameters$parasite == "falciparum"){
## p.f models blood immunity
b <- blood_immunity(variables$ib$get_values(source_humans), parameters)

} else if (parameters$parasite == "vivax"){
## p.v does not model blood immunity
b <- parameters$b
}

source_vector <- source_humans$to_vector()

Expand Down
20 changes: 16 additions & 4 deletions R/processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ create_processes <- function(
# Maternal immunity
create_exponential_decay_process(variables$icm, parameters$rm),
create_exponential_decay_process(variables$ivm, parameters$rvm),
# Blood immunity
create_exponential_decay_process(variables$ib, parameters$rb),
# Acquired immunity
create_exponential_decay_process(variables$ica, parameters$rc),
create_exponential_decay_process(variables$iva, parameters$rva),
create_exponential_decay_process(variables$id, parameters$rid)
)

if(parameters$parasite == "falciparum"){
processes <- c(
processes,
# Blood immunity
create_exponential_decay_process(variables$ib, parameters$rb)
)
}

if (parameters$individual_mosquitoes) {
processes <- c(
Expand Down Expand Up @@ -169,6 +175,12 @@ create_processes <- function(
# =========
# Rendering
# =========

imm_var_names <- c('ica','icm','id','iva','ivm')
if(parameters$parasite == "falciparum"){
imm_var_names <- c(imm_var_names,'ib')
}

processes <- c(
processes,
individual::categorical_count_renderer_process(
Expand All @@ -178,8 +190,8 @@ create_processes <- function(
),
create_variable_mean_renderer_process(
renderer,
c('ica', 'icm', 'ib', 'id', 'iva', 'ivm'),
variables[c('ica', 'icm', 'ib', 'id', 'iva', 'ivm')]
imm_var_names,
variables[imm_var_names]
),
create_prevelance_renderer(
variables$state,
Expand Down
37 changes: 22 additions & 15 deletions R/variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' boosted for tracking grace periods in the boost of immunity
#' * ICM - Maternal immunity to clinical disease
#' * IVM - Maternal immunity to severe disease
#' * IB - Pre-erythoctic immunity
#' * IB - Pre-erythoctic immunity (p.f only)
#' * ICA - Acquired immunity to clinical disease
#' * IVA - Acquired immunity to severe disease
#' * ID - Acquired immunity to detectability
Expand Down Expand Up @@ -96,7 +96,6 @@ create_variables <- function(parameters) {
initial_states <- initial_state(parameters, initial_age, groups, eq, states)
state <- individual::CategoricalVariable$new(states, initial_states)
birth <- individual::IntegerVariable$new(-initial_age)
last_boosted_ib <- individual::DoubleVariable$new(rep(-1, size))
last_boosted_ica <- individual::DoubleVariable$new(rep(-1, size))
last_boosted_iva <- individual::DoubleVariable$new(rep(-1, size))
last_boosted_id <- individual::DoubleVariable$new(rep(-1, size))
Expand Down Expand Up @@ -124,17 +123,21 @@ create_variables <- function(parameters) {
)
)

# Pre-erythoctic immunity
ib <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_ib,
initial_age,
groups,
eq,
parameters,
'IB'
if(parameters$parasite == "falciparum"){
# Pre-erythoctic immunity
last_boosted_ib <- individual::DoubleVariable$new(rep(-1, size))
ib <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_ib,
initial_age,
groups,
eq,
parameters,
'IB'
)
)
)
}

# Acquired immunity to clinical disease
ica <- individual::DoubleVariable$new(
initial_immunity(
Expand Down Expand Up @@ -224,13 +227,11 @@ create_variables <- function(parameters) {
variables <- list(
state = state,
birth = birth,
last_boosted_ib = last_boosted_ib,
last_boosted_ica = last_boosted_ica,
last_boosted_iva = last_boosted_iva,
last_boosted_id = last_boosted_id,
icm = icm,
ivm = ivm,
ib = ib,
ica = ica,
iva = iva,
id = id,
Expand All @@ -248,7 +249,13 @@ create_variables <- function(parameters) {
spray_time = spray_time
)


if(parameters$parasite == "falciparum"){
variables <- c(variables,
last_boosted_ib = last_boosted_ib,
ib = ib
)
}

# Add variables for individual mosquitoes
if (parameters$individual_mosquitoes) {
species_values <- NULL
Expand Down
7 changes: 0 additions & 7 deletions data-raw/parasite_parameters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,13 @@ vivax,kmax,10
vivax,du,110,to_be_removed
vivax,init_iva,0,to_be_removed
vivax,init_ivm,0,to_be_removed
vivax,init_ib,0,to_be_removed
vivax,init_id,0,to_be_removed
vivax,ub,7.2,to_be_removed
vivax,uv,11.4321,to_be_removed
vivax,ud,9.44512,to_be_removed
vivax,pvm,0.195768,to_be_removed
vivax,rvm,76.8365,to_be_removed
vivax,rb,3650,to_be_removed
vivax,rva,10950,to_be_removed
vivax,rid,3650,to_be_removed
vivax,b0,0.59,to_be_removed
vivax,b1,0.5,to_be_removed
vivax,ib0,43.9,to_be_removed
vivax,kb,2.16,to_be_removed
vivax,theta0,0.0749886,to_be_removed
vivax,theta1,0.0001191,to_be_removed
vivax,iv0,1.09629,to_be_removed
Expand Down

0 comments on commit 78d5819

Please sign in to comment.