Expand EntitySets to member species (no bare set nodes)#45
Conversation
…set nodes)
An EntitySet could survive as a standalone network node when a reaction
referenced the set directly (e.g. a phosphatase substrate) while the producing
reaction emitted a specific member — leaving the set orphaned with no producer
(often a curator readout). Root cause: the emission mapper intersected the set's
get_terminal_components (which collapses modified species to their base reference
protein, e.g. p-ERK R-HSA-109844 -> ERK R-HSA-109842) with the VR's resolved
members (which keep the modified form). Empty intersection -> bare-set fallback.
Fix: intersect against _matching_leaves — a pure read that mirrors
break_apart_entity's depth (Complexes atomic unless they contain a set; sets
expand), preserving modified species so the levels line up and the set expands
to its members. Env toggle LNG_SET_EXPAND (default on) keeps the old behavior
for A/B.
Effect (RAF/MAP kinase cascade): 12 -> 2 non-ubiquitin set nodes; connectivity
(expected-change perturbation->readout pairs reachable) 54% -> 77%.
Verified impact across the 10-pathway experimental + held-out curator sets
(shipping despite a mixed experimental result, per design owner):
- held-out curator (16,696 cases): 80.53% -> 81.20% (+67 cases)
- experimental (849 cases): 68.20% -> 66.43%
RAF 36.7% -> 49.0% (+6, the target)
TP53 65.0% -> 57.6% (-19; 12 are DAXX over-coupling, a known noisy
co-repressor gaining spurious reach)
Edges added are minimal and curated (TP53 +22, ERBB2 -3) — not inflation.
Adds TestMatchingLeavesGranularity.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Adds a second generator-faithfulness fix on this branch: drop fully-identical duplicate edges before emission. Distinct virtual reactions of one curated reaction can canonicalize to the same target node; a catalyst attached to each then yields exact-duplicate rows that the solver double-weights in its activator aggregation. Final dedup keyed by (source, target, sign, type, reaction). Scale: 39/92 pathways; Pre-NOTCH 40,548→27,552 (−32%), FGFR2 −7,806, ERBB2 −3,345, RAF −2,191. Suite 139 green. |
|
Final state of this PR (commit ee1fdad): Shipping (default-on, both neutral-or-positive):
Behind a toggle (default-OFF, Net PR effect at default: set-expansion + dedup only. Bundle inert unless toggled. |
Summary
Sets should always decompose to their member species — they should not survive as standalone network nodes (except deliberate exceptions like ubiquitin). But an EntitySet could remain a bare, producer-less node when one reaction referenced the set directly (e.g. a phosphatase substrate) while the producing reaction emitted a specific member. The two are the same curated entity, left unlinked — stranding the set, which is frequently the curator's readout.
Root cause: the emission mapper intersected the set's
get_terminal_components— which collapses modified species down to their base reference protein (p-ERK R-HSA-109844→ERK R-HSA-109842) — with the VR's resolved members, which keep the modified form. Empty intersection → bare-set fallback.Fix: intersect against a new
_matching_leaveshelper — a pure read mirroringbreak_apart_entity's decomposition depth (Complexes atomic unless they contain a set; sets expand), so modified species are preserved and the set expands to its members.LNG_SET_EXPANDenv toggle (default on) keeps the old behavior for A/B.Effect
RAF/MAP kinase cascade: 12 → 2 non-ubiquitin set nodes; expected-change perturbation→readout connectivity 54% → 77% (via real set-expansion, curated
hasMemberonly — edges added are minimal, e.g. TP53 +22, ERBB2 −3, not a cartesian).Benchmarked (mixed, shipped per design-owner decision):
The companion deltasignal benchmark change maps set-typed curator readouts to their member species (since sets no longer have nodes).
Tests
TestMatchingLeavesGranularity+ full non-DB suite (139) green, ruff + mypy clean, coverage 46%.🤖 Generated with Claude Code