A wrapper for ape:::.reorder_ape
.
Calling this C function directly is approximately twice as fast as using
ape::cladewise
or
ape::postorder
Cladewise(tree, nTip = NULL, edge = tree$edge)ApePostorder(tree, nTip = length(tree$tip.label), edge = tree$edge)
Postorder(tree, force = FALSE)
PostorderEdges(edge)
Pruningwise(tree, nTip = length(tree$tip.label), edge = tree$edge)
Preorder(tree)
A tree of class phylo
.
Integer specifying number of tips (leaves).
(optional) the value of tree$edge
Logical specifying whether to rearrange trees already in postorder, in order to ensure TreeTools edge ordering.
A matrix with two columns, with each row listing the parent and
child node of an edge in a phylogenetic tree. Property edge
of objects
of class phylo
.
A tree of class phylo
with nodes following the specified
numbering scheme.
ApePostorder
: Reorder tree in Postorder using ape's postorder
function, which is robust to unconventional node numbering
Postorder
: Reorder tree in Postorder. Edge lengths are not retained.
PostorderEdges
: Reorder edges in Postorder.
Pruningwise
: Reorder tree Pruningwise
Preorder
: Reorder tree in Preorder (special case of cladewise)
For Cladewise
, Postorder
and Pruningwise
, all nodes must be binary;
ape::collapse.singles and ape::multi2di may help.
Preorder
is more robust: it supports polytomies, nodes can be numbered
in any sequence, and edges can be listed in any order in the input tree.
It has a unique output for each tree topology, allowing unique trees
to be detected by comparing sorted edge matrices alone.
A tree in preorder is numbered starting from the root node. Each node is numbered in the sequence in which it is encountered, and each edge is listed in the sequence in which it is visited.
Child edges of a node are sorted from left to right in order of the smallest descendant tip; i.e. an edge leading to tip 1 will be to the left of an edge leading to a subtree that contains tip 2.
Numbering begins by following the leftmost edge of the root node, and sorting its descendant subtree into preorder. Then, the next edge at the root node is followed, and its descendants sorted into preorder, until each edge has been visited.
Postorder
is modified from the ape function to return a specific
order: edges are listed from the node that subtends the smallest
subtree to the one that subtends the largest (i.e. the root node), with
all of a node's descendant edges listed adjacently. If a tree is already
in postorder, it will not be rearranged unless force = TRUE
, or
PostorderEdges
is employed.
Other C wrappers: Neworder
,
RenumberTree