Package: phylodeep
PhyloDeepPhyloDeep is a python library for parameter estimation and model selection from phylogenetic trees, based on deep learning.ArticleVoznica J, Zhukova A, Boskova V, Saulnier E, Lemoine F, Moslonka-Lefebvre M, Gascuel O.Deep learning from phylogenies to uncover the transmission dynamics of epidemics.Nat Commun 13, 3896 (2022)InstallationThe installation time of the package can be up to several minutes, including downloading dependencies. The run time
should be a couple of seconds. The package was tested in Linux (Ubuntu 18.08), Windows 10 and MacOS.WindowsForWindowsusers, we recommend installingphylodeepviaCygwin environment.
First install Python>=3.8 and pip3 from the Cygwin packages. Then installphylodeep:pip3installphylodeepAll other platformsYou can installphylodeepfor Python (version 3.8 or higher) with or withoutconda, following the procedures described below:Installing with condaOnce you have conda installed, create an environment forphylodeepwith Python>=3.8 (here we name it phyloenv):condacreate--namephyloenvpython=3.8Then activate it:condaactivatephyloenvThen installphylodeepin it:pipinstallphylodeepInstalling without condaMake sure that Python>=3.8 and pip3 are installed, then installphylodeep:pip3installphylodeepUsageIf you installedphylodeepwith conda, do not forget to activate the corresponding environment (e.g. phyloenv) before using PhyloDeep:condaactivatephyloenvWe recommend to perform a priori model adequacy first to assess whether the input data resembles well the
simulations on which the neural networks were trained.Example dataHere, we use an HIV tree reconstructed from 200 sequences, published in "Phylodynamics on local sexual contact networks"
by Rasmussenet al.[PLoS Comput. Biol. 2017],
which you can find atPairTree GitHuband intest_tree_HIV_Zurich/Zurich.trees.PythonfromphylodeepimportBD,BDEI,BDSS,FULLfromphylodeep.checkdeepimportcheckdeepfromphylodeep.modeldeepimportmodeldeepfromphylodeep.paramdeepimportparamdeeppath_to_tree='./Zurich.trees'# set presumed sampling probabilitysampling_proba=0.25# a priori check for models BD, BDEI, BDSScheckdeep(path_to_tree,model=BD,outputfile_png='BD_a_priori_check.png')checkdeep(path_to_tree,model=BDEI,outputfile_png='BDEI_a_priori_check.png')checkdeep(path_to_tree,model=BDSS,outputfile_png='BDSS_a_priori_check.png')# model selectionmodel_BDEI_vs_BD_vs_BDSS=modeldeep(path_to_tree,sampling_proba,vector_representation=FULL)# the selected model is BDSS# parameter inferenceparam_BDSS=paramdeep(path_to_tree,sampling_proba,model=BDSS,vector_representation=FULL,ci_computation=True)# for the interpretation of results, please see belowCommand line# we use here a tree of 200 tips# a priori model adequacy check: highly recommendedcheckdeep-t./Zurich.trees-mBD-oBD_model_adequacy.png
checkdeep-t./Zurich.trees-mBDEI-oBDEI_model_adequacy.png
checkdeep-t./Zurich.trees-mBDSS-oBDSS_model_adequacy.png# model selectionmodeldeep-t./Zurich.trees-p0.25-vCNN_FULL_TREE-omodel_selection.csv# parameter inferenceparamdeep-t./Zurich.trees-p0.25-mBDSS-vFFNN_SUMSTATS-oHIV_Zurich_BDSS_CNN.csv
paramdeep-t./Zurich.trees-p0.25-mBDSS-vCNN_FULL_TREE-oHIV_Zurich_BDSS_FFNN_CI.csv-cExample of output and interpretationsThe a priori model adequacy check results in the following figures:BD model adequacy testBDEI model adequacy testBDSS model adequacy testFor the three models (BD, BDEI and BDSS), HIV tree datapoint (represented by a red star) is well inside the data cloud
of simulations, where warm colors correspond to high density of simulations. The simulations and HIV tree datapoint were
in the form of summary statistics prior to applying PCA. All three models thus pass the model adequacy check.We then apply model selection using the full tree representation and obtain the following result:ModelProbability BDEIProbability BDProbability BDSSPredicted probability0.000.001.00The BDSS probability is by far the highest: it is the BDSS model that is confidently selectedFinally, under the selected model BDSS, we predict parameter values together with 95% CIs:R naughtInfectious periodX transmissionSuperspreading fractionpredicted value1.699.789.340.079CI 2.5%1.408.126.650.050CI 97.5%2.0812.26100.133The point estimates for parameters that are no time related (R naught, X transmission and Superspreading fraction) are
well inside the parameter ranges of simulations and thus seem valid (R naught between 1 and 5, x transmission between 3
and 10, superspreading fraction between 0.05 and 0.20).The time related parameters (infectious and eventually incubation period for BDEI model) are in the same units as the
branches of input tree, here in years (9.78 years). The covered parameter space for time related parameters is large
due to internal rescaling of all input trees. It should apply to any tree.