annbatch.write_sharded

Contents

annbatch.write_sharded#

annbatch.write_sharded(group, adata, *, n_obs_per_chunk=64, shard_size='1GB', compressors=(BloscCodec(_tunable_attrs={'typesize'}, typesize=1, cname=<BloscCname.lz4: 'lz4'>, clevel=3, shuffle=<BloscShuffle.shuffle: 'shuffle'>, blocksize=0), ), key=None)#

Write a sharded zarr store from a single AnnData object.

Parameters:
group Group

The destination group, must be zarr v3

adata AnnData

The source anndata object

n_obs_per_chunk int (default: 64)

Number of observations per chunk. For dense arrays this directly sets the first-axis chunk size. For sparse arrays it is converted to element counts using the average non-zero elements per row of the matrix being written.

shard_size int | str (default: '1GB')

Number of observations per shard, or a size string (e.g. '1GB', '512MB'). If a size string is provided, the observation count is derived independently for each array element from its uncompressed bytes-per-row so that every shard stays close to the target size. For dense arrays the resolved count directly sets the first-axis shard size. For sparse arrays it is converted to element counts using the average non-zero elements per row of the matrix being written.

compressors Iterable[BytesBytesCodec] (default: (BloscCodec(_tunable_attrs={'typesize'}, typesize=1, cname=<BloscCname.lz4: 'lz4'>, clevel=3, shuffle=<BloscShuffle.shuffle: 'shuffle'>, blocksize=0),))

The compressors to pass to zarr.

key str | None (default: None)

The key to which this object should be written - by default the root, in which case the entire store (not just the group) is cleared first.