anndata
Lets your agent work with single-cell data in specific formats. It's useful for organizing and analyzing complex biological research information.
What it does
AnnData is a package that helps organize and analyze scientific data, especially from single-cell genomics. It stores the main measurements (X) along with information about the samples (obs) and the measured features (var).
When to use it
- ✓When creating or reading scientific data files like .h5ad or .zarr.
- ✓When working with single-cell genomics data.
- ✓When combining multiple datasets or experimental batches.
Example of what to ask your AI
“How can I read a data file named 'my_data.h5ad'?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
AnnData organizes your data into a main structure (X) and adds descriptive metadata (obs, var). It allows you to read and write this data efficiently in common formats like .h5ad and .zarr.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add K-Dense-AI/scientific-agent-skills --skill anndataOr download just the file:
curl -L https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/main/skills/anndata/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
AnnData
Overview
AnnData is a Python package for handling annotated data matrices, storing experimental measurements (X) alongside observation metadata (obs), variable metadata (var), and multi-dimensional annotations (obsm, varm, obsp, varp, uns). Originally designed for single-cell genomics through Scanpy, it now serves as a general-purpose framework for any annotated data requiring efficient storage, manipulation, and analysis.
When to Use This Skill
Use this skill when:
- Creating, reading, or writing AnnData objects
- Working with h5ad, zarr, or other genomics data formats
- Performing single-cell RNA-seq analysis
- Managing large datasets with sparse matrices or backed mode
- Concatenating multiple datasets or experimental batches
- Subsetting, filtering, or transforming annotated data
- Integrating with scanpy, scvi-tools, or other scverse ecosystem tools
Installation
Targets AnnData 0.13.4 (current PyPI release reviewed 2026-09-30), requiring Python 3.12+. Small synthetic checks cover dense/sparse matrices, native I/O, metadata, concatenation, and lazy reads. File paths, biological analysis, remote stores, and third-party integration examples are illustrative unless stated otherwise.
uv pip install "anndata==0.13.4"
# Lazy I/O and dask-backed operations
uv pip install "anndata[dask,lazy]==0.13.4"
Use unpinned installs only when intentionally tracking the latest compatible release.
Current API notes:
- Use
anndata.iofor non-nativeread_*andwrite_*helpers. Top-levelanndata.read_h5adandanndata.read_zarrremain supported. - Use
ad.concat;AnnData.concatenate()was removed in 0.13. Avoid oldad.read, deprecatedAnnData.*_keys()helpers andanndata.__version__; prefer explicit readers, mapping.keys(), andimportlib.metadata.version("anndata"). - In 0.13,
.Xis alsolayers[None]; layer iteration includesNone. Usekey is not Nonewhen selecting named layers. View.Xwrites now use copy-on-write. - Zarr v3 and automatic sharding are the defaults; the Python dependency is Zarr >=3. Dense H5AD
Xremains writable withbacked="r+", but backed sparse item assignment is unsupported in 0.13. AnnLoaderand Loom reading/writing are deprecated.AnnCollectionand other experimental APIs need the caveats in the references.
These changes are documented in the official release notes. The live docs header still displayed 0.13.3.post0 at review; behavior below was also checked against installed 0.13.4 source.
Quick Start
Creating an AnnData object
import anndata as ad
import numpy as np
import pandas as pd
# Minimal creation
X = np.random.rand(100, 2000) # 100 cells × 2000 genes
adata = ad.AnnData(X)
# With metadata
obs = pd.DataFrame({
'cell_type': ['T cell', 'B cell'] * 50,
'sample': ['A', 'B'] * 50
}, index=[f'cell_{i}' for i in range(100)])
var = pd.DataFrame({
'gene_name': [f'Gene_{i}' for i in range(2000)]
}, index=[f'ENSG{i:05d}' for i in range(2000)])
adata = ad.AnnData(X=X, obs=obs, var=var)
Reading data
# Native formats (read_h5ad/read_zarr remain at top-level)
adata = ad.read_h5ad('data.h5ad')
source = ad.read_h5ad('large_data.h5ad', backed='r') # X backed; metadata/layers can load
try:
subset = source[:100, :].to_memory()
finally:
source.file.close()
adata = ad.read_zarr('data.zarr')
# Other formats: prefer anndata.io (top-level imports are deprecated)
from anndata.io import read_csv, read_loom, read_mtx
adata = read_csv('data.csv')
adata = read_loom('data.loom')
# 10X Genomics: use scanpy (not anndata) — see scanpy skill
import scanpy as sc
adata = sc.read_10x_h5('filtered_feature_bc_matrix.h5')
adata = sc.read_10x_mtx('filtered_feature_bc_matrix/')
Writing data
# Write h5ad file
adata.write_h5ad('output.h5ad')
# Write with compression
adata.write_h5ad('output.h5ad', compression='gzip')
# Write other formats
adata.write_zarr('output.zarr')
adata.write_csvs('output_dir/', skip_data=False) # Lossy; may densify X
Basic operations
# Subset by conditions
t_cells = adata[adata.obs['cell_type'] == 'T cell']
# Subset by indices
subset = adata[0:50, 0:100]
# Add metadata
adata.obs['quality_score'] = np.random.rand(adata.n_obs)
adata.var['highly_variable'] = np.random.rand(adata.n_vars) > 0.8
# Access dimensions
print(f"{adata.n_obs} observations × {adata.n_vars} variables")
…
FAQ
What are 'obs' and 'var'?
'obs' contains information about the observations (like cells), and 'var' contains information about the measured variables (like genes).
Can I use AnnData with large datasets?
Yes, AnnData supports 'backed mode' for working with large files that don't fit entirely in memory.
How do I install AnnData?
You can install it using pip with the command: `uv pip install anndata`.
Details
Original description by the author
Handles annotated matrices in single-cell analysis, .h5ad and Zarr files, and integration with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.
Popularity
- GitHub stars
- 51k
- Ranking position
- #1832
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
13c-metabolic-flux
Estimates metabolic fluxes using carbon-13 isotope tracing data. It is useful for analyzing cellular metabolism and biochemical pathways.
K-Dense-AI/scientific-agent-skills
adaptyv
Designs protein characterization experiments using the Adaptyv API. It helps estimate costs, submit sequences, and monitor lab results.
K-Dense-AI/scientific-agent-skills
aeon
Performs machine learning tasks on time series data. It is useful for classifying, forecasting, detecting anomalies, and finding patterns in sequential data.
K-Dense-AI/scientific-agent-skills
alphagenome
Looks up precomputed genomic effects for genetic variants. It provides scores and explanations to understand the impact of variants on the genome.
K-Dense-AI/scientific-agent-skills
Similar skills
data-throughput-accelerator
Makes your agent speed up the movement of large data volumes. It finds bottlenecks and ensures data is transferred quickly and correctly.
affaan-m/ECC
inventory-demand-planning
Helps your agent predict product demand in stores. It optimizes stock and plans when to run promotions to sell more.
affaan-m/ECC
market-research
Helps your agent conduct market research and competitive analysis. Provides summaries with source attribution.
affaan-m/ECC