phytools: Phylogenetic Tools for Comparative Biology (and Other Things)

Package contains various functions for phylogenetic analysis. This functionality is concentrated in the phylogenetic analysis of comparative data from species. For example, the package includes functions for Bayesian and ML ancestral state estimation; visual simulation of trait evolution; fitting models of trait evolution with multiple Brownian rates and correlations; visualizing discrete and continuous character evolution using colors or projections into trait space; identifying the location of a change in the rate of character evolution on the tree; fast Brownian motion simulation and simulation under several other models of continuous trait evolution; fitting a model of correlated binary trait evolution; locating the position of a fossil or an recently extinct lineage on a tree using continuous character data with ML; plotting lineage accumulation through time, including across multiple trees (such as a Bayesian posterior sample); conducting an analysis called stochastic character mapping, in which character histories for a discrete trait are sampled from their posterior probability distribution under a model; conducting a multiple (i.e., partial) Mantel test; fitting a phylogenetic regression model with error in predictor and response variables; conducting a phylogenetic principal components analysis, a phylogenetic regression, a reduced major axis regression, a phylogenetic canonical correlation analysis, and a phylogenetic ANOVA; projecting a tree onto a geographic map; simulating discrete character histories on the tree; fitting a model in which a discrete character evolves under the threshold model; visualization of cospeciation; and a simple statistical test for cospeciation between two trees. In addition to this phylogenetic comparative method functionality, the package also contains functions for a wide range of other purposes in phylogenetic biology. For instance, functionality in this package includes (but is not restricted to): adding taxa to a tree (including randomly, everywhere, or automatically to genera); generating all bi- and multi-furcating trees for a set of taxa; reducing a phylogeny to its backbone tree; dropping tips or adding tips to special types of phylogenetic trees; exporting a tree as an XML file; converting a tree with a mapped character to a tree with singleton nodes and one character state per edge; estimating a phylogeny using the least squares method; simulating birth-death trees under a range of conditions; rerooting trees; computing a consensus tree under multiple methods, including via minimization of the distance to other trees in the set; a wide range of visualizations of trees; and a variety of other manipulations and analyses that phylogenetic biologists may find useful for their research.

Install the latest version of this package by entering the following in R:
AuthorLiam J. Revell
Date of publication2017-03-28 21:11:25 UTC
MaintainerLiam J. Revell <>
LicenseGPL (>= 2)

View on CRAN

Man pages

add.arrow: Add an arrow pointing to a tip or node on the tree Add color bar to a plot

add.everywhere: Add tip to all edges in a tree

add.random: Add tips at random to the tree

add.simmap.legend: Add legend to stochastically mapped tree Add species to genus on a phylogeny or bind simulated species...

aic.w: Computes AIC weights

allFurcTrees: Generate all bi- and multifurcating unrooted trees

anc.Bayes: Bayesian ancestral character estimation

anc.ML: Ancestral character estimation using likelihood

ancThresh: Ancestral character estimation under the threshold model...

anc.trend: Ancestral character estimation with a trend

anoletree: Phylogeny of Greater Antillean anole ecomorph species with...

applyBranchLengths: Applies the branch lengths of a reference tree to a target

as.multiPhylo: Conversion to object of class '"multiPhylo"'

averageTree: Compute an average tree from a set of trees and related...

ave.rates: Average the posterior rates

bd: Convert object of class "birthdeath" to raw birth & death...

bind.tip: Attaches a new tip to a tree

bind.tree.simmap: Attaches a new tip to a tree

bmPlot: Simulates and visualizes discrete-time Brownian evolution on...

branching.diffusion: Animation of branching random diffusion

brownie.lite: Likelihood test for rate variation in a continuous trait

brownieREML: REML version of brownie.lite

cladelabels: Add labels to subtrees of a plotted phylogeny Collapse a subtree to a star phylogeny

collapseTree: Interactive tree visualizer

consensus.edges: Compute consensus edges for a tree under some criterion

contMap: Map continuous trait evolution on the tree

cophylo: Creates a co-phylogenetic plot

cospeciation: Conducts a statistical test of cospeciation between two trees

countSimmap: Counts the number of character changes on a SIMMAP style tree...

densityMap: Plot posterior density of stochastic mapping on a tree

densityTree: Plots a posterior sample of trees

describe.simmap: Summarizes a stochastic mapped tree or set of trees

di2multi.simmap: Collapse branches of zero length to polytomy in stochastic...

dotTree: Creates a phylogenetic dot plot

drop.clade: Drop a clade from a tree

drop.leaves: Drop all the leaves (tips) from a tree

drop.tip.contMap: Drop tip or tips from an object of class "contMap" or...

drop.tip.simmap: Drop tips or extract clade from tree with mapped discrete...

edgeProbs: Compute the relative frequencies of state changes along edges

estDiversity: Estimate diversity at each node of the tree

evol.rate.mcmc: Bayesian MCMC method for identifying exceptional phenotypic...

evol.vcv: Likelihood test for variation in the evolutionary VCV matrix

evolvcv.lite: Likelihood test for a shift in the evolutionary correlation...

exhaustiveMP: Exhaustive and branch & bound MP optimization

expm: Matrix exponential Export trees & data in XML format

fancyTree: Plots special types of phylogenetic trees

fastAnc: Fast estimation of ML ancestral states

fastBM: Fast Brownian simulation

fastMRCA: Get the MRCA (or height above the root of the MRCA) of a pair...

findMRCA: Get the MRCA of a set of taxa

fitBayes: Evolutionary model fitting with intraspecific variability...

fitDiversityModel: Fit diversity-dependent phenotypic evolution model

fitMk: Fits Mk model

fitPagel: Function to test for correlated evolution of binary traits

force.ultrametric: Forces a phylogenetic tree to be ultrametric

gammatest: Gamma test of Pybus & Harvey (2000)

genSeq: Simulate a DNA alignment on the tree under a model

getCladesofSize: Get all subtrees larger than or equal to a specified size

getDescendants: Get descendant node numbers

getExtant: Returns a list of the extant or extinct lineages in a tree...

getSisters: Get the sister node number, label, or set of nodes for a node...

getStates: Get the states at nodes or tips from a mapped tree

get.treepos: Internal functions

labelnodes: Function to interactively label nodes of a plotted tree

ladderize.simmap: Ladderize a tree with a mapped discrete character

lambda.transform: Lambda transformation of matrix

likMlambda: Likelihood for joint lambda

locate.fossil: Locate a fossil lineage in a tree using continuous characters

locate.yeti: Locate a cryptic, recently extinct, or missing taxon on a...

ls.tree: Least squares branch lengths for a given tree

ltt: Creates lineage-through-time plot (including extinct...

ltt95: Creates a (1-alpha)-percent CI for a set of LTTs Create "era" map on a phylogenetic tree

make.simmap: Simulate stochastic character maps on a phylogenetic tree or...

map.overlap: Proportional overlap between two mapped character histories...

mapped.states: Returns a vector, matrix, or list of the mapped states on a... Converts a mapped tree to a tree with singleton nodes

markChanges: Add marked changes to a plotted tree with mapped discrete...

matchNodes: Matches nodes between two trees

mergeMappedStates: Merge two or more mapped states into one state

midpoint.root: Midpoint root a phylogeny

minRotate: Rotates all nodes of the tree to minimize the difference in...

minSplit: Finding the minimum (median) split in the posterior sample

modified.Grafen: Computes modified Grafen edge lengths

mrp.supertree: Matrix representation parsimony supertree estimation

multiC: Returns a list with phylogenetic VCV matrix for each mapped...

multi.mantel: Multiple matrix regression (partial Mantel test)

multiRF: Computes Robinson-Foulds distance between a set of trees

nodeHeights: Compute the heights above the root of each node

nodelabels.cophylo: Add labels to a plotted "cophylo" object Phylogeny inference using the least squares method

orderMappedEdge: Order the columns of mapped.edge to match across trees

paintSubTree: Paint sub-trees with a discrete character

paste.tree: Paste two trees together

pbtree: Simulate pure-birth or birth-death stochastic tree or trees

pgls.Ives: Phylogenetic regression with intraspecific sampling error

phenogram: Plot phenogram (traitgram)

phylANOVA: Phylogenetic ANOVA and post-hoc tests

phyl.cca: Phylogenetic canonical correlation analysis

phyloDesign: Compute design matrix for least squares analyses

phylo.heatmap: Creates a phylogenetic heat map

phylomorphospace: Creates phylomorphospace plot

phylomorphospace3d: Creates tree-dimensional phylomorphospace plot

phylosig: Compute phylogenetic signal with two methods

phylo.toBackbone: Converts tree to backbone or vice versa Plot tree with tips linked to geographic coordinates

phyl.pairedttest: Phylogenetic paired t-test

phyl.pca: Phylogenetic principal components analysis

phyl.resid: Phylogenetic size-correction via GLS regression

phyl.RMA: Phylogenetic reduced major axis (RMA) regression

phyl.vcv: Compute evolutionary VCV matrix for a tree & dataset

phytools-package: phytools: Phylogenetic Tools for comparative biology (and...

plot.backbonePhylo: Plots backbone tree with triangles as clades

plotBranchbyTrait: Plot branch colors by a quantitative trait or value

plotSimmap: Plot stochastic character mapped tree

plotThresh: Tree plotting with posterior probabilities of ancestral...

plotTree: Plots rooted phylogenetic tree

plotTree.errorbars: Plot a tree with error bars around divergence dates

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

posterior.evolrate: Analysis of the posterior sample from evol.rate.mcmc

print.backbonePhylo: Print method for backbone phylogeny

ratebystate: Method for investigating the rate of one trait as a function...

ratebytree: Likelihood test for rate variation among trees

rateshift: Find the temporal position of one or more rate shifts

read.newick: Robust Newick style tree reader

read.simmap: Read SIMMAP style trees from file

reorder.backbonePhylo: Reorders a backbone phylogeny

reorderSimmap: Reorder edges of a simmap tree

rep.phylo: Replicate a tree or set of trees

reroot: Re-root a tree along an edge

rerootingMethod: Get marginal ancestral state reconstructions by re-rooting

rescaleSimmap: Rescale SIMMAP style tree

resolveNode: Compute all possible resolutions of a node or all nodes in a...

rotateNodes: Rotates a node or set of nodes in a phylogenetic tree

roundBranches: Rounds the branch lengths of a tree

roundPhylogram: Plot a round phylogram

rstate: Pick a random state according to a vector of probabilities

sampleFrom: Sample from a set of distributions

setMap: Set color map for objects of class '"contMap"' or...

sim.corrs: Multivariate Brownian simulation with multiple correlations...

sim.history: Simulate stochastic character history under some model

sim.ratebystate: Conduct simulation of state dependent rate variation

sim.rates: Brownian or OU simulation with multiple evolutionary regimes

skewers: Matrix comparison using the method of random skewers

splitEdgeColor: Split edge colors when descendant edges have different mapped...

splitplotTree: Plots a phylogeny in two columns

splitTree: Split tree at a point

starTree: Create star phylogeny

strahlerNumber: Computes Strahler number for trees and nodes

threshBayes: Threshold model using Bayesian MCMC

threshDIC: Deviance Information Criterion from the threshold model

threshState: Computes value for a threshold character from a liability and...

to.matrix: Convert a character vector to a binary matrix

treeSlice: Slices the tree at a particular point and returns all...

untangle: Attempts to untangle crossing branches for plotting

vcvPhylo: Calculates cophenetic (i.e., phylogenetic VCV) matrix

writeAncestors: Write a tree to file with ancestral states and (optionally)...

writeNexus: Write a tree to file in Nexus format

write.simmap: Write a stochastic character mapped tree to file


add.arrow Man page Man page
add.everywhere Man page
add.random Man page
add.simmap.legend Man page Man page
aic.w Man page
allFurcTrees Man page
allRotations Man page
anc.Bayes Man page
anc.ML Man page
ancThresh Man page
anc.trend Man page
anoletree Man page
applyBranchLengths Man page
arc.cladelabels Man page
as.multiPhylo Man page
as.multiPhylo.multiSimmap Man page
as.multiPhylo.phylo Man page
averageTree Man page
ave.rates Man page
backbone.toPhylo Man page
bd Man page
bind.tip Man page
bind.tree.simmap Man page
biplot.phyl.pca Man page
bmPlot Man page
branching.diffusion Man page
brownie.lite Man page
brownieREML Man page
cladelabels Man page
coef.phyl.RMA Man page Man page
collapseTree Man page Man page
consensus.edges Man page
contMap Man page
cophylo Man page
cospeciation Man page
countSimmap Man page
densityMap Man page
densityTree Man page
describe.simmap Man page
di2multi.simmap Man page
dot.legend Man page
dotTree Man page
drop.clade Man page
drop.leaves Man page
drop.tip.contMap Man page
drop.tip.densityMap Man page
drop.tip.simmap Man page
drop.tip.singleton Man page
edgelabels.cophylo Man page
edgeProbs Man page
errorbar.contMap Man page
estDiversity Man page
evol.rate.mcmc Man page
evol.vcv Man page
evolvcv.lite Man page
exhaustiveMP Man page
expm Man page Man page
extract.clade.simmap Man page
extract.strahlerNumber Man page
fancyTree Man page
fastAnc Man page
fastBM Man page
fastDist Man page
fastHeight Man page
fastMRCA Man page
findMRCA Man page
fitBayes Man page
fitDiversityModel Man page
fitMk Man page
fitPagel Man page
force.ultrametric Man page
gammatest Man page
genSeq Man page Man page
getCladesofSize Man page
getDescendants Man page
getExtant Man page
getExtinct Man page
getnode Man page
getSisters Man page
getStates Man page
get.treepos Man page
labelnodes Man page
ladderize.simmap Man page
lambda.transform Man page
likMlambda Man page
likSurface.rateshift Man page
locate.fossil Man page
locate.yeti Man page
ls.consensus Man page
ls.tree Man page
ltt Man page
ltt95 Man page Man page
make.simmap Man page
make.transparent Man page
map.overlap Man page
Map.Overlap Man page
mapped.states Man page Man page
markChanges Man page
matchLabels Man page
matchNodes Man page
mergeMappedStates Man page
midpoint.root Man page
minRotate Man page
minSplit Man page
minTreeDist Man page
modified.Grafen Man page
mrp.supertree Man page
multiC Man page
multi.mantel Man page
multiOU Man page
multiRF Man page
nodeheight Man page
nodeHeights Man page
nodelabels.cophylo Man page
node.paths Man page Man page
orderMappedEdge Man page
paintBranches Man page
paintSubTree Man page
paste.tree Man page
pbtree Man page
pgls.Ives Man page
pgls.SEy Man page
phenogram Man page
phylANOVA Man page
phyl.cca Man page
phyloDesign Man page
phylo.heatmap Man page
phylomorphospace Man page
phylomorphospace3d Man page
phylosig Man page
phylo.toBackbone Man page Man page
phyl.pairedttest Man page
phyl.pca Man page
phyl.resid Man page
phyl.RMA Man page
phyl.vcv Man page
phytools Man page
phytools-package Man page
plot.backbonePhylo Man page
plotBranchbyTrait Man page
plot.contMap Man page
plot.cophylo Man page
plot.cospeciation Man page
plot.densityMap Man page
plot.describe.simmap Man page
plot.fitMk Man page
plot.fitPagel Man page
plot.gfit Man page
plot.ltt95 Man page
plot.multiSimmap Man page Man page
plot.phyl.RMA Man page
plot.rateshift Man page
plot.simmap Man page
plotSimmap Man page
plotThresh Man page
plotTree Man page
plotTree.barplot Man page
plotTree.boxplot Man page
plotTree.errorbars Man page
plotTree.singletons Man page
plotTree.splits Man page
plotTree.wBars Man page
posterior.evolrate Man page
print.backbonePhylo Man page
print.cospeciation Man page
ratebystate Man page
ratebytree Man page
rateshift Man page
read.newick Man page
read.simmap Man page
reorder.backbonePhylo Man page
reorderSimmap Man page
rep.multiPhylo Man page
rep.phylo Man page
repPhylo Man page
reroot Man page
rerootingMethod Man page
rescaleSimmap Man page
resolveAllNodes Man page
resolveNode Man page Man page
rotate.multi Man page
rotateNodes Man page
roundBranches Man page
roundPhylogram Man page
rstate Man page
sampleFrom Man page
setMap Man page
sim.corrs Man page
sim.history Man page
sim.ratebystate Man page
sim.rates Man page
skewers Man page
splitEdgeColor Man page
splitplotTree Man page
splitTree Man page
starTree Man page
strahlerNumber Man page
summary.multiSimmap Man page
summary.simmap Man page
threshBayes Man page
threshDIC Man page
threshState Man page
tiplabels.cophylo Man page
tipRotate Man page
to.matrix Man page
treeSlice Man page
untangle Man page
vcvPhylo Man page
writeAncestors Man page
writeNexus Man page
write.simmap Man page


R/backbonePhylo.R R/fitMk.R R/read.newick.R R/ls.consensus.R R/paintSubTree.R R/contMap.R R/cophylo.R R/plotBranchbyTrait.R R/sim.rates.R R/splitplotTree.R R/anc.ML.R R/ R/phyl.resid.R R/make.simmap.R R/locate.fossil.R R/ratebystate.R R/bmPlot.R R/multi.mantel.R R/phylo.heatmap.R R/phylomorphospace.R R/phyl.pairedttest.R R/densityMap.R R/rerootingMethod.R R/estDiversity.R R/fastAnc.R R/phylANOVA.R R/pgls.Ives.R R/ R/utilities.R R/consensus.edges.R R/rateshift.R R/ R/add.everywhere.R R/phyl.pca.R R/ltt.R R/add.random.R R/mcmcLambda.R R/densityTree.R R/writeAncestors.R R/collapseTree.R R/fancyTree.R R/pbtree.R R/cospeciation.R R/ratebytree.R R/allFurcTrees.R R/resolveNodes.R R/phyl.cca.R R/starTree.R R/plotSimmap.R R/ancThresh.R R/plotTree.wBars.R R/evol.rate.mcmc.R R/mrp.supertree.R R/plotTree.errorbars.R R/ R/write.simmap.R R/mcmcBM.full.R R/fastBM.R R/exhaustiveMP.R R/ltt95.R R/sim.history.R R/evol.vcv.R R/phylosig.R R/ R/threshBayes.R R/fitDiversityModel.R R/fitPagel.R R/treeSlice.R R/phylomorphospace3d.R R/evolvcv.lite.R R/fitBayes.R R/anc.Bayes.R R/multiRF.R R/branching.diffusion.R R/read.simmap.R R/map.overlap.R R/skewers.R R/phyl.RMA.R R/drop.tip.simmap.R R/phenogram.R R/dotTree.R R/writeNexus.R R/brownieREML.R R/strahlerNumber.R R/sim.corrs.R R/roundPhylogram.R R/mcmcBM.R R/ R/anc.trend.R R/brownie.lite.R R/locate.yeti.R
man/markChanges.Rd man/nodeHeights.Rd man/posterior.evolrate.Rd man/cophylo.Rd man/brownie.lite.Rd man/add.simmap.legend.Rd man/ave.rates.Rd man/anc.Bayes.Rd man/phylANOVA.Rd man/paste.tree.Rd man/branching.diffusion.Rd man/fitDiversityModel.Rd man/getCladesofSize.Rd man/get.treepos.Rd man/evol.rate.mcmc.Rd man/cospeciation.Rd man/locate.fossil.Rd man/averageTree.Rd man/countSimmap.Rd man/ls.tree.Rd man/writeAncestors.Rd man/findMRCA.Rd man/anc.trend.Rd man/threshState.Rd man/phyl.vcv.Rd man/rateshift.Rd man/bd.Rd man/orderMappedEdge.Rd man/splitTree.Rd man/writeNexus.Rd man/bmPlot.Rd man/splitplotTree.Rd man/applyBranchLengths.Rd man/getSisters.Rd man/ man/ladderize.simmap.Rd man/getExtant.Rd man/add.arrow.Rd man/minRotate.Rd man/plotTree.Rd man/phyloDesign.Rd man/sim.rates.Rd man/rotateNodes.Rd man/ltt95.Rd man/contMap.Rd man/di2multi.simmap.Rd man/phyl.cca.Rd man/sim.corrs.Rd man/mrp.supertree.Rd man/ltt.Rd man/force.ultrametric.Rd man/ man/fancyTree.Rd man/reroot.Rd man/labelnodes.Rd man/multi.mantel.Rd man/map.overlap.Rd man/roundPhylogram.Rd man/edgeProbs.Rd man/skewers.Rd man/ man/add.everywhere.Rd man/ man/mergeMappedStates.Rd man/sampleFrom.Rd man/starTree.Rd man/treeSlice.Rd man/plotTree.errorbars.Rd man/fitBayes.Rd man/nodelabels.cophylo.Rd man/locate.yeti.Rd man/fastAnc.Rd man/drop.leaves.Rd man/plotSimmap.Rd man/strahlerNumber.Rd man/read.simmap.Rd man/evol.vcv.Rd man/print.backbonePhylo.Rd man/bind.tip.Rd man/ancThresh.Rd man/matchNodes.Rd man/phylomorphospace.Rd man/consensus.edges.Rd man/multiC.Rd man/plot.backbonePhylo.Rd man/phenogram.Rd man/minSplit.Rd man/densityMap.Rd man/ man/to.matrix.Rd man/setMap.Rd man/likMlambda.Rd man/phyl.pca.Rd man/untangle.Rd man/sim.history.Rd man/threshBayes.Rd man/plotThresh.Rd man/anoletree.Rd man/splitEdgeColor.Rd man/vcvPhylo.Rd man/phylosig.Rd man/read.newick.Rd man/plotBranchbyTrait.Rd man/ man/rerootingMethod.Rd man/ man/reorder.backbonePhylo.Rd man/paintSubTree.Rd man/phylo.heatmap.Rd man/allFurcTrees.Rd man/exhaustiveMP.Rd man/write.simmap.Rd man/phyl.pairedttest.Rd man/threshDIC.Rd man/make.simmap.Rd man/multiRF.Rd man/fastBM.Rd man/reorderSimmap.Rd man/phylo.toBackbone.Rd man/aic.w.Rd man/phytools-package.Rd man/cladelabels.Rd man/lambda.transform.Rd man/modified.Grafen.Rd man/mapped.states.Rd man/as.multiPhylo.Rd man/densityTree.Rd man/fastMRCA.Rd man/pgls.Ives.Rd man/fitPagel.Rd man/resolveNode.Rd man/bind.tree.simmap.Rd man/describe.simmap.Rd man/drop.tip.contMap.Rd man/midpoint.root.Rd man/phylomorphospace3d.Rd man/getStates.Rd man/phyl.RMA.Rd man/roundBranches.Rd man/gammatest.Rd man/genSeq.Rd man/expm.Rd man/phyl.resid.Rd man/anc.ML.Rd man/fitMk.Rd man/rep.phylo.Rd man/dotTree.Rd man/estDiversity.Rd man/rescaleSimmap.Rd man/evolvcv.lite.Rd man/rstate.Rd man/pbtree.Rd man/add.random.Rd man/ratebytree.Rd man/plotTree.wBars.Rd man/ratebystate.Rd man/brownieREML.Rd man/sim.ratebystate.Rd man/getDescendants.Rd man/collapseTree.Rd man/drop.clade.Rd man/ man/drop.tip.simmap.Rd

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.