Skip to main content

Rule-based cell-type annotation for single-cell RNA-seq with automatic resolution optimization

Project description

scblueprint

Rule-based cell-type annotation for single-cell RNA-seq with automatic resolution optimization

PyPI License Python 3.11+


scblueprint is a Python library for reproducible, YAML-driven cell-type annotation of single-cell RNA-seq data. It scores gene signatures, optimizes Leiden clustering resolution, applies correction rules, and provides an explain mode that shows exactly why each cluster received its label.

Features

  • YAML blueprints - define cell types with positive/negative markers, colors, and references in a single file
  • Automatic resolution - coarse-to-fine Leiden sweep that maximizes biological label diversity
  • Correction rules - 4 built-in types (expression threshold, ontogeny override, coexpression required, mutually exclusive) plus custom Python rules
  • Explain mode - every cluster label comes with score breakdowns and rule override chains
  • Labeling strategies - majority vote or DE-gene overlap for cluster-level assignment
  • UMAP sweep - multiprocessing parameter sweep with grid output
  • Presets - mouse_cardiac with 30 literature-sourced cardiac cell types
  • Built on scanpy - integrates with any scanpy/AnnData workflow

Installation

pip install scblueprint

Quick Start

import scanpy as sc
import scblueprint as scb

adata = sc.read_h5ad("my_data.h5ad")

bp = scb.Blueprint.from_preset("mouse_cardiac")

opt = scb.LeidenOptimizer()
result = opt.find_optimal(adata, bp.signatures, "leiden",
                          negative_markers=bp.negative_markers)
print(f"Best resolution: {result.resolution}")

ann = scb.Annotator(bp)
res = ann.apply(adata, "leiden", "cell_type", de_key="global_de")
print(res.summary())

ev = res.explain("3")
print(f"{ev.final_label}: {ev.score_breakdown}")

For YAML schema, correction rules, strategies and UMAP sweep see docs/usage.md.

API

Class Description
Blueprint Load YAML, access signatures / negative_markers / colors / rules
LeidenOptimizer Scan resolutions, pick the one maximizing biological label diversity
Annotator Score -> label -> correct -> explain
UmapSweeper Multiprocessing UMAP parameter sweep with grid output
LabelCorrectionRule ABC for custom correction rules

Examples

6 runnable scripts covering basic annotation, auto-resolution, explain mode, custom rules, UMAP sweep and subpopulation deep dive - see docs/examples.md for the full list.

cd examples && python generate_all.py

Citation

If you use scblueprint in a publication, please cite it:

APA:

dam2452. (2026). scblueprint: Rule-based cell-type annotation for single-cell RNA-seq (Version 0.1.0). https://github.com/dam2452/scblueprint

BibTeX:

@software{scblueprint2026,
  title   = {scblueprint: Rule-based cell-type annotation for single-cell RNA-seq},
  author  = {dam2452},
  year    = {2026},
  version = {0.1.0},
  url     = {https://github.com/dam2452/scblueprint}
}

Contributing

Contributions are welcome! Here's how you can help:

  1. Bug reports - Open an issue with a minimal reproducible example
  2. Feature requests - Open an issue describing the use case
  3. Code contributions - Fork, create a feature branch, and open a pull request
  4. New presets - Add a YAML file under scblueprint/presets/ with markers and a test

Development setup

git clone https://github.com/dam2452/scblueprint.git
cd scblueprint
pip install -e ".[dev]"
pytest tests/ -v

License

This project is licensed under MIT - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scblueprint-0.1.0.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scblueprint-0.1.0-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file scblueprint-0.1.0.tar.gz.

File metadata

  • Download URL: scblueprint-0.1.0.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for scblueprint-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6b6b592af2f199a81fddfa118186607db597700ff91455f6fb2b6f248348a3b1
MD5 77a42bf3bfd1da11c1d41d580d682de7
BLAKE2b-256 0d9378d669658561362bf2fce64749a97a5ce58898ffe397253b5636b993cf97

See more details on using hashes here.

File details

Details for the file scblueprint-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: scblueprint-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for scblueprint-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 195295f6dfa61670a295b03f6f887637a006566f3278a65d26ab2a84f70bcd39
MD5 366360edfb1bd160eaea03113c0d6773
BLAKE2b-256 c88874a37473ebf536dfd7932dfbb68c2b8c52496b6f73df5b027bed17c4be15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page