mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 02:20:49 +01:00
Store EUCAST MIC breakpoints exactly as published, and compare dilutions in as.sir() (#331)
The reproduction script no longer maps MIC breakpoints to AMR:::COMMON_MIC_VALUES, and also keeps the off-scale S breakpoint of 0.001 mg/L. as.sir() compares through the new internal mic_dilution_level(), so that e.g. an MIC of 0.032 and a breakpoint of 0.03 are the same dilution, and shows the published breakpoints in sir_interpretation_history(). Every parsed breakpoint now holds the address of its workbook cell in breakpoints_eucast_raw, and the script stops if a second reading of the workbooks with readxl does not find the value in that cell. The data sets are rebuilt once, at the end of this PR.
This commit is contained in:
1 parent
844e2581ee
commit
5eed396dce
5 files changed
+119
-19
No files matched your search
@@ -582,6 +582,23 @@ test_that("microorganisms.codes: unique codes for existing names", {
|
||||
expect_true(all(is.na(microorganisms.codes$source) | grepl("^WHONET \\(.+\\)$", microorganisms.codes$source)))
|
||||
})
|
||||
|
||||
test_that("clinical_breakpoints: EUCAST MIC breakpoints are stored as published (#331)", {
|
||||
skip_on_cran()
|
||||
cb <- as.data.frame(clinical_breakpoints, stringsAsFactors = FALSE)
|
||||
cb <- cb[cb$type == "human" & cb$method == "MIC" & cb$guideline %like% "EUCAST" & cb$ref_tbl %like% "file: ", , drop = FALSE]
|
||||
expect_true(nrow(cb) > 0)
|
||||
# these notations do not occur in the EUCAST Clinical Breakpoint Tables
|
||||
published_as <- c("0.032" = 0.032, "0.064" = 0.064, "0.0001" = 0.0001)
|
||||
for (value in names(published_as)) {
|
||||
wrong <- which(cb$breakpoint_S == published_as[value] | cb$breakpoint_R == published_as[value])
|
||||
expect_true(length(wrong) == 0, info = paste("EUCAST MIC breakpoint", value, "in", paste(unique(cb$guideline[wrong]), collapse = ", ")))
|
||||
}
|
||||
# but those as published do, e.g., benzylpenicillin for group A streptococci in v16.1
|
||||
expect_true(any(cb$breakpoint_S == 0.03, na.rm = TRUE))
|
||||
expect_true(any(cb$breakpoint_S == 0.06, na.rm = TRUE))
|
||||
expect_true(any(cb$breakpoint_S == 0.001, na.rm = TRUE))
|
||||
})
|
||||
|
||||
test_that("clinical_breakpoints: consistent and unambiguous", {
|
||||
skip_on_cran()
|
||||
cb <- clinical_breakpoints
|
||||
|
||||
@@ -638,6 +638,29 @@ test_that("custom reference_data: host = NA acts as host-agnostic fallback", {
|
||||
expect_equal(as.character(result), "R")
|
||||
})
|
||||
|
||||
test_that("MIC breakpoints are compared as dilutions, not as their notation (#331)", {
|
||||
skip_on_cran()
|
||||
sir <- function(x, mo, ab, guideline = "EUCAST 2026") {
|
||||
as.character(suppressMessages(suppressWarnings(as.sir(as.mic(x), mo = mo, ab = ab, guideline = guideline, info = FALSE))))
|
||||
}
|
||||
# the published value is the stored value
|
||||
pen <- subset(clinical_breakpoints, guideline == "EUCAST 2026" & type == "human" & method == "MIC" & ab == "PEN" & mo == "B_STRPT_GRPA")
|
||||
expect_identical(unique(pen$breakpoint_S), 0.03)
|
||||
# all notations of this dilution are S, the next dilution is not
|
||||
expect_identical(sir(c(0.03, 0.031, 0.03125, 0.032), "Streptococcus pyogenes", "PEN"), rep("S", 4))
|
||||
expect_identical(sir(0.064, "Streptococcus pyogenes", "PEN"), "R")
|
||||
# the same for an R breakpoint, in the notation of the guideline and of the laboratory
|
||||
expect_identical(mic_dilution_level(c(0.03, 0.032, 0.06, 0.064, 0.12, 0.125, 0.19, 3)), c(0.032, 0.032, 0.064, 0.064, 0.125, 0.125, 0.19, 3))
|
||||
# the off-scale S breakpoint is stored as published, and never leads to S
|
||||
cip <- subset(clinical_breakpoints, guideline == "EUCAST 2026" & type == "human" & method == "MIC" & ab == "CIP" & mo == "B_PSDMN" & is.na(site))
|
||||
expect_identical(unique(cip$breakpoint_S), 0.001)
|
||||
expect_identical(sir(c(0.0005, 0.001, 0.25), "Pseudomonas aeruginosa", "CIP"), c("I", "I", "I"))
|
||||
# the log shows the published breakpoint
|
||||
sir_interpretation_history(clean = TRUE)
|
||||
sir(0.032, "Streptococcus pyogenes", "PEN")
|
||||
expect_identical(sir_interpretation_history(clean = TRUE)$breakpoint_S_R, "0.03-0.03")
|
||||
})
|
||||
|
||||
test_that("Morganella is interpreted as reported, not as M. morganii (#330)", {
|
||||
skip_on_cran()
|
||||
cb <- as.data.frame(clinical_breakpoints, stringsAsFactors = FALSE)
|
||||
|
||||
Reference in new issue
Block a user