From a57099629e5a9eae854005f2ab492a875a3b8ec8 Mon Sep 17 00:00:00 2001 From: RJSheppard Date: Fri, 28 Jun 2024 12:34:56 +0100 Subject: [PATCH] P.f models blood immunity impact on new infections, while P.v does not. An if statement is added to the human_infection.R code to reflect this. IB immunity is therefore also redundant in the Pv model. These variable assignments, immunity decay, boosts, rendering, and resetting during mortality are removed when parasite == "vivax". The blood immunity parameters have now been removed from the vivax parameter list, and documentation has been adjusted to reflect this. --- R/human_infection.R | 25 ++++++++++++++------- R/mortality_processes.R | 7 ++++-- R/processes.R | 17 ++++++++++---- R/variables.R | 37 ++++++++++++++++++------------- data-raw/parasite_parameters.csv | 7 ------ data/parasite_parameters.rda | Bin 1219 -> 1182 bytes tests/testthat/test-vivax.R | 3 ++- vignettes/Plasmodium_vivax.Rmd | 8 ++++++- 8 files changed, 66 insertions(+), 38 deletions(-) diff --git a/R/human_infection.R b/R/human_infection.R index fdd8019c..09597149 100644 --- a/R/human_infection.R +++ b/R/human_infection.R @@ -22,13 +22,15 @@ simulate_infection <- function( infection_outcome ) { if (bitten_humans$size() > 0) { - boost_immunity( - variables$ib, - bitten_humans, - variables$last_boosted_ib, - timestep, - parameters$ub - ) + if(parameters$parasite == "falciparum"){ + boost_immunity( + variables$ib, + bitten_humans, + variables$last_boosted_ib, + timestep, + parameters$ub + ) + } } # Calculate Infected @@ -61,7 +63,14 @@ calculate_infections <- function( source_humans <- variables$state$get_index_of( c('S', 'A', 'U'))$and(bitten_humans) - b <- blood_immunity(variables$ib$get_values(source_humans), parameters) + if(parameters$parasite == "falciparum"){ + ## p.f models blood immunity + b <- blood_immunity(variables$ib$get_values(source_humans), parameters) + + } else if (parameters$parasite == "vivax"){ + ## p.v does not model blood immunity + b <- parameters$b + } source_vector <- source_humans$to_vector() diff --git a/R/mortality_processes.R b/R/mortality_processes.R index b68f5ee7..9e527e2a 100644 --- a/R/mortality_processes.R +++ b/R/mortality_processes.R @@ -91,15 +91,18 @@ reset_target <- function(variables, events, target, state, parameters, timestep) variables$birth$queue_update(timestep, target) # non-maternal immunity - variables$last_boosted_ib$queue_update(-1, target) variables$last_boosted_ica$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$ica$queue_update(0, target) variables$iva$queue_update(0, target) variables$id$queue_update(0, target) variables$state$queue_update(state, target) + + if(parameters$parasite == "falciparum"){ + variables$last_boosted_ib$queue_update(-1, target) + variables$ib$queue_update(0, target) + } # treatment variables$drug$queue_update(0, target) diff --git a/R/processes.R b/R/processes.R index 12ee3528..39385ac3 100644 --- a/R/processes.R +++ b/R/processes.R @@ -45,9 +45,6 @@ create_processes <- function( parameters$rm), immunity_process = create_exponential_decay_process(variables$ivm, parameters$rvm), - # Blood immunity - immunity_process = create_exponential_decay_process(variables$ib, - parameters$rb), # Acquired immunity immunity_process = create_exponential_decay_process(variables$ica, parameters$rc), @@ -56,6 +53,15 @@ create_processes <- function( immunity_process = create_exponential_decay_process(variables$id, parameters$rid) ) + + if(parameters$parasite == "falciparum"){ + processes <- c( + processes, + # Blood immunity + immunity_process = create_exponential_decay_process(variables$ib, + parameters$rb) + ) + } if (parameters$individual_mosquitoes) { processes <- c( @@ -179,7 +185,10 @@ create_processes <- function( # Rendering # ========= - imm_var_names <- c('ica', 'icm', 'id', 'ib', 'iva', 'ivm') + imm_var_names <- c('ica', 'icm', 'id', 'iva', 'ivm') + if(parameters$parasite == "falciparum"){ + imm_var_names <- c(imm_var_names, 'ib') + } processes <- c( processes, diff --git a/R/variables.R b/R/variables.R index cb3b1a17..db635ba8 100644 --- a/R/variables.R +++ b/R/variables.R @@ -12,7 +12,7 @@ #' boosted for tracking grace periods in the boost of immunity #' * ICM - Maternal immunity to clinical disease #' * IVM - Maternal immunity to severe disease -#' * IB - Pre-erythoctic immunity +#' * IB - Pre-erythrocytic immunity (p.f only) #' * ICA - Acquired immunity to clinical disease #' * IVA - Acquired immunity to severe disease #' * ID - Acquired immunity to detectability @@ -96,7 +96,6 @@ 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_ib <- individual::DoubleVariable$new(rep(-1, size)) last_boosted_ica <- individual::DoubleVariable$new(rep(-1, size)) last_boosted_iva <- individual::DoubleVariable$new(rep(-1, size)) last_boosted_id <- individual::DoubleVariable$new(rep(-1, size)) @@ -124,17 +123,21 @@ create_variables <- function(parameters) { ) ) - # Pre-erythoctic immunity - ib <- individual::DoubleVariable$new( - initial_immunity( - parameters$init_ib, - initial_age, - groups, - eq, - parameters, - 'IB' + if(parameters$parasite == "falciparum"){ + # Pre-erythrocytic immunity + last_boosted_ib <- individual::DoubleVariable$new(rep(-1, size)) + ib <- individual::DoubleVariable$new( + initial_immunity( + parameters$init_ib, + initial_age, + groups, + eq, + parameters, + 'IB' + ) ) - ) + } + # Acquired immunity to clinical disease ica <- individual::DoubleVariable$new( initial_immunity( @@ -224,13 +227,11 @@ create_variables <- function(parameters) { variables <- list( state = state, birth = birth, - last_boosted_ib = last_boosted_ib, last_boosted_ica = last_boosted_ica, last_boosted_iva = last_boosted_iva, last_boosted_id = last_boosted_id, icm = icm, ivm = ivm, - ib = ib, ica = ica, iva = iva, id = id, @@ -248,7 +249,13 @@ create_variables <- function(parameters) { spray_time = spray_time ) - + if(parameters$parasite == "falciparum"){ + variables <- c(variables, + last_boosted_ib = last_boosted_ib, + ib = ib + ) + } + # Add variables for individual mosquitoes if (parameters$individual_mosquitoes) { species_values <- NULL diff --git a/data-raw/parasite_parameters.csv b/data-raw/parasite_parameters.csv index f4142ca5..a1c89444 100644 --- a/data-raw/parasite_parameters.csv +++ b/data-raw/parasite_parameters.csv @@ -89,20 +89,13 @@ vivax,kmax,10, White (2018); doi: 10.1038/s41467-018-05860-8 vivax,du,110,to_be_removed vivax,init_iva,0,to_be_removed vivax,init_ivm,0,to_be_removed -vivax,init_ib,0,to_be_removed vivax,init_id,0,to_be_removed -vivax,ub,7.2,to_be_removed vivax,uv,11.4321,to_be_removed vivax,ud,9.44512,to_be_removed vivax,pvm,0.195768,to_be_removed vivax,rvm,76.8365,to_be_removed -vivax,rb,3650,to_be_removed vivax,rva,10950,to_be_removed vivax,rid,3650,to_be_removed -vivax,b0,0.59,to_be_removed -vivax,b1,0.5,to_be_removed -vivax,ib0,43.9,to_be_removed -vivax,kb,2.16,to_be_removed vivax,theta0,0.0749886,to_be_removed vivax,theta1,0.0001191,to_be_removed vivax,iv0,1.09629,to_be_removed diff --git a/data/parasite_parameters.rda b/data/parasite_parameters.rda index d59e365698b0402456aa2a773280f6c452ef4257..05b107416ca1578f6b754ef0d691db6af7c9f984 100644 GIT binary patch delta 1174 zcmV;H1Zn%j37!cYLRx4!F+o`-Q(1b$_0<3bc>n+Z`F>^JZ~y1#ksKL+o=^(51850R zO${cX9+34k&>p6bNYDn4Q`8=&fHVvtpgks<0ie)mG&C9mKz^yAqfG#MCZ2@yhpDoj znwwFkhv}*fR71)DXaE2J4Lv{uO#lNx13&=K0iXZ?00E!?0000003gYxO$H#)27mz2 z&>0LvO#lW=O*8?cLqH9G1}2&s0MGyc02n5K(V?M}AcH2EG#G~wMuvf*pwIvf15Z#4fHY~4 z$)FyS)E=M!X`lcD)BrSS(V%EFX{#|=tmht{1RI+>1`g%V-)kv|ac0?$Ac1kxCjNi-wA#o8O5EAZsMJ0CR>@*uHFEkREA6(-1ya;w_-5r_icGHXlk zH`5pz8UBkmIl;`!dNo%F|$v^wY$rF4*R5Tj^|%rNQ5OumN61U29TkX0VIP| zGzl#WLP1o@2I%B}Gcyj4VIwfey8$T{Rgs z?TOhA-|Bx=Sbpz(+ZQ=4cB07EbGDov>E>D0{N(WQ)k6G{vs!4P1ZIq{HcW}wIn zfYW5d90(91K!awtRfKJcD>hl$9oN`kZw!$>jPb~<&9{H#=%XMt05aanxrp(wH zb17NPH&IG|VqBR!m2|0K#95RGMlC$lp$HIG*g7AQ zhz^$PA4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z?i^Pwj4@BK(Lz_%#wZ>3)#eTqX>Zj diff --git a/tests/testthat/test-vivax.R b/tests/testthat/test-vivax.R index 0cf0bdf2..acd5f089 100644 --- a/tests/testthat/test-vivax.R +++ b/tests/testthat/test-vivax.R @@ -24,7 +24,8 @@ test_that('Test difference between falciparum and vivax parameter lists', { expect_identical( in_falciparum_not_vivax, - c("gamma1") # asymptomatic infected infectivity towards mosquitos parameter + c("init_ib", "rb", "ub", "b0", "b1", "ib0", "kb", # blood immunity parameters + "gamma1") # asymptomatic infected infectivity towards mosquitos parameter ) expect_identical( diff --git a/vignettes/Plasmodium_vivax.Rmd b/vignettes/Plasmodium_vivax.Rmd index 2cfeef45..5ed608d4 100644 --- a/vignettes/Plasmodium_vivax.Rmd +++ b/vignettes/Plasmodium_vivax.Rmd @@ -53,9 +53,15 @@ The *P. falciparum* model has five human disease compartments: susceptible (S), The *P. vivax* model follows a similar structure to the *P. falciparum* model, and also has five human disease compartments. However, the human disease states modeled explicitly focus on parasite density and detectability, such that we have: susceptible (S), clinical disease (D), **light-microscopy detectable infection (A)**, **PCR detectable infection (U)**, and treated (Tr). +### Immunity + +The *P. falciparum* model tracks four kinds of immunity: immunity to blood stage infection (IB), clinical disease (acquired and maternal, ICA and ICM), to severe disease (acquired and maternal, IVA and IVM), and to detectability (ID). + +The *P. vivax* model tracks two kinds of immunity: immunity to clinical infection (acquired and maternal, ICA and ICM) and anti-parasite immunity (acquired and maternal, IAA and IAM). We do not track immunity to blood stage infections, severe immunity or immunity to detectability. + ### Infectivity of LM-detectable infections -While the *P. falciparum* model calculates the onward infectivity of asymptomatic infections (`ca`) using the age and detectability immunity of each individual, the *P. vivax* model uses a constant infectivity for LM-detectable infections (`ca = 0.1`). +While the *P. falciparum* model calculates the onward infectivity of asymptomatic infections (`ca`) using the age and detectability immunity of each individual, the *P. vivax* model uses a constant onwards infectivity for LM-detectable infections (`ca = 0.1`). ### Key Model References