Single-cell RNA Analysis
Use this workflow for human or mouse 10x GEX scRNA-seq or snRNA-seq after cell
calling. It preserves raw counts, keeps descriptive cluster markers separate
from condition inference, and treats annotations as evidence until the user
confirms them.
Before running
- Read the input contract, select exactly one
analysis_mode, and resolve every input path. Use descriptive only for a
single h5ad without a valid condition contrast; otherwise use comparative.
- Run
preflight(config). Do not proceed when status is invalid.
- Show the user warnings about ambient RNA, confounding, annotation evidence,
or insufficient donor replication before interpreting results.
- Harmony is opt-in only. Never infer a batch key or silently replace a
confounded one.
Call the workflow
The directory contains hyphens, so import it with importlib:
import importlib
single_cell = importlib.import_module("single-cell-rna-analysis.kernel")
config = {
"schema_version": 1,
"analysis_mode": "comparative",
"organism": "human",
"modality": "scrna",
"input": {"mode": "sample_sheet", "path": "samples.csv"},
"reference": {
"gene_id_type": "symbol",
"genome_build": "GRCh38",
"annotation_release": "GENCODE 46",
},
"design": {
"tested": "stim",
"reference": "control",
"condition_key": "condition",
"donor_key": "donor_id",
"paired": True,
"covariates": [],
},
"integration": {"method": "none", "batch_keys": []},
}
check = single_cell.preflight(config)
result = single_cell.run(config, "single-cell-run")
For a single h5ad with no donor or condition metadata, use descriptive mode:
config = {
"schema_version": 1,
"analysis_mode": "descriptive",
"organism": "human",
"modality": "scrna",
"input": {
"mode": "h5ad",
"path": "pbmc3k.h5ad",
"counts_layer": "X",
"sample_id": "pbmc3k",
},
"reference": {
"gene_id_type": "symbol",
"genome_build": "hg19",
"annotation_release": "GENCODE 19",
},
"integration": {"method": "none", "batch_keys": []},
}
Descriptive mode never invents donor/condition labels, performs integration,
or emits inferential DE/DA. It runs raw-count validation, within-sample QC,
embedding, resolution-sweep clustering, descriptive markers and optional
evidence-assisted annotation.
run() and resume() return status, run_dir, featured_files, warnings,
annotation_status, statistics_status, and manifest. Save every featured
file as an Artifact:
for featured_file in result["featured_files"]:
host.save_artifact(featured_file)
If a run was interrupted, call:
resumed = single_cell.resume("single-cell-run")
Resume validates the resolved configuration and input hashes. A changed source
invalidates dependent checkpoints instead of mixing results from different
inputs.
Stage routing
- Input ambiguity or validation failure: use
the input contract.
- QC, Scrublet, representation, Harmony, clustering, and marker questions: use
the scientific workflow.
- Marker panels, reference evidence,
Unknown, or confirmed labels: use
the annotation contract.
- Pseudobulk DE, pairing, donor replication, or Milo DA: use
the statistics contract.
- Checkpoints, statuses, manifest, or Artifact delivery: use
the output contract.
Non-negotiable interpretation rules
- A normalized-only matrix is not valid input for formal analysis.
- Multiple samples do not imply that integration is appropriate.
- UMAP appearance does not establish an optimal clustering resolution.
- Cluster markers are descriptive and are not condition DE.
- Descriptive mode cannot support condition, donor, treatment or causal claims.
- Cells are not biological replicates. Inferential DE/DA requires at least
three independent donors in each contrast level.
- Candidate labels, including reference transfer, are not ground truth.
- scVI, scGPT, GPU, remote compute, ambient correction, FASTQ processing and
downstream specialty analyses require a separate, explicit workflow.
1---2name: single-cell-rna-analysis3description: Reproducible Scanpy workflow for human or mouse 10x scRNA-seq and snRNA-seq count matrices: single-sample descriptive QC, clustering and annotation, or comparative donor-aware pseudobulk DE and Milo DA; plus preflight validation, optional explicitly requested Harmony, checkpoints, resume, and a checksummed analysis bundle. Use for cell-called GEX matrices, not FASTQ, CITE-seq, ATAC, Multiome, spatial, trajectory, communication, or CNV analysis.4---56# Single-cell RNA Analysis78Use this workflow for human or mouse 10x GEX scRNA-seq or snRNA-seq after cell9calling. It preserves raw counts, keeps descriptive cluster markers separate10from condition inference, and treats annotations as evidence until the user11confirms them.1213## Before running14151. Read [the input contract](references/input-contract.md), select exactly one16 `analysis_mode`, and resolve every input path. Use `descriptive` only for a17 single h5ad without a valid condition contrast; otherwise use `comparative`.182. Run `preflight(config)`. Do not proceed when `status` is `invalid`.193. Show the user warnings about ambient RNA, confounding, annotation evidence,20 or insufficient donor replication before interpreting results.214. Harmony is opt-in only. Never infer a batch key or silently replace a22 confounded one.2324## Call the workflow2526The directory contains hyphens, so import it with `importlib`:2728```python29import importlib3031single_cell = importlib.import_module("single-cell-rna-analysis.kernel")32config = {33 "schema_version": 1,34 "analysis_mode": "comparative",35 "organism": "human",36 "modality": "scrna",37 "input": {"mode": "sample_sheet", "path": "samples.csv"},38 "reference": {39 "gene_id_type": "symbol",40 "genome_build": "GRCh38",41 "annotation_release": "GENCODE 46",42 },43 "design": {44 "tested": "stim",45 "reference": "control",46 "condition_key": "condition",47 "donor_key": "donor_id",48 "paired": True,49 "covariates": [],50 },51 "integration": {"method": "none", "batch_keys": []},52}5354check = single_cell.preflight(config)55result = single_cell.run(config, "single-cell-run")56```5758For a single h5ad with no donor or condition metadata, use descriptive mode:5960```python61config = {62 "schema_version": 1,63 "analysis_mode": "descriptive",64 "organism": "human",65 "modality": "scrna",66 "input": {67 "mode": "h5ad",68 "path": "pbmc3k.h5ad",69 "counts_layer": "X",70 "sample_id": "pbmc3k",71 },72 "reference": {73 "gene_id_type": "symbol",74 "genome_build": "hg19",75 "annotation_release": "GENCODE 19",76 },77 "integration": {"method": "none", "batch_keys": []},78}79```8081Descriptive mode never invents donor/condition labels, performs integration,82or emits inferential DE/DA. It runs raw-count validation, within-sample QC,83embedding, resolution-sweep clustering, descriptive markers and optional84evidence-assisted annotation.8586`run()` and `resume()` return `status`, `run_dir`, `featured_files`, `warnings`,87`annotation_status`, `statistics_status`, and `manifest`. Save every featured88file as an Artifact:8990```python91for featured_file in result["featured_files"]:92 host.save_artifact(featured_file)93```9495If a run was interrupted, call:9697```python98resumed = single_cell.resume("single-cell-run")99```100101Resume validates the resolved configuration and input hashes. A changed source102invalidates dependent checkpoints instead of mixing results from different103inputs.104105## Stage routing106107- Input ambiguity or validation failure: use108 [the input contract](references/input-contract.md).109- QC, Scrublet, representation, Harmony, clustering, and marker questions: use110 [the scientific workflow](references/scientific-workflow.md).111- Marker panels, reference evidence, `Unknown`, or confirmed labels: use112 [the annotation contract](references/annotation-contract.md).113- Pseudobulk DE, pairing, donor replication, or Milo DA: use114 [the statistics contract](references/statistics-contract.md).115- Checkpoints, statuses, manifest, or Artifact delivery: use116 [the output contract](references/output-contract.md).117118## Non-negotiable interpretation rules119120- A normalized-only matrix is not valid input for formal analysis.121- Multiple samples do not imply that integration is appropriate.122- UMAP appearance does not establish an optimal clustering resolution.123- Cluster markers are descriptive and are not condition DE.124- Descriptive mode cannot support condition, donor, treatment or causal claims.125- Cells are not biological replicates. Inferential DE/DA requires at least126 three independent donors in each contrast level.127- Candidate labels, including reference transfer, are not ground truth.128- scVI, scGPT, GPU, remote compute, ambient correction, FASTQ processing and129 downstream specialty analyses require a separate, explicit workflow.