Package 'magenta'

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]
Maintainer: Oliver Watson <[email protected]>
License: MIT + file LICENSE
Version: 1.3.5
Built: 2024-06-18 05:35:27 UTC
Source: https://github.com/OJWatson/magenta

Help Index


Admin level 1 africa seasonal parameters

Description

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

Usage

admin_units_seasonal

Format

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 human barcodes to numerics

Description

convert_barcode_vectors converts human barcode vectors to nums and calculated COIs.

Usage

convert_barcode_vectors(
  sim_save,
  ID,
  sub_patents_included = TRUE,
  ibd = FALSE,
  nl = 24,
  COI_type = "pcr_imperial"
)

Arguments

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"

convert_barcode_vectors


Create list describing parameters for drug efficacy and prophlyaxis

Description

Create list describing parameters for drug efficacy and prophlyaxis

Usage

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)
)

Arguments

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:

c(1.0, 0.97, 0.80, 0.55)

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:

c(0,1)

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 c(1), which shows that for the drug, the prophylactic position is encoded in barcode position 1.

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 drug_clearance_max_time and the first element is the probability at time = 0 days.

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 drug_clearance_max_time and the first element is the probability at time = 0 days.


AL Drug Create

Description

AL Drug Create

Usage

drug_create_al()

Note

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

Description

ASAQ Drug Create

Usage

drug_create_asaq()

Note

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

Description

Perfect Drug Create

Usage

drug_create_default_no_resistance()

Note

Perfect Efficacy Drug. Used as default to match deterministic model easily


DHA-PPQ Drug Create

Description

DHA-PPQ Drug Create

Usage

drug_create_dhappq()

Create drug list

Description

List for simulating drug usage for resistance/mft variables

Usage

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)
)

Arguments

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 drug_create.

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


Drug Efficacy by Genotype Table

Description

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

Usage

drug_table

Format

A data.frame of drug efficacies by genotype


Equilibrium initialisation list creation

Description

equilibrium_init_create creates an equilibrium initialisation state to be used within later model runs

Usage

equilibrium_init_create(
  age_vector,
  het_brackets,
  ft,
  EIR,
  model_param_list,
  country = NULL,
  admin = NULL,
  quiet = FALSE
)

Arguments

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.


Create housekeeping parameter list

Description

List for simulation housekeeping vars, e.g. quiet prints,

Usage

housekeeping_list_create(
  quiet = TRUE,
  quiet_test = TRUE,
  cluster = FALSE,
  clear_up = TRUE
)

Arguments

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

Description

Importation data for admin units in admin_units_seasonal

Usage

importations

Format

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

Description

Intervention grab

Usage

intervention_grab(
  country,
  admin,
  year_range,
  final_itn_cov = NULL,
  final_irs_cov = NULL,
  final_ft = NULL
)

Arguments

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

Details

Grabs ITN, IRS ft from database

N.B. The admin region used for ft can be checked


IRS for 2000 to 2015

Description

IRS data for SSSA for 2000 to 2015

Usage

irs_2000_2015

Format

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 for 2000 to 2015

Description

ITN data for SSSA for 2000 to 2015

Usage

itn_2000_2015

Format

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 Parameter List Creation

Description

model_param_list_create creates list of model parameters to be used within equilibrium_init_create

Usage

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,
  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
)

Arguments

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

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

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 IRS decay = 1. Default = 3 * DY


Create nmf list

Description

List for simulating non malarial fever

Usage

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
)

Arguments

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.


Parameter List creation for magenta simulation finalizer

Description

param_list_simulation_finalizer_create creates suitable parameter list for simulation_R for free memory used by a simulation

Usage

param_list_simulation_finalizer_create(statePtr)

Arguments

statePtr

Pointer for current model state as return by simulation_R$Ptr


Parameter List creation for magenta simulation getting (saving to disk)

Description

param_list_simulation_get_create creates suitable parameter list for simulation_R for continuing a simulation from memory within the active session.

Usage

param_list_simulation_get_create(statePtr)

Arguments

statePtr

Pointer for current model state as return by simulation_R$Ptr


Parameter List creation for magenta simulation initialisation

Description

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.

Usage

param_list_simulation_init_create(
  N = 10000,
  eqSS,
  barcode_list,
  spatial_list,
  housekeeping_list,
  drug_list,
  nmf_list,
  vector_adaptation_list,
  mpl
)

Arguments

N

Population size. Default = 1e4

eqSS

Output of equilibrium_steady_state_create

barcode_list

List of barcode/genetic parameters

spatial_list

Spatial parmeters to come in

housekeeping_list

Housekeeping parameter list from housekeeping_list_create

drug_list

Drug parameter list from drug_list_create

nmf_list

Non malarial fever parameter list from nmf_list_create

vector_adaptation_list

vector adaptation list from vector_adaptation_list

mpl

model parameter list from model_param_list_create


Parameter List creation for loading saved magenta simulation

Description

param_list_simulation_saved_init_create creates suitable parameter list for simulation_R for continuing a simulation from memory within the active session.

Usage

param_list_simulation_saved_init_create(savedState)

Arguments

savedState

Saved state generated by simulation_R when provided with a param_list_simulation_get_create parameter list


Parameter List creation for magenta simulation updating

Description

param_list_simulation_update_create creates suitable parameter list for simulation_R for continuing a simulation from memory within the active session.

Usage

param_list_simulation_update_create(
  years = 1,
  ft = 0.4,
  mu_vec = NULL,
  fv_vec = NULL,
  statePtr,
  spatial_list,
  drug_list,
  barcode_list
)

Arguments

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 simulation_R$Ptr

spatial_list

Spatial list

drug_list

Drug list

barcode_list

Barcode parameter list


Pipeline for cluster submission

Description

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.

Usage

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,
  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(),
  ...
)

Arguments

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

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 rbinom(1, 1, plaf[plaf>0][1]) is TRUE. I.e. the first loci greater than 0 is used to determine if the incoming barcode is 1 at all sites where plaf is greater than 0.

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 update_saves for the default one.

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 COI_df_create. Default = FALSE

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 genetics_df_without_summarising=TRUE. Default = FALSE

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 housekeeping_list_create

drug_list

List created by drug_list_create

vector_adaptation_list

List created by vector_adaptation_list_create

only_allele_freqs

Boolean for returning the summarised genetics (allele frequencies and maybe strain frequencies) or the whole data frame produced by pop_strains_df. Default = TRUE

nmf_list

List created by nmf_list_create

...

Other parameters to model_param_list_create

pipeline

Details

# Main Params


Returns the population's parasite genetics summarised by coi for given sample size and state

Description

Returns the population's parasite genetics summarised by coi for given sample size and state

Usage

population_get_genetics_df_n(param_list)

Arguments

param_list

param_list containing statePtr, sample_size, and sample_states

Value

list of population information


Returns the population's parasite genetics for ibd style summarised by pibd for given sample size and state

Description

Returns the population's parasite genetics for ibd style summarised by pibd for given sample size and state

Usage

population_get_genetics_ibd_df_n(param_list)

Arguments

param_list

param_list containing statePtr, sample_size, and sample_states

Value

list of population information


Returns whole model to R in series of nested lists

Description

Returns whole model to R in series of nested lists

Usage

Simulation_Finalizer_cpp(param_list)

Arguments

param_list

parameter list generated with param_list_simulation_finalizer_create

Value

list of 1 confirming finalizer has finished


Returns whole model to R in series of nested lists

Description

Returns whole model to R in series of nested lists

Usage

Simulation_Get_cpp(param_list)

Arguments

param_list

parameter list generated with Param_List_Simulation_Get_Create

Value

list of 4 lists with the entire model state


Creates initial model simulation using paramter list provided

Description

Creates initial model simulation using paramter list provided

Usage

Simulation_Init_cpp(param_list)

Arguments

param_list

parameter list generated with Param_List_Simulation_Init_Create

Value

list with ptr to model state and loggers describing the current model state


simulation_R function

Description

This function triggers the main magenta simulation from the R side

Usage

simulation_R(param_list, seed)

Arguments

param_list

paramlist passed from param_list_simulation_init_create or from param_list_simulation_update_create

seed

Seed for the simulation


Creates initial model simulation using a saved model state

Description

Creates initial model simulation using a saved model state

Usage

Simulation_Saved_Init_cpp(param_list)

Arguments

param_list

parameter list generated with Param_List_Simulation_Get_Create

Value

list with ptr to model state and loggers describing the current model state


Continues simulation forward for as long as specified in param_list

Description

Continues simulation forward for as long as specified in param_list

Usage

Simulation_Update_cpp(param_list)

Arguments

param_list

parameter list generated with Param_List_Simulation_Update_Create

Value

list with ptr to model state and loggers describing the current model state


Spatial matrix grab

Description

Grabs spatial incidence and mosquitoFOI matrix from database

Usage

spl_grab(country, admin, year_range)

Arguments

country

Country string

admin

Admin string

year_range

Year range


Create vector adaptation list

Description

List for vector adaptations relating to oocyst success

Usage

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
)

Arguments

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