-
Notifications
You must be signed in to change notification settings - Fork 2
Home
treeswithintrees (twt) is an R package for the coalescent (reverse time) simulation of host (transmission) trees and pathogen trees within host trees. It is designed to be flexible so that it can accommodate a range of models at different levels of diversity, such as:
- compartmental epidemic models, e.g., susceptible-infected-recovered (SIR) models
- cospeciation/cophylogeny models
- models of compartmentalized within-host evolution, e.g., migration between the blood and genital tract
twt attempts to accommodate these models with a common set of basic components: compartments and lineages. A lineage is a sequence of individual pathogens descending from an ancestor in the past. A compartment represents an individual environment in which lineages are contained. Compartments are grouped into Compartment Types to make it more convenient to specify models and for more efficient simulation. We assume that the compartments are related through by a transmission or host tree, whose shape is determined by the transmission rates among hosts. Lineages may also migrate between compartments that are both hosts to other lineages.
Like many other simulation programs, twt uses a conventional Gillespie method to sample a sequence of discrete stochastic events over reverse time. If a host tree is not specified by the user, then the host/transmission tree is simulated while simulating the coalescence of the pathogen lineages within the hosts. Otherwise, the timing and direction of transmission events are parsed from the user tree and set as fixed events in the simulation.