From a06dc6c3dc11a83229faac1a29cf1293b7a3c8e5 Mon Sep 17 00:00:00 2001 From: RJSheppard Date: Tue, 17 Sep 2024 17:15:53 +0100 Subject: [PATCH] Immunity to severe disease is not modelled in vivax. Switches are included to set and use severe immunity variables. Relevant severe immunity parameters removed from the pv parameters in the parameters csv file. --- R/disease_progression.R | 7 +-- R/human_infection.R | 16 +++--- R/mortality_processes.R | 12 ++-- R/processes.R | 24 ++++---- R/variables.R | 94 +++++++++++++++---------------- data-raw/parasite_parameters.csv | 13 ----- data/parasite_parameters.rda | Bin 1154 -> 1067 bytes tests/testthat/test-vivax.R | 19 ++++--- 8 files changed, 90 insertions(+), 95 deletions(-) diff --git a/R/disease_progression.R b/R/disease_progression.R index 58122915..16de3b18 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){ if (parameters$parasite == "falciparum"){ @@ -33,7 +33,6 @@ create_progression_rates_process <- function( progression_outcome$set_rates( target, progression_rates) - } } 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 81a66d38d4aba71417f8697583dd50a2ae40f579..29d10844ecca16fe66825757c44fc4ce731437e2 100644 GIT binary patch literal 1067 zcmV+`1l0RNT4*^jL0KkKSb^GO;Bw$GJ2YNfb~5msiudNWO|;VP0BC8D&>9SyXlM-p z000ssDWgfEG};Ks4V3*T&;S4c0004y&;S}V4KjLw06jne0NRgG28|j3&;zN*A1Bsw zQ4P;K5*}7p>#?2iEI?P|NI`VcV`9iiFjxkP1VEUEA%bEK?;p?Fa360IeV=FW@uN3W zo2uV&|4(dt?bB!Qqr!dpW3Kx0CzfknSsJ@gxq4L&H9SU7CRn|Wps{H~MpB_%Rdhil zilcmxkTHlMhyc_v0Jf$HDvn@pSHtFJ9Oq|D!zU^U6SRuuEoHe(l;Mw-A*pbivInbhjH}b?QEr7cZ(&QZxR0XG2T4T*6H)-uwvxi^e2SadtvEE7_bpl zuonyyk0Q$m001~y~2t-w(!B+uUb8Kf}g%C1S9zhTkP&lZm zjIQLHVIalAyM|aRwMty2l(lD0d8CzQJ~rwt65LL&(Z}t@-}}~n{6Ib$t8g9Mifw#uU@4oHFPa#N(^CHr)eII z>Tt8s7Hr-ygKjC9WatAD$kiEkQZ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_KrCrK-W@oK9}tiyfHRU6 z1SCmxMq)8NG&7chSc)>7lLQR!(ux$ar<8!T&A==MC3hm%LHhY#9wPAz167A5w7~u^ z{kE#oJ5yXqjyG6pbtWowY`nmWd;I-;$YhOQLj|V}WYWkb!TrE@f>xGe@uDq9h0wIN zLj9}Z!y#tz?V;VEXJKO2UX?+479Yc~s7OlQk5xMq)Zq z%K2UCZMPno!V@wnbg)_W1{L=jY*uJaIXok+c5fC)`Dl_O6*!S4!}dbzXQRu7A+Mqs UuW-a72Ve1bBvXY62{y9(a1{;degFUf 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