CellTypePilot
Local-first single-cell annotation review plugin for your existing coding workspace.
For individual researchers, small labs, and computational biologists — no standalone app, no heavy infrastructure.
CellTypePilot operates across two coordinated distributions: PyPI delivers the deterministic Python backend, while each GitHub Release delivers the complete Agent plugin bundle for OpenAI Codex and Anthropic Claude Code.
CellTypePilot is an evidence-first review plugin for Claude Code and OpenAI Codex. It turns pre-clustered scRNA-seq and spatial transcriptomics data into auditable draft cell-type annotations — featuring governed context, a backend-neutral hierarchical selective decision layer, independent cell-state analysis, conservative critic review, a risk-adaptive claim ladder, and an auto-generated methodology paragraph for scientific publication.
It integrates candidates from CellTypist, popV, SingleR, scANVI, Azimuth, CHETAH, custom references, and optional LLM hypotheses. Marker scoring and CellAssign contribute evidence only and cannot unilaterally force an identity.
It is not an autonomous analysis agent. It is a deterministic, artifact-producing plugin that embeds rigorous evidence review, conservative abstention, benchmark holdouts, and provenance into your daily workflow. A qualified human retains final biological ownership.
🌟 Key Highlights (v0.5.0)
- Risk-Adaptive Claim Ladder: Decouples bold exploratory
working_hypothesis (allowing downstream analysis to proceed under explicit usage badges) from conservative scientific_claim (Unknown until confirmed by a named human signer).
- Productive Review Workflow: Automatic high-priority triage focusing on the highest-risk 20% of clusters (capped at 25 clusters) to maximize human reviewer efficiency without review fatigue.
- Multi-Backend Governance: Standardized contracts for Python runtimes (CellTypist, scANVI, popV), R/Bioconductor adapters (SingleR, CHETAH, Azimuth, CellAssign), and custom references under strict independence group tracking.
- Balanced Cascade Optimization (
balanced_cascade): Runs lightweight primary backends first, selectively escalating expensive backends only to unresolved or ambiguous clusters.
- Hierarchical Selective Decision: Two independent backend families required for leaf calls; sibling disagreements collapse conservatively to governed ancestor terms rather than forcing unverified leaf labels.
- Independent Identity × State: Canonical cell identity and exploratory activation/functional states are scored on separate axes; state evidence cannot overwrite or rescue an abstained identity.
- Governed Context Pack: Free text remains provenance-only; custom markers enter ordinary differential expression and critic gates under strict scoping and hashing.
- Blinded Human Review Experiment Framework: Preregistered 3-arm crossover evaluation protocol measuring expert revision time under an accuracy non-inferiority boundary.
Current Validation Boundary
| Available in v0.5.0 |
Not yet claimed |
| Direction-, log2FC-, FDR-, and expression-fraction-gated DE evidence |
Biological superiority over CellTypist, SingleR, Azimuth, or popV |
| Complete expected-marker denominators, with missing genes separated from present-but-silent genes |
A completed public multi-study/donor benchmark |
Explicit Unknown/abstain decisions; low-evidence clusters cannot pass |
Calibrated accuracy for every tissue, platform, disease state, or species |
| Unified annotation pipeline for scoring, critic review, write-back, HTML report, and manifest |
Primary-source experimental verification of every bundled marker relationship |
| Locked study/donor holdout runner and comparator adapters |
Clinical-grade or fully automated biological decisions |
| Governed Context Pack: structured custom markers share normal evidence gates; free text is provenance-only |
That free-text biological context constitutes validated evidence |
| Separate identity and state outputs; state scoring cannot overwrite identity or rescue an abstained identity |
Calibrated cell-state accuracy or comprehensive state coverage |
| Backend-neutral candidate contract, ontology-aware parent fallback, and explicit candidate sets |
That backend agreement is a calibrated probability or selective-risk guarantee |
Three depth-validation domains: lung, gut/IBD, and tumor microenvironment, all currently fail-closed as evidence_required |
Claim readiness before locked multi-study evidence, separate calibration, and expert adjudication are complete |
For mkg-2026.08.1, 280 of 599 bundled marker relationships have been verified as literature_cooccurrence_supported via an auditable PubMed co-occurrence sweep (celltypepilot curate). The remaining 319 relationships are aggregate_source_only_not_edge_verified. All relationships remain usable under the default exploratory database evidence policy; the literature policy requires at least co-occurrence support.
🏗️ Decision & Governance Architecture
[ Pre-clustered AnnData (.h5ad / .rds) ]
│
▼
[ 1. Data Adapter & Preflight ]
│
┌───────────────────────────┴───────────────────────────┐
▼ ▼
[ Governed Context Pack ] [ Native Backend Candidates ]
(JSON/CSV scoped & hashed) (CellTypist, popV, SingleR,
│ scANVI, Azimuth, CHETAH)
▼ │
[ Marker Scorer & Critic ] ▼
(DE direction, log2FC, FDR, [ Hierarchical Selective Decision ]
coverage vs complete panel) (2 independent groups for leaf,
│ governed ancestor collapse)
└───────────────────────────┬───────────────────────────┘
▼
[ Risk-Adaptive Claim Ladder ]
├── working_hypothesis (bold continuation)
├── risk_tier (green / yellow / red)
└── scientific_claim (conservative, human-signed)
│
┌───────────────────────────┼───────────────────────────┐
▼ ▼ ▼
[ State Lens ] [ Novelty / OOD Axis ] [ Productive Review Queue ]
(Independent activation/ (Atlas gaps & unexplained (Top 20% highest risk,
functional state axis) DE program review) batch sign-off)
│
▼
[ Auditable Artifact Outputs ]
├── data.annotated.h5ad
├── evidence_table.csv & contrastive_evidence.csv
├── report_draft.html & figures/
└── manifest.json & methodology_draft.txt
📦 What You Get
output/
├── data.annotated.h5ad # AnnData with identity, state, risk_tier, and confidence in obs
├── evidence_table.csv # Per-cluster scores, markers, critic flags, claims, and licenses
├── contrastive_evidence.csv # Top-two candidate contrast: support, conflicts, and gaps
├── evidence_gaps.json # Unknown clusters -> observed evidence deficits & next actions
├── backend_escalation_plan.json # Yellow-risk clusters needing escalation candidate evidence
├── state_results.csv # Independent cell-state candidate, decision, and marker evidence
├── novelty_results.csv # Independent Novelty/OOD candidate review axis
├── context_pack.normalized.json # Scoped, normalized, and hashed context pack (when supplied)
├── report_draft.html # Standalone interactive HTML report with embedded figures
├── methodology_draft.txt # Draft methods paragraph formatted for publication
├── manifest.json # Run provenance: version, parameters, data hash, output hashes
└── figures/
├── umap_cluster.png # UMAP by cluster ID (colorblind-friendly palette)
├── umap_celltype.png # UMAP by annotated cell type
├── umap_confidence.png # UMAP by critic confidence tier
├── marker_dotplot.png # Cell type x marker gene expression dotplot
└── confidence_distribution.png
🚀 Quick Start
1. Installation
# Core Python backend
pip install celltypepilot
# Verify installation and dependencies
celltypepilot doctor
Optional backend extras:
pip install "celltypepilot[web]" — Interactive Web Inspector review cockpit
pip install "celltypepilot[mcp]" — Local MCP facade for Agent hosts
pip install "celltypepilot[native]" — CellTypist, scANVI, popV (Python 3.12+), and LLM support
pip install "celltypepilot[seurat]" — Seurat .rds to AnnData conversion
pip install "celltypepilot[all]" — All optional features
2. Inspect Dataset
celltypepilot inspect --input data.h5ad
Automatically inspects and reports:
- Detected species (Ensembl prefix voting across 9 species)
- Atlas support boundaries (human / mouse supported)
- Tissue matching against built-in Marker Knowledge Graph
- Cluster and embedding keys in
obs / obsm
- Layer normalization state (counts vs log1p)
3. Annotate
# Basic deterministic annotation
celltypepilot annotate --input data.h5ad --cluster-key leiden --species human --tissue blood
# With multi-backend candidates
celltypepilot annotate --input data.h5ad --cluster-key leiden --tissue lung \
--candidate-table celltypist.csv --candidate-table popv.csv
# With governed native backends configuration
celltypepilot annotate --input data.h5ad --cluster-key leiden --tissue lung \
--native-backends native_backends.json
# With structured disease context & custom markers
celltypepilot annotate --input data.h5ad --cluster-key leiden --species human --tissue kidney \
--context "Post-ischemic reperfusion injury" \
--context-file context.json --custom-markers custom_markers.csv
4. Interactive Review & Deep Review
# Launch interactive Web Inspector dashboard
celltypepilot inspect-web --output output/
# Deep-review a specific flagged cluster
celltypepilot critic --input data.h5ad --cluster-key leiden --focus cluster_3
# Validate specific markers against PubMed literature
celltypepilot literature --cell-type "T cells" --markers "CD3E,CD4,CD8A"
5. Python API Usage
import celltypepilot as ctp
import scanpy as sc
adata = sc.read_h5ad("pbmc.h5ad")
# Scanpy-native in-place annotation
adata = ctp.annotate(adata, cluster_key="leiden", species="human", tissue="blood")
# Or obtain full structured product result dictionary
result = ctp.annotate(
adata,
cluster_key="leiden",
species="human",
tissue="blood",
output_dir="ctp_run",
return_result=True,
)
print(result["product_result"]["summary"])
🔌 Agent Plugin Architecture
CellTypePilot attaches directly to your existing coding assistant workspace (Claude Code or OpenAI Codex):
| Platform |
Manifest |
Host Components |
Discovery |
| Anthropic Claude Code |
.claude-plugin/plugin.json |
commands/*.md, hooks/, rules/ |
Discovered in .claude-plugin/ |
| OpenAI Codex |
.codex-plugin/plugin.json |
skills/*/agents/openai.yaml, AGENTS.md |
Discovered in .codex-plugin/ |
| CLI / Script |
N/A |
Typer CLI, Python API |
celltypepilot CLI / import |
Download celltypepilot-plugin-0.5.0.zip from GitHub Releases and extract it into your workspace plugin directory.
Agent Golden Workflow (MCP)
For Agent hosts, CellTypePilot exposes a four-stage stateful workflow:
prepare_annotation — Inspects data, validates parameters, and returns a hashed, locked execution plan.
annotate_from_plan — Executes annotation strictly following the plan.
review_uncertain_clusters — Read-only evidence review for flagged or Unknown clusters.
finalize_reviewed_annotations — Gated step requiring an explicit human signer; applies confirmed overrides and regenerates audit trails.
🧬 Built-in Marker Knowledge Graph (mkg-2026.08.1)
The bundled marker knowledge graph covers 80+ cell types across 11 core tissues, mapped to Cell Ontology (CL) terms with positive/negative marker definitions:
- Blood/PBMC: T cells (CD4, CD8, Naive, Memory, Treg, Th1, Th17), B cells, Plasma cells, NK cells, Monocytes (Classical, Non-classical), cDCs, pDCs, Platelets
- Lung: Alveolar macrophages, AT1, AT2, Ciliated, Club, Goblet, Basal cells
- Liver: Hepatocytes, Kupffer cells, Cholangiocytes, Endothelial cells, Hepatic stellate cells
- Brain: Excitatory neurons, Inhibitory neurons, Astrocytes, Oligodendrocytes, OPCs, Microglia
- Kidney: Proximal tubule, Loop of Henle, DCT, Podocytes, Collecting duct cells
- Gut: Enterocytes, Goblet cells, Enteroendocrine cells, Paneth cells, Stem cells
- Skin: Keratinocytes, Melanocytes, Langerhans cells, Dermal fibroblasts
- Heart: Cardiomyocytes, Endothelial cells, Fibroblasts, Smooth muscle cells
- Pancreas