liana.method.cross_pcf.__call__

liana.method.cross_pcf.__call__#

cross_pcf.__call__(groupby, spatial_key='spatial', cell_types=None, min_cells=5, max_radius=200, radius_step=20, annulus_width=20, extend_first_annulus=True, n_angle_samples=360, key_added='cross_pcf', inplace=True, verbose=False)#

Cross pair-correlation function for all directed cell-type pairs.

Computes the distance-resolved cross-PCF g(r) for every directed sender→receiver combination of cell types present in adata.obs[groupby]. g(r) compares the observed density of receiver cells at distance r from each sender to the density expected under spatial randomness, revealing the length scales at which cell types co-localise (> 1) or avoid one another (< 1). Expression is not used — this characterises tissue architecture alone.

Parameters:
  • adata (AnnData) – Annotated data object.

  • groupby (str) – Key to be used for grouping.

  • spatial_key (str (default: 'spatial')) – Key in adata.obsm that contains the spatial coordinates. Default is 'spatial'.

  • cell_types (Iterable[str] | None (default: None)) – Subset of cell types to consider. Defaults to all types in adata.obs[groupby].

  • min_cells (int (default: 5)) – Minimum cells (per cell identity if grouped by groupby) to be considered for downstream analysis.

  • max_radius (float (default: 200)) – Inner edge of the last (widest) annulus bin; the outer edge extends to max_radius + annulus_width.

  • radius_step (float (default: 20)) – Step between successive annulus inner edges.

  • annulus_width (float (default: 20)) – Ring width of each annulus.

  • extend_first_annulus (bool (default: True)) – If True (default), extend the first annulus inward to start at radius 0 (spanning [0, radius_step + annulus_width)) rather than at radius_step. Cell centroids cannot lie closer than ~one cell diameter, so the innermost band is otherwise a thin, near-empty, high-variance bin; extending it folds genuine cell-cell contact pairs into the first bin instead of discarding them. False keeps the first annulus at [radius_step, radius_step + annulus_width).

  • n_angle_samples (int (default: 360)) – Angular resolution for bounding-box edge correction (360 ≈ 0.3 % error).

  • key_added (str (default: 'cross_pcf')) – Key under which the results will be stored in adata.uns if inplace is True.

  • inplace (bool (default: True)) – Whether to store results in place, or else to return them.

  • verbose (bool (default: False)) – Verbosity flag.

Return type:

dict | None

Returns:

dict with keys cell_types, radii, results if inplace=False, else None. results maps (sender, receiver) tuples to (n_bins,) arrays.