aipoch/medical-research-skills/anndata
Claude Code and agent skill by aipoch/medical-research-skills
Trust tier 2
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Data structure for annotated matrices in single-cell analysis; use when reading/writing .h5ad (or zarr) and exchanging data with the scverse ecosystem.
Install
npx vskill@latest install aipoch/medical-research-skills/anndataSKILL.md
When to Use
Use AnnData when you need to:
- Load, inspect, or export annotated single-cell datasets stored as
.h5ad(orzarr) for downstream tools. - Keep a matrix (cells × features) tightly coupled with observation/feature metadata (e.g., cell types, batches, gene annotations).
- Work efficiently with large, sparse count matrices (e.g., scRNA-seq) and avoid loading everything into memory (backed mode).
- Combine multiple experiments/batches/modalities into a unified object while tracking provenance.
- Subset/filter/transform data while preserving alignment between the matrix and metadata.
Key Features
- Unified container:
X(data matrix) plus aligned annotations:obs,var,uns, and multi-dimensional slots (obsm,varm,obsp,varp), pluslayersand optionalraw. - Interoperable I/O: Native
.h5adandzarr, plus common genomics formats (e.g., 10x, loom, mtx, csv). - Scalable workflows: Sparse matrices and backed mode (
backed="r") for large datasets. - Safe subsetting: Slicing preserves alignment across matrix and annotations; supports views vs copies.
- Concatenation utilities:
ad.concat(...)with join/merge strategies and batch labeling; experimental lazy collections.
Reference notes: the original material mentions additional guides underreferences/(e.g.,references/data_structure.md,references/io_operations.md,references/concatenation.md,references/manipulation.md,references/best_practices.md) for deeper explanations of each topic.
Dependencies
anndata(latest compatible with your environment; install via pip/uv)numpypandasscipy(recommended for sparse matrices)- Optional ecosystem tools (only if needed):
scanpymuontorch(for deep learning) andanndataexperimental loader utilities
Example Usage
A complete runnable example that creates an AnnData object, writes/reads .h5ad, subsets, concatenates batches, and demonstrates backed mode.
Implementation Details
Data model (core slots)
X: primary data matrix (densenumpy.ndarrayor sparsescipy.sparse), shape(n_obs, n_vars).obs: per-observation metadata (pandas.DataFrame), indexed byobs_names(e.g., cell IDs).var: per-variable metadata (pandas.DataFrame), indexed byvar_names(e.g., gene IDs).layers: named alternative matrices aligned toX(e.g.,"counts","log1p").obsm/varm: multi-dimensional embeddings aligned to obs/var (e.g., PCA, UMAP coordinates).obsp/varp: pairwise graphs/matrices (e.g., kNN graph inobsp["connectivities"]).uns: unstructured metadata (dict-like), often used for parameters and plotting configs.raw(optional): snapshot of unfiltered/untransformed data for reproducibility.
Views vs copies
- Slicing like
adata_subset = adata[mask, :]typically returns a view (lightweight reference). - Use
.copy()when you need an independent object (e.g., before in-place modifications).
Backed mode (large datasets)
ad.read_h5ad(path, backed="r")keeps the matrix on disk and loads data lazily.- Convert a slice to memory with
.to_memory()when you need in-memory computation. - Backed mode is best for filtering by metadata, chunked processing, and avoiding OOM.
Concatenation behavior
ad.concat([...], axis=0)stacks observations;axis=1stacks variables.join="inner"keeps intersection of variables;join="outer"unions variables (may introduce missing values).label+keysrecords dataset/batch provenance in.obs[label].- Merge strategies control how conflicting
.unsand annotation columns are handled (choose based on your data governance needs).
Practical performance parameters
- Prefer sparse matrices (
csr_matrix) for count-like data. - Convert repeated strings to categoricals (
adata.strings_to_categoricals()). - Use compression when writing
.h5ad(e.g.,compression="gzip") to reduce storage; considerzarrfor chunked/cloud-friendly access.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingscientific-skills/Data Analysis/anndata/SKILL.md
Popularity
- Repository stars
- 1,557
- Repository forks
- 152
- 7-day trend score
- 37
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aipoch/medical-research-skills/anndata)