1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 19:26:13 +01:00

new EUCAST rules: clinical breakpoints

This commit is contained in:
dr. M.S. (Matthijs) Berends 2018-10-17 17:32:34 +02:00
parent d5a41de711
commit 693f64bdbf
20 changed files with 1165 additions and 171 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.4.0.9003
Date: 2018-10-16
Version: 0.4.0.9004
Date: 2018-10-17
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(
@ -47,6 +47,7 @@ Depends:
Imports:
backports,
curl,
crayon (>= 1.3.0),
data.table (>= 1.9.0),
dplyr (>= 0.7.0),
hms,

View File

@ -161,6 +161,13 @@ exportMethods(skewness.default)
exportMethods(skewness.matrix)
exportMethods(summary.mic)
exportMethods(summary.rsi)
importFrom(crayon,bgGreen)
importFrom(crayon,bgRed)
importFrom(crayon,bgYellow)
importFrom(crayon,black)
importFrom(crayon,blue)
importFrom(crayon,bold)
importFrom(crayon,green)
importFrom(curl,nslookup)
importFrom(data.table,as.data.table)
importFrom(data.table,data.table)

11
NEWS.md
View File

@ -4,13 +4,21 @@
* Function `count_all` to get all available isolates (that like all `portion_*` and `count_*` functions also supports `summarise` and `group_by`), the old `n_rsi` is now an alias of `count_all`
#### Changed
* Big changes to the `EUCAST_rules` function:
* It now also applies rules from the EUCAST 'Breakpoint tables for bacteria', version 8.1, 2018, http://www.eucast.org/clinical_breakpoints/ (see Source of the function)
* There's better error handling when rules cannot be applied (i.e. new values could not be inserted)
* A new `verbose` parameter can be set to `TRUE` to get very specific messages about which columns and rows were affected
* The amount of affected values will now only be measured once per row/column combination
* Data set `septic_patients` now reflects these changes
* Added parameter `combine_IR` (TRUE/FALSE) to functions `portion_df` and `count_df`, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)
* Fix for `portion_*(..., as_percent = TRUE)` when minimal amount of isolates would not be met
* Using `portion_*` functions now throws a warning when total available isolate is below parameter `minimum`
* `as.mo` will not set package name as attribute anymore
* Functions `as.mo`, `as.rsi` and `as.mic` will not set package name as attribute anymore
* Data set `septic_patients` is now a `data.frame`, not a tibble anymore
* Check for `hms::is.hms` in frequency tables
* Removed diacritics from all authors (columns `microorganisms$ref` and `microorganisms.old$ref`) to comply with CRAN policy to only allow ASCII characters
* Fix for `mo_property` not working properly
* Fix for `EUCAST_rules` where some Streptococci would become ceftazidime R in EUCAST rule 4.5
* Support for class `difftime` in frequency tables
* Support for named vectors of class `mo`, useful for `top_freq()`
* AI improvements for `as.mo`:
@ -22,6 +30,7 @@
* In `g.test`, when `sum(x)` is below 1000, suggest Fisher's Exact Test
#### Other
* New dependency on package `crayon`, to support formatted text in the console
* Updated vignettes to comply with README

View File

@ -186,7 +186,7 @@
#' Data set with 2000 blood culture isolates of septic patients
#'
#' An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This \code{data.frame} can be used to practice AMR analysis. For examples, press F1.
#' @format A \code{\link{tibble}} with 2,000 observations and 49 variables:
#' @format A \code{\link{data.frame}} with 2,000 observations and 49 variables:
#' \describe{
#' \item{\code{date}}{date of receipt at the laboratory}
#' \item{\code{hospital_id}}{ID of the hospital, from A to D}
@ -199,7 +199,6 @@
#' \item{\code{mo}}{ID of microorganism, see \code{\link{microorganisms}}}
#' \item{\code{peni:rifa}}{40 different antibiotics with class \code{rsi} (see \code{\link{as.rsi}}); these column names occur in \code{\link{antibiotics}} data set and can be translated with \code{\link{abname}}}
#' }
# source MOLIS (LIS of Certe) - \url{https://www.certe.nl}
#' @examples
#' # ----------- #
#' # PREPARATION #

1104
R/eucast.R

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
#' @rdname as.mic
#' @param x vector
#' @param na.rm a logical indicating whether missing values should be removed
#' @return Ordered factor with new class \code{mic} and new attribute \code{package}
#' @return Ordered factor with new class \code{mic}
#' @keywords mic
#' @export
#' @importFrom dplyr %>%
@ -148,11 +148,8 @@ as.mic <- function(x, na.rm = FALSE) {
list_missing, call. = FALSE)
}
x <- factor(x = x,
levels = lvls,
ordered = TRUE)
x <- factor(x, levels = lvls, ordered = TRUE)
class(x) <- c('mic', 'ordered', 'factor')
attr(x, 'package') <- 'AMR'
x
}
}

View File

@ -22,7 +22,7 @@
#' @rdname as.rsi
#' @param x vector
#' @details The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains only valid antimicrobial interpretations (S and/or I and/or R), and \code{FALSE} otherwise.
#' @return Ordered factor with new class \code{rsi} and new attribute \code{package}
#' @return Ordered factor with new class \code{rsi}
#' @keywords rsi
#' @export
#' @importFrom dplyr %>%
@ -81,9 +81,8 @@ as.rsi <- function(x) {
list_missing, call. = FALSE)
}
x <- x %>% factor(levels = c("S", "I", "R"), ordered = TRUE)
x <- factor(x, levels = c("S", "I", "R"), ordered = TRUE)
class(x) <- c('rsi', 'ordered', 'factor')
attr(x, 'package') <- 'AMR'
x
}
}

View File

@ -202,7 +202,7 @@ Adjust it with any parameter you know from the `ggplot2` package:
septic_patients %>%
select(amox, nitr, fosf, trim, cipr) %>%
ggplot_rsi(datalabels = FALSE,
width = 0.5, colour = "black", size = 1, linetype = 2, alpha = 0.25)
width = 0.5, colour = "purple", size = 1, linetype = 2, alpha = 0.5)
```
![example_3_rsi](man/figures/rsi_example3.png)
@ -225,6 +225,41 @@ septic_patients %>%
You could use this to group on anything in your plots: Gram stain, age (group), genus, geographic location, et cetera.
Is there a significant difference between hospital A and D when it comes to Fosfomycin?
```r
check_A_and_D <- septic_patients %>%
filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
select(hospital_id, fosf) %>% # select the hospitals and fosfomycin
group_by(hospital_id) %>%
count_df(combine_IR = TRUE) %>% # count all isolates per group (hospital_id)
tidyr::spread(hospital_id, Value) %>% # transform output so A and D are columns
select(A, D) %>% # and select these only
as.matrix() # transform to good old matrix for fisher.test
check_A_and_D
# A D
# [1,] 24 33
# [2,] 25 77
```
Total sum is lower than 1,000 so we'd prefer a [Fisher's exact test](https://en.wikipedia.org/wiki/Fisher%27s_exact_test), not a [*G*-test](https://en.wikipedia.org/wiki/G-test) (or its formerly used equivalent, the famous [Chi<sup>2</sup> test](https://en.wikipedia.org/wiki/Chi-squared_test)):
```
fisher.test(check_A_and_D)
#
# Fisher's Exact Test for Count Data
#
# data: .
# p-value = 0.03104
# alternative hypothesis: true odds ratio is not equal to 1
# 95 percent confidence interval:
# 1.054283 4.735995
# sample estimates:
# odds ratio
# 2.228006
```
Well, there you go!
#### MIC
```r

Binary file not shown.

View File

@ -3,14 +3,23 @@
\name{EUCAST_rules}
\alias{EUCAST_rules}
\alias{interpretive_reading}
\title{EUCAST expert rules}
\title{EUCAST rules}
\source{
EUCAST Expert Rules Version 2.0: \cr
Leclercq et al. \strong{EUCAST expert rules in antimicrobial susceptibility testing.} \emph{Clin Microbiol Infect.} 2013;19(2):141-60. \cr
\url{https://doi.org/10.1111/j.1469-0691.2011.03703.x} \cr
\cr
EUCAST Expert Rules Version 3.1 (Intrinsic Resistance and Exceptional Phenotypes Tables): \cr
\url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}
\itemize{
\item{
EUCAST Expert Rules. Version 2.0, 2012. \cr
Leclercq et al. \strong{EUCAST expert rules in antimicrobial susceptibility testing.} \emph{Clin Microbiol Infect.} 2013;19(2):141-60. \cr
\url{https://doi.org/10.1111/j.1469-0691.2011.03703.x}
}
\item{
EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016. \cr
\url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}
}
\item{
EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 8.1, 2018. \cr
\url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_8.1_Breakpoint_Tables.xlsx}
}
}
}
\usage{
EUCAST_rules(tbl, col_mo = "mo", info = TRUE, amcl = "amcl",
@ -25,11 +34,11 @@ EUCAST_rules(tbl, col_mo = "mo", info = TRUE, amcl = "amcl",
line = "line", mero = "mero", mezl = "mezl", mino = "mino",
moxi = "moxi", nali = "nali", neom = "neom", neti = "neti",
nitr = "nitr", norf = "norf", novo = "novo", oflo = "oflo",
peni = "peni", pita = "pita", poly = "poly", pris = "pris",
qida = "qida", rifa = "rifa", roxi = "roxi", siso = "siso",
teic = "teic", tetr = "tetr", tica = "tica", tige = "tige",
tobr = "tobr", trim = "trim", trsu = "trsu", vanc = "vanc",
col_bactid = "bactid")
oxac = "oxac", peni = "peni", pita = "pita", poly = "poly",
pris = "pris", qida = "qida", rifa = "rifa", roxi = "roxi",
siso = "siso", teic = "teic", tetr = "tetr", tica = "tica",
tige = "tige", tobr = "tobr", trim = "trim", trsu = "trsu",
vanc = "vanc", col_bactid = "bactid", verbose = FALSE)
interpretive_reading(...)
}
@ -40,23 +49,25 @@ interpretive_reading(...)
\item{info}{print progress}
\item{amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, peni, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
\item{amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, oxac, peni, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
\item{col_bactid}{Deprecated. Use \code{col_mo} instead.}
\item{verbose}{a logical to indicate whether extensive info should be printed to the console about which rows and columns are effected with their old and new values}
\item{...}{parameters that are passed on to \code{EUCAST_rules}}
}
\value{
table with edited variables of antibiotics.
}
\description{
Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
Apply susceptibility rules as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}. This includes (1) expert rules, (2) intrinsic resistance and (3) inferred resistance as defined in their breakpoint tables.
}
\section{Antibiotics}{
Abbrevations of the column containing antibiotics:
\strong{amcl}: amoxicillin and beta-lactamase inhibitor (\emph{J01CR02}),
\strong{amcl}: amoxicillin+clavulanic acid (\emph{J01CR02}),
\strong{amik}: amikacin (\emph{J01GB06}),
\strong{amox}: amoxicillin (\emph{J01CA04}),
\strong{ampi}: ampicillin (\emph{J01CA01}),
@ -85,7 +96,7 @@ Abbrevations of the column containing antibiotics:
\strong{fosf}: fosfomycin (\emph{J01XX01}),
\strong{fusi}: fusidic acid (\emph{J01XC01}),
\strong{gent}: gentamicin (\emph{J01GB03}),
\strong{imip}: imipenem and cilastatin (\emph{J01DH51}),
\strong{imip}: imipenem (\emph{J01DH51}),
\strong{kana}: kanamycin (\emph{J01GB04}),
\strong{levo}: levofloxacin (\emph{J01MA12}),
\strong{linc}: lincomycin (\emph{J01FF02}),
@ -101,8 +112,8 @@ Abbrevations of the column containing antibiotics:
\strong{norf}: norfloxacin (\emph{J01MA06}),
\strong{novo}: novobiocin (an ATCvet code: \emph{QJ01XX95}),
\strong{oflo}: ofloxacin (\emph{J01MA01}),
\strong{peni}: penicillins, combinations with other antibacterials (\emph{J01RA01}),
\strong{pita}: piperacillin and beta-lactamase inhibitor (\emph{J01CR05}),
\strong{peni}: penicillin (\emph{J01RA01}),
\strong{pita}: piperacillin+tazobactam (\emph{J01CR05}),
\strong{poly}: polymyxin B (\emph{J01XB02}),
\strong{pris}: pristinamycin (\emph{J01FG01}),
\strong{qida}: quinupristin/dalfopristin (\emph{J01FG02}),

View File

@ -175,7 +175,7 @@ When \code{country} will be left blank, guidelines will be taken from EUCAST Exp
Abbrevations of the column containing antibiotics:
\strong{amcl}: amoxicillin and beta-lactamase inhibitor (\emph{J01CR02}),
\strong{amcl}: amoxicillin+clavulanic acid (\emph{J01CR02}),
\strong{amik}: amikacin (\emph{J01GB06}),
\strong{amox}: amoxicillin (\emph{J01CA04}),
\strong{ampi}: ampicillin (\emph{J01CA01}),
@ -204,7 +204,7 @@ Abbrevations of the column containing antibiotics:
\strong{fosf}: fosfomycin (\emph{J01XX01}),
\strong{fusi}: fusidic acid (\emph{J01XC01}),
\strong{gent}: gentamicin (\emph{J01GB03}),
\strong{imip}: imipenem and cilastatin (\emph{J01DH51}),
\strong{imip}: imipenem (\emph{J01DH51}),
\strong{kana}: kanamycin (\emph{J01GB04}),
\strong{levo}: levofloxacin (\emph{J01MA12}),
\strong{linc}: lincomycin (\emph{J01FF02}),
@ -220,8 +220,8 @@ Abbrevations of the column containing antibiotics:
\strong{norf}: norfloxacin (\emph{J01MA06}),
\strong{novo}: novobiocin (an ATCvet code: \emph{QJ01XX95}),
\strong{oflo}: ofloxacin (\emph{J01MA01}),
\strong{peni}: penicillins, combinations with other antibacterials (\emph{J01RA01}),
\strong{pita}: piperacillin and beta-lactamase inhibitor (\emph{J01CR05}),
\strong{peni}: penicillin (\emph{J01RA01}),
\strong{pita}: piperacillin+tazobactam (\emph{J01CR05}),
\strong{poly}: polymyxin B (\emph{J01XB02}),
\strong{pris}: pristinamycin (\emph{J01FG01}),
\strong{qida}: quinupristin/dalfopristin (\emph{J01FG02}),

View File

@ -15,7 +15,7 @@ is.mic(x)
\item{na.rm}{a logical indicating whether missing values should be removed}
}
\value{
Ordered factor with new class \code{mic} and new attribute \code{package}
Ordered factor with new class \code{mic}
}
\description{
This transforms a vector to a new class \code{mic}, which is an ordered factor with valid MIC values as levels. Invalid MIC values will be translated as \code{NA} with a warning.

View File

@ -16,7 +16,7 @@ is.rsi.eligible(x)
\item{x}{vector}
}
\value{
Ordered factor with new class \code{rsi} and new attribute \code{package}
Ordered factor with new class \code{rsi}
}
\description{
This transforms a vector to a new class \code{rsi}, which is an ordered factor with levels \code{S < I < R}. Invalid antimicrobial interpretations will be translated as \code{NA} with a warning.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -4,7 +4,7 @@
\name{septic_patients}
\alias{septic_patients}
\title{Data set with 2000 blood culture isolates of septic patients}
\format{A \code{\link{tibble}} with 2,000 observations and 49 variables:
\format{A \code{\link{data.frame}} with 2,000 observations and 49 variables:
\describe{
\item{\code{date}}{date of receipt at the laboratory}
\item{\code{hospital_id}}{ID of the hospital, from A to D}

View File

@ -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))

View File

@ -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)))
})

View File

@ -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