root

0th

Percentile

Roots Phylogenetic Trees

root reroots a phylogenetic tree with respect to the specified outgroup or at the node specified in node.

unroot unroots a phylogenetic tree, or returns it unchanged if it is already unrooted.

is.rooted tests whether a tree is rooted.

Keywords
manip
Usage
root(phy, outgroup, node = NULL, resolve.root = FALSE, interactive = FALSE)
unroot(phy)
is.rooted(phy)
Arguments
phy
an object of class "phylo".
outgroup
a vector of mode numeric or character specifying the new outgroup.
node
alternatively, a node number where to root the tree (this should give the MRCA of the ingroup).
resolve.root
a logical specifying whether to resolve the new root as a bifurcating node.
interactive
if TRUE the user is asked to select the node by clicking on the tree which must be plotted.
Details

The argument outgroup can be either character or numeric. In the first case, it gives the labels of the tips of the new outgroup; in the second case the numbers of these labels in the vector phy$tip.label are given.

If outgroup is of length one (i.e., a single value), then the tree is rerooted using the node below this tip as the new root.

If outgroup is of length two or more, the most recent common ancestor (MRCA) of the ingroup is used as the new root. Note that the tree is unrooted before being rerooted, so that if outgroup is already the outgroup, then the returned tree is not the same than the original one (see examples). If outgroup is not monophyletic, the operation fails and an error message is issued.

If resolve.root = TRUE, root adds a zero-length branch below the MRCA of the ingroup.

A tree is considered rooted if either only two branches connect to the root, or if there is a root.edge element. In all other cases, is.rooted returns FALSE.

Value

  • an object of class "phylo" for root and unroot; a single logical value for is.rooted.

See Also

bind.tree, drop.tip, nodelabels, identify.phylo

Aliases
  • root
  • unroot
  • is.rooted
Examples
data(bird.orders)
plot(root(bird.orders, 1))
plot(root(bird.orders, 1:5))

tr <- root(bird.orders, 1)
is.rooted(bird.orders) # yes!
is.rooted(tr)          # no!
### This is because the tree has been unrooted first before rerooting.
### You can delete the outgroup...
is.rooted(drop.tip(tr, "Struthioniformes"))
### ... or resolve the basal trichotomy in two ways:
is.rooted(multi2di(tr))
is.rooted(root(bird.orders, 1, r = TRUE))
### To keep the basal trichotomy but forcing the tree as rooted:
tr$root.edge <- 0
is.rooted(tr)
Documentation reproduced from package ape, version 2.7-3, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.