View source: R/mcmc2multiphylo.R
mcmc2multiphylo | R Documentation |
Convert an MCMC sample from BPP or MCMCTree to a list of trees
mcmc2multiphylo(tree, mcmc, time.name, thin)
tree |
an object of class phylo |
mcmc |
data frame with an MCMC sample from MCMCTree or a BPP A00 analysis |
time.name |
character vector of length one |
thin |
numeric, the fraction of MCMC samples to keep |
tree
must be rooted and strictly bifurcating, and it must
match the tree used by BPP or MCMCTree to obtain the MCMC sample. The
function uses the node ages in mcmc
to calculate branch lengths and
generate a list of trees (with the same topology as tree
), one tree
per (thinned) MCMC sample. The tips of the phylogeny are assumed to have
age zero.
An object of class multiPhylo (i.e., a list of trees).
Mario dos Reis
data(microcebus)
# convert a BPP A00 MCMC sample of Microcebus spp. to a list of trees
mtts <- mcmc2multiphylo(microcebus$tree, microcebus$mcmc, "tau_", thin=0.01)
length(mtts)
data(hominids)
# Calibrate the hominid phylogeny with a uniform fossil calibration of
# between 6.5 to 10 Ma for the human-chimp divergence.
calmsc <- msc2time.t(mcmc=hominids$mcmc, node="7humanchimp", calf=runif,
min=6.5, max=10)
# convert the time-calibrated MCMC sample to a list of trees
htts <- mcmc2multiphylo(hominids$tree, calmsc, "t_", thin=0.01)
htts[[1]]
## Not run:
# If you have the ape package installed, you can output the trees in Newick
ape::write.tree(htts[1:5])
# The trees are suitable for plotting with the phangorn package
# Relative node ages (tau's):
mcon <- microcebus$tree$tip.label
phangorn::densiTree(mtts, col="blue", alpha=0.04, cons=mcon, label.offset=.01)
# Absolute node ages (in millions of years):
hcon <- hominids$tree$tip.label
phangorn::densiTree(htts, col="blue", alpha=0.04, cons=hcon, label.offset=.01)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.