Skip to main content

Computes Tajimas D, the Pi- or Watterson-Estimator for multiple sequences.

Project description


Compute the Tajima's-D, Pi-Estimator or Watterson-Estimator for multiple sequences.

Test Badge Python Version Badge Download Badge Code style: black

Tajima's D is a population genetic test statistic that computes the difference between the mean number of pairwise differences and the number of segregating sites. It is used to determine whether a population is expanding or shrinking.

Tajima's D

Tajima's D is defined as follows:


If expanding, there are many rare variants, indicating an expanding population.

Whereas declining, indicates an declining population as there are many intermediate variants.

A result is consideres significant if declining-sig or expanding-sig.


The π estimator is the average number of pairwise differences between any two sequences:



The Watterson estimator is the expected number of segregating sites.



Using pip / pip3:

pip install tajimas_d

Using conda:

conda install -c bioconda tajimas_d

Or by source:

git clone
cd tajimas_d
pip install .

How to use

from tajimas_d import tajimas_d, watterson_estimator, pi_estimator

sequences = ["AAAA", "AAAT", "AAGT", "AAGT"]

theta_tajima = tajimas_d(sequences)
theta_pi = pi_estimator(sequences)
theta_w = watterson_estimator(sequences)

Standalone version

The standalone version requires miniFasta>=2.2 to be installed.

usage: tajimas_d [-h] -f PATH [-p] [-t] [-w]

tajimas_d: Compute Tajima's D, the Pi- or Watterson-Estimator for multiple

optional arguments:
  -h, --help            show this help message and exit
  -f PATH, --file PATH  Path to fasta file with all sequences.
  -p, --pi              Compute the Pi-Estimator score.
  -t, --tajima          Compute the Pi-Estimator score. (default)
  -w, --watterson       Compute the Watterson-Estimator score.


Copyright (C) 2024 by Jules Kreuer - @not_a_feature

This piece of software is published unter the GNU General Public License v3.0 TLDR:

Permissions Conditions Limitations
✓ Commercial use Disclose source ✕ Liability
✓ Distribution License and copyright notice ✕ Warranty
✓ Modification Same license
✓ Patent use State changes
✓ Private use

Go to to see the full version.

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

tajimas_d-2.0.1.tar.gz (18.3 kB view hashes)

Uploaded Source

Built Distribution

tajimas_d-2.0.1-py3-none-any.whl (17.9 kB view hashes)

Uploaded Python 3

Supported by

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