liana.pl.circle_plot

Contents

liana.pl.circle_plot#

liana.pl.circle_plot(adata, uns_key='liana_res', liana_res=None, groupby=None, source_key='source', target_key='target', score_key=None, inverse_score=False, top_n=None, orderby=None, orderby_ascending=None, orderby_absolute=False, filter_fn=None, source_labels=None, target_labels=None, ligand_complex=None, receptor_complex=None, pivot_mode='counts', mask_mode='or', figure_size=(5, 5), edge_alpha=0.5, edge_arrow_size=10, edge_width_scale=(1, 5), node_alpha=1, node_size_scale=(100, 400), node_label_offset=(0.1, -0.2), node_label_size=8, node_label_alpha=0.7)#

Visualize the cell-cell communication network using a circular plot.

Parameters:
adata AnnData

Annotated data object.

uns_key str (default: 'liana_res')

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.

groupby str | None (default: None)

Key to be used for grouping.

source_key str (default: 'source')

Column name of the sender/source cell types in liana_res.

target_key str (default: 'target')

Column name of the receiver/target cell types in liana_res.

score_key str | None (default: None)

Column name of the score in liana_res. If None, the score is inferred from the method.

inverse_score bool (default: False)

Whether to invert the score, by default False. If True, the score will be -log10(score).

top_n int | None (default: None)

top_n entities to plot.

orderby str | None (default: None)

If top_n is not None, order the interactions by this column

orderby_ascending bool | None (default: None)

If top_n is not None, specify how to order the interactions

orderby_absolute bool (default: False)

If top_n is not None, whether to order by the absolute value of the orderby column.

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.

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

List of labels to use as source, the rest are filtered out.

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

List of labels to use as target, the rest are filtered out.

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

list of ligand complexes to filter the interactions to be plotted. Defaults to None.

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

list of receptor complexes to filter the interactions to be plotted. Defaults to None.

pivot_mode Literal['counts', 'mean'] (default: 'counts')

The mode of the pivot table, by default ‘counts’. - ‘counts’: The number of connections between source and target. - ‘mean’: The mean of the values of score_key between source and target cell types (groupby), over the rows that pass filter_fn.

mask_mode Literal['and', 'or'] (default: 'or')

How source_labels and target_labels are combined, by default ‘or’. Both narrow the interactions before filter_fn/top_n, so top_n ranks the interactions among the cell types asked for; the nodes are the labels that still carry an edge. - ‘or’: Keep an interaction whose source or whose target is among the labels. - ‘and’: Keep an interaction whose source and whose target are among the labels.

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

Figure x,y size

edge_alpha float (default: 0.5)

The transparency of the edges, by default .5.

edge_arrow_size int (default: 10)

The size of the arrow, by default 10.

edge_width_scale tuple[float, float] (default: (1, 5))

The scale of the edge width, by default (1, 5).

node_alpha float (default: 1)

The transparency of the nodes, by default 1.

node_size_scale tuple[float, float] (default: (100, 400))

The scale of the node size, by default (100, 400).

node_label_offset tuple[float, float] (default: (0.1, -0.2))

The offset of the node label, by default (0.1, -0.2).

node_label_size int (default: 8)

The size of the node label, by default 8.

node_label_alpha float (default: 0.7)

The transparency of the node label, by default .7.

Return type:

Axes

Returns:

The figure axes containing the circle plot.

Raises:
  • ValueError – If groupby is not provided, if a source_labels/target_labels entry is not among the interactions, or if none of them remain after filtering

  • KeyError – If groupby is not a column of adata.obs

Examples

groupby must name the .obs column that the interactions’ source/target labels came from, so that its colours can be re-used for the nodes:

>>> import liana as li
>>> adata = li.ds.generate_toy_adata()
>>> li.mt.rank_aggregate(adata, groupby="bulk_labels", n_perms=None)
>>> ax = li.pl.circle(adata, groupby="bulk_labels")

With pivot_mode='mean' and a score_key the edges are weighted by that score’s mean instead of by the number of interactions.