From c88ba3550e981894c3ae85cb004f0bbe3ee36710 Mon Sep 17 00:00:00 2001 From: RJSheppard Date: Fri, 28 Jun 2024 15:40:11 +0100 Subject: [PATCH] Immunity to severe disease is not modelled in vivax. Switches are included to set and manipulate severe immunity variables. Relevant severe immunity parameters removed from parameters csv file. --- R/human_infection.R | 16 +++--- R/mortality_processes.R | 12 ++-- R/processes.R | 14 ++--- R/variables.R | 96 ++++++++++++++++--------------- data-raw/parasite_parameters.csv | 15 +---- data/parasite_parameters.rda | Bin 1120 -> 1043 bytes tests/testthat/test-vivax.R | 8 ++- 7 files changed, 78 insertions(+), 83 deletions(-) diff --git a/R/human_infection.R b/R/human_infection.R index 127be07c..d4450cf2 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 aa59908b..e4fa323f 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 8e08cfde..afa74f50 100644 --- a/R/processes.R +++ b/R/processes.R @@ -38,12 +38,9 @@ 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"){ @@ -51,6 +48,9 @@ create_processes <- function( 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) ) @@ -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') } diff --git a/R/variables.R b/R/variables.R index 97fa23db..e5d5a574 100644 --- a/R/variables.R +++ b/R/variables.R @@ -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 @@ -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, @@ -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)) @@ -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( @@ -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)) @@ -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, @@ -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"){ diff --git a/data-raw/parasite_parameters.csv b/data-raw/parasite_parameters.csv index 3fbf37bd..07472b03 100644 --- a/data-raw/parasite_parameters.csv +++ b/data-raw/parasite_parameters.csv @@ -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, diff --git a/data/parasite_parameters.rda b/data/parasite_parameters.rda index 72e794d65e8710ed21b301fe1160d3a00ec70635..4449a56a6251f7a1a4de30e9c24791211aa7e536 100644 GIT binary patch literal 1043 zcmV+u1nm1lT4*^jL0KkKSw4(nTL1%*|NsB_d_~{wfA8nteOUkh|8;ge|NQ><{^q}? zIP-h|eLKJc{H+bB#emX6H8Pk_M8v{9L)2)~3Fv5=28PizWWsuxF&F>{(WZk;O&S59 z83t%H0v?lTsi&c&{ZC4G)Eb7Nsfnc-npD`D z(et#(jyYhd0ZJJm1j4^vn-GvtumuyOIG7U%U`!zISUJC2*RKaMw<@dM!+N~kUc^V< z@ym{+z2he>y{*`P`L+$Frz0XD*+9k7emQmBy*u0&Dht*z?2Keq8A)K0M3<(BNEl%Q zuz(EP2nAzcNl7vT9=~?|_@9ea_=<}_Afo0B5m_=y0#TJz3KIqnRZ7VuTlE-_#3&l7 z2HITYni(^)_i@Du_fNMcp*DVub^r>5goa2Fop(Y(U1OZ9J&F;NBsjp4_Jfm*?2v^4 zhG7LuB&Zw=I%0f1TzfC8llH!6AtePoiitPXLomqcUhU0kW;0l z+#7|_rU#>D&(wiuiPMKLa!qu93q%~Ial}=v;RkaOP|G*W(pp{@uVO>cM9+9bp~@1V zShT^sRbI^BwJaEdliT+BHuGZF^|Z^OaiLv5{)TNh3$kJa0D$+eXnIy^%*Q{>9ZjzY zEFOCTrF7iRn>u*u+pSzWX@Wf<>0Y|btBe! z{S>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vivax.R b/tests/testthat/test-vivax.R index af866893..db1edf19 100644 --- a/tests/testthat/test-vivax.R +++ b/tests/testthat/test-vivax.R @@ -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 ) )