Learn R Programming

TreeTools (version 1.15.0)

Create, Modify and Analyse Phylogenetic Trees

Description

Efficient implementations of functions for the creation, modification and analysis of phylogenetic trees. Applications include: generation of trees with specified shapes; tree rearrangement; analysis of tree shape; rooting of trees and extraction of subtrees; calculation and depiction of split support; plotting the position of rogue taxa (Klopfstein & Spasojevic 2019) ; calculation of ancestor-descendant relationships, of 'stemwardness' (Asher & Smith, 2022) , and of tree balance (Mir et al. 2013, Lemant et al. 2022) , ; artificial extinction (Asher & Smith, 2022) ; import and export of trees from Newick, Nexus (Maddison et al. 1997) , and TNT formats; and analysis of splits and cladistic information.

Copy Link

Version

Install

install.packages('TreeTools')

Monthly Downloads

1,996

Version

1.15.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Martin R. Smith

Last Published

July 21st, 2025

Functions in TreeTools (1.15.0)

KeptVerts

Identify vertices retained when leaves are dropped
LabelSplits

Label splits
Hamming

Hamming distance between taxa in a phylogenetic dataset
KeptPaths

Paths present in reduced tree
J1Index

Robust universal tree balance index
EndSentence

Add full stop to end of a sentence
DropTip

Drop leaves from tree
EnforceOutgroup

Generate a tree with a specified outgroup
MorphoBankDecode

Decode MorphoBank text
MatrixToPhyDat

Convert between matrices and phyDat objects
Consensus

Construct consensus trees
MatchStrings

Check for mismatch between character vectors
MatchEdges

Match nodes and edges between trees
ExtractTaxa

Extract taxa from a matrix block
GenerateTree

Generate pectinate, balanced or random trees
NTip

Number of leaves in a phylogenetic tree
MakeTreeBinary

Generate binary tree by collapsing polytomies
MSTEdges

Minimum spanning tree
NewickTree

Write Newick Tree
NodeDepth

Distance of each node from tree exterior
Neworder

Reorder edges of a phylogenetic tree
N1Spr

Number of trees one SPR step away
ReadTntTree

Parse TNT Tree
Renumber

Renumber a tree's nodes and tips
ImposeConstraint

Force a tree to match a constraint
StringToPhyDat

Convert between strings and phyDat objects
PolarizeSplits

Polarize splits on a single taxon
Lobo.data

Data from Zhang et al. 2016
ReadMrBayesTrees

Read posterior tree sample produced by MrBayes
NPartitionPairs

Distributions of tips consistent with a partition pair
ReadCharacters

Read phylogenetic characters from file
MRCA

Most recent common ancestor
NJTree

Generate a neighbour joining tree
SortTree

Sort tree
RenumberTree

Reorder tree edges and nodes
NDescendants

Count descendants for each node in a tree
RenumberTips

Renumber a tree's tips
PathLengths

Calculate length of paths between each pair of vertices within tree
PairwiseDistances

Distances between each pair of trees
SpectrumLegend

Produce a legend for continuous gradient scales
SampleOne

Select element at random
RootTree

Root or unroot a phylogenetic tree
SplitFrequency

Frequency of splits
RightmostCharacter

Rightmost character of string
SplitInformation

Phylogenetic information content of splitting leaves into two partitions
Reweight

Reweight phylogenetic characters
Splits

Convert object to Splits
SplitMatchProbability

Probability of matching this well
RoguePlot

Visualize position of rogue taxa
SplitsInBinaryTree

Maximum splits in an n-leaf tree
RootNode

Which node is a tree's root?
Stemwardness

"Stemwardness" of a leaf
NodeOrder

Number of edges incident to each node in a tree
NRooted

Number of trees
TipTimedTree

Display time-calibrated tree using tip information only
SupportColour

Colour for node support value
LeafLabelInterchange

Leaf label interchange
NodeNumbers

Numeric index of each node in a tree NodeNumbers() returns a sequence corresponding to the nodes in a tree
ListAncestors

List ancestors
Subsplit

Subset of a split on fewer leaves
NSplits

Number of distinct splits
as.Newick

Write a phylogenetic tree in Newick format
as.multiPhylo

Convert object to multiPhylo class
TotalCopheneticIndex

Total Cophenetic Index
TopologyOnly

Remove metadata from trees
TipsInSplits

Tips contained within splits
TreeTools-package

TreeTools
WriteTntCharacters

Write morphological character matrix to TNT file
TipLabels

Extract tip labels
UnshiftTree

Add tree to start of list
unrootedKeys

Integer representing shape of a tree
sapply64

Apply a function that returns 64-bit integers over a list or vector
root_on_node

Wrapper for internal C function root_on_node()
match,Splits,Splits-method

Split matching
Unquote

Remove quotation marks from a string
UnrootedTreesMatchingSplit

Number of trees consistent with split
is.TreeNumber

Is an object a TreeNumber object?
logDoubleFactorials

Natural logarithms of double factorials
Subtree

Extract a subtree
TreesMatchingSplit

Number of trees matching a bipartition split
TreesMatchingTree

Number of trees containing a tree
print.TreeNumber

Print TreeNumber object
nRootedShapes

Number of rooted / unrooted tree shapes
sort.multiPhylo

Sort a list of phylogenetic trees
TreeIsRooted

Is tree rooted?
TreeNumber

Unique integer indices for bifurcating tree topologies
TrivialSplits

Identify and remove trivial splits
doubleFactorials

Double factorials
xor

Exclusive OR operation
TrivialTree

Generate trivial trees
edge_to_splits

Efficiently convert edge matrix to splits
match,phylo,phylo-method

Tree matching
brewer

Brewer palettes
.RandomParent

Random parent vector
ClusterTable

Convert phylogenetic tree to ClusterTable
CollapseNode

Collapse nodes on a phylogenetic tree
ApeTime

Read modification time from "ape" Nexus file
ArtificialExtinction

Artificial Extinction
EdgeAncestry

Ancestors of an edge
CompatibleSplits

Which splits are compatible?
EdgeDistances

Distance between edges
CladisticInfo

Cladistic information content of a tree
ClusterTable-methods

S3 methods for ClusterTable objects
CladeSizes

Clade sizes
CharacterInformation

Character information content
AncestorEdge

Ancestral edge
AddTip

Add a tip to a phylogenetic tree
Decompose

Decompose additive (ordered) phylogenetic characters
DoubleFactorial

Double factorial
DescendantEdges

Identify descendant edges
ConsensusWithout

Reduced consensus, omitting specified taxa
ConstrainedNJ

Constrained neighbour-joining tree