mantispy.tl.network_enrichment#

mantispy.tl.network_enrichment(adata, similarity_key='similarity', edges=None, gene_key='Metadata_Gene', top_quantile=0.95, key_added='network_enrichment', copy=False)[source]#

Test the most-similar perturbation pairs for enrichment of known interactions.

Parameters:
adata AnnData

Object whose obsp[similarity_key] holds a pairwise similarity, from similarity(), and whose obs[gene_key] names each profile’s gene.

similarity_key str (default: 'similarity')

obsp key holding the pairwise similarity matrix.

edges DataFrame | None (default: None)

A two-column frame of reference gene pairs. Its first two columns are read as the pair, in any order. Defaults to mantispy.ds.interactions() (CORUM within-complex pairs).

gene_key str (default: 'Metadata_Gene')

obs column holding the gene symbol.

top_quantile float (default: 0.95)

Quantile of the off-diagonal similarity above which a pair counts as a top pair. The default 0.95 takes the top 5%.

key_added str (default: 'network_enrichment')

Name for the output.

copy bool (default: False)

Return a modified copy instead of mutating in place.

Return type:

AnnData | None

Returns:

None, or the modified copy. Writes uns["mantispy"][key_added] with the 2x2 contingency table (top vs not, known vs not), odds_ratio and pvalue (a one-sided Fisher exact test), the threshold similarity, and the pair counts n_top, n_known and n_pairs.

Raises:
  • KeyError – obsp has no similarity_key, or obs has no gene_key.

  • ValueError – top_quantile is outside (0, 1), or the object has fewer than two annotated profiles.

Notes

Only pairs whose two profiles both carry a gene are counted, so control wells with no gene are left out of the universe. The default reference needs the network on its first call to build the pinned CORUM snapshot; pass edges to avoid any fetch, or to test against a real protein-protein network.