]> git.donarmstrong.com Git - ape.git/blob - man/drop.tip.Rd
small changed in add.scale.bar
[ape.git] / man / drop.tip.Rd
1 \name{drop.tip}
2 \alias{drop.tip}
3 \alias{extract.clade}
4 \title{Remove Tips in a Phylogenetic Tree}
5 \usage{
6 drop.tip(phy, tip, trim.internal = TRUE, subtree = FALSE,
7          root.edge = 0, rooted = is.rooted(phy))
8 extract.clade(phy, node, root.edge = 0)
9 }
10 \arguments{
11   \item{phy}{an object of class \code{"phylo"}.}
12   \item{tip}{a vector of mode numeric or character specifying the tips
13     to delete.}
14   \item{trim.internal}{a logical specifying whether to delete the
15     corresponding internal branches.}
16   \item{subtree}{a logical specifying whether to output in the tree how
17     many tips have been deleted and where.}
18   \item{root.edge}{an integer giving the number of internal branches to
19     be used to build the new root edge. This has no effect if
20     \code{trim.internal = FALSE}.}
21   \item{rooted}{a logical indicated whether the tree must be treated as
22     rooted or not. This allows to force the tree to be considered as
23     unrooted (see examples).}
24   \item{node}{a node number or label.}
25 }
26 \description{
27   \code{drop.tip} removes the terminal branches of a phylogenetic tree,
28   possibly removing the corresponding internal branches.
29
30   \code{extract.clade} does the inverse operation: it keeps all the tips
31   from a given node, and deletes all the other tips.
32 }
33 \details{
34   The argument \code{tip} can be either character or numeric. In the
35   first case, it gives the labels of the tips to be deleted; in the
36   second case the numbers of these labels in the vector
37   \code{phy$tip.label} are given.
38
39   This also applies to \code{node}, but if this argument is character
40   and the tree has no node label, this results in an error. If more than
41   one value is given with \code{node} (i.e., a vector of length two or
42   more), only the first one is used with a warning.
43
44   If \code{trim.internal = FALSE}, the new tips are given \code{"NA"} as
45   labels, unless there are node labels in the tree in which case they
46   are used.
47
48   If \code{subtree = TRUE}, the returned tree has one or several
49   terminal branches indicating how many tips have been removed (with a
50   label \code{"[x_tips]"}). This is done for as many monophyletic groups
51   that have been deleted.
52
53   Note that \code{subtree = TRUE} implies \code{trim.internal = TRUE}.
54
55   To undestand how the option \code{root.edge} works, see the examples
56   below.
57 }
58 \value{
59   an object of class \code{"phylo"}.
60 }
61 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
62 \seealso{
63   \code{\link{bind.tree}}, \code{\link{root}}
64 }
65 \examples{
66 data(bird.families)
67 tip <- c(
68 "Eopsaltriidae", "Acanthisittidae", "Pittidae", "Eurylaimidae",
69 "Philepittidae", "Tyrannidae", "Thamnophilidae", "Furnariidae",
70 "Formicariidae", "Conopophagidae", "Rhinocryptidae", "Climacteridae",
71 "Menuridae", "Ptilonorhynchidae", "Maluridae", "Meliphagidae",
72 "Pardalotidae", "Petroicidae", "Irenidae", "Orthonychidae",
73 "Pomatostomidae", "Laniidae", "Vireonidae", "Corvidae",
74 "Callaeatidae", "Picathartidae", "Bombycillidae", "Cinclidae",
75 "Muscicapidae", "Sturnidae", "Sittidae", "Certhiidae",
76 "Paridae", "Aegithalidae", "Hirundinidae", "Regulidae",
77 "Pycnonotidae", "Hypocoliidae", "Cisticolidae", "Zosteropidae",
78 "Sylviidae", "Alaudidae", "Nectariniidae", "Melanocharitidae",
79 "Paramythiidae","Passeridae", "Fringillidae")
80 plot(drop.tip(bird.families, tip))
81 plot(drop.tip(bird.families, tip, trim.internal = FALSE))
82 data(bird.orders)
83 plot(drop.tip(bird.orders, 6:23, subtree = TRUE))
84 plot(drop.tip(bird.orders, c(1:5, 20:23), subtree = TRUE))
85 plot(drop.tip(bird.orders, c(1:20, 23), subtree = TRUE))
86 plot(drop.tip(bird.orders, c(1:20, 23), subtree = TRUE, rooted = FALSE))
87 ### Examples of the use of `root.edge'
88 tr <- read.tree(text = "(A:1,(B:1,(C:1,(D:1,E:1):1):1):1):1;")
89 drop.tip(tr, c("A", "B"), root.edge = 0) # = (C:1,(D:1,E:1):1);
90 drop.tip(tr, c("A", "B"), root.edge = 1) # = (C:1,(D:1,E:1):1):1;
91 drop.tip(tr, c("A", "B"), root.edge = 2) # = (C:1,(D:1,E:1):1):2;
92 drop.tip(tr, c("A", "B"), root.edge = 3) # = (C:1,(D:1,E:1):1):3;
93 }
94 \keyword{manip}