interactive_spatial_plot

spac.visualization.interactive_spatial_plot(adata, annotations=None, feature=None, layer=None, dot_size=1.5, dot_transparency=0.75, annotation_colorscale='rainbow', feature_colorscale='balance', figure_width=6, figure_height=4, figure_dpi=200, font_size=12, stratify_by=None, defined_color_map=None, reverse_y_axis=False, cmin=None, cmax=None, **kwargs)[source]

Create an interactive scatter plot for spatial data using provided annotations.

Parameters:
  • adata (AnnData) – Annotated data matrix object, must have a .obsm attribute with ‘spatial’ key.

  • annotations (list of str or str, optional) – Column(s) in adata.obs that contain the annotations to plot. If a single string is provided, it will be converted to a list. The interactive plot will show all the labels in the annotation columns passed.

  • feature (str, optional) – If annotation is None, the name of the gene or feature in adata.var_names to use for coloring the scatter plot points based on feature expression.

  • layer (str, optional) – If feature is not None, the name of the data layer in adata.layers to use for visualization. If None, the main data matrix adata.X is used.

  • dot_size (float, optional) – Size of the scatter dots in the plot. Default is 1.5.

  • dot_transparency (float, optional) – Transparancy level of the scatter dots. Default is 0.75.

  • annotation_colorscale (str, optional) – Name of the color scale to use for the dots when annotation is used. Default is ‘Viridis’.

  • feature_colorscale (srt, optional) – Name of the color scale to use for the dots when feature is used. Default is ‘seismic’.

  • figure_width (int, optional) – Width of the figure in inches. Default is 12.

  • figure_height (int, optional) – Height of the figure in inches. Default is 8.

  • figure_dpi (int, optional) – DPI (dots per inch) for the figure. Default is 200.

  • font_size (int, optional) – Font size for text in the plot. Default is 12.

  • stratify_by (str, optional) – Column in adata.obs to stratify the plot. Default is None.

  • defined_color_map (str, optional) – Predefined color mapping stored in adata.uns for specific labels. Default is None, which will generate the color mapping automatically.

  • reverse_y_axis (bool, optional) – If True, reverse the Y-axis of the plot. Default is False.

  • cmin (float, optional) – Minimum value for the color scale when using features. Default is None.

  • cmax (float, optional) – Maximum value for the color scale when using features. Default is None.

  • **kwargs – Additional keyword arguments for customization.

Returns:

A list of dictionaries, each containing the following keys: - “image_name”: str, the name of the generated image. - “image_object”: Plotly Figure object.

Return type:

list of dict

Notes

This function is tailored for spatial single-cell data and expects the AnnData object to have spatial coordinates in its .obsm attribute under the ‘spatial’ key.