6 bind.tree(x, y, where = "root", position = 0, interactive = FALSE)
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.}
22 This function binds together two phylogenetic trees to give a single
23 object of class \code{"phylo"}.
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.
32 \code{x + y} is a shortcut for:
35 bind.tree(x, y, position = if (is.null(x$root.edge)) 0 else
40 an object of class \code{"phylo"}.
42 \author{Emmanuel Paradis}
44 \code{\link{drop.tip}}, \code{\link{root}}
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))
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
76 z <- bind.tree(x, y, po=.2)
77 plot(y, show.node.label = TRUE, font = 1, root.edge = TRUE)
79 plot(x, show.node.label = TRUE, font = 1, root.edge = TRUE)
81 plot(z, show.node.label = TRUE, font = 1, root.edge = TRUE)
82 title("z <- bind.tree(x, y, po=.2)")
84 z <- bind.tree(x, y, 2, .1)
85 plot(y, show.node.label = TRUE, font = 1, root.edge = TRUE)
87 plot(x, show.node.label = TRUE, font = 1, root.edge = TRUE)
89 plot(z, show.node.label = TRUE, font = 1, root.edge = TRUE)
90 title("z <- bind.tree(x, y, 2, .1)")
94 x$root.edge <- y$root.edge <- .2
96 plot(y, show.tip.label = FALSE, root.edge = TRUE); axisPhylo()
98 plot(x, show.tip.label = FALSE, root.edge = TRUE); axisPhylo()
100 plot(z, show.tip.label = FALSE, root.edge = TRUE); axisPhylo()