Skip to content

Commit

Permalink
Immunity to severe disease is not modelled in vivax. Switches are inc…
Browse files Browse the repository at this point in the history
…luded to set and manipulate severe immunity variables. Relevant severe immunity parameters removed from parameters csv file.
  • Loading branch information
RJSheppard committed Jul 30, 2024
1 parent 4d1fb9a commit c88ba35
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 83 deletions.
16 changes: 9 additions & 7 deletions R/human_infection.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,15 @@ infection_outcome_process <- function(
timestep
)

update_severe_disease(
timestep,
infected_humans,
variables,
parameters,
renderer
)
if(parameters$parasite == "falciparum"){
update_severe_disease(
timestep,
infected_humans,
variables,
parameters,
renderer
)
}

treated <- calculate_treated(
variables,
Expand Down
12 changes: 7 additions & 5 deletions R/mortality_processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ sample_maternal_immunity <- function(variables, target, timestep, parameters) {

# set their maternal immunities
birth_icm <- variables$ica$get_values(mothers) * parameters$pcm
birth_ivm <- variables$iva$get_values(mothers) * parameters$pvm
variables$icm$queue_update(birth_icm, target_group)
variables$ivm$queue_update(birth_ivm, target_group)
if(parameters$parasite == "vivax"){
if(parameters$parasite == "falciparum"){
birth_ivm <- variables$iva$get_values(mothers) * parameters$pvm
variables$ivm$queue_update(birth_ivm, target_group)

} else if(parameters$parasite == "vivax"){
birth_iam <- variables$iaa$get_values(mothers) * parameters$pcm
variables$iam$queue_update(birth_iam, target_group)
}
Expand All @@ -96,15 +98,15 @@ reset_target <- function(variables, events, target, state, parameters, timestep)

# non-maternal immunity
variables$last_boosted_ica$queue_update(-1, target)
variables$last_boosted_iva$queue_update(-1, target)
variables$ica$queue_update(0, target)
variables$iva$queue_update(0, target)
variables$state$queue_update(state, target)

if(parameters$parasite == "falciparum"){
variables$last_boosted_ib$queue_update(-1, target)
variables$last_boosted_iva$queue_update(-1, target)
variables$last_boosted_id$queue_update(-1, target)
variables$ib$queue_update(0, target)
variables$iva$queue_update(0, target)
variables$id$queue_update(0, target)

} else if (parameters$parasite == "vivax"){
Expand Down
14 changes: 7 additions & 7 deletions R/processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ create_processes <- function(
# Immunity
# ========
processes <- list(
# Maternal immunity
# Immunity to clinical disease
create_exponential_decay_process(variables$icm, parameters$rm),
create_exponential_decay_process(variables$ivm, parameters$rvm),
# Acquired immunity
create_exponential_decay_process(variables$ica, parameters$rc),
create_exponential_decay_process(variables$iva, parameters$rva)
create_exponential_decay_process(variables$ica, parameters$rc)
)

if(parameters$parasite == "falciparum"){
processes <- c(
processes,
# Blood immunity
create_exponential_decay_process(variables$ib, parameters$rb),
# Immunity to severe disease
create_exponential_decay_process(variables$ivm, parameters$rvm),
create_exponential_decay_process(variables$iva, parameters$rva),
# Immunity to detectability
create_exponential_decay_process(variables$id, parameters$rid)
)
Expand Down Expand Up @@ -185,9 +185,9 @@ create_processes <- function(
# Rendering
# =========

imm_var_names <- c('ica', 'icm', 'iva', 'ivm')
imm_var_names <- c('ica', 'icm')
if(parameters$parasite == "falciparum"){
imm_var_names <- c(imm_var_names, 'ib', 'id')
imm_var_names <- c(imm_var_names, 'ib', 'iva', 'ivm', 'id')
} else if (parameters$parasite == "vivax"){
imm_var_names <- c(imm_var_names, 'iaa', 'iam')
}
Expand Down
96 changes: 49 additions & 47 deletions R/variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#' boosted for tracking grace periods in the boost of immunity
#' * IAM - Maternal anti-parasite immunity (p.v only)
#' * ICM - Maternal immunity to clinical disease
#' * IVM - Maternal immunity to severe disease
#' * IVM - Maternal immunity to severe disease (p.f only)
#' * IB - Pre-erythrocytic immunity (p.f only)
#' * IAA - Acquired anti-parasite immunity (p.v only)
#' * ICA - Acquired immunity to clinical disease
#' * IVA - Acquired immunity to severe disease
#' * IVA - Acquired immunity to severe disease (p.f only)
#' * ID - Acquired immunity to detectability (p.f only)
#' * zeta - Heterogeneity of human individuals
#' * zeta_group - Discretised heterogeneity of human individuals
Expand Down Expand Up @@ -98,10 +98,8 @@ 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_ica <- individual::DoubleVariable$new(rep(-1, size))
last_boosted_iva <- individual::DoubleVariable$new(rep(-1, size))

# Maternal immunity

# Maternal immunity to clinical disease
icm <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_icm,
Expand All @@ -112,18 +110,20 @@ create_variables <- function(parameters) {
'ICM'
)
)

ivm <- individual::DoubleVariable$new(

# Acquired immunity to clinical disease
last_boosted_ica <- individual::DoubleVariable$new(rep(-1, size))
ica <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_ivm,
parameters$init_ica,
initial_age,
groups,
eq,
parameters,
'IVM'
'ICA'
)
)

if(parameters$parasite == "falciparum"){
# Pre-erythoctic immunity
last_boosted_ib <- individual::DoubleVariable$new(rep(-1, size))
Expand All @@ -138,7 +138,32 @@ create_variables <- function(parameters) {
)
)

# Acquired immunity to detectability
# Maternal immunity to severe disease
ivm <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_ivm,
initial_age,
groups,
eq,
parameters,
'IVM'
)
)

# Acquired immunity to severe disease
last_boosted_iva <- individual::DoubleVariable$new(rep(-1, size))
iva <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_iva,
initial_age,
groups,
eq,
parameters,
'IVA'
)
)

# Acquired immunity to lm detectability
last_boosted_id <- individual::DoubleVariable$new(rep(-1, size))
id <- individual::DoubleVariable$new(
initial_immunity(
Expand All @@ -152,55 +177,32 @@ create_variables <- function(parameters) {
)

} else if (parameters$parasite == "vivax"){
# Acquired anti-parasite immunity
last_boosted_iaa <- individual::DoubleVariable$new(rep(-1, size))
iaa <- individual::DoubleVariable$new(
# Maternal anti-parasite immunity
iam <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_iaa,
parameters$init_iam,
initial_age,
groups,
eq,
parameters,
'IAA'
'IAM'
)
)

# Maternal anti-parasite immunity
iam <- individual::DoubleVariable$new(
# Acquired anti-parasite immunity
last_boosted_iaa <- individual::DoubleVariable$new(rep(-1, size))
iaa <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_iam,
parameters$init_iaa,
initial_age,
groups,
eq,
parameters,
'IAM'
'IAA'
)
)
}

# Acquired immunity to clinical disease
ica <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_ica,
initial_age,
groups,
eq,
parameters,
'ICA'
)
)
# Acquired immunity to severe disease
iva <- individual::DoubleVariable$new(
initial_immunity(
parameters$init_iva,
initial_age,
groups,
eq,
parameters,
'IVA'
)
)

# Initialise infectiousness of humans -> mosquitoes
# NOTE: not yet supporting initialisation of infectiousness of Treated individuals
infectivity_values <- rep(0, get_human_population(parameters, 0))
Expand Down Expand Up @@ -267,11 +269,8 @@ create_variables <- function(parameters) {
state = state,
birth = birth,
last_boosted_ica = last_boosted_ica,
last_boosted_iva = last_boosted_iva,
icm = icm,
ivm = ivm,
ica = ica,
iva = iva,
zeta = zeta,
zeta_group = zeta_group,
infectivity = infectivity,
Expand All @@ -289,8 +288,11 @@ create_variables <- function(parameters) {
if(parameters$parasite == "falciparum"){
variables <- c(variables,
last_boosted_ib = last_boosted_ib,
last_boosted_iva = last_boosted_iva,
last_boosted_id = last_boosted_id,
ivm = ivm,
ib = ib,
iva = iva,
id = id
)
} else if (parameters$parasite == "vivax"){
Expand Down
15 changes: 1 addition & 14 deletions data-raw/parasite_parameters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,4 @@ vivax,dem,8.4,
vivax,f,0.02439024,
vivax,gammal,0.002610966,
vivax,init_hyp,0,
vivax,kmax,10
vivax,init_iva,0,to_be_removed
vivax,init_ivm,0,to_be_removed
vivax,uv,11.4321,to_be_removed
vivax,pvm,0.195768,to_be_removed
vivax,rvm,76.8365,to_be_removed
vivax,rva,10950,to_be_removed
vivax,theta0,0.0749886,to_be_removed
vivax,theta1,0.0001191,to_be_removed
vivax,iv0,1.09629,to_be_removed
vivax,kv,2.00048,to_be_removed
vivax,fv0,0.141195,to_be_removed
vivax,av,2493.41,to_be_removed
vivax,gammav,2.91282,to_be_removed
vivax,kmax,10,
Binary file modified data/parasite_parameters.rda
Binary file not shown.
8 changes: 5 additions & 3 deletions tests/testthat/test-vivax.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ test_that('Test difference between falciparum and vivax parameter lists', {
expect_identical(
in_falciparum_not_vivax,
c("du",
"init_ib", "init_id", # initial immunity parameters
"rb", "rid", # rates of immune loss
"ub", "ud", # non-boosting periods
"init_ib", "init_iva", "init_ivm", "init_id", # initial immunity parameters
"rb", "rva", "rid", "rvm", # rates of immune loss
"ub", "uv", "ud", # non-boosting periods
"pvm", # maternal immunity parameters
"b0", "b1", "ib0", "kb", # blood immunity parameters
"fd0", "ad", "gammad", "d1", "id0", "kd", # asymptomatic detection by light microscopy parameters
"theta0", "theta1", "iv0", "kv", "fv0", "av", "gammav", # severe immunity parameters
"gamma1" # asymptomatic infected infectivity towards mosquitos parameter
)
)
Expand Down

0 comments on commit c88ba35

Please sign in to comment.