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.unsthat contains the LIANA results. Default is'liana_res'.- liana_res
DataFrame|None(default:None) liana_resaDataFramein liana’s format. Where anadatais accepted too, a frame passed here takes precedence overadata.uns[uns_key], which is only read when this isNone.- 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_nentities to plot.- orderby
str|None(default:None) If
top_nis notNone, order the interactions by this column- orderby_ascending
bool|None(default:None) If
top_nis notNone, specify how to order the interactions- orderby_absolute
bool(default:False) If
top_nis notNone, whether to order by the absolute value of theorderbycolumn.- 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
dotplotandtileplotit 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.circleand 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) listof ligand complexes to filter the interactions to be plotted. Defaults to None.- receptor_complex
list[str] |str|None(default:None) listof 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_keybetween source and target cell types (groupby), over the rows that passfilter_fn.- mask_mode
Literal['and','or'] (default:'or') How
source_labelsandtarget_labelsare combined, by default ‘or’. Both narrow the interactions beforefilter_fn/top_n, sotop_nranks 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.
- adata
- Return type:
- Returns:
The figure axes containing the circle plot.
- Raises:
ValueError – If
groupbyis not provided, if asource_labels/target_labelsentry is not among the interactions, or if none of them remain after filteringKeyError – If
groupbyis not a column ofadata.obs
Examples
groupbymust name the.obscolumn that the interactions’source/targetlabels 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 ascore_keythe edges are weighted by that score’s mean instead of by the number of interactions.