spateo.plotting.static.three_d_plot.pairwise_align_plots¶
Functions¶
|
Visualize a heatmap of the pi matrix. |
|
Visualize the pairing of cells between two models. |
|
Visualize the results of each iteration in the alignment process. |
|
Module Contents¶
- spateo.plotting.static.three_d_plot.pairwise_align_plots.pi_heatmap(pi: numpy.ndarray, model1_name: str = 'model1', model2_name: str = 'model2', colormap: str = 'hot_r', fig_height: int | float = 3, robust: bool = False, vmin: int | float | None = None, vmax: int | float | None = None, fontsize: int | float = 12, filename: str | None = None, **kwargs)[source]¶
Visualize a heatmap of the pi matrix.
- Parameters:
- pi
The pi matrix obtained by alignment.
- model1_name
The name/id of model1.
- model2_name
The name/id of model2.
- colormap
Colors to use for plotting heatmap. The default colormap is
'hot_r'
.- fig_height
Figure height.
- robust
If True and vmin or vmax are absent, the colormap range is computed with robust quantiles instead of the extreme values.
- vmin
Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments.
- vmax
Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments.
- fontsize
The font size of x label and y label.
- filename
Filename of output file.
- **kwargs
Additional parameters that will be passed to
sns.heatmap
function.
- spateo.plotting.static.three_d_plot.pairwise_align_plots.pairwise_mapping(idA: str = 'sampleA', idB: str = 'sampleB', adataA: anndata.AnnData | None = None, adataB: anndata.AnnData | None = None, pi: numpy.ndarray | None = None, modelA: pyvista.PolyData | None = None, modelB: pyvista.PolyData | None = None, model_lines: pyvista.PolyData | None = None, layer: str = 'X', group_key: str | list = None, spatial_key: str = 'align_spatial', keep_all: bool = False, distance: int | float | None = 300, direction: Literal['x', 'y', 'z'] | None = 'z', filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, cpo: str | list | None = 'iso', window_size: tuple | None = (1024, 1024), background: str = 'black', modelA_cmap: str = 'dodgerblue', modelA_amap: float | list = 1.0, modelB_cmap: str = 'red', modelB_amap: float | list = 1.0, line_color: str = 'gainsboro', line_alpha: float | list = 1.0, ambient: float = 0.3, model_opacity: float = 1, line_opacity: float = 0.03, model_size: float | list = 6.0, line_size: float | list = 2.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 the pairing of cells between two models.
- Parameters:
- idA
ID of modelA.
- idB
ID of modelB.
- adataA
Anndata object of modelA.
- adataB
Anndata object of modelB.
- pi
The pi matrix obtained by alignment.
- modelA
The point cloud model of adataA.
- modelB
The point cloud model of adataB.
- model_lines
Cell connection lines between modelA and modelB
- 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.- keep_all
Whether to retain all the optimal relationships obtained only based on the pi matrix, If
keep_all
is False, the optimal relationships obtained based on the pi matrix and the nearest coordinates.- distance
Distance between modelA and modelB when visualizing.
- direction
The direction between modelA and modelB when visualizing.
- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_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'.
- window_size
Window size in pixels. The default window_size is
(1024, 1024)
.- background
The background color of the window.
- modelA_cmap
Colors to use for plotting modelA. The default colormap is
'dodgerblue'
.- modelA_amap
The opacity of the colors to use for plotting modelA. The default alphamap is
1.0
.- modelB_cmap
Colors to use for plotting modelB. The default colormap is
'red'
.- modelB_amap
The opacity of the colors to use for plotting modelB. The default alphamap is
1.0
.- line_color
Colors to use for plotting lines. The default colormap is
'gainsboro'
.- line_alpha
Alpha to use for plotting lines. The default colormap is
'gainsboro'
.- 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.
- model_opacity
Opacity of the modelA and modelB.
- line_opacity
Opacity of the lines.
- model_size
The point size of any nodes in the dataset plotted.
- line_size
The line size of lines 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_plot
function.
- Returns:
The point cloud models of adataA. pcB: The point cloud models of adataB. model_lines: Cell mapping lines between modelA and modelB.
- Return type:
pcA
- spateo.plotting.static.three_d_plot.pairwise_align_plots.pairwise_iteration(adataA: anndata.AnnData, adataB: anndata.AnnData, layer: str = 'X', group_key: str | list = None, spatial_key: str = 'align_spatial', iter_key: str = 'iter_spatial', id_key: str = 'slices', filename: str = 'animate.mp4', jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, cpo: str | list | None = None, window_size: tuple | None = None, background: str = 'black', modelA_cmap: str = 'dodgerblue', modelB_cmap: str = 'red', ambient: int | float = 0.3, modelA_opacity: int | float = 0.8, modelB_opacity: int | float = 1.0, model_size: float | list = 6.0, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, framerate: int = 6, **kwargs)[source]¶
Visualize the results of each iteration in the alignment process.
- Parameters:
- adataA
Anndata object of modelA.
- adataB
Anndata object of modelB.
- 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.- iter_key
The key in
.uns
that corresponds to the result of each iteration of the iterative process.- id_key
The key in
.obs
that corresponds to the model id of each bucket.- filename
Filename of output file. Writer type is inferred from the extension of the filename.
Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- 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'.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- modelA_cmap
Colors to use for plotting modelA. The default colormap is
'dodgerblue'
.- modelB_cmap
Colors to use for plotting modelB. The default colormap is
'red'
.- 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.
- modelA_opacity
Opacity of the modelA.
- modelB_opacity
Opacity of the modelB.
- 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.- framerate
Frames per second.
- **kwargs
Additional parameters that will be passed to
three_d_animate
function.
- spateo.plotting.static.three_d_plot.pairwise_align_plots.pairwise_iteration_panel(adataA: anndata.AnnData, adataB: anndata.AnnData, layer: str = 'X', group_key: str | list = None, select_group: str | list = None, spatial_key: str = 'align_spatial', iter_key: str = 'iter_spatial', filename: str = 'animate.mp4', jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, id_key: str | None = None, cpo: str | list | None = None, window_size: tuple | None = None, background: str = 'black', modelA_cmap: str = 'dodgerblue', modelB_cmap: str = 'red', ambient: int | float = 0.3, modelA_opacity: int | float = 0.8, modelB_opacity: int | float = 1.0, model_size: float | list = 6.0, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, framerate: int = 6, **kwargs)[source]¶