Skip to main content

Recursieve logo

DOI

RecurSieve is an iterative gene selection algorithm that identifies discriminative genes between two biological groups in single-cell datasets. It uses an ensemble learning approach with a blend of random forest classifiers and gaussian mixture models to progressively select genes that best separate the groups, collapsing selected genes into a lower dimensional representational axis at each iteration.

Installation

Install from PyPI:

pip install recursieve

RecurSieve requires Python 3.12 or newer.

To install the development version from GitHub:

pip install git+https://github.com/ArpiarSaundersLab/RecurSieve.git

Usage

import anndata as ad
from recursieve import recursieve

adata = ad.read_h5ad("data/alz.h5ad")
model = recursieve(
    adata=adata,
    group1="control",
    group2="disease",
    field_name="condition",
    max_iterations=100,
)

# all genes found
panel = model.genes

# genes unique to RecurSieve
non_de_genes = model.unique_gene_panel 

Example

examples/recursieve_example.ipynb is a short notebook that runs RecurSieve on simulated data, with no download needed. It builds a two-group dataset of 2,000 cells and 2,000 genes. In 10 of the genes, the control group is unimodal and the disease group is bimodal around the same center, and those genes move together. Because the group means match, differential expression has little to find. The notebook runs RecurSieve with default parameters and checks which of the 10 genes appear in unique_gene_panel.

Parameters

Parameter Type Default Description
adata AnnData required Annotated data matrix
group1 str required First group label
group2 str required Second group label
field_name str "sample" Column in obs containing group labels
plots bool False Generate visualization plots
print_to_console bool False Print selected genes during iteration
max_iterations int 100 Maximum iterations to run
additive bool True Add new genes to panel or replace
flip_rate_percentage float 0.01 Stop when the label flip rate falls below this value
patience int or None 10 Stop after this many iterations without a new flip-rate minimum (None disables)
pval_cutoff float 0.05 P-value threshold for differential expression
logfc_cutoff float 0.1 Absolute log2 fold-change threshold for differential expression
seed int 42 Random seed for reproducibility
summary_method str "mean" Method to collapse genes: "mean" or "pca"
n_estimators int 300 Number of random forest trees
n_jobs int -1 Number of parallel jobs (-1 uses all cores)
max_depth int or None 10 Maximum random forest tree depth
n_seeds int 10 Seeds used by seed_stability()
preprocess bool True Run QC, normalization, and HVG selection
run bool True Run the pipeline on construction; if False, call fit() later
annsql_db str or None None AnnSQL database to load instead of adata

Robustness checks

seed_stability checks whether the same genes are selected with different random seeds. coexpression_null checks whether the selected genes are found more often than by chance, by rerunning on randomized data.

Each seed and each shuffle is a full RecurSieve run, so these checks take much longer than a single run. On a 10-core laptop, 25 shuffles took about 1.5 hours for 25,000 cells and about 3.5 hours for 50,000 cells.

Both methods return a dictionary of pandas DataFrames and do not write files. The example below runs both checks and saves the main tables as CSV files.

seeds = model.seed_stability(n_seeds=10)
null = model.coexpression_null(n_shuffles=100)

seeds["gene_frequency"].to_csv("seed_gene_frequency.csv", index=False)
null["pvalues"].to_csv("null_pvalues.csv", index=False)
null["gene_frequency"].to_csv("null_gene_frequency.csv", index=False)

License

The RecurSieve software is released under the MIT License. The data, figures, and tables in manuscript/ are dedicated to the public domain under CC0 1.0.

Citation

RecurSieve: A Python Package to Detect Subtle Gene Expression Differences Across Single-Cell RNA-seq Comparisons Using Iterative Machine Learning
bioRxiv link coming soon

Metadata

Release files for recursieve 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recursieve 1.0.4
File Size Uploaded Provenance Actions
recursieve-1.0.4.tar.gz 24.1 kB With provenance Details for recursieve-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for recursieve 1.0.4
File Interpreter ABI Platform Actions
recursieve-1.0.4-py3-none-any.whl Python 3 none any Details for recursieve-1.0.4-py3-none-any.whl

Total release size: 43.6 kB

Release files / recursieve-1.0.4.tar.gz

Download URL recursieve-1.0.4.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4f9d432840fd828339d2e68fe0a2af97805dd565367ca51e66dbe68a5d3dc2ad
BLAKE2b-256 checksum
How to use checksums
55630de67e04b53ad01270c9d7b90b54514cfcc40bf59d7460b744545368d440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / recursieve-1.0.4-py3-none-any.whl

Download URL recursieve-1.0.4-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6475a5ec6f216d9df97563468f076dfaf9de2c26425a8481fe2980840b442cb7
BLAKE2b-256 checksum
How to use checksums
4073aa698d91ad08a7e3b06a7bee08460ee87a46886d276887a86ce2c081dd47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Security for recursieve 1.0.4

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for recursieve-1.0.4.tar.gz

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 Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page