Skip to main content

A python library for calculating the delta score (Holland et al. 2002) and Q-Residual (Gray et al. 2010)

Project description

phylogemetric

A python library for calculating delta score (Holland et al. 2002) and Q-Residual (Gray et al. 2010) for phylogenetic data.

Build Status Coverage Status DOI License JOSS

Installation:

Installation is only a pip install away:

pip install phylogemetric

Usage: Command line

Basic usage:

> phylogemetric

usage: phylogemetric [-h] method filename

Calculate delta score for filename example.nex:

> phylogemetric delta example.nex

taxon1              0.2453
taxon2              0.2404
taxon3              0.2954
...

Calculate qresidual score for filename example.nex:

> phylogemetric qresidual example.nex

taxon1              0.0030
taxon2              0.0037
taxon3              0.0063
...

Note: to save the results to a file use shell piping e.g.:

> phylogemetric qresidual example.nex > qresidual.txt

Speeding things up by using multiple processes.

You can tell phylogemetric to use multiple cores with the -w/--workers argument:

> phylogemetric -w 4 qresidual example.nex

Usage: Library

Calculate scores:

from nexus import NexusReader
from phylogemetric import DeltaScoreMetric
from phylogemetric import QResidualMetric

# load data from a nexus file:
nex = NexusReader("filename.nex")
qres = QResidualMetric(nex.data.matrix)

# Or construct a data matrix directly: 

matrix = {
    'A': [
        '1', '1', '1', '1', '0', '0', '1', '1', '1', '0', '1', '1',
        '1', '1', '0', '0', '1', '1', '1', '0'
    ],
    'B': [
        '1', '1', '1', '1', '0', '0', '0', '1', '1', '1', '1', '1',
        '1', '1', '1', '0', '0', '1', '1', '1'
    ],
    'C': [
        '1', '1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '0',
        '0', '0', '0', '1', '0', '1', '1', '1'
    ],
    'D': [
        '1', '0', '0', '0', '0', '1', '0', '1', '1', '1', '1', '0',
        '0', '0', '0', '1', '0', '1', '1', '1'
    ],
    'E': [
        '1', '0', '0', '0', '0', '1', '0', '1', '0', '1', '1', '0',
        '0', '0', '0', '1', '1', '1', '1', '1'
    ],
}

delta = DeltaScoreMetric(matrix)

Class Methods:

m = DeltaScoreMetric(matrix)

# calculates the number of quartets in the data:

m.nquartets()

# returns the distance between two sequences:
m.dist(['1', '1', '0'], ['0', '1', '0'])

# gets a dictionary of metric scores:
m.score()
m.score(workers=4) # with multiple processes.


# pretty prints the metric scores:
m.pprint()

Requirements:

  • python-nexus >= 1.1

Performance Notes:

Currently phylogemetric is implemented in python, and the Delta/Q-Residual algorithms are O(n). This means that performance is not optimal, and it may take a while to calculate these metrics for datasets with more than 100 taxa or so. To help speed this up, use the multiple processes argument -w/--workers at the command line or by passing workers=n to the score function.

I hope to improve performance in the near future, but in the meantime, if this is an issue for you then try using the implementations available in SplitsTree.

Citation:

If you use phylogemetric, please cite:

Greenhill, SJ. 2016. Phylogemetric: A Python library for calculating phylogenetic network metrics. Journal of Open Source Software.
http://dx.doi.org/10.21105/joss.00028

Changelog:

  • 1.1.0:
  • Added support for multiple processes.
  • Removed python 2 support.

Acknowledgements:

  • Thanks to David Bryant for clarifying the Q-Residual code.
  • Thanks to Kristian Rother for code quality suggestions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phylogemetric-1.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

phylogemetric-1.1.0-py3.9.egg (30.0 kB view details)

Uploaded Egg

phylogemetric-1.1.0-py2.py3-none-any.whl (16.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file phylogemetric-1.1.0.tar.gz.

File metadata

  • Download URL: phylogemetric-1.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

File hashes

Hashes for phylogemetric-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5329ba2a88974ce1f9baa16dd95d1856a90acfe92d5f11e0f3a53cda8378a057
MD5 121f07984c990b6f8ee761c186a4f560
BLAKE2b-256 d76b51fc63f99ac88677c7eb6dbf8361fc874d71cc864d7e096b668c4d94eaa9

See more details on using hashes here.

File details

Details for the file phylogemetric-1.1.0-py3.9.egg.

File metadata

  • Download URL: phylogemetric-1.1.0-py3.9.egg
  • Upload date:
  • Size: 30.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

File hashes

Hashes for phylogemetric-1.1.0-py3.9.egg
Algorithm Hash digest
SHA256 a6e36f6e98da5b481e1dfac5f3dba06cbc397c8084bf1967a98c4ad41ed1e1cb
MD5 af586351d9862e636abaa21b64ee7922
BLAKE2b-256 650e0428f33bebb24b9dae69f17f45b53598fdd687a065550143d91645986889

See more details on using hashes here.

File details

Details for the file phylogemetric-1.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: phylogemetric-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

File hashes

Hashes for phylogemetric-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 64c7571a969a7991412dd6131c53cb8355cf595c8176c14719093070e9658e9e
MD5 95744c2edd32a10fc8f3c47a61d74aab
BLAKE2b-256 2b7bd266c26f3a2f2d2beb3ba89ca7ff117430d171f960740f46535d3ce5c7fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page