{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/scvi-tools",
  "version": "1.0.0",
  "name": "scvi-tools",
  "description": "Deep learning for single-cell analysis using scvi-tools. This skill should be used when users need (1) data integration and batch correction with scVI/scANVI, (2) ATAC-seq analysis with PeakVI, (3) CITE-seq multi-modal analysis with totalVI, (4) multiome RNA+ATAC analysis with MultiVI, (5) spatial transcriptomics deconvolution with DestVI, (6) label transfer and reference mapping with scANVI/scArches, (7) RNA velocity with veloVI, or (8) any deep learning-based single-cell method. Triggers include mentions of scVI, scANVI, totalVI, PeakVI, MultiVI, DestVI, veloVI, sysVI, scArches, variational autoencoder, VAE, batch correction, data integration, multi-modal, CITE-seq, multiome, reference mapping, latent space.",
  "system_prompt_fragment": "# scvi-tools Deep Learning Skill\n\nThis skill provides guidance for deep learning-based single-cell analysis using scvi-tools, the leading framework for probabilistic models in single-cell genomics.\n\n## How to Use This Skill\n\n1. Identify the appropriate workflow from the model/workflow tables below\n2. Read the corresponding reference file for detailed steps and code\n3. Use scripts in `scripts/` to avoid rewriting common code\n4. For installation or GPU issues, consult `references/environment_setup.md`\n5. For debugging, consult `references/troubleshooting.md`\n\n## When to Use This Skill\n\n- When scvi-tools, scVI, scANVI, or related models are mentioned\n- When deep learning-based batch correction or integration is needed\n- When working with multi-modal data (CITE-seq, multiome)\n- When reference mapping or label transfer is required\n- When analyzing ATAC-seq or spatial transcriptomics data\n- When learning latent representations of single-cell data\n\n## Model Selection Guide\n\n| Data Type | Model | Primary Use Case |\n|-----------|-------|------------------|\n| scRNA-seq | **scVI** | Unsupervised integration, DE, imputation |\n| scRNA-seq + labels | **scANVI** | Label transfer, semi-supervised integration |\n| CITE-seq (RNA+protein) | **totalVI** | Multi-modal integration, protein denoising |\n| scATAC-seq | **PeakVI** | Chromatin accessibility analysis |\n| Multiome (RNA+ATAC) | **MultiVI** | Joint modality analysis |\n| Spatial + scRNA reference | **DestVI** | Cell type deconvolution |\n| RNA velocity | **veloVI** | Transcriptional dynamics |\n| Cross-technology | **sysVI** | System-level batch correction |\n\n## Workflow Reference Files\n\n| Workflow | Reference File | Description |\n|----------|---------------|-------------|\n| Environment Setup | `references/environment_setup.md` | Installation, GPU, version info |\n| Data Preparation | `references/data_preparation.md` | Formatting data for any model |\n| scRNA Integration | `references/scrna_integration.md` | scVI/scANVI batch correction |\n| ATAC-seq Analysis | `references/atac_peakvi.md` | PeakVI for accessibility |\n| CITE-seq Analysis | `references/citeseq_totalvi.md` | totalVI for protein+RNA |\n| Multiome Analysis | `references/multiome_multivi.md` | MultiVI for RNA+ATAC |\n| Spatial Deconvolution | `references/spatial_deconvolution.md` | DestVI spatial analysis |\n| Label Transfer | `references/label_transfer.md` | scANVI reference mapping |\n| scArches Mapping | `references/scarches_mapping.md` | Query-to-reference mapping |\n| Batch Correction | `references/batch_correction_sysvi.md` | Advanced batch methods |\n| RNA Velocity | `references/rna_velocity_velovi.md` | veloVI dynamics |\n| Troubleshooting | `references/troubleshooting.md` | Common issues and solutions |\n\n## CLI Scripts\n\nModular scripts for common workflows. Chain together or modify as needed.\n\n### Pipeline Scripts\n\n| Script | Purpose | Usage |\n|--------|---------|-------|\n| `prepare_data.py` | QC, filter, HVG selection | `python scripts/prepare_data.py raw.h5ad prepared.h5ad --batch-key batch` |\n| `train_model.py` | Train any scvi-tools model | `python scripts/train_model.py prepared.h5ad results/ --model scvi` |\n| `cluster_embed.py` | Neighbors, UMAP, Leiden | `python scripts/cluster_embed.py adata.h5ad results/` |\n| `differential_expression.py` | DE analysis | `python scripts/differential_expression.py model/ adata.h5ad de.csv --groupby leiden` |\n| `transfer_labels.py` | Label transfer with scANVI | `python scripts/transfer_labels.py ref_model/ query.h5ad results/` |\n| `integrate_datasets.py` | Multi-dataset integration | `python scripts/integrate_datasets.py results/ data1.h5ad data2.h5ad` |\n| `validate_adata.py` | Check data compatibility | `python scripts/validate_adata.py data.h5ad --batch-key batch` |\n\n### Example Workflow\n\n```bash\n# 1. Validate input data\npython scripts/validate_adata.py raw.h5ad --batch-key batch --suggest\n\n# 2. Prepare data (QC, HVG selection)\npython scripts/prepare_data.py raw.h5ad prepared.h5ad --batch-key batch --n-hvgs 2000\n\n# 3. Train model\npython scripts/train_model.py prepared.h5ad results/ --model scvi --batch-key batch\n\n# 4. Cluster and visualize\npython scripts/cluster_embed.py results/adata_trained.h5ad results/ --resolution 0.8\n\n# 5. Differential expression\npython scripts/differential_expression.py results/model results/adata_clustered.h5ad results/de.csv --groupby leiden\n```\n\n### Python Utilities\n\nThe `scripts/model_utils.py` provides importable functions for custom workflows:\n\n| Function | Purpose |\n|----------|---------|\n| `prepare_adata()` | Data preparation (QC, HVG, layer setup) |\n| `train_scvi()` | Train scVI or scANVI |\n| `evaluate_integration()` | Compute integration metrics |\n| `get_marker_genes()` | Extract DE markers |\n| `save_results()` | Save model, data, plots |\n| `auto_select_model()` | Suggest best model |\n| `quick_clustering()` | Neighbors + UMAP + Leiden |\n\n## Critical Requirements\n\n1. **Raw counts required**: scvi-tools models require integer count data\n   ```python\n   adata.layers[\"counts\"] = adata.X.copy()  # Before normalization\n   scvi.model.SCVI.setup_anndata(adata, layer=\"counts\")\n   ```\n\n2. **HVG selection**: Use 2000-4000 highly variable genes\n   ```python\n   sc.pp.highly_variable_genes(adata, n_top_genes=2000, batch_key=\"batch\", layer=\"counts\", flavor=\"seurat_v3\")\n   adata = adata[:, adata.var['highly_variable']].copy()\n   ```\n\n3. **Batch information**: Specify batch_key for integration\n   ```python\n   scvi.model.SCVI.setup_anndata(adata, layer=\"counts\", batch_key=\"batch\")\n   ```\n\n## Quick Decision Tree\n\n```\nNeed to integrate scRNA-seq data?\n├── Have cell type labels? → scANVI (references/label_transfer.md)\n└── No labels? → scVI (references/scrna_integration.md)\n\nHave multi-modal data?\n├── CITE-seq (RNA + protein)? → totalVI (references/citeseq_totalvi.md)\n├── Multiome (RNA + ATAC)? → MultiVI (references/multiome_multivi.md)\n└── scATAC-seq only? → PeakVI (references/atac_peakvi.md)\n\nHave spatial data?\n└── Need cell type deconvolution? → DestVI (references/spatial_deconvolution.md)\n\nHave pre-trained reference model?\n└── Map query to reference? → scArches (references/scarches_mapping.md)\n\nNeed RNA velocity?\n└── veloVI (references/rna_velocity_velovi.md)\n\nStrong cross-technology batch effects?\n└── sysVI (references/batch_correction_sysvi.md)\n```\n\n## Key Resources\n\n- [scvi-tools Documentation](https://docs.scvi-tools.org/)\n- [scvi-tools Tutorials](https://docs.scvi-tools.org/en/stable/tutorials/index.html)\n- [Model Hub](https://huggingface.co/scvi-tools)\n- [GitHub Issues](https://github.com/scverse/scvi-tools/issues)",
  "applicable_domains": [
    "research",
    "science"
  ],
  "invocation": [
    "/scvi-tools"
  ],
  "tags": [
    "bio-research",
    "anthropics",
    "knowledge-work"
  ],
  "authored_by": "anthropics",
  "source_url": "https://github.com/anthropics/knowledge-work-plugins/blob/main/bio-research/skills/scvi-tools/SKILL.md",
  "lifecycle": "stable",
  "category": "data",
  "provenance": {
    "source": "anthropics/knowledge-work-plugins",
    "source_url": "https://github.com/anthropics/knowledge-work-plugins/blob/main/bio-research/skills/scvi-tools/SKILL.md",
    "author": "Anthropic",
    "license": "Apache-2.0",
    "notes": "Imported by scripts/import-anthropic-skills.py."
  }
}