mesa.ecospatial.diversity_heatmap

mesa.ecospatial.diversity_heatmap(spatial_data, library_key, library_id, spatial_key, patches, heterogeneity_indices, tissue_only=False, plot=True, return_fig=False)

Visualize the diversity indices as a heatmap on the original spatial data, optionally returning the plot figure for further customization.

Parameters:
  • spatial_data (Union[ad.AnnData, pd.DataFrame]) – The spatial data to be used for visualization. This can be either an AnnData object or a DataFrame.

  • library_key (str) – The key associated with the library in spatial_data, used to access library-specific data.

  • library_id (str) – The identifier for the library to be used in the analysis.

  • spatial_key (Union[str, List[str]]) – Key(s) identifying the spatial information within spatial_data.

  • patches (list) – The list of patches to be analyzed. Each patch corresponds to a specific region in the spatial data.

  • heterogeneity_indices (pandas.Series) – The heterogeneity indices to be visualized. Each index value corresponds to a patch, indicating its heterogeneity level.

  • tissue_only (bool, optional) – If True, only tissue regions are included in the analysis. Default is False.

  • plot (bool, optional) – If True, a heatmap is plotted to visualize the indices. Default is True.

  • return_fig (bool, optional) – If True, the matplotlib.figure.Figure is returned for further customization. Default is False.

Return type:

Union[ndarray, Figure, None]

Returns:

  • numpy.ndarray – A grid where each cell represents the diversity index for a corresponding patch.

  • matplotlib.figure.Figure, optional – The matplotlib figure object, returned if both return_fig is True and plot is True.