scatter#

API pages include interactive (HTML) plots that would possibly not render correctly on a mobile device.

scatter(data: AnnData | MuData, mapping: FeatureSpec, *, axis: Literal[0, 1] | None = None, variable_keys: Sequence[str] | None = None, observation_id_column: str = 'Barcode', variable_id_column: str = 'Variable', include_dimensions: bool | int = False, interactive: bool = False, **geom_kwargs) → PlotSpec#

Scatter Plot.

Parameters:
  • data (AnnData | MuData) – The single-cell data object.

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

  • axis ({0,1} | None, default None) – axis of the data, 0 for observations and 1 for variables.

  • variable_keys (str | Sequence[str] | None, default None) – Variable keys to add to the DataFrame. If None, no additional keys are added.

  • observation_id_column (str, default 'Barcode') – The name of the observations column.

  • variable_id_column (str, default 'Variable') – Name for the variables index column.

  • include_dimensions (bool | int, default False) – Whether to include dimensions in the DataFrame. Providing an integer will limit the number of dimensions to given number.

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

  • **geom_kwargs – Additional parameters for the geom_point layer. For more information on geom_point parameters, see: https://lets-plot.org/python/pages/api/lets_plot.geom_point.html

Returns:

PlotSpec – Scatter plot.

Examples

Scatter plot requires mapping of aesthetics.

import scanpy as sc
from ggrust import *

import cellestial as cl

data = cl.datasets.pbmc3k()

cl.scatter(
    data,
    mapping=aes(x="n_genes_by_counts", y="pct_counts_in_top_50_genes"),
    color="grey",
    alpha=0.6,
)
0 1,000 2,000 3,000 4,000 5,000 6,000 7,000 8,000 20 30 40 50 60 70 80 90 100 n_genes_by_counts pct_counts_in_top_50_genes

Further customization via color aesthetic.

import scanpy as sc
from ggrust import *

import cellestial as cl

data = cl.datasets.pbmc3k()

cl.scatter(
    data,
    mapping=aes(x="n_genes_by_counts", y="pct_counts_in_top_50_genes", color="cell_type_lvl1"),
    alpha=0.6,
) + scale_color_viridis()
0 2,000 4,000 6,000 8,000 20 30 40 50 60 70 80 90 100 n_genes_by_counts pct_counts_in_top_50_genes cell_type_lvl1 Lymphocytes Monocytes Erythroid B Cells

Faceting by categorical data is also possible.

import scanpy as sc
from ggrust import *

import cellestial as cl

data = cl.datasets.pbmc3k()


cl.scatter(
    data,
    mapping=aes(x="n_genes_by_counts", y="pct_counts_in_top_50_genes", color="cell_type_lvl1"),
    alpha=0.6,
) + scale_color_viridis() + facet_wrap("cell_type_lvl1")
20 40 60 80 100 B Cells Erythroid 0 2,000 4,000 6,000 8,000 20 40 60 80 100 Lymphocytes 0 2,000 4,000 6,000 8,000 Monocytes n_genes_by_counts pct_counts_in_top_50_genes cell_type_lvl1 Lymphocytes Monocytes Erythroid B Cells