mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 11:11:54 +02:00
new EUCAST rules: clinical breakpoints
This commit is contained in:
@ -2,18 +2,18 @@ context("count.R")
|
||||
|
||||
test_that("counts work", {
|
||||
# amox resistance in `septic_patients`
|
||||
expect_equal(count_R(septic_patients$amox), 662)
|
||||
expect_equal(count_R(septic_patients$amox), 683)
|
||||
expect_equal(count_I(septic_patients$amox), 3)
|
||||
expect_equal(count_S(septic_patients$amox), 335)
|
||||
expect_equal(count_S(septic_patients$amox), 486)
|
||||
expect_equal(count_R(septic_patients$amox) + count_I(septic_patients$amox),
|
||||
count_IR(septic_patients$amox))
|
||||
expect_equal(count_S(septic_patients$amox) + count_I(septic_patients$amox),
|
||||
count_SI(septic_patients$amox))
|
||||
|
||||
library(dplyr)
|
||||
expect_equal(septic_patients %>% count_S(amcl), 1057)
|
||||
expect_equal(septic_patients %>% count_S(amcl, gent), 1396)
|
||||
expect_equal(septic_patients %>% count_all(amcl, gent), 1517)
|
||||
expect_equal(septic_patients %>% count_S(amcl), 1291)
|
||||
expect_equal(septic_patients %>% count_S(amcl, gent), 1609)
|
||||
expect_equal(septic_patients %>% count_all(amcl, gent), 1747)
|
||||
expect_identical(septic_patients %>% count_all(amcl, gent),
|
||||
septic_patients %>% count_S(amcl, gent) +
|
||||
septic_patients %>% count_IR(amcl, gent))
|
||||
|
@ -8,30 +8,26 @@ test_that("EUCAST rules work", {
|
||||
expect_identical(colnames(septic_patients),
|
||||
colnames(suppressWarnings(EUCAST_rules(septic_patients))))
|
||||
|
||||
a <- data.frame(mo =
|
||||
c("KLEPNE", # Klebsiella pneumoniae
|
||||
"PSEAER", # Pseudomonas aeruginosa
|
||||
"ENTAER"), # Enterobacter aerogenes
|
||||
a <- data.frame(mo = c("KLEPNE", # Klebsiella pneumoniae
|
||||
"PSEAER", # Pseudomonas aeruginosa
|
||||
"ENTAER"), # Enterobacter aerogenes
|
||||
amox = "-", # Amoxicillin
|
||||
stringsAsFactors = FALSE)
|
||||
b <- data.frame(mo =
|
||||
c("KLEPNE", # Klebsiella pneumoniae
|
||||
"PSEAER", # Pseudomonas aeruginosa
|
||||
"ENTAER"), # Enterobacter aerogenes
|
||||
amox = "R", # Amoxicillin
|
||||
b <- data.frame(mo = c("KLEPNE", # Klebsiella pneumoniae
|
||||
"PSEAER", # Pseudomonas aeruginosa
|
||||
"ENTAER"), # Enterobacter aerogenes
|
||||
amox = "R", # Amoxicillin
|
||||
stringsAsFactors = FALSE)
|
||||
expect_identical(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
|
||||
expect_identical(suppressWarnings(interpretive_reading(a, info = TRUE)), b)
|
||||
|
||||
a <- data.frame(mo =
|
||||
c("STAAUR", # Staphylococcus aureus
|
||||
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
||||
coli = "-", # Colistin
|
||||
a <- data.frame(mo = c("STAAUR", # Staphylococcus aureus
|
||||
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
||||
coli = "-", # Colistin
|
||||
stringsAsFactors = FALSE)
|
||||
b <- data.frame(mo =
|
||||
c("STAAUR", # Staphylococcus aureus
|
||||
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
||||
coli = "R", # Colistin
|
||||
b <- data.frame(mo = c("STAAUR", # Staphylococcus aureus
|
||||
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
||||
coli = "R", # Colistin
|
||||
stringsAsFactors = FALSE)
|
||||
expect_equal(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
|
||||
|
||||
@ -48,17 +44,35 @@ test_that("EUCAST rules work", {
|
||||
unique() %>%
|
||||
as.character()),
|
||||
"R")
|
||||
|
||||
# azit and clar must be equal to eryt
|
||||
expect_equal(suppressWarnings(
|
||||
a <- suppressWarnings(
|
||||
septic_patients %>%
|
||||
mutate(azit = as.rsi("R"),
|
||||
clar = as.rsi("R")) %>%
|
||||
transmute(mo,
|
||||
eryt,
|
||||
azit = as.rsi("R"),
|
||||
clar = as.rsi("R")) %>%
|
||||
EUCAST_rules(col_mo = "mo") %>%
|
||||
pull(clar)),
|
||||
suppressWarnings(
|
||||
septic_patients %>%
|
||||
EUCAST_rules(col_mo = "mo") %>%
|
||||
left_join_microorganisms() %>%
|
||||
pull(eryt)))
|
||||
pull(clar))
|
||||
b <- suppressWarnings(
|
||||
septic_patients %>%
|
||||
select(mo, eryt) %>%
|
||||
EUCAST_rules(col_mo = "mo") %>%
|
||||
pull(eryt))
|
||||
|
||||
expect_identical(a[!is.na(b)],
|
||||
b[!is.na(b)])
|
||||
|
||||
# amox is inferred by benzylpenicillin in Kingella kingae
|
||||
expect_equal(
|
||||
as.list(EUCAST_rules(
|
||||
data.frame(mo = as.mo("Kingella kingae"),
|
||||
peni = "S",
|
||||
amox = "-",
|
||||
stringsAsFactors = FALSE)
|
||||
, info = FALSE))$amox,
|
||||
"S")
|
||||
|
||||
expect_message(suppressWarnings(EUCAST_rules(septic_patients, verbose = TRUE)))
|
||||
|
||||
})
|
||||
|
@ -2,8 +2,8 @@ context("portion.R")
|
||||
|
||||
test_that("portions works", {
|
||||
# amox resistance in `septic_patients`
|
||||
expect_equal(portion_R(septic_patients$amox), 0.662, tolerance = 0.0001)
|
||||
expect_equal(portion_I(septic_patients$amox), 0.003, tolerance = 0.0001)
|
||||
expect_equal(portion_R(septic_patients$amox), 0.5827645, tolerance = 0.0001)
|
||||
expect_equal(portion_I(septic_patients$amox), 0.0025597, tolerance = 0.0001)
|
||||
expect_equal(1 - portion_R(septic_patients$amox) - portion_I(septic_patients$amox),
|
||||
portion_S(septic_patients$amox))
|
||||
expect_equal(portion_R(septic_patients$amox) + portion_I(septic_patients$amox),
|
||||
@ -12,17 +12,17 @@ test_that("portions works", {
|
||||
portion_SI(septic_patients$amox))
|
||||
|
||||
expect_equal(septic_patients %>% portion_S(amcl),
|
||||
0.6706853,
|
||||
0.7062363,
|
||||
tolerance = 0.001)
|
||||
expect_equal(septic_patients %>% portion_S(amcl, gent),
|
||||
0.9202373,
|
||||
0.9210074,
|
||||
tolerance = 0.001)
|
||||
|
||||
# amcl+genta susceptibility around 92.1%
|
||||
expect_equal(suppressWarnings(rsi(septic_patients$amcl,
|
||||
septic_patients$gent,
|
||||
interpretation = "S")),
|
||||
0.9202373,
|
||||
0.9210074,
|
||||
tolerance = 0.000001)
|
||||
|
||||
# percentages
|
||||
@ -57,7 +57,7 @@ test_that("portions works", {
|
||||
septic_patients$gent)))
|
||||
expect_equal(suppressWarnings(n_rsi(as.character(septic_patients$amcl,
|
||||
septic_patients$gent))),
|
||||
1576)
|
||||
1828)
|
||||
|
||||
# check for errors
|
||||
expect_error(portion_IR("test", minimum = "test"))
|
||||
@ -83,16 +83,16 @@ test_that("portions works", {
|
||||
})
|
||||
|
||||
test_that("old rsi works", {
|
||||
# amox resistance in `septic_patients` should be around 66.33%
|
||||
expect_equal(suppressWarnings(rsi(septic_patients$amox)), 0.665, tolerance = 0.0001)
|
||||
expect_equal(suppressWarnings(rsi(septic_patients$amox, interpretation = "S")), 1 - 0.665, tolerance = 0.0001)
|
||||
# amox resistance in `septic_patients` should be around 58.53%
|
||||
expect_equal(suppressWarnings(rsi(septic_patients$amox)), 0.5853, tolerance = 0.0001)
|
||||
expect_equal(suppressWarnings(rsi(septic_patients$amox, interpretation = "S")), 1 - 0.5853, tolerance = 0.0001)
|
||||
|
||||
# pita+genta susceptibility around 98.09%
|
||||
expect_equal(suppressWarnings(rsi(septic_patients$pita,
|
||||
septic_patients$gent,
|
||||
interpretation = "S",
|
||||
info = TRUE)),
|
||||
0.9540412,
|
||||
0.9498886,
|
||||
tolerance = 0.0001)
|
||||
|
||||
# count of cases
|
||||
|
Reference in New Issue
Block a user