Description Usage Arguments Value Author(s) See Also Examples
fast.tree replicates the functionality of sim.bd.taxa for a single tree (more specifically, the internal function sim2.bd.reverse.single). When traits is set to TRUE it will also simulate the evolution of a character over the tree with Brownian motion, returning its result for every node and tip. In addition sample points across the length of the tree can be given and fast.tree will return a time slice of the character values for the extant branches given at these time points.
1 |
n |
Number of extant sampled tips. |
lambda |
Speciation rate. |
mu |
Extinction rate. |
frac |
For use with incomplete sampling (see sim.bd.taxa). The actual number of tips is n/frac. |
traits |
When greater than zero, enables character tracking and sampling for the specified number of independent traits on the same tree. |
sigma |
The standard deviation of the Brownian motion of the character over time. |
sampleTimes |
A vector of times at which to sample, expressed as a proportion of the overall tree length (in time). |
If traits = FALSE, a list with two values, the first containing the simulated tree with n/frac extant tips, and the second containing the tree length. This format is used for consistency with sim2.bd.reverse.single.
If traits = TRUE, a list with items:
tree |
The simulated tree with n/frac extant tips. |
samples |
A traits x max.leaves x n.samples matrix of characters taken at sampleTimes (padded with zeros), where traits is the number of independent traits, max.leaves is the maximum number of leaves at a sampled time and n.samples is the length of vector sampleTimes. |
n.leaves |
The number of leaves extant at each of the sampled times. |
sampleTimes |
The vector of sampled times (no longer expressed as a proportion). |
Nick Beeton
sim.bd.taxa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ##
# Demonstration of the two tree techniques
#
# use microbenchmark library to compare run times for a single tree
# (note that improvement decreases for multiple trees using sim.bd.taxa due to overheads)
library(microbenchmark)
# generate a single 1000 extant leaf random tree using raw fast.tree function
microbenchmark(fast.tree(n = 1000, lambda = 1.5, mu = 1, frac = 1), times = 1)
# generate the same tree using the sim.bd.taxa framework (which uses fast.tree)
microbenchmark(sim.bd.taxa(n = 1000, numbsim = 1, lambda = 1.5, mu = 1, frac = 1, fast = TRUE), times = 1)
# now generate a tree using the original technique
microbenchmark(sim.bd.taxa(n = 1000, numbsim = 1, lambda = 1.5, mu = 1, frac = 1, fast = FALSE), times = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.