xyplot#

xyplot(data: AnnData, x: str, y: str, *, mapping: FeatureSpec | None = None, axis: Literal[0, 1] | None = None, tooltips: Literal['none'] | Sequence[str] | FeatureSpec | None = None, interactive: bool = False, observations_name: str = 'Barcode', variables_name: str = 'Variable', include_dimensions: bool | int = False, **point_kwargs) PlotSpec#

Scatter Plot.

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

  • x (str) – The key for the x-axis.

  • y (str) – The key for the y-axis.

  • mapping (FeatureSpec | None, default None) – Additional 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.

  • 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.

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

  • observations_name (str, default 'Barcode') – The name to give to barcode (or index) column in the dataframe.

  • variables_name (str, default 'Variable') – The name to give to variable index column in the dataframe.

  • 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.

  • **point_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

xyplot requires x and y values to be provided directly.

import scanpy as sc
from lets_plot import *

import cellestial as cl

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

cl.xyplot(
    data,
    x="n_genes_by_counts",
    y="pct_counts_in_top_50_genes",
    color="grey",
    alpha=0.6,
)

xyplot also supports customization of aesthetics via mapping.

import scanpy as sc
from lets_plot import *

import cellestial as cl

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

cl.xyplot(
    data,
    x="n_genes_by_counts",
    y="pct_counts_in_top_50_genes",
    mapping=aes(color="cell_type_lvl1"),
    alpha=0.6,
) + scale_color_viridis()

Faceting by categorical data is also possible.

import scanpy as sc
from lets_plot import *

import cellestial as cl

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

cl.xyplot(
    data,
    x="n_genes_by_counts",
    y="pct_counts_in_top_50_genes",
    mapping=aes(color="cell_type_lvl1"),
    alpha=0.6,
) + scale_color_viridis() + facet_wrap("cell_type_lvl1")