rsfgseapy
Python bindings for rsfgsea, a Rust implementation of preranked gene set enrichment analysis with decor, classic fgsea-compatible, and native blitz workflows.
What It Exposes
The package exposes three public entrypoints:
run_gsea_py(...)write_enrichment_plot_png_py(...)write_gsea_table_plot_png_py(...)
The API intentionally keeps fgsea-style parameter names while exposing decor first, classic fgsea-compatible modes second, and native blitz third:
method="decor"/method="classic"decor_cache,decor_expression,decor_preset,decor_stringencymode="fgsea"mode="simple"mode="multilevel"mode="blitz"nPermSimpleseednpermminSizemaxSizesampleSizescoreTypegseaParamblitz_anchors,blitz_symmetric,blitz_center,blitz_accuracy,blitz_deep_accuracy,blitz_signature_cache
Installation
From PyPI:
pip install rsfgseapy
From a repository:
git clone https://github.com/deminden/rsfgsea
cd rsfgsea
cd crates/rsfgseapy
maturin develop --release
Input Shape
ranks
- Python mapping of
gene -> score - values must be finite numeric scores
gmt_path
- path to a GMT file
Performance and Precision
The Python package calls the same Rust backend as the CLI and R wrapper. Current benchmark protocols, results, and Blitz precision evidence are owned by:
Decor Example
Decor is CPU-only. It uses fixed-permutation simple runs when nperm is set,
and decor multilevel refinement when mode="multilevel" or wrapper mode omits
nperm.
import rsfgseapy
results = rsfgseapy.run_gsea_py(
ranks={"TP53": 3.1, "MYC": 2.8, "ACTB": -1.2},
gmt_path="pathways.gmt",
method="decor",
mode="simple",
nperm=10000,
decor_cache="cache/pathways.decor.tsv",
decor_expression="data/expression.tsv",
)
Classic Minimal Example
Wrapper mode with defaults is the closest match to the standard R fgsea interface.
import rsfgseapy
results = rsfgseapy.run_gsea_py(
ranks={"GENE_A": 2.0, "GENE_B": 1.0, "GENE_C": -1.0, "GENE_D": -2.0},
gmt_path="pathways.gmt",
)
for row in results:
print(row["pathway"], row["pval"])
Classic Full Example
import rsfgseapy
ranks = {
"GENE_A": 3.2,
"GENE_B": 1.7,
"GENE_C": -2.4,
"GENE_D": -3.1,
}
results = rsfgseapy.run_gsea_py(
ranks=ranks,
gmt_path="pathways.gmt",
mode="fgsea",
gpu=False,
nPermSimple=100000,
seed=None,
nperm=None,
minSize=1,
maxSize=None,
eps=1e-50,
sampleSize=101,
scoreType="std",
gseaParam=1.0,
nproc=0,
)
for row in results:
print(row["pathway"], row["nes"], row["pval"])
Blitz Example
Blitz mode is a native Rust implementation of the blitzgsea.gsea() workflow.
import rsfgseapy
results = rsfgseapy.run_gsea_py(
ranks={"TP53": 3.1, "MYC": 2.8, "ACTB": -1.2, "GATA3": -2.0, "ESR1": 1.5},
gmt_path="pathways.gmt",
mode="blitz",
)
blitz_signature_cache=True reuses native blitz null-model fits for repeated identical calls in the same Python process. Set it to False to force cold calibration.
Plotting
import rsfgseapy
rsfgseapy.write_enrichment_plot_png_py(
ranks={"GENE_A": 2.0, "GENE_B": 1.0, "GENE_C": -1.0, "GENE_D": -2.0},
pathway_genes=["GENE_A", "GENE_B"],
output_path="enrichment.png",
pathway_name="PW_A",
dpi=300,
title="PW_A",
)
For multi-pathway summaries:
import rsfgseapy
rsfgseapy.write_gsea_table_plot_png_py(
ranks={"GENE_A": 2.0, "GENE_B": 1.0, "GENE_C": -1.0, "GENE_D": -2.0},
pathways=[("PW_A", ["GENE_A", "GENE_B"]), ("PW_B", ["GENE_C", "GENE_D"])],
results=[
{"pathway": "PW_A", "nes": 1.5, "pval": 0.01, "padj": 0.02},
{"pathway": "PW_B", "nes": -1.4, "pval": 0.03, "padj": 0.05},
],
output_path="table.png",
dpi=300,
)
All plotting parameters are available in the Python API; the examples above keep only the most common publication-oriented overrides visible.
For the full cross-interface plotting guide, see:
nPermSimple vs nperm
These two names come from fgsea and they are not interchangeable.
nPermSimple
- the normal simple-stage permutation count
- used by default in wrapper mode
- tune this when you want a different wrapper screening budget
nperm
- explicit fixed-permutation override
- in wrapper mode, setting
npermforces simple-mode execution instead of multilevel refinement - leave this as
Noneunless you intentionally want simple mode
Practical rule:
- leave
seed=Nonefor a fresh random run, or setseed=<int>for reproducibility - light users: keep
nperm=None - use
nPermSimpleto tune the default wrapper behavior - only set
npermwhen you deliberately want fixed-permutation simple execution - for CPU/GPU or R/GPU comparisons, prefer
nPermSimple=100000as a practical baseline; use10000only as a smoke tier and1000000for final tail/stress checks when runtime allows
Returned Results
Each result row is a dictionary with:
pathwaysizeesnespvalpadjlog2errleading_edge
leading_edge is returned as a Python list of genes.
GPU Support
gpu=True enables the hybrid GPU path when the extension is built with the gpu feature.
Current behavior:
- GPU accelerates simple-stage screening
- CPU performs parity-focused multilevel refinement
If the extension is built without GPU support, gpu=True raises a runtime error.
On WSL2, CUDA can be visible while WebGPU still selects Mesa llvmpipe. If
nvidia-smi works but gpu=True fails with a llvmpipe adapter error, start
Python with Mesa's D3D12 path enabled:
export GALLIUM_DRIVER=d3d12
export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA
For older builds or adapter debugging, also try WGPU_BACKEND=gl and
RSFGSEA_GPU_ALLOW_GL=1.
Supported Python Versions
The package metadata targets Python 3.10 and newer.
Project Links
- Repository: https://github.com/deminden/rsfgsea
- Main project docs: https://github.com/deminden/rsfgsea/tree/main/docs
- Rust crate: https://crates.io/crates/rsfgsea
Release files for rsfgseapy 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rsfgseapy-0.4.0.tar.gz | 2.3 MB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rsfgseapy-0.4.0-cp314-cp314-win_amd64.whl | CPython 3.14 | CPython 3.14 | Windows x86-64 | Details |
| rsfgseapy-0.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.14 | CPython 3.14 | Linux glibc 2.17+ x86-64 | Details |
| rsfgseapy-0.4.0-cp314-cp314-macosx_11_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 11.0+ ARM64 | Details |
Total release size: 6.4 MB
Release files / rsfgseapy-0.4.0.tar.gz
| Download URL | rsfgseapy-0.4.0.tar.gz |
|---|---|
| Size | 2.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bee84d8d212792399a2b4d93b771703f95b2c69ededb3aa4cee5af750bddc45c
|
|
BLAKE2b-256 checksum How to use checksums |
451f44009485b44ca3f8d8bf01095bc32bd71fd8fee3124caaf61bc747a7b415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logRelease files / rsfgseapy-0.4.0-cp314-cp314-win_amd64.whl
| Download URL | rsfgseapy-0.4.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
39d086687792bedc7bf12aa6180393ac3a35e6d36452a92c1798036f1b3167e6
|
|
BLAKE2b-256 checksum How to use checksums |
3961f186a69d0fca6c189aa8bdb35d02166c8d4630a1a228e1772036c0b55b6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logRelease files / rsfgseapy-0.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | rsfgseapy-0.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
abf068c63a213d79ec4534ac709a382ab5f79a98024f0e60cbd38e113e944ba1
|
|
BLAKE2b-256 checksum How to use checksums |
1a0f441e160208f70eebe714ec51b26f736d88171aadd2eaea3df72b7cd10f86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logRelease files / rsfgseapy-0.4.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | rsfgseapy-0.4.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0df530131a9de2c2b892687ee3047cade0f45446e9e15e9a63abf13ff615b9a0
|
|
BLAKE2b-256 checksum How to use checksums |
e5160ed37037a438cc738d746f3c7923ed525732e8bef4bb525ccf8e108869fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency log