SpatialQuery.spatial_query.motif_enrichment_dist

spatial_query.motif_enrichment_dist(ct, motifs=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.

Parameters:
  • ct (str) – Cell type as the center cells.

  • 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.

  • 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 motif within the neighborhood of central cell type. By defaults do not return cell ID.

Returns:

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 (across all cell types)

  • expectation: expected number under hypergeometric distribution

  • p-values: p-value from hypergeometric test

  • if_significant: whether the enrichment is significant (p < 0.05)

  • adj-pval: FDR-corrected p-values (only when multiple motifs tested)

  • neighbor_id: array of unique neighbor cell indices with motif types (only if return_cellID=True)

  • center_id: array of center cell indices with motif in neighborhood (only if return_cellID=True)

Return type:

pd.DataFrame