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, verbose=False)#

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, read when liana_res is None.

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. Where an adata is accepted too, a frame passed here takes precedence over adata.uns[uns_key], which is only read when this is None.

A lric / cross_pcf result; takes precedence over adata.uns.

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 0x7ef622c36a20>)

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 proportion-masked / degenerate interactions).

verbose bool | None (default: False)

Verbosity flag. False, the default, hides progress and info messages but still warns about data-altering conditions; True shows both; None silences everything, warnings included.

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.

Raises:

ValueError – If any column other than the id and g(r) columns takes more than one value – e.g. a concatenation of several results, separated by a sample/condition column. Score one result at a time, or group by that column and score each group.

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")