| fixNodes | R Documentation |
(Re-)establishes the standard numbering of terminal and internal
nodes in phylogenies represented as objects of class phylo.
fixNodes(phy)
phy |
An object of class |
Internal and terminal nodes of phylo objects have a standard,
"canonical" node numbering. It consists of the following rules:
Number tip nodes from left/bottom to right/top by 1 to ntip()
Number internal nodes by preorder traversal (see Examples) consecutively
from ntip() + 1 to nnode() + 1
When reading phylogenetic trees from a NEXUS file that contains a
translate section, it can happen that the terminal nodes (tips,
leaves) of the corresponding phylo object are not numbered
consecutively, which can be a problem in some downstream applications. You
can use fixNodes to get the correct order of terminal node numbers.
fixNodes is also intended to re-establish the standard numbering of
internal nodes and reorder all node value elements (e.g. node.label,
posterior, ...) if a phylo object has been modified by
either root, ladderize, or
rotate.
An object of class phylo.
read.tree, read.nexus,
read.beast for reading trees in NEWICK and NEXUS format;
ladderize and rotate for tree
manipulation; node.support for plotting node support values has been
moved to package viper.
non-standard node elements in class phylo.
set.seed(9999)
# Create random topology with random node numbering
phy1 <- rtopology(10)
# Impose 'canonical' node numbering
phy2 <- fixNodes(phy1)
# Compare node numbering schemes
op = par(no.readonly = TRUE)
par(mfcol = c(1, 2), mar = c(0, 0, 3, 0))
plot(phy1, use.edge.length = FALSE, show.tip.label = FALSE)
nodelabels(); tiplabels()
title("random node numbers")
plot(phy2, use.edge.length = FALSE, show.tip.label = FALSE)
nodelabels(); tiplabels()
title("preorder traversal of internal nodes")
par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.