/datascales-skills:zarr-for-single-cellfrom datascales-skills
Configures and tunes AnnData Zarr v3 stores for single-cell RNA-seq data using annizarr. Helps with h5ad/10x conversion, chunking, compression, layout (CSR/CSC/dense), sorting, and sharding to optimize read performance and memory usage.
Ships in datascales-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
One store holds the raw counts for every cell. annizarr (pip install annizarr, command
annizarr or anz, Python import annizarr as az) writes Zarr v3 that stock
anndata.read_zarr opens, and streams so memory does not grow with the store. Its docs
(a-jolly-holly.github.io/annizarr) cover every flag; this file holds the choices and traps.
Commands below were run on 2026-11-30 with annizarr 0.2.4, anndata 0.13.4, zarr 3.4.2, and
on 2026-12-01 on 204k PBMC cells on Linux with anndata 0.12.19.
Check annizarr --version first.
Reads on a synthetic 2M × 34k store on GCS, single cold runs, client machine not recorded.
| Read | CSR X | CSC | Dense 1k × 1k |
|---|---|---|---|
| 500k cells | 4.42 s | about 29 to 37 s | 36.9 s |
| 1 gene, all cells | about 29 s | 0.26 s | 2.24 s |
| 250k cells returned as CSR | 2.34 s | 45 s | 63 to 83 s |
X as CSR, raw counts. Dask and GPU pipelines read cells in blocks, and a lazy
sparse read can only be chunked along the stored axis (rows for CSR).X. The CSC copy is rewritten whole on
every append, so add it after the cells are in.X.Sort cells by the column people filter on. Cells with one label become contiguous, so a read
touches a few chunks instead of all of them. Measured on the same store: about 200k B cells
from sorted CSR in 2.04 s against 37.2 s unsorted (single run; the raw file for the sorted
run is missing). Sort by one or two columns, primary first, for example cell_type, or
donor cell_type. Ask the person which query is most common before choosing.
Keep the defaults unless there is a symptom.
| Setting | Default | Change it when |
|---|---|---|
| Sparse chunk | 9,000,000 nonzeros | Rarely. --row-chunk N sizes chunks to about N cells instead |
| Dense chunk | 2048 × 2048 | Only for dense layers |
| Compression | Blosc zstd level 3, byte shuffle | Rarely. Level 5 wrote 2 to 3.6 times slower for 1 to 7% fewer bytes (annizarr release notes) |
--auto-shard | off | A remote store has too many objects. On local disk it cut objects by 32% and made reads 15 to 36% slower (100k-cell test, laptop). Not measured on object storage |
--cpus | every usable core | Memory is short: each worker holds about 630 MB |
annizarr rechunk changes chunks or shards without changing the layout.
annizarr convert a.h5ad b.h5ad -o merged.zarr # many inputs become one store
annizarr sort merged.zarr -o atlas.icechunk --by cell_type --ic \
-m "raw counts, all cells, sorted by cell_type" # sorted, with a history
annizarr convert c.h5ad -o c.zarr # new samples: convert first,
annizarr append atlas.icechunk c.zarr --drop-derived -m "add sample C" # then append: one commit
annizarr add-layer atlas.icechunk --layer counts_csc -m "CSC copy" # CSC copy of X for gene reads
Build the final store as an Icechunk repository by default (--ic -m "message" on
convert or sort), without waiting to be asked: later results then land as commits (see
icechunk-analysis-history). append and add-layer on a repository commit by themselves.
Drop --ic for plain Zarr only if the person asks for it. s3:// and gs:// outputs
require Icechunk. Run on 2026-12-01 as written (5,500 + 1,500 cells, local disk).
az.plan_append(store, cells=...) reports what an append would add and drop without writing.
import zarr
from anndata.experimental import read_elem_lazy
from anndata.io import read_elem
zarr.config.set({"async.concurrency": 64, "threading.max_workers": 8}) # set both
g = zarr.open_group("sorted.zarr", mode="r")
n_cells, n_genes = g["X"].attrs["shape"]
X = read_elem_lazy(g["X"], (24_000, n_genes)) # Dask array, 24,000 cells per block
cell_type = read_elem(g["obs"]["cell_type"]) # one obs column, not the whole table
gene = read_elem_lazy(g["layers/counts_csc"])[:, 5].compute() # one gene from the CSC layer
async.concurrency only starts chunk fetches;
threading.max_workers is the pool that decompresses. Raising one alone does little: a
dense read went from 12.05 s to 1.73 s with both raised from 1 to 12, and stayed at
11.9 s when the pool was raised but async.concurrency was left at 1 (single run,
machine not recorded). Use about the number of cores for the pool.obs by column. The whole table of a large store takes a lot of memory.X[first:last + 1]..compute() a large block to the client or call .toarray() on the whole matrix.| Trap | What to do |
|---|---|
convert with several inputs keeps only X, obs and var. Layers, obsm, raw and uns are left out | Convert first, analyse after |
Several inputs need the same genes in the same order, and the same obs columns | Pass --obs-columns to keep a shared set |
convert a.h5ad b.h5ad --sort-by ... is refused | Convert, then sort |
append breaks the sort order and drops obsm, obsp and layers the new cells lack | Append, then sort, then analyse. A script needs --drop-derived |
append on plain Zarr cannot be rolled back if it dies midway | Use Icechunk for a store that grows |
sort needs CSR X and a local output | Sort locally, then copy or convert to the remote repository |
convert refuses an existing store as input, and no command copies a subset of cells | rechunk and sort are the store-to-store commands. For a subset, see QC in icechunk-analysis-history |
annizarr reads .h5ad and 10x HDF5 only | Export Seurat or MuData to .h5ad first. It has no reader for Xenium or Atera bundles |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub aifimmunology/datascales --plugin datascales-skills5 skills in this plugin
/datascales-workflowPlans an analysis of large single-cell or spatial data as one workflow, AnnData on Zarr, Icechunk history and rapids-singlecell on a GPU, as the DataScales team at the Allen Institute for Immunology runs it. Use when someone wants to analyse data that is too big for memory, keeps growing or is shared between people; asks whether a GPU is worth it; wants QC through clustering at scale; or asks which DataScales tools, capsules or benchmarks exist. Start here for a whole analysis; the topic skills cover single steps./icechunk-analysis-historyKeeps the history of an analysis inside an Icechunk repository holding an AnnData store, with commits and branches through annizarr. Use by default whenever a Zarr store is built or results are saved into one, and when someone wants to version or snapshot a single-cell store, keep raw counts safe while analysing, give each person or analysis a branch, save QC results or clusters as a commit with the settings that made them, read or compare an earlier state, undo a step, or avoid keeping a full copy of the data per analysis stage. Not for choosing the store layout, and not for versioning code./rapids-out-of-coreRuns rapids-singlecell on a GPU over a Zarr AnnData store that is larger than GPU or host memory, reading cells in Dask blocks. Use when someone wants to normalize, find variable genes, run PCA, neighbors, UMAP or Leiden on millions of cells on a GPU, set up a Dask-CUDA cluster, choose managed memory or a pool, size a GPU for a dataset, or when a GPU run is slow, runs out of memory, or does not speed up with more GPUs. Not for building the store or for spatial statistics./spatial-on-gpuAnalyses spatial transcriptomics cell tables (10x Xenium, Atera, or any SpatialData table with cell coordinates) with rapids-singlecell on a GPU. Use when someone wants spatial QC, a spatial neighbor graph, tissue niches or zones, neighborhood enrichment, co-occurrence, ligand-receptor analysis or spatially variable genes on a GPU, wants to combine several spatial samples, or asks how a SpatialData store fits with Zarr and Icechunk. Not for segmentation, image processing or dissociated scRNA.