quadsv.comparators.grid#
ComparatorGrid — cross-sample pattern comparison on a list of
spatialdata.SpatialData (regular rasterized bins, FFT
backend).
Classes#
Cross-sample pattern comparison on regular bins via FFT + SpatialData. |
Module Contents#
- class quadsv.comparators.grid.ComparatorGrid(samples, *, bins, table_name, col_key, row_key, value_key=None, gene_names=None, feature_mode='radial', n_radial_bins=30, fft_solver='rfft2', workers=None, spacing=None, freq_edges=None, presence_threshold=0.0, fft_chunk_size=256)[source]#
Bases:
quadsv.comparators.base._ComparatorBaseCross-sample pattern comparison on regular bins via FFT + SpatialData.
Accepts a list of
spatialdata.SpatialData(one per sample). For each sample,spatialdata.rasterize_bins()turns the designated bin shape + table into a dense(n_genes, ny, nx)image, which is then fed to the batched 2D FFT. All samples are expected to share the same rasterization schema (bins/table_name/col_key/row_key/value_key) — this mirrorsDetectorGrid.- Parameters:
samples (sequence of
spatialdata.SpatialData)bins (str) – SpatialElement key for the bin shapes in each
sdata.table_name (str) – Table key in each
sdata.tables.col_key (str) – Column / row-index columns in the table’s
.obs.row_key (str) – Column / row-index columns in the table’s
.obs.value_key (str, optional) – Expression column in
.obs; defaults toNone(rasterizes counts / presence directly off.X).gene_names (sequence of str, optional) – If None, inferred from the first sample’s table. All samples must share
var_names.fft_chunk_size (int, default 256) – Genes per batched
scipy.fftcall on the rasterized block. Keeps transient memory bounded atO(ny · nx · chunk · 8 B). The raster itself is still built once per sample (full(n_genes, ny, nx)footprint is unavoidable on SpatialData).feature_mode (str) – See
_ComparatorBase.n_radial_bins (int) – See
_ComparatorBase.fft_solver (str) – See
_ComparatorBase.workers (int | None) – See
_ComparatorBase.freq_edges (ndarray | None) – See
_ComparatorBase.presence_threshold (float) – See
_ComparatorBase.spacing (tuple[float, float] | None)
Notes
The comparator carries no design / contrast state — supply the cross-sample contrast directly to
test_diff_freq()/test_diff_expr(). A single fitted comparator can therefore serve any number of unrelated comparisons on the same spectra.