Learn R Programming

phytools (version 2.5-2)

Phylogenetic Tools for Comparative Biology (and Other Things)

Description

A wide range of methods for phylogenetic analysis - concentrated in phylogenetic comparative biology, but also including numerous techniques for visualizing, analyzing, manipulating, reading or writing, and even inferring phylogenetic trees. Included among the functions in phylogenetic comparative biology are various for ancestral state reconstruction, model-fitting, and simulation of phylogenies and trait data. A broad range of plotting methods for phylogenies and comparative data include (but are not restricted to) methods for mapping trait evolution on trees, for projecting trees into phenotype space or a onto a geographic map, and for visualizing correlated speciation between trees. Lastly, numerous functions are designed for reading, writing, analyzing, inferring, simulating, and manipulating phylogenetic trees and comparative data. For instance, there are functions for computing consensus phylogenies from a set, for simulating phylogenetic trees and data under a range of models, for randomly or non-randomly attaching species or clades to a tree, as well as for a wide range of other manipulations and analyses that phylogenetic biologists might find useful in their research.

Copy Link

Version

Install

install.packages('phytools')

Monthly Downloads

8,304

Version

2.5-2

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Liam Revell

Last Published

September 19th, 2025

Functions in phytools (2.5-2)

anc.trend

Ancestral character estimation with a trend
as.multiPhylo

Conversion to object of class "multiPhylo"
ansi_phylo

Graph a phylogeny using only ANSI characters
anc.ML

Ancestral character estimation using likelihood
ave.rates

Average the posterior rates
as.Qmatrix

Convert a fitted Mk model to a Q-matrix
bind.tree.simmap

Binds two trees of class "simmap"
brownie.lite

Likelihood test for rate variation in a continuous trait
branching.diffusion

Animation of branching random diffusion
bind.tip

Attaches a new tip to a tree
cladelabels

Add labels to subtrees of a plotted phylogeny
bounded_bm

Fits bounded and wrapped Brownian motion models
ctt

Generates (or simulates) a 'changes through time' plot from a set of stochastic map character histories
collapseTree

Interactive tree visualizer
compare.chronograms

Compares two chronograms with precisely matching nodes in a visual manner
density.multiSimmap

Computes a posterior distribution for the number and types of changes on the tree
countSimmap

Counts the number of character changes on a object of class "simmap" or "multiSimmap"
collapse.to.star

Collapse a subtree to a star phylogeny
consensus.edges

Compute consensus edges for a tree under some criterion
describe.simmap

Summarizes a stochastic mapped tree or set of trees
drop.leaves

Drop all the leaves (tips) from a tree
dotTree

Creates a phylogenetic dot plot
densityMap

Plot posterior density of stochastic mapping on a tree
drop.clade

Drop a clade from a tree
densityTree

Plots a posterior sample of trees
drop.tip.simmap

Drop tips or extract clade from tree with mapped discrete character
evol.rate.mcmc

Bayesian MCMC method for identifying exceptional phenotypic diversification in a phylogeny
estDiversity

Estimate diversity at each node of the tree
expand.clade

Expands (or contracts) the tip-spacing of a given clade or clades
edgeProbs

Compute the relative frequencies of state changes along edges
edge.widthMap

Map continuous trait evolution on the tree
evolvcv.lite

Likelihood test for a shift in the evolutionary correlation between traits
fancyTree

Plots special types of phylogenetic trees
exhaustiveMP

Exhaustive and branch & bound MP optimization
export.as.xml

Export trees & data in XML format
evol.vcv

Likelihood test for variation in the evolutionary variance-covariance matrix
fastMRCA

Get the MRCA (or height above the root of the MRCA) of a pair of tip taxa
fitDiversityModel

Fit diversity-dependent phenotypic evolution model
fitThresh

Fits binary, multi-state, and semi-threshold models using the discretized diffusion approximation
findMRCA

Get the MRCA of a set of taxa
fastBM

(Reasonably) fast quantitative trait simulation on phylogenies
fitMk

Fits extended Mk model for discrete character evolution
geo.legend

Adds a geological (or other temporal) legend to a plotted tree
gammatest

\(\gamma\) test of Pybus & Harvey (2000)
gamma_pruning

Internally used function
getCladesofSize

Get all subtrees larger than or equal to a specified size
genSeq

Simulate a DNA alignment on the tree under a model
fitcontMk

Fits binary discrete character evolution model where the transition rate varies as a function of a continuous trait
getDescendants

Get descendant node numbers
likMlambda

Likelihood for joint \(\lambda\)
locate.yeti

Locate a cryptic, recently extinct, or missing taxon on a tree
getExtant

Returns a list of the extant or extinct lineages in a tree containing non-contemporaneous tips
lambda.transform

\(\lambda\) transformation of matrix
map.to.singleton

Converts a tree without singletons to a tree with singleton nodes
ls.tree

Least squares branch lengths for a given tree
mapped.states

Returns a vector, matrix, or list of the mapped states on a tree or set of trees
make.era.map

Create "era" map on a phylogenetic tree
ltt95

Creates a (1-\(\alpha\))% CI for a set of LTTs
midpoint_root

Midpoint root a phylogeny
mergeMappedStates

Merge two or more mapped states into one state
multiRF

Computes Robinson-Foulds distance between a set of trees
paste.tree

Paste two trees together
phenogram

Plot traitgram (phenogram)
pgls.Ives

Phylogenetic regression with intraspecific sampling error
pbtree

Simulate pure-birth or birth-death stochastic tree or trees
nodelabels.cophylo

Add labels to a plotted "cophylo" object
phyl.vcv

Compute evolutionary VCV matrix for a tree & dataset
phylo.to.map

Plot tree with tips linked to geographic coordinates
phylo.heatmap

Creates a phylogenetic heat map
phyl.pairedttest

Phylogenetic paired t-test
phyl.resid

Phylogenetic size-correction via GLS regression
phyl.pca

Phylogenetic principal components analysis
phyl.cca

Phylogenetic canonical correlation analysis
phytools-package

phytools: Phylogenetic Tools for comparative biology (and other things)
phylosig

Compute phylogenetic signal with two methods
phylomorphospace3d

Creates three-dimensional phylomorphospace plot
plotSimmap

Plot stochastic character mapped tree
plotThresh

Tree plotting with posterior probabilities of ancestral states from the threshold model
phylomorphospace

Creates phylomorphospace plot
posterior.evolrate

Analysis of the posterior sample from evol.rate.mcmc
plotTree.errorbars

Plot a tree with error bars around divergence dates
print.backbonePhylo

Print method for backbone phylogeny
plotTree.lollipop

Plot a tree with one or more matched lollipop plots
plotTree.datamatrix

Plot a tree with a discrete (or continuous) character data matrix at the tips
pscore

Compute the parsimony score
plotTree.wBars

Plot a tree with bars at the tips
ratebytree

Likelihood test for rate variation among trees, clades, or traits
rep.phylo

Replicate a tree or set of trees
read.newick

Newick or Nexus style tree reader
rateshift

Find the temporal position of one or more rate shifts
rescale.simmap

Rescale object of class "simmap"
reorderSimmap

Reorder edges of a "simmap" tree
rerootingMethod

Get marginal ancestral state reconstructions by re-rooting
rotateNodes

Rotates a node or set of nodes in a phylogenetic tree
sampleFrom

Sample from a set of distributions
roundPhylogram

Plot a round, sigmoidal, or spline phylogram or cladogram
roundBranches

Rounds the branch lengths of a tree
sim.corrs

Multivariate Brownian simulation with multiple correlations and rates
setMap

Set color map for various phylogenetic objects of classes
splitEdgeColor

Split edge colors when descendant edges have different mapped states
strahlerNumber

Computes Strahler number for trees and nodes
threshDIC

Deviance Information Criterion from the threshold model
threshBayes

Threshold model using Bayesian MCMC
splitTree

Split tree at a point
skewers

Matrix comparison using the method of random skewers
write.simmap

Write a stochastic character mapped tree to file
vcvPhylo

Calculates cophenetic (i.e., phylogenetic VCV) matrix
treeSlice

Slices the tree at a particular point and returns all subtrees, or the tree rootward of the point
sim.rates

Brownian or OU simulation with multiple evolutionary regimes
to.matrix

Convert a character vector to a binary matrix
writeAncestors

Write a tree to file with ancestral states and (optionally) CIs at nodes
tree.grow

Creates an animation of a tree growing from left-to-right or upwards
untangle

Attempts to untangle crossing branches for plotting
simBMphylo

Creates a graphical illustration of Brownian motion evolution on a phylogeny
threshState

Computes value for a threshold character from a liability and thresholds
writeNexus

Write a tree to file in Nexus format
anc.Bayes

Bayesian ancestral character estimation
add.species.to.genus

Add species to genus on a phylogeny or bind simulated species subtrees to a backbone genus tree
add.simmap.legend

Add legend to stochastically mapped tree
add.everywhere

Add tip to all edges in a tree
aic.w

Computes Akaike weights
allFurcTrees

Generate all bi- and multifurcating unrooted trees
add.color.bar

Add color bar to a plot
Dtest

Conducts correlational D-test from stochastic mapping
add.random

Add tips at random to the tree
add.arrow

Add an arrow pointing to a tip or node on the tree
applyBranchLengths

Applies the branch lengths of a reference tree to a target
anoletree

Phylogenetic datasets
ancr

Compute marginal or joint ancestral state estimates
ancThresh

Ancestral character estimation under the threshold model using Bayesian MCMC
bd

Convert object of class "birthdeath" to raw birth & death rates
averageTree

Compute an average tree from a set of trees and related operations
bmPlot

Simulates and visualizes continuous trait evolution on a phylogeny
brownieREML

REML version of brownie.lite
cospeciation

Conducts a statistical test of cospeciation between two trees
cophylo

Creates a co-phylogenetic plot
contMap

Map continuous trait evolution on the tree
drop.tip.multiSimmap

Drop or keep tip or tips from an object of class "multiSimmap"
di2multi.simmap

Collapse or resolve polytomies in a tree with a character painted on the edges
drop.tip.contMap

Drop tip or tips from an object of class "contMap" or "densityMap"
fitPagel

Function to test for correlated evolution of binary traits
fitBayes

Evolutionary model fitting with intraspecific variability using Bayesian MCMC
fastAnc

(Reasonably) fast estimation of ML ancestral states
fit.bd

Fits birth-death (speciation/extinction) model to reconstructed phylogeny
force.ultrametric

Coerces a phylogenetic tree to be ultrametric
get.treepos

Get position or node of a plotted tree interactively
fitmultiBM

Fits multi-rate (or multi-trend) discrete character dependent continuous trait evolution
getStates

Get the states at nodes or tips from a mapped tree
linklabels

Function to add tip labels to a plotted tree with linking lines
getSisters

Get the sister node number, label, or set of nodes for a node or tip
locate.fossil

Locate a fossil lineage in a tree using continuous characters
ladderize.simmap

Ladderize a tree with a mapped discrete character
labelnodes

Function to interactively label nodes of a plotted tree
matchNodes

Matches nodes between two trees
map.overlap

Proportional overlap between two mapped character histories on a tree
ltt

Creates lineage-through-time plot (including extinct lineages)
markChanges

Add marked changes to a plotted tree with mapped discrete character
make.simmap

Simulate stochastic character maps on a phylogenetic tree or trees
multiC

Returns a list with phylogenetic VCV matrix for each mapped state
mrp.supertree

Matrix representation parsimony supertree estimation
multi.mantel

Multiple matrix regression (partial Mantel test)
modified.Grafen

Computes modified Grafen edge lengths
minRotate

Rotates all nodes of the tree to minimize the difference in order with a vector
minSplit

Finding the minimum (median) split in the posterior sample
multirateBM

Function to fit a multi-rate Brownian evolution model
optim.phylo.ls

Phylogeny inference using the least squares method
phyl.RMA

Phylogenetic reduced major axis (RMA) regression
orderMappedEdge

Order the columns of mapped.edge to match across trees
nodeHeights

Compute the heights above the root of each node
phylANOVA

Phylogenetic ANOVA and post-hoc tests
phylo.toBackbone

Converts tree to backbone or vice versa
paintSubTree

Paint sub-trees with a discrete character
phylo.impute

Phylogenetic imputation for multivariate continuous character data
plot.backbonePhylo

Plots backbone tree with triangles as clades
phyloDesign

Compute design matrix for least squares analyses
plotBranchbyTrait

Plot branch colors by a quantitative trait or value
plotTree

Plots rooted phylogenetic tree
ratebystate

Method for investigating the rate of one trait as a function of the state of another
posthoc

Generic post-hoc test
read.simmap

Read SIMMAP style trees from file
reorder.backbonePhylo

Reorders a backbone phylogeny
reroot

Re-root a tree along an edge
rescale

Rescale phylogenetic objects of different types
resolveNode

Compute all possible resolutions of a node or all nodes in a multifurcating tree
sim.ratebystate

Conduct simulation of state dependent rate variation
rstate

Pick a random state according to a vector of probabilities
sim.history

Simulate character history or a discrete character at the tips of the tree under some model
starTree

Create star phylogeny
splitplotTree

Plots a phylogeny in two columns