reorder-methods {phylobase}R Documentation

reordering trees within phylobase objects

Description

Methods for reordering trees into various traversal orders

Usage

## S4 method for signature 'phylo':
reorder(x, order = "cladewise")
## S4 method for signature 'phylo4':
reorder(x, order = c("preorder", "postorder"))

Arguments

x a phylo4 or phylo4d object
order The desired traversal order; currently only 'preorder' and 'postorder' are allowed for phylo4 and phylo4d objects, whereas only 'cladewise' and 'pruningwise' are allowed for phylo objects

Details

The reorder method takes a phylo4 or phylo4d tree and orders the edge matrix (i.e. edges(x)) in the requested traversal order. Currently only two orderings are permitted, and both require rooted trees. In "postorder", a node's descendants come before that node, thus the root, which is ancestral to all nodes, comes last. In "preorder", a node is visited before its descendants, thus the root comes first.

A method is also defined that takes an ape phylo object. This also takes an order argument, however, 'pruningwise' and 'cladewise' are the only acceptable parameters. This is because this method actually uses the ape reorder() command to complete the ordering.

Value

A phylo4 or phylo4d object with the edge, label, length and data slots ordered as order, which is itself recorded in the order slot.

Methods

x = "phylo"
reorders a phylo object
x = "phylo4"
reorders a phylo4 object
x = "phylo4d"
reorders a phylo4d object

Note

The "preorder" parameter corresponds to "cladewise" in the ape package, and "postorder" corresponds (almost but close enough?) to "pruningwise".

See http://ape.mpl.ird.fr/misc/FormatTreeR_28July2008.pdf

Author(s)

Peter Cowan, Jim Regetz

See Also

reorder.phylo in the ape package. ancestors ancestor siblings children descendants

Examples

phy <- phylo4(rtree(5))
edges(reorder(phy, "preorder"))
edges(reorder(phy, "postorder"))

[Package phylobase version 0.5 Index]