mesa.ecospatial.calculate_DPI

mesa.ecospatial.calculate_DPI(spatial_data, scale, library_key, library_id, spatial_key, cluster_key, hotspot=True, p_value=0.01, mode='MoranI', restricted=False, **kwargs)

Calculate the Diversity Proximity Index (DPI) for specified samples within spatial data.

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

  • scale (float) – The scale factor used for generating patches within the spatial regions.

  • library_key (str) – Key in spatial_data that corresponds to library identifiers.

  • library_id (Union[tuple, list]) – A tuple or list of identifiers for the libraries to be processed.

  • spatial_key (Union[str, List[str]]) – Key(s) in spatial_data used to determine spatial coordinates.

  • cluster_key (str) – Key used to identify different clusters or types within spatial_data.

  • hotspot (bool, optional) – Specifies whether to identify diversity hotspots (True) or coldspots (False). Default is True.

  • p_value (float, optional) – The significance level used for hotspot or coldspot identification. Default is 0.01.

  • mode (str, optional) – Specifies the mode of spatial statistics to be used, such as ‘MoranI’. Default is ‘MoranI’.

  • restricted (bool, optional) – If set to True, restricts analysis to specific tissue regions. Default is False.

  • **kwargs – Additional keyword arguments for further customization of the diversity calculations.

Returns:

A DataFrame where each index represents a library_id and the columns contain the calculated DPI for each sample.

Return type:

pandas.DataFrame