EUCAST import: blocking rows, note restrictions, PK-PD and parser fixes (#310)

Make the EUCAST Clinical Breakpoint Tables import (2019-2026) fail-safe:

- Add blocking rows (NA breakpoints, reason in `note`) where EUCAST gives
  no breakpoint for an organism (IE, "-", Note, brackets, "except"
  clauses, table scope), so as.sir() no longer falls back to broader taxa
- Apply restrictions from EUCAST notes via a curated rule table with a
  completeness guard (e.g. zone diameters for E. coli only)
- Import PK-PD (non-species related) breakpoints 2019-2023, H.
  parainfluenzae MIC breakpoints, and explicit screening thresholds from
  notes (high-level aminoglycosides, cefoxitin MIC, unidentified CoNS)
- Parser fixes: lost Staphylococcus sheets 2019/2020, note keys and
  bodies, struck-through cells, hidden sheets, missing disk contents,
  organism groups, site vocabulary, MIC dilution levels, off-scale
  breakpoints stored as 0.0001
- Keep EUCAST antifungal breakpoints 2019-2025 from WHONET; code WHONET
  streptomycin as STR1 instead of STR (streptoduocin)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Matthijs BerendsandClaude Opus 5.5 authored and GitHub committed 2026-10-02 06:01:58 +02:00
1 parent 5d9974e2b9
commit dab4c47e86
25 files changed
+83693 -58604

No files matched your search

@@ -282,6 +282,24 @@ breakpoints |>
breakpoints <- breakpoints |>
filter(!is.na(WHONET_ABX_CODE))
# a WHONET code can also exist in `antimicrobials` as the code of another
# agent, e.g. WHONET "STR" (streptomycin) is "STR" (streptoduocin) here, so
# compare the code with WHONET's own name of the agent:
whonet_code_check <- breakpoints |>
distinct(WHONET_ABX_CODE) |>
left_join(whonet_antibiotics_raw |> select(WHONET_ABX_CODE, ANTIBIOTIC), by = "WHONET_ABX_CODE") |>
filter(!is.na(ANTIBIOTIC)) |>
mutate(
by_code = as.ab(if_else(WHONET_ABX_CODE == "STR", "STR1", WHONET_ABX_CODE), info = FALSE),
by_name = as.ab(ANTIBIOTIC, info = FALSE)
) |>
filter(is.na(by_code) | is.na(by_name) | by_code != by_name)
# 2026-10-01: SUD (WHONET: sulbactam-durlobactam, CLSI 2024-2026) is
# sulfadimethoxine here, and sulbactam-durlobactam is not in `antimicrobials`
# yet; this must be resolved before these breakpoints can be used. This
# should otherwise be empty:
whonet_code_check
## Build new breakpoints table ----
@@ -304,7 +322,10 @@ breakpoints_new <- breakpoints |>
mo_rank(mo, keep_synonyms = TRUE) == "order" ~ 5,
TRUE ~ 6
),
ab = as.ab(WHONET_ABX_CODE),
# WHONET code "STR" is streptomycin, but in this package "STR" is
# streptoduocin (streptomycin is "STR1"), so as.ab("STR") would return
# the wrong agent
ab = as.ab(if_else(WHONET_ABX_CODE == "STR", "STR1", WHONET_ABX_CODE)),
ref_tbl = ifelse(type == "ECOFF" & is.na(REFERENCE_TABLE), "ECOFF", REFERENCE_TABLE),
disk_dose = POTENCY,
breakpoint_S = ifelse(type == "ECOFF" & is.na(S) & !is.na(ECV_ECOFF), ECV_ECOFF, S),
@@ -505,6 +526,9 @@ dim(clinical_breakpoints)
# Retrieve >= EUCAST 2019 directly from EUCAST ----
# This parses the EUCAST Clinical Breakpoint Tables in data-raw/ and creates
# `breakpoints_eucast`, `eucast_coverage` and merge_eucast_breakpoints(), used
# below to replace the WHONET-based human EUCAST rows that these tables cover
source("data-raw/_reproduction_scripts/reproduction_of_clinical_breakpoints_eucast.R")
@@ -525,8 +549,7 @@ breakpoints_new <- breakpoints_new |>
# and arrange
arrange(desc(guideline), mo, ab, type, host, method)
clinical_breakpoints <- breakpoints_new
clinical_breakpoints <- clinical_breakpoints |> dataset_UTF8_to_ASCII()
clinical_breakpoints <- merge_eucast_breakpoints(breakpoints_new, breakpoints_eucast, eucast_coverage)
usethis::use_data(clinical_breakpoints, overwrite = TRUE, compress = "xz", version = 2)
rm(clinical_breakpoints)
devtools::load_all(".")
File diff suppressed because it is too large. Load diff