Skip to main content

Mini implementations of population genetics algorithms

Project description

watchgen

Unit tests CI Read the Docs License

The Watchmaker's Guide to Population Genetics — a build-it-yourself book on the algorithms behind modern population genetics. Every concept is derived from first principles, every method reimplemented from scratch in Python. No black boxes.

Read online: https://watchgen.readthedocs.io  |  Download PDF: https://watchgen.readthedocs.io/_/downloads/en/latest/pdf/

Note: A citable version number will be assigned in the coming days. Until then, please cite by URL and access date.


What this is

Population genetics has powerful algorithms — but inaccessible ones. Most live inside papers and codebases that assume years of specialised training. This book is an attempt to change that: explicit derivations, step-by-step implementations, and unit tests for every algorithm covered.

The companion Python package watchgen provides 19 minimal, self-contained reimplementations — small enough to read in one sitting, complete enough to run on toy examples, tested enough to trust. Think of them as movements built on the workbench: not for production, but for understanding.


Contents

Prerequisites (8 chapters)

Coalescent theory, ARGs, HMMs, SMC, diffusion approximation, ODEs, MCMC, probabilistic inference — everything you need before tackling a Timepiece.

Timepieces (18 algorithms)

Category Algorithms
Simulators msprime, SLiM, discoal
Demographic inference PSMC, SMC++, Gamma-SMC, PHLASH
SFS-based inference moments, dadi, momi2
Genealogy & ARG inference Li & Stephens HMM, ARGweaver, tsinfer, SINGER, Threads, Relate
Dating & selection tsdate, CLUES

The watchgen package

pip install watchgen  # or: git clone + pip install -e .
from watchgen import mini_psmc, mini_msprime, mini_tsinfer  # etc.

19 modules, ~17,500 lines of code, 2,672 unit tests. Each module depends only on NumPy and SciPy.


Building the book locally

HTML:

pip install sphinx sphinx-rtd-theme sphinx-copybutton sphinx-design sphinxcontrib-bibtex
python -m sphinx docs docs/_build/html -b html
open docs/_build/html/index.html

PDF (requires XeLaTeX / MacTeX / TeX Live):

python -m sphinx docs docs/_build/latex -b latex
cd docs/_build/latex && xelatex watchmakers-guide.tex

Contributing

This is version 0.1 — an unverified draft. No chapter has been reviewed by a domain expert yet. Contributions that cross-check derivations, correct mistakes, improve explanations, or add chapters are very welcome. Substantial contributors will be invited as co-authors.

Open an issue or pull request on GitHub.


If you find this useful, consider supporting with PayPal.

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

watchgen-0.0.1.tar.gz (54.8 MB view details)

Uploaded Source

Built Distribution

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

watchgen-0.0.1-py3-none-any.whl (154.5 kB view details)

Uploaded Python 3

File details

Details for the file watchgen-0.0.1.tar.gz.

File metadata

  • Download URL: watchgen-0.0.1.tar.gz
  • Upload date:
  • Size: 54.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for watchgen-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9171999d305364d422169354823bf45d815f2c6c57a30d4dcf72b2f161bcceeb
MD5 ccf56f6970546e405069f51f8f798fb5
BLAKE2b-256 aae32617417ba6f0f99ed40b8e2833737946fb9886c2f7fc8749480cb0858254

See more details on using hashes here.

Provenance

The following attestation bundles were made for watchgen-0.0.1.tar.gz:

Publisher: workflow.yml on kevinkorfmann/watchgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file watchgen-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: watchgen-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 154.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for watchgen-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3bda5ea382d62e81eaa93cfc55f4ba23ffc9a6512fdb0fe2cf2f0af8ca87aa5
MD5 9d83485336530bc73117a0f497c422b4
BLAKE2b-256 c4fb11c83abff40e6a8206f4dba3dd802305e2bb28f2e4a758e6ec411936ab43

See more details on using hashes here.

Provenance

The following attestation bundles were made for watchgen-0.0.1-py3-none-any.whl:

Publisher: workflow.yml on kevinkorfmann/watchgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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