pegasus.spatial

pegasus.spatial(data, attrs=None, basis='spatial', resolution='hires', cmaps='viridis', vmin=None, vmax=None, alpha=1.0, alpha_img=1.0, dpi=300.0, return_fig=False, **kwargs)[source]

Scatter plot on spatial coordinates. This function is inspired by SCANPY’s pl.spatial function.

Parameters
  • data (pegasusio.MultimodalData or pegasusio.UnimodalData or anndata.AnnData) – Use current selected modality in data.

  • attr (str, optional, default: None) – Color scatter plots by attribute ‘attr’. This attribute should be one key in data.obs, data.var_names (e.g. one gene) or data.obsm (attribute has the format of ‘obsm_key@component’, like ‘X_pca@0’). If it is categorical, a palette will be used to color each category separately. Otherwise, a color map will be used. If None, just plot data points of the same color.

  • basis (str, optional, default: spatial) – Basis to be used to generate spatial plots. Must be the 2D array showing the spatial coordinates of data points.

  • resolution (str, optional, default: hires) – Use the spatial image whose value is specified in data.img['image_id'] to show in background. For 10X Visium data, user can either specify hires or lowres to use High or Low resolution spatial images, respectively.

  • cmaps (str or List[str], optional, default: viridis) – The colormap(s) for plotting numeric attributes. The default viridis colormap theme follows the spatial plot function in SCANPY (scanpy.pl.spatial).

  • vmin (float, optional, default: None) – Minimum value to show on a numeric scatter plot (feature plot).

  • vmax (float, optional, default: None) – Maximum value to show on a numeric scatter plot (feature plot).

  • alpha (float or List[float], optional, default: 1.0) – Alpha value for blending the attribute layers, from 0.0 (transparent) to 1.0 (opaque). If this is a list, the length must match attrs, which means we set a separate alpha value for each attribute.

  • alpha_img (float, optional, default: 1.0) – Alpha value for blending the background spatial image, from 0.0 (transparent) to 1.0 (opaque).

  • dpi (float, optional, default: 300.0) – The resolution of the figure in dots-per-inch.

  • return_fig (bool, optional, default: False) – Return a Figure object if True; return None otherwise.

Returns

A matplotlib.figure.Figure object containing the dot plot if return_fig == True

Return type

Figure object

Examples

>>> pg.spatial(data, attrs=['louvain_labels', 'Channel'])
>>> pg.spatial(data, attrs=['CD14', 'TRAC'], resolution='lowres')