mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 05:26:12 +01:00
(v0.7.1.9075) new microorganism codes
This commit is contained in:
parent
f553a08a7b
commit
e2aa4f996b
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 0.7.1.9074
|
||||
Date: 2019-09-16
|
||||
Version: 0.7.1.9075
|
||||
Date: 2019-09-18
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
@ -15,6 +15,8 @@ Authors@R: c(
|
||||
family = "Albers", given = c("Casper", "J."), email = "c.j.albers@rug.nl", comment = c(ORCID = "0000-0002-9213-6743")),
|
||||
person(role = c("aut", "ths"),
|
||||
family = "Glasner", given = "Corinna", email = "c.glasner@umcg.nl", comment = c(ORCID = "0000-0003-1241-1328")),
|
||||
person(role = "ctb",
|
||||
family = "Fonville", given = c("Judith", "M."), email = "j.fonville@pamm.nl"),
|
||||
person(role = "ctb",
|
||||
family = "Hassing", given = c("Erwin", "E.", "A."), email = "e.hassing@certe.nl"),
|
||||
person(role = "ctb",
|
||||
|
9
NEWS.md
9
NEWS.md
@ -1,5 +1,5 @@
|
||||
# AMR 0.7.1.9074
|
||||
<small>Last updated: 16-Sep-2019</small>
|
||||
# AMR 0.7.1.9075
|
||||
<small>Last updated: 18-Sep-2019</small>
|
||||
|
||||
### Breaking
|
||||
* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new parameter `include_unknown`:
|
||||
@ -72,7 +72,7 @@
|
||||
```
|
||||
|
||||
### Changed
|
||||
* Many algorithm improvements for `as.mo()` (of which some led to additions to the `microorganisms` data set):
|
||||
* Many algorithm improvements for `as.mo()` (of which some led to additions to the `microorganisms` data set). Many thanks to all contributors that helped improving the algorithms.
|
||||
* Self-learning algorithm - the function now gains experience from previously determined microorganism IDs and learns from it (yielding 80-95% speed improvement for any guess after the first try)
|
||||
* Big improvement for misspelled input
|
||||
* These new trivial names known to the field are now understood: meningococcus, gonococcus, pneumococcus
|
||||
@ -80,6 +80,7 @@
|
||||
* Added support for Viridans Group Streptococci (VGS) and Milleri Group Streptococci (MGS)
|
||||
* Added support for 5,000 new fungi
|
||||
* Added support for unknown yeasts and fungi
|
||||
* Changed most microorganism IDs to improve readability. **IMPORTANT:** Because of these changes, the microorganism IDs have been changed to a slightly different format. Old microorganism IDs are still supported, but support will be dropped in a future version. Use `as.mo()` on your old codes to transform them to the new format.
|
||||
* Renamed data set `septic_patients` to `example_isolates`
|
||||
* Function `eucast_rules()`:
|
||||
* Fixed a bug for *Yersinia pseudotuberculosis*
|
||||
@ -105,7 +106,7 @@
|
||||
* Fix for `key_antibiotics()` on foreign systems
|
||||
|
||||
#### Other
|
||||
* Added Prof Dr Casper Albers as doctoral advisor and Dr Bart Meijer, Dr Dennis Souverein and Annick Lenglet as contributors
|
||||
* Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors
|
||||
|
||||
# AMR 0.7.1
|
||||
|
||||
|
18
R/data.R
18
R/data.R
@ -55,7 +55,7 @@
|
||||
#'
|
||||
#' A data set containing the microbial taxonomy of six kingdoms from the Catalogue of Life. MO codes can be looked up using \code{\link{as.mo}}.
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @format A \code{\link{data.frame}} with 69,855 observations and 16 variables:
|
||||
#' @format A \code{\link{data.frame}} with 69,460 observations and 16 variables:
|
||||
#' \describe{
|
||||
#' \item{\code{mo}}{ID of microorganism as used by this package}
|
||||
#' \item{\code{col_id}}{Catalogue of Life ID}
|
||||
@ -73,7 +73,7 @@
|
||||
#' \item{2 entries of \emph{Staphylococcus} (coagulase-negative [CoNS] and coagulase-positive [CoPS])}
|
||||
#' \item{3 entries of \emph{Trichomonas} (\emph{Trichomonas vaginalis}, and its family and genus)}
|
||||
#' \item{5 other 'undefined' entries (unknown, unknown Gram negatives, unknown Gram positives, unknown yeast and unknown fungus)}
|
||||
#' \item{8,970 species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) that are not in the Catalogue of Life}
|
||||
#' \item{22,654 species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) overwriting records from the Catalogue of Life, since the DSMZ contain the latest taxonomic information based on recent publications}
|
||||
#' }
|
||||
#' @section About the records from DSMZ (see source):
|
||||
#' Names of prokaryotes are defined as being validly published by the International Code of Nomenclature of Bacteria. Validly published are all names which are included in the Approved Lists of Bacterial Names and the names subsequently published in the International Journal of Systematic Bacteriology (IJSB) and, from January 2000, in the International Journal of Systematic and Evolutionary Microbiology (IJSEM) as original articles or in the validation lists.
|
||||
@ -98,7 +98,7 @@ catalogue_of_life <- list(
|
||||
#'
|
||||
#' A data set containing old (previously valid or accepted) taxonomic names according to the Catalogue of Life. This data set is used internally by \code{\link{as.mo}}.
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @format A \code{\link{data.frame}} with 22,932 observations and 4 variables:
|
||||
#' @format A \code{\link{data.frame}} with 24,246 observations and 4 variables:
|
||||
#' \describe{
|
||||
#' \item{\code{col_id}}{Catalogue of Life ID that was originally given}
|
||||
#' \item{\code{col_id_new}}{New Catalogue of Life ID that responds to an entry in the \code{\link{microorganisms}} data set}
|
||||
@ -110,12 +110,12 @@ catalogue_of_life <- list(
|
||||
#' @seealso \code{\link{as.mo}} \code{\link{mo_property}} \code{\link{microorganisms}}
|
||||
"microorganisms.old"
|
||||
|
||||
#' Translation table for microorganism codes
|
||||
#' Translation table for common microorganism codes
|
||||
#'
|
||||
#' A data set containing commonly used codes for microorganisms, from laboratory systems and WHONET. Define your own with \code{\link{set_mo_source}}.
|
||||
#' @format A \code{\link{data.frame}} with 4,965 observations and 2 variables:
|
||||
#' @format A \code{\link{data.frame}} with 4,927 observations and 2 variables:
|
||||
#' \describe{
|
||||
#' \item{\code{certe}}{Commonly used code of a microorganism}
|
||||
#' \item{\code{code}}{Commonly used code of a microorganism}
|
||||
#' \item{\code{mo}}{ID of the microorganism in the \code{\link{microorganisms}} data set}
|
||||
#' }
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
@ -123,9 +123,9 @@ catalogue_of_life <- list(
|
||||
#' @seealso \code{\link{as.mo}} \code{\link{microorganisms}}
|
||||
"microorganisms.codes"
|
||||
|
||||
#' Data set with 2,000 blood culture isolates from septic patients
|
||||
#' Data set with 2,000 blood culture isolates
|
||||
#'
|
||||
#' An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This \code{data.frame} can be used to practice AMR analysis. For examples, please read \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{the tutorial on our website}.
|
||||
#' An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found 4 different hospitals in the Netherlands, between 2001 and 2017. This \code{data.frame} can be used to practice AMR analysis. For examples, please read \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{the tutorial on our website}.
|
||||
#' @format A \code{\link{data.frame}} with 2,000 observations and 49 variables:
|
||||
#' \describe{
|
||||
#' \item{\code{date}}{date of receipt at the laboratory}
|
||||
@ -137,7 +137,7 @@ catalogue_of_life <- list(
|
||||
#' \item{\code{gender}}{gender of the patient}
|
||||
#' \item{\code{patient_id}}{ID of the patient, first 10 characters of an SHA hash containing irretrievable information}
|
||||
#' \item{\code{mo}}{ID of microorganism created with \code{\link{as.mo}}, see also \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{ab_name}}}
|
||||
#' \item{\code{PEN:RIF}}{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{ab_name}}}
|
||||
#' }
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
"example_isolates"
|
||||
|
@ -67,6 +67,7 @@ globalVariables(c(".",
|
||||
"observations",
|
||||
"observed",
|
||||
"old",
|
||||
"old_name",
|
||||
"other_pat_or_mo",
|
||||
"package_version",
|
||||
"patient_id",
|
||||
|
179
R/mo.R
179
R/mo.R
@ -29,7 +29,7 @@
|
||||
#' @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 [3]. These \emph{Streptococci} will be categorised in their first group, e.g. \emph{Streptococcus dysgalactiae} will be group C, although officially it was also categorised into groups G and L.
|
||||
#'
|
||||
#' This excludes \emph{Enterococci} at default (who are in group D), use \code{Lancefield = "all"} to also categorise all \emph{Enterococci} as group D.
|
||||
#' @param allow_uncertain a number between 0 (or "none") and 3 (or "all"), or TRUE (= 2) or FALSE (= 0) to indicate whether the input should be checked for less possible results, see Details
|
||||
#' @param allow_uncertain a number between 0 (or "none") and 3 (or "all"), or TRUE (= 2) or FALSE (= 0) to indicate whether the input should be checked for less probable results, see Details
|
||||
#' @param reference_df a \code{data.frame} to use for extra reference when translating \code{x} to a valid \code{mo}. See \code{\link{set_mo_source}} and \code{\link{get_mo_source}} to automate the usage of your own codes (e.g. used in your analysis or organisation).
|
||||
#' @param ... other parameters passed on to functions
|
||||
#' @rdname as.mo
|
||||
@ -39,16 +39,16 @@
|
||||
#' \strong{General info} \cr
|
||||
#' A microorganism ID from this package (class: \code{mo}) typically looks like these examples:\cr
|
||||
#' \preformatted{
|
||||
#' Code Full name
|
||||
#' --------------- --------------------------------------
|
||||
#' B_KLBSL Klebsiella
|
||||
#' B_KLBSL_PNE Klebsiella pneumoniae
|
||||
#' B_KLBSL_PNE_RHI Klebsiella pneumoniae rhinoscleromatis
|
||||
#' | | | |
|
||||
#' | | | |
|
||||
#' | | | ----> subspecies, a 3-4 letter acronym
|
||||
#' | | ----> species, a 3-4 letter acronym
|
||||
#' | ----> genus, a 5-7 letter acronym, mostly without vowels
|
||||
#' Code Full name
|
||||
#' --------------- --------------------------------------
|
||||
#' B_KLBSL Klebsiella
|
||||
#' B_KLBSL_PNMN Klebsiella pneumoniae
|
||||
#' B_KLBSL_PNMN_RHNS Klebsiella pneumoniae rhinoscleromatis
|
||||
#' | | | |
|
||||
#' | | | |
|
||||
#' | | | ---> subspecies, a 4-5 letter acronym
|
||||
#' | | ----> species, a 4-5 letter acronym
|
||||
#' | ----> genus, a 5-7 letter acronym
|
||||
#' ----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
|
||||
#' C (Chromista), F (Fungi), P (Protozoa)
|
||||
#' }
|
||||
@ -95,7 +95,7 @@
|
||||
#'
|
||||
#' Examples:
|
||||
#' \itemize{
|
||||
#' \item{\code{"Streptococcus group B (known as S. agalactiae)"}. The text between brackets will be removed and a warning will be thrown that the result \emph{Streptococcus group B} (\code{B_STRPT_GRB}) needs review.}
|
||||
#' \item{\code{"Streptococcus group B (known as S. agalactiae)"}. The text between brackets will be removed and a warning will be thrown that the result \emph{Streptococcus group B} (\code{B_STRPT_GRPB}) needs review.}
|
||||
#' \item{\code{"S. aureus - please mind: MRSA"}. The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result \emph{Staphylococcus aureus} (\code{B_STPHY_AUR}) needs review.}
|
||||
#' \item{\code{"Fluoroquinolone-resistant Neisseria gonorrhoeae"}. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result \emph{Neisseria gonorrhoeae} (\code{B_NESSR_GON}) needs review.}
|
||||
#' }
|
||||
@ -135,7 +135,7 @@
|
||||
#' @importFrom dplyr %>% pull left_join
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' # These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
||||
#' # These examples all return "B_STPHY_AURS", the ID of S. aureus:
|
||||
#' as.mo("sau") # WHONET code
|
||||
#' as.mo("stau")
|
||||
#' as.mo("STAU")
|
||||
@ -160,11 +160,11 @@
|
||||
#' as.mo("GAS") # Group A Streptococci
|
||||
#' as.mo("GBS") # Group B Streptococci
|
||||
#'
|
||||
#' as.mo("S. epidermidis") # will remain species: B_STPHY_EPI
|
||||
#' as.mo("S. epidermidis", Becker = TRUE) # will not remain species: B_STPHY_CNS
|
||||
#' as.mo("S. epidermidis") # will remain species: B_STPHY_EPDR
|
||||
#' as.mo("S. epidermidis", Becker = TRUE) # will not remain species: B_STPHY_CONS
|
||||
#'
|
||||
#' as.mo("S. pyogenes") # will remain species: B_STRPT_PYO
|
||||
#' as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRA
|
||||
#' as.mo("S. pyogenes") # will remain species: B_STRPT_PYGN
|
||||
#' as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRPA
|
||||
#'
|
||||
#' # All mo_* functions use as.mo() internally too (see ?mo_property):
|
||||
#' mo_genus("E. coli") # returns "Escherichia"
|
||||
@ -342,6 +342,7 @@ exec_as.mo <- function(x,
|
||||
stringsAsFactors = FALSE)
|
||||
failures <- character(0)
|
||||
uncertainty_level <- translate_allow_uncertain(allow_uncertain)
|
||||
old_mo_warning <- FALSE
|
||||
|
||||
x_input <- x
|
||||
# already strip leading and trailing spaces
|
||||
@ -359,6 +360,7 @@ exec_as.mo <- function(x,
|
||||
if (any(x %like_case% "^[BFP]_[A-Z]{3,7}") & !all(x %in% microorganisms$mo)) {
|
||||
leftpart <- gsub("^([BFP]_[A-Z]{3,7}).*", "\\1", x)
|
||||
if (any(leftpart %in% names(mo_codes_v0.5.0))) {
|
||||
old_mo_warning <- TRUE
|
||||
rightpart <- gsub("^[BFP]_[A-Z]{3,7}(.*)", "\\1", x)
|
||||
leftpart <- mo_codes_v0.5.0[leftpart]
|
||||
x[!is.na(leftpart)] <- paste0(leftpart[!is.na(leftpart)], rightpart[!is.na(leftpart)])
|
||||
@ -366,6 +368,7 @@ exec_as.mo <- function(x,
|
||||
# now check if some are still old
|
||||
still_old <- x[x %in% names(mo_codes_v0.5.0)]
|
||||
if (length(still_old) > 0) {
|
||||
old_mo_warning <- TRUE
|
||||
x[x %in% names(mo_codes_v0.5.0)] <- data.frame(old = still_old, stringsAsFactors = FALSE) %>%
|
||||
left_join(data.frame(old = names(mo_codes_v0.5.0),
|
||||
new = mo_codes_v0.5.0,
|
||||
@ -466,6 +469,14 @@ exec_as.mo <- function(x,
|
||||
|
||||
x <- reference_data_to_use[data.table(mo = y[["mo"]]), on = "mo", ..property][[1]]
|
||||
|
||||
} else if (all(x %in% microorganisms.translation$mo_old)) {
|
||||
# is an old mo code, used in previous versions of this package
|
||||
old_mo_warning <- TRUE
|
||||
y <- as.data.table(microorganisms.translation)[data.table(mo_old = x), on = "mo_old", "mo_new"][[1]]
|
||||
y <- reference_data_to_use[data.table(mo = y), on = "mo", ..property][[1]]
|
||||
# don't save to history, as all items are already in microorganisms.translation
|
||||
x <- y
|
||||
|
||||
} else if (!all(x %in% AMR::microorganisms[, property])) {
|
||||
|
||||
strip_whitespace <- function(x, dyslexia_mode) {
|
||||
@ -487,6 +498,8 @@ exec_as.mo <- function(x,
|
||||
# from here on case-insensitive
|
||||
x <- tolower(x)
|
||||
|
||||
x_backup[grepl("^(fungus|fungi)$", x)] <- "F_FUNGUS" # will otherwise become the kingdom
|
||||
|
||||
# remove spp and species
|
||||
x <- gsub(" +(spp.?|ssp.?|sp.? |ss ?.?|subsp.?|subspecies|biovar |serovar |species)", " ", x, ignore.case = TRUE)
|
||||
x <- gsub("(spp.?|ssp.?|subsp.?|subspecies|biovar|serovar|species)", "", x, ignore.case = TRUE)
|
||||
@ -499,12 +512,14 @@ exec_as.mo <- function(x,
|
||||
# no groups and complexes as ending
|
||||
x <- gsub("(complex|group)$", "", x)
|
||||
x <- gsub("((an)?aero+b)[a-z]*", "", x)
|
||||
x <- gsub("^atyp[a-z]*", "", x)
|
||||
x <- gsub("(vergroen)[a-z]*", "viridans", x)
|
||||
x <- gsub("[a-z]*diff?erent[a-z]*", "", x)
|
||||
x <- gsub("(hefe|gist|gisten|levadura|lievito|fermento|levure)[a-z]*", "yeast", x)
|
||||
x <- gsub("(schimmels?|mofo|molde|stampo|moisissure|fungi)[a-z]*", "fungus", x)
|
||||
x <- gsub("fungus[ph|f]rya", "fungiphrya", x)
|
||||
# remove non-text in case of "E. coli" except dots and spaces
|
||||
x <- gsub("[^.a-zA-Z0-9/ \\-]+", "", x)
|
||||
x <- trimws(gsub("[^.a-zA-Z0-9/ \\-]+", " ", x))
|
||||
# replace minus by a space
|
||||
x <- gsub("-+", " ", x)
|
||||
# replace hemolytic by haemolytic
|
||||
@ -543,7 +558,7 @@ exec_as.mo <- function(x,
|
||||
x[nchar(x_backup_without_spp) > 10] <- gsub("[+]", paste0("+[", constants, "]?"), x[nchar(x_backup_without_spp) > 10])
|
||||
}
|
||||
x <- strip_whitespace(x, dyslexia_mode)
|
||||
|
||||
|
||||
x_trimmed <- x
|
||||
x_trimmed_species <- paste(x_trimmed, "species")
|
||||
x_trimmed_without_group <- gsub(" gro.u.p$", "", x_trimmed)
|
||||
@ -591,6 +606,11 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
}
|
||||
|
||||
if (x_backup[i] %like_case% "\\(unknown [a-z]+\\)") {
|
||||
x[i] <- "UNKNOWN"
|
||||
next
|
||||
}
|
||||
|
||||
found <- reference_data_to_use[mo == toupper(x_backup[i]), ..property][[1]]
|
||||
# is a valid MO code
|
||||
if (length(found) > 0) {
|
||||
@ -598,6 +618,17 @@ exec_as.mo <- function(x,
|
||||
next
|
||||
}
|
||||
|
||||
if (x_backup[i] %in% microorganisms.translation$mo_old) {
|
||||
# is an old mo code, used in previous versions of this package
|
||||
old_mo_warning <- TRUE
|
||||
found <- reference_data_to_use[mo == microorganisms.translation[which(microorganisms.translation$mo_old == x_backup[i]), "mo_new"], ..property][[1]]
|
||||
if (length(found) > 0) {
|
||||
x[i] <- found[1L]
|
||||
# don't save to history, as all items are already in microorganisms.translation
|
||||
next
|
||||
}
|
||||
}
|
||||
|
||||
found <- reference_data_to_use[fullname_lower %in% tolower(c(x_backup[i], x_backup_without_spp[i])), ..property][[1]]
|
||||
# most probable: is exact match in fullname
|
||||
if (length(found) > 0) {
|
||||
@ -665,19 +696,22 @@ exec_as.mo <- function(x,
|
||||
|
||||
if (x_backup_without_spp[i] %like_case% "virus") {
|
||||
# there is no fullname like virus, so don't try to coerce it
|
||||
x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]]
|
||||
if (initial_search == TRUE) {
|
||||
failures <- c(failures, x_backup[i])
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
x[i] <- NA_character_
|
||||
next
|
||||
}
|
||||
# x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]]
|
||||
# if (initial_search == TRUE) {
|
||||
# failures <- c(failures, x_backup[i])
|
||||
# set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
# }
|
||||
# next
|
||||
# }
|
||||
|
||||
# translate known trivial abbreviations to genus + species ----
|
||||
if (!is.na(x_trimmed[i])) {
|
||||
if (toupper(x_backup_without_spp[i]) %in% c('MRSA', 'MSSA', 'VISA', 'VRSA')
|
||||
| x_backup_without_spp[i] %like_case% " (mrsa|mssa|visa|vrsa) ") {
|
||||
x[i] <- microorganismsDT[mo == 'B_STPHY_AUR', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STPHY_AURS', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -685,7 +719,7 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
if (toupper(x_backup_without_spp[i]) %in% c('MRSE', 'MSSE')
|
||||
| x_backup_without_spp[i] %like_case% " (mrse|msse) ") {
|
||||
x[i] <- microorganismsDT[mo == 'B_STPHY_EPI', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STPHY_EPDR', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -715,7 +749,7 @@ exec_as.mo <- function(x,
|
||||
if (toupper(x_backup_without_spp[i]) %in% c("AIEC", "ATEC", "DAEC", "EAEC", "EHEC", "EIEC", "EPEC", "ETEC", "NMEC", "STEC", "UPEC")
|
||||
# also support O-antigens of E. coli: O26, O103, O104, O111, O121, O145, O157
|
||||
| x_backup_without_spp[i] %like_case% "o?(26|103|104|111|121|145|157)") {
|
||||
x[i] <- microorganismsDT[mo == 'B_ESCHR_COL', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_ESCHR_COLI', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -724,7 +758,7 @@ exec_as.mo <- function(x,
|
||||
if (toupper(x_backup_without_spp[i]) == 'MRPA'
|
||||
| x_backup_without_spp[i] %like_case% " mrpa ") {
|
||||
# multi resistant P. aeruginosa
|
||||
x[i] <- microorganismsDT[mo == 'B_PSDMN_AER', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_PSDMN_ARGN', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -733,7 +767,7 @@ exec_as.mo <- function(x,
|
||||
if (toupper(x_backup_without_spp[i]) == 'CRS'
|
||||
| toupper(x_backup_without_spp[i]) == 'CRSM') {
|
||||
# co-trim resistant S. maltophilia
|
||||
x[i] <- microorganismsDT[mo == 'B_STNTR_MAL', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STNTR_MLTP', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -742,15 +776,15 @@ exec_as.mo <- function(x,
|
||||
if (toupper(x_backup_without_spp[i]) %in% c('PISP', 'PRSP', 'VISP', 'VRSP')
|
||||
| x_backup_without_spp[i] %like_case% " (pisp|prsp|visp|vrsp) ") {
|
||||
# peni I, peni R, vanco I, vanco R: S. pneumoniae
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_PNE', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_PNMN', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
next
|
||||
}
|
||||
if (x_backup_without_spp[i] %like_case% '^g[abcdfghk]s$') {
|
||||
# Streptococci, like GBS = Group B Streptococci (B_STRPT_GRB)
|
||||
x[i] <- microorganismsDT[mo == toupper(gsub("g([abcdfghk])s", "B_STRPT_GR\\1", x_backup_without_spp[i])), ..property][[1]][1L]
|
||||
# Streptococci, like GBS = Group B Streptococci (B_STRPT_GRPB)
|
||||
x[i] <- microorganismsDT[mo == toupper(gsub("g([abcdfghk])s", "B_STRPT_GRP\\1", x_backup_without_spp[i])), ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -758,7 +792,7 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
if (x_backup_without_spp[i] %like_case% '(streptococ|streptokok).* [abcdfghk]$') {
|
||||
# Streptococci in different languages, like "estreptococos grupo B"
|
||||
x[i] <- microorganismsDT[mo == toupper(gsub(".*(streptococ|streptokok|estreptococ).* ([abcdfghk])$", "B_STRPT_GR\\2", x_backup_without_spp[i])), ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == toupper(gsub(".*(streptococ|streptokok|estreptococ).* ([abcdfghk])$", "B_STRPT_GRP\\2", x_backup_without_spp[i])), ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -766,7 +800,7 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
if (x_backup_without_spp[i] %like_case% 'group [abcdfghk] (streptococ|streptokok|estreptococ)') {
|
||||
# Streptococci in different languages, like "Group A Streptococci"
|
||||
x[i] <- microorganismsDT[mo == toupper(gsub(".*group ([abcdfghk]) (streptococ|streptokok|estreptococ).*", "B_STRPT_GR\\1", x_backup_without_spp[i])), ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == toupper(gsub(".*group ([abcdfghk]) (streptococ|streptokok|estreptococ).*", "B_STRPT_GRP\\1", x_backup_without_spp[i])), ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -774,7 +808,7 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
if (x_backup_without_spp[i] %like_case% 'haemoly.*strept') {
|
||||
# Haemolytic streptococci in different languages
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_HAE', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_HAEM', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -785,7 +819,7 @@ exec_as.mo <- function(x,
|
||||
| x_trimmed[i] %like_case% '[ck]oagulas[ea] negatie?[vf]'
|
||||
| x_backup_without_spp[i] %like_case% '[ck]o?ns[^a-z]?$') {
|
||||
# coerce S. coagulase negative
|
||||
x[i] <- microorganismsDT[mo == 'B_STPHY_CNS', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STPHY_CONS', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -795,7 +829,7 @@ exec_as.mo <- function(x,
|
||||
| x_trimmed[i] %like_case% '[ck]oagulas[ea] positie?[vf]'
|
||||
| x_backup_without_spp[i] %like_case% '[ck]o?ps[^a-z]?$') {
|
||||
# coerce S. coagulase positive
|
||||
x[i] <- microorganismsDT[mo == 'B_STPHY_CPS', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STPHY_COPS', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -806,7 +840,7 @@ exec_as.mo <- function(x,
|
||||
| x_backup_without_spp[i] %like_case% 'strepto.* milleri'
|
||||
| x_backup_without_spp[i] %like_case% 'mgs[^a-z]?$') {
|
||||
# Milleri Group Streptococcus (MGS)
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_MIL', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_MILL', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -816,7 +850,7 @@ exec_as.mo <- function(x,
|
||||
| x_backup_without_spp[i] %like_case% 'strepto.* viridans'
|
||||
| x_backup_without_spp[i] %like_case% 'vgs[^a-z]?$') {
|
||||
# Viridans Group Streptococcus (VGS)
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_VIR', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_VIRI', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -842,6 +876,15 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
next
|
||||
}
|
||||
if (x_backup_without_spp[i] %like_case% 'mycoba[ck]teri.[nm]?$') {
|
||||
# coerce Gram positives
|
||||
x[i] <- microorganismsDT[mo == 'B_MYCBC', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
if (x_backup_without_spp[i] %like_case% "salmonella [a-z]+ ?.*") {
|
||||
if (x_backup_without_spp[i] %like_case% "salmonella group") {
|
||||
# Salmonella Group A to Z, just return S. species for now
|
||||
@ -852,38 +895,38 @@ exec_as.mo <- function(x,
|
||||
next
|
||||
} else if (grepl("[sS]almonella [A-Z][a-z]+ ?.*", x_backup[i], ignore.case = FALSE)) {
|
||||
# Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica
|
||||
x[i] <- microorganismsDT[mo == 'B_SLMNL_ENT', ..property][[1]][1L]
|
||||
x[i] <- microorganismsDT[mo == 'B_SLMNL_ENTR', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
uncertainties <- rbind(uncertainties,
|
||||
format_uncertainty_as_df(uncertainty_level = 1,
|
||||
input = x_backup_without_spp[i],
|
||||
result_mo = "B_SLMNL_ENT"))
|
||||
result_mo = "B_SLMNL_ENTR"))
|
||||
next
|
||||
}
|
||||
}
|
||||
|
||||
# trivial names known to the field:
|
||||
if ("meningococcus" %like_case% x_trimmed[i]) {
|
||||
# coerce S. coagulase positive
|
||||
x[i] <- microorganismsDT[mo == 'B_NESSR_MEN', ..property][[1]][1L]
|
||||
# coerce Neisseria meningitidis
|
||||
x[i] <- microorganismsDT[mo == 'B_NESSR_MNNG', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
next
|
||||
}
|
||||
if ("gonococcus" %like_case% x_trimmed[i]) {
|
||||
# coerce S. coagulase positive
|
||||
x[i] <- microorganismsDT[mo == 'B_NESSR_GON', ..property][[1]][1L]
|
||||
# coerce Neisseria gonorrhoeae
|
||||
x[i] <- microorganismsDT[mo == 'B_NESSR_GNRR', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
next
|
||||
}
|
||||
if ("pneumococcus" %like_case% x_trimmed[i]) {
|
||||
# coerce S. coagulase positive
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_PNE', ..property][[1]][1L]
|
||||
# coerce Streptococcus penumoniae
|
||||
x[i] <- microorganismsDT[mo == 'B_STRPT_PNMN', ..property][[1]][1L]
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history, disable = disable_mo_history)
|
||||
}
|
||||
@ -1611,35 +1654,35 @@ exec_as.mo <- function(x,
|
||||
immediate. = TRUE)
|
||||
}
|
||||
|
||||
x[x %in% CoNS] <- microorganismsDT[mo == 'B_STPHY_CNS', ..property][[1]][1L]
|
||||
x[x %in% CoPS] <- microorganismsDT[mo == 'B_STPHY_CPS', ..property][[1]][1L]
|
||||
x[x %in% CoNS] <- microorganismsDT[mo == 'B_STPHY_CONS', ..property][[1]][1L]
|
||||
x[x %in% CoPS] <- microorganismsDT[mo == 'B_STPHY_COPS', ..property][[1]][1L]
|
||||
if (Becker == "all") {
|
||||
x[x %in% microorganismsDT[mo %like_case% '^B_STPHY_AUR', ..property][[1]]] <- microorganismsDT[mo == 'B_STPHY_CPS', ..property][[1]][1L]
|
||||
x[x %in% microorganismsDT[mo %like_case% '^B_STPHY_AURS', ..property][[1]]] <- microorganismsDT[mo == 'B_STPHY_COPS', ..property][[1]][1L]
|
||||
}
|
||||
}
|
||||
|
||||
# Lancefield ----
|
||||
if (Lancefield == TRUE | Lancefield == "all") {
|
||||
# group A - S. pyogenes
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_PYO', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRA', ..property][[1]][1L]
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_PYGN', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRPA', ..property][[1]][1L]
|
||||
# group B - S. agalactiae
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_AGA', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRB', ..property][[1]][1L]
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_AGLC', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRPB', ..property][[1]][1L]
|
||||
# group C
|
||||
S_groupC <- microorganismsDT %>% filter(genus == "Streptococcus",
|
||||
species %in% c("equisimilis", "equi",
|
||||
"zooepidemicus", "dysgalactiae")) %>%
|
||||
pull(property)
|
||||
x[x %in% S_groupC] <- microorganismsDT[mo == 'B_STRPT_GRC', ..property][[1]][1L]
|
||||
x[x %in% S_groupC] <- microorganismsDT[mo == 'B_STRPT_GRPC', ..property][[1]][1L]
|
||||
if (Lancefield == "all") {
|
||||
# all Enterococci
|
||||
x[x %like% "^(Enterococcus|B_ENTRC)"] <- microorganismsDT[mo == 'B_STRPT_GRD', ..property][[1]][1L]
|
||||
x[x %like% "^(Enterococcus|B_ENTRC)"] <- microorganismsDT[mo == 'B_STRPT_GRPD', ..property][[1]][1L]
|
||||
}
|
||||
# group F - S. anginosus
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_ANG', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRF', ..property][[1]][1L]
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_ANGN', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRPF', ..property][[1]][1L]
|
||||
# group H - S. sanguinis
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_SAN', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRH', ..property][[1]][1L]
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_SNGN', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRPH', ..property][[1]][1L]
|
||||
# group K - S. salivarius
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_SAL', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRK', ..property][[1]][1L]
|
||||
x[x == microorganismsDT[mo == 'B_STRPT_SLVR', ..property][[1]][1L]] <- microorganismsDT[mo == 'B_STRPT_GRPK', ..property][[1]][1L]
|
||||
}
|
||||
|
||||
# Wrap up ----------------------------------------------------------------
|
||||
@ -1672,6 +1715,10 @@ exec_as.mo <- function(x,
|
||||
print(mo_renamed())
|
||||
}
|
||||
|
||||
if (old_mo_warning == TRUE) {
|
||||
warning("The input contained old microorganism IDs from previous versions of this package. Please use as.mo() on these old codes.\nSUPPORT FOR THIS WILL BE DROPPED IN A FUTURE VERSION.", call. = FALSE)
|
||||
}
|
||||
|
||||
x
|
||||
}
|
||||
|
||||
@ -1682,6 +1729,7 @@ empty_result <- function(x) {
|
||||
#' @importFrom crayon italic
|
||||
was_renamed <- function(name_old, name_new, ref_old = "", ref_new = "", mo = "") {
|
||||
newly_set <- data.frame(old_name = name_old,
|
||||
old_ref = ref_old,
|
||||
new_name = name_new,
|
||||
new_ref = ref_new,
|
||||
mo = mo,
|
||||
@ -1757,7 +1805,7 @@ pillar_shaft.mo <- function(x, ...) {
|
||||
#' @noRd
|
||||
summary.mo <- function(object, ...) {
|
||||
# unique and top 1-3
|
||||
x <- object
|
||||
x <- as.mo(object)
|
||||
top_3 <- unname(top_freq(freq(x), 3))
|
||||
c("Class" = "mo",
|
||||
"<NA>" = length(x[is.na(x)]),
|
||||
@ -1803,7 +1851,7 @@ as.data.frame.mo <- function(x, ...) {
|
||||
"[<-.mo" <- function(i, j, ..., value) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(i)
|
||||
class_integrity_check(y, "microbial code", AMR::microorganisms$mo)
|
||||
class_integrity_check(y, "microbial code", c(as.character(AMR::microorganisms$mo), as.character(microorganisms.translation$mo_old)))
|
||||
}
|
||||
#' @exportMethod [[<-.mo
|
||||
#' @export
|
||||
@ -1811,7 +1859,7 @@ as.data.frame.mo <- function(x, ...) {
|
||||
"[[<-.mo" <- function(i, j, ..., value) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(i)
|
||||
class_integrity_check(y, "microbial code", AMR::microorganisms$mo)
|
||||
class_integrity_check(y, "microbial code", c(as.character(AMR::microorganisms$mo), as.character(microorganisms.translation$mo_old)))
|
||||
}
|
||||
#' @exportMethod c.mo
|
||||
#' @export
|
||||
@ -1819,7 +1867,7 @@ as.data.frame.mo <- function(x, ...) {
|
||||
c.mo <- function(x, ...) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(x)
|
||||
class_integrity_check(y, "microbial code", AMR::microorganisms$mo)
|
||||
class_integrity_check(y, "microbial code", c(as.character(AMR::microorganisms$mo), as.character(microorganisms.translation$mo_old)))
|
||||
}
|
||||
|
||||
#' @rdname as.mo
|
||||
@ -1898,9 +1946,12 @@ print.mo_renamed <- function(x, ...) {
|
||||
}
|
||||
for (i in 1:nrow(x)) {
|
||||
message(blue(paste0("NOTE: ",
|
||||
italic(x$old_name[i]), " was renamed ", italic(x$new_name[i]),
|
||||
" (", gsub("et al.", italic("et al."), x$new_ref[i]), ")",
|
||||
" (", x$mo[i], ")")))
|
||||
italic(x$old_name[i]), ifelse(x$old_ref[i] %in% c("", NA), "",
|
||||
paste0(" (", gsub("et al.", italic("et al."), x$old_ref[i]), ")")),
|
||||
" was renamed ",
|
||||
italic(x$new_name[i]), ifelse(x$new_ref[i] %in% c("", NA), "",
|
||||
paste0(" (", gsub("et al.", italic("et al."), x$new_ref[i]), ")")),
|
||||
" [", x$mo[i], "]")))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ get_mo_history <- function(x, uncertainty_level, force = FALSE, disable = FALSE)
|
||||
if (base::is.null(history)) {
|
||||
result <- NA
|
||||
} else {
|
||||
result <- data.frame(x = toupper(x), stringsAsFactors = FALSE) %>%
|
||||
result <- data.frame(x = as.character(toupper(x)), stringsAsFactors = FALSE) %>%
|
||||
left_join(history, by = "x") %>%
|
||||
pull(mo)
|
||||
}
|
||||
|
2
R/rsi.R
2
R/rsi.R
@ -197,7 +197,7 @@ exec_as.rsi <- function(method, x, mo, ab, guideline) {
|
||||
mo_order <- as.mo(mo_order(mo))
|
||||
mo_becker <- as.mo(mo, Becker = TRUE)
|
||||
mo_lancefield <- as.mo(mo, Lancefield = TRUE)
|
||||
|
||||
|
||||
guideline_param <- toupper(guideline)
|
||||
if (guideline_param %in% c("CLSI", "EUCAST")) {
|
||||
guideline_param <- AMR::rsi_translation %>%
|
||||
|
BIN
R/sysdata.rda
BIN
R/sysdata.rda
Binary file not shown.
46
R/zzz.R
46
R/zzz.R
@ -54,29 +54,29 @@
|
||||
|
||||
|
||||
.onAttach <- function(...) {
|
||||
if (interactive() & !isFALSE(getOption("AMR_survey"))) {
|
||||
options(AMR_survey = FALSE)
|
||||
console_width <- options()$width - 1
|
||||
url <- "https://www.surveymonkey.com/r/AMR_for_R"
|
||||
txt <- paste0("Thanks for using the AMR package! ",
|
||||
"As researchers, we are interested in how and why you use this package and if there are things you're missing from it. ",
|
||||
"Please fill in our 2-minute survey at: ", url, ". ",
|
||||
"This message can be turned off with: options(AMR_survey = FALSE)")
|
||||
|
||||
# make it honour new lines bases on console width:
|
||||
txt <- unlist(strsplit(txt, " "))
|
||||
txt_new <- ""
|
||||
total_chars <- 0
|
||||
for (i in 1:length(txt)) {
|
||||
total_chars <- total_chars + nchar(txt[i]) + 1
|
||||
if (total_chars > console_width) {
|
||||
txt_new <- paste0(txt_new, "\n")
|
||||
total_chars <- 0
|
||||
}
|
||||
txt_new <- paste0(txt_new, txt[i], " ")
|
||||
}
|
||||
# packageStartupMessage(txt_new)
|
||||
}
|
||||
# if (interactive() & !isFALSE(getOption("AMR_survey"))) {
|
||||
# options(AMR_survey = FALSE)
|
||||
# console_width <- options()$width - 1
|
||||
# url <- "https://www.surveymonkey.com/r/AMR_for_R"
|
||||
# txt <- paste0("Thanks for using the AMR package! ",
|
||||
# "As researchers, we are interested in how and why you use this package and if there are things you're missing from it. ",
|
||||
# "Please fill in our 2-minute survey at: ", url, ". ",
|
||||
# "This message can be turned off with: options(AMR_survey = FALSE)")
|
||||
#
|
||||
# # make it honour new lines bases on console width:
|
||||
# txt <- unlist(strsplit(txt, " "))
|
||||
# txt_new <- ""
|
||||
# total_chars <- 0
|
||||
# for (i in 1:length(txt)) {
|
||||
# total_chars <- total_chars + nchar(txt[i]) + 1
|
||||
# if (total_chars > console_width) {
|
||||
# txt_new <- paste0(txt_new, "\n")
|
||||
# total_chars <- 0
|
||||
# }
|
||||
# txt_new <- paste0(txt_new, txt[i], " ")
|
||||
# }
|
||||
# # packageStartupMessage(txt_new)
|
||||
# }
|
||||
}
|
||||
|
||||
#' @importFrom data.table as.data.table setkey
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Version 0.8.0
|
||||
|
||||
* A NOTE for having a data directory over 3 MB. This is needed to offer users reference data for the complete taxonomy of microorganisms - one of the most important features of this pacakge. Has been this way since version 0.3.0.
|
||||
* This package writes lines to `[user library]/AMR/inst/mo_history/mo_history.csv` when using the `as.mo()` function. Users are notified about this. The CSV file is never newly created or deleted by this package, it only changes this file to improve speed and reliability of the `as.mo()` function. Staged install still works. The source code was taken from the `extrafont` package on CRAN (version 0.17), that writes to the package folder in the user library exactly the same way. See the source code of `set_mo_history()` and `clear_mo_history()`.
|
||||
* This package writes lines to `[user library]/AMR/mo_history/mo_history.csv` when using the `as.mo()` function, in the exact same way (and borrowed from) the `extrafont` package on CRAN (version 0.17) writes to the package folder. Users are notified about this and staged install still works. The CSV file is never newly created or deleted by this package, it only changes this file to improve speed and reliability of the `as.mo()` function. See the source code of `set_mo_history()` and `clear_mo_history()`.
|
||||
|
BIN
data-raw/DRGLST1.xlsx
Normal file
BIN
data-raw/DRGLST1.xlsx
Normal file
Binary file not shown.
@ -33,8 +33,12 @@ translations_file <- utils::read.delim(file = "data-raw/translations.tsv",
|
||||
allowEscapes = TRUE, # else "\\1" will be imported as "\\\\1"
|
||||
quote = "")
|
||||
|
||||
# Old microorganism codes -------------------------------------------------
|
||||
|
||||
microorganisms.translation <- readRDS("data-raw/microorganisms.translation.rds")
|
||||
|
||||
# Export to package as internal data ----
|
||||
usethis::use_data(eucast_rules_file, translations_file,
|
||||
usethis::use_data(eucast_rules_file, translations_file, microorganisms.translation,
|
||||
internal = TRUE,
|
||||
overwrite = TRUE,
|
||||
version = 2)
|
||||
@ -42,6 +46,7 @@ usethis::use_data(eucast_rules_file, translations_file,
|
||||
# Remove from global environment ----
|
||||
rm(eucast_rules_file)
|
||||
rm(translations_file)
|
||||
rm(microorganisms.translation)
|
||||
|
||||
# Clean mo history ----
|
||||
mo_history_file <- file.path(file.path(system.file(package = "AMR"), "mo_history"), "mo_history.csv")
|
||||
|
BIN
data-raw/microorganisms.translation.rds
Normal file
BIN
data-raw/microorganisms.translation.rds
Normal file
Binary file not shown.
@ -102,22 +102,38 @@ MOs <- data_total %>%
|
||||
& !order %in% c("Eurotiales", "Microascales", "Mucorales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales", "Onygenales", "Pneumocystales"))
|
||||
)
|
||||
# or the genus has to be one of the genera we found in our hospitals last decades (Northern Netherlands, 2002-2018)
|
||||
| genus %in% c("Absidia", "Acremonium", "Actinotignum", "Alternaria", "Anaerosalibacter", "Ancylostoma", "Anisakis", "Apophysomyces",
|
||||
"Arachnia", "Ascaris", "Aureobacterium", "Aureobasidium", "Balantidum", "Bilophilia", "Branhamella", "Brochontrix",
|
||||
"Brugia", "Calymmatobacterium", "Catabacter", "Cdc", "Chilomastix", "Chryseomonas", "Cladophialophora", "Cladosporium",
|
||||
"Clonorchis", "Cordylobia", "Curvularia", "Demodex", "Dermatobia", "Diphyllobothrium", "Dracunculus", "Echinococcus",
|
||||
"Enterobius", "Euascomycetes", "Exophiala", "Fasciola", "Fusarium", "Hendersonula", "Hymenolepis", "Hypomyces", "Kloeckera",
|
||||
"Koserella", "Larva", "Leishmania", "Lelliottia", "Loa", "Lumbricus", "Malassezia", "Metagonimus", "Molonomonas",
|
||||
"Mucor", "Nattrassia", "Necator", "Nectria", "Novospingobium", "Onchocerca", "Opistorchis", "Paragonimus", "Paramyxovirus",
|
||||
"Pediculus", "Phoma", "Phthirus", "Pityrosporum", "Pseudallescheria", "Pulex", "Rhizomucor", "Rhizopus", "Rhodotorula",
|
||||
"Salinococcus", "Sanguibacteroides", "Schistosoma", "Scopulariopsis", "Scytalidium", "Sporobolomyces", "Stomatococcus",
|
||||
"Strongyloides", "Syncephalastraceae", "Taenia", "Torulopsis", "Trichinella", "Trichobilharzia", "Trichoderma", "Trichomonas",
|
||||
"Trichosporon", "Trichuris", "Trypanosoma", "Wuchereria")
|
||||
| genus %in% c("Absidia", "Acremonium", "Actinotignum", "Aedes", "Alternaria", "Anaerosalibacter", "Ancylostoma", "Angiostrongylus",
|
||||
"Anisakis", "Anopheles", "Apophysomyces", "Arachnia", "Ascaris", "Aureobacterium", "Aureobasidium", "Balantidum", "Basidiobolus",
|
||||
"Beauveria", "Bilophilia", "Branhamella", "Brochontrix", "Brugia", "Calymmatobacterium", "Capillaria", "Catabacter", "Cdc", "Chaetomium",
|
||||
"Chilomastix", "Chryseomonas", "Chrysonilia", "Cladophialophora", "Cladosporium", "Clonorchis", "Conidiobolus", "Contracaecum",
|
||||
"Cordylobia", "Curvularia", "Demodex", "Dermatobia", "Dicrocoelium", "Dioctophyma", "Diphyllobothrium", "Dipylidium", "Dirofilaria",
|
||||
"Dracunculus", "Echinococcus", "Echinostoma", "Enterobius", "Enteromonas", "Euascomycetes", "Exophiala", "Exserohilum", "Fasciola",
|
||||
"Fasciolopsis", "Fonsecaea", "Fusarium", "Gnathostoma", "Hendersonula", "Heterophyes", "Hymenolepis", "Hypomyces", "Hysterothylacium",
|
||||
"Kloeckera", "Koserella", "Larva", "Lecythophora", "Leishmania", "Lelliottia", "Leptomyxida", "Leptosphaeria", "Loa", "Lucilia",
|
||||
"Lumbricus", "Malassezia", "Malbranchea", "Mansonella", "Mesocestoides", "Metagonimus", "Metarrhizium", "Molonomonas", "Mortierella",
|
||||
"Mucor", "Multiceps", "Mycocentrospora", "Nanophetus", "Nattrassia", "Necator", "Nectria", "Novospingobium", "Ochroconis",
|
||||
"Oesophagostomum", "Oidiodendron", "Onchocerca", "Opisthorchis", "Opistorchis", "Paragonimus", "Paramyxovirus", "Pediculus",
|
||||
"Phlebotomus", "Phocanema", "Phoma", "Phthirus", "Piedraia", "Pithomyces", "Pityrosporum", "Pseudallescheria", "Pseudoterranova",
|
||||
"Pulex", "Retortamonas", "Rhizomucor", "Rhizopus", "Rhodotorula", "Salinococcus", "Sanguibacteroides", "Sarcophagidae", "Sarcoptes",
|
||||
"Schistosoma", "Scolecobasidium", "Scopulariopsis", "Scytalidium", "Spirometra", "Sporobolomyces", "Stachybotrys", "Stenotrophomononas",
|
||||
"Stomatococcus", "Strongyloides", "Syncephalastraceae", "Syngamus", "Taenia", "Ternidens", "Torulopsis", "Toxocara", "Trichinella",
|
||||
"Trichobilharzia", "Trichoderma", "Trichomonas", "Trichosporon", "Trichostrongylus", "Trichuris", "Tritirachium", "Trombicula",
|
||||
"Trypanosoma", "Tunga", "Wuchereria")
|
||||
# or the taxonomic entry is old - the species was renamed
|
||||
| !is.na(col_id_new)
|
||||
) %>%
|
||||
# really no Plantae (e.g. Dracunculus exist both as worm and as plant)
|
||||
filter(kingdom != "Plantae")
|
||||
filter(kingdom != "Plantae") %>%
|
||||
filter(!rank %in% c("kingdom", "phylum", "class", "order", "family", "genus"))
|
||||
|
||||
# include all ranks other than species for the included species
|
||||
MOs <- MOs %>% bind_rows(data_total %>%
|
||||
filter((kingdom %in% MOs$kingdom & rank == "kingdom")
|
||||
| (phylum %in% MOs$phylum & rank == "phylum")
|
||||
| (class %in% MOs$class & rank == "class")
|
||||
| (order %in% MOs$order & rank == "order")
|
||||
| (family %in% MOs$family & rank == "family")
|
||||
| (genus %in% MOs$genus & rank == "genus")))
|
||||
|
||||
# filter old taxonomic names so only the ones with an existing reference will be kept
|
||||
MOs <- MOs %>%
|
||||
@ -193,6 +209,11 @@ MOs.old <- MOs %>%
|
||||
distinct(fullname, .keep_all = TRUE) %>%
|
||||
arrange(col_id)
|
||||
|
||||
MO.bak <- MOs
|
||||
MOold.bak <- MOs.old
|
||||
MOs <- MO.bak
|
||||
MOs.old <- MOold.bak
|
||||
|
||||
MOs <- MOs %>%
|
||||
filter(is.na(col_id_new) | source == "DSMZ") %>%
|
||||
transmute(col_id,
|
||||
@ -215,20 +236,93 @@ MOs <- MOs %>%
|
||||
species_id = gsub(".*/([a-f0-9]+)", "\\1", species_id),
|
||||
source) %>%
|
||||
#distinct(fullname, .keep_all = TRUE) %>%
|
||||
filter(!grepl("unassigned", fullname, ignore.case = TRUE))
|
||||
filter(!grepl("unassigned", fullname, ignore.case = TRUE)) %>%
|
||||
# prefer DSMZ over CoL, since that's more recent
|
||||
arrange(desc(source)) %>%
|
||||
distinct(kingdom, fullname, .keep_all = TRUE)
|
||||
|
||||
# Filter out the DSMZ records that were renamed and are now in MOs.old
|
||||
MOs <- MOs %>%
|
||||
filter(!(source == "DSMZ" & fullname %in% MOs.old$fullname),
|
||||
!(source == "DSMZ" & fullname %in% (MOs %>% filter(source == "CoL") %>% pull(fullname)))) %>%
|
||||
distinct(fullname, .keep_all = TRUE)
|
||||
# # Filter out the DSMZ records that were renamed and are now in MOs.old
|
||||
# MOs <- MOs %>%
|
||||
# filter(!(source == "DSMZ" & fullname %in% MOs.old$fullname)) %>%
|
||||
# distinct(kingdom, fullname, .keep_all = TRUE) %>%
|
||||
# filter(fullname != "")
|
||||
|
||||
# remove all genera that have no species - they are irrelevant for microbiology and almost all from the kingdom of Animalia
|
||||
to_remove <- MOs %>%
|
||||
filter(!kingdom %in% c("Bacteria", "Protozoa")) %>%
|
||||
group_by(kingdom, genus) %>%
|
||||
count() %>%
|
||||
filter(n == 1) %>%
|
||||
ungroup() %>%
|
||||
mutate(kingdom_genus = paste(kingdom, genus)) %>%
|
||||
pull(kingdom_genus)
|
||||
MOs <- MOs %>% filter(!(paste(kingdom, genus) %in% to_remove))
|
||||
rm(to_remove)
|
||||
|
||||
# add CoL ID from MOs.bak, for the cases where DSMZ took preference
|
||||
MOs <- MOs %>%
|
||||
mutate(kingdom_fullname = paste(kingdom, fullname)) %>%
|
||||
select(-col_id) %>%
|
||||
left_join(MO.bak %>%
|
||||
filter(is.na(col_id_new), !is.na(col_id)) %>%
|
||||
transmute(col_id, kingdom_fullname = trimws(paste(kingdom, genus, species, subspecies))),
|
||||
by = "kingdom_fullname") %>%
|
||||
select(col_id, everything(), -kingdom_fullname)
|
||||
|
||||
|
||||
MOs.old <- MOs.old %>%
|
||||
# remove the ones that are in the MOs data set
|
||||
filter(col_id_new %in% MOs$col_id) %>%
|
||||
# and remove the ones that have the exact same fullname in the MOs data set, like Moraxella catarrhalis
|
||||
left_join(MOs, by = "fullname") %>%
|
||||
filter(col_id_new != col_id.y | is.na(col_id.y)) %>%
|
||||
select(col_id = col_id.x, col_id_new, fullname, ref = ref.x)
|
||||
|
||||
# remove the records that are in MOs.old
|
||||
MOs <- MOs %>% filter(!fullname %in% MOs.old$fullname)
|
||||
|
||||
# what characters are in the fullnames?
|
||||
table(sort(unlist(strsplit(x = paste(MOs$fullname, collapse = ""), split = ""))))
|
||||
|
||||
table(MOs$kingdom, MOs$rank)
|
||||
table(AMR::microorganisms$kingdom, AMR::microorganisms$rank)
|
||||
|
||||
# set prevalence per species
|
||||
MOs <- MOs %>%
|
||||
mutate(prevalence = case_when(
|
||||
class == "Gammaproteobacteria"
|
||||
| genus %in% c("Enterococcus", "Staphylococcus", "Streptococcus")
|
||||
~ 1,
|
||||
phylum %in% c("Proteobacteria",
|
||||
"Firmicutes",
|
||||
"Actinobacteria",
|
||||
"Sarcomastigophora")
|
||||
| genus %in% c("Aspergillus",
|
||||
"Bacteroides",
|
||||
"Candida",
|
||||
"Capnocytophaga",
|
||||
"Chryseobacterium",
|
||||
"Cryptococcus",
|
||||
"Elisabethkingia",
|
||||
"Flavobacterium",
|
||||
"Fusobacterium",
|
||||
"Giardia",
|
||||
"Leptotrichia",
|
||||
"Mycoplasma",
|
||||
"Prevotella",
|
||||
"Rhodotorula",
|
||||
"Treponema",
|
||||
"Trichophyton",
|
||||
"Ureaplasma")
|
||||
| rank %in% c("kingdom", "phylum", "class", "order", "family")
|
||||
~ 2,
|
||||
TRUE ~ 3
|
||||
))
|
||||
|
||||
# Add abbreviations so we can easily know which ones are which ones.
|
||||
# These will become valid and unique microbial IDs for the AMR package.
|
||||
MOs <- MOs %>%
|
||||
arrange(prevalence, fullname) %>%
|
||||
group_by(kingdom) %>%
|
||||
mutate(abbr_other = case_when(
|
||||
rank == "family" ~ paste0("[FAM]_",
|
||||
@ -270,14 +364,14 @@ MOs <- MOs %>%
|
||||
# species abbreviations may be the same between genera
|
||||
# because the genus abbreviation is part of the abbreviation
|
||||
mutate(abbr_species = abbreviate(species,
|
||||
minlength = 3,
|
||||
use.classes = FALSE,
|
||||
minlength = 4,
|
||||
use.classes = TRUE,
|
||||
method = "both.sides")) %>%
|
||||
ungroup() %>%
|
||||
group_by(genus, species) %>%
|
||||
mutate(abbr_subspecies = abbreviate(subspecies,
|
||||
minlength = 3,
|
||||
use.classes = FALSE,
|
||||
minlength = 4,
|
||||
use.classes = TRUE,
|
||||
method = "both.sides")) %>%
|
||||
ungroup() %>%
|
||||
# remove trailing underscores
|
||||
@ -302,9 +396,6 @@ MOs <- MOs %>%
|
||||
# put `mo` in front, followed by the rest
|
||||
select(mo, everything(), -abbr_other, -abbr_genus, -abbr_species, -abbr_subspecies)
|
||||
|
||||
# remove empty fullnames
|
||||
MOs <- MOs %>% filter(fullname != "")
|
||||
|
||||
# add non-taxonomic entries
|
||||
MOs <- MOs %>%
|
||||
bind_rows(
|
||||
@ -324,6 +415,7 @@ MOs <- MOs %>%
|
||||
ref = NA_character_,
|
||||
species_id = "",
|
||||
source = "manually added",
|
||||
prevalence = 1,
|
||||
stringsAsFactors = FALSE),
|
||||
data.frame(mo = "B_GRAMN",
|
||||
col_id = NA_integer_,
|
||||
@ -340,6 +432,7 @@ MOs <- MOs %>%
|
||||
ref = NA_character_,
|
||||
species_id = "",
|
||||
source = "manually added",
|
||||
prevalence = 1,
|
||||
stringsAsFactors = FALSE),
|
||||
data.frame(mo = "B_GRAMP",
|
||||
col_id = NA_integer_,
|
||||
@ -356,6 +449,7 @@ MOs <- MOs %>%
|
||||
ref = NA_character_,
|
||||
species_id = "",
|
||||
source = "manually added",
|
||||
prevalence = 1,
|
||||
stringsAsFactors = FALSE),
|
||||
data.frame(mo = "F_YEAST",
|
||||
col_id = NA_integer_,
|
||||
@ -372,6 +466,7 @@ MOs <- MOs %>%
|
||||
ref = NA_character_,
|
||||
species_id = "",
|
||||
source = "manually added",
|
||||
prevalence = 2,
|
||||
stringsAsFactors = FALSE),
|
||||
data.frame(mo = "F_FUNGUS",
|
||||
col_id = NA_integer_,
|
||||
@ -388,11 +483,12 @@ MOs <- MOs %>%
|
||||
ref = NA_character_,
|
||||
species_id = "",
|
||||
source = "manually added",
|
||||
prevalence = 2,
|
||||
stringsAsFactors = FALSE),
|
||||
# CoNS
|
||||
MOs %>%
|
||||
filter(genus == "Staphylococcus", species == "epidermidis") %>% .[1,] %>%
|
||||
mutate(mo = gsub("EPI", "CNS", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_CONS", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "coagulase-negative",
|
||||
fullname = "Coagulase-negative Staphylococcus (CoNS)",
|
||||
@ -402,7 +498,7 @@ MOs <- MOs %>%
|
||||
# CoPS
|
||||
MOs %>%
|
||||
filter(genus == "Staphylococcus", species == "epidermidis") %>% .[1,] %>%
|
||||
mutate(mo = gsub("EPI", "CPS", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_COPS", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "coagulase-positive",
|
||||
fullname = "Coagulase-positive Staphylococcus (CoPS)",
|
||||
@ -413,18 +509,20 @@ MOs <- MOs %>%
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "pyogenes") %>% .[1,] %>%
|
||||
# we can keep all other details, since S. pyogenes is the only member of group A
|
||||
mutate(mo = gsub("PYO", "GRA", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_GRPA", mo),
|
||||
species = "group A" ,
|
||||
fullname = "Streptococcus group A"),
|
||||
fullname = "Streptococcus group A",
|
||||
source = "manually added"),
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
# we can keep all other details, since S. agalactiae is the only member of group B
|
||||
mutate(mo = gsub("AGA", "GRB", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_GRPB", mo),
|
||||
species = "group B" ,
|
||||
fullname = "Streptococcus group B"),
|
||||
fullname = "Streptococcus group B",
|
||||
source = "manually added"),
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "dysgalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("DYS", "GRC", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_GRPC", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "group C" ,
|
||||
fullname = "Streptococcus group C",
|
||||
@ -433,7 +531,7 @@ MOs <- MOs %>%
|
||||
source = "manually added"),
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("AGA", "GRD", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_GRPD", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "group D" ,
|
||||
fullname = "Streptococcus group D",
|
||||
@ -442,7 +540,7 @@ MOs <- MOs %>%
|
||||
source = "manually added"),
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("AGA", "GRF", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_GRPF", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "group F" ,
|
||||
fullname = "Streptococcus group F",
|
||||
@ -451,7 +549,7 @@ MOs <- MOs %>%
|
||||
source = "manually added"),
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("AGA", "GRG", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_GRPG", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "group G" ,
|
||||
fullname = "Streptococcus group G",
|
||||
@ -460,7 +558,7 @@ MOs <- MOs %>%
|
||||
source = "manually added"),
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("AGA", "GRH", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_GRPH", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "group H" ,
|
||||
fullname = "Streptococcus group H",
|
||||
@ -469,7 +567,7 @@ MOs <- MOs %>%
|
||||
source = "manually added"),
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("AGA", "GRK", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_GRPK", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "group K" ,
|
||||
fullname = "Streptococcus group K",
|
||||
@ -479,7 +577,7 @@ MOs <- MOs %>%
|
||||
# Beta haemolytic Streptococci
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("AGA", "HAE", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_HAEM", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "beta-haemolytic" ,
|
||||
fullname = "Beta-haemolytic Streptococcus",
|
||||
@ -489,7 +587,7 @@ MOs <- MOs %>%
|
||||
# Viridans Streptococci
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("AGA", "VIR", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_VIRI", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "viridans" ,
|
||||
fullname = "Viridans Group Streptococcus (VGS)",
|
||||
@ -499,7 +597,7 @@ MOs <- MOs %>%
|
||||
# Milleri Streptococci
|
||||
MOs %>%
|
||||
filter(genus == "Streptococcus", species == "agalactiae") %>% .[1,] %>%
|
||||
mutate(mo = gsub("AGA", "MIL", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_MILL", mo),
|
||||
col_id = NA_integer_,
|
||||
species = "milleri" ,
|
||||
fullname = "Milleri Group Streptococcus (MGS)",
|
||||
@ -509,7 +607,7 @@ MOs <- MOs %>%
|
||||
# Trichomonas vaginalis is missing, same order as Dientamoeba
|
||||
MOs %>%
|
||||
filter(fullname == "Dientamoeba") %>%
|
||||
mutate(mo = gsub("DNTMB", "THMNS", mo),
|
||||
mutate(mo = gsub("(.*?)_.*", "\\1_THMNS", mo),
|
||||
col_id = NA,
|
||||
fullname = "Trichomonas",
|
||||
family = "Trichomonadidae",
|
||||
@ -519,8 +617,7 @@ MOs <- MOs %>%
|
||||
species_id = ""),
|
||||
MOs %>%
|
||||
filter(fullname == "Dientamoeba fragilis") %>%
|
||||
mutate(mo = gsub("DNTMB", "THMNS", mo),
|
||||
mo = gsub("FRA", "VAG", mo),
|
||||
mutate(mo = gsub("(.*?)_.*", "\\1_THMNS_VAG", mo),
|
||||
col_id = NA,
|
||||
fullname = "Trichomonas vaginalis",
|
||||
family = "Trichomonadidae",
|
||||
@ -531,7 +628,7 @@ MOs <- MOs %>%
|
||||
species_id = ""),
|
||||
MOs %>% # add family as such too
|
||||
filter(fullname == "Monocercomonadidae") %>%
|
||||
mutate(mo = gsub("MNCRCMND", "TRCHMNDD", mo),
|
||||
mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_TRCHMNDD", mo),
|
||||
col_id = NA,
|
||||
fullname = "Trichomonadidae",
|
||||
family = "Trichomonadidae",
|
||||
@ -541,9 +638,12 @@ MOs <- MOs %>%
|
||||
source = "manually added",
|
||||
ref = "",
|
||||
species_id = ""),
|
||||
|
||||
)
|
||||
|
||||
MOs <- MOs %>%
|
||||
group_by(kingdom) %>%
|
||||
distinct(fullname, .keep_all = TRUE) %>%
|
||||
ungroup()
|
||||
|
||||
# everything distinct?
|
||||
sum(duplicated(MOs$mo))
|
||||
@ -551,60 +651,44 @@ sum(duplicated(MOs$fullname))
|
||||
colnames(MOs)
|
||||
|
||||
# here we welcome the new ones:
|
||||
MOs %>% filter(!fullname %in% AMR::microorganisms$fullname) %>% View()
|
||||
MOs %>% arrange(genus, species, subspecies) %>% filter(!fullname %in% AMR::microorganisms$fullname) %>% View()
|
||||
# and the ones we lost:
|
||||
AMR::microorganisms %>% filter(!fullname %in% MOs$fullname) %>% View()
|
||||
# and these IDs have changed:
|
||||
MOs %>%
|
||||
filter(fullname %in% AMR::microorganisms$fullname) %>%
|
||||
left_join(AMR::microorganisms %>% select(mo, fullname), by = "fullname", suffix = c("_new", "_old")) %>%
|
||||
old_new <- MOs %>%
|
||||
mutate(kingdom_fullname = paste(kingdom, fullname)) %>%
|
||||
filter(kingdom_fullname %in% (AMR::microorganisms %>% mutate(kingdom_fullname = paste(kingdom, fullname)) %>% pull(kingdom_fullname))) %>%
|
||||
left_join(AMR::microorganisms %>% mutate(kingdom_fullname = paste(kingdom, fullname)) %>% select(mo, kingdom_fullname), by = "kingdom_fullname", suffix = c("_new", "_old")) %>%
|
||||
filter(mo_new != mo_old) %>%
|
||||
select(mo_old, mo_new, everything()) %>%
|
||||
select(mo_old, mo_new, everything())
|
||||
old_new %>%
|
||||
View()
|
||||
# and these codes are now missing (which will throw a unit test error):
|
||||
AMR::microorganisms.codes %>% filter(!mo %in% AMR::microorganisms$mo)
|
||||
|
||||
# set prevalence per species
|
||||
MOs <- MOs %>%
|
||||
mutate(prevalence = case_when(
|
||||
class == "Gammaproteobacteria"
|
||||
| genus %in% c("Enterococcus", "Staphylococcus", "Streptococcus")
|
||||
| mo %in% c("UNKNOWN", "B_GRAMN", "B_GRAMP")
|
||||
~ 1,
|
||||
phylum %in% c("Proteobacteria",
|
||||
"Firmicutes",
|
||||
"Actinobacteria",
|
||||
"Sarcomastigophora")
|
||||
| genus %in% c("Aspergillus",
|
||||
"Bacteroides",
|
||||
"Candida",
|
||||
"Capnocytophaga",
|
||||
"Chryseobacterium",
|
||||
"Cryptococcus",
|
||||
"Elisabethkingia",
|
||||
"Flavobacterium",
|
||||
"Fusobacterium",
|
||||
"Giardia",
|
||||
"Leptotrichia",
|
||||
"Mycoplasma",
|
||||
"Prevotella",
|
||||
"Rhodotorula",
|
||||
"Treponema",
|
||||
"Trichophyton",
|
||||
"Ureaplasma")
|
||||
| rank %in% c("kingdom", "phylum", "class", "order", "family")
|
||||
~ 2,
|
||||
TRUE ~ 3
|
||||
))
|
||||
AMR::microorganisms.codes %>% filter(!mo %in% MOs$mo)
|
||||
# this is how to fix it
|
||||
microorganisms.codes <- AMR::microorganisms.codes %>%
|
||||
left_join(MOs %>%
|
||||
mutate(kingdom_fullname = paste(kingdom, fullname)) %>%
|
||||
left_join(AMR::microorganisms %>%
|
||||
mutate(kingdom_fullname = paste(kingdom, fullname)) %>%
|
||||
select(mo, kingdom_fullname), by = "kingdom_fullname", suffix = c("_new", "_old")) %>%
|
||||
select(mo_old, mo_new),
|
||||
by = c("mo" = "mo_old")) %>%
|
||||
select(code, mo = mo_new) %>%
|
||||
filter(!is.na(mo))
|
||||
microorganisms.codes %>% filter(!mo %in% MOs$mo)
|
||||
|
||||
# arrange
|
||||
MOs <- MOs %>% arrange(genus, species, subspecies)
|
||||
MOs.old <- MOs.old %>% arrange(fullname)
|
||||
microorganisms.codes <- microorganisms.codes %>% arrange(code)
|
||||
|
||||
# transform
|
||||
MOs <- as.data.frame(MOs, stringsAsFactors = FALSE)
|
||||
MOs.old <- as.data.frame(MOs.old, stringsAsFactors = FALSE)
|
||||
microorganisms.codes <- as.data.frame(microorganisms.codes, stringsAsFactors = FALSE)
|
||||
class(MOs$mo) <- "mo"
|
||||
class(microorganisms.codes$mo) <- "mo"
|
||||
MOs$col_id <- as.integer(MOs$col_id)
|
||||
MOs.old$col_id <- as.integer(MOs.old$col_id)
|
||||
MOs.old$col_id_new <- as.integer(MOs.old$col_id_new)
|
||||
@ -616,10 +700,17 @@ saveRDS(MOs.old, "microorganisms.old.rds")
|
||||
### for same server
|
||||
microorganisms <- MOs
|
||||
microorganisms.old <- MOs.old
|
||||
microorganisms.translation <- old_new %>% select(mo_old, mo_new)
|
||||
class(microorganisms.translation$mo_old) <- "mo"
|
||||
class(microorganisms.translation$mo_new) <- "mo"
|
||||
|
||||
# on the server, do:
|
||||
usethis::use_data(microorganisms, overwrite = TRUE, version = 2)
|
||||
usethis::use_data(microorganisms.old, overwrite = TRUE, version = 2)
|
||||
usethis::use_data(microorganisms.codes, overwrite = TRUE, version = 2)
|
||||
saveRDS(AMR::microorganisms.translation, file = "microorganisms.translation.rds", version = 2) # this one will be covered in data-raw/internals.R
|
||||
rm(microorganisms)
|
||||
rm(microorganisms.old)
|
||||
rm(microorganisms.codes)
|
||||
rm(microorganisms.translation)
|
||||
# and update the year and dimensions in R/data.R
|
||||
|
@ -4,7 +4,7 @@ library(readxl)
|
||||
# Installed WHONET 2019 software on Windows (http://www.whonet.org/software.html),
|
||||
# opened C:\WHONET\Codes\WHONETCodes.mdb in MS Access
|
||||
# and exported table 'DRGLST1' to MS Excel
|
||||
DRGLST1 <- read_excel("DRGLST1.xlsx")
|
||||
DRGLST1 <- read_excel("data-raw/DRGLST1.xlsx")
|
||||
rsi_translation <- DRGLST1 %>%
|
||||
# only keep CLSI and EUCAST guidelines:
|
||||
filter(GUIDELINES %like% "^(CLSI|EUCST)") %>%
|
||||
@ -22,6 +22,8 @@ rsi_translation <- DRGLST1 %>%
|
||||
filter(!is.na(mo) & !is.na(ab)) %>%
|
||||
arrange(desc(guideline), mo, ab)
|
||||
|
||||
print(mo_failures())
|
||||
|
||||
# create 2 tables: MIC and disk
|
||||
tbl_mic <- rsi_translation %>%
|
||||
filter(method == "MIC") %>%
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9074</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9074</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -185,7 +185,7 @@
|
||||
<h1>Benchmarks</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">16 September 2019</h4>
|
||||
<h4 class="date">18 September 2019</h4>
|
||||
|
||||
|
||||
<div class="hidden name"><code>benchmarks.Rmd</code></div>
|
||||
@ -199,7 +199,7 @@
|
||||
<p>Using the <code>microbenchmark</code> package, we can review the calculation performance of this function. Its function <code><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark()</a></code> runs different input expressions independently of each other and measures their time-to-result.</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(microbenchmark)</a>
|
||||
<a class="sourceLine" id="cb1-2" data-line-number="2"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(AMR)</a></code></pre></div>
|
||||
<p>In the next test, we try to ‘coerce’ different input values for <em>Staphylococcus aureus</em>. The actual result is the same every time: it returns its MO code <code>B_STPHY_AUR</code> (<em>B</em> stands for <em>Bacteria</em>, the taxonomic kingdom).</p>
|
||||
<p>In the next test, we try to ‘coerce’ different input values for <em>Staphylococcus aureus</em>. The actual result is the same every time: it returns its MO code <code>B_STPHY_AURS</code> (<em>B</em> stands for <em>Bacteria</em>, the taxonomic kingdom).</p>
|
||||
<p>But the calculation time differs a lot:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" data-line-number="1">S.aureus <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(</a>
|
||||
<a class="sourceLine" id="cb2-2" data-line-number="2"> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"sau"</span>), <span class="co"># WHONET code</span></a>
|
||||
@ -220,38 +220,38 @@
|
||||
<a class="sourceLine" id="cb2-17" data-line-number="17"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
|
||||
<a class="sourceLine" id="cb2-18" data-line-number="18"><span class="co"># Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb2-19" data-line-number="19"><span class="co"># expr min lq mean median uq</span></a>
|
||||
<a class="sourceLine" id="cb2-20" data-line-number="20"><span class="co"># as.mo("sau") 8.6 8.7 11.0 8.8 9.3</span></a>
|
||||
<a class="sourceLine" id="cb2-21" data-line-number="21"><span class="co"># as.mo("stau") 30.0 30.0 41.0 31.0 32.0</span></a>
|
||||
<a class="sourceLine" id="cb2-22" data-line-number="22"><span class="co"># as.mo("STAU") 30.0 30.0 42.0 31.0 32.0</span></a>
|
||||
<a class="sourceLine" id="cb2-23" data-line-number="23"><span class="co"># as.mo("staaur") 8.5 8.9 12.0 9.1 9.6</span></a>
|
||||
<a class="sourceLine" id="cb2-24" data-line-number="24"><span class="co"># as.mo("STAAUR") 8.5 9.0 9.1 9.2 9.3</span></a>
|
||||
<a class="sourceLine" id="cb2-25" data-line-number="25"><span class="co"># as.mo("S. aureus") 23.0 23.0 30.0 23.0 40.0</span></a>
|
||||
<a class="sourceLine" id="cb2-26" data-line-number="26"><span class="co"># as.mo("S aureus") 22.0 23.0 28.0 23.0 37.0</span></a>
|
||||
<a class="sourceLine" id="cb2-27" data-line-number="27"><span class="co"># as.mo("Staphylococcus aureus") 28.0 29.0 30.0 30.0 31.0</span></a>
|
||||
<a class="sourceLine" id="cb2-28" data-line-number="28"><span class="co"># as.mo("Staphylococcus aureus (MRSA)") 520.0 530.0 540.0 540.0 550.0</span></a>
|
||||
<a class="sourceLine" id="cb2-29" data-line-number="29"><span class="co"># as.mo("Sthafilokkockus aaureuz") 270.0 280.0 300.0 290.0 300.0</span></a>
|
||||
<a class="sourceLine" id="cb2-30" data-line-number="30"><span class="co"># as.mo("MRSA") 8.5 8.7 8.9 8.8 9.0</span></a>
|
||||
<a class="sourceLine" id="cb2-31" data-line-number="31"><span class="co"># as.mo("VISA") 18.0 19.0 24.0 19.0 35.0</span></a>
|
||||
<a class="sourceLine" id="cb2-32" data-line-number="32"><span class="co"># as.mo("VRSA") 18.0 18.0 31.0 19.0 34.0</span></a>
|
||||
<a class="sourceLine" id="cb2-33" data-line-number="33"><span class="co"># as.mo(22242419) 17.0 18.0 22.0 18.0 19.0</span></a>
|
||||
<a class="sourceLine" id="cb2-20" data-line-number="20"><span class="co"># as.mo("sau") 8.5 8.9 12.0 9.1 9.7</span></a>
|
||||
<a class="sourceLine" id="cb2-21" data-line-number="21"><span class="co"># as.mo("stau") 31.0 32.0 48.0 34.0 55.0</span></a>
|
||||
<a class="sourceLine" id="cb2-22" data-line-number="22"><span class="co"># as.mo("STAU") 31.0 31.0 35.0 32.0 33.0</span></a>
|
||||
<a class="sourceLine" id="cb2-23" data-line-number="23"><span class="co"># as.mo("staaur") 8.6 8.8 12.0 9.0 9.3</span></a>
|
||||
<a class="sourceLine" id="cb2-24" data-line-number="24"><span class="co"># as.mo("STAAUR") 8.6 8.9 9.0 9.0 9.1</span></a>
|
||||
<a class="sourceLine" id="cb2-25" data-line-number="25"><span class="co"># as.mo("S. aureus") 23.0 23.0 26.0 24.0 24.0</span></a>
|
||||
<a class="sourceLine" id="cb2-26" data-line-number="26"><span class="co"># as.mo("S aureus") 23.0 23.0 31.0 24.0 44.0</span></a>
|
||||
<a class="sourceLine" id="cb2-27" data-line-number="27"><span class="co"># as.mo("Staphylococcus aureus") 27.0 28.0 29.0 29.0 29.0</span></a>
|
||||
<a class="sourceLine" id="cb2-28" data-line-number="28"><span class="co"># as.mo("Staphylococcus aureus (MRSA)") 550.0 560.0 590.0 580.0 590.0</span></a>
|
||||
<a class="sourceLine" id="cb2-29" data-line-number="29"><span class="co"># as.mo("Sthafilokkockus aaureuz") 270.0 290.0 340.0 300.0 330.0</span></a>
|
||||
<a class="sourceLine" id="cb2-30" data-line-number="30"><span class="co"># as.mo("MRSA") 8.7 8.8 9.1 9.1 9.4</span></a>
|
||||
<a class="sourceLine" id="cb2-31" data-line-number="31"><span class="co"># as.mo("VISA") 18.0 19.0 20.0 19.0 20.0</span></a>
|
||||
<a class="sourceLine" id="cb2-32" data-line-number="32"><span class="co"># as.mo("VRSA") 19.0 19.0 23.0 19.0 22.0</span></a>
|
||||
<a class="sourceLine" id="cb2-33" data-line-number="33"><span class="co"># as.mo(22242419) 18.0 18.0 37.0 30.0 42.0</span></a>
|
||||
<a class="sourceLine" id="cb2-34" data-line-number="34"><span class="co"># max neval</span></a>
|
||||
<a class="sourceLine" id="cb2-35" data-line-number="35"><span class="co"># 28.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-35" data-line-number="35"><span class="co"># 31.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-36" data-line-number="36"><span class="co"># 120.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-37" data-line-number="37"><span class="co"># 120.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-37" data-line-number="37"><span class="co"># 59.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-38" data-line-number="38"><span class="co"># 34.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-39" data-line-number="39"><span class="co"># 9.4 10</span></a>
|
||||
<a class="sourceLine" id="cb2-40" data-line-number="40"><span class="co"># 41.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-41" data-line-number="41"><span class="co"># 43.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-42" data-line-number="42"><span class="co"># 31.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-43" data-line-number="43"><span class="co"># 570.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-44" data-line-number="44"><span class="co"># 400.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-45" data-line-number="45"><span class="co"># 9.3 10</span></a>
|
||||
<a class="sourceLine" id="cb2-46" data-line-number="46"><span class="co"># 36.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-47" data-line-number="47"><span class="co"># 110.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-48" data-line-number="48"><span class="co"># 43.0 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb2-39" data-line-number="39"><span class="co"># 9.2 10</span></a>
|
||||
<a class="sourceLine" id="cb2-40" data-line-number="40"><span class="co"># 49.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-41" data-line-number="41"><span class="co"># 53.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-42" data-line-number="42"><span class="co"># 30.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-43" data-line-number="43"><span class="co"># 670.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-44" data-line-number="44"><span class="co"># 620.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-45" data-line-number="45"><span class="co"># 9.5 10</span></a>
|
||||
<a class="sourceLine" id="cb2-46" data-line-number="46"><span class="co"># 28.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-47" data-line-number="47"><span class="co"># 45.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-48" data-line-number="48"><span class="co"># 110.0 10</span></a></code></pre></div>
|
||||
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="562.5"></p>
|
||||
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.</p>
|
||||
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Thermus islandicus</em> (<code>B_THERMS_ISL</code>), a bug probably never found before in humans:</p>
|
||||
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Thermus islandicus</em> (<code>B_THERMS_ISLN</code>), a bug probably never found before in humans:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1">T.islandicus <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"theisl"</span>),</a>
|
||||
<a class="sourceLine" id="cb3-2" data-line-number="2"> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"THEISL"</span>),</a>
|
||||
<a class="sourceLine" id="cb3-3" data-line-number="3"> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"T. islandicus"</span>),</a>
|
||||
@ -320,53 +320,53 @@
|
||||
<a class="sourceLine" id="cb3-66" data-line-number="66"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(T.islandicus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
|
||||
<a class="sourceLine" id="cb3-67" data-line-number="67"><span class="co"># Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb3-68" data-line-number="68"><span class="co"># expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb3-69" data-line-number="69"><span class="co"># as.mo("theisl") 1300 1300 1300 1300 1400 1400 10</span></a>
|
||||
<a class="sourceLine" id="cb3-70" data-line-number="70"><span class="co"># as.mo("THEISL") 1300 1300 1300 1300 1300 1400 10</span></a>
|
||||
<a class="sourceLine" id="cb3-71" data-line-number="71"><span class="co"># as.mo("T. islandicus") 360 360 370 380 380 390 10</span></a>
|
||||
<a class="sourceLine" id="cb3-72" data-line-number="72"><span class="co"># as.mo("T. islandicus") 360 370 400 380 450 480 10</span></a>
|
||||
<a class="sourceLine" id="cb3-73" data-line-number="73"><span class="co"># as.mo("Thermus islandicus") 29 30 32 30 30 50 10</span></a></code></pre></div>
|
||||
<p>That takes 8.6 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
|
||||
<a class="sourceLine" id="cb3-69" data-line-number="69"><span class="co"># as.mo("theisl") 1300 1400 1400 1400 1500 1600 10</span></a>
|
||||
<a class="sourceLine" id="cb3-70" data-line-number="70"><span class="co"># as.mo("THEISL") 1400 1400 1400 1400 1500 1600 10</span></a>
|
||||
<a class="sourceLine" id="cb3-71" data-line-number="71"><span class="co"># as.mo("T. islandicus") 370 400 410 410 420 450 10</span></a>
|
||||
<a class="sourceLine" id="cb3-72" data-line-number="72"><span class="co"># as.mo("T. islandicus") 360 370 400 380 410 490 10</span></a>
|
||||
<a class="sourceLine" id="cb3-73" data-line-number="73"><span class="co"># as.mo("Thermus islandicus") 28 30 35 32 35 59 10</span></a></code></pre></div>
|
||||
<p>That takes 8.5 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
|
||||
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Thermus islandicus</em> (which is uncommon):</p>
|
||||
<pre><code># Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)</code></pre>
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.</code></pre>
|
||||
<p><img src="benchmarks_files/figure-html/unnamed-chunk-6-1.png" width="562.5"></p>
|
||||
<p>In reality, the <code><a href="../reference/as.mo.html">as.mo()</a></code> functions <strong>learns from its own output to speed up determinations for next times</strong>. In above figure, this effect was disabled to show the difference with the boxplot below - when you would use <code><a href="../reference/as.mo.html">as.mo()</a></code> yourself:</p>
|
||||
<pre><code># NOTE: results are saved to /Users/msberends/Library/R/3.6/library/AMR/mo_history/mo_history.csv.
|
||||
# NOTE: Prevotella ruminicola brevis (Shah et al., 1990) was renamed Prevotella brevis (Avgustin et al., 2016) [B_PRVTL_BRVS]
|
||||
# Warning:
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
|
||||
# NOTE: Prevotella ruminicola brevis was renamed Prevotella brevis (Avgustin et al., 1997) (B_PRVTL_BRE)</code></pre>
|
||||
# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.</code></pre>
|
||||
<p><img src="benchmarks_files/figure-html/unnamed-chunk-7-1.png" width="562.5"></p>
|
||||
<p>The highest outliers are the first times. All next determinations were done in only thousands of seconds.</p>
|
||||
<p>Uncommon microorganisms take a lot more time than common microorganisms. To relieve this pitfall and further improve performance, two important calculations take almost no time at all: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
|
||||
@ -400,23 +400,23 @@
|
||||
<a class="sourceLine" id="cb6-24" data-line-number="24"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb6-25" data-line-number="25"><span class="co"># Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb6-26" data-line-number="26"><span class="co"># expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb6-27" data-line-number="27"><span class="co"># mo_name(x) 607 619 636 632 660 671 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.63 seconds (632 ms). You only lose time on your unique input values.</p>
|
||||
<a class="sourceLine" id="cb6-27" data-line-number="27"><span class="co"># mo_name(x) 610 644 669 665 684 748 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.66 seconds (664 ms). You only lose time on your unique input values.</p>
|
||||
</div>
|
||||
<div id="precalculated-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#precalculated-results" class="anchor"></a>Precalculated results</h3>
|
||||
<p>What about precalculated results? If the input is an already precalculated result of a helper function like <code><a href="../reference/mo_property.html">mo_name()</a></code>, it almost doesn’t take any time at all (see ‘C’ below):</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">run_it <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"B_STPHY_AUR"</span>),</a>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">run_it <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"B_STPHY_AURS"</span>),</a>
|
||||
<a class="sourceLine" id="cb7-2" data-line-number="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"S. aureus"</span>),</a>
|
||||
<a class="sourceLine" id="cb7-3" data-line-number="3"> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),</a>
|
||||
<a class="sourceLine" id="cb7-4" data-line-number="4"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
|
||||
<a class="sourceLine" id="cb7-5" data-line-number="5"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb7-6" data-line-number="6"><span class="co"># Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb7-7" data-line-number="7"><span class="co"># expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb7-8" data-line-number="8"><span class="co"># A 6.410 6.500 6.720 6.570 6.840 7.660 10</span></a>
|
||||
<a class="sourceLine" id="cb7-9" data-line-number="9"><span class="co"># B 21.700 22.100 25.900 22.600 24.200 48.600 10</span></a>
|
||||
<a class="sourceLine" id="cb7-10" data-line-number="10"><span class="co"># C 0.763 0.774 0.812 0.812 0.849 0.855 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb7-8" data-line-number="8"><span class="co"># A 6.150 6.260 6.400 6.390 6.520 6.710 10</span></a>
|
||||
<a class="sourceLine" id="cb7-9" data-line-number="9"><span class="co"># B 22.200 22.500 26.400 22.700 24.800 53.100 10</span></a>
|
||||
<a class="sourceLine" id="cb7-10" data-line-number="10"><span class="co"># C 0.645 0.774 0.801 0.803 0.812 0.911 10</span></a></code></pre></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0008 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1">run_it <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</a>
|
||||
<a class="sourceLine" id="cb8-2" data-line-number="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</a>
|
||||
@ -430,14 +430,14 @@
|
||||
<a class="sourceLine" id="cb8-10" data-line-number="10"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb8-11" data-line-number="11"><span class="co"># Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb8-12" data-line-number="12"><span class="co"># expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb8-13" data-line-number="13"><span class="co"># A 0.449 0.471 0.492 0.474 0.483 0.671 10</span></a>
|
||||
<a class="sourceLine" id="cb8-14" data-line-number="14"><span class="co"># B 0.611 0.621 0.638 0.626 0.629 0.717 10</span></a>
|
||||
<a class="sourceLine" id="cb8-15" data-line-number="15"><span class="co"># C 0.649 0.706 0.743 0.743 0.807 0.818 10</span></a>
|
||||
<a class="sourceLine" id="cb8-16" data-line-number="16"><span class="co"># D 0.458 0.463 0.474 0.468 0.481 0.520 10</span></a>
|
||||
<a class="sourceLine" id="cb8-17" data-line-number="17"><span class="co"># E 0.432 0.452 0.459 0.463 0.472 0.476 10</span></a>
|
||||
<a class="sourceLine" id="cb8-18" data-line-number="18"><span class="co"># F 0.427 0.454 0.461 0.461 0.471 0.487 10</span></a>
|
||||
<a class="sourceLine" id="cb8-19" data-line-number="19"><span class="co"># G 0.448 0.453 0.465 0.463 0.470 0.506 10</span></a>
|
||||
<a class="sourceLine" id="cb8-20" data-line-number="20"><span class="co"># H 0.431 0.444 0.459 0.458 0.468 0.506 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb8-13" data-line-number="13"><span class="co"># A 0.467 0.471 0.509 0.492 0.512 0.680 10</span></a>
|
||||
<a class="sourceLine" id="cb8-14" data-line-number="14"><span class="co"># B 0.628 0.634 0.664 0.646 0.685 0.748 10</span></a>
|
||||
<a class="sourceLine" id="cb8-15" data-line-number="15"><span class="co"># C 0.712 0.723 0.771 0.755 0.797 0.906 10</span></a>
|
||||
<a class="sourceLine" id="cb8-16" data-line-number="16"><span class="co"># D 0.444 0.455 0.475 0.464 0.501 0.518 10</span></a>
|
||||
<a class="sourceLine" id="cb8-17" data-line-number="17"><span class="co"># E 0.452 0.453 0.468 0.457 0.487 0.510 10</span></a>
|
||||
<a class="sourceLine" id="cb8-18" data-line-number="18"><span class="co"># F 0.439 0.450 0.462 0.459 0.470 0.501 10</span></a>
|
||||
<a class="sourceLine" id="cb8-19" data-line-number="19"><span class="co"># G 0.450 0.460 0.476 0.480 0.492 0.496 10</span></a>
|
||||
<a class="sourceLine" id="cb8-20" data-line-number="20"><span class="co"># H 0.443 0.455 0.461 0.456 0.466 0.495 10</span></a></code></pre></div>
|
||||
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> too, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
|
||||
</div>
|
||||
<div id="results-in-other-languages" class="section level3">
|
||||
@ -464,13 +464,13 @@
|
||||
<a class="sourceLine" id="cb9-18" data-line-number="18"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</a>
|
||||
<a class="sourceLine" id="cb9-19" data-line-number="19"><span class="co"># Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb9-20" data-line-number="20"><span class="co"># expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb9-21" data-line-number="21"><span class="co"># en 17.29 17.79 18.11 18.13 18.57 18.86 10</span></a>
|
||||
<a class="sourceLine" id="cb9-22" data-line-number="22"><span class="co"># de 18.44 19.01 20.23 19.76 19.86 27.61 10</span></a>
|
||||
<a class="sourceLine" id="cb9-23" data-line-number="23"><span class="co"># nl 23.83 24.71 26.99 25.97 26.53 39.93 10</span></a>
|
||||
<a class="sourceLine" id="cb9-24" data-line-number="24"><span class="co"># es 18.71 18.88 19.43 19.24 19.47 21.88 10</span></a>
|
||||
<a class="sourceLine" id="cb9-25" data-line-number="25"><span class="co"># it 18.48 18.84 19.40 19.50 19.84 20.57 10</span></a>
|
||||
<a class="sourceLine" id="cb9-26" data-line-number="26"><span class="co"># fr 18.51 19.39 25.08 20.26 37.11 38.24 10</span></a>
|
||||
<a class="sourceLine" id="cb9-27" data-line-number="27"><span class="co"># pt 18.60 18.92 19.33 19.45 19.64 19.96 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb9-21" data-line-number="21"><span class="co"># en 18.19 18.35 18.84 18.65 18.99 20.91 10</span></a>
|
||||
<a class="sourceLine" id="cb9-22" data-line-number="22"><span class="co"># de 19.31 19.71 20.39 20.29 20.92 21.83 10</span></a>
|
||||
<a class="sourceLine" id="cb9-23" data-line-number="23"><span class="co"># nl 24.43 24.92 25.51 25.37 25.65 27.97 10</span></a>
|
||||
<a class="sourceLine" id="cb9-24" data-line-number="24"><span class="co"># es 19.22 19.53 20.06 19.82 20.47 21.81 10</span></a>
|
||||
<a class="sourceLine" id="cb9-25" data-line-number="25"><span class="co"># it 19.36 20.03 24.77 20.26 20.96 45.31 10</span></a>
|
||||
<a class="sourceLine" id="cb9-26" data-line-number="26"><span class="co"># fr 19.11 19.30 19.71 19.72 20.11 20.37 10</span></a>
|
||||
<a class="sourceLine" id="cb9-27" data-line-number="27"><span class="co"># pt 19.40 19.90 27.80 21.38 41.88 45.37 10</span></a></code></pre></div>
|
||||
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 93 KiB |
Binary file not shown.
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 61 KiB |
Binary file not shown.
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 61 KiB |
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9074</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9074</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -249,6 +249,10 @@
|
||||
<p><strong><a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a></strong>. Author, thesis advisor. <a href='https://orcid.org/0000-0003-1241-1328' target='orcid.widget'><img src='https://members.orcid.org/sites/default/files/vector_iD_icon.svg' class='orcid' alt='ORCID' height='16'></a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><strong>Judith M. Fonville</strong>. Contributor.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><strong>Erwin E. A. Hassing</strong>. Contributor.
|
||||
</p>
|
||||
|
@ -81,13 +81,14 @@ $( document ).ready(function() {
|
||||
x = x.replace(/Author, maintainer/g, "Main developer");
|
||||
x = x.replace(/Author, contributor/g, "Main contributor");
|
||||
x = x.replace(/Author, thesis advisor/g, "Doctoral advisor");
|
||||
x = x.replace("Alex", "Prof. Dr Alex");
|
||||
x = x.replace("Bhanu", "Prof. Dr Bhanu");
|
||||
x = x.replace("Casper", "Prof. Dr Casper");
|
||||
x = x.replace("Corinna", "Dr Corinna");
|
||||
x = x.replace("Alex", "Prof. Dr. Alex");
|
||||
x = x.replace("Bhanu", "Prof. Dr. Bhanu");
|
||||
x = x.replace("Casper", "Prof. Dr. Casper");
|
||||
x = x.replace("Corinna", "Dr. Corinna");
|
||||
// others
|
||||
x = x.replace("Bart", "Dr Bart");
|
||||
x = x.replace("Dennis", "Dr Dennis");
|
||||
x = x.replace("Bart", "Dr. Bart");
|
||||
x = x.replace("Dennis", "Dr. Dennis");
|
||||
x = x.replace("Judith", "Dr. Judith");
|
||||
}
|
||||
return(x);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9074</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -307,7 +307,7 @@
|
||||
<li>
|
||||
<p>It <strong>cleanses existing data</strong> by providing new <em>classes</em> for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect:</p>
|
||||
<ul>
|
||||
<li>Use <code><a href="reference/as.mo.html">as.mo()</a></code> to get a microbial ID. The IDs are human readable for the trained eye - the ID of <em>Klebsiella pneumoniae</em> is “B_KLBSL_PNE” (B stands for Bacteria) and the ID of <em>S. aureus</em> is “B_STPHY_AUR”. The function takes almost any text as input that looks like the name or code of a microorganism like “E. coli”, “esco” or “esccol” and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set. It only takes milliseconds to find results, please see our <a href="./articles/benchmarks.html">benchmarks</a>. Moreover, it can group <em>Staphylococci</em> into coagulase negative and positive (CoNS and CoPS, see <a href="./reference/as.mo.html#source">source</a>) and can categorise <em>Streptococci</em> into Lancefield groups (like beta-haemolytic <em>Streptococcus</em> Group B, <a href="./reference/as.mo.html#source">source</a>).</li>
|
||||
<li>Use <code><a href="reference/as.mo.html">as.mo()</a></code> to get a microbial ID. The IDs are human readable for the trained eye - the ID of <em>Klebsiella pneumoniae</em> is “B_KLBSL_PNMN” (B stands for Bacteria) and the ID of <em>S. aureus</em> is “B_STPHY_AURS”. The function takes almost any text as input that looks like the name or code of a microorganism like “E. coli”, “esco” or “esccol” and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set. It only takes milliseconds to find results, please see our <a href="./articles/benchmarks.html">benchmarks</a>. Moreover, it can group <em>Staphylococci</em> into coagulase negative and positive (CoNS and CoPS, see <a href="./reference/as.mo.html#source">source</a>) and can categorise <em>Streptococci</em> into Lancefield groups (like beta-haemolytic <em>Streptococcus</em> Group B, <a href="./reference/as.mo.html#source">source</a>).</li>
|
||||
<li>Use <code><a href="reference/as.ab.html">as.ab()</a></code> to get an antibiotic ID. Like microbial IDs, these IDs are also human readable based on those used by EARS-Net. For example, the ID of amoxicillin is <code>AMX</code> and the ID of gentamicin is <code>GEN</code>. The <code><a href="reference/as.ab.html">as.ab()</a></code> function also uses intelligent rules to find results like accepting misspelling, trade names and abbrevations used in many laboratory systems. For instance, the values “Furabid”, “Furadantin”, “nitro” all return the ID of Nitrofurantoine. To accomplish this, the package contains a database with most LIS codes, official names, trade names, ATC codes, defined daily doses (DDD) and drug categories of antibiotics.</li>
|
||||
<li>Use <code><a href="reference/as.rsi.html">as.rsi()</a></code> to get antibiotic interpretations based on raw MIC values (in mg/L) or disk diffusion values (in mm), or transform existing 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”.</li>
|
||||
<li>Use <code><a href="reference/as.mic.html">as.mic()</a></code> to cleanse your MIC values. It produces a so-called factor (called <em>ordinal</em> in SPSS) with valid MIC values as levels. A value like “<=0.002; S” (combined MIC/RSI) will result in “<=0.002”.</li>
|
||||
|
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9074</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -225,11 +225,11 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="amr-0-7-1-9074" class="section level1">
|
||||
<div id="amr-0-7-1-9075" class="section level1">
|
||||
<h1 class="page-header">
|
||||
<a href="#amr-0-7-1-9074" class="anchor"></a>AMR 0.7.1.9074<small> Unreleased </small>
|
||||
<a href="#amr-0-7-1-9075" class="anchor"></a>AMR 0.7.1.9075<small> Unreleased </small>
|
||||
</h1>
|
||||
<p><small>Last updated: 16-Sep-2019</small></p>
|
||||
<p><small>Last updated: 18-Sep-2019</small></p>
|
||||
<div id="breaking" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#breaking" class="anchor"></a>Breaking</h3>
|
||||
@ -305,7 +305,7 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>Many algorithm improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code> (of which some led to additions to the <code>microorganisms</code> data set):
|
||||
<li>Many algorithm improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code> (of which some led to additions to the <code>microorganisms</code> data set). Many thanks to all contributors that helped improving the algorithms.
|
||||
<ul>
|
||||
<li>Self-learning algorithm - the function now gains experience from previously determined microorganism IDs and learns from it (yielding 80-95% speed improvement for any guess after the first try)</li>
|
||||
<li>Big improvement for misspelled input</li>
|
||||
@ -314,6 +314,7 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
|
||||
<li>Added support for Viridans Group Streptococci (VGS) and Milleri Group Streptococci (MGS)</li>
|
||||
<li>Added support for 5,000 new fungi</li>
|
||||
<li>Added support for unknown yeasts and fungi</li>
|
||||
<li>Changed most microorganism IDs to improve readability. <strong>IMPORTANT:</strong> Because of these changes, the microorganism IDs have been changed to a slightly different format. Old microorganism IDs are still supported, but support will be dropped in a future version. Use <code><a href="../reference/as.mo.html">as.mo()</a></code> on your old codes to transform them to the new format.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Renamed data set <code>septic_patients</code> to <code>example_isolates</code>
|
||||
@ -351,7 +352,7 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#other" class="anchor"></a>Other</h4>
|
||||
<ul>
|
||||
<li>Added Prof Dr Casper Albers as doctoral advisor and Dr Bart Meijer, Dr Dennis Souverein and Annick Lenglet as contributors</li>
|
||||
<li>Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -1265,7 +1266,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
|
||||
<div id="tocnav">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#amr-0-7-1-9074">0.7.1.9074</a></li>
|
||||
<li><a href="#amr-0-7-1-9075">0.7.1.9075</a></li>
|
||||
<li><a href="#amr-0-7-1">0.7.1</a></li>
|
||||
<li><a href="#amr-0-7-0">0.7.0</a></li>
|
||||
<li><a href="#amr-0-6-1">0.6.1</a></li>
|
||||
|
@ -80,7 +80,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9073</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -266,7 +266,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th>allow_uncertain</th>
|
||||
<td><p>a number between 0 (or "none") and 3 (or "all"), or TRUE (= 2) or FALSE (= 0) to indicate whether the input should be checked for less possible results, see Details</p></td>
|
||||
<td><p>a number between 0 (or "none") and 3 (or "all"), or TRUE (= 2) or FALSE (= 0) to indicate whether the input should be checked for less probable results, see Details</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>reference_df</th>
|
||||
@ -286,16 +286,16 @@
|
||||
|
||||
<p><strong>General info</strong> <br />
|
||||
A microorganism ID from this package (class: <code>mo</code>) typically looks like these examples:<br /></p><pre>
|
||||
Code Full name
|
||||
--------------- --------------------------------------
|
||||
B_KLBSL Klebsiella
|
||||
B_KLBSL_PNE Klebsiella pneumoniae
|
||||
B_KLBSL_PNE_RHI Klebsiella pneumoniae rhinoscleromatis
|
||||
| | | |
|
||||
| | | |
|
||||
| | | ----> subspecies, a 3-4 letter acronym
|
||||
| | ----> species, a 3-4 letter acronym
|
||||
| ----> genus, a 5-7 letter acronym, mostly without vowels
|
||||
Code Full name
|
||||
--------------- --------------------------------------
|
||||
B_KLBSL Klebsiella
|
||||
B_KLBSL_PNMN Klebsiella pneumoniae
|
||||
B_KLBSL_PNMN_RHNS Klebsiella pneumoniae rhinoscleromatis
|
||||
| | | |
|
||||
| | | |
|
||||
| | | ---> subspecies, a 4-5 letter acronym
|
||||
| | ----> species, a 4-5 letter acronym
|
||||
| ----> genus, a 5-7 letter acronym
|
||||
----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
|
||||
C (Chromista), F (Fungi), P (Protozoa)
|
||||
</pre>
|
||||
@ -325,7 +325,7 @@ The algorithm can additionally use three different levels of uncertainty to gues
|
||||
</ul>
|
||||
<p>You can also use e.g. <code>as.mo(..., allow_uncertain = 1)</code> to only allow up to level 1 uncertainty.</p>
|
||||
<p>Examples:</p><ul>
|
||||
<li><p><code>"Streptococcus group B (known as S. agalactiae)"</code>. The text between brackets will be removed and a warning will be thrown that the result <em>Streptococcus group B</em> (<code>B_STRPT_GRB</code>) needs review.</p></li>
|
||||
<li><p><code>"Streptococcus group B (known as S. agalactiae)"</code>. The text between brackets will be removed and a warning will be thrown that the result <em>Streptococcus group B</em> (<code>B_STRPT_GRPB</code>) needs review.</p></li>
|
||||
<li><p><code>"S. aureus - please mind: MRSA"</code>. The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result <em>Staphylococcus aureus</em> (<code>B_STPHY_AUR</code>) needs review.</p></li>
|
||||
<li><p><code>"Fluoroquinolone-resistant Neisseria gonorrhoeae"</code>. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result <em>Neisseria gonorrhoeae</em> (<code>B_NESSR_GON</code>) needs review.</p></li>
|
||||
</ul>
|
||||
@ -369,7 +369,7 @@ The <code><a href='mo_property.html'>mo_property</a></code> functions (like <cod
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><span class='co'># NOT RUN {</span>
|
||||
<span class='co'># These examples all return "B_STPHY_AUR", the ID of S. aureus:</span>
|
||||
<span class='co'># These examples all return "B_STPHY_AURS", the ID of S. aureus:</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"sau"</span>) <span class='co'># WHONET code</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"stau"</span>)
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"STAU"</span>)
|
||||
@ -394,11 +394,11 @@ The <code><a href='mo_property.html'>mo_property</a></code> functions (like <cod
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"GAS"</span>) <span class='co'># Group A Streptococci</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"GBS"</span>) <span class='co'># Group B Streptococci</span>
|
||||
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"S. epidermidis"</span>) <span class='co'># will remain species: B_STPHY_EPI</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"S. epidermidis"</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># will not remain species: B_STPHY_CNS</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"S. epidermidis"</span>) <span class='co'># will remain species: B_STPHY_EPDR</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"S. epidermidis"</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># will not remain species: B_STPHY_CONS</span>
|
||||
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"S. pyogenes"</span>) <span class='co'># will remain species: B_STRPT_PYO</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"S. pyogenes"</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># will not remain species: B_STRPT_GRA</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"S. pyogenes"</span>) <span class='co'># will remain species: B_STRPT_PYGN</span>
|
||||
<span class='fu'>as.mo</span>(<span class='st'>"S. pyogenes"</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># will not remain species: B_STRPT_GRPA</span>
|
||||
|
||||
<span class='co'># All mo_* functions use as.mo() internally too (see ?mo_property):</span>
|
||||
<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='st'>"E. coli"</span>) <span class='co'># returns "Escherichia"</span>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Data set with 2,000 blood culture isolates from septic patients — example_isolates • AMR (for R)</title>
|
||||
<title>Data set with 2,000 blood culture isolates — example_isolates • AMR (for R)</title>
|
||||
|
||||
<!-- favicons -->
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
|
||||
@ -45,9 +45,9 @@
|
||||
|
||||
<link href="../extra.css" rel="stylesheet">
|
||||
<script src="../extra.js"></script>
|
||||
<meta property="og:title" content="Data set with 2,000 blood culture isolates from septic patients — example_isolates" />
|
||||
<meta property="og:title" content="Data set with 2,000 blood culture isolates — example_isolates" />
|
||||
|
||||
<meta property="og:description" content="An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This data.frame can be used to practice AMR analysis. For examples, please read the tutorial on our website." />
|
||||
<meta property="og:description" content="An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found 4 different hospitals in the Netherlands, between 2001 and 2017. This data.frame can be used to practice AMR analysis. For examples, please read the tutorial on our website." />
|
||||
|
||||
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
@ -80,7 +80,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9067</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -223,14 +223,14 @@
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Data set with 2,000 blood culture isolates from septic patients</h1>
|
||||
<h1>Data set with 2,000 blood culture isolates</h1>
|
||||
|
||||
<div class="hidden name"><code>example_isolates.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This <code>data.frame</code> can be used to practice AMR analysis. For examples, please read <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>the tutorial on our website</a>.</p>
|
||||
<p>An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found 4 different hospitals in the Netherlands, between 2001 and 2017. This <code>data.frame</code> can be used to practice AMR analysis. For examples, please read <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>the tutorial on our website</a>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
@ -248,7 +248,7 @@
|
||||
<dt><code>gender</code></dt><dd><p>gender of the patient</p></dd>
|
||||
<dt><code>patient_id</code></dt><dd><p>ID of the patient, first 10 characters of an SHA hash containing irretrievable information</p></dd>
|
||||
<dt><code>mo</code></dt><dd><p>ID of microorganism created with <code><a href='as.mo.html'>as.mo</a></code>, see also <code><a href='microorganisms.html'>microorganisms</a></code></p></dd>
|
||||
<dt><code>peni:rifa</code></dt><dd><p>40 different antibiotics with class <code>rsi</code> (see <code><a href='as.rsi.html'>as.rsi</a></code>); these column names occur in <code><a href='antibiotics.html'>antibiotics</a></code> data set and can be translated with <code><a href='ab_property.html'>ab_name</a></code></p></dd>
|
||||
<dt><code>PEN:RIF</code></dt><dd><p>40 different antibiotics with class <code>rsi</code> (see <code><a href='as.rsi.html'>as.rsi</a></code>); these column names occur in <code><a href='antibiotics.html'>antibiotics</a></code> data set and can be translated with <code><a href='ab_property.html'>ab_name</a></code></p></dd>
|
||||
</dl>
|
||||
|
||||
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
|
||||
|
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9074</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -492,7 +492,7 @@
|
||||
<td>
|
||||
<p><code><a href="example_isolates.html">example_isolates</a></code> </p>
|
||||
</td>
|
||||
<td><p>Data set with 2,000 blood culture isolates from septic patients</p></td>
|
||||
<td><p>Data set with 2,000 blood culture isolates</p></td>
|
||||
</tr><tr>
|
||||
|
||||
<td>
|
||||
@ -504,7 +504,7 @@
|
||||
<td>
|
||||
<p><code><a href="microorganisms.codes.html">microorganisms.codes</a></code> </p>
|
||||
</td>
|
||||
<td><p>Translation table for microorganism codes</p></td>
|
||||
<td><p>Translation table for common microorganism codes</p></td>
|
||||
</tr><tr>
|
||||
|
||||
<td>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Translation table for microorganism codes — microorganisms.codes • AMR (for R)</title>
|
||||
<title>Translation table for common microorganism codes — microorganisms.codes • AMR (for R)</title>
|
||||
|
||||
<!-- favicons -->
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
<link href="../extra.css" rel="stylesheet">
|
||||
<script src="../extra.js"></script>
|
||||
<meta property="og:title" content="Translation table for microorganism codes — microorganisms.codes" />
|
||||
<meta property="og:title" content="Translation table for common microorganism codes — microorganisms.codes" />
|
||||
|
||||
<meta property="og:description" content="A data set containing commonly used codes for microorganisms, from laboratory systems and WHONET. Define your own with set_mo_source." />
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -223,7 +223,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Translation table for microorganism codes</h1>
|
||||
<h1>Translation table for common microorganism codes</h1>
|
||||
|
||||
<div class="hidden name"><code>microorganisms.codes.Rd</code></div>
|
||||
</div>
|
||||
@ -238,8 +238,8 @@
|
||||
|
||||
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
|
||||
|
||||
<p>A <code><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code> with 4,965 observations and 2 variables:</p><dl class='dl-horizontal'>
|
||||
<dt><code>certe</code></dt><dd><p>Commonly used code of a microorganism</p></dd>
|
||||
<p>A <code><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code> with 4,927 observations and 2 variables:</p><dl class='dl-horizontal'>
|
||||
<dt><code>code</code></dt><dd><p>Commonly used code of a microorganism</p></dd>
|
||||
<dt><code>mo</code></dt><dd><p>ID of the microorganism in the <code><a href='microorganisms.html'>microorganisms</a></code> data set</p></dd>
|
||||
</dl>
|
||||
|
||||
|
@ -80,7 +80,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -238,7 +238,7 @@
|
||||
|
||||
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
|
||||
|
||||
<p>A <code><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code> with 69,855 observations and 16 variables:</p><dl class='dl-horizontal'>
|
||||
<p>A <code><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code> with 69,460 observations and 16 variables:</p><dl class='dl-horizontal'>
|
||||
<dt><code>mo</code></dt><dd><p>ID of microorganism as used by this package</p></dd>
|
||||
<dt><code>col_id</code></dt><dd><p>Catalogue of Life ID</p></dd>
|
||||
<dt><code>fullname</code></dt><dd><p>Full name, like <code>"Escherichia coli"</code></p></dd>
|
||||
@ -262,7 +262,7 @@
|
||||
<li><p>2 entries of <em>Staphylococcus</em> (coagulase-negative [CoNS] and coagulase-positive [CoPS])</p></li>
|
||||
<li><p>3 entries of <em>Trichomonas</em> (<em>Trichomonas vaginalis</em>, and its family and genus)</p></li>
|
||||
<li><p>5 other 'undefined' entries (unknown, unknown Gram negatives, unknown Gram positives, unknown yeast and unknown fungus)</p></li>
|
||||
<li><p>8,970 species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) that are not in the Catalogue of Life</p></li>
|
||||
<li><p>22,654 species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) overwriting records from the Catalogue of Life, since the DSMZ contain the latest taxonomic information based on recent publications</p></li>
|
||||
</ul>
|
||||
|
||||
<h2 class="hasAnchor" id="about-the-records-from-dsmz-see-source-"><a class="anchor" href="#about-the-records-from-dsmz-see-source-"></a>About the records from DSMZ (see source)</h2>
|
||||
|
@ -80,7 +80,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9075</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -238,7 +238,7 @@
|
||||
|
||||
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
|
||||
|
||||
<p>A <code><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code> with 22,932 observations and 4 variables:</p><dl class='dl-horizontal'>
|
||||
<p>A <code><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code> with 24,246 observations and 4 variables:</p><dl class='dl-horizontal'>
|
||||
<dt><code>col_id</code></dt><dd><p>Catalogue of Life ID that was originally given</p></dd>
|
||||
<dt><code>col_id_new</code></dt><dd><p>New Catalogue of Life ID that responds to an entry in the <code><a href='microorganisms.html'>microorganisms</a></code> data set</p></dd>
|
||||
<dt><code>fullname</code></dt><dd><p>Old full taxonomic name of the microorganism</p></dd>
|
||||
|
2
index.md
2
index.md
@ -123,7 +123,7 @@ The `AMR` package basically does four important things:
|
||||
|
||||
1. It **cleanses existing data** by providing new *classes* for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect:
|
||||
|
||||
* Use `as.mo()` to get a microbial ID. The IDs are human readable for the trained eye - the ID of *Klebsiella pneumoniae* is "B_KLBSL_PNE" (B stands for Bacteria) and the ID of *S. aureus* is "B_STPHY_AUR". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" or "esccol" and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set. It only takes milliseconds to find results, please see our [benchmarks](./articles/benchmarks.html). Moreover, it can group *Staphylococci* into coagulase negative and positive (CoNS and CoPS, see [source](./reference/as.mo.html#source)) and can categorise *Streptococci* into Lancefield groups (like beta-haemolytic *Streptococcus* Group B, [source](./reference/as.mo.html#source)).
|
||||
* Use `as.mo()` to get a microbial ID. The IDs are human readable for the trained eye - the ID of *Klebsiella pneumoniae* is "B_KLBSL_PNMN" (B stands for Bacteria) and the ID of *S. aureus* is "B_STPHY_AURS". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" or "esccol" and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set. It only takes milliseconds to find results, please see our [benchmarks](./articles/benchmarks.html). Moreover, it can group *Staphylococci* into coagulase negative and positive (CoNS and CoPS, see [source](./reference/as.mo.html#source)) and can categorise *Streptococci* into Lancefield groups (like beta-haemolytic *Streptococcus* Group B, [source](./reference/as.mo.html#source)).
|
||||
* Use `as.ab()` to get an antibiotic ID. Like microbial IDs, these IDs are also human readable based on those used by EARS-Net. For example, the ID of amoxicillin is `AMX` and the ID of gentamicin is `GEN`. The `as.ab()` function also uses intelligent rules to find results like accepting misspelling, trade names and abbrevations used in many laboratory systems. For instance, the values "Furabid", "Furadantin", "nitro" all return the ID of Nitrofurantoine. To accomplish this, the package contains a database with most LIS codes, official names, trade names, ATC codes, defined daily doses (DDD) and drug categories of antibiotics.
|
||||
* Use `as.rsi()` to get antibiotic interpretations based on raw MIC values (in mg/L) or disk diffusion values (in mm), or transform existing 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".
|
||||
|
34
man/as.mo.Rd
34
man/as.mo.Rd
@ -34,7 +34,7 @@ clear_mo_history(...)
|
||||
|
||||
This excludes \emph{Enterococci} at default (who are in group D), use \code{Lancefield = "all"} to also categorise all \emph{Enterococci} as group D.}
|
||||
|
||||
\item{allow_uncertain}{a number between 0 (or "none") and 3 (or "all"), or TRUE (= 2) or FALSE (= 0) to indicate whether the input should be checked for less possible results, see Details}
|
||||
\item{allow_uncertain}{a number between 0 (or "none") and 3 (or "all"), or TRUE (= 2) or FALSE (= 0) to indicate whether the input should be checked for less probable results, see Details}
|
||||
|
||||
\item{reference_df}{a \code{data.frame} to use for extra reference when translating \code{x} to a valid \code{mo}. See \code{\link{set_mo_source}} and \code{\link{get_mo_source}} to automate the usage of your own codes (e.g. used in your analysis or organisation).}
|
||||
|
||||
@ -50,16 +50,16 @@ Use this function to determine a valid microorganism ID (\code{mo}). Determinati
|
||||
\strong{General info} \cr
|
||||
A microorganism ID from this package (class: \code{mo}) typically looks like these examples:\cr
|
||||
\preformatted{
|
||||
Code Full name
|
||||
--------------- --------------------------------------
|
||||
B_KLBSL Klebsiella
|
||||
B_KLBSL_PNE Klebsiella pneumoniae
|
||||
B_KLBSL_PNE_RHI Klebsiella pneumoniae rhinoscleromatis
|
||||
| | | |
|
||||
| | | |
|
||||
| | | ----> subspecies, a 3-4 letter acronym
|
||||
| | ----> species, a 3-4 letter acronym
|
||||
| ----> genus, a 5-7 letter acronym, mostly without vowels
|
||||
Code Full name
|
||||
--------------- --------------------------------------
|
||||
B_KLBSL Klebsiella
|
||||
B_KLBSL_PNMN Klebsiella pneumoniae
|
||||
B_KLBSL_PNMN_RHNS Klebsiella pneumoniae rhinoscleromatis
|
||||
| | | |
|
||||
| | | |
|
||||
| | | ---> subspecies, a 4-5 letter acronym
|
||||
| | ----> species, a 4-5 letter acronym
|
||||
| ----> genus, a 5-7 letter acronym
|
||||
----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
|
||||
C (Chromista), F (Fungi), P (Protozoa)
|
||||
}
|
||||
@ -105,7 +105,7 @@ You can also use e.g. \code{as.mo(..., allow_uncertain = 1)} to only allow up to
|
||||
|
||||
Examples:
|
||||
\itemize{
|
||||
\item{\code{"Streptococcus group B (known as S. agalactiae)"}. The text between brackets will be removed and a warning will be thrown that the result \emph{Streptococcus group B} (\code{B_STRPT_GRB}) needs review.}
|
||||
\item{\code{"Streptococcus group B (known as S. agalactiae)"}. The text between brackets will be removed and a warning will be thrown that the result \emph{Streptococcus group B} (\code{B_STRPT_GRPB}) needs review.}
|
||||
\item{\code{"S. aureus - please mind: MRSA"}. The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result \emph{Staphylococcus aureus} (\code{B_STPHY_AUR}) needs review.}
|
||||
\item{\code{"Fluoroquinolone-resistant Neisseria gonorrhoeae"}. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result \emph{Neisseria gonorrhoeae} (\code{B_NESSR_GON}) needs review.}
|
||||
}
|
||||
@ -154,7 +154,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
|
||||
\examples{
|
||||
\donttest{
|
||||
# These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
||||
# These examples all return "B_STPHY_AURS", the ID of S. aureus:
|
||||
as.mo("sau") # WHONET code
|
||||
as.mo("stau")
|
||||
as.mo("STAU")
|
||||
@ -179,11 +179,11 @@ as.mo("Streptococcus group A")
|
||||
as.mo("GAS") # Group A Streptococci
|
||||
as.mo("GBS") # Group B Streptococci
|
||||
|
||||
as.mo("S. epidermidis") # will remain species: B_STPHY_EPI
|
||||
as.mo("S. epidermidis", Becker = TRUE) # will not remain species: B_STPHY_CNS
|
||||
as.mo("S. epidermidis") # will remain species: B_STPHY_EPDR
|
||||
as.mo("S. epidermidis", Becker = TRUE) # will not remain species: B_STPHY_CONS
|
||||
|
||||
as.mo("S. pyogenes") # will remain species: B_STRPT_PYO
|
||||
as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRA
|
||||
as.mo("S. pyogenes") # will remain species: B_STRPT_PYGN
|
||||
as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRPA
|
||||
|
||||
# All mo_* functions use as.mo() internally too (see ?mo_property):
|
||||
mo_genus("E. coli") # returns "Escherichia"
|
||||
|
@ -3,7 +3,7 @@
|
||||
\docType{data}
|
||||
\name{example_isolates}
|
||||
\alias{example_isolates}
|
||||
\title{Data set with 2,000 blood culture isolates from septic patients}
|
||||
\title{Data set with 2,000 blood culture isolates}
|
||||
\format{A \code{\link{data.frame}} with 2,000 observations and 49 variables:
|
||||
\describe{
|
||||
\item{\code{date}}{date of receipt at the laboratory}
|
||||
@ -15,13 +15,13 @@
|
||||
\item{\code{gender}}{gender of the patient}
|
||||
\item{\code{patient_id}}{ID of the patient, first 10 characters of an SHA hash containing irretrievable information}
|
||||
\item{\code{mo}}{ID of microorganism created with \code{\link{as.mo}}, see also \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{ab_name}}}
|
||||
\item{\code{PEN:RIF}}{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{ab_name}}}
|
||||
}}
|
||||
\usage{
|
||||
example_isolates
|
||||
}
|
||||
\description{
|
||||
An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This \code{data.frame} can be used to practice AMR analysis. For examples, please read \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{the tutorial on our website}.
|
||||
An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found 4 different hospitals in the Netherlands, between 2001 and 2017. This \code{data.frame} can be used to practice AMR analysis. For examples, please read \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{the tutorial on our website}.
|
||||
}
|
||||
\section{Read more on our website!}{
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
\name{microorganisms}
|
||||
\alias{microorganisms}
|
||||
\title{Data set with ~70,000 microorganisms}
|
||||
\format{A \code{\link{data.frame}} with 69,855 observations and 16 variables:
|
||||
\format{A \code{\link{data.frame}} with 69,460 observations and 16 variables:
|
||||
\describe{
|
||||
\item{\code{mo}}{ID of microorganism as used by this package}
|
||||
\item{\code{col_id}}{Catalogue of Life ID}
|
||||
@ -34,7 +34,7 @@ Manually added were:
|
||||
\item{2 entries of \emph{Staphylococcus} (coagulase-negative [CoNS] and coagulase-positive [CoPS])}
|
||||
\item{3 entries of \emph{Trichomonas} (\emph{Trichomonas vaginalis}, and its family and genus)}
|
||||
\item{5 other 'undefined' entries (unknown, unknown Gram negatives, unknown Gram positives, unknown yeast and unknown fungus)}
|
||||
\item{8,970 species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) that are not in the Catalogue of Life}
|
||||
\item{22,654 species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) overwriting records from the Catalogue of Life, since the DSMZ contain the latest taxonomic information based on recent publications}
|
||||
}
|
||||
}
|
||||
\section{About the records from DSMZ (see source)}{
|
||||
|
@ -3,10 +3,10 @@
|
||||
\docType{data}
|
||||
\name{microorganisms.codes}
|
||||
\alias{microorganisms.codes}
|
||||
\title{Translation table for microorganism codes}
|
||||
\format{A \code{\link{data.frame}} with 4,965 observations and 2 variables:
|
||||
\title{Translation table for common microorganism codes}
|
||||
\format{A \code{\link{data.frame}} with 4,927 observations and 2 variables:
|
||||
\describe{
|
||||
\item{\code{certe}}{Commonly used code of a microorganism}
|
||||
\item{\code{code}}{Commonly used code of a microorganism}
|
||||
\item{\code{mo}}{ID of the microorganism in the \code{\link{microorganisms}} data set}
|
||||
}}
|
||||
\usage{
|
||||
|
@ -4,7 +4,7 @@
|
||||
\name{microorganisms.old}
|
||||
\alias{microorganisms.old}
|
||||
\title{Data set with previously accepted taxonomic names}
|
||||
\format{A \code{\link{data.frame}} with 22,932 observations and 4 variables:
|
||||
\format{A \code{\link{data.frame}} with 24,246 observations and 4 variables:
|
||||
\describe{
|
||||
\item{\code{col_id}}{Catalogue of Life ID that was originally given}
|
||||
\item{\code{col_id_new}}{New Catalogue of Life ID that responds to an entry in the \code{\link{microorganisms}} data set}
|
||||
|
@ -81,13 +81,14 @@ $( document ).ready(function() {
|
||||
x = x.replace(/Author, maintainer/g, "Main developer");
|
||||
x = x.replace(/Author, contributor/g, "Main contributor");
|
||||
x = x.replace(/Author, thesis advisor/g, "Doctoral advisor");
|
||||
x = x.replace("Alex", "Prof. Dr Alex");
|
||||
x = x.replace("Bhanu", "Prof. Dr Bhanu");
|
||||
x = x.replace("Casper", "Prof. Dr Casper");
|
||||
x = x.replace("Corinna", "Dr Corinna");
|
||||
x = x.replace("Alex", "Prof. Dr. Alex");
|
||||
x = x.replace("Bhanu", "Prof. Dr. Bhanu");
|
||||
x = x.replace("Casper", "Prof. Dr. Casper");
|
||||
x = x.replace("Corinna", "Dr. Corinna");
|
||||
// others
|
||||
x = x.replace("Bart", "Dr Bart");
|
||||
x = x.replace("Dennis", "Dr Dennis");
|
||||
x = x.replace("Bart", "Dr. Bart");
|
||||
x = x.replace("Dennis", "Dr. Dennis");
|
||||
x = x.replace("Judith", "Dr. Judith");
|
||||
}
|
||||
return(x);
|
||||
}
|
||||
|
@ -190,19 +190,19 @@ test_that("first isolates work", {
|
||||
|
||||
# unknown MOs
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", "UNKNOWN", mo)) %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COLI", "UNKNOWN", mo)) %>%
|
||||
mutate(first = first_isolate(., include_unknown = FALSE)) %>%
|
||||
.$first %>%
|
||||
sum(),
|
||||
1062)
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", "UNKNOWN", mo)) %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COLI", "UNKNOWN", mo)) %>%
|
||||
mutate(first = first_isolate(., include_unknown = TRUE)) %>%
|
||||
.$first %>%
|
||||
sum(),
|
||||
1529)
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", NA, mo)) %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COLI", NA, mo)) %>%
|
||||
mutate(first = first_isolate(.)) %>%
|
||||
.$first %>%
|
||||
sum(),
|
||||
|
@ -26,8 +26,8 @@ test_that("frequency table works", {
|
||||
# mo
|
||||
expect_true(is.freq(freq(example_isolates$mo)))
|
||||
# for this to work, the output of mo_gramstain() is to be expected as follows:
|
||||
expect_equal(mo_gramstain("B_ESCHR_COL", language = NULL), "Gram-negative")
|
||||
expect_equal(mo_gramstain("B_STPHY_AUR", language = NULL), "Gram-positive")
|
||||
expect_equal(mo_gramstain("B_ESCHR_COLI", language = NULL), "Gram-negative")
|
||||
expect_equal(mo_gramstain("B_STPHY_AURS", language = NULL), "Gram-positive")
|
||||
|
||||
# rsi
|
||||
expect_true(is.freq(freq(example_isolates$AMX)))
|
||||
|
@ -45,17 +45,17 @@ test_that("joins work", {
|
||||
expect_true(nrow(unjoined) < nrow(full))
|
||||
|
||||
|
||||
expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COL")), 1)
|
||||
expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COL", by = c("mo" = "mo"))), 1)
|
||||
expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COLI")), 1)
|
||||
expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COLI", by = c("mo" = "mo"))), 1)
|
||||
expect_warning(inner_join_microorganisms("Escherichia", by = c("mo" = "genus")))
|
||||
|
||||
expect_equal(nrow(left_join_microorganisms("B_ESCHR_COL")), 1)
|
||||
expect_equal(nrow(left_join_microorganisms("B_ESCHR_COLI")), 1)
|
||||
expect_warning(left_join_microorganisms("Escherichia", by = c("mo" = "genus")))
|
||||
|
||||
expect_equal(nrow(semi_join_microorganisms("B_ESCHR_COL")), 1)
|
||||
expect_equal(nrow(anti_join_microorganisms("B_ESCHR_COL")), 0)
|
||||
expect_equal(nrow(semi_join_microorganisms("B_ESCHR_COLI")), 1)
|
||||
expect_equal(nrow(anti_join_microorganisms("B_ESCHR_COLI")), 0)
|
||||
|
||||
expect_warning(right_join_microorganisms("B_ESCHR_COL"))
|
||||
expect_warning(full_join_microorganisms("B_ESCHR_COL"))
|
||||
expect_warning(right_join_microorganisms("B_ESCHR_COLI"))
|
||||
expect_warning(full_join_microorganisms("B_ESCHR_COLI"))
|
||||
|
||||
})
|
||||
|
@ -40,7 +40,7 @@ test_that("mdro works", {
|
||||
|
||||
# example_isolates should have these finding using Dutch guidelines
|
||||
expect_equal(outcome %>% freq() %>% pull(count),
|
||||
c(1969, 25, 6)) # 1969 neg, 25 unconfirmed, 6 pos
|
||||
c(1972, 22, 6)) # 1969 neg, 25 unconfirmed, 6 pos
|
||||
|
||||
expect_equal(brmo(example_isolates, info = FALSE),
|
||||
mdro(example_isolates, guideline = "BRMO", info = FALSE))
|
||||
|
@ -31,49 +31,50 @@ test_that("as.mo works", {
|
||||
|
||||
expect_identical(
|
||||
as.character(as.mo(c("E. coli", "H. influenzae"))),
|
||||
c("B_ESCHR_COL", "B_HMPHL_INF"))
|
||||
c("B_ESCHR_COLI", "B_HMPHL_INFL"))
|
||||
|
||||
expect_equal(as.character(as.mo("Escherichia coli")), "B_ESCHR_COL")
|
||||
expect_equal(as.character(as.mo("Escherichia coli")), "B_ESCHR_COL")
|
||||
expect_equal(as.character(as.mo(22242416)), "B_ESCHR_COL")
|
||||
expect_equal(as.character(as.mo("Escherichia coli")), "B_ESCHR_COLI")
|
||||
expect_equal(as.character(as.mo("Escherichia coli")), "B_ESCHR_COLI")
|
||||
expect_equal(as.character(as.mo(22242416)), "B_ESCHR_COLI")
|
||||
expect_equal(as.character(as.mo("Escherichia species")), "B_ESCHR")
|
||||
expect_equal(as.character(as.mo("Escherichia")), "B_ESCHR")
|
||||
expect_equal(as.character(as.mo("Esch spp.")), "B_ESCHR")
|
||||
expect_equal(as.character(as.mo(" B_ESCHR_COL ")), "B_ESCHR_COL")
|
||||
expect_equal(as.character(as.mo("e coli")), "B_ESCHR_COL") # not Campylobacter
|
||||
expect_equal(as.character(as.mo("klpn")), "B_KLBSL_PNE")
|
||||
expect_equal(as.character(as.mo(" B_ESCHR_COLI ")), "B_ESCHR_COLI")
|
||||
expect_equal(as.character(as.mo("e coli")), "B_ESCHR_COLI") # not Campylobacter
|
||||
expect_equal(as.character(as.mo("klpn")), "B_KLBSL_PNMN")
|
||||
expect_equal(as.character(as.mo("Klebsiella")), "B_KLBSL")
|
||||
expect_equal(as.character(as.mo("K. pneu rhino")), "B_KLBSL_PNE_RHI") # K. pneumoniae subspp. rhinoscleromatis
|
||||
expect_equal(as.character(as.mo("K. pneu rhino")), "B_KLBSL_PNMN_RHNS") # K. pneumoniae subspp. rhinoscleromatis
|
||||
expect_equal(as.character(as.mo("Bartonella")), "B_BRTNL")
|
||||
expect_equal(as.character(as.mo("C. difficile")), "B_CLSTR_DIF")
|
||||
expect_equal(as.character(as.mo("L. pneumophila")), "B_LGNLL_PNE")
|
||||
expect_equal(as.character(as.mo("C. difficile")), "B_CTRDM_DFFC")
|
||||
expect_equal(as.character(as.mo("L. pneumophila")), "B_LGNLL_PNMP")
|
||||
expect_equal(as.character(as.mo("Strepto")), "B_STRPT")
|
||||
expect_equal(as.character(as.mo("Streptococcus")), "B_STRPT") # not Peptostreptoccus
|
||||
expect_equal(as.character(as.mo("Estreptococos grupo B")), "B_STRPT_GRB")
|
||||
expect_equal(as.character(as.mo("Group B Streptococci")), "B_STRPT_GRB")
|
||||
expect_equal(as.character(as.mo("B_STRPTC")), "B_STRPT") # old MO code (<=v0.5.0)
|
||||
expect_equal(as.character(as.mo("Estreptococos grupo B")), "B_STRPT_GRPB")
|
||||
expect_equal(as.character(as.mo("Group B Streptococci")), "B_STRPT_GRPB")
|
||||
expect_equal(as.character(suppressWarnings(as.mo("B_STRPTC"))), "B_STRPT") # old MO code (<=v0.5.0)
|
||||
expect_equal(as.character(suppressWarnings(as.mo("B_STRPT_PNE"))), "B_STRPT_PNMN") # old MO code (<=v0.8.0)
|
||||
|
||||
expect_equal(as.character(as.mo(c("GAS", "GBS"))), c("B_STRPT_GRA", "B_STRPT_GRB"))
|
||||
expect_equal(as.character(as.mo(c("GAS", "GBS"))), c("B_STRPT_GRPA", "B_STRPT_GRPB"))
|
||||
|
||||
expect_equal(as.character(as.mo("S. pyo")), "B_STRPT_PYO") # not Actinomyces pyogenes
|
||||
expect_equal(as.character(as.mo("S. pyo")), "B_STRPT_PYGN") # not Actinomyces pyogenes
|
||||
|
||||
# GLIMS
|
||||
expect_equal(as.character(as.mo("bctfgr")), "B_BCTRD_FRA")
|
||||
expect_equal(as.character(as.mo("bctfgr")), "B_BCTRD_FRGL")
|
||||
|
||||
expect_equal(as.character(as.mo("MRSE")), "B_STPHY_EPI")
|
||||
expect_equal(as.character(as.mo("MRSE")), "B_STPHY_EPDR")
|
||||
expect_equal(as.character(as.mo("VRE")), "B_ENTRC")
|
||||
expect_equal(as.character(as.mo("MRPA")), "B_PSDMN_AER")
|
||||
expect_equal(as.character(as.mo("PISP")), "B_STRPT_PNE")
|
||||
expect_equal(as.character(as.mo("PRSP")), "B_STRPT_PNE")
|
||||
expect_equal(as.character(as.mo("VISP")), "B_STRPT_PNE")
|
||||
expect_equal(as.character(as.mo("VRSP")), "B_STRPT_PNE")
|
||||
expect_equal(as.character(as.mo("MRPA")), "B_PSDMN_ARGN")
|
||||
expect_equal(as.character(as.mo("PISP")), "B_STRPT_PNMN")
|
||||
expect_equal(as.character(as.mo("PRSP")), "B_STRPT_PNMN")
|
||||
expect_equal(as.character(as.mo("VISP")), "B_STRPT_PNMN")
|
||||
expect_equal(as.character(as.mo("VRSP")), "B_STRPT_PNMN")
|
||||
|
||||
expect_equal(as.character(as.mo("CNS")), "B_STPHY_CNS")
|
||||
expect_equal(as.character(as.mo("CoNS")), "B_STPHY_CNS")
|
||||
expect_equal(as.character(as.mo("CPS")), "B_STPHY_CPS")
|
||||
expect_equal(as.character(as.mo("CoPS")), "B_STPHY_CPS")
|
||||
expect_equal(as.character(as.mo("VGS")), "B_STRPT_VIR")
|
||||
expect_equal(as.character(as.mo("streptococcus milleri")), "B_STRPT_MIL")
|
||||
expect_equal(as.character(as.mo("CNS")), "B_STPHY_CONS")
|
||||
expect_equal(as.character(as.mo("CoNS")), "B_STPHY_CONS")
|
||||
expect_equal(as.character(as.mo("CPS")), "B_STPHY_COPS")
|
||||
expect_equal(as.character(as.mo("CoPS")), "B_STPHY_COPS")
|
||||
expect_equal(as.character(as.mo("VGS")), "B_STRPT_VIRI")
|
||||
expect_equal(as.character(as.mo("streptococcus milleri")), "B_STRPT_MILL")
|
||||
|
||||
|
||||
expect_equal(as.character(as.mo(c("Gram negative", "Gram positive"))), c("B_GRAMN", "B_GRAMP"))
|
||||
@ -90,11 +91,11 @@ test_that("as.mo works", {
|
||||
"Staphylococcus aureus",
|
||||
"MRSA",
|
||||
"VISA")))),
|
||||
rep("B_STPHY_AUR", 9))
|
||||
rep("B_STPHY_AURS", 9))
|
||||
expect_identical(
|
||||
as.character(
|
||||
as.mo(c('EHEC', 'EPEC', 'EIEC', 'STEC', 'ATEC', 'UPEC'))),
|
||||
rep("B_ESCHR_COL", 6))
|
||||
rep("B_ESCHR_COLI", 6))
|
||||
# unprevalent MO
|
||||
expect_identical(
|
||||
as.character(
|
||||
@ -102,7 +103,7 @@ test_that("as.mo works", {
|
||||
"B. nodosa",
|
||||
"B nodosa",
|
||||
"Burkholderia nodosa"))),
|
||||
rep("B_BRKHL_NOD", 4))
|
||||
rep("B_BRKHL_NODS", 4))
|
||||
|
||||
# empty values
|
||||
expect_identical(as.character(as.mo(c("", NA, NaN))), rep(NA_character_, 3))
|
||||
@ -110,40 +111,40 @@ test_that("as.mo works", {
|
||||
expect_warning(as.mo("ab"))
|
||||
|
||||
expect_equal(suppressWarnings(as.character(as.mo(c("Qq species", "", "CRS", "K. pneu rhino", "esco")))),
|
||||
c("UNKNOWN", NA_character_, "B_STNTR_MAL", "B_KLBSL_PNE_RHI", "B_ESCHR_COL"))
|
||||
c("UNKNOWN", NA_character_, "B_STNTR_MLTP", "B_KLBSL_PNMN_RHNS", "B_ESCHR_COLI"))
|
||||
|
||||
# check for Becker classification
|
||||
expect_identical(as.character(as.mo("S. epidermidis", Becker = FALSE)), "B_STPHY_EPI")
|
||||
expect_identical(as.character(as.mo("S. epidermidis", Becker = TRUE)), "B_STPHY_CNS")
|
||||
expect_identical(as.character(as.mo("STAEPI", Becker = TRUE)), "B_STPHY_CNS")
|
||||
expect_identical(as.character(as.mo("S. intermedius", Becker = FALSE)), "B_STPHY_INT")
|
||||
expect_identical(as.character(as.mo("Sta intermedius",Becker = FALSE)), "B_STPHY_INT")
|
||||
expect_identical(as.character(as.mo("Sta intermedius",Becker = TRUE)), "B_STPHY_CPS")
|
||||
expect_identical(as.character(as.mo("STAINT", Becker = TRUE)), "B_STPHY_CPS")
|
||||
expect_identical(as.character(as.mo("S. epidermidis", Becker = FALSE)), "B_STPHY_EPDR")
|
||||
expect_identical(as.character(as.mo("S. epidermidis", Becker = TRUE)), "B_STPHY_CONS")
|
||||
expect_identical(as.character(as.mo("STAEPI", Becker = TRUE)), "B_STPHY_CONS")
|
||||
expect_identical(as.character(as.mo("S. intermedius", Becker = FALSE)), "B_STPHY_INTR")
|
||||
expect_identical(as.character(as.mo("Sta intermedius",Becker = FALSE)), "B_STPHY_INTR")
|
||||
expect_identical(as.character(as.mo("Sta intermedius",Becker = TRUE)), "B_STPHY_COPS")
|
||||
expect_identical(as.character(as.mo("STAINT", Becker = TRUE)), "B_STPHY_COPS")
|
||||
# aureus must only be influenced if Becker = "all"
|
||||
expect_identical(as.character(as.mo("STAAUR", Becker = FALSE)), "B_STPHY_AUR")
|
||||
expect_identical(as.character(as.mo("STAAUR", Becker = TRUE)), "B_STPHY_AUR")
|
||||
expect_identical(as.character(as.mo("STAAUR", Becker = "all")), "B_STPHY_CPS")
|
||||
expect_identical(as.character(as.mo("STAAUR", Becker = FALSE)), "B_STPHY_AURS")
|
||||
expect_identical(as.character(as.mo("STAAUR", Becker = TRUE)), "B_STPHY_AURS")
|
||||
expect_identical(as.character(as.mo("STAAUR", Becker = "all")), "B_STPHY_COPS")
|
||||
|
||||
# check for Lancefield classification
|
||||
expect_identical(as.character(as.mo("S. pyogenes", Lancefield = FALSE)), "B_STRPT_PYO")
|
||||
expect_identical(as.character(as.mo("S. pyogenes", Lancefield = TRUE)), "B_STRPT_GRA")
|
||||
expect_identical(as.character(as.mo("STCPYO", Lancefield = TRUE)), "B_STRPT_GRA") # group A
|
||||
expect_identical(as.character(as.mo("S. agalactiae", Lancefield = FALSE)), "B_STRPT_AGA")
|
||||
expect_identical(as.character(as.mo("S. agalactiae", Lancefield = TRUE)), "B_STRPT_GRB") # group B
|
||||
expect_identical(as.character(suppressWarnings(as.mo("estreptococos grupo B"))), "B_STRPT_GRB")
|
||||
expect_identical(as.character(as.mo("S. equisimilis", Lancefield = FALSE)), "B_STRPT_DYS_EQU")
|
||||
expect_identical(as.character(as.mo("S. equisimilis", Lancefield = TRUE)), "B_STRPT_GRC") # group C
|
||||
expect_identical(as.character(as.mo("S. pyogenes", Lancefield = FALSE)), "B_STRPT_PYGN")
|
||||
expect_identical(as.character(as.mo("S. pyogenes", Lancefield = TRUE)), "B_STRPT_GRPA")
|
||||
expect_identical(as.character(as.mo("STCPYO", Lancefield = TRUE)), "B_STRPT_GRPA") # group A
|
||||
expect_identical(as.character(as.mo("S. agalactiae", Lancefield = FALSE)), "B_STRPT_AGLC")
|
||||
expect_identical(as.character(as.mo("S. agalactiae", Lancefield = TRUE)), "B_STRPT_GRPB") # group B
|
||||
expect_identical(as.character(suppressWarnings(as.mo("estreptococos grupo B"))), "B_STRPT_GRPB")
|
||||
expect_identical(as.character(as.mo("S. equisimilis", Lancefield = FALSE)), "B_STRPT_DYSG_EQSM")
|
||||
expect_identical(as.character(as.mo("S. equisimilis", Lancefield = TRUE)), "B_STRPT_GRPC") # group C
|
||||
# Enterococci must only be influenced if Lancefield = "all"
|
||||
expect_identical(as.character(as.mo("E. faecium", Lancefield = FALSE)), "B_ENTRC_IUM")
|
||||
expect_identical(as.character(as.mo("E. faecium", Lancefield = TRUE)), "B_ENTRC_IUM")
|
||||
expect_identical(as.character(as.mo("E. faecium", Lancefield = "all")), "B_STRPT_GRD") # group D
|
||||
expect_identical(as.character(as.mo("S. anginosus", Lancefield = FALSE)), "B_STRPT_ANG")
|
||||
expect_identical(as.character(as.mo("S. anginosus", Lancefield = TRUE)), "B_STRPT_GRF") # group F
|
||||
expect_identical(as.character(as.mo("S. sanguinis", Lancefield = FALSE)), "B_STRPT_SAN")
|
||||
expect_identical(as.character(as.mo("S. sanguinis", Lancefield = TRUE)), "B_STRPT_GRH") # group H
|
||||
expect_identical(as.character(as.mo("S. salivarius", Lancefield = FALSE)), "B_STRPT_SAL")
|
||||
expect_identical(as.character(as.mo("S. salivarius", Lancefield = TRUE)), "B_STRPT_GRK") # group K
|
||||
expect_identical(as.character(as.mo("E. faecium", Lancefield = FALSE)), "B_ENTRC_FACM")
|
||||
expect_identical(as.character(as.mo("E. faecium", Lancefield = TRUE)), "B_ENTRC_FACM")
|
||||
expect_identical(as.character(as.mo("E. faecium", Lancefield = "all")), "B_STRPT_GRPD") # group D
|
||||
expect_identical(as.character(as.mo("S. anginosus", Lancefield = FALSE)), "B_STRPT_ANGN")
|
||||
expect_identical(as.character(as.mo("S. anginosus", Lancefield = TRUE)), "B_STRPT_GRPF") # group F
|
||||
expect_identical(as.character(as.mo("S. sanguinis", Lancefield = FALSE)), "B_STRPT_SNGN")
|
||||
expect_identical(as.character(as.mo("S. sanguinis", Lancefield = TRUE)), "B_STRPT_GRPH") # group H
|
||||
expect_identical(as.character(as.mo("S. salivarius", Lancefield = FALSE)), "B_STRPT_SLVR")
|
||||
expect_identical(as.character(as.mo("S. salivarius", Lancefield = TRUE)), "B_STRPT_GRPK") # group K
|
||||
|
||||
library(dplyr)
|
||||
|
||||
@ -173,14 +174,14 @@ test_that("as.mo works", {
|
||||
expect_error(example_isolates %>% select(1:3) %>% as.mo())
|
||||
|
||||
# print
|
||||
expect_output(print(as.mo(c("B_ESCHR_COL", NA))))
|
||||
expect_output(print(as.mo(c("B_ESCHR_COLI", NA))))
|
||||
|
||||
# test pull
|
||||
expect_equal(nrow(example_isolates %>% mutate(mo = as.mo(mo))),
|
||||
2000)
|
||||
|
||||
# test data.frame
|
||||
expect_equal(nrow(data.frame(test = as.mo("B_ESCHR_COL"))),
|
||||
expect_equal(nrow(data.frame(test = as.mo("B_ESCHR_COLI"))),
|
||||
1)
|
||||
|
||||
# check empty values
|
||||
@ -188,40 +189,40 @@ test_that("as.mo works", {
|
||||
NA_character_)
|
||||
|
||||
# check less prevalent MOs
|
||||
expect_equal(as.character(as.mo("Gomphosphaeria aponina delicatula")), "B_GMPHS_APO_DEL")
|
||||
expect_equal(as.character(as.mo("Gomphosphaeria apo del")), "B_GMPHS_APO_DEL")
|
||||
expect_equal(as.character(as.mo("G apo deli")), "B_GMPHS_APO_DEL")
|
||||
expect_equal(as.character(as.mo("Gomphosphaeria aponina")), "B_GMPHS_APO")
|
||||
expect_equal(as.character(as.mo("Gomphosphaeria aponina delicatula")), "B_GMPHS_APNN_DLCT")
|
||||
expect_equal(as.character(as.mo("Gomphosphaeria apo del")), "B_GMPHS_APNN_DLCT")
|
||||
expect_equal(as.character(as.mo("G apo deli")), "B_GMPHS_APNN_DLCT")
|
||||
expect_equal(as.character(as.mo("Gomphosphaeria aponina")), "B_GMPHS_APNN")
|
||||
expect_equal(as.character(as.mo("Gomphosphaeria species")), "B_GMPHS")
|
||||
expect_equal(as.character(as.mo("Gomphosphaeria")), "B_GMPHS")
|
||||
expect_equal(as.character(as.mo(" B_GMPHS_APO ")), "B_GMPHS_APO")
|
||||
expect_equal(as.character(as.mo("g aponina")), "B_GMPHS_APO")
|
||||
expect_equal(as.character(as.mo(" B_GMPHS_APNN ")), "B_GMPHS_APNN")
|
||||
expect_equal(as.character(as.mo("g aponina")), "B_GMPHS_APNN")
|
||||
|
||||
# check old names
|
||||
expect_equal(suppressMessages(as.character(as.mo("Escherichia blattae"))), "B_SHMWL_BLA")
|
||||
expect_equal(suppressMessages(as.character(as.mo("Escherichia blattae"))), "B_SHMWL_BLTT")
|
||||
print(mo_renamed())
|
||||
|
||||
# check uncertain names
|
||||
expect_equal(suppressWarnings(as.character(as.mo("staaur extratest", allow_uncertain = TRUE))), "B_STPHY_AUR")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("staaur extratest", allow_uncertain = TRUE))), "B_STPHY_AURS")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("staaur extratest", allow_uncertain = FALSE))), "UNKNOWN")
|
||||
expect_warning(as.mo("esco extra_text", allow_uncertain = TRUE))
|
||||
expect_equal(suppressWarnings(as.character(as.mo("unexisting aureus", allow_uncertain = 3))), "B_STPHY_AUR")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("unexisting aureus", allow_uncertain = 3))), "B_STPHY_AURS")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("unexisting staphy", allow_uncertain = 3))), "B_STPHY")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("Staphylococcus aureus unexisting", allow_uncertain = 3))), "B_STPHY_AUR")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("Staphylococcus aureus unexisting", allow_uncertain = 3))), "B_STPHY_AURS")
|
||||
|
||||
# predefined reference_df
|
||||
expect_equal(as.character(as.mo("TestingOwnID",
|
||||
reference_df = data.frame(mycol = "TestingOwnID", mo = "B_ESCHR_COL"))),
|
||||
"B_ESCHR_COL")
|
||||
reference_df = data.frame(mycol = "TestingOwnID", mo = "B_ESCHR_COLI"))),
|
||||
"B_ESCHR_COLI")
|
||||
expect_equal(as.character(as.mo(c("TestingOwnID", "E. coli"),
|
||||
reference_df = data.frame(mycol = "TestingOwnID", mo = "B_ESCHR_COL"))),
|
||||
c("B_ESCHR_COL", "B_ESCHR_COL"))
|
||||
reference_df = data.frame(mycol = "TestingOwnID", mo = "B_ESCHR_COLI"))),
|
||||
c("B_ESCHR_COLI", "B_ESCHR_COLI"))
|
||||
expect_warning(as.mo("TestingOwnID", reference_df = NULL))
|
||||
expect_error(as.mo("E. coli", reference_df = data.frame(mycol = "TestingOwnID")))
|
||||
|
||||
# combination of existing mo and other code
|
||||
expect_identical(as.character(as.mo(c("B_ESCHR_COL", "ESCCOL"))),
|
||||
c("B_ESCHR_COL", "B_ESCHR_COL"))
|
||||
expect_identical(suppressWarnings(as.character(as.mo(c("B_ESCHR_COL", "ESCCOL")))),
|
||||
c("B_ESCHR_COLI", "B_ESCHR_COLI"))
|
||||
|
||||
# expect_equal(mo_fullname(c("E. spp.",
|
||||
# "E. spp",
|
||||
@ -230,24 +231,24 @@ test_that("as.mo works", {
|
||||
|
||||
# from different sources
|
||||
expect_equal(as.character(as.mo(
|
||||
c("PRTMIR", "bclcer", "B_ESCHR_COL"))),
|
||||
c("B_PROTS_MIR", "B_BCLLS_CER", "B_ESCHR_COL"))
|
||||
c("PRTMIR", "bclcer", "B_ESCHR_COLI"))),
|
||||
c("B_PROTS_MRBL", "B_BCLLS_CERS", "B_ESCHR_COLI"))
|
||||
|
||||
# hard to find
|
||||
expect_equal(as.character(suppressWarnings(as.mo(
|
||||
c("Microbacterium paraoxidans",
|
||||
"Streptococcus suis (bovis gr)",
|
||||
"Raoultella (here some text) terrigena")))),
|
||||
c("B_MCRBC_PAR", "B_STRPT_SUI", "B_RLTLL_TER"))
|
||||
print(mo_uncertainties())
|
||||
c("B_MCRBC_PRXY", "B_STRPT_SUIS", "B_RLTLL_TRRG"))
|
||||
expect_output(print(mo_uncertainties()))
|
||||
|
||||
# Salmonella (City) are all actually Salmonella enterica spp (City)
|
||||
expect_equal(as.character(suppressWarnings(as.mo("Salmonella Goettingen"))),
|
||||
"B_SLMNL_ENT")
|
||||
"B_SLMNL_ENTR")
|
||||
expect_equal(as.character(as.mo("Salmonella Group A")), "B_SLMNL")
|
||||
|
||||
# no virusses
|
||||
expect_warning(as.mo("Virus"))
|
||||
expect_equal(as.character(as.mo("Virus")), NA_character_)
|
||||
|
||||
# summary
|
||||
expect_equal(length(summary(example_isolates$mo)), 6)
|
||||
@ -257,7 +258,7 @@ test_that("as.mo works", {
|
||||
rep(NA_character_, 3))
|
||||
expect_equal(as.character(as.mo("con")), "UNKNOWN")
|
||||
expect_equal(as.character(as.mo("xxx")), NA_character_)
|
||||
expect_equal(as.character(as.mo(c("xxx", "con", "eco"))), c(NA_character_, "UNKNOWN", "B_ESCHR_COL"))
|
||||
expect_equal(as.character(as.mo(c("xxx", "con", "eco"))), c(NA_character_, "UNKNOWN", "B_ESCHR_COLI"))
|
||||
expect_equal(as.character(as.mo(c("other", "none", "unknown"))),
|
||||
rep("UNKNOWN", 3))
|
||||
|
||||
@ -271,21 +272,21 @@ test_that("as.mo works", {
|
||||
expect_error(translate_allow_uncertain(5))
|
||||
|
||||
# very old MO codes (<= v0.5.0)
|
||||
expect_equal(as.character(as.mo("F_CCCCS_NEO")), "F_CRYPT_NEO")
|
||||
expect_equal(as.character(as.mo("F_CANDD_GLB")), "F_CANDD_GLA")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("F_CCCCS_NEO"))), "F_CRYPT_NFRM")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("F_CANDD_GLB"))), "F_CANDD_GLBR")
|
||||
|
||||
# debug mode
|
||||
expect_output(print(suppressMessages(suppressWarnings(as.mo("kshgcjkhsdgkshjdfsfvsdfv", debug = TRUE, allow_uncertain = 3)))))
|
||||
|
||||
# ..coccus
|
||||
expect_equal(as.character(as.mo(c("meningococ", "gonococ", "pneumococ"))),
|
||||
c("B_NESSR_MEN", "B_NESSR_GON", "B_STRPT_PNE"))
|
||||
c("B_NESSR_MNNG", "B_NESSR_GNRR", "B_STRPT_PNMN"))
|
||||
# yeasts and fungi
|
||||
expect_equal(suppressWarnings(as.character(as.mo(c("yeasts", "fungi")))),
|
||||
c("F_YEAST", "F_FUNGUS"))
|
||||
|
||||
# print tibble
|
||||
expect_output(print(tibble(mo = as.mo("B_STRPT_PNE"))))
|
||||
expect_output(print(tibble(mo = as.mo("B_ESCHR_COLI"))))
|
||||
|
||||
# assigning and subsetting
|
||||
x <- example_isolates$mo
|
||||
|
@ -57,7 +57,7 @@ test_that("mo_property works", {
|
||||
expect_equal(mo_shortname("Streptococcus agalactiae"), "S. agalactiae")
|
||||
expect_equal(mo_shortname("Streptococcus agalactiae", Lancefield = TRUE), "GBS")
|
||||
|
||||
expect_true(mo_url("Escherichia coli") %like% "www.catalogueoflife.org")
|
||||
#expect_true(mo_url("Escherichia coli") %like% "www.catalogueoflife.org")
|
||||
|
||||
# test integrity
|
||||
MOs <- AMR::microorganisms
|
||||
|
@ -45,7 +45,7 @@ test_that("read 4D works", {
|
||||
expect_equal(ncol(x), 11)
|
||||
expect_equal(class(x$date_received), "Date")
|
||||
expect_equal(class(x$mo), "mo")
|
||||
expect_equal(as.character(x$mo), "B_ESCHR_COL")
|
||||
expect_equal(as.character(x$mo), "B_ESCHR_COLI")
|
||||
expect_equal(is.rsi(x$peni), TRUE)
|
||||
|
||||
})
|
||||
|
@ -23,7 +23,7 @@ context("resistance_predict.R")
|
||||
|
||||
test_that("prediction of rsi works", {
|
||||
AMX_R <- example_isolates %>%
|
||||
filter(mo == "B_ESCHR_COL") %>%
|
||||
filter(mo == "B_ESCHR_COLI") %>%
|
||||
rsi_predict(col_ab = "AMX",
|
||||
col_date = "date",
|
||||
model = "binomial",
|
||||
@ -40,47 +40,47 @@ test_that("prediction of rsi works", {
|
||||
|
||||
library(dplyr)
|
||||
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
model = "binomial",
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
model = "loglin",
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
model = "lin",
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
model = "INVALID MODEL",
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
model = "binomial",
|
||||
col_ab = "NOT EXISTING COLUMN",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
model = "binomial",
|
||||
col_ab = "AMX",
|
||||
col_date = "NOT EXISTING COLUMN",
|
||||
info = TRUE))
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
col_ab = "AMX",
|
||||
col_date = "NOT EXISTING COLUMN",
|
||||
info = TRUE))
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
# almost all E. coli are MEM S in the Netherlands :)
|
||||
expect_error(resistance_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
expect_error(resistance_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
model = "binomial",
|
||||
col_ab = "MEM",
|
||||
col_date = "date",
|
||||
|
@ -58,13 +58,13 @@ test_that("rsi works", {
|
||||
test_that("mic2rsi works", {
|
||||
expect_equal(as.character(
|
||||
as.rsi(x = as.mic(0.125),
|
||||
mo = "B_STRPT_PNE",
|
||||
mo = "B_STRPT_PNMN",
|
||||
ab = "AMX",
|
||||
guideline = "EUCAST")),
|
||||
"S")
|
||||
expect_equal(as.character(
|
||||
as.rsi(x = as.mic(4),
|
||||
mo = "B_STRPT_PNE",
|
||||
mo = "B_STRPT_PNMN",
|
||||
ab = "AMX",
|
||||
guideline = "EUCAST")),
|
||||
"R")
|
||||
@ -80,19 +80,19 @@ test_that("mic2rsi works", {
|
||||
test_that("disk2rsi works", {
|
||||
expect_equal(as.character(
|
||||
as.rsi(x = as.disk(22),
|
||||
mo = "B_STRPT_PNE",
|
||||
mo = "B_STRPT_PNMN",
|
||||
ab = "ERY",
|
||||
guideline = "CLSI")),
|
||||
"S")
|
||||
expect_equal(as.character(
|
||||
as.rsi(x = as.disk(18),
|
||||
mo = "B_STRPT_PNE",
|
||||
mo = "B_STRPT_PNMN",
|
||||
ab = "ERY",
|
||||
guideline = "CLSI")),
|
||||
"I")
|
||||
expect_equal(as.character(
|
||||
as.rsi(x = as.disk(10),
|
||||
mo = "B_STRPT_PNE",
|
||||
mo = "B_STRPT_PNMN",
|
||||
ab = "ERY",
|
||||
guideline = "CLSI")),
|
||||
"R")
|
||||
|
@ -64,7 +64,7 @@ library(microbenchmark)
|
||||
library(AMR)
|
||||
```
|
||||
|
||||
In the next test, we try to 'coerce' different input values for *Staphylococcus aureus*. The actual result is the same every time: it returns its MO code `B_STPHY_AUR` (*B* stands for *Bacteria*, the taxonomic kingdom).
|
||||
In the next test, we try to 'coerce' different input values for *Staphylococcus aureus*. The actual result is the same every time: it returns its MO code `B_STPHY_AURS` (*B* stands for *Bacteria*, the taxonomic kingdom).
|
||||
|
||||
But the calculation time differs a lot:
|
||||
|
||||
@ -93,7 +93,7 @@ ggplot.bm(S.aureus)
|
||||
|
||||
In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.
|
||||
|
||||
To achieve this speed, the `as.mo` function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of *Thermus islandicus* (`B_THERMS_ISL`), a bug probably never found before in humans:
|
||||
To achieve this speed, the `as.mo` function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of *Thermus islandicus* (`B_THERMS_ISLN`), a bug probably never found before in humans:
|
||||
|
||||
```{r}
|
||||
T.islandicus <- microbenchmark(as.mo("theisl"),
|
||||
@ -198,7 +198,7 @@ So transforming 500,000 values (!!) of `r n_distinct(x)` unique values only take
|
||||
What about precalculated results? If the input is an already precalculated result of a helper function like `mo_name()`, it almost doesn't take any time at all (see 'C' below):
|
||||
|
||||
```{r}
|
||||
run_it <- microbenchmark(A = mo_name("B_STPHY_AUR"),
|
||||
run_it <- microbenchmark(A = mo_name("B_STPHY_AURS"),
|
||||
B = mo_name("S. aureus"),
|
||||
C = mo_name("Staphylococcus aureus"),
|
||||
times = 10)
|
||||
|
Loading…
Reference in New Issue
Block a user