Co-occurrence records two or more medical entities mentioned in the same sentence or textual context. In a knowledge graph, it projects Page nodes onto MedicalEntity nodes and makes their textual proximity explicit through COOCCURR relationships. section 7.6.5
Co-occurrence is a starting point rather than a semantic explanation. Traversing ontology paths can validate why entities appear together, interpret their relationship, or discover connections absent from the sentence and biomedical ontology assumptions. section 7.7.3
From co-occurrence to ontology meaning
AIDS and Hepatitis co-occur in blood-donation guidance because both represent infectious-disease risks. SNOMED paths connect them through infectious disease and inflammatory disorder of liver, while additional paths expose liver and immune-system associations. Similar queries retrieve disease entities and surrounding text for Zika virus, or match co-occurring phenotypic features to HPO disease entities.
Listing 7.23 Creating co-occurrence relationships at the sentence level
CALL apoc.periodic.iterate(
"MATCH (n:Page) WHERE exists( (n)-[:MENTIONS_ENTITY]->(:MedicalEntity) )
RETURN n",
"MATCH (n)-[r:MENTIONS_ENTITY]->(m:MedicalEntity)
WITH n, r.sentence_index as sentences, m
UNWIND sentences as sentence
WITH n, sentence, collect(distinct m) as entities
UNWIND range(0, size(entities)-2) as i
UNWIND range(i+1, size(entities)-1) as j
WITH n, sentence, entities, i, j
MATCH (m1) WHERE id(m1) = id(entities[i])
MATCH (m2) WHERE id(m2) = id(entities[j])
WITH n, sentence, entities, i, j, m1, m2
MERGE (m1)-[s:COOCCURR]-(m2)
ON CREATE SET s.count = 1,
s.sentences = [sentence]
ON MATCH SET s.count = s.count + 1,
s.sentences = s.sentences + sentence",
{batchSize: 50})
Inspect the Cypher and APOC query that groups mentions by sentence, generates entity pairs, and maintains COOCCURR counts and sentence lists. section 7.6.5


