Learn R Programming

phytools (version 0.7-70)

fancyTree: Plots special types of phylogenetic trees

Description

This function plots different types of phylogenetic trees.

If type="extinction" (or any unambiguous abbreviation) the function will plot a tree in which branches preceding the MRCA of all extant taxa and branches leading only to extnct lineages are plotted with dashed red lines.

If type="traitgram3d" the function will plot a three dimensional traitgram (that is, a projection of the tree into three dimensional morphospace where two dimensions are the phenotypic trait and the third axis is time since the root). In this case, the additional argument X, a matrix containing the tip values of all species (with species IDs as row names) should be supplied. Optionally, the user can also supply the matrix A, which contains the ancestral states in the tree with rows labeled by node number.

If type="droptip" the function will create a two panel figure in which the first panel is the tree with lineages to be pruned highlighted; and the second panel is the pruned tree. In this case, the additional argument tip, the tip name or vector of tip names to be dropped, must be supplied.

If type="densitymap", a posterior probability density "heat-map" is created based on a set of trees in a "multiPhylo" object containing a binary [0,1] mapped character. (See densityMap for additional optional arguments if type="densitymap".) This option just calls the function densityMap internally.

If type="contmap", reconstructed continuous trait evolution is mapped on the tree. Again, see contMap for additional arguments if type="contmap". Much like type="densitymap", this option just calls the function contMap internally.

If type="phenogram95" a 95-percent phenogram is plotted using transparency to visualize uncertainty at ancestral nodes and along branches. Most of the options of phenogram are available.

Finally, if type="scattergram" a phylogenetic scatter plot matrix containing contMap style trees on the diagonal and phylomorphospace plots in non-diagonal panels is produced. For this type a trait matrix X must also be supplied. The only additional arguments available for this type are ftype, fsize, colors, and label. (See phylomorphospace for details on how these arguments should be used.) This function calls phyloScattergram (which is also now exported to the name space) internally. In addition to creating a plot, phyloScattergram also returns an object of class "phyloScattergram" which can be replotted using different options if desired.

Presently only type="traitgram3d" uses the list control which can be supplied the same set of control parameters as phylomorphospace3d, as well as the control parameter maxit which will be passed to anc.ML.

Finally, the optional argument hold will be passed to multiple methods if supplied. It is a logical value that indicates whether or not the output to the graphical device should be held using dev.hold before plotting (defaults to hold=TRUE).

Usage

fancyTree(tree, type=c("extinction","traitgram3d","droptip","densitymap",
   "contmap","phenogram95","scattergram"), ..., control=list())
phyloScattergram(tree, X=NULL, ...)
phenogram95(tree, x=NULL, ...)

Arguments

tree

an object of class "phylo".

type

the type of special plot to create. See Description.

...

arguments to be passed to different methods. See Description.

control

a list of control parameters, depending on type.

X

in phyloScattergram, a matrix of continuous trait values. Row names in the matrix should correspond to species names in the tree.

x

in phenogram95, a named vector with values for a continuously distributed trait.

Value

This function plots different types of phylogenetic trees. For type="droptip" the function also returns the pruned tree.

References

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

See Also

contMap, densityMap, drop.tip, phenogram, phylomorphospace3d, plot.phylo, plotSimmap

Examples

Run this code
# NOT RUN {
# plot tree with extinction
set.seed(10)
tree<-pbtree(b=1,d=0.4,t=4)
fancyTree(tree,type="extinction")

# }
# NOT RUN {
# plot 3D traitgram
tree<-pbtree(n=50,scale=10)
Y<-sim.corrs(tree,vcv=matrix(c(1,0.75,0.75,1),2,2))
fancyTree(tree,type="traitgram3d",X=Y,
    control=list(spin=FALSE))
	
# plot with internal nodes from simulation
Y<-sim.corrs(tree,vcv=matrix(c(1,0.75,0.75,1),
    2,2),internal=TRUE)
B<-Y[length(tree$tip)+1:tree$Nnode,]
Y<-Y[1:length(tree$tip),]
fancyTree(tree,type="traitgram3d",X=Y,A=B,
    control=list(simple.axes=TRUE,spin=FALSE))
# }
# NOT RUN {
	
# plot with dropped tips
tree<-pbtree(n=30)
tips<-sample(tree$tip.label)[1:10]
pruned<-fancyTree(tree,type="droptip",tip=tips)

# }
# NOT RUN {
# plot 95-percent CI phenogram
tree<-pbtree(n=30)
x<-fastBM(tree)
fancyTree(tree,type="phenogram95",x=x)
# }
# NOT RUN {
## reset par to defaults
par(mar=c(5.1,4.1,4.1,2.1))
par(mfrow=c(1,1))
# }

Run the code above in your browser using DataLab