scatter#
- scatter(data: AnnData, mapping: FeatureSpec, *, axis: Literal[0, 1] | None = None, variable_keys: Sequence[str] | None = None, observations_name: str = 'Barcode', variables_name: str = 'Variable', include_dimensions: bool | int = False, interactive: bool = False, **geom_kwargs) PlotSpec#
Scatter Plot.
- Parameters:
data (
AnnData) – The AnnData object of the single cell data.mapping (
FeatureSpec | None, defaultNone) – Aesthetic mappings for the plot, the result of aes().axis (
{0,1}| None, defaultNone) – axis of the data, 0 for observations and 1 for variables.variable_keys (
str | Sequence[str] | None, defaultNone) – Variable keys to add to the DataFrame. If None, no additional keys are added.observations_name (
str, default'Barcode') – The name of the observations column.variables_name (
str, default'Variable') – Name for the variables index column.include_dimensions (
bool | int, defaultFalse) – Whether to include dimensions in the DataFrame. Providing an integer will limit the number of dimensions to given number.interactive (
bool, defaultFalse) – 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 lets_plot import * import cellestial as cl data = sc.read_h5ad("data/pbmc3k_pped.h5ad") cl.scatter( data, mapping=aes(x="n_genes_by_counts", y="pct_counts_in_top_50_genes"), color="grey", alpha=0.6, )
Further customization via color aesthetic.
import scanpy as sc from lets_plot import * import cellestial as cl data = sc.read_h5ad("data/pbmc3k_pped.h5ad") 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()
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.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")