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