Pure-Python port of the R/CRAN package susieR — Sum of Single Effects (SuSiE) regression for Bayesian variable selection and genetic fine-mapping.
Project description
py-susie
Pure-Python port of the R/CRAN package susieR — the "Sum of Single Effects" (SuSiE) regression model for Bayesian variable selection and genetic fine-mapping (Wang, Sarkar, Carbonetto & Stephens, J. R. Stat. Soc. B 2020, 82:1273-1300; Zou, Carbonetto, Wang & Stephens, PLoS Genetics 2022, 18:e1010299).
pysusie is a standalone, dependency-light implementation of susieR's
complete computational core. It does not require R or rpy2 — only
numpy, scipy, pandas and matplotlib.
| PyPI / import name | pysusie |
| License | BSD 3-Clause (same as upstream susieR) |
| Upstream | susieR 0.14.2 (CRAN) |
What is SuSiE?
SuSiE fits the sparse linear regression y = mu + Xb + e under the
"susie assumption" that b is a sum of L single effects, each a
vector with exactly one non-zero element. The fitting algorithm,
Iterative Bayesian Stepwise Selection (IBSS), is a fast coordinate
ascent over L Bayesian single-effect regressions. SuSiE summarises
uncertainty with credible sets — small groups of variables, one of
which is (with high probability) the true effect — which is especially
useful when variables are highly correlated, as in genetic fine-mapping.
Install
pip install pysusie # once published
# or, from a checkout:
pip install -e .
Dependencies: numpy, scipy, pandas, matplotlib.
Quick start
Individual-level data
import numpy as np
import pysusie as ps
rng = np.random.default_rng(1)
X = rng.standard_normal((400, 200))
beta = np.zeros(200); beta[[10, 50, 120]] = 1.0
y = X @ beta + rng.standard_normal(400)
fit = ps.susie(X, y, L=10)
fit.sets["cs"] # credible sets (0-based indices)
fit.pip # posterior inclusion probabilities
ps.coef_susie(fit) # intercept + per-variable effects
ps.susie_plot(fit, "PIP", add_legend=True)
Summary-statistics fine-mapping (genetics)
# z : p-vector of GWAS z-scores
# R : p x p LD (correlation) matrix
# n : sample size
fit = ps.susie_rss(z=z, R=R, n=n, L=10)
# Or from effect estimates and standard errors:
fit = ps.susie_rss(bhat=bhat, shat=shat, R=R, n=n)
Sufficient statistics
ss = ps.compute_suff_stat(X, y)
fit = ps.susie_suff_stat(ss["XtX"], ss["Xty"], ss["yty"], ss["n"],
X_colmeans=ss["X_colmeans"], y_mean=ss["y_mean"])
Public API
- Fitting —
susie,susie_suff_stat,susie_rss,susie_rss_lambda. - Sufficient statistics / univariate —
compute_suff_stat(compute_ss),univariate_regression,calc_z. - Single-effect core —
single_effect_regression,single_effect_regression_ss,single_effect_regression_rss. - Inference —
susie_get_cs,susie_get_pip,susie_get_objective,susie_get_posterior_mean,susie_get_posterior_sd,susie_get_lfsr,susie_get_niter,susie_get_prior_variance,susie_get_residual_variance,susie_get_posterior_samples,get_cs_correlation,n_in_CS,in_CS. - Prediction / utilities —
coef_susie,predict_susie,susie_init_coef,susie_prune_single_effects. - Diagnostics —
estimate_s_rss,kriging_rss. - Plotting —
susie_plot.
Numerical parity with susieR
pysusie is a faithful, line-by-line port of the susieR R source. On
susieR's bundled N3finemapping fine-mapping benchmark the Python
results are numerically identical to susieR 0.14.2:
| quantity | susie |
susie_rss |
|---|---|---|
| PIP Pearson r | 1.000 (max abs diff ~1e-11) | 1.000 (~1e-9) |
per-effect alpha |
max abs diff ~1e-11 | ~1e-9 |
| ELBO | diff ~1e-12 | diff ~1e-12 |
sigma2 |
diff ~1e-11 | exact |
| credible sets | identical | identical |
See tests/test_r_parity.py and examples/compare_R_vs_Python.ipynb.
Tests
python -m pytest tests/ -q
tests/test_smoke.py runs without R; tests/test_r_parity.py compares
against susieR (skipped automatically when R / susieR is unavailable).
Relationship to upstream
This port mirrors susieR's R source faithfully: susie.R,
susie_rss.R, susie_ss.R, single_effect_regression*.R, elbo*.R,
estimate_residual_variance.R, susie_utils.R, cs/credible-set logic
and susie_plots.R. The IBSS algorithm, ELBO, prior-variance estimation
(EM / optim / uniroot), credible-set purity filtering and the
susie_get_* family are all reproduced.
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 pysusie-0.1.0.tar.gz.
File metadata
- Download URL: pysusie-0.1.0.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
118d10304df91f5f29f9e3ed6aab611fcac1ce2d931afd3a43589978f07c6d30
|
|
| MD5 |
2a26eec0b3366147a36a62c126783689
|
|
| BLAKE2b-256 |
825579f099b2091e85833b113a88c3daf9ed0b8e05ee9c9c7b768fd3cf289d38
|
Provenance
The following attestation bundles were made for pysusie-0.1.0.tar.gz:
Publisher:
publish.yml on omicverse/py-susie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysusie-0.1.0.tar.gz -
Subject digest:
118d10304df91f5f29f9e3ed6aab611fcac1ce2d931afd3a43589978f07c6d30 - Sigstore transparency entry: 1582436879
- Sigstore integration time:
-
Permalink:
omicverse/py-susie@b8927bcecbc250ab7f058e0f2a1c2d15d9596b19 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/omicverse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8927bcecbc250ab7f058e0f2a1c2d15d9596b19 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pysusie-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pysusie-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42ad24c520cbae759790879ce4b5b5947e2ed696fade53520fff138a77d6ddbc
|
|
| MD5 |
e2eef3601e28fff226c7bb82fc27ee53
|
|
| BLAKE2b-256 |
a7135100e4827491688bd668d520957429bd6b659b3ec6d5297b833af45a22bd
|
Provenance
The following attestation bundles were made for pysusie-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on omicverse/py-susie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysusie-0.1.0-py3-none-any.whl -
Subject digest:
42ad24c520cbae759790879ce4b5b5947e2ed696fade53520fff138a77d6ddbc - Sigstore transparency entry: 1582436987
- Sigstore integration time:
-
Permalink:
omicverse/py-susie@b8927bcecbc250ab7f058e0f2a1c2d15d9596b19 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/omicverse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8927bcecbc250ab7f058e0f2a1c2d15d9596b19 -
Trigger Event:
workflow_dispatch
-
Statement type: