mechanochat.plotting.alphashape_plot#
- mechanochat.plotting.alphashape_plot(sem: SEM2, vis_key: str | None = None, obsm_key: str | None = None, arr: ndarray[Any, dtype[_ScalarType_co]] | Series | None = None, summary: str = 'receiver_mechano_signal', compute_alphashape: bool = False, cid_list: ndarray[Any, dtype[int64]] | ndarray[Any, dtype[bool_]] | Sequence[int] | None = None, cmap_name: str = 'Reds', palette: Dict[str, Tuple] | None = None, vmax: float | None = None, vmin: float | None = None, boundary_width: float = 0.5, boundary_color: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None = 'gray', boundary_alpha: float = 1, face_color: str | ndarray[Any, dtype[floating]] | Sequence[float] | None = None, face_alpha: float | Iterable[float] = 1, show_axis: bool = False, enable_annotation: bool = False, enable_legend: bool = True, enable_colorbar: bool = True, return_mappable: bool = False, ax: Axes | None = None, show: bool = True, save_name: str | None = None, rotation: Dict | None = None, **kwargs)[source]#
Plot cell shape using alpha shape, visualize cell data by colors.
- Parameters:
sem (
SEM) – Subcellular element method objectvis_key (
str, optional) – Key to retrieve visualization data from sem.adataobsm_key (
str, optional) – Key of the signal DataFrame in adata.obsm used when summary == ‘cell’arr (
np.ndarrayorpd.Series, optional) –Data for visualization. shape = (nc,) or (len(cid_list),)
Ignored if vis_key is provided .
sem.ctype will be visualized if arr and vis_key both are not provided.
summary (
str) –if summary == ‘gene’, retrieve data from adata[:, vis_key]
if summary == ‘cell’, retrieve data from adata.obs[vis_key]
if summary in adata.obsm, retrieve data from adata.obsm[summary][vis_key]
compute_alphashape (
bool, defaultFalse) – Compute alphashape if Truecid_list (
ndarray, optional) – Array of index for cells to be visualized. Default: all cellscmap_name (
str, default'Reds') – Valid matplotlib colormap name to visualize datapalette (
dict, optional) – Category -> color mapping used for categorical data instead of the colors stored in adata.uns[f’{vis_key}_colors’]vmax (
float, optional) – Colormap upper bound. Default: 95th percentile for positive datavmin (
float, optional) – Colormap lower bound. Default: data minboundary_width (
float, default1) – Cell boundary line widthboundary_color (
strortuple, default'gray') – Cell boundary line color. Set to None to let each boundary match its face colorboundary_alpha (
float, default1) – Cell boundary line opacity, 0 (fully transparent), 1 (fully opaque)face_color (
str,ndarrayorsequence, optional) – Single color (or one color per cell) overriding the cell type colors. Setting it disables the legendface_alpha (
float, default1) – Cell shape face opacity, 0 (fully transparent), 1 (fully opaque)enable_annotation (
bool, defaultFalse) – Annotate cells with index at centroidsenable_legend (
bool, defaultFalse) – Show categorical legend (only for category data)enable_colorbar (
bool, defaultFalse) – Show colorbar (only for continuous data)return_mappable (
bool, defaultFalse) – Whether to return the colormap and the normalization usedax (
Axes, optional) – Target matplotlib axes object. Creates new figure if None.show (
bool, defaultTrue) – Whether to keep the figure open after saving. Ignored when save_name is Nonesave_name (
str, optional) – Output path for figure saving (e.g., ‘figure.pdf’)rotation (
dict, optional) – Rotate the coordinates before plotting. Keys: ‘center’ (2,) and ‘theta’ (radians)**kwargs – keyword arguments passed to sem.compute_alphashape()
- Returns:
ax (
Axes) – If return_mappable=False(ax, cmap, norm) (
tuple) – If return_mappable=True. cmap and norm are None when a categorical variable was plotted