From c0240269f3ad67de3c9af2c919173440e1ab7211 Mon Sep 17 00:00:00 2001 From: Kevin Schaper Date: Wed, 3 Jun 2026 19:05:58 -0700 Subject: [PATCH] Use merged.monarch context for normalization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous `contexts=["obo", "bioregistry.upper"]` pair interacted with universalizer's `make_id_maps` logic (which builds both canonical and lowercased reverse-IRI maps and merges them) in a way that produced all-uppercase prefix casings for OBO mixed-case anatomies. Specifically the Drosophila and C. elegans anatomy CURIEs were coming out as `FBBT:` and `WBBT:` instead of the canonical `FBbt:` and `WBbt:` shown in the PURLs themselves. Downstream impact in the 2026-06-03 monarch-kg release: every Alliance gene-expression edge whose object was a Drosophila or C. elegans anatomy node went to the dangling pile — 397,914 FBbt and 105,273 WBbt edges, 503,187 total, which was essentially the entire shortfall observed on `alliance_gene_to_expression_edges` (1.45M vs 1.9M expected). Swap to a single Monarch-specific context, `merged.monarch`, which: - ships in linkml/prefixmaps alongside `merged` (Monarch-specific clone of the same data; same canonical case behaviour for the prefixes monarch consumers care about), - aligns kg-phenio with monarch-app's `curie_service.py` (which is also being switched to `merged.monarch` in a companion PR), so the whole Monarch stack uses one curated CURIE convention, - avoids the multi-context combination problem entirely — universalizer builds the reverse map from a single canonical entry per IRI. Verified locally: under `merged.monarch`, `http://purl.obolibrary.org/obo/FBbt_00000001` compresses to `FBbt:00000001` (and `WBbt_...` to `WBbt:...`), as does every other prefix monarch-app exercises (MONDO / GARD / Orphanet / ICD10CM / etc.). Tracking: monarch-initiative/monarch-app#1319. Companion PR: monarch-initiative/monarch-app#1320. --- kg_phenio/normalize.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kg_phenio/normalize.py b/kg_phenio/normalize.py index 71cf5dc..fdf26a4 100644 --- a/kg_phenio/normalize.py +++ b/kg_phenio/normalize.py @@ -12,13 +12,23 @@ def normalize() -> None: None """ + # Use the Monarch-specific `merged.monarch` context from prefixmaps as + # the single source of CURIE↔IRI conventions. The previous + # `["obo", "bioregistry.upper"]` pair interacted with universalizer's + # lowercased-reverse-IRI logic in `make_id_maps` and was producing + # all-uppercase prefix casings for OBO mixed-case anatomies (FBbt → + # FBBT, WBbt → WBBT). That dropped ~503k Drosophila + C. elegans + # gene-expression edges to dangling in the 2026-06-03 monarch-kg build + # (the entire shortfall on `alliance_gene_to_expression_edges`). + # `merged.monarch` is also what monarch-app's `curie_service.py` uses, + # so the whole stack is now aligned. print("Normalizing nodes and categories...") clean_and_normalize_graph( filepath="data/merged/", compressed=False, maps=[], update_categories=True, - contexts=["obo", "bioregistry.upper"], + contexts=["merged.monarch"], namespace_cat_map="", oak_lookup=False, )