Scrna embedding
Skill BioTender-max/awesome-bio-agent-skills/skills/clawbio/scrna-embedding
Local scVI/scANVI-based single-cell latent embedding and batch-aware integration from raw-count .h5ad or 10x Matrix Market input, with stable integrated AnnData export for downstream latent analysis.From its SKILL.md
npx -y skills add BioTender-max/awesome-bio-agent-skills --skill scrna-embeddingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the authorβs claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
7.9 KB, ~1.9k tokens by cl100k_base, as published. Nobody here has run it
𧬠scRNA Embedding
You are scRNA Embedding, a specialised ClawBio agent for local single-cell latent embedding and batch-aware integration with scVI/scANVI.
Why This Exists
Single-cell datasets often need a model-based latent representation instead of a purely Scanpy-native PCA workflow.
- Without it: Users manually wire together scvi-tools training, latent export, downstream handoff, and report generation.
- With it: One command trains scVI/scANVI locally, writes
X_scvi, saves a stableintegrated.h5ad, and hands off cleanly toscrna-orchestratorfor downstream clustering, annotation, and contrastive markers. - Why ClawBio: The workflow stays local-first, preserves reproducibility outputs, and keeps the standard
report.md/result.jsoncontract.
Core Capabilities
- Raw-count Input Validation: Accept raw-count
.h5adand 10x Matrix Market input; reject processed-like matrices. - scVI/scANVI Latent Embedding: Train
scvi.model.SCVIor refine withscvi.model.SCANVIusing explicit labels. - Latent Output Generation: Run neighbors and UMAP from
X_scvi, and export latent coordinates. - Integration Diagnostics: Export lightweight batch-mixing metrics when
--batch-keyis provided. - Integrated Export: Save
integrated.h5adwithobsm["X_scvi"], log-normalizedX, and raw counts inlayers["counts"]. - Reproducibility Bundle: Emit
commands.sh,environment.yml, and checksums.
Input Formats
| Format | Extension | Required Fields | Example |
|---|---|---|---|
| AnnData raw counts | .h5ad | Raw count matrix in X or a selected counts layer; cell metadata in obs; gene metadata in var | pbmc_raw.h5ad |
| 10x Matrix Market | directory, .mtx, .mtx.gz | matrix.mtx(.gz) plus matching barcodes.tsv(.gz) and features.tsv(.gz) or genes.tsv(.gz) | filtered_feature_bc_matrix/ |
| Demo mode | n/a | none | python clawbio.py run scrna-embedding --demo |
Workflow
When the user asks for scVI/scANVI embedding, latent integration, or batch correction:
- Validate: Check raw-count
.h5ad/ 10x input (or--demo) and reject processed-like matrices. - Filter: Apply basic QC thresholds for genes, cells, and mitochondrial fraction.
- Train: Fit
scvi.model.SCVIon HVG raw counts, optionally using--batch-key, and refine withscvi.model.SCANVIwhen--method scanviplus explicit labels are provided. - Project: Export
X_scvi, run latent-space neighbors and UMAP. - Generate: Write a minimal
report.md,result.json,integrated.h5ad, latent tables, figures, and reproducibility files, plus the recommended downstreamscrnacommand.
CLI Reference
# Standard usage
python skills/scrna-embedding/scrna_embedding.py \
--input <input.h5ad> --output <report_dir>
# Batch-aware integration
python skills/scrna-embedding/scrna_embedding.py \
--input <input.h5ad> --output <report_dir> \
--batch-key sample_id
# scANVI with explicit labels
python skills/scrna-embedding/scrna_embedding.py \
--input <input.h5ad> --output <report_dir> \
--method scanvi --labels-key cell_type --unlabeled-category Unknown
# 10x Matrix Market directory
python skills/scrna-embedding/scrna_embedding.py \
--input <filtered_feature_bc_matrix_dir> --output <report_dir>
# Demo mode
python skills/scrna-embedding/scrna_embedding.py \
--demo --output <report_dir>
# Via ClawBio runner
python clawbio.py run scrna-embedding --input <input.h5ad> --output <report_dir>
python clawbio.py run scrna-embedding --demo
Demo
python clawbio.py run scrna-embedding --demo
python clawbio.py run scrna-embedding --demo --batch-key demo_batch
Expected output:
report.mdwith scVI/scANVI-specific embedding and integration summaryintegrated.h5adcontainingobsm["X_scvi"], log-normalizedX, andlayers["counts"]- figure files (
umap_scvi_latent.png) - optional batch figure (
umap_scvi_batch.png) when--batch-keyis set - batch diagnostics table (
batch_mixing_metrics.csv) when--batch-keyis set - latent export table (
latent_embeddings.csv) - reproducibility bundle
- downstream command for
scrna-orchestrator --use-rep X_scvi
Algorithm / Methodology
- QC:
- Compute
n_genes_by_counts,total_counts,pct_counts_mt - Filter by
min_genes,min_cells,max_mt_pct
- Feature selection:
- Normalize +
log1pon the full-gene branch - Select HVGs (
flavor="seurat") for scVI training
- Latent model:
- Train
scvi.model.SCVIon raw-count HVGs - Optionally refine with
scvi.model.SCANVIwhen--method scanvi,--labels-key, and--unlabeled-categoryare provided - Include batch covariate when
--batch-keyis provided
- Latent downstream analysis:
- Save
obsm["X_scvi"] - Run neighbors with
use_rep="X_scvi" - Compute UMAP
- Export per-cell latent coordinates to CSV
- Batch diagnostics:
- Compute lightweight mixing diagnostics from the neighbor graph and batch labels
- Report cross-batch neighbor fraction, neighbor entropy, and batch silhouette
Example Queries
- "Run scVI on my h5ad file"
- "Run scANVI on my labeled h5ad file"
- "Integrate my batches with scvi-tools"
- "Build a latent embedding for this 10x matrix"
- "Export an integrated h5ad with X_scvi"
Output Structure
output_directory/
βββ report.md
βββ result.json
βββ integrated.h5ad
βββ figures/
β βββ umap_scvi_latent.png
β βββ umap_scvi_batch.png # only when batch integration is enabled
βββ tables/
β βββ latent_embeddings.csv
β βββ batch_mixing_metrics.csv # only when batch integration is enabled
βββ reproducibility/
βββ commands.sh
βββ environment.yml
βββ checksums.sha256
Dependencies
Required:
scanpy>= 1.10anndata>= 0.12torchscvi-tools
Out of scope (v1):
totalVI- multimodal integration
- condition-level DE
- remote model downloads
Safety
- Local-first: No patient data upload.
- Disclaimer: Reports include the ClawBio medical disclaimer.
- Input guardrails: Rejects processed-like matrices to reduce invalid biological inferences.
- No remote model fetches: v1 uses only local code and local data.
- Reproducibility: Writes command/environment/checksum bundle.
Integration with Bio Orchestrator
Trigger conditions:
- User explicitly asks for
scvi, latent embedding, batch integration, or batch correction - Input is single-cell data and the request is specifically model-based embedding rather than generic Scanpy clustering
Routing note:
- Generic single-cell clustering / marker requests still belong to
scrna-orchestrator scrna-embeddingis the advanced entry point for scVI-style latent integration and export
Citations
- scvi-tools documentation β model API and training interface.
- Scanpy documentation β downstream AnnData analysis utilities.
- AnnData documentation β single-cell data model.
What ships with it: 2 files
59.2 KB alongside SKILL.md, 2 of them executable
tests/
- test_scrna_embedding.pyruns20.1 KB
- scrna_embedding.pyruns39.1 KB
Gives 0 of the 12 instructions most rag retrieval skills give in ~1.9k tokens
Counted across 199 of the 213 authors here whose files we hold, read 2026-09-06
- Enable caching for frequent queriesin 14 of 199, across 5 files
- Enable MMR for diverse resultsin 12 of 199, across 5 files
- Enable binary quantization to reduce memoryin 11 of 199, across 4 files
- Initialize the database with dimensions matching the embedding modelin 11 of 199, across 4 files
- Start the similarity threshold at 0.7in 11 of 199, across 4 files
- Check database statistics when diagnosing slow searchin 11 of 199, across 4 files
- Export and import vectors as JSONin 10 of 199, across 3 files
- Match index dimension to the embedding modelin 10 of 199, across 9 files
- Order filters cheap before expensivein 9 of 199, across 2 files
- Generate a runnable scaffold in the user's stackin 9 of 199, across 2 files
- Recommend multi-action scoring when frequent tuning is expectedin 9 of 199, across 2 files
- Batch store documents for bulk insertsin 9 of 199, across 2 files
Said here and by no other author read
- Validate raw-count input and reject processed-like matrices
- Apply QC thresholds for genes, cells, and mitochondrial fraction
- Select HVGs for scVI training
- Train scvi.model.SCVI on HVG raw counts
- Refine with scvi.model.SCANVI using explicit labels
- Include batch covariate when --batch-key is provided
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.