liana.pl.feature_by_group

liana.pl.feature_by_group#

liana.pl.feature_by_group(adata=None, groupby=None, spatial_key='spatial', labels=None, feature=None, figure_size=(10, 6), normalize=True, percentile_scaling=None, show_counts=True)#

Plot inflow scores for single feature across spatial coordinates.

Parameters:
adata AnnData | None (default: None)

Annotated data object.

groupby str | None (default: None)

Key to be used for grouping.

spatial_key str (default: 'spatial')

Key in adata.obsm that contains the spatial coordinates.

labels list[str] | None (default: None)

List of labels to compare, from groupby.

feature str | None (default: None)

From adata.var_names.

figure_size tuple[float, float] (default: (10, 6))

Figure x,y size

normalize bool (default: True)

Normalize expression values between 0 and 1 for each cell type.

percentile_scaling tuple[int, int] | None (default: None)

Tuple specifying percentiles for scaling.

show_counts bool (default: True)

Show counts of expression cells (expression > 0).

Return type:

tuple[Figure, Axes]

Returns:

A tuple of the matplotlib Figure and its main Axes.

Examples

adata is typically the output of liana.mt.inflow, whose var_names are 'source^ligand^receptor' triplets. Each label in labels gets its own colormap and colorbar, so the groups can be compared in place:

>>> import liana as li
>>> adata = li.ds.generate_toy_spatial()
>>> lrdata = li.mt.inflow(adata, groupby="bulk_labels", resource_name="consensus")
>>> fig, ax = li.pl.feature_by_group(
...     lrdata, groupby="bulk_labels", labels=["Dendritic", "CD14+ Monocyte"], feature=lrdata.var_names[0]
... )