mirror of
https://github.com/msberends/AMR.git
synced 2024-12-27 10:06:12 +01:00
added prevalence column and alterted as.mo algorith to use it, added ab_name as alias
This commit is contained in:
parent
b0ca49d68d
commit
b792a2754e
@ -41,8 +41,8 @@ export(MDRO)
|
|||||||
export(MRGN)
|
export(MRGN)
|
||||||
export(ab_atc)
|
export(ab_atc)
|
||||||
export(ab_certe)
|
export(ab_certe)
|
||||||
|
export(ab_name)
|
||||||
export(ab_official)
|
export(ab_official)
|
||||||
export(ab_official_nl)
|
|
||||||
export(ab_property)
|
export(ab_property)
|
||||||
export(ab_tradenames)
|
export(ab_tradenames)
|
||||||
export(ab_trivial_nl)
|
export(ab_trivial_nl)
|
||||||
|
6
NEWS.md
6
NEWS.md
@ -37,7 +37,7 @@
|
|||||||
mo_fullname("S. group A") # when run on a on a Portuguese system
|
mo_fullname("S. group A") # when run on a on a Portuguese system
|
||||||
# [1] "Streptococcus grupo A"
|
# [1] "Streptococcus grupo A"
|
||||||
```
|
```
|
||||||
* Function `ab_property` and its aliases: `ab_official`, `ab_tradenames`, `ab_certe`, `ab_umcg`, `ab_official_nl` and `ab_trivial_nl`
|
* Function `ab_property` and its aliases: `ab_name`, `ab_tradenames`, `ab_certe`, `ab_umcg` and `ab_trivial_nl`
|
||||||
* Introduction to AMR as a vignette
|
* Introduction to AMR as a vignette
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
@ -47,7 +47,7 @@
|
|||||||
```r
|
```r
|
||||||
ab_official("Bactroban")
|
ab_official("Bactroban")
|
||||||
# [1] "Mupirocin"
|
# [1] "Mupirocin"
|
||||||
ab_official(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
|
ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
|
||||||
# [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin"
|
# [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin"
|
||||||
ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
|
ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
|
||||||
# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
|
# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
|
||||||
@ -56,7 +56,7 @@
|
|||||||
* Function `ratio` is now deprecated and will be removed in a future release, 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
|
||||||
* Small fix where *B. fragilis* would not be found in the `microorganisms.umcg` data set
|
* Small fix where *B. fragilis* would not be found in the `microorganisms.umcg` data set
|
||||||
* Fix for `is.rsi.eligible`, now ignores reading marks
|
* Added `prevalence` column to the `microorganisms` data set
|
||||||
* 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
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#' Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set, based on their ATC code. Get such a code with \code{\link{as.atc}}.
|
#' Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set, based on their ATC code. Get such a code with \code{\link{as.atc}}.
|
||||||
#' @param x a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}}
|
#' @param x a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}}
|
||||||
#' @param property one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"}
|
#' @param property one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"}
|
||||||
|
#' @param language language of the returned text, defaults to the systems language. Either one of \code{"en"} (English) or \code{"nl"} (Dutch).
|
||||||
#' @rdname ab_property
|
#' @rdname ab_property
|
||||||
#' @return A vector of values. In case of \code{ab_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names.
|
#' @return A vector of values. In case of \code{ab_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names.
|
||||||
#' @export
|
#' @export
|
||||||
@ -28,8 +29,8 @@
|
|||||||
#' @seealso \code{\link{antibiotics}}
|
#' @seealso \code{\link{antibiotics}}
|
||||||
#' @examples
|
#' @examples
|
||||||
#' ab_atc("amcl") # J01CR02
|
#' ab_atc("amcl") # J01CR02
|
||||||
#' ab_official("amcl") # Amoxicillin and beta-lactamase inhibitor
|
#' ab_name("amcl") # Amoxicillin and beta-lactamase inhibitor
|
||||||
#' ab_official_nl("amcl") # Amoxicilline met enzymremmer
|
#' ab_name("amcl", "nl") # Amoxicilline met enzymremmer
|
||||||
#' ab_trivial_nl("amcl") # Amoxicilline/clavulaanzuur
|
#' ab_trivial_nl("amcl") # Amoxicilline/clavulaanzuur
|
||||||
#' ab_certe("amcl") # amcl
|
#' ab_certe("amcl") # amcl
|
||||||
#' ab_umcg("amcl") # AMCL
|
#' ab_umcg("amcl") # AMCL
|
||||||
@ -56,15 +57,25 @@ ab_atc <- function(x) {
|
|||||||
|
|
||||||
#' @rdname ab_property
|
#' @rdname ab_property
|
||||||
#' @export
|
#' @export
|
||||||
ab_official <- function(x) {
|
ab_official <- function(x, language = NULL) {
|
||||||
|
|
||||||
|
if (is.null(language)) {
|
||||||
|
language <- Sys.locale()
|
||||||
|
} else {
|
||||||
|
language <- tolower(language[1])
|
||||||
|
}
|
||||||
|
if (language %in% c("en", "")) {
|
||||||
ab_property(x, "official")
|
ab_property(x, "official")
|
||||||
|
} else if (language == "nl") {
|
||||||
|
ab_property(x, "official_nl")
|
||||||
|
} else {
|
||||||
|
stop("Unsupported language: '", language, "' - use one of: 'en', 'nl'", call. = FALSE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname ab_property
|
#' @rdname ab_property
|
||||||
#' @export
|
#' @export
|
||||||
ab_official_nl <- function(x) {
|
ab_name <- ab_official
|
||||||
ab_property(x, "official_nl")
|
|
||||||
}
|
|
||||||
|
|
||||||
#' @rdname ab_property
|
#' @rdname ab_property
|
||||||
#' @export
|
#' @export
|
||||||
|
5
R/data.R
5
R/data.R
@ -122,8 +122,8 @@
|
|||||||
|
|
||||||
#' Data set with human pathogenic microorganisms
|
#' Data set with human pathogenic microorganisms
|
||||||
#'
|
#'
|
||||||
#' A data set containing 2,630 (potential) human pathogenic microorganisms. MO codes can be looked up using \code{\link{guess_mo}}.
|
#' A data set containing (potential) human pathogenic microorganisms. MO codes can be looked up using \code{\link{guess_mo}}.
|
||||||
#' @format A \code{\link{tibble}} with 2,630 observations and 10 variables:
|
#' @format A \code{\link{tibble}} with 2,642 observations and 11 variables:
|
||||||
#' \describe{
|
#' \describe{
|
||||||
#' \item{\code{mo}}{ID of microorganism}
|
#' \item{\code{mo}}{ID of microorganism}
|
||||||
#' \item{\code{bactsys}}{Bactsyscode of microorganism}
|
#' \item{\code{bactsys}}{Bactsyscode of microorganism}
|
||||||
@ -135,6 +135,7 @@
|
|||||||
#' \item{\code{aerobic}}{Logical whether bacteria is aerobic}
|
#' \item{\code{aerobic}}{Logical whether bacteria is aerobic}
|
||||||
#' \item{\code{type}}{Type of microorganism, like \code{"Bacteria"} and \code{"Fungus/yeast"}}
|
#' \item{\code{type}}{Type of microorganism, like \code{"Bacteria"} and \code{"Fungus/yeast"}}
|
||||||
#' \item{\code{gramstain}}{Gram of microorganism, like \code{"Negative rods"}}
|
#' \item{\code{gramstain}}{Gram of microorganism, like \code{"Negative rods"}}
|
||||||
|
#' \item{\code{prevalence}}{A rounded integer based on prevalence of the microorganism. Used internally by \code{\link{as.mo}}, otherwise quite meaningless.}
|
||||||
#' }
|
#' }
|
||||||
# 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,]
|
||||||
|
@ -47,6 +47,7 @@ globalVariables(c(".",
|
|||||||
"Pasted",
|
"Pasted",
|
||||||
"patient_id",
|
"patient_id",
|
||||||
"Percentage",
|
"Percentage",
|
||||||
|
"prevalence",
|
||||||
"R",
|
"R",
|
||||||
"real_first_isolate",
|
"real_first_isolate",
|
||||||
"S",
|
"S",
|
||||||
|
14
R/misc.R
14
R/misc.R
@ -155,6 +155,20 @@ tbl_parse_guess <- function(tbl,
|
|||||||
tbl
|
tbl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' @importFrom dplyr case_when
|
||||||
|
Sys.locale <- function() {
|
||||||
|
sys <- base::Sys.getlocale()
|
||||||
|
case_when(
|
||||||
|
sys %like% '(Deutsch|German|de_)' ~ "de",
|
||||||
|
sys %like% '(Nederlands|Dutch|nl_)' ~ "nl",
|
||||||
|
sys %like% '(Espa.ol|Spanish|es_)' ~ "es",
|
||||||
|
sys %like% '(Fran.ais|French|fr_)' ~ "fr",
|
||||||
|
sys %like% '(Portugu.s|Portuguese|pt_)' ~ "pt",
|
||||||
|
sys %like% '(Italiano|Italian|it_)' ~ "it",
|
||||||
|
TRUE ~ "en"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
# transforms date format like "dddd d mmmm yyyy" to "%A %e %B %Y"
|
# transforms date format like "dddd d mmmm yyyy" to "%A %e %B %Y"
|
||||||
date_generic <- function(format) {
|
date_generic <- function(format) {
|
||||||
if (!grepl('%', format, fixed = TRUE)) {
|
if (!grepl('%', format, fixed = TRUE)) {
|
||||||
|
49
R/mo.R
49
R/mo.R
@ -33,12 +33,12 @@
|
|||||||
#'
|
#'
|
||||||
#' Use the \code{\link{mo_property}} functions to get properties based on the returned code, see Examples.
|
#' Use the \code{\link{mo_property}} functions to get properties based on the returned code, see Examples.
|
||||||
#'
|
#'
|
||||||
#' Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. These are:
|
#' Thus function uses Artificial Intelligence (AI) to help getting more logical results, based on type of input and known prevalence of human pathogens. For example:
|
||||||
#' \itemize{
|
#' \itemize{
|
||||||
#' \item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
|
#' \item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
|
||||||
#' \item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae}}
|
#' \item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae} for the same reason}
|
||||||
#' \item{Something like \code{"p aer"} will return the ID of \emph{Pseudomonas aeruginosa} and not \emph{Pasteurella aerogenes}}
|
#' \item{Something like \code{"p aer"} will return the ID of \emph{Pseudomonas aeruginosa} and not \emph{Pasteurella aerogenes}}
|
||||||
#' \item{Something like \code{"stau"} or \code{"staaur"} will return the ID of \emph{Staphylococcus aureus} and not \emph{Staphylococcus auricularis}}
|
#' \item{Something like \code{"stau"} or \code{"S aur"} will return the ID of \emph{Staphylococcus aureus} and not \emph{Staphylococcus auricularis}}
|
||||||
#' }
|
#' }
|
||||||
#' Moreover, this function also supports ID's based on only Gram stain, when the species is not known. \cr
|
#' Moreover, this function also supports ID's based on only Gram stain, when the species is not known. \cr
|
||||||
#' For example, \code{"Gram negative rods"} and \code{"GNR"} will both return the ID of a Gram negative rod: \code{GNR}.
|
#' For example, \code{"Gram negative rods"} and \code{"GNR"} will both return the ID of a Gram negative rod: \code{GNR}.
|
||||||
@ -47,7 +47,7 @@
|
|||||||
#'
|
#'
|
||||||
#' [2] Lancefield RC \strong{A serological differentiation of human and other groups of hemolytic streptococci}. 1933. J Exp Med. 57(4): 571–95. \url{https://dx.doi.org/10.1084/jem.57.4.571}
|
#' [2] Lancefield RC \strong{A serological differentiation of human and other groups of hemolytic streptococci}. 1933. J Exp Med. 57(4): 571–95. \url{https://dx.doi.org/10.1084/jem.57.4.571}
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>% pull left_join
|
#' @importFrom dplyr %>% pull left_join arrange
|
||||||
#' @return Character (vector) with class \code{"mo"}. 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
|
||||||
@ -118,7 +118,10 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MOs <- AMR::microorganisms %>% filter(!mo %like% '^_FAM') # dont search in those
|
MOs <- AMR::microorganisms %>%
|
||||||
|
arrange(prevalence) %>% # more expected result on multiple findings
|
||||||
|
filter(!mo %like% '^_FAM', # don't search in those
|
||||||
|
(nchar(mo) > 3 | mo %in% c("GNR", "GPR", "GNC", "GPC"))) # no genera
|
||||||
failures <- character(0)
|
failures <- character(0)
|
||||||
x_input <- x
|
x_input <- x
|
||||||
|
|
||||||
@ -144,11 +147,11 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
|||||||
x_withspaces_start <- paste0('^', x_withspaces)
|
x_withspaces_start <- paste0('^', x_withspaces)
|
||||||
x_withspaces <- paste0('^', x_withspaces, '$')
|
x_withspaces <- paste0('^', x_withspaces, '$')
|
||||||
|
|
||||||
# print(x)
|
# cat(paste0('x "', x, '"\n'))
|
||||||
# print(x_withspaces_all)
|
# cat(paste0('x_withspaces_all "', x_withspaces_all, '"\n'))
|
||||||
# print(x_withspaces_start)
|
# cat(paste0('x_withspaces_start "', x_withspaces_start, '"\n'))
|
||||||
# print(x_withspaces)
|
# cat(paste0('x_withspaces "', x_withspaces, '"\n'))
|
||||||
# print(x_backup)
|
# cat(paste0('x_backup "', x_backup, '"\n'))
|
||||||
|
|
||||||
for (i in 1:length(x)) {
|
for (i in 1:length(x)) {
|
||||||
if (identical(x_trimmed[i], "")) {
|
if (identical(x_trimmed[i], "")) {
|
||||||
@ -201,7 +204,7 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
|||||||
next
|
next
|
||||||
}
|
}
|
||||||
if (toupper(x_trimmed[i]) == 'VRE') {
|
if (toupper(x_trimmed[i]) == 'VRE') {
|
||||||
x[i] <- 'ENC'
|
x[i] <- 'ENCSPP'
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
if (toupper(x_trimmed[i]) == 'MRPA') {
|
if (toupper(x_trimmed[i]) == 'MRPA') {
|
||||||
@ -234,6 +237,13 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
|||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# try any match with genus, keeping spaces, not ending with $ ----
|
||||||
|
found <- MOs[which(MOs$genus %like% x_withspaces_start[i] & MOs$mo %like% 'SPP$'),]$mo
|
||||||
|
if (length(found) > 0) {
|
||||||
|
x[i] <- found[1L]
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
# try any match keeping spaces, not ending with $ ----
|
# try any match keeping spaces, not ending with $ ----
|
||||||
found <- MOs[which(MOs$fullname %like% x_withspaces_start[i]),]$mo
|
found <- MOs[which(MOs$fullname %like% x_withspaces_start[i]),]$mo
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
@ -297,19 +307,6 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# avoid detection of Staphylococcus auricularis in case of S. aureus ----
|
|
||||||
x[x == "STAAUC" & toupper(x_backup) != "STAAUC" & !x_backup %like% 'auri'] <- "STAAUR"
|
|
||||||
# avoid detection of Entamoeba coli in case of E. coli ----
|
|
||||||
x[x == "ENMCOL" & toupper(x_backup) != "ENMCOL" & !x_backup %like% '^ent?'] <- "ESCCOL"
|
|
||||||
# avoid detection of Haematobacter influenzae in case of H. influenzae ----
|
|
||||||
x[x == "HABINF" & toupper(x_backup) != "HABINF" & !x_backup %like% '^haema'] <- "HAEINF"
|
|
||||||
# avoid detection of Pasteurella aerogenes in case of P. aeruginosa ----
|
|
||||||
x[x == "PASAER" & toupper(x_backup) != "PASAER" & !(x_backup %like% '^pas?' | x_backup %like% 'aero')] <- "PSEAER"
|
|
||||||
# avoid detection of Legionella non pneumophila in case of Legionella pneumophila ----
|
|
||||||
x[x == "LEGNON" & toupper(x_backup) != "LEGNON" & !x_backup %like% 'non'] <- "LEGPNE"
|
|
||||||
# avoid detection of Streptobacillus in case of Streptococcus ----
|
|
||||||
x[x == "STB" & toupper(x_backup) != "STB" & !x_backup %like% 'streptob'] <- "STC"
|
|
||||||
|
|
||||||
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 ", length(failures) , " values could not be coerced to a valid mo: ",
|
warning("These ", length(failures) , " values could not be coerced to a valid mo: ",
|
||||||
@ -376,7 +373,9 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) {
|
|||||||
|
|
||||||
# for the returned genera without species, add species ----
|
# for the returned genera without species, add species ----
|
||||||
# like "ESC" -> "ESCSPP", but only where the input contained it
|
# like "ESC" -> "ESCSPP", but only where the input contained it
|
||||||
indices <- unique(x_input) %like% "[A-Z]{3}SPP" & !x %like% "[A-Z]{3}SPP"
|
indices <- nchar(unique(x)) == 3 & !x %like% "[A-Z]{3}SPP" & !x %in% c("GNR", "GPR", "GNC", "GPC",
|
||||||
|
"GNS", "GPS", "GNK", "GPK")
|
||||||
|
indices <- indices[!is.na(indices)]
|
||||||
x[indices] <- paste0(x[indices], 'SPP')
|
x[indices] <- paste0(x[indices], 'SPP')
|
||||||
|
|
||||||
# left join the found results to the original input values (x_input)
|
# left join the found results to the original input values (x_input)
|
||||||
|
@ -207,7 +207,7 @@ mo_property <- function(x, property = 'fullname', Becker = FALSE, Lancefield = F
|
|||||||
#' @importFrom dplyr %>% case_when
|
#' @importFrom dplyr %>% case_when
|
||||||
mo_translate <- function(x, language) {
|
mo_translate <- function(x, language) {
|
||||||
if (is.null(language)) {
|
if (is.null(language)) {
|
||||||
language <- mo_getlangcode()
|
language <- Sys.locale()
|
||||||
} else {
|
} else {
|
||||||
language <- tolower(language[1])
|
language <- tolower(language[1])
|
||||||
}
|
}
|
||||||
@ -350,17 +350,3 @@ mo_translate <- function(x, language) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @importFrom dplyr case_when
|
|
||||||
mo_getlangcode <- function() {
|
|
||||||
sys <- base::Sys.getlocale()
|
|
||||||
case_when(
|
|
||||||
sys %like% '(Deutsch|German|de_)' ~ "de",
|
|
||||||
sys %like% '(Nederlands|Dutch|nl_)' ~ "nl",
|
|
||||||
sys %like% '(Espa.ol|Spanish|es_)' ~ "es",
|
|
||||||
sys %like% '(Fran.ais|French|fr_)' ~ "fr",
|
|
||||||
sys %like% '(Portugu.s|Portuguese|pt_)' ~ "pt",
|
|
||||||
sys %like% '(Italiano|Italian|it_)' ~ "it",
|
|
||||||
TRUE ~ "en"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
@ -56,7 +56,7 @@ This `AMR` package basically does four important things:
|
|||||||
* 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 3,000 potential human pathogenic microorganisms (bacteria, fungi/yeasts and parasites). 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`. As they use `as.mo` internally, they also use artificial intelligence. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, French, Italian, Spanish and Portuguese. 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 3,000 potential human pathogenic microorganisms (bacteria, fungi/yeasts and parasites). 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`. As they use `as.mo` internally, they also use artificial intelligence. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, French, Italian, Spanish and Portuguese. 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.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.
|
* 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_name` 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_name("Fluclox")`, `ab_name("Floxapen")` and `ab_name("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.
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ antibiotics # A tibble: 423 x 18
|
|||||||
|
|
||||||
# Dataset with bacteria codes and properties like gram stain and
|
# Dataset with bacteria codes and properties like gram stain and
|
||||||
# aerobic/anaerobic
|
# aerobic/anaerobic
|
||||||
microorganisms # A tibble: 2,630 x 10
|
microorganisms # A tibble: 2,642 x 11
|
||||||
```
|
```
|
||||||
|
|
||||||
## Copyright
|
## Copyright
|
||||||
|
Binary file not shown.
@ -4,7 +4,7 @@
|
|||||||
\alias{ab_property}
|
\alias{ab_property}
|
||||||
\alias{ab_atc}
|
\alias{ab_atc}
|
||||||
\alias{ab_official}
|
\alias{ab_official}
|
||||||
\alias{ab_official_nl}
|
\alias{ab_name}
|
||||||
\alias{ab_trivial_nl}
|
\alias{ab_trivial_nl}
|
||||||
\alias{ab_certe}
|
\alias{ab_certe}
|
||||||
\alias{ab_umcg}
|
\alias{ab_umcg}
|
||||||
@ -15,9 +15,9 @@ ab_property(x, property = "official")
|
|||||||
|
|
||||||
ab_atc(x)
|
ab_atc(x)
|
||||||
|
|
||||||
ab_official(x)
|
ab_official(x, language = NULL)
|
||||||
|
|
||||||
ab_official_nl(x)
|
ab_name(x, language = NULL)
|
||||||
|
|
||||||
ab_trivial_nl(x)
|
ab_trivial_nl(x)
|
||||||
|
|
||||||
@ -31,6 +31,8 @@ ab_tradenames(x)
|
|||||||
\item{x}{a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}}}
|
\item{x}{a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}}}
|
||||||
|
|
||||||
\item{property}{one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"}}
|
\item{property}{one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"}}
|
||||||
|
|
||||||
|
\item{language}{language of the returned text, defaults to the systems language. Either one of \code{"en"} (English) or \code{"nl"} (Dutch).}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
A vector of values. In case of \code{ab_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names.
|
A vector of values. In case of \code{ab_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names.
|
||||||
@ -40,8 +42,8 @@ Use these functions to return a specific property of an antibiotic from the \cod
|
|||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
ab_atc("amcl") # J01CR02
|
ab_atc("amcl") # J01CR02
|
||||||
ab_official("amcl") # Amoxicillin and beta-lactamase inhibitor
|
ab_name("amcl") # Amoxicillin and beta-lactamase inhibitor
|
||||||
ab_official_nl("amcl") # Amoxicilline met enzymremmer
|
ab_name("amcl", "nl") # Amoxicilline met enzymremmer
|
||||||
ab_trivial_nl("amcl") # Amoxicilline/clavulaanzuur
|
ab_trivial_nl("amcl") # Amoxicilline/clavulaanzuur
|
||||||
ab_certe("amcl") # amcl
|
ab_certe("amcl") # amcl
|
||||||
ab_umcg("amcl") # AMCL
|
ab_umcg("amcl") # AMCL
|
||||||
|
@ -40,12 +40,12 @@ Use this function to determine a valid ID based on a genus (and species). Determ
|
|||||||
|
|
||||||
Use the \code{\link{mo_property}} functions to get properties based on the returned code, see Examples.
|
Use the \code{\link{mo_property}} functions to get properties based on the returned code, see Examples.
|
||||||
|
|
||||||
Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. These are:
|
Thus function uses Artificial Intelligence (AI) to help getting more logical results, based on type of input and known prevalence of human pathogens. For example:
|
||||||
\itemize{
|
\itemize{
|
||||||
\item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
|
\item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
|
||||||
\item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae}}
|
\item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae} for the same reason}
|
||||||
\item{Something like \code{"p aer"} will return the ID of \emph{Pseudomonas aeruginosa} and not \emph{Pasteurella aerogenes}}
|
\item{Something like \code{"p aer"} will return the ID of \emph{Pseudomonas aeruginosa} and not \emph{Pasteurella aerogenes}}
|
||||||
\item{Something like \code{"stau"} or \code{"staaur"} will return the ID of \emph{Staphylococcus aureus} and not \emph{Staphylococcus auricularis}}
|
\item{Something like \code{"stau"} or \code{"S aur"} will return the ID of \emph{Staphylococcus aureus} and not \emph{Staphylococcus auricularis}}
|
||||||
}
|
}
|
||||||
Moreover, this function also supports ID's based on only Gram stain, when the species is not known. \cr
|
Moreover, this function also supports ID's based on only Gram stain, when the species is not known. \cr
|
||||||
For example, \code{"Gram negative rods"} and \code{"GNR"} will both return the ID of a Gram negative rod: \code{GNR}.
|
For example, \code{"Gram negative rods"} and \code{"GNR"} will both return the ID of a Gram negative rod: \code{GNR}.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
\name{microorganisms}
|
\name{microorganisms}
|
||||||
\alias{microorganisms}
|
\alias{microorganisms}
|
||||||
\title{Data set with human pathogenic microorganisms}
|
\title{Data set with human pathogenic microorganisms}
|
||||||
\format{A \code{\link{tibble}} with 2,630 observations and 10 variables:
|
\format{A \code{\link{tibble}} with 2,642 observations and 11 variables:
|
||||||
\describe{
|
\describe{
|
||||||
\item{\code{mo}}{ID of microorganism}
|
\item{\code{mo}}{ID of microorganism}
|
||||||
\item{\code{bactsys}}{Bactsyscode of microorganism}
|
\item{\code{bactsys}}{Bactsyscode of microorganism}
|
||||||
@ -16,12 +16,13 @@
|
|||||||
\item{\code{aerobic}}{Logical whether bacteria is aerobic}
|
\item{\code{aerobic}}{Logical whether bacteria is aerobic}
|
||||||
\item{\code{type}}{Type of microorganism, like \code{"Bacteria"} and \code{"Fungus/yeast"}}
|
\item{\code{type}}{Type of microorganism, like \code{"Bacteria"} and \code{"Fungus/yeast"}}
|
||||||
\item{\code{gramstain}}{Gram of microorganism, like \code{"Negative rods"}}
|
\item{\code{gramstain}}{Gram of microorganism, like \code{"Negative rods"}}
|
||||||
|
\item{\code{prevalence}}{A rounded integer based on prevalence of the microorganism. Used internally by \code{\link{as.mo}}, otherwise quite meaningless.}
|
||||||
}}
|
}}
|
||||||
\usage{
|
\usage{
|
||||||
microorganisms
|
microorganisms
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
A data set containing 2,630 (potential) human pathogenic microorganisms. MO codes can be looked up using \code{\link{guess_mo}}.
|
A data set containing (potential) human pathogenic microorganisms. MO codes can be looked up using \code{\link{guess_mo}}.
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
\code{\link{guess_mo}} \code{\link{antibiotics}} \code{\link{microorganisms.umcg}}
|
\code{\link{guess_mo}} \code{\link{antibiotics}} \code{\link{microorganisms.umcg}}
|
||||||
|
@ -2,8 +2,9 @@ context("ab_property.R")
|
|||||||
|
|
||||||
test_that("ab_property works", {
|
test_that("ab_property works", {
|
||||||
expect_equal(ab_certe("amox"), "amox")
|
expect_equal(ab_certe("amox"), "amox")
|
||||||
expect_equal(ab_official("amox"), "Amoxicillin")
|
expect_equal(ab_name("amox", language = "en"), "Amoxicillin")
|
||||||
expect_equal(ab_official_nl("amox"), "Amoxicilline")
|
expect_equal(ab_name("amox", language = "nl"), "Amoxicilline")
|
||||||
|
expect_equal(ab_official("amox", language = "en"), "Amoxicillin")
|
||||||
expect_equal(ab_trivial_nl("amox"), "Amoxicilline")
|
expect_equal(ab_trivial_nl("amox"), "Amoxicilline")
|
||||||
expect_equal(ab_umcg("amox"), "AMOX")
|
expect_equal(ab_umcg("amox"), "AMOX")
|
||||||
expect_equal(class(ab_tradenames("amox")), "character")
|
expect_equal(class(ab_tradenames("amox")), "character")
|
||||||
@ -11,4 +12,6 @@ test_that("ab_property works", {
|
|||||||
expect_equal(ab_atc("amox"), as.character(as.atc("amox")))
|
expect_equal(ab_atc("amox"), as.character(as.atc("amox")))
|
||||||
|
|
||||||
expect_error(ab_property("amox", "invalid property"))
|
expect_error(ab_property("amox", "invalid property"))
|
||||||
|
expect_error(ab_name("amox", language = "INVALID"))
|
||||||
|
expect_output(print(ab_name("amox", language = NULL)))
|
||||||
})
|
})
|
||||||
|
@ -3,7 +3,7 @@ context("mo.R")
|
|||||||
test_that("as.mo works", {
|
test_that("as.mo works", {
|
||||||
|
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
MOs <- AMR::microorganisms %>% filter(!is.na(mo))
|
MOs <- AMR::microorganisms %>% filter(!is.na(mo), nchar(mo) > 3)
|
||||||
expect_identical(as.character(MOs$mo), as.character(as.mo(MOs$mo)))
|
expect_identical(as.character(MOs$mo), as.character(as.mo(MOs$mo)))
|
||||||
|
|
||||||
expect_identical(
|
expect_identical(
|
||||||
@ -12,18 +12,20 @@ test_that("as.mo works", {
|
|||||||
|
|
||||||
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 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("Escherichia species")), "ESCSPP")
|
||||||
|
expect_equal(as.character(as.mo("Escherichia")), "ESCSPP")
|
||||||
expect_equal(as.character(as.mo(" ESCCOL ")), "ESCCOL")
|
expect_equal(as.character(as.mo(" ESCCOL ")), "ESCCOL")
|
||||||
|
expect_equal(as.character(as.mo("coli")), "ESCCOL") # not Campylobacter
|
||||||
expect_equal(as.character(as.mo("klpn")), "KLEPNE")
|
expect_equal(as.character(as.mo("klpn")), "KLEPNE")
|
||||||
expect_equal(as.character(as.mo("Klebsiella")), "KLE")
|
expect_equal(as.character(as.mo("Klebsiella")), "KLESPP")
|
||||||
expect_equal(as.character(as.mo("K. pneu rhino")), "KLEPNERH") # K. pneumoniae subspp. rhinoscleromatis
|
expect_equal(as.character(as.mo("K. pneu rhino")), "KLEPNERH") # K. pneumoniae subspp. rhinoscleromatis
|
||||||
expect_equal(as.character(as.mo("Bartonella")), "BAR")
|
expect_equal(as.character(as.mo("Bartonella")), "BARSPP")
|
||||||
expect_equal(as.character(as.mo("C. difficile")), "CLODIF")
|
expect_equal(as.character(as.mo("C. difficile")), "CLODIF")
|
||||||
expect_equal(as.character(as.mo("L. pneumophila")), "LEGPNE")
|
expect_equal(as.character(as.mo("L. pneumophila")), "LEGPNE")
|
||||||
expect_equal(as.character(as.mo("L. non pneumophila")), "LEGNON")
|
expect_equal(as.character(as.mo("L. non pneumophila")), "LEGNON")
|
||||||
expect_equal(as.character(as.mo("S. beta-haemolytic")), "STCHAE")
|
expect_equal(as.character(as.mo("S. beta-haemolytic")), "STCHAE")
|
||||||
expect_equal(as.character(as.mo("Strepto")), "STC") # not Streptobacillus
|
expect_equal(as.character(as.mo("Strepto")), "STCSPP")
|
||||||
expect_equal(as.character(as.mo("Streptococcus")), "STC") # not Peptostreptoccus
|
expect_equal(as.character(as.mo("Streptococcus")), "STCSPP") # not Peptostreptoccus
|
||||||
|
|
||||||
expect_equal(as.character(as.mo(c("GAS", "GBS"))), c("STCGRA", "STCGRB"))
|
expect_equal(as.character(as.mo(c("GAS", "GBS"))), c("STCGRA", "STCGRB"))
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ test_that("as.mo works", {
|
|||||||
expect_equal(as.character(as.mo("bctfgr")), "BACFRA")
|
expect_equal(as.character(as.mo("bctfgr")), "BACFRA")
|
||||||
|
|
||||||
expect_equal(as.character(as.mo("MRSE")), "STAEPI")
|
expect_equal(as.character(as.mo("MRSE")), "STAEPI")
|
||||||
expect_equal(as.character(as.mo("VRE")), "ENC")
|
expect_equal(as.character(as.mo("VRE")), "ENCSPP")
|
||||||
expect_equal(as.character(as.mo("MRPA")), "PSEAER")
|
expect_equal(as.character(as.mo("MRPA")), "PSEAER")
|
||||||
expect_equal(as.character(as.mo("PISP")), "STCPNE")
|
expect_equal(as.character(as.mo("PISP")), "STCPNE")
|
||||||
expect_equal(as.character(as.mo("PRSP")), "STCPNE")
|
expect_equal(as.character(as.mo("PRSP")), "STCPNE")
|
||||||
@ -67,8 +69,9 @@ test_that("as.mo works", {
|
|||||||
expect_identical(as.character(guess_mo("S. epidermidis", Becker = FALSE)), "STAEPI")
|
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("S. epidermidis", Becker = TRUE)), "STACNS")
|
||||||
expect_identical(as.character(guess_mo("STAEPI", 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 = FALSE)), "STCINT") # Strep (!) intermedius
|
||||||
expect_identical(as.character(guess_mo("S. intermedius", Becker = TRUE)), "STACPS")
|
expect_identical(as.character(guess_mo("Sta intermedius",Becker = FALSE)), "STAINT")
|
||||||
|
expect_identical(as.character(guess_mo("Sta intermedius",Becker = TRUE)), "STACPS")
|
||||||
expect_identical(as.character(guess_mo("STAINT", Becker = TRUE)), "STACPS")
|
expect_identical(as.character(guess_mo("STAINT", Becker = TRUE)), "STACPS")
|
||||||
# aureus must only be influenced if Becker = "all"
|
# 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 = FALSE)), "STAAUR")
|
||||||
@ -103,8 +106,9 @@ test_that("as.mo works", {
|
|||||||
select(genus) %>%
|
select(genus) %>%
|
||||||
as.mo() %>%
|
as.mo() %>%
|
||||||
as.character(),
|
as.character(),
|
||||||
c("ESC", "ESC", "STA", "STA", "STA",
|
paste0(c("ESC", "ESC", "STA", "STA", "STA",
|
||||||
"STA", "STA", "STA", "STA", "STA"))
|
"STA", "STA", "STA", "STA", "STA"),
|
||||||
|
"SPP"))
|
||||||
|
|
||||||
# select with two columns
|
# select with two columns
|
||||||
expect_identical(
|
expect_identical(
|
||||||
|
@ -18,7 +18,7 @@ test_that("mo_property works", {
|
|||||||
|
|
||||||
# test integrity
|
# test integrity
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
MOs <- AMR::microorganisms %>% filter(!is.na(mo))
|
MOs <- AMR::microorganisms %>% filter(!is.na(mo), nchar(mo) > 3)
|
||||||
expect_identical(MOs$fullname, mo_fullname(MOs$fullname, language = "en"))
|
expect_identical(MOs$fullname, mo_fullname(MOs$fullname, language = "en"))
|
||||||
|
|
||||||
mo_clean <- MOs$mo
|
mo_clean <- MOs$mo
|
||||||
|
Loading…
Reference in New Issue
Block a user