Convert a simulated edge matrix to an ape:phylo object
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)
tr.wrap
tr.range
; default TRUE.phylo$edge
$traits
slot) in the phylogenysim.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
that
extend this to simulate meta-community structure at the same time.
tree <- sim.bd.phy(0.1, 0, 10)
plot(tree)
Run the code above in your browser using DataLab