spateo.plotting.static.align ============================ .. py:module:: spateo.plotting.static.align Functions --------- .. autoapisummary:: spateo.plotting.static.align.slices_2d spateo.plotting.static.align.overlay_slices_2d spateo.plotting.static.align.optimization_animation spateo.plotting.static.align.plot_deformation_grid spateo.plotting.static.align.multi_slices spateo.plotting.static.align._agenerate_palette spateo.plotting.static.align._compute_smallest_distance spateo.plotting.static.align.transform_by_min_max spateo.plotting.static.align.get_min_max spateo.plotting.static.align.transform_H spateo.plotting.static.align.get_H Module Contents --------------- .. py:function:: slices_2d(slices: Union[anndata.AnnData, List[anndata.AnnData]], slices_key: Optional[Union[bool, str]] = None, label_key: Optional[str] = None, label_type: Optional[str] = None, spatial_key: str = 'spatial', point_size: Optional[float] = None, n_sampling: int = -1, palette: Optional[dict] = None, ncols: int = 4, title: str = '', title_kwargs: Optional[dict] = None, show_legend: bool = True, legend_kwargs: Optional[dict] = None, axis_off: bool = False, axis_kwargs: Optional[dict] = None, ticks_off: bool = True, x_min=None, x_max=None, y_min=None, y_max=None, height: float = 2, alpha: float = 1.0, cmap='tab20', center_coordinate: bool = False, gridspec_kws: Optional[dict] = None, return_palette: bool = False, save_show_or_return: Literal['save', 'show', 'return', 'both', 'all'] = 'show', save_kwargs: Optional[dict] = None, sort_values: bool = True, sort_ascending: bool = True, **kwargs) Plot multiple 2D spatial transcriptomics slices for both categorical clusters and scalar values. :param slices: A single :class:`~anndata.AnnData` object **or** a list of ``AnnData``, each element represents one spatial slice. :param slices_key: Column in ``.obs`` that identifies each slice. Required when a single ``AnnData`` containing multiple batches is supplied. :param label_key: Column name in ``.obs`` **or** gene name in ``.var`` whose values will be visualised. If the value is numeric, it will be treated as a scalar value, otherwise it will be treated as a cluster. :param label_type: Force interpretation of ``label_key`` as ``'cluster'`` or ``'scalar'``. If *None* the type is inferred automatically. If the value is numeric, it will be treated as a scalar value, otherwise it will be treated as a cluster. :param spatial_key: Key in ``.obsm`` that stores the spatial coordinates (default ``'spatial'``). :param point_size: Size of scatter points in points². If *None* an empirical value is computed based on the overall point density. :param n_sampling: Down-sample each slice to *n_sampling* points (without replacement). Supply ``-1`` to disable down-sampling. :param palette: Mapping from category → color for cluster plots **or** a colormap name for scalar plots. If *None* a palette/colormap is generated automatically. :param ncols: Number of subplot columns. The value is automatically clipped so as not to exceed the number of slices. :param title: Common title string and optional ``Axes.set_title`` keyword arguments. :param title_kwargs: Common title string and optional ``Axes.set_title`` keyword arguments. :param show_legend: Whether to draw a legend (clusters) or colour-bar (scalar) and optional keyword overrides. :param legend_kwargs: Whether to draw a legend (clusters) or colour-bar (scalar) and optional keyword overrides. :param axis_off: Whether to hide the axis frame/ticks and optional overrides to ``Axes.axis``. :param axis_kwargs: Whether to hide the axis frame/ticks and optional overrides to ``Axes.axis``. :param ticks_off: If *True* x/y-tick labels are removed. :param x_min: Explicit axis limits. When *None* the limits are derived from the data and padded by 5 % so that points at the border are still visible. :param x_max: Explicit axis limits. When *None* the limits are derived from the data and padded by 5 % so that points at the border are still visible. :param y_min: Explicit axis limits. When *None* the limits are derived from the data and padded by 5 % so that points at the border are still visible. :param y_max: Explicit axis limits. When *None* the limits are derived from the data and padded by 5 % so that points at the border are still visible. :param height: Height of **one** subplot in inches. :param alpha: Global alpha (transparency) for all points. :param cmap: Name of a matplotlib colormap to use when ``label_type == 'scalar'``. :param center_coordinate: If *True* centre the coordinates of every slice at (0, 0). :param gridspec_kws: Extra keyword arguments passed to ``plt.subplots`` via the ``gridspec_kw`` parameter. :param return_palette: If *True* the colour mapping used for plotting is returned alongside the figure. :param save_show_or_return: One of ``'save'``, ``'show'``, ``'return'`` or ``'both'`` / ``'all'`` – forwarded to :func:`save_return_show_fig_utils`. :param save_kwargs: Extra keyword arguments for saving. :param sort_values: Only relevant for scalar plots. If *True* the points are rendered in order of ``label_key`` (after sorting) so that points with higher (or lower) values are drawn on top. :param sort_ascending: Sort direction used when ``sort_values`` is *True* (ascending ⇢ smaller values on top). :param \*\*kwargs: Additional keyword arguments forwarded to :func:`matplotlib.pyplot.scatter`. :returns: * Depending on ``save_show_or_return`` either a :class:`matplotlib.figure.Figure` * object, ``None`` (when the figure is saved/shown directly), or a tuple * *containing both the figure and the palette.* .. py:function:: overlay_slices_2d(slices: Union[anndata.AnnData, List[anndata.AnnData]], slices_key: Optional[Union[bool, str]] = None, label_key: Optional[str] = None, overlay_type: Literal['forward', 'backward', 'both'] = 'both', spatial_key: str = 'spatial', point_size: Optional[float] = None, n_sampling: int = -1, palette: Optional[dict] = None, ncols: int = 4, title: str = '', title_kwargs: Optional[dict] = None, show_legend: bool = True, legend_kwargs: Optional[dict] = None, axis_off: bool = False, axis_kwargs: Optional[dict] = None, ticks_off: bool = True, x_min=None, x_max=None, y_min=None, y_max=None, height: float = 2, alpha: float = 1.0, cmap='tab20', center_coordinate: bool = False, gridspec_kws: Optional[dict] = None, save_show_or_return: Literal['save', 'show', 'return', 'both', 'all'] = 'show', save_kwargs: Optional[dict] = None, **kwargs) .. py:function:: optimization_animation(aligned_slices: List[anndata.AnnData], label_key: Optional[str] = None, spatial_key: str = 'spatial', key_added: str = 'align_spatial', iter_key_added: Optional[str] = 'iter_spatial', filename: Optional[str] = 'Visualization2D', fps: int = 10, stepsize: int = 10, cmap='Set1', palette: Optional[dict] = None, point_size: Optional[float] = None, n_sampling: int = -1) .. py:function:: plot_deformation_grid(adata, spatial_key, origin_spatial_key, label_key, predict_func, ax, point_size, grid_num=10, line_width=0.5, grid_color='black', expand_scale=0.1, palette=None, title='', legend=True, fontsize=8, fill=False) .. py:function:: multi_slices(slices: Union[anndata.AnnData, List[anndata.AnnData]], slices_key: Optional[str] = None, label: Optional[str] = None, spatial_key: str = 'align_spatial', layer: str = 'X', point_size: Optional[float] = None, font_size: Optional[float] = 20, color: Optional[str] = 'skyblue', palette: Optional[str] = None, alpha: float = 1.0, ncols: int = 4, ax_height: float = 1, dpi: int = 100, show_legend: bool = True, save_show_or_return: Literal['save', 'show', 'return', 'both', 'all'] = 'show', save_kwargs: Optional[dict] = None, **kwargs) .. py:function:: _agenerate_palette(*labels, cmap='tab20') .. py:function:: _compute_smallest_distance(spatial_coord1, spatial_coord2, direction='x', scale_factor=1.1) .. py:function:: transform_by_min_max(x, _min, _max, interval=0.1) .. py:function:: get_min_max(x) .. py:function:: transform_H(x, H, z_shift=0) .. py:function:: get_H(h=0.5, w=0.2)