SpatialQuery.spatial_query_multi.motif_enrichment_dist
- spatial_query_multi.motif_enrichment_dist(ct, motifs=None, dataset=None, max_dist=20, min_size=0, min_support=0.5, return_cellID=False)[source]
Perform motif enrichment analysis within a specified radius-based neighborhood in multiple fields of view.
- Parameters:
ct (str) – Cell type of the center cell.
motifs (str or List[str] or List[List[str]], optional) – Specified motifs to be tested. If motifs=None, find the frequent patterns as motifs within the neighborhood of center cell type.
dataset (str or List[str], optional) – Datasets for searching for frequent patterns and performing enrichment analysis. Use all datasets if dataset=None.
max_dist (float, default=20) – Maximum distance for considering a cell as a neighbor.
min_size (int, default=0) – Minimum neighborhood size for each point to consider.
min_support (float, default=0.5) – Threshold of frequency to consider a pattern as a frequent pattern.
return_cellID (bool, default=False) – Indicate whether return cell IDs for each frequent pattern within the neighborhood of center cells. By defaults do not return cell ID.
- Returns:
- If return_cellID is False:
- pd.DataFrame with motif enrichment results. Columns include:
center: center cell type name
motifs: list of cell types in the motif
n_center_motif: number of center cells with motif in neighborhood
n_center: total number of center cells
n_motif: total number of cells with motif in neighborhood
expectation: expected number under hypergeometric distribution
p-values: p-value from hypergeometric test
adj-pval: FDR-corrected p-values (when multiple motifs tested)
if_significant: whether the enrichment is significant
- If return_cellID is True:
- Tuple containing:
pd.DataFrame: enrichment results as described above
Dict: cell IDs of motifs in center cell’s neighborhood Format: {‘motif_str’: {‘dataset_name’: [cell_ids]}}
Dict: cell IDs of center cells with motif in neighborhood Format: {‘motif_str’: {‘dataset_name’: [cell_ids]}}
- Return type:
Union[pd.DataFrame, Tuple[pd.DataFrame, Dict, Dict]]