Simulate phylogenies under pure birth/death or as a function of trait evolution
sim.bd.phy(speciate = 0.1, extinction = 0.025, time.steps = 20)sim.bd.tr.phy(
speciate = 0.1,
extinction = 0.025,
time.steps = 20,
tr.range = c(0, 1),
sp.tr = 2,
ext.tr = 1,
tr.walk = 0.2,
tr.wrap = TRUE
)
edge2phylo(edge, s, e = numeric(0), el = NA, t = NULL)
phylo
object with random
tip.labels, and trait values if using sim.br.tr.tree
.
probability each species will speciate in each time-step (0-1)
probability each species will go extinct in each time-step (0-1)
number of time-steps for simulation
vector of length two specifying boundaries for
trait values (see notes); initial two species will be at the 25th
and 75th percentiles of this space. See also tr.wrap
speciation rate's interaction with the minimum distance between a species and the species most similar to it (see details)
extinction rate's interaction with the minimum distance between a species and the species most similar to it (see details)
at each time-step a species not undergoing speciation or extinction has its trait value drawn from a distribution centered at its current value and with a standard deviation set by this value. I.e., this is the rate of the Brownian motion trait evolution.
whether to force species' trait values to stay
within the boundary defined by tr.range
; default TRUE.
a two-column matrix where the first column is the start
node, the second the destination, as in
phylo$edge
which of the rows in the edge matrix represent extant species
which of the tips in the edge matrix are extinct (DEFAULT: empty vector, i.e., none)
a vector to be used to give edge.length to the phylogeny (default NA, i.e., none)
if given (default NA), a vector to be used for traits
($traits
slot) in the phylogeny
Will Pearse
Will Pearse
Will Pearse
sim.bd.tree
simulates a pure birth/death speciation
model. There are two important things to note: (1) speciation is
randomised before extinction, and only one thing can happen to a
lineage per timestep. (2) This code works well for my purposes, but
absurd parameter values can cause the function to crash.
sim.bd.tr.tree
is an extension of sim.bd.tree
, and
all its caveats apply to it. It additionally simulated the
evolution of a trait under Brownain motion
(tr.walk
). Species' speciation/extinction rates change
depending on whether they have a trait value similar to other
species (sp.tr
, ext.tr
). When a speciation event
happens, the two daughters split evenly about the ancestor's trait
value, taking values half-way to whatever the nearest species'
value is. To be precise: \(p(speciate)_i = speciate_i + sp.tr
\times min(trait distance)\), \(p(extinct)_i = exinction_i + ext.tr
\times min(trait distance)\), where \(i\) denotes each species.
edge2phylo
is an internal function for the
sim.phy
and sim.meta
function families,
which may be of use to you. Check those functions' code for
examples of use.
These functions are closely related to sim.meta
; the
latter are extensions that simulate meta-community structure at the
same time.
sim.meta scape
tree <- sim.bd.phy(0.1, 0, 10)
plot(tree)
Run the code above in your browser using DataLab