Storage I/O
Use this sub-skill when a task mentions .h5ad, .zarr, HDF5, Zarr, storage formats, backed mode, lazy reads, read_h5ad, read_zarr, write_h5ad, write_zarr, anndata.io.read_elem, anndata.io.write_elem, anndata.io.sparse_dataset, encoding metadata, sparse on-disk arrays, compression, chunking, Zarr v3, metadata consolidation, or concat_on_disk storage prerequisites.
Route First
- Continue here for whole-object H5AD/Zarr reads and writes, storage choice, backed/lazy access, element-level reads/writes, sparse on-disk datasets, encoding metadata, and storage-specific failures.
- Route object construction, aligned slot shape rules, views,
obs/var semantics, .raw, and in-memory mutation to ../data-model/SKILL.md.
- Route multi-object combination semantics to
../combining-data/SKILL.md; use this sub-skill only to prepare readable input stores and validate writable output stores for concat_on_disk.
- Route accessors, references, and extension namespaces to
../accessors-extensions/SKILL.md.
Use The Bundled Files
references/api-reference.md lists verified public I/O signatures, stable versus experimental APIs, and option notes.
references/file-format.md distills the H5AD/Zarr hierarchy, required encoding metadata, and inspection checks.
references/io-workflows.md gives decision workflows for H5AD versus Zarr, backed versus lazy access, element I/O, sparse datasets, Zarr v3 metadata, sharding, and compressor choices.
references/troubleshooting.md maps storage symptoms to causes and recovery steps.
scripts/check_anndata_io_roundtrip.py creates tiny deterministic H5AD and/or Zarr fixtures, reads them back, optionally checks backed/lazy access, and prints pass/fail without network access.
Default Decisions
- Prefer
.h5ad for single-file local exchange and HDF5 backed reads; close backed objects with adata.file.close().
- Prefer Zarr for directory or cloud-style stores, chunk tuning, consolidated metadata, sharding, and codec configuration.
- Use full
read_h5ad/read_zarr for small or final validation reads; use read_h5ad(..., backed="r") for low-memory H5AD inspection; use anndata.experimental.read_lazy for experimental dask/xarray-backed low-memory reads.
- Treat
anndata.experimental.read_lazy, read_dispatched, and write_dispatched as experimental APIs; use stable high-level methods and anndata.io.read_elem/write_elem unless callback-based traversal or lazy materialization is required.
- After writing any store, re-read it and validate shape, names, expected keys, sparse/dense representation, and backing/lazy file lifecycle.
Quick Checks
python sub-skills/storage-io/scripts/check_anndata_io_roundtrip.py
python sub-skills/storage-io/scripts/check_anndata_io_roundtrip.py --backed-lazy
python sub-skills/storage-io/scripts/check_anndata_io_roundtrip.py --output-dir ./tmp-anndata-io --keep
When running the script from outside the skill directory, use its full path. The script creates only local temporary fixtures unless --output-dir is provided.
1---2name: storage-io3description: "Read, write, choose, inspect, and troubleshoot AnnData H5AD/Zarr4 storage, backed mode, lazy reads, sparse datasets, element-level I/O, and Zarr5 v3 options."6disable-model-invocation: true7metadata:8 source: https://skillmd.com/skills/vectorspacelab/storage-io9 disco-role: operating10license: BSD 3-Clause11---1213# Storage I/O1415Use this sub-skill when a task mentions `.h5ad`, `.zarr`, HDF5, Zarr, storage formats, backed mode, lazy reads, `read_h5ad`, `read_zarr`, `write_h5ad`, `write_zarr`, `anndata.io.read_elem`, `anndata.io.write_elem`, `anndata.io.sparse_dataset`, encoding metadata, sparse on-disk arrays, compression, chunking, Zarr v3, metadata consolidation, or `concat_on_disk` storage prerequisites.1617## Route First1819- Continue here for whole-object H5AD/Zarr reads and writes, storage choice, backed/lazy access, element-level reads/writes, sparse on-disk datasets, encoding metadata, and storage-specific failures.20- Route object construction, aligned slot shape rules, views, `obs`/`var` semantics, `.raw`, and in-memory mutation to `../data-model/SKILL.md`.21- Route multi-object combination semantics to `../combining-data/SKILL.md`; use this sub-skill only to prepare readable input stores and validate writable output stores for `concat_on_disk`.22- Route accessors, references, and extension namespaces to `../accessors-extensions/SKILL.md`.2324## Use The Bundled Files2526- `references/api-reference.md` lists verified public I/O signatures, stable versus experimental APIs, and option notes.27- `references/file-format.md` distills the H5AD/Zarr hierarchy, required encoding metadata, and inspection checks.28- `references/io-workflows.md` gives decision workflows for H5AD versus Zarr, backed versus lazy access, element I/O, sparse datasets, Zarr v3 metadata, sharding, and compressor choices.29- `references/troubleshooting.md` maps storage symptoms to causes and recovery steps.30- `scripts/check_anndata_io_roundtrip.py` creates tiny deterministic H5AD and/or Zarr fixtures, reads them back, optionally checks backed/lazy access, and prints pass/fail without network access.3132## Default Decisions3334- Prefer `.h5ad` for single-file local exchange and HDF5 `backed` reads; close backed objects with `adata.file.close()`.35- Prefer Zarr for directory or cloud-style stores, chunk tuning, consolidated metadata, sharding, and codec configuration.36- Use full `read_h5ad`/`read_zarr` for small or final validation reads; use `read_h5ad(..., backed="r")` for low-memory H5AD inspection; use `anndata.experimental.read_lazy` for experimental dask/xarray-backed low-memory reads.37- Treat `anndata.experimental.read_lazy`, `read_dispatched`, and `write_dispatched` as experimental APIs; use stable high-level methods and `anndata.io.read_elem`/`write_elem` unless callback-based traversal or lazy materialization is required.38- After writing any store, re-read it and validate shape, names, expected keys, sparse/dense representation, and backing/lazy file lifecycle.3940## Quick Checks4142```bash43python sub-skills/storage-io/scripts/check_anndata_io_roundtrip.py44python sub-skills/storage-io/scripts/check_anndata_io_roundtrip.py --backed-lazy45python sub-skills/storage-io/scripts/check_anndata_io_roundtrip.py --output-dir ./tmp-anndata-io --keep46```4748When running the script from outside the skill directory, use its full path. The script creates only local temporary fixtures unless `--output-dir` is provided.