spcoral.plot.show_cross_align_3D#
- spcoral.plot.show_cross_align_3D(adata_omics1, adata_omics2, registering_parameters, subsample_size=300, color_based=None, omics1_use_obsm='spatial', omics2_use_obsm='spatial', size_omics1=1.5, size_omics2=1.5, conf_cutoff=0, line_width=0.3, line_color='grey', line_alpha=0.7, hide_axis=True, show_error=True, show_celltype=False, color=None, cmap='Reds', figsize=None, dpi=None, title=None, ax=None, show=True, save=None, **kwargs)#
Visualize the 3D alignment of two omics datasets with spatial coordinates and cell matching.
This function creates a 3D scatter plot to display the spatial alignment of two datasets (e.g., omics data) with optional lines connecting matched cells. It supports coloring by metadata (e.g., cell types), scaling coordinates, and visualizing matching errors.
- Parameters:
adata_omics1 (ad.AnnData) – AnnData object for the first omics dataset (reference dataset).
adata_omics2 (ad.AnnData) – AnnData object for the second omics dataset (target dataset).
registering_parameters (Dict) – Dictionary containing matching parameters, where keys 1 and 2 correspond to indices of matched cells.
subsample_size (int, optional) – Number of cell pairs to subsample for visualization (default: 300).
color_based (str, optional) – Column name in adata_omics*.obs to color points by (e.g., ‘celltype’). If None, no coloring is applied.
omics1_use_obsm (str, optional) – Key in adata_omics1.obsm for spatial coordinates (default: ‘spatial’).
omics2_use_obsm (str, optional) – Key in adata_omics2.obsm for spatial coordinates (default: ‘spatial’).
size_omics1 (float, optional) – Size of scatter points for the first dataset (default: 1.5).
size_omics2 (float, optional) – Size of scatter points for the second dataset (default: 1.5).
conf_cutoff (float, optional) – Confidence threshold for displaying matched pairs (default: 0).
line_width (float, optional) – Width of lines connecting matched cells (default: 0.3).
line_color (str, optional) – Color of lines connecting matched cells (default: ‘grey’).
line_alpha (float, optional) – Transparency of lines connecting matched cells (default: 0.7).
hide_axis (bool, optional) – If True, hide plot axes (default: True).
show_error (bool, optional) – If True, color lines differently for mismatched cell types (requires meta) (default: True).
show_celltype (bool, optional) – If True, color lines by cell type for matched pairs (requires meta) (default: False).
cmap (str, optional) – Colormap for visualizing expression or metadata (default: ‘Reds’).
figsize (Tuple[float, float], optional) – Figure size as (width, height). If None, defaults to (7, 7).
dpi (float, optional) – Resolution of the figure in dots per inch. If None, uses default.
title (str, optional) – Title of the plot. If None, no title is set.
ax (matplotlib.axes.Axes, optional) – Existing axes to plot on. If None, a new figure and axes are created.
show (bool, optional) – If True, display the plot (default: True).
save (str or os.PathLike, optional) – File path to save the plot. If None, the plot is not saved.
**kwargs (Dict[str, Any]) – Additional keyword arguments passed to
match_3D_multi.
- Returns:
The axes object containing the plot, returned only if
showis False.- Return type:
matplotlib.axes.Axes, optional
Notes
The function assumes
adata_omics1andadata_omics2have spatial coordinates in.obsm.The
registering_parametersdictionary should contain matching indices under keys 1 and 2.If
color_basedis provided, it must exist in both datasets’.obs.