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)
This function visualizes the heterogeneity indices as a heatmap on the original spatial data.
- Parameters:
spatial_data (Union[ad.AnnData, pd.DataFrame]) – The spatial data to be used for visualization.
library_key (str) – The key associated with the library in the spatial_data.
library_id (str) – The identifier for the library to be used in the analysis.
spatial_key (Union[str, List[str]]) – The key(s) identifying the spatial information within spatial_data.
patches (list) – The list of patches to be analyzed. Each patch should correspond to a specific region in the spatial data.
heterogeneity_indices (pandas.Series) – The heterogeneity indices to be visualized. Each value in this series corresponds to a patch, indicating its heterogeneity level.
tissue_only (bool, optional) – If True, only tissue regions are considered in the analysis. Defaults to False.
plot (bool, optional) – If True, a heatmap is plotted. Defaults to True.
return_fig (bool, optional) – If True, the matplotlib figure is returned. This is useful for further customization of the plot. Defaults to False.
- Returns:
numpy.ndarray – A grid where each cell represents the heterogeneity index for a corresponding patch.
matplotlib.figure.Figure, optional – The matplotlib figure object if return_fig is True and plot is True; otherwise, this is not returned.
Notes
This function requires that the spatial data is properly formatted and that the heterogeneity indices have been previously calculated.