2018-02-21 11:52:31 +01:00
# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Analysis #
# #
# AUTHORS #
# Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
# #
# LICENCE #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License version 2.0, #
# as published by the Free Software Foundation. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# ==================================================================== #
#' EUCAST expert rules
#'
#' Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
#' @param tbl table with antibiotic columns, like e.g. \code{amox} and \code{amcl}
2018-08-31 13:36:19 +02:00
#' @param col_mo column name of the bacteria ID in \code{tbl} - values of this column should be present in \code{microorganisms$mo}, see \code{\link{microorganisms}}
2018-02-21 11:52:31 +01:00
#' @param info print progress
2018-08-31 13:36:19 +02:00
#' @param 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.
#' @param col_bactid Deprecated. Use \code{col_mo} instead.
2018-02-21 11:52:31 +01:00
#' @param ... parameters that are passed on to \code{EUCAST_rules}
2018-08-31 13:36:19 +02:00
#' @section Antibiotics:
2018-07-26 16:30:42 +02:00
#' Abbrevations of the column containing antibiotics:
#'
#' \strong{amcl}: amoxicillin and beta-lactamase inhibitor (\emph{J01CR02}),
#' \strong{amik}: amikacin (\emph{J01GB06}),
#' \strong{amox}: amoxicillin (\emph{J01CA04}),
#' \strong{ampi}: ampicillin (\emph{J01CA01}),
#' \strong{azit}: azithromycin (\emph{J01FA10}),
#' \strong{azlo}: azlocillin (\emph{J01CA09}),
#' \strong{aztr}: aztreonam (\emph{J01DF01}),
#' \strong{cefa}: cefaloridine (\emph{J01DB02}),
#' \strong{cfep}: cefepime (\emph{J01DE01}),
#' \strong{cfot}: cefotaxime (\emph{J01DD01}),
#' \strong{cfox}: cefoxitin (\emph{J01DC01}),
#' \strong{cfra}: cefradine (\emph{J01DB09}),
#' \strong{cfta}: ceftazidime (\emph{J01DD02}),
#' \strong{cftr}: ceftriaxone (\emph{J01DD04}),
#' \strong{cfur}: cefuroxime (\emph{J01DC02}),
#' \strong{chlo}: chloramphenicol (\emph{J01BA01}),
#' \strong{cipr}: ciprofloxacin (\emph{J01MA02}),
#' \strong{clar}: clarithromycin (\emph{J01FA09}),
#' \strong{clin}: clindamycin (\emph{J01FF01}),
#' \strong{clox}: flucloxacillin (\emph{J01CF05}),
#' \strong{coli}: colistin (\emph{J01XB01}),
#' \strong{czol}: cefazolin (\emph{J01DB04}),
#' \strong{dapt}: daptomycin (\emph{J01XX09}),
#' \strong{doxy}: doxycycline (\emph{J01AA02}),
#' \strong{erta}: ertapenem (\emph{J01DH03}),
#' \strong{eryt}: erythromycin (\emph{J01FA01}),
#' \strong{fosf}: fosfomycin (\emph{J01XX01}),
#' \strong{fusi}: fusidic acid (\emph{J01XC01}),
#' \strong{gent}: gentamicin (\emph{J01GB03}),
#' \strong{imip}: imipenem and cilastatin (\emph{J01DH51}),
#' \strong{kana}: kanamycin (\emph{J01GB04}),
#' \strong{levo}: levofloxacin (\emph{J01MA12}),
#' \strong{linc}: lincomycin (\emph{J01FF02}),
#' \strong{line}: linezolid (\emph{J01XX08}),
#' \strong{mero}: meropenem (\emph{J01DH02}),
#' \strong{mezl}: mezlocillin (\emph{J01CA10}),
#' \strong{mino}: minocycline (\emph{J01AA08}),
#' \strong{moxi}: moxifloxacin (\emph{J01MA14}),
#' \strong{nali}: nalidixic acid (\emph{J01MB02}),
#' \strong{neom}: neomycin (\emph{J01GB05}),
#' \strong{neti}: netilmicin (\emph{J01GB07}),
#' \strong{nitr}: nitrofurantoin (\emph{J01XE01}),
#' \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{poly}: polymyxin B (\emph{J01XB02}),
#' \strong{pris}: pristinamycin (\emph{J01FG01}),
#' \strong{qida}: quinupristin/dalfopristin (\emph{J01FG02}),
#' \strong{rifa}: rifampicin (\emph{J04AB02}),
#' \strong{roxi}: roxithromycin (\emph{J01FA06}),
#' \strong{siso}: sisomicin (\emph{J01GB08}),
#' \strong{teic}: teicoplanin (\emph{J01XA02}),
#' \strong{tetr}: tetracycline (\emph{J01AA07}),
#' \strong{tica}: ticarcillin (\emph{J01CA13}),
#' \strong{tige}: tigecycline (\emph{J01AA12}),
#' \strong{tobr}: tobramycin (\emph{J01GB01}),
#' \strong{trim}: trimethoprim (\emph{J01EA01}),
#' \strong{trsu}: sulfamethoxazole and trimethoprim (\emph{J01EE01}),
#' \strong{vanc}: vancomycin (\emph{J01XA01}).
#' @keywords interpretive eucast reading resistance
2018-02-21 11:52:31 +01:00
#' @rdname EUCAST
#' @export
#' @importFrom dplyr %>% left_join select
2018-02-22 20:48:48 +01:00
#' @return table with edited variables of antibiotics.
2018-02-21 11:52:31 +01:00
#' @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
2018-03-23 14:46:02 +01:00
#' 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}
2018-02-21 11:52:31 +01:00
#' @examples
2018-05-02 14:56:25 +02:00
#' a <- EUCAST_rules(septic_patients)
2018-08-31 13:36:19 +02:00
#' a <- data.frame(mo = c("STAAUR", # Staphylococcus aureus
#' "ENCFAE", # Enterococcus faecalis
#' "ESCCOL", # Escherichia coli
#' "KLEPNE", # Klebsiella pneumoniae
#' "PSEAER"), # Pseudomonas aeruginosa
#' vanc = "-", # Vancomycin
#' amox = "-", # Amoxicillin
#' coli = "-", # Colistin
#' cfta = "-", # Ceftazidime
#' cfur = "-", # Cefuroxime
2018-02-22 21:37:10 +01:00
#' stringsAsFactors = FALSE)
#' a
2018-04-02 16:05:09 +02:00
#'
2018-03-13 14:40:52 +01:00
#' b <- EUCAST_rules(a)
2018-02-22 21:37:10 +01:00
#' b
2018-02-21 11:52:31 +01:00
EUCAST_rules <- function ( tbl ,
2018-08-31 13:36:19 +02:00
col_mo = ' mo' ,
2018-02-21 11:52:31 +01:00
info = TRUE ,
amcl = ' amcl' ,
amik = ' amik' ,
amox = ' amox' ,
ampi = ' ampi' ,
azit = ' azit' ,
2018-07-26 16:30:42 +02:00
azlo = ' azlo' ,
2018-02-21 11:52:31 +01:00
aztr = ' aztr' ,
cefa = ' cefa' ,
cfep = ' cfep' ,
cfot = ' cfot' ,
cfox = ' cfox' ,
2018-07-26 16:30:42 +02:00
cfra = ' cfra' ,
2018-02-21 11:52:31 +01:00
cfta = ' cfta' ,
cftr = ' cftr' ,
cfur = ' cfur' ,
chlo = ' chlo' ,
cipr = ' cipr' ,
clar = ' clar' ,
clin = ' clin' ,
clox = ' clox' ,
coli = ' coli' ,
czol = ' czol' ,
dapt = ' dapt' ,
doxy = ' doxy' ,
erta = ' erta' ,
eryt = ' eryt' ,
fosf = ' fosf' ,
fusi = ' fusi' ,
gent = ' gent' ,
imip = ' imip' ,
kana = ' kana' ,
levo = ' levo' ,
linc = ' linc' ,
line = ' line' ,
mero = ' mero' ,
2018-07-26 16:30:42 +02:00
mezl = ' mezl' ,
2018-02-21 11:52:31 +01:00
mino = ' mino' ,
moxi = ' moxi' ,
nali = ' nali' ,
neom = ' neom' ,
neti = ' neti' ,
nitr = ' nitr' ,
norf = ' norf' ,
2018-07-26 16:30:42 +02:00
novo = ' novo' ,
2018-02-21 11:52:31 +01:00
oflo = ' oflo' ,
peni = ' peni' ,
pita = ' pita' ,
poly = ' poly' ,
2018-07-26 16:30:42 +02:00
pris = ' pris' ,
2018-02-21 11:52:31 +01:00
qida = ' qida' ,
rifa = ' rifa' ,
roxi = ' roxi' ,
siso = ' siso' ,
teic = ' teic' ,
tetr = ' tetr' ,
tica = ' tica' ,
tige = ' tige' ,
tobr = ' tobr' ,
trim = ' trim' ,
trsu = ' trsu' ,
2018-08-31 13:36:19 +02:00
vanc = ' vanc' ,
col_bactid = ' bactid' ) {
2018-03-23 14:46:02 +01:00
EUCAST_VERSION <- " 3.1"
2018-08-31 13:36:19 +02:00
if ( col_bactid %in% colnames ( tbl ) ) {
col_mo <- col_bactid
warning ( " Use of `col_bactid` is deprecated. Use `col_mo` instead." )
}
if ( ! col_mo %in% colnames ( tbl ) ) {
stop ( ' Column ' , col_mo , ' not found.' , call. = FALSE )
2018-02-21 11:52:31 +01:00
}
2018-04-02 16:05:09 +02:00
2018-03-23 14:46:02 +01:00
# check columns
2018-07-26 16:30:42 +02:00
col.list <- c ( amcl , amik , amox , ampi , azit , azlo , aztr , cefa , cfra , cfep , cfot ,
2018-03-23 14:46:02 +01:00
cfox , cfta , cftr , cfur , chlo , cipr , clar , clin , clox , coli ,
czol , dapt , doxy , erta , eryt , fosf , fusi , gent , imip , kana ,
2018-07-26 16:30:42 +02:00
levo , linc , line , mero , mezl , mino , moxi , nali , neom , neti , nitr ,
novo , norf , oflo , peni , pita , poly , pris , qida , rifa , roxi , siso ,
2018-03-23 14:46:02 +01:00
teic , tetr , tica , tige , tobr , trim , trsu , vanc )
2018-04-25 15:33:58 +02:00
col.list <- check_available_columns ( tbl = tbl , col.list = col.list , info = info )
amcl <- col.list [amcl ]
amik <- col.list [amik ]
amox <- col.list [amox ]
ampi <- col.list [ampi ]
azit <- col.list [azit ]
2018-07-26 16:30:42 +02:00
azlo <- col.list [azlo ]
2018-04-25 15:33:58 +02:00
aztr <- col.list [aztr ]
cefa <- col.list [cefa ]
cfep <- col.list [cfep ]
cfot <- col.list [cfot ]
cfox <- col.list [cfox ]
2018-07-26 16:30:42 +02:00
cfra <- col.list [cfra ]
2018-04-25 15:33:58 +02:00
cfta <- col.list [cfta ]
cftr <- col.list [cftr ]
cfur <- col.list [cfur ]
chlo <- col.list [chlo ]
cipr <- col.list [cipr ]
clar <- col.list [clar ]
clin <- col.list [clin ]
clox <- col.list [clox ]
coli <- col.list [coli ]
czol <- col.list [czol ]
dapt <- col.list [dapt ]
doxy <- col.list [doxy ]
erta <- col.list [erta ]
eryt <- col.list [eryt ]
fosf <- col.list [fosf ]
fusi <- col.list [fusi ]
gent <- col.list [gent ]
imip <- col.list [imip ]
kana <- col.list [kana ]
levo <- col.list [levo ]
linc <- col.list [linc ]
line <- col.list [line ]
mero <- col.list [mero ]
2018-07-26 16:30:42 +02:00
mezl <- col.list [mezl ]
2018-04-25 15:33:58 +02:00
mino <- col.list [mino ]
moxi <- col.list [moxi ]
nali <- col.list [nali ]
neom <- col.list [neom ]
neti <- col.list [neti ]
nitr <- col.list [nitr ]
norf <- col.list [norf ]
2018-07-26 16:30:42 +02:00
novo <- col.list [novo ]
2018-04-25 15:33:58 +02:00
oflo <- col.list [oflo ]
peni <- col.list [peni ]
pita <- col.list [pita ]
poly <- col.list [poly ]
2018-07-26 16:30:42 +02:00
pris <- col.list [pris ]
2018-04-25 15:33:58 +02:00
qida <- col.list [qida ]
rifa <- col.list [rifa ]
roxi <- col.list [roxi ]
siso <- col.list [siso ]
teic <- col.list [teic ]
tetr <- col.list [tetr ]
tica <- col.list [tica ]
tige <- col.list [tige ]
tobr <- col.list [tobr ]
trim <- col.list [trim ]
trsu <- col.list [trsu ]
vanc <- col.list [vanc ]
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
total <- 0
2018-02-26 14:37:40 +01:00
total_rows <- integer ( 0 )
2018-04-02 16:05:09 +02:00
2018-03-23 14:46:02 +01:00
# helper function for editing the table
2018-07-26 16:30:42 +02:00
edit_rsi <- function ( to , rows , cols , EUCAST_rule = " " ) {
# later: use this as attribute for the edited observations
EUCAST_rule <- trimws ( paste ( " EUCAST rule" , EUCAST_rule ) )
2018-02-21 11:52:31 +01:00
cols <- cols [ ! is.na ( cols ) ]
if ( length ( rows ) > 0 & length ( cols ) > 0 ) {
tbl [rows , cols ] <<- to
total <<- total + ( length ( rows ) * length ( cols ) )
2018-02-26 14:37:40 +01:00
total_rows <<- c ( total_rows , rows )
2018-02-21 11:52:31 +01:00
}
}
2018-04-02 16:05:09 +02:00
2018-07-26 16:30:42 +02:00
# join to microorganisms data set
2018-09-01 21:19:46 +02:00
col_mo_original <- NULL
2018-08-31 13:36:19 +02:00
if ( ! tbl %>% pull ( col_mo ) %>% is.mo ( ) ) {
2018-09-01 21:19:46 +02:00
col_mo_original <- tbl %>% pull ( col_mo )
tbl [ , col_mo ] <- as.mo ( tbl [ , col_mo ] )
2018-07-23 14:14:03 +02:00
}
2018-08-31 13:36:19 +02:00
tbl <- tbl %>% left_join_microorganisms ( by = col_mo , suffix = c ( " _tempmicroorganisms" , " " ) )
2018-04-02 16:05:09 +02:00
2018-03-23 14:46:02 +01:00
# antibiotic classes
aminoglycosides <- c ( tobr , gent , kana , neom , neti , siso )
tetracyclines <- c ( doxy , mino , tetr ) # since EUCAST v3.1 tige(cycline) is set apart
polymyxins <- c ( poly , coli )
macrolides <- c ( eryt , azit , roxi , clar ) # since EUCAST v3.1 clinda is set apart
glycopeptides <- c ( vanc , teic )
2018-07-26 16:30:42 +02:00
streptogramins <- c ( qida , pris ) # should officially also be quinupristin/dalfopristin
2018-03-23 14:46:02 +01:00
cephalosporins <- c ( cfep , cfot , cfox , cfra , cfta , cftr , cfur , czol )
2018-02-21 11:52:31 +01:00
carbapenems <- c ( erta , imip , mero )
2018-03-23 14:46:02 +01:00
aminopenicillins <- c ( ampi , amox )
2018-07-26 16:30:42 +02:00
ureidopenicillins <- c ( pita , azlo , mezl )
2018-03-23 14:46:02 +01:00
fluoroquinolones <- c ( oflo , cipr , norf , levo , moxi )
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
if ( info == TRUE ) {
2018-03-23 14:46:02 +01:00
cat (
paste0 (
' \nApplying rules to ' ,
2018-02-26 14:37:40 +01:00
tbl [ ! is.na ( tbl $ genus ) , ] %>% nrow ( ) %>% format ( big.mark = " ," ) ,
2018-03-23 14:46:02 +01:00
' rows according to "EUCAST Expert Rules Version ' , EUCAST_VERSION , ' "\n' )
)
2018-02-21 11:52:31 +01:00
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 1: Intrinsic resistance in Enterobacteriaceae ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 1: Intrinsic resistance in Enterobacteriaceae\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# Intrisiek R for this group
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ family == ' Enterobacteriaceae' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( peni , glycopeptides , fusi , macrolides , linc , streptogramins , rifa , dapt , line ) )
2018-02-21 11:52:31 +01:00
# Citrobacter
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , tica ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfox ) )
2018-02-21 11:52:31 +01:00
# Enterobacter
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Enterobacter cloacae' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfox ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Enterobacter aerogenes' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfox ) )
2018-02-21 11:52:31 +01:00
# Escherichia
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Escherichia hermanni' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , tica ) )
2018-02-21 11:52:31 +01:00
# Hafnia
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Hafnia alvei' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfox ) )
2018-02-21 11:52:31 +01:00
# Klebsiella
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Klebsiella' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , tica ) )
2018-02-21 11:52:31 +01:00
# Morganella / Proteus
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Morganella morganii' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , tetracyclines , polymyxins , nitr ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Proteus mirabilis' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( tetracyclines , tige , polymyxins , nitr ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Proteus penneri' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , czol , cfur , tetracyclines , tige , polymyxins , nitr ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Proteus vulgaris' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , czol , cfur , tetracyclines , tige , polymyxins , nitr ) )
2018-02-21 11:52:31 +01:00
# Providencia
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Providencia rettgeri' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfur , tetracyclines , tige , polymyxins , nitr ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Providencia stuartii' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfur , tetracyclines , tige , polymyxins , nitr ) )
2018-02-21 11:52:31 +01:00
# Raoultella
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Raoultella' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , tica ) )
2018-02-21 11:52:31 +01:00
# Serratia
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Serratia marcescens' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfox , cfur , tetracyclines [tetracyclines != ' mino' ] , polymyxins , nitr ) )
2018-02-21 11:52:31 +01:00
# Yersinia
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Yersinia enterocolitica' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , tica , czol , cfox ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Yersinia pseudotuberculosis' ) ,
cols = c ( poly , coli ) )
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# Intrisiek R for this group
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus %in% c ( ' Achromobacter' ,
' Acinetobacter' ,
' Alcaligenes' ,
' Bordatella' ,
' Burkholderia' ,
' Elizabethkingia' ,
' Flavobacterium' ,
' Ochrobactrum' ,
' Pseudomonas' ,
' Stenotrophomonas' ) ) ,
2018-03-23 14:46:02 +01:00
cols = c ( peni , cfox , cfur , glycopeptides , fusi , macrolides , linc , streptogramins , rifa , dapt , line ) )
2018-02-21 11:52:31 +01:00
# Acinetobacter
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Acinetobacter (baumannii|pittii|nosocomialis|calcoaceticus)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfot , cftr , aztr , erta , trim , fosf , tetracyclines [tetracyclines != ' mino' ] ) )
2018-02-21 11:52:31 +01:00
# Achromobacter
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Achromobacter (xylosoxydans|xylosoxidans)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , czol , cfot , cftr , erta ) )
2018-02-21 11:52:31 +01:00
# Burkholderia
edit_rsi ( to = ' R' ,
# onder 'Burkholderia cepacia complex' vallen deze species allemaal: PMID 16217180.
rows = which ( tbl $ fullname %like% ' ^Burkholderia (cepacia|multivorans|cenocepacia|stabilis|vietnamiensis|dolosa|ambifaria|anthina|pyrrocinia|ubonensis)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , tica , pita , czol , cfot , cftr , aztr , erta , cipr , chlo , aminoglycosides , trim , fosf , polymyxins ) )
2018-02-21 11:52:31 +01:00
# Elizabethkingia
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Elizabethkingia meningoseptic(a|um)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , tica , czol , cfot , cftr , cfta , cfep , aztr , erta , imip , mero , polymyxins ) )
2018-02-21 11:52:31 +01:00
# Ochrobactrum
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Ochrobactrum anthropi' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , tica , pita , czol , cfot , cftr , cfta , cfep , aztr , erta ) )
2018-02-21 11:52:31 +01:00
# Pseudomonas
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Pseudomonas aeruginosa' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , czol , cfot , cftr , erta , chlo , kana , neom , trim , trsu , tetracyclines , tige ) )
2018-02-21 11:52:31 +01:00
# Stenotrophomonas
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Stenotrophomonas maltophilia' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , amcl , tica , pita , czol , cfot , cftr , cfta , aztr , erta , imip , mero , aminoglycosides , trim , fosf , tetr ) )
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 3: Intrinsic resistance in other Gram-negative bacteria ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 3: Intrinsic resistance in other Gram-negative bacteria\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# Intrisiek R for this group
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus %in% c ( ' Haemophilus' ,
' Moraxella' ,
' Neisseria' ,
' Campylobacter' ) ) ,
2018-03-23 14:46:02 +01:00
cols = c ( glycopeptides , linc , dapt , line ) )
2018-02-21 11:52:31 +01:00
# Haemophilus
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Haemophilus influenzae' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( fusi , streptogramins ) )
2018-02-21 11:52:31 +01:00
# Moraxella
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Moraxella catarrhalis' ) ,
cols = trim )
# Neisseria
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Neisseria' ) ,
cols = trim )
# Campylobacter
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Campylobacter fetus' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( fusi , streptogramins , trim , nali ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Campylobacter (jejuni|coli)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( fusi , streptogramins , trim ) )
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 4: Intrinsic resistance in Gram-positive bacteria ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 4: Intrinsic resistance in Gram-positive bacteria\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# Intrisiek R for this group
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ gramstain %like% ' Positi(e|)(v|f)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aztr , polymyxins , nali ) )
2018-02-21 11:52:31 +01:00
# Staphylococcus
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Staphylococcus saprophyticus' ) ,
cols = c ( fusi , cfta , fosf , novo ) )
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Staphylococcus (cohnii|xylosus)' ) ,
cols = c ( cfta , novo ) )
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Staphylococcus capitis' ) ,
cols = c ( cfta , fosf ) )
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Staphylococcus (aureus|epidermidis|coagulase negatief|hominis|haemolyticus|intermedius|pseudointermedius)' ) ,
cols = cfta )
# Streptococcus
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Streptococcus' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( fusi , cfta , aminoglycosides ) )
2018-02-21 11:52:31 +01:00
# Enterococcus
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Enterococcus faecalis' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( fusi , cfta , cephalosporins [cephalosporins != cfta ] , aminoglycosides , macrolides , clin , qida , trim , trsu ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Enterococcus (gallinarum|casseliflavus)' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( fusi , cfta , cephalosporins [cephalosporins != cfta ] , aminoglycosides , macrolides , clin , qida , vanc , trim , trsu ) )
2018-02-21 11:52:31 +01:00
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Enterococcus faecium' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( fusi , cfta , cephalosporins [cephalosporins != cfta ] , aminoglycosides , macrolides , trim , trsu ) )
2018-02-21 11:52:31 +01:00
# Corynebacterium
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Corynebacterium' ) ,
cols = fosf )
# Listeria
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Listeria monocytogenes' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( cfta , cephalosporins [cephalosporins != cfta ] ) )
2018-02-21 11:52:31 +01:00
# overig
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus %in% c ( ' Leuconostoc' , ' Pediococcus' ) ) ,
cols = c ( vanc , teic ) )
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Lactobacillus' ) ,
cols = c ( vanc , teic ) )
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Clostridium (ramosum|innocuum)' ) ,
cols = vanc )
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 8.3
2018-02-21 11:52:31 +01:00
if ( ! is.na ( peni ) ) {
edit_rsi ( to = ' S' ,
rows = which ( tbl $ fullname %like% ' ^Streptococcus (pyogenes|agalactiae|dysgalactiae|groep A|groep B|groep C|groep G)'
& tbl [ , peni ] == ' S' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( aminopenicillins , cephalosporins , carbapenems ) )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 8.6
2018-02-21 11:52:31 +01:00
if ( ! is.na ( ampi ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Enterococcus'
& tbl [ , ampi ] == ' R' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( ureidopenicillins , carbapenems ) )
2018-02-21 11:52:31 +01:00
}
2018-02-22 21:37:10 +01:00
if ( ! is.na ( amox ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Enterococcus'
& tbl [ , amox ] == ' R' ) ,
2018-03-23 14:46:02 +01:00
cols = c ( ureidopenicillins , carbapenems ) )
2018-02-22 21:37:10 +01:00
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 9: Interpretive rules for B-lactam agents and Gram-negative rods ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 9: Interpretive rules for B-lactam agents and Gram-negative rods\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 9.3
2018-02-21 11:52:31 +01:00
if ( ! is.na ( tica ) & ! is.na ( pita ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ family == ' Enterobacteriaceae'
& tbl [ , tica ] == ' R'
& tbl [ , pita ] == ' S' ) ,
cols = pita )
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 10.2
2018-02-21 11:52:31 +01:00
if ( ! is.na ( ampi ) ) {
2018-03-23 14:46:02 +01:00
# you should know first if the are B-lactamase positive, so do not run for now
2018-02-21 11:52:31 +01:00
# edit_rsi(to = 'R',
# rows = which(tbl$fullname %like% '^Haemophilus influenza'
# & tbl[, ampi] == 'R'),
# cols = c(ampi, amox, amcl, pita, cfur))
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 11.1
2018-02-21 11:52:31 +01:00
if ( ! is.na ( eryt ) ) {
if ( ! is.na ( azit ) ) {
tbl [ , azit ] <- tbl [ , eryt ]
}
if ( ! is.na ( clar ) ) {
tbl [ , clar ] <- tbl [ , eryt ]
}
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 12: Interpretive rules for aminoglycosides ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 12: Interpretive rules for aminoglycosides\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 12.2
2018-02-21 11:52:31 +01:00
if ( ! is.na ( tobr ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Staphylococcus'
& tbl [ , tobr ] == ' R' ) ,
cols = c ( kana , amik ) )
}
2018-03-23 14:46:02 +01:00
# rule 12.3
2018-02-21 11:52:31 +01:00
if ( ! is.na ( gent ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Staphylococcus'
& tbl [ , gent ] == ' R' ) ,
2018-03-23 14:46:02 +01:00
cols = aminoglycosides )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 12.8
2018-02-21 11:52:31 +01:00
if ( ! is.na ( gent ) & ! is.na ( tobr ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ family == ' Enterobacteriaceae'
& tbl [ , gent ] == ' I'
& tbl [ , tobr ] == ' S' ) ,
cols = gent )
}
2018-03-23 14:46:02 +01:00
# rule 12.9
2018-02-21 11:52:31 +01:00
if ( ! is.na ( gent ) & ! is.na ( tobr ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ family == ' Enterobacteriaceae'
& tbl [ , tobr ] == ' I'
& tbl [ , gent ] == ' R' ) ,
cols = tobr )
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Table 13: Interpretive rules for quinolones ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Table 13: Interpretive rules for quinolones\n' )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 13.2
2018-02-21 11:52:31 +01:00
if ( ! is.na ( moxi ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ genus == ' Staphylococcus'
& tbl [ , moxi ] == ' R' ) ,
2018-03-23 14:46:02 +01:00
cols = fluoroquinolones )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 13.4
2018-02-21 11:52:31 +01:00
if ( ! is.na ( moxi ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Streptococcus pneumoniae'
& tbl [ , moxi ] == ' R' ) ,
2018-03-23 14:46:02 +01:00
cols = fluoroquinolones )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 13.5
2018-02-21 11:52:31 +01:00
if ( ! is.na ( cipr ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ family == ' Enterobacteriaceae'
& tbl [ , cipr ] == ' R' ) ,
2018-03-23 14:46:02 +01:00
cols = fluoroquinolones )
2018-02-21 11:52:31 +01:00
}
2018-03-23 14:46:02 +01:00
# rule 13.8
2018-02-21 11:52:31 +01:00
if ( ! is.na ( cipr ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl $ fullname %like% ' ^Neisseria gonorrhoeae'
& tbl [ , cipr ] == ' R' ) ,
2018-03-23 14:46:02 +01:00
cols = fluoroquinolones )
2018-02-21 11:52:31 +01:00
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
# Other ----
if ( info == TRUE ) {
2018-07-26 16:30:42 +02:00
cat ( ' - Non-EUCAST: trim = R where trsu = R and ampi = R where amcl = R\n' )
2018-02-21 11:52:31 +01:00
}
if ( ! is.na ( amcl ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl [ , amcl ] == ' R' ) ,
cols = ampi )
}
if ( ! is.na ( trsu ) ) {
edit_rsi ( to = ' R' ,
rows = which ( tbl [ , trsu ] == ' R' ) ,
cols = trim )
}
2018-07-26 16:30:42 +02:00
if ( info == TRUE ) {
cat ( ' - Non-EUCAST: trsu = S where trim = S and amcl = S where ampi = S\n' )
}
if ( ! is.na ( amcl ) ) {
edit_rsi ( to = ' S' ,
rows = which ( tbl [ , ampi ] == ' S' ) ,
cols = amcl )
}
if ( ! is.na ( trsu ) ) {
edit_rsi ( to = ' S' ,
rows = which ( tbl [ , trim ] == ' S' ) ,
cols = trsu )
}
# amox = ampi
2018-02-21 11:52:31 +01:00
if ( ! is.na ( ampi ) & ! is.na ( amox ) ) {
2018-02-22 21:37:10 +01:00
tbl [ , amox ] <- tbl %>% pull ( ampi )
2018-02-21 11:52:31 +01:00
}
2018-04-02 16:05:09 +02:00
2018-03-23 14:46:02 +01:00
# Remove added columns again
microorganisms.ncol <- ncol ( AMR :: microorganisms ) - 2
2018-02-21 11:52:31 +01:00
tbl.ncol <- ncol ( tbl )
2018-03-23 14:46:02 +01:00
tbl <- tbl %>% select ( - c ( ( tbl.ncol - microorganisms.ncol ) : tbl.ncol ) )
# and remove added suffices
colnames ( tbl ) <- gsub ( " _tempmicroorganisms" , " " , colnames ( tbl ) )
2018-09-01 21:19:46 +02:00
# restore old col_mo values if needed
if ( ! is.null ( col_mo_original ) ) {
tbl [ , col_mo ] <- col_mo_original
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
if ( info == TRUE ) {
2018-03-23 14:46:02 +01:00
cat ( ' Done.\n\nEUCAST Expert rules applied to' ,
2018-02-26 14:37:40 +01:00
total_rows %>% unique ( ) %>% length ( ) %>% format ( big.mark = " ," ) ,
2018-07-26 16:30:42 +02:00
' different rows; overwritten a total of' ,
2018-02-26 14:37:40 +01:00
total %>% format ( big.mark = " ," ) , ' test results.\n\n' )
2018-02-21 11:52:31 +01:00
}
2018-04-02 16:05:09 +02:00
2018-02-21 11:52:31 +01:00
tbl
}
#' @rdname EUCAST
#' @export
interpretive_reading <- function ( ... ) {
EUCAST_rules ( ... )
}