]> git.donarmstrong.com Git - ape.git/blob - man/bind.tree.Rd
f7de459f80f2752d5f8c51f5d479dc6643b6b463
[ape.git] / man / bind.tree.Rd
1 \name{bind.tree}
2 \alias{bind.tree}
3 \alias{+.phylo}
4 \title{Binds Trees}
5 \usage{
6 bind.tree(x, y, where = "root", position = 0, interactive = FALSE)
7 \special{x + y}
8 }
9 \arguments{
10   \item{x}{an object of class \code{"phylo"}.}
11   \item{y}{an object of class \code{"phylo"}.}
12   \item{where}{an integer giving the number of the node or tip of the
13     tree \code{x} where the tree \code{y} is binded (\code{"root"} is a
14     short-cut for the root).}
15   \item{position}{a numeric value giving the position from the tip or
16     node given by \code{node} where the tree \code{y} is binded;
17     negative values are ignored.}
18   \item{interactive}{if \code{TRUE} the user is asked to choose the tip
19     or node of \code{x} by clicking on the tree which must be plotted.}
20 }
21 \description{
22   This function binds together two phylogenetic trees to give a single
23   object of class \code{"phylo"}.
24 }
25 \details{
26   The argument \code{x} can be seen as the receptor tree, whereas
27   \code{y} is the donor tree. The root of \code{y} is then grafted on a
28   location of \code{x} specified by \code{where} and, possibly,
29   \code{position}. If \code{y} has a root edge, this is added as in
30   internal branch in the resulting tree.
31
32   \code{x + y} is a shortcut for:
33
34   \preformatted{
35     bind.tree(x, y, position = if (is.null(x$root.edge)) 0 else
36     x$root.edge)
37   }
38 }
39 \value{
40   an object of class \code{"phylo"}.
41 }
42 \author{Emmanuel Paradis}
43 \seealso{
44   \code{\link{drop.tip}}, \code{\link{root}}
45 }
46 \examples{
47 ### binds the two clades of bird orders
48 cat("((Struthioniformes:21.8,Tinamiformes:21.8):4.1,",
49     "((Craciformes:21.6,Galliformes:21.6):1.3,Anseriformes:22.9):3.0):2.1;",
50     file = "ex1.tre", sep = "\n")
51 cat("(Turniciformes:27.0,(Piciformes:26.3,((Galbuliformes:24.4,",
52     "((Bucerotiformes:20.8,Upupiformes:20.8):2.6,",
53     "(Trogoniformes:22.1,Coraciiformes:22.1):1.3):1.0):0.6,",
54     "(Coliiformes:24.5,(Cuculiformes:23.7,(Psittaciformes:23.1,",
55     "(((Apodiformes:21.3,Trochiliformes:21.3):0.6,",
56     "(Musophagiformes:20.4,Strigiformes:20.4):1.5):0.6,",
57     "((Columbiformes:20.8,(Gruiformes:20.1,Ciconiiformes:20.1):0.7):0.8,",
58     "Passeriformes:21.6):0.9):0.6):0.6):0.8):0.5):1.3):0.7):1.0;",
59     file = "ex2.tre", sep = "\n")
60 tree.bird1 <- read.tree("ex1.tre")
61 tree.bird2 <- read.tree("ex2.tre")
62 unlink(c("ex1.tre", "ex2.tre")) # clean-up
63 (birds <- tree.bird1 + tree.bird2)
64 layout(matrix(c(1, 2, 3, 3), 2, 2))
65 plot(tree.bird1)
66 plot(tree.bird2)
67 plot(birds)
68
69 ### examples with random trees
70 x <- rtree(4, tip.label = LETTERS[1:4])
71 y <- rtree(4, tip.label = LETTERS[5:8])
72 x <- makeNodeLabel(x, prefix = "x_")
73 y <- makeNodeLabel(y, prefix = "y_")
74 x$root.edge <- y$root.edge <- .2
75
76 z <- bind.tree(x, y, po=.2)
77 plot(y, show.node.label = TRUE, font = 1, root.edge = TRUE)
78 title("y")
79 plot(x, show.node.label = TRUE, font = 1, root.edge = TRUE)
80 title("x")
81 plot(z, show.node.label = TRUE, font = 1, root.edge = TRUE)
82 title("z <- bind.tree(x, y, po=.2)")
83
84 z <- bind.tree(x, y, 2, .1)
85 plot(y, show.node.label = TRUE, font = 1, root.edge = TRUE)
86 title("y")
87 plot(x, show.node.label = TRUE, font = 1, root.edge = TRUE)
88 title("x")
89 plot(z, show.node.label = TRUE, font = 1, root.edge = TRUE)
90 title("z <- bind.tree(x, y, 2, .1)")
91
92 x <- rtree(50)
93 y <- rtree(50)
94 x$root.edge <- y$root.edge <- .2
95 z <- x + y
96 plot(y, show.tip.label = FALSE, root.edge = TRUE); axisPhylo()
97 title("y")
98 plot(x, show.tip.label = FALSE, root.edge = TRUE); axisPhylo()
99 title("x")
100 plot(z, show.tip.label = FALSE, root.edge = TRUE); axisPhylo()
101 title("z <- x + y")
102 layout(1)
103 }
104 \keyword{manip}