| Title: | Individual-Based Simulation Model of Malaria Epidemiology and Genomics |
|---|---|
| Description: | Individual-based simulation model of malaria epidemiology and genomics. magenta extends the imperial malaria model by tracking the infection history of individuals. With this additional genetic characteristics of the parasite can be assessed, including resistance. |
| Authors: | OJ Watson [aut, cre] (ORCID: <https://orcid.org/0000-0003-2374-0741>) |
| Maintainer: | Oliver Watson <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.5.1 |
| Built: | 2026-11-27 16:11:13 UTC |
| Source: | https://github.com/OJWatson/magenta |
These datasets represent the data fitted within the Imperial College Malaria model for relating seasonal profiles to malaria transmission intensity at level 1 admin regions across Africa
admin_units_seasonaladmin_units_seasonal
A dataframe of 850 observations of 15 variables:
admin_units_seasonal: A dataframe of admin units and their seasonal parameters
country: Country string
admin1: Admin 1 string
map_prev_2010: 2010 Atlas map microscopy prevalence in 2-10 year olds
id: Numeric vector of 1:850
gaul_code: Numeric vector for gaul code
a0: Average value of fourier series
a1: First of partial series cos terms
b1: First of partial series sine terms
a2: Second of partial series cos terms
b2: Second of partial series sine terms
a3: Third of partial series cos terms
b3: Third of partial series sine terms
theta_c: Rainfall normalising constant
dide_code: DIDE geo plotting code
ft: Treatment Coverage
convert_barcode_vectors converts human barcode vectors to nums and
calculated COIs.
convert_barcode_vectors( sim_save, ID, sub_patents_included = TRUE, ibd = FALSE, nl = 24, COI_type = "pcr_imperial" )convert_barcode_vectors( sim_save, ID, sub_patents_included = TRUE, ibd = FALSE, nl = 24, COI_type = "pcr_imperial" )
sim_save |
Saved output of simulation |
ID |
Vector of detection immunities for the population |
sub_patents_included |
Boolean as to whether subpatents are included. Default = TRUE |
ibd |
Boolean for IBD simulations. Default = FALSE |
nl |
Numeric for number of loci. Default = 24 |
COI_type |
String for type of COI calculation. Default = "pcr_imperial"
|
Create list describing parameters for drug efficacy and prophlyaxis
drug_create( prob_of_lpf = c(1, 0.97, 0.8, 0.55), barcode_res_pos = c(0, 1), prophylactic_pos = 1, dur_P = 25, dur_SPC = 5, drug_clearance_max_time = 60, prophylactic_probability = 1 - pgamma(seq(0, drug_clearance_max_time, 0.2), shape = 16.8, rate = 16.8/17.9), prophylactic_resistant_probability = 1 - pgamma(seq(0, drug_clearance_max_time, 0.2), shape = 16.8, rate = 16.8/8.7) )drug_create( prob_of_lpf = c(1, 0.97, 0.8, 0.55), barcode_res_pos = c(0, 1), prophylactic_pos = 1, dur_P = 25, dur_SPC = 5, drug_clearance_max_time = 60, prophylactic_probability = 1 - pgamma(seq(0, drug_clearance_max_time, 0.2), shape = 16.8, rate = 16.8/17.9), prophylactic_resistant_probability = 1 - pgamma(seq(0, drug_clearance_max_time, 0.2), shape = 16.8, rate = 16.8/8.7) )
prob_of_lpf |
Vector of probabilities for the chance of late parasitological failure (lpf). The vector gives the prob of lpf for each relevent barcode combination for a given drug. E.g. The default is:
The vector is length 4, and so 2 barcode positions change the prob of lpf. If the parasite is 0,0 then the prob of lpf is 0 (1-1), but if it was 0,1 it would be 0.2. |
barcode_res_pos |
Vector for which barcode positions correspond to which drug resistance mechanism. E.g. the default is:
Resistance to drug is encoded at barcode position 0 and 1 |
prophylactic_pos |
Vector for which barcode positions determine the
impact of drug resistance in shortening the effective prophylactic period.
E.g. the default is |
dur_P |
Duration of prophylaxis in days. Default = 25. |
dur_SPC |
Duration of slow parasite clearance. Default = 5. |
drug_clearance_max_time |
Maximum number of days to which to consider waning prophylaxis. Default = 60 days. |
prophylactic_probability |
Vector of changing probability of reinfection
due to waning prophylaxis. The last element reflects the probability after
|
prophylactic_resistant_probability |
Vector of changing probability of
reinfection due to waning prophylaxis when challenged by a parasite that is
resistant to the partner drug. The last element reflects the probability after
|
AL Drug Create
drug_create_al()drug_create_al()
We have curves of the longest and shortest duration of AL prophylaxis from Bretscher et al. However, we have multiple types of partner drug resistance. At the moment we will say that any loci associated with lumefantrine resistance yield the resistant curve but it may be better to have a distinct curve for each lumefantrine resistant genotype with the T0.5 aligned to the prob of lpf.
ASAQ Drug Create
drug_create_asaq()drug_create_asaq()
We have curves of the longest and shortest duration of ASAQ prophylaxis from Bretscher et al. However, we have multiple types of partner drug resistance. At the moment we will say that any loci associated with AQ resistance yield the resistant curve but it may be better to have a distinct curve for each AQ resistant genotype with the T0.5 aligned to the prob of lpf.
Perfect Drug Create
drug_create_default_no_resistance()drug_create_default_no_resistance()
Perfect Efficacy Drug. Used as default to match deterministic model easily
List for simulating drug usage for resistance/mft variables
drug_list_create( resistance_flag = FALSE, number_of_resistance_loci = 2, artemisinin_loci = c(0), cost_of_resistance = c(0.99, 0.99), absolute_fitness_cost_flag = FALSE, epistatic_logic = NULL, number_of_drugs = 1, drugs = list(drug_create_default_no_resistance()), mft_flag = FALSE, temporal_cycling = -1, sequential_cycling = -1, sequential_update = 3, drug_choice = 0, partner_drug_ratios = rep(1/number_of_drugs, number_of_drugs) )drug_list_create( resistance_flag = FALSE, number_of_resistance_loci = 2, artemisinin_loci = c(0), cost_of_resistance = c(0.99, 0.99), absolute_fitness_cost_flag = FALSE, epistatic_logic = NULL, number_of_drugs = 1, drugs = list(drug_create_default_no_resistance()), mft_flag = FALSE, temporal_cycling = -1, sequential_cycling = -1, sequential_update = 3, drug_choice = 0, partner_drug_ratios = rep(1/number_of_drugs, number_of_drugs) )
resistance_flag |
Boolean are we simulating resistance |
number_of_resistance_loci |
Numeric for number of res. loci |
artemisinin_loci |
Numerics for barcode positions that confer artemisinin resistance |
cost_of_resistance |
Numeric vector for fitness cost of each resistance loci. |
absolute_fitness_cost_flag |
Boolean are we simulating fitness costs as absolute (i.e. impactive onward transmission chance) or relative (resistant strains have decreases chance of being onwardly transmitted in mixed infections). Default = FALSE. |
epistatic_logic |
Is there compensatory relationships. i.e. what loci need to be true for resistance cost to exist. Default of NULL means that this becomes seq_len(number_of_resistance_loci), i.e. only dependent on their own loci. (TODO: Change this to be a list of length norl) |
number_of_drugs |
Numeric for number of drugs used |
drugs |
List of drugs that are being used, with each list element being
created by |
mft_flag |
Boolean are we doing mft |
temporal_cycling |
Numeric for when in years a drug switch occurs |
sequential_cycling |
Numeric for what perc. treatment failure before switch |
sequential_update |
How long does it take in years for sequential to be implemented |
drug_choice |
What's the default drug choice to begin. Default = 0 |
partner_drug_ratios |
Numeric vector for ratio of first line drugs used |
Table of probaility of late parasitological failure (28-day treatment failure) per genoytpe.
Sourced from:
Antimalarial mass drug administration in large populations and the evolution of drug resistance. Tran Dang Nguyen, Thu Nguyen-Anh Tran, Daniel M. Parker, Nicholas J White, Maciej F Boni. bioRxiv 2021.03.08.434496; doi: https://doi.org/10.1101/2021.03.08.434496
drug_tabledrug_table
A data.frame of drug efficacies by genotype
equilibrium_init_create creates an equilibrium initialisation state to be
used within later model runs
equilibrium_init_create( age_vector, het_brackets, ft, EIR, model_param_list, country = NULL, admin = NULL, quiet = FALSE, seasonality = NULL )equilibrium_init_create( age_vector, het_brackets, ft, EIR, model_param_list, country = NULL, admin = NULL, quiet = FALSE, seasonality = NULL )
age_vector |
Vector of age brackets. |
het_brackets |
Integer number of biting heteogenity compartments. |
ft |
Numeric for the frequency of people seeking treatment. |
EIR |
Numeric for desired annual EIR. |
model_param_list |
List of epidemiological parameters created by |
country |
String for country of interest. If NULL the seasonal parameters will attempt to be loaded using just the admin unit, however if there is ambiguity in the admin unit an error will be thrown. If both NULL then no seasonality is assumed. Default = NULL. |
admin |
String for admin unit with country for loading seasonal parameters. If country is NULL, the admin unit will attempt to be located,however if there is ambiguity in the admin unit an error will be thrown. If both country and admin are NULL then no seasonality is assumed. Default = NULL. |
quiet |
Whether function should be quiet. If FALSE (default) the returned country and admin are printed. |
seasonality |
Optional named numeric vector (or list) of seasonal
parameters, |
List for simulation housekeeping vars, e.g. quiet prints,
housekeeping_list_create( quiet = TRUE, quiet_test = TRUE, cluster = FALSE, clear_up = TRUE )housekeeping_list_create( quiet = TRUE, quiet_test = TRUE, cluster = FALSE, clear_up = TRUE )
quiet |
Boolean for quiet simulation. Default = TRUE |
quiet_test |
Boolean for quiet testing statement. Default = TRUE |
cluster |
Boolean for simulation being on cluster. Default = TRUE |
clear_up |
Boolean for whether to clear up the memory used by the simulation. Default = TRUE |
Importation data for admin units in admin_units_seasonal
importationsimportations
A list of length 18
importations: A list of length 18, with each list representing a year. In each
year is then a further 2 lists which are:
incidence: Proportions of incidence that originated from other admin units, i.e. individuals in admin i that moved to admin j and then returned with an infection acquired while in admin j.
mosquitoFOI: Proportion of the force of infection towards mosquitoes that originated from outside admin units, i.e. the proportion of mosquitoes that are infected from infected individuals who travelled from admin j into admin i.
Intervention grab
intervention_grab( country, admin, year_range, final_itn_cov = NULL, final_irs_cov = NULL, final_ft = NULL )intervention_grab( country, admin, year_range, final_itn_cov = NULL, final_irs_cov = NULL, final_ft = NULL )
country |
Country string |
admin |
Admin string |
year_range |
Year range |
final_itn_cov |
Final ITN coverage |
final_irs_cov |
Final IRS coverage |
final_ft |
Final treatment coverage |
Grabs ITN, IRS ft from database
N.B. The admin region used for ft can be checked
IRS data for SSSA for 2000 to 2015
irs_2000_2015irs_2000_2015
A dataframe of 5 elements:
$irs_2000_2015: A dataframe of admin units and their seasonal parameters
intervention: String stating IRS
country: Country string
admin: Admin string
year: Numeric year
value: Value for IRS coverage
ITN data for SSSA for 2000 to 2015
itn_2000_2015itn_2000_2015
A dataframe of 5 elements:
itn_2000_2015: A dataframe of admin units and their seasonal parameters
intervention: String stating ITN
country: Country string
admin: Admin string
year: Numeric year
value: Value for ITN coverage
model_param_list_create creates list of model parameters to be used
within equilibrium_init_create
model_param_list_create( eta = 0.0001305, rho = 0.85, a0 = 2920, sigma2 = 1.67, max_age = 100 * 365, rA = 0.00512821, rT = 0.2, rD = 0.2, rU = 0.00906627, rP = 1/25, dE = 12, delayGam = 12.5, cD = 0.0676909, cT = 0.322 * cD, cU = 0.006203, gamma1 = 1.82425, d1 = 0.160527, dID = 3650, ID0 = 1.577533, kD = 0.476614, uD = 9.44512, aD = 8001.99, fD0 = 0.007055, gammaD = 4.8183, alphaA = 0.75735, alphaU = 0.185624, b0 = 0.590076, b1 = 0.5, dB = 3650, IB0 = 43.8787, kB = 2.15506, uB = 7.19919, phi0 = 0.791666, phi1 = 0.000737, dCA = 10950, IC0 = 18.02366, kC = 2.36949, uCA = 6.06349, PM = 0.774368, dCM = 67.6952, theta0 = 0.0749886, theta1 = 0.0001191, dVA = 10950, IV0 = 1.09629, kV = 2.00048, uVA = 11.4321, fV0 = 0.141195, aV = 2493.41, gammaV = 2.91282, PVM = 0.195768, dVM = 76.8365, delayMos = 10, tau1 = 0.69, tau2 = 2.31, mu0 = 0.132, Q0 = 0.92, chi = 0.86, bites_Bed = 0.89, bites_Indoors = 0.97, muEL = 0.0338, muLL = 0.0348, muPL = 0.249, dEL = 6.64, dLL = 3.72, dPL = 0.643, gammaL = 13.25, km = 11, cm = 0.05, betaL = 21.2, num_int = 4, itn_cov = 0, irs_cov = 0, ITN_IRS_on = -1, DY = 365, d_ITN0 = 0.41, r_ITN0 = 0.56, r_ITN1 = 0.24, r_IRS0 = 0.6, d_IRS0 = 1, irs_half_life = 0.5 * DY, itn_half_life = 2.64 * DY, IRS_interval = 1 * DY, ITN_interval = 3 * DY, itn_decay_clock = c("breakpoint", "campaign", "constant"), itn_campaign_t0 = 0 )model_param_list_create( eta = 0.0001305, rho = 0.85, a0 = 2920, sigma2 = 1.67, max_age = 100 * 365, rA = 0.00512821, rT = 0.2, rD = 0.2, rU = 0.00906627, rP = 1/25, dE = 12, delayGam = 12.5, cD = 0.0676909, cT = 0.322 * cD, cU = 0.006203, gamma1 = 1.82425, d1 = 0.160527, dID = 3650, ID0 = 1.577533, kD = 0.476614, uD = 9.44512, aD = 8001.99, fD0 = 0.007055, gammaD = 4.8183, alphaA = 0.75735, alphaU = 0.185624, b0 = 0.590076, b1 = 0.5, dB = 3650, IB0 = 43.8787, kB = 2.15506, uB = 7.19919, phi0 = 0.791666, phi1 = 0.000737, dCA = 10950, IC0 = 18.02366, kC = 2.36949, uCA = 6.06349, PM = 0.774368, dCM = 67.6952, theta0 = 0.0749886, theta1 = 0.0001191, dVA = 10950, IV0 = 1.09629, kV = 2.00048, uVA = 11.4321, fV0 = 0.141195, aV = 2493.41, gammaV = 2.91282, PVM = 0.195768, dVM = 76.8365, delayMos = 10, tau1 = 0.69, tau2 = 2.31, mu0 = 0.132, Q0 = 0.92, chi = 0.86, bites_Bed = 0.89, bites_Indoors = 0.97, muEL = 0.0338, muLL = 0.0348, muPL = 0.249, dEL = 6.64, dLL = 3.72, dPL = 0.643, gammaL = 13.25, km = 11, cm = 0.05, betaL = 21.2, num_int = 4, itn_cov = 0, irs_cov = 0, ITN_IRS_on = -1, DY = 365, d_ITN0 = 0.41, r_ITN0 = 0.56, r_ITN1 = 0.24, r_IRS0 = 0.6, d_IRS0 = 1, irs_half_life = 0.5 * DY, itn_half_life = 2.64 * DY, IRS_interval = 1 * DY, ITN_interval = 3 * DY, itn_decay_clock = c("breakpoint", "campaign", "constant"), itn_campaign_t0 = 0 )
eta |
Death rate for expoential population distribtuion, i.e. 1/Mean Population Age. Default = 0.0001305 |
rho |
Age-dependent biting parameter. Default = 0.85 |
a0 |
Age-dependent biting parameter. Default = 2920 |
sigma2 |
Variance of the log heterogeneity in biting rates. Default = 1.67 |
max_age |
Maximum age in days. Default = 100*365 |
rA |
Rate of leaving asymptomatic infection. Default = 0.00512821 |
rT |
Rate of leaving treatment. Default = 0.2 |
rD |
Rate of leaving clinical disease. Default = 0.2 |
rU |
Rate of recovering from subpatent infection. Default = 0.00906627 |
rP |
Rate of leaving prophylaxis. Default = 0.05 |
dE |
Latent period of human infection. Default = 12 |
delayGam |
Lag from parasites to infectious gametocytes. Default = 12.5 |
cD |
Untreated disease contribution to infectiousness. Default = 0.0676909 |
cT |
Treated disease contribution to infectiousness. Default = 0.322 * cD |
cU |
Subpatent disease contribution to infectiousness. Default = 0.006203 |
gamma1 |
Parameter for infectiousness of state A. Default = 1.82425 |
d1 |
Minimum probability due to maximum immunity. Default = 0.160527 |
dID |
Inverse of decay rate. Default = 3650 |
ID0 |
Scale parameter. Default = 1.577533 |
kD |
Shape parameter. Default = 0.476614 |
uD |
Duration in which immunity is not boosted. Default = 9.44512 |
aD |
Scale parameter relating age to immunity. Default = 8001.99 |
fD0 |
Time-scale at which immunity changes with age. Default = 0.007055 |
gammaD |
Shape parameter relating age to immunity. Default = 4.8183 |
alphaA |
PCR detection probability parameters state A. Default = 0.757 |
alphaU |
PCR detection probability parameters state U. Default = 0.186 |
b0 |
Maximum probability due to no immunity. Default = 0.590076 |
b1 |
Maximum relative reduction due to immunity. Default = 0.5 |
dB |
Inverse of decay rate. Default = 3650 |
IB0 |
Scale parameter. Default = 43.8787 |
kB |
Shape parameter. Default = 2.15506 |
uB |
Duration in which immunity is not boosted. Default = 7.19919 |
phi0 |
Maximum probability due to no immunity. Default = 0.791666 |
phi1 |
Maximum relative reduction due to immunity. Default = 0.000737 |
dCA |
Inverse of decay rate. Default = 10950 |
IC0 |
Scale parameter. Default = 18.02366 |
kC |
Shape parameter. Default = 2.36949 |
uCA |
Duration in which immunity is not boosted. Default = 6.06349 |
PM |
New-born immunity relative to mother. Default = 0.774368 |
dCM |
Inverse of decay rate of maternal immunity. Default = 67.6952 |
theta0 |
Maximum probability that an infection is severe, i.e. with no severe immunity. Default = 0.0749886 |
theta1 |
Maximum relative reduction in the probability of severe disease due to immunity. Default = 0.0001191 |
dVA |
Inverse of decay rate of acquired severe immunity (30 years). Default = 10950 |
IV0 |
Severe immunity scale parameter. Default = 1.09629 |
kV |
Severe immunity shape parameter. Default = 2.00048 |
uVA |
Duration in which severe immunity is not boosted. Default = 11.4321 |
fV0 |
Severe immunity age modifier at birth. Default = 0.141195 |
aV |
Severe immunity age modifier scale. Default = 2493.41 |
gammaV |
Severe immunity age modifier shape. Default = 2.91282 |
PVM |
New-born severe immunity relative to mother. Default = 0.195768 |
dVM |
Inverse of decay rate of maternal severe immunity. Default = 76.8365 |
delayMos |
Extrinsic incubation period. Default = 10 |
tau1 |
Duration of host seeking, assumed to be constant between species. Default = 0.69 |
tau2 |
Duration of mosquito resting after feed. Default = 2.31 |
mu0 |
Daily mortality of adult mosquitos. Default = 0.132 |
Q0 |
Anthrophagy probability. Default = 0.92 |
chi |
Endophily probability. Default = 0.86 |
bites_Bed |
Percentage of bites indoors and in bed. Default = 0.89 |
bites_Indoors |
Percentage of bites indoors . Default = 0.97 |
muEL |
Per capita daily mortality rate of early stage larvae (low density). Default = 0.0338 |
muLL |
Per capita daily mortality rate of late stage larvae (low density). Default = 0.0348 |
muPL |
Per capita daily mortality rate of pupae. Default = 0.249 |
dEL |
Development time of early stage larvae. Default = 6.64 |
dLL |
Development time of late stage larvae. Default = 3.72 |
dPL |
Development time of pupae. Default = 0.643 |
gammaL |
Relative effect of density dependence on late instars relative to early instars. Default = 13.25 |
km |
Seasonal carrying capacity. Default = 11 |
cm |
Seasonal birth rate. Default = 0.05 |
betaL |
Number of eggs laid per day per mosquito. Default = 21.2 |
num_int |
Number of possible interventions. Default = 4 |
itn_cov |
The proportion of people that use an ITN. Default = 0 |
irs_cov |
The proportion of people living in houses that have been sprayed. Default = 0 |
ITN_IRS_on |
Time of ITN and IRS to be activated. Default = -1, i.e. never. |
DY |
Duration of year (days). Default = 365 |
d_ITN0 |
Probability of dying with an encounter with ITN (max). Default = 0.41 |
r_ITN0 |
Probability of repeating behaviour with ITN (max). Default = 0.56 |
r_ITN1 |
Probability of repeating behaviour with ITN (min). Default = 0.24 |
r_IRS0 |
Probability of repeating behaviour with IRS (min). Default = 0.6 |
d_IRS0 |
Probability of dying with an encounter with IRS (max). Default = 1 |
irs_half_life |
IRS half life. Default = 0.5 * DY |
itn_half_life |
ITN half life. Default = 2.64 * DY |
IRS_interval |
How long before IRS is repeated, i.e. when IRS decay = 1. Default = 1 * DY |
ITN_interval |
How long before ITN is repeated, i.e. when ITN decay = 1. Default = 3 * DY |
itn_decay_clock |
How ITN efficacy decays over time in the mosquito model: "breakpoint" (default, the original behaviour) treats nets as new at each intervention breakpoint (each year in [pipeline()]), so nets are never more than a year old; "campaign" ages nets from 'itn_campaign_t0' and re-issues them every 'ITN_interval'; "constant" holds efficacy at its mean over a net life of 'ITN_interval', i.e. the steady state of continuous top-ups. IRS always resets at each breakpoint. |
itn_campaign_t0 |
Day (simulation time) of a net campaign, used to anchor the "campaign" clock. Default = 0 |
The severe disease parameters follow Griffin JT, Hollingsworth TD, Reyburn H, Drakeley CJ, Riley EM, Ghani AC. Gradual acquisition of immunity to severe malaria with increasing exposure. Proc R Soc B 2015;282:20142657 (Table S3). The defaults are the values used in malariasimulation, which differ slightly from the published medians (IV0 1.05, kV 1.99, uVA 11.3). fV0, aV and gammaV are not tabulated in the 2015 paper; they are the fitted values as used in malariasimulation.
List for simulating non malarial fever
nmf_list_create( nmf_flag = FALSE, mean_nmf_frequency = c(148.578, 139.578, 141.564, 155.874, 179.364, 216.192, 233.478, 268.056, 312.858, 315.564, 285.156, 255.246, 238.302, 216.618), nmf_age_brackets = c(-0.1, 365, 730, 1095, 1460, 1825, 2555, 3285, 4015, 4745, 5475, 7300, 9125, 10950, 36850), prob_of_testing_nmf = 0.5 )nmf_list_create( nmf_flag = FALSE, mean_nmf_frequency = c(148.578, 139.578, 141.564, 155.874, 179.364, 216.192, 233.478, 268.056, 312.858, 315.564, 285.156, 255.246, 238.302, 216.618), nmf_age_brackets = c(-0.1, 365, 730, 1095, 1460, 1825, 2555, 3285, 4015, 4745, 5475, 7300, 9125, 10950, 36850), prob_of_testing_nmf = 0.5 )
nmf_flag |
Boolean are we doing non malarial fevers |
mean_nmf_frequency |
Vector for mean number of days between fevers for the age bracket considered |
nmf_age_brackets |
Vector for age brackets |
prob_of_testing_nmf |
Numeric for probability that a NMF is tested by RDT before being treated with antimalarials. |
param_list_simulation_finalizer_create creates suitable parameter list for
simulation_R for free memory used by a simulation
param_list_simulation_finalizer_create(statePtr)param_list_simulation_finalizer_create(statePtr)
statePtr |
Pointer for current model state as return by |
param_list_simulation_get_create creates suitable parameter list for
simulation_R for continuing a simulation from memory within the active
session.
param_list_simulation_get_create(statePtr)param_list_simulation_get_create(statePtr)
statePtr |
Pointer for current model state as return by |
param_list_simulation_init_create creates suitable parameter list for
simulation_R for the beginning of a simulation. Also takes an argument
for feeding in spatial parameters/data.
param_list_simulation_init_create( N = 10000, eqSS, barcode_list, spatial_list, housekeeping_list, drug_list, nmf_list, vector_adaptation_list, mpl )param_list_simulation_init_create( N = 10000, eqSS, barcode_list, spatial_list, housekeeping_list, drug_list, nmf_list, vector_adaptation_list, mpl )
N |
Population size. Default = 1e4 |
eqSS |
Output of |
barcode_list |
List of barcode/genetic parameters |
spatial_list |
Spatial parmeters to come in |
housekeeping_list |
Housekeeping parameter list
from |
drug_list |
Drug parameter list
from |
nmf_list |
Non malarial fever parameter list
from |
vector_adaptation_list |
vector adaptation list
from |
mpl |
model parameter list from |
param_list_simulation_saved_init_create creates
suitable parameter list for simulation_R for continuing a
simulation from memory within the active session.
param_list_simulation_saved_init_create(savedState)param_list_simulation_saved_init_create(savedState)
savedState |
Saved state generated by
|
param_list_simulation_update_create creates suitable parameter list for
simulation_R for continuing a simulation from memory within the active
session.
param_list_simulation_update_create( years = 1, ft = 0.4, mu_vec = NULL, fv_vec = NULL, statePtr, spatial_list, drug_list, barcode_list )param_list_simulation_update_create( years = 1, ft = 0.4, mu_vec = NULL, fv_vec = NULL, statePtr, spatial_list, drug_list, barcode_list )
years |
Length of simulation. Default = 1 |
ft |
Treatments seeking value |
mu_vec |
Vector of mosquito mortalities for each day with years. Default = NULL, which will result in rep(0.132,floor(years*365)) |
fv_vec |
Vector of mosquito bitings for each day with years. Default = NULL, which will result in rep(1/3,floor(years*365)) |
statePtr |
Pointer for current model state as return by |
spatial_list |
Spatial list |
drug_list |
Drug list |
barcode_list |
Barcode parameter list |
pipeline steps through creating the parameter list, the equilibrium
initialisation and steady state creation before checking and passing suitable
parameters to the simulation. This is then saved. If a path to a
savedState is provided then this state is loaded and continued.
pipeline( EIR = 120, ft = 0.4, itn_cov = 0, irs_cov = 0, use_historic_interventions = FALSE, survival_percentage = 0.2, oocyst_mean = 2.5, oocyst_shape = 1, N = 1e+05, years = 20, update_length = 365, country = NULL, admin = NULL, seasonality = NULL, spatial_type = NULL, spatial_incidence_matrix = NULL, spatial_mosquitoFOI_matrix = NULL, island_imports_plaf_linked_flag = FALSE, num_loci = 24, ibd_length = 1, plaf = rep(0.5, num_loci), prob_crossover = rep(0.5, num_loci), starting_ibd = 0, mutation_rate = rep(1e-07, num_loci), mutation_flag = FALSE, mutation_treated_modifier = 1, full_save = FALSE, full_update_save = FALSE, human_only_full_save = FALSE, update_save = FALSE, update_save_func = NULL, human_update_save = FALSE, genetics_df_without_summarising = FALSE, summary_saves_only = FALSE, set_up_only = FALSE, mean_only = TRUE, save_lineages = FALSE, saved_state_path = NULL, seed = as.integer(runif(1, 1, 1e+09)), sample_size = Inf, sample_states = 0:5, age_breaks = c(-0.001, 5, 15, 100.1), sample_reps = 1, housekeeping_list = housekeeping_list_create(), drug_list = drug_list_create(), vector_adaptation_list = vector_adaptation_list_create(num_loci), only_allele_freqs = TRUE, nmf_list = nmf_list_create(), ... )pipeline( EIR = 120, ft = 0.4, itn_cov = 0, irs_cov = 0, use_historic_interventions = FALSE, survival_percentage = 0.2, oocyst_mean = 2.5, oocyst_shape = 1, N = 1e+05, years = 20, update_length = 365, country = NULL, admin = NULL, seasonality = NULL, spatial_type = NULL, spatial_incidence_matrix = NULL, spatial_mosquitoFOI_matrix = NULL, island_imports_plaf_linked_flag = FALSE, num_loci = 24, ibd_length = 1, plaf = rep(0.5, num_loci), prob_crossover = rep(0.5, num_loci), starting_ibd = 0, mutation_rate = rep(1e-07, num_loci), mutation_flag = FALSE, mutation_treated_modifier = 1, full_save = FALSE, full_update_save = FALSE, human_only_full_save = FALSE, update_save = FALSE, update_save_func = NULL, human_update_save = FALSE, genetics_df_without_summarising = FALSE, summary_saves_only = FALSE, set_up_only = FALSE, mean_only = TRUE, save_lineages = FALSE, saved_state_path = NULL, seed = as.integer(runif(1, 1, 1e+09)), sample_size = Inf, sample_states = 0:5, age_breaks = c(-0.001, 5, 15, 100.1), sample_reps = 1, housekeeping_list = housekeeping_list_create(), drug_list = drug_list_create(), vector_adaptation_list = vector_adaptation_list_create(num_loci), only_allele_freqs = TRUE, nmf_list = nmf_list_create(), ... )
EIR |
Numeric for desired annual EIR. Default = 120 |
ft |
Vector of treatment frequency. Default = 0.4 |
itn_cov |
Vector for ITN coverages that change at update_length intervals. Default = 0 |
irs_cov |
Vector for IRS coverages that change at update_length intervals. Default = 0 |
use_historic_interventions |
Boolean as to whether to use interventions on file for the admin and country specified. If TRUE then provide the years as a year range, e.g. 2000:2015. WARNING - Best to have this as FALSE and manually specify the itn_cov, irs_cov and ft. |
survival_percentage |
Mumeric for Default = 0.2 |
oocyst_mean |
Mean for number of oocysts formed from a bite. Default=2.5 |
oocyst_shape |
Shape parameter for oocysts formed. Default=1 # Spatial |
N |
Population Size. Default = 100000 |
years |
Lenth of simulation. Default = 20 |
update_length |
How long each update is run for in days. Default = 365 |
country |
Character for country within which admin2 is in. Default = NULL |
admin |
Character for admin region. Some fuzzy logic will be used to match. If not provided then no seasonality is introduced. Default = NULL |
seasonality |
Optional named seasonal parameters (a0, a1, a2, a3, b1, b2,
b3, theta_c) used instead of the country and admin lookup, e.g. from
|
spatial_type |
Default = NULL. If spatial is wanted then provide a character describing the type of spatial simulation, which must be one of "island" or "metapop". |
spatial_incidence_matrix |
Spatial incidence for humans, i.e. importation vector |
spatial_mosquitoFOI_matrix |
Spatial mosquio FOI, i.e. importation to mosquitoes vector # Genetic Params |
island_imports_plaf_linked_flag |
Boolean. Whether imported barcodes for
island model are drawn dependent on other sites. Currently, if TRUE, imported
barcodes will either be all 0 or will be 1 at all loci where plaf > 0,
if |
num_loci |
Number of loci. Default = 24 |
ibd_length |
If we are simulating IBD dynamics, each loci is now represented by a bitset of ibd_length. Thus ibd_length needs to be long enough to ensure that as new identity relationships occur, i.e. an importation barcode will be a new identity. e.g. If are population is 1000, we may expect at 80 2400 different identities, i.e. 2^ibd_length > 2400. However, keep in mind importations as these need to be continually new, i.e. if we are simulating for 30 years, with 3 importations a day, then we will need at least length to ensure that 2^ibd_length > 2400 + (30*365*3). This will probably be automatically calculated in the future. If we are not ding IBD, then this should be 1, which is the defalt. |
plaf |
Vector of population level allele frequencies for the barcode. Default = rep(0.5, num_loci) |
prob_crossover |
Vector of probabilities for crossover events for the barcode. Default = rep(0.5, num_loci) |
starting_ibd |
Starting IBD. Default = 0, which means that each infected individual at initialisation is given a unique ID for their parasites. |
mutation_rate |
Probability of mutation occuring and fixing |
mutation_flag |
Boolean for simulating mutations # Saving Params |
mutation_treated_modifier |
Multiplier for how much more likely mutations are to occur in treated individuals with respect to resistance. Default = 1, i.e no difference |
full_save |
Boolean detailing whether the entire simulation is saved. Default = FALSE |
full_update_save |
Boolean to save entire simualation at each update save. Default = FALSE |
human_only_full_save |
Boolean detailing whether just the human component of the simulation is saved within full_save. Default = FALSE |
update_save |
Boolean detailing whether the logging output is saved each update_length up to years. Default = FALSE |
update_save_func |
As opposed to having to provide arguments for the
update behaviour, you can pass in a function. See |
human_update_save |
Boolean detailing if the human state is also saved during each update_length. Default = FALSE |
genetics_df_without_summarising |
Boolean for returning just the
genetics data frame without summarising with |
summary_saves_only |
Boolean if summary tables about COI are saved within human yearly save only. Dataframes of age, clinical status binned COI. |
set_up_only |
Boolean for whether to return just the initialised simulation. Default = FALSE |
mean_only |
Boolean for returning only the mean when summarising the population COI, COU etc. Default = TRUE |
save_lineages |
Boolean for whether we save the frequency of each strain
when summarising with |
saved_state_path |
Full file path to a saved model state to be loaded and continued. Default = NULL, which will trigger initialisation |
seed |
Random seed. Default is Random |
sample_size |
Numeric for number of individuals to be sampled at the end of each update. Default = Inf, which samples everyone. If you provide a vector of sample sizes it will sample at each specified sample size. |
sample_states |
Numeric for which sample infection states are to be included in sampling. Default = 0:5 (i.e. all states). 1:4 for example would ensure only infected individuals are included. |
age_breaks |
What age breaks are used when summarising the population. Default is 'c(-0.001, 5, 15, 100.1)' |
sample_reps |
Numeric for how many sample reps are done. Default = 1. # Parameter Lists |
housekeeping_list |
List created by |
drug_list |
List created by |
vector_adaptation_list |
List created by |
only_allele_freqs |
Boolean for returning the summarised genetics (allele
frequencies and maybe strain frequencies) or the whole data frame produced
by |
nmf_list |
List created by |
... |
Other parameters to model_param_list_create
|
# Main Params
Returns the population's parasite genetics summarised by coi for given sample size and state
population_get_genetics_df_n(param_list)population_get_genetics_df_n(param_list)
param_list |
param_list containing statePtr, sample_size, and sample_states |
list of population information
Returns the population's parasite genetics for ibd style summarised by pibd for given sample size and state
population_get_genetics_ibd_df_n(param_list)population_get_genetics_ibd_df_n(param_list)
param_list |
param_list containing statePtr, sample_size, and sample_states |
list of population information
severe_outcomes converts a rate of severe disease into rates of
hospitalised and community severe cases and deaths, following
severe_incidence_mortality in the postie package (1.1.0), so that
the numbers line up with malariasimulation outputs processed with postie.
severe_outcomes( severe, ft, treatment_scaler = 0.42, ft_sev = 0.8, hosp_sev_cfr = 0.065, community_sev_cfr = 0.6, baseline_treatment = 0.1, severe_scaler = 1/0.8 )severe_outcomes( severe, ft, treatment_scaler = 0.42, ft_sev = 0.8, hosp_sev_cfr = 0.065, community_sev_cfr = 0.6, baseline_treatment = 0.1, severe_scaler = 1/0.8 )
severe |
Numeric rate of severe disease from the model, e.g. the
|
ft |
Proportion of clinical cases treated in the simulation. |
treatment_scaler |
Reduction in severe disease from treating a clinical case. Default = 0.42 |
ft_sev |
Proportion of severe cases that are hospitalised. Default = 0.8 |
hosp_sev_cfr |
Case fatality ratio of hospitalised severe cases. Default = 0.065 |
community_sev_cfr |
Case fatality ratio of severe cases in the community. Default = 0.6 |
baseline_treatment |
Treatment coverage in the data the severe model was fitted to. Default = 0.1 (fixed in postie) |
severe_scaler |
Multiplier applied to the model severe rate. Default = 1/0.8 (fixed in postie) |
The model severe rate is first scaled by severe_scaler and then by
the effect of treatment, (ft * (1 - treatment_scaler) + (1 - ft)) /
(baseline_treatment * (1 - treatment_scaler) + (1 - baseline_treatment)).
A fraction ft_sev of severe cases are hospitalised, with case
fatality hosp_sev_cfr; the rest die with community_sev_cfr.
The case fatality ratios (6.5% in hospital from Reyburn et al., 60% in
the community from Lubell et al.) and the hospitalised share of 0.8 are
from Griffin et al. 2016 Lancet Infect Dis 16:465-72, supplement section
3.4.4. The treatment_scaler of 0.42 is a postie assumption based on
Mousa et al. 2020 PLoS Med, and the 10% baseline_treatment is
hard-coded in postie (the historical coverage in the Griffin et al. 2016
supplement).
A data frame with columns severe_model (the input),
severe, severe_hospital, severe_community,
mortality_hospital, mortality_community and
mortality.
# severe rate of 0.01 per person per year with 40% of cases treated severe_outcomes(0.01, ft = 0.4)# severe rate of 0.01 per person per year with 40% of cases treated severe_outcomes(0.01, ft = 0.4)
severe_rates turns the Loggers returned by a simulation into
annual rates per person of clinical and severe disease, for all ages and
for children aged 0 to 5 years.
severe_rates(loggers)severe_rates(loggers)
loggers |
The |
The severe output is the expected number of severe cases, i.e. the sum of
the probability that each new infection is severe (Griffin et al. 2015
Proc R Soc B 282:20142657), rather than a random draw. It is averaged over the logging
period in the same way as Incidence. The denominators are the
population at the end of the logging period.
A data frame with columns age_group ("all" and "0-5"),
clinical and severe, both per person per year.
Returns whole model to R in series of nested lists
Simulation_Finalizer_cpp(param_list)Simulation_Finalizer_cpp(param_list)
param_list |
parameter list generated with |
list of 1 confirming finalizer has finished
Returns whole model to R in series of nested lists
Simulation_Get_cpp(param_list)Simulation_Get_cpp(param_list)
param_list |
parameter list generated with |
list of 4 lists with the entire model state
Creates initial model simulation using paramter list provided
Simulation_Init_cpp(param_list)Simulation_Init_cpp(param_list)
param_list |
parameter list generated with |
list with ptr to model state and loggers describing the current model state
This function triggers the main magenta simulation from the R side
simulation_R(param_list, seed)simulation_R(param_list, seed)
param_list |
paramlist passed from
|
seed |
Seed for the simulation |
Creates initial model simulation using a saved model state
Simulation_Saved_Init_cpp(param_list)Simulation_Saved_Init_cpp(param_list)
param_list |
parameter list generated with |
list with ptr to model state and loggers describing the current model state
Continues simulation forward for as long as specified in param_list
Simulation_Update_cpp(param_list)Simulation_Update_cpp(param_list)
param_list |
parameter list generated with |
list with ptr to model state and loggers describing the current model state
Site files give tx_cov, the effective treatment coverage, and
malariasimulation treats that fraction of clinical cases with a fully
effective drug. magenta instead treats a fraction ft with the drugs in
drug_list, which can fail. site_ft() sets ft so that the
drugs' baseline (no resistance) efficacy gives the site's effective coverage:
ft = tx_cov / efficacy, capped at 1, where efficacy is the mean of the
drugs' wild type lpf weighted by partner_drug_ratios (as
pipeline uses for the deterministic model). Resistance then
lowers the effective coverage below the site's.
site_ft(tx_cov, drug_list = drug_list_create())site_ft(tx_cov, drug_list = drug_list_create())
tx_cov |
Numeric vector of effective treatment coverage |
drug_list |
Drug list, see |
The site file also splits tx_cov into ACT and non-ACT
(prop_act), but both are given at full efficacy in malariasimulation,
so the split does not change the cleared fraction. It is not used here: all
treatment is with drug_list.
Numeric vector of ft
Turns the rainfall Fourier coefficients of a malariasimulation site file
(site$seasonality$seasonality_parameters, one unit) into magenta's
seasonal parameters. magenta's seasonal curve is
max((a0 + sum(a_i cos + b_i sin)) / theta_c, 0.001), so
a0 = g0, a_i = g_i, b_i = h_i, and theta_c is the
yearly mean of the curve floored at 0.001, which is malariasimulation's
normalising constant.
site_seasonality(site)site_seasonality(site)
site |
Site file for one unit, e.g. from |
Named numeric vector (a0, a1, a2, a3, b1, b2, b3, theta_c) for the
seasonality argument of pipeline
Turns one unit of an Imperial malariasimulation site file (e.g. a foresite
calibrated, scaled site, reduced to one unit with site::subset_site())
into the arguments for pipeline, so magenta runs on the site's
calibrated EIR without its own fitting.
site_to_pipeline( site, years = NULL, burnin = 20, burnin_interventions = c("none", "first"), drug_list = drug_list_create(), irs_scale = 0.75, net_type = "pyrethroid_only", update_length = 365 )site_to_pipeline( site, years = NULL, burnin = 20, burnin_interventions = c("none", "first"), drug_list = drug_list_create(), irs_scale = 0.75, net_type = "pyrethroid_only", update_length = 365 )
site |
Site file for one unit, e.g. from |
years |
Calendar years to run after the burn-in. Default = all years with treatment coverage in the site file |
burnin |
Years of burn-in before |
burnin_interventions |
"none" (default) or "first", see Details |
drug_list |
Drug list used for |
irs_scale |
Multiplier on the site's IRS coverage. Default = 0.75 |
net_type |
Net type in |
update_length |
Days between updates in |
EIR: the site's pf EIR (adult EIR, as magenta's EIR).
Seasonality: site_seasonality.
Burn-in: burnin years before the first site year. With
burnin_interventions = "none" the burn-in has no treatment, ITNs or
IRS (so the starting equilibrium is at ft = 0); with "first" it
holds the first year's values.
Yearly interventions: itn_cov is the site's ITN use,
irs_cov the site's IRS coverage times irs_scale (0.75, the
adjustment malariasimulation runs apply), and ft from
site_ft with drug_list. Years missing from the site
are 0.
Nets: d_ITN0, r_ITN0 and r_ITN1 are
dn0, rn0 and rnm from site::net_efficacy
(net_type) at the unit's pyrethroid resistance, averaged over the
site years weighted by ITN use (magenta has one net efficacy for the whole
run). The ITN half-life is gamman * log(2) (malariasimulation's
decay is exp(-t / gamman)), and nets are aged with the "constant"
clock over a life of the site's retention half-life (see
itn_decay_clock in model_param_list_create). This is
the mean efficacy of nets in use when nets are topped up every year to
hold use steady, as the site's yearly distributions do. Without a
retention half-life the net life is 3 years.
Vectors: Q0, bites_Bed, bites_Indoors and
mu0 are the species means (weighted by prop) of Q0,
phi_bednets, phi_indoors and mum.
Demography is not set: magenta's population is exponential with a
mean age of 21 years in the individual model, whatever eta, so
the site's demography is not used.
Drugs, resistance, non-malarial fevers, barcodes and the other
pipeline arguments are left to the user: add them to the returned
list. Use the same drug_list here and in pipeline.
The aim is to put magenta in the right transmission setting for
scenario modelling of drug resistance, not to reproduce every intervention
in the site file. Only treatment, ITNs and IRS are used: SMC, PMC, vaccines
and larval source management in the site file are not modelled, and IRS uses
magenta's default efficacy whatever the insecticide.
Named list of arguments for pipeline, with attributes
year (calendar year of each simulated year, burn-in included) and
tx_cov (the site's treatment coverage in each simulated year, e.g.
for severe_outcomes)
## Not run: s <- readRDS("calibrated_scaled_site.rds") unit <- site::subset_site(s, data.frame(name_1 = "Busia", urban_rural = "urban")) args <- site_to_pipeline(unit) out <- do.call(pipeline, c(args, list(N = 10000))) ## End(Not run)## Not run: s <- readRDS("calibrated_scaled_site.rds") unit <- site::subset_site(s, data.frame(name_1 = "Busia", urban_rural = "urban")) args <- site_to_pipeline(unit) out <- do.call(pipeline, c(args, list(N = 10000))) ## End(Not run)
Grabs spatial incidence and mosquitoFOI matrix from database
spl_grab(country, admin, year_range)spl_grab(country, admin, year_range)
country |
Country string |
admin |
Admin string |
year_range |
Year range |
This function adjusts the barcode vectors stored in a saved simulation state so that the population level allele frequency (PLAF) matches a user supplied target. The adjustment is applied to each of the supported barcode containers individually (human strain barcodes, infection realisations, and male and female mosquito oocyst barcodes) as well as to the combined set of barcodes across all containers.
update_saved_state_barcode_plaf(saved_state, target_plaf, seed = NULL)update_saved_state_barcode_plaf(saved_state, target_plaf, seed = NULL)
saved_state |
A list representing the saved simulation state returned by [saveRDS()] on the final element of a 'run_sim()' output. |
target_plaf |
Numeric vector giving the desired PLAF for each locus. |
seed |
Optional integer to set the random number generator state before modifying barcodes. This is useful to obtain reproducible adjustments. |
The input 'saved_state' with barcode vectors modified in place so that their PLAF equals 'target_plaf' (within numerical tolerance).
List for vector adaptations relating to oocyst success
vector_adaptation_list_create( vector_adaptation_loci, vector_adaptation_flag = FALSE, local_oocyst_advantage = 0.5, gametocyte_sterilisation_flag = FALSE, gametocyte_sterilisation = 0.5, oocyst_reduction_by_artemisinin = 0.2 )vector_adaptation_list_create( vector_adaptation_loci, vector_adaptation_flag = FALSE, local_oocyst_advantage = 0.5, gametocyte_sterilisation_flag = FALSE, gametocyte_sterilisation = 0.5, oocyst_reduction_by_artemisinin = 0.2 )
vector_adaptation_loci |
Vector of integers detailing which loci in the barcode correspond to the vector adaptation phenotype |
vector_adaptation_flag |
Boolean are we doing vector adaptation. |
local_oocyst_advantage |
Numeric for probability that non adapated parasites will get through. Default = 0.5 |
gametocyte_sterilisation_flag |
Boolean for whether we are doing gametocye sterilisation as a result from artemisinin. Default = FALSE |
gametocyte_sterilisation |
Numeric for theimpact of artemisinin on male gametocytes. Default = 0.5, which causes the probability that a wild type male gametocyte will be chosen to be in oocysts is halved. |
oocyst_reduction_by_artemisinin |
Numeric for reduction in oocyst under artemisinin drug pressure. default = 0.2 |