LLM Skills
~/catalog/debugging & maintenance//SKILL

Anndata

/SKILL

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem.

K-Dense-AIK-Dense-AI
31.9k
June 15, 2026
MIT License
// skill content

--- name: anndata description: Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating 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. license: BSD-3-Clause license allowed-tools: Read Write Edit Bash compatibility: Requires Python 3.11+ and uv. Examples target AnnData 0.12.16, with experimental APIs clearly marked where used. metadata: {"version": "1.1", "skill -author": "K-Dense Inc."} --- # AnnData ## Overview AnnData is a Python package for handling annotated data matrices, storing experimental measurements (X) alongside observation metadata (obs), variable metadata (var), and multidimensional annotations (obsm, varm, obsp, varp, uns). Originally designed for single-cell genomics using 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 in backed mode - Concatenating multiple datasets or experimental batches - Subsetting, filtering, or transforming annotated data - Integrating with Scanpy, scvi-tools, or other tools in the scverse ecosystem ## Installation Requires Python 3.11+. Current stable release: 0.12.16 (released May 18, 2026). ``bash uv pip install "anndata==0.12.16" # Lazy I/O and dask-backed operations uv pip install "anndata[dask,lazy]==0.12.16" # Development / docs (contributors) uv pip install "anndata[dev,test,doc]==0.12.16" ` Use unpinned installs only when intentionally tracking the latest compatible release. Current API notes: - Use anndata.io for non-native read_* and write_* helpers. Top-level anndata. read_h5ad and anndata. read_zarr remain supported. - Avoid deprecated APIs: ad.read , AnnData.concatenate(), AnnData.*_, and . Prefer ad. read_h5ad, ad.concat , mapping .keys(), and importlib.metadata.version("anndata"). - Treat APIs as useful but unstable. Prefer them for large-data workflows only when their current caveats are acceptable. ## Quick Start ### Creating an AnnData object `python 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 `python # Native formats (read_h5ad/read_zarr remain at top-level) adata = ad.read_h5ad('data.h5ad') adata = ad.read_h5ad('large_data.h5ad', backed='r') # lazy load for large files 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 `python # 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/') ` ### Basic operations `python # 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") `` ## Core Capabilities ###

// original public source
K-Dense-AI/scientific-agent-skills
/skills/anndata/SKILL.md
License: MIT License
Independent project, not affiliated with Anthropic. This skill remains the property of its original author.
// install this skill
Paste this command in your terminal at the root of your project:
mkdir -p .claude/commands && curl -o ".claude/commands/SKILL.md" "https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/main/skills/anndata/SKILL.md"
Then in Claude Code, type /SKILL to activate it.
open_in_newOpen original source
// save
Save available after sign in.
loginSign in to save
// information
CreatorK-Dense-AI
Stars 31.9k
LicenseMIT License
UpdatedJune 15, 2026
Format.md
AccessFree
// similar

Skills Debugging & maintenance

View allarrow_forward