High-performance Python library for fitting high-order epistatic interactions in genotype-phenotype maps.
Project description
epistasis-v2
High-performance Python library for fitting high-order epistatic interactions in genotype-phenotype maps. A clean-break rewrite of harmslab/epistasis.
Status: alpha. Phase 1 port, Phase 2 Rust kernel, and the Phase 3 Walsh-Hadamard OLS fast path are all in. Sparse design matrices for high-order Lasso and remaining polish items are still to come.
What changed from v1
- Rust hot-path kernels via PyO3 (
epistasis._core) instead of a shipped Cython.cblob. uv+maturinbuild.pyproject.tomlonly; nosetup.py.- Python 3.10 through 3.13. Older interpreters dropped.
- Type hints on the public API;
mypy --strictin CI. - Composition over
@use_sklearnMRO injection. Concrete models hold an sklearn estimator as an attribute and forward calls explicitly, which unlocks modern sklearn (>=1.2) that broke the v1 trick whennormalize=was removed. - Walsh-Hadamard fast-path for Hadamard-encoded OLS fits:
O(n log n)closed-form solve, no dense design matrix. Auto-engaged inEpistasisLinearRegression.fitwhen the attached GPM is a full-order biallelic library under global encoding; everything else falls back to the sklearn path. - Sparse design matrix path for Lasso / ElasticNet at high order (pending; a memory concern at
L >= 20). - Coordinated rewrite of the gpmap dependency as gpmap-v2. Consumes
binary_packed(uint8 2D) andencoding_tablewithsite_indexinstead of the deprecatedgenotype_index. - No backward compatibility with v1. Pin the v1 package if you need that behavior.
Repository layout
epistasis-v2/
├── pyproject.toml uv + maturin build, ruff + mypy + pytest config
├── Cargo.toml Rust workspace
├── python/epistasis/ Python source (installed as `epistasis`)
├── crates/epistasis-core/ Rust crate, exposed as `epistasis._core`
├── tests/ pytest suite
├── benches/ pytest-benchmark suites (matrix kernels + FWHT)
├── docs/ Sphinx docs (Phase 5)
├── .github/workflows/ CI (lint, test, matrix) + release (semantic-release, maturin wheels, PyPI OIDC)
├── CHANGELOG.md generated by python-semantic-release
└── CONTRIBUTING.md commit conventions, dev workflow
Installation (dev)
Requires Python >= 3.10 and a Rust toolchain. gpmap-v2 is pulled from PyPI.
uv sync
uv run maturin develop --release
uv run pytest
For lint and type-check:
uv run ruff check .
uv run ruff format --check .
uv run mypy python/epistasis
Current progress
Phase 0 (scaffold), Phase 1 (port), Phase 2 (Rust kernels), and most of Phase 3 (FWHT fast path) are complete.
Ported modules:
epistasis.mapping(sites, coefficients,EpistasisMap)epistasis.matrix(encoded vectors and design matrix; Rust-backed)epistasis.exceptions(EpistasisError,XMatrixError,FittingError)epistasis.utils(genotypes_to_X)epistasis.models.base(AbstractEpistasisModel,EpistasisBaseModel)epistasis.models.linear(EpistasisLinearRegressionwith analytic coefficient standard errors and a Walsh-Hadamard fast path for full-order biallelic fits,EpistasisRidge,EpistasisLasso,EpistasisElasticNet)epistasis.models.nonlinear(EpistasisNonlinearRegression,FunctionMinimizer;powerandsplinevariants deferred)epistasis.models.classifiers(EpistasisLogisticRegression; LDA, QDA, Gaussian Process, and GMM deferred)epistasis.simulate(simulate_linear_gpm,simulate_random_linear_gpm)epistasis.stats(Pearson, R^2, RMSD, SS residuals, AIC,split_gpm)epistasis.validate(k_fold,holdout)epistasis.sampling.bayesian(BayesianSamplervia emcee 3)epistasis.fast(fwht_ols_coefficients: closed-form OLS via FWHT)
Rust hot-path kernels in epistasis._core:
encode_vectors(uint8 binary_packed to int8 Hadamard/local encoding)build_model_matrix(parallel site-product over genotype rows; flat ragged sites layout)fwht(iterative butterfly Fast Walsh-Hadamard Transform)
Benchmarks (release build, Windows, 16 threads; see benches/):
| kernel | input | Rust | NumPy reference | speedup |
|---|---|---|---|---|
build_model_matrix |
L=12, order=3 | 1.7 ms | 10.1 ms | ~6x |
build_model_matrix |
L=16, order=3 | 50 ms | 283 ms | ~5.7x |
encode_vectors |
L=16 (65k genotypes) | 1.06 ms | 3.24 ms | ~3x |
EpistasisLinearRegression.fit |
full-order L=10 | 0.78 ms | 292 ms (lstsq) | ~375x |
EpistasisLinearRegression.fit |
full-order L=12 | 3.4 ms | 15.4 s (lstsq) | ~4500x |
Pending:
- Sparse design matrix path for Lasso / ElasticNet (memory at L >= 20)
power.pyandspline.pynonlinear variants- Remaining classifier implementations if demand surfaces
- ReadTheDocs build
Contributing
See CONTRIBUTING.md. Commits follow Conventional Commits; releases and the changelog are automated by python-semantic-release.
License
Unlicense (public domain). See UNLICENSE.
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 Distributions
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 epistasis_v2-1.1.0.tar.gz.
File metadata
- Download URL: epistasis_v2-1.1.0.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92dc05f396816afddfdbd179537c50c469d34ae20ab5d8ac84f8542587acb612
|
|
| MD5 |
2f7aa64cb2e04e0679333d6f39e8484d
|
|
| BLAKE2b-256 |
a5641549e2b54974f309c32fec43cc9f61d5a1b923ad1243ed2dd02cf60171ab
|
Provenance
The following attestation bundles were made for epistasis_v2-1.1.0.tar.gz:
Publisher:
release.yml on lperezmo/epistasis-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
epistasis_v2-1.1.0.tar.gz -
Subject digest:
92dc05f396816afddfdbd179537c50c469d34ae20ab5d8ac84f8542587acb612 - Sigstore transparency entry: 1341675204
- Sigstore integration time:
-
Permalink:
lperezmo/epistasis-v2@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lperezmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Trigger Event:
push
-
Statement type:
File details
Details for the file epistasis_v2-1.1.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: epistasis_v2-1.1.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 224.5 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4c2f9590fc1b416a90607e4e594bdc67c76d93d8081d06b0a7de8221b9077dd
|
|
| MD5 |
ff13706f4b304e1cc0eab3247b35245e
|
|
| BLAKE2b-256 |
4d29d96d77efb51a7c94504812f910c03c9cc73d001090369c4de78cb4ab58d2
|
Provenance
The following attestation bundles were made for epistasis_v2-1.1.0-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on lperezmo/epistasis-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
epistasis_v2-1.1.0-cp310-abi3-win_amd64.whl -
Subject digest:
d4c2f9590fc1b416a90607e4e594bdc67c76d93d8081d06b0a7de8221b9077dd - Sigstore transparency entry: 1341675219
- Sigstore integration time:
-
Permalink:
lperezmo/epistasis-v2@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lperezmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Trigger Event:
push
-
Statement type:
File details
Details for the file epistasis_v2-1.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: epistasis_v2-1.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 361.0 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
100c2e4a58e1cf4e423b813b2d4ca908fd86098da88bcf16df889b56452103a7
|
|
| MD5 |
6867f3344ee7427ec1edcd778102d607
|
|
| BLAKE2b-256 |
29fa1e70027a97015a1196990badae3f436af6ea646c372015be088e71b9afc9
|
Provenance
The following attestation bundles were made for epistasis_v2-1.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on lperezmo/epistasis-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
epistasis_v2-1.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
100c2e4a58e1cf4e423b813b2d4ca908fd86098da88bcf16df889b56452103a7 - Sigstore transparency entry: 1341675209
- Sigstore integration time:
-
Permalink:
lperezmo/epistasis-v2@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lperezmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Trigger Event:
push
-
Statement type:
File details
Details for the file epistasis_v2-1.1.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: epistasis_v2-1.1.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 322.7 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
315268ba071d571e2a7c2adf100ca11860cc2f7e01dfe33dad5f56b800f3afa2
|
|
| MD5 |
27b8e9f85f43624ada1b00ca81769df9
|
|
| BLAKE2b-256 |
2a343e67196ffb5c5e0df8bed8fbb92fd0d90186b8bcd691bbcd42b58574606a
|
Provenance
The following attestation bundles were made for epistasis_v2-1.1.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on lperezmo/epistasis-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
epistasis_v2-1.1.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
315268ba071d571e2a7c2adf100ca11860cc2f7e01dfe33dad5f56b800f3afa2 - Sigstore transparency entry: 1341675211
- Sigstore integration time:
-
Permalink:
lperezmo/epistasis-v2@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lperezmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Trigger Event:
push
-
Statement type:
File details
Details for the file epistasis_v2-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: epistasis_v2-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 330.7 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
625752418213b0978552f34c20ea12924c2c364b9d1c6977fec66282ffb0320d
|
|
| MD5 |
46212ac8997d7e653919d684ec7740a3
|
|
| BLAKE2b-256 |
f04165a1d2a9076e13ce195da497ea4e75394571f8ec76b941e5f71d3c85a874
|
Provenance
The following attestation bundles were made for epistasis_v2-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on lperezmo/epistasis-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
epistasis_v2-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
625752418213b0978552f34c20ea12924c2c364b9d1c6977fec66282ffb0320d - Sigstore transparency entry: 1341675216
- Sigstore integration time:
-
Permalink:
lperezmo/epistasis-v2@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lperezmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe431a8c7a68a8a0fe79f6e761e75c0bd753f593 -
Trigger Event:
push
-
Statement type: