Estimation of BDPN parameters from phylogenetic trees.
Project description
bdpn
Estimator of BD-PN model parameters from phylogenetic trees and a non-parametric PN detection test.
BD-PN model
BD-PN model extends the classical birth-death (BD) model with incomplete sampling [Stadler 2009], by adding partner notification (PN). Under this model, infected individuals can transmit their pathogen with a constant rate λ, get removed (become non-infectious) with a constant rate ψ, and their pathogen can be sampled upon removal with a constant probability ρ. On top of that, in the BD-PN model, at the moment of sampling the sampled individual might notify their most recent partner with a constant probability υ. Upon notification, the partner is removed almost instantaneously (modeled via a constant notified removal rate φ >> ψ) and their pathogen is sampled.
BD-PN model therefore has 5 parameters:
- λ -- transmission rate
- ψ -- removal rate
- ρ -- sampling probability upon removal
- υ -- probability to notify the last partner upon sampling
- φ -- removal (and sampling) rate after notification
These parameters can be expressed in terms of the following epidemiological parameters:
- R0=λ/ψ -- reproduction number
- 1/ψ -- infectious time
- 1/φ -- partner removal time
BD-PN model makes 3 assumptions:
- only observed individuals can notify (instead of any removed individual);
- notified individuals are always observed upon removal;
- only the most recent partner can get notified.
For identifiability, BD-PN model requires one of the three BD model parameters (λ, ψ, ρ) to be fixed.
BD-PN parameter estimator
The bdpn package provides a classical BD and a BD-PN model maximum-likelihood parameter estimator from a user-supplied time-scaled phylogenetic tree. User must also provide a value for one of the three BD model parameters (λ, ψ, or ρ). We recommend providing the sampling probability ρ, which could be estimated as the number of tree tips divided by the number of declared cases for the same time period.
PN test
The bdpn package provides a non-parametric test detecting presence/absence of partner notification in a user-supplied time-scaled phylogenetic tree. It outputs a p-value.
Input data
One needs to supply a time-scaled phylogenetic tree in newick format. In the examples below we will use an HIV tree reconstructed from 200 sequences, published in [Rasmussen et al. PLoS Comput. Biol. 2017], which you can find at PairTree GitHub and in hiv_zurich/Zurich.nwk.
Installation
There are 4 alternative ways to run bdpn on your computer: with docker, apptainer, in Python3, or via command line (requires installation with Python3).
Run in python3 or command-line (for linux systems, recommended Ubuntu 21 or newer versions)
You could either install python (version 3.9 or higher) system-wide and then install bdpn via pip:
sudo apt install -y python3 python3-pip python3-setuptools python3-distutils
pip3 install bdpn
or alternatively, you could install python (version 3.9 or higher) and bdpn via conda (make sure that conda is installed first). Here we will create a conda environment called bdpnenv:
conda create --name bdpnenv python=3.9
conda activate bdpnenv
pip install bdpn
Basic usage in a command line
If you installed bdpn in a conda environment (here named bdpnenv), do not forget to first activate it, e.g.
conda activate bdpnenv
Run the following commands to check for the presence of partner notification and estimate BD-PN model parameters. The first command applies the PN test to a tree Zurich.nwk and saves the PN-test value to the file cherry_test.txt The second command estimated the BD-PN parameters and their 95% CIs for this tree, assuming the sampling probability of 0.25, and saves the estimated parameters to a comma-separated file estimates_bdpn.csv. The third command estimated the classical BD parameters and their 95% CIs for this tree, assuming the sampling probability of 0.25, and saves the estimated parameters to a comma-separated file estimates_bd.csv.
pn_test --nwk Zurich.nwk --log cherry_test.txt
bdpn_infer --nwk Zurich.nwk --ci --p 0.25 --log estimates_bdpn.csv
bd_infer --nwk Zurich.nwk --ci --p 0.25 --log estimates_bd.csv
Help
To see detailed options, run:
pn_test --help
bdpn_infer --help
bd_infer --help
Run with docker
Basic usage
Once docker is installed, run the following command to estimate BD-PN model parameters:
docker run -v <path_to_the_folder_containing_the_tree>:/data:rw -t evolbioinfo/bdpn --nwk /data/Zurich.nwk --ci --p 0.25 --log /data/estimates.csv
This will produce a comma-separated file estimates.csv in the <path_to_the_folder_containing_the_tree> folder, containing the estimated parameter values and their 95% CIs (can be viewed with a text editor, Excel or Libre Office Calc).
Help
To see advanced options, run
docker run -t evolbioinfo/bdpn -h
Run with apptainer
Basic usage
Once apptainer is installed, run the following command to estimate BD-PN model parameters (from the folder where the Zurich.nwk tree is contained):
apptainer run docker://evolbioinfo/bdpn --nwk Zurich.nwk --ci --p 0.25 --log estimates.csv
This will produce a comma-separated file estimates.csv, containing the estimated parameter values and their 95% CIs (can be viewed with a text editor, Excel or Libre Office Calc).
Help
To see advanced options, run
apptainer run docker://evolbioinfo/bdpn -h
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bdpn-0.1.15.tar.gz
.
File metadata
- Download URL: bdpn-0.1.15.tar.gz
- Upload date:
- Size: 38.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e04d3d02ab55f28252dad9cafbe0cd1ea25ade8b1792a70314641dff02d5e23 |
|
MD5 | 579d5739e45d303becd4d6f6cc23d78c |
|
BLAKE2b-256 | 36d318434894ce91af8d09e98620c019ce0d7cab4af0016eab208b0590c9fa3a |
File details
Details for the file bdpn-0.1.15-py3-none-any.whl
.
File metadata
- Download URL: bdpn-0.1.15-py3-none-any.whl
- Upload date:
- Size: 46.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73ff6cbfd7a31489d7c359a84addfa2a415204b79214a9e60633667944d50651 |
|
MD5 | 63edcc6c0d6a721cd2a66f9d755c9db8 |
|
BLAKE2b-256 | 29d474480c3be656cd1932a421b098143cf76fe45a988b8cb2296c7646bf752b |