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