Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

SortTree

Sort tree


Description

SortTree() sorts each node into a consistent order, so that node rotation does not obscure similarities between similar trees.

Usage

SortTree(tree)

## S3 method for class 'phylo'
SortTree(tree)

## S3 method for class 'list'
SortTree(tree)

## S3 method for class 'multiPhylo'
SortTree(tree)

Arguments

tree

One or more trees of class phylo, optionally as a list or a multiPhylo object.

Details

At each node, clades will be listed in tree$edge in decreasing size order.

Clades that contain the same number of leaves are sorted in decreasing order of minimum leaf number, so (2, 3) will occur before (1, 4).

As trees are plotted from 'bottom up', the largest clades will 'sink' to the bottom of a plotted tree.

tree must (presently) be binary (#25).

Value

SortTree() returns tree in the format of tree, with each node in each tree sorted such that the larger clade is first.

Author(s)

Martin R. Smith (martin.smith@durham.ac.uk)

See Also

Preorder() also rearranges trees into a consistent shape, but based on the index of leaves rather than the size of subtrees.

Examples

messyTree <- as.phylo(10, 6)
plot(messyTree)

sorted <- SortTree(messyTree)
plot(sorted)
ape::nodelabels()
ape::edgelabels()

TreeTools

Create, Modify and Analyse Phylogenetic Trees

v1.4.4
GPL (>= 3)
Authors
Martin R. Smith [aut, cre, cph] (<https://orcid.org/0000-0001-5660-1727>), Emmanuel Paradis [cph] (<https://orcid.org/0000-0003-3092-2199>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.