Skip to content

clusterPlots

clusterPlots

clusterPlots(
    data,
    groupBy,
    subsample=100000,
    palette="viridis",
    useRaw=False,
    size=None,
    outputDir=None,
    show=True,
    returnData=False,
    returnFig=False,
    sdataTable=None,
    **kwargs
)

Plot cluster labels on an existing UMAP embedding.

A convenience wrapper: clusterPlots(adata, groupBy="leiden") is sp.pl.umap(adata, color="leiden") with a palette default suited to cluster labels. Requires an embedding in obsm['umap'], so run sp.tl.umap first.

Parameters:

Name Type Description Default
data (AnnData | SpatialData | str, required)

The cell table. An AnnData, a path to an .h5ad file, a SpatialData object, or a path to a .zarr SpatialData store.

required
groupBy (str, required)

Column in obs holding the cluster labels to colour by.

required
subsample int

Accepted for signature compatibility with scimap. The current implementation plots every cell; subsample the object yourself if you need to.

100000
palette str

Matplotlib colormap name used to build the discrete palette.

'viridis'
useRaw bool

Accepted for signature compatibility with scimap; it has no effect when colouring by a label column.

False
size float

Point size.

None
outputDir str

Directory to save the figure in.

None
show bool

Call plt.show() before returning.

True
returnData bool

Return the plotted DataFrame instead of drawing.

False
returnFig bool

Return (fig, axes).

False
sdataTable str

Which SpatialData table to read.

None
**kwargs dict

Forwarded to sp.pl.umap.

{}

Returns:

Name Type Description
result None | DataFrame | tuple

Whatever sp.pl.umap returns for the same arguments.

Example
adata = sp.tl.cluster(adata, method="leiden", label="leiden")
adata = sp.tl.umap(adata)
sp.pl.clusterPlots(adata, groupBy="leiden")