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 Using Iterative Machine Learning to Detect Subtle Gene Expression Patterns in Single-Cell Data
bioRxiv link coming soon

Metadata

Release files for recursieve 1.0.3

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.3
File Size Uploaded
recursieve-1.0.3.tar.gz 24.1 kB Details

Built distribution (wheel)

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

Total release size: 43.6 kB

Release files / recursieve-1.0.3.tar.gz

Download URL recursieve-1.0.3.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9a92b9dfc225967eb1c2549f6d875fc611667c4c58e3b780691b80c7a5dd12c8
BLAKE2b-256 checksum
How to use checksums
c0cd0ef83d99322633aa8e9582667da918d2096ce74500f71b83ff70d27abe50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 Oct 13, 2026.

Transparency log

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

Download URL recursieve-1.0.3-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22afc9810fa74b48fbfd5bc14a4253db13dacf6dd0f5ec5f5495192c0dd914d8
BLAKE2b-256 checksum
How to use checksums
57b2e453fe7c4776a26801cf69d709bb5c871736263b9ab54736c0eda5d9e947
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

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