sim.bdtree | R Documentation |
simulating phylogenetic trees under a uniform birth-death process
sim.bdtree(b=1, d=0, stop=c("taxa", "time"), n=100, t=4, seed=0, extinct=TRUE)
b |
per-lineage birth (speciation) rate |
d |
per-lineage death (extinction) rate |
stop |
stopping criterion |
n |
maximum number of taxa in simulation |
t |
maximum time steps of simulation |
seed |
random number seed (default is to seed based on the clock) |
extinct |
whether to return trees where all lineages have gone extinct (see Details) |
Starting from a root node - i.e., two living lineages - this function simulates the growth of a
phylogenetic tree under a uniform, time-homogeneous birth-death process. This means that every
lineage has a constant probability of speciating, and a constant probability of going extinct, per
unit time. If birth is greater than death, then the number of lineages is expected to grow exponentially.
If extinct=FALSE
, the function will build trees until one is simulated with at least one surviving lineage.
A phylogenetic tree in 'phylo' format is returned. If death rate is non-zero, then the returned tree will likely
include some extinct lineages (terminating before the present day). See drop.extinct
for
a function to remove these lineages.
One note of caution: it is easy to set parameter values that result in tremendously huge trees. If the function seems to hang up, this could be the problem.
Other tree simulators are available from the packages ape (rbdtree
), TreeSim (sim.bd.taxa
, sim.bd.age
, and sim.bd.taxa.age
), and phytools (pbtree
).
LJ Harmon and J Weir
sim.bd
for non-phylogenetic simulations; drop.extinct
# Pure-birth tree
p1 <- sim.bdtree(b=0.1, d=0, stop="time", t=20)
plot(p1)
# Birth-death tree with extinct taxa
# The extinct flag prevents trees with no survivors
p2 <- sim.bdtree(b=0.2, d=0.05, stop="time", t=20, extinct=FALSE)
plot(p2)
# Previous tree with extinct taxa removed
p3 <- drop.extinct(p2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.