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

reorder-methods

reordering trees within phylobase objects


Description

Methods for reordering trees into various traversal orders

Usage

reorder(x, ...)

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

Arguments

x

a phylo4 or phylo4d object

...

additional optional elements (not in use)

order

The desired traversal order; currently only “preorder” and “postorder” are allowed for phylo4 and phylo4d 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.

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.

Note

The preorder parameter corresponds to cladewise in the ape package, and postorder corresponds (almost) to pruningwise.

Author(s)

Peter Cowan, Jim Regetz

See Also

Examples

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

phylobase

Base Package for Phylogenetic Structures and Comparative Data

v0.8.10
GPL (>= 2)
Authors
R Hackathon et al. (alphabetically: Ben Bolker, Marguerite Butler, Peter Cowan, Damien de Vienne, Dirk Eddelbuettel, Mark Holder, Thibaut Jombart, Steve Kembel, Francois Michonneau, David Orme, Brian O'Meara, Emmanuel Paradis, Jim Regetz, Derrick Zwickl)
Initial release

We don't support your browser anymore

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