Skip to content

Expand EntitySets to member species (no bare set nodes)#45

Merged
adamjohnwright merged 1 commit into
mainfrom
fix/set-expansion-granularity
Jul 15, 2026
Merged

Expand EntitySets to member species (no bare set nodes)#45
adamjohnwright merged 1 commit into
mainfrom
fix/set-expansion-granularity

Conversation

@adamjohnwright

Copy link
Copy Markdown
Contributor

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-109844ERK 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_leaves helper — a pure read mirroring break_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_EXPAND env 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 hasMember only — edges added are minimal, e.g. TP53 +22, ERBB2 −3, not a cartesian).

Benchmarked (mixed, shipped per design-owner decision):

  • held-out curator (16,696 cases): 80.53% → 81.20% (+67)
  • experimental (849): 68.20% → 66.43% — RAF +6 (target), TP53 −19 (12 are DAXX over-coupling, a known noisy co-repressor)

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

…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>
@adamjohnwright
adamjohnwright merged commit 3773464 into main Jul 15, 2026
4 checks passed
@adamjohnwright
adamjohnwright deleted the fix/set-expansion-granularity branch July 15, 2026 20:16
@adamjohnwright

Copy link
Copy Markdown
Contributor Author

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.

@adamjohnwright

Copy link
Copy Markdown
Contributor Author

Final state of this PR (commit ee1fdad):

Shipping (default-on, both neutral-or-positive):

  1. Set-expansion — EntitySets expand to member species at matching granularity (no bare producer-less set nodes). Curator 80.53→81.20%.
  2. Duplicate-edge dedup — removes exact-duplicate catalyst/regulator edges that double-weighted the solver. Neutral (exp 66.43%, cur 81.18%); Pre-NOTCH 40,548→27,552 edges.

Behind a toggle (default-OFF, LNG_CATALYST_BUNDLE=1):
3. Catalyst/regulator bundling — the faithful complex-as-node representation, but it exposes a pre-existing UUID-silo defect (a complex produced by one reaction and catalysing/regulating another is stored as separate un-unified nodes, compounded by set-variant mismatch + non-deterministic set-member selection). Subunit-shatter accidentally masks this via spurious hub paths and scores ~1.2pp higher on experimental — luck, not correctness. Kept opt-in until the canonical entity-node unification is redesigned (documented ceiling; full-merge was −204pp).

Net PR effect at default: set-expansion + dedup only. Bundle inert unless toggled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant