Mini implementations of population genetics algorithms
Project description
watchgen
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9171999d305364d422169354823bf45d815f2c6c57a30d4dcf72b2f161bcceeb
|
|
| MD5 |
ccf56f6970546e405069f51f8f798fb5
|
|
| BLAKE2b-256 |
aae32617417ba6f0f99ed40b8e2833737946fb9886c2f7fc8749480cb0858254
|
Provenance
The following attestation bundles were made for watchgen-0.0.1.tar.gz:
Publisher:
workflow.yml on kevinkorfmann/watchgen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
watchgen-0.0.1.tar.gz -
Subject digest:
9171999d305364d422169354823bf45d815f2c6c57a30d4dcf72b2f161bcceeb - Sigstore transparency entry: 1006743027
- Sigstore integration time:
-
Permalink:
kevinkorfmann/watchgen@a2963a442abba1dc0dcd3c8a5b6ab0d07e23fcd2 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/kevinkorfmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@a2963a442abba1dc0dcd3c8a5b6ab0d07e23fcd2 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3bda5ea382d62e81eaa93cfc55f4ba23ffc9a6512fdb0fe2cf2f0af8ca87aa5
|
|
| MD5 |
9d83485336530bc73117a0f497c422b4
|
|
| BLAKE2b-256 |
c4fb11c83abff40e6a8206f4dba3dd802305e2bb28f2e4a758e6ec411936ab43
|
Provenance
The following attestation bundles were made for watchgen-0.0.1-py3-none-any.whl:
Publisher:
workflow.yml on kevinkorfmann/watchgen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
watchgen-0.0.1-py3-none-any.whl -
Subject digest:
d3bda5ea382d62e81eaa93cfc55f4ba23ffc9a6512fdb0fe2cf2f0af8ca87aa5 - Sigstore transparency entry: 1006743028
- Sigstore integration time:
-
Permalink:
kevinkorfmann/watchgen@a2963a442abba1dc0dcd3c8a5b6ab0d07e23fcd2 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/kevinkorfmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@a2963a442abba1dc0dcd3c8a5b6ab0d07e23fcd2 -
Trigger Event:
release
-
Statement type: