mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 05:00:50 +01:00
Store all screening breakpoints under screening agents, and add these agents to antimicrobials (#328)
Implements the decisions ticked in #328, and the behaviour specified in https://github.com/msberends/AMR/pull/339#issuecomment-6577438074: `include_screening` now defaults to NULL, using screening breakpoints for screening agents only. With TRUE, a regular agent also takes these breakpoints, and with FALSE a screening agent gives NA with a note. - antimicrobials gains 13 screening agents, e.g. GEN-S, ERY-S and STR1-S - GEH and STH rows move to GEN-S and STR1-S, and as.sir() keeps accepting both codes - Topical cut-off values move to -S agents with site "Topical" - WHONET-based rows move as ticked, including CLSI cefoxitin for staphylococci and pefloxacin for Salmonella, and EUCAST 2012-2018 cefoxitin MIC - Clinical breakpoints that EUCAST also allows as a screening test get a copy under the -S agent
This commit is contained in:
1 parent
fab20c5eaa
commit
2c98dac7ae
12 files changed
+213
-37
No files matched your search
@@ -931,6 +931,32 @@ antimicrobials <- antimicrobials |>
|
||||
)
|
||||
|
||||
|
||||
# add the screening agents of #328, for all explicit screening tests in clinical_breakpoints; agreed by the maintainer in that issue
|
||||
for (agent in c("CHL", "CIP", "COL", "ERY", "FUS", "GEN", "LVX", "MUP", "NEO", "OFX", "RTP", "STR1", "TOB")) {
|
||||
antimicrobials <- antimicrobials |>
|
||||
mutate(ab = as.character(ab)) |>
|
||||
bind_rows(
|
||||
antimicrobials |>
|
||||
mutate(ab = as.character(ab)) |>
|
||||
filter(ab == agent) |>
|
||||
mutate(
|
||||
abbreviations = list(paste(tolower(ab), "screen")),
|
||||
ab = paste0(ab, "-S"),
|
||||
name = paste(name, "screening test"),
|
||||
cid = NA,
|
||||
atc = list(character(0)),
|
||||
atc_group1 = NA_character_,
|
||||
atc_group2 = NA_character_,
|
||||
synonyms = list(character(0)),
|
||||
oral_ddd = NA_real_,
|
||||
oral_units = NA_character_,
|
||||
iv_ddd = NA_real_,
|
||||
iv_units = NA_character_,
|
||||
loinc = list(character(0))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
# add pretomanid
|
||||
antimicrobials <- antimicrobials %>%
|
||||
mutate(ab = as.character(ab)) %>%
|
||||
|
||||
@@ -729,6 +729,30 @@ breakpoints_new <- breakpoints_new |>
|
||||
arrange(desc(guideline), mo, ab, type, host, method)
|
||||
|
||||
clinical_breakpoints <- merge_eucast_breakpoints(breakpoints_new, breakpoints_eucast, eucast_coverage)
|
||||
|
||||
# Screening tests ----
|
||||
# Every explicit screening test is stored under its screening agent, so that it can never be taken for a breakpoint of the regular agent (#328). The EUCAST rows from its own tables already are, see reproduction_of_clinical_breakpoints_eucast.R. This takes care of the WHONET-based rows, as decided in #328:
|
||||
# - all rows with a site that states screening
|
||||
# - high-level aminoglycoside tests: GEH and STH to GEN-S and STR1-S (as.sir() keeps accepting GEH and STH)
|
||||
# - cefoxitin MIC for S. aureus and S. lugdunensis in EUCAST 2012-2018, which from 2019 on is labelled as screening
|
||||
# - CLSI surrogate tests: cefoxitin for staphylococci, and pefloxacin for Salmonella
|
||||
# EUCAST 2011-2013 rows without a label stay under the regular agent, also as decided in #328.
|
||||
screening_year <- as.integer(gsub("[^0-9]", "", clinical_breakpoints$guideline))
|
||||
screening_genus <- mo_genus(clinical_breakpoints$mo, keep_synonyms = TRUE, language = NULL)
|
||||
is_human <- clinical_breakpoints$type == "human"
|
||||
is_screening <- (!is.na(clinical_breakpoints$site) & grepl("screen", clinical_breakpoints$site, ignore.case = TRUE) & !grepl("-S$", as.character(clinical_breakpoints$ab))) |
|
||||
(is_human & clinical_breakpoints$guideline %like% "EUCAST" & screening_year %in% 2012:2018 & clinical_breakpoints$ab == "FOX" & clinical_breakpoints$method == "MIC" & as.character(clinical_breakpoints$mo) %in% c("B_STPHY_AURS", "B_STPHY_LGDN")) |
|
||||
(is_human & clinical_breakpoints$guideline %like% "CLSI" & clinical_breakpoints$ab == "FOX" & screening_genus %in% "Staphylococcus") |
|
||||
(is_human & clinical_breakpoints$guideline %like% "CLSI" & screening_year >= 2015 & clinical_breakpoints$ab == "PEF" & screening_genus %in% "Salmonella")
|
||||
message("NOTE: ", sum(is_screening), " WHONET-based row(s) moved to their screening agent")
|
||||
clinical_breakpoints$ab <- as.character(clinical_breakpoints$ab)
|
||||
clinical_breakpoints$ab[is_screening] <- paste0(clinical_breakpoints$ab[is_screening], "-S")
|
||||
clinical_breakpoints$ab[clinical_breakpoints$ab == "GEH"] <- "GEN-S"
|
||||
clinical_breakpoints$ab[clinical_breakpoints$ab == "STH"] <- "STR1-S"
|
||||
if (any(!clinical_breakpoints$ab %in% AMR::antimicrobials$ab)) {
|
||||
stop("agent(s) missing from the antimicrobials data set: ", toString(unique(clinical_breakpoints$ab[!clinical_breakpoints$ab %in% AMR::antimicrobials$ab])))
|
||||
}
|
||||
clinical_breakpoints$ab <- as.ab(clinical_breakpoints$ab)
|
||||
usethis::use_data(clinical_breakpoints, overwrite = TRUE, compress = "xz", version = 2)
|
||||
rm(clinical_breakpoints)
|
||||
devtools::load_all(".")
|
||||
@@ -2276,15 +2276,17 @@ breakpoints_eucast <- breakpoints_eucast |>
|
||||
ab_input = gsub("\\s*\\(.*$", "", ab),
|
||||
ab_input = trimws(sub("\\s+(iv|i\\.v\\.|oral)$", "", ab_input, ignore.case = TRUE)),
|
||||
ab = as.ab(ab_input),
|
||||
# use dedicated screening test codes when available (e.g. FOX -> FOX-S).
|
||||
ab = as.ab(if_else(
|
||||
!is.na(site) &
|
||||
site == "Screen" &
|
||||
paste0(as.character(ab), "-S") %in% as.character(antibiotics$ab),
|
||||
paste0(as.character(ab), "-S"),
|
||||
as.character(ab)
|
||||
)
|
||||
))
|
||||
# every screening test is stored under its screening agent (e.g. FOX-S), so that it can never be taken for a breakpoint of the regular agent (#328)
|
||||
is_screening_row = !is.na(site) & grepl("Screen", site, fixed = TRUE),
|
||||
ab = as.ab(if_else(is_screening_row, paste0(as.character(ab), "-S"), as.character(ab))),
|
||||
# the agent now holds the screening meaning; the topical cut-off values remain distinguishable from systemic screening tests by their site
|
||||
site = if_else(site %in% "Topical, Screen", "Topical", site)
|
||||
) |>
|
||||
select(-is_screening_row)
|
||||
if (any(!is.na(breakpoints_eucast$ab_input) & grepl("Screen", breakpoints_eucast$site, fixed = TRUE) & is.na(breakpoints_eucast$ab))) {
|
||||
print(distinct(filter(breakpoints_eucast, grepl("Screen", site, fixed = TRUE), is.na(ab)), ab_input))
|
||||
stop("screening agent(s) missing from the antimicrobials data set, see above")
|
||||
}
|
||||
|
||||
# ab_previously_coerced also logs every intermediate word-by-word fallback
|
||||
# as.ab() tries internally while resolving a route-suffixed name (e.g. for
|
||||
@@ -2475,13 +2477,13 @@ derived_rows <- list()
|
||||
hlar_rows <- breakpoints_eucast |>
|
||||
filter(
|
||||
grepl("Negative test: Isolates with (gentamicin|streptomycin) MIC \u2264", note),
|
||||
ab %in% c("GEN", "STR1"), site %in% "Screen"
|
||||
ab %in% c("GEN-S", "STR1-S"), site %in% "Screen"
|
||||
)
|
||||
for (r in seq_len(nrow(hlar_rows))) {
|
||||
row <- hlar_rows[r, ]
|
||||
# the note of a row can also hold the test for the other agent, so the
|
||||
# agent is taken from the row itself
|
||||
agent <- c(GEN = "gentamicin", STR1 = "streptomycin")[as.character(row$ab)]
|
||||
agent <- c("GEN-S" = "gentamicin", "STR1-S" = "streptomycin")[as.character(row$ab)]
|
||||
if (is.na(agent)) stop("unexpected agent for a high-level aminoglycoside screening test: ", row$ab)
|
||||
neg <- regmatches(row$note, regexec(paste0("Negative test: Isolates with ", agent, " MIC \u2264([0-9]+) mg/L(?: or a zone diameter \u2265([0-9]+) mm)?"), row$note, perl = TRUE))[[1]]
|
||||
pos <- regmatches(row$note, regexec(paste0("Positive test: Isolates with ", agent, " MIC >([0-9]+) mg/L(?: or a zone diameter <([0-9]+) mm)?"), row$note, perl = TRUE))[[1]]
|
||||
@@ -2492,11 +2494,26 @@ for (r in seq_len(nrow(hlar_rows))) {
|
||||
if (!nzchar(value)) next # e.g. no zone diameter given in this version
|
||||
derived_rows[[length(derived_rows) + 1]] <- row |>
|
||||
mutate(
|
||||
ab = as.ab(if (agent == "gentamicin") "GEH" else "STH"), site = NA_character_, is_blocker = FALSE,
|
||||
site = "Screen", is_blocker = FALSE,
|
||||
breakpoint_S = value, breakpoint_R = value,
|
||||
note = sub("^\\[No breakpoint\\][^|]*(\\| )?", "", note)
|
||||
)
|
||||
}
|
||||
# EUCAST states that some clinical breakpoints can also be used as a screening test, e.g. "Erythromycin can be used to screen for macrolide resistance in staphylococci". These stay under the regular agent, with a copy under the screening agent (#328).
|
||||
also_screening <- breakpoints_eucast |>
|
||||
filter(
|
||||
!is_blocker, !grepl("-S$", as.character(ab)), !site %in% c("Screen", "Topical"),
|
||||
(ab == "ERY" & grepl("Erythromycin can be used to screen", note, fixed = TRUE)) |
|
||||
(ab == "TCY" & grepl("Tetracycline can be used to screen", note, fixed = TRUE)) |
|
||||
(ab == "PEN" & grepl("Benzylpenicillin( 1 unit| \\(MIC or disk diffusion\\))? can be used to screen", note)) |
|
||||
(ab == "NAL" & grepl("nalidixic acid disk diffusion test can be used to screen", note, fixed = TRUE)) |
|
||||
(ab == "NOR" & grepl("norfloxacin disk diffusion test can be used to screen", note, fixed = TRUE))
|
||||
) |>
|
||||
mutate(ab = as.ab(paste0(as.character(ab), "-S")), site = "Screen")
|
||||
message("NOTE: ", nrow(also_screening), " clinical breakpoint row(s) copied to their screening agent, as EUCAST also allows them as a screening test")
|
||||
breakpoints_eucast <- breakpoints_eucast |>
|
||||
bind_rows(also_screening)
|
||||
|
||||
fox_mic <- breakpoints_eucast |>
|
||||
filter(
|
||||
ab == "FOX-S", method == "MIC",
|
||||
|
||||
Reference in new issue
Block a user