mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 06:46:11 +01:00
EUCAST rules for MDRO
This commit is contained in:
parent
0b22ddef8e
commit
970e3ed7f1
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 0.2.0
|
Version: 0.2.0
|
||||||
Date: 2018-04-19
|
Date: 2018-04-23
|
||||||
Title: Antimicrobial Resistance Analysis
|
Title: Antimicrobial Resistance Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(
|
person(
|
||||||
|
@ -16,6 +16,7 @@ S3method(summary,mic)
|
|||||||
S3method(summary,rsi)
|
S3method(summary,rsi)
|
||||||
export("%like%")
|
export("%like%")
|
||||||
export(BRMO)
|
export(BRMO)
|
||||||
|
export(EUCAST_exceptional_phenotypes)
|
||||||
export(EUCAST_rules)
|
export(EUCAST_rules)
|
||||||
export(MDRO)
|
export(MDRO)
|
||||||
export(MRGN)
|
export(MRGN)
|
||||||
@ -30,6 +31,7 @@ export(first_isolate)
|
|||||||
export(freq)
|
export(freq)
|
||||||
export(frequency_tbl)
|
export(frequency_tbl)
|
||||||
export(full_join_microorganisms)
|
export(full_join_microorganisms)
|
||||||
|
export(guess_atc)
|
||||||
export(guess_bactid)
|
export(guess_bactid)
|
||||||
export(inner_join_microorganisms)
|
export(inner_join_microorganisms)
|
||||||
export(interpretive_reading)
|
export(interpretive_reading)
|
||||||
|
29
NEWS.md
29
NEWS.md
@ -1,31 +1,36 @@
|
|||||||
# 0.2.0
|
# 0.2.0
|
||||||
#### New
|
#### New
|
||||||
* Full support for Windows, Linux and macOS
|
* Full support for Windows, Linux and macOS
|
||||||
* Full support for old R versions, only R-3.0.0 (April 2013) or later is needed
|
* Full support for old R versions, only R-3.0.0 (April 2013) or later is needed (needed packages may have other dependencies)
|
||||||
* Function `guess_bactid` to determine the ID of a microorganism based on genus/species or known abbreviations like MRSA
|
* Function `guess_bactid` to **determine the ID** of a microorganism based on genus/species or known abbreviations like MRSA
|
||||||
* Functions `clipboard_import` and `clipboard_export` as helper functions to quickly copy and paste from/to software like Excel and SPSS
|
* Function `guess_atc` to **determine the ATC** of an antibiotic based on name, trade name, or known abbreviations
|
||||||
* Function `MDRO` to determine Multi Drug Resistant Organisms (MDRO) with support for country-specific guidelines. Suggest your own via [this link](https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E). Functions `BRMO` and `MRGN` are wrappers for Dutch and German guidelines, respectively
|
* Functions `clipboard_import` and `clipboard_export` as helper functions to **quickly copy and paste** from/to software like Excel and SPSS
|
||||||
* Function `freq` to create frequency tables, with additional info in a header
|
* Function `freq` to create **frequency tables**, with additional info in a header
|
||||||
|
* Function `MDRO` to **determine Multi Drug Resistant Organisms (MDRO)** with support for country-specific guidelines.
|
||||||
|
* Suggest your own via [https://github.com/msberends/AMR/issues/new](https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E)
|
||||||
|
* [Exceptional resistances defined by EUCAST](http://www.eucast.org/expert_rules_and_intrinsic_resistance) are also supported instead of countries alone
|
||||||
|
* Functions `BRMO` and `MRGN` are wrappers for Dutch and German guidelines, respectively
|
||||||
* New algorithm to determine weighted isolates, can now be `"points"` or `"keyantibiotics"`, see `?first_isolate`
|
* New algorithm to determine weighted isolates, can now be `"points"` or `"keyantibiotics"`, see `?first_isolate`
|
||||||
* New print format for tibbles and data.tables
|
* New print format for `tibble`s and `data.table`s
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
* Renamed dataset `ablist` to `antibiotics`
|
* Renamed dataset `ablist` to `antibiotics`
|
||||||
* Renamed dataset `bactlist` to `microorganisms`
|
* Renamed dataset `bactlist` to `microorganisms`
|
||||||
* Added more microorganisms to `bactlist`
|
* Added common abbreviations and trade names to the `antibiotics` dataset
|
||||||
|
* Added more microorganisms to the `microorganisms` dataset
|
||||||
* Added analysis examples on help page of dataset `septic_patients`
|
* Added analysis examples on help page of dataset `septic_patients`
|
||||||
* Added support for character vector in `join` functions
|
* Added support for character vector in `join` functions
|
||||||
* Added warnings when a join results in more rows after than before the join
|
* Added warnings when a join results in more rows after than before the join
|
||||||
* Altered `%like%` to make it case insensitive
|
* Altered `%like%` to make it case insensitive
|
||||||
* For parameters of functions `first_isolate` and `EUCAST_rules` the column names are now case-insensitive
|
* For parameters of functions `first_isolate` and `EUCAST_rules` column names are now case-insensitive
|
||||||
* Functions `as.rsi` and `as.mic` now add the package name and version as attribute
|
* Functions `as.rsi` and `as.mic` now add the package name and version as attributes
|
||||||
|
|
||||||
#### Other
|
#### Other
|
||||||
* Expanded README.md with more examples
|
* Expanded `README.md` with more examples
|
||||||
* Added ORC IDs of authors to DESCRIPTION file
|
* Added [ORCID](https://orcid.org) of authors to DESCRIPTION file
|
||||||
* Added unit testing with the `testthat` package
|
* Added unit testing with the `testthat` package
|
||||||
* Added build tests for Linux and macOS using Travis CI (https://travis-ci.org/msberends/AMR)
|
* Added build tests for Linux and macOS using Travis CI (https://travis-ci.org/msberends/AMR)
|
||||||
* Added Line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R)
|
* Added line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R)
|
||||||
|
|
||||||
# 0.1.1
|
# 0.1.1
|
||||||
* `EUCAST_rules` applies for amoxicillin even if ampicillin is missing
|
* `EUCAST_rules` applies for amoxicillin even if ampicillin is missing
|
||||||
|
84
R/atc.R
84
R/atc.R
@ -367,3 +367,87 @@ guess_bactid <- function(x) {
|
|||||||
}
|
}
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' Find ATC code based on antibiotic property
|
||||||
|
#'
|
||||||
|
#' Use this function to determine the ATC code of one or more antibiotics. The dataset \code{\link{antibiotics}} will be searched for abbreviations, official names and trade names.
|
||||||
|
#' @param x character vector to determine \code{ATC} code
|
||||||
|
#' @export
|
||||||
|
#' @importFrom dplyr %>% filter slice pull
|
||||||
|
#' @details In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups.
|
||||||
|
#' Source: \url{https://www.whocc.no/atc/structure_and_principles/}
|
||||||
|
#' @return Character (vector).
|
||||||
|
#' @seealso \code{\link{antibiotics}} for the dataframe that is being used to determine ATC's.
|
||||||
|
#' @examples
|
||||||
|
#' # These examples all return "J01FA01", the ATC code of Erythromycin:
|
||||||
|
#' guess_atc("J01FA01")
|
||||||
|
#' guess_atc("Erythromycin")
|
||||||
|
#' guess_atc("eryt")
|
||||||
|
#' guess_atc("ERYT")
|
||||||
|
#' guess_atc("ERY")
|
||||||
|
#' guess_atc("Erythrocin") # Trade name
|
||||||
|
#' guess_atc("Eryzole") # Trade name
|
||||||
|
#' guess_atc("Pediamycin") # Trade name
|
||||||
|
guess_atc <- function(x) {
|
||||||
|
|
||||||
|
# use this later to further fill AMR::antibiotics
|
||||||
|
|
||||||
|
# drug <- "Ciprofloxacin"
|
||||||
|
# url <- xml2::read_html(paste0("https://www.ncbi.nlm.nih.gov/pccompound?term=", drug)) %>%
|
||||||
|
# html_nodes(".rslt") %>%
|
||||||
|
# .[[1]] %>%
|
||||||
|
# html_nodes(".title a") %>%
|
||||||
|
# html_attr("href") %>%
|
||||||
|
# gsub("/compound/", "/rest/pug_view/data/compound/", ., fixed = TRUE) %>%
|
||||||
|
# paste0("/XML/?response_type=display")
|
||||||
|
# synonyms <- url %>%
|
||||||
|
# read_xml() %>%
|
||||||
|
# xml_contents() %>% .[[6]] %>%
|
||||||
|
# xml_contents() %>% .[[8]] %>%
|
||||||
|
# xml_contents() %>% .[[3]] %>%
|
||||||
|
# xml_contents() %>% .[[3]] %>%
|
||||||
|
# xml_contents() %>%
|
||||||
|
# paste() %>%
|
||||||
|
# .[. %like% "StringValueList"] %>%
|
||||||
|
# gsub("[</]+StringValueList[>]", "", .)
|
||||||
|
|
||||||
|
|
||||||
|
for (i in 1:length(x)) {
|
||||||
|
|
||||||
|
# first try atc
|
||||||
|
found <- AMR::antibiotics %>% filter(atc == x[i])
|
||||||
|
|
||||||
|
if (nrow(found) == 0) {
|
||||||
|
# try abbreviation of molis and glims
|
||||||
|
found <- AMR::antibiotics %>% filter(molis == x[i] | umcg == x[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nrow(found) == 0) {
|
||||||
|
# try exact official name
|
||||||
|
found <- AMR::antibiotics[which(AMR::antibiotics$official == x[i]),]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nrow(found) == 0) {
|
||||||
|
# try trade name
|
||||||
|
found <- AMR::antibiotics[which(paste0("(", AMR::antibiotics$trade_name, ")") %like% x[i]),]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nrow(found) == 0) {
|
||||||
|
# try abbreviation
|
||||||
|
found <- AMR::antibiotics[which(paste0("(", AMR::antibiotics$abbr, ")") %like% x[i]),]
|
||||||
|
}
|
||||||
|
# if (nrow(found) == 0) {
|
||||||
|
# # loosely try official name
|
||||||
|
# found <- AMR::antibiotics[which(AMR::antibiotics$official %like% x[i]),]
|
||||||
|
# }
|
||||||
|
|
||||||
|
if (nrow(found) != 0) {
|
||||||
|
x[i] <- found %>%
|
||||||
|
slice(1) %>%
|
||||||
|
pull(atc)
|
||||||
|
} else {
|
||||||
|
x[i] <- NA
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x
|
||||||
|
}
|
||||||
|
23
R/classes.R
23
R/classes.R
@ -21,7 +21,7 @@
|
|||||||
#' 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.
|
#' 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.
|
||||||
#' @rdname as.rsi
|
#' @rdname as.rsi
|
||||||
#' @param x vector
|
#' @param x vector
|
||||||
#' @return New class \code{rsi}
|
#' @return Ordered factor with new class \code{rsi} and new attributes \code{package} and \code{package.version}
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>%
|
#' @importFrom dplyr %>%
|
||||||
#' @importFrom utils packageDescription
|
#' @importFrom utils packageDescription
|
||||||
@ -92,20 +92,13 @@ print.rsi <- function(x, ...) {
|
|||||||
I <- x[x == 'I'] %>% length()
|
I <- x[x == 'I'] %>% length()
|
||||||
R <- x[x == 'R'] %>% length()
|
R <- x[x == 'R'] %>% length()
|
||||||
IR <- x[x %in% c('I', 'R')] %>% length()
|
IR <- x[x %in% c('I', 'R')] %>% length()
|
||||||
cat("Class 'rsi': ", n, " isolates\n", sep = '')
|
cat("Class 'rsi'\n")
|
||||||
|
cat(n, " results (missing: ", n_total - n, ' = ', percent((n_total - n) / n, force_zero = TRUE), ')\n', sep = "")
|
||||||
cat('\n')
|
cat('\n')
|
||||||
cat('<NA>: ', n_total - n, '\n')
|
cat('Sum of S: ', S, ' (', percent(S / n, force_zero = TRUE), ')\n', sep = "")
|
||||||
cat('Sum of S: ', S, '\n')
|
cat('Sum of IR: ', IR, ' (', percent(IR / n, force_zero = TRUE), ')\n', sep = "")
|
||||||
cat('Sum of IR: ', IR, '\n')
|
cat('- Sum of R: ', R, ' (', percent(R / n, force_zero = TRUE), ')\n', sep = "")
|
||||||
cat('- Sum of R:', R, '\n')
|
cat('- Sum of I: ', I, ' (', percent(I / n, force_zero = TRUE), ')\n', sep = "")
|
||||||
cat('- Sum of I:', I, '\n')
|
|
||||||
cat('\n')
|
|
||||||
print(c(
|
|
||||||
`%S` = round((S / n) * 100, 1),
|
|
||||||
`%IR` = round((IR / n) * 100, 1),
|
|
||||||
`%I` = round((I / n) * 100, 1),
|
|
||||||
`%R` = round((R / n) * 100, 1)
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @exportMethod summary.rsi
|
#' @exportMethod summary.rsi
|
||||||
@ -197,7 +190,7 @@ barplot.rsi <- function(height, ...) {
|
|||||||
#' @rdname as.mic
|
#' @rdname as.mic
|
||||||
#' @param x vector
|
#' @param x vector
|
||||||
#' @param na.rm a logical indicating whether missing values should be removed
|
#' @param na.rm a logical indicating whether missing values should be removed
|
||||||
#' @return New class \code{mic}
|
#' @return Ordered factor with new class \code{mic} and new attributes \code{package} and \code{package.version}
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>%
|
#' @importFrom dplyr %>%
|
||||||
#' @importFrom utils packageDescription
|
#' @importFrom utils packageDescription
|
||||||
|
173
R/data.R
173
R/data.R
@ -24,9 +24,11 @@
|
|||||||
#' \item{\code{atc}}{ATC code, like \code{J01CR02}}
|
#' \item{\code{atc}}{ATC code, like \code{J01CR02}}
|
||||||
#' \item{\code{molis}}{MOLIS code, like \code{amcl}}
|
#' \item{\code{molis}}{MOLIS code, like \code{amcl}}
|
||||||
#' \item{\code{umcg}}{UMCG code, like \code{AMCL}}
|
#' \item{\code{umcg}}{UMCG code, like \code{AMCL}}
|
||||||
|
#' \item{\code{abbr}}{Abbreviation as used by many countries, to be used for \code{\link{guess_atc}}}
|
||||||
#' \item{\code{official}}{Official name by the WHO, like \code{"Amoxicillin and enzyme inhibitor"}}
|
#' \item{\code{official}}{Official name by the WHO, like \code{"Amoxicillin and enzyme inhibitor"}}
|
||||||
#' \item{\code{official_nl}}{Official name in the Netherlands, like \code{"Amoxicilline met enzymremmer"}}
|
#' \item{\code{official_nl}}{Official name in the Netherlands, like \code{"Amoxicilline met enzymremmer"}}
|
||||||
#' \item{\code{trivial_nl}}{Trivial name in Dutch, like \code{"Amoxicilline/clavulaanzuur"}}
|
#' \item{\code{trivial_nl}}{Trivial name in Dutch, like \code{"Amoxicilline/clavulaanzuur"}}
|
||||||
|
#' \item{\code{trade_name}}{Trade name as used by many countries, to be used for \code{\link{guess_atc}}}
|
||||||
#' \item{\code{oral_ddd}}{Defined Daily Dose (DDD), oral treatment}
|
#' \item{\code{oral_ddd}}{Defined Daily Dose (DDD), oral treatment}
|
||||||
#' \item{\code{oral_units}}{Units of \code{ddd_units}}
|
#' \item{\code{oral_units}}{Units of \code{ddd_units}}
|
||||||
#' \item{\code{iv_ddd}}{Defined Daily Dose (DDD), parenteral treatment}
|
#' \item{\code{iv_ddd}}{Defined Daily Dose (DDD), parenteral treatment}
|
||||||
@ -40,6 +42,177 @@
|
|||||||
#' }
|
#' }
|
||||||
#' @source - World Health Organization: \url{https://www.whocc.no/atc_ddd_index/} \cr - EUCAST - Expert rules intrinsic exceptional V3.1 \cr - MOLIS (LIS of Certe): \url{https://www.certe.nl} \cr - GLIMS (LIS of UMCG): \url{https://www.umcg.nl}
|
#' @source - World Health Organization: \url{https://www.whocc.no/atc_ddd_index/} \cr - EUCAST - Expert rules intrinsic exceptional V3.1 \cr - MOLIS (LIS of Certe): \url{https://www.certe.nl} \cr - GLIMS (LIS of UMCG): \url{https://www.umcg.nl}
|
||||||
#' @seealso \code{\link{microorganisms}}
|
#' @seealso \code{\link{microorganisms}}
|
||||||
|
# abbr and trade_name created with:
|
||||||
|
# https://hs.unr.edu/Documents/dhs/chs/NVPHTC/antibiotic_refeference_guide.pdf
|
||||||
|
# antibiotics %>%
|
||||||
|
# mutate(abbr =
|
||||||
|
# case_when(
|
||||||
|
# official == 'Amikacin' ~ 'Ak|AN|AMI|AMK',
|
||||||
|
# official == 'Amoxicillin' ~ 'AMX|AMOX|AC',
|
||||||
|
# official == 'Amoxicillin and beta-lactamase inhibitor' ~ 'AUG|A/C|XL|AML',
|
||||||
|
# official == 'Ampicillin' ~ 'AM|AMP',
|
||||||
|
# official == 'Ampicillin and beta-lactamase inhibitor' ~ 'A/S|SAM|AMS|AB',
|
||||||
|
# official == 'Azithromycin' ~ 'Azi|AZM|AZ',
|
||||||
|
# official == 'Azlocillin' ~ 'AZ|AZL',
|
||||||
|
# official == 'Aztreonam' ~ 'Azt|ATM|AT|AZM',
|
||||||
|
# official == 'Carbenicillin' ~ 'Cb|BAR',
|
||||||
|
# official == 'Cefaclor' ~ 'Ccl|CEC|Cfr|FAC|CF',
|
||||||
|
# official == 'Cefadroxil' ~ 'CFR|FAD',
|
||||||
|
# official == 'Cefazolin' ~ 'Cfz|CZ|FAZ|KZ',
|
||||||
|
# official == 'Cefdinir' ~ 'Cdn|CDR|DIN|CD|CFD',
|
||||||
|
# official == 'Cefditoren' ~ 'CDN',
|
||||||
|
# official == 'Cefepime' ~ 'Cpe|FEP|PM|CPM',
|
||||||
|
# official == 'Cefixime' ~ 'Cfe|DCFM|FIX|IX',
|
||||||
|
# official == 'Cefoperazone' ~ 'Cfp|CPZ|PER|FOP|CP',
|
||||||
|
# official == 'Cefotaxime' ~ 'Cft|CTX|TAX|FOT|CT',
|
||||||
|
# official == 'Cefotetan' ~ 'Ctn|CTT|CTE|TANS|CN',
|
||||||
|
# official == 'Cefoxitin' ~ 'Cfx|FOX|CX|FX',
|
||||||
|
# official == 'Cefpodoxime' ~ 'Cpd|POD|PX',
|
||||||
|
# official == 'Cefprozil' ~ 'Cpz|CPR|FP',
|
||||||
|
# official == 'Ceftaroline' ~ 'CPT',
|
||||||
|
# official == 'Ceftazidime' ~ 'Caz|TAZ|TZ',
|
||||||
|
# official == 'Ceftibuten' ~ 'CTB|TIB|CB',
|
||||||
|
# official == 'Ceftizoxime' ~ 'Cz|ZOX|CZX|CZ|CTZ|TIZ',
|
||||||
|
# official == 'Ceftriaxone' ~ 'Cax|CRO|CTR|FRX|AXO|TX',
|
||||||
|
# official == 'Cefuroxime' ~ 'Crm|CXM|CFX|ROX|FUR|XM',
|
||||||
|
# official == 'Cephalexin' ~ 'CN|LX|CFL',
|
||||||
|
# official == 'Cephalothin' ~ 'Cf',
|
||||||
|
# official == 'Chloramphenicol' ~ 'C|CHL|CL',
|
||||||
|
# official == 'Ciprofloxacin' ~ 'Cp|CIP|CI',
|
||||||
|
# official == 'Clarithromycin' ~ 'Cla|CLR|CLM|CH',
|
||||||
|
# official == 'Clindamycin' ~ 'Cd|CC|CM|CLI|DA',
|
||||||
|
# official == 'Colistin' ~ 'CL|CS|CT',
|
||||||
|
# official == 'Daptomycin' ~ 'Dap',
|
||||||
|
# official == 'Doxycycline' ~ 'Dox',
|
||||||
|
# official == 'Doripenem' ~ 'DOR|Dor',
|
||||||
|
# official == 'Ertapenem' ~ 'Etp',
|
||||||
|
# official == 'Erythromycin' ~ 'E|ERY|EM',
|
||||||
|
# official == 'Fosfomycin' ~ 'FOS|FF|FO|FM',
|
||||||
|
# official == 'Flucloxacillin' ~ 'CLOX',
|
||||||
|
# official == 'Gentamicin' ~ 'Gm|CN|GEN',
|
||||||
|
# official == 'Imipenem' ~ 'Imp|IPM|IMI|IP',
|
||||||
|
# official == 'Kanamycin' ~ 'K|KAN|HLK|KM',
|
||||||
|
# official == 'Levofloxacin' ~ 'Lvx|LEV|LEVO|LE',
|
||||||
|
# official == 'Linezolid' ~ 'Lzd|LNZ|LZ',
|
||||||
|
# official == 'Lomefloxacin' ~ 'Lmf|LOM',
|
||||||
|
# official == 'Meropenem' ~ 'Mer|MEM|MERO|MRP|MP',
|
||||||
|
# official == 'Metronidazole' ~ 'MNZ',
|
||||||
|
# official == 'Mezlocillin' ~ 'Mz|MEZ',
|
||||||
|
# official == 'Minocycline' ~ 'Min|MI|MN|MNO|MC|MH',
|
||||||
|
# official == 'Moxifloxacin' ~ 'Mox|MXF',
|
||||||
|
# official == 'Mupirocin' ~ 'MUP',
|
||||||
|
# official == 'Nafcillin' ~ 'Naf|NF',
|
||||||
|
# official == 'Nalidixic acid' ~ 'NA|NAL',
|
||||||
|
# official == 'Nitrofurantoin' ~ 'Fd|F/M|FT|NIT|NI|F',
|
||||||
|
# official == 'Norfloxacin' ~ 'Nxn|NOR|NX',
|
||||||
|
# official == 'Ofloxacin' ~ 'Ofl|OFX|OF',
|
||||||
|
# official == 'Oxacillin' ~ 'Ox|OXS|OXA',
|
||||||
|
# official == 'Benzylpenicillin' ~ 'P|PEN|PV',
|
||||||
|
# official == 'Penicillins, combinations with other antibacterials' ~ 'P|PEN|PV',
|
||||||
|
# official == 'Piperacillin' ~ 'Pi|PIP|PP',
|
||||||
|
# official == 'Piperacillin and beta-lactamase inhibitor' ~ 'PT|TZP|PTZ|P/T|PTc',
|
||||||
|
# official == 'Polymyxin B' ~ 'PB',
|
||||||
|
# official == 'Quinupristin/dalfopristin' ~ 'Syn|Q/D|QDA|RP',
|
||||||
|
# official == 'Rifampin' ~ 'Rif|RA|RI|RD',
|
||||||
|
# official == 'Spectinomycin' ~ 'SPT|SPE|SC',
|
||||||
|
# official == 'Streptomycin' ~ 'S|STR',
|
||||||
|
# official == 'Teicoplanin' ~ 'Tei|TEC|TPN|TP|TPL',
|
||||||
|
# official == 'Telavancin' ~ 'TLV',
|
||||||
|
# official == 'Telithromcyin' ~ 'Tel',
|
||||||
|
# official == 'Tetracycline' ~ 'Te|TET|TC',
|
||||||
|
# official == 'Ticarcillin' ~ 'Ti|TIC|TC',
|
||||||
|
# official == 'Ticarcillin and beta-lactamase inhibitor' ~ 'Tim|T/C|TCC|TLc',
|
||||||
|
# official == 'Tigecycline' ~ 'TGC',
|
||||||
|
# official == 'Tobramycin' ~ 'To|NN|TM|TOB',
|
||||||
|
# official == 'Trimethoprim' ~ 'T|TMP|TR|W',
|
||||||
|
# official == 'Sulfamethoxazole and trimethoprim' ~ 'T/S|SXT|SxT|TS|COT',
|
||||||
|
# official == 'Vancomycin' ~ 'Va|VAN',
|
||||||
|
# TRUE ~ NA_character_),
|
||||||
|
#
|
||||||
|
# trade_name =
|
||||||
|
# case_when(
|
||||||
|
# official == 'Amikacin' ~ 'Amikin',
|
||||||
|
# official == 'Amoxicillin' ~ 'Amoxil|Dispermox|Larotid|Trimox',
|
||||||
|
# official == 'Amoxicillin and beta-lactamase inhibitor' ~ 'Augmentin',
|
||||||
|
# official == 'Ampicillin' ~ 'Pfizerpen-A|Principen',
|
||||||
|
# official == 'Ampicillin and beta-lactamase inhibitor' ~ 'Unasyn',
|
||||||
|
# official == 'Azithromycin' ~ 'Zithromax',
|
||||||
|
# official == 'Azlocillin' ~ 'Azlin',
|
||||||
|
# official == 'Aztreonam' ~ 'Azactam',
|
||||||
|
# official == 'Carbenicillin' ~ 'Geocillin',
|
||||||
|
# official == 'Cefaclor' ~ 'Ceclor',
|
||||||
|
# official == 'Cefadroxil' ~ 'Duricef',
|
||||||
|
# official == 'Cefazolin' ~ 'Ancef',
|
||||||
|
# official == 'Cefdinir' ~ 'Omnicef',
|
||||||
|
# official == 'Cefditoren' ~ 'Spectracef',
|
||||||
|
# official == 'Cefepime' ~ 'Maxipime',
|
||||||
|
# official == 'Cefixime' ~ 'Suprax',
|
||||||
|
# official == 'Cefoperazone' ~ 'Cefobid',
|
||||||
|
# official == 'Cefotaxime' ~ 'Claforan',
|
||||||
|
# official == 'Cefotetan' ~ 'Cefotan',
|
||||||
|
# official == 'Cefoxitin' ~ 'Mefoxin',
|
||||||
|
# official == 'Cefpodoxime' ~ 'Vantin',
|
||||||
|
# official == 'Cefprozil' ~ 'Cefzil',
|
||||||
|
# official == 'Ceftaroline' ~ 'Teflaro',
|
||||||
|
# official == 'Ceftazidime' ~ 'Fortaz|Tazicef|Tazidime',
|
||||||
|
# official == 'Ceftibuten' ~ 'Cedax',
|
||||||
|
# official == 'Ceftizoxime' ~ 'Cefizox',
|
||||||
|
# official == 'Ceftriaxone' ~ 'Rocephin',
|
||||||
|
# official == 'Cefuroxime' ~ 'Ceftin|Zinacef',
|
||||||
|
# official == 'Cephalexin' ~ 'Keflex|Panixine',
|
||||||
|
# official == 'Cephalothin' ~ 'Keflin',
|
||||||
|
# official == 'Chloramphenicol' ~ 'Chloromycetin',
|
||||||
|
# official == 'Ciprofloxacin' ~ 'Cipro|Ciloxan|Ciproxin',
|
||||||
|
# official == 'Clarithromycin' ~ 'Biaxin',
|
||||||
|
# official == 'Clindamycin' ~ 'Cleocin|Clinda-Derm|Clindagel|Clindesse|Clindets|Evoclin',
|
||||||
|
# official == 'Colistin' ~ 'Coly-Mycin',
|
||||||
|
# official == 'Daptomycin' ~ 'Cubicin',
|
||||||
|
# official == 'Doxycycline' ~ 'Doryx|Monodox|Vibramycin|Atridox|Oracea|Periostat|Vibra-Tabs',
|
||||||
|
# official == 'Doripenem' ~ 'Doribax',
|
||||||
|
# official == 'Ertapenem' ~ 'Invanz',
|
||||||
|
# official == 'Erythromycin' ~ 'Eryc|EryPed|Erythrocin|E-Base|E-Glades|E-Mycin|E.E.S.|Ery-Tab|Eryderm|Erygel|Erythra-derm|Eryzole|Pediamycin',
|
||||||
|
# official == 'Fosfomycin' ~ 'Monurol',
|
||||||
|
# official == 'Flucloxacillin' ~ 'Flopen|Floxapen|Fluclox|Sesamol|Softapen|Staphylex',
|
||||||
|
# official == 'Gentamicin' ~ 'Garamycin|Genoptic',
|
||||||
|
# official == 'Imipenem' ~ 'Primaxin',
|
||||||
|
# official == 'Kanamycin' ~ 'Kantrex',
|
||||||
|
# official == 'Levofloxacin' ~ 'Levaquin|Quixin',
|
||||||
|
# official == 'Linezolid' ~ 'Zyvox',
|
||||||
|
# official == 'Lomefloxacin' ~ 'Maxaquin',
|
||||||
|
# official == 'Meropenem' ~ 'Merrem',
|
||||||
|
# official == 'Metronidazole' ~ 'Flagyl|MetroGel|MetroCream|MetroLotion',
|
||||||
|
# official == 'Mezlocillin' ~ 'Mezlin',
|
||||||
|
# official == 'Minocycline' ~ 'Arestin|Solodyn',
|
||||||
|
# official == 'Moxifloxacin' ~ 'Avelox|Vigamox',
|
||||||
|
# official == 'Mupirocin' ~ 'Bactroban|Centany',
|
||||||
|
# official == 'Nafcillin' ~ 'Unipen',
|
||||||
|
# official == 'Nalidixic acid' ~ 'NegGram',
|
||||||
|
# official == 'Nitrofurantoin' ~ 'Furadantin|Macrobid|Macrodantin',
|
||||||
|
# official == 'Norfloxacin' ~ 'Noroxin',
|
||||||
|
# official == 'Ofloxacin' ~ 'Floxin|Ocuflox|Ophthalmic',
|
||||||
|
# official == 'Oxacillin' ~ 'Bactocill',
|
||||||
|
# official == 'Benzylpenicillin' ~ 'Permapen|Pfizerpen|Veetids',
|
||||||
|
# official == 'Penicillins, combinations with other antibacterials' ~ 'Permapen|Pfizerpen|Veetids',
|
||||||
|
# official == 'Piperacillin' ~ 'Pipracil',
|
||||||
|
# official == 'Piperacillin and beta-lactamase inhibitor' ~ 'Zosyn',
|
||||||
|
# official == 'Polymyxin B' ~ 'Poly-RX',
|
||||||
|
# official == 'Quinupristin/dalfopristin' ~ 'Synercid',
|
||||||
|
# official == 'Rifampin' ~ 'Rifadin|Rifamate|Rimactane',
|
||||||
|
# official == 'Spectinomycin' ~ 'Trobicin',
|
||||||
|
# official == 'Streptomycin' ~ 'Streptomycin Sulfate',
|
||||||
|
# official == 'Teicoplanin' ~ 'Targocid',
|
||||||
|
# official == 'Telavancin' ~ 'Vibativ',
|
||||||
|
# official == 'Telithromcyin' ~ 'Ketek',
|
||||||
|
# official == 'Tetracycline' ~ 'Sumycin|Bristacycline|Tetrex',
|
||||||
|
# official == 'Ticarcillin' ~ 'Ticar',
|
||||||
|
# official == 'Ticarcillin and beta-lactamase inhibitor' ~ 'Timentin',
|
||||||
|
# official == 'Tigecycline' ~ 'Tygacil',
|
||||||
|
# official == 'Tobramycin' ~ 'Tobi|Aktob|Tobre',
|
||||||
|
# official == 'Trimethoprim' ~ 'Primsol|Proloprim',
|
||||||
|
# official == 'Sulfamethoxazole and trimethoprim' ~ 'Bactrim|Septra|Sulfatrim',
|
||||||
|
# official == 'Vancomycin' ~ 'Vancocin|Vancomycin Hydrochloride',
|
||||||
|
# TRUE ~ NA_character_)
|
||||||
|
# )
|
||||||
# last two columns created with:
|
# last two columns created with:
|
||||||
# antibiotics %>%
|
# antibiotics %>%
|
||||||
# mutate(useful_gramnegative =
|
# mutate(useful_gramnegative =
|
||||||
|
143
R/eucast.R
143
R/eucast.R
@ -116,7 +116,7 @@ EUCAST_rules <- function(tbl,
|
|||||||
EUCAST_VERSION <- "3.1"
|
EUCAST_VERSION <- "3.1"
|
||||||
|
|
||||||
if (!col_bactid %in% colnames(tbl)) {
|
if (!col_bactid %in% colnames(tbl)) {
|
||||||
stop('Column ', col_bactid, ' not found.')
|
stop('Column ', col_bactid, ' not found.', call. = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
# check columns
|
# check columns
|
||||||
@ -126,88 +126,65 @@ EUCAST_rules <- function(tbl,
|
|||||||
levo, linc, line, mero, mino, moxi, nali, neom, neti, nitr,
|
levo, linc, line, mero, mino, moxi, nali, neom, neti, nitr,
|
||||||
novo, norf, oflo, peni, pita, poly, qida, rifa, roxi, siso,
|
novo, norf, oflo, peni, pita, poly, qida, rifa, roxi, siso,
|
||||||
teic, tetr, tica, tige, tobr, trim, trsu, vanc)
|
teic, tetr, tica, tige, tobr, trim, trsu, vanc)
|
||||||
col.list <- col.list[!is.na(col.list)]
|
col.list <- check_available_columns(tbl = tbl, col.list = col.list, info = info)
|
||||||
col.list.bak <- col.list
|
amcl <- col.list[amcl]
|
||||||
# are they available as upper case or lower case then?
|
amik <- col.list[amik]
|
||||||
for (i in 1:length(col.list)) {
|
amox <- col.list[amox]
|
||||||
if (toupper(col.list[i]) %in% colnames(tbl)) {
|
ampi <- col.list[ampi]
|
||||||
col.list[i] <- toupper(col.list[i])
|
azit <- col.list[azit]
|
||||||
} else if (tolower(col.list[i]) %in% colnames(tbl)) {
|
aztr <- col.list[aztr]
|
||||||
col.list[i] <- tolower(col.list[i])
|
cefa <- col.list[cefa]
|
||||||
} else if (!col.list[i] %in% colnames(tbl)) {
|
cfra <- col.list[cfra]
|
||||||
col.list[i] <- NA
|
cfep <- col.list[cfep]
|
||||||
}
|
cfot <- col.list[cfot]
|
||||||
}
|
cfox <- col.list[cfox]
|
||||||
if (!all(col.list %in% colnames(tbl))) {
|
cfta <- col.list[cfta]
|
||||||
if (info == TRUE) {
|
cftr <- col.list[cftr]
|
||||||
cat('\n')
|
cfur <- col.list[cfur]
|
||||||
}
|
chlo <- col.list[chlo]
|
||||||
if (info == TRUE) {
|
cipr <- col.list[cipr]
|
||||||
warning('These columns do not exist and will be ignored: ',
|
clar <- col.list[clar]
|
||||||
col.list.bak[!(col.list %in% colnames(tbl))] %>% toString(),
|
clin <- col.list[clin]
|
||||||
immediate. = TRUE,
|
clox <- col.list[clox]
|
||||||
call. = FALSE)
|
coli <- col.list[coli]
|
||||||
}
|
czol <- col.list[czol]
|
||||||
}
|
dapt <- col.list[dapt]
|
||||||
|
doxy <- col.list[doxy]
|
||||||
amcl <- col.list[1]
|
erta <- col.list[erta]
|
||||||
amik <- col.list[2]
|
eryt <- col.list[eryt]
|
||||||
amox <- col.list[3]
|
fosf <- col.list[fosf]
|
||||||
ampi <- col.list[4]
|
fusi <- col.list[fusi]
|
||||||
azit <- col.list[5]
|
gent <- col.list[gent]
|
||||||
aztr <- col.list[6]
|
imip <- col.list[imip]
|
||||||
cefa <- col.list[7]
|
kana <- col.list[kana]
|
||||||
cfra <- col.list[8]
|
levo <- col.list[levo]
|
||||||
cfep <- col.list[9]
|
linc <- col.list[linc]
|
||||||
cfot <- col.list[10]
|
line <- col.list[line]
|
||||||
cfox <- col.list[11]
|
mero <- col.list[mero]
|
||||||
cfta <- col.list[12]
|
mino <- col.list[mino]
|
||||||
cftr <- col.list[13]
|
moxi <- col.list[moxi]
|
||||||
cfur <- col.list[14]
|
nali <- col.list[nali]
|
||||||
chlo <- col.list[15]
|
neom <- col.list[neom]
|
||||||
cipr <- col.list[16]
|
neti <- col.list[neti]
|
||||||
clar <- col.list[17]
|
nitr <- col.list[nitr]
|
||||||
clin <- col.list[18]
|
novo <- col.list[novo]
|
||||||
clox <- col.list[19]
|
norf <- col.list[norf]
|
||||||
coli <- col.list[20]
|
oflo <- col.list[oflo]
|
||||||
czol <- col.list[21]
|
peni <- col.list[peni]
|
||||||
dapt <- col.list[22]
|
pita <- col.list[pita]
|
||||||
doxy <- col.list[23]
|
poly <- col.list[poly]
|
||||||
erta <- col.list[24]
|
qida <- col.list[qida]
|
||||||
eryt <- col.list[25]
|
rifa <- col.list[rifa]
|
||||||
fosf <- col.list[26]
|
roxi <- col.list[roxi]
|
||||||
fusi <- col.list[27]
|
siso <- col.list[siso]
|
||||||
gent <- col.list[28]
|
teic <- col.list[teic]
|
||||||
imip <- col.list[29]
|
tetr <- col.list[tetr]
|
||||||
kana <- col.list[30]
|
tica <- col.list[tica]
|
||||||
levo <- col.list[31]
|
tige <- col.list[tige]
|
||||||
linc <- col.list[32]
|
tobr <- col.list[tobr]
|
||||||
line <- col.list[33]
|
trim <- col.list[trim]
|
||||||
mero <- col.list[34]
|
trsu <- col.list[trsu]
|
||||||
mino <- col.list[35]
|
vanc <- col.list[vanc]
|
||||||
moxi <- col.list[36]
|
|
||||||
nali <- col.list[37]
|
|
||||||
neom <- col.list[38]
|
|
||||||
neti <- col.list[39]
|
|
||||||
nitr <- col.list[40]
|
|
||||||
novo <- col.list[41]
|
|
||||||
norf <- col.list[42]
|
|
||||||
oflo <- col.list[43]
|
|
||||||
peni <- col.list[44]
|
|
||||||
pita <- col.list[45]
|
|
||||||
poly <- col.list[46]
|
|
||||||
qida <- col.list[47]
|
|
||||||
rifa <- col.list[48]
|
|
||||||
roxi <- col.list[49]
|
|
||||||
siso <- col.list[50]
|
|
||||||
teic <- col.list[51]
|
|
||||||
tetr <- col.list[52]
|
|
||||||
tica <- col.list[53]
|
|
||||||
tige <- col.list[54]
|
|
||||||
tobr <- col.list[55]
|
|
||||||
trim <- col.list[56]
|
|
||||||
trsu <- col.list[57]
|
|
||||||
vanc <- col.list[58]
|
|
||||||
|
|
||||||
total <- 0
|
total <- 0
|
||||||
total_rows <- integer(0)
|
total_rows <- integer(0)
|
||||||
|
@ -436,6 +436,10 @@ key_antibiotics <- function(tbl,
|
|||||||
|
|
||||||
keylist <- character(length = nrow(tbl))
|
keylist <- character(length = nrow(tbl))
|
||||||
|
|
||||||
|
if (!col_bactid %in% colnames(tbl)) {
|
||||||
|
stop('Column ', col_bactid, ' not found.', call. = FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
# check columns
|
# check columns
|
||||||
col.list <- c(amox, cfot, cfta, cftr, cfur, cipr, clar,
|
col.list <- c(amox, cfot, cfta, cftr, cfur, cipr, clar,
|
||||||
clin, clox, doxy, gent, line, mero, peni,
|
clin, clox, doxy, gent, line, mero, peni,
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
globalVariables(c('abname',
|
globalVariables(c('abname',
|
||||||
|
'atc',
|
||||||
'bactid',
|
'bactid',
|
||||||
'cnt',
|
'cnt',
|
||||||
'Count',
|
'Count',
|
||||||
@ -35,6 +36,7 @@ globalVariables(c('abname',
|
|||||||
'key_ab_other',
|
'key_ab_other',
|
||||||
'mic',
|
'mic',
|
||||||
'mocode',
|
'mocode',
|
||||||
|
'molis',
|
||||||
'n',
|
'n',
|
||||||
'other_pat_or_mo',
|
'other_pat_or_mo',
|
||||||
'patient_id',
|
'patient_id',
|
||||||
@ -42,5 +44,6 @@ globalVariables(c('abname',
|
|||||||
'quantile',
|
'quantile',
|
||||||
'real_first_isolate',
|
'real_first_isolate',
|
||||||
'species',
|
'species',
|
||||||
|
'umcg',
|
||||||
'y',
|
'y',
|
||||||
'.'))
|
'.'))
|
||||||
|
295
R/mdro.R
295
R/mdro.R
@ -20,42 +20,112 @@
|
|||||||
#'
|
#'
|
||||||
#' Determine which isolates are multidrug-resistant organisms (MDRO) according to country-specific guidelines.
|
#' Determine which isolates are multidrug-resistant organisms (MDRO) according to country-specific guidelines.
|
||||||
#' @param tbl table with antibiotic columns, like e.g. \code{amox} and \code{amcl}
|
#' @param tbl table with antibiotic columns, like e.g. \code{amox} and \code{amcl}
|
||||||
#' @param country country to determine guidelines. Should be a code from the \href{https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements}{list of ISO 3166-1 alpha-2 country codes}. Case-insensitive. Currently supported are \code{de} (Germany) and \code{nl} (the Netherlands).
|
#' @param country country code to determine guidelines. EUCAST rules will be used when left empty, see Details. Should be or a code from the \href{https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements}{list of ISO 3166-1 alpha-2 country codes}. Case-insensitive. Currently supported are \code{de} (Germany) and \code{nl} (the Netherlands).
|
||||||
#' @param col_bactid column name of the bacteria ID in \code{tbl} - values of this column should be present in \code{microorganisms$bactid}, see \code{\link{microorganisms}}
|
#' @param col_bactid column name of the bacteria ID in \code{tbl} - values of this column should be present in \code{microorganisms$bactid}, see \code{\link{microorganisms}}
|
||||||
#' @param info print progress
|
#' @param info print progress
|
||||||
#' @param aminoglycosides,quinolones,carbapenems character vector with column names of antibiotics
|
#' @param amcl,amik,amox,ampi,azit,aztr,cefa,cfra,cfep,cfot,cfox,cfta,cftr,cfur,chlo,cipr,clar,clin,clox,coli,czol,dapt,doxy,erta,eryt,fosf,fusi,gent,imip,kana,levo,linc,line,mero,metr,mino,moxi,nali,neom,neti,nitr,novo,norf,oflo,peni,pita,poly,qida,rifa,roxi,siso,teic,tetr,tica,tige,tobr,trim,trsu,vanc column names of antibiotics. column names of antibiotics
|
||||||
#' @param ceftazidime,piperacillin,trimethoprim_sulfa,penicillin,vancomycin column names of antibiotics
|
#' @param ... parameters that are passed on to methods
|
||||||
#' @param ... parameters that are passed on to \code{MDR}
|
#' @details When \code{country} will be left blank, guidelines will be taken from EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (\url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}).
|
||||||
#' @return Ordered factor with values \code{Positive}, \code{Unconfirmed}, \code{Negative}.
|
#' @return Ordered factor with levels \code{Unknown < Negative < Unconfirmed < Positive}.
|
||||||
#' @rdname MDRO
|
#' @rdname MDRO
|
||||||
#' @export
|
#' @export
|
||||||
|
#' @examples
|
||||||
|
#' library(dplyr)
|
||||||
|
#'
|
||||||
|
#' septic_patients %>%
|
||||||
|
#' mutate(EUCAST = MDRO(.),
|
||||||
|
#' BRMO = MDRO(., "nl"))
|
||||||
MDRO <- function(tbl,
|
MDRO <- function(tbl,
|
||||||
country,
|
country = NULL,
|
||||||
col_bactid = 'bactid',
|
col_bactid = 'bactid',
|
||||||
info = TRUE,
|
info = TRUE,
|
||||||
aminoglycosides = c('gent', 'tobr', 'kana'),
|
amcl = 'amcl',
|
||||||
quinolones = c('cipr', 'norf'),
|
amik = 'amik',
|
||||||
carbapenems = c('imip', 'mero', 'erta'),
|
amox = 'amox',
|
||||||
ceftazidime = 'cfta',
|
ampi = 'ampi',
|
||||||
piperacillin = 'pita',
|
azit = 'azit',
|
||||||
trimethoprim_sulfa = 'trsu',
|
aztr = 'aztr',
|
||||||
penicillin = 'peni',
|
cefa = 'cefa',
|
||||||
vancomycin = 'vanc') {
|
cfra = 'cfra',
|
||||||
|
cfep = 'cfep',
|
||||||
|
cfot = 'cfot',
|
||||||
|
cfox = 'cfox',
|
||||||
|
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',
|
||||||
|
metr = 'metr',
|
||||||
|
mino = 'mino',
|
||||||
|
moxi = 'moxi',
|
||||||
|
nali = 'nali',
|
||||||
|
neom = 'neom',
|
||||||
|
neti = 'neti',
|
||||||
|
nitr = 'nitr',
|
||||||
|
novo = 'novo',
|
||||||
|
norf = 'norf',
|
||||||
|
oflo = 'oflo',
|
||||||
|
peni = 'peni',
|
||||||
|
pita = 'pita',
|
||||||
|
poly = 'poly',
|
||||||
|
qida = 'qida',
|
||||||
|
rifa = 'rifa',
|
||||||
|
roxi = 'roxi',
|
||||||
|
siso = 'siso',
|
||||||
|
teic = 'teic',
|
||||||
|
tetr = 'tetr',
|
||||||
|
tica = 'tica',
|
||||||
|
tige = 'tige',
|
||||||
|
tobr = 'tobr',
|
||||||
|
trim = 'trim',
|
||||||
|
trsu = 'trsu',
|
||||||
|
vanc = 'vanc') {
|
||||||
|
|
||||||
|
if (!col_bactid %in% colnames(tbl)) {
|
||||||
|
stop('Column ', col_bactid, ' not found.', call. = FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
# strip whitespaces
|
# strip whitespaces
|
||||||
country <- trimws(country)
|
|
||||||
if (length(country) > 1) {
|
if (length(country) > 1) {
|
||||||
stop('`country` must be a length one character string.', call. = FALSE)
|
stop('`country` must be a length one character string.', call. = FALSE)
|
||||||
}
|
}
|
||||||
if (!country %like% '^[a-z]{2}$') {
|
|
||||||
|
if (is.null(country)) {
|
||||||
|
country <- 'EUCAST'
|
||||||
|
}
|
||||||
|
country <- trimws(country)
|
||||||
|
if (country != 'EUCAST' & !country %like% '^[a-z]{2}$') {
|
||||||
stop('This is not a valid ISO 3166-1 alpha-2 country code: "', country, '". Please see ?MDRO.', call. = FALSE)
|
stop('This is not a valid ISO 3166-1 alpha-2 country code: "', country, '". Please see ?MDRO.', call. = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
# create list and make country code case-independent
|
# create list and make country code case-independent
|
||||||
guideline <- list(country = list(code = tolower(country)))
|
guideline <- list(country = list(code = tolower(country)))
|
||||||
|
|
||||||
# support per country
|
if (guideline$country$code == 'eucast') {
|
||||||
if (guideline$country$code == 'de') {
|
guideline$country$name <- '(European guidelines)'
|
||||||
|
guideline$name <- 'EUCAST Expert Rules, "Intrinsic Resistance and Exceptional Phenotypes Tables"'
|
||||||
|
guideline$version <- 'Version 3.1'
|
||||||
|
guideline$source <- 'http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf'
|
||||||
|
# support per country:
|
||||||
|
} else if (guideline$country$code == 'de') {
|
||||||
guideline$country$name <- 'Germany'
|
guideline$country$name <- 'Germany'
|
||||||
guideline$name <- ''
|
guideline$name <- ''
|
||||||
guideline$version <- ''
|
guideline$version <- ''
|
||||||
@ -79,38 +149,177 @@ MDRO <- function(tbl,
|
|||||||
ANSI_reset <- "\033[0m"
|
ANSI_reset <- "\033[0m"
|
||||||
|
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
cat("Determining Highly Resistant Microorganisms (MDRO), according to:\n",
|
cat("Determining multidrug-resistant organisms (MDRO), according to:\n",
|
||||||
"Guideline: ", ANSI_red, guideline$name, ", ", guideline$version, ANSI_reset, "\n",
|
"Guideline: ", ANSI_red, guideline$name, ", ", guideline$version, ANSI_reset, "\n",
|
||||||
"Country : ", ANSI_red, guideline$country$name, ANSI_reset, "\n",
|
"Country : ", ANSI_red, guideline$country$name, ANSI_reset, "\n",
|
||||||
"Source : ", ANSI_blue, guideline$source, ANSI_reset, "\n",
|
"Source : ", ANSI_blue, guideline$source, ANSI_reset, "\n",
|
||||||
"\n", sep = "")
|
"\n", sep = "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check columns
|
||||||
|
col.list <- c(amcl, amik, amox, ampi, azit, aztr, cefa, cfra, cfep, cfot,
|
||||||
|
cfox, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli,
|
||||||
|
czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana,
|
||||||
|
levo, linc, line, mero, metr, mino, moxi, nali, neom, neti, nitr,
|
||||||
|
novo, norf, oflo, peni, pita, poly, qida, rifa, roxi, siso,
|
||||||
|
teic, tetr, tica, tige, tobr, trim, trsu, vanc)
|
||||||
|
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]
|
||||||
|
aztr <- col.list[aztr]
|
||||||
|
cefa <- col.list[cefa]
|
||||||
|
cfra <- col.list[cfra]
|
||||||
|
cfep <- col.list[cfep]
|
||||||
|
cfot <- col.list[cfot]
|
||||||
|
cfox <- col.list[cfox]
|
||||||
|
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]
|
||||||
|
metr <- col.list[metr]
|
||||||
|
mino <- col.list[mino]
|
||||||
|
moxi <- col.list[moxi]
|
||||||
|
nali <- col.list[nali]
|
||||||
|
neom <- col.list[neom]
|
||||||
|
neti <- col.list[neti]
|
||||||
|
nitr <- col.list[nitr]
|
||||||
|
novo <- col.list[novo]
|
||||||
|
norf <- col.list[norf]
|
||||||
|
oflo <- col.list[oflo]
|
||||||
|
peni <- col.list[peni]
|
||||||
|
pita <- col.list[pita]
|
||||||
|
poly <- col.list[poly]
|
||||||
|
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]
|
||||||
|
|
||||||
|
# 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 clin(damycin) is set apart
|
||||||
|
glycopeptides <- c(vanc, teic)
|
||||||
|
streptogramins <- qida # should officially also be pristinamycin and quinupristin/dalfopristin
|
||||||
|
cephalosporins <- c(cfep, cfot, cfox, cfra, cfta, cftr, cfur, czol)
|
||||||
|
cephalosporins_3rd <- c(cfot, cftr, cfta)
|
||||||
|
carbapenems <- c(erta, imip, mero)
|
||||||
|
aminopenicillins <- c(ampi, amox)
|
||||||
|
ureidopenicillins <- pita # should officially also be azlo and mezlo
|
||||||
|
fluoroquinolones <- c(oflo, cipr, norf, levo, moxi)
|
||||||
|
|
||||||
|
# helper function for editing the table
|
||||||
|
trans_tbl <- function(to, rows, cols) {
|
||||||
|
cols <- cols[!is.na(cols)]
|
||||||
|
if (length(rows) > 0 & length(cols) > 0) {
|
||||||
|
col_filter <- which(tbl[, cols] == 'R')
|
||||||
|
rows <- rows[rows %in% col_filter]
|
||||||
|
tbl[rows, 'MDRO'] <<- to
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# join microorganisms
|
# join microorganisms
|
||||||
tbl <- tbl %>% left_join_microorganisms(col_bactid)
|
tbl <- tbl %>% left_join_microorganisms(col_bactid)
|
||||||
|
|
||||||
tbl$MDRO <- 1
|
tbl$MDRO <- NA_integer_
|
||||||
|
|
||||||
|
if (guideline$country$code == 'eucast') {
|
||||||
|
# EUCAST ------------------------------------------------------------------
|
||||||
|
# Table 5
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$family == 'Enterobacteriaceae'
|
||||||
|
| tbl$fullname %like% '^Pseudomonas aeruginosa'
|
||||||
|
| tbl$genus == 'Acinetobacter'),
|
||||||
|
coli)
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Salmonella Typhi'),
|
||||||
|
c(carbapenems, fluoroquinolones))
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Haemophilus influenzae'),
|
||||||
|
c(cephalosporins_3rd, carbapenems, fluoroquinolones))
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Moraxella catarrhalis'),
|
||||||
|
c(cephalosporins_3rd, fluoroquinolones))
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Neisseria meningitidis'),
|
||||||
|
c(cephalosporins_3rd, fluoroquinolones))
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Neisseria gonorrhoeae'),
|
||||||
|
azit)
|
||||||
|
# Table 6
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Staphylococcus (aureus|epidermidis|coagulase negatief|hominis|haemolyticus|intermedius|pseudointermedius)'),
|
||||||
|
c(vanc, teic, dapt, line, qida, tige))
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$genus == 'Corynebacterium'),
|
||||||
|
c(vanc, teic, dapt, line, qida, tige))
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Streptococcus pneumoniae'),
|
||||||
|
c(carbapenems, vanc, teic, dapt, line, qida, tige, rifa))
|
||||||
|
trans_tbl(4, # Sr. groups A/B/C/G
|
||||||
|
which(tbl$fullname %like% '^Streptococcus (pyogenes|agalactiae|equisimilis|equi|zooepidemicus|dysgalactiae|anginosus)'),
|
||||||
|
c(peni, cephalosporins, vanc, teic, dapt, line, qida, tige))
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$genus == 'Enterococcus'),
|
||||||
|
c(dapt, line, tige, teic))
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Enterococcus faecalis'),
|
||||||
|
c(ampi, amox))
|
||||||
|
# Table 7
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$genus == 'Bacteroides'),
|
||||||
|
metr)
|
||||||
|
trans_tbl(4,
|
||||||
|
which(tbl$fullname %like% '^Clostridium difficile'),
|
||||||
|
c(metr, vanc))
|
||||||
|
}
|
||||||
|
|
||||||
if (guideline$country$code == 'de') {
|
if (guideline$country$code == 'de') {
|
||||||
|
# Germany -----------------------------------------------------------------
|
||||||
stop("We are still working on German guidelines in this beta version.", call. = FALSE)
|
stop("We are still working on German guidelines in this beta version.", call. = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guideline$country$code == 'nl') {
|
if (guideline$country$code == 'nl') {
|
||||||
# BRMO; Bijzonder Resistente Micro-Organismen
|
# Netherlands -------------------------------------------------------------
|
||||||
aminoglycosides <- aminoglycosides[aminoglycosides %in% colnames(tbl)]
|
aminoglycosides <- aminoglycosides[!is.na(aminoglycosides)]
|
||||||
quinolones <- quinolones[quinolones %in% colnames(tbl)]
|
fluoroquinolones <- fluoroquinolones[!is.na(fluoroquinolones)]
|
||||||
carbapenems <- carbapenems[carbapenems %in% colnames(tbl)]
|
carbapenems <- carbapenems[!is.na(carbapenems)]
|
||||||
if (!ceftazidime %in% colnames(tbl)) { ceftazidime <- NA }
|
|
||||||
if (!piperacillin %in% colnames(tbl)) { piperacillin <- NA }
|
|
||||||
if (!trimethoprim_sulfa %in% colnames(tbl)) { trimethoprim_sulfa <- NA }
|
|
||||||
if (!penicillin %in% colnames(tbl)) { penicillin <- NA }
|
|
||||||
if (!vancomycin %in% colnames(tbl)) { vancomycin <- NA }
|
|
||||||
|
|
||||||
# Table 1
|
# Table 1
|
||||||
tbl[which(
|
tbl[which(
|
||||||
tbl$family == 'Enterobacteriaceae'
|
tbl$family == 'Enterobacteriaceae'
|
||||||
& rowSums(tbl[, aminoglycosides] == 'R', na.rm = TRUE) >= 1
|
& rowSums(tbl[, aminoglycosides] == 'R', na.rm = TRUE) >= 1
|
||||||
& rowSums(tbl[, quinolones] == 'R', na.rm = TRUE) >= 1
|
& rowSums(tbl[, fluoroquinolones] == 'R', na.rm = TRUE) >= 1
|
||||||
), 'MDRO'] <- 4
|
), 'MDRO'] <- 4
|
||||||
tbl[which(
|
tbl[which(
|
||||||
tbl$family == 'Enterobacteriaceae'
|
tbl$family == 'Enterobacteriaceae'
|
||||||
@ -130,7 +339,7 @@ MDRO <- function(tbl,
|
|||||||
tbl[which(
|
tbl[which(
|
||||||
tbl$genus == 'Acinetobacter'
|
tbl$genus == 'Acinetobacter'
|
||||||
& rowSums(tbl[, aminoglycosides] == 'R', na.rm = TRUE) >= 1
|
& rowSums(tbl[, aminoglycosides] == 'R', na.rm = TRUE) >= 1
|
||||||
& rowSums(tbl[, quinolones] == 'R', na.rm = TRUE) >= 1
|
& rowSums(tbl[, fluoroquinolones] == 'R', na.rm = TRUE) >= 1
|
||||||
), 'MDRO'] <- 4
|
), 'MDRO'] <- 4
|
||||||
# rest of Acinetobacter is negative
|
# rest of Acinetobacter is negative
|
||||||
tbl[which(
|
tbl[which(
|
||||||
@ -140,7 +349,7 @@ MDRO <- function(tbl,
|
|||||||
|
|
||||||
tbl[which(
|
tbl[which(
|
||||||
tbl$fullname %like% 'Stenotrophomonas maltophilia'
|
tbl$fullname %like% 'Stenotrophomonas maltophilia'
|
||||||
& tbl[, trimethoprim_sulfa] == 'R'
|
& tbl[, trsu] == 'R'
|
||||||
), 'MDRO'] <- 4
|
), 'MDRO'] <- 4
|
||||||
# rest of Stenotrophomonas is negative
|
# rest of Stenotrophomonas is negative
|
||||||
tbl[which(
|
tbl[which(
|
||||||
@ -152,9 +361,9 @@ MDRO <- function(tbl,
|
|||||||
tbl$fullname %like% 'Pseudomonas aeruginosa'
|
tbl$fullname %like% 'Pseudomonas aeruginosa'
|
||||||
& sum(rowSums(tbl[, carbapenems] == 'R', na.rm = TRUE) >= 1,
|
& sum(rowSums(tbl[, carbapenems] == 'R', na.rm = TRUE) >= 1,
|
||||||
rowSums(tbl[, aminoglycosides] == 'R', na.rm = TRUE) >= 1,
|
rowSums(tbl[, aminoglycosides] == 'R', na.rm = TRUE) >= 1,
|
||||||
rowSums(tbl[, quinolones] == 'R', na.rm = TRUE) >= 1,
|
rowSums(tbl[, fluoroquinolones] == 'R', na.rm = TRUE) >= 1,
|
||||||
tbl[, ceftazidime] == 'R',
|
tbl[, cfta] == 'R',
|
||||||
tbl[, piperacillin] == 'R') >= 3
|
tbl[, pita] == 'R') >= 3
|
||||||
), 'MDRO'] <- 4
|
), 'MDRO'] <- 4
|
||||||
# rest of Pseudomonas is negative
|
# rest of Pseudomonas is negative
|
||||||
tbl[which(
|
tbl[which(
|
||||||
@ -165,11 +374,11 @@ MDRO <- function(tbl,
|
|||||||
# Table 3
|
# Table 3
|
||||||
tbl[which(
|
tbl[which(
|
||||||
tbl$fullname %like% 'Streptococcus pneumoniae'
|
tbl$fullname %like% 'Streptococcus pneumoniae'
|
||||||
& tbl[, penicillin] == 'R'
|
& tbl[, peni] == 'R'
|
||||||
), 'MDRO'] <- 4
|
), 'MDRO'] <- 4
|
||||||
tbl[which(
|
tbl[which(
|
||||||
tbl$fullname %like% 'Streptococcus pneumoniae'
|
tbl$fullname %like% 'Streptococcus pneumoniae'
|
||||||
& tbl[, vancomycin] == 'R'
|
& tbl[, vanc] == 'R'
|
||||||
), 'MDRO'] <- 4
|
), 'MDRO'] <- 4
|
||||||
# rest of Streptococcus pneumoniae is negative
|
# rest of Streptococcus pneumoniae is negative
|
||||||
tbl[which(
|
tbl[which(
|
||||||
@ -179,7 +388,7 @@ MDRO <- function(tbl,
|
|||||||
|
|
||||||
tbl[which(
|
tbl[which(
|
||||||
tbl$fullname %like% 'Enterococcus faecium'
|
tbl$fullname %like% 'Enterococcus faecium'
|
||||||
& rowSums(tbl[, c(penicillin, vancomycin)] == 'R', na.rm = TRUE) >= 1
|
& rowSums(tbl[, c(peni, vanc)] == 'R', na.rm = TRUE) >= 1
|
||||||
), 'MDRO'] <- 4
|
), 'MDRO'] <- 4
|
||||||
# rest of Enterococcus faecium is negative
|
# rest of Enterococcus faecium is negative
|
||||||
tbl[which(
|
tbl[which(
|
||||||
@ -197,11 +406,17 @@ MDRO <- function(tbl,
|
|||||||
#' @rdname MDRO
|
#' @rdname MDRO
|
||||||
#' @export
|
#' @export
|
||||||
BRMO <- function(tbl, country = "nl", ...) {
|
BRMO <- function(tbl, country = "nl", ...) {
|
||||||
MDRO(tbl = tbl, country = country, ...)
|
MDRO(tbl = tbl, country = "nl", ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname MDRO
|
#' @rdname MDRO
|
||||||
#' @export
|
#' @export
|
||||||
MRGN <- function(tbl, country = "de", ...) {
|
MRGN <- function(tbl, country = "de", ...) {
|
||||||
MDRO(tbl = tbl, country = country, ...)
|
MDRO(tbl = tbl, country = "de", ...)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @rdname MDRO
|
||||||
|
#' @export
|
||||||
|
EUCAST_exceptional_phenotypes <- function(tbl, country = "EUCAST", ...) {
|
||||||
|
MDRO(tbl = tbl, country = "EUCAST", ...)
|
||||||
}
|
}
|
||||||
|
1
R/misc.R
1
R/misc.R
@ -73,6 +73,7 @@ check_available_columns <- function(tbl, col.list, info = TRUE) {
|
|||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
warning('These columns do not exist and will be ignored: ',
|
warning('These columns do not exist and will be ignored: ',
|
||||||
col.list.bak[!(col.list %in% colnames(tbl))] %>% toString(),
|
col.list.bak[!(col.list %in% colnames(tbl))] %>% toString(),
|
||||||
|
'.\nTHIS MAY STRONGLY INFLUENCE THE OUTCOME.',
|
||||||
immediate. = TRUE,
|
immediate. = TRUE,
|
||||||
call. = FALSE)
|
call. = FALSE)
|
||||||
}
|
}
|
||||||
|
15
README.md
15
README.md
@ -9,13 +9,14 @@ This R package was created for academic research by PhD students of the Faculty
|
|||||||
This R package contains functions to make microbiological, epidemiological data analysis easier. It allows the use of some new classes to work with MIC values and antimicrobial interpretations (i.e. values S, I and R).
|
This R package contains functions to make microbiological, epidemiological data analysis easier. It allows the use of some new classes to work with MIC values and antimicrobial interpretations (i.e. values S, I and R).
|
||||||
|
|
||||||
With `AMR` you can also:
|
With `AMR` you can also:
|
||||||
* Conduct AMR analysis with the `rsi()` function, that can also be used with the `dplyr` package (e.g. in conjunction with `summarise`) to calculate the resistance percentages of different antibiotic columns of a table.
|
* Create frequency tables with the `freq` function
|
||||||
* Predict antimicrobial resistance for the nextcoming years with the `rsi_predict()` function
|
* Conduct AMR analysis with the `rsi` function, that can also be used with the `dplyr` package (e.g. in conjunction with `summarise`) to calculate the resistance percentages of different antibiotic columns of a table
|
||||||
* Apply [EUCAST rules to isolates](http://www.eucast.org/expert_rules_and_intrinsic_resistance/) with the `EUCAST_rules()` function
|
* Predict antimicrobial resistance for the nextcoming years with the `rsi_predict` function
|
||||||
* Identify first isolates of every patient [using guidelines from the CLSI](https://clsi.org/standards/products/microbiology/documents/m39/) (Clinical and Laboratory Standards Institute) with the `first_isolate()` function
|
* Apply [EUCAST rules to isolates](http://www.eucast.org/expert_rules_and_intrinsic_resistance/) with the `EUCAST_rules` function
|
||||||
* Translate antibiotic codes from the lab (like `"AMOX"`) or the [WHO](https://www.whocc.no/atc_ddd_index/?code=J01CA04&showdescription=no) (like `"J01CA04"`) to trivial names (like `"amoxicillin"`) with the `abname()` function
|
* Identify first isolates of every patient [using guidelines from the CLSI](https://clsi.org/standards/products/microbiology/documents/m39/) (Clinical and Laboratory Standards Institute) with the `first_isolate` function
|
||||||
|
* Translate antibiotic codes from the lab (like `"AMOX"`) or the [WHO](https://www.whocc.no/atc_ddd_index/?code=J01CA04&showdescription=no) (like `"J01CA04"`) to trivial names (like `"amoxicillin"`) with the `abname` function
|
||||||
|
|
||||||
With the `MDRO` function (abbreviation of mutli-drug resistant organisms), you can check your isolates for exceptional resistance with country-specific guidelines. Currently guidelines for Germany and the Netherlands are supported. Please suggest addition of your own country here: [https://github.com/msberends/AMR/issues](https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E).
|
With the `MDRO` function (abbreviation of Multi Drug Resistant Organisms), you can check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently guidelines for Germany and the Netherlands are supported. Please suggest addition of your own country here: [https://github.com/msberends/AMR/issues/new](https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E).
|
||||||
|
|
||||||
This package contains an example data set `septic_patients`, consisting of 2000 isolates from anonymised septic patients between 2001 and 2017.
|
This package contains an example data set `septic_patients`, consisting of 2000 isolates from anonymised septic patients between 2001 and 2017.
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ after
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Frequency tables
|
### Frequency tables
|
||||||
Base R lacks a simple function to create frequency tables. We created such a function that works with almost all data types: `freq()` (or `frequency_tbl()`).
|
Base R lacks a simple function to create frequency tables. We created such a function that works with almost all data types: `freq` (or `frequency_tbl`).
|
||||||
```r
|
```r
|
||||||
## Factors sort on item by default:
|
## Factors sort on item by default:
|
||||||
|
|
||||||
|
Binary file not shown.
44
man/MDRO.Rd
44
man/MDRO.Rd
@ -4,36 +4,58 @@
|
|||||||
\alias{MDRO}
|
\alias{MDRO}
|
||||||
\alias{BRMO}
|
\alias{BRMO}
|
||||||
\alias{MRGN}
|
\alias{MRGN}
|
||||||
|
\alias{EUCAST_exceptional_phenotypes}
|
||||||
\title{Determine multidrug-resistant organisms (MDRO)}
|
\title{Determine multidrug-resistant organisms (MDRO)}
|
||||||
\usage{
|
\usage{
|
||||||
MDRO(tbl, country, col_bactid = "bactid", info = TRUE,
|
MDRO(tbl, country = NULL, col_bactid = "bactid", info = TRUE,
|
||||||
aminoglycosides = c("gent", "tobr", "kana"), quinolones = c("cipr",
|
amcl = "amcl", amik = "amik", amox = "amox", ampi = "ampi",
|
||||||
"norf"), carbapenems = c("imip", "mero", "erta"), ceftazidime = "cfta",
|
azit = "azit", aztr = "aztr", cefa = "cefa", cfra = "cfra",
|
||||||
piperacillin = "pita", trimethoprim_sulfa = "trsu", penicillin = "peni",
|
cfep = "cfep", cfot = "cfot", cfox = "cfox", cfta = "cfta",
|
||||||
vancomycin = "vanc")
|
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", metr = "metr", mino = "mino",
|
||||||
|
moxi = "moxi", nali = "nali", neom = "neom", neti = "neti",
|
||||||
|
nitr = "nitr", novo = "novo", norf = "norf", oflo = "oflo",
|
||||||
|
peni = "peni", pita = "pita", poly = "poly", qida = "qida",
|
||||||
|
rifa = "rifa", roxi = "roxi", siso = "siso", teic = "teic",
|
||||||
|
tetr = "tetr", tica = "tica", tige = "tige", tobr = "tobr",
|
||||||
|
trim = "trim", trsu = "trsu", vanc = "vanc")
|
||||||
|
|
||||||
BRMO(tbl, country = "nl", ...)
|
BRMO(tbl, country = "nl", ...)
|
||||||
|
|
||||||
MRGN(tbl, country = "de", ...)
|
MRGN(tbl, country = "de", ...)
|
||||||
|
|
||||||
|
EUCAST_exceptional_phenotypes(tbl, country = "EUCAST", ...)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{tbl}{table with antibiotic columns, like e.g. \code{amox} and \code{amcl}}
|
\item{tbl}{table with antibiotic columns, like e.g. \code{amox} and \code{amcl}}
|
||||||
|
|
||||||
\item{country}{country to determine guidelines. Should be a code from the \href{https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements}{list of ISO 3166-1 alpha-2 country codes}. Case-insensitive. Currently supported are \code{de} (Germany) and \code{nl} (the Netherlands).}
|
\item{country}{country code to determine guidelines. EUCAST rules will be used when left empty, see Details. Should be or a code from the \href{https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements}{list of ISO 3166-1 alpha-2 country codes}. Case-insensitive. Currently supported are \code{de} (Germany) and \code{nl} (the Netherlands).}
|
||||||
|
|
||||||
\item{col_bactid}{column name of the bacteria ID in \code{tbl} - values of this column should be present in \code{microorganisms$bactid}, see \code{\link{microorganisms}}}
|
\item{col_bactid}{column name of the bacteria ID in \code{tbl} - values of this column should be present in \code{microorganisms$bactid}, see \code{\link{microorganisms}}}
|
||||||
|
|
||||||
\item{info}{print progress}
|
\item{info}{print progress}
|
||||||
|
|
||||||
\item{aminoglycosides, quinolones, carbapenems}{character vector with column names of antibiotics}
|
\item{amcl, amik, amox, ampi, azit, aztr, cefa, cfra, cfep, cfot, cfox, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, metr, mino, moxi, nali, neom, neti, nitr, novo, norf, oflo, peni, pita, poly, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column names of antibiotics. column names of antibiotics}
|
||||||
|
|
||||||
\item{ceftazidime, piperacillin, trimethoprim_sulfa, penicillin, vancomycin}{column names of antibiotics}
|
\item{...}{parameters that are passed on to methods}
|
||||||
|
|
||||||
\item{...}{parameters that are passed on to \code{MDR}}
|
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
Ordered factor with values \code{Positive}, \code{Unconfirmed}, \code{Negative}.
|
Ordered factor with levels \code{Unknown < Negative < Unconfirmed < Positive}.
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Determine which isolates are multidrug-resistant organisms (MDRO) according to country-specific guidelines.
|
Determine which isolates are multidrug-resistant organisms (MDRO) according to country-specific guidelines.
|
||||||
}
|
}
|
||||||
|
\details{
|
||||||
|
When \code{country} will be left blank, guidelines will be taken from EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (\url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}).
|
||||||
|
}
|
||||||
|
\examples{
|
||||||
|
library(dplyr)
|
||||||
|
|
||||||
|
septic_patients \%>\%
|
||||||
|
mutate(EUCAST = MDRO(.),
|
||||||
|
BRMO = MDRO(., "nl"))
|
||||||
|
}
|
||||||
|
@ -9,9 +9,11 @@
|
|||||||
\item{\code{atc}}{ATC code, like \code{J01CR02}}
|
\item{\code{atc}}{ATC code, like \code{J01CR02}}
|
||||||
\item{\code{molis}}{MOLIS code, like \code{amcl}}
|
\item{\code{molis}}{MOLIS code, like \code{amcl}}
|
||||||
\item{\code{umcg}}{UMCG code, like \code{AMCL}}
|
\item{\code{umcg}}{UMCG code, like \code{AMCL}}
|
||||||
|
\item{\code{abbr}}{Abbreviation as used by many countries, to be used for \code{\link{guess_atc}}}
|
||||||
\item{\code{official}}{Official name by the WHO, like \code{"Amoxicillin and enzyme inhibitor"}}
|
\item{\code{official}}{Official name by the WHO, like \code{"Amoxicillin and enzyme inhibitor"}}
|
||||||
\item{\code{official_nl}}{Official name in the Netherlands, like \code{"Amoxicilline met enzymremmer"}}
|
\item{\code{official_nl}}{Official name in the Netherlands, like \code{"Amoxicilline met enzymremmer"}}
|
||||||
\item{\code{trivial_nl}}{Trivial name in Dutch, like \code{"Amoxicilline/clavulaanzuur"}}
|
\item{\code{trivial_nl}}{Trivial name in Dutch, like \code{"Amoxicilline/clavulaanzuur"}}
|
||||||
|
\item{\code{trade_name}}{Trade name as used by many countries, to be used for \code{\link{guess_atc}}}
|
||||||
\item{\code{oral_ddd}}{Defined Daily Dose (DDD), oral treatment}
|
\item{\code{oral_ddd}}{Defined Daily Dose (DDD), oral treatment}
|
||||||
\item{\code{oral_units}}{Units of \code{ddd_units}}
|
\item{\code{oral_units}}{Units of \code{ddd_units}}
|
||||||
\item{\code{iv_ddd}}{Defined Daily Dose (DDD), parenteral treatment}
|
\item{\code{iv_ddd}}{Defined Daily Dose (DDD), parenteral treatment}
|
||||||
|
@ -15,7 +15,7 @@ is.mic(x)
|
|||||||
\item{na.rm}{a logical indicating whether missing values should be removed}
|
\item{na.rm}{a logical indicating whether missing values should be removed}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
New class \code{mic}
|
Ordered factor with new class \code{mic} and new attributes \code{package} and \code{package.version}
|
||||||
}
|
}
|
||||||
\description{
|
\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.
|
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.
|
||||||
|
@ -13,7 +13,7 @@ is.rsi(x)
|
|||||||
\item{x}{vector}
|
\item{x}{vector}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
New class \code{rsi}
|
Ordered factor with new class \code{rsi} and new attributes \code{package} and \code{package.version}
|
||||||
}
|
}
|
||||||
\description{
|
\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.
|
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.
|
||||||
|
35
man/guess_atc.Rd
Normal file
35
man/guess_atc.Rd
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/atc.R
|
||||||
|
\name{guess_atc}
|
||||||
|
\alias{guess_atc}
|
||||||
|
\title{Find ATC code based on antibiotic property}
|
||||||
|
\usage{
|
||||||
|
guess_atc(x)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{x}{character vector to determine \code{ATC} code}
|
||||||
|
}
|
||||||
|
\value{
|
||||||
|
Character (vector).
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Use this function to determine the ATC code of one or more antibiotics. The dataset \code{\link{antibiotics}} will be searched for abbreviations, official names and trade names.
|
||||||
|
}
|
||||||
|
\details{
|
||||||
|
In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups.
|
||||||
|
Source: \url{https://www.whocc.no/atc/structure_and_principles/}
|
||||||
|
}
|
||||||
|
\examples{
|
||||||
|
# These examples all return "J01FA01", the ATC code of Erythromycin:
|
||||||
|
guess_atc("J01FA01")
|
||||||
|
guess_atc("Erythromycin")
|
||||||
|
guess_atc("eryt")
|
||||||
|
guess_atc("ERYT")
|
||||||
|
guess_atc("ERY")
|
||||||
|
guess_atc("Erythrocin") # Trade name
|
||||||
|
guess_atc("Eryzole") # Trade name
|
||||||
|
guess_atc("Pediamycin") # Trade name
|
||||||
|
}
|
||||||
|
\seealso{
|
||||||
|
\code{\link{antibiotics}} for the dataframe that is being used to determine ATC's.
|
||||||
|
}
|
@ -3,13 +3,17 @@ context("mdro.R")
|
|||||||
|
|
||||||
test_that("MDRO works", {
|
test_that("MDRO works", {
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
outcome <- MDRO(septic_patients, "nl", info = FALSE)
|
|
||||||
|
|
||||||
|
outcome <- MDRO(septic_patients, "EUCAST", info = FALSE)
|
||||||
|
# check class
|
||||||
|
expect_equal(outcome %>% class(), c('ordered', 'factor'))
|
||||||
|
|
||||||
|
outcome <- MDRO(septic_patients, "nl", info = FALSE)
|
||||||
# check class
|
# check class
|
||||||
expect_equal(outcome %>% class(), c('ordered', 'factor'))
|
expect_equal(outcome %>% class(), c('ordered', 'factor'))
|
||||||
|
|
||||||
# septic_patients should have these finding using Dutch guidelines
|
# septic_patients should have these finding using Dutch guidelines
|
||||||
expect_equal(outcome %>% freq(toConsole = FALSE) %>% pull(Count), c(1152, 824, 3, 21))
|
expect_equal(outcome %>% freq(toConsole = FALSE) %>% pull(Count), c(3, 21))
|
||||||
|
|
||||||
expect_equal(BRMO(septic_patients, info = FALSE), MDRO(septic_patients, "nl", info = FALSE))
|
expect_equal(BRMO(septic_patients, info = FALSE), MDRO(septic_patients, "nl", info = FALSE))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user