]> git.donarmstrong.com Git - ape.git/blob - man/root.Rd
current 2.1 release
[ape.git] / man / root.Rd
1 \name{root}
2 \alias{root}
3 \alias{unroot}
4 \alias{is.rooted}
5 \title{Roots Phylogenetic Trees}
6 \usage{
7 root(phy, outgroup)
8 unroot(phy)
9 is.rooted(phy)
10 }
11 \arguments{
12   \item{phy}{an object of class \code{"phylo"}.}
13   \item{outgroup}{a vector of mode numeric or character specifying the
14     new outgroup.}
15 }
16 \description{
17   \code{root} reroots a phylogenetic tree with respect to the specified
18   outgroup.
19
20   \code{unroot} unroots a phylogenetic tree, or returns it unchanged if
21   it is already unrooted.
22
23   \code{is.rooted} tests whether a tree is rooted.
24 }
25 \details{
26   The argument \code{outgroup} can be either character or numeric. In
27   the first case, it gives the labels of the tips of the new outgroup;
28   in the second case the numbers of these labels in the vector
29   \code{phy$tip.label} are given.
30
31   If \code{outgroup} is of length one (i.e., a single value), then the
32   tree is rerooted using the node below this tip as the new root.
33
34   If \code{outgroup} is of length two or more, the most recent common
35   ancestor (MRCA) is used as the new root. Note that the tree is really
36   unrooted before being rerooted, so that if \code{outgroup} is already
37   the outgroup, then the returned tree is not the same than the original
38   one (see examples). If \code{outgroup} is not monophyletic, the
39   operation fails and an error message is issued.
40
41   A tree is considered rooted if either only two branches connect to the
42   root, or if there is a \code{root.edge} element. In all other cases,
43   \code{is.rooted} returns \code{FALSE}.
44 }
45 \value{
46   an object of class \code{"phylo"} for \code{root} and \code{unroot}; a
47   single logical value for \code{is.rooted}.
48 }
49 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
50 \seealso{
51   \code{\link{bind.tree}}, \code{\link{drop.tip}}
52 }
53 \examples{
54 data(bird.orders)
55 plot(root(bird.orders, 1))
56 plot(root(bird.orders, 1:5))
57
58 tr <- root(bird.orders, 1)
59 is.rooted(bird.orders) # yes!
60 is.rooted(tr)          # no!
61 ### This is because the tree has been unrooted first before rerooting.
62 ### You can delete the outgroup...
63 is.rooted(drop.tip(tr, "Struthioniformes"))
64 ### ... or resolve the basal trichotomy:
65 is.rooted(multi2di(tr))
66 ### To keep the basal trichotomy but forcing the tree as rooted:
67 tr$root.edge <- 0
68 is.rooted(tr)
69 }
70 \keyword{manip}