growTree(b = 1, d = 0, halt = 20, grain = 0.1, linObj = NULL, ct.start = NULL, ct.change = NULL, ct.var = NULL, dt.rates = NULL, inheritance = NULL, trace.events = FALSE, trace.cladesize = FALSE, output.lineages = FALSE, neg.rates = "abort", inf.rates = "abort", stall.time = 10, extend.proportion=0)
## S3 method for class 'growTree':
as.comparative.data(x, ...)linToApe willneg.rates. With 'warn' or 'quiet', infinite rates are left in place, resulting in events happening instantly. This may, in some cases, be desirable!grain is infinite, then the simulation stalls immediately when all rates are zero.output.phylo, either an object of class 'phylo' or an object of class 'growTree' with the following structure:parent.id and id of the row along with the total age of the lineage (lin.age) and the times at which the lineage was born (birth.time). If the species went extinct (or speciated) then the death.time is recorded and extinct is set to TRUE. Speciating lineages have tip set to FALSE. Each row also records the caic.code of the lineage - this is used as a sorting code for conversion to a 'phylo' object and is a kludge. If traits are defined in the simulation then the values or states are recorded in this table. These are the current values for extant tips and the values at extinction for extinct tips and internal nodes.clade.age, the total age of the simulation; nLin, the total number of lineages; nTip, the total number of tips, differentated into nExtantTip and nExtinctTip.b), death (d) and stopping (halt) rules and any inheritance rules.ct.start, ct.change and ct.var details provided.dt.rates details provided.b, d and halt) which act as rules defining speciation and extinction and the ending of the simulation. These can be simple constants, but can also make use of the properties of the environment of the evolving tree. This includes both lineage specific properties (as described in the lineages section of the returned value) or properties of the clade as a whole (as described in the clade section of the returned value). For example, a extinction rate might increase with lineage age (d=0.01*lin.age) or a speciation rate might decrease according to a density dependent process (b=1 - (nExtantTip/500)). Halt expressions will typically use clade properties (halt=clade.age >= 5 or nTips >= 50) but could use lineage properties, for example stopping when a trait value hits a certain value (halt=any(ct1 >= 10)). It is not permitted to use '==' in a halt function of clade.age because it will allow the simulation to run away if the actual value steps over the test value.Discrete traits are defined using a matrices of rates for transitions between states for each trait. At present, these are fixed for the duration of a simulation epoch and cannot be set as expressions of tree variables.
Continuous trait evolution currently employs a simple Brownian model, given a starting value and variance per unit time. The traits can have defined co-variance (the simulation uses mvrnorm at present) and can also have a defined mean change, allowing for a directional walk in the trait values. At present, it is not possible for the trait variance to vary according to the internal state of the tree; continuous characters retain the same variance and covariance for the whole of the simulation epoch.
Whilst none of the halt rules are TRUE, then the function evaluates the birth, death and discrete trait rates and converts these to waiting times using random variates from a exponential distribution with the calculated rates. These competing waiting times are compared both to each other and the grain of the simulation, the shortest waiting time is found and the relevant event is then triggered. The winning event is identified in the character vector winnerName in order to allow inheritance rules to differentiate events.
## see the package vignette for a much fuller discussion of examples.
# A basic 200 tip tree, output as a 'comparative.data' object
tree <- growTree(halt=200, grain=Inf)
plot(tree$phy)
# A basic tree of age 4 time units, output as a 'comparative.data' object
tree <- growTree(halt=expression(clade.age >= 4), grain=Inf)
plot(tree$phy)Run the code above in your browser using DataLab