quadsv.comparators.irregular#

ComparatorIrregular — cross-sample pattern comparison on a list of anndata.AnnData (irregular spots, NUFFT backend).

Classes#

ComparatorIrregular

Cross-sample pattern comparison on irregular spots via NUFFT.

Module Contents#

class quadsv.comparators.irregular.ComparatorIrregular(samples, gene_names=None, *, feature_mode='radial', n_radial_bins=30, obsm_key='spatial', layer=None, unit_scales=None, grid_shape=None, spacing=None, freq_edges=None, eps=1e-06, presence_threshold=0.0, nufft_chunk_size=64, workers=None)[source]#

Bases: quadsv.comparators.base._ComparatorBase

Cross-sample pattern comparison on irregular spots via NUFFT.

Accepts a list of anndata.AnnData (one per sample). For each sample, the per-sample obsm[obsm_key] supplies the irregular (y, x) coordinates and .X (or .layers[layer] when set) is the expression matrix. Spectra are evaluated with a batched type-1 NUFFT (finufft.nufft2d1), densifying at most nufft_chunk_size columns of .X at a time so the full slab is never materialized.

Parameters:
  • samples (sequence of anndata.AnnData)

  • gene_names (sequence of str, optional) – If None, inferred from the first sample; every other sample must share the same var_names.

  • feature_mode ({'radial', '2d'}, default 'radial')

  • n_radial_bins (int, default 30)

  • obsm_key (str, default 'spatial')

  • layer (str, optional)

  • unit_scales (sequence of float, optional) – Per-sample multiplier applied to coords before NUFFT (e.g. pixels→μm).

  • grid_shape (optional) – When both given, used for every sample. Otherwise each sample’s k-grid is auto-inferred from coords via quadsv.kernels.nufft._infer_grid_from_coords().

  • spacing (optional) – When both given, used for every sample. Otherwise each sample’s k-grid is auto-inferred from coords via quadsv.kernels.nufft._infer_grid_from_coords().

  • freq_edges (np.ndarray, optional)

  • eps (float, default 1e-6) – NUFFT tolerance.

  • presence_threshold (float, default 0.0) – Minimum fraction of non-zero spots for a gene to count as “observed” in a sample (feeds presence_ and, transitively, the masked pattern test).

  • nufft_chunk_size (int, default 64) – Number of genes per batched NUFFT call. 32–128 balances finufft’s per-call overhead against the (n_spots, chunk) transient RAM.

  • workers (int, optional) – Forwarded to per-sample FFTs used by normalize_covariates().

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.

feature_mode = 'radial'[source]#
freq_edges = None[source]#
gene_names[source]#
samples[source]#