mcmc2multiphylo: Convert an MCMC sample from BPP or MCMCTree to a list of...

View source: R/mcmc2multiphylo.R

mcmc2multiphyloR Documentation

Convert an MCMC sample from BPP or MCMCTree to a list of trees

Description

Convert an MCMC sample from BPP or MCMCTree to a list of trees

Usage

mcmc2multiphylo(tree, mcmc, time.name, thin)

Arguments

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

Details

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.

Value

An object of class multiPhylo (i.e., a list of trees).

Author(s)

Mario dos Reis

Examples

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)


dosreislab/bppr documentation built on April 10, 2023, 6:12 p.m.