treesimulator


Nametreesimulator JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/evolbioinfo/treesimulator
SummarySimulation of rooted phylogenetic trees under a given Multitype Birth–Death model.
upload_time2024-12-18 12:56:52
maintainerNone
docs_urlNone
authorAnna Zhukova
requires_pythonNone
licenseNone
keywords phylogenetics tree generator multitype birth-death model
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # treesimulator

Simulation of rooted phylogenetic trees under a given Multitype Birth–Death (MTBD) model, with or without contact tracing (CT).

[//]: # ([![DOI:10.1093/sysbio/syad059](https://zenodo.org/badge/DOI/10.1093/sysbio/syad059.svg)](https://doi.org/10.1093/sysbio/syad059))
[![GitHub release](https://img.shields.io/github/v/release/evolbioinfo/treesimulator.svg)](https://github.com/evolbioinfo/treesimulator/releases)
[![PyPI version](https://badge.fury.io/py/treesimulator.svg)](https://pypi.org/project/treesimulator/)
[![PyPI downloads](https://shields.io/pypi/dm/treesimulator)](https://pypi.org/project/treesimulator/)
[![Docker pulls](https://img.shields.io/docker/pulls/evolbioinfo/treesimulator)](https://hub.docker.com/r/evolbioinfo/treesimulator/tags)

## MTBD
The MTBD models were introduced by Stadler & Bonhoeffer [[_Philos. Trans. R. Soc. B_ 2013]](https://royalsocietypublishing.org/doi/10.1098/rstb.2012.0198).

An MTBD model with m states has 

m(m-1) state transition rate parameters:
* μ<sub>ij</sub> -- transition rate from state i to state j (1 ≤ i, j ≤ m; i ≠ j), where μ<sub>ij</sub> ≥ 0

m<sup>2</sup> transmission rate parameters:
* λ<sub>ij</sub> -- transmission rate from state i (donor) to state j (recipient) (1 ≤ i, j ≤ m), where λ<sub>ij</sub> ≥ 0

m removal (becoming non-infectious) rate parameters:
* ψ<sub>i</sub> -- removal rate of state i (1 ≤ i ≤ m), where ψ<sub>i</sub> ≥ 0

m sampling probability upon removal parameters:
* p<sub>i</sub> -- probability to sample the pathogen of an individual in state i upon removal (1 ≤ i ≤ m), where 0 < p<sub>i</sub> ≤ 1

## Contact Tracing (CT)
Contact tracing adds two parameters to the initial MTBD model:

* υ -- probability to notify contacts upon sampling
* φ -- notified contact removal and sampling rate: φ >> ψ<sub>i</sub> ∀i (1 ≤ i ≤ m). The pathogen of a notified contact is sampled automatically (with a probability of 1) upon removal. 


We pay particular interest to the classical BD model, the BD Exposed-Infectious (BDEI) model, 
and BD with superspreading (BDSS), 
as they are described in [[Voznica _et al._ 2021]]((https://www.biorxiv.org/content/10.1101/2021.03.11.435006v1)), and to their -CT versions.


## BD
3 parameters:
* λ -- transmission rate
* ψ -- removal rate
* p -- sampling probability upon removal

Epidemiological parameters:
* R<sub>0</sub>=λ/ψ -- reproduction number
* 1/ψ -- infectious time


## BD-CT
5 parameters:
* λ -- transmission rate
* ψ -- removal rate
* p -- sampling probability upon removal
* υ -- probability to notify contacts upon sampling
* φ -- notified contact removal and sampling rate: φ >> ψ 


Epidemiological parameters:
* R<sub>0</sub>=λ/ψ -- reproduction number
* 1/ψ -- infectious time
* 1/φ -- notified contact removal time

## BDEI
2 states: 
* E, exposed, i.e. infected but not yet infectious
* I, infectious

4 parameters:
* μ -- transition rate from E to I (becoming infectious)
* λ -- transmission rate from I to E
* ψ -- removal rate of I
* p -- sampling probability upon removal

Epidemiological parameters:
* R<sub>0</sub>=λ/ψ -- reproduction number
* 1/ψ -- infectious time
* 1/μ -- incubation period


## BDEI-CT
2 states: 
* E, exposed, i.e. infected but not yet infectious
* I, infectious

6 parameters:
* μ -- transition rate from E to I (becoming infectious)
* λ -- transmission rate from I to E
* ψ -- removal rate of I
* p -- sampling probability upon removal
* υ -- probability to notify contacts upon sampling
* φ -- notified contact removal and sampling rate: φ >> ψ 

Epidemiological parameters:
* R<sub>0</sub>=λ/ψ -- reproduction number
* 1/ψ -- infectious time
* 1/μ -- incubation period
* 1/φ -- notified contact removal time

## BDSS
2 compartments: 
* N, standard infectious individual
* S, superspreader

6 parameters:
* λ<sub>nn</sub> -- transmission rate from N to N
* λ<sub>ns</sub> -- transmission rate from N to S
* λ<sub>sn</sub> -- transmission rate from S to N
* λ<sub>ss</sub> -- transmission rate from S to S

    (with a constraint that λ<sub>ss</sub>/λ<sub>ns</sub>=λ<sub>sn</sub>/λ<sub>nn</sub>)
* ψ -- removal rate of S and of N (the same)
* p -- sampling probability upon removal (the same for N and S)

Epidemiological parameters:
* R<sub>0</sub>=(λ<sub>nn</sub> + λ<sub>ss</sub>)/ψ -- reproduction number
* 1/ψ -- infectious time
* X=λ<sub>ss</sub>/λ<sub>ns</sub>=λ<sub>sn</sub>/λ<sub>nn</sub> -- super-spreading transmission ratio
* f=λ<sub>ss</sub>/(λ<sub>sn</sub> + λ<sub>ss</sub>) -- super-spreading fraction

## BDSS-CT
2 states: 
* N, standard infectious individual
* S, superspreader

8 parameters:
* λ<sub>nn</sub> -- transmission rate from N to N
* λ<sub>ns</sub> -- transmission rate from N to S
* λ<sub>sn</sub> -- transmission rate from S to N
* λ<sub>ss</sub> -- transmission rate from S to S

    (with a constraint that λ<sub>ss</sub>/λ<sub>ns</sub>=λ<sub>sn</sub>/λ<sub>nn</sub>)
* ψ -- removal rate of S and of N (the same)
* p -- sampling probability upon removal (the same for N and S)
* υ -- probability to notify contacts upon sampling
* φ -- notified contact removal and sampling rate: φ >> ψ 

Epidemiological parameters:
* R<sub>0</sub>=(λ<sub>nn</sub> + λ<sub>ss</sub>)/ψ -- reproduction number
* 1/ψ -- infectious time
* X=λ<sub>ss</sub>/λ<sub>ns</sub>=λ<sub>sn</sub>/λ<sub>nn</sub> -- super-spreading transmission ratio
* f=λ<sub>ss</sub>/(λ<sub>sn</sub> + λ<sub>ss</sub>) -- super-spreading fraction
* 1/φ -- notified contact removal time


## Installation

There are 4 alternative ways to run __treesimulator__ on your computer: 
with [docker](https://www.docker.com/community-edition), 
[apptainer](https://apptainer.org/),
in Python3, or via command line (requires installation with Python3).


### Installation in python3 or command-line

You could either install python (version 3.6 or higher) system-wide and then install treesimulator via pip:
```bash
sudo apt install -y python3 python3-pip python3-setuptools python3-distutils
pip3 install treesimulator
```

or alternatively, you could install python (version 3.6 or higher) and treesimulator via [conda](https://conda.io/docs/) (make sure that conda is installed first). 

(Optional) to install treesimulator in a new conda environment (e.g., called _phyloenv_ below), first create and activate the environment:
```bash
conda create --name phyloenv python=3.6
conda activate phyloenv
```

Install treesimulator with conda
```bash
conda install treesimulator
```


### Basic usage in a command line
If you installed __treesimulator__ in a conda environment (here named _phyloenv_), do not forget to first activate it, e.g.

```bash
conda activate phyloenv
```


#### BD and BD-CT
The following command simulates a tree with 200-500 tips under the BD model, with λ=0.5, ψ=0.25, p=0.5,
and saves it to the file tree.nwk, while saving the parameters to the comma-separated file params.csv:
```bash
generate_bd --min_tips 200 --max_tips 500 \
--la 0.5 --psi 0.25 --p 0.5 \
--nwk tree.nwk --log params.csv
```
The following command simulates a tree with 200-500 tips under the BD-CT model, with λ=0.5, ψ=0.25, p=0.5, φ=2.5, υ=0.2, 
and allowing to notify only the most recent contact of each sampled index case. 
The simulated tree is saved to the file tree.nwk, while the model parameters are saved to the comma-separated file params.csv:
```bash
generate_bd --min_tips 200 --max_tips 500 \
--la 0.5 --psi 0.25 --p 0.5 \
--phi 2.5 --upsilon 0.2 --max_notified_contacts 1 \
--nwk tree.nwk --log params.csv
```
To see detailed options, run:
```bash
generate_bd --help
```

#### BDEI and BDEI-CT
The following command simulates a tree with 200-500 tips under the BDEI model, with μ=1, λ=0.5, ψ=0.25, p=0.5, 
and saves it to the file tree.nwk, while saving the parameters to the comma-separated file params.csv:
```bash
generate_bdei --min_tips 200 --max_tips 500 \
--mu 1 --la 0.5 --psi 0.25 --p 0.5 \
--nwk tree.nwk --log params.csv
```
The following command simulates a tree with 200-500 tips under the BDEI-CT model, with μ=1, λ=0.5, ψ=0.25, p=0.5, φ=2.5, υ=0.2, 
and allowing to notify only the most recent contact of each sampled index case. 
The simulated tree is saved to the file tree.nwk, while the model parameters are saved to the comma-separated file params.csv:
```bash
generate_bdei --min_tips 200 --max_tips 500 \
--mu 1 --la 0.5 --psi 0.25 --p 0.5 \
--phi 2.5 --upsilon 0.2 --max_notified_contacts 1 \
--nwk tree.nwk --log params.csv
```
To see detailed options, run:
```bash
generate_bdei --help
```


#### BDSS and BDSS-CT
The following command simulates a tree with 200-500 tips under the BDSS model, 
with λ<sub>nn</sub>=0.1, λ<sub>ns</sub>=0.3, λ<sub>sn</sub>=0.5, λ<sub>ss</sub>=1.5, ψ=0.25, p=0.5, 
and saves it to the file tree.nwk, while saving the parameters to the comma-separated file params.csv:
```bash
generate_bdss --min_tips 200 --max_tips 500 \
--la_nn 0.1 --la_ns 0.3 --la_sn 0.5 --la_ss 1.5 --psi 0.25 --p 0.5 \
--nwk tree.nwk --log params.csv
```
The following command simulates a tree with 200-500 tips under the BDSS-CT model, 
with λ<sub>nn</sub>=0.1, λ<sub>ns</sub>=0.3, λ<sub>sn</sub>=0.5, λ<sub>ss</sub>=1.5, ψ=0.25, p=0.5, φ=2.5, υ=0.2, 
and allowing to notify only the most recent contact of each sampled index case. 
The simulated tree is saved to the file tree.nwk, while the model parameters are saved to the comma-separated file params.csv:
```bash
generate_bdss --min_tips 200 --max_tips 500 \
--la_nn 0.1 --la_ns 0.3 --la_sn 0.5 --la_ss 1.5 --psi 0.25 --p 0.5 \
--phi 2.5 --upsilon 0.2 --max_notified_contacts 1 \
--nwk tree.nwk --log params.csv
```
To see detailed options, run:
```bash
generate_bdss --help
```

#### User-defined MTBD and MTBD-CT models
The following command simulates a tree with 200-500 tips under a generic MTBD model, with two states A and B, 
with μ<sub>aa</sub>=0.5, μ<sub>ab</sub>=0.6, μ<sub>ba</sub>=0.7, μ<sub>bb</sub>=0.8, 
λ<sub>aa</sub>=0.1, λ<sub>ab</sub>=0.2, λ<sub>ba</sub>=0.3, λ<sub>bb</sub>=0.4, 
ψ<sub>a</sub>=0.05, ψ<sub>b</sub>=0.08,
p=<sub>a</sub>0.15, p=<sub>b</sub>0.65,
and saves it to the file tree.nwk, while saving the parameters to the comma-separated file params.csv:
```bash
generate_mtbd --min_tips 200 --max_tips 500 \
--states A B \
--transition_rates 0.5 0.6 0.7 0.8 \
--transmission_rates 0.1 0.2 0.3 0.4 \
--removal_rates 0.05 0.08 \
--sampling_probabilities 0.15 0.65 \
--nwk tree.nwk --log params.csv
```
The following command simulates a tree with 200-500 tips under a generic MTBD model, with two states A and B, 
with μ<sub>aa</sub>=0.5, μ<sub>ab</sub>=0.6, μ<sub>ba</sub>=0.7, μ<sub>bb</sub>=0.8, 
λ<sub>aa</sub>=0.1, λ<sub>ab</sub>=0.2, λ<sub>ba</sub>=0.3, λ<sub>bb</sub>=0.4, 
ψ<sub>a</sub>=0.05, ψ<sub>b</sub>=0.08,
p=<sub>a</sub>0.15, p=<sub>b</sub>0.65,
φ=2.5, υ=0.2, 
and allowing to notify only the most recent contact of each sampled index case. 
The simulated tree is saved to the file tree.nwk, while the model parameters are saved to the comma-separated file params.csv:
```bash
generate_mtbd --min_tips 200 --max_tips 500 \
--states A B \
--transition_rates 0.5 0.6 0.7 0.8 \
--transmission_rates 0.1 0.2 0.3 0.4 \
--removal_rates 0.05 0.08 \
--sampling_probabilities 0.15 0.65 \
--phi 2.5 --upsilon 0.2 --max_notified_contacts 1 \
--nwk tree.nwk --log params.csv
```
To see detailed options, run:
```bash
generate_mtbd --help
```


#### Basic usage in Python3
To simulate trees with 200-500 tips under the above models and settings:

```python3
from treesimulator.generator import generate
from treesimulator import save_forest
from treesimulator.mtbd_models import Model, BirthDeathModel, BirthDeathExposedInfectiousModel, BirthDeathWithSuperSpreadingModel, CTModel

# BD and BD-CT
bd_model = BirthDeathModel(p=0.5, la=0.5, psi=0.25)
print(bd_model.get_epidemiological_parameters())
[bd_tree], _, _ = generate(bd_model, min_tips=200, max_tips=500)
save_forest([bd_tree], 'BD_tree.nwk')
bdpn_model = CTModel(model=bd_model, upsilon=0.2, notified_removal_rate=2.5)
[bdpn_tree], _, _ = generate(bdpn_model, min_tips=200, max_tips=500)
save_forest([bdpn_tree], 'BDCT_tree.nwk')

# BDEI and BDEI-CT
bdei_model = BirthDeathExposedInfectiousModel(p=0.5, mu=1, la=0.5, psi=0.25)
print(bdei_model.get_epidemiological_parameters())
[bdei_tree], _, _ = generate(bdei_model, min_tips=200, max_tips=500)
save_forest([bdei_tree], 'BDEI_tree.nwk')
bdeipn_model = CTModel(model=bdei_model, upsilon=0.2, notified_removal_rate=2.5)
[bdeipn_tree], _, _ = generate(bdeipn_model, min_tips=200, max_tips=500)
save_forest([bdeipn_tree], 'BDEICT_tree.nwk')

# BDSS and BDSS-CT
bdss_model = BirthDeathWithSuperSpreadingModel(p=0.5, la_nn=0.1, la_ns=0.3, la_sn=0.5, la_ss=1.5, psi=0.25)
print(bdss_model.get_epidemiological_parameters())
[bdss_tree], _, _ = generate(bdss_model, min_tips=200, max_tips=500)
save_forest([bdss_tree], 'BDSS_tree.nwk')
bdsspn_model = CTModel(model=bdss_model, upsilon=0.2, notified_removal_rate=2.5)
[bdsspn_tree], _, _ = generate(bdsspn_model, min_tips=200, max_tips=500)
save_forest([bdsspn_tree], 'BDSSCT_tree.nwk')

# MTBD and MTBD-CT
mtbd_model = Model(states=['A', 'B'], transition_rates=[[0.5, 0.6], [0.7, 0.8]],
                   transmission_rates=[[0.1, 0.2], [0.3, 0.4]],
                   removal_rates=[0.05, 0.08], ps=[0.15, 0.65])
[mtbd_tree], _, _ = generate(mtbd_model, min_tips=200, max_tips=500)
save_forest([mtbd_tree], 'MTBD_tree.nwk')
mtbdpn_model = CTModel(model=mtbd_model, upsilon=0.2, notified_removal_rate=2.5)
[mtbdpn_tree], _, _ = generate(mtbdpn_model, min_tips=200, max_tips=500)
save_forest([mtbdpn_tree], 'MTBDCT_tree.nwk')
```

### Run with apptainer

Once [apptainer](https://apptainer.org/docs/user/latest/quick_start.html#installation) is installed, 
run the following command:

```bash
apptainer run docker://evolbioinfo/treesimlator
```

This will launch a terminal session within the container, 
in which you can run treesimulator following the instructions for the command line ("Basic usage in a command line") above.





            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/evolbioinfo/treesimulator",
    "name": "treesimulator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "phylogenetics, tree generator, multitype birth-death model",
    "author": "Anna Zhukova",
    "author_email": "anna.zhukova@pasteur.fr",
    "download_url": "https://files.pythonhosted.org/packages/64/66/57fff523b9881738e0d9782bd47882856601a926c386f0765288421ca479/treesimulator-0.2.1.tar.gz",
    "platform": null,
    "description": "# treesimulator\n\nSimulation of rooted phylogenetic trees under a given Multitype Birth\u2013Death (MTBD) model, with or without contact tracing (CT).\n\n[//]: # ([![DOI:10.1093/sysbio/syad059]&#40;https://zenodo.org/badge/DOI/10.1093/sysbio/syad059.svg&#41;]&#40;https://doi.org/10.1093/sysbio/syad059&#41;)\n[![GitHub release](https://img.shields.io/github/v/release/evolbioinfo/treesimulator.svg)](https://github.com/evolbioinfo/treesimulator/releases)\n[![PyPI version](https://badge.fury.io/py/treesimulator.svg)](https://pypi.org/project/treesimulator/)\n[![PyPI downloads](https://shields.io/pypi/dm/treesimulator)](https://pypi.org/project/treesimulator/)\n[![Docker pulls](https://img.shields.io/docker/pulls/evolbioinfo/treesimulator)](https://hub.docker.com/r/evolbioinfo/treesimulator/tags)\n\n## MTBD\nThe MTBD models were introduced by Stadler & Bonhoeffer [[_Philos. Trans. R. Soc. B_ 2013]](https://royalsocietypublishing.org/doi/10.1098/rstb.2012.0198).\n\nAn MTBD model with m states has \n\nm(m-1) state transition rate parameters:\n* \u03bc<sub>ij</sub> -- transition rate from state i to state j (1 \u2264 i, j \u2264 m; i \u2260 j), where \u03bc<sub>ij</sub> \u2265 0\n\nm<sup>2</sup> transmission rate parameters:\n* \u03bb<sub>ij</sub> -- transmission rate from state i (donor) to state j (recipient) (1 \u2264 i, j \u2264 m), where \u03bb<sub>ij</sub> \u2265 0\n\nm removal (becoming non-infectious) rate parameters:\n* \u03c8<sub>i</sub> -- removal rate of state i (1 \u2264 i \u2264 m), where \u03c8<sub>i</sub> \u2265 0\n\nm sampling probability upon removal parameters:\n* p<sub>i</sub> -- probability to sample the pathogen of an individual in state i upon removal (1 \u2264 i \u2264 m), where 0 < p<sub>i</sub> \u2264 1\n\n## Contact Tracing (CT)\nContact tracing adds two parameters to the initial MTBD model:\n\n* \u03c5 -- probability to notify contacts upon sampling\n* \u03c6 -- notified contact removal and sampling rate: \u03c6 >> \u03c8<sub>i</sub> \u2200i (1 \u2264 i \u2264 m). The pathogen of a notified contact is sampled automatically (with a probability of 1) upon removal. \n\n\nWe pay particular interest to the classical BD model, the BD Exposed-Infectious (BDEI) model, \nand BD with superspreading (BDSS), \nas they are described in [[Voznica _et al._ 2021]]((https://www.biorxiv.org/content/10.1101/2021.03.11.435006v1)), and to their -CT versions.\n\n\n## BD\n3 parameters:\n* \u03bb -- transmission rate\n* \u03c8 -- removal rate\n* p -- sampling probability upon removal\n\nEpidemiological parameters:\n* R<sub>0</sub>=\u03bb/\u03c8 -- reproduction number\n* 1/\u03c8 -- infectious time\n\n\n## BD-CT\n5 parameters:\n* \u03bb -- transmission rate\n* \u03c8 -- removal rate\n* p -- sampling probability upon removal\n* \u03c5 -- probability to notify contacts upon sampling\n* \u03c6 -- notified contact removal and sampling rate: \u03c6 >> \u03c8 \n\n\nEpidemiological parameters:\n* R<sub>0</sub>=\u03bb/\u03c8 -- reproduction number\n* 1/\u03c8 -- infectious time\n* 1/\u03c6 -- notified contact removal time\n\n## BDEI\n2 states: \n* E, exposed, i.e. infected but not yet infectious\n* I, infectious\n\n4 parameters:\n* \u03bc -- transition rate from E to I (becoming infectious)\n* \u03bb -- transmission rate from I to E\n* \u03c8 -- removal rate of I\n* p -- sampling probability upon removal\n\nEpidemiological parameters:\n* R<sub>0</sub>=\u03bb/\u03c8 -- reproduction number\n* 1/\u03c8 -- infectious time\n* 1/\u03bc -- incubation period\n\n\n## BDEI-CT\n2 states: \n* E, exposed, i.e. infected but not yet infectious\n* I, infectious\n\n6 parameters:\n* \u03bc -- transition rate from E to I (becoming infectious)\n* \u03bb -- transmission rate from I to E\n* \u03c8 -- removal rate of I\n* p -- sampling probability upon removal\n* \u03c5 -- probability to notify contacts upon sampling\n* \u03c6 -- notified contact removal and sampling rate: \u03c6 >> \u03c8 \n\nEpidemiological parameters:\n* R<sub>0</sub>=\u03bb/\u03c8 -- reproduction number\n* 1/\u03c8 -- infectious time\n* 1/\u03bc -- incubation period\n* 1/\u03c6 -- notified contact removal time\n\n## BDSS\n2 compartments: \n* N, standard infectious individual\n* S, superspreader\n\n6 parameters:\n* \u03bb<sub>nn</sub> -- transmission rate from N to N\n* \u03bb<sub>ns</sub> -- transmission rate from N to S\n* \u03bb<sub>sn</sub> -- transmission rate from S to N\n* \u03bb<sub>ss</sub> -- transmission rate from S to S\n\n    (with a constraint that \u03bb<sub>ss</sub>/\u03bb<sub>ns</sub>=\u03bb<sub>sn</sub>/\u03bb<sub>nn</sub>)\n* \u03c8 -- removal rate of S and of N (the same)\n* p -- sampling probability upon removal (the same for N and S)\n\nEpidemiological parameters:\n* R<sub>0</sub>=(\u03bb<sub>nn</sub> + \u03bb<sub>ss</sub>)/\u03c8 -- reproduction number\n* 1/\u03c8 -- infectious time\n* X=\u03bb<sub>ss</sub>/\u03bb<sub>ns</sub>=\u03bb<sub>sn</sub>/\u03bb<sub>nn</sub> -- super-spreading transmission ratio\n* f=\u03bb<sub>ss</sub>/(\u03bb<sub>sn</sub> + \u03bb<sub>ss</sub>) -- super-spreading fraction\n\n## BDSS-CT\n2 states: \n* N, standard infectious individual\n* S, superspreader\n\n8 parameters:\n* \u03bb<sub>nn</sub> -- transmission rate from N to N\n* \u03bb<sub>ns</sub> -- transmission rate from N to S\n* \u03bb<sub>sn</sub> -- transmission rate from S to N\n* \u03bb<sub>ss</sub> -- transmission rate from S to S\n\n    (with a constraint that \u03bb<sub>ss</sub>/\u03bb<sub>ns</sub>=\u03bb<sub>sn</sub>/\u03bb<sub>nn</sub>)\n* \u03c8 -- removal rate of S and of N (the same)\n* p -- sampling probability upon removal (the same for N and S)\n* \u03c5 -- probability to notify contacts upon sampling\n* \u03c6 -- notified contact removal and sampling rate: \u03c6 >> \u03c8 \n\nEpidemiological parameters:\n* R<sub>0</sub>=(\u03bb<sub>nn</sub> + \u03bb<sub>ss</sub>)/\u03c8 -- reproduction number\n* 1/\u03c8 -- infectious time\n* X=\u03bb<sub>ss</sub>/\u03bb<sub>ns</sub>=\u03bb<sub>sn</sub>/\u03bb<sub>nn</sub> -- super-spreading transmission ratio\n* f=\u03bb<sub>ss</sub>/(\u03bb<sub>sn</sub> + \u03bb<sub>ss</sub>) -- super-spreading fraction\n* 1/\u03c6 -- notified contact removal time\n\n\n## Installation\n\nThere are 4 alternative ways to run __treesimulator__ on your computer: \nwith [docker](https://www.docker.com/community-edition), \n[apptainer](https://apptainer.org/),\nin Python3, or via command line (requires installation with Python3).\n\n\n### Installation in python3 or command-line\n\nYou could either install python (version 3.6 or higher) system-wide and then install treesimulator via pip:\n```bash\nsudo apt install -y python3 python3-pip python3-setuptools python3-distutils\npip3 install treesimulator\n```\n\nor alternatively, you could install python (version 3.6 or higher) and treesimulator via [conda](https://conda.io/docs/) (make sure that conda is installed first). \n\n(Optional) to install treesimulator in a new conda environment (e.g., called _phyloenv_ below), first create and activate the environment:\n```bash\nconda create --name phyloenv python=3.6\nconda activate phyloenv\n```\n\nInstall treesimulator with conda\n```bash\nconda install treesimulator\n```\n\n\n### Basic usage in a command line\nIf you installed __treesimulator__ in a conda environment (here named _phyloenv_), do not forget to first activate it, e.g.\n\n```bash\nconda activate phyloenv\n```\n\n\n#### BD and BD-CT\nThe following command simulates a tree with 200-500 tips under the BD model, with \u03bb=0.5, \u03c8=0.25, p=0.5,\nand saves it to the file tree.nwk, while saving the parameters to the comma-separated file params.csv:\n```bash\ngenerate_bd --min_tips 200 --max_tips 500 \\\n--la 0.5 --psi 0.25 --p 0.5 \\\n--nwk tree.nwk --log params.csv\n```\nThe following command simulates a tree with 200-500 tips under the BD-CT model, with \u03bb=0.5, \u03c8=0.25, p=0.5, \u03c6=2.5, \u03c5=0.2, \nand allowing to notify only the most recent contact of each sampled index case. \nThe simulated tree is saved to the file tree.nwk, while the model parameters are saved to the comma-separated file params.csv:\n```bash\ngenerate_bd --min_tips 200 --max_tips 500 \\\n--la 0.5 --psi 0.25 --p 0.5 \\\n--phi 2.5 --upsilon 0.2 --max_notified_contacts 1 \\\n--nwk tree.nwk --log params.csv\n```\nTo see detailed options, run:\n```bash\ngenerate_bd --help\n```\n\n#### BDEI and BDEI-CT\nThe following command simulates a tree with 200-500 tips under the BDEI model, with \u03bc=1, \u03bb=0.5, \u03c8=0.25, p=0.5, \nand saves it to the file tree.nwk, while saving the parameters to the comma-separated file params.csv:\n```bash\ngenerate_bdei --min_tips 200 --max_tips 500 \\\n--mu 1 --la 0.5 --psi 0.25 --p 0.5 \\\n--nwk tree.nwk --log params.csv\n```\nThe following command simulates a tree with 200-500 tips under the BDEI-CT model, with \u03bc=1, \u03bb=0.5, \u03c8=0.25, p=0.5, \u03c6=2.5, \u03c5=0.2, \nand allowing to notify only the most recent contact of each sampled index case. \nThe simulated tree is saved to the file tree.nwk, while the model parameters are saved to the comma-separated file params.csv:\n```bash\ngenerate_bdei --min_tips 200 --max_tips 500 \\\n--mu 1 --la 0.5 --psi 0.25 --p 0.5 \\\n--phi 2.5 --upsilon 0.2 --max_notified_contacts 1 \\\n--nwk tree.nwk --log params.csv\n```\nTo see detailed options, run:\n```bash\ngenerate_bdei --help\n```\n\n\n#### BDSS and BDSS-CT\nThe following command simulates a tree with 200-500 tips under the BDSS model, \nwith \u03bb<sub>nn</sub>=0.1, \u03bb<sub>ns</sub>=0.3, \u03bb<sub>sn</sub>=0.5, \u03bb<sub>ss</sub>=1.5, \u03c8=0.25, p=0.5, \nand saves it to the file tree.nwk, while saving the parameters to the comma-separated file params.csv:\n```bash\ngenerate_bdss --min_tips 200 --max_tips 500 \\\n--la_nn 0.1 --la_ns 0.3 --la_sn 0.5 --la_ss 1.5 --psi 0.25 --p 0.5 \\\n--nwk tree.nwk --log params.csv\n```\nThe following command simulates a tree with 200-500 tips under the BDSS-CT model, \nwith \u03bb<sub>nn</sub>=0.1, \u03bb<sub>ns</sub>=0.3, \u03bb<sub>sn</sub>=0.5, \u03bb<sub>ss</sub>=1.5, \u03c8=0.25, p=0.5, \u03c6=2.5, \u03c5=0.2, \nand allowing to notify only the most recent contact of each sampled index case. \nThe simulated tree is saved to the file tree.nwk, while the model parameters are saved to the comma-separated file params.csv:\n```bash\ngenerate_bdss --min_tips 200 --max_tips 500 \\\n--la_nn 0.1 --la_ns 0.3 --la_sn 0.5 --la_ss 1.5 --psi 0.25 --p 0.5 \\\n--phi 2.5 --upsilon 0.2 --max_notified_contacts 1 \\\n--nwk tree.nwk --log params.csv\n```\nTo see detailed options, run:\n```bash\ngenerate_bdss --help\n```\n\n#### User-defined MTBD and MTBD-CT models\nThe following command simulates a tree with 200-500 tips under a generic MTBD model, with two states A and B, \nwith \u03bc<sub>aa</sub>=0.5, \u03bc<sub>ab</sub>=0.6, \u03bc<sub>ba</sub>=0.7, \u03bc<sub>bb</sub>=0.8, \n\u03bb<sub>aa</sub>=0.1, \u03bb<sub>ab</sub>=0.2, \u03bb<sub>ba</sub>=0.3, \u03bb<sub>bb</sub>=0.4, \n\u03c8<sub>a</sub>=0.05, \u03c8<sub>b</sub>=0.08,\np=<sub>a</sub>0.15, p=<sub>b</sub>0.65,\nand saves it to the file tree.nwk, while saving the parameters to the comma-separated file params.csv:\n```bash\ngenerate_mtbd --min_tips 200 --max_tips 500 \\\n--states A B \\\n--transition_rates 0.5 0.6 0.7 0.8 \\\n--transmission_rates 0.1 0.2 0.3 0.4 \\\n--removal_rates 0.05 0.08 \\\n--sampling_probabilities 0.15 0.65 \\\n--nwk tree.nwk --log params.csv\n```\nThe following command simulates a tree with 200-500 tips under a generic MTBD model, with two states A and B, \nwith \u03bc<sub>aa</sub>=0.5, \u03bc<sub>ab</sub>=0.6, \u03bc<sub>ba</sub>=0.7, \u03bc<sub>bb</sub>=0.8, \n\u03bb<sub>aa</sub>=0.1, \u03bb<sub>ab</sub>=0.2, \u03bb<sub>ba</sub>=0.3, \u03bb<sub>bb</sub>=0.4, \n\u03c8<sub>a</sub>=0.05, \u03c8<sub>b</sub>=0.08,\np=<sub>a</sub>0.15, p=<sub>b</sub>0.65,\n\u03c6=2.5, \u03c5=0.2, \nand allowing to notify only the most recent contact of each sampled index case. \nThe simulated tree is saved to the file tree.nwk, while the model parameters are saved to the comma-separated file params.csv:\n```bash\ngenerate_mtbd --min_tips 200 --max_tips 500 \\\n--states A B \\\n--transition_rates 0.5 0.6 0.7 0.8 \\\n--transmission_rates 0.1 0.2 0.3 0.4 \\\n--removal_rates 0.05 0.08 \\\n--sampling_probabilities 0.15 0.65 \\\n--phi 2.5 --upsilon 0.2 --max_notified_contacts 1 \\\n--nwk tree.nwk --log params.csv\n```\nTo see detailed options, run:\n```bash\ngenerate_mtbd --help\n```\n\n\n#### Basic usage in Python3\nTo simulate trees with 200-500 tips under the above models and settings:\n\n```python3\nfrom treesimulator.generator import generate\nfrom treesimulator import save_forest\nfrom treesimulator.mtbd_models import Model, BirthDeathModel, BirthDeathExposedInfectiousModel, BirthDeathWithSuperSpreadingModel, CTModel\n\n# BD and BD-CT\nbd_model = BirthDeathModel(p=0.5, la=0.5, psi=0.25)\nprint(bd_model.get_epidemiological_parameters())\n[bd_tree], _, _ = generate(bd_model, min_tips=200, max_tips=500)\nsave_forest([bd_tree], 'BD_tree.nwk')\nbdpn_model = CTModel(model=bd_model, upsilon=0.2, notified_removal_rate=2.5)\n[bdpn_tree], _, _ = generate(bdpn_model, min_tips=200, max_tips=500)\nsave_forest([bdpn_tree], 'BDCT_tree.nwk')\n\n# BDEI and BDEI-CT\nbdei_model = BirthDeathExposedInfectiousModel(p=0.5, mu=1, la=0.5, psi=0.25)\nprint(bdei_model.get_epidemiological_parameters())\n[bdei_tree], _, _ = generate(bdei_model, min_tips=200, max_tips=500)\nsave_forest([bdei_tree], 'BDEI_tree.nwk')\nbdeipn_model = CTModel(model=bdei_model, upsilon=0.2, notified_removal_rate=2.5)\n[bdeipn_tree], _, _ = generate(bdeipn_model, min_tips=200, max_tips=500)\nsave_forest([bdeipn_tree], 'BDEICT_tree.nwk')\n\n# BDSS and BDSS-CT\nbdss_model = BirthDeathWithSuperSpreadingModel(p=0.5, la_nn=0.1, la_ns=0.3, la_sn=0.5, la_ss=1.5, psi=0.25)\nprint(bdss_model.get_epidemiological_parameters())\n[bdss_tree], _, _ = generate(bdss_model, min_tips=200, max_tips=500)\nsave_forest([bdss_tree], 'BDSS_tree.nwk')\nbdsspn_model = CTModel(model=bdss_model, upsilon=0.2, notified_removal_rate=2.5)\n[bdsspn_tree], _, _ = generate(bdsspn_model, min_tips=200, max_tips=500)\nsave_forest([bdsspn_tree], 'BDSSCT_tree.nwk')\n\n# MTBD and MTBD-CT\nmtbd_model = Model(states=['A', 'B'], transition_rates=[[0.5, 0.6], [0.7, 0.8]],\n                   transmission_rates=[[0.1, 0.2], [0.3, 0.4]],\n                   removal_rates=[0.05, 0.08], ps=[0.15, 0.65])\n[mtbd_tree], _, _ = generate(mtbd_model, min_tips=200, max_tips=500)\nsave_forest([mtbd_tree], 'MTBD_tree.nwk')\nmtbdpn_model = CTModel(model=mtbd_model, upsilon=0.2, notified_removal_rate=2.5)\n[mtbdpn_tree], _, _ = generate(mtbdpn_model, min_tips=200, max_tips=500)\nsave_forest([mtbdpn_tree], 'MTBDCT_tree.nwk')\n```\n\n### Run with apptainer\n\nOnce [apptainer](https://apptainer.org/docs/user/latest/quick_start.html#installation) is installed, \nrun the following command:\n\n```bash\napptainer run docker://evolbioinfo/treesimlator\n```\n\nThis will launch a terminal session within the container, \nin which you can run treesimulator following the instructions for the command line (\"Basic usage in a command line\") above.\n\n\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Simulation of rooted phylogenetic trees under a given Multitype Birth\u2013Death model.",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/evolbioinfo/treesimulator"
    },
    "split_keywords": [
        "phylogenetics",
        " tree generator",
        " multitype birth-death model"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a75a99aeae3ecd2811b23799e1aa931559bea93e10719ad7d2a75b638e08423",
                "md5": "d0c891b56ed5d6a128a3d07f92c2b80f",
                "sha256": "1062916ff45982f8db4f791e272a3ce5b8255fb8d3844b6c83c339c7e8c25352"
            },
            "downloads": -1,
            "filename": "treesimulator-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d0c891b56ed5d6a128a3d07f92c2b80f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 34640,
            "upload_time": "2024-12-18T12:56:50",
            "upload_time_iso_8601": "2024-12-18T12:56:50.979162Z",
            "url": "https://files.pythonhosted.org/packages/9a/75/a99aeae3ecd2811b23799e1aa931559bea93e10719ad7d2a75b638e08423/treesimulator-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "646657fff523b9881738e0d9782bd47882856601a926c386f0765288421ca479",
                "md5": "a57d2697ae9e9c4da522eaeb9553e276",
                "sha256": "10520e629a4ba47e7e5c0012b47f1dc1123389b4b7a96d1ff3f89ba8d60eafb4"
            },
            "downloads": -1,
            "filename": "treesimulator-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a57d2697ae9e9c4da522eaeb9553e276",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 32721,
            "upload_time": "2024-12-18T12:56:52",
            "upload_time_iso_8601": "2024-12-18T12:56:52.254759Z",
            "url": "https://files.pythonhosted.org/packages/64/66/57fff523b9881738e0d9782bd47882856601a926c386f0765288421ca479/treesimulator-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-18 12:56:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "evolbioinfo",
    "github_project": "treesimulator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "treesimulator"
}
        
Elapsed time: 0.50272s