mirror of https://github.com/msberends/AMR.git
replaced bactid by mo
This commit is contained in:
parent
98ff131680
commit
5965d3c794
|
@ -1,6 +1,6 @@
|
||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 0.3.0.9005
|
Version: 0.3.0.9006
|
||||||
Date: 2018-08-29
|
Date: 2018-08-31
|
||||||
Title: Antimicrobial Resistance Analysis
|
Title: Antimicrobial Resistance Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(
|
person(
|
||||||
|
|
10
NAMESPACE
10
NAMESPACE
|
@ -3,6 +3,7 @@
|
||||||
S3method(as.data.frame,atc)
|
S3method(as.data.frame,atc)
|
||||||
S3method(as.data.frame,bactid)
|
S3method(as.data.frame,bactid)
|
||||||
S3method(as.data.frame,frequency_tbl)
|
S3method(as.data.frame,frequency_tbl)
|
||||||
|
S3method(as.data.frame,mo)
|
||||||
S3method(as.double,mic)
|
S3method(as.double,mic)
|
||||||
S3method(as.integer,mic)
|
S3method(as.integer,mic)
|
||||||
S3method(as.numeric,mic)
|
S3method(as.numeric,mic)
|
||||||
|
@ -22,9 +23,11 @@ S3method(print,atc)
|
||||||
S3method(print,bactid)
|
S3method(print,bactid)
|
||||||
S3method(print,frequency_tbl)
|
S3method(print,frequency_tbl)
|
||||||
S3method(print,mic)
|
S3method(print,mic)
|
||||||
|
S3method(print,mo)
|
||||||
S3method(print,rsi)
|
S3method(print,rsi)
|
||||||
S3method(pull,atc)
|
S3method(pull,atc)
|
||||||
S3method(pull,bactid)
|
S3method(pull,bactid)
|
||||||
|
S3method(pull,mo)
|
||||||
S3method(skewness,data.frame)
|
S3method(skewness,data.frame)
|
||||||
S3method(skewness,default)
|
S3method(skewness,default)
|
||||||
S3method(skewness,matrix)
|
S3method(skewness,matrix)
|
||||||
|
@ -49,6 +52,7 @@ export(anti_join_microorganisms)
|
||||||
export(as.atc)
|
export(as.atc)
|
||||||
export(as.bactid)
|
export(as.bactid)
|
||||||
export(as.mic)
|
export(as.mic)
|
||||||
|
export(as.mo)
|
||||||
export(as.rsi)
|
export(as.rsi)
|
||||||
export(atc_ddd)
|
export(atc_ddd)
|
||||||
export(atc_groups)
|
export(atc_groups)
|
||||||
|
@ -71,11 +75,13 @@ export(geom_rsi)
|
||||||
export(ggplot_rsi)
|
export(ggplot_rsi)
|
||||||
export(guess_atc)
|
export(guess_atc)
|
||||||
export(guess_bactid)
|
export(guess_bactid)
|
||||||
|
export(guess_mo)
|
||||||
export(inner_join_microorganisms)
|
export(inner_join_microorganisms)
|
||||||
export(interpretive_reading)
|
export(interpretive_reading)
|
||||||
export(is.atc)
|
export(is.atc)
|
||||||
export(is.bactid)
|
export(is.bactid)
|
||||||
export(is.mic)
|
export(is.mic)
|
||||||
|
export(is.mo)
|
||||||
export(is.rsi)
|
export(is.rsi)
|
||||||
export(is.rsi.eligible)
|
export(is.rsi.eligible)
|
||||||
export(key_antibiotics)
|
export(key_antibiotics)
|
||||||
|
@ -102,6 +108,7 @@ export(portion_R)
|
||||||
export(portion_S)
|
export(portion_S)
|
||||||
export(portion_SI)
|
export(portion_SI)
|
||||||
export(portion_df)
|
export(portion_df)
|
||||||
|
export(ratio)
|
||||||
export(resistance_predict)
|
export(resistance_predict)
|
||||||
export(right_join_microorganisms)
|
export(right_join_microorganisms)
|
||||||
export(rsi)
|
export(rsi)
|
||||||
|
@ -115,6 +122,7 @@ export(top_freq)
|
||||||
exportMethods(as.data.frame.atc)
|
exportMethods(as.data.frame.atc)
|
||||||
exportMethods(as.data.frame.bactid)
|
exportMethods(as.data.frame.bactid)
|
||||||
exportMethods(as.data.frame.frequency_tbl)
|
exportMethods(as.data.frame.frequency_tbl)
|
||||||
|
exportMethods(as.data.frame.mo)
|
||||||
exportMethods(as.double.mic)
|
exportMethods(as.double.mic)
|
||||||
exportMethods(as.integer.mic)
|
exportMethods(as.integer.mic)
|
||||||
exportMethods(as.numeric.mic)
|
exportMethods(as.numeric.mic)
|
||||||
|
@ -135,9 +143,11 @@ exportMethods(print.atc)
|
||||||
exportMethods(print.bactid)
|
exportMethods(print.bactid)
|
||||||
exportMethods(print.frequency_tbl)
|
exportMethods(print.frequency_tbl)
|
||||||
exportMethods(print.mic)
|
exportMethods(print.mic)
|
||||||
|
exportMethods(print.mo)
|
||||||
exportMethods(print.rsi)
|
exportMethods(print.rsi)
|
||||||
exportMethods(pull.atc)
|
exportMethods(pull.atc)
|
||||||
exportMethods(pull.bactid)
|
exportMethods(pull.bactid)
|
||||||
|
exportMethods(pull.mo)
|
||||||
exportMethods(skewness)
|
exportMethods(skewness)
|
||||||
exportMethods(skewness.data.frame)
|
exportMethods(skewness.data.frame)
|
||||||
exportMethods(skewness.default)
|
exportMethods(skewness.default)
|
||||||
|
|
9
NEWS.md
9
NEWS.md
|
@ -4,6 +4,11 @@
|
||||||
* Functions `count_R`, `count_IR`, `count_I`, `count_SI` and `count_S` to selectively count resistant or susceptible isolates
|
* Functions `count_R`, `count_IR`, `count_I`, `count_SI` and `count_S` to selectively count resistant or susceptible isolates
|
||||||
* Extra function `count_df` (which works like `portion_df`) to get all counts of S, I and R of a data set with antibiotic columns, with support for grouped variables
|
* Extra function `count_df` (which works like `portion_df`) to get all counts of S, I and R of a data set with antibiotic columns, with support for grouped variables
|
||||||
* Function `is.rsi.eligible` to check for columns that have valid antimicrobial results, but do not have the `rsi` class yet. Transform the columns of your raw data with: `data %>% mutate_if(is.rsi.eligible, as.rsi)`
|
* Function `is.rsi.eligible` to check for columns that have valid antimicrobial results, but do not have the `rsi` class yet. Transform the columns of your raw data with: `data %>% mutate_if(is.rsi.eligible, as.rsi)`
|
||||||
|
* Functions `as.mo` and `is.mo` as replacements for `as.bactid` and `is.bactid`. These last two functions are deprecated and will be removed in a future release.
|
||||||
|
* Renamed all previous references to `bactid` to `mo`, like:
|
||||||
|
* Column names inputs of `EUCAST_rules`, `first_isolate` and `key_antibiotics`
|
||||||
|
* Column names of datasets `microorganisms` and `septic_patients`
|
||||||
|
* All old syntaxes will still work with this version, but will throw warnings
|
||||||
* Functions `as.atc` and `is.atc` to transform/look up antibiotic ATC codes as defined by the WHO. The existing function `guess_atc` is now an alias of `as.atc`.
|
* Functions `as.atc` and `is.atc` to transform/look up antibiotic ATC codes as defined by the WHO. The existing function `guess_atc` is now an alias of `as.atc`.
|
||||||
* Aliases for existing function `mo_property`: `mo_aerobic`, `mo_family`, `mo_fullname`, `mo_genus`, `mo_gramstain`, `mo_gramstain_nl`, `mo_property`, `mo_species`, `mo_subspecies`, `mo_type`, `mo_type_nl`
|
* Aliases for existing function `mo_property`: `mo_aerobic`, `mo_family`, `mo_fullname`, `mo_genus`, `mo_gramstain`, `mo_gramstain_nl`, `mo_property`, `mo_species`, `mo_subspecies`, `mo_type`, `mo_type_nl`
|
||||||
* Function `ab_property` and its aliases: `ab_certe`, `ab_official`, `ab_official_nl`, `ab_property`, `ab_trivial_nl`, `ab_umcg`, `ab_tradenames`
|
* Function `ab_property` and its aliases: `ab_certe`, `ab_official`, `ab_official_nl`, `ab_property`, `ab_trivial_nl`, `ab_umcg`, `ab_tradenames`
|
||||||
|
@ -21,9 +26,9 @@
|
||||||
ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
|
ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
|
||||||
# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
|
# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
|
||||||
```
|
```
|
||||||
* Removed function `ratio` as it is not really the scope of this package
|
* Function `ratio` is now deprecated and will be removed in a future release, as it is not really the scope of this package
|
||||||
* Fix for `as.mic` for values ending in zeroes after a real number
|
* Fix for `as.mic` for values ending in zeroes after a real number
|
||||||
* Huge speed improvement for `as.bactid`
|
* Huge speed improvement for `as.bactid` (now `as.mo`)
|
||||||
* Added parameters `minimum` and `as_percent` to `portion_df`
|
* Added parameters `minimum` and `as_percent` to `portion_df`
|
||||||
* Support for quasiquotation in the functions series `count_*` and `portions_*`, and `n_rsi`. This allows to check for more than 2 vectors or columns.
|
* Support for quasiquotation in the functions series `count_*` and `portions_*`, and `n_rsi`. This allows to check for more than 2 vectors or columns.
|
||||||
```r
|
```r
|
||||||
|
|
24
R/data.R
24
R/data.R
|
@ -125,7 +125,7 @@
|
||||||
#' A dataset containing 2,646 microorganisms. MO codes of the UMCG can be looked up using \code{\link{microorganisms.umcg}}.
|
#' A dataset containing 2,646 microorganisms. MO codes of the UMCG can be looked up using \code{\link{microorganisms.umcg}}.
|
||||||
#' @format A data.frame with 2,646 observations and 12 variables:
|
#' @format A data.frame with 2,646 observations and 12 variables:
|
||||||
#' \describe{
|
#' \describe{
|
||||||
#' \item{\code{bactid}}{ID of microorganism}
|
#' \item{\code{mo}}{ID of microorganism}
|
||||||
#' \item{\code{bactsys}}{Bactsyscode of microorganism}
|
#' \item{\code{bactsys}}{Bactsyscode of microorganism}
|
||||||
#' \item{\code{family}}{Family name of microorganism}
|
#' \item{\code{family}}{Family name of microorganism}
|
||||||
#' \item{\code{genus}}{Genus name of microorganism, like \code{"Echerichia"}}
|
#' \item{\code{genus}}{Genus name of microorganism, like \code{"Echerichia"}}
|
||||||
|
@ -140,27 +140,27 @@
|
||||||
#' }
|
#' }
|
||||||
# source MOLIS (LIS of Certe) - \url{https://www.certe.nl}
|
# source MOLIS (LIS of Certe) - \url{https://www.certe.nl}
|
||||||
# new <- microorganisms %>% filter(genus == "Bacteroides") %>% .[1,]
|
# new <- microorganisms %>% filter(genus == "Bacteroides") %>% .[1,]
|
||||||
# new[1, 'bactid'] <- "DIAPNU"
|
# new[1, 'mo'] <- "DIAPNU"
|
||||||
# new[1, 'bactsys'] <- "DIAPNU"
|
# new[1, 'bactsys'] <- "DIAPNU"
|
||||||
# new[1, 'family'] <- "Veillonellaceae"
|
# new[1, 'family'] <- "Veillonellaceae"
|
||||||
# new[1, 'genus'] <- "Dialister"
|
# new[1, 'genus'] <- "Dialister"
|
||||||
# new[1, 'species'] <- "pneumosintes"
|
# new[1, 'species'] <- "pneumosintes"
|
||||||
# new[1, 'subspecies'] <- NA
|
# new[1, 'subspecies'] <- NA
|
||||||
# new[1, 'fullname'] <- paste(new[1, 'genus'], new[1, 'species'])
|
# new[1, 'fullname'] <- paste(new[1, 'genus'], new[1, 'species'])
|
||||||
# microorganisms <- microorganisms %>% bind_rows(new) %>% arrange(bactid)
|
# microorganisms <- microorganisms %>% bind_rows(new) %>% arrange(mo)
|
||||||
#' @seealso \code{\link{guess_bactid}} \code{\link{antibiotics}} \code{\link{microorganisms.umcg}}
|
#' @seealso \code{\link{guess_mo}} \code{\link{antibiotics}} \code{\link{microorganisms.umcg}}
|
||||||
"microorganisms"
|
"microorganisms"
|
||||||
|
|
||||||
#' Translation table for UMCG with ~1100 microorganisms
|
#' Translation table for UMCG with ~1100 microorganisms
|
||||||
#'
|
#'
|
||||||
#' A dataset containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$bactid} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{bactid}'s with \code{\link{guess_bactid}}.
|
#' A dataset containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$mo} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{mo}'s with \code{\link{guess_mo}}.
|
||||||
#' @format A data.frame with 1090 observations and 2 variables:
|
#' @format A data.frame with 1090 observations and 2 variables:
|
||||||
#' \describe{
|
#' \describe{
|
||||||
#' \item{\code{mocode}}{Code of microorganism according to UMCG MMB}
|
#' \item{\code{umcg}}{Code of microorganism according to UMCG MMB}
|
||||||
#' \item{\code{bactid}}{Code of microorganism in \code{\link{microorganisms}}}
|
#' \item{\code{mo}}{Code of microorganism in \code{\link{microorganisms}}}
|
||||||
#' }
|
#' }
|
||||||
# source MOLIS (LIS of Certe) - \url{https://www.certe.nl} \cr \cr GLIMS (LIS of UMCG) - \url{https://www.umcg.nl}
|
# source MOLIS (LIS of Certe) - \url{https://www.certe.nl} \cr \cr GLIMS (LIS of UMCG) - \url{https://www.umcg.nl}
|
||||||
#' @seealso \code{\link{guess_bactid}} \code{\link{microorganisms}}
|
#' @seealso \code{\link{guess_mo}} \code{\link{microorganisms}}
|
||||||
"microorganisms.umcg"
|
"microorganisms.umcg"
|
||||||
|
|
||||||
#' Dataset with 2000 blood culture isolates of septic patients
|
#' Dataset with 2000 blood culture isolates of septic patients
|
||||||
|
@ -176,7 +176,7 @@
|
||||||
#' \item{\code{age}}{age of the patient}
|
#' \item{\code{age}}{age of the patient}
|
||||||
#' \item{\code{sex}}{sex of the patient}
|
#' \item{\code{sex}}{sex of the patient}
|
||||||
#' \item{\code{patient_id}}{ID of the patient, first 10 characters of an SHA hash containing irretrievable information}
|
#' \item{\code{patient_id}}{ID of the patient, first 10 characters of an SHA hash containing irretrievable information}
|
||||||
#' \item{\code{bactid}}{ID of microorganism, see \code{\link{microorganisms}}}
|
#' \item{\code{mo}}{ID of microorganism, see \code{\link{microorganisms}}}
|
||||||
#' \item{\code{peni:rifa}}{40 different antibiotics with class \code{rsi} (see \code{\link{as.rsi}}); these column names occur in \code{\link{antibiotics}} data set and can be translated with \code{\link{abname}}}
|
#' \item{\code{peni:rifa}}{40 different antibiotics with class \code{rsi} (see \code{\link{as.rsi}}); these column names occur in \code{\link{antibiotics}} data set and can be translated with \code{\link{abname}}}
|
||||||
#' }
|
#' }
|
||||||
# source MOLIS (LIS of Certe) - \url{https://www.certe.nl}
|
# source MOLIS (LIS of Certe) - \url{https://www.certe.nl}
|
||||||
|
@ -193,7 +193,7 @@
|
||||||
#'
|
#'
|
||||||
#' # Add first isolates to our dataset:
|
#' # Add first isolates to our dataset:
|
||||||
#' my_data <- my_data %>%
|
#' my_data <- my_data %>%
|
||||||
#' mutate(first_isolates = first_isolate(my_data, "date", "patient_id", "bactid"))
|
#' mutate(first_isolates = first_isolate(my_data, "date", "patient_id", "mo"))
|
||||||
#'
|
#'
|
||||||
#' # -------- #
|
#' # -------- #
|
||||||
#' # ANALYSIS #
|
#' # ANALYSIS #
|
||||||
|
@ -203,7 +203,7 @@
|
||||||
#' # and numbers (n) of E. coli, divided by hospital:
|
#' # and numbers (n) of E. coli, divided by hospital:
|
||||||
#'
|
#'
|
||||||
#' my_data %>%
|
#' my_data %>%
|
||||||
#' filter(bactid == guess_bactid("E. coli"),
|
#' filter(mo == guess_mo("E. coli"),
|
||||||
#' first_isolates == TRUE) %>%
|
#' first_isolates == TRUE) %>%
|
||||||
#' group_by(hospital_id) %>%
|
#' group_by(hospital_id) %>%
|
||||||
#' summarise(n = n_rsi(amox),
|
#' summarise(n = n_rsi(amox),
|
||||||
|
@ -214,7 +214,7 @@
|
||||||
#' # percentages of E. coli, trend over the years:
|
#' # percentages of E. coli, trend over the years:
|
||||||
#'
|
#'
|
||||||
#' my_data %>%
|
#' my_data %>%
|
||||||
#' filter(bactid == guess_bactid("E. coli"),
|
#' filter(mo == guess_mo("E. coli"),
|
||||||
#' first_isolates == TRUE) %>%
|
#' first_isolates == TRUE) %>%
|
||||||
#' group_by(year = format(date, "%Y")) %>%
|
#' group_by(year = format(date, "%Y")) %>%
|
||||||
#' summarise(n = n_rsi(amcl),
|
#' summarise(n = n_rsi(amcl),
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
# ==================================================================== #
|
||||||
|
# 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. #
|
||||||
|
# ==================================================================== #
|
||||||
|
|
||||||
|
#' Deprecated functions
|
||||||
|
#'
|
||||||
|
#' These functions are \link{Deprecated}. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by.
|
||||||
|
#' @export
|
||||||
|
#' @keywords internal
|
||||||
|
#' @name AMR-deprecated
|
||||||
|
#' @rdname AMR-deprecated
|
||||||
|
as.bactid <- function(...) {
|
||||||
|
.Deprecated("as.mo", package = "AMR")
|
||||||
|
as.mo(...)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @rdname AMR-deprecated
|
||||||
|
#' @export
|
||||||
|
is.bactid <- function(...) {
|
||||||
|
.Deprecated(new = "is.mo", package = "AMR")
|
||||||
|
is.mo(...)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @rdname AMR-deprecated
|
||||||
|
#' @export
|
||||||
|
guess_bactid <- function(...) {
|
||||||
|
.Deprecated(new = "guess_mo", package = "AMR")
|
||||||
|
guess_mo(...)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @rdname AMR-deprecated
|
||||||
|
#' @export
|
||||||
|
ratio <- function(x, ratio) {
|
||||||
|
.Deprecated(package = "AMR")
|
||||||
|
|
||||||
|
if (!all(is.numeric(x))) {
|
||||||
|
stop('`x` must be a vector of numeric values.')
|
||||||
|
}
|
||||||
|
if (length(ratio) == 1) {
|
||||||
|
if (ratio %like% '^([0-9]+([.][0-9]+)?[-,:])+[0-9]+([.][0-9]+)?$') {
|
||||||
|
# support for "1:2:1", "1-2-1", "1,2,1" and even "1.75:2:1.5"
|
||||||
|
ratio <- ratio %>% base::strsplit("[-,:]") %>% base::unlist() %>% base::as.double()
|
||||||
|
} else {
|
||||||
|
stop('Invalid `ratio`: ', ratio, '.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (length(x) != length(ratio)) {
|
||||||
|
stop('`x` and `ratio` must be of same size.')
|
||||||
|
}
|
||||||
|
base::sum(x, na.rm = TRUE) * (ratio / base::sum(ratio, na.rm = TRUE))
|
||||||
|
}
|
46
R/eucast.R
46
R/eucast.R
|
@ -20,11 +20,12 @@
|
||||||
#'
|
#'
|
||||||
#' Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
|
#' Apply 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}
|
#' @param tbl table with antibiotic columns, like e.g. \code{amox} and \code{amcl}
|
||||||
#' @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_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}}
|
||||||
#' @param info print progress
|
#' @param info print progress
|
||||||
#' @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 names of antibiotics. 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 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.
|
||||||
#' @param ... parameters that are passed on to \code{EUCAST_rules}
|
#' @param ... parameters that are passed on to \code{EUCAST_rules}
|
||||||
#' @section Abbrevations of antibiotics:
|
#' @section Antibiotics:
|
||||||
#' Abbrevations of the column containing antibiotics:
|
#' Abbrevations of the column containing antibiotics:
|
||||||
#'
|
#'
|
||||||
#' \strong{amcl}: amoxicillin and beta-lactamase inhibitor (\emph{J01CR02}),
|
#' \strong{amcl}: amoxicillin and beta-lactamase inhibitor (\emph{J01CR02}),
|
||||||
|
@ -102,23 +103,23 @@
|
||||||
#' \url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}
|
#' \url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}
|
||||||
#' @examples
|
#' @examples
|
||||||
#' a <- EUCAST_rules(septic_patients)
|
#' a <- EUCAST_rules(septic_patients)
|
||||||
#' a <- data.frame(bactid = c("STAAUR", # Staphylococcus aureus
|
#' a <- data.frame(mo = c("STAAUR", # Staphylococcus aureus
|
||||||
#' "ENCFAE", # Enterococcus faecalis
|
#' "ENCFAE", # Enterococcus faecalis
|
||||||
#' "ESCCOL", # Escherichia coli
|
#' "ESCCOL", # Escherichia coli
|
||||||
#' "KLEPNE", # Klebsiella pneumoniae
|
#' "KLEPNE", # Klebsiella pneumoniae
|
||||||
#' "PSEAER"), # Pseudomonas aeruginosa
|
#' "PSEAER"), # Pseudomonas aeruginosa
|
||||||
#' vanc = "-", # Vancomycin
|
#' vanc = "-", # Vancomycin
|
||||||
#' amox = "-", # Amoxicillin
|
#' amox = "-", # Amoxicillin
|
||||||
#' coli = "-", # Colistin
|
#' coli = "-", # Colistin
|
||||||
#' cfta = "-", # Ceftazidime
|
#' cfta = "-", # Ceftazidime
|
||||||
#' cfur = "-", # Cefuroxime
|
#' cfur = "-", # Cefuroxime
|
||||||
#' stringsAsFactors = FALSE)
|
#' stringsAsFactors = FALSE)
|
||||||
#' a
|
#' a
|
||||||
#'
|
#'
|
||||||
#' b <- EUCAST_rules(a)
|
#' b <- EUCAST_rules(a)
|
||||||
#' b
|
#' b
|
||||||
EUCAST_rules <- function(tbl,
|
EUCAST_rules <- function(tbl,
|
||||||
col_bactid = 'bactid',
|
col_mo = 'mo',
|
||||||
info = TRUE,
|
info = TRUE,
|
||||||
amcl = 'amcl',
|
amcl = 'amcl',
|
||||||
amik = 'amik',
|
amik = 'amik',
|
||||||
|
@ -180,12 +181,17 @@ EUCAST_rules <- function(tbl,
|
||||||
tobr = 'tobr',
|
tobr = 'tobr',
|
||||||
trim = 'trim',
|
trim = 'trim',
|
||||||
trsu = 'trsu',
|
trsu = 'trsu',
|
||||||
vanc = 'vanc') {
|
vanc = 'vanc',
|
||||||
|
col_bactid = 'bactid') {
|
||||||
|
|
||||||
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.', call. = FALSE)
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
# check columns
|
# check columns
|
||||||
|
@ -274,10 +280,10 @@ EUCAST_rules <- function(tbl,
|
||||||
}
|
}
|
||||||
|
|
||||||
# join to microorganisms data set
|
# join to microorganisms data set
|
||||||
if (!tbl %>% pull(col_bactid) %>% is.bactid()) {
|
if (!tbl %>% pull(col_mo) %>% is.mo()) {
|
||||||
warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.")
|
warning("Improve integrity of the `", col_mo, "` column by transforming it with 'as.mo'.")
|
||||||
}
|
}
|
||||||
tbl <- tbl %>% left_join_microorganisms(by = col_bactid, suffix = c("_tempmicroorganisms", ""))
|
tbl <- tbl %>% left_join_microorganisms(by = col_mo, suffix = c("_tempmicroorganisms", ""))
|
||||||
|
|
||||||
# antibiotic classes
|
# antibiotic classes
|
||||||
aminoglycosides <- c(tobr, gent, kana, neom, neti, siso)
|
aminoglycosides <- c(tobr, gent, kana, neom, neti, siso)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#' @param tbl a \code{data.frame} containing isolates.
|
#' @param tbl a \code{data.frame} containing isolates.
|
||||||
#' @param col_date column name of the result date (or date that is was received on the lab)
|
#' @param col_date column name of the result date (or date that is was received on the lab)
|
||||||
#' @param col_patient_id column name of the unique IDs of the patients
|
#' @param col_patient_id column name of the unique IDs of the patients
|
||||||
#' @param col_bactid column name of the unique IDs of the microorganisms: \code{bactid}'s. If this column has another class than \code{"bactid"}, values will be coerced using \code{\link{as.bactid}}.
|
#' @param col_mo column name of the unique IDs of the microorganisms, see \code{\link{mo}}. If this column has another class than \code{"mo"}, values will be coerced using \code{\link{as.mo}}.
|
||||||
#' @param col_testcode column name of the test codes. Use \code{col_testcode = NA} to \strong{not} exclude certain test codes (like test codes for screening). In that case \code{testcodes_exclude} will be ignored. Supports tidyverse-like quotation.
|
#' @param col_testcode column name of the test codes. Use \code{col_testcode = NA} to \strong{not} exclude certain test codes (like test codes for screening). In that case \code{testcodes_exclude} will be ignored. Supports tidyverse-like quotation.
|
||||||
#' @param col_specimen column name of the specimen type or group
|
#' @param col_specimen column name of the specimen type or group
|
||||||
#' @param col_icu column name of the logicals (\code{TRUE}/\code{FALSE}) whether a ward or department is an Intensive Care Unit (ICU)
|
#' @param col_icu column name of the logicals (\code{TRUE}/\code{FALSE}) whether a ward or department is an Intensive Care Unit (ICU)
|
||||||
|
@ -36,8 +36,9 @@
|
||||||
#' @param ignore_I logical to determine whether antibiotic interpretations with \code{"I"} will be ignored when \code{type = "keyantibiotics"}, see Details
|
#' @param ignore_I logical to determine whether antibiotic interpretations with \code{"I"} will be ignored when \code{type = "keyantibiotics"}, see Details
|
||||||
#' @param points_threshold points until the comparison of key antibiotics will lead to inclusion of an isolate when \code{type = "points"}, see Details
|
#' @param points_threshold points until the comparison of key antibiotics will lead to inclusion of an isolate when \code{type = "points"}, see Details
|
||||||
#' @param info print progress
|
#' @param info print progress
|
||||||
#' @param col_genus (deprecated, use \code{col_bactid} instead) column name of the genus of the microorganisms
|
#' @param col_bactid (deprecated, use \code{col_mo} instead)
|
||||||
#' @param col_species (deprecated, use \code{col_bactid} instead) column name of the species of the microorganisms
|
#' @param col_genus (deprecated, use \code{col_mo} instead) column name of the genus of the microorganisms
|
||||||
|
#' @param col_species (deprecated, use \code{col_mo} instead) column name of the species of the microorganisms
|
||||||
#' @details \strong{WHY THIS IS SO IMPORTANT} \cr
|
#' @details \strong{WHY THIS IS SO IMPORTANT} \cr
|
||||||
#' To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode \href{https://www.ncbi.nlm.nih.gov/pubmed/17304462}{[1]}. If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following week. The resistance percentage of oxacillin of all \emph{S. aureus} isolates would be overestimated, because you included this MRSA more than once. It would be \href{https://en.wikipedia.org/wiki/Selection_bias}{selection bias}.
|
#' To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode \href{https://www.ncbi.nlm.nih.gov/pubmed/17304462}{[1]}. If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following week. The resistance percentage of oxacillin of all \emph{S. aureus} isolates would be overestimated, because you included this MRSA more than once. It would be \href{https://en.wikipedia.org/wiki/Selection_bias}{selection bias}.
|
||||||
#' @section Key antibiotics:
|
#' @section Key antibiotics:
|
||||||
|
@ -63,7 +64,7 @@
|
||||||
#' mutate(first_isolate = first_isolate(.,
|
#' mutate(first_isolate = first_isolate(.,
|
||||||
#' col_date = "date",
|
#' col_date = "date",
|
||||||
#' col_patient_id = "patient_id",
|
#' col_patient_id = "patient_id",
|
||||||
#' col_bactid = "bactid"))
|
#' col_mo = "mo"))
|
||||||
#'
|
#'
|
||||||
#' # Now let's see if first isolates matter:
|
#' # Now let's see if first isolates matter:
|
||||||
#' A <- my_patients %>%
|
#' A <- my_patients %>%
|
||||||
|
@ -126,7 +127,7 @@
|
||||||
first_isolate <- function(tbl,
|
first_isolate <- function(tbl,
|
||||||
col_date,
|
col_date,
|
||||||
col_patient_id,
|
col_patient_id,
|
||||||
col_bactid = NA,
|
col_mo = NA,
|
||||||
col_testcode = NA,
|
col_testcode = NA,
|
||||||
col_specimen = NA,
|
col_specimen = NA,
|
||||||
col_icu = NA,
|
col_icu = NA,
|
||||||
|
@ -140,12 +141,17 @@ first_isolate <- function(tbl,
|
||||||
ignore_I = TRUE,
|
ignore_I = TRUE,
|
||||||
points_threshold = 2,
|
points_threshold = 2,
|
||||||
info = TRUE,
|
info = TRUE,
|
||||||
|
col_bactid = NA,
|
||||||
col_genus = NA,
|
col_genus = NA,
|
||||||
col_species = NA) {
|
col_species = NA) {
|
||||||
|
|
||||||
|
if (!is.na(col_bactid)) {
|
||||||
|
col_mo <- col_bactid
|
||||||
|
warning("Use of `col_bactid` is deprecated. Use `col_mo` instead.")
|
||||||
|
}
|
||||||
# bactid OR genus+species must be available
|
# bactid OR genus+species must be available
|
||||||
if (is.na(col_bactid) & (is.na(col_genus) | is.na(col_species))) {
|
if (is.na(col_mo) & (is.na(col_genus) | is.na(col_species))) {
|
||||||
stop('`col_bactid` or both `col_genus` and `col_species` must be available.')
|
stop('`col_mo` or both `col_genus` and `col_species` must be available.')
|
||||||
}
|
}
|
||||||
|
|
||||||
# check if columns exist
|
# check if columns exist
|
||||||
|
@ -163,19 +169,19 @@ first_isolate <- function(tbl,
|
||||||
|
|
||||||
check_columns_existance(col_date)
|
check_columns_existance(col_date)
|
||||||
check_columns_existance(col_patient_id)
|
check_columns_existance(col_patient_id)
|
||||||
check_columns_existance(col_bactid)
|
check_columns_existance(col_mo)
|
||||||
check_columns_existance(col_genus)
|
check_columns_existance(col_genus)
|
||||||
check_columns_existance(col_species)
|
check_columns_existance(col_species)
|
||||||
check_columns_existance(col_testcode)
|
check_columns_existance(col_testcode)
|
||||||
check_columns_existance(col_icu)
|
check_columns_existance(col_icu)
|
||||||
check_columns_existance(col_keyantibiotics)
|
check_columns_existance(col_keyantibiotics)
|
||||||
|
|
||||||
if (!is.na(col_bactid)) {
|
if (!is.na(col_mo)) {
|
||||||
if (!tbl %>% pull(col_bactid) %>% is.bactid()) {
|
if (!tbl %>% pull(col_mo) %>% is.mo()) {
|
||||||
warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.")
|
warning("Improve integrity of the `", col_mo, "` column by transforming it with 'as.mo'.")
|
||||||
}
|
}
|
||||||
# join to microorganisms data set
|
# join to microorganisms data set
|
||||||
tbl <- tbl %>% left_join_microorganisms(by = col_bactid)
|
tbl <- tbl %>% left_join_microorganisms(by = col_mo)
|
||||||
col_genus <- "genus"
|
col_genus <- "genus"
|
||||||
col_species <- "species"
|
col_species <- "species"
|
||||||
}
|
}
|
||||||
|
|
4
R/freq.R
4
R/freq.R
|
@ -76,7 +76,7 @@
|
||||||
#' # you could also use `select` or `pull` to get your variables
|
#' # you could also use `select` or `pull` to get your variables
|
||||||
#' septic_patients %>%
|
#' septic_patients %>%
|
||||||
#' filter(hospital_id == "A") %>%
|
#' filter(hospital_id == "A") %>%
|
||||||
#' select(bactid) %>%
|
#' select(mo) %>%
|
||||||
#' freq()
|
#' freq()
|
||||||
#'
|
#'
|
||||||
#' # multiple selected variables will be pasted together
|
#' # multiple selected variables will be pasted together
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
#' # get top 10 bugs of hospital A as a vector
|
#' # get top 10 bugs of hospital A as a vector
|
||||||
#' septic_patients %>%
|
#' septic_patients %>%
|
||||||
#' filter(hospital_id == "A") %>%
|
#' filter(hospital_id == "A") %>%
|
||||||
#' freq(bactid) %>%
|
#' freq(mo) %>%
|
||||||
#' top_freq(10)
|
#' top_freq(10)
|
||||||
#'
|
#'
|
||||||
#' # save frequency table to an object
|
#' # save frequency table to an object
|
||||||
|
|
|
@ -100,14 +100,14 @@
|
||||||
#' # genuine analysis: check 2 most prevalent microorganisms
|
#' # genuine analysis: check 2 most prevalent microorganisms
|
||||||
#' septic_patients %>%
|
#' septic_patients %>%
|
||||||
#' # create new bacterial ID's, with all CoNS under the same group (Becker et al.)
|
#' # create new bacterial ID's, with all CoNS under the same group (Becker et al.)
|
||||||
#' mutate(bactid = as.bactid(bactid, Becker = TRUE)) %>%
|
#' mutate(mo = as.mo(mo, Becker = TRUE)) %>%
|
||||||
#' # filter on top 2 bacterial ID's
|
#' # filter on top 2 bacterial ID's
|
||||||
#' filter(bactid %in% top_freq(freq(.$bactid), 2)) %>%
|
#' filter(mo %in% top_freq(freq(.$mo), 2)) %>%
|
||||||
#' # determine first isolates
|
#' # determine first isolates
|
||||||
#' mutate(first_isolate = first_isolate(.,
|
#' mutate(first_isolate = first_isolate(.,
|
||||||
#' col_date = "date",
|
#' col_date = "date",
|
||||||
#' col_patient_id = "patient_id",
|
#' col_patient_id = "patient_id",
|
||||||
#' col_bactid = "bactid")) %>%
|
#' col_mo = "mo")) %>%
|
||||||
#' # filter on first isolates
|
#' # filter on first isolates
|
||||||
#' filter(first_isolate == TRUE) %>%
|
#' filter(first_isolate == TRUE) %>%
|
||||||
#' # join the `microorganisms` data set
|
#' # join the `microorganisms` data set
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
#' ggplot_rsi(x = "Antibiotic",
|
#' ggplot_rsi(x = "Antibiotic",
|
||||||
#' facet = "mo") +
|
#' facet = "mo") +
|
||||||
#' labs(title = "AMR of Top Two Microorganisms In Blood Culture Isolates",
|
#' labs(title = "AMR of Top Two Microorganisms In Blood Culture Isolates",
|
||||||
#' subtitle = "Only First Isolates, CoNS grouped according to Becker et al.",
|
#' subtitle = "Only First Isolates, CoNS grouped according to Becker et al. (2014)",
|
||||||
#' x = "Microorganisms")
|
#' x = "Microorganisms")
|
||||||
#' }
|
#' }
|
||||||
ggplot_rsi <- function(data,
|
ggplot_rsi <- function(data,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#' @name join
|
#' @name join
|
||||||
#' @aliases join inner_join
|
#' @aliases join inner_join
|
||||||
#' @param x existing table to join, also supports character vectors
|
#' @param x existing table to join, also supports character vectors
|
||||||
#' @param by a variable to join by - could be a column name of \code{x} with values that exist in \code{microorganisms$bactid} (like \code{by = "bacteria_id"}), or another column in \code{\link{microorganisms}} (but then it should be named, like \code{by = c("my_genus_species" = "fullname")})
|
#' @param by a variable to join by - could be a column name of \code{x} with values that exist in \code{microorganisms$mo} (like \code{by = "bacteria_id"}), or another column in \code{\link{microorganisms}} (but then it should be named, like \code{by = c("my_genus_species" = "fullname")})
|
||||||
#' @param suffix if there are non-joined duplicate variables in \code{x} and \code{y}, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2.
|
#' @param suffix if there are non-joined duplicate variables in \code{x} and \code{y}, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2.
|
||||||
#' @param ... other parameters to pass on to \code{dplyr::\link[dplyr]{join}}.
|
#' @param ... other parameters to pass on to \code{dplyr::\link[dplyr]{join}}.
|
||||||
#' @details As opposed to the \code{\link[dplyr]{join}} functions of \code{dplyr}, characters vectors are supported and at default existing columns will get a suffix \code{"2"} and the newly joined columns will not get a suffix. See \code{\link[dplyr]{join}} for more information.
|
#' @details As opposed to the \code{\link[dplyr]{join}} functions of \code{dplyr}, characters vectors are supported and at default existing columns will get a suffix \code{"2"} and the newly joined columns will not get a suffix. See \code{\link[dplyr]{join}} for more information.
|
||||||
|
@ -25,9 +25,9 @@
|
||||||
#' colnames(df)
|
#' colnames(df)
|
||||||
#' df2 <- left_join_microorganisms(df, "bacteria_id")
|
#' df2 <- left_join_microorganisms(df, "bacteria_id")
|
||||||
#' colnames(df2)
|
#' colnames(df2)
|
||||||
inner_join_microorganisms <- function(x, by = 'bactid', suffix = c("2", ""), ...) {
|
inner_join_microorganisms <- function(x, by = 'mo', suffix = c("2", ""), ...) {
|
||||||
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
||||||
x <- data.frame(bactid = as.character(x), stringsAsFactors = FALSE)
|
x <- data.frame(mo = as.character(x), stringsAsFactors = FALSE)
|
||||||
}
|
}
|
||||||
# no name set to `by` parameter
|
# no name set to `by` parameter
|
||||||
if (is.null(names(by))) {
|
if (is.null(names(by))) {
|
||||||
|
@ -47,9 +47,9 @@ inner_join_microorganisms <- function(x, by = 'bactid', suffix = c("2", ""), ...
|
||||||
|
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
#' @export
|
#' @export
|
||||||
left_join_microorganisms <- function(x, by = 'bactid', suffix = c("2", ""), ...) {
|
left_join_microorganisms <- function(x, by = 'mo', suffix = c("2", ""), ...) {
|
||||||
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
||||||
x <- data.frame(bactid = as.character(x), stringsAsFactors = FALSE)
|
x <- data.frame(mo = as.character(x), stringsAsFactors = FALSE)
|
||||||
}
|
}
|
||||||
# no name set to `by` parameter
|
# no name set to `by` parameter
|
||||||
if (is.null(names(by))) {
|
if (is.null(names(by))) {
|
||||||
|
@ -69,9 +69,9 @@ left_join_microorganisms <- function(x, by = 'bactid', suffix = c("2", ""), ...)
|
||||||
|
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
#' @export
|
#' @export
|
||||||
right_join_microorganisms <- function(x, by = 'bactid', suffix = c("2", ""), ...) {
|
right_join_microorganisms <- function(x, by = 'mo', suffix = c("2", ""), ...) {
|
||||||
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
||||||
x <- data.frame(bactid = as.character(x), stringsAsFactors = FALSE)
|
x <- data.frame(mo = as.character(x), stringsAsFactors = FALSE)
|
||||||
}
|
}
|
||||||
# no name set to `by` parameter
|
# no name set to `by` parameter
|
||||||
if (is.null(names(by))) {
|
if (is.null(names(by))) {
|
||||||
|
@ -91,9 +91,9 @@ right_join_microorganisms <- function(x, by = 'bactid', suffix = c("2", ""), ...
|
||||||
|
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
#' @export
|
#' @export
|
||||||
full_join_microorganisms <- function(x, by = 'bactid', suffix = c("2", ""), ...) {
|
full_join_microorganisms <- function(x, by = 'mo', suffix = c("2", ""), ...) {
|
||||||
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
||||||
x <- data.frame(bactid = as.character(x), stringsAsFactors = FALSE)
|
x <- data.frame(mo = as.character(x), stringsAsFactors = FALSE)
|
||||||
}
|
}
|
||||||
# no name set to `by` parameter
|
# no name set to `by` parameter
|
||||||
if (is.null(names(by))) {
|
if (is.null(names(by))) {
|
||||||
|
@ -113,9 +113,9 @@ full_join_microorganisms <- function(x, by = 'bactid', suffix = c("2", ""), ...)
|
||||||
|
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
#' @export
|
#' @export
|
||||||
semi_join_microorganisms <- function(x, by = 'bactid', ...) {
|
semi_join_microorganisms <- function(x, by = 'mo', ...) {
|
||||||
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
||||||
x <- data.frame(bactid = as.character(x), stringsAsFactors = FALSE)
|
x <- data.frame(mo = as.character(x), stringsAsFactors = FALSE)
|
||||||
}
|
}
|
||||||
# no name set to `by` parameter
|
# no name set to `by` parameter
|
||||||
if (is.null(names(by))) {
|
if (is.null(names(by))) {
|
||||||
|
@ -131,9 +131,9 @@ semi_join_microorganisms <- function(x, by = 'bactid', ...) {
|
||||||
|
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
#' @export
|
#' @export
|
||||||
anti_join_microorganisms <- function(x, by = 'bactid', ...) {
|
anti_join_microorganisms <- function(x, by = 'mo', ...) {
|
||||||
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
||||||
x <- data.frame(bactid = as.character(x), stringsAsFactors = FALSE)
|
x <- data.frame(mo = as.character(x), stringsAsFactors = FALSE)
|
||||||
}
|
}
|
||||||
# no name set to `by` parameter
|
# no name set to `by` parameter
|
||||||
if (is.null(names(by))) {
|
if (is.null(names(by))) {
|
||||||
|
|
|
@ -52,9 +52,9 @@
|
||||||
#' mutate(keyab = key_antibiotics(.)) %>%
|
#' mutate(keyab = key_antibiotics(.)) %>%
|
||||||
#' mutate(
|
#' mutate(
|
||||||
#' # now calculate first isolates
|
#' # now calculate first isolates
|
||||||
#' first_regular = first_isolate(., "date", "patient_id", "bactid"),
|
#' first_regular = first_isolate(., "date", "patient_id", "mo"),
|
||||||
#' # and first WEIGHTED isolates
|
#' # and first WEIGHTED isolates
|
||||||
#' first_weighted = first_isolate(., "date", "patient_id", "bactid",
|
#' first_weighted = first_isolate(., "date", "patient_id", "mo",
|
||||||
#' col_keyantibiotics = "keyab")
|
#' col_keyantibiotics = "keyab")
|
||||||
#' )
|
#' )
|
||||||
#'
|
#'
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
#' key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
|
#' key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
|
||||||
#' # FALSE, because I is not ignored and so the 4th value differs
|
#' # FALSE, because I is not ignored and so the 4th value differs
|
||||||
key_antibiotics <- function(tbl,
|
key_antibiotics <- function(tbl,
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
universal_1 = "amox",
|
universal_1 = "amox",
|
||||||
universal_2 = "amcl",
|
universal_2 = "amcl",
|
||||||
universal_3 = "cfur",
|
universal_3 = "cfur",
|
||||||
|
@ -92,10 +92,15 @@ key_antibiotics <- function(tbl,
|
||||||
GramNeg_4 = "cfot",
|
GramNeg_4 = "cfot",
|
||||||
GramNeg_5 = "cfta",
|
GramNeg_5 = "cfta",
|
||||||
GramNeg_6 = "mero",
|
GramNeg_6 = "mero",
|
||||||
warnings = TRUE) {
|
warnings = TRUE,
|
||||||
|
col_bactid = "bactid") {
|
||||||
|
|
||||||
if (!col_bactid %in% colnames(tbl)) {
|
if (col_bactid %in% colnames(tbl)) {
|
||||||
stop('Column ', col_bactid, ' not found.', call. = FALSE)
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
# check columns
|
# check columns
|
||||||
|
@ -136,7 +141,7 @@ key_antibiotics <- function(tbl,
|
||||||
gram_negative <- gram_negative[!is.na(gram_negative)]
|
gram_negative <- gram_negative[!is.na(gram_negative)]
|
||||||
|
|
||||||
# join microorganisms
|
# join microorganisms
|
||||||
tbl <- tbl %>% left_join_microorganisms(col_bactid)
|
tbl <- tbl %>% left_join_microorganisms(col_mo)
|
||||||
|
|
||||||
tbl$key_ab <- NA_character_
|
tbl$key_ab <- NA_character_
|
||||||
|
|
||||||
|
|
22
R/mdro.R
22
R/mdro.R
|
@ -21,10 +21,11 @@
|
||||||
#' 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 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 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 info print progress
|
#' @param info print progress
|
||||||
#' @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
|
#' @inheritParams EUCAST_rules
|
||||||
|
#' @param metr 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 ... parameters that are passed on to methods
|
#' @param ... parameters that are passed on to methods
|
||||||
|
#' @inheritSection EUCAST_rules Antibiotics
|
||||||
#' @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}).
|
#' @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 levels \code{Unknown < Negative < Unconfirmed < Positive}.
|
#' @return Ordered factor with levels \code{Unknown < Negative < Unconfirmed < Positive}.
|
||||||
#' @rdname MDRO
|
#' @rdname MDRO
|
||||||
|
@ -34,10 +35,10 @@
|
||||||
#'
|
#'
|
||||||
#' septic_patients %>%
|
#' septic_patients %>%
|
||||||
#' mutate(EUCAST = MDRO(.),
|
#' mutate(EUCAST = MDRO(.),
|
||||||
#' BRMO = MDRO(., "nl"))
|
#' BRMO = BRMO(.))
|
||||||
MDRO <- function(tbl,
|
MDRO <- function(tbl,
|
||||||
country = NULL,
|
country = NULL,
|
||||||
col_bactid = 'bactid',
|
col_mo = 'mo',
|
||||||
info = TRUE,
|
info = TRUE,
|
||||||
amcl = 'amcl',
|
amcl = 'amcl',
|
||||||
amik = 'amik',
|
amik = 'amik',
|
||||||
|
@ -97,10 +98,15 @@ MDRO <- function(tbl,
|
||||||
tobr = 'tobr',
|
tobr = 'tobr',
|
||||||
trim = 'trim',
|
trim = 'trim',
|
||||||
trsu = 'trsu',
|
trsu = 'trsu',
|
||||||
vanc = 'vanc') {
|
vanc = 'vanc',
|
||||||
|
col_bactid = 'bactid') {
|
||||||
|
|
||||||
if (!col_bactid %in% colnames(tbl)) {
|
if (col_bactid %in% colnames(tbl)) {
|
||||||
stop('Column ', col_bactid, ' not found.', call. = FALSE)
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
# strip whitespaces
|
# strip whitespaces
|
||||||
|
@ -249,7 +255,7 @@ MDRO <- function(tbl,
|
||||||
}
|
}
|
||||||
|
|
||||||
# join microorganisms
|
# join microorganisms
|
||||||
tbl <- tbl %>% left_join_microorganisms(col_bactid)
|
tbl <- tbl %>% left_join_microorganisms(col_mo)
|
||||||
|
|
||||||
tbl$MDRO <- NA_integer_
|
tbl$MDRO <- NA_integer_
|
||||||
|
|
||||||
|
|
|
@ -16,18 +16,18 @@
|
||||||
# GNU General Public License for more details. #
|
# GNU General Public License for more details. #
|
||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
#' Transform to bacteria ID
|
#' Transform to microorganism ID
|
||||||
#'
|
#'
|
||||||
#' Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
#' Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
||||||
#' @param x a character vector or a dataframe with one or two columns
|
#' @param x a character vector or a dataframe with one or two columns
|
||||||
#' @param Becker a logical to indicate whether \emph{Staphylococci} should be categorised into Coagulase Negative \emph{Staphylococci} ("CoNS") and Coagulase Positive \emph{Staphylococci} ("CoPS") instead of their own species, according to Karsten Becker \emph{et al.} [1]. This excludes \emph{Staphylococcus aureus} at default, use \code{Becker = "all"} to also categorise \emph{S. aureus} as "CoPS".
|
#' @param Becker a logical to indicate whether \emph{Staphylococci} should be categorised into Coagulase Negative \emph{Staphylococci} ("CoNS") and Coagulase Positive \emph{Staphylococci} ("CoPS") instead of their own species, according to Karsten Becker \emph{et al.} [1]. This excludes \emph{Staphylococcus aureus} at default, use \code{Becker = "all"} to also categorise \emph{S. aureus} as "CoPS".
|
||||||
#' @param Lancefield a logical to indicate whether beta-haemolytic \emph{Streptococci} should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield [2]. These \emph{Streptococci} will be categorised in their first group, i.e. \emph{Streptococcus dysgalactiae} will be group C, although officially it was also categorised into groups G and L. Groups D and E will be ignored, since they are \emph{Enterococci}.
|
#' @param Lancefield a logical to indicate whether beta-haemolytic \emph{Streptococci} should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield [2]. These \emph{Streptococci} will be categorised in their first group, i.e. \emph{Streptococcus dysgalactiae} will be group C, although officially it was also categorised into groups G and L. Groups D and E will be ignored, since they are \emph{Enterococci}.
|
||||||
#' @rdname as.bactid
|
#' @rdname as.mo
|
||||||
#' @aliases bactid
|
#' @aliases mo
|
||||||
#' @keywords bactid Becker becker Lancefield lancefield guess
|
#' @keywords mo Becker becker Lancefield lancefield guess
|
||||||
#' @details \code{guess_bactid} is an alias of \code{as.bactid}.
|
#' @details \code{guess_mo} is an alias of \code{as.mo}.
|
||||||
#'
|
#'
|
||||||
#' Use the \code{\link{mo_property}} functions to get properties based on the returned bactid, see Examples.
|
#' Use the \code{\link{mo_property}} functions to get properties based on the returned mo, see Examples.
|
||||||
#'
|
#'
|
||||||
#' Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. These are:
|
#' Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. These are:
|
||||||
#' \itemize{
|
#' \itemize{
|
||||||
|
@ -45,51 +45,51 @@
|
||||||
#' \url{https://dx.doi.org/10.1084/jem.57.4.571}
|
#' \url{https://dx.doi.org/10.1084/jem.57.4.571}
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>% pull left_join
|
#' @importFrom dplyr %>% pull left_join
|
||||||
#' @return Character (vector) with class \code{"bactid"}. Unknown values will return \code{NA}.
|
#' @return Character (vector) with class \code{"mo"}. Unknown values will return \code{NA}.
|
||||||
#' @seealso \code{\link{microorganisms}} for the dataframe that is being used to determine ID's.
|
#' @seealso \code{\link{microorganisms}} for the dataframe that is being used to determine ID's.
|
||||||
#' @examples
|
#' @examples
|
||||||
#' # These examples all return "STAAUR", the ID of S. aureus:
|
#' # These examples all return "STAAUR", the ID of S. aureus:
|
||||||
#' as.bactid("stau")
|
#' as.mo("stau")
|
||||||
#' as.bactid("STAU")
|
#' as.mo("STAU")
|
||||||
#' as.bactid("staaur")
|
#' as.mo("staaur")
|
||||||
#' as.bactid("S. aureus")
|
#' as.mo("S. aureus")
|
||||||
#' as.bactid("S aureus")
|
#' as.mo("S aureus")
|
||||||
#' as.bactid("Staphylococcus aureus")
|
#' as.mo("Staphylococcus aureus")
|
||||||
#' as.bactid("MRSA") # Methicillin Resistant S. aureus
|
#' as.mo("MRSA") # Methicillin Resistant S. aureus
|
||||||
#' as.bactid("VISA") # Vancomycin Intermediate S. aureus
|
#' as.mo("VISA") # Vancomycin Intermediate S. aureus
|
||||||
#' as.bactid("VRSA") # Vancomycin Resistant S. aureus
|
#' as.mo("VRSA") # Vancomycin Resistant S. aureus
|
||||||
#'
|
#'
|
||||||
#' # guess_bactid is an alias of as.bactid and works the same
|
#' # guess_mo is an alias of as.mo and works the same
|
||||||
#' guess_bactid("S. epidermidis") # will remain species: STAEPI
|
#' guess_mo("S. epidermidis") # will remain species: STAEPI
|
||||||
#' guess_bactid("S. epidermidis", Becker = TRUE) # will not remain species: STACNS
|
#' guess_mo("S. epidermidis", Becker = TRUE) # will not remain species: STACNS
|
||||||
#'
|
#'
|
||||||
#' guess_bactid("S. pyogenes") # will remain species: STCAGA
|
#' guess_mo("S. pyogenes") # will remain species: STCAGA
|
||||||
#' guess_bactid("S. pyogenes", Lancefield = TRUE) # will not remain species: STCGRA
|
#' guess_mo("S. pyogenes", Lancefield = TRUE) # will not remain species: STCGRA
|
||||||
#'
|
#'
|
||||||
#' # Use mo_* functions to get a specific property based on a bactid
|
#' # Use mo_* functions to get a specific property based on `mo`
|
||||||
#' Ecoli <- as.bactid("E. coli") # returns `ESCCOL`
|
#' Ecoli <- as.mo("E. coli") # returns `ESCCOL`
|
||||||
#' mo_genus(Ecoli) # returns "Escherichia"
|
#' mo_genus(Ecoli) # returns "Escherichia"
|
||||||
#' mo_gramstain(Ecoli) # returns "Negative rods"
|
#' mo_gramstain(Ecoli) # returns "Negative rods"
|
||||||
#'
|
#'
|
||||||
#' \dontrun{
|
#' \dontrun{
|
||||||
#' df$bactid <- as.bactid(df$microorganism_name)
|
#' df$mo <- as.mo(df$microorganism_name)
|
||||||
#'
|
#'
|
||||||
#' # the select function of tidyverse is also supported:
|
#' # the select function of tidyverse is also supported:
|
||||||
#' library(dplyr)
|
#' library(dplyr)
|
||||||
#' df$bactid <- df %>%
|
#' df$mo <- df %>%
|
||||||
#' select(microorganism_name) %>%
|
#' select(microorganism_name) %>%
|
||||||
#' guess_bactid()
|
#' guess_mo()
|
||||||
#'
|
#'
|
||||||
#' # and can even contain 2 columns, which is convenient for genus/species combinations:
|
#' # and can even contain 2 columns, which is convenient for genus/species combinations:
|
||||||
#' df$bactid <- df %>%
|
#' df$mo <- df %>%
|
||||||
#' select(genus, species) %>%
|
#' select(genus, species) %>%
|
||||||
#' guess_bactid()
|
#' guess_mo()
|
||||||
#'
|
#'
|
||||||
#' # same result:
|
#' # same result:
|
||||||
#' df <- df %>%
|
#' df <- df %>%
|
||||||
#' mutate(bactid = guess_bactid(paste(genus, species)))
|
#' mutate(mo = guess_mo(paste(genus, species)))
|
||||||
#' }
|
#' }
|
||||||
as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
|
|
||||||
|
|
||||||
if (NCOL(x) == 2) {
|
if (NCOL(x) == 2) {
|
||||||
|
@ -111,7 +111,7 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MOs <- AMR::microorganisms %>% filter(!bactid %like% '^_FAM') # dont search in those
|
MOs <- AMR::microorganisms %>% filter(!mo %like% '^_FAM') # dont search in those
|
||||||
failures <- character(0)
|
failures <- character(0)
|
||||||
x_input <- x
|
x_input <- x
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
for (i in 1:length(x)) {
|
for (i in 1:length(x)) {
|
||||||
|
|
||||||
if (Becker == TRUE | Becker == "all") {
|
if (Becker == TRUE | Becker == "all") {
|
||||||
mo <- suppressWarnings(guess_bactid(x_backup[i]))
|
mo <- suppressWarnings(guess_mo(x_backup[i]))
|
||||||
if (mo %like% '^STA') {
|
if (mo %like% '^STA') {
|
||||||
# See Source. It's this figure:
|
# See Source. It's this figure:
|
||||||
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4187637/figure/F3/
|
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4187637/figure/F3/
|
||||||
|
@ -167,7 +167,7 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Lancefield == TRUE) {
|
if (Lancefield == TRUE) {
|
||||||
mo <- suppressWarnings(guess_bactid(x_backup[i]))
|
mo <- suppressWarnings(guess_mo(x_backup[i]))
|
||||||
if (mo %like% '^STC') {
|
if (mo %like% '^STC') {
|
||||||
# See Source
|
# See Source
|
||||||
species <- left_join_microorganisms(mo)$species
|
species <- left_join_microorganisms(mo)$species
|
||||||
|
@ -205,13 +205,13 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
failures <- c(failures, x_backup[i])
|
failures <- c(failures, x_backup[i])
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
if (x_backup[i] %in% AMR::microorganisms$bactid) {
|
if (x_backup[i] %in% AMR::microorganisms$mo) {
|
||||||
# is already a valid bactid
|
# is already a valid mo
|
||||||
x[i] <- x_backup[i]
|
x[i] <- x_backup[i]
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
if (x_trimmed[i] %in% AMR::microorganisms$bactid) {
|
if (x_trimmed[i] %in% AMR::microorganisms$mo) {
|
||||||
# is already a valid bactid
|
# is already a valid mo
|
||||||
x[i] <- x_trimmed[i]
|
x[i] <- x_trimmed[i]
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
@ -275,14 +275,14 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# try any match keeping spaces
|
# try any match keeping spaces
|
||||||
found <- MOs[which(MOs$fullname %like% x_withspaces[i]),]$bactid
|
found <- MOs[which(MOs$fullname %like% x_withspaces[i]),]$mo
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
x[i] <- found[1L]
|
x[i] <- found[1L]
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
# try any match diregarding spaces
|
# try any match diregarding spaces
|
||||||
found <- MOs[which(MOs$fullname %like% x[i]),]$bactid
|
found <- MOs[which(MOs$fullname %like% x[i]),]$mo
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
x[i] <- found[1L]
|
x[i] <- found[1L]
|
||||||
next
|
next
|
||||||
|
@ -290,21 +290,21 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
|
|
||||||
# try exact match of only genus, with 'species' attached
|
# try exact match of only genus, with 'species' attached
|
||||||
# (this prevents Streptococcus from becoming Peptostreptococcus, since "p" < "s")
|
# (this prevents Streptococcus from becoming Peptostreptococcus, since "p" < "s")
|
||||||
found <- MOs[which(MOs$fullname == x_species[i]),]$bactid
|
found <- MOs[which(MOs$fullname == x_species[i]),]$mo
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
x[i] <- found[1L]
|
x[i] <- found[1L]
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
# try any match of only genus, with 'species' attached
|
# try any match of only genus, with 'species' attached
|
||||||
found <- MOs[which(MOs$fullname %like% x_species[i]),]$bactid
|
found <- MOs[which(MOs$fullname %like% x_species[i]),]$mo
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
x[i] <- found[1L]
|
x[i] <- found[1L]
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
# search for GLIMS code
|
# search for GLIMS code
|
||||||
found <- AMR::microorganisms.umcg[which(toupper(AMR::microorganisms.umcg$mocode) == toupper(x_trimmed[i])),]$bactid
|
found <- AMR::microorganisms.umcg[which(toupper(AMR::microorganisms.umcg$umcg) == toupper(x_trimmed[i])),]$mo
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
x[i] <- found[1L]
|
x[i] <- found[1L]
|
||||||
next
|
next
|
||||||
|
@ -317,7 +317,7 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
x_split[i] <- paste0(x_trimmed[i] %>% substr(1, x_length / 2) %>% trimws(),
|
x_split[i] <- paste0(x_trimmed[i] %>% substr(1, x_length / 2) %>% trimws(),
|
||||||
'.* ',
|
'.* ',
|
||||||
x_trimmed[i] %>% substr((x_length / 2) + 1, x_length) %>% trimws())
|
x_trimmed[i] %>% substr((x_length / 2) + 1, x_length) %>% trimws())
|
||||||
found <- MOs[which(MOs$fullname %like% paste0('^', x_split[i])),]$bactid
|
found <- MOs[which(MOs$fullname %like% paste0('^', x_split[i])),]$mo
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
x[i] <- found[1L]
|
x[i] <- found[1L]
|
||||||
next
|
next
|
||||||
|
@ -331,7 +331,7 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
x_trimmed[i] <- trimws(x_trimmed[i], which = "both")
|
x_trimmed[i] <- trimws(x_trimmed[i], which = "both")
|
||||||
}
|
}
|
||||||
if (!is.na(x_trimmed[i])) {
|
if (!is.na(x_trimmed[i])) {
|
||||||
found <- MOs[which(MOs$fullname %like% x_trimmed[i]),]$bactid
|
found <- MOs[which(MOs$fullname %like% x_trimmed[i]),]$mo
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
x[i] <- found[1L]
|
x[i] <- found[1L]
|
||||||
next
|
next
|
||||||
|
@ -346,7 +346,7 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
|
|
||||||
failures <- failures[!failures %in% c(NA, NULL, NaN)]
|
failures <- failures[!failures %in% c(NA, NULL, NaN)]
|
||||||
if (length(failures) > 0) {
|
if (length(failures) > 0) {
|
||||||
warning("These values could not be coerced to a valid bactid: ",
|
warning("These values could not be coerced to a valid mo: ",
|
||||||
paste('"', unique(failures), '"', sep = "", collapse = ', '),
|
paste('"', unique(failures), '"', sep = "", collapse = ', '),
|
||||||
".",
|
".",
|
||||||
call. = FALSE)
|
call. = FALSE)
|
||||||
|
@ -364,19 +364,51 @@ as.bactid <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
||||||
by = "input") %>%
|
by = "input") %>%
|
||||||
pull(found)
|
pull(found)
|
||||||
|
|
||||||
class(x) <- "bactid"
|
class(x) <- "mo"
|
||||||
attr(x, 'package') <- 'AMR'
|
attr(x, 'package') <- 'AMR'
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname as.bactid
|
#' @rdname as.mo
|
||||||
#' @export
|
#' @export
|
||||||
guess_bactid <- as.bactid
|
is.mo <- function(x) {
|
||||||
|
# bactid for older releases
|
||||||
|
# remove when is.bactid will be removed
|
||||||
|
identical(class(x), "mo") | identical(class(x), "bactid")
|
||||||
|
}
|
||||||
|
|
||||||
#' @rdname as.bactid
|
#' @rdname as.mo
|
||||||
#' @export
|
#' @export
|
||||||
is.bactid <- function(x) {
|
guess_mo <- as.mo
|
||||||
identical(class(x), "bactid")
|
|
||||||
|
#' @exportMethod print.mo
|
||||||
|
#' @export
|
||||||
|
#' @noRd
|
||||||
|
print.mo <- function(x, ...) {
|
||||||
|
cat("Class 'mo'\n")
|
||||||
|
print.default(as.character(x), quote = FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @exportMethod as.data.frame.mo
|
||||||
|
#' @export
|
||||||
|
#' @noRd
|
||||||
|
as.data.frame.mo <- function (x, ...) {
|
||||||
|
# same as as.data.frame.character but with removed stringsAsFactors
|
||||||
|
nm <- paste(deparse(substitute(x), width.cutoff = 500L),
|
||||||
|
collapse = " ")
|
||||||
|
if (!"nm" %in% names(list(...))) {
|
||||||
|
as.data.frame.vector(x, ..., nm = nm)
|
||||||
|
} else {
|
||||||
|
as.data.frame.vector(x, ...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @exportMethod pull.mo
|
||||||
|
#' @export
|
||||||
|
#' @importFrom dplyr pull
|
||||||
|
#' @noRd
|
||||||
|
pull.mo <- function(.data, ...) {
|
||||||
|
pull(as.data.frame(.data), ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @exportMethod print.bactid
|
#' @exportMethod print.bactid
|
|
@ -18,9 +18,9 @@
|
||||||
|
|
||||||
#' Property of a microorganism
|
#' Property of a microorganism
|
||||||
#'
|
#'
|
||||||
#' Use these functions to return a specific property of a microorganism from the \code{\link{microorganisms}} data set, based on their \code{bactid}. Get such an ID with \code{\link{as.bactid}}.
|
#' Use these functions to return a specific property of a microorganism from the \code{\link{microorganisms}} data set, based on their \code{mo}. Get such an ID with \code{\link{as.mo}}.
|
||||||
#' @param x a (vector of a) valid \code{\link{bactid}} or any text that can be coerced to a valid bactid with \code{\link{as.bactid}}
|
#' @param x a (vector of a) valid \code{\link{mo}} or any text that can be coerced to a valid microorganism code with \code{\link{as.mo}}
|
||||||
#' @param property one of the column names of one of the \code{\link{microorganisms}} data set, like \code{"bactid"}, \code{"bactsys"}, \code{"family"}, \code{"genus"}, \code{"species"}, \code{"fullname"}, \code{"gramstain"} and \code{"aerobic"}
|
#' @param property one of the column names of one of the \code{\link{microorganisms}} data set, like \code{"mo"}, \code{"bactsys"}, \code{"family"}, \code{"genus"}, \code{"species"}, \code{"fullname"}, \code{"gramstain"} and \code{"aerobic"}
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>% left_join pull
|
#' @importFrom dplyr %>% left_join pull
|
||||||
|
@ -68,12 +68,12 @@ mo_property <- function(x, property = 'fullname') {
|
||||||
if (!property %in% colnames(microorganisms)) {
|
if (!property %in% colnames(microorganisms)) {
|
||||||
stop("invalid property: ", property, " - use a column name of `microorganisms`")
|
stop("invalid property: ", property, " - use a column name of `microorganisms`")
|
||||||
}
|
}
|
||||||
if (!is.bactid(x)) {
|
if (!is.mo(x)) {
|
||||||
x <- as.bactid(x) # this will give a warning if x cannot be coerced
|
x <- as.mo(x) # this will give a warning if x cannot be coerced
|
||||||
}
|
}
|
||||||
suppressWarnings(
|
suppressWarnings(
|
||||||
data.frame(bactid = x, stringsAsFactors = FALSE) %>%
|
data.frame(mo = x, stringsAsFactors = FALSE) %>%
|
||||||
left_join(AMR::microorganisms, by = "bactid") %>%
|
left_join(AMR::microorganisms, by = "mo") %>%
|
||||||
pull(property)
|
pull(property)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,13 +65,13 @@
|
||||||
#' library(dplyr)
|
#' library(dplyr)
|
||||||
#' septic_patients %>%
|
#' septic_patients %>%
|
||||||
#' # get bacteria properties like genus and species
|
#' # get bacteria properties like genus and species
|
||||||
#' left_join_microorganisms("bactid") %>%
|
#' left_join_microorganisms("mo") %>%
|
||||||
#' # calculate first isolates
|
#' # calculate first isolates
|
||||||
#' mutate(first_isolate =
|
#' mutate(first_isolate =
|
||||||
#' first_isolate(.,
|
#' first_isolate(.,
|
||||||
#' "date",
|
#' "date",
|
||||||
#' "patient_id",
|
#' "patient_id",
|
||||||
#' "bactid",
|
#' "mo",
|
||||||
#' col_specimen = NA,
|
#' col_specimen = NA,
|
||||||
#' col_icu = NA)) %>%
|
#' col_icu = NA)) %>%
|
||||||
#' # filter on first E. coli isolates
|
#' # filter on first E. coli isolates
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
#' if (!require(ggplot2)) {
|
#' if (!require(ggplot2)) {
|
||||||
#'
|
#'
|
||||||
#' data <- septic_patients %>%
|
#' data <- septic_patients %>%
|
||||||
#' filter(bactid == "ESCCOL") %>%
|
#' filter(mo == "ESCCOL") %>%
|
||||||
#' resistance_predict(col_ab = "amox",
|
#' resistance_predict(col_ab = "amox",
|
||||||
#' col_date = "date",
|
#' col_date = "date",
|
||||||
#' info = FALSE,
|
#' info = FALSE,
|
||||||
|
|
34
README.md
34
README.md
|
@ -44,7 +44,7 @@ This `AMR` package basically does four important things:
|
||||||
|
|
||||||
1. It **cleanses existing data**, by transforming it to reproducible and profound *classes*, making the most efficient use of R. These functions all use artificial intelligence to guess results that you would expect:
|
1. It **cleanses existing data**, by transforming it to reproducible and profound *classes*, making the most efficient use of R. These functions all use artificial intelligence to guess results that you would expect:
|
||||||
|
|
||||||
* Use `as.bactid` to get an ID of a microorganism. The IDs are quite obvious - the ID of *E. coli* is "ESCCOL" and the ID of *S. aureus* is "STAAUR". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" and "esccol". Even `as.bactid("MRSA")` will return the ID of *S. aureus*. Moreover, it can group all coagulase negative and positive *Staphylococci*, and can transform *Streptococci* into Lancefield groups. To find bacteria based on your input, this package contains a freely available database of ~2,650 different (potential) human pathogenic microorganisms.
|
* Use `as.mo` to get an ID of a microorganism. The IDs are quite obvious - the ID of *E. coli* is "ESCCOL" and the ID of *S. aureus* is "STAAUR". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" and "esccol". Even `as.mo("MRSA")` will return the ID of *S. aureus*. Moreover, it can group all coagulase negative and positive *Staphylococci*, and can transform *Streptococci* into Lancefield groups. To find bacteria based on your input, this package contains a freely available database of ~2,650 different (potential) human pathogenic microorganisms.
|
||||||
* Use `as.rsi` to transform values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like "<=0.002; S" (combined MIC/RSI) will result in "S".
|
* Use `as.rsi` to transform values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like "<=0.002; S" (combined MIC/RSI) will result in "S".
|
||||||
* Use `as.mic` to cleanse your MIC values. It produces a so-called factor (called *ordinal* in SPSS) with valid MIC values as levels. A value like "<=0.002; S" (combined MIC/RSI) will result in "<=0.002".
|
* Use `as.mic` to cleanse your MIC values. It produces a so-called factor (called *ordinal* in SPSS) with valid MIC values as levels. A value like "<=0.002; S" (combined MIC/RSI) will result in "<=0.002".
|
||||||
* Use `as.atc` to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values "Furabid", "Furadantin", "nitro" all return the ATC code of Nitrofurantoine.
|
* Use `as.atc` to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values "Furabid", "Furadantin", "nitro" all return the ATC code of Nitrofurantoine.
|
||||||
|
@ -55,8 +55,8 @@ This `AMR` package basically does four important things:
|
||||||
* Use `first_isolate` to identify the first isolates of every patient [using guidelines from the CLSI](https://clsi.org/standards/products/microbiology/documents/m39/) (Clinical and Laboratory Standards Institute).
|
* Use `first_isolate` to identify the first isolates of every patient [using guidelines from the CLSI](https://clsi.org/standards/products/microbiology/documents/m39/) (Clinical and Laboratory Standards Institute).
|
||||||
* You can also identify first *weighted* isolates of every patient, an adjusted version of the CLSI guideline. This takes into account key antibiotics of every strain and compares them.
|
* You can also identify first *weighted* isolates of every patient, an adjusted version of the CLSI guideline. This takes into account key antibiotics of every strain and compares them.
|
||||||
* Use `MDRO` (abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported.
|
* Use `MDRO` (abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported.
|
||||||
* The data set `microorganisms` contains the family, genus, species, subspecies, colloquial name and Gram stain of almost 2,650 microorganisms (2,207 bacteria, 285 fungi/yeasts, 153 parasites, 1 other). This enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus`, `mo_family` or `mo_gramstain`. Since it uses `as.bactid` internally, AI is supported. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. These functions can be used to add new variables to your data.
|
* The data set `microorganisms` contains the family, genus, species, subspecies, colloquial name and Gram stain of almost 2,650 microorganisms (2,207 bacteria, 285 fungi/yeasts, 153 parasites, 1 other). This enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus`, `mo_family` or `mo_gramstain`. Since it uses `as.mo` internally, AI is supported. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. These functions can be used to add new variables to your data.
|
||||||
* The data set `antibiotics` contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like `ab_official` and `ab_tradenames` to look up values. As the `mo_*` functions use `as.bactid` internally, the `ab_*` functions use `as.atc` internally so it uses AI to guess your expected result. For example, `ab_official("Fluclox")`, `ab_official("Floxapen")` and `ab_official("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data.
|
* The data set `antibiotics` contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like `ab_official` and `ab_tradenames` to look up values. As the `mo_*` functions use `as.mo` internally, the `ab_*` functions use `as.atc` internally so it uses AI to guess your expected result. For example, `ab_official("Fluclox")`, `ab_official("Floxapen")` and `ab_official("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data.
|
||||||
|
|
||||||
3. It **analyses the data** with convenient functions that use well-known methods.
|
3. It **analyses the data** with convenient functions that use well-known methods.
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ plot(mic_data)
|
||||||
### Overwrite/force resistance based on EUCAST rules
|
### Overwrite/force resistance based on EUCAST rules
|
||||||
This is also called *interpretive reading*.
|
This is also called *interpretive reading*.
|
||||||
```r
|
```r
|
||||||
before <- data.frame(bactid = c("STAAUR", # Staphylococcus aureus
|
before <- data.frame(bact = c("STAAUR", # Staphylococcus aureus
|
||||||
"ENCFAE", # Enterococcus faecalis
|
"ENCFAE", # Enterococcus faecalis
|
||||||
"ESCCOL", # Escherichia coli
|
"ESCCOL", # Escherichia coli
|
||||||
"KLEPNE", # Klebsiella pneumoniae
|
"KLEPNE", # Klebsiella pneumoniae
|
||||||
|
@ -216,7 +216,7 @@ before <- data.frame(bactid = c("STAAUR", # Staphylococcus aureus
|
||||||
cfur = "-", # Cefuroxime
|
cfur = "-", # Cefuroxime
|
||||||
stringsAsFactors = FALSE)
|
stringsAsFactors = FALSE)
|
||||||
before
|
before
|
||||||
# bactid vanc amox coli cfta cfur
|
# bact vanc amox coli cfta cfur
|
||||||
# 1 STAAUR - - - - -
|
# 1 STAAUR - - - - -
|
||||||
# 2 ENCFAE - - - - -
|
# 2 ENCFAE - - - - -
|
||||||
# 3 ESCCOL - - - - -
|
# 3 ESCCOL - - - - -
|
||||||
|
@ -224,9 +224,9 @@ before
|
||||||
# 5 PSEAER - - - - -
|
# 5 PSEAER - - - - -
|
||||||
|
|
||||||
# Now apply those rules; just need a column with bacteria IDs and antibiotic results:
|
# Now apply those rules; just need a column with bacteria IDs and antibiotic results:
|
||||||
after <- EUCAST_rules(before)
|
after <- EUCAST_rules(before, col_mo = "bact")
|
||||||
after
|
after
|
||||||
# bactid vanc amox coli cfta cfur
|
# bact vanc amox coli cfta cfur
|
||||||
# 1 STAAUR - - R R -
|
# 1 STAAUR - - R R -
|
||||||
# 2 ENCFAE - - R R R
|
# 2 ENCFAE - - R R R
|
||||||
# 3 ESCCOL R - - - -
|
# 3 ESCCOL R - - - -
|
||||||
|
@ -234,17 +234,17 @@ after
|
||||||
# 5 PSEAER R R - - R
|
# 5 PSEAER R R - - R
|
||||||
```
|
```
|
||||||
|
|
||||||
Bacteria IDs can be retrieved with the `guess_bactid` function. It uses any type of info about a microorganism as input. For example, all these will return value `STAAUR`, the ID of *S. aureus*:
|
Bacteria IDs can be retrieved with the `guess_mo` function. It uses any type of info about a microorganism as input. For example, all these will return value `STAAUR`, the ID of *S. aureus*:
|
||||||
```r
|
```r
|
||||||
guess_bactid("stau")
|
guess_mo("stau")
|
||||||
guess_bactid("STAU")
|
guess_mo("STAU")
|
||||||
guess_bactid("staaur")
|
guess_mo("staaur")
|
||||||
guess_bactid("S. aureus")
|
guess_mo("S. aureus")
|
||||||
guess_bactid("S aureus")
|
guess_mo("S aureus")
|
||||||
guess_bactid("Staphylococcus aureus")
|
guess_mo("Staphylococcus aureus")
|
||||||
guess_bactid("MRSA") # Methicillin Resistant S. aureus
|
guess_mo("MRSA") # Methicillin Resistant S. aureus
|
||||||
guess_bactid("VISA") # Vancomycin Intermediate S. aureus
|
guess_mo("VISA") # Vancomycin Intermediate S. aureus
|
||||||
guess_bactid("VRSA") # Vancomycin Resistant S. aureus
|
guess_mo("VRSA") # Vancomycin Resistant S. aureus
|
||||||
```
|
```
|
||||||
|
|
||||||
### Other (microbial) epidemiological functions
|
### Other (microbial) epidemiological functions
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,22 @@
|
||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/deprecated.R
|
||||||
|
\name{AMR-deprecated}
|
||||||
|
\alias{AMR-deprecated}
|
||||||
|
\alias{as.bactid}
|
||||||
|
\alias{is.bactid}
|
||||||
|
\alias{guess_bactid}
|
||||||
|
\alias{ratio}
|
||||||
|
\title{Deprecated functions}
|
||||||
|
\usage{
|
||||||
|
as.bactid(...)
|
||||||
|
|
||||||
|
is.bactid(...)
|
||||||
|
|
||||||
|
guess_bactid(...)
|
||||||
|
|
||||||
|
ratio(x, ratio)
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
These functions are \link{Deprecated}. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by.
|
||||||
|
}
|
||||||
|
\keyword{internal}
|
|
@ -13,7 +13,7 @@ EUCAST Expert Rules Version 2.0: \cr
|
||||||
\url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}
|
\url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
EUCAST_rules(tbl, col_bactid = "bactid", info = TRUE, amcl = "amcl",
|
EUCAST_rules(tbl, col_mo = "mo", info = TRUE, amcl = "amcl",
|
||||||
amik = "amik", amox = "amox", ampi = "ampi", azit = "azit",
|
amik = "amik", amox = "amox", ampi = "ampi", azit = "azit",
|
||||||
azlo = "azlo", aztr = "aztr", cefa = "cefa", cfep = "cfep",
|
azlo = "azlo", aztr = "aztr", cefa = "cefa", cfep = "cfep",
|
||||||
cfot = "cfot", cfox = "cfox", cfra = "cfra", cfta = "cfta",
|
cfot = "cfot", cfox = "cfox", cfra = "cfra", cfta = "cfta",
|
||||||
|
@ -28,18 +28,21 @@ EUCAST_rules(tbl, col_bactid = "bactid", info = TRUE, amcl = "amcl",
|
||||||
peni = "peni", pita = "pita", poly = "poly", pris = "pris",
|
peni = "peni", pita = "pita", poly = "poly", pris = "pris",
|
||||||
qida = "qida", rifa = "rifa", roxi = "roxi", siso = "siso",
|
qida = "qida", rifa = "rifa", roxi = "roxi", siso = "siso",
|
||||||
teic = "teic", tetr = "tetr", tica = "tica", tige = "tige",
|
teic = "teic", tetr = "tetr", tica = "tica", tige = "tige",
|
||||||
tobr = "tobr", trim = "trim", trsu = "trsu", vanc = "vanc")
|
tobr = "tobr", trim = "trim", trsu = "trsu", vanc = "vanc",
|
||||||
|
col_bactid = "bactid")
|
||||||
|
|
||||||
interpretive_reading(...)
|
interpretive_reading(...)
|
||||||
}
|
}
|
||||||
\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{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_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}}}
|
||||||
|
|
||||||
\item{info}{print progress}
|
\item{info}{print progress}
|
||||||
|
|
||||||
\item{amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, peni, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column names of antibiotics. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
\item{amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, peni, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{col_bactid}{Deprecated. Use \code{col_mo} instead.}
|
||||||
|
|
||||||
\item{...}{parameters that are passed on to \code{EUCAST_rules}}
|
\item{...}{parameters that are passed on to \code{EUCAST_rules}}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +52,7 @@ table with edited variables of antibiotics.
|
||||||
\description{
|
\description{
|
||||||
Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
|
Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
|
||||||
}
|
}
|
||||||
\section{Abbrevations of antibiotics}{
|
\section{Antibiotics}{
|
||||||
|
|
||||||
Abbrevations of the column containing antibiotics:
|
Abbrevations of the column containing antibiotics:
|
||||||
|
|
||||||
|
@ -118,16 +121,16 @@ Abbrevations of the column containing antibiotics:
|
||||||
|
|
||||||
\examples{
|
\examples{
|
||||||
a <- EUCAST_rules(septic_patients)
|
a <- EUCAST_rules(septic_patients)
|
||||||
a <- data.frame(bactid = c("STAAUR", # Staphylococcus aureus
|
a <- data.frame(mo = c("STAAUR", # Staphylococcus aureus
|
||||||
"ENCFAE", # Enterococcus faecalis
|
"ENCFAE", # Enterococcus faecalis
|
||||||
"ESCCOL", # Escherichia coli
|
"ESCCOL", # Escherichia coli
|
||||||
"KLEPNE", # Klebsiella pneumoniae
|
"KLEPNE", # Klebsiella pneumoniae
|
||||||
"PSEAER"), # Pseudomonas aeruginosa
|
"PSEAER"), # Pseudomonas aeruginosa
|
||||||
vanc = "-", # Vancomycin
|
vanc = "-", # Vancomycin
|
||||||
amox = "-", # Amoxicillin
|
amox = "-", # Amoxicillin
|
||||||
coli = "-", # Colistin
|
coli = "-", # Colistin
|
||||||
cfta = "-", # Ceftazidime
|
cfta = "-", # Ceftazidime
|
||||||
cfur = "-", # Cefuroxime
|
cfur = "-", # Cefuroxime
|
||||||
stringsAsFactors = FALSE)
|
stringsAsFactors = FALSE)
|
||||||
a
|
a
|
||||||
|
|
||||||
|
|
196
man/MDRO.Rd
196
man/MDRO.Rd
|
@ -7,7 +7,7 @@
|
||||||
\alias{EUCAST_exceptional_phenotypes}
|
\alias{EUCAST_exceptional_phenotypes}
|
||||||
\title{Determine multidrug-resistant organisms (MDRO)}
|
\title{Determine multidrug-resistant organisms (MDRO)}
|
||||||
\usage{
|
\usage{
|
||||||
MDRO(tbl, country = NULL, col_bactid = "bactid", info = TRUE,
|
MDRO(tbl, country = NULL, col_mo = "mo", info = TRUE,
|
||||||
amcl = "amcl", amik = "amik", amox = "amox", ampi = "ampi",
|
amcl = "amcl", amik = "amik", amox = "amox", ampi = "ampi",
|
||||||
azit = "azit", aztr = "aztr", cefa = "cefa", cfra = "cfra",
|
azit = "azit", aztr = "aztr", cefa = "cefa", cfra = "cfra",
|
||||||
cfep = "cfep", cfot = "cfot", cfox = "cfox", cfta = "cfta",
|
cfep = "cfep", cfot = "cfot", cfox = "cfox", cfta = "cfta",
|
||||||
|
@ -22,7 +22,8 @@ MDRO(tbl, country = NULL, col_bactid = "bactid", info = TRUE,
|
||||||
peni = "peni", pita = "pita", poly = "poly", qida = "qida",
|
peni = "peni", pita = "pita", poly = "poly", qida = "qida",
|
||||||
rifa = "rifa", roxi = "roxi", siso = "siso", teic = "teic",
|
rifa = "rifa", roxi = "roxi", siso = "siso", teic = "teic",
|
||||||
tetr = "tetr", tica = "tica", tige = "tige", tobr = "tobr",
|
tetr = "tetr", tica = "tica", tige = "tige", tobr = "tobr",
|
||||||
trim = "trim", trsu = "trsu", vanc = "vanc")
|
trim = "trim", trsu = "trsu", vanc = "vanc",
|
||||||
|
col_bactid = "bactid")
|
||||||
|
|
||||||
BRMO(tbl, country = "nl", ...)
|
BRMO(tbl, country = "nl", ...)
|
||||||
|
|
||||||
|
@ -35,11 +36,129 @@ EUCAST_exceptional_phenotypes(tbl, country = "EUCAST", ...)
|
||||||
|
|
||||||
\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{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_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}}}
|
||||||
|
|
||||||
\item{info}{print progress}
|
\item{info}{print progress}
|
||||||
|
|
||||||
\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{amcl}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{amik}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{amox}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{ampi}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{azit}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{aztr}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cefa}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cfra}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cfep}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cfot}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cfox}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cfta}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cftr}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cfur}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{chlo}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{cipr}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{clar}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{clin}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{clox}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{coli}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{czol}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{dapt}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{doxy}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{erta}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{eryt}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{fosf}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{fusi}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{gent}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{imip}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{kana}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{levo}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{linc}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{line}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{mero}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{metr}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{mino}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{moxi}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{nali}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{neom}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{neti}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{nitr}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{novo}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{norf}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{oflo}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{peni}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{pita}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{poly}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{qida}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{rifa}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{roxi}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{siso}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{teic}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{tetr}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{tica}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{tige}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{tobr}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{trim}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{trsu}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{vanc}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
|
||||||
|
|
||||||
|
\item{col_bactid}{Deprecated. Use \code{col_mo} instead.}
|
||||||
|
|
||||||
\item{...}{parameters that are passed on to methods}
|
\item{...}{parameters that are passed on to methods}
|
||||||
}
|
}
|
||||||
|
@ -52,10 +171,77 @@ Determine which isolates are multidrug-resistant organisms (MDRO) according to c
|
||||||
\details{
|
\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}).
|
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}).
|
||||||
}
|
}
|
||||||
|
\section{Antibiotics}{
|
||||||
|
|
||||||
|
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}).
|
||||||
|
}
|
||||||
|
|
||||||
\examples{
|
\examples{
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
|
|
||||||
septic_patients \%>\%
|
septic_patients \%>\%
|
||||||
mutate(EUCAST = MDRO(.),
|
mutate(EUCAST = MDRO(.),
|
||||||
BRMO = MDRO(., "nl"))
|
BRMO = BRMO(.))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
% Generated by roxygen2: do not edit by hand
|
% Generated by roxygen2: do not edit by hand
|
||||||
% Please edit documentation in R/bactid.R
|
% Please edit documentation in R/mo.R
|
||||||
\name{as.bactid}
|
\name{as.mo}
|
||||||
\alias{as.bactid}
|
\alias{as.mo}
|
||||||
\alias{bactid}
|
\alias{mo}
|
||||||
\alias{guess_bactid}
|
\alias{is.mo}
|
||||||
\alias{is.bactid}
|
\alias{guess_mo}
|
||||||
\title{Transform to bacteria ID}
|
\title{Transform to microorganism ID}
|
||||||
\source{
|
\source{
|
||||||
[1] Becker K \emph{et al.} \strong{Coagulase-Negative Staphylococci}. 2014. Clin Microbiol Rev. 27(4): 870–926. \cr
|
[1] Becker K \emph{et al.} \strong{Coagulase-Negative Staphylococci}. 2014. Clin Microbiol Rev. 27(4): 870–926. \cr
|
||||||
\url{https://dx.doi.org/10.1128/CMR.00109-13} \cr
|
\url{https://dx.doi.org/10.1128/CMR.00109-13} \cr
|
||||||
|
@ -13,11 +13,11 @@
|
||||||
\url{https://dx.doi.org/10.1084/jem.57.4.571}
|
\url{https://dx.doi.org/10.1084/jem.57.4.571}
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
as.bactid(x, Becker = FALSE, Lancefield = FALSE)
|
as.mo(x, Becker = FALSE, Lancefield = FALSE)
|
||||||
|
|
||||||
guess_bactid(x, Becker = FALSE, Lancefield = FALSE)
|
is.mo(x)
|
||||||
|
|
||||||
is.bactid(x)
|
guess_mo(x, Becker = FALSE, Lancefield = FALSE)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{x}{a character vector or a dataframe with one or two columns}
|
\item{x}{a character vector or a dataframe with one or two columns}
|
||||||
|
@ -27,15 +27,15 @@ is.bactid(x)
|
||||||
\item{Lancefield}{a logical to indicate whether beta-haemolytic \emph{Streptococci} should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield [2]. These \emph{Streptococci} will be categorised in their first group, i.e. \emph{Streptococcus dysgalactiae} will be group C, although officially it was also categorised into groups G and L. Groups D and E will be ignored, since they are \emph{Enterococci}.}
|
\item{Lancefield}{a logical to indicate whether beta-haemolytic \emph{Streptococci} should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield [2]. These \emph{Streptococci} will be categorised in their first group, i.e. \emph{Streptococcus dysgalactiae} will be group C, although officially it was also categorised into groups G and L. Groups D and E will be ignored, since they are \emph{Enterococci}.}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
Character (vector) with class \code{"bactid"}. Unknown values will return \code{NA}.
|
Character (vector) with class \code{"mo"}. Unknown values will return \code{NA}.
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
||||||
}
|
}
|
||||||
\details{
|
\details{
|
||||||
\code{guess_bactid} is an alias of \code{as.bactid}.
|
\code{guess_mo} is an alias of \code{as.mo}.
|
||||||
|
|
||||||
Use the \code{\link{mo_property}} functions to get properties based on the returned bactid, see Examples.
|
Use the \code{\link{mo_property}} functions to get properties based on the returned mo, see Examples.
|
||||||
|
|
||||||
Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. These are:
|
Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. These are:
|
||||||
\itemize{
|
\itemize{
|
||||||
|
@ -49,45 +49,45 @@ For example, \code{"Gram negative rods"} and \code{"GNR"} will both return the I
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
# These examples all return "STAAUR", the ID of S. aureus:
|
# These examples all return "STAAUR", the ID of S. aureus:
|
||||||
as.bactid("stau")
|
as.mo("stau")
|
||||||
as.bactid("STAU")
|
as.mo("STAU")
|
||||||
as.bactid("staaur")
|
as.mo("staaur")
|
||||||
as.bactid("S. aureus")
|
as.mo("S. aureus")
|
||||||
as.bactid("S aureus")
|
as.mo("S aureus")
|
||||||
as.bactid("Staphylococcus aureus")
|
as.mo("Staphylococcus aureus")
|
||||||
as.bactid("MRSA") # Methicillin Resistant S. aureus
|
as.mo("MRSA") # Methicillin Resistant S. aureus
|
||||||
as.bactid("VISA") # Vancomycin Intermediate S. aureus
|
as.mo("VISA") # Vancomycin Intermediate S. aureus
|
||||||
as.bactid("VRSA") # Vancomycin Resistant S. aureus
|
as.mo("VRSA") # Vancomycin Resistant S. aureus
|
||||||
|
|
||||||
# guess_bactid is an alias of as.bactid and works the same
|
# guess_mo is an alias of as.mo and works the same
|
||||||
guess_bactid("S. epidermidis") # will remain species: STAEPI
|
guess_mo("S. epidermidis") # will remain species: STAEPI
|
||||||
guess_bactid("S. epidermidis", Becker = TRUE) # will not remain species: STACNS
|
guess_mo("S. epidermidis", Becker = TRUE) # will not remain species: STACNS
|
||||||
|
|
||||||
guess_bactid("S. pyogenes") # will remain species: STCAGA
|
guess_mo("S. pyogenes") # will remain species: STCAGA
|
||||||
guess_bactid("S. pyogenes", Lancefield = TRUE) # will not remain species: STCGRA
|
guess_mo("S. pyogenes", Lancefield = TRUE) # will not remain species: STCGRA
|
||||||
|
|
||||||
# Use mo_* functions to get a specific property based on a bactid
|
# Use mo_* functions to get a specific property based on `mo`
|
||||||
Ecoli <- as.bactid("E. coli") # returns `ESCCOL`
|
Ecoli <- as.mo("E. coli") # returns `ESCCOL`
|
||||||
mo_genus(Ecoli) # returns "Escherichia"
|
mo_genus(Ecoli) # returns "Escherichia"
|
||||||
mo_gramstain(Ecoli) # returns "Negative rods"
|
mo_gramstain(Ecoli) # returns "Negative rods"
|
||||||
|
|
||||||
\dontrun{
|
\dontrun{
|
||||||
df$bactid <- as.bactid(df$microorganism_name)
|
df$mo <- as.mo(df$microorganism_name)
|
||||||
|
|
||||||
# the select function of tidyverse is also supported:
|
# the select function of tidyverse is also supported:
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
df$bactid <- df \%>\%
|
df$mo <- df \%>\%
|
||||||
select(microorganism_name) \%>\%
|
select(microorganism_name) \%>\%
|
||||||
guess_bactid()
|
guess_mo()
|
||||||
|
|
||||||
# and can even contain 2 columns, which is convenient for genus/species combinations:
|
# and can even contain 2 columns, which is convenient for genus/species combinations:
|
||||||
df$bactid <- df \%>\%
|
df$mo <- df \%>\%
|
||||||
select(genus, species) \%>\%
|
select(genus, species) \%>\%
|
||||||
guess_bactid()
|
guess_mo()
|
||||||
|
|
||||||
# same result:
|
# same result:
|
||||||
df <- df \%>\%
|
df <- df \%>\%
|
||||||
mutate(bactid = guess_bactid(paste(genus, species)))
|
mutate(mo = guess_mo(paste(genus, species)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
|
@ -95,7 +95,7 @@ df <- df \%>\%
|
||||||
}
|
}
|
||||||
\keyword{Becker}
|
\keyword{Becker}
|
||||||
\keyword{Lancefield}
|
\keyword{Lancefield}
|
||||||
\keyword{bactid}
|
|
||||||
\keyword{becker}
|
\keyword{becker}
|
||||||
\keyword{guess}
|
\keyword{guess}
|
||||||
\keyword{lancefield}
|
\keyword{lancefield}
|
||||||
|
\keyword{mo}
|
|
@ -7,13 +7,13 @@
|
||||||
Methodology of this function is based on: \strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}.
|
Methodology of this function is based on: \strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}.
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
first_isolate(tbl, col_date, col_patient_id, col_bactid = NA,
|
first_isolate(tbl, col_date, col_patient_id, col_mo = NA,
|
||||||
col_testcode = NA, col_specimen = NA, col_icu = NA,
|
col_testcode = NA, col_specimen = NA, col_icu = NA,
|
||||||
col_keyantibiotics = NA, episode_days = 365,
|
col_keyantibiotics = NA, episode_days = 365,
|
||||||
testcodes_exclude = "", icu_exclude = FALSE, filter_specimen = NA,
|
testcodes_exclude = "", icu_exclude = FALSE, filter_specimen = NA,
|
||||||
output_logical = TRUE, type = "keyantibiotics", ignore_I = TRUE,
|
output_logical = TRUE, type = "keyantibiotics", ignore_I = TRUE,
|
||||||
points_threshold = 2, info = TRUE, col_genus = NA,
|
points_threshold = 2, info = TRUE, col_bactid = NA,
|
||||||
col_species = NA)
|
col_genus = NA, col_species = NA)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{tbl}{a \code{data.frame} containing isolates.}
|
\item{tbl}{a \code{data.frame} containing isolates.}
|
||||||
|
@ -22,7 +22,7 @@ first_isolate(tbl, col_date, col_patient_id, col_bactid = NA,
|
||||||
|
|
||||||
\item{col_patient_id}{column name of the unique IDs of the patients}
|
\item{col_patient_id}{column name of the unique IDs of the patients}
|
||||||
|
|
||||||
\item{col_bactid}{column name of the unique IDs of the microorganisms: \code{bactid}'s. If this column has another class than \code{"bactid"}, values will be coerced using \code{\link{as.bactid}}.}
|
\item{col_mo}{column name of the unique IDs of the microorganisms, see \code{\link{mo}}. If this column has another class than \code{"mo"}, values will be coerced using \code{\link{as.mo}}.}
|
||||||
|
|
||||||
\item{col_testcode}{column name of the test codes. Use \code{col_testcode = NA} to \strong{not} exclude certain test codes (like test codes for screening). In that case \code{testcodes_exclude} will be ignored. Supports tidyverse-like quotation.}
|
\item{col_testcode}{column name of the test codes. Use \code{col_testcode = NA} to \strong{not} exclude certain test codes (like test codes for screening). In that case \code{testcodes_exclude} will be ignored. Supports tidyverse-like quotation.}
|
||||||
|
|
||||||
|
@ -50,9 +50,11 @@ first_isolate(tbl, col_date, col_patient_id, col_bactid = NA,
|
||||||
|
|
||||||
\item{info}{print progress}
|
\item{info}{print progress}
|
||||||
|
|
||||||
\item{col_genus}{(deprecated, use \code{col_bactid} instead) column name of the genus of the microorganisms}
|
\item{col_bactid}{(deprecated, use \code{col_mo} instead)}
|
||||||
|
|
||||||
\item{col_species}{(deprecated, use \code{col_bactid} instead) column name of the species of the microorganisms}
|
\item{col_genus}{(deprecated, use \code{col_mo} instead) column name of the genus of the microorganisms}
|
||||||
|
|
||||||
|
\item{col_species}{(deprecated, use \code{col_mo} instead) column name of the species of the microorganisms}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
A vector to add to table, see Examples.
|
A vector to add to table, see Examples.
|
||||||
|
@ -84,7 +86,7 @@ my_patients <- septic_patients \%>\%
|
||||||
mutate(first_isolate = first_isolate(.,
|
mutate(first_isolate = first_isolate(.,
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_bactid = "bactid"))
|
col_mo = "mo"))
|
||||||
|
|
||||||
# Now let's see if first isolates matter:
|
# Now let's see if first isolates matter:
|
||||||
A <- my_patients \%>\%
|
A <- my_patients \%>\%
|
||||||
|
|
|
@ -88,7 +88,7 @@ septic_patients \%>\% freq(hospital_id) #<- easiest to remember when you're use
|
||||||
# you could also use `select` or `pull` to get your variables
|
# you could also use `select` or `pull` to get your variables
|
||||||
septic_patients \%>\%
|
septic_patients \%>\%
|
||||||
filter(hospital_id == "A") \%>\%
|
filter(hospital_id == "A") \%>\%
|
||||||
select(bactid) \%>\%
|
select(mo) \%>\%
|
||||||
freq()
|
freq()
|
||||||
|
|
||||||
# multiple selected variables will be pasted together
|
# multiple selected variables will be pasted together
|
||||||
|
@ -100,7 +100,7 @@ septic_patients \%>\%
|
||||||
# get top 10 bugs of hospital A as a vector
|
# get top 10 bugs of hospital A as a vector
|
||||||
septic_patients \%>\%
|
septic_patients \%>\%
|
||||||
filter(hospital_id == "A") \%>\%
|
filter(hospital_id == "A") \%>\%
|
||||||
freq(bactid) \%>\%
|
freq(mo) \%>\%
|
||||||
top_freq(10)
|
top_freq(10)
|
||||||
|
|
||||||
# save frequency table to an object
|
# save frequency table to an object
|
||||||
|
|
|
@ -119,14 +119,14 @@ septic_patients \%>\%
|
||||||
# genuine analysis: check 2 most prevalent microorganisms
|
# genuine analysis: check 2 most prevalent microorganisms
|
||||||
septic_patients \%>\%
|
septic_patients \%>\%
|
||||||
# create new bacterial ID's, with all CoNS under the same group (Becker et al.)
|
# create new bacterial ID's, with all CoNS under the same group (Becker et al.)
|
||||||
mutate(bactid = as.bactid(bactid, Becker = TRUE)) \%>\%
|
mutate(mo = as.mo(mo, Becker = TRUE)) \%>\%
|
||||||
# filter on top 2 bacterial ID's
|
# filter on top 2 bacterial ID's
|
||||||
filter(bactid \%in\% top_freq(freq(.$bactid), 2)) \%>\%
|
filter(mo \%in\% top_freq(freq(.$mo), 2)) \%>\%
|
||||||
# determine first isolates
|
# determine first isolates
|
||||||
mutate(first_isolate = first_isolate(.,
|
mutate(first_isolate = first_isolate(.,
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_bactid = "bactid")) \%>\%
|
col_mo = "mo")) \%>\%
|
||||||
# filter on first isolates
|
# filter on first isolates
|
||||||
filter(first_isolate == TRUE) \%>\%
|
filter(first_isolate == TRUE) \%>\%
|
||||||
# join the `microorganisms` data set
|
# join the `microorganisms` data set
|
||||||
|
@ -140,7 +140,7 @@ septic_patients \%>\%
|
||||||
ggplot_rsi(x = "Antibiotic",
|
ggplot_rsi(x = "Antibiotic",
|
||||||
facet = "mo") +
|
facet = "mo") +
|
||||||
labs(title = "AMR of Top Two Microorganisms In Blood Culture Isolates",
|
labs(title = "AMR of Top Two Microorganisms In Blood Culture Isolates",
|
||||||
subtitle = "Only First Isolates, CoNS grouped according to Becker et al.",
|
subtitle = "Only First Isolates, CoNS grouped according to Becker et al. (2014)",
|
||||||
x = "Microorganisms")
|
x = "Microorganisms")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
man/join.Rd
14
man/join.Rd
|
@ -11,22 +11,22 @@
|
||||||
\alias{anti_join_microorganisms}
|
\alias{anti_join_microorganisms}
|
||||||
\title{Join a table with \code{microorganisms}}
|
\title{Join a table with \code{microorganisms}}
|
||||||
\usage{
|
\usage{
|
||||||
inner_join_microorganisms(x, by = "bactid", suffix = c("2", ""), ...)
|
inner_join_microorganisms(x, by = "mo", suffix = c("2", ""), ...)
|
||||||
|
|
||||||
left_join_microorganisms(x, by = "bactid", suffix = c("2", ""), ...)
|
left_join_microorganisms(x, by = "mo", suffix = c("2", ""), ...)
|
||||||
|
|
||||||
right_join_microorganisms(x, by = "bactid", suffix = c("2", ""), ...)
|
right_join_microorganisms(x, by = "mo", suffix = c("2", ""), ...)
|
||||||
|
|
||||||
full_join_microorganisms(x, by = "bactid", suffix = c("2", ""), ...)
|
full_join_microorganisms(x, by = "mo", suffix = c("2", ""), ...)
|
||||||
|
|
||||||
semi_join_microorganisms(x, by = "bactid", ...)
|
semi_join_microorganisms(x, by = "mo", ...)
|
||||||
|
|
||||||
anti_join_microorganisms(x, by = "bactid", ...)
|
anti_join_microorganisms(x, by = "mo", ...)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{x}{existing table to join, also supports character vectors}
|
\item{x}{existing table to join, also supports character vectors}
|
||||||
|
|
||||||
\item{by}{a variable to join by - could be a column name of \code{x} with values that exist in \code{microorganisms$bactid} (like \code{by = "bacteria_id"}), or another column in \code{\link{microorganisms}} (but then it should be named, like \code{by = c("my_genus_species" = "fullname")})}
|
\item{by}{a variable to join by - could be a column name of \code{x} with values that exist in \code{microorganisms$mo} (like \code{by = "bacteria_id"}), or another column in \code{\link{microorganisms}} (but then it should be named, like \code{by = c("my_genus_species" = "fullname")})}
|
||||||
|
|
||||||
\item{suffix}{if there are non-joined duplicate variables in \code{x} and \code{y}, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2.}
|
\item{suffix}{if there are non-joined duplicate variables in \code{x} and \code{y}, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2.}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
\alias{key_antibiotics_equal}
|
\alias{key_antibiotics_equal}
|
||||||
\title{Key antibiotics for first \emph{weighted} isolates}
|
\title{Key antibiotics for first \emph{weighted} isolates}
|
||||||
\usage{
|
\usage{
|
||||||
key_antibiotics(tbl, col_bactid = "bactid", universal_1 = "amox",
|
key_antibiotics(tbl, col_mo = "mo", universal_1 = "amox",
|
||||||
universal_2 = "amcl", universal_3 = "cfur", universal_4 = "pita",
|
universal_2 = "amcl", universal_3 = "cfur", universal_4 = "pita",
|
||||||
universal_5 = "cipr", universal_6 = "trsu", GramPos_1 = "vanc",
|
universal_5 = "cipr", universal_6 = "trsu", GramPos_1 = "vanc",
|
||||||
GramPos_2 = "teic", GramPos_3 = "tetr", GramPos_4 = "eryt",
|
GramPos_2 = "teic", GramPos_3 = "tetr", GramPos_4 = "eryt",
|
||||||
GramPos_5 = "oxac", GramPos_6 = "rifa", GramNeg_1 = "gent",
|
GramPos_5 = "oxac", GramPos_6 = "rifa", GramNeg_1 = "gent",
|
||||||
GramNeg_2 = "tobr", GramNeg_3 = "coli", GramNeg_4 = "cfot",
|
GramNeg_2 = "tobr", GramNeg_3 = "coli", GramNeg_4 = "cfot",
|
||||||
GramNeg_5 = "cfta", GramNeg_6 = "mero", warnings = TRUE)
|
GramNeg_5 = "cfta", GramNeg_6 = "mero", warnings = TRUE,
|
||||||
|
col_bactid = "bactid")
|
||||||
|
|
||||||
key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"),
|
key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"),
|
||||||
ignore_I = TRUE, points_threshold = 2, info = FALSE)
|
ignore_I = TRUE, points_threshold = 2, info = FALSE)
|
||||||
|
@ -19,7 +20,7 @@ key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"),
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{tbl}{table with antibiotics coloms, like \code{amox} and \code{amcl}.}
|
\item{tbl}{table with antibiotics coloms, like \code{amox} and \code{amcl}.}
|
||||||
|
|
||||||
\item{col_bactid}{column name of the unique IDs of the microorganisms: \code{bactid}'s. If this column has another class than \code{"bactid"}, values will be coerced using \code{\link{as.bactid}}.}
|
\item{col_mo}{column name of the unique IDs of the microorganisms, see \code{\link{mo}}. If this column has another class than \code{"mo"}, values will be coerced using \code{\link{as.mo}}.}
|
||||||
|
|
||||||
\item{universal_1, universal_2, universal_3, universal_4, universal_5, universal_6}{column names of \strong{broad-spectrum} antibiotics, case-insensitive}
|
\item{universal_1, universal_2, universal_3, universal_4, universal_5, universal_6}{column names of \strong{broad-spectrum} antibiotics, case-insensitive}
|
||||||
|
|
||||||
|
@ -29,6 +30,8 @@ key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"),
|
||||||
|
|
||||||
\item{warnings}{give warning about missing antibiotic columns, they will anyway be ignored}
|
\item{warnings}{give warning about missing antibiotic columns, they will anyway be ignored}
|
||||||
|
|
||||||
|
\item{col_bactid}{(deprecated, use \code{col_mo} instead)}
|
||||||
|
|
||||||
\item{x, y}{characters to compare}
|
\item{x, y}{characters to compare}
|
||||||
|
|
||||||
\item{type}{type to determine weighed isolates; can be \code{"keyantibiotics"} or \code{"points"}, see Details}
|
\item{type}{type to determine weighed isolates; can be \code{"keyantibiotics"} or \code{"points"}, see Details}
|
||||||
|
@ -76,9 +79,9 @@ my_patients <- my_patients \%>\%
|
||||||
mutate(keyab = key_antibiotics(.)) \%>\%
|
mutate(keyab = key_antibiotics(.)) \%>\%
|
||||||
mutate(
|
mutate(
|
||||||
# now calculate first isolates
|
# now calculate first isolates
|
||||||
first_regular = first_isolate(., "date", "patient_id", "bactid"),
|
first_regular = first_isolate(., "date", "patient_id", "mo"),
|
||||||
# and first WEIGHTED isolates
|
# and first WEIGHTED isolates
|
||||||
first_weighted = first_isolate(., "date", "patient_id", "bactid",
|
first_weighted = first_isolate(., "date", "patient_id", "mo",
|
||||||
col_keyantibiotics = "keyab")
|
col_keyantibiotics = "keyab")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
\title{Dataset with ~2650 microorganisms}
|
\title{Dataset with ~2650 microorganisms}
|
||||||
\format{A data.frame with 2,646 observations and 12 variables:
|
\format{A data.frame with 2,646 observations and 12 variables:
|
||||||
\describe{
|
\describe{
|
||||||
\item{\code{bactid}}{ID of microorganism}
|
\item{\code{mo}}{ID of microorganism}
|
||||||
\item{\code{bactsys}}{Bactsyscode of microorganism}
|
\item{\code{bactsys}}{Bactsyscode of microorganism}
|
||||||
\item{\code{family}}{Family name of microorganism}
|
\item{\code{family}}{Family name of microorganism}
|
||||||
\item{\code{genus}}{Genus name of microorganism, like \code{"Echerichia"}}
|
\item{\code{genus}}{Genus name of microorganism, like \code{"Echerichia"}}
|
||||||
|
@ -26,6 +26,6 @@ microorganisms
|
||||||
A dataset containing 2,646 microorganisms. MO codes of the UMCG can be looked up using \code{\link{microorganisms.umcg}}.
|
A dataset containing 2,646 microorganisms. MO codes of the UMCG can be looked up using \code{\link{microorganisms.umcg}}.
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
\code{\link{guess_bactid}} \code{\link{antibiotics}} \code{\link{microorganisms.umcg}}
|
\code{\link{guess_mo}} \code{\link{antibiotics}} \code{\link{microorganisms.umcg}}
|
||||||
}
|
}
|
||||||
\keyword{datasets}
|
\keyword{datasets}
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
\title{Translation table for UMCG with ~1100 microorganisms}
|
\title{Translation table for UMCG with ~1100 microorganisms}
|
||||||
\format{A data.frame with 1090 observations and 2 variables:
|
\format{A data.frame with 1090 observations and 2 variables:
|
||||||
\describe{
|
\describe{
|
||||||
\item{\code{mocode}}{Code of microorganism according to UMCG MMB}
|
\item{\code{umcg}}{Code of microorganism according to UMCG MMB}
|
||||||
\item{\code{bactid}}{Code of microorganism in \code{\link{microorganisms}}}
|
\item{\code{mo}}{Code of microorganism in \code{\link{microorganisms}}}
|
||||||
}}
|
}}
|
||||||
\usage{
|
\usage{
|
||||||
microorganisms.umcg
|
microorganisms.umcg
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
A dataset containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$bactid} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{bactid}'s with \code{\link{guess_bactid}}.
|
A dataset containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$mo} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{mo}'s with \code{\link{guess_mo}}.
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
\code{\link{guess_bactid}} \code{\link{microorganisms}}
|
\code{\link{guess_mo}} \code{\link{microorganisms}}
|
||||||
}
|
}
|
||||||
\keyword{datasets}
|
\keyword{datasets}
|
||||||
|
|
|
@ -37,12 +37,12 @@ mo_type_nl(x)
|
||||||
mo_gramstain_nl(x)
|
mo_gramstain_nl(x)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{x}{a (vector of a) valid \code{\link{bactid}} or any text that can be coerced to a valid bactid with \code{\link{as.bactid}}}
|
\item{x}{a (vector of a) valid \code{\link{mo}} or any text that can be coerced to a valid microorganism code with \code{\link{as.mo}}}
|
||||||
|
|
||||||
\item{property}{one of the column names of one of the \code{\link{microorganisms}} data set, like \code{"bactid"}, \code{"bactsys"}, \code{"family"}, \code{"genus"}, \code{"species"}, \code{"fullname"}, \code{"gramstain"} and \code{"aerobic"}}
|
\item{property}{one of the column names of one of the \code{\link{microorganisms}} data set, like \code{"mo"}, \code{"bactsys"}, \code{"family"}, \code{"genus"}, \code{"species"}, \code{"fullname"}, \code{"gramstain"} and \code{"aerobic"}}
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Use these functions to return a specific property of a microorganism from the \code{\link{microorganisms}} data set, based on their \code{bactid}. Get such an ID with \code{\link{as.bactid}}.
|
Use these functions to return a specific property of a microorganism from the \code{\link{microorganisms}} data set, based on their \code{mo}. Get such an ID with \code{\link{as.mo}}.
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
# All properties
|
# All properties
|
||||||
|
|
|
@ -71,13 +71,13 @@ tbl \%>\%
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
septic_patients \%>\%
|
septic_patients \%>\%
|
||||||
# get bacteria properties like genus and species
|
# get bacteria properties like genus and species
|
||||||
left_join_microorganisms("bactid") \%>\%
|
left_join_microorganisms("mo") \%>\%
|
||||||
# calculate first isolates
|
# calculate first isolates
|
||||||
mutate(first_isolate =
|
mutate(first_isolate =
|
||||||
first_isolate(.,
|
first_isolate(.,
|
||||||
"date",
|
"date",
|
||||||
"patient_id",
|
"patient_id",
|
||||||
"bactid",
|
"mo",
|
||||||
col_specimen = NA,
|
col_specimen = NA,
|
||||||
col_icu = NA)) \%>\%
|
col_icu = NA)) \%>\%
|
||||||
# filter on first E. coli isolates
|
# filter on first E. coli isolates
|
||||||
|
@ -95,7 +95,7 @@ septic_patients \%>\%
|
||||||
if (!require(ggplot2)) {
|
if (!require(ggplot2)) {
|
||||||
|
|
||||||
data <- septic_patients \%>\%
|
data <- septic_patients \%>\%
|
||||||
filter(bactid == "ESCCOL") \%>\%
|
filter(mo == "ESCCOL") \%>\%
|
||||||
resistance_predict(col_ab = "amox",
|
resistance_predict(col_ab = "amox",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
info = FALSE,
|
info = FALSE,
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
\item{\code{age}}{age of the patient}
|
\item{\code{age}}{age of the patient}
|
||||||
\item{\code{sex}}{sex of the patient}
|
\item{\code{sex}}{sex of the patient}
|
||||||
\item{\code{patient_id}}{ID of the patient, first 10 characters of an SHA hash containing irretrievable information}
|
\item{\code{patient_id}}{ID of the patient, first 10 characters of an SHA hash containing irretrievable information}
|
||||||
\item{\code{bactid}}{ID of microorganism, see \code{\link{microorganisms}}}
|
\item{\code{mo}}{ID of microorganism, see \code{\link{microorganisms}}}
|
||||||
\item{\code{peni:rifa}}{40 different antibiotics with class \code{rsi} (see \code{\link{as.rsi}}); these column names occur in \code{\link{antibiotics}} data set and can be translated with \code{\link{abname}}}
|
\item{\code{peni:rifa}}{40 different antibiotics with class \code{rsi} (see \code{\link{as.rsi}}); these column names occur in \code{\link{antibiotics}} data set and can be translated with \code{\link{abname}}}
|
||||||
}}
|
}}
|
||||||
\usage{
|
\usage{
|
||||||
|
@ -36,7 +36,7 @@ library(dplyr)
|
||||||
|
|
||||||
# Add first isolates to our dataset:
|
# Add first isolates to our dataset:
|
||||||
my_data <- my_data \%>\%
|
my_data <- my_data \%>\%
|
||||||
mutate(first_isolates = first_isolate(my_data, "date", "patient_id", "bactid"))
|
mutate(first_isolates = first_isolate(my_data, "date", "patient_id", "mo"))
|
||||||
|
|
||||||
# -------- #
|
# -------- #
|
||||||
# ANALYSIS #
|
# ANALYSIS #
|
||||||
|
@ -46,7 +46,7 @@ my_data <- my_data \%>\%
|
||||||
# and numbers (n) of E. coli, divided by hospital:
|
# and numbers (n) of E. coli, divided by hospital:
|
||||||
|
|
||||||
my_data \%>\%
|
my_data \%>\%
|
||||||
filter(bactid == guess_bactid("E. coli"),
|
filter(mo == guess_mo("E. coli"),
|
||||||
first_isolates == TRUE) \%>\%
|
first_isolates == TRUE) \%>\%
|
||||||
group_by(hospital_id) \%>\%
|
group_by(hospital_id) \%>\%
|
||||||
summarise(n = n_rsi(amox),
|
summarise(n = n_rsi(amox),
|
||||||
|
@ -57,7 +57,7 @@ my_data \%>\%
|
||||||
# percentages of E. coli, trend over the years:
|
# percentages of E. coli, trend over the years:
|
||||||
|
|
||||||
my_data \%>\%
|
my_data \%>\%
|
||||||
filter(bactid == guess_bactid("E. coli"),
|
filter(mo == guess_mo("E. coli"),
|
||||||
first_isolates == TRUE) \%>\%
|
first_isolates == TRUE) \%>\%
|
||||||
group_by(year = format(date, "\%Y")) \%>\%
|
group_by(year = format(date, "\%Y")) \%>\%
|
||||||
summarise(n = n_rsi(amcl),
|
summarise(n = n_rsi(amcl),
|
||||||
|
|
|
@ -1,118 +0,0 @@
|
||||||
context("bactid.R")
|
|
||||||
|
|
||||||
test_that("as.bactid works", {
|
|
||||||
expect_identical(
|
|
||||||
as.character(as.bactid(c("E. coli", "H. influenzae"))),
|
|
||||||
c("ESCCOL", "HAEINF"))
|
|
||||||
|
|
||||||
expect_equal(as.character(as.bactid("Escherichia coli")), "ESCCOL")
|
|
||||||
expect_equal(as.character(as.bactid("Escherichia coli")), "ESCCOL")
|
|
||||||
expect_equal(as.character(as.bactid("Escherichia species")), "ESC")
|
|
||||||
expect_equal(as.character(as.bactid(" ESCCOL ")), "ESCCOL")
|
|
||||||
expect_equal(as.character(as.bactid("klpn")), "KLEPNE")
|
|
||||||
expect_equal(as.character(as.bactid("Klebsiella")), "KLE")
|
|
||||||
expect_equal(as.character(as.bactid("coagulase negative")), "STACNS")
|
|
||||||
|
|
||||||
expect_equal(as.character(as.bactid("P. aer")), "PSEAER") # not Pasteurella aerogenes
|
|
||||||
|
|
||||||
expect_equal(as.character(as.bactid("Negative rods")), "GNR")
|
|
||||||
expect_equal(as.character(as.bactid("Gram negative rods")), "GNR")
|
|
||||||
|
|
||||||
# GLIMS
|
|
||||||
expect_equal(as.character(as.bactid("shiboy")), "SHIBOY")
|
|
||||||
|
|
||||||
expect_equal(as.character(as.bactid("MRSE")), "STAEPI")
|
|
||||||
expect_equal(as.character(as.bactid("VRE")), "ENC")
|
|
||||||
expect_equal(as.character(as.bactid("MRPA")), "PSEAER")
|
|
||||||
expect_equal(as.character(as.bactid("PISP")), "STCPNE")
|
|
||||||
expect_equal(as.character(as.bactid("PRSP")), "STCPNE")
|
|
||||||
expect_equal(as.character(as.bactid("VISP")), "STCPNE")
|
|
||||||
expect_equal(as.character(as.bactid("VRSP")), "STCPNE")
|
|
||||||
|
|
||||||
expect_identical(
|
|
||||||
as.character(
|
|
||||||
as.bactid(c("stau",
|
|
||||||
"STAU",
|
|
||||||
"staaur",
|
|
||||||
"S. aureus",
|
|
||||||
"S aureus",
|
|
||||||
"Staphylococcus aureus",
|
|
||||||
"MRSA",
|
|
||||||
"VISA"))),
|
|
||||||
rep("STAAUR", 8))
|
|
||||||
|
|
||||||
# check for Becker classification
|
|
||||||
expect_identical(as.character(guess_bactid("S. epidermidis", Becker = FALSE)), "STAEPI")
|
|
||||||
expect_identical(as.character(guess_bactid("S. epidermidis", Becker = TRUE)), "STACNS")
|
|
||||||
expect_identical(as.character(guess_bactid("STAEPI", Becker = TRUE)), "STACNS")
|
|
||||||
expect_identical(as.character(guess_bactid("S. intermedius", Becker = FALSE)), "STAINT")
|
|
||||||
expect_identical(as.character(guess_bactid("S. intermedius", Becker = TRUE)), "STACPS")
|
|
||||||
expect_identical(as.character(guess_bactid("STAINT", Becker = TRUE)), "STACPS")
|
|
||||||
# aureus must only be influenced if Becker = "all"
|
|
||||||
expect_identical(as.character(guess_bactid("STAAUR", Becker = FALSE)), "STAAUR")
|
|
||||||
expect_identical(as.character(guess_bactid("STAAUR", Becker = TRUE)), "STAAUR")
|
|
||||||
expect_identical(as.character(guess_bactid("STAAUR", Becker = "all")), "STACPS")
|
|
||||||
|
|
||||||
# check for Lancefield classification
|
|
||||||
expect_identical(as.character(guess_bactid("S. pyogenes", Lancefield = FALSE)), "STCPYO")
|
|
||||||
expect_identical(as.character(guess_bactid("S. pyogenes", Lancefield = TRUE)), "STCGRA")
|
|
||||||
expect_identical(as.character(guess_bactid("STCPYO", Lancefield = TRUE)), "STCGRA")
|
|
||||||
expect_identical(as.character(guess_bactid("S. agalactiae", Lancefield = FALSE)), "STCAGA")
|
|
||||||
expect_identical(as.character(guess_bactid("S. agalactiae", Lancefield = TRUE)), "STCGRB") # group B
|
|
||||||
expect_identical(as.character(guess_bactid("S. equisimilis", Lancefield = FALSE)), "STCEQS")
|
|
||||||
expect_identical(as.character(guess_bactid("S. equisimilis", Lancefield = TRUE)), "STCGRC") # group C
|
|
||||||
expect_identical(as.character(guess_bactid("S. anginosus", Lancefield = FALSE)), "STCANG")
|
|
||||||
expect_identical(as.character(guess_bactid("S. anginosus", Lancefield = TRUE)), "STCGRF") # group F
|
|
||||||
expect_identical(as.character(guess_bactid("S. sanguis", Lancefield = FALSE)), "STCSAN")
|
|
||||||
expect_identical(as.character(guess_bactid("S. sanguis", Lancefield = TRUE)), "STCGRH") # group H
|
|
||||||
expect_identical(as.character(guess_bactid("S. salivarius", Lancefield = FALSE)), "STCSAL")
|
|
||||||
expect_identical(as.character(guess_bactid("S. salivarius", Lancefield = TRUE)), "STCGRK") # group K
|
|
||||||
|
|
||||||
library(dplyr)
|
|
||||||
|
|
||||||
# select with one column
|
|
||||||
expect_identical(
|
|
||||||
septic_patients[1:10,] %>%
|
|
||||||
left_join_microorganisms() %>%
|
|
||||||
select(genus) %>%
|
|
||||||
as.bactid() %>%
|
|
||||||
as.character(),
|
|
||||||
c("ESC", "ESC", "STA", "STA", "STA",
|
|
||||||
"STA", "STA", "STA", "STA", "STA"))
|
|
||||||
|
|
||||||
# select with two columns
|
|
||||||
expect_identical(
|
|
||||||
septic_patients[1:10,] %>%
|
|
||||||
pull(bactid),
|
|
||||||
septic_patients[1:10,] %>%
|
|
||||||
left_join_microorganisms() %>%
|
|
||||||
select(genus, species) %>%
|
|
||||||
as.bactid() %>%
|
|
||||||
as.character())
|
|
||||||
|
|
||||||
# unknown results
|
|
||||||
expect_warning(as.bactid(c("INVALID", "Yeah, unknown")))
|
|
||||||
|
|
||||||
# too many columns
|
|
||||||
expect_error(septic_patients %>% select(1:3) %>% as.bactid())
|
|
||||||
|
|
||||||
# print
|
|
||||||
expect_output(print(as.bactid(c("ESCCOL", NA))))
|
|
||||||
|
|
||||||
# helper function
|
|
||||||
expect_identical(as.bactid("ESCCOL"),
|
|
||||||
guess_bactid("ESCCOL"))
|
|
||||||
|
|
||||||
# test pull
|
|
||||||
expect_equal(nrow(septic_patients %>% mutate(bactid = as.bactid(bactid))),
|
|
||||||
2000)
|
|
||||||
|
|
||||||
# test data.frame
|
|
||||||
expect_equal(nrow(data.frame(test = as.bactid("ESCCOL"))),
|
|
||||||
1)
|
|
||||||
|
|
||||||
# check empty values
|
|
||||||
expect_equal(as.character(suppressWarnings(as.bactid(""))),
|
|
||||||
NA_character_)
|
|
||||||
|
|
||||||
})
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
context("deprecated.R")
|
||||||
|
|
||||||
|
test_that("deprecated functions work", {
|
||||||
|
|
||||||
|
expect_identical(is.mo(as.mo("esco")), suppressWarnings(is.bactid(as.bactid("esco"))))
|
||||||
|
expect_warning(identical(is.mo(as.mo("esco")), is.bactid(as.bactid("esco"))))
|
||||||
|
|
||||||
|
expect_identical(as.mo("esco"), suppressWarnings(guess_bactid("esco")))
|
||||||
|
|
||||||
|
expect_error(suppressWarnings(ratio("A")))
|
||||||
|
expect_error(suppressWarnings(ratio(1, ratio = "abc")))
|
||||||
|
expect_error(suppressWarnings(ratio(c(1, 2), ratio = c(1, 2, 3))))
|
||||||
|
expect_warning(ratio(c(772, 1611, 737), ratio = "1:2:1"))
|
||||||
|
expect_identical(suppressWarnings(ratio(c(772, 1611, 737), ratio = "1:2:1")), c(780, 1560, 780))
|
||||||
|
expect_identical(suppressWarnings(ratio(c(1752, 1895), ratio = c(1, 1))), c(1823.5, 1823.5))
|
||||||
|
|
||||||
|
old_mo <- "ESCCOL"
|
||||||
|
class(old_mo) <- "bactid"
|
||||||
|
# print
|
||||||
|
expect_output(print(old_mo))
|
||||||
|
# test data.frame and pull
|
||||||
|
expect_equal(as.character(dplyr::pull(data.frame(test = old_mo), test)), "ESCCOL")
|
||||||
|
|
||||||
|
})
|
|
@ -2,19 +2,19 @@ context("eucast.R")
|
||||||
|
|
||||||
test_that("EUCAST rules work", {
|
test_that("EUCAST rules work", {
|
||||||
|
|
||||||
expect_error(EUCAST_rules(septic_patients, col_bactid = "Non-existing"))
|
expect_error(EUCAST_rules(septic_patients, col_mo = "Non-existing"))
|
||||||
|
|
||||||
|
|
||||||
expect_identical(colnames(septic_patients),
|
expect_identical(colnames(septic_patients),
|
||||||
colnames(suppressWarnings(EUCAST_rules(septic_patients))))
|
colnames(suppressWarnings(EUCAST_rules(septic_patients))))
|
||||||
|
|
||||||
a <- data.frame(bactid =
|
a <- data.frame(mo =
|
||||||
c("KLEPNE", # Klebsiella pneumoniae
|
c("KLEPNE", # Klebsiella pneumoniae
|
||||||
"PSEAER", # Pseudomonas aeruginosa
|
"PSEAER", # Pseudomonas aeruginosa
|
||||||
"ENTAER"), # Enterobacter aerogenes
|
"ENTAER"), # Enterobacter aerogenes
|
||||||
amox = "-", # Amoxicillin
|
amox = "-", # Amoxicillin
|
||||||
stringsAsFactors = FALSE)
|
stringsAsFactors = FALSE)
|
||||||
b <- data.frame(bactid =
|
b <- data.frame(mo =
|
||||||
c("KLEPNE", # Klebsiella pneumoniae
|
c("KLEPNE", # Klebsiella pneumoniae
|
||||||
"PSEAER", # Pseudomonas aeruginosa
|
"PSEAER", # Pseudomonas aeruginosa
|
||||||
"ENTAER"), # Enterobacter aerogenes
|
"ENTAER"), # Enterobacter aerogenes
|
||||||
|
@ -24,12 +24,12 @@ test_that("EUCAST rules work", {
|
||||||
expect_identical(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
|
expect_identical(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
|
||||||
expect_identical(suppressWarnings(interpretive_reading(a, info = TRUE)), b)
|
expect_identical(suppressWarnings(interpretive_reading(a, info = TRUE)), b)
|
||||||
|
|
||||||
a <- data.frame(bactid =
|
a <- data.frame(mo =
|
||||||
c("STAAUR", # Staphylococcus aureus
|
c("STAAUR", # Staphylococcus aureus
|
||||||
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
||||||
coli = "-", # Colistin
|
coli = "-", # Colistin
|
||||||
stringsAsFactors = FALSE)
|
stringsAsFactors = FALSE)
|
||||||
b <- data.frame(bactid =
|
b <- data.frame(mo =
|
||||||
c("STAAUR", # Staphylococcus aureus
|
c("STAAUR", # Staphylococcus aureus
|
||||||
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
||||||
coli = "R", # Colistin
|
coli = "R", # Colistin
|
||||||
|
@ -42,7 +42,7 @@ test_that("EUCAST rules work", {
|
||||||
septic_patients %>%
|
septic_patients %>%
|
||||||
mutate(tica = as.rsi("R"),
|
mutate(tica = as.rsi("R"),
|
||||||
pita = as.rsi("S")) %>%
|
pita = as.rsi("S")) %>%
|
||||||
EUCAST_rules(col_bactid = "bactid") %>%
|
EUCAST_rules(col_mo = "mo") %>%
|
||||||
left_join_microorganisms() %>%
|
left_join_microorganisms() %>%
|
||||||
filter(family == "Enterobacteriaceae") %>%
|
filter(family == "Enterobacteriaceae") %>%
|
||||||
pull(pita) %>%
|
pull(pita) %>%
|
||||||
|
@ -54,11 +54,11 @@ test_that("EUCAST rules work", {
|
||||||
septic_patients %>%
|
septic_patients %>%
|
||||||
mutate(azit = as.rsi("R"),
|
mutate(azit = as.rsi("R"),
|
||||||
clar = as.rsi("R")) %>%
|
clar = as.rsi("R")) %>%
|
||||||
EUCAST_rules(col_bactid = "bactid") %>%
|
EUCAST_rules(col_mo = "mo") %>%
|
||||||
pull(clar)),
|
pull(clar)),
|
||||||
suppressWarnings(
|
suppressWarnings(
|
||||||
septic_patients %>%
|
septic_patients %>%
|
||||||
EUCAST_rules(col_bactid = "bactid") %>%
|
EUCAST_rules(col_mo = "mo") %>%
|
||||||
left_join_microorganisms() %>%
|
left_join_microorganisms() %>%
|
||||||
pull(eryt)))
|
pull(eryt)))
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ test_that("first isolates work", {
|
||||||
first_isolate(tbl = septic_patients,
|
first_isolate(tbl = septic_patients,
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
info = TRUE),
|
info = TRUE),
|
||||||
na.rm = TRUE),
|
na.rm = TRUE),
|
||||||
1331)
|
1331)
|
||||||
|
@ -19,7 +19,7 @@ test_that("first isolates work", {
|
||||||
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_keyantibiotics = "keyab",
|
col_keyantibiotics = "keyab",
|
||||||
type = "keyantibiotics",
|
type = "keyantibiotics",
|
||||||
info = TRUE),
|
info = TRUE),
|
||||||
|
@ -32,7 +32,7 @@ test_that("first isolates work", {
|
||||||
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_keyantibiotics = "keyab",
|
col_keyantibiotics = "keyab",
|
||||||
ignore_I = FALSE,
|
ignore_I = FALSE,
|
||||||
type = "keyantibiotics",
|
type = "keyantibiotics",
|
||||||
|
@ -46,7 +46,7 @@ test_that("first isolates work", {
|
||||||
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_keyantibiotics = "keyab",
|
col_keyantibiotics = "keyab",
|
||||||
type = "points",
|
type = "points",
|
||||||
info = TRUE),
|
info = TRUE),
|
||||||
|
@ -57,7 +57,7 @@ test_that("first isolates work", {
|
||||||
expect_equal(
|
expect_equal(
|
||||||
sum(
|
sum(
|
||||||
first_isolate(septic_patients,
|
first_isolate(septic_patients,
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_icu = "ward_icu",
|
col_icu = "ward_icu",
|
||||||
|
@ -76,7 +76,7 @@ test_that("first isolates work", {
|
||||||
"Other")),
|
"Other")),
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_specimen = "specimen",
|
col_specimen = "specimen",
|
||||||
filter_specimen = "Urine",
|
filter_specimen = "Urine",
|
||||||
info = TRUE),
|
info = TRUE),
|
||||||
|
@ -91,7 +91,7 @@ test_that("first isolates work", {
|
||||||
"Other")),
|
"Other")),
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_specimen = "specimen",
|
col_specimen = "specimen",
|
||||||
filter_specimen = "Urine",
|
filter_specimen = "Urine",
|
||||||
col_icu = "ward_icu",
|
col_icu = "ward_icu",
|
||||||
|
@ -104,7 +104,7 @@ test_that("first isolates work", {
|
||||||
expect_message(septic_patients %>%
|
expect_message(septic_patients %>%
|
||||||
mutate(specimen = "test") %>%
|
mutate(specimen = "test") %>%
|
||||||
mutate(first = first_isolate(., "date", "patient_id",
|
mutate(first = first_isolate(., "date", "patient_id",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_specimen = "specimen",
|
col_specimen = "specimen",
|
||||||
filter_specimen = "something_unexisting",
|
filter_specimen = "something_unexisting",
|
||||||
output_logical = FALSE)))
|
output_logical = FALSE)))
|
||||||
|
@ -112,22 +112,22 @@ test_that("first isolates work", {
|
||||||
# printing of exclusion message
|
# printing of exclusion message
|
||||||
expect_output(septic_patients %>%
|
expect_output(septic_patients %>%
|
||||||
first_isolate(col_date = "date",
|
first_isolate(col_date = "date",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_patient_id = "patient_id",
|
col_patient_id = "patient_id",
|
||||||
col_testcode = "sex",
|
col_testcode = "sex",
|
||||||
testcodes_exclude = "M"))
|
testcodes_exclude = "M"))
|
||||||
|
|
||||||
# errors
|
# errors
|
||||||
expect_error(first_isolate("date", "patient_id", col_bactid = "bactid"))
|
expect_error(first_isolate("date", "patient_id", col_mo = "mo"))
|
||||||
expect_error(first_isolate(septic_patients))
|
expect_error(first_isolate(septic_patients))
|
||||||
expect_error(first_isolate(septic_patients,
|
expect_error(first_isolate(septic_patients,
|
||||||
col_date = "non-existing col",
|
col_date = "non-existing col",
|
||||||
col_bactid = "bactid"))
|
col_mo = "mo"))
|
||||||
|
|
||||||
expect_warning(septic_patients %>%
|
expect_warning(septic_patients %>%
|
||||||
mutate(bactid = as.character(bactid)) %>%
|
mutate(mo = as.character(mo)) %>%
|
||||||
first_isolate(col_date = "date",
|
first_isolate(col_date = "date",
|
||||||
col_bactid = "bactid",
|
col_mo = "mo",
|
||||||
col_patient_id = "patient_id"))
|
col_patient_id = "patient_id"))
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,7 +22,7 @@ test_that("frequency table works", {
|
||||||
expect_output(print(freq(septic_patients$age[0])))
|
expect_output(print(freq(septic_patients$age[0])))
|
||||||
|
|
||||||
# character
|
# character
|
||||||
expect_output(print(freq(septic_patients$bactid)))
|
expect_output(print(freq(septic_patients$mo)))
|
||||||
# integer
|
# integer
|
||||||
expect_output(print(freq(septic_patients$age)))
|
expect_output(print(freq(septic_patients$age)))
|
||||||
# date
|
# date
|
||||||
|
@ -56,21 +56,21 @@ test_that("frequency table works", {
|
||||||
# top 5
|
# top 5
|
||||||
expect_equal(
|
expect_equal(
|
||||||
septic_patients %>%
|
septic_patients %>%
|
||||||
freq(bactid) %>%
|
freq(mo) %>%
|
||||||
top_freq(5) %>%
|
top_freq(5) %>%
|
||||||
length(),
|
length(),
|
||||||
5)
|
5)
|
||||||
# there're more than 5 lowest values
|
# there're more than 5 lowest values
|
||||||
expect_gt(
|
expect_gt(
|
||||||
septic_patients %>%
|
septic_patients %>%
|
||||||
freq(bactid) %>%
|
freq(mo) %>%
|
||||||
top_freq(-5) %>%
|
top_freq(-5) %>%
|
||||||
length(),
|
length(),
|
||||||
5)
|
5)
|
||||||
# n has length > 1
|
# n has length > 1
|
||||||
expect_error(
|
expect_error(
|
||||||
septic_patients %>%
|
septic_patients %>%
|
||||||
freq(bactid) %>%
|
freq(mo) %>%
|
||||||
top_freq(n = c(1, 2))
|
top_freq(n = c(1, 2))
|
||||||
)
|
)
|
||||||
# input must be freq tbl
|
# input must be freq tbl
|
||||||
|
|
|
@ -25,11 +25,11 @@ test_that("joins work", {
|
||||||
|
|
||||||
|
|
||||||
expect_equal(nrow(inner_join_microorganisms("ESCCOL")), 1)
|
expect_equal(nrow(inner_join_microorganisms("ESCCOL")), 1)
|
||||||
expect_equal(nrow(inner_join_microorganisms("ESCCOL", by = c("bactid" = "bactid"))), 1)
|
expect_equal(nrow(inner_join_microorganisms("ESCCOL", by = c("mo" = "mo"))), 1)
|
||||||
expect_warning(inner_join_microorganisms("Escherichia", by = c("bactid" = "genus")))
|
expect_warning(inner_join_microorganisms("Escherichia", by = c("mo" = "genus")))
|
||||||
|
|
||||||
expect_equal(nrow(left_join_microorganisms("ESCCOL")), 1)
|
expect_equal(nrow(left_join_microorganisms("ESCCOL")), 1)
|
||||||
expect_warning(left_join_microorganisms("Escherichia", by = c("bactid" = "genus")))
|
expect_warning(left_join_microorganisms("Escherichia", by = c("mo" = "genus")))
|
||||||
|
|
||||||
expect_equal(nrow(semi_join_microorganisms("ESCCOL")), 1)
|
expect_equal(nrow(semi_join_microorganisms("ESCCOL")), 1)
|
||||||
expect_equal(nrow(anti_join_microorganisms("ESCCOL")), 0)
|
expect_equal(nrow(anti_join_microorganisms("ESCCOL")), 0)
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
context("mo.R")
|
||||||
|
|
||||||
|
test_that("as.mo works", {
|
||||||
|
expect_identical(
|
||||||
|
as.character(as.mo(c("E. coli", "H. influenzae"))),
|
||||||
|
c("ESCCOL", "HAEINF"))
|
||||||
|
|
||||||
|
expect_equal(as.character(as.mo("Escherichia coli")), "ESCCOL")
|
||||||
|
expect_equal(as.character(as.mo("Escherichia coli")), "ESCCOL")
|
||||||
|
expect_equal(as.character(as.mo("Escherichia species")), "ESC")
|
||||||
|
expect_equal(as.character(as.mo(" ESCCOL ")), "ESCCOL")
|
||||||
|
expect_equal(as.character(as.mo("klpn")), "KLEPNE")
|
||||||
|
expect_equal(as.character(as.mo("Klebsiella")), "KLE")
|
||||||
|
expect_equal(as.character(as.mo("coagulase negative")), "STACNS")
|
||||||
|
|
||||||
|
expect_equal(as.character(as.mo("P. aer")), "PSEAER") # not Pasteurella aerogenes
|
||||||
|
|
||||||
|
expect_equal(as.character(as.mo("Negative rods")), "GNR")
|
||||||
|
expect_equal(as.character(as.mo("Gram negative rods")), "GNR")
|
||||||
|
|
||||||
|
# GLIMS
|
||||||
|
expect_equal(as.character(as.mo("shiboy")), "SHIBOY")
|
||||||
|
|
||||||
|
expect_equal(as.character(as.mo("MRSE")), "STAEPI")
|
||||||
|
expect_equal(as.character(as.mo("VRE")), "ENC")
|
||||||
|
expect_equal(as.character(as.mo("MRPA")), "PSEAER")
|
||||||
|
expect_equal(as.character(as.mo("PISP")), "STCPNE")
|
||||||
|
expect_equal(as.character(as.mo("PRSP")), "STCPNE")
|
||||||
|
expect_equal(as.character(as.mo("VISP")), "STCPNE")
|
||||||
|
expect_equal(as.character(as.mo("VRSP")), "STCPNE")
|
||||||
|
|
||||||
|
expect_identical(
|
||||||
|
as.character(
|
||||||
|
as.mo(c("stau",
|
||||||
|
"STAU",
|
||||||
|
"staaur",
|
||||||
|
"S. aureus",
|
||||||
|
"S aureus",
|
||||||
|
"Staphylococcus aureus",
|
||||||
|
"MRSA",
|
||||||
|
"VISA"))),
|
||||||
|
rep("STAAUR", 8))
|
||||||
|
|
||||||
|
# check for Becker classification
|
||||||
|
expect_identical(as.character(guess_mo("S. epidermidis", Becker = FALSE)), "STAEPI")
|
||||||
|
expect_identical(as.character(guess_mo("S. epidermidis", Becker = TRUE)), "STACNS")
|
||||||
|
expect_identical(as.character(guess_mo("STAEPI", Becker = TRUE)), "STACNS")
|
||||||
|
expect_identical(as.character(guess_mo("S. intermedius", Becker = FALSE)), "STAINT")
|
||||||
|
expect_identical(as.character(guess_mo("S. intermedius", Becker = TRUE)), "STACPS")
|
||||||
|
expect_identical(as.character(guess_mo("STAINT", Becker = TRUE)), "STACPS")
|
||||||
|
# aureus must only be influenced if Becker = "all"
|
||||||
|
expect_identical(as.character(guess_mo("STAAUR", Becker = FALSE)), "STAAUR")
|
||||||
|
expect_identical(as.character(guess_mo("STAAUR", Becker = TRUE)), "STAAUR")
|
||||||
|
expect_identical(as.character(guess_mo("STAAUR", Becker = "all")), "STACPS")
|
||||||
|
|
||||||
|
# check for Lancefield classification
|
||||||
|
expect_identical(as.character(guess_mo("S. pyogenes", Lancefield = FALSE)), "STCPYO")
|
||||||
|
expect_identical(as.character(guess_mo("S. pyogenes", Lancefield = TRUE)), "STCGRA")
|
||||||
|
expect_identical(as.character(guess_mo("STCPYO", Lancefield = TRUE)), "STCGRA")
|
||||||
|
expect_identical(as.character(guess_mo("S. agalactiae", Lancefield = FALSE)), "STCAGA")
|
||||||
|
expect_identical(as.character(guess_mo("S. agalactiae", Lancefield = TRUE)), "STCGRB") # group B
|
||||||
|
expect_identical(as.character(guess_mo("S. equisimilis", Lancefield = FALSE)), "STCEQS")
|
||||||
|
expect_identical(as.character(guess_mo("S. equisimilis", Lancefield = TRUE)), "STCGRC") # group C
|
||||||
|
expect_identical(as.character(guess_mo("S. anginosus", Lancefield = FALSE)), "STCANG")
|
||||||
|
expect_identical(as.character(guess_mo("S. anginosus", Lancefield = TRUE)), "STCGRF") # group F
|
||||||
|
expect_identical(as.character(guess_mo("S. sanguis", Lancefield = FALSE)), "STCSAN")
|
||||||
|
expect_identical(as.character(guess_mo("S. sanguis", Lancefield = TRUE)), "STCGRH") # group H
|
||||||
|
expect_identical(as.character(guess_mo("S. salivarius", Lancefield = FALSE)), "STCSAL")
|
||||||
|
expect_identical(as.character(guess_mo("S. salivarius", Lancefield = TRUE)), "STCGRK") # group K
|
||||||
|
|
||||||
|
library(dplyr)
|
||||||
|
|
||||||
|
# select with one column
|
||||||
|
expect_identical(
|
||||||
|
septic_patients[1:10,] %>%
|
||||||
|
left_join_microorganisms() %>%
|
||||||
|
select(genus) %>%
|
||||||
|
as.mo() %>%
|
||||||
|
as.character(),
|
||||||
|
c("ESC", "ESC", "STA", "STA", "STA",
|
||||||
|
"STA", "STA", "STA", "STA", "STA"))
|
||||||
|
|
||||||
|
# select with two columns
|
||||||
|
expect_identical(
|
||||||
|
septic_patients[1:10,] %>%
|
||||||
|
pull(mo),
|
||||||
|
septic_patients[1:10,] %>%
|
||||||
|
left_join_microorganisms() %>%
|
||||||
|
select(genus, species) %>%
|
||||||
|
as.mo() %>%
|
||||||
|
as.character())
|
||||||
|
|
||||||
|
# unknown results
|
||||||
|
expect_warning(as.mo(c("INVALID", "Yeah, unknown")))
|
||||||
|
|
||||||
|
# too many columns
|
||||||
|
expect_error(septic_patients %>% select(1:3) %>% as.mo())
|
||||||
|
|
||||||
|
# print
|
||||||
|
expect_output(print(as.mo(c("ESCCOL", NA))))
|
||||||
|
|
||||||
|
# helper function
|
||||||
|
expect_identical(as.mo("ESCCOL"),
|
||||||
|
guess_mo("ESCCOL"))
|
||||||
|
|
||||||
|
# test pull
|
||||||
|
expect_equal(nrow(septic_patients %>% mutate(mo = as.mo(mo))),
|
||||||
|
2000)
|
||||||
|
|
||||||
|
# test data.frame
|
||||||
|
expect_equal(nrow(data.frame(test = as.mo("ESCCOL"))),
|
||||||
|
1)
|
||||||
|
|
||||||
|
# check empty values
|
||||||
|
expect_equal(as.character(suppressWarnings(as.mo(""))),
|
||||||
|
NA_character_)
|
||||||
|
|
||||||
|
})
|
|
@ -122,7 +122,7 @@ test_that("old rsi works", {
|
||||||
|
|
||||||
test_that("prediction of rsi works", {
|
test_that("prediction of rsi works", {
|
||||||
amox_R <- septic_patients %>%
|
amox_R <- septic_patients %>%
|
||||||
filter(bactid == "ESCCOL") %>%
|
filter(mo == "ESCCOL") %>%
|
||||||
rsi_predict(col_ab = "amox",
|
rsi_predict(col_ab = "amox",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
minimum = 10,
|
minimum = 10,
|
||||||
|
@ -131,37 +131,37 @@ test_that("prediction of rsi works", {
|
||||||
# amox resistance will increase according to data set `septic_patients`
|
# amox resistance will increase according to data set `septic_patients`
|
||||||
expect_true(amox_R[3] < amox_R[20])
|
expect_true(amox_R[3] < amox_R[20])
|
||||||
|
|
||||||
expect_output(rsi_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
|
expect_output(rsi_predict(tbl = filter(septic_patients, mo == "ESCCOL"),
|
||||||
model = "binomial",
|
model = "binomial",
|
||||||
col_ab = "amox",
|
col_ab = "amox",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
info = TRUE))
|
info = TRUE))
|
||||||
expect_output(rsi_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
|
expect_output(rsi_predict(tbl = filter(septic_patients, mo == "ESCCOL"),
|
||||||
model = "loglin",
|
model = "loglin",
|
||||||
col_ab = "amox",
|
col_ab = "amox",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
info = TRUE))
|
info = TRUE))
|
||||||
expect_output(rsi_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
|
expect_output(rsi_predict(tbl = filter(septic_patients, mo == "ESCCOL"),
|
||||||
model = "lin",
|
model = "lin",
|
||||||
col_ab = "amox",
|
col_ab = "amox",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
info = TRUE))
|
info = TRUE))
|
||||||
|
|
||||||
expect_error(rsi_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
|
expect_error(rsi_predict(tbl = filter(septic_patients, mo == "ESCCOL"),
|
||||||
model = "INVALID MODEL",
|
model = "INVALID MODEL",
|
||||||
col_ab = "amox",
|
col_ab = "amox",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
info = TRUE))
|
info = TRUE))
|
||||||
expect_error(rsi_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
|
expect_error(rsi_predict(tbl = filter(septic_patients, mo == "ESCCOL"),
|
||||||
col_ab = "NOT EXISTING COLUMN",
|
col_ab = "NOT EXISTING COLUMN",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
info = TRUE))
|
info = TRUE))
|
||||||
expect_error(rsi_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
|
expect_error(rsi_predict(tbl = filter(septic_patients, mo == "ESCCOL"),
|
||||||
col_ab = "amox",
|
col_ab = "amox",
|
||||||
col_date = "NOT EXISTING COLUMN",
|
col_date = "NOT EXISTING COLUMN",
|
||||||
info = TRUE))
|
info = TRUE))
|
||||||
# almost all E. coli are mero S in the Netherlands :)
|
# almost all E. coli are mero S in the Netherlands :)
|
||||||
expect_error(resistance_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
|
expect_error(resistance_predict(tbl = filter(septic_patients, mo == "ESCCOL"),
|
||||||
col_ab = "mero",
|
col_ab = "mero",
|
||||||
col_date = "date",
|
col_date = "date",
|
||||||
info = TRUE))
|
info = TRUE))
|
||||||
|
|
Loading…
Reference in New Issue