decoupler.pl.source_targets#

decoupler.pl.source_targets(data, net, x, y, name, top=5, thr_x=0.0, thr_y=0.0, max_x=None, max_y=None, color_pos='#D62728', color_neg='#1F77B4', kw_scatter=None, **kwargs)#

Plots target features of a given source as a scatter plot.

Parameters:
data DataFrame

DataFrame containing feature-level statistics. Feature names must be in df.index.

net DataFrame

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

x str

Name of the column containing values to place on the x-axis.

y str

Name of the column containing values to place on the y-axis.

name str

Name of the source to plot.

top int | None (default: 5)

Number of top features to show labels based on the product of x and y to label. Can be None.

thr_x float (default: 0.0)

Value were to place a baseline for the x-axis.

thr_y float (default: 0.0)

Value were to place a baseline for the y-axis.

max_x float | None (default: None)

Maximum value to plot on x-axis.

max_y float | None (default: None)

Maximum value to plot on y-axis.

color_pos str (default: '#D62728')

Color to plot positively associated features.

color_neg str (default: '#1F77B4')

Color to plot negatively associated features.

kw_scatter dict | None (default: None)

Keyword arguments passed to matplotlib.pyplot.scatter.

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="A").set_index("names")
dc.pl.source_targets(data=deg, x="weight", y="scores", net=net, name="T1")