liana.pl.misty_interactions

liana.pl.misty_interactions#

liana.pl.misty_interactions(misty=None, interactions=None, view=None, top_n=None, ascending=False, key=None, filter_fn=None, aggregate_fn=None, figure_size=(5, 5), return_fig=True)#

Plot interaction importances.

Parameters:
misty MistyData | None (default: None)

MistyData object with modelling results

interactions DataFrame | None (default: None)

Interactions from which to plot the importance

view str | None (default: None)

A Misty view to plot

top_n int | None (default: None)

top_n entities to plot.

ascending bool (default: False)

Whether to sort interactions in ascending order

key Callable[[Series], Series] | None (default: None)

Function to use to sort the interactions

filter_fn Callable[[Series], bool] | None (default: None)

A function, applied along the columns (axis=1) of the results, used to filter the results to be plotted. In dotplot and tileplot it selects interactions rather than rows: an interaction (ligand_complex -> receptor_complex) is kept whenever the predicate holds for any of its source-target pairs, and is then plotted for all of them, so rows that fail the predicate are drawn alongside those that pass. circle and the misty plots filter row-wise.

aggregate_fn Callable[[Series], object] | str | None (default: None)

A function used to aggregate the results to be plotted.

figure_size tuple[float, float] (default: (5, 5))

Figure x,y size

return_fig bool (default: True)

bool whether to return the fig object.

Return type:

plotnine.ggplot | None

Returns:

A plotnine plot.

Raises:

ValueError – If neither misty or interactions input or view are not provided.

Examples

One tile per predictor-target pair of the chosen view, coloured by the importance the model gave it, read from misty.uns['interactions']:

>>> import liana as li
>>> adata = li.ds.generate_toy_spatial()
>>> adata = adata[:, adata.var_names[:5]].copy()
>>> misty = li.mt.genericMistyData(intra=adata, bandwidth=200, set_diag=True)
>>> misty(model=li.mt.sp.LinearModel)
>>> p = li.pl.misty_interactions(misty, view="intra")

misty.view_names lists the views available – here 'intra', 'juxta' and 'para'.