mantispy.metrics.known_relationships#
- mantispy.metrics.known_relationships(adata, net, label_key='Metadata_Perturbation', metric='cosine', use_rep=None, percentile=5.0, name=None)#
Share of annotated pairs that land in either tail of the similarity distribution [Celik et al., 2024].
- Parameters:
adata (
AnnData) – One profile per perturbation, normally the output ofconsensus().net (
DataFrame) – The annotation, with asourcecolumn naming a set and atargetcolumn naming one of its members, asgene_sets()returns it: two perturbations are related when they share a set, which also expresses a mechanism of action shared by several compounds. A pair is counted once whichever way round it appears, and nothing is paired with itself. The reference gene sets — CORUM, hu.MAP, Reactome, SIGNOR, StringDB — are distributed as one pair per row, which becomes this shape withpairs.assign(source=pairs.index.astype(str)).melt(id_vars="source", value_name="target")[["source", "target"]].label_key (
str(default:'Metadata_Perturbation')) –obscolumn holding the perturbation label, normally a gene symbol. Labels are matched to the annotation exactly, as the reference implementation matches them, so a screen that writes its symbols in another case recalls nothing.metric (
str(default:'cosine')) – Similarity between profiles,"cosine"or"pearson".use_rep (
str|None(default:None)) – Measure inobsm[use_rep]instead ofX.percentile (
float(default:5.0)) – Size of each tail, in percent, between 0 and 50. The comparison distribution is every pair of profiles, so the tails adapt to how similar the map is overall.name (
str|None(default:None)) – What to call this annotation in themetriccolumn, asknown_relationships:name. Each source is scored separately, and two rows both calledknown_relationshipswould collide whenmetrics()pivots the table.
- Return type:
- Returns:
A one-row tidy frame with
metric,representation,keyandvalue, so it stacks with the other metrics.valueis the recall, between 0 and 1.- Raises:
KeyError –
obshas no columnlabel_key.ValueError –
label_keyrepeats a label, so a pair of labels would not be a pair of profiles. Aggregate first withadata = mt.tl.consensus(adata).ValueError –
netlackssourceortarget, or relates no two perturbations that were both profiled.ValueError –
percentileis not between 0 and 50, or the sets expand into more pairs than the module’sMAX_PAIRScap allows.
Notes
Read this against the 2 ×
percentilebaseline, not against 100%. Annotated pairs are noisy — two genes share a complex and still do different things — so published maps recover a minority of them, and the number ranks pipelines against each other rather than standing on its own [Celik et al., 2024].Which annotation is supplied matters more than any argument here. Broad sets, such as the hallmark programs, call hundreds of genes related and pull the recall toward the baseline; curated complexes are the stricter test. Score each source on its own, under its own
name, rather than concatenating them: a pair two sources agree on would otherwise be counted once and a source with more pairs would decide the number.The comparison distribution contains the annotated pairs themselves, as in the reference implementation. They are a small minority of all pairs in a real screen, and holding them out would score each source against a different distribution.