Skip to content
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

Remove severe immunity for P.v #319

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions R/disease_progression.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#' @param progression_outcome competing hazards object for disease progression rates
#' @noRd
create_progression_rates_process <- function(
parameters,
variables,
progression_outcome
parameters,
variables,
progression_outcome
) {
function(timestep){
target <- variables$state$get_index_of("S")$not()
Expand Down
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
24 changes: 13 additions & 11 deletions R/processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,26 @@ create_processes <- function(
# Immunity
# ========
processes <- list(
# Maternal immunity
# Immunity to clinical disease (maternal)
immunity_process = create_exponential_decay_process(variables$icm,
parameters$rm),
immunity_process = create_exponential_decay_process(variables$ivm,
parameters$rvm),
# Acquired immunity
# Immunity to clinical disease (acquired)
immunity_process = create_exponential_decay_process(variables$ica,
parameters$rc),
immunity_process = create_exponential_decay_process(variables$iva,
parameters$rva)
parameters$rc)
)

if(parameters$parasite == "falciparum"){
processes <- c(
processes,
# Blood immunity
immunity_process = create_exponential_decay_process(variables$ib,
parameters$rb),
# Immunity to severe disease (maternal)
immunity_process = create_exponential_decay_process(variables$ivm,
parameters$rvm),
# Immunity to severe disease (acquired)
immunity_process = create_exponential_decay_process(variables$iva,
parameters$rva),
# Immunity to detectability
immunity_process = create_exponential_decay_process(variables$id, parameters$rid)
)
Expand Down Expand Up @@ -193,13 +195,13 @@ 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')
}

processes <- c(
processes,
categorical_renderer = individual::categorical_count_renderer_process(
Expand Down
94 changes: 47 additions & 47 deletions R/variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ create_variables <- function(parameters) {
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 @@ -113,20 +110,22 @@ 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-erythrocytic immunity
# Pre-erythoctic immunity
last_boosted_ib <- individual::DoubleVariable$new(rep(-1, size))
ib <- individual::DoubleVariable$new(
initial_immunity(
Expand All @@ -138,8 +137,33 @@ create_variables <- function(parameters) {
'IB'
)
)

# 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 @@ -153,56 +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 @@ -269,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 @@ -291,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
13 changes: 0 additions & 13 deletions data-raw/parasite_parameters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,3 @@ vivax,f,0.02439024, White (2018); doi: 10.1186/s12936-018-2318-1
vivax,gammal,0.002610966, White (2018): doi: 10.1186/s12936-018-2318-1
vivax,init_hyp,0,
vivax,kmax,10, White (2018); doi: 10.1038/s41467-018-05860-8
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
Binary file modified data/parasite_parameters.rda
Binary file not shown.
19 changes: 11 additions & 8 deletions tests/testthat/test-vivax.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ test_that('Test difference between falciparum and vivax parameter lists', {

expect_identical(
in_falciparum_not_vivax,
c("du", # human delays
"init_ib", "init_id", ## initial immunities
"rb", "rid", # rates of immune loss
"ub", "ud", # immunity non-boosting periods
c("du",
"init_ib", "init_iva", "init_ivm", "init_id", # initial immunity parameters
"rb", "rva", "rid", "rvm", # rates of immune loss
"ub", "uv", "ud", # immunity non-boosting periods
"pvm", # maternal immunity parameters
"b0", "b1", "ib0", "kb", # blood immunity parameters
"fd0", "ad", "gammad", "d1", "id0", "kd", # immunity to detectability parameters
"gamma1") # asymptomatic infected infectivity towards mosquitos parameter
)

"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
)
)

expect_identical(
in_vivax_not_falciparum,
c("dpcr_max", "dpcr_min", "kpcr", "apcr50", # human sub-patent state delay
Expand Down
Loading