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