anndata_skill

This skill helps you manage annotated data matrices with ease, enabling reading, writing, and manipulating AnnData objects across workflows.
  • Python

7.4k

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill k-dense-ai/claude-scientific-skills --skill anndata

  • SKILL.md10.8 KB

Overview

This skill provides a compact, practical interface to the AnnData annotated-matrix data structure used across single-cell and multimodal genomics. It helps create, read, write, subset, and manipulate .h5ad / zarr datasets and integrates smoothly with the scverse ecosystem (Scanpy, scvi-tools, muon). Use it to manage large, metadata-rich experiments with memory- and disk-efficient patterns.

How this skill works

The skill exposes common AnnData operations: constructing AnnData objects with X, obs, var and multi-dimensional annotations (layers, obsm, varm, obsp, varp, uns), reading and writing h5ad/zarr/loom/10x formats, and performing efficient subsetting and concatenation. It supports backed mode for out-of-core workflows, sparse matrix storage, and helpers for converting strings to categoricals and preserving raw data before filtering.

When to use it

  • Loading or saving single-cell datasets (.h5ad, .zarr, .loom, 10x)
  • Creating AnnData objects with cell and gene metadata
  • Subsetting, filtering, or transforming annotated matrices
  • Concatenating multiple batches or modalities with tracking labels
  • Working with very large datasets using backed mode or sparse storage
  • Preparing data for Scanpy, scvi-tools, muon, or deep learning pipelines

Best practices

  • Use sparse matrices for inherently sparse counts (scipy.sparse.csr_matrix) to save memory
  • Convert repeated strings to categoricals with strings_to_categoricals()
  • Store raw before aggressive filtering: adata.raw = adata.copy()
  • Use backed='r' for read-only access to very large h5ad files and load subsets to memory for processing
  • Track sample/batch provenance via ad.concat(label='batch', keys=[...]) to simplify batch correction

Example use cases

  • Preprocess a 10x single-cell experiment, compute highly variable genes, and save a processed .h5ad for downstream analysis
  • Concatenate three experiment batches with batch labels and run Combat or other batch-correction workflows
  • Open a 100+ GB h5ad in backed mode, filter cells by metadata, and load only the filtered subset to memory
  • Create a MuData container combining RNA and protein AnnData objects for multimodal analysis
  • Build an AnnLoader-backed DataLoader to stream batches into a PyTorch training loop

FAQ

Yes. Use ad.read_h5ad(..., backed='r') to access data on disk, filter by obs or metadata without loading all values, and call .to_memory() on a subset when you need it in RAM.

How do I avoid accidental copies and high memory use?

Be aware of views vs copies. Slicing returns lightweight views; call .copy() when you need an independent object. Favor sparse matrices and categoricals to reduce memory footprint.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
anndata skill by k-dense-ai/claude-scientific-skills | VeilStrat