Sc velocity prep

From TianGzlab/OmicsClaw · View interactive version

Sc velocity prep is an AI agent skill from the GitHub repository TianGzlab/OmicsClaw. Load when generating spliced / unspliced layers from Cell Ranger BAM, FASTQ, STARsolo output, or velocyto loom — the prerequisite for sc-velocity. Skip when AnnData already has spliced+unspliced layers (use sc-velocity); any non-velocity preprocessing (use sc-preprocessing).

How to use this skill

Skill file

sc-velocity-prep

Use from a step

This is CLI_ONLY: it runs external preparation tools or imports their files.

from skills._sdk.notebook import run_cli

run_cli("sc-velocity-prep", "--input", "data/velocity.loom",
        "--base-h5ad", "data/clustered.h5ad",
        inputs=["data/velocity.loom", "data/clustered.h5ad"])

The demo splits PBMC3k counts into fixed 82% spliced, 14% unspliced and

4% ambiguous layers. It checks packaging, not velocity biology or external

tool installation. There is no _api.py for this skill.

When to use

The user has raw Cell Ranger output (BAM + barcodes), STARsolo output,

or paired FASTQs and needs an AnnData with layers["spliced"] /

layers["unspliced"] (and optional layers["ambiguous"]) before

running sc-velocity. Two backends:

using a GTF. Produces a .loom and reads it back into AnnData.

Velocyto solo subworkflow, or loads existing STARsolo Velocyto

output directly when detected.

--base-h5ad lets you merge the velocity layers into an

already-processed AnnData (preserves obs / obsm / clustering).

For velocity estimation itself use sc-velocity. For non-velocity

scRNA preprocessing use sc-preprocessing.

Inputs & Outputs

Inputs

Outputs

Flow

  1. Resolve --input (Cell Ranger dir / STARsolo dir / FASTQ / .loom).
  2. For velocyto: locate BAM + barcodes, validate --gtf (or auto-pick from resources/singlecell/references/gtf/), run velocyto run, load .loom.
  3. For starsolo: detect existing STARsolo Velocyto output and load directly, OR re-run STARsolo Velocyto with --reference + --chemistry + auto-detected --whitelist.
  4. Optionally merge layers into --base-h5ad.
  5. Compute layer totals (tables/velocity_layer_summary.csv) and top-gene balance.
  6. Save processed.h5ad, tables, figures, report.md, result.json.

Gotchas

Key CLI

# Demo (proportional PBMC3k layers; no velocyto / STARsolo)
python skills/singlecell/scrna/sc-velocity-prep/sc_velocity_prep.py --demo --output /tmp/sc_velo_prep_demo

# velocyto from a Cell Ranger run (BAM-backed)
python skills/singlecell/scrna/sc-velocity-prep/sc_velocity_prep.py \
  --input /data/cellranger_run/ --output results/ \
  --method velocyto --gtf /refs/Homo_sapiens.GRCh38.gtf

# Load existing STARsolo Velocyto output directly
python skills/singlecell/scrna/sc-velocity-prep/sc_velocity_prep.py \
  --input /data/starsolo_run/ --output results/ \
  --method starsolo

# Re-run STARsolo from FASTQ (chemistry must be explicit)
python skills/singlecell/scrna/sc-velocity-prep/sc_velocity_prep.py \
  --input /data/fastqs/ --output results/ \
  --method starsolo --reference /refs/star_index --chemistry 10xv3

# Merge velocity layers into an existing processed AnnData
python skills/singlecell/scrna/sc-velocity-prep/sc_velocity_prep.py \
  --input /data/cellranger_run/ --output results/ \
  --method velocyto --gtf /refs/Homo_sapiens.GRCh38.gtf \
  --base-h5ad /path/to/clustered.h5ad

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, scanpy, 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.