sc-count
Load when turning scRNA FASTQ (or existing CellRanger/STARsolo/SimpleAF/kb-python output) into a downstream-ready AnnData. Skip when reads are already counted into AnnData (use sc-standardize-input); raw quality assessment only (use sc-fastq-qc).
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-08
- Stars
- ★ 161
- Forks
- 27
01 前言 Front Matter
- name
- sc-count
- tags
- [ "singlecell", "scrna", "counting", "cellranger", "starsolo", "simpleaf", "kb-python" ]
- trigger
- Cell Ranger count, STARsolo count, fastq to adata, raw single-cell counting, generate count matrix
- description
- Load when turning scRNA FASTQ (or existing CellRanger/STARsolo/SimpleAF/kb-python output) into a downstream-ready AnnData. Skip when reads are already counted into AnnData (use sc-standardize-input); raw quality assessment only (use sc-fastq-qc).
02 资源文件 7
- 资产文件methods.csv9.7 KB
- 参考文档references/methodology.md9.5 KB
- 参考文档references/output_contract.md3.4 KB
- 参考文档references/parameters.md2.3 KB
- 参考文档references/r_visualization.md288 B
- 脚本sc_count.py28.6 KB
- 脚本tests/test_sc_count.py5.0 KB
03 SKILL.md 正文
sc-count
Use from a step
This is CLI_ONLY: counting needs external tools and reference indexes.
from skills._sdk.notebook import run_cli
run_cli("sc-count", "--input", "data/sample_R1.fastq.gz",
"--read2", "data/sample_R2.fastq.gz", "--method", "starsolo",
"--reference", "/refs/star", "--chemistry", "10xv3",
"--whitelist", "/refs/barcodes.tsv",
inputs=["data/sample_R1.fastq.gz", "data/sample_R2.fastq.gz",
"/refs/barcodes.tsv"])
Record the reference index version in the module README as well. The demo
standardizes PBMC3k raw counts; it does not align or count reads. There is
no _api.py for this skill.
When to use
The user has FASTQ files (or pre-existing tool output directories) and
wants per-cell counts in OmicsClaw's canonical AnnData contract. Four
backends share one CLI: cellranger, starsolo, simpleaf,
kb_python. When passed a matching already-counted directory the skill
re-canonicalises rather than re-counts. Pairs with sc-fastq-qc
upstream (read QC) and sc-multi-count downstream (merging multiple
samples).
Inputs & Outputs
Inputs
- Input kinds:
file,directory - Modalities: scrna
- File types:
.fastq,.fq, compressed FASTQ, and backend-specific.h5ad - FASTQ structure: valid first record;
pairedlayout - Directory layouts (any):
paired-fastq,tenx-matrix,cellranger-output,starsolo-output,pseudoalign-output
Outputs
tables/backend_summary.csvtables/barcode_metrics.csvtables/count_summary.csvfigures/barcode_rank.pngfigures/count_complexity_scatter.pngfigures/count_distributions.pngprocessed.h5adstandardized_input.h5adfigures/manifest.json,figure_data/manifest.json, plot-data CSV filesreproducibility/commands.sh,reproducibility/requirements.txt- Backend-specific files under
artifacts/only when counting runs; BAM and HTML are not guaranteed. report.mdresult.json- Processed AnnData (
saves_h5ad)
Flow
- Resolve
--input; if it's an existing CellRanger / STARsolo / SimpleAF / kb-python output dir, re-canonicalise instead of running the backend. - Otherwise validate backend prerequisites (chemistry, reference, t2g for kb-python, whitelist for STARsolo).
- Run the chosen backend against the FASTQ (and
--read2if explicit). - Load the resulting matrix into AnnData; canonicalise (
layers["counts"],adata.raw, gene-name harmonisation). - Render barcode-rank + count-distribution figures.
- Emit
processed.h5ad+report.md+result.json.
Gotchas
- Missing input path → hard fail.
sc_count.pyraisesFileNotFoundError(f"Input path not found: {input_path}"). Common when the FASTQ dir is on a network mount that has not been resolved at run time. - STARsolo requires explicit chemistry.
sc_count.pyraisesValueError("STARsolo runs require an explicit--chemistryvalue such as10xv3.")when chemistry is left at theautodefault. STARsolo currently supports10xv2,10xv3, and10xv4; pass one of those. - Backend prerequisites are validated up front.
sc_count.pyraisesValueErrorfor missing--reference(CellRanger/STARsolo/simpleaf), missing--t2g(kb-python), or unsupported--chemistryfor STARsolo. No silent fallback to a different backend — pick a feasible one before invoking. - Choose the backend matching the existing output.
sc_count.py:maindetects directory shape within the selected--method.result.json["data"]["execution"]is empty when no backend ran.tables/backend_summary.csvis always written and can be empty; imported output may already contain backend metrics. sc_count.py:_recommended_reference_dirnames suggested reference locations, not bundled indexes. Supply references yourself. The simpleaf backend needs a configuredALEVIN_FRY_HOME; the installed simpleaf 0.24.0 failed without it during migration preflight. The demo does not validate external-tool setup.sc_count.py:maindefaults to eight threads. A directory containing several FASTQ samples needs--sample.
Key CLI
# Demo (standardizes PBMC3k counts; no counting backend)
python skills/singlecell/scrna/sc-count/sc_count.py --demo --output /tmp/sc_count_demo
# CellRanger over FASTQ
python skills/singlecell/scrna/sc-count/sc_count.py \
--input fastq_dir/ --output results/ \
--reference cellranger_transcriptome --threads 16
# STARsolo (requires explicit chemistry)
python skills/singlecell/scrna/sc-count/sc_count.py \
--input fastq_dir/ --output results/ \
--method starsolo --reference star_genome_dir --chemistry 10xv3 --whitelist barcodes.tsv
# Re-canonicalise an existing CellRanger output directory
python skills/singlecell/scrna/sc-count/sc_count.py \
--input cellranger_output_dir/ --output results/
See also
references/parameters.md— every CLI flag and per-backend prerequisitereferences/methodology.md— backend selection guide, re-canonicalise vs re-run logicreferences/output_contract.md—processed.h5adschema + table layouts- Adjacent skills:
sc-fastq-qc(upstream — read-quality check before counting),sc-multi-count(downstream — merge multiple sample outputs),sc-standardize-input(parallel — for AnnData from outside OmicsClaw)
Dependencies
Python packages this skill's script needs. They are not installed for you — check before a long run.
anndata, matplotlib, numpy, pandas, scanpy, scipy, seaborn
04 同仓库更多 Skills
demo-skill
A fixture skill for the skill environment tests. Use it for nothing else.
fake-domains
Test fixture for the golden deployment in tests/entry. Load never; it has no script.
replace-me-skill
Load when copying this directory to bootstrap a new OmicsClaw skill. Skip when an existing skill already covers the request.
spatial-velocity
Load when estimating RNA velocity on a spatial AnnData with `layers["spliced"]` + `layers["unspliced"]` via scVelo (stochastic / deterministic / dynamical) or veloVI (deep generative). Skip when input lacks the spliced/unspliced layers (must be quantified upstream by velocyto / kb-python / STARsolo); non-spatial scRNA velocity (use sc-velocity).
spatial-trajectory
Load when inferring pseudotime / lineage trajectories on a preprocessed spatial AnnData via DPT (default — diffusion pseudotime), CellRank (terminal-state + fate-probability), or Palantir (waypoint branch probabilities). Skip when the data has spliced/unspliced layers and you want velocity-driven dynamics (use spatial-velocity); non-spatial scRNA pseudotime (use sc-pseudotime).
spatial-statistics
Load when running spatial autocorrelation / hotspot / co-occurrence / neighbourhood-enrichment / Ripley K stats on a clustered spatial AnnData via squidpy. Skip when ranking spatially variable genes (use spatial-genes); tissue domain detection (use spatial-domains).