mcmc2densitree: Plot a densi-tree from an MCMC sample

View source: R/mcmc2densitree.R

mcmc2densitreeR Documentation

Plot a densi-tree from an MCMC sample

Description

Plot a densi-tree from an MCMC sample from a BPP or MCMCTree analysis

Usage

mcmc2densitree(
  tree,
  mcmc,
  time.name,
  thin,
  col = "blue",
  alpha = 1,
  y.offset = 0,
  pfract = 0.1,
  plot.labels = TRUE,
  cex.lab = 1,
  axis = TRUE,
  add = FALSE,
  tip.ages = NULL
)

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.

col

character, the color for branches.

alpha

numeric, between 0 and 1, the branch color transparency.

y.offset

numeric, the vertical offset for plotting the tree.

pfract

numeric, how much of the plotting space to used for plotting the tip labels. If pfrac = 1, the same amount of space is used for the tree and the labels. Use large values if your tip labels are long.

plot.labels

logical, whether to plot the tip labels. Ignored if add = TRUE.

cex.lab

numeric, the relative character size for the tip labels.

axis

logical, whether to plot the x axis.

add

logical, if TRUE add the trees to an existing plot, otherwise create a new plot.

tip.ages

numeric, the ages of the tips, with the most recent tip having age zero, and the oldest tip having the largest age. If NULL, tips are assumed to have all age zero.

Details

The function will reduce the MCMC sample to dim(mcmc)[1] * thin observations. Then the node ages in each observarion are used to plot each tree in the sample. For a tree with s species. The y coordinates of the tips are given by 0:(s - 1) + y.offset.

The tree must be rooted, strictly bifurcating, and be the same tree used to genarate the BPP (A00) or MCMCTree MCMC samples.

Author(s)

Mario dos Reis

Examples

data(microcebus)
mcmc2densitree(microcebus$tree, microcebus$mcmc, time.name="tau_", thin=0.05,
 alpha=0.01, col="blue")
 title(xlab="Distance (substitutions per site)")

# data(hominids) TODO: Fix this example (add msc2time.t function)
# Calibrate the hominid phylogeny with a uniform fossil calibration of
# between 6.5 to 10 Ma for the human-chimp divergence, and plot the
# calibrated sample
#calmsc <- msc2time.t(mcmc=hominids$mcmc, node="7humanchimp", calf=runif,
#   min=6.5, max=10)
# mcmc2densitree(hominids$tree, calmsc, "t_", thin=0.05, alpha=0.01)
# title(xlab="Divergence time (Ma)")


dosreislab/mcmc3r documentation built on March 29, 2024, 6:45 p.m.