deepspatial.vis_utils.plot_virtual_slice

deepspatial.vis_utils.plot_virtual_slice#

deepspatial.vis_utils.plot_virtual_slice(adata: AnnData, plane_normal: str | Tuple[float, float, float] = 'sagittal', thickness: float = 10.0, color_col: str = 'cell_class', palette: Dict[str, str] | None = None, center: Tuple[float, float, float] | None = None, spatial_key: str = 'spatial', z_key: str = 'z_coord', azim: float = -60.0, elev: float = 30.0, point_size: float = 2.0, alpha: float = 0.8, bg_color: str = 'white', save_pdf: str | None = None, return_adata: bool = False, show: bool = True) None | AnnData | Figure | Tuple[Figure, AnnData][source]#

Simulate physical sectioning and generate a virtual 2D/3D slice plot.

Parameters:
  • adata (ad.AnnData) – Annotated data matrix.

  • plane_normal (str or tuple) – Normal vector of the cutting plane. Accepts predefined strings (‘coronal’, ‘sagittal’, ‘transverse’, ‘axial’) or a custom 3D vector.

  • thickness (float) – Thickness of the virtual slice.

  • color_col (str) – Column in adata.obs for coloring points.

  • palette (dict, optional) – Mapping of categories to hex colors.

  • center (tuple, optional) – The (X, Y, Z) point the plane passes through. Defaults to data centroid.

  • spatial_key (str) – Key in adata.obsm for XY coordinates.

  • z_key (str) – Key in adata.obs for Z coordinate.

  • azim (float) – Azimuthal viewing angle (only applies to custom 3D angled slices).

  • elev (float) – Elevation viewing angle (only applies to custom 3D angled slices).

  • point_size (float) – Marker size.

  • alpha (float) – Marker opacity.

  • bg_color (str) – Figure background color.

  • save_pdf (str, optional) – Path to save output PDF.

  • return_adata (bool) – If True, returns the subsetted AnnData object containing only the slice.

  • show (bool) – If True, display the plot immediately.

Returns:

Depends on return_adata and show toggles.

Return type:

Mixed