
Last chance! 50% off unlimited learning
Sale ends in
root
reroots a phylogenetic tree with respect to the specified
outgroup. unroot
unroots a phylogenetic tree, or returns it unchanged if
it is already unrooted.
is.rooted
tests whether a tree is rooted.
root(phy, outgroup)
unroot(phy)
is.rooted(phy)
"phylo"
."phylo"
for root
and unroot
; a
logical for is.rooted
.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) is used as the new root. Note that the tree is really
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.
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
.
bind.tree
, drop.tip
, rotate
data(bird.orders)
plot(root(bird.orders, 1))
plot(root(bird.orders, 1:5))
is.rooted(bird.orders) # yes!
is.rooted(root(bird.orders, 1)) # no!
### This is because the tree has been unrooted first before re-rooting.
### You can delete the outgroup...
is.rooted(drop.tip(root(bird.orders, 1), "Struthioniformes"))
### ... or resolve the basal trichotomy:
is.rooted(multi2di(root(bird.orders, 1)))
### To keep the basal trichotomy but forcing the tree as rooted:
tr <- root(bird.orders, 1)
tr$root.edge <- 0
is.rooted(tr)
Run the code above in your browser using DataLab