liana.plotting.connectivity

Contents

liana.plotting.connectivity#

liana.plotting.connectivity(adata, idx, spatial_key='spatial', connectivity_key='spatial_connectivities', size=1, figure_size=(5.4, 5), return_fig=True)#

Plot spatial connectivity weights.

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

  • idx (int) – Column index of the connectivity weights to plot.

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

  • connectivity_key (str (default: 'spatial_connectivities')) – Key in adata.obsp that contains the spatial connectivity matrix. Default is 'spatial_connectivities'.

  • size (float (default: 1)) – Size of the points

  • figure_size (tuple[float, float] (default: (5.4, 5))) – Figure x,y size

  • return_fig (bool (default: True)) – bool whether to return the fig object.

Return type:

Figure

Returns:

The resulting connectivity plot.

Raises:

AssertionError – If connectivity_key or spatial_key are not in adata.obsp or adata.obsm respectively.

Examples

idx picks one spot, and the plot shows how strongly every other spot is connected to it under the kernel of liana.utils.spatial_neighbors():

>>> import liana as li
>>> adata = li.testing.generate_toy_spatial()
>>> p = li.pl.connectivity(adata, idx=0)