anndata

Read, write, subset, and concatenate AnnData objects in .h5ad format.

1|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/tony-zhelonkin/SciAgent-toolkit --skill anndata-tony-zhelonkin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: anndata
Source: https://github.com/tony-zhelonkin/SciAgent-toolkit/tree/main/skills/anndata
Command: npx skills add https://github.com/tony-zhelonkin/SciAgent-toolkit --skill anndata-tony-zhelonkin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AnnData is the shared data container for the scverse ecosystem (scanpy, scvi-tools, scvelo, cellrank, squidpy, muon). Understanding its structure is prerequisite knowledge for all single-cell Python work. Every tool in this skill library reads and writes AnnData objects.

Core Features & Use Cases

  • AnnData Structure: The AnnData object stores cell metadata in .obs, gene metadata in .var, expression in .X, and unstructured data in .uns, with additional slots like .obsm, .varm, .obsp, and .layers for modular data representations.
  • Memory and I/O: Supports backed mode for on-disk operations, multiple read/write formats (h5ad, zarr), and efficient subsetting without loading all data into memory.
  • Common Operations: Reading/writing, subsetting, concatenation, and slot management across .X, .obs, .var, .uns, .obsm, .varm.
  • Use Case: Debug shape/index mismatches during data integration and prepare data for downstream tools in scanpy/scvi-tools workflows.

Quick Start

Load an example AnnData object and inspect its .obs and .var to understand the data model.

Frequently Asked Questions about anndata

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure single-cell data in Python using AnnData?

AnnData structures single-cell data by storing cell metadata in .obs, gene metadata in .var, expression matrices in .X, and unstructured annotations in .uns. It also supports modular representations using .obsm, .varm, .obsp, and .layers.

What is the best way to read and write large .h5ad files for single-cell analysis?

For large .h5ad files, AnnData supports backed mode for on-disk operations and multiple read/write formats like h5ad and zarr. This enables efficient subsetting and I/O without loading the entire dataset into memory.

Why does my AnnData object have shape or index mismatches during data integration?

Shape and index mismatches in AnnData objects typically occur when cell or gene labels are inconsistent across batches. You can debug these issues by inspecting the .obs and .var slots to ensure alignment before concatenation.

Can I use AnnData objects with scverse ecosystem tools like scanpy and scvi-tools?

Yes, AnnData serves as the shared data container for the scverse ecosystem, including scanpy, scvi-tools, scvelo, and squidpy. Every tool in this ecosystem natively reads and writes AnnData objects.

How do I subset and concatenate single-cell datasets without running out of memory?

You can subset and concatenate single-cell datasets efficiently by using AnnData's backed mode. This allows on-disk operations and modular slot management across .X, .obs, and .var without loading all data into memory.

When do I need to use .obsm or .layers instead of .X in an AnnData object?

You need .obsm for multidimensional cell-level data like embeddings, and .layers for alternative expression matrices. Using these slots ensures modular data representations separate from the primary .X matrix.