5 \title{Roots Phylogenetic Trees}
7 root(phy, outgroup, node = NULL, resolve.root = FALSE)
12 \item{phy}{an object of class \code{"phylo"}.}
13 \item{outgroup}{a vector of mode numeric or character specifying the
15 \item{node}{alternatively, a node number where to root the tree.}
16 \item{resolve.root}{a logical specifying whether to resolve the new
17 root as a bifurcating node.}
20 \code{root} reroots a phylogenetic tree with respect to the specified
21 outgroup or at the node specified in \code{node}.
23 \code{unroot} unroots a phylogenetic tree, or returns it unchanged if
24 it is already unrooted.
26 \code{is.rooted} tests whether a tree is rooted.
29 The argument \code{outgroup} can be either character or numeric. In
30 the first case, it gives the labels of the tips of the new outgroup;
31 in the second case the numbers of these labels in the vector
32 \code{phy$tip.label} are given.
34 If \code{outgroup} is of length one (i.e., a single value), then the
35 tree is rerooted using the node below this tip as the new root.
37 If \code{outgroup} is of length two or more, the most recent common
38 ancestor (MRCA) is used as the new root. Note that the tree is really
39 unrooted before being rerooted, so that if \code{outgroup} is already
40 the outgroup, then the returned tree is not the same than the original
41 one (see examples). If \code{outgroup} is not monophyletic, the
42 operation fails and an error message is issued.
44 If \code{resolve.root = TRUE}, \code{root} adds a zero-length branch
45 below the MRCA of the ingroup.
47 A tree is considered rooted if either only two branches connect to the
48 root, or if there is a \code{root.edge} element. In all other cases,
49 \code{is.rooted} returns \code{FALSE}.
52 an object of class \code{"phylo"} for \code{root} and \code{unroot}; a
53 single logical value for \code{is.rooted}.
55 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
57 \code{\link{bind.tree}}, \code{\link{drop.tip}},
58 \code{\link{nodelabels}}, \code{\link{identify.phylo}}
62 plot(root(bird.orders, 1))
63 plot(root(bird.orders, 1:5))
65 tr <- root(bird.orders, 1)
66 is.rooted(bird.orders) # yes!
68 ### This is because the tree has been unrooted first before rerooting.
69 ### You can delete the outgroup...
70 is.rooted(drop.tip(tr, "Struthioniformes"))
71 ### ... or resolve the basal trichotomy in two ways:
72 is.rooted(multi2di(tr))
73 is.rooted(root(bird.orders, 1, r = TRUE))
74 ### To keep the basal trichotomy but forcing the tree as rooted: