smftools.analysis.compute.metrics_store#
metrics_store.py — Per-run Zarr store for computed per-read analysis metrics.
Keeps raw signal caches pristine by storing derived metrics separately. Row ordering matches the companion <run>.zarr barcode-sorted obs.
Structure:
<run>_metrics.zarr/
obs/
ls_nrl_bp_<mask> float (n_obs,) — NaN where not computed
ls_snr_<mask> float (n_obs,)
ls_peak_power_<mask> float (n_obs,)
ls_fwhm_bp_<mask> float (n_obs,)
obsm/
ls_power_<mask> float (n_obs, n_freqs)
ls_freqs_<mask> float (n_freqs,) — shared frequency grid
Usage:
from smftools.analysis.compute import metrics_store
# Writing (analyses driver):
store = metrics_store.open_or_create(path, n_obs)
metrics_store.write_obs_array(store, "ls_nrl_bp_full_locus", arr)
metrics_store.write_obsm_array(store, "ls_power_full_locus", power_mat)
metrics_store.write_obsm_array(store, "ls_freqs_full_locus", freqs)
metrics_store.consolidate(path)
# Reading:
store = metrics_store.open_metrics_store(path)
nrl = store["obs"]["ls_nrl_bp_full_locus"][:]
power = store["obsm"]["ls_power_full_locus"][:]
Functions
|
Consolidate Zarr metadata so arrays are visible in read mode. |
|
Open an existing metrics store read-only. |
|
Open an existing metrics store in append mode, or create a new one. |
|
Write or overwrite a full-length (n_obs,) obs metric array. |
|
Write or overwrite an obsm array (2D for per-read power, 1D for shared freqs). |
- smftools.analysis.compute.metrics_store.open_or_create(path, n_obs)#
Open an existing metrics store in append mode, or create a new one.
- Return type:
Parameters#
path : Path to the
<run>_metrics.zarrdirectory. n_obs : Total number of obs rows (must match the companion signal Zarr).Returns#
zarr.Group
- smftools.analysis.compute.metrics_store.write_obs_array(store, col, values)#
Write or overwrite a full-length (n_obs,) obs metric array.
- Return type:
- smftools.analysis.compute.metrics_store.write_obsm_array(store, key, values)#
Write or overwrite an obsm array (2D for per-read power, 1D for shared freqs).
- Return type:
- smftools.analysis.compute.metrics_store.consolidate(path)#
Consolidate Zarr metadata so arrays are visible in read mode.
- Return type:
- smftools.analysis.compute.metrics_store.open_metrics_store(path)#
Open an existing metrics store read-only.