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)
This function analyzes cell frequency and co-occurrence across different spots in spatial data based on specified library IDs and clustering keys, applying spatial statistics methods. It processes each specified region, calculates diversity indices, and evaluates the presence of hotspots, coldspots, or overall diversity based on the specified mode.
- Parameters:
spatial_data (Union[ad.AnnData, pd.DataFrame]) – The spatial data containing library information and spatial coordinates.
scale (float) – The scaling factor for adjusting the 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 used in the analysis.
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.
spots (str, optional) – Type of spots to analyze (‘hot’, ‘cold’, or ‘global’). Defaults to ‘hot’.
p_value (float, optional) – The p-value threshold for significance in spatial statistics testing. Defaults to 0.01.
combination (int, optional) – The number of top combinations to consider for analyzing frequency. Defaults to 2.
top (int, optional) – The number of top results to return. Defaults to 15.
selected_comb (list, optional) – Specific combinations of clusters to analyze. If None, the top combinations are used.
mode (str, optional) – The mode of spatial statistics to apply (e.g., ‘MoranI’). Defaults to ‘MoranI’.
restricted (bool, optional) – If True, the analysis is restricted to specified conditions. Defaults to False.
**kwargs – Additional keyword arguments for other specific parameters or configurations.
- Returns:
pd.DataFrame – A DataFrame containing the normalized cell frequencies for each cluster across the specified regions, or across the entire tissue if ‘global’ is specified.
pd.DataFrame – A transposed DataFrame containing the frequency of specific cluster combinations in each region, sorted by the top specified combinations if selected_comb is None.