decoupler.pl.barplot

Contents

decoupler.pl.barplot#

decoupler.pl.barplot(data, name, top=25, vertical=False, cmap='RdBu_r', vmin=None, vcenter=0, vmax=None, kw_barplot=None, **kwargs)#

Plot barplots showing top scores.

Parameters:
  • data (DataFrame) – DataFrame in wide format containing enrichment scores (contrasts, sources).

  • name (str) – Name of the contrast (row) to plot.

  • top (int (default: 25)) – Number of top sources to plot.

  • vertical (bool (default: False)) – Whether to plot the bars verticaly or horizontaly.

  • cmap (str (default: 'RdBu_r')) – Colormap to use.

  • vmin (float | None (default: None)) – The value representing the lower limit of the color scale.

  • vcenter (float | None (default: 0)) – The value representing the center of the color scale.

  • vmax (float | None (default: None)) – The value representing the upper limit of the color scale.

  • kw_barplot (dict | None (default: None)) – Keyword arguments passed to seaborn.barplot.

  • 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.

Return type:

None | Figure

Returns:

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

Example

import decoupler as dc
import scanpy as sc

adata, net = dc.ds.toy()
sc.tl.rank_genes_groups(adata, groupby="group")
deg = sc.get.rank_genes_groups_df(adata, group=None)
mat = deg.pivot(index="group", columns="names", values="scores")
scores, padjs = dc.mt.ulm(mat, net, tmin=3)
dc.pl.barplot(scores, name="A")