mesa.ecospatial.calculate_GDI
- mesa.ecospatial.calculate_GDI(spatial_data, scale, library_key, library_id, spatial_key, cluster_key, hotspot=True, whole_tissue=False, p_value=0.01, restricted=False, mode='MoranI', **kwargs)
Calculates a generalized diversity index (GDI) for specified libraries within spatial data. The function processes each specified library, calculates diversity indices, and assesses spatial statistics to determine GDI values under the specified mode of analysis.
- Parameters:
spatial_data (Union[ad.AnnData, pd.DataFrame]) – The spatial data containing library and clustering information.
scale (float) – The scaling factor to adjust spatial coordinates.
library_key (str) – The key associated with the library information in spatial_data.
library_id (Union[tuple, list]) – The identifiers for libraries to be analyzed.
spatial_key (Union[str, List[str]]) – The key(s) identifying the spatial coordinates in spatial_data.
cluster_key (str) – The key used to access cluster information within spatial_data.
hotspot (bool, optional) – If True, analyzes spatial hotspots; otherwise, analyzes coldspots. Defaults to True.
whole_tissue (bool, optional) – If True, analyzes the whole tissue instead of specific regions. Defaults to False.
p_value (float, optional) – The p-value threshold for statistical significance in spatial analysis. Defaults to 0.01.
restricted (bool, optional) – If True, the analysis is restricted to specified conditions, typically specific tissue types. Defaults to False.
mode (str, optional) – The mode of spatial statistics to apply (e.g., ‘MoranI’). Defaults to ‘MoranI’.
**kwargs – Additional keyword arguments for further customization and specific parameters in underlying functions.
- Returns:
A DataFrame with indices representing library identifiers and a single column ‘GDI’ containing the calculated Global Diversity Index for each sample.
- Return type:
pd.DataFrame