spatial-raw-processing
Load when converting spatial transcriptomics raw FASTQ pairs through ST-Pipeline into a `raw_counts.h5ad` ready for spatial-preprocess. Skip when input is already a count-matrix AnnData (use spatial-preprocess); non-spatial bulk / scRNA FASTQ (use bulkrna-read-qc).
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-08
- Stars
- ★ 161
- Forks
- 27
01 前言 Front Matter
- name
- spatial-raw-processing
- tags
- [ "spatial", "raw-processing", "fastq", "st-pipeline", "visium", "slideseq" ]
- trigger
- spatial raw processing, raw spatial fastq, spatial fastq, st_pipeline, st pipeline, barcode coordinates, ids file, visium raw fastq, slide-seq fastq, slideseq fastq, upstream spatial processing
- description
- Load when converting spatial transcriptomics raw FASTQ pairs through ST-Pipeline into a `raw_counts.h5ad` ready for spatial-preprocess. Skip when input is already a count-matrix AnnData (use spatial-preprocess); non-spatial bulk / scRNA FASTQ (use bulkrna-read-qc).
02 资源文件 8
- 脚本examples/example_step.py717 B
- 其他r_visualization/raw_processing_publication_template.R3.5 KB
- 参考文档r_visualization/README.md1.4 KB
- 参考文档references/methodology.md7.8 KB
- 参考文档references/output_contract.md2.0 KB
- 参考文档references/parameters.md2.0 KB
- 脚本spatial_raw_processing.py12.3 KB
- 脚本tests/test_spatial_raw_processing.py3.4 KB
03 SKILL.md 正文
spatial-raw-processing
Use from a step
This is CLI_ONLY: ST-Pipeline consumes FASTQ files, barcode coordinates and reference indexes. It is not an in-memory analysis function.
from skills._sdk.notebook import run_cli
output = run_cli("spatial-raw-processing", "--input", "data/run_bundle.json",
inputs=["data/run_bundle.json", "data/R1.fastq.gz",
"data/R2.fastq.gz", "data/barcodes.tsv"])
Record the reference index version in the module README. The executable example uses synthetic upstream outputs and does not run ST-Pipeline.
When to use
The user has paired-end spatial-transcriptomics FASTQ files (read1 =
spatial barcode + UMI, read2 = cDNA) plus a STAR genome index, and
wants the standard ST-Pipeline run that produces a raw_counts.h5ad
with one row per spatial spot. Single backend: st_pipeline (calls
run_stpipeline from skills/spatial/_lib/stpipeline_adapter.py).
After this skill, chain to spatial-preprocess for QC + normalisation.
For non-spatial scRNA FASTQ use sc-fastq-qc. For bulk RNA-seq read
QC use bulkrna-read-qc.
Inputs & Outputs
Inputs
- Input kinds:
file,directory - Modalities: visium, slideseq
- File types:
.fastq,.fq,.json,.yaml,.yml - FASTQ structure: valid first record;
pairedlayout - Directory layouts (any):
paired-fastq
Outputs
tables/gene_qc.csvtables/raw_gene_qc.csvtables/raw_processing_run_summary.csvtables/raw_processing_spatial_points.csvtables/raw_spot_qc.csvtables/raw_top_genes.csvtables/run_summary.csvtables/saturation_curve.csvtables/spatial_coordinates.csvtables/spot_qc.csvtables/stage_summary.csvtables/top_genes.csvfigures/raw_detected_genes_spatial.pngfigures/raw_spot_qc_histograms.pngfigures/raw_top_genes_barplot.pngfigures/raw_total_counts_spatial.pngfigures/st_pipeline_saturation_curve.pngfigures/st_pipeline_stage_attrition.pngomicsclaw_stpipeline_run.jsonraw_counts.h5adst_pipeline.stderr.txtst_pipeline.stdout.txtreport.mdresult.json- Processed AnnData (
saves_h5ad) — addsobs:barcode,x_array,y_array;obsm:spatial
Flow
- Parse args (or load bundle JSON / YAML from positional
--input). _apply_effective_defaultsfills missing parameter values (threads, trimming, UMI ranges, etc.)._validate_real_run_bundle: checkread1/read2/ids/ref-mapexist and are well-typed; reject duplicate read1=read2; verify FASTQ extension.- Call
run_stpipeline(...)which shells out to ST-Pipeline (requires thestpipelinebinary on PATH or--stpipeline-repo+--bin-path). - Wrap the resulting count matrix into AnnData with
X = raw_counts,layers["counts"],raw = raw_counts_snapshot. - Save
raw_counts.h5adandresult.json. Print "next: spatial-preprocess on raw_counts.h5ad".
Gotchas
- All input failures raise typed exceptions wrapped in
SystemExit(1).spatial_raw_processing.pycatchesDataError/DependencyError/ParameterError/ProcessingErrorand re-raises asSystemExit(1). The originating raises live in_validate_real_run_bundle— it raisesParameterError(f"Missing required parameter: {key}")for missingread1/read2/ids; raisesDataError(...)for non-existent files; raisesDataError("Resolved read1/read2 inputs must be FASTQ files.")for non-FASTQ extensions; raisesParameterErrorfor read1==read2; raisesDataErrorfor missing / wrong-type STAR index dir; raisesDataErroronly when--ref-annotationwas provided but the path is missing or not a file (the param itself is optional — omitting it doesn't raise). --read1/--read2/--ids/--ref-mapare all required for real runs (not enforced by argparserequired=True, validated later). Missing any →ParameterError. Demo mode skips this validation entirely.- The output filename is always
raw_counts.h5ad(spatial_raw_processing.py). It's not configurable — the contract is consumed byspatial-preprocess. Multiple runs to the same--outputwill overwrite. - QC tables and figures are written.
tables/spot_qc.csvandfigures/raw_total_counts_spatial.pngdescribe the count matrix; upstream stage and saturation plots depend on available pipeline metrics. - Demo mode skips ST-Pipeline entirely.
spatial_raw_processing.pycallscreate_demo_upstream_outputs(...)to fabricate a syntheticraw_counts.h5ad. Useful for plumbing checks; does NOT exercise the FASTQ → matrix code path. --platformis a metadata label only._build_parserdocuments it as "Label recorded in outputs"; ST-Pipeline doesn't branch on it. Common values:visium,visium_hd,slideseq, custom strings.
Key CLI
# Demo (synthetic raw_counts.h5ad — does NOT run ST-Pipeline)
python skills/spatial/spatial-raw-processing/spatial_raw_processing.py --demo --output /tmp/spatial_raw_demo
# Real run with explicit args
python skills/spatial/spatial-raw-processing/spatial_raw_processing.py \
--read1 sample_R1.fastq.gz --read2 sample_R2.fastq.gz \
--ids barcodes.tsv \
--ref-map /refs/star_index_human \
--ref-annotation /refs/genes.gtf \
--exp-name visium_001 --platform visium \
--threads 16 \
--output results/
# Real run from bundle JSON
python skills/spatial/spatial-raw-processing/spatial_raw_processing.py \
--input run_bundle.json --output results/
# Slide-seq with custom UMI range
python skills/spatial/spatial-raw-processing/spatial_raw_processing.py \
--read1 R1.fq.gz --read2 R2.fq.gz --ids barcodes.tsv \
--ref-map /refs/star_index --platform slideseq \
--umi-start-position 1 --umi-end-position 8 \
--output results/
See also
references/parameters.md— every CLI flag, ST-Pipeline option mappingreferences/methodology.md— when ST-Pipeline wins vs Space Ranger; barcode-ID formatreferences/output_contract.md—raw_counts.h5adschema- Adjacent skills:
spatial-preprocess(downstream — required next step; consumesraw_counts.h5ad),bulkrna-read-qc/sc-fastq-qc(parallel — non-spatial FASTQ paths)
Dependencies
Python packages this skill's script needs. They are not installed for you — check before a long run.
anndata, matplotlib, numpy, pandas, PyYAML, 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).