spateo.plotting.interactive#

Submodules#

Package Contents#

Functions#

cellbin_select(...)

Select cells by drawing a polygon on a binning image of the spatial transcriptomics data.

contours(→ plotly.graph_objects.Figure)

Interactively display UMI density bins.

select_polygon(→ matplotlib.widgets.PolygonSelector)

Display raw data within an AnnData with interactive polygon selection.

spateo.plotting.interactive.cellbin_select(adata: anndata.AnnData, binsize: int = 50, spatial_key: str = 'spatial', layer: str | None = None, scale: float = 0.5, scale_unit: str = 'um', return_all: bool = False) matplotlib.widgets.PolygonSelector | Tuple[matplotlib.widgets.PolygonSelector, anndata.AnnData][source]#

Select cells by drawing a polygon on a binning image of the spatial transcriptomics data.

Parameters:
adata

Anndata containing segmented cells.

binsize

Size of bins to use for aggregating the expression data.

spatial_key

The key to the spatial coordinates in the adata.obsm attribute.

layer

The layer to use for the expression data. Defaults to None (adata.X will be used).

scale

The scale of the spatial coordinates.

scale_unit

The unit of the spatial coordinates.

return_all

Whether to return both the PolygonSelector and the aggregated image.

Returns:

When return_all is False, only a PolygonSelector object will be returned; otherwise both a tuple of both

the aggregated image data and the PolygonSelector object will be used.

spateo.plotting.interactive.contours(adata: anndata.AnnData, layer: str, colors: List | None = None, scale: float = 0.05) plotly.graph_objects.Figure[source]#

Interactively display UMI density bins.

Parameters:
adata

Anndata containing aggregated UMI counts.

layer

Layer to display

colors

List of colors.

scale

Scale width and height by this amount.

Returns:

A Plotly figure

spateo.plotting.interactive.select_polygon(adata: anndata.AnnData, layer: str, out_layer: str | None = None, ax: matplotlib.axes.Axes | None = None, background: str | None = None, **kwargs) matplotlib.widgets.PolygonSelector[source]#

Display raw data within an AnnData with interactive polygon selection.

Parameters:
adata

Anndata containing aggregated UMI counts.

layer

Layer to display. Defaults to X.

out_layer

Layer to output selection result as a boolean mask. Defaults to {layer}_selection.

ax

Axes to plot.

background

string or None (optional, default ‘None`) The color of the background. Usually this will be either ‘white’ or ‘black’, but any color name will work. Ideally one wants to match this appropriately to the colors being used for points etc. This is one of the things that themes handle for you. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.

**kwargs

Additional keyword arguments are all passed to spateo.pl.imshow().