Skip to content

pl

heatmap(adata, topic_prop, groupby, dendrogram=False, swap_axes=True, cmap=None, figsize=(10, 5), save=None, **kwargs)

Creates a heatmap of cell(grouped by groupby) by topics

Parameters:

Name Type Description Default
adata _type_

Adata object

required
topic_prop _type_

Topic proportions returned by STAMP

required
groupby _type_

Column in adata object to arrange the cells

required
figsize tuple

Figsize. Defaults to (10, 5).

(10, 5)
dendrogram bool

Whether to cluster. Defaults to False.

False
swap_axes bool

Whether to swap x and y axis. Defaults to True.

True
cmap _type_

What matplotib cmap to use. Defaults to None.

None
save _type_

Whether to save the object. Defaults to None.

None

matrixplot(adata, topic_prop, groupby, dendrogram=False, swap_axes=True, cmap=None, figsize=(10, 5), save=None, **kwargs)

Creates a matrixplot of cell(grouped by groupby) by topics

Parameters:

Name Type Description Default
adata _type_

Adata object

required
topic_prop _type_

Topic proportions returned by STAMP

required
groupby _type_

Column in adata object to arrange the cells

required
figsize tuple

Figsize. Defaults to (10, 5).

(10, 5)
dendrogram bool

Whether to cluster. Defaults to False.

False
swap_axes bool

Whether to swap x and y axis. Defaults to True.

True
cmap _type_

What matplotib cmap to use. Defaults to None.

None
save _type_

Whether to save the object. Defaults to None.

None

trackplot(adata, topic_prop, groupby, dendrogram=False, swap_axes=True, cmap=None, figsize=(10, 5), save=None, **kwargs)

Creates a trackplot of cell(grouped by groupby) by topics

Parameters:

Name Type Description Default
adata _type_

Adata object

required
topic_prop _type_

Topic proportions returned by STAMP

required
groupby _type_

Column in adata object to arrange the cells

required
figsize tuple

Figsize. Defaults to (10, 5).

(10, 5)
dendrogram bool

Whether to cluster. Defaults to False.

False
swap_axes bool

Whether to swap x and y axis. Defaults to True.

True
cmap _type_

What matplotib cmap to use. Defaults to None.

None
save _type_

Whether to save the object. Defaults to None.

None

spatialpie(adata, color, N=2, *, basis='spatial', img=None, img_key=_empty, library_id=_empty, crop_coord=None, alpha_img=1.0, bw=False, frameon=False, size=1.0, scale_factor=None, spot_size=None, na_color=None, show=None, return_fig=None, cmap='tab20', legend=True, figsize=None, title=None)

Creates a spatialpie plot of object. Very ugly according to twitter.

Parameters:

Name Type Description Default
adata _type_

Adata object

required
topic_prop _type_

Return

required
basis str

Basis to use. Defaults to "spatial".

'spatial'
img Union[np.ndarray, None]

description. Defaults to None.

None
img_key Union[str, None, Empty]

description. Defaults to _empty.

_empty
library_id Union[str, Empty]

description. Defaults to _empty.

_empty
crop_coord Tuple[int, int, int, int]

description.

None
alpha_img float

description. Defaults to 1.0.

1.0
bw Optional[bool]

description. Defaults to False.

False
frameon bool

description. Defaults to False.

False
size float

description. Defaults to 1.0.

1.0
scale_factor Optional[float]

description. Defaults to None.

None
spot_size Optional[float]

description. Defaults to None.

None
na_color Optional[ColorLike]

description. Defaults to None.

None
show Optional[bool]

description. Defaults to None.

None
return_fig Optional[bool]

description. Defaults to None.

None
cmap str

description. Defaults to "tab20".

'tab20'
legend bool

description. Defaults to True.

True
figsize _type_

description. Defaults to None.

None
title _type_

description. Defaults to None.

None

Returns:

Type Description
Union[Axes, List[Axes], None]

Union[Axes, List[Axes], None]: description

get_rgb_function(cmap, min_value, max_value)

Generate a function to map continous values to RGB values using colormap between min_value & max_value.

rgb_to_ryb(rgb)

Converts colours from RGB colorspace to RYB

Parameters

rgb numpy array Nx3

Returns

Numpy array Nx3

ryb_to_rgb(ryb)

Converts colours from RYB colorspace to RGB

Parameters

ryb numpy array Nx3

Returns

Numpy array Nx3

plot_spatial(adata, topic_prop, basis='spatial', bw=False, img=None, library_id=_empty, crop_coord=None, img_key=_empty, spot_size=None, na_color=None, scale_factor=None, scale_default=0.5, show_img=True, display_zeros=False, figsize=(10, 10), **kwargs)

Plot taken from cell2location at https://github.com/BayraktarLab/cell2location. Able to display zeros and also on umap through the basis function

Parameters:

Name Type Description Default
adata _type_

Adata object with spatial coordinates in adata.obsm['spatial']

required
topic_prop _type_

Topic proportion obtained from STAMP.

required
basis str

Which basis to plot in adata.obsm. Defaults to "spatial".

'spatial'
bw bool

Defaults to False.

False
img _type_

. Defaults to None.

None
library_id _type_

description. Defaults to _empty.

_empty
crop_coord _type_

description. Defaults to None.

None
img_key _type_

description. Defaults to _empty.

_empty
spot_size _type_

description. Defaults to None.

None
na_color _type_

description. Defaults to None.

None
scale_factor _type_

description. Defaults to None.

None
scale_default float

description. Defaults to 0.5.

0.5
show_img bool

Whether to display spatial image. Sets to false

True
display_zeros bool

Whether to display cells that have low counts

False
figsize tuple

Figsize of image. Defaults to (10, 10).

(10, 10)

Returns:

Name Type Description
_type_

Function taken from cell2location at

https

//cell2location.readthedocs.io/en/latest/_modules/cell2location/plt/plot_spatial.html#plot_spatial.

Able to plot both on spatial and umap coordinates. Still very raw.

spatial(adata, color=None, cmap=None, frameon=None, title=None, wspace=None, hspace=0.25, palette=None, colorbar_loc='right', size=1, basis='spatial', vmax=None, ncols=4, layer=None, show=True, *args, **kwargs)

A faster simple function that uses sc.pl.embedding to plot for non-visium data so it dont take too long. ~sleep. Very inflexible.

Parameters:

Name Type Description Default
adata _type_

Annotated data matrix.

required
color _type_

Keys for annotations of observations/cells or variables/genes

None
size int

size of spots. Defaults to 1.

1
basis str

basis in obsm. Defaults to "spatial".

'spatial'
vmax str

The value representing the upper limit of the color scale. Defaults to "p99".

None
show bool

Show the plot, do not return axis. Defaults to True.

True

Returns:

Name Type Description
_type_

A plot