metachat.pl.plot_3d_LRC_with_two_slices

metachat.pl.plot_3d_LRC_with_two_slices(adata, mask_key, spatial_key='spatial_3d', z_levels=None, slab_ratio=0.02, flatten_z=True, bg_color='#b0b0b0', ch_color='#ff7f0e', plane_opacity=0.35)[source]

Visualize 3D long-range channels (LRCs) with two representative z-slice views.

This function creates a 3D interactive Plotly visualization showing the overall distribution of long-range channels (LRCs) and two sectional slices at selected z-levels. It helps interpret the spatial continuity of LRCs across depth and verify their anatomical localization relative to tissue layers.

The figure layout consists of:
  1. Left panel — full 3D overview of the tissue with highlighted LRC voxels.

  2. Middle and right panels — top-down slice views at two z-planes, showing LRCs within thin slabs (controlled by slab_ratio).

Parameters

adataanndata.AnnData

Annotated data object containing 3D spatial coordinates in .obsm[spatial_key] and a binary mask column in .obs[mask_key] indicating LRC membership.

mask_keystr

Key in adata.obs corresponding to a boolean array marking LRC points (e.g., 'LRC_CSF_manual_filtered' or 'LRC_Blood_auto').

spatial_keystr, default=”spatial_3d”

Key in adata.obsm specifying 3D spatial coordinates (shape: N × 3).

z_levelslist of float, optional

Two z-levels to use for slice visualization. If None, the function automatically selects the 0.3 and 0.7 quantiles of the z-coordinate distribution.

slab_ratiofloat, default=0.02

Fraction of the z-range defining the slab thickness for each slice. Smaller values yield thinner and cleaner cross-sections.

flatten_zbool, default=True

If True, all points within a slice are flattened to the central z-plane (for a 2D-like appearance). If False, preserves their original depth variation.

bg_colorstr, default=”#b0b0b0”

Color for non-LRC (background) points.

ch_colorstr, default=”#ff7f0e”

Color for highlighted LRC points (channels).

plane_opacityfloat, default=0.35

Opacity of the grey slicing planes shown in the main 3D view.

Returns

figplotly.graph_objects.Figure

A Plotly figure object containing three synchronized 3D scenes: the main tissue view and two z-slice panels.

Notes

  • The function uses Plotly’s make_subplots with three 3D scenes arranged horizontally for combined visualization.

  • The selected z-levels are marked by semi-transparent planes in the main panel.

  • Each slice subplot is rendered with an orthographic top-down projection to emphasize spatial distribution patterns rather than depth.

  • This function is useful for verifying whether manually or automatically identified LRC regions form continuous 3D paths through the tissue volume.