mesa.ecospatial.spot_cellfreq

mesa.ecospatial.spot_cellfreq(spatial_data, scale, library_key, library_id, spatial_key, cluster_key, spots='hot', p_value=0.01, combination=2, top=15, selected_comb=None, mode='MoranI', restricted=False, **kwargs)

Analyze cell frequency and co-occurrence across different spots in spatial data.

Parameters:
  • spatial_data (Union[ad.AnnData, pd.DataFrame]) – The spatial data containing library information and spatial coordinates for analysis.

  • scale (float) – The scaling factor for adjusting the spatial coordinates in the analysis.

  • library_key (str) – Key associated with the library information in spatial_data.

  • library_id (Union[tuple, list]) – Identifiers for the libraries to be used in the analysis.

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

  • cluster_key (str) – Key used to access cluster information within spatial_data.

  • spots (str, optional) – Specifies the type of spots to analyze (‘hot’, ‘cold’, or ‘global’). Default is ‘hot’.

  • p_value (float, optional) – The p-value threshold for significance in spatial statistics testing. Default is 0.01.

  • combination (int, optional) – The number of top combinations to consider for analyzing frequency and co-occurrence. Default is 2.

  • top (int, optional) – The number of top results to return for each combination. Default is 15.

  • selected_comb (Optional[list], optional) – Specific combinations of clusters to analyze; if None, the top combinations are used. Default is None.

  • mode (str, optional) – The mode of spatial statistics to apply (e.g., ‘MoranI’). Default is ‘MoranI’.

  • restricted (bool, optional) – If set to True, restricts the analysis to specified conditions or regions. Default is False.

  • **kwargs – Additional keyword arguments for further customization and specific parameters in underlying functions.

Return type:

Tuple[DataFrame, DataFrame]

Returns:

  • pandas.DataFrame – A DataFrame containing normalized cell frequencies for each cluster across specified regions, or across the entire tissue if ‘global’ is selected.

  • pandas.DataFrame – A transposed DataFrame showing the frequency of specific cluster combinations in each region, sorted by the top specified combinations if selected_comb is None.