Claude Skill

alterlab-scgpt

Apply the scGPT single-cell foundation model (Cui 2024) to annotate and embed cells — zero-shot and fine-tuned cell-type annotation, gene/cell embeddings, batch integration, and gene-regulatory / perturbation inference from AnnData. Use when annotating cell types with a pretraine

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download alterlab-ieu-alterlab-academic-skills-skills_bioinformatics_alterlab-scgpt-e4836c0.zip · 5 KB
Part of alterlab-ieu/alterlab-academic-skills — 94 skills

Install

skills CLI npx skills add https://github.com/AlterLab-IEU/AlterLab-Academic-Skills/tree/main/skills/bioinformatics/alterlab-scgpt
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install alterlab-ieu-alterlab-academic-skills@llmmart
Git git clone https://github.com/AlterLab-IEU/AlterLab-Academic-Skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole alterlab-ieu/alterlab-academic-skills collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

scGPT (single-cell foundation model)

Overview

scGPT (Cui et al., Nature Methods 2024; bowang-lab/scGPT) is a transformer foundation model pretrained on tens of millions of cells. It provides zero-shot and fine-tuned cell-type annotation, gene and cell embeddings, batch integration, and gene-regulatory / perturbation inference — all operating on AnnData (.h5ad) objects.

Its niche vs. the existing single-cell skills: scGPT is the pretrained-transformer route. For probabilistic latent-variable models use alterlab-scvi-tools; for the conventional Scanpy analysis pipeline use alterlab-scanpy; scGPT complements both.

When to Use This Skill

Use this skill when the user wants to:

  • Annotate cell types with a pretrained foundation model (zero-shot or fine-tuned).
  • Generate scGPT embeddings for cells or genes.
  • Integrate batches using the transformer's representation.
  • Run zero-shot inference / transfer to a new dataset without training from scratch.

Does NOT Trigger

Scenario Use instead
Probabilistic integration / latent model (scVI, scANVI) alterlab-scvi-tools
Standard QC → cluster → UMAP → differential expression alterlab-scanpy
Read/write/wrangle the .h5ad data structure itself alterlab-anndata
RNA velocity alterlab-scvelo
Protein (not single-cell) language models alterlab-esm

Core Capabilities

1. Zero-shot cell embedding & annotation

import scanpy as sc
from scgpt.tasks import embed_data

adata = sc.read_h5ad("cells.h5ad")
adata = embed_data(
    adata,
    model_dir="checkpoints/scGPT_human",   # downloaded checkpoint folder
    gene_col="feature_name",               # column in adata.var holding gene symbols
    batch_size=64,
    device="cuda",
)
# cell embeddings land in adata.obsm["X_scGPT"]

gene_col must name an adata.var column of gene symbols matching the checkpoint's vocabulary (pass "index" to use var_names); symbols that miss the vocab are dropped, so check how many genes survive before trusting the embedding. Set use_fast_transformer=False when flash-attn is not installed. Zero-shot mode maps a new dataset onto scGPT's learned space without training — fast triage of cell identities. Fine-tuning on labeled reference data improves accuracy on a specific tissue.

2. Embeddings for downstream analysis

Produce cell embeddings (for clustering/visualization) or gene embeddings (for gene-network/similarity analysis). Feed embeddings back into a Scanpy neighbors/UMAP workflow.

3. Batch integration

Use the model representation to integrate across batches/donors, comparable in role to scVI-based integration but from the pretrained-transformer paradigm.

4. Environment, GPU, and dispatch

scGPT's last release is 0.2.4 (March 2025) and its pins have not moved since: it requires scvi-tools<1.0 and scanpy<2.0, and imports torchtext, whose own last release was 0.18.0 in April 2024. That stack will not co-install with a current scverse environment, so give scGPT its own venv and move data between environments as .h5ad files rather than trying to satisfy both sets of pins at once. Say so plainly when a user expects it to drop into their existing environment.

Checkpoints (whole-human, continual-pretrained, organ-specific) are downloaded by hand from the Drive links in the upstream README — there is no from_pretrained downloader. The whole-human model is the default choice; the continual-pretrained one is aimed at zero-shot cell-embedding tasks.

scGPT needs a GPU for realistic dataset sizes; fine-tuning is heavy. Dispatch fine-tuning / large inference via alterlab-remote-compute (submit → poll → harvest). Keep the AnnData I/O consistent with alterlab-anndata.

Because the model has been static for over a year while the foundation-model field has not, treat its published benchmarks as a 2024 snapshot: report the checkpoint name and date with any result, and where annotation accuracy matters, sanity-check the labels against marker-gene evidence (alterlab-scanpy) rather than accepting them unverified.

Resources

  • references/scgpt_usage.md — install/pinning, checkpoints, embed/annotate/fine-tune calls, scverse integration, and paradigm comparison. Loaded on demand.

Part of the AlterLab Academic Skills suite.

Files (alterlab-academic-skills)
  • evals
    • evals.json 2.9 KB
      {
        "skill": "alterlab-scgpt",
        "evals": [
          {
            "id": "zero-shot-annotation",
            "prompt": "I have an unlabeled scRNA-seq dataset in h5ad. Use a pretrained single-cell foundation model to annotate the cell types without training my own classifier.",
            "expected_output": "Invokes alterlab-scgpt: loads a pretrained scGPT checkpoint, embeds the AnnData cells, and transfers cell-type labels zero-shot. Notes GPU need and heavy fine-tuning dispatch via alterlab-remote-compute.",
            "assertions": [
              { "type": "should_trigger", "value": true },
              { "type": "output_contains", "value": "zero-shot" },
              { "type": "behavior", "value": "Uses a pretrained foundation model for annotation rather than training a classifier from scratch." }
            ]
          },
          {
            "id": "cell-embeddings",
            "prompt": "Generate scGPT embeddings for my cells so I can cluster them in the learned representation.",
            "expected_output": "Invokes alterlab-scgpt to produce cell embeddings from a pretrained checkpoint, then feeds them into a neighbors/UMAP workflow (alterlab-scanpy) for clustering.",
            "assertions": [
              { "type": "should_trigger", "value": true },
              { "type": "output_contains", "value": "embedding" }
            ]
          },
          {
            "id": "batch-integration",
            "prompt": "Integrate several scRNA-seq batches using a transformer foundation-model representation to remove batch effects.",
            "expected_output": "Invokes alterlab-scgpt to integrate batches via the model representation, comparable in role to scVI integration but from the pretrained-transformer paradigm.",
            "assertions": [
              { "type": "should_trigger", "value": true },
              { "type": "behavior", "value": "Integrates batches using the scGPT representation." }
            ]
          },
          {
            "id": "near-miss-scvi-tools",
            "prompt": "I want a probabilistic latent-variable model (scVI/scANVI) to integrate my data and do differential expression with uncertainty.",
            "expected_output": "Should NOT trigger this skill; defers to alterlab-scvi-tools, which provides the probabilistic VAE models (scVI/scANVI). scGPT is the pretrained-transformer route, not the probabilistic-latent-model route.",
            "assertions": [
              { "type": "should_not_trigger", "value": true },
              { "type": "output_contains", "value": "alterlab-scvi-tools" }
            ]
          },
          {
            "id": "near-miss-scanpy",
            "prompt": "Run the standard single-cell workflow: QC filtering, normalization, PCA, Leiden clustering, and a UMAP with marker genes.",
            "expected_output": "Should NOT trigger this skill; defers to alterlab-scanpy, the standard analysis pipeline. scGPT is a foundation model for annotation/embeddings, not the conventional QC→cluster→UMAP toolchain.",
            "assertions": [
              { "type": "should_not_trigger", "value": true },
              { "type": "output_contains", "value": "alterlab-scanpy" }
            ]
          }
        ]
      }
      
  • references
    • scgpt_usage.md 2.9 KB
      # scGPT — Usage Reference
      
      Deeper detail for `alterlab-scgpt`. API and packaging below were checked against the upstream
      `bowang-lab/scGPT` repo (2026-09); PyPI `scgpt` is still 0.2.4 (March 2025).
      
      ## Install
      
      ```bash
      # dedicated environment — scgpt's pins conflict with a current scverse stack
      uv venv .venv-scgpt && source .venv-scgpt/bin/activate
      uv pip install scgpt "flash-attn<1.0.5"   # flash-attn optional; needs CUDA to build
      ```
      
      Upstream also documents `"orbax<0.1.8"` as a workaround for resolver failures. Poetry
      installation is documented as out of sync — use pip/uv.
      
      Then download a checkpoint folder (whole-human, continual-pretrained, or organ-specific) from
      the Drive links in the upstream README; each folder ships the paired gene-name→id vocabulary.
      A GPU is strongly recommended.
      
      ## Zero-shot embedding API
      
      ```python
      from scgpt.tasks import embed_data
      
      adata = embed_data(
          adata_or_file,            # AnnData or path to .h5ad
          model_dir="checkpoints/scGPT_human",
          gene_col="feature_name",  # or "index" to use var_names
          max_length=1200,          # genes per cell fed to the transformer
          batch_size=64,
          obs_to_save=["celltype"], # obs columns to carry through
          device="cuda",
          use_fast_transformer=True,  # False when flash-attn is absent
          return_new_adata=False,     # False: writes adata.obsm["X_scGPT"] in place
      )
      ```
      
      `scgpt.tasks` also exposes `get_batch_cell_embeddings` (the lower-level batched call) and
      `GeneEmbedding` (gene-embedding / GRN work).
      
      ## Typical tasks
      
      - **Zero-shot annotation** — embed a query dataset with a pretrained checkpoint and transfer
        labels from a reference. Fast, no training.
      - **Fine-tuned annotation** — fine-tune on a labeled reference for a specific tissue for higher
        accuracy (GPU-heavy — dispatch via `alterlab-remote-compute`).
      - **Embeddings** — export cell/gene embeddings for clustering, UMAP, or gene-network analysis.
      - **Integration** — use the model representation to integrate batches/donors.
      
      Annotation and perturbation fine-tuning are driven by the scripts and notebooks in the repo's
      `examples/` and `tutorials/` directories (e.g. `examples/finetune_integration.py`), not by a
      stable importable API — read the notebook matching your task rather than assuming a function
      name.
      
      ## scverse integration
      
      Inputs and outputs are AnnData (`.h5ad`). Keep the object well-formed with `alterlab-anndata`,
      and feed scGPT embeddings into a Scanpy neighbors/UMAP/Leiden workflow (`alterlab-scanpy`) for
      downstream steps.
      
      ## Choosing the single-cell skill
      
      | Goal | Skill |
      |------|-------|
      | Pretrained foundation-model annotation/embeddings | `alterlab-scgpt` |
      | Probabilistic latent model (scVI/scANVI), integration, DE | `alterlab-scvi-tools` |
      | Standard pipeline: QC, clustering, UMAP, marker DE | `alterlab-scanpy` |
      | `.h5ad` data structure I/O and wrangling | `alterlab-anndata` |
      | RNA velocity | `alterlab-scvelo` |
      
  • SKILL.md 5.7 KB
    ---
    name: alterlab-scgpt
    description: Apply the scGPT single-cell foundation model (Cui 2024) to annotate and embed cells — zero-shot and fine-tuned cell-type annotation, gene/cell embeddings, batch integration, and gene-regulatory / perturbation inference from AnnData. Use when annotating cell types with a pretrained foundation model, generating scGPT embeddings, integrating batches with a transformer, or running zero-shot single-cell inference on an h5ad. For probabilistic latent models (scVI/scANVI) prefer alterlab-scvi-tools; for the standard QC→cluster→UMAP→DE pipeline prefer alterlab-scanpy; for the AnnData data structure itself prefer alterlab-anndata; for protein language models prefer alterlab-esm. Part of the AlterLab Academic Skills suite.
    license: MIT
    allowed-tools: Read Write Edit Bash(python:*) Bash(uv:*)
    compatibility: "Runs scGPT (`bowang-lab/scGPT`; PyPI `scgpt` 0.2.4, unchanged since 2025-03) under `uv run python`. Its old pins (`scvi-tools<1.0`, `scanpy<2.0`, `torchtext`) conflict with a current scverse stack, so use a dedicated environment, not one shared with alterlab-scanpy/alterlab-scvi-tools. Checkpoints (GB-scale) download manually from the repo's Drive links; a CUDA GPU is strongly recommended. I/O is AnnData (`.h5ad`); dispatch heavy fine-tuning via alterlab-remote-compute."
    metadata:
        skill-author: AlterLab
        version: "1.1.0"
        last_updated: "2026-09-23"
    ---
    
    # scGPT (single-cell foundation model)
    
    ## Overview
    
    **scGPT** (Cui et al., *Nature Methods* 2024; `bowang-lab/scGPT`) is a transformer **foundation
    model** pretrained on tens of millions of cells. It provides **zero-shot** and fine-tuned
    **cell-type annotation**, **gene and cell embeddings**, **batch integration**, and
    gene-regulatory / perturbation inference — all operating on **AnnData** (`.h5ad`) objects.
    
    Its niche vs. the existing single-cell skills: scGPT is the *pretrained-transformer* route.
    For probabilistic latent-variable models use `alterlab-scvi-tools`; for the conventional
    Scanpy analysis pipeline use `alterlab-scanpy`; scGPT complements both.
    
    ## When to Use This Skill
    
    Use this skill when the user wants to:
    - **Annotate cell types** with a pretrained foundation model (zero-shot or fine-tuned).
    - Generate **scGPT embeddings** for cells or genes.
    - **Integrate batches** using the transformer's representation.
    - Run **zero-shot** inference / transfer to a new dataset without training from scratch.
    
    ### Does NOT Trigger
    
    | Scenario | Use instead |
    |----------|-------------|
    | Probabilistic integration / latent model (scVI, scANVI) | `alterlab-scvi-tools` |
    | Standard QC → cluster → UMAP → differential expression | `alterlab-scanpy` |
    | Read/write/wrangle the `.h5ad` data structure itself | `alterlab-anndata` |
    | RNA velocity | `alterlab-scvelo` |
    | Protein (not single-cell) language models | `alterlab-esm` |
    
    ## Core Capabilities
    
    ### 1. Zero-shot cell embedding & annotation
    
    ```python
    import scanpy as sc
    from scgpt.tasks import embed_data
    
    adata = sc.read_h5ad("cells.h5ad")
    adata = embed_data(
        adata,
        model_dir="checkpoints/scGPT_human",   # downloaded checkpoint folder
        gene_col="feature_name",               # column in adata.var holding gene symbols
        batch_size=64,
        device="cuda",
    )
    # cell embeddings land in adata.obsm["X_scGPT"]
    ```
    
    `gene_col` must name an `adata.var` column of gene symbols matching the checkpoint's vocabulary
    (pass `"index"` to use `var_names`); symbols that miss the vocab are dropped, so check how many
    genes survive before trusting the embedding. Set `use_fast_transformer=False` when flash-attn
    is not installed. Zero-shot mode maps a new dataset onto scGPT's learned space without training
    — fast triage of cell identities. Fine-tuning on labeled reference data improves accuracy on a
    specific tissue.
    
    ### 2. Embeddings for downstream analysis
    
    Produce cell embeddings (for clustering/visualization) or gene embeddings (for
    gene-network/similarity analysis). Feed embeddings back into a Scanpy neighbors/UMAP workflow.
    
    ### 3. Batch integration
    
    Use the model representation to integrate across batches/donors, comparable in role to
    scVI-based integration but from the pretrained-transformer paradigm.
    
    ### 4. Environment, GPU, and dispatch
    
    scGPT's last release is 0.2.4 (March 2025) and its pins have not moved since: it requires
    `scvi-tools<1.0` and `scanpy<2.0`, and imports `torchtext`, whose own last release was 0.18.0
    in April 2024. That stack will not co-install with a current scverse environment, so give scGPT
    its own venv and move data between environments as `.h5ad` files rather than trying to satisfy
    both sets of pins at once. Say so plainly when a user expects it to drop into their existing
    environment.
    
    Checkpoints (whole-human, continual-pretrained, organ-specific) are downloaded by hand from the
    Drive links in the upstream README — there is no `from_pretrained` downloader. The
    whole-human model is the default choice; the continual-pretrained one is aimed at zero-shot
    cell-embedding tasks.
    
    scGPT needs a GPU for realistic dataset sizes; fine-tuning is heavy. Dispatch fine-tuning /
    large inference via `alterlab-remote-compute` (submit → poll → harvest). Keep the AnnData I/O
    consistent with `alterlab-anndata`.
    
    Because the model has been static for over a year while the foundation-model field has not,
    treat its published benchmarks as a 2024 snapshot: report the checkpoint name and date with any
    result, and where annotation accuracy matters, sanity-check the labels against marker-gene
    evidence (`alterlab-scanpy`) rather than accepting them unverified.
    
    ## Resources
    
    - `references/scgpt_usage.md` — install/pinning, checkpoints, embed/annotate/fine-tune calls,
      scverse integration, and paradigm comparison. Loaded on demand.
    
    Part of the AlterLab Academic Skills suite.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related