monkeybread.plot.cell_density

monkeybread.plot.cell_density(adata, key, spot_size=None, alpha=1.0, cmap=None, legend_loc='right margin', show=True, title=None, ax=None)

Plots the spatial density of cells across the tissue, as calculated by monkeybread.calc.cell_density().

Parameters:
  • adata (Union[AnnData, Series, Dict[str, Series]]) – Annotated data matrix

  • key (Union[str, Dict[str, str]]) – Either a key in adata.obs or a mapping of group names to keys in adata.obs corresponding to density columns

  • spot_size (Optional[float] (default: None)) – The size of spots to plot

  • alpha (Optional[float] (default: 1.0)) – The alpha blending value, between 0 (transparent) and 1 (opaque).

  • cmap (Optional[str] (default: None)) – Colormap to use for values 0 to 1

  • show_legend – If True show the legend. Otherwise, hide it.

  • show (Optional[bool] (default: True)) – Whether to show the plot or return it

  • title (Optional[str] (default: None)) – Title of the plot

  • ax (Optional[Axes] (default: None)) – An Axes object to add the plot to. Only works if key is a single key.

Return type:

Union[Figure, Axes, None]

Returns:

: If show = False returns the current figure (if key is a mapping) or the current axes (if key is a string). If show = True returns nothing.

Example

https://raw.githubusercontent.com/immunitastx/monkeybread/main/docs/_static/kernel_density.png