spateo.plotting.static.three_d_plot.align_plots#

Module Contents#

Functions#

_check_cpos_in_multi_plot(models[, window_size, cpo])

multi_models(*adata[, layer, group_key, spatial_key, ...])

Visualize multiple models separately in one figure.

deformation(*adata, deformed_grid[, layer, group_key, ...])

spateo.plotting.static.three_d_plot.align_plots._check_cpos_in_multi_plot(models: List, window_size: tuple | None = None, cpo: str | list = 'xy')[source]#
spateo.plotting.static.three_d_plot.align_plots.multi_models(*adata: anndata.AnnData, layer: str = 'X', group_key: str | list = None, spatial_key: str = 'align_spatial', id_key: str = 'slices', mode: Literal[single, overlap, both] = 'single', center_zero: bool = False, filename: str | None = None, jupyter: bool | Literal[none, static, trame] = False, off_screen: bool = False, cpo: str | list = 'xy', shape: str | list | tuple = None, window_size: tuple | None = None, background: str = 'white', colormap: str | list | dict = 'red', overlap_cmap: str | list | dict = 'dodgerblue', alphamap: float | list | dict = 1.0, overlap_amap: float | list | dict = 0.5, ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_size: float | list = 3.0, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, **kwargs)[source]#

Visualize multiple models separately in one figure.

Parameters:
*adata

A list of models[Anndata object].

layer

If 'X', uses .X, otherwise uses the representation given by .layers[layer].

group_key

The key that stores clustering or annotation information in .obs, a gene name or a list of gene names in .var.

spatial_key

The key in .obsm that corresponds to the spatial coordinate of each bucket.

id_key

The key in .obs that corresponds to the model id of each bucket.

mode

Three modes of visualization. Available mode are:

  • 'single' - Visualize each model individually.

  • 'overlap' - Simultaneously visualize two models aligned front to back in one subplot.

  • 'both' - Simultaneously visualize both types above.

center_zero

Whether to move the center point of the model to the (0, 0, 0).

filename

Filename of output file. Writer type is inferred from the extension of the filename.

  • Output an image file,please enter a filename ending with '.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'. When jupyter=False, if you want to save ‘.png’ file, please ensure off_screen=True.

jupyter

Whether to plot in jupyter notebook. Available jupyter are:

  • 'none' - Do not display in the notebook.

  • 'trame' - Show a trame widget

  • 'static' - Display a static figure.

off_screen

Renders off-screen when True. Useful for automated screenshots.

cpo

Camera position of the active render window. Available cpo are:

  • Iterable containing position, focal_point, and view up.

    E.g.: [(2.0, 5.0, 13.0), (0.0, 0.0, 0.0), (-0.7, -0.5, 0.3)].

  • Iterable containing a view vector.

    E.g.: [-1.0, 2.0, -5.0].

  • A string containing the plane orthogonal to the view direction.

    E.g.: 'xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'.

shape

Number of sub-render windows inside the main window. By default, there is only one render window.

  • Specify two across with ``shape``=(2, 1) and a two by two grid with ``shape``=(2, 2).

  • shape Can also accept a string descriptor as shape.

    E.g.: shape="3|1" means 3 plots on the left and 1 on the right, E.g.: shape="4/2" means 4 plots on top and 2 at the bottom.

window_size

Window size in pixels. The default window_size is [512, 512].

background

The background color of the window.

colormap

Colors to use for plotting pc. The default colormap is 'dodgerblue'.

overlap_cmap

Colors to use for plotting overlapped pc. The default colormap is 'red'.

alphamap

The opacity of the colors to use for plotting pc. The default alphamap is 1.0.

overlap_amap

The opacity of the colors to use for plotting overlapped pc. The default alphamap is .5.

ambient

When lighting is enabled, this is the amount of light in the range of 0 to 1 (default 0.0) that reaches the actor when not directed at the light source emitted from the viewer.

opacity

Opacity of the model.

If a single float value is given, it will be the global opacity of the model and uniformly applied everywhere, elif a numpy.ndarray with single float values is given, it will be the opacity of each point. - should be between 0 and 1.

A string can also be specified to map the scalars range to a predefined opacity transfer function (options include: ‘linear’, ‘linear_r’, ‘geom’, ‘geom_r’).

model_size

The point size of any nodes in the dataset plotted.

show_axes

Whether to add a camera orientation widget to the active renderer.

show_legend

whether to add a legend to the plotter.

legend_kwargs

A dictionary that will be pass to the add_legend function.

By default, it is an empty dictionary and the add_legend function will use the {"legend_size": None, "legend_loc": None,  "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True} as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.

text

The text to add the rendering.

text_kwargs

A dictionary that will be pass to the add_text function.

By default, it is an empty dictionary and the add_legend function will use the { "font_family": "arial", "font_size": 12, "font_color": "black", "text_loc": "upper_left"} as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.

**kwargs

Additional parameters that will be passed to three_d_multi_plot function.

spateo.plotting.static.three_d_plot.align_plots.deformation(*adata: anndata.AnnData, deformed_grid: pyvista.PolyData | List[pyvista.PolyData], layer: str = 'X', group_key: str | list = None, spatial_key: str = 'align_spatial', id_key: str = 'slices', deformation_key: str | None = 'deformation', center_zero: bool = False, show_model: bool = True, filename: str | None = None, jupyter: bool | Literal[none, static, trame] = False, off_screen: bool = False, cpo: str | list = 'xy', shape: str | list | tuple = None, window_size: tuple | None = (1024, 756), background: str = 'white', model_color: str | list = 'red', model_alpha: float | list | dict = 1, colormap: str | list | dict = 'black', alphamap: float | list | dict = 1.0, ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, grid_size: float | list = 2.0, model_size: float | list = 3.0, show_axes: bool = True, show_legend: bool = False, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, **kwargs)[source]#