liana.mt.get_lric_auc

Contents

liana.mt.get_lric_auc#

liana.mt.get_lric_auc(adata=None, uns_key='lric', liana_res=None, max_dist=None, transform_fn=<function _log2_floor>, min_bins=3)#

Summarise a lric / cross_pcf result into one score per interaction.

Each interaction’s g(r) profile is reduced to the span-normalised area under its log2 g(r) curve – a mean log2 fold change: > 0 co-enriched, < 0 depleted, 0 random.

Parameters:
adata AnnData | None (default: None)

Annotated data object. Its .uns[uns_key] holds the result. Mutually exclusive with liana_res.

uns_key str (default: 'lric')

Key in adata.uns that contains the LIANA results. Default is 'liana_res'.

liana_res DataFrame | None (default: None)

liana_res a DataFrame in liana’s format.

A lric / cross_pcf result, used when adata is None.

max_dist float | None (default: None)

Integrate only over radii r < max_dist; None uses all radii.

transform_fn Callable[[NDArray[floating]], NDArray[floating]] (default: <function _log2_floor at 0x7e3fd8445c60>)

Applied to g before integrating; defaults to log2 with g floored at 0.05, so empty/depleted bins stay finite and count as strong depletion. Pass numpy.log2 for the strict behaviour where non-finite values (e.g. log2(0) = -inf) are dropped from the integral.

min_bins int (default: 3)

Drop interactions with fewer than this many finite bins in the window (a support gate for expr_prop-masked / degenerate interactions).

Return type:

DataFrame

Returns:

A pandas.DataFrame with the id columns of the input (whichever of source, target, ligand_complex, receptor_complex, interaction are present) plus score and peak_radius – the radius at which |transform_fn(g)| is largest, i.e. where the interaction deviates most from the null – sorted most-enriched first. The column names match liana.pl.dotplot()’s expectations. Empty if nothing clears min_bins.

Examples

Rank the interactions of a spatial result by how co-enriched they are across radius – here the cell-type-agnostic LRIC of liana.mt.lric.__call__():

>>> import liana as li
>>> adata = li.ds.generate_toy_spatial()
>>> li.mt.lric(adata, resource_name="consensus", key_added="lric")
>>> scores = li.mt.get_lric_auc(adata, uns_key="lric")