mantispy.tl.pathway_coherence#

mantispy.tl.pathway_coherence(adata, net, gene_key='Metadata_Gene', metric='cosine', use_rep=None, min_genes=5, n_permutations=1000, seed=0, key_added='pathway_coherence', copy=False)[source]#

Score how similar the profiles of each gene set’s genes are.

For each set, the mean pairwise similarity among the profiles of its genes is compared with random sets of the same number of profiles. This checks whether a genetic screen recovers known biology.

Parameters:
adata AnnData

One profile per gene, normally the output of consensus().

net DataFrame

A gene-set network from gene_set_network(), or any frame with source and target.

gene_key str (default: 'Metadata_Gene')

obs column holding the gene symbol.

metric str (default: 'cosine')

Similarity between profiles, "cosine" or "pearson".

use_rep str | None (default: None)

Measure in obsm[use_rep] instead of X.

min_genes int (default: 5)

Sets with fewer of their genes present in the screen are skipped.

n_permutations int (default: 1000)

Number of random sets in the null.

seed int (default: 0)

Seed for drawing the random sets.

key_added str (default: 'pathway_coherence')

Name for the output table.

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 set, n_genes, coherence, pvalue and qvalue, sorted by coherence.

Raises:

KeyError – obs has no column gene_key.

Notes

Rank sets by coherence rather than by p-value. With 1000 permutations every strongly coherent set reaches the p-value floor of 1/1001 and ties there. The p-value shows whether a set is coherent, and the coherence orders the sets that are.