dotplot#

dotplot(data: AnnData, keys: Sequence[str] | Mapping[str, Sequence[str]], group_by: str, *, mapping: FeatureSpec | None = None, threshold: float = 0, size_scale: float = 1.0, variable_column: str = 'variable', color_low: str = '#e6e6e6', color_mid: str | None = None, color_high: str = '#D2042D', mid_point: Literal['mean', 'median', 'mid'] | float = 'mid', sort_by: str | Sequence[str] | None = None, sort_order: Literal['ascending', 'descending'] = 'descending', percentage_key: str = 'pct_exp', mean_key: str = 'avg_exp', rectangle: bool = True, dendrogram: bool = False, dendrogram_color: str = 'black', dendrogram_size: float = 0.5, dendrogram_kwargs: dict | None = None, rectangle_size: float = 0.8, rectangle_color: str = '#3f3f3f', rectangle_kwargs: dict | None = None, key_labels: bool = True, tooltips: Literal['none'] | Sequence[str] | FeatureSpec | None = None, interactive: bool = False, **geom_kwargs) PlotSpec#

Dotplot.

Parameters:
  • data (AnnData) – The AnnData object of the single cell data.

  • keys (Sequence[str] | Mapping[str, Sequence[str]]) – The variable keys to include in the dotplot. When a mapping is provided, each entry maps a group label to the keys belonging to that group; the keys are placed on the x-axis in mapping order. The same key cannot appear in more than one group.

  • group_by (str) – The key to group the data by.

  • mapping (FeatureSpec | None, default None) – Aesthetic mappings for the plot, the result of aes().

  • threshold (float, default 0) – The expression threshold to consider a gene as expressed.

  • size_scale (float, default 1.0) – Scaling factor for the point sizes in the plot.

  • point_size (float, default 1.0) – Scaling factor for the point sizes in the plot.

  • variable_column (str, default 'variable') – Name for the variable column after unpivoting.

  • color_low (str, default '#e6e6e6') – Color for low values in the gradient.

  • color_mid (str | None, default None) – Color for mid values in the gradient.

  • color_high (str, default '#D2042D') – Color for high values in the gradient.

  • mid_point ({'mean', 'median', 'mid'} | float, default 'mid') – Midpoint for the color gradient.

  • fill (bool, optional) – Whether to use fill aesthetic instead of color, by default False.

  • sort_by (str | None) – The column to sort the results by, by default None.

  • sort_order (str, default 'descending') – The sort order, either ‘ascending’ or ‘descending’.

  • percentage_key (str, default 'pct_exp') – The name of the percentage column.

  • mean_key (str, default 'avg_exp') – The name of the mean expression column.

  • rectangle (bool, default True) – Whether to add a rectangle border around the data area

  • dendrogram (bool, default False) – Whether to add a dendrogram for the group_by axis. Uses scanpy.tl.dendrogram if not already computed. When True, group order is determined by the dendrogram.

  • dendrogram_color (str, default 'black') – Color of the dendrogram segments.

  • dendrogram_size (float, default 0.5) – Size (thickness) of the dendrogram segments.

  • dendrogram_kwargs (dict | None, default None) – Additional parameters to pass to the dendrogram geom_segment.

  • rectangle_size (float, default 0.8) – Size (thickness) of the rectangle border.

  • rectangle_color (str, default '#3f3f3f') – Color of the rectangle border.

  • rectangle_kwargs (dict | None, default None) – Additional parameters to pass to the rectangle geom_rect.

  • key_labels (bool, default True) – Whether to draw bracket labels above the plot when keys is a mapping.

  • tooltips ({'none'} | Sequence[str] | FeatureSpec | None, default None) – Tooltips to show when hovering over the geom. Accepts Sequence[str] or result of layer_tooltips() for more complex tooltips. Use ‘none’ to disable tooltips.

  • show_tooltips (bool, default True) – Whether to show tooltips.

  • interactive (bool, default False) – Whether to make the plot interactive.

  • **geom_kwargs (Any) – Additional keyword arguments for the geom_point layer.

Returns:

PlotSpec – Dotplot.

Examples

A simple dotplot.

import scanpy as sc
from lets_plot import *

import cellestial as cl

data = sc.read_h5ad("data/pbmc3k_pped.h5ad")

markers = ["C1QA", "PSAP", "CD79A", "CD79B", "CST3", "LYZ"]

dot = cl.dotplot(
    data,
    keys=markers,
    group_by="cell_type_lvl1",
)
dot

Dotplot allows dendrograms among the groups.

dot = cl.dotplot(
    data,
    keys=markers,
    group_by="cell_type_lvl1",
    dendrogram=True,
)
dot

Modify the dendrogram and rectangle borders.

dot = cl.dotplot(
    data,
    keys=markers,
    group_by="cell_type_lvl1",
    dendrogram=True,
    dendrogram_color="gray",
    dendrogram_size=1,
    rectangle_color="gray",
    rectangle_size=3,
)
dot