Package: treesimulator
treesimulatorSimulation of rooted phylogenetic trees under a given Multitype Birth–Death (MTBD) model.
The MTBD models were introduced by Stadler & Bonhoeffer[Philos. Trans. R. Soc. B2013].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[Voznicaet al.2021].BD3 parameters:λ -- transmission rateψ -- removal ratep -- sampling probability upon removalEpidemiological parameters:R0=λ/ψ -- reproduction number1/ψ -- infectious timeBDEI2 compartments:E, exposed, i.e. infected but not yet infectiousI, infectious4 parameters:μ -- transition rate from E to I (becoming infectious)λ -- transmission rate from I to Eψ -- removal rate of Ip -- sampling probability upon removalEpidemiological parameters:R0=λ/ψ -- reproduction number1/ψ -- infectious time1/μ -- incubation periodBDSS2 compartments:N, standard infectious individualS, superspreader6 parameters:λnn-- transmission rate from N to Nλns-- transmission rate from N to Sλsn-- transmission rate from S to Nλss-- transmission rate from S to S(with a constraint that λss/λns=λsn/λnn)ψ -- removal rate of S and of N (the same)p -- sampling probability upon removal (the same for N and S)Epidemiological parameters:R0=(λnn+ λss)/ψ -- reproduction number1/ψ -- infectious timeX=λss/λns=λsn/λnn-- super-spreading transmission ratiof=λss/(λsn+ λss) -- super-spreading fractionInstallationTo install treesimulator:pip3installtreesimulatorUsageCommand lineBDThe following command simulates a tree with 200-500 tips under BD model, with λ=0.5, ψ=0.25, p=0.5,
and saves it to a file tree.nwk, while saving the parameters to a comma-separated file params.csv:generate_bd--min_tips200--max_tips500--la0.5--psi0.25--p0.5--nwktree.nwk--logparams.csvTo seee detailed options, run:generate_bd--helpBDEIThe following command simulates a tree with 200-500 tips under BDEI model, with μ=1, λ=0.5, ψ=0.25, p=0.5,
and saves it to a file tree.nwk, while saving the parameters to a comma-separated file params.csv:generate_bdei--min_tips200--max_tips500--mu1--la0.5--psi0.25--p0.5--nwktree.nwk--logparams.csvTo seee detailed options, run:generate_bdei--helpBDSSThe following command simulates a tree with 200-500 tips under BDSS model,
with λnn=0.1, λns=0.3, λsn=0.5, λss=1.5, ψ=0.25, p=0.5,
and saves it to a file tree.nwk, while saving the parameters to a comma-separated file params.csv:generate_bdss--min_tips200--max_tips500--la_nn0.1--la_ns0.3--la_sn0.5--la_ss1.5--psi0.25--p0.5--nwktree.nwk--logparams.csvTo seee detailed options, run:generate_bdss--helpUser-defined MTBD modelThe following command simulates a tree with 200-500 tips under a generic MTBD model, with two states A and B,
with μaa=0.5, μab=0.6, μba=0.7, μbb=0.8,
λaa=0.1, λab=0.2, λba=0.3, λbb=0.4,
ψa=0.05, ψb=0.08,
p=a0.15, p=b0.65,
and saves it to a file tree.nwk, while saving the parameters to a comma-separated file params.csv:generate_mtbd--min_tips200--max_tips500--nwktree.nwk--logparams.csv\--statesAB\--transition_rates0.50.60.70.8\--transmission_rates0.10.20.30.4\--removal_rates0.050.08\--sampling_probabilities0.150.65To seee detailed options, run:generate_mtbd--helpPython3To simulate trees with 200-500 tips under the above models and settings:fromtreesimulator.generatorimportgeneratefromtreesimulatorimportsave_forestfromtreesimulator.mtbd_modelsimportModel,BirthDeathModel,BirthDeathExposedInfectiousModel,BirthDeathWithSuperSpreadingModelbd_model=BirthDeathModel(p=0.5,la=0.5,psi=0.25)print(bd_model.get_epidemiological_parameters())[bd_tree],(bd_total_tips,_,bd_total_time)=generate(bd_model,min_tips=200,max_tips=500)save_forest([bd_tree],'BD_tree.nwk')bdei_model=BirthDeathExposedInfectiousModel(p=0.5,mu=1,la=0.5,psi=0.25)print(bdei_model.get_epidemiological_parameters())[bdei_tree],(bdei_total_tips,_,bdei_total_time)=generate(bdei_model,min_tips=200,max_tips=500)save_forest([bdei_tree],'BDEI_tree.nwk')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],(bdss_total_tips,_,bdss_total_time)=generate(bdss_model,min_tips=200,max_tips=500)save_forest([bdss_tree],'BDSS_tree.nwk')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],(mtbd_total_tips,_,mtbd_total_time)=generate(mtbd_model,min_tips=200,max_tips=500)save_forest([mtbd_tree],'MTBD_tree.nwk')