uchrom.io¶
I/O helpers with lazy optional-dependency imports.
Format upgrade¶
Convert ChromData files to the current container (.chromdata.zarr).
ChromData.read no longer reads the HDF5 .h5cd container (format 1.x
and 2.0); this converts such a file once, after which it reads fast and can
be backed (ChromData.read(path, backed=True)):
python -m uchrom.io.upgrade old.h5cd new.chromdata.zarr
python -m uchrom.io.upgrade data/*.h5cd --out-dir converted/ # <stem>.chromdata.zarr
python -m uchrom.io.upgrade data/*.h5cd --out-dir converted/ --format cdz
What changes (see docs/source/guide/chromdata_2_0_design.md):
1.x → 2.0 data model:
bins= the unique spot loci;spotsstorebin_idinstead ofchrom/start/end(still available viacd.spots/cd.to_dataframe()); the spot-aligned 1.xtrackssplit into bin-leveltracks(columns constant within every bin) andspot_tracks;the container: Zarr v3 + Parquet, spots sorted by (cell, trace, bin) with an
index/of row offsets (index/source_rowkeeps the original order).
The target format follows the destination suffix (.chromdata.zarr or
.cdz). The source is never modified. Older zarr / cdz stores are
rewritten in the current layout too.
- uchrom.io.upgrade.convert(src: str | Path, dst: str | Path | None = None, *, overwrite: bool = False, coord_dtype: str = 'float64') dict¶
the conversion is not specific to .h5cd sources
- uchrom.io.upgrade.default_target(src: str | Path, fmt: str = 'zarr', out_dir: str | Path | None = None) Path[source]¶
<dir>/<stem>.chromdata.zarr(or.cdz) forsrc.
- uchrom.io.upgrade.file_format_version(path: str | Path) str[source]¶
The
uchrom_format_versionof a ChromData file ("1.0"for an unversioned.h5cd).
- uchrom.io.upgrade.upgrade_h5cd(src: str | Path, dst: str | Path | None = None, *, overwrite: bool = False, coord_dtype: str = 'float64') dict[source]¶
Read
src(.h5cd1.x / 2.0, or any ChromData store) and write it todstin the current format (.chromdata.zarr/.cdz); a zarr / cdz source is read in its original row order.dstdefaults to<src stem>.chromdata.zarrnext tosrc; its suffix picks the container.coord_dtypeis the storage dtype ofcoords/layers(seeChromData.write()).Returns a summary: source / target versions and containers,
n_spots,n_binsand which tracks are bin- vs spot-level.srcis never modified;dstmust differ from it.