5 \title{Generates Random Trees}
7 These functions generate trees by splitting randomly the edges
8 (\code{rtree}) or randomly clustering the tips (\code{rcoal}).
9 \code{rtree} generates general trees, and \code{rcoal} generates
10 coalescent trees. The algorithms are described in Paradis (2012).
13 rtree(n, rooted = TRUE, tip.label = NULL, br = runif, ...)
14 rcoal(n, tip.label = NULL, br = "coalescent", ...)
15 rmtree(N, n, rooted = TRUE, tip.label = NULL, br = runif, ...)
18 \item{n}{an integer giving the number of tips in the tree.}
19 \item{rooted}{a logical indicating whether the tree should be rooted
21 \item{tip.label}{a character vector giving the tip labels; if not
22 specified, the tips "t1", "t2", ..., are given.}
23 \item{br}{one of the following: (i) an \R function used to generate the
24 branch lengths (\code{rtree}; use \code{NULL} to simulate only a
25 topology), or the coalescence times (\code{rcoal}); (ii) a character
26 to simulate a genuine coalescent tree for \code{rcoal} (the
27 default); or (iii) a numeric vector for the branch lengths or the
29 \item{\dots}{further argument(s) to be passed to \code{br}.}
30 \item{N}{an integer giving the number of trees to generate.}
33 The trees generated are bifurcating. If \code{rooted = FALSE} in
34 (\code{rtree}), the tree is trifurcating at its root.
36 The default function to generate branch lengths in \code{rtree} is
37 \code{runif}. If further arguments are passed to \code{br}, they need
38 to be tagged (e.g., \code{min = 0, max = 10}).
40 \code{rmtree} calls successively \code{rtree} and set the class of
41 the returned object appropriately.
44 An object of class \code{"phylo"} or of class \code{"multiPhylo"} in
45 the case of \code{rmtree}.
48 Paradis, E. (2012) \emph{Analysis of Phylogenetics and Evolution with
49 R (Second Edition).} New York: Springer.
51 \author{Emmanuel Paradis}
53 \code{\link{stree}}, \code{\link{rlineage}}
56 layout(matrix(1:9, 3, 3))
57 ### Nine random trees:
58 for (i in 1:9) plot(rtree(20))
59 ### Nine random cladograms:
60 for (i in 1:9) plot(rtree(20, FALSE), type = "c")
61 ### generate 4 random trees of bird orders:
63 layout(matrix(1:4, 2, 2))
65 plot(rcoal(23, tip.label = bird.orders$tip.label), no.margin = TRUE)