liana.plotting.interactions

Contents

liana.plotting.interactions#

liana.plotting.interactions(misty=None, interactions=None, view=None, top_n=None, ascending=False, key=None, filter_fun=None, aggregate_fun=None, figure_size=(5, 5), return_fig=True)#

Plot interaction importances.

Parameters:
  • misty (MistyData (default: None)) – MistyData object with modelling results

  • interactions (DataFrame (default: None)) – Interactions from which to plot the importance

  • view (str (default: None)) – A Misty view to plot

  • top_n (int (default: None)) – top_n entities to plot.

  • ascending (bool (default: False)) – Whether to sort interactions in ascending order

  • key (str (default: None)) – Key to use when sorting interactions

  • filter_fun (Callable (default: None)) – A function, applied along the columns (axis=1), used to filter the results to be plotted.

  • aggregate_fun (Callable (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:

Figure

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.testing.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.interactions(misty, view='intra')

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