Skip to content

About

An LLM‑orchestrated, human‑in‑the‑loop system that takes one Adverse Outcome Pathway (AOP) plus scientific literature and turns it into a structured, Bradford‑Hill‑aligned Weight‑of‑Evidence (WoE) assessment with quantitative confidence scores

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Agentic AOP WoE Assistant

An LLM‑orchestrated, human‑in‑the‑loop system that takes one Adverse Outcome Pathway (AOP) plus scientific literature and turns it into a structured, Bradford‑Hill‑aligned Weight‑of‑Evidence (WoE) assessment with quantitative confidence scores — then hands it to a curator in an interactive review dashboard to validate, edit, and export. It follows the OECD Users' Handbook for developing and assessing AOPs, and it borrows the per‑article consensus ranking from the ONTOX / Verhoeven et al. (2024) WoE‑interactome work.

The whole thing runs end‑to‑end offline, with no API keys, using a deterministic mock LLM and a small built‑in literature corpus, so you can see real output immediately. Swapping to a live LLM (OpenAI / Anthropic) and live literature (OpenAlex / PubMed) is a matter of setting a few environment variables — no code changes.

AOP JSON ─▶ [1] ingest graph ─▶ [2] harvest evidence ─▶ [3] WoE assess (LLM + rubric) ─▶ [4] MCDA score ─▶ [5] review dashboard
             MIE·KEs·KERs·AO     OpenAlex / PubMed / mock   Bradford‑Hill, categorical      confidence 0–100      validate · edit · export

Two worked examples ship with the tool, and the same code scores any AOP JSON:

  • AOP 518 — LXR activation → liver steatosis (default): faithful to AOP‑Wiki, strongly supported throughout with one genuinely Moderate node (the essentiality of de novo fatty‑acid synthesis, because hepatic triglyceride can also accumulate via uptake and reduced export/oxidation). Overall confidence lands at 93.8 / High.
  • AOP 25 — aromatase (Cyp19a1) inhibition → reproductive dysfunction: strong upstream mechanism but a modelling‑based downstream population linkage. Overall confidence lands at 66.2 / Moderate.

That the tool assigns two genuinely different pathways two different confidence bands — for defensible, inspectable reasons — is the point.


Table of contents

  1. What the system does, step by step — the five core objectives
  2. The Bradford‑Hill rubric
  3. The MCDA scoring model
  4. Literature relevance: the WoE consensus metric
  5. How to run it
  6. Repository / notebook contents
  7. The scientific‑grounding notebook (ONTOX / PubMed)
  8. Design choices and guardrails
  9. Scope and honest limitations
  10. References

What the system does, step by step

The pipeline is deliberately five clean stages, each one mapping to one of the project's core objectives. The orchestrator that wires them together is src/pipeline.py; below, each stage names the exact module and function that carries it out and illustrates it on the default steatosis example.

Objective 1 — Ingest the AOP structure (MIE, KEs, KERs, AO) as a machine‑readable graph

What happens. The system reads an AOP‑Wiki‑style JSON export and turns it into a lightweight directed graph: Key Events become nodes, Key Event Relationships become the edges connecting them. It identifies the Molecular Initiating Event (MIE) and the Adverse Outcome (AO) by their type, then walks the adjacent KERs to reconstruct the ordered linear path MIE → … → AO. Before anything downstream runs, it validates the graph — every KER endpoint must reference a Key Event that actually exists — so a malformed pathway fails loudly at ingest instead of silently producing a wrong score.

The parser is intentionally tolerant of the field‑name variation seen in real AOP‑Wiki exports (it accepts upstream/upstream_ke/source, key_events/keyEvents, and so on), and it is dependency‑free so it runs anywhere. An optional to_networkx() helper is provided for teams that want richer graph algorithms.

Where it lives. src/aop_graph.py — the KeyEvent / KeyEventRelationship / AOPGraph dataclasses, load_aop() for parsing, and linear_path() for ordering. The AOP inputs themselves are data/aop_steatosis.json and data/aop25_aromatase.json.

On the example. AOP 518 ingests as MIE (Activation, LXR) → KE1 (Increased expression of LXR‑activated genes) → KE2 (De novo fatty‑acid synthesis) → KE3 (Triglyceride accumulation) → AO (Liver steatosis), with four KERs (KER1–KER4) linking the five events. Each event carries its AOP‑Wiki Event id in its description so the graph stays traceable back to the source.

Objective 2 — Harvest and structure supporting evidence for selected KERs

What happens. For each KER, the system composes a literature query from the two Key‑Event names it connects, retrieves candidate papers, and normalises every hit into a uniform Evidence record: source_id, title, year, abstract, doi, venue, backend, and a relevance score. Hits are ranked by lexical overlap with the query, and the top N per KER are kept. The same harvester also gathers essentiality evidence for each upstream Key Event (querying for knock‑out / reversibility studies), because essentiality is a Key‑Event property that later feeds every KER the event gates.

Three retrieval backends are available behind one interface, so the rest of the pipeline never cares which one is in use:

  • openalex → the OpenAlex /works API (no key required; polite‑pool mailto). Abstracts are reconstructed from OpenAlex's inverted index.
  • pubmed → NCBI E‑utilities (esearch + esummary; an API key is optional).
  • mock → a small in‑repo corpus, namespaced per AOP (selected by the mock_key field in the AOP JSON), so the pipeline retrieves sensible, edge‑specific papers entirely offline. The mock abstracts are short paraphrases written for the demo — not verbatim text from the cited papers.

A clearly‑marked PDF‑ingestion stub (EvidenceHarvester.ingest_pdf) shows the intended integration point for organiser‑provided full‑text; a production build would add GROBID/pdfplumber chunking and passage‑level grounding here.

Where it lives. src/evidence_harvester.py — the Evidence dataclass, EvidenceHarvester with its harvest() dispatcher and the _openalex / _pubmed / _MockCorpus backends, plus the lexical _rank() helper.

On the example. KER1 (LXR activation → LXR‑gene expression) harvests papers such as Schultz 2000 (LXRs control of lipogenesis), Repa 2000 (SREBP‑1c is under LXR control), and Mellor 2016 (nuclear‑receptor initiating events for hepatic steatosis); the downstream KERs harvest Postic 2008, Angrish 2016, and Landesmann 2012. Each paper is tagged with its lexical relevance to the specific edge it was retrieved for.

Objective 3 — Produce Bradford‑Hill‑aligned WoE rationales and categorical ratings

What happens. This is the reasoning stage. For each KER, the system prompts an LLM with (a) the machine‑actionable rubric's anchor descriptors for each criterion and (b) the evidence harvested in Objective 2, and asks it to return a structured judgement per criterion:

  • Biological plausibility (a KER property) — is the KEup → KEdown link consistent with an established, ideally conserved, mechanism?
  • Empirical support (a KER property) — do the data show a causal change, judged on dose‑response, temporal, and incidence concordance plus cross‑study consistency?
  • Essentiality (a Key‑Event property, assessed separately per KE and then folded into each KER it gates) — does blocking or attenuating the upstream event prevent or diminish the downstream events (knock‑out / block‑and‑rescue / reversibility evidence)?

Every criterion comes back as an ordinal rating — HIGH / MODERATE / LOW / NOT_ASSESSED — matching the OECD summary tables, together with the LLM's own self‑confidence (0–1), a rationale grounded in the evidence, and citations to specific source_ids. Each KER assessment must also declare its uncertainties and inconsistencies, with a boolean material flag that later forces curator sign‑off.

Grounded, not trusting. The assessor validates every LLM response against the rubric's output contract before it is allowed downstream:

  • an unrecognised rating is coerced to NOT_ASSESSED (it becomes a visible coverage gap, never a silently invented score);
  • any citation to a source that was not in the retrieved evidence is dropped and flagged (dropped_hallucinated_citation);
  • criteria are annotated with flags (coverage_gap, uncited, dropped_hallucinated_citation) so weaknesses surface rather than hide.

A misbehaving model therefore degrades to an inspectable gap rather than a fluent‑but‑fabricated assessment — the exact failure mode that keeps AOPs out of regulatory practice.

The LLM is reached through a single abstraction (LLMClient.complete_json) that guarantees a parsed JSON object back, with three interchangeable backends: openai (also any OpenAI‑compatible local server such as vLLM/Ollama), anthropic, and a deterministic mock that returns canned, schema‑valid assessments for the worked examples so the whole pipeline runs with no keys.

Where it lives. src/woe_assessor.py (WoEAssessor.assess_ker, assess_ke_essentiality, and the _validate contract check), src/llm_client.py (the provider abstraction), and the rubric in rubric/woe_rubric.json.

Objective 4 — Convert the rationales to quantitative confidence scores (MCDA)

What happens. A deterministic, LLM‑free Multi‑Criteria Decision Analysis converts the ordinal ratings into numbers. Each rating maps to a value (HIGH = 1.0, MODERATE = 0.5, LOW = 0.0, NOT_ASSESSED = excluded), each criterion carries a weight (plausibility 0.40, empirical 0.40, essentiality 0.20), and a weighted sum on a 0–100 scale is computed per KER:

KER score = 100 · Σ(wᵢ · valueᵢ) / Σ(wᵢ over the assessed criteria)

When a criterion is NOT_ASSESSED its weight is redistributed proportionally across the criteria that were assessed, so the score stays on a 0–100 scale and the KER is flagged partial rather than being unfairly penalised.

The overall AOP score is deliberately not a naive average. Regulatory practice treats a pathway as only as strong as its weakest essential linkage, so the aggregation is a weakest‑link‑penalised mean:

AOP score = mean(KER scores) − λ · (mean − min),   with λ = 0.5

λ = 0.5 splits the difference between an optimistic mean (λ = 0) and a strict weakest‑link rule (λ = 1); a curator can push λ toward 1 for a more conservative regulatory context. On top of this, an essential KER that falls in the LOW band caps the whole AOP at Moderate, regardless of the mean. Confidence bands are High ≥ 66.7, Moderate 33.3–66.7, Low < 33.3.

Because the scoring is pure arithmetic sitting on top of the stochastic drafter, a curator can re‑score instantly by editing a rating or a weight — with no LLM re‑run.

Where it lives. src/mcda_scorer.py (MCDAScorer.score_ker and score_aop) driven by rubric/mcda_config.json.

On the example. For steatosis, KER1/KER2/KER4 score 100 and KER3 scores 90 — pulled down by the single Moderate essentiality of de novo fatty‑acid synthesis. The weakest‑link‑penalised mean (mean 97.5, min 90.0, λ 0.5) yields an AOP confidence of 93.8 / High. For the aromatase example the same machinery yields 66.2 / Moderate, because its VTG → fecundity step is multifactorial (KER3 = 50) and its population linkage rests on demographic modelling.

Objective 5 — Present the results in a human‑in‑the‑loop review dashboard

What happens. The scored assessment JSON is injected into a single self‑contained HTML file — no build step, no server, no external data — that gives a curator everything needed to validate, edit, or export the agent's work. Everything the agent produced is treated as a draft until a human reviews it. In the dashboard a curator can:

  • read the AOP as a pathway, with every KER edge coloured by its confidence band;
  • inspect any KER — the three Bradford‑Hill criteria, each with the agent's rating, its self‑confidence, its rationale, and the citations + underlying evidence behind it;
  • edit any rating → the KER and the whole AOP re‑score live, showing an agent‑vs‑curator diff;
  • tune the MCDA weights and λ with live sliders to test sensitivity;
  • see material uncertainties and coverage gaps surfaced explicitly, not buried;
  • rank and filter the consulted literature by consensus relevance — a slider hides papers below a chosen relevance, each KER reports how many of its papers pass, and every evidence item shows its consensus bar (see the next section);
  • mark KERs reviewed (the confidence‑aware curation step) and export the edited assessment as JSON, an OECD‑style Markdown summary table, or the literature‑relevance table as CSV.

Crucially, the dashboard re‑implements the exact MCDA arithmetic from Objective 4 in the browser, so edits re‑score identically to the Python pipeline, and filtering the literature never changes the WoE scores — the arithmetic stays rubric‑driven and auditable; relevance only focuses attention. Curator edits and review status travel with the exported file, so the human sign‑off is part of the artifact.

Where it lives. dashboard/dashboard_template.html (the UI, with a __DATA__ placeholder) → dashboard/steatosis_review_dashboard.html (template + embedded worked‑example data, ready to open).


The Bradford‑Hill rubric (machine‑actionable)

rubric/woe_rubric.json encodes the OECD tailored (evolved) Bradford‑Hill considerations as a schema the LLM and the scorer both consume. Each criterion carries:

  • a plain‑language question the assessor must answer;
  • anchor descriptors for HIGH / MODERATE / LOW that steer the rationale and keep ratings comparable across KERs;
  • a numeric value that drives the MCDA;
  • evidence signals listing the kinds of study that support each rating.
Criterion Applies to Default weight Question in one line
Biological plausibility KER 0.40 Is the KEup → KEdown link consistent with established mechanism?
Empirical support KER 0.40 Do dose‑response, temporal, incidence and cross‑study data support causation?
Essentiality Key Event 0.20 Does blocking/attenuating the upstream KE prevent the downstream events?

Empirical support has three sub‑criteria (dose‑response, temporal, and incidence concordance), each with its own anchors; the demo aggregates them into a single Empirical‑support rating for clarity (ordinal median, capped at Moderate if dose‑response is LOW). A fourth, optional Quantitative understanding consideration is defined and reported alongside WoE but excluded from the default score (it can be enabled via the MCDA config). Ratings are constrained to the ordinal HIGH / MODERATE / LOW / NOT_ASSESSED scale to match OECD summary tables, and NOT_ASSESSED is excluded from aggregation and surfaced to the curator as a coverage gap.


The MCDA scoring model

rubric/mcda_config.json holds the value function, criterion weights, confidence bands, and the AOP aggregation rule — all editable by the curator in the dashboard. The defaults:

value(HIGH)=1.0   value(MODERATE)=0.5   value(LOW)=0.0   value(NOT_ASSESSED)=excluded

KER score = 100 · Σ(wᵢ · valueᵢ) / Σ(wᵢ over assessed criteria)      # weights renormalise on gaps
AOP score = mean(KER scores) − λ·(mean − min)                        # weakest‑link penalised, λ=0.5

bands: HIGH ≥ 66.7 · MODERATE 33.3–66.7 · LOW < 33.3
essential‑KER override: an essential KER in the LOW band caps the AOP band at MODERATE

The design principle is a deterministic, auditable score on top of a stochastic drafter: the LLM proposes ordinal ratings, but the arithmetic is fixed and the curator owns the weights.


Literature relevance: the WoE consensus metric

The harvester tags each paper with a lexical relevance to the single KER it was retrieved for. That answers "does this paper mention this edge?" — but not "how much does this paper corroborate the confident core of the whole pathway?", which is what a curator actually triages on.

src/article_relevance.py answers the second question with the consensus metric from the ONTOX / Verhoeven et al. (2024) WoE‑interactome work, computed on this run's KER scores:

for each article A:
    supported_KERs(A)   = the KERs whose evidence includes A
    cumulative_score(A) = Σ confidence(KER)  over KER in supported_KERs(A)
    consensus_relevance = cumulative_score(A) / max over articles

A paper that backs several high‑confidence KERs ranks above one backing a single edge. Two bases are reported per paper: retrieved (faithful to the reference — a paper supports a KER if it was harvested for it) and cited (stricter — a paper supports a KER only if the assessor actually cited it in a rationale). The function is pure and dependency‑free, so it re‑runs instantly in the dashboard on curator‑edited scores and can be recomputed from a saved assessment JSON.

On the steatosis run this ranks the six consulted papers with Schultz 2000 at the top (it backs two 100‑confidence KERs, cumulative WoE 200, relevance 1.00). In the dashboard this becomes a triage lens — a slider that ranks and hides low‑relevance papers — and, importantly, filtering never changes the WoE scores; it only focuses attention, and it travels with the JSON/CSV export.


How to run it

Option A — Google Colab, one click, no install

Open AOP_WoE_pipeline_colab.ipynb at colab.research.google.com (File ▸ Upload notebook), then Runtime ▸ Run all. The notebook is self‑contained: it recreates the entire project on a fresh runtime (writing each source file from a %%writefile cell), runs the steatosis example end‑to‑end in mock mode, prints an OECD‑style summary table, shows the literature‑relevance ranking, and renders the review dashboard inline. No API keys, no GPU. A download button gives you the standalone dashboard file to open full‑screen.

Option B — Locally from the command line

Mock mode needs nothing beyond the Python standard library:

# default steatosis example → 93.8 / High
python src/pipeline.py --aop data/aop_steatosis.json --out output/steatosis_assessment.json

# then open the dashboard (data is injected from the template)
python - <<'PY'
import pathlib
tpl  = pathlib.Path('dashboard/dashboard_template.html').read_text()
data = pathlib.Path('output/steatosis_assessment.json').read_text().replace('</', '<\\/')
pathlib.Path('dashboard/steatosis_review_dashboard.html').write_text(tpl.replace('__DATA__', data))
PY
# open dashboard/steatosis_review_dashboard.html in a browser

Swap the input to data/aop25_aromatase.json to score the aromatase example (66.2 / Moderate).

Option C — Going live (real LLM + real literature)

The pipeline talks to the model only through LLMClient, and validates every response against the rubric, so a live run degrades to a visible coverage gap rather than a silent wrong score.

# LLM: OpenAI‑compatible (incl. local vLLM/Ollama via WOE_LLM_BASE_URL) or Anthropic
export WOE_LLM_PROVIDER=openai         # or anthropic
export WOE_LLM_MODEL=gpt-4o-mini       # any chat model
export WOE_LLM_API_KEY=sk-...
# export WOE_LLM_BASE_URL=http://localhost:8000/v1   # for a local server

# Literature: OpenAlex needs no key; PubMed key optional
python src/pipeline.py --aop data/aop_steatosis.json \
    --out output/steatosis_assessment.json --evidence-backend openalex

requirements.txt lists the optional extras (openai, anthropic, networkx); install only the backend you intend to use.


Repository / notebook contents

The archive ships these files. The Colab notebook is the entry point and recreates the full src/ / rubric/ / data/ / dashboard/ tree on any runtime, so the individual source modules live embedded inside it.

File Role
AOP_WoE_pipeline_colab.ipynb Self‑contained, one‑click notebook: builds the project, runs the steatosis example, renders the dashboard inline.
build_notebook.py Assembles the notebook above by embedding each source file in a %%writefile cell.
article_relevance.py The per‑article WoE consensus relevance metric (ranking + filter).
steatosis_review_dashboard.html The human‑in‑the‑loop review console with the steatosis assessment already embedded.
steatosis_pubmed_aop (1).ipynb Scientific‑grounding notebook: a Python port of the ONTOX xploreaop pipeline with live PubMed mining (see below).
requirements.txt Optional dependencies for the live LLM / literature backends.
README.md Project documentation.

The project tree recreated by the notebook:

aop-woe/
├── rubric/
│   ├── woe_rubric.json          # machine‑actionable Bradford‑Hill rubric  (Objective 3)
│   └── mcda_config.json         # weights, value function, aggregation      (Objective 4)
├── src/
│   ├── aop_graph.py             # [1] AOP JSON → directed KE/KER graph       (Objective 1)
│   ├── evidence_harvester.py    # [2] OpenAlex / PubMed / mock + PDF stub    (Objective 2)
│   ├── llm_client.py            # LLM abstraction (openai / anthropic / mock)
│   ├── woe_assessor.py          # [3] rubric‑constrained WoE rationales      (Objective 3)
│   ├── mcda_scorer.py           # [4] deterministic 0–100 confidence         (Objective 4)
│   ├── article_relevance.py     # per‑paper WoE consensus relevance
│   └── pipeline.py              # orchestrator wiring the five stages
├── data/
│   ├── aop_steatosis.json       # worked example: LXR → liver steatosis (AOP 518)
│   └── aop25_aromatase.json     # worked example: aromatase inhibition (AOP 25)
├── output/
│   └── steatosis_assessment.json   # generated assessment (dashboard input)
└── dashboard/
    ├── dashboard_template.html     # UI template (data placeholder)
    └── steatosis_review_dashboard.html   # template + embedded data          (Objective 5)

The scientific‑grounding notebook (ONTOX / PubMed)

steatosis_pubmed_aop (1).ipynb is a separate, complementary artifact that establishes the scientific provenance of the consensus‑relevance idea used above. It is a Python port of the ONTOX xploreaop pipeline, reproducing and extending the WoE AOP‑network method of Verhoeven et al. (2024). It follows the authors' four‑stage protocol: query PubMed via the NCBI E‑utilities API for chemical‑induced liver‑steatosis literature, apply article inclusion, extract the KER interactome, and score it. It first validates the port by running the scoring engine on the authors' own curated dataset and checking that it reproduces their published edge weights and node frequencies, then mines fresh PubMed data. This is where the "how much does a paper corroborate the confident core of the pathway" metric comes from that the main agent reuses per‑run.


Design choices and guardrails

  • Grounded, not trusting. Rationales must cite retrieved sources; citations that don't match the evidence set are stripped and flagged. This is the guardrail against a fluent but fabricated assessment.
  • Deterministic scoring on top of a stochastic drafter. The LLM proposes ordinal ratings; the arithmetic is fixed and auditable, and the curator owns the weights.
  • Essentiality is a Key‑Event property, assessed per KE and aggregated into each KER it gates — matching the OECD framing rather than treating it as a free‑floating KER criterion.
  • Human‑in‑the‑loop by construction. Everything the agent produces is a draft until a curator reviews it; edits and review status travel with the exported assessment.
  • Relevance filtering is a lens, not a lever. Ranking or hiding papers never changes a WoE score; the score stays rubric‑driven and reproducible.

Scope and honest limitations

This is a prototype, and it is explicit about where the illustrative parts end:

  • The mock corpus and mock LLM produce illustrative content that reflects the genuine science but is not a substitute for a real literature‑grounded run. The mock abstracts are paraphrases, not verbatim source text.
  • Full‑text PDF ingestion is a clearly‑marked stub (EvidenceHarvester.ingest_pdf); a production build would add GROBID/pdfplumber chunking and passage‑level grounding.
  • The empirical sub‑criteria (dose/temporal/incidence) are prompted and can be surfaced per‑KER; the demo aggregates them into a single Empirical‑support rating for clarity.
  • There is no authentication or multi‑user state; the dashboard keeps edits in memory and exports to file — by design, so it is trivially hostable with nothing to leak.

References

About

An LLM‑orchestrated, human‑in‑the‑loop system that takes one Adverse Outcome Pathway (AOP) plus scientific literature and turns it into a structured, Bradford‑Hill‑aligned Weight‑of‑Evidence (WoE) assessment with quantitative confidence scores

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages