/datascales-skills:icechunk-analysis-historyfrom datascales-skills
Versions single-cell AnnData stores using Icechunk repositories with commits and branches via annizarr. Tracks analysis steps, preserves raw counts, and enables branching per person or analysis.
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.
Icechunk stores a Zarr store with a history. A repository is the store plus its history.
A commit (snapshot) is one saved state. A branch is a named line of commits. Data
that does not change between commits is not written again. annizarr.Repo wraps the parts an
AnnData store needs (pip install "annizarr[icechunk]"); its docs page "Icechunk" lists
every call. The code below was run on 2026-11-30 with annizarr 0.2.4, icechunk 2.4.1,
anndata 0.13.4, on a small store on local disk, and on 2026-12-01 on a 204k-cell PBMC
repository on Linux with icechunk 2.3.1 and anndata 0.12.19.
Make it the default. Whenever the workflow builds a store, build it as a repository and
save each step as a commit, without being asked: people ask for clusters, not for a history,
and it is what lets a result be traced to the data and settings that made it. Use plain Zarr
only if the person asks for it. Data small enough to stay one .h5ad in memory needs no
store at all. The cost against plain Zarr has not been measured by the team; say so if asked.
| Branch | Holds | Who writes |
|---|---|---|
main | Every cell as ingested, raw counts. Changed only by ingest | Whoever ingests |
qc | The curated store: only the cells that passed QC, raw counts, plus results the group agrees on | One person or job at a time |
<name>/<analysis> | One person's or one analysis's work, branched off qc | That person |
main, and the Code Ocean capsules use
these names. Analysis reads qc, not main.X are never overwritten. Normalized values go in a layer, results in obsm,
obs and uns.import annizarr as az, numpy as np, pandas as pd
from anndata.io import read_elem, write_elem
def put(group, key, value): # write or replace one element
if key in group:
del group[key]
write_elem(group, key, value)
def put_column(frame, name, values): # add or replace an obs or var column
put(frame, name, values)
frame.attrs["column-order"] = [*(c for c in frame.attrs["column-order"] if c != name), name]
repo = az.Repo("atlas.icechunk", branch="qc") # no branch= opens main; s3:// and gs:// also work
base = repo.log()[0].id # the snapshot you are about to build on
root = repo.open_zarr("r") # read-only group at the branch tip
# analysis results on a personal branch
repo.checkout("alex/clustering", create=True) # branch off the current tip
g = repo.open_zarr("w") # edits are staged until commit
if "obsm" not in g:
write_elem(g, "obsm", {})
put(g["obsm"], "X_umap", umap.astype(np.float32))
put_column(g["obs"], "leiden", pd.Categorical(leiden))
repo.commit("leiden 1.1 on 50 PCs", metadata={"resolution": 1.1, "n_comps": 50})
# look back
repo.tree() # every branch as a text graph
[(s.id, s.message, s.metadata) for s in repo.log()]
old = repo.open_zarr("r", snapshot_id=base) # the store as it was, read-only
Building a repository: any annizarr command with --ic -m "message" makes one commit on
main: annizarr convert a.h5ad b.h5ad -o atlas.icechunk --ic -m "raw counts, all cells".
An existing plain store becomes a repository with az.Repo.init("atlas.zarr", "atlas.icechunk").
An analysed AnnData in memory (a spatial table, a subset) becomes one with
az.convert(adata, output="table.icechunk", cfg=AppConfig(io=IOConfig(backend="icechunk")), message="..."); obs, obsm, layers and uns are kept (run 2026-12-01, 3,000 cells).
main to a curated qc branchannizarr 0.2.4 has no command that copies a subset of cells. convert reads .h5ad and 10x
files, not an existing store ("already a store; use rechunk or sort"), and rechunk and
sort copy every cell. So the passing cells go through files: write them band by band to
temporary .h5ad parts, then one az.convert streams the parts onto branch qc as one
commit. Only one band of cells is in memory at a time.
If the store fits in memory, skip the parts: read it, subset it, and pass the AnnData
straight to az.convert(adata[passed].copy(), output=REPO, branch="qc", ...) with the same
arguments. On 2.0M cells with 179 GB of RAM the file route took 14 minutes where an
in-memory route took 10 (single runs). The same holds for a branch of one cell type.
import tempfile, anndata as ad
from anndata.experimental import read_elem_lazy
from annizarr.config import AppConfig, IOConfig
ad.settings.allow_write_nullable_strings = True # anndata 0.12: write_h5ad fails on obs without it
def main():
raw = az.Repo(REPO) # main: every cell
raw_snapshot = raw.log()[0].id
src = raw.open_zarr("r")
n_cells, n_genes = src["X"].attrs["shape"]
obs, var = read_elem(src["obs"]), read_elem(src["var"])
X = read_elem_lazy(src["X"], (BAND, n_genes)) # BAND cells in memory at a time
# ... compute QC metrics into obs, agree thresholds with the person, build `passed` ...
with tempfile.TemporaryDirectory(dir=SCRATCH) as tmp: # needs room for the passing cells
parts = []
for r0 in range(0, n_cells, BAND):
keep = passed[r0:r0 + BAND]
if keep.any():
parts.append(f"{tmp}/part_{r0:012d}.h5ad")
ad.AnnData(X=X[r0:r0 + BAND].compute()[keep], obs=obs.iloc[r0:r0 + BAND][keep],
var=var).write_h5ad(parts[-1])
az.convert(parts, output=REPO, branch="qc", # qc is created off main if missing
cfg=AppConfig(io=IOConfig(backend="icechunk", overwrite=True)),
message=f"QC: {int(passed.sum()):,} of {n_cells:,} cells pass")
repo = az.Repo(REPO, branch="qc") # record the decision on qc
g = repo.open_zarr("w")
if "uns" not in g:
write_elem(g, "uns", {})
write_elem(g["uns"], "qc", {"thresholds": thresholds, "n_cells": int(n_cells),
"n_pass": int(passed.sum()), "source_snapshot": raw_snapshot})
repo.commit("QC: record thresholds", metadata={"thresholds": thresholds, "source_snapshot": raw_snapshot})
if __name__ == "__main__": # required: annizarr starts worker processes
main()
X, obs (with the QC metrics you added) and var. A multi-input
convert carries nothing else, so run QC before any analysis is saved.overwrite=True replaces the contents of branch qc only; main is not touched.qc matched main in values, names
and dtype. Also run on 203,773 cells (182,343 passed), not larger; the .h5ad parts are
a second copy on disk until it finishes.qc again from main; the earlier curated state stays in the history.qc capsule does this step with a review file.Promoting a branch. There is no merge. az.Repo(path, branch="qc").cherrypick(snapshot_id)
points qc at a snapshot, like git reset --hard. Use it to move agreed results from a
personal branch onto qc. It is safe only when that snapshot was built on the current tip
of qc; otherwise the commits qc had are dropped from it.
Guard before a long write. Check the branch did not move while you computed:
store = repo.open_zarr("w")
if repo.log()[0].id != base:
repo.discard()
raise RuntimeError("The branch moved since the store was opened; nothing was written.")
| Limit | What to do |
|---|---|
| Two writers at once on a local or shared disk lose commits with no error. Reproduced 2026-11-30: two processes, 20 commits each to their own branch, 20 of 40 kept. Not tested on S3 or GCS | One writer at a time. Agree who writes, or run writes in sequence |
No branch merge or rebase in annizarr.Repo | Each branch builds on the last agreed state; promote by reset as above |
The annizarr command line reads main only; --branch is the branch written | Pass az.Repo(path, branch=...) to the Python function |
| A writable session cannot be sent to Dask workers | Compute from a read-only group, then open a writable one to save |
No tags and no command-line log in annizarr | Use repo.log(); raw icechunk has tags |
| A whole SpatialData store cannot live in Icechunk (points and shapes are Parquet) | Keep SpatialData as plain Zarr; only its cell table can be versioned |
repo.copy() works to local disk and s3://, not gs:// | — |
| Not measured by the team: overhead against plain Zarr, storage shared between commits | Do not claim versioning is free |
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./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./zarr-for-single-cellSets up and tunes one AnnData store on Zarr v3 for single-cell counts with annizarr. Use when someone wants to convert or combine h5ad or 10x files into a Zarr store, add samples later, choose between CSR, CSC and dense, sort cells, pick chunks, shards or compression, or when reading one gene or one cell type from a store is slow, a store has too many small files, or a conversion runs out of memory. Not for commits and branches, and not for the GPU analysis itself.