liana.method.lric.__call__

Contents

liana.method.lric.__call__#

lric.__call__(resource=None, resource_name=None, interactions=None, groupby=None, spatial_key='spatial', max_radius=200, radius_step=20, annulus_width=20, extend_first_annulus=True, cell_types=None, min_cells=5, min_expressing=0, n_angle_samples=360, complex_sep='_', transform_fn=None, use_raw=True, layer=None, key_added='lric', inplace=True, verbose=False)#

Ligand-Receptor Interaction Correlation (LRIC).

Computes an expression-weighted cross-PCF g(r): each cell’s contribution at distance r is weighted by its ligand and receptor expression, so g(r) > 1 flags ligand- and receptor-expressing cells that are spatially co-enriched beyond cell-type co-localisation alone — candidate ligand-receptor interactions that are both proximal and co-expressed.

When groupby is None (default), all cells are treated as potential senders and receivers (self-pairs excluded), providing a global screen for LR pairs with strong spatial co-enrichment signal. Result dict keys: pair_names, radii, lric (shape (n_bins, n_pairs)).

When groupby is a column name in adata.obs, the LRIC is computed for every directed sender→receiver cell-type pair. Result dict keys: cell_types, pair_names, radii, results mapping (sender, receiver) tuples to (n_bins, n_pairs) arrays.

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

  • resource (DataFrame | None (default: None)) – A pandas dataframe with [ligand, receptor] columns. If provided will overrule the resource requested via resource_name

  • resource_name (str | None (default: None)) – Name of the resource to be used for ligand-receptor inference. See li.rs.show_resources() for available resources.

  • interactions (list | None (default: None)) – List of tuples with ligand-receptor pairs [(ligand, receptor), ...] to be used for the analysis. If passed, it will overrule the resource requested via resource and resource_name.

  • groupby (str | None (default: None)) – Column in adata.obs used to define cell types. None runs the cell-type-agnostic mode across all cells.

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

  • 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 (juxtacrine) pairs into the first bin instead of discarding them. False keeps the first annulus at [radius_step, radius_step + annulus_width).

  • cell_types (Iterable[str] | None (default: None)) – Subset of cell types to consider (only when groupby is set). 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.

  • min_expressing (int (default: 0)) – Minimum number of cells (within the relevant population: each cell∂ type in pairwise mode, all cells in agnostic mode) that must express the ligand or receptor for an LR pair to be kept; pairs below the threshold are set to NaN. Default 0 keeps all results.

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

  • complex_sep (str | None (default: '_')) – Separator used to identify multi-subunit complexes in the resource (e.g. "_" splits "ITGAV_ITGB3" into its subunits and adds the minimum-subunit expression as a new column in adata.var). Set to None to skip complex handling.

  • transform_fn (Callable[[ndarray], ndarray] | None (default: None)) – Expression transform applied to ligand and receptor matrices, defaulting to mean→1 normalization (_linear_transform()). It is applied per population: globally in agnostic mode, within each cell type in pairwise mode.

  • use_raw (bool (default: True)) – Use raw attribute of adata if present.

  • layer (str | None (default: None)) – Layer in anndata.AnnData.layers to use. If None, use anndata.AnnData.X.

  • key_added (str (default: 'lric')) – 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 if inplace=False, else None.