decoupler.pl.network#

decoupler.pl.network(net, data=None, score=None, sources=5, targets=10, by_abs=True, size_node=5, size_label=2.5, s_cmap='RdBu_r', t_cmap='viridis', vcenter=False, c_pos_w='darkgreen', c_neg_w='darkred', s_label='Enrichment\nscore', t_label='Gene\nexpression', layout='kk', kw_igraph=None, **kwargs)#

Plot results of enrichment analysis as network.

Parameters:
net

Dataframe in long format. Must include source and target columns, and optionally a weight column.

data DataFrame (default: None)

Input of enrichment analysis, needs to be a one row dataframe with targets as features. Used to filter net.

score DataFrame (default: None)

Ouput of enrichment analysis, needs to be a one row dataframe with sources as features. Used to filter net.

sources int | list | str (default: 5)

Number of top sources to plot or list of source names.

targets int | list | str (default: 10)

Number of top targets to plot or list of target names.

by_abs bool (default: True)

Whether to consider the absolute value when sorting for n_sources and n_targets.

size_node int (default: 5)

Size of the nodes in the plot.

size_label float | int (default: 2.5)

Size of the labels in the plot.

s_cmap str (default: 'RdBu_r')

Color or colormap to use to color sources.

t_cmap str (default: 'viridis')

Color or colormap to use to color targets.

vcenter bool (default: False)

Whether to center colors around 0.

c_pos_w str (default: 'darkgreen')

Color for edges with positive weights. If no weights are available, they are set to positive by default.

c_neg_w str (default: 'darkred')

Color for edges with negative weights.

s_label str (default: 'Enrichment\nscore')

Label to place in the source colorbar.

t_label str (default: 'Gene\nexpression')

Label to place in the target colorbar.

layout str (default: 'kk')

Layout to use to order the nodes. Check igraph documentation for more options.

kw_igraph dict | None (default: None)

Keyword arguments passed to igraph.plot.

ax

An existing matplotlib.axes._axes.Axes instance to plot on. If None, a new figure and axes will be created.

figsize

Size of the figure in inches as (width, height).

dpi

Dots per inch for the figure resolution.

return_fig

If True, plotting methods should return the figure object instead of showing it.

save

If set, path to save the plot automatically to a file.

Returns:

If return_fig=True, returns matplotlib.figure.Figure instance.

Example

import decoupler as dc

adata, net = dc.ds.toy()
dc.pl.network(net, figsize=(4, 4))