]> git.donarmstrong.com Git - ape.git/blob - man/rtree.Rd
05a1fbea45e92ddd4bf67263fd44fa828de8dd14
[ape.git] / man / rtree.Rd
1 \name{rtree}
2 \alias{rtree}
3 \alias{rcoal}
4 \alias{rmtree}
5 \title{Generates Random Trees}
6 \usage{
7 rtree(n, rooted = TRUE, tip.label = NULL, br = runif, ...)
8 rcoal(n, tip.label = NULL, br = "coalescent", ...)
9 rmtree(N, n, rooted = TRUE, tip.label = NULL, br = runif, ...)
10 }
11 \arguments{
12   \item{n}{an integer giving the number of tips in the tree.}
13   \item{rooted}{a logical indicating whether the tree should be rooted
14     (the default).}
15   \item{tip.label}{a character vector giving the tip labels; if not
16     specified, the tips "t1", "t2", ..., are given.}
17   \item{br}{one of the following: (i) an R function used to generate the
18     branch lengths (\code{rtree}; use \code{NULL} to simulate only a
19     topology), or the coalescence times (\code{rcoal}); (ii) a character
20     to simulate a genuine coalescent tree for \code{rcoal} (the
21     default); or (iii) a numeric vector for the branch lengths or the
22     coalescence times.}
23   \item{\dots}{further argument(s) to be passed to \code{br}.}
24   \item{N}{an integer giving the number of trees to generate.}
25 }
26 \description{
27   These functions generate trees by splitting randomly the edges
28   (\code{rtree}) or randomly clustering the tips (\code{rcoal}).
29   \code{rtree} generates general (non-ultrametric) trees, and
30   \code{rcoal} generates coalescent (ultrametric) trees.
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 \author{Emmanuel Paradis}
48 \seealso{
49   \code{\link{stree}}
50 }
51 \examples{
52 layout(matrix(1:9, 3, 3))
53 ### Nine random trees:
54 for (i in 1:9) plot(rtree(20))
55 ### Nine random cladograms:
56 for (i in 1:9) plot(rtree(20, FALSE), type = "c")
57 ### generate 4 random trees of bird orders:
58 data(bird.orders)
59 layout(matrix(1:4, 2, 2))
60 for (i in 1:4)
61   plot(rcoal(23, tip.label = bird.orders$tip.label), no.margin = TRUE)
62 layout(matrix(1))
63 }
64 \keyword{datagen}