diff --git a/R/disease_progression.R b/R/disease_progression.R index 3347bedc..e7968a4d 100644 --- a/R/disease_progression.R +++ b/R/disease_progression.R @@ -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() diff --git a/R/human_infection.R b/R/human_infection.R index 3977c0ba..b00e6ec0 100644 --- a/R/human_infection.R +++ b/R/human_infection.R @@ -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, diff --git a/R/mortality_processes.R b/R/mortality_processes.R index 6396414e..b41aca32 100644 --- a/R/mortality_processes.R +++ b/R/mortality_processes.R @@ -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) } @@ -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"){ diff --git a/R/processes.R b/R/processes.R index b9b2ee82..72513b0c 100644 --- a/R/processes.R +++ b/R/processes.R @@ -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) ) @@ -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( diff --git a/R/variables.R b/R/variables.R index 8567998c..024b695d 100644 --- a/R/variables.R +++ b/R/variables.R @@ -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, @@ -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( @@ -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( @@ -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)) @@ -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, @@ -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"){ diff --git a/data-raw/parasite_parameters.csv b/data-raw/parasite_parameters.csv index 7f2ebb94..e96bada8 100644 --- a/data-raw/parasite_parameters.csv +++ b/data-raw/parasite_parameters.csv @@ -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 diff --git a/data/parasite_parameters.rda b/data/parasite_parameters.rda index 81a66d38..29d10844 100644 Binary files a/data/parasite_parameters.rda and b/data/parasite_parameters.rda differ diff --git a/tests/testthat/test-vivax.R b/tests/testthat/test-vivax.R index 4b4a150f..b1310584 100644 --- a/tests/testthat/test-vivax.R +++ b/tests/testthat/test-vivax.R @@ -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