Spatial raw processing

From TianGzlab/OmicsClaw · View interactive version

Spatial raw processing is an AI agent skill from the GitHub repository TianGzlab/OmicsClaw. 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).

How to use this skill

Skill file

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

Outputs

Flow

  1. Parse args (or load bundle JSON / YAML from positional --input).
  2. _apply_effective_defaults fills missing parameter values (threads, trimming, UMI ranges, etc.).
  3. _validate_real_run_bundle: check read1 / read2 / ids / ref-map exist and are well-typed; reject duplicate read1=read2; verify FASTQ extension.
  4. Call run_stpipeline(...) which shells out to ST-Pipeline (requires the stpipeline binary on PATH or --stpipeline-repo + --bin-path).
  5. Wrap the resulting count matrix into AnnData with X = raw_counts, layers["counts"], raw = raw_counts_snapshot.
  6. Save raw_counts.h5ad and result.json. Print "next: spatial-preprocess on raw_counts.h5ad".

Gotchas

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

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.