spateo.plotting.static
#
Spatiotemporal modeling of spatial transcriptomics
Subpackages#
Submodules#
spateo.plotting.static.agg
spateo.plotting.static.align
spateo.plotting.static.bbs
spateo.plotting.static.colorlabel
spateo.plotting.static.contour
spateo.plotting.static.dotplot
spateo.plotting.static.geo
spateo.plotting.static.glm
spateo.plotting.static.interactions
spateo.plotting.static.lisa
spateo.plotting.static.polarity
spateo.plotting.static.position
spateo.plotting.static.scatters
spateo.plotting.static.space
spateo.plotting.static.utils
Package Contents#
Functions#
|
Indicate selected QC regions with boxes on the full tissue. |
|
Display raw data within an AnnData. |
|
Display QC regions. |
|
|
|
Plot the Delaunay triangulation result. |
|
Plot the polygon identified by the alpha hull method. |
|
Color the segmented cells with different colors. |
|
Generate an image with contours of each spatial domains. |
|
Makes a dot plot of the expression values of var_names. For each var_name and each groupby category a dot |
Plotting functions for spatial geometry plots. |
|
|
Visualize the glm_degs result. |
|
Dotplot for visualizing results of ligand-receptor interaction analysis |
|
Plot spatial_connections between labels- visualization of how closely labels are colocalized |
|
Create a plot with four panels. The first one is for the raw lisa (Local Indicators of Spatial Association ) |
|
Scatterplot of the gene expression and its spatial lag. Categorization into the four regions (HH, HL, LH, LL) is |
|
Simple function to visualize expression level varies along regions. |
|
Visualize the torsion result. |
|
Add a legend to the plotter. |
|
Add model(s) to the plotter. |
|
Produce an outline of the full extent for the model. |
|
Add text to the plotter. |
|
Create a plotting object to display pyvista/vtk model. |
|
Visualize the curl result. |
|
Visualize the curvature result. |
|
Visualize the divergence result. |
|
Visualize the jacobian result. |
|
Use MoviePy to compose a new animation and play multiple animations together in the new animation. |
|
Output plotter as image, gif file or mp4 file. |
|
Save plotter as gltf file, html file, obj file or vtkjs file. |
|
Animated visualization of 3D reconstruction model. |
|
Multi-view visualization of reconstructed 3D model. |
|
Visualize the torsion result. |
- spateo.plotting.static.box_qc_regions(adata: anndata.AnnData, layer: str = SKM.X_LAYER, use_scale: bool = True, box_kwargs: Optional[Dict] = None, ax: Optional[matplotlib.axes.Axes] = None, background: Optional[str] = None, save_show_or_return: typing_extensions.Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[Dict] = None, **kwargs)[source]#
Indicate selected QC regions with boxes on the full tissue.
- Parameters
- adata
Input Anndata
- layer
Layer to display
- use_scale
Whether or not to plot in physical units. Only valid when appropriate scale keys are present in .uns
- box_kwargs
Keyword arguments to pass to
patches.Rectangle()
. By default, the boxes will be transparent with red outlines of 1 point thickness.- ax
Axes to plot.
- background
string or None (optional, default ‘None`) The color of the background. Usually this will be either ‘white’ or ‘black’, but any color name will work. Ideally one wants to match this appropriately to the colors being used for points etc. This is one of the things that themes handle for you. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.
- save_show_or_return
Whether to save, show or return the figure. If “both”, it will save and plot the figure at the same time. If “all”, the figure will be saved, displayed and the associated axis and other object will be return.
- save_kwargs
A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise you can provide a dictionary that properly modify those keys according to your needs.
- **kwargs
Additional keyword arguments are all passed to
imshow()
.
- spateo.plotting.static.imshow(adata: anndata.AnnData, layer: str = SKM.X_LAYER, ax: Optional[matplotlib.axes.Axes] = None, show_cbar: bool = False, use_scale: bool = True, absolute: bool = False, labels: bool = False, downscale: float = 1.0, downscale_interpolation: Optional[int] = None, background: Optional[str] = None, save_show_or_return: typing_extensions.Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[Dict] = None, **kwargs) Optional[Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]] [source]#
Display raw data within an AnnData.
- Parameters
- adata
Anndata containing aggregated UMI counts.
- layer
Layer to display. Defaults to X.
- ax
Axes to plot.
- show_cbar
Whether or not to show a colorbar next to the plot.
- use_scale
Whether or not to plot in physical units. Only valid when appropriate scale keys are present in .uns
- absolute
Whether to set the axes to be in absolute coordinates. By default, relative coordinates are used (i.e. the axes start at zero).
- labels
Whether the input data contains labels, encoded as positive integers.
- downscale
Downscale image by this amount for faster plotting.
- downscale_interpolation
Use this CV2 interpolation method when downscaling. By default, bilinear interpolation is used when labels=True and nearest neighbor interpolation when labels=False. Available options are located here: https://docs.opencv.org/3.4/da/d54/group__imgproc__transform.html#ga5bb5a1fea74ea38e1a5445ca803ff121 Only has an effect when downscale < 1.
- background
string or None (optional, default ‘None`) The color of the background. Usually this will be either ‘white’ or ‘black’, but any color name will work. Ideally one wants to match this appropriately to the colors being used for points etc. This is one of the things that themes handle for you. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.
- save_show_or_return
Whether to save, show or return the figure. If “both”, it will save and plot the figure at the same time. If “all”, the figure will be saved, displayed and the associated axis and other object will be return.
- save_kwargs
A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise you can provide a dictionary that properly modify those keys according to your needs.
- **kwargs
Additional keyword arguments are all passed to
imshow()
.
- Returns
The figure and axis if ax is not provided.
- spateo.plotting.static.qc_regions(adata: anndata.AnnData, layer: str = SKM.X_LAYER, axes: Optional[numpy.ndarray] = None, ncols: int = 1, background: Optional[str] = None, save_show_or_return: typing_extensions.Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[Dict] = None, **kwargs) Optional[Tuple[matplotlib.figure.Figure, numpy.ndarray]] [source]#
Display QC regions.
- Parameters
- adata
Input Anndata
- layer
Layer to display
- axes
Numpy array (possibly 2D) of Matplotlib axes to plot each region. This option is useful when trying to overlay multiple layers together.
- ncols
Number of columns when displaying multiple panels.
- background
string or None (optional, default ‘None`) The color of the background. Usually this will be either ‘white’ or ‘black’, but any color name will work. Ideally one wants to match this appropriately to the colors being used for points etc. This is one of the things that themes handle for you. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.
- save_show_or_return
Whether to save, show or return the figure. If “both”, it will save and plot the figure at the same time. If “all”, the figure will be saved, displayed and the associated axis and other object will be return.
- save_kwargs
A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise you can provide a dictionary that properly modify those keys according to your needs.
- **kwargs
Additional keyword arguments are all passed to
imshow()
.
- Returns
The figure and axes if axes is not provided.
- spateo.plotting.static.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)[source]#
- spateo.plotting.static.delaunay(edge_points, figsize: Union[Tuple, List] = (10, 10), pc: str = '#f16824', title: Optional[str] = None, fig: Optional[matplotlib.figure.Figure] = None, ax: Optional[matplotlib.axes.Axes] = None, background: Optional[str] = None, save_show_or_return: typing_extensions.Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[Dict] = None)[source]#
Plot the Delaunay triangulation result.
- Parameters
- edge_points
- figsize
The size of the figure
- fc
The color of the scatter points.
- title
The title of the figure.
- fig
The matplotlib.figure figure object of the figure.
- ax
The matplotlib.axes._subplots AxesSubplot object of the figure.
- background
string or None (optional, default ‘None`) The color of the background. Usually this will be either ‘white’ or ‘black’, but any color name will work. Ideally one wants to match this appropriately to the colors being used for points etc. This is one of the things that themes handle for you. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.
- save_show_or_return
Whether to save, show or return the figure. If “both”, it will save and plot the figure at the same time. If “all”, the figure will be saved, displayed and the associated axis and other object will be return.
- save_kwargs
A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise you can provide a dictionary that properly modify those keys according to your needs.
- Returns
The matplotlib.figure figure object of the figure. ax: The matplotlib.axes._subplots AxesSubplot object of the figure.
- Return type
fig
- spateo.plotting.static.polygon(concave_hull: Union[shapely.geometry.MultiPolygon, shapely.geometry.Polygon], figsize: Union[Tuple, List] = (10, 10), margin: float = 0.3, fc: str = '#999999', ec: str = '#000000', fig: Optional[matplotlib.figure.Figure] = None, ax: Optional[matplotlib.axes.Axes] = None, background: Optional[str] = None, save_show_or_return: typing_extensions.Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[Dict] = None)[source]#
Plot the polygon identified by the alpha hull method.
- Parameters
- concave_hull
The identified polygon (or multi-polygon) returned from the alpha_shape method or other methods.
- figsize
The size of the figure
- margin
The margin of the figure Axes.
- fc
The facecolor of the PolygonPatch.
- ec
The edgecolor of the PolygonPatch.
- background
string or None (optional, default ‘None`) The color of the background. Usually this will be either ‘white’ or ‘black’, but any color name will work. Ideally one wants to match this appropriately to the colors being used for points etc. This is one of the things that themes handle for you. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.
- save_show_or_return
Whether to save, show or return the figure. If “both”, it will save and plot the figure at the same time. If “all”, the figure will be saved, displayed and the associated axis and other object will be return.
- save_kwargs
A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise you can provide a dictionary that properly modify those keys according to your needs.
- Returns
The matplotlib.figure figure object of the figure. ax: The matplotlib.axes._subplots AxesSubplot object of the figure.
- Return type
fig
- spateo.plotting.static.color_label(adata: anndata.AnnData, basis='contour', color_key: Optional[list] = None, dpi: int = 100, boundary_width: float = 0.2, boundary_color='black', figsize=(6, 6), aspect: str = 'equal', *args, **kwargs)[source]#
Color the segmented cells with different colors.
- Parameters
- adata
~anndata.AnnData An Annodata object.
- basis
str The key to the column in the adata.obs, from which the contour of the cell segmentation will be generated.
- color_key
list List of colors. If the number of labels exceeds the number of colors, then the colors are cycled.
- dpi
float, (default: 100.0) The resolution of the figure in dots-per-inch. Dots per inches (dpi) determines how many pixels the figure comprises. dpi is different from ppi or points per inches. Note that most elements like lines, markers, texts have a size given in points so you can convert the points to inches. Matplotlib figures use Points per inch (ppi) of 72. A line with thickness 1 point will be 1./72. inch wide. A text with fontsize 12 points will be 12./72. inch height. Of course if you change the figure size in inches, points will not change, so a larger figure in inches still has the same size of the elements.Changing the figure size is thus like taking a piece of paper of a different size. Doing so, would of course not change the width of the line drawn with the same pen. On the other hand, changing the dpi scales those elements. At 72 dpi, a line of 1 point size is one pixel strong. At 144 dpi, this line is 2 pixels strong. A larger dpi will therefore act like a magnifying glass. All elements are scaled by the magnifying power of the lens. see more details at answer 2 by @ImportanceOfBeingErnest: https://stackoverflow.com/questions/47633546/relationship-between-dpi-and-figure-size
- boundary_width
float, (default: 0.2) The line width of boundary.
- boundary_color
(default: “black”) The color value of boundary.
- figsize
tuple The size of the figure in inches.
- aspect
str Set the aspect of the axis scaling, i.e. the ratio of y-unit to x-unit. In physical spatial plot, the default is ‘equal’. See more details at: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_aspect.html
- spateo.plotting.static.spatial_domains(adata: anndata.AnnData, bin_size: Optional[int] = None, spatial_key: str = 'spatial', label_key: str = 'cluster_img_label', plot_size=(3, 3), save_img='spatial_domains.png')[source]#
Generate an image with contours of each spatial domains.
- Parameters
- adata
The adata object used to create the image.
- bin_size
The size of the binning. Default to None.
- spatial_key
The key name of the spatial coordinates. Default to “spatial”.
- label_key
The key name of the image label values. Default to “cluster_img_label”.
- plot_size
figsize for showing the image.
- save_img
path to saving image file.
- spateo.plotting.static.dotplot(adata: anndata.AnnData, var_names: Sequence[str], cat_key: Union[str, Sequence[str]], num_categories: int = 7, cell_cell_dp: bool = False, delta: Union[None, float] = None, minn: Union[None, float] = None, alpha: Union[None, float] = None, prescale_adata: bool = False, expression_cutoff: float = 0.0, mean_only_expressed: bool = False, cmap: str = 'Reds', dot_max: float = Dotplot.default_dot_max, dot_min: float = Dotplot.default_dot_min, standard_scale: Literal[var, group] = None, smallest_dot: float = Dotplot.default_smallest_dot, largest_dot: float = Dotplot.default_largest_dot, title: str = None, colorbar_title: str = Dotplot.default_color_legend_title, size_title: str = Dotplot.default_size_legend_title, figsize: Union[None, Tuple[float, float]] = None, dendrogram: Union[bool, str] = False, gene_symbols_key: Union[None, str] = None, var_group_positions: Union[None, Sequence[Tuple[int, int]]] = None, var_group_labels: Union[None, Sequence[str]] = None, var_group_rotation: Union[None, float] = None, layer: Union[None, str] = None, swap_axes: bool = False, dot_color_df: Union[None, pandas.DataFrame] = None, save_show_or_return: Literal[save, show, return, both, all] = 'save', save_kwargs: dict = {}, ax: Union[None, matplotlib.axes.Axes] = None, vmin: Union[None, float] = None, vmax: Union[None, float] = None, vcenter: Union[None, float] = None, norm: Union[None, matplotlib.colors.Normalize] = None, **kwargs)[source]#
Makes a dot plot of the expression values of var_names. For each var_name and each groupby category a dot is plotted. Each dot represents two values: mean expression within each category (visualized by color) and fraction of cells expressing the var_name in the category (visualized by the size of the dot). If groupby is not given, the dotplot assumes that all data belongs to a single category.
- Parameters
- adata
object of class anndata.AnnData
- var_names
Should be a subset of adata.var_names
- cat_key
The key(s) in .obs of the grouping to consider. Should be a categorical observation; if not, will be subdivided into ‘num_categories’.
- num_categories
Only used if groupby observation is not categorical. This value determines the number of groups into which the groupby observation should be subdivided.
- cell_cell_dp
Set True to initialize specialized cell-cell dotplot instead of gene expression dotplot
- delta
Only used if ‘cell_cell_dp’ is True- distance between the largest value to consider and the smallest value to consider (see ‘minn’ parameter below)
- minn
Only used if ‘cell_cell_dp’ is True- for the dot size legend, sets the value corresponding to the smallest dot on the legend
- alpha
Only used if ‘cell_cell_dp’ is True- significance threshold. If given, all elements w/ p-values <= ‘alpha’ will be marked by rings instead of dots.
- prescale_adata
Set True to indicate that AnnData object should be scaled- if so, will use ‘delta’ and ‘minn’ to do so. If False, will proceed as though adata has already been processed as needed.
- expression_cutoff
Used for binarizing feature expression- feature is considered to be expressed only if the expression value is greater than this threshold
- mean_only_expressed
If True, gene expression is averaged only over the cells expressing the given features
- cmap
Name of Matplotlib color map to use
- dot_max
If none, the maximum dot size is set to the maximum fraction value found (e.g. 0.6). If given, the value should be a number between 0 and 1. All fractions larger than dot_max are clipped to this value.
- dot_min
If none, the minimum dot size is set to 0. If given, the value should be a number between 0 and 1. All fractions smaller than dot_min are clipped to this value.
- standard_scale
Whether or not to standardize that dimension between 0 and 1, meaning for each variable or group, subtract the minimum and divide each by its maximum. ‘val’ or ‘group’ is used to specify whether this should be done over variables or groups.
- smallest_dot
If None, the smallest dot has size 0. All expression fractions with dot_min are plotted with this size.
- largest_dot
If None, the largest dot has size 200. All expression fractions with dot_max are plotted with this size.
- title
Title for the entire plot
- colorbar_title
Title for the color legend. If None will use generic default title
- size_title
Title for the dot size legend. If None will use generic default title
- figsize
Sets width and height of figure window
- dendrogram
If True, adds dendrogram to plot. Will do the same thing if string is given here, but will recompute dendrogram and save using this argument to set key in .uns.
- gene_symbols_key
Key in .var containing gene symbols
- var_group_positions
Each item in the list should contain the start and end position that the bracket should cover. Eg. [(0, 4), (5, 8)] means that there are two brackets, one for the var_names in positions 0-4 and other for positions 5-8
- var_group_labels
List of group labels for the variable names (e.g. can group var_names in positions 0-4 as being “group A”)
- var_group_rotation
Rotation in degrees of the variable name labels. If not given, small labels (<4 characters) are not rotated, but otherwise labels are rotated 90 degrees.
- layer
Key in .layers specifying layer to use. If not given, will use .X.
- swap_axes
Set True to switch what is plotted on the x- and y-axes
- dot_color_df
Pre-prepared dataframe with features as indices, categories as columns, and indices corresponding to color intensities
- save_show_or_return
Options: “save”, “show”, “return”, “both”, “all” - “both” for save and show
- save_kwargs
A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. But to change any of these parameters, this dictionary can be used to do so.
- ax
Pre-initialized axis object to plot on
- vmin
The data value that defines 0.0 in the normalization. Defaults to the min value of the dataset.
- vmax
The data value that defines 1.0 in the normalization. Defaults to the the max value of the dataset.
- vcenter
The data value that defines 0.5 in the normalization
- norm
Optional already-initialized normalizing object that scales data, typically into the interval [0, 1], for the purposes of mapping to color intensities for plotting. Do not pass both ‘norm’ and ‘vmin’/’vmax’, etc.
- kwargs
Additional keyword arguments passed to
matplotlib.pyplot.scatter()
- Returns
Instantiated Figure object- only if ‘return’ is True axes: Instantiated Axes object- only if ‘return’ is True
- Return type
fig
- spateo.plotting.static.geo(adata: anndata.AnnData, basis: str = 'contour', color: Union[list, str, None] = None, genes: Union[list, None] = [], gene_cmaps: Optional[str] = None, dpi: int = 100, alpha: float = 0.8, boundary_width: float = 0.2, boundary_color='black', stack_genes: bool = False, stack_genes_threshold: float = 0.01, stack_colors_legend_size: int = 10, figsize: Tuple[float, float] = (6, 6), aspect: str = 'equal', slices: Optional[int] = None, img_layers: Optional[int] = None, *args, **kwargs)#
Geometry plot for physical coordinates of each cell.
- Parameters
- adata
an Annodata object that contain the physical coordinates for each bin/cell, etc.
- basis
The key to the column in the adata.obs, from which the contour of the cell segmentation will be generated.
- color
Any or any list of column names or gene name, etc. that will be used for coloring cells. If color is not None, stack_genes will be disabled automatically because color can contain non numerical values.
- genes
The gene list that will be used to plot the gene expression on the same scatter plot. Each gene will have a different color. Can be a single gene name string and we will convert it to a list.
- gene_cmaps
The colormap used to stack different genes in a single plot.
- dpi
The resolution of the figure in dots-per-inch. Dots per inches (dpi) determines how many pixels the figure comprises. dpi is different from ppi or points per inches. Note that most elements like lines, markers, texts have a size given in points so you can convert the points to inches. Matplotlib figures use Points per inch (ppi) of 72. A line with thickness 1 point will be 1./72. inch wide. A text with fontsize 12 points will be 12./72. inch height. Of course if you change the figure size in inches, points will not change, so a larger figure in inches still has the same size of the elements.Changing the figure size is thus like taking a piece of paper of a different size. Doing so, would of course not change the width of the line drawn with the same pen. On the other hand, changing the dpi scales those elements. At 72 dpi, a line of 1 point size is one pixel strong. At 144 dpi, this line is 2 pixels strong. A larger dpi will therefore act like a magnifying glass. All elements are scaled by the magnifying power of the lens. see more details at answer 2 by @ImportanceOfBeingErnest: https://stackoverflow.com/questions/47633546/relationship-between-dpi-and-figure-size
- alpha
The alpha value of the cells.
- boundary_width
The line width of boundary.
- boundary_color
The color value of boundary.
- stack_genes
whether to show all gene plots on the same plot
- stack_genes_threshold
lower bound of gene values that will be drawn on the plot.
- stack_colors_legend_size
control the size of legend when stacking genes
- figuresize
size of the figure.
- aspect
Set the aspect of the axis scaling, i.e. the ratio of y-unit to x-unit. In physical spatial plot, the default is ‘equal’. See more details at: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_aspect.html
- slices
The index to the tissue slice, will used in adata.uns[“spatial”][slices].
- img_layers
The index to the (staining) image of a tissue slice, will be used in adata.uns[“spatial”][slices][“images”].
- Returns
plots gene or cell feature of the adata object on the physical spatial coordinates.
- spateo.plotting.static.glm_fit(adata: anndata.AnnData, gene: Union[str, list] = None, feature_x: str = None, feature_y: Optional[str] = 'expression', feature_fit: Optional[str] = 'mu', glm_key: str = 'glm_degs', lowess: bool = False, frac: float = 0.1, show_ci: bool = True, show_legend: bool = True, point_size: float = 1, point_color: Union[str, numpy.ndarray, list] = 'skyblue', line_size: float = 1, line_color: str = 'black', ci_color: str = 'gainsboro', ci_alpha: float = 0.7, ax_size: Union[tuple, list] = (3, 3), background_color: str = 'white', ncols: int = 4, save_show_or_return: Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[dict] = None, **kwargs)[source]#
Visualize the glm_degs result.
- Parameters
- adata
An Anndata object contain glm_degs result in
.uns[glm_key]
.- gene
A gene name or a list of genes that will be used to plot.
- feature_x
The key in
.uns[glm_key]['correlation'][gene]
that corresponds to the independent variables, such as'torsion'
, etc.- feature_y
The key in
.uns[glm_key]['correlation'][gene]
that corresponds to the dependent variables, such as'expression'
, etc.- feature_fit
The key in
.uns[glm_key]['correlation'][gene]
that corresponds to the fitted values, such as'mu'
, etc.- glm_key
The key in
.uns
that corresponds to the glm_degs result.- lowess
Locally Weighted Scatter-plot Smoothing. Whether to use the lowess function on the feature_y value.
- frac
Between 0 and 1. The fraction of the data used when estimating each feature_y-value. Only valid when
lowess
is True.- show_ci
Whether to show the confidence interval.
- show_legend
Whether to show the legend.
- point_size
The scale of the feature_y point size.
- point_color
The color of the feature_y point.
- line_size
The scale of the fitted line width.
- line_color
The color of the fitted line.
- ci_color
The color of the confidence interval.
- ci_alpha
The transparency of the ci_color.
- ax_size
The width and height of each ax.
- background_color
The background color of the figure.
- ncols
Number of columns for the figure.
- save_show_or_return
If
'both'
, it will save and plot the figure at the same time.If
'all'
, the figure will be saved, displayed and the associated axis and other object will be return.- save_kwargs
A dictionary that will be passed to the save_fig function.
By default, it is an empty dictionary and the save_fig function will use the
{"path": None, "prefix": 'scatter', "dpi": None, "ext": 'pdf', "transparent": True, "close": True, "verbose": True}
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 into the
statsmodels.nonparametric.smoothers_lowess.lowess
function.
- spateo.plotting.static.ligrec(adata: anndata.AnnData, dict_key: str, source_groups: Union[None, str, List[str]] = None, target_groups: Union[None, str, List[str]] = None, means_range: Tuple[float, float] = (-np.inf, np.inf), pvalue_threshold: float = 1.0, remove_empty_interactions: bool = True, remove_nonsig_interactions: bool = False, dendrogram: Union[None, str] = None, alpha: float = 0.001, swap_axes: bool = False, title: Union[None, str] = None, figsize: Union[None, Tuple[float, float]] = None, save_show_or_return: Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[ligrec.dict] = {}, **kwargs)[source]#
Dotplot for visualizing results of ligand-receptor interaction analysis
For each L:R pair on the dotplot, molecule 1 is sent from the cluster(s) labeled on the top of the plot (or on the right, if ‘swap_axes’ is True), whereas molecule 2 is the receptor on the cluster(s) labeled on the bottom.
- Parameters
- adata
Object of :class anndata.AnnData
- dict_key
Key in .uns to dictionary containing cell-cell communication information. Should contain keys labeled “means” and “pvalues”, with values being dataframes for the mean cell type-cell type L:R product and significance values.
- source_groups
Source interaction clusters. If None, select all clusters.
- target_groups
Target interaction clusters. If None, select all clusters.
- means_range
Only show interactions whose means are within this closed interval
- pvalue_threshold
Only show interactions with p-value <= pvalue_threshold
- remove_empty_interactions
Remove rows and columns that contain NaN values
- remove_nonsig_interactions
Remove rows and columns that only contain interactions that are larger than alpha
- dendrogram
How to cluster based on the p-values. Valid options are: - None (no input) - do not perform clustering. - ‘interacting_molecules’ - cluster the interacting molecules. - ‘interacting_clusters’ - cluster the interacting clusters. - ‘both’ - cluster both rows and columns. Note that in this case, the dendrogram is not shown.
- alpha
Significance threshold. All elements with p-values <= alpha will be marked by tori instead of dots.
- swap_axes
Whether to show the cluster combinations as rows and the interacting pairs as columns
- title
Title of the plot
- figsize
The width and height of a figure
- save_show_or_return
Options: “save”, “show”, “return”, “both”, “all” - “both” for save and show
- save_kwargs
A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. But to change any of these parameters, this dictionary can be used to do so.
- kwargs
Keyword arguments for :func style or :func legend of :class Dotplot
- spateo.plotting.static.plot_connections(adata: anndata.AnnData, cat_key: str, spatial_key: str = 'spatial', n_spatial_neighbors: Union[None, int] = 6, spatial_weights_matrix: Union[None, scipy.sparse.csr_matrix, numpy.ndarray] = None, expr_weights_matrix: Union[None, scipy.sparse.csr_matrix, numpy.ndarray] = None, reverse_expr_plot_orientation: bool = False, ax: Union[None, matplotlib.axes.Axes] = None, figsize: tuple = (3, 3), zero_self_connections: bool = True, normalize_by_self_connections: bool = False, shapes_style: bool = True, label_outline: bool = False, max_scale: float = 0.46, colormap: Union[str, dict, matplotlib.colormap] = 'Spectral', title_str: Union[None, str] = None, title_fontsize: Union[None, float] = None, label_fontsize: Union[None, float] = None, save_show_or_return: Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[dict] = {})[source]#
Plot spatial_connections between labels- visualization of how closely labels are colocalized
- Parameters
- adata
AnnData object
- cat_key
Key in .obs containing categorical grouping labels. Colocalization will be assessed for pairwise combinations of these labels.
- spatial_key
Key in .obsm containing coordinates in the physical space. Not used unless ‘spatial_weights_matrix’ is None, in which case this is required. Defaults to “spatial”.
- n_spatial_neighbors
Optional, number of neighbors in the physical space for each cell. Not used unless ‘spatial_weights_matrix’ is None.
- spatial_weights_matrix
Spatial distance matrix, weighted by distance between spots. If not given, will compute at runtime.
- expr_weights_matrix
Gene expression distance matrix, weighted by distance in transcriptomic or PCA space. If not given, only the spatial distance matrix will be plotted. If given, will plot the spatial distance matrix in the left plot and the gene expression distance matrix in the right plot.
- reverse_expr_plot_orientation
If True, plot the gene expression connections in the form of a lower right triangle. If False, gene expression connections will be an upper left triangle just like the spatial connections.
- ax
Existing axes object, if applicable
- figsize
Width x height of desired figure window in inches
- zero_self_connections
If True, ignores intra-label interactions
- normalize_by_self_connections
Only used if ‘zero_self_connections’ is False. If True, normalize intra-label connections by the number of spots of that label
- shapes_style
If True plots squares, if False plots heatmap
- label_outline
If True, gives dark outline to axis tick label text
- max_scale
Only used for the case that ‘shape_style’ is True, gives maximum size of square
- colormap
Specifies colors to use for plotting. If dictionary, keys should be numerical labels corresponding to those of the Label object.
- title_str
Optionally used to give plot a title
- title_fontsize
Size of plot title- only used if ‘title_str’ is given.
- label_fontsize
Size of labels along the axes of the graph
- save_show_or_return
Whether to save, show or return the figure. If “both”, it will save and plot the figure at the same time. If “all”, the figure will be saved, displayed and the associated axis and other object will be return.
- save_kwargs
A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise you can provide a dictionary that properly modifies those keys according to your needs.
- Returns
Returns plot and axis object if ‘save_show_or_return’ is “all”
- Return type
(fig, ax)
- spateo.plotting.static.lisa(df: geopandas.GeoDataFrame)[source]#
Create a plot with four panels. The first one is for the raw lisa (Local Indicators of Spatial Association ) score. The second one (the right one in the first row) is for the four quantiles. The third one is for the significance while the fourth one the five categories (not significant, hotspot, doughnut, coldspot and diamond.
- Parameters
- df
The GeoDataFrame returned from running st.tl.lisa_geo_df(adata, gene).
- Returns
Nothing but plot the four panels .
- spateo.plotting.static.lisa_quantiles(df: geopandas.GeoDataFrame)[source]#
Scatterplot of the gene expression and its spatial lag. Categorization into the four regions (HH, HL, LH, LL) is also annotated. This function should be used in conjunction with st.tl.lisa_geo_df.
- Parameters
- df
The GeoDataFrame returned from running st.tl.lisa_geo_df(adata, gene).
- Returns
Nothing but plot the scatterplot.
- spateo.plotting.static.polarity(adata: anndata.AnnData, gene_dict: dict, region_key: str, mode: str = 'density')[source]#
Simple function to visualize expression level varies along regions.
- spateo.plotting.static.scatters(adata: anndata.AnnData, basis: Union[str, list] = 'umap', x: int = 0, y: int = 1, z: int = 2, color: Union[str, list] = 'ntr', layer: Union[str, list] = 'X', highlights: Optional[list] = None, labels: Optional[list] = None, values: Optional[list] = None, theme: Optional[str] = None, cmap: Optional[str] = None, color_key: Union[dict, list] = None, color_key_cmap: Optional[str] = None, background: Optional[str] = None, ncols: int = 4, pointsize: Union[None, float] = None, figsize: tuple = (6, 4), show_legend='on data', use_smoothed: bool = True, aggregate: Optional[str] = None, show_arrowed_spines: bool = False, ax: Optional[matplotlib.axes.Axes] = None, sort: str = 'raw', save_show_or_return: typing_extensions.Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[Dict] = None, return_all: bool = False, add_gamma_fit: bool = False, frontier: bool = False, contour: bool = False, ccmap: Optional[str] = None, alpha: float = 0.1, calpha: float = 0.4, sym_c: bool = False, smooth: bool = False, dpi: int = 100, inset_dict: dict = {}, marker: str = None, group: str = None, add_group_gamma_fit: bool = False, affine_transform_degree: int = None, affine_transform_A: Optional[numpy.ndarray] = None, affine_transform_b: Optional[numpy.ndarray] = None, stack_colors: bool = False, stack_colors_threshold: float = 0.001, stack_colors_title: str = 'stacked colors', stack_colors_legend_size: int = 2, stack_colors_cmaps: Optional[str] = None, despline: bool = True, deaxis: bool = True, despline_sides: Union[None, List[str]] = None, projection: str = '2d', geo: bool = False, boundary_width: float = 0.2, boundary_color: str = 'black', aspect: str = 'auto', slices: Optional[int] = None, img_layers: Optional[int] = None, **kwargs) Union[None, matplotlib.axes.Axes] #
Plot an embedding as points. Currently, this only works for 2D embeddings. While there are many optional parameters to further control and tailor the plotting, you need only pass in the trained/fit umap model to get results. This plot utility will attempt to do the hard work of avoiding overplotting issues, and make it easy to automatically colour points by a categorical labelling or numeric values. This method is intended to be used within a Jupyter notebook with
%matplotlib inline
.- Parameters
- adata
AnnData
an Anndata object- basis
str The reduced dimension.
- x
int (default: 0) The column index of the low dimensional embedding for the x-axis.
- y
int (default: 1) The column index of the low dimensional embedding for the y-axis.
- color
string (default: ntr) Any column names or gene expression, etc. that will be used for coloring cells.
- layer
str (default: X) The layer of data to use for the scatter plot.
- highlights
list (default: None) Which color group will be highlighted. if highlights is a list of lists - each list is relate to each color element.
- labels
array, shape (n_samples,) (optional, default None) An array of labels (assumed integer or categorical), one for each data sample. This will be used for coloring the points in the plot according to their label. Note that this option is mutually exclusive to the
values
option.- values
array, shape (n_samples,) (optional, default None) An array of values (assumed float or continuous), one for each sample. This will be used for coloring the points in the plot according to a colorscale associated to the total range of values. Note that this option is mutually exclusive to the
labels
option.- theme
string (optional, default None) A color theme to use for plotting. A small set of predefined themes are provided which have relatively good aesthetics. Available themes are:
’blue’
’red’
’green’
’inferno’
’fire’
’viridis’
’darkblue’
’darkred’
’darkgreen’
- cmap
string (optional, default ‘Blues’) The name of a matplotlib colormap to use for coloring or shading points. If no labels or values are passed this will be used for shading points according to density (largely only of relevance for very large datasets). If values are passed this will be used for shading according the value. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.
- color_key
dict or array, shape (n_categories) (optional, default None) A way to assign colors to categoricals. This can either be an explicit dict mapping labels to colors (as strings of form ‘#RRGGBB’), or an array like object providing one color for each distinct category being provided in
labels
. Either way this mapping will be used to color points according to the label. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.- color_key_cmap
The name of a matplotlib colormap to use for categorical coloring. If an explicit
color_key
is not given a color mapping for categories can be generated from the label list and selecting a matching list of colors from the given colormap. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.- background
string or None (optional, default ‘None`) The color of the background. Usually this will be either ‘white’ or ‘black’, but any color name will work. Ideally one wants to match this appropriately to the colors being used for points etc. This is one of the things that themes handle for you. Note that if theme is passed then this value will be overridden by the corresponding option of the theme.
- ncols
int (optional, default 4) Number of columns for the figure.
- pointsize
None or float (default: None) The scale of the point size. Actual point cell size is calculated as 500.0 / np.sqrt(adata.shape[0]) * pointsize
- figsize
None or [float, float] (default: None) The width and height of a figure.
- show_legend
bool (optional, default True) Whether to display a legend of the labels
- use_smoothed
bool (optional, default True) Whether to use smoothed values (i.e. M_s / M_u instead of spliced / unspliced, etc.).
- aggregate
str or None (default: None) The column in adata.obs that will be used to aggregate data points.
- show_arrowed_spines
bool (optional, default False) Whether to show a pair of arrowed spines representing the basis of the scatter is currently using.
- ax
matplotlib.Axis (optional, default None) The matplotlib axes object where new plots will be added to. Only applicable to drawing a single component.
- sort
str (optional, default raw) The method to reorder data so that high values points will be on top of background points. Can be one of {‘raw’, ‘abs’, ‘neg’}, i.e. sorted by raw data, sort by absolute values or sort by negative values.
- save_show_or_return
Whether to save, show or return the figure. If “both”, it will save and plot the figure at the same time. If “all”, the figure will be saved, displayed and the associated axis and other object will be return.
- save_kwargs
A dictionary that will be passed to the save_fig function. By default, it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.
- return_all
bool (default: False) Whether to return all the scatter related variables. Default is False.
- add_gamma_fit
bool (default: False) Whether to add the line of the gamma fitting. This will automatically turn on if basis points to gene names and those genes have went through gamma fitting.
- frontier
bool (default: False) Whether to add the frontier. Scatter plots can be enhanced by using transparency (alpha) in order to show area of high density and multiple scatter plots can be used to delineate a frontier. See matplotlib tips & tricks cheatsheet (https://github.com/matplotlib/cheatsheets). Originally inspired by figures from scEU-seq paper: https://science.sciencemag.org/content/367/6482/1151. If contour is set to be True, frontier will be ignored as contour also add an outlier for data points.
- contour
bool (default: False) Whether to add an countor on top of scatter plots. We use tricontourf to plot contour for non-gridded data. The shapely package was used to create a polygon of the concave hull of the scatters. With the polygon we then check if the mean of the triangulated points are within the polygon and use this as our condition to form the mask to create the contour. We also add the polygon shape as a frontier of the data point (similar to when setting frontier = True). When the color of the data points is continuous, we will use the same cmap as for the scatter points by default, when color is categorical, no contour will be drawn but just the polygon. cmap can be set with ccmap argument. See below. This has recently changed to use seaborn’s kdeplot.
- ccmap
str or None (default: None) The name of a matplotlib colormap to use for coloring or shading points the contour. See above.
- calpha
float (default: 0.4) Contour alpha value passed into sns.kdeplot. The value should be inbetween [0, 1]
- sym_c
bool (default: False) Whether do you want to make the limits of continuous color to be symmetric, normally this should be used for plotting velocity, jacobian, curl, divergence or other types of data with both positive or negative values.
- smooth
bool or int (default: False) Whether do you want to further smooth data and how much smoothing do you want. If it is False, no smoothing will be applied. If True, smoothing based on one step diffusion of connectivity matrix (.uns[‘moment_cnn’] will be applied. If a number larger than 1, smoothing will based on `smooth steps of diffusion.
- dpi
float, (default: 100.0) The resolution of the figure in dots-per-inch. Dots per inches (dpi) determines how many pixels the figure comprises. dpi is different from ppi or points per inches. Note that most elements like lines, markers, texts have a size given in points so you can convert the points to inches. Matplotlib figures use Points per inch (ppi) of 72. A line with thickness 1 point will be 1./72. inch wide. A text with fontsize 12 points will be 12./72. inch heigh. Of course if you change the figure size in inches, points will not change, so a larger figure in inches still has the same size of the elements.Changing the figure size is thus like taking a piece of paper of a different size. Doing so, would of course not change the width of the line drawn with the same pen. On the other hand, changing the dpi scales those elements. At 72 dpi, a line of 1 point size is one pixel strong. At 144 dpi, this line is 2 pixels strong. A larger dpi will therefore act like a magnifying glass. All elements are scaled by the magnifying power of the lens. see more details at answer 2 by @ImportanceOfBeingErnest: https://stackoverflow.com/questions/47633546/relationship-between-dpi-and-figure-size
- inset_dict
dict (default: {}) A dictionary of parameters in inset_ax. Example, something like {“width”: “5%”, “height”: “50%”, “loc”: ‘lower left’, “bbox_to_anchor”: (0.85, 0.90, 0.145, 0.145), “bbox_transform”: ax.transAxes, “borderpad”: 0} See more details at https://matplotlib.org/api/_as_gen/mpl_toolkits.axes_grid1.inset_locator.inset_axes.html or https://stackoverflow.com/questions/39803385/what-does-a-4-element-tuple-argument-for-bbox-to-anchor-mean -in-matplotlib
- marker
str (default: None) The marker style. marker can be either an instance of the class or the text shorthand for a particular marker. See matplotlib.markers for more information about marker styles.
- group
The key to the column in adata.obs that points to cell groups that will be used to include the gamma fittings.
- add_group_gamma_fit
Whether or not to add the gamma fitting line for each cell group.
- affine_transform_degree
Transform coordinates of points according to some degree.
- affine_transform_A
Coefficients in affine transformation Ax + b. 2D for now.
- affine_transform_b
Bias in affine transformation Ax + b.
- stack_colors
Whether to stack all color on the same ax passed above. Currently only support 18 sequential matplotlib default cmaps assigning to different color groups. (#colors should be smaller than 18, reuse if #colors > 18. To-do: generate cmaps according to #colors)
- stack_colors_threshold
A threshold for filtering points values < threshold when drawing each color. E.g. if you do not want points with values < 1 showing up on axis, set threshold to be 1
- stack_colors_title
The title for the stack_color plot.
- stack_colors_legend_size
Control the legend size in stack color plot.
- stack_colors_cmaps
The colormap used to stack different genes in a single plot.
- despline
Whether to remove splines of the figure.
- despline_sides
Which side of splines should be removed. Can be any combination of [“bottom”, “right”, “top”, “left”].
- deaxis
Whether to remove axis ticks of the figure.
- projection
The projection of the figure. Can be “2d”, “3d”, “polar”, etc.
- geo
bool (default: False) Use geometry info or not.
- boundary_width
float, (default: 0.2) The line width of boundary.
- boundary_color
(default: “black”) The color value of boundary.
- aspect
Set the aspect of the axis scaling, i.e. the ratio of y-unit to x-unit. In physical spatial plot, the default is ‘equal’. See more details at: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_aspect.html
- slices
The index to the tissue slice, will used in adata.uns[“spatial”][slices].
- img_layers
The index to the (staining) image of a tissue slice, will be used in adata.uns[“spatial”][slices][“images”].
- kwargs
Additional arguments passed to plt.scatters.
- Returns
Either None or a matplotlib axis with the relevant plot displayed. If you are using a notbooks and have
%matplotlib inline
set then this will simply display inline.- Return type
result
- spateo.plotting.static.space(adata: anndata.AnnData, color: Union[list, str, None] = None, genes: Union[list, None] = [], gene_cmaps=None, space: str = 'spatial', width: float = 6, marker: str = '.', pointsize: Union[float, None] = None, dpi: int = 100, ps_sample_num: int = 1000, alpha: float = 0.8, stack_genes: bool = False, stack_genes_threshold: float = 0.01, stack_colors_legend_size: int = 10, figsize=None, *args, **kwargs)#
Scatter plot for physical coordinates of each cell. :param adata: an Annodata object that contain the physical coordinates for each bin/cell, etc. :param genes: The gene list that will be used to plot the gene expression on the same scatter plot. Each gene will have a
different color. Can be a single gene name string and we will convert it to a list.
- Parameters
- color : string (default: ntr)
Any or any list of column names or gene name, etc. that will be used for coloring cells. If color is not None, stack_genes will be disabled automatically because color can contain non numerical values.
- space : str
The key to space coordinates.
- stack_genes
whether to show all gene plots on the same plot
- stack_genes_threshold
lower bound of gene values that will be drawn on the plot.
- stack_colors_legend_size
control the size of legend when stacking genes
- alpha : float
The alpha value of the scatter points.
- width : int
- marker
a string representing some marker from matplotlib https://matplotlib.org/stable/api/markers_api.html#module-matplotlib.markers
- pointsize : float
The size of the points on the scatter plot.
- dpi : float, (default: 100.0)
The resolution of the figure in dots-per-inch. Dots per inches (dpi) determines how many pixels the figure comprises. dpi is different from ppi or points per inches. Note that most elements like lines, markers, texts have a size given in points so you can convert the points to inches. Matplotlib figures use Points per inch (ppi) of 72. A line with thickness 1 point will be 1./72. inch wide. A text with fontsize 12 points will be 12./72. inch heigh. Of course if you change the figure size in inches, points will not change, so a larger figure in inches still has the same size of the elements.Changing the figure size is thus like taking a piece of paper of a different size. Doing so, would of course not change the width of the line drawn with the same pen. On the other hand, changing the dpi scales those elements. At 72 dpi, a line of 1 point size is one pixel strong. At 144 dpi, this line is 2 pixels strong. A larger dpi will therefore act like a magnifying glass. All elements are scaled by the magnifying power of the lens. see more details at answer 2 by @ImportanceOfBeingErnest: https://stackoverflow.com/questions/47633546/relationship-between-dpi-and-figure-size
- ps_sample_num : int
The number of bins / cells that will be sampled to estimate the distance between different bin / cells.
- %(scatters.parameters.no_adata|basis|figsize)s
- Returns
plots gene or cell feature of the adata object on the physical spatial coordinates.
- spateo.plotting.static.acceleration(adata: anndata.AnnData, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock, list], acceleration_key: str = 'acceleration', filename: Optional[str] = None, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, colormap: Optional[Union[str, list]] = 'default_cmap', ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'points', model_size: Union[float, list] = 3.0, **kwargs)#
Visualize the torsion result.
- Parameters
- adata
An anndata object contain acceleration values in
.obs[acceleration_key]
.- model
A reconstructed model contains
obs_index
values.- acceleration_key
The key in
.obs
that corresponds to the acceleration values in the anndata object.- 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'
.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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- Returns
- List of camera position, focal point, and view up.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.- img: Numpy array of the last image.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.
- Return type
cpo
Examples
Visualize only in one model:
- st.pl.acceleration(
adata=stage_adata, model=stage_pc, acceleration_key=”acceleration”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.acceleration(
adata=stage_adata, model=[stage_pc, trajectory_model], acceleration_key=”acceleration”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.add_legend(plotter: pyvista.Plotter, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], key: Optional[Union[str, list]] = None, colormap: Optional[Union[str, list]] = None, legend_size: Optional[Tuple] = None, legend_loc: Union[str, tuple, list] = None, title: Optional[str] = '', title_font_size: Optional[Union[int, float]] = None, label_font_size: Optional[Union[int, float]] = None, font_color: str = 'black', font_family: Literal[times, courier, arial] = 'arial', fmt='%.2e', n_labels: int = 5, vertical: bool = True)#
Add a legend to the plotter.
- Parameters
- plotter
The plotting object to display pyvista/vtk model.
- model
A reconstructed model.
- key
The key under which are the legend labels.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- legend_size
The percentage (0 to 1) width and height of the window for the legend.
- legend_loc
The location of the legend in the window.
- title
Title of the legend. Default ‘’ which is rendered as an empty title.
- title_font_size
Sets the size of the title font. Only available when colormap is not None.
- label_font_size
Sets the size of the label font. Only available when colormap is not None.
- font_color
The color of the font. Only available when colormap is not None.
- font_family
The font of the text. Only available when colormap is not None.
Available font_family are:
font_family = times
font_family = courier
font_family = arial
- fmt
printf format for labels. Only available when colormap is not None.
- n_labels
Number of labels to use for the legend. Only available when colormap is not None.
- vertical
Use vertical or horizontal legend. Only available when colormap is not None.
- spateo.plotting.static.add_model(plotter: pyvista.Plotter, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock, list], key: Union[str, list] = None, colormap: Optional[Union[str, list]] = None, ambient: Union[float, list] = 0.2, opacity: Union[float, list, numpy.ndarray] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'surface', model_size: Union[float, list] = 3.0)#
Add model(s) to the plotter.
- Parameters
- plotter
The plotting object to display pyvista/vtk model.
- model
A reconstructed model.
- key
The key under which are the labels.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.
- spateo.plotting.static.add_outline(plotter: pyvista.Plotter, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], outline_width: float = 5.0, outline_color: Union[str, tuple] = 'black', show_labels: bool = True, font_size: int = 16, font_color: Union[str, tuple] = 'white', font_family: Literal[times, courier, arial] = 'arial')#
Produce an outline of the full extent for the model. If labels is True, add the length, width and height information of the model to the outline.
- Parameters
- plotter
The plotting object to display pyvista/vtk model.
- model
A reconstructed model.
- outline_width
The width of the outline.
- outline_color
The color of the outline.
- show_labels
Whether to add the length, width and height information of the model to the outline.
- font_family
The font family of the text. Available font_family are:
font_family = times
font_family = courier
font_family = arial
- font_size
The size of the font.
- font_color
The color of the font.
- spateo.plotting.static.add_text(plotter: pyvista.Plotter, text: str, font_family: Literal[times, courier, arial] = 'arial', font_size: Union[int, float] = 12, font_color: Union[str, tuple, list] = 'black', text_loc: Literal[lower_left, lower_right, upper_left, upper_right, lower_edge, upper_edge, right_edge, left_edge] = 'upper_left')#
Add text to the plotter.
- Parameters
- plotter
The plotting object to display pyvista/vtk model.
- text
The text to add the rendering.
- font_family
The font family of the text. Available font_family are:
font_family = times
font_family = courier
font_family = arial
- font_size
The size of the font.
- font_color
The color of the font.
- text_loc
The location of the text in the window. Available text_loc are:
text_loc = 'lower_left'
text_loc = 'lower_right'
text_loc = 'upper_left'
text_loc = 'upper_right'
text_loc = 'lower_edge'
text_loc = 'upper_edge'
text_loc = 'right_edge'
text_loc = 'left_edge'
- spateo.plotting.static.create_plotter(jupyter: bool = False, off_screen: bool = False, window_size: tuple = (512, 512), background: str = 'white', shape: Union[str, list, tuple] = (1, 1)) pyvista.Plotter #
Create a plotting object to display pyvista/vtk model.
- Parameters
- jupyter
Whether to plot in jupyter notebook.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- window_size
Window size in pixels. The default window_size is
[1024, 768]
.- background
The background color of the window.
- shape
Number of sub-render windows inside the main window. By default, there is only one render window.
- Returns
The plotting object to display pyvista/vtk model.
- Return type
plotter
- spateo.plotting.static.curl(adata: anndata.AnnData, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock, list], curl_key: str = 'curl', filename: Optional[str] = None, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, colormap: Optional[Union[str, list]] = 'default_cmap', ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'points', model_size: Union[float, list] = 3.0, **kwargs)#
Visualize the curl result.
- Parameters
- adata
An anndata object contain curl values in
.obs[curl_key]
.- model
A reconstructed model contains
obs_index
values.- curl_key
The key in
.obs
that corresponds to the curl values in the anndata object.- 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'
.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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- Returns
- List of camera position, focal point, and view up.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.- img: Numpy array of the last image.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.
- Return type
cpo
Examples
Visualize only in one model:
- st.pl.curl(
adata=stage_adata, model=stage_pc, curl_key=”curl”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.curl(
adata=stage_adata, model=[stage_pc, trajectory_model], curl_key=”curl”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.curvature(adata: anndata.AnnData, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock, list], curvature_key: str = 'curvature', filename: Optional[str] = None, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, colormap: Optional[Union[str, list]] = 'default_cmap', ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'points', model_size: Union[float, list] = 3.0, **kwargs)#
Visualize the curvature result.
- Parameters
- adata
An anndata object contain curvature values in
.obs[curvature_key]
.- model
A reconstructed model contains
obs_index
values.- curvature_key
The key in
.obs
that corresponds to the curvature values in the anndata object.- 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'
.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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- Returns
- List of camera position, focal point, and view up.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.- img: Numpy array of the last image.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.
- Return type
cpo
Examples
Visualize only in one model:
- st.pl.curvature(
adata=stage_adata, model=stage_pc, curvature_key=”curvature”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.curvature(
adata=stage_adata, model=[stage_pc, trajectory_model], curvature_key=”curvature”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.divergence(adata: anndata.AnnData, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock, list], divergence_key: str = 'divergence', filename: Optional[str] = None, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, colormap: Optional[Union[str, list]] = 'default_cmap', ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'points', model_size: Union[float, list] = 3.0, **kwargs)#
Visualize the divergence result.
- Parameters
- adata
An anndata object contain curl values in
.obs[divergence_key]
.- model
A reconstructed model contains
obs_index
values.- divergence_key
The key in
.obs
that corresponds to the divergence values in the anndata object.- 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'
.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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- Returns
- List of camera position, focal point, and view up.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.- img: Numpy array of the last image.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.
- Return type
cpo
Examples
Visualize only in one model:
- st.pl.divergence(
adata=stage_adata, model=stage_pc, divergence_key=”divergence”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.divergence(
adata=stage_adata, model=[stage_pc, trajectory_model], divergence_key=”divergence”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.jacobian(adata: anndata.AnnData, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock, list], jacobian_key: str = 'jacobian', filename: Optional[str] = None, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, off_screen: bool = False, shape: Union[str, list, tuple] = (3, 3), window_size: Optional[tuple] = (512 * 3, 512 * 3), background: str = 'black', colormap: Optional[Union[str, list]] = 'default_cmap', ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'points', model_size: Union[float, list] = 3.0, show_legend: bool = True, legend_kwargs: Optional[dict] = None, text: Union[bool, str] = True, text_kwargs: Optional[dict] = None, **kwargs)#
Visualize the jacobian result.
- Parameters
- adata
An anndata object contain jacobian matrix in
.uns[jacobian_key]
.- model
A reconstructed model contains
obs_index
values.- jacobian_key
The key in
.uns
that corresponds to the jacobian matrix in the anndata object.- 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'
.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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- shape
Number of sub-render windows inside the main window. By default, there are nine render window.
- window_size
Window size in pixels. The default window_size is
[512*3, 512*3]
.- background
The background color of the window.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- 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 theadd_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 into the
st.pl.three_d_multi_plot
function.
- Returns
- List of camera position, focal point, and view up.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.- img: Numpy array of the last image.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.
- Return type
cpo
Examples
Visualize only in one model:
- st.pl.jacobian(
adata=stage_adata, model=stage_pc, jacobian_key=”jacobian”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.jacobian(
adata=stage_adata, model=[stage_pc, trajectory_model], jacobian_key=”jacobian”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.merge_animations(mp4_files: Optional[list] = None, mp4_folder: Optional[list] = None, filename: str = 'merged_animation.mp4')#
Use MoviePy to compose a new animation and play multiple animations together in the new animation.
- Parameters
- mp4_files
A list containing absolute paths to mp4 files that need to be played together.
- mp4_folder
Absolute path to the folder containing all mp4 files that need to be played together. If
mp4_files
is provided,mp4_folder
cannot also be provided.- filename
Absolute path to save the newly composed animation.
Examples
st.pl.merge_animations(mp4_files=[“animation1.mp4”, “animation2.mp4”], filename=f”merged_animation.mp4”)
- spateo.plotting.static.output_plotter(plotter: pyvista.Plotter, filename: Optional[str] = None, view_up: tuple = (0.5, 0.5, 1), framerate: int = 15, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False)#
Output plotter as image, gif file or mp4 file.
- Parameters
- plotter
The plotting object to display pyvista/vtk model.
- 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'
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- view_up
The normal to the orbital plane. Only available when filename ending with
.mp4
or.gif
.- framerate
Frames per second. Only available when filename ending with
.mp4
or.gif
.- jupyter
Whether to plot in jupyter notebook. Available
jupyter
are:'none'
- Do not display in the notebook.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- Returns
- List of camera position, focal point, and view up.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.- img: Numpy array of the last image.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.
- Return type
cpo
- spateo.plotting.static.save_plotter(plotter: pyvista.Plotter, filename: str)#
Save plotter as gltf file, html file, obj file or vtkjs file.
- Parameters
- plotter
The plotting object to display pyvista/vtk model.
- filename
- The filename of the file where the plotter is saved.
Writer type is inferred from the extension of the filename.
Output a gltf file, please enter a filename ending with
.gltf
.Output a html file, please enter a filename ending with
.html
.Output an obj file, please enter a filename ending with
.obj
.Output a vtkjs file, please enter a filename without format.
- spateo.plotting.static.three_d_animate(models: Union[List[PolyData or UnstructuredGrid], pyvista.MultiBlock], stable_model: Optional[Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock]] = None, stable_kwargs: Optional[dict] = None, key: Optional[str] = None, filename: str = 'animate.mp4', jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, off_screen: bool = False, window_size: tuple = (512, 512), background: str = 'white', cpo: Union[str, list] = 'iso', colormap: Optional[Union[str, list]] = None, ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'surface', model_size: Union[float, list] = 3.0, show_legend: bool = True, legend_kwargs: Optional[dict] = None, show_outline: bool = False, outline_kwargs: Optional[dict] = None, text: Optional[str] = None, text_kwargs: Optional[dict] = None, framerate: int = 24, plotter_filename: Optional[str] = None)#
Animated visualization of 3D reconstruction model.
- Parameters
- models
A List of reconstructed models or a MultiBlock.
- stable_model
The model that do not change with time in animation.
- stable_kwargs
Parameters for plotting stable model. Available
stable_kwargs
are:'key'
'ambient'
'opacity'
'model_style'
'model_size'
'background'
'show_legend'
'legend_kwargs'
'show_outline'
'outline_kwargs'
'text'
'text_kwargs'
- key
The key under which are the labels.
- 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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- 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'.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- 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 theadd_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.- show_outline
whether to produce an outline of the full extent for the model.
- outline_kwargs
A dictionary that will be pass to the
add_outline
function.By default, it is an empty dictionary and the add_legend function will use the
{"outline_width": 5.0, "outline_color": "black", "show_labels": True, "font_size": 16, "font_color": "white", "font_family": "arial"}
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. Only available when filename ending with
.mp4
or.gif
.- plotter_filename
- The filename of the file where the plotter is saved.
Writer type is inferred from the extension of the filename.
Output a gltf file, please enter a filename ending with
.gltf
.Output a html file, please enter a filename ending with
.html
.Output an obj file, please enter a filename ending with
.obj
.Output a vtkjs file, please enter a filename without format.
- spateo.plotting.static.three_d_multi_plot(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], key: Union[str, list] = None, filename: Optional[str] = None, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, off_screen: bool = False, shape: Union[str, list, tuple] = None, window_size: Optional[tuple] = None, background: str = 'white', cpo: Union[str, list] = 'iso', colormap: Optional[Union[str, list]] = None, ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'surface', model_size: Union[float, list] = 3.0, show_legend: bool = True, legend_kwargs: Optional[dict] = None, show_outline: bool = False, outline_kwargs: Optional[dict] = None, text: Union[str, list] = None, text_kwargs: Optional[dict] = None, view_up: tuple = (0.5, 0.5, 1), framerate: int = 24, plotter_filename: Optional[str] = None)#
Multi-view visualization of reconstructed 3D model.
- Parameters
- model
A MultiBlock of reconstructed models or a reconstructed model.
- key
The key under which are the labels.
- 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'
.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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- shape
Number of sub-render windows inside the main window. By default, there is only one render window.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- 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'.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- 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 theadd_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.- show_outline
whether to produce an outline of the full extent for the model.
- outline_kwargs
A dictionary that will be pass to the
add_outline
function.By default, it is an empty dictionary and the add_legend function will use the
{"outline_width": 5.0, "outline_color": "black", "show_labels": True, "font_size": 16, "font_color": "white", "font_family": "arial"}
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.- view_up
The normal to the orbital plane. Only available when filename ending with
.mp4
or.gif
.- framerate
Frames per second. Only available when filename ending with
.mp4
or.gif
.- plotter_filename
- The filename of the file where the plotter is saved.
Writer type is inferred from the extension of the filename.
Output a gltf file, please enter a filename ending with
.gltf
.Output a html file, please enter a filename ending with
.html
.Output an obj file, please enter a filename ending with
.obj
.Output a vtkjs file, please enter a filename without format.
- spateo.plotting.static.three_d_plot(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], key: Union[str, list] = None, filename: Optional[str] = None, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, off_screen: bool = False, window_size: tuple = (512, 512), background: str = 'white', cpo: Union[str, list] = 'iso', colormap: Optional[Union[str, list]] = None, ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'surface', model_size: Union[float, list] = 3.0, show_legend: bool = True, legend_kwargs: Optional[dict] = None, show_outline: bool = False, outline_kwargs: Optional[dict] = None, text: Optional[str] = None, text_kwargs: Optional[dict] = None, view_up: tuple = (0.5, 0.5, 1), framerate: int = 24, plotter_filename: Optional[str] = None)#
Visualize reconstructed 3D model.
- Parameters
- model
A reconstructed model.
- key
The key under which are the labels.
- 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'
.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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- 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'.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- 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 theadd_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.- show_outline
whether to produce an outline of the full extent for the model.
- outline_kwargs
A dictionary that will be pass to the
add_outline
function.By default, it is an empty dictionary and the add_legend function will use the
{"outline_width": 5.0, "outline_color": "black", "show_labels": True, "font_size": 16, "font_color": "white", "font_family": "arial"}
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.- view_up
The normal to the orbital plane. Only available when filename ending with
.mp4
or.gif
.- framerate
Frames per second. Only available when filename ending with
.mp4
or.gif
.- plotter_filename
- The filename of the file where the plotter is saved.
Writer type is inferred from the extension of the filename.
Output a gltf file, please enter a filename ending with
.gltf
.Output a html file, please enter a filename ending with
.html
.Output an obj file, please enter a filename ending with
.obj
.Output a vtkjs file, please enter a filename without format.
- Returns
- List of camera position, focal point, and view up.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.- img: Numpy array of the last image.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.
- Return type
cpo
- spateo.plotting.static.torsion(adata: anndata.AnnData, model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock, list], torsion_key: str = 'torsion', filename: Optional[str] = None, jupyter: Union[bool, Literal[panel, none, pythreejs, static, ipygany]] = False, colormap: Optional[Union[str, list]] = 'default_cmap', ambient: Union[float, list] = 0.2, opacity: Union[float, numpy.ndarray, list] = 1.0, model_style: Union[Literal[points, surface, wireframe], list] = 'points', model_size: Union[float, list] = 3.0, **kwargs)#
Visualize the torsion result.
- Parameters
- adata
An anndata object contain torsion values in
.obs[torsion_key]
.- model
A reconstructed model contains
obs_index
values.- torsion_key
The key in
.obs
that corresponds to the torsion values in the anndata object.- 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'
.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.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- colormap
Name of the Matplotlib colormap to use when mapping the scalars.
When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- 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_style
Visualization style of the model. One of the following:
model_style = 'surface'
,model_style = 'wireframe'
,model_style = 'points'
.
- model_size
If
model_style = 'points'
, point size of any nodes in the dataset plotted.If
model_style = 'wireframe'
, thickness of lines.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- Returns
- List of camera position, focal point, and view up.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.- img: Numpy array of the last image.
Returned only if filename is None or filename ending with
'.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'
.
- Return type
cpo
Examples
Visualize only in one model:
- st.pl.torsion(
adata=stage_adata, model=stage_pc, torsion_key=”torsion”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.torsion(
adata=stage_adata, model=[stage_pc, trajectory_model], torsion_key=”torsion”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)