5 \title{Roots Phylogenetic Trees}
7 root(phy, outgroup, node = NULL, resolve.root = FALSE, interactive = 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.}
18 \item{interactive}{if \code{TRUE} the user is asked to select the node
19 by clicking on the tree which must be plotted.}
22 \code{root} reroots a phylogenetic tree with respect to the specified
23 outgroup or at the node specified in \code{node}.
25 \code{unroot} unroots a phylogenetic tree, or returns it unchanged if
26 it is already unrooted.
28 \code{is.rooted} tests whether a tree is rooted.
31 The argument \code{outgroup} can be either character or numeric. In
32 the first case, it gives the labels of the tips of the new outgroup;
33 in the second case the numbers of these labels in the vector
34 \code{phy$tip.label} are given.
36 If \code{outgroup} is of length one (i.e., a single value), then the
37 tree is rerooted using the node below this tip as the new root.
39 If \code{outgroup} is of length two or more, the most recent common
40 ancestor (MRCA) is used as the new root. Note that the tree is really
41 unrooted before being rerooted, so that if \code{outgroup} is already
42 the outgroup, then the returned tree is not the same than the original
43 one (see examples). If \code{outgroup} is not monophyletic, the
44 operation fails and an error message is issued.
46 If \code{resolve.root = TRUE}, \code{root} adds a zero-length branch
47 below the MRCA of the ingroup.
49 A tree is considered rooted if either only two branches connect to the
50 root, or if there is a \code{root.edge} element. In all other cases,
51 \code{is.rooted} returns \code{FALSE}.
54 an object of class \code{"phylo"} for \code{root} and \code{unroot}; a
55 single logical value for \code{is.rooted}.
57 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
59 \code{\link{bind.tree}}, \code{\link{drop.tip}},
60 \code{\link{nodelabels}}, \code{\link{identify.phylo}}
64 plot(root(bird.orders, 1))
65 plot(root(bird.orders, 1:5))
67 tr <- root(bird.orders, 1)
68 is.rooted(bird.orders) # yes!
70 ### This is because the tree has been unrooted first before rerooting.
71 ### You can delete the outgroup...
72 is.rooted(drop.tip(tr, "Struthioniformes"))
73 ### ... or resolve the basal trichotomy in two ways:
74 is.rooted(multi2di(tr))
75 is.rooted(root(bird.orders, 1, r = TRUE))
76 ### To keep the basal trichotomy but forcing the tree as rooted: