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

Add hypnozoites to the P.v model #321

Merged
merged 3 commits into from
Oct 22, 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
30 changes: 21 additions & 9 deletions R/biting_process.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ create_biting_process <- function(
function(timestep) {
# Calculate combined EIR
age <- get_age(variables$birth$get_values(), timestep)
bitten_humans <- simulate_bites(
bitten <- simulate_bites(
renderer,
solvers,
models,
Expand All @@ -52,7 +52,8 @@ create_biting_process <- function(
simulate_infection(
variables,
events,
bitten_humans,
bitten$bitten_humans,
bitten$n_bites_per_person,
age,
parameters,
timestep,
Expand All @@ -78,6 +79,7 @@ simulate_bites <- function(
mixing_index = 1
) {
bitten_humans <- individual::Bitset$new(parameters$human_population)
n_bites_per_person <- numeric(0)

human_infectivity <- variables$infectivity$get_values()
if (parameters$tbv) {
Expand Down Expand Up @@ -146,13 +148,24 @@ simulate_bites <- function(

renderer$render(paste0('EIR_', species_name), species_eir, timestep)
EIR <- EIR + species_eir
expected_bites <- species_eir * mean(psi)
if(parameters$parasite == "falciparum"){
# p.f model factors eir by psi
expected_bites <- species_eir * mean(psi)
} else if (parameters$parasite == "vivax"){
# p.v model standardises biting rate het to eir
expected_bites <- species_eir
}

if (expected_bites > 0) {
n_bites <- rpois(1, expected_bites)
if (n_bites > 0) {
bitten_humans$insert(
fast_weighted_sample(n_bites, lambda)
)
bitten <- fast_weighted_sample(n_bites, lambda)
bitten_humans$insert(bitten)
renderer$render('n_bitten', bitten_humans$size(), timestep)
if(parameters$parasite == "vivax"){
# p.v must pass through the number of bites per person
n_bites_per_person <- tabulate(bitten, nbins = length(lambda))
}
}
}

Expand Down Expand Up @@ -202,9 +215,8 @@ simulate_bites <- function(
)
}
}

renderer$render('n_bitten', bitten_humans$size(), timestep)
bitten_humans

list(bitten_humans = bitten_humans, n_bites_per_person = n_bites_per_person)
}


Expand Down
11 changes: 7 additions & 4 deletions R/competing_hazards.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@ CompetingOutcome <- R6::R6Class(

self$target <- individual::Bitset$new(size)
self$rates <- NULL
self$args <- NULL
},
set_rates = function(target, rates){
set_rates = function(target, rates, ...){
stopifnot(target$size() == length(rates))

self$target$copy_from(target)
self$rates <- rates
self$args <- list(...)
},
execute = function(t, target){
private$targeted_process(t, target)
do.call(private$targeted_process, c(t, list(target), self$args))
},
reset = function() {
self$target$clear()
self$rates <- NULL
self$args <- NULL
},
target = NULL,
rates = NULL
rates = NULL,
args = NULL
)
)

Expand Down
Loading
Loading