ocelli.pl.scatter_interactive#
- ocelli.pl.scatter_interactive(adata: AnnData, x: str, s: float = 1.0, c: str | None = None, cdiscrete=None, ccontinuous=None, vmin=None, vmax=None, title=None, showlegend: bool = True, showaxes: bool = False, save=None)#
2D and 3D interactive scatter plots
Generates a 2D or 3D interactive scatter plot using Plotly. The plot is based on data stored in adata.obsm and can optionally use a color scheme from adata.obs.
- Parameters:
adata (anndata.AnnData) – The annotated data matrix.
x (str) – Key in adata.obsm containing 2D or 3D data for plotting.
s (float) – Size of the scatter plot markers. (default: 1.0)
c (str or None) – Key in adata.obs specifying the color scheme. (default: None)
cdiscrete (dict or None) – A dictionary mapping discrete groups in the color scheme to specific colors. Used for discrete color schemes. (default: None)
ccontinuous (str or None) – Colormap for continuous color schemes. Options from Plotly’s colors.sequential, colors.diverging, or colors.cyclical. (default: None)
vmin (float or None) – Lower bound of the colormap for continuous color schemes. Must be used with vmax. (default: None)
vmax (float or None) – Upper bound of the colormap for continuous color schemes. Must be used with vmin. (default: None)
title (str or None) – Title of the plot. (default: None)
showlegend (bool) – Whether to display a legend. (default: True)
showaxes (bool) – Whether to display the plot axes. (default: False)
save (str or None) – Path to save the plot as an HTML file. If None, the plot is returned as a Plotly figure. (default: None)
- Returns:
If save=None: Returns a Plotly figure object.
Otherwise, saves the plot to the specified path as an HTML file.
- Return type:
plotly.graph_objs._figure.Figure or None
- Example:
import ocelli as oci from anndata import AnnData import numpy as np # Example data adata = AnnData(X=np.random.rand(100, 50)) adata.obsm["embedding"] = np.random.rand(100, 2) adata.obs["group"] = np.random.choice(["A", "B", "C"], 100) # Generate an interactive scatter plot oci.pl.scatter_interactive(adata, x="embedding", c="group", s=5, title="Interactive Scatter Plot")