spateo.plotting.static.dotplot#

Dotplot class adapted from https://github.com/scverse/scanpy with modifications for suitability to cell-cell communication and interaction analyses

Development notes: some of the methods mention dendrograms/other extra plots and there is currently no capability to generate those- coming in future update…additions that will have to be made: functions for plot_dendrogram, plot_totals, additional if condition in make_figure()…

Module Contents#

Classes#

Dotplot

Simultaneous visualization of two variates that are encoded by the dot size and the dot color. Size usually

CCDotplot

Because of the often much smaller values dealt with in cell-cell communication inference, this class creates a

Functions#

adata_to_frame(adata, var_names, cat_key[, ...])

For the purposes of dot plotting, converts the information given in AnnData object to a dataframe in which the

make_grid_spec(→ Tuple[matplotlib.figure.Figure, ...)

Initialize grid layout to place subplots within a figure environment

dotplot(adata, var_names, cat_key, Sequence[str]], ...)

Makes a dot plot of the expression values of var_names. For each var_name and each groupby category a dot

spateo.plotting.static.dotplot.adata_to_frame(adata: anndata.AnnData, var_names: Sequence[str], cat_key: str | Sequence[str], num_categories: int = 7, layer: None | str = None, gene_symbols_key: None | str = None)[source]#

For the purposes of dot plotting, converts the information given in AnnData object to a dataframe in which the row names are categories defined by groups and column names correspond to variable names.

Parameters:
adata

class anndata.AnnData

var_names

Should be a subset of adata.var_names

cat_key

The key(s) in .obs of the grouping to consider. Should be a categorical observation; if not, will be subdivided into ‘num_categories’.

num_categories

Only used if groupby observation is not categorical. This value determines the number of groups into which the groupby observation should be subdivided.

layer

Key in .layers specifying layer to use. If not given, will use .X.

gene_symbols_key

Key in .var containing gene symbols

spateo.plotting.static.dotplot.make_grid_spec(ax_or_figsize: Tuple[int, int] | matplotlib.axes.Axes, nrows: int, ncols: int, wspace: float | None = None, hspace: float | None = None, width_ratios: Sequence[float] | None = None, height_ratios: Sequence[float] | None = None) Tuple[matplotlib.figure.Figure, matplotlib.gridspec.GridSpecBase][source]#

Initialize grid layout to place subplots within a figure environment

Parameters:
ax_or_figsize

Either already-existing ax object or the width and height to create a figure window

nrows

Number of rows in the grid

ncols

Number of columns in the grid

wspace

The amount of width reserved for space between subplots, expressed as a fraction of the average axis width

hspace

The amount of height reserved for space between subplots, expressed as a fraction of the average axis height

width_ratios

Defines the relative widths of the columns. Each column gets a relative width of width_ratios[i] / sum( width_ratios). If not given, all columns will have the same width.

height_ratios

Defines the relative heights of the rows. Each row gets a relative width of height_ratios[i] / sum( height_ratios). If not given, all columns will have the same width.

Returns:

Instantiated Figure object gs: Instantiated gridspec object

Return type:

fig

class spateo.plotting.static.dotplot.Dotplot(adata: anndata.AnnData, var_names: Sequence[str], cat_key: str | Sequence[str], num_categories: int = 7, prescale_adata: bool = False, categories_order: None | Sequence[str] = None, title: None | str = None, figsize: None | Tuple[float, float] = None, gene_symbols_key: None | str = None, var_group_positions: None | Sequence[Tuple[int, int]] = None, var_group_labels: None | Sequence[str] = None, var_group_rotation: None | float = None, layer: None | str = None, expression_cutoff: float = 0.0, mean_only_expressed: bool = False, standard_scale: Literal[var, group] = None, dot_color_df: pandas.DataFrame | None = None, dot_size_df: pandas.DataFrame | None = None, ax: None | matplotlib.axes.Axes = None, vmin: None | float = None, vmax: None | float = None, vcenter: None | float = None, norm: matplotlib.colors.Normalize | None = None, **kwargs)[source]#

Simultaneous visualization of two variates that are encoded by the dot size and the dot color. Size usually represents the fraction of samples that have non-zero values, and color usually represents the magnitude of the value.

Parameters:
adata

class anndata.AnnData

var_names

Should be a subset of adata.var_names

cat_key

The key(s) in .obs of the grouping to consider. Should be a categorical observation; if not, will be subdivided into ‘num_categories’.

num_categories

Only used if groupby observation is not categorical. This value determines the number of groups into which the groupby observation should be subdivided.

categories_order

Sets order of categories given by ‘cat_key’ along the plotting axis

title

Sets title for figure window

figsize

The width and height of a figure

gene_symbols_key

Key in .var containing gene symbols

var_group_positions

Each item in the list should contain the start and end position that the bracket should cover. Eg. [(0, 4), (5, 8)] means that there are two brackets, one for the var_names in positions 0-4 and other for positions 5-8.

var_group_labels

List of group labels for the variable names (e.g. can group var_names in positions 0-4 as being “group A”)

var_group_rotation

Rotation in degrees of the variable name labels. If not given, small labels (<4 characters) are not rotated, but otherwise labels are rotated 90 degrees.

layer

Key in .layers specifying layer to use. If not given, will use .X.

expression_cutoff

Used for binarizing feature expression- feature is considered to be expressed only if the expression value is greater than this threshold

mean_only_expressed

If True, gene expression is averaged only over the cells expressing the given features

standard_scale

Whether or not to standardize that dimension between 0 and 1, meaning for each variable or group, subtract the minimum and divide each by its maximum. ‘val’ or ‘group’ is used to specify whether this should be done over variables or groups.

dot_color_df

Pre-prepared dataframe with features as indices, categories as columns, and indices corresponding to color intensities

dot_size_df

Pre-prepared dataframe with features as indices, categories as columns, and indices corresponding to dot sizes

ax

Can be used to provide pre-existing plotting axis

vmin

The data value that defines 0.0 in the normalization. Defaults to the min value of the dataset.

vmax

The data value that defines 1.0 in the normalization. Defaults to the the max value of the dataset.

vcenter

The data value that defines 0.5 in the normalization

norm

Optional already-initialized normalizing object that scales data, typically into the interval [0, 1], for the purposes of mapping to color intensities for plotting. Do not pass both ‘norm’ and ‘vmin’/’vmax’, etc.

**kwargs

Additional arguments passed to matplotlib.pyplot.scatter()

default_colormap = 'winter'[source]#
default_color_on = 'dot'[source]#
default_dot_max[source]#
default_dot_min[source]#
default_smallest_dot = 0.0[source]#
default_largest_dot = 200.0[source]#
default_dot_edgecolor = 'black'[source]#
default_dot_edgelw = 0.2[source]#
default_size_exponent = 1.5[source]#
default_size_legend_title = Multiline-String[source]#
Show Value
"""Fraction of cells
in group (%)"""
default_color_legend_title = Multiline-String[source]#
Show Value
"""Mean expression
in group"""
default_base = 10[source]#
default_num_colorbar_ticks = 5[source]#
default_num_size_legend_dots = 5[source]#
default_legends_width = 1.5[source]#
default_plot_x_padding = 0.8[source]#
default_plot_y_padding = 1.0[source]#
default_category_height = 0.35[source]#
default_category_width = 0.37[source]#
min_figure_height = 2.5[source]#
default_wspace = 0[source]#
swap_axes()[source]#

Modifies variables to flip x- and y-axes of dotplot.

By default, the x axis contains ‘var_names’ (e.g. genes) and the y axis the groupby categories. By setting ‘swap_axes’ the x-axis becomes the categories and the y-axis becomes the variable names.

add_dendrogram(show: bool = True, dendrogram_key: None | str = None, size: float = 0.8)[source]#

Show dendrogram based on the hierarchical clustering between the cat_key categories. Categories are reordered to match the dendrogram order.

The dendrogram information is computed using utils.dendrogram() within Spateo. If utils.dendrogram has not been called previously the function is called with default parameters here.

The dendrogram is by default shown on the right side of the plot or on top if the axes are swapped.

Parameters:
show

Boolean to turn on (True) or off (False) ‘add_dendrogram’

dendrogram_key

Needed if :func utils.dendrogram saved the dendrogram using a key different than the default name.

size

Size of the dendrogram. Corresponds to width when dendrogram shown on the right of the plot,

matplotlib or height when shown on top. The unit is the same as in

style(cmap: str = default_colormap, color_on: Literal[dot, square] | None = default_color_on, dot_max: float | None = default_dot_max, dot_min: float | None = default_dot_min, smallest_dot: float | None = default_smallest_dot, largest_dot: float | None = default_largest_dot, dot_edge_color: float | None = default_dot_edgecolor, dot_edge_lw: float | None = default_dot_edgelw, size_exponent: float | None = default_size_exponent, grid: float | None = False, x_padding: float | None = default_plot_x_padding, y_padding: float | None = default_plot_y_padding)[source]#

Modifies visual aspects of the dot plot

Args: cmap: Name of Matplotlib color map to use color_on: Options are ‘dot’ or ‘square’. By default the colormap is applied to the color of the dot,

but ‘square’ changes this to be applied to a square region behind the dot, in which case the dot becomes transparent with only the edge of the dot shown.

dot_max: If none, the maximum dot size is set to the maximum fraction value found (e.g. 0.6). If given,

the value should be a number between 0 and 1. All fractions larger than dot_max are clipped to this value.

dot_min: If none, the minimum dot size is set to 0. If given, the value should be a number between 0 and 1.

All fractions smaller than dot_min are clipped to this value.

smallest_dot: If none, the smallest dot has size 0. All expression fractions with dot_min are plotted with this size. largest_dot: If none, the largest dot has size 200. All expression fractions with dot_max are plotted with this size. dot_edge_color: Only used if ‘color_on’ is ‘square’. Sets dot edge color dot_edge_lw: Only used if ‘color_on’ is ‘square’. Sets dot edge line width size_exponent: Dot size is computed as:

fraction ** size exponent

and is afterwards scaled to match the ‘smallest_dot’ and ‘largest_dot’ size parameters. Using a different size exponent changes the relative sizes of the dots to each other.

grid: Set to true to show grid lines. By default grid lines are not shown. Further configuration of the grid

lines can be achieved directly on the returned ax.

x_padding: Space between the plot left/right borders and the dots center. A unit is the distance between the x

ticks. Only applied when ‘color_on’ = ‘dot’

y_padding: Space between the plot top/bottom borders and the dots center. A unit is the distance between the x

ticks. Only applied when ‘color_on’ = ‘dot’

Returns:

self (instance of class DotPlot)

Example

Creating a modified dot plot (w/ a loaded AnnData object given name ‘adata’): markers = [‘C1QA’, ‘PSAP’, ‘CD79A’, ‘CD79B’, ‘CST3’, ‘LYZ’] st.pl.DotPlot(adata, var_names=markers, cat_key=’Celltype’).style(cmap=’RdBu_r’, color_on=’square’).show()

legend(show: bool = True, show_size_legend: bool = True, show_colorbar: bool = True, size_title: str | None = default_size_legend_title, colorbar_title: str | None = default_color_legend_title, base: int | None = default_base, num_colorbar_ticks: int | None = default_num_colorbar_ticks, num_size_legend_dots: int | None = default_num_size_legend_dots, width: float | None = default_legends_width)[source]#

Configures colorbar and other legends for dotplot

Parameters:
show

Set to False to hide the default plot of the legends. This sets the legend width to zero, which will result in a wider main plot.

show_size_legend

Set to False to hide the dot size legend

show_colorbar

Set to False to hide the colorbar legend

size_title

Title for the dot size legend. Use ‘n’ to add line breaks. Will be shown at the top of the dot size legend box

colorbar_title

Title for the color bar. Use ‘n’ to add line breaks. Will be shown at the top of the color bar.

base

To determine the size of each “benchmark” dot in the size legend, will use a logscale; this parameter sets the base of that scale.

num_colorbar_ticks

Number of ticks for the colorbar

num_size_legend_dots

Number of “benchmark” dots to include in the dot size legend

width

Width of the legends area. The unit is the same as in matplotlib (inches)

Returns:

self (instance of class DotPlot)

Example

Setting the colorbar title (w/ a loaded AnnData object given name ‘adata’): markers = {{‘T-cell’: ‘CD3D’, ‘B-cell’: ‘CD79A’, ‘myeloid’: ‘CST3’}} dp = st.pl.DotPlot(adata, markers, groupby=’Celltype’) dp.legend(colorbar_title=’log(UMI counts + 1)’).show()

get_axes()[source]#
_plot_size_legend(size_legend_ax: matplotlib.axes.Axes)[source]#

Given axis object, generates dot size legend and displays on plot

For the dot size “benchmarks” on the legend, adjust the difference in size between consecutive benchmarks based on how different ‘self.dot_max’ and ‘self.dot_min’ are.

_plot_colorbar(color_legend_ax: matplotlib.axes.Axes, normalize: None | matplotlib.colors.Normalize = None)[source]#

Given axis object, plots a horizontal colorbar

Parameters:
color_legend_ax

mpl.axes.Axes object Matplotlib axis object to plot onto

normalize

mpl.colors.Normalize object The normalizing object that scales data, typically into the interval [0, 1], for the purposes of mapping to color intensities for plotting. If None, norm defaults to a colors.Normalize object and automatically scales based on min/max values in the data.

_plot_legend(legend_ax: matplotlib.axes.Axes, return_ax_dict: dict, normalize: None | matplotlib.colors.Normalize = None)[source]#

Organizes the size legend and color legend.

The structure for the legends is: First row: Empty space of variable size to control the size of the other rows Second row: Dot size legend Third row: Spacer to prevent titles/labels of the color and dot size legends overlapping Fourth row: Colorbar

Parameters:
legend_ax

mpl.axes.Axes Matplotlib axis object to plot onto

return_ax_dict

_mainplot(ax: matplotlib.axes.Axes)[source]#
static _dotplot(dot_size: pandas.DataFrame, dot_color: pandas.DataFrame, dot_ax: matplotlib.axes.Axes, cmap: str = 'Reds', color_on: str = 'dot', y_label: None | str = None, dot_max: None | float = None, dot_min: None | float = None, standard_scale: None | Literal[var, group] = None, smallest_dot: float = 0.0, largest_dot: float = 200, size_exponent: float = 2, edge_color: None | str = None, edge_lw: None | float = None, grid: bool = False, x_padding: float = 0.8, y_padding: float = 1.0, vmin: None | float = None, vmax: None | float = None, vcenter: None | float = None, norm: None | matplotlib.colors.Normalize = None, **kwargs)[source]#

Generate a dotplot given the axis object and two dataframes containing the dot size and dot color. The indices and columns of the dataframes are used to label the resultant image.

The dots are plotted using matplotlib.pyplot.scatter(). Thus, additional arguments can be passed.

Parameters:
dot_size

pd.DataFrame Data frame containing the dot_size.

dot_color

pd.DataFrame Data frame containing the dot_color, should have the same shape, columns and indices as dot_size.

dot_ax

matplotlib Axes object Axis to plot figure onto

cmap

str, default ‘Reds’ String denoting matplotlib color map

color_on

str, default ‘dot’ Options: ‘dot’ or ‘square’. By default the colormap is applied to the color of the dot. Optionally, the colormap can be applied to an square behind the dot, in which case the dot is transparent and only the edge is shown.

y_label

optional str Label for y-axis

dot_max

optional float If none, the maximum dot size is set to the maximum fraction value found (e.g. 0.6). If given, the value should be a number between 0 and 1. All fractions larger than dot_max are clipped to this value.

dot_min

optional float If none, the minimum dot size is set to 0. If given, the value should be a number between 0 and 1. All fractions smaller than dot_min are clipped to this value.

standard_scale

‘None’, ‘val’, or ‘group’ Whether or not to standardize that dimension between 0 and 1, meaning for each variable or group, subtract the minimum and divide each by its maximum. ‘val’ or ‘group’ is used to specify whether this should be done over variables or groups.

smallest_dot

optional float If none, the smallest dot has size 0. All expression fractions with dot_min are plotted with this size.

largest_dot

optional float If none, the largest dot has size 200. All expression fractions with dot_max are plotted with this size.

size_exponent

float, default 1.5 Dot size is computed as:

fraction ** size exponent

and is afterwards scaled to match the ‘smallest_dot’ and ‘largest_dot’ size parameters. Using a different size exponent changes the relative sizes of the dots to each other.

edge_color

str, default ‘black’ Only used if ‘color_on’ is ‘square’. Sets dot edge color

edge_lw

float, default 0.2 Only used if ‘color_on’ is ‘square’. Sets dot edge line width

grid

bool, default False Set to true to show grid lines. By default grid lines are not shown. Further configuration of the grid lines can be achieved directly on the returned ax.

x_padding

float, default 0.8 Space between the plot left/right borders and the dots center. A unit is the distance between the x ticks. Only applied when ‘color_on’ = ‘dot’

y_padding

float, default 1.0 Space between the plot top/bottom borders and the dots center. A unit is the distance between the x ticks. Only applied when ‘color_on’ = ‘dot’

vmin

optional float The data value that defines 0.0 in the normalization. Defaults to the min value of the dataset.

vmax

optional float The data value that defines 1.0 in the normalization. Defaults to the the max value of the dataset.

vcenter

optional float The data value that defines 0.5 in the normalization

norm

optional matplotlib.colors.Normalize object Optional already-initialized normalizing object that scales data, typically into the interval [0, 1], for the purposes of mapping to color intensities for plotting. Do not pass both ‘norm’ and ‘vmin’/’vmax’, etc.

**kwargs

Additional arguments passed to matplotlib.pyplot.scatter

Returns:

matplotlib.colors.Normalize object

The normalizing object that scales data, typically into the interval [0, 1], for the purposes of mapping to color intensities for plotting.

dot_minfloat

The minimum dot size represented on the plot, given as a fration of the maximum value in the data

dot_maxfloat

The maximum dot size represented on the plot, given as a fraction of the maximum value in the data

Return type:

normalize

reorder_categories_after_dendrogram(dendrogram_key)[source]#

Reorders categorical observations along plot axis based on dendrogram results.

The function checks if a dendrogram has already been precomputed. If not, utils.dendrogram is run with default parameters.

The results found in .uns[dendrogram_key] are used to reorder var_group_labels and var_group_positions.

static _plot_var_groups_brackets(gene_groups_ax: matplotlib.axes.Axes, group_positions: Iterable[Tuple[int, int]], group_labels: Sequence[str], left_adjustment: float = -0.3, right_adjustment: float = 0.3, rotation: float | None = None, orientation: Literal[Dotplot._plot_var_groups_brackets.top, Dotplot._plot_var_groups_brackets.right] = 'top')[source]#

Draws brackets that represent groups of features on the given axis.

The ‘gene_groups_ax’ Axes object should share the x-axis/y-axis (depending on the axis along which the features are plotted) with the main plot axis. For example, in instantiation: gene_groups_ax = fig.add_subplot(axs[0,0], sharex=dot_ax)

Parameters:
gene_groups_ax

matplotlib.axes.Axes object Axis to plot on, should correspond to the axis of the main plot on which the feature names/feature ticks are drawn

group_positions

list of tuples of form (int, int) Each item in the list, should contain the start and end position that the bracket should cover. Eg. [(0, 4), (5, 8)] means that there are two brackets, one for the var_names (eg genes) in positions 0-4 and the second for positions 5-8.

group_labels

list of str List of labels for the feature groups

left_adjustment

float, default -0.3 Adjustment to plot the bracket start slightly before or after the first feature position. If the value is negative the start is moved before.

right_adjustment

float, default 0.3 Adjustment to plot the bracket end slightly before or after the first feature position. If the value is negative the end is moved before, if positive the end is moved after.

rotation

optional float In degrees, angle of rotation for the labels. If not given, small labels (<4 characters) are not rotated, otherwise, they are rotated 90 degrees

orientation

str Options: ‘top’ or ‘right’ to set the location of the brackets

_update_var_groups()[source]#

Checks if var_names is a dict. Is this is the cases, then set the correct values for var_group_labels and var_group_positions

Updates var_names, var_group_labels, var_group_positions

make_figure()[source]#

Renders the image, but does not call matplotlib.pyplot.show().

class spateo.plotting.static.dotplot.CCDotplot(minn: float, delta: float, alpha: float, *args, **kwargs)[source]#

Bases: Dotplot

Because of the often much smaller values dealt with in cell-cell communication inference, this class creates a modified legend.

Parameters:
delta

optional float Distance between the largest value to consider and the smallest value to consider (see ‘minn’ parameter below)

minn

optional float For the dot size legend, sets the value corresponding to the smallest dot on the legend

alpha

optional float Significance threshold. If given, all elements w/ p-values <= ‘alpha’ will be marked by rings instead of dots.

*args

Positional arguments to initialize :class Dotplot

**kwargs

Keyword arguments to initialize :class Dotplot

base = 10[source]#
default_largest_dot = 50.0[source]#
_plot_size_legend(size_legend_ax: matplotlib.axes.Axes)[source]#

Given axis object, generates dot size legend and displays on plot

Overwrites the default :func plot_size_legend for :class Dotplot

spateo.plotting.static.dotplot.dotplot(adata: anndata.AnnData, var_names: Sequence[str], cat_key: Union[str, Sequence[str]], num_categories: int = 7, cell_cell_dp: bool = False, delta: Union[None, float] = None, minn: Union[None, float] = None, alpha: Union[None, float] = None, prescale_adata: bool = False, expression_cutoff: float = 0.0, mean_only_expressed: bool = False, cmap: str = 'Reds', dot_max: float = Dotplot.default_dot_max, dot_min: float = Dotplot.default_dot_min, standard_scale: Literal[var, group] = None, smallest_dot: float = Dotplot.default_smallest_dot, largest_dot: float = Dotplot.default_largest_dot, title: str = None, colorbar_title: str = Dotplot.default_color_legend_title, size_title: str = Dotplot.default_size_legend_title, figsize: Union[None, Tuple[float, float]] = None, dendrogram: Union[bool, str] = False, gene_symbols_key: Union[None, str] = None, var_group_positions: Union[None, Sequence[Tuple[int, int]]] = None, var_group_labels: Union[None, Sequence[str]] = None, var_group_rotation: Union[None, float] = None, layer: Union[None, str] = None, swap_axes: bool = False, dot_color_df: Union[None, pandas.DataFrame] = None, save_show_or_return: Literal[save, show, return, both, all] = 'save', save_kwargs: dict = {}, ax: Union[None, matplotlib.axes.Axes] = None, vmin: Union[None, float] = None, vmax: Union[None, float] = None, vcenter: Union[None, float] = None, norm: Union[None, matplotlib.colors.Normalize] = None, **kwargs)[source]#

Makes a dot plot of the expression values of var_names. For each var_name and each groupby category a dot is plotted. Each dot represents two values: mean expression within each category (visualized by color) and fraction of cells expressing the var_name in the category (visualized by the size of the dot). If groupby is not given, the dotplot assumes that all data belongs to a single category.

Parameters:
adata

object of class anndata.AnnData

var_names

Should be a subset of adata.var_names

cat_key

The key(s) in .obs of the grouping to consider. Should be a categorical observation; if not, will be subdivided into ‘num_categories’.

num_categories

Only used if groupby observation is not categorical. This value determines the number of groups into which the groupby observation should be subdivided.

cell_cell_dp

Set True to initialize specialized cell-cell dotplot instead of gene expression dotplot

delta

Only used if ‘cell_cell_dp’ is True- distance between the largest value to consider and the smallest value to consider (see ‘minn’ parameter below)

minn

Only used if ‘cell_cell_dp’ is True- for the dot size legend, sets the value corresponding to the smallest dot on the legend

alpha

Only used if ‘cell_cell_dp’ is True- significance threshold. If given, all elements w/ p-values <= ‘alpha’ will be marked by rings instead of dots.

prescale_adata

Set True to indicate that AnnData object should be scaled- if so, will use ‘delta’ and ‘minn’ to do so. If False, will proceed as though adata has already been processed as needed.

expression_cutoff

Used for binarizing feature expression- feature is considered to be expressed only if the expression value is greater than this threshold

mean_only_expressed

If True, gene expression is averaged only over the cells expressing the given features

cmap

Name of Matplotlib color map to use

dot_max

If none, the maximum dot size is set to the maximum fraction value found (e.g. 0.6). If given, the value should be a number between 0 and 1. All fractions larger than dot_max are clipped to this value.

dot_min

If none, the minimum dot size is set to 0. If given, the value should be a number between 0 and 1. All fractions smaller than dot_min are clipped to this value.

standard_scale

Whether or not to standardize that dimension between 0 and 1, meaning for each variable or group, subtract the minimum and divide each by its maximum. ‘val’ or ‘group’ is used to specify whether this should be done over variables or groups.

smallest_dot

If None, the smallest dot has size 0. All expression fractions with dot_min are plotted with this size.

largest_dot

If None, the largest dot has size 200. All expression fractions with dot_max are plotted with this size.

title

Title for the entire plot

colorbar_title

Title for the color legend. If None will use generic default title

size_title

Title for the dot size legend. If None will use generic default title

figsize

Sets width and height of figure window

dendrogram

If True, adds dendrogram to plot. Will do the same thing if string is given here, but will recompute dendrogram and save using this argument to set key in .uns.

gene_symbols_key

Key in .var containing gene symbols

var_group_positions

Each item in the list should contain the start and end position that the bracket should cover. Eg. [(0, 4), (5, 8)] means that there are two brackets, one for the var_names in positions 0-4 and other for positions 5-8

var_group_labels

List of group labels for the variable names (e.g. can group var_names in positions 0-4 as being “group A”)

var_group_rotation

Rotation in degrees of the variable name labels. If not given, small labels (<4 characters) are not rotated, but otherwise labels are rotated 90 degrees.

layer

Key in .layers specifying layer to use. If not given, will use .X.

swap_axes

Set True to switch what is plotted on the x- and y-axes

dot_color_df

Pre-prepared dataframe with features as indices, categories as columns, and indices corresponding to color intensities

save_show_or_return

Options: “save”, “show”, “return”, “both”, “all” - “both” for save and show

save_kwargs

A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. But to change any of these parameters, this dictionary can be used to do so.

ax

Pre-initialized axis object to plot on

vmin

The data value that defines 0.0 in the normalization. Defaults to the min value of the dataset.

vmax

The data value that defines 1.0 in the normalization. Defaults to the the max value of the dataset.

vcenter

The data value that defines 0.5 in the normalization

norm

Optional already-initialized normalizing object that scales data, typically into the interval [0, 1], for the purposes of mapping to color intensities for plotting. Do not pass both ‘norm’ and ‘vmin’/’vmax’, etc.

kwargs

Additional keyword arguments passed to matplotlib.pyplot.scatter()

Returns:

Instantiated Figure object- only if ‘return’ is True axes: Instantiated Axes object- only if ‘return’ is True

Return type:

fig