# Scvi Tools

Probabilistic single-cell RNA-seq with scvi-tools, scVI for a batch-corrected latent...

- Repository: https://github.com/aipoch/open-science (5414 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add aipoch/open-science --skill scvi-tools -g -a claude-code -y`
Codex: `npx skills add aipoch/open-science --skill scvi-tools -g -a codex -y`
Cursor: `npx skills add aipoch/open-science --skill scvi-tools -g -a cursor -y`
Gemini CLI: `npx skills add aipoch/open-science --skill scvi-tools -g -a gemini-cli -y`

## Description

Probabilistic single-cell RNA-seq with scvi-tools, scVI for a batch-corrected latent space, scANVI for semi-supervised label transfer, and Bayesian differential expression. Reach for this skill to integrate scRNA-seq batches, embed cells for clustering, transfer annotations from a reference onto a query, or score differentially expressed genes per cluster. For spatial deconvolution / mapping use the cell2location, DestVI, or Tangram methods instead.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# scvi-tools, scVI / scANVI

scvi-tools (Gayoso et al. 2022, github.com/scverse/scvi-tools, BSD-3-Clause)
wraps a family
of deep generative models for single-cell omics. The scRNA-seq core is **scVI**
(unsupervised batch-corrected latent embedding) and **scANVI** (scVI + a
classifier head for semi-supervised cell-type label transfer). Both expect
**raw integer UMI counts** and emit a low-dimensional `X_scVI` / `X_scANVI`
that drops into the scanpy neighbors → leiden → umap pipeline.

## Setup (any agent, no API key)

This is a **pure skill**, `kernel.py` is deterministic Python and _you_ (the
base model) do all the reasoning. There is no `host` runtime and no LLM API.
The helpers are `prepare_scvi_counts` for input validation and `h5ad_safe_obs`
for obs/var frames that `anndata.write_h5ad()` can serialize. Load them once
per session in a Python cell:

```python
exec(open("scvi-tools/kernel.py", encoding="utf-8").read())   # path to this skill's kernel.py
```

Nothing auto-loads it outside Claude Science. Then call the helpers directly.
If a helper raises `NameError`, you haven't exec'd kernel.py.

Dependencies: `pip install scvi-tools scanpy anndata`. Training needs a
CUDA-capable GPU, see [Remote compute](#remote-compute-rent-a-gpu) to fall out
to a rented GPU when you don't have one locally.

## How to run

### scVI, batch-corrected latent space

`prepare_scvi_counts(adata)` checks and preserves existing `counts`. If absent,
it checks `.X` before copying it to `counts`. Values must be finite, nonnegative,
and integer-valued, with at least one positive count. Invalid existing counts
raise instead of being replaced by `.X`; sparse matrices stay sparse.

The rest: https://github.com/aipoch/open-science/blob/HEAD/resources/skills/scvi-tools/SKILL.md
