typhoid
Typhoid model.
Classes
| Name | Description |
|---|---|
| Typhoid | Typhoid module that includes the natural history of the disease in a human |
Typhoid
typhoid.Typhoid(pars=None, *args, **kwargs)Typhoid module that includes the natural history of the disease in a human agent.
Methods
| Name | Description |
|---|---|
| chronic_gall_prob_function | Assumes gallstone probabilities and prevalence are defined. |
| chronic_prob_function | Does not use gallstone probabilities and prevalence. |
| drc | The probability of infection due to environmental exposure is mediated by |
| get_acute_duration_by_age | Duration of the acute stage |
| get_chronic_duration | Determine duration of chronic stage |
| get_prepatent_duration_by_exposure | Get durations in number of timesteps |
| get_subclinical_duration_by_age | Determine duration of the sublinical stage |
| get_tai_vals | Value of typhoid individual infectiousness |
| get_wait_duration | Determine how many days a person in the acute stage would wait before |
| inf_dur_mean | _ |
| inf_dur_std | Age-dependent standard deviation of the distribution of durations of the |
| infection_prob_function_env | Calculate the probability of infection for environmental route |
| init_post | Set initial values for all agent states, and seed new cases if initial |
| init_pre | Initialise objects and valid before simulation run |
| init_results | Initialise Result objects |
| make_new_cases_contact | Add new cases of module, through transmission, incidence, etc. |
| make_new_cases_environmental | At each time step: |
| make_new_cases_sequential | This function exists to allow for testing different mechanisms |
| make_susceptible | Our model assumes all individuals are born into an unexposed, completely |
| prepare_partial_prep_funs | Partially evaluate functions that return parameters (mean and std) of |
| prepatent_mean_dur_function | Returns a mean duration parameter for every agent based on the cfu_dose, |
| prepatent_std_dur_function | Returns a stdev duration parameter for every agent based on the cfu_dose, |
| prior_infections_by_age | TODO: [WIP] placeholder - the functional form is just a toy example |
| set_prognoses | Here we define the whole natural history for every agent that has been infected. |
| step | Handle transmission of pathogens and who becomes infected, |
| step_die | Reset states for dead agents |
| step_state | Update the progression of the disease – handles disease state transitions. |
| tai_mean | Make an array of values for the mean of a normal distribution. |
| tai_std | Make an array of values for the std of a normal distribution |
| unexp2sus_prob_gauld2018 | Estimate the age-dependent probability of transistioning from |
| unexp2susc_prob_function | Simple (default) mechanism that defines the probability of |
| update_susceptibility | Susceptibility due to acquired immunity following infection. |
| validate_beta | Perform any parameter validation |
| validate_environment | Validate environment |
| will_become_chronic_carrier | Determine who will become a chronic carrier |
chronic_gall_prob_function
typhoid.Typhoid.chronic_gall_prob_function(module, sim, uids)Assumes gallstone probabilities and prevalence are defined. This scales p_cpg using prob of having gallstones and gallstone prevalence.
chronic_prob_function
typhoid.Typhoid.chronic_prob_function(module, sim, uids)Does not use gallstone probabilities and prevalence. Uses directly p_cpg as p_chro.
This method can be useful when either we do not have age and sex gallstone prob and prevalence distributions, or we want to simplify calibration by reducing degrees of freedom.
drc
typhoid.Typhoid.drc(cfu_dose)The probability of infection due to environmental exposure is mediated by the dose-response curve (drc), taking in the contagion population as a value of colony-forming units (CFU) and returning a probability of infection.
Here cfu_dose is the CFU dose received from the environment.
The DRC is a beta-binomial curve fitted the historical challenge data by QMRA (Enger, 2013), where:
P(response) = 1- [1 + cfu_dose * (2^(1/ α)- 1)/N50] ^(-α) and self.drc() could be a method to be defined by the user.
get_acute_duration_by_age
typhoid.Typhoid.get_acute_duration_by_age(uids)Duration of the acute stage
get_chronic_duration
typhoid.Typhoid.get_chronic_duration(uids)Determine duration of chronic stage See: https://github.com/starsimhub/typhoidsim/issues/66
get_prepatent_duration_by_exposure
typhoid.Typhoid.get_prepatent_duration_by_exposure(uids)Get durations in number of timesteps
get_subclinical_duration_by_age
typhoid.Typhoid.get_subclinical_duration_by_age(uids)Determine duration of the sublinical stage
get_tai_vals
typhoid.Typhoid.get_tai_vals(uids)Value of typhoid individual infectiousness
get_wait_duration
typhoid.Typhoid.get_wait_duration(uids)Determine how many days a person in the acute stage would wait before seeking treatment
inf_dur_mean
typhoid.Typhoid.inf_dur_mean(module, sim, uids)_ Age-dependent mean of the distribution of durations of the acute or subclinical stage. Assumes a lognormal_im distribution.
inf_dur_std
typhoid.Typhoid.inf_dur_std(module, sim, uids)Age-dependent standard deviation of the distribution of durations of the acute or subclinical stage. Assumes a lognormal_im distribution.
infection_prob_function_env
typhoid.Typhoid.infection_prob_function_env(module, sim, uids)Calculate the probability of infection for environmental route In EMOD (https://github.com/jgauld/DtkTrunk/blob/Typhoid-Ongoing/Eradication/IndividualTyphoid.cpp): NonNegativeFloat infects = 1.0f-pow( 1.0f + exposure * ( pow( 2.0f, (1/alpha) ) -1.0f )/N50, -alpha ); // Dose-response for prob of infection prob = 1.0f - pow(1.0f - immunity * infects * ira, number_of_exposures);
init_post
typhoid.Typhoid.init_post()Set initial values for all agent states, and seed new cases if initial prevalence is provided.
This function could involve passing in a full set of initial conditions, or using init_prev (initial prevalence), or other.
init_pre
typhoid.Typhoid.init_pre(sim)Initialise objects and valid before simulation run
init_results
typhoid.Typhoid.init_results()Initialise Result objects
make_new_cases_contact
typhoid.Typhoid.make_new_cases_contact()Add new cases of module, through transmission, incidence, etc. Common-random-number-safe transmission code works by mapping edges onto slots.
The direct or contact transmission route. The probability of infection is calculated for each infector-infectee pair (not summed across all possible exposures an infectee experiences).
See diagram for Model A in https://github.com/starsimhub/typhoidsim/issues/90
Implicitly, at each time step, the number of “exposures” for a src-trg pair is equal to 1.
In starsim we use beta_per_dt, the per time step probability that a contact between two susceptible people results in transmission.
However, historically in EMOD-world this per-time-step probability is called exposure2contact_rate. For time being, and to faciliate mapping between past EMOD-based simulations, and starsim-based sims, we enforce beta_per_dt=1, and keep exposure2contct_rate. Eventually, we can move onto just using beta_per_dt.
make_new_cases_environmental
typhoid.Typhoid.make_new_cases_environmental()At each time step: 1. Individuals get exposed by the environment (env->ppl) - They receive a cfu dose, which depends on: - the cfu concentration in the environment, and - the exposures amouint to the environment.
New individuals may become infected, based on the cfu dose received and their past history with the disease. This is mediated by the Dose Response Curve. See self.drc(),
Individuals shed bacteria/CFU to the environment. How many CFUs are shedded depends on two main factors: - shedding rate, a single factor that depends on the environment as it represents level of sanitation and/or collective change in behaviour. - each agent’s infectiousness, which can be modulated by treatment interventions.
make_new_cases_sequential
typhoid.Typhoid.make_new_cases_sequential()This function exists to allow for testing different mechanisms that handle multiroute transmission.
make_susceptible
typhoid.Typhoid.make_susceptible()Our model assumes all individuals are born into an unexposed, completely immune state and move to the susceptible class based on some probability.
The mechanism that moves individuals from one state to the other, can depend on age and/or other factors.
By default, we do not assume any age-specific structure. Thus, agents are born into the unexposed state and are moved immediately to the susceptible state.
However, there are a couple of predefined age-specific susceptibility probability functions implemented: - unexp2sus_youth_prob_function_gauld2018() - unexp2sus_childhood_prob_function_gauld2018()
These functions can be passed as arguments to the Typhoid parameter. For instance:
p_unexp2sus=ss.bernoulli(p=unexp2sus_prob_gauld2018), or p_unexp2sus=ss.bernoulli(p=unexp2sus_childhood_prob_function_gauld2018),
See Also: https://github.com/jgauld/DtkTrunk/blob/Typhoid-Ongoing/Eradication/SusceptibilityTyphoid.cpp
prepare_partial_prep_funs
typhoid.Typhoid.prepare_partial_prep_funs()Partially evaluate functions that return parameters (mean and std) of the distribution of prepatatent durations.
prepatent_mean_dur_function
typhoid.Typhoid.prepatent_mean_dur_function(module, sim, uids)Returns a mean duration parameter for every agent based on the cfu_dose, they have been exposed to. Assumes the parameter will be used by a lognormal_im distribution.
prepatent_std_dur_function
typhoid.Typhoid.prepatent_std_dur_function(module, sim, uids)Returns a stdev duration parameter for every agent based on the cfu_dose, they have been exposed to. Assumes the parameter will be used by a lognormal_im distribution.
prior_infections_by_age
typhoid.Typhoid.prior_infections_by_age(module, sim, uids)TODO: [WIP] placeholder - the functional form is just a toy example Function to modulate probability of prior n_infections by age at t=0, but would need to discuss functional form/how to parameterize before use.
set_prognoses
typhoid.Typhoid.set_prognoses(uids, sources=None)Here we define the whole natural history for every agent that has been infected. Specifically, we define how long each agent will stay in each stage of the disease, thus define when agents transition from one stage (state) to the next. This function also uses the probability distributions passes as parameters of the model to determine whol will become acute/sublinical/chronic, etc.
The progression of this natural history can be altered by the environment, interventions, or other diseases.
step
typhoid.Typhoid.step()Handle transmission of pathogens and who becomes infected, includes all transmission routes. This method is called by the Sim object.
step_die
typhoid.Typhoid.step_die(uids)Reset states for dead agents
step_state
typhoid.Typhoid.step_state()Update the progression of the disease – handles disease state transitions. In a typical simulation flow this method is called before propagating the infection/disease is propagated via make_new_cases()
tai_mean
typhoid.Typhoid.tai_mean(module, sim, uids)Make an array of values for the mean of a normal distribution. Any function with the same signature can be passed as the values to the parameters of a distribution.
tai_std
typhoid.Typhoid.tai_std(module, sim, uids)Make an array of values for the std of a normal distribution Any function with the same signature can be passed as the values to the parameters of a distribution.
unexp2sus_prob_gauld2018
typhoid.Typhoid.unexp2sus_prob_gauld2018(module, sim, uids)Estimate the age-dependent probability of transistioning from unexposed to susceptible. From Gauld et al 2018, Fig. 2B.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| module | a starsim (disease) Module | required | |
| sim | the starsim Sim object (fully initialized) | required | |
| uids | the uids of the eligible people | required |
Returns
| Name | Type | Description |
|---|---|---|
| p_sus | array | array of probabilities for every agent in uids. |
EMOD: if( ( age < twenty_years_old_days ) && mod_acquire == 0 ) { float lambda = IndividualHumanTyphoidConfig::typhoid_exposure_lambda;
perc2 = 1.0f - ((twenty_years_old_days - age) / (age*lambda + twenty_years_old_days ));
perc1 = 1.0f - ((twenty_years_old_days - (age-1)) / ((age-1)*lambda + twenty_years_old_days ));
perc = (perc2 - perc1) / (1 - perc1); <--- probability
}
From Gauld 2018: Specifically, at each month of age a fitted curve determines the probability of an individual entering the susceptible class.
But the EMOD code does not seem to assess at every month of age, rather at every time step of 1 day.
unexp2susc_prob_function
typhoid.Typhoid.unexp2susc_prob_function(module, sim, uids)Simple (default) mechanism that defines the probability of moving from the unexposed stat to the susceptible state. This mechanism moves everyone to the susceotible state.
update_susceptibility
typhoid.Typhoid.update_susceptibility(uids)Susceptibility due to acquired immunity following infection. The more infections, the lower the number.
validate_beta
typhoid.Typhoid.validate_beta()Perform any parameter validation
validate_environment
typhoid.Typhoid.validate_environment()Validate environment
will_become_chronic_carrier
typhoid.Typhoid.will_become_chronic_carrier(uids)Determine who will become a chronic carrier
Functions
| Name | Description |
|---|---|
| unexp2sus_childhood_prob_function_gauld2018 | Estimate the age-dependent probability of transitioning from |
unexp2sus_childhood_prob_function_gauld2018
typhoid.unexp2sus_childhood_prob_function_gauld2018(module, sim, uids)Estimate the age-dependent probability of transitioning from unexposed to susceptible. From Gauld et al 2018, Fig. 2B.
Age-specific immunity. Individuals that are created through births in the model start out in a fully immune state. For the Santiago-site simulation, there are three ages that individuals can move from immune (unexposed) to susceptible:
- 6 months (no children under 6 months of age can be infected).
- Need to define the distribution parameter p_unexp2sus_6m=ss.bernoulli(p=0.14)
- 3 years
- Need to define the distribution parameter p_unexp2sus_3y=ss.bernoulli(p=0.29),
- 6 years
- Need to define the distribution parameter p_unexp2sus_6y=ss.bernoulli(p=0.61)
At each of these ages, a proportion of the remaining unexposed population will be moved to the susceptible population determined by the calibrated values below
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| module | a starsim (disease) Module | required | |
| sim | the starsim Sim object (fully initialized) | required | |
| uids | the uids of the eligible people | required |
Returns
| Name | Type | Description |
|---|---|---|
| p_sus | array | array of probabilities for every agent in uids. |