rtreeshape {apTreeshape} R Documentation

## Generate a list of random binary trees according to a given model

### Description

This function generates a tree or a list of trees of class `"treeshape"` according to the Yule, PDA, Biased models. Speciation-specified models are also allowed.

### Usage

```rtreeshape(n, tip.number, p = 0.3, model="", FUN="")
```

### Arguments

 `n` The number of trees to generate. `tip.number` The number of tips of the trees to generate. Can be a vector. `p` Only used when `model="biased"`. It represents the bias factor of the tree to generate. `model` A character string equals to `"yule"`, `"pda"`, `"aldous"` or `"biased"`. `FUN` A two variables (`n` and `i`) function.

### Details

The `"FUN"` and `"model"` arguments cannot be specified at the same time. An error will be returned if both arguments are specified.

If `tip.number` is a vector, `n` trees will be generated for each size contained by `tip.number`

`Q` enables you to build trees of class `"treeshape"` according to the Markov branching model described by D. Aldous. `Qn(i)` is the probability that the left daughter clade of an internal node with `n` descendents contains `i` tips. The `Qn(i)` need not sum to one. Still, be carefull when you specify this distribution: computational errors may occur for complicated distributions and/or large trees.

The Yule model, also known as Markov model, can be described as follows. At any time, all the extant branches have the same probability to split into two subspecies.
The PDA model (Proportional to Distinguishable Arrangements) is not a model of growing tree. Instead, each tree with n tips has the same probability to be generated under this model. There is (2n-3)!! possible trees with n tips.
The Biased model is a model of growing tree. When a species with speciation rate r splits, one of its descendent species is given the rate pr and the other is given the speciation rate (1-pr) where p is a probability parameter. The Biased model was introduced by Kirkpatrick and Slatkin (1993). The Aldous' Branching (AB) model is defined by the following symmetric split distribution q(n,i) = (1/(2*h(n-1))) * (1/(i(n-i))), where h(n) is the nth harmonic number. The AB model is hardly motivated by biological considerations.

### Value

A list of objects of class `"treeshape"` NULL if `n`=0

### Author(s)

Michael Blum <michael.blum@imag.fr>
Nicolas Bortolussi <nicolas.bortolussi@imag.fr>
Eric Durand <eric.durand@imag.fr>
Olivier Francois <olivier.francois@imag.fr>

### References

Mooers, A. O. and Heard, S. B. (Mar., 1997), Inferring Evolutionnary Process from Phylogenetic Tree Shape. The Quarterly Review of Biology, 72, 31-54, for more details about the Yule and PDA models.

Aldous, D. J. (1996), Probability Distributions on Cladograms. pp.1-18 of Random Discrete Structures eds D. Aldous and R. Pemantle, IMA Volumes Math. Appl. 76.

Kirkpatrick, M. and Slatkin, M. (1993) Searching for evolutionary patterns in the shape of a phylogenetic tree. Evolution, 47, 1171 – 1181.

### Examples

```
## Summary of a PDA tree with 10 tips:
summary(rtreeshape(n=1, tip.number=10, model="pda")[])
## Summary of a Yule tree with 10 tips:
summary(rtreeshape(n=1, tip.number=100, model="yule")[])

## Generate trees with different sizes
trees=rtreeshape(n=2, tip.number=c(10,20), model="yule")
length(trees)
plot(trees[])
plot(trees[])

## Histogram of Colless' indices for a list of 100 PDA trees with 50 tips
hist(sapply(rtreeshape(100,50,model="pda"),FUN=colless,norm="pda"),freq=FALSE)

## Histogram of shape statistics for a list of 100 Yule trees with 50 tips
##      (takes some time to compute)
main="Histogram of shape statistics for a list of 100 Yule trees"
hist(sapply(rtreeshape(100,50,model="yule"),FUN=shape.statistic,norm="yule"),
freq=FALSE, main=main)
## It should be a gaussian with mean 0 and standard deviation 1
## consider to increase the number of trees>100
x<-seq(-4,4,by=0.01)
lines(x,dnorm(x))

## Building a tree using Markov splitting model
Q <- function(n,i) (i==1)

tree=rtreeshape(n=1, tip.number=10, FUN=Q)
plot(tree[])
```

[Package apTreeshape version 1.5-0.1 Index]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7940844,"math_prob":0.96451485,"size":3755,"snap":"2021-43-2021-49","text_gpt3_token_len":1060,"char_repetition_ratio":0.11810184,"word_repetition_ratio":0.037567083,"special_character_ratio":0.2711052,"punctuation_ratio":0.15494792,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9939051,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-09T10:28:03Z\",\"WARC-Record-ID\":\"<urn:uuid:1628302c-9eed-4878-81ae-9de4481fa747>\",\"Content-Length\":\"6375\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b48d4a48-4481-499d-b48d-b3ce921178cd>\",\"WARC-Concurrent-To\":\"<urn:uuid:99675436-9b24-43f5-8a26-8c6eba96ddc6>\",\"WARC-IP-Address\":\"137.208.57.46\",\"WARC-Target-URI\":\"https://search.r-project.org/CRAN/refmans/apTreeshape/html/rtreeshape.html\",\"WARC-Payload-Digest\":\"sha1:NQNRD2Q5WYV6DRBSBEVWSER3OUHSSW56\",\"WARC-Block-Digest\":\"sha1:VN7R4ICNCEDUPTLSGBIBG47P7ZZJMZZU\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964363791.16_warc_CC-MAIN-20211209091917-20211209121917-00228.warc.gz\"}"}