Learn R Programming

phytools (version 1.2-0)

plotTree.wBars: Plot a tree with bars at the tips

Description

plotTree.wbars plots a phylogeny in phylogram or fan style with bars at the tips representing the values for a phenotypic trait.

plotTree.barplot creates a split plot in which a right-facing phylogram is on the left, and a bar plot is shown on the right.

plotTree.boxplot creates a split plot in which a right-facing phylogram is on the left, and a box plot is shown on the right.

Usage

plotTree.wBars(tree, x, scale=NULL, width=NULL, type="phylogram", 
   method="plotTree", tip.labels=FALSE, col="grey", border=NULL, 
   ...)
plotTree.barplot(tree, x, args.plotTree=list(), args.barplot=list(), 
	...)
plotTree.boxplot(tree, x, args.plotTree=list(), args.boxplot=list(),
	...)

Value

Plots a tree with an associated bar plot for a continuously valued character at the tips.

Arguments

tree

an object of class "phylo".

x

a named vector or matrix of trait values. For plotTree.boxplot, the names should repeat for multiple observations per species. For plotTree.boxplot x can also be supplied as a formula, though in that case the factor levels need to be provided in a valid cladewise order of the tips in tree. This order doesn't need to correspond with the current order of the tip labels. For plotTree.barplot x can be a matrix (or a data frame) in which columns are the values of multiple traits to be simultaneously plotted on the tree.

scale

scaling factor for the tip bars (relative to the total tree height). If left as NULL a reasonable scaling factor is computed automatically.

width

width of the tip bars.

type

plot type. Can be "phylogram" or "fan".

method

plotting method to use. Can be "plotTree" (for plotTree) or "plotSimmap" (for plotSimmap).

tip.labels

argument indicating whether or not tip labels should be plotted. Defaults to tip.labels=FALSE.

col

colors of the plotted bars. Can be a single value or a vector with length equal to the number of tips in the tree.

border

single value specifying the color of the border for the plotted bars. Defaults to border=NULL, which means that black borders will be plotted.

args.plotTree

in plotTree.barplot, arguments to be passed to plotTree.

args.barplot

in plotTree.barplot, arguments to be passed to barplot.

args.boxplot

in plotTree.boxplot, arguments to be passed to boxplot.

...

optional arguments to be passed to plotTree or plotSimmap in the case of plotTree.wBars. For plotTree.barplot, the only optional arguments are add and ylim. Generally add should not be used; however it can be employed to tell the function to draw the tree & barplot, respectively, in the next two open plotting devices - rather than creating a table of figures in the current plotting device. ylim (which is also an optional argument for plotTree.boxplot should be supplied here rather than using args.plotTree or args.boxplot\codeargs.barplot because y axis limits must match exactly between the two plots.

Author

Liam Revell liam.revell@umb.edu

References

Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223.

See Also

barplot, dotTree, plotSimmap, plotTree

Examples

Run this code
## load data from Mahler et al. (2010)
data(anoletree)
data(anole.data)
## extract overall body size (SVL)
svl<-setNames(anole.data$SVL,rownames(anole.data))
## plotTree.wBars
plotTree.wBars(anoletree,svl,type="fan",scal=0.5)
par(mar=c(5.1,4.1,4.1,2.1))
## plotTree.barplot
plotTree.barplot(anoletree,exp(svl),
    args.plotTree=list(fsize=0.5),
    args.barplot=list(xlab="SVL (mm)"))
	
## load vertebrate tree and data
data(vertebrate.tree)
data(vertebrate.data)
## plotTree.barplot
options(scipen=3) ## change sci-notation
plotTree.barplot(vertebrate.tree,
	setNames(vertebrate.data$Mass,
	rownames(vertebrate.data)),
	args.barplot=list(log="x",
	xlab="mass (kg)",
	xlim=c(0.01,500000),
	col=palette()[4]))
options(scipen=0)

## reset par to defaults
par(mfrow=c(1,1),mar=c(5.1,4.1,4.1,2.1))

Run the code above in your browser using DataLab