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 takesamplesthere. Cross-sample contrasts (design) are supplied later, at test time, ontest_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#
|
Construct the right |
|
Construct the right |
Module Contents#
- quadsv.api.Comparator(data_list, **kwargs)[source]#
Construct the right
Comparatorfordata_list.Dispatches on the homogeneous element type:
all
anndata.AnnData→ComparatorIrregular.all
spatialdata.SpatialData→ComparatorGrid.mixed types →
TypeError.
Unlike
Detector(), the data list is forwarded as the first positional arg to the chosen class (both comparator constructors takesamplesas 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 ontest_diff_freq()/test_diff_expr(), not here.
- Returns:
Constructed comparator instance.
- Return type:
- Raises:
TypeError – If
data_listis 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
Detectorfordata.Dispatches on
type(data):anndata.AnnData→DetectorIrregular.spatialdata.SpatialData→DetectorGrid.
The data itself is not passed to the constructor — the caller is expected to chain
.setup_data(data, ...)afterwards (the factory only usesdata’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:
- Raises:
TypeError – If
datais neither anAnnDatanor aSpatialData.
Examples
>>> from quadsv import Detector >>> det = Detector(adata, kernel_method="gaussian", backend="matrix") >>> det = det.setup_data(adata) >>> df = det.compute_qstat()