snapatac2.pl.regions#

snapatac2.pl.regions(adata, groupby, peaks, width=600, height=400, show=True, interactive=True, out_file=None)[source]#

Plot grouped accessibility over selected peak regions.

Use this function to compare normalized accessibility across groups for a supplied peak set.

Anti-Patterns#

  • Do NOT pass peaks that are absent from adata.var_names; each peak name must map to a variable in the input matrix.

  • Do NOT use this function for very large peak sets when exact display is required. Inputs above 50,000 peaks are randomly downsampled for plotting.

param adata:

Annotated data matrix with peaks in var_names.

type adata:

AnnData | AnnDataSet

param groupby:

Cell grouping definition. If a string, groups are read from adata.obs[groupby].

type groupby:

str | list[str]

param peaks:

Mapping from group names to peak names to include in the heatmap.

type peaks:

dict[str, list[str]]

param width:

Width of the rendered plot in pixels.

type width:

float

param height:

Height of the rendered plot in pixels.

type height:

float

param show:

Whether to display the figure immediately.

type show:

bool

param interactive:

Whether to display an interactive Plotly figure when show=True.

type interactive:

bool

param out_file:

Output path for saving the plot. Supported suffixes include .svg, .pdf, .png, and .html.

type out_file:

str | None

returns:

Returns a Plotly figure when show=False and out_file=None; otherwise renders or saves the plot and returns None.

rtype:

plotly.graph_objects.Figure’ | None

Examples

>>> import snapatac2 as snap
>>> adata = snap.read(snap.datasets.pbmc5k(type="h5ad"))
>>> peaks = {"selected": list(adata.var_names[:20])}
>>> fig = snap.pl.regions(adata, groupby="cell_type", peaks=peaks, show=False)
>>> fig.update_layout(title="Grouped accessibility")