quadsv.api#

Top-level factory entry points: Detector() and Comparator().

Thin one-liner discovery face on top of the four explicit classes (DetectorIrregular, DetectorGrid, ComparatorIrregular, ComparatorGrid). Dispatches on the runtime type of the input data so users don’t have to know the Irregular / Grid split:

>>> det = Detector(adata)             # → DetectorIrregular
>>> det = Detector(sdata)             # → DetectorGrid
>>> cmp = Comparator([adata, ...])    # → ComparatorIrregular
>>> cmp = Comparator([sdata, ...])    # → ComparatorGrid

The factories only check isinstance to pick the right class, then forward kwargs verbatim. Asymmetry between the two:

  • Detector() does not pass the data argument to the constructor — the caller chains .setup_data(data) afterwards (matching the explicit-class flow).

  • Comparator() does pass the sample list as the first positional argument, since both comparator constructors take samples there. Cross-sample contrasts (design) are supplied later, at test time, on test_diff_freq() / test_diff_expr().

For advanced use (custom kernel selection, sample-list inputs that mix two backends intentionally) prefer the explicit class names — the factories deliberately reject mixed-type lists with a TypeError.

Functions#

Comparator(data_list, **kwargs)

Construct the right Comparator for data_list.

Detector(data, **kwargs)

Construct the right Detector for data.

Module Contents#

quadsv.api.Comparator(data_list, **kwargs)[source]#

Construct the right Comparator for data_list.

Dispatches on the homogeneous element type:

Unlike Detector(), the data list is forwarded as the first positional arg to the chosen class (both comparator constructors take samples as their first positional parameter).

Parameters:
  • data_list (sequence of AnnData or sequence of SpatialData) – Per-sample inputs. Must all be of the same type.

  • **kwargs – Forwarded to the chosen class’s __init__ verbatim (e.g. gene_names=..., feature_mode=..., etc.). The cross-sample contrast (design) is supplied later on test_diff_freq() / test_diff_expr(), not here.

Returns:

Constructed comparator instance.

Return type:

ComparatorIrregular or ComparatorGrid

Raises:

TypeError – If data_list is empty or its elements aren’t all the same supported type.

Examples

>>> from quadsv import Comparator
>>> cmp = Comparator([a1, a2, a3]).compute_spectra()
>>> df = cmp.test_diff_freq(group_labels)
quadsv.api.Detector(data, **kwargs)[source]#

Construct the right Detector for data.

Dispatches on type(data):

The data itself is not passed to the constructor — the caller is expected to chain .setup_data(data, ...) afterwards (the factory only uses data’s type to pick a class).

Parameters:
  • data (AnnData or SpatialData) – The dataset whose type drives the dispatch.

  • **kwargs – Forwarded to the chosen class’s __init__ verbatim.

Returns:

Constructed (but not yet set up) detector instance.

Return type:

DetectorIrregular or DetectorGrid

Raises:

TypeError – If data is neither an AnnData nor a SpatialData.

Examples

>>> from quadsv import Detector
>>> det = Detector(adata, kernel_method="gaussian", backend="matrix")
>>> det = det.setup_data(adata)
>>> df = det.compute_qstat()