]> git.donarmstrong.com Git - ape.git/blob - man/rtree.Rd
some small changes
[ape.git] / man / rtree.Rd
1 \name{rtree}
2 \alias{rtree}
3 \alias{rcoal}
4 \alias{rmtree}
5 \title{Generates Random Trees}
6 \description{
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).
11 }
12 \usage{
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, ...)
16 }
17 \arguments{
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
20     (the default).}
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
28     coalescence times.}
29   \item{\dots}{further argument(s) to be passed to \code{br}.}
30   \item{N}{an integer giving the number of trees to generate.}
31 }
32 \details{
33   The trees generated are bifurcating. If \code{rooted = FALSE} in
34   (\code{rtree}), the tree is trifurcating at its root.
35
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}).
39
40   \code{rmtree} calls successively \code{rtree} and set the class of
41   the returned object appropriately.
42 }
43 \value{
44   An object of class \code{"phylo"} or of class \code{"multiPhylo"} in
45   the case of \code{rmtree}.
46 }
47 \references{
48   Paradis, E. (2012) \emph{Analysis of Phylogenetics and Evolution with
49     R (Second Edition).} New York: Springer.
50 }
51 \author{Emmanuel Paradis}
52 \seealso{
53   \code{\link{stree}}, \code{\link{rlineage}}
54 }
55 \examples{
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:
62 data(bird.orders)
63 layout(matrix(1:4, 2, 2))
64 for (i in 1:4)
65   plot(rcoal(23, tip.label = bird.orders$tip.label), no.margin = TRUE)
66 layout(matrix(1))
67 }
68 \keyword{datagen}