View source: R/treeSimulatorCpp2.R
sim.co.tree | R Documentation |
A tree is simulated based on a demographic process and user-supplied parameters and initial conditions. The times and types of samples must also be supplied.
sim.co.tree(
theta,
demographic.process.model,
x0,
t0,
sampleTimes,
sampleStates = NULL,
res = 1000,
integrationMethod = "lsoda",
finiteSizeCorrections = TRUE,
substitutionRates = NULL,
sequenceLength = 0
)
theta |
A named vector of parameter values required by the model |
demographic.process.model |
An object of class demographic.process.
See |
x0 |
A named vector of initial conditions required by the model. This includes demes and any other dynamic variables. |
t0 |
The time of origin of the process |
sampleTimes |
A numeric vector providing the times of samples. If named, taxon labels will be based on names of the corresponding sample times |
sampleStates |
For models with more than one deme, a matrix must be supplied describing the probability of sampling from each deme. Each row corresponds to a sample in the same order as sampleTimes. Each column corresponds to probability of sampling each deme. Column names should be defined which correspond to deme names in the model. Rows should sum to one. |
res |
Integer number of time steps to use when simulating model. |
integrationMethod |
If simulating an ODE (ordinary differential equation) model, this provides the integration routine corresponding to options in deSolve. |
finiteSizeCorrections |
to do |
substitutionRates |
to do |
sequenceLength |
to do |
An object of class DatedTree, which subclasses ape::phylo. The $heights attribute provides the time of each node in the tree. The $maxHeight attribute provides the time of the root.
Erik Volz
# A simple exponential growth model with birth rates beta, and death rates gamma:
# I is the number of infected individuals
dm <- build.demographic.process(births = c(I = 'parms$beta * I'),
deaths = c(I = 'parms$gamma * I'),
parameterNames = c('beta', 'gamma'),
rcpp = FALSE,
sde = FALSE)
# simulate a tree based on the model:
tre <- sim.co.tree(list(beta = 1.5, gamma = 1),
dm,
x0 = c(I = 1),
t0 = 0,
sampleTimes = seq(10, 15, length.out = 50),
res = 1000)
# plot the tree
plot(tre)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.