uncertainty levels, new WHONET codes

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-03-12 12:19:27 +01:00
parent b319b89750
commit 504a042fba
22 changed files with 402 additions and 292 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.5.0.9021
Date: 2019-03-09
Version: 0.5.0.9022
Date: 2019-03-12
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(

28
NEWS.md
View File

@ -24,7 +24,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* Support for data from [WHONET](https://whonet.org/) and [EARS-Net](https://ecdc.europa.eu/en/about-us/partnerships-and-networks/disease-and-laboratory-networks/ears-net) (European Antimicrobial Resistance Surveillance Network):
* Exported files from WHONET can be read and used in this package. For functions like `first_isolate()` and `eucast_rules()`, all parameters will be filled in automatically.
* This package now knows all antibiotic abbrevations by EARS-Net (which are also being used by WHONET) - the `antibiotics` data set now contains a column `ears_net`.
* The function `as.mo()` now knows all WHONET species abbreviations too, because more than 1,600 microbial abbreviations were added to the `microorganisms.codes` data set.
* The function `as.mo()` now knows all WHONET species abbreviations too, because almost 2,000 microbial abbreviations were added to the `microorganisms.codes` data set.
* New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:
```r
filter_aminoglycosides()
@ -100,8 +100,29 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* Functions `atc_ddd()` and `atc_groups()` have been renamed `atc_online_ddd()` and `atc_online_groups()`. The old functions are deprecated and will be removed in a future version.
* Function `guess_mo()` is now deprecated in favour of `as.mo()` and will be removed in future versions
* Function `guess_atc()` is now deprecated in favour of `as.atc()` and will be removed in future versions
* Improvements for `as.mo()`:\
* Incoercible results will now be considered 'unknown', MO code `UNKNOWN`. Properties of these will be translated on foreign systems in all language already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:
* Improvements for `as.mo()`:
* Now handles incorrect spelling like `i` instead of `y` and `f` instead of `ph`:
```r
# mo_fullname() uses as.mo() internally
mo_fullname("Sthafilokockus aaureuz")
#> [1] "Staphylococcus aureus"
mo_fullname("S. klossi")
#> [1] "Staphylococcus kloosii"
```
* Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default `allow_uncertain = TRUE` is equal to uncertainty level 2. Run `?as.mo` for more info about these levels.
```r
# equal:
as.mo(..., allow_uncertain = TRUE)
as.mo(..., allow_uncertain = 2)
# also equal:
as.mo(..., allow_uncertain = FALSE)
as.mo(..., allow_uncertain = 0)
```
Using `as.mo(..., allow_uncertain = 3)` could lead to very unreliable results.
* Incoercible results will now be considered 'unknown', MO code `UNKNOWN`. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:
```r
mo_genus("qwerty", language = "es")
# Warning:
@ -164,6 +185,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* Automatic parameter filling for `mdro()`, `key_antibiotics()` and `eucast_rules()`
* Updated examples for resistance prediction (`resistance_predict()` function)
* Fix for `as.mic()` to support more values ending in (several) zeroes
* if using different lengths of pattern and x in `%like%`, it will now return the call
#### Other
* Updated licence text to emphasise GPL 2.0 and that this is an R package.

View File

@ -188,7 +188,7 @@ catalogue_of_life <- list(
#' Translation table for 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,731 observations and 2 variables:
#' @format A \code{\link{data.frame}} with 5,171 observations and 2 variables:
#' \describe{
#' \item{\code{certe}}{Commonly used code of a microorganism}
#' \item{\code{mo}}{ID of the microorganism in the \code{\link{microorganisms}} data set}

View File

@ -56,7 +56,7 @@ like <- function(x, pattern) {
if (length(pattern) > 1) {
if (length(x) != length(pattern)) {
pattern <- pattern[1]
warning('only the first element of argument `pattern` used for `%like%`', call. = FALSE)
warning('only the first element of argument `pattern` used for `%like%`', call. = TRUE)
} else {
# x and pattern are of same length, so items with each other
res <- vector(length = length(pattern))

299
R/mo.R
View File

@ -21,7 +21,7 @@
#' Transform to microorganism ID
#'
#' Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using intelligent rules and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
#' Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea, Viruses, and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. Please see Examples.
#' @param x a character vector or a \code{data.frame} with one or two columns
#' @param Becker a logical to indicate whether \emph{Staphylococci} should be categorised into Coagulase Negative \emph{Staphylococci} ("CoNS") and Coagulase Positive \emph{Staphylococci} ("CoPS") instead of their own species, according to Karsten Becker \emph{et al.} [1].
#'
@ -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 [2]. 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 logical to indicate whether the input should be checked for less possible results, see Details
#' @param allow_uncertain a logical (\code{TRUE} or \code{FALSE}) or a value between 0 and 3 to indicate whether the input should be checked for less possible 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).
#' @rdname as.mo
#' @aliases mo
@ -58,9 +58,9 @@
#' \strong{Intelligent rules} \cr
#' This function uses intelligent rules to help getting fast and logical results. It tries to find matches in this order:
#' \itemize{
#' \item{Taxonomic kingdom: it first searches in Bacteria, then Fungi, then Protozoa}
#' \item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see section \emph{Microbial prevalence of pathogens in humans})}
#' \item{Valid MO codes and full names: it first searches in already valid MO code and known genus/species combinations}
#' \item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see \emph{Microbial prevalence of pathogens in humans} below)}
#' \item{Taxonomic kingdom: it first searches in Bacteria/Chromista, then Fungi, then Protozoa, then Viruses}
#' \item{Breakdown of input values: from here it starts to breakdown input values to find possible matches}
#' }
#'
@ -73,15 +73,19 @@
#' This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms.
#'
#' \strong{Uncertain results} \cr
#' When using \code{allow_uncertain = TRUE} (which is the default setting), it will use additional rules if all previous rules failed to get valid results. These are:
#' The algorithm can additionally use three different levels of uncertainty to guess valid results. The default is \code{allow_uncertain = TRUE}, which is uqual to uncertainty level 2. Using \code{allow_uncertain = FALSE} will skip all of these additional rules:
#' \itemize{
#' \item{It tries to look for previously accepted (but now invalid) taxonomic names}
#' \item{It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules}
#' \item{It strips off words from the end one by one and re-evaluates the input with all previous rules}
#' \item{It strips off words from the start one by one and re-evaluates the input with all previous rules}
#' \item{It tries to look for some manual changes which are not (yet) published to the Catalogue of Life (like \emph{Propionibacterium} being \emph{Cutibacterium})}
#' \item{(uncertainty level 1): It tries to look for only matching genera}
#' \item{(uncertainty level 1): It tries to look for previously accepted (but now invalid) taxonomic names}
#' \item{(uncertainty level 1): It tries to look for some manual changes which are not (yet) published to the Catalogue of Life (like \emph{Propionibacterium} being \emph{Cutibacterium})}
#' \item{(uncertainty level 2): It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules}
#' \item{(uncertainty level 2): It strips off words from the end one by one and re-evaluates the input with all previous rules}
#' \item{(uncertainty level 3): It strips off words from the start one by one and re-evaluates the input with all previous rules}
#' \item{(uncertainty level 3): It tries any part of the name}
#' }
#'
#' You can also use e.g. \code{as.mo(..., allow_uncertain = 1)} to only allow up to level 1 uncertainty.
#'
#' 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.}
@ -96,7 +100,7 @@
#' Use \code{mo_renamed()} to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name.
#'
#' \strong{Microbial prevalence of pathogens in humans} \cr
#' The intelligent rules takes into account microbial prevalence of pathogens in humans. It uses three groups and every (sub)species is in the group it matches first. These groups are:
#' The intelligent rules takes into account microbial prevalence of pathogens in humans. It uses three groups and all (sub)species are in only one group. These groups are:
#' \itemize{
#' \item{1 (most prevalent): class is Gammaproteobacteria \strong{or} genus is one of: \emph{Enterococcus}, \emph{Staphylococcus}, \emph{Streptococcus}.}
#' \item{2: phylum is one of: Proteobacteria, Firmicutes, Actinobacteria, Sarcomastigophora \strong{or} genus is one of: \emph{Aspergillus}, \emph{Bacteroides}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Chryseobacterium}, \emph{Cryptococcus}, \emph{Elisabethkingia}, \emph{Flavobacterium}, \emph{Fusobacterium}, \emph{Giardia}, \emph{Leptotrichia}, \emph{Mycoplasma}, \emph{Prevotella}, \emph{Rhodotorula}, \emph{Treponema}, \emph{Trichophyton}, \emph{Ureaplasma}.}
@ -130,6 +134,7 @@
#' as.mo("S aureus")
#' as.mo("Staphylococcus aureus")
#' as.mo("Staphylococcus aureus (MRSA)")
#' as.mo("Sthafilokkockus aaureuz") # handles incorrect spelling
#' as.mo("MRSA") # Methicillin Resistant S. aureus
#' as.mo("VISA") # Vancomycin Intermediate S. aureus
#' as.mo("VRSA") # Vancomycin Resistant S. aureus
@ -202,8 +207,8 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE,
)
} else if (all(x %in% AMR::microorganisms$mo)
& isFALSE(Becker)
& isFALSE(Lancefield)) {
& isFALSE(Becker)
& isFALSE(Lancefield)) {
y <- x
} else if (all(tolower(x) %in% microorganismsDT$fullname_lower)
@ -284,6 +289,15 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
fullname = character(0),
mo = character(0))
failures <- character(0)
if (isTRUE(allow_uncertain)) {
# default to uncertainty level 2
allow_uncertain <- 2
} else {
allow_uncertain <- as.integer(allow_uncertain)
if (!allow_uncertain %in% c(0:3)) {
stop("`allow_uncertain` must be a number between 0 (none) and 3 (all), or TRUE (= 2) or FALSE (= 0).", call. = FALSE)
}
}
x_input <- x
# already strip leading and trailing spaces
x <- trimws(x, which = "both")
@ -387,6 +401,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
# remove spp and species
x <- trimws(gsub(" +(spp.?|ssp.?|sp.? |ss ?.?|subsp.?|subspecies|biovar |serovar |species)", " ", x_backup, ignore.case = TRUE), which = "both")
x_backup_without_spp <- x
x_species <- paste(x, "species")
# translate to English for supported languages of mo_property
x <- gsub("(Gruppe|gruppe|groep|grupo|gruppo|groupe)", "group", x, ignore.case = TRUE)
@ -400,12 +415,21 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
x <- gsub("(alpha|beta|gamma) ha?emoly", "\\1-haemoly", x)
# remove genus as first word
x <- gsub("^Genus ", "", x)
# allow characters that resemble others
x <- gsub("[iy]+", "[iy]+", x, ignore.case = TRUE)
x <- gsub("[sz]+", "[sz]+", x, ignore.case = TRUE)
x <- gsub("(c|k|q|qu)+", "(c|k|q|qu)+", x, ignore.case = TRUE)
x <- gsub("(ph|f|v)+", "(ph|f|v)+", x, ignore.case = TRUE)
x <- gsub("(th|t)+", "(th|t)+", x, ignore.case = TRUE)
x <- gsub("a+", "a+", x, ignore.case = TRUE)
x <- gsub("e+", "e+", x, ignore.case = TRUE)
x <- gsub("o+", "o+", x, ignore.case = TRUE)
# but spaces before and after should be omitted
x <- trimws(x, which = "both")
x_trimmed <- x
x_trimmed_species <- paste(x_trimmed, "species")
x_trimmed_without_group <- gsub(" group$", "", x_trimmed, ignore.case = TRUE)
x_trimmed_without_group <- gsub(" gro.u.p$", "", x_trimmed, ignore.case = TRUE)
# remove last part from "-" or "/"
x_trimmed_without_group <- gsub("(.*)[-/].*", "\\1", x_trimmed_without_group)
# replace space and dot by regex sign
@ -423,6 +447,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
# cat(paste0('x_withspaces_end_only "', x_withspaces_end_only, '"\n'))
# cat(paste0('x_withspaces_start_end "', x_withspaces_start_end, '"\n'))
# cat(paste0('x_backup "', x_backup, '"\n'))
# cat(paste0('x_backup_without_spp "', x_backup_without_spp, '"\n'))
# cat(paste0('x_trimmed "', x_trimmed, '"\n'))
# cat(paste0('x_trimmed_species "', x_trimmed_species, '"\n'))
# cat(paste0('x_trimmed_without_group "', x_trimmed_without_group, '"\n'))
@ -440,12 +465,19 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
next
}
if (any(x_trimmed[i] %in% c(NA, "", "xxx", "con"))) {
found <- microorganismsDT[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) {
x[i] <- found[1L]
next
}
if (any(x_backup_without_spp[i] %in% c(NA, "", "xxx", "con"))) {
x[i] <- NA_character_
next
}
if (tolower(x_trimmed[i]) %in% c("other", "none", "unknown")) {
if (tolower(x_backup_without_spp[i]) %in% c("other", "none", "unknown")) {
# empty and nonsense values, ignore without warning
x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]]
next
@ -472,7 +504,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
next
}
if (x_trimmed[i] %like% "virus") {
if (x_backup_without_spp[i] %like% "virus") {
# there is no fullname like virus, so don't try to coerce it
x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]]
failures <- c(failures, x_backup[i])
@ -481,100 +513,100 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
# translate known trivial abbreviations to genus + species ----
if (!is.na(x_trimmed[i])) {
if (toupper(x_trimmed[i]) %in% c('MRSA', 'MSSA', 'VISA', 'VRSA')) {
if (toupper(x_backup_without_spp[i]) %in% c('MRSA', 'MSSA', 'VISA', 'VRSA')) {
x[i] <- microorganismsDT[mo == 'B_STPHY_AUR', ..property][[1]][1L]
next
}
if (toupper(x_trimmed[i]) %in% c('MRSE', 'MSSE')) {
if (toupper(x_backup_without_spp[i]) %in% c('MRSE', 'MSSE')) {
x[i] <- microorganismsDT[mo == 'B_STPHY_EPI', ..property][[1]][1L]
next
}
if (toupper(x_trimmed[i]) == "VRE"
| x_trimmed[i] %like% '(enterococci|enterokok|enterococo)[a-z]*?$') {
if (toupper(x_backup_without_spp[i]) == "VRE"
| x_backup_without_spp[i] %like% '(enterococci|enterokok|enterococo)[a-z]*?$') {
x[i] <- microorganismsDT[mo == 'B_ENTRC', ..property][[1]][1L]
next
}
if (toupper(x_trimmed[i]) %in% c("EHEC", "EPEC", "EIEC", "STEC", "ATEC")) {
if (toupper(x_backup_without_spp[i]) %in% c("EHEC", "EPEC", "EIEC", "STEC", "ATEC")) {
x[i] <- microorganismsDT[mo == 'B_ESCHR_COL', ..property][[1]][1L]
next
}
if (toupper(x_trimmed[i]) == 'MRPA') {
if (toupper(x_backup_without_spp[i]) == 'MRPA') {
# multi resistant P. aeruginosa
x[i] <- microorganismsDT[mo == 'B_PSDMN_AER', ..property][[1]][1L]
next
}
if (toupper(x_trimmed[i]) == 'CRS'
| toupper(x_trimmed[i]) == 'CRSM') {
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]
next
}
if (toupper(x_trimmed[i]) %in% c('PISP', 'PRSP', 'VISP', 'VRSP')) {
if (toupper(x_backup_without_spp[i]) %in% c('PISP', 'PRSP', 'VISP', 'VRSP')) {
# peni I, peni R, vanco I, vanco R: S. pneumoniae
x[i] <- microorganismsDT[mo == 'B_STRPT_PNE', ..property][[1]][1L]
next
}
if (x_trimmed[i] %like% '^G[ABCDFGHK]S$') {
if (x_backup_without_spp[i] %like% '^G[ABCDFGHK]S$') {
# Streptococci, like GBS = Group B Streptococci (B_STRPT_GRB)
x[i] <- microorganismsDT[mo == gsub("G([ABCDFGHK])S", "B_STRPT_GR\\1", x_trimmed[i], ignore.case = TRUE), ..property][[1]][1L]
x[i] <- microorganismsDT[mo == gsub("G([ABCDFGHK])S", "B_STRPT_GR\\1", x_backup_without_spp[i], ignore.case = TRUE), ..property][[1]][1L]
next
}
if (x_trimmed[i] %like% '(streptococ|streptokok).* [ABCDFGHK]$') {
if (x_backup_without_spp[i] %like% '(streptococ|streptokok).* [ABCDFGHK]$') {
# Streptococci in different languages, like "estreptococos grupo B"
x[i] <- microorganismsDT[mo == gsub(".*(streptococ|streptokok|estreptococ).* ([ABCDFGHK])$", "B_STRPT_GR\\2", x_trimmed[i], ignore.case = TRUE), ..property][[1]][1L]
x[i] <- microorganismsDT[mo == gsub(".*(streptococ|streptokok|estreptococ).* ([ABCDFGHK])$", "B_STRPT_GR\\2", x_backup_without_spp[i], ignore.case = TRUE), ..property][[1]][1L]
next
}
if (x_trimmed[i] %like% 'group [ABCDFGHK] (streptococ|streptokok|estreptococ)') {
if (x_backup_without_spp[i] %like% 'group [ABCDFGHK] (streptococ|streptokok|estreptococ)') {
# Streptococci in different languages, like "Group A Streptococci"
x[i] <- microorganismsDT[mo == gsub(".*group ([ABCDFGHK]) (streptococ|streptokok|estreptococ).*", "B_STRPT_GR\\1", x_trimmed[i], ignore.case = TRUE), ..property][[1]][1L]
x[i] <- microorganismsDT[mo == gsub(".*group ([ABCDFGHK]) (streptococ|streptokok|estreptococ).*", "B_STRPT_GR\\1", x_backup_without_spp[i], ignore.case = TRUE), ..property][[1]][1L]
next
}
# CoNS/CoPS in different languages (support for German, Dutch, Spanish, Portuguese) ----
if (x[i] %like% '[ck]oagulas[ea] negatie?[vf]'
if (x_backup_without_spp[i] %like% '[ck]oagulas[ea] negatie?[vf]'
| x_trimmed[i] %like% '[ck]oagulas[ea] negatie?[vf]'
| x[i] %like% '[ck]o?ns[^a-z]?$') {
| x_backup_without_spp[i] %like% '[ck]o?ns[^a-z]?$') {
# coerce S. coagulase negative
x[i] <- microorganismsDT[mo == 'B_STPHY_CNS', ..property][[1]][1L]
next
}
if (x[i] %like% '[ck]oagulas[ea] positie?[vf]'
if (x_backup_without_spp[i] %like% '[ck]oagulas[ea] positie?[vf]'
| x_trimmed[i] %like% '[ck]oagulas[ea] positie?[vf]'
| x[i] %like% '[ck]o?ps[^a-z]?$') {
| x_backup_without_spp[i] %like% '[ck]o?ps[^a-z]?$') {
# coerce S. coagulase positive
x[i] <- microorganismsDT[mo == 'B_STPHY_CPS', ..property][[1]][1L]
next
}
if (x[i] %like% 'gram[ -]?neg.*'
if (x_backup_without_spp[i] %like% 'gram[ -]?neg.*'
| x_trimmed[i] %like% 'gram[ -]?neg.*') {
# coerce S. coagulase positive
# coerce Gram negatives
x[i] <- microorganismsDT[mo == 'B_GRAMN', ..property][[1]][1L]
next
}
if (x[i] %like% 'gram[ -]?pos.*'
if (x_backup_without_spp[i] %like% 'gram[ -]?pos.*'
| x_trimmed[i] %like% 'gram[ -]?pos.*') {
# coerce S. coagulase positive
# coerce Gram positives
x[i] <- microorganismsDT[mo == 'B_GRAMP', ..property][[1]][1L]
next
}
if (grepl("[sS]almonella [A-Z][a-z]+ ?.*", x_trimmed[i], ignore.case = FALSE)) {
if (x_trimmed[i] %like% "Salmonella group") {
if (grepl("[sS]almonella [A-Z][a-z]+ ?.*", x_backup_without_spp[i], ignore.case = FALSE)) {
if (x_backup_without_spp[i] %like% "Salmonella group") {
# Salmonella Group A to Z, just return S. species for now
x[i] <- microorganismsDT[mo == 'B_SLMNL', ..property][[1]][1L]
notes <- c(notes,
magenta(paste0("Note: ",
italic("Salmonella"), " ", trimws(gsub("Salmonella", "", x_trimmed[i])),
" was considered ",
italic("Salmonella species"),
" (B_SLMNL)")))
options(mo_renamed = c(getOption("mo_renamed"),
magenta(paste0("Note: ",
italic("Salmonella"), " ", trimws(gsub("Salmonella", "", x_backup_without_spp[i])),
" was considered ",
italic("Salmonella species"),
" (B_SLMNL)"))))
} else {
# Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica
x[i] <- microorganismsDT[mo == 'B_SLMNL_ENT', ..property][[1]][1L]
notes <- c(notes,
magenta(paste0("Note: ",
italic("Salmonella"), " ", trimws(gsub("Salmonella", "", x_trimmed[i])),
" was considered a subspecies of ",
italic("Salmonella enterica"),
" (B_SLMNL_ENT)")))
options(mo_renamed = c(getOption("mo_renamed"),
magenta(paste0("Note: ",
italic("Salmonella"), " ", trimws(gsub("Salmonella", "", x_backup_without_spp[i])),
" was considered a subspecies of ",
italic("Salmonella enterica"),
" (B_SLMNL_ENT)"))))
}
next
}
@ -588,8 +620,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
x[i] <- found[1L]
next
}
if (nchar(x_trimmed[i]) >= 6) {
found <- microorganismsDT[fullname_lower %like% paste0(x_withspaces_start_only[i], "[a-z]+ species"), ..property][[1]]
if (nchar(x_backup_without_spp[i]) >= 6) {
found <- microorganismsDT[fullname_lower %like% paste0("^", x_backup_without_spp[i], "[a-z]+"), ..property][[1]]
if (length(found) > 0) {
x[i] <- found[1L]
next
@ -621,7 +653,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
}
# allow no codes less than 4 characters long, was already checked for WHONET above
if (nchar(x_trimmed[i]) < 4) {
if (nchar(x_backup_without_spp[i]) < 4) {
x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]]
failures <- c(failures, x_backup[i])
next
@ -633,22 +665,23 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
c.x_trimmed_without_group,
d.x_withspaces_start_end,
e.x_withspaces_start_only,
f.x_withspaces_end_only) {
f.x_withspaces_end_only,
g.x_backup_without_spp) {
found <- data_to_check[fullname_lower %in% tolower(c(a.x_backup, b.x_trimmed)), ..property][[1]]
# most probable: is exact match in fullname
# try probable: trimmed version of fullname ----
found <- data_to_check[fullname_lower %in% tolower(g.x_backup_without_spp), ..property][[1]]
if (length(found) > 0) {
return(found[1L])
}
found <- data_to_check[fullname_lower == tolower(c.x_trimmed_without_group), ..property][[1]]
if (length(found) > 0) {
found <- data_to_check[fullname_lower %like% b.x_trimmed
| fullname_lower %like% c.x_trimmed_without_group, ..property][[1]]
if (length(found) > 0 & nchar(g.x_backup_without_spp) >= 6) {
return(found[1L])
}
# try any match keeping spaces ----
found <- data_to_check[fullname %like% d.x_withspaces_start_end, ..property][[1]]
if (length(found) > 0 & nchar(b.x_trimmed) >= 6) {
if (length(found) > 0 & nchar(g.x_backup_without_spp) >= 6) {
return(found[1L])
}
@ -658,7 +691,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
return(found[1L])
}
found <- data_to_check[fullname %like% e.x_withspaces_start_only, ..property][[1]]
if (length(found) > 0 & nchar(b.x_trimmed) >= 6) {
if (length(found) > 0 & nchar(g.x_backup_without_spp) >= 6) {
return(found[1L])
}
@ -671,12 +704,12 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
# try splitting of characters in the middle and then find ID ----
# only when text length is 6 or lower
# like esco = E. coli, klpn = K. pneumoniae, stau = S. aureus, staaur = S. aureus
if (nchar(b.x_trimmed) <= 6) {
x_length <- nchar(b.x_trimmed)
if (nchar(g.x_backup_without_spp) <= 6) {
x_length <- nchar(g.x_backup_without_spp)
x_split <- paste0("^",
b.x_trimmed %>% substr(1, x_length / 2),
g.x_backup_without_spp %>% substr(1, x_length / 2),
'.* ',
b.x_trimmed %>% substr((x_length / 2) + 1, x_length))
g.x_backup_without_spp %>% substr((x_length / 2) + 1, x_length))
found <- data_to_check[fullname %like% x_split, ..property][[1]]
if (length(found) > 0) {
return(found[1L])
@ -701,7 +734,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
c.x_trimmed_without_group = x_trimmed_without_group[i],
d.x_withspaces_start_end = x_withspaces_start_end[i],
e.x_withspaces_start_only = x_withspaces_start_only[i],
f.x_withspaces_end_only = x_withspaces_end_only[i])
f.x_withspaces_end_only = x_withspaces_end_only[i],
g.x_backup_without_spp = x_backup_without_spp[i])
if (!empty_result(x[i])) {
next
}
@ -712,7 +746,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
c.x_trimmed_without_group = x_trimmed_without_group[i],
d.x_withspaces_start_end = x_withspaces_start_end[i],
e.x_withspaces_start_only = x_withspaces_start_only[i],
f.x_withspaces_end_only = x_withspaces_end_only[i])
f.x_withspaces_end_only = x_withspaces_end_only[i],
g.x_backup_without_spp = x_backup_without_spp[i])
if (!empty_result(x[i])) {
next
}
@ -723,7 +758,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
c.x_trimmed_without_group = x_trimmed_without_group[i],
d.x_withspaces_start_end = x_withspaces_start_end[i],
e.x_withspaces_start_only = x_withspaces_start_only[i],
f.x_withspaces_end_only = x_withspaces_end_only[i])
f.x_withspaces_end_only = x_withspaces_end_only[i],
g.x_backup_without_spp = x_backup_without_spp[i])
if (!empty_result(x[i])) {
next
}
@ -752,31 +788,23 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
}
# check for uncertain results ----
if (allow_uncertain == TRUE) {
uncertain_fn <- function(a.x_backup,
b.x_trimmed,
c.x_withspaces_start_end,
d.x_withspaces_start_only,
f.x_withspaces_end_only,
g.x_backup_without_spp) {
uncertain_fn <- function(a.x_backup, b.x_trimmed, c.x_withspaces_start_end, d.x_withspaces_start_only, f.x_withspaces_end_only) {
if (allow_uncertain == 0) {
# do not allow uncertainties
return(NA_character_)
}
# (1) look for genus only, part of name ----
if (nchar(b.x_trimmed) > 4 & !b.x_trimmed %like% " ") {
if (!grepl("^[A-Z][a-z]+", b.x_trimmed, ignore.case = FALSE)) {
# not when input is like Genustext, because then Neospora would lead to Actinokineospora
found <- microorganismsDT[fullname_lower %like% paste(b.x_trimmed, "species"), ..property][[1]]
if (length(found) > 0) {
x[i] <- found[1L]
uncertainties <<- rbind(uncertainties,
data.frame(uncertainty = 2,
input = a.x_backup,
fullname = microorganismsDT[mo == found[1L], fullname][[1]],
mo = found[1L]))
return(x)
}
}
}
# (2) look again for old taxonomic names, now for G. species ----
if (allow_uncertain >= 1) {
# (1) look again for old taxonomic names, now for G. species ----
found <- microorganisms.oldDT[fullname %like% c.x_withspaces_start_end
| fullname %like% d.x_withspaces_start_only]
if (NROW(found) > 0 & nchar(b.x_trimmed) >= 6) {
if (NROW(found) > 0 & nchar(g.x_backup_without_spp) >= 6) {
if (property == "ref") {
# when property is "ref" (which is the case in mo_ref, mo_authors and mo_year), return the old value, so:
# mo_ref("Chlamydia psittaci) = "Page, 1968" (with warning)
@ -798,7 +826,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
return(x)
}
# (3) not yet implemented taxonomic changes in Catalogue of Life ----
# (2) not yet implemented taxonomic changes in Catalogue of Life ----
found <- suppressMessages(suppressWarnings(exec_as.mo(TEMPORARY_TAXONOMY(b.x_trimmed), clear_options = FALSE, allow_uncertain = FALSE)))
if (!empty_result(found)) {
found_result <- found
@ -810,12 +838,31 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
mo = found_result[1L]))
return(found[1L])
}
}
if (allow_uncertain >= 2) {
# (3) look for genus only, part of name ----
if (nchar(g.x_backup_without_spp) > 4 & !b.x_trimmed %like% " ") {
if (!grepl("^[A-Z][a-z]+", b.x_trimmed, ignore.case = FALSE)) {
# not when input is like Genustext, because then Neospora would lead to Actinokineospora
found <- microorganismsDT[fullname_lower %like% paste(b.x_trimmed, "species"), ..property][[1]]
if (length(found) > 0) {
x[i] <- found[1L]
uncertainties <<- rbind(uncertainties,
data.frame(uncertainty = 2,
input = a.x_backup,
fullname = microorganismsDT[mo == found[1L], fullname][[1]],
mo = found[1L]))
return(x)
}
}
}
# (4) strip values between brackets ----
a.x_backup_stripped <- gsub("( *[(].*[)] *)", " ", a.x_backup)
a.x_backup_stripped <- trimws(gsub(" +", " ", a.x_backup_stripped))
found <- suppressMessages(suppressWarnings(exec_as.mo(a.x_backup_stripped, clear_options = FALSE, allow_uncertain = FALSE)))
if (!empty_result(found) & nchar(b.x_trimmed) >= 6) {
if (!empty_result(found) & nchar(g.x_backup_without_spp) >= 6) {
found_result <- found
found <- microorganismsDT[mo == found, ..property][[1]]
uncertainties <<- rbind(uncertainties,
@ -828,26 +875,30 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
# (5) try to strip off one element from end and check the remains ----
x_strip <- a.x_backup %>% strsplit(" ") %>% unlist()
if (length(x_strip) > 1 & nchar(b.x_trimmed) >= 6) {
if (length(x_strip) > 1) {
for (i in 1:(length(x_strip) - 1)) {
x_strip_collapsed <- paste(x_strip[1:(length(x_strip) - i)], collapse = " ")
found <- suppressMessages(suppressWarnings(exec_as.mo(x_strip_collapsed, clear_options = FALSE, allow_uncertain = FALSE)))
if (!empty_result(found)) {
found_result <- found
found <- microorganismsDT[mo == found, ..property][[1]]
uncertainties <<- rbind(uncertainties,
data.frame(uncertainty = 2,
input = a.x_backup,
fullname = microorganismsDT[mo == found_result[1L], fullname][[1]],
mo = found_result[1L]))
return(found[1L])
if (nchar(x_strip_collapsed) >= 4) {
found <- suppressMessages(suppressWarnings(exec_as.mo(x_strip_collapsed, clear_options = FALSE, allow_uncertain = FALSE)))
if (!empty_result(found)) {
found_result <- found
found <- microorganismsDT[mo == found, ..property][[1]]
uncertainties <<- rbind(uncertainties,
data.frame(uncertainty = 2,
input = a.x_backup,
fullname = microorganismsDT[mo == found_result[1L], fullname][[1]],
mo = found_result[1L]))
return(found[1L])
}
}
}
}
}
if (allow_uncertain >= 3) {
# (6) try to strip off one element from start and check the remains ----
x_strip <- a.x_backup %>% strsplit(" ") %>% unlist()
if (length(x_strip) > 1 & nchar(b.x_trimmed) >= 6) {
if (length(x_strip) > 1 & nchar(g.x_backup_without_spp) >= 6) {
for (i in 2:(length(x_strip))) {
x_strip_collapsed <- paste(x_strip[i:length(x_strip)], collapse = " ")
found <- suppressMessages(suppressWarnings(exec_as.mo(x_strip_collapsed, clear_options = FALSE, allow_uncertain = FALSE)))
@ -868,7 +919,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
found <- microorganismsDT[fullname %like% f.x_withspaces_end_only]
if (nrow(found) > 0) {
found_result <- found[["mo"]]
if (!empty_result(found_result)) {
if (!empty_result(found_result) & nchar(g.x_backup_without_spp) >= 6) {
found <- microorganismsDT[mo == found_result[1L], ..property][[1]]
uncertainties <<- rbind(uncertainties,
data.frame(uncertainty = 3,
@ -878,16 +929,21 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
return(found[1L])
}
}
# didn't found in uncertain results too
return(NA_character_)
}
x[i] <- uncertain_fn(x_backup[i], x_trimmed[i], x_withspaces_start_end[i], x_withspaces_start_only[i], x_withspaces_end_only[i])
if (!empty_result(x[i])) {
next
}
# didn't found in uncertain results too
return(NA_character_)
}
x[i] <- uncertain_fn(x_backup[i],
x_trimmed[i],
x_withspaces_start_end[i],
x_withspaces_start_only[i],
x_withspaces_end_only[i],
x_backup_without_spp[i])
if (!empty_result(x[i])) {
next
}
# not found ----
x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]]
@ -899,19 +955,19 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
failures <- failures[!failures %in% c(NA, NULL, NaN)]
if (length(failures) > 0 & clear_options == TRUE) {
options(mo_failures = sort(unique(failures)))
plural <- c("value", "it", "is")
plural <- c("value", "it", "was")
if (n_distinct(failures) > 1) {
plural <- c("values", "them", "are")
plural <- c("values", "them", "were")
}
total_failures <- length(x_input[x_input %in% failures & !x_input %in% c(NA, NULL, NaN)])
total_n <- length(x_input[!x_input %in% c(NA, NULL, NaN)])
msg <- paste0("\n", nr2char(n_distinct(failures)), " unique ", plural[1],
msg <- paste0(nr2char(n_distinct(failures)), " unique ", plural[1],
" (^= ", percent(total_failures / total_n, round = 1, force_zero = TRUE),
") could not be coerced and ", plural[3], " considered 'unknown'")
if (n_distinct(failures) <= 10) {
msg <- paste0(msg, ": ", paste('"', unique(failures), '"', sep = "", collapse = ', '))
}
msg <- paste0(msg, ". Use mo_failures() to review ", plural[2], ".")
msg <- paste0(msg, ". Use mo_failures() to review ", plural[2], ". Edit the `allow_uncertain` parameter if needed (see ?as.mo).")
warning(red(msg),
call. = FALSE,
immediate. = TRUE) # thus will always be shown, even if >= warnings
@ -1026,7 +1082,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
}
empty_result <- function(x) {
x %in% c(NA, "UNKNOWN")
all(x %in% c(NA, "UNKNOWN"))
}
TEMPORARY_TAXONOMY <- function(x) {
@ -1124,6 +1180,9 @@ mo_uncertainties <- function() {
#' @export
#' @noRd
print.mo_uncertainties <- function(x, ...) {
if (NROW(x) == 0) {
return(NULL)
}
cat(paste0(bold(nrow(x), "unique result(s) guessed with uncertainty:"),
"\n(1 = ", green("renamed"),
", 2 = ", yellow("uncertain"),

35
R/zzz.R
View File

@ -25,28 +25,25 @@
backports::import(pkgname)
# register data
if (!all(c("microorganismsDT", "microorganisms.oldDT") %in% ls(envir = asNamespace("AMR")))) {
microorganisms.oldDT <- as.data.table(AMR::microorganisms.old)
microorganisms.oldDT$fullname_lower <- tolower(microorganisms.oldDT$fullname)
setkey(microorganisms.oldDT, col_id, fullname)
microorganisms.oldDT <- as.data.table(AMR::microorganisms.old)
microorganisms.oldDT$fullname_lower <- tolower(microorganisms.oldDT$fullname)
setkey(microorganisms.oldDT, col_id, fullname)
assign(x = "microorganisms",
value = make(),
envir = asNamespace("AMR"))
assign(x = "microorganisms",
value = make(),
envir = asNamespace("AMR"))
assign(x = "microorganismsDT",
value = make_DT(),
envir = asNamespace("AMR"))
assign(x = "microorganismsDT",
value = make_DT(),
envir = asNamespace("AMR"))
assign(x = "microorganisms.oldDT",
value = microorganisms.oldDT,
envir = asNamespace("AMR"))
assign(x = "microorganisms.oldDT",
value = microorganisms.oldDT,
envir = asNamespace("AMR"))
assign(x = "mo_codes_v0.5.0",
value = make_trans_tbl(),
envir = asNamespace("AMR"))
}
assign(x = "mo_codes_v0.5.0",
value = make_trans_tbl(),
envir = asNamespace("AMR"))
}
#' @importFrom dplyr mutate case_when
@ -88,8 +85,8 @@ make_DT <- function() {
microorganismsDT <- as.data.table(make())
microorganismsDT$fullname_lower <- tolower(microorganismsDT$fullname)
setkey(microorganismsDT,
kingdom,
prevalence,
kingdom,
fullname)
microorganismsDT
}

Binary file not shown.

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>
@ -192,7 +192,7 @@
<h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">09 March 2019</h4>
<h4 class="date">12 March 2019</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div>
@ -217,14 +217,14 @@
<a class="sourceLine" id="cb2-8" title="8"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb2-9" title="9"><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">3</span>)</a>
<a class="sourceLine" id="cb2-10" title="10"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#&gt; as.mo("sau") 16.60 16.60 25.2 16.80 18.00 58.3 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#&gt; as.mo("stau") 31.60 31.80 44.8 32.40 72.20 76.7 10</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#&gt; as.mo("staaur") 16.60 16.60 26.4 16.70 17.30 71.9 10</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#&gt; as.mo("STAAUR") 16.50 16.60 16.6 16.60 16.70 16.8 10</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#&gt; as.mo("S. aureus") 24.50 24.60 29.0 24.70 25.00 66.6 10</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#&gt; as.mo("S. aureus") 24.30 24.60 24.6 24.60 24.70 24.9 10</span></a>
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#&gt; as.mo("Staphylococcus aureus") 7.45 7.47 11.9 7.53 7.97 50.0 10</span></a></code></pre></div>
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#&gt; as.mo("sau") 16.70 16.8 25.70 17.00 19.60 59.7 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#&gt; as.mo("stau") 39.10 39.2 43.70 39.30 40.60 80.4 10</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#&gt; as.mo("staaur") 16.70 16.8 24.60 17.00 18.20 58.9 10</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#&gt; as.mo("STAAUR") 16.70 16.7 22.70 16.80 17.20 74.5 10</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#&gt; as.mo("S. aureus") 29.70 29.7 46.70 29.80 71.30 110.0 10</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#&gt; as.mo("S. aureus") 29.60 29.7 36.10 29.70 33.10 83.7 10</span></a>
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#&gt; as.mo("Staphylococcus aureus") 7.03 7.1 7.14 7.14 7.17 7.3 10</span></a></code></pre></div>
<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>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1">T.islandicus &lt;-<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>
@ -235,13 +235,13 @@
<a class="sourceLine" id="cb3-6" title="6"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb3-7" title="7"><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">3</span>)</a>
<a class="sourceLine" id="cb3-8" title="8"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="co">#&gt; as.mo("theisl") 262.0 263.0 284.0 284.0 304 308 10</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#&gt; as.mo("THEISL") 263.0 264.0 293.0 304.0 306 308 10</span></a>
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#&gt; as.mo("T. islandicus") 142.0 142.0 151.0 143.0 147 187 10</span></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#&gt; as.mo("T. islandicus") 142.0 142.0 169.0 184.0 185 194 10</span></a>
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#&gt; as.mo("Thermus islandicus") 67.9 68.1 93.3 90.3 116 130 10</span></a></code></pre></div>
<p>That takes 7.8 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-9" title="9"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="co">#&gt; as.mo("theisl") 417.0 419.0 450.0 460.0 464.0 474 10</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#&gt; as.mo("THEISL") 415.0 416.0 443.0 458.0 460.0 468 10</span></a>
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#&gt; as.mo("T. islandicus") 281.0 281.0 299.0 285.0 325.0 352 10</span></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#&gt; as.mo("T. islandicus") 292.0 298.0 341.0 336.0 340.0 495 10</span></a>
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#&gt; as.mo("Thermus islandicus") 66.2 66.5 75.5 66.9 68.2 112 10</span></a></code></pre></div>
<p>That takes 10.9 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 very uncommon):</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/par">par</a></span>(<span class="dt">mar =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">5</span>, <span class="dv">16</span>, <span class="dv">4</span>, <span class="dv">2</span>)) <span class="co"># set more space for left margin text (16)</span></a>
<a class="sourceLine" id="cb4-2" title="2"></a>
@ -286,9 +286,9 @@
<a class="sourceLine" id="cb5-23" title="23"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb5-24" title="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="cb5-25" title="25"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb5-26" title="26"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb5-27" title="27"><span class="co">#&gt; mo_fullname(x) 734 810 840 817 860 973 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.82 seconds (817 ms). You only lose time on your unique input values.</p>
<a class="sourceLine" id="cb5-26" title="26"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb5-27" title="27"><span class="co">#&gt; mo_fullname(x) 794 834 863 844 876 1050 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.84 seconds (844 ms). You only lose time on your unique input values.</p>
</div>
<div id="precalculated-results" class="section level3">
<h3 class="hasAnchor">
@ -301,9 +301,9 @@
<a class="sourceLine" id="cb6-5" title="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="cb6-6" title="6"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb6-7" title="7"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#&gt; A 11.200 11.300 11.400 11.400 11.600 11.600 10</span></a>
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#&gt; B 22.200 22.400 26.800 22.600 22.800 63.700 10</span></a>
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#&gt; C 0.328 0.564 0.525 0.568 0.577 0.591 10</span></a></code></pre></div>
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#&gt; A 10.900 11.100 11.200 11.200 11.300 11.400 10</span></a>
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#&gt; B 27.300 27.900 28.300 28.000 28.100 31.500 10</span></a>
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#&gt; C 0.319 0.326 0.472 0.563 0.568 0.579 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0006 seconds - it doesnt 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="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1">run_it &lt;-<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="cb7-2" title="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>
@ -317,14 +317,14 @@
<a class="sourceLine" id="cb7-10" title="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="cb7-11" title="11"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb7-12" title="12"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#&gt; A 0.318 0.376 0.414 0.419 0.449 0.537 10</span></a>
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#&gt; B 0.343 0.397 0.437 0.447 0.479 0.522 10</span></a>
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#&gt; C 0.325 0.380 0.486 0.482 0.554 0.703 10</span></a>
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#&gt; D 0.334 0.337 0.381 0.372 0.426 0.434 10</span></a>
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#&gt; E 0.304 0.322 0.356 0.335 0.393 0.460 10</span></a>
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#&gt; F 0.295 0.323 0.370 0.362 0.424 0.463 10</span></a>
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#&gt; G 0.296 0.321 0.362 0.348 0.387 0.470 10</span></a>
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#&gt; H 0.289 0.335 0.355 0.351 0.387 0.421 10</span></a></code></pre></div>
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#&gt; A 0.308 0.332 0.396 0.393 0.457 0.498 10</span></a>
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#&gt; B 0.349 0.376 0.419 0.444 0.462 0.467 10</span></a>
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#&gt; C 0.351 0.398 0.529 0.555 0.628 0.702 10</span></a>
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#&gt; D 0.302 0.330 0.378 0.381 0.424 0.465 10</span></a>
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#&gt; E 0.282 0.329 0.371 0.374 0.384 0.539 10</span></a>
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#&gt; F 0.281 0.354 0.364 0.366 0.402 0.444 10</span></a>
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#&gt; G 0.275 0.309 0.347 0.351 0.380 0.420 10</span></a>
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#&gt; H 0.279 0.306 0.356 0.363 0.404 0.411 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">
@ -351,13 +351,13 @@
<a class="sourceLine" id="cb8-18" title="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="cb8-19" title="19"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb8-20" title="20"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#&gt; en 15.57 15.87 24.21 20.71 37.98 38.78 10</span></a>
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#&gt; de 28.79 34.96 53.24 52.02 56.97 95.22 10</span></a>
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#&gt; nl 28.31 29.29 47.74 40.57 58.94 97.03 10</span></a>
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#&gt; es 28.97 30.43 42.78 34.70 51.47 72.11 10</span></a>
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#&gt; it 27.71 29.15 38.88 31.19 35.10 76.86 10</span></a>
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#&gt; fr 28.37 29.28 40.89 41.73 50.43 56.78 10</span></a>
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#&gt; pt 27.82 29.03 42.49 29.84 50.14 94.96 10</span></a></code></pre></div>
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#&gt; en 16.61 17.17 17.23 17.28 17.38 17.56 10</span></a>
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#&gt; de 28.83 28.85 29.31 29.50 29.63 29.67 10</span></a>
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#&gt; nl 29.08 29.44 33.71 29.65 29.72 71.15 10</span></a>
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#&gt; es 28.86 29.52 38.07 29.70 30.60 72.14 10</span></a>
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#&gt; it 28.71 29.48 34.04 29.63 31.28 71.09 10</span></a>
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#&gt; fr 29.32 29.47 41.44 29.53 62.86 73.16 10</span></a>
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#&gt; pt 29.05 29.43 33.93 29.62 30.93 71.00 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: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>
@ -267,7 +267,7 @@ This data is updated annually - check the included version with the new function
<ul>
<li>Exported files from WHONET can be read and used in this package. For functions like <code><a href="../reference/first_isolate.html">first_isolate()</a></code> and <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>, all parameters will be filled in automatically.</li>
<li>This package now knows all antibiotic abbrevations by EARS-Net (which are also being used by WHONET) - the <code>antibiotics</code> data set now contains a column <code>ears_net</code>.</li>
<li>The function <code><a href="../reference/as.mo.html">as.mo()</a></code> now knows all WHONET species abbreviations too, because more than 1,600 microbial abbreviations were added to the <code>microorganisms.codes</code> data set.</li>
<li>The function <code><a href="../reference/as.mo.html">as.mo()</a></code> now knows all WHONET species abbreviations too, because almost 2,000 microbial abbreviations were added to the <code>microorganisms.codes</code> data set.</li>
</ul>
</li>
<li>
@ -347,14 +347,35 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
<li>Functions <code><a href="../reference/AMR-deprecated.html">atc_ddd()</a></code> and <code><a href="../reference/AMR-deprecated.html">atc_groups()</a></code> have been renamed <code><a href="../reference/atc_online.html">atc_online_ddd()</a></code> and <code><a href="../reference/atc_online.html">atc_online_groups()</a></code>. The old functions are deprecated and will be removed in a future version.</li>
<li>Function <code><a href="../reference/AMR-deprecated.html">guess_mo()</a></code> is now deprecated in favour of <code><a href="../reference/as.mo.html">as.mo()</a></code> and will be removed in future versions</li>
<li>Function <code><a href="../reference/AMR-deprecated.html">guess_atc()</a></code> is now deprecated in favour of <code><a href="../reference/as.atc.html">as.atc()</a></code> and will be removed in future versions</li>
<li>Improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code>:\
<li>Improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code>:
<ul>
<li>Incoercible results will now be considered unknown, MO code <code>UNKNOWN</code>. Properties of these will be translated on foreign systems in all language already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:</li>
<li>Now handles incorrect spelling like <code>i</code> instead of <code>y</code> and <code>f</code> instead of <code>ph</code>:</li>
</ul>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1"><span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"qwerty"</span>, <span class="dt">language =</span> <span class="st">"es"</span>)</a>
<a class="sourceLine" id="cb7-2" title="2"><span class="co"># Warning: </span></a>
<a class="sourceLine" id="cb7-3" title="3"><span class="co"># one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it.</span></a>
<a class="sourceLine" id="cb7-4" title="4"><span class="co">#&gt; [1] "(género desconocido)"</span></a></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1"><span class="co"># mo_fullname() uses as.mo() internally</span></a>
<a class="sourceLine" id="cb7-2" title="2"></a>
<a class="sourceLine" id="cb7-3" title="3"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"Sthafilokockus aaureuz"</span>)</a>
<a class="sourceLine" id="cb7-4" title="4"><span class="co">#&gt; [1] "Staphylococcus aureus"</span></a>
<a class="sourceLine" id="cb7-5" title="5"></a>
<a class="sourceLine" id="cb7-6" title="6"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"S. klossi"</span>)</a>
<a class="sourceLine" id="cb7-7" title="7"><span class="co">#&gt; [1] "Staphylococcus kloosii"</span></a></code></pre></div>
<ul>
<li>Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default <code>allow_uncertain = TRUE</code> is equal to uncertainty level 2. Run <code><a href="../reference/as.mo.html">?as.mo</a></code> for more info about these levels.</li>
</ul>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1"><span class="co"># equal:</span></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(..., <span class="dt">allow_uncertain =</span> <span class="ot">TRUE</span>)</a>
<a class="sourceLine" id="cb8-3" title="3"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(..., <span class="dt">allow_uncertain =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb8-4" title="4"></a>
<a class="sourceLine" id="cb8-5" title="5"><span class="co"># also equal:</span></a>
<a class="sourceLine" id="cb8-6" title="6"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(..., <span class="dt">allow_uncertain =</span> <span class="ot">FALSE</span>)</a>
<a class="sourceLine" id="cb8-7" title="7"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(..., <span class="dt">allow_uncertain =</span> <span class="dv">0</span>)</a></code></pre></div>
Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a></code> could lead to very unreliable results.
<ul>
<li>Incoercible results will now be considered unknown, MO code <code>UNKNOWN</code>. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:</li>
</ul>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" title="1"><span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"qwerty"</span>, <span class="dt">language =</span> <span class="st">"es"</span>)</a>
<a class="sourceLine" id="cb9-2" title="2"><span class="co"># Warning: </span></a>
<a class="sourceLine" id="cb9-3" title="3"><span class="co"># one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it.</span></a>
<a class="sourceLine" id="cb9-4" title="4"><span class="co">#&gt; [1] "(género desconocido)"</span></a></code></pre></div>
<ul>
<li>Fix for vector containing only empty values</li>
<li>Finds better results when input is in other languages</li>
@ -400,19 +421,19 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
<ul>
<li>
<p>Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1"><span class="co"># Determine genus of microorganisms (mo) in `septic_patients` data set:</span></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="co"># OLD WAY</span></a>
<a class="sourceLine" id="cb8-3" title="3">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-4" title="4"><span class="st"> </span><span class="kw">mutate</span>(<span class="dt">genus =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo)) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-5" title="5"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus)</a>
<a class="sourceLine" id="cb8-6" title="6"><span class="co"># NEW WAY</span></a>
<a class="sourceLine" id="cb8-7" title="7">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-8" title="8"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a>
<a class="sourceLine" id="cb8-9" title="9"></a>
<a class="sourceLine" id="cb8-10" title="10"><span class="co"># Even supports grouping variables:</span></a>
<a class="sourceLine" id="cb8-11" title="11">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-12" title="12"><span class="st"> </span><span class="kw">group_by</span>(gender) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-13" title="13"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a></code></pre></div>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" title="1"><span class="co"># Determine genus of microorganisms (mo) in `septic_patients` data set:</span></a>
<a class="sourceLine" id="cb10-2" title="2"><span class="co"># OLD WAY</span></a>
<a class="sourceLine" id="cb10-3" title="3">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb10-4" title="4"><span class="st"> </span><span class="kw">mutate</span>(<span class="dt">genus =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo)) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb10-5" title="5"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus)</a>
<a class="sourceLine" id="cb10-6" title="6"><span class="co"># NEW WAY</span></a>
<a class="sourceLine" id="cb10-7" title="7">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb10-8" title="8"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a>
<a class="sourceLine" id="cb10-9" title="9"></a>
<a class="sourceLine" id="cb10-10" title="10"><span class="co"># Even supports grouping variables:</span></a>
<a class="sourceLine" id="cb10-11" title="11">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb10-12" title="12"><span class="st"> </span><span class="kw">group_by</span>(gender) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb10-13" title="13"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a></code></pre></div>
</li>
<li>Header info is now available as a list, with the <code>header</code> function</li>
<li>The parameter <code>header</code> is now set to <code>TRUE</code> at default, even for markdown</li>
@ -432,6 +453,7 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
</li>
<li>Updated examples for resistance prediction (<code><a href="../reference/resistance_predict.html">resistance_predict()</a></code> function)</li>
<li>Fix for <code><a href="../reference/as.mic.html">as.mic()</a></code> to support more values ending in (several) zeroes</li>
<li>if using different lengths of pattern and x in <code>%like%</code>, it will now return the call</li>
</ul>
</div>
<div id="other" class="section level4">
@ -486,10 +508,10 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
<li>Fewer than 3 characters as input for <code>as.mo</code> will return NA</li>
<li>
<p>Function <code>as.mo</code> (and all <code>mo_*</code> wrappers) now supports genus abbreviations with “species” attached</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" title="1"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"E. species"</span>) <span class="co"># B_ESCHR</span></a>
<a class="sourceLine" id="cb9-2" title="2"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"E. spp."</span>) <span class="co"># "Escherichia species"</span></a>
<a class="sourceLine" id="cb9-3" title="3"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S. spp"</span>) <span class="co"># B_STPHY</span></a>
<a class="sourceLine" id="cb9-4" title="4"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"S. species"</span>) <span class="co"># "Staphylococcus species"</span></a></code></pre></div>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb11-1" title="1"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"E. species"</span>) <span class="co"># B_ESCHR</span></a>
<a class="sourceLine" id="cb11-2" title="2"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"E. spp."</span>) <span class="co"># "Escherichia species"</span></a>
<a class="sourceLine" id="cb11-3" title="3"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S. spp"</span>) <span class="co"># B_STPHY</span></a>
<a class="sourceLine" id="cb11-4" title="4"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"S. species"</span>) <span class="co"># "Staphylococcus species"</span></a></code></pre></div>
</li>
<li>Added parameter <code>combine_IR</code> (TRUE/FALSE) to functions <code>portion_df</code> and <code>count_df</code>, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)</li>
<li>Fix for <code>portion_*(..., as_percent = TRUE)</code> when minimal number of isolates would not be met</li>
@ -502,15 +524,15 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
<ul>
<li>
<p>Support for grouping variables, test with:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" title="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb10-2" title="2"><span class="st"> </span><span class="kw">group_by</span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb10-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" title="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb12-2" title="2"><span class="st"> </span><span class="kw">group_by</span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb12-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div>
</li>
<li>
<p>Support for (un)selecting columns:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb11-1" title="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb11-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb11-3" title="3"><span class="st"> </span><span class="kw">select</span>(<span class="op">-</span>count, <span class="op">-</span>cum_count) <span class="co"># only get item, percent, cum_percent</span></a></code></pre></div>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb13-1" title="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb13-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb13-3" title="3"><span class="st"> </span><span class="kw">select</span>(<span class="op">-</span>count, <span class="op">-</span>cum_count) <span class="co"># only get item, percent, cum_percent</span></a></code></pre></div>
</li>
<li>Check for <code><a href="https://www.rdocumentation.org/packages/hms/topics/hms">hms::is.hms</a></code>
</li>
@ -590,18 +612,18 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
</li>
</ul>
<p>They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" title="1"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>)</a>
<a class="sourceLine" id="cb12-2" title="2"><span class="co"># [1] "Gram negative"</span></a>
<a class="sourceLine" id="cb12-3" title="3"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>, <span class="dt">language =</span> <span class="st">"de"</span>) <span class="co"># German</span></a>
<a class="sourceLine" id="cb12-4" title="4"><span class="co"># [1] "Gramnegativ"</span></a>
<a class="sourceLine" id="cb12-5" title="5"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>, <span class="dt">language =</span> <span class="st">"es"</span>) <span class="co"># Spanish</span></a>
<a class="sourceLine" id="cb12-6" title="6"><span class="co"># [1] "Gram negativo"</span></a>
<a class="sourceLine" id="cb12-7" title="7"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"S. group A"</span>, <span class="dt">language =</span> <span class="st">"pt"</span>) <span class="co"># Portuguese</span></a>
<a class="sourceLine" id="cb12-8" title="8"><span class="co"># [1] "Streptococcus grupo A"</span></a></code></pre></div>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb14-1" title="1"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>)</a>
<a class="sourceLine" id="cb14-2" title="2"><span class="co"># [1] "Gram negative"</span></a>
<a class="sourceLine" id="cb14-3" title="3"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>, <span class="dt">language =</span> <span class="st">"de"</span>) <span class="co"># German</span></a>
<a class="sourceLine" id="cb14-4" title="4"><span class="co"># [1] "Gramnegativ"</span></a>
<a class="sourceLine" id="cb14-5" title="5"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>, <span class="dt">language =</span> <span class="st">"es"</span>) <span class="co"># Spanish</span></a>
<a class="sourceLine" id="cb14-6" title="6"><span class="co"># [1] "Gram negativo"</span></a>
<a class="sourceLine" id="cb14-7" title="7"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"S. group A"</span>, <span class="dt">language =</span> <span class="st">"pt"</span>) <span class="co"># Portuguese</span></a>
<a class="sourceLine" id="cb14-8" title="8"><span class="co"># [1] "Streptococcus grupo A"</span></a></code></pre></div>
<p>Furthermore, former taxonomic names will give a note about the current taxonomic name:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb13-1" title="1"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"Esc blattae"</span>)</a>
<a class="sourceLine" id="cb13-2" title="2"><span class="co"># Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)</span></a>
<a class="sourceLine" id="cb13-3" title="3"><span class="co"># [1] "Gram negative"</span></a></code></pre></div>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb15-1" title="1"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"Esc blattae"</span>)</a>
<a class="sourceLine" id="cb15-2" title="2"><span class="co"># Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)</span></a>
<a class="sourceLine" id="cb15-3" title="3"><span class="co"># [1] "Gram negative"</span></a></code></pre></div>
</li>
<li>Functions <code>count_R</code>, <code>count_IR</code>, <code>count_I</code>, <code>count_SI</code> and <code>count_S</code> to selectively count resistant or susceptible isolates
<ul>
@ -612,18 +634,18 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
</li>
<li>
<p>Functions <code>as.mo</code> and <code>is.mo</code> as replacements for <code>as.bactid</code> and <code>is.bactid</code> (since the <code>microoganisms</code> data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The <code>as.mo</code> function determines microbial IDs using intelligent rules:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb14-1" title="1"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"E. coli"</span>)</a>
<a class="sourceLine" id="cb14-2" title="2"><span class="co"># [1] B_ESCHR_COL</span></a>
<a class="sourceLine" id="cb14-3" title="3"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"MRSA"</span>)</a>
<a class="sourceLine" id="cb14-4" title="4"><span class="co"># [1] B_STPHY_AUR</span></a>
<a class="sourceLine" id="cb14-5" title="5"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S group A"</span>)</a>
<a class="sourceLine" id="cb14-6" title="6"><span class="co"># [1] B_STRPTC_GRA</span></a></code></pre></div>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb16-1" title="1"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"E. coli"</span>)</a>
<a class="sourceLine" id="cb16-2" title="2"><span class="co"># [1] B_ESCHR_COL</span></a>
<a class="sourceLine" id="cb16-3" title="3"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"MRSA"</span>)</a>
<a class="sourceLine" id="cb16-4" title="4"><span class="co"># [1] B_STPHY_AUR</span></a>
<a class="sourceLine" id="cb16-5" title="5"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S group A"</span>)</a>
<a class="sourceLine" id="cb16-6" title="6"><span class="co"># [1] B_STRPTC_GRA</span></a></code></pre></div>
<p>And with great speed too - on a quite regular Linux server from 2007 it takes us less than 0.02 seconds to transform 25,000 items:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb15-1" title="1">thousands_of_E_colis &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/rep">rep</a></span>(<span class="st">"E. coli"</span>, <span class="dv">25000</span>)</a>
<a class="sourceLine" id="cb15-2" title="2">microbenchmark<span class="op">::</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>(thousands_of_E_colis), <span class="dt">unit =</span> <span class="st">"s"</span>)</a>
<a class="sourceLine" id="cb15-3" title="3"><span class="co"># Unit: seconds</span></a>
<a class="sourceLine" id="cb15-4" title="4"><span class="co"># min median max neval</span></a>
<a class="sourceLine" id="cb15-5" title="5"><span class="co"># 0.01817717 0.01843957 0.03878077 100</span></a></code></pre></div>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" title="1">thousands_of_E_colis &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/rep">rep</a></span>(<span class="st">"E. coli"</span>, <span class="dv">25000</span>)</a>
<a class="sourceLine" id="cb17-2" title="2">microbenchmark<span class="op">::</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>(thousands_of_E_colis), <span class="dt">unit =</span> <span class="st">"s"</span>)</a>
<a class="sourceLine" id="cb17-3" title="3"><span class="co"># Unit: seconds</span></a>
<a class="sourceLine" id="cb17-4" title="4"><span class="co"># min median max neval</span></a>
<a class="sourceLine" id="cb17-5" title="5"><span class="co"># 0.01817717 0.01843957 0.03878077 100</span></a></code></pre></div>
</li>
<li>Added parameter <code>reference_df</code> for <code>as.mo</code>, so users can supply their own microbial IDs, name or codes as a reference table</li>
<li>Renamed all previous references to <code>bactid</code> to <code>mo</code>, like:
@ -651,12 +673,12 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
<li>Added three antimicrobial agents to the <code>antibiotics</code> data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)</li>
<li>
<p>Added 163 trade names to the <code>antibiotics</code> data set, it now contains 298 different trade names in total, e.g.:</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb16-1" title="1"><span class="kw"><a href="../reference/AMR-deprecated.html">ab_official</a></span>(<span class="st">"Bactroban"</span>)</a>
<a class="sourceLine" id="cb16-2" title="2"><span class="co"># [1] "Mupirocin"</span></a>
<a class="sourceLine" id="cb16-3" title="3"><span class="kw"><a href="../reference/AMR-deprecated.html">ab_name</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Bactroban"</span>, <span class="st">"Amoxil"</span>, <span class="st">"Zithromax"</span>, <span class="st">"Floxapen"</span>))</a>
<a class="sourceLine" id="cb16-4" title="4"><span class="co"># [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin"</span></a>
<a class="sourceLine" id="cb16-5" title="5"><span class="kw"><a href="../reference/AMR-deprecated.html">ab_atc</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Bactroban"</span>, <span class="st">"Amoxil"</span>, <span class="st">"Zithromax"</span>, <span class="st">"Floxapen"</span>))</a>
<a class="sourceLine" id="cb16-6" title="6"><span class="co"># [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"</span></a></code></pre></div>
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb18-1" title="1"><span class="kw"><a href="../reference/AMR-deprecated.html">ab_official</a></span>(<span class="st">"Bactroban"</span>)</a>
<a class="sourceLine" id="cb18-2" title="2"><span class="co"># [1] "Mupirocin"</span></a>
<a class="sourceLine" id="cb18-3" title="3"><span class="kw"><a href="../reference/AMR-deprecated.html">ab_name</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Bactroban"</span>, <span class="st">"Amoxil"</span>, <span class="st">"Zithromax"</span>, <span class="st">"Floxapen"</span>))</a>
<a class="sourceLine" id="cb18-4" title="4"><span class="co"># [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin"</span></a>
<a class="sourceLine" id="cb18-5" title="5"><span class="kw"><a href="../reference/AMR-deprecated.html">ab_atc</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Bactroban"</span>, <span class="st">"Amoxil"</span>, <span class="st">"Zithromax"</span>, <span class="st">"Floxapen"</span>))</a>
<a class="sourceLine" id="cb18-6" title="6"><span class="co"># [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"</span></a></code></pre></div>
</li>
<li>For <code>first_isolate</code>, rows will be ignored when theres no species available</li>
<li>Function <code>ratio</code> is now deprecated and will be removed in a future release, as it is not really the scope of this package</li>
@ -667,13 +689,13 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
</li>
<li>
<p>Support for quasiquotation in the functions series <code>count_*</code> and <code>portions_*</code>, and <code>n_rsi</code>. This allows to check for more than 2 vectors or columns.</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" title="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">select</span>(amox, cipr) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/count.html">count_IR</a></span>()</a>
<a class="sourceLine" id="cb17-2" title="2"><span class="co"># which is the same as:</span></a>
<a class="sourceLine" id="cb17-3" title="3">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/count.html">count_IR</a></span>(amox, cipr)</a>
<a class="sourceLine" id="cb17-4" title="4"></a>
<a class="sourceLine" id="cb17-5" title="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl)</a>
<a class="sourceLine" id="cb17-6" title="6">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl, gent)</a>
<a class="sourceLine" id="cb17-7" title="7">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl, gent, pita)</a></code></pre></div>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb19-1" title="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">select</span>(amox, cipr) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/count.html">count_IR</a></span>()</a>
<a class="sourceLine" id="cb19-2" title="2"><span class="co"># which is the same as:</span></a>
<a class="sourceLine" id="cb19-3" title="3">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/count.html">count_IR</a></span>(amox, cipr)</a>
<a class="sourceLine" id="cb19-4" title="4"></a>
<a class="sourceLine" id="cb19-5" title="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl)</a>
<a class="sourceLine" id="cb19-6" title="6">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl, gent)</a>
<a class="sourceLine" id="cb19-7" title="7">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl, gent, pita)</a></code></pre></div>
</li>
<li>Edited <code>ggplot_rsi</code> and <code>geom_rsi</code> so they can cope with <code>count_df</code>. The new <code>fun</code> parameter has value <code>portion_df</code> at default, but can be set to <code>count_df</code>.</li>
<li>Fix for <code>ggplot_rsi</code> when the <code>ggplot2</code> package was not loaded</li>
@ -687,12 +709,12 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
</li>
<li>
<p>Support for types (classes) list and matrix for <code>freq</code></p>
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb18-1" title="1">my_matrix =<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/with">with</a></span>(septic_patients, <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/matrix">matrix</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(age, gender), <span class="dt">ncol =</span> <span class="dv">2</span>))</a>
<a class="sourceLine" id="cb18-2" title="2"><span class="kw"><a href="../reference/freq.html">freq</a></span>(my_matrix)</a></code></pre></div>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" title="1">my_matrix =<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/with">with</a></span>(septic_patients, <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/matrix">matrix</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(age, gender), <span class="dt">ncol =</span> <span class="dv">2</span>))</a>
<a class="sourceLine" id="cb20-2" title="2"><span class="kw"><a href="../reference/freq.html">freq</a></span>(my_matrix)</a></code></pre></div>
<p>For lists, subsetting is possible:</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb19-1" title="1">my_list =<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">age =</span> septic_patients<span class="op">$</span>age, <span class="dt">gender =</span> septic_patients<span class="op">$</span>gender)</a>
<a class="sourceLine" id="cb19-2" title="2">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(age)</a>
<a class="sourceLine" id="cb19-3" title="3">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" title="1">my_list =<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">age =</span> septic_patients<span class="op">$</span>age, <span class="dt">gender =</span> septic_patients<span class="op">$</span>gender)</a>
<a class="sourceLine" id="cb21-2" title="2">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(age)</a>
<a class="sourceLine" id="cb21-3" title="3">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div>
</li>
</ul>
</div>

View File

@ -47,7 +47,7 @@
<script src="../extra.js"></script>
<meta property="og:title" content="Transform to microorganism ID — as.mo" />
<meta property="og:description" content="Use this function to determine a valid microorganism ID (mo). Determination is done using intelligent rules and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like &quot;Staphylococcus aureus&quot;), an abbreviated name (like &quot;S. aureus&quot;), an abbreviation known in the field (like &quot;MRSA&quot;), or just a genus. You could also select a genus and species column, zie Examples." />
<meta property="og:description" content="Use this function to determine a valid microorganism ID (mo). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea, Viruses, and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like &quot;Staphylococcus aureus&quot;), an abbreviated name (like &quot;S. aureus&quot;), an abbreviation known in the field (like &quot;MRSA&quot;), or just a genus. Please see Examples." />
<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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>
@ -237,7 +237,7 @@
<div class="ref-description">
<p>Use this function to determine a valid microorganism ID (<code>mo</code>). Determination is done using intelligent rules and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like <code>"Staphylococcus aureus"</code>), an abbreviated name (like <code>"S. aureus"</code>), an abbreviation known in the field (like <code>"MRSA"</code>), or just a genus. You could also <code>select</code> a genus and species column, zie Examples.</p>
<p>Use this function to determine a valid microorganism ID (<code>mo</code>). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea, Viruses, and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like <code>"Staphylococcus aureus"</code>), an abbreviated name (like <code>"S. aureus"</code>), an abbreviation known in the field (like <code>"MRSA"</code>), or just a genus. Please see Examples.</p>
</div>
@ -271,7 +271,7 @@
</tr>
<tr>
<th>allow_uncertain</th>
<td><p>a logical to indicate whether the input should be checked for less possible results, see Details</p></td>
<td><p>a logical (<code>TRUE</code> or <code>FALSE</code>) or a value between 0 and 3 to indicate whether the input should be checked for less possible results, see Details</p></td>
</tr>
<tr>
<th>reference_df</th>
@ -303,9 +303,9 @@
<p>Use the <code><a href='mo_property.html'>mo_property</a></code> functions to get properties based on the returned code, see Examples.</p>
<p><strong>Intelligent rules</strong> <br />
This function uses intelligent rules to help getting fast and logical results. It tries to find matches in this order:</p><ul>
<li><p>Taxonomic kingdom: it first searches in Bacteria, then Fungi, then Protozoa</p></li>
<li><p>Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see section <em>Microbial prevalence of pathogens in humans</em>)</p></li>
<li><p>Valid MO codes and full names: it first searches in already valid MO code and known genus/species combinations</p></li>
<li><p>Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see <em>Microbial prevalence of pathogens in humans</em> below)</p></li>
<li><p>Taxonomic kingdom: it first searches in Bacteria/Chromista, then Fungi, then Protozoa, then Viruses</p></li>
<li><p>Breakdown of input values: from here it starts to breakdown input values to find possible matches</p></li>
</ul>
<p>A couple of effects because of these rules:</p><ul>
@ -314,14 +314,17 @@ This function uses intelligent rules to help getting fast and logical results. I
<li><p>Something like <code>"stau"</code> or <code>"S aur"</code> will return the ID of <em>Staphylococcus aureus</em> and not <em>Staphylococcus auricularis</em></p></li>
</ul><p>This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms.</p>
<p><strong>Uncertain results</strong> <br />
When using <code>allow_uncertain = TRUE</code> (which is the default setting), it will use additional rules if all previous rules failed to get valid results. These are:</p><ul>
<li><p>It tries to look for previously accepted (but now invalid) taxonomic names</p></li>
<li><p>It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules</p></li>
<li><p>It strips off words from the end one by one and re-evaluates the input with all previous rules</p></li>
<li><p>It strips off words from the start one by one and re-evaluates the input with all previous rules</p></li>
<li><p>It tries to look for some manual changes which are not (yet) published to the Catalogue of Life (like <em>Propionibacterium</em> being <em>Cutibacterium</em>)</p></li>
The algorithm can additionally use three different levels of uncertainty to guess valid results. The default is <code>allow_uncertain = TRUE</code>, which is uqual to uncertainty level 2. Using <code>allow_uncertain = FALSE</code> will skip all of these additional rules:</p><ul>
<li><p>(uncertainty level 1): It tries to look for only matching genera</p></li>
<li><p>(uncertainty level 1): It tries to look for previously accepted (but now invalid) taxonomic names</p></li>
<li><p>(uncertainty level 1): It tries to look for some manual changes which are not (yet) published to the Catalogue of Life (like <em>Propionibacterium</em> being <em>Cutibacterium</em>)</p></li>
<li><p>(uncertainty level 2): It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules</p></li>
<li><p>(uncertainty level 2): It strips off words from the end one by one and re-evaluates the input with all previous rules</p></li>
<li><p>(uncertainty level 3): It strips off words from the start one by one and re-evaluates the input with all previous rules</p></li>
<li><p>(uncertainty level 3): It tries any part of the name</p></li>
</ul>
<p>Examples:</p><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>"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>
@ -330,7 +333,7 @@ When using <code>allow_uncertain = TRUE</code> (which is the default setting), i
<p>Use <code>mo_uncertainties()</code> to get a data.frame with all values that were coerced to a valid value, but with uncertainty.</p>
<p>Use <code>mo_renamed()</code> to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name.</p>
<p><strong>Microbial prevalence of pathogens in humans</strong> <br />
The intelligent rules takes into account microbial prevalence of pathogens in humans. It uses three groups and every (sub)species is in the group it matches first. These groups are:</p><ul>
The intelligent rules takes into account microbial prevalence of pathogens in humans. It uses three groups and all (sub)species are in only one group. These groups are:</p><ul>
<li><p>1 (most prevalent): class is Gammaproteobacteria <strong>or</strong> genus is one of: <em>Enterococcus</em>, <em>Staphylococcus</em>, <em>Streptococcus</em>.</p></li>
<li><p>2: phylum is one of: Proteobacteria, Firmicutes, Actinobacteria, Sarcomastigophora <strong>or</strong> genus is one of: <em>Aspergillus</em>, <em>Bacteroides</em>, <em>Candida</em>, <em>Capnocytophaga</em>, <em>Chryseobacterium</em>, <em>Cryptococcus</em>, <em>Elisabethkingia</em>, <em>Flavobacterium</em>, <em>Fusobacterium</em>, <em>Giardia</em>, <em>Leptotrichia</em>, <em>Mycoplasma</em>, <em>Prevotella</em>, <em>Rhodotorula</em>, <em>Treponema</em>, <em>Trichophyton</em>, <em>Ureaplasma</em>.</p></li>
<li><p>3 (least prevalent): all others.</p></li>
@ -374,6 +377,7 @@ The <code><a href='mo_property.html'>mo_property</a></code> functions (like <cod
<span class='fu'>as.mo</span>(<span class='st'>"S aureus"</span>)
<span class='fu'>as.mo</span>(<span class='st'>"Staphylococcus aureus"</span>)
<span class='fu'>as.mo</span>(<span class='st'>"Staphylococcus aureus (MRSA)"</span>)
<span class='fu'>as.mo</span>(<span class='st'>"Sthafilokkockus aaureuz"</span>) <span class='co'># handles incorrect spelling</span>
<span class='fu'>as.mo</span>(<span class='st'>"MRSA"</span>) <span class='co'># Methicillin Resistant S. aureus</span>
<span class='fu'>as.mo</span>(<span class='st'>"VISA"</span>) <span class='co'># Vancomycin Intermediate S. aureus</span>
<span class='fu'>as.mo</span>(<span class='st'>"VRSA"</span>) <span class='co'># Vancomycin Resistant S. aureus</span>

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>

View File

@ -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="Released version">0.5.0.9021</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9022</span>
</span>
</div>
@ -245,7 +245,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 4,731 observations and 2 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 5,171 observations and 2 variables:</p><dl class='dl-horizontal'>
<dt><code>certe</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>

View File

@ -31,7 +31,7 @@ mo_renamed()
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 logical to indicate whether the input should be checked for less possible results, see Details}
\item{allow_uncertain}{a logical (\code{TRUE} or \code{FALSE}) or a value between 0 and 3 to indicate whether the input should be checked for less possible 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).}
}
@ -39,7 +39,7 @@ mo_renamed()
Character (vector) with class \code{"mo"}. Unknown values will return \code{NA}.
}
\description{
Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using intelligent rules and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea, Viruses, and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. Please see Examples.
}
\details{
A microbial ID from this package (class: \code{mo}) typically looks like these examples:\cr
@ -65,9 +65,9 @@ Use the \code{\link{mo_property}} functions to get properties based on the retur
\strong{Intelligent rules} \cr
This function uses intelligent rules to help getting fast and logical results. It tries to find matches in this order:
\itemize{
\item{Taxonomic kingdom: it first searches in Bacteria, then Fungi, then Protozoa}
\item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see section \emph{Microbial prevalence of pathogens in humans})}
\item{Valid MO codes and full names: it first searches in already valid MO code and known genus/species combinations}
\item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see \emph{Microbial prevalence of pathogens in humans} below)}
\item{Taxonomic kingdom: it first searches in Bacteria/Chromista, then Fungi, then Protozoa, then Viruses}
\item{Breakdown of input values: from here it starts to breakdown input values to find possible matches}
}
@ -80,15 +80,19 @@ A couple of effects because of these rules:
This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms.
\strong{Uncertain results} \cr
When using \code{allow_uncertain = TRUE} (which is the default setting), it will use additional rules if all previous rules failed to get valid results. These are:
The algorithm can additionally use three different levels of uncertainty to guess valid results. The default is \code{allow_uncertain = TRUE}, which is uqual to uncertainty level 2. Using \code{allow_uncertain = FALSE} will skip all of these additional rules:
\itemize{
\item{It tries to look for previously accepted (but now invalid) taxonomic names}
\item{It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules}
\item{It strips off words from the end one by one and re-evaluates the input with all previous rules}
\item{It strips off words from the start one by one and re-evaluates the input with all previous rules}
\item{It tries to look for some manual changes which are not (yet) published to the Catalogue of Life (like \emph{Propionibacterium} being \emph{Cutibacterium})}
\item{(uncertainty level 1): It tries to look for only matching genera}
\item{(uncertainty level 1): It tries to look for previously accepted (but now invalid) taxonomic names}
\item{(uncertainty level 1): It tries to look for some manual changes which are not (yet) published to the Catalogue of Life (like \emph{Propionibacterium} being \emph{Cutibacterium})}
\item{(uncertainty level 2): It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules}
\item{(uncertainty level 2): It strips off words from the end one by one and re-evaluates the input with all previous rules}
\item{(uncertainty level 3): It strips off words from the start one by one and re-evaluates the input with all previous rules}
\item{(uncertainty level 3): It tries any part of the name}
}
You can also use e.g. \code{as.mo(..., allow_uncertain = 1)} to only allow up to level 1 uncertainty.
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.}
@ -103,7 +107,7 @@ Use \code{mo_uncertainties()} to get a data.frame with all values that were coer
Use \code{mo_renamed()} to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name.
\strong{Microbial prevalence of pathogens in humans} \cr
The intelligent rules takes into account microbial prevalence of pathogens in humans. It uses three groups and every (sub)species is in the group it matches first. These groups are:
The intelligent rules takes into account microbial prevalence of pathogens in humans. It uses three groups and all (sub)species are in only one group. These groups are:
\itemize{
\item{1 (most prevalent): class is Gammaproteobacteria \strong{or} genus is one of: \emph{Enterococcus}, \emph{Staphylococcus}, \emph{Streptococcus}.}
\item{2: phylum is one of: Proteobacteria, Firmicutes, Actinobacteria, Sarcomastigophora \strong{or} genus is one of: \emph{Aspergillus}, \emph{Bacteroides}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Chryseobacterium}, \emph{Cryptococcus}, \emph{Elisabethkingia}, \emph{Flavobacterium}, \emph{Fusobacterium}, \emph{Giardia}, \emph{Leptotrichia}, \emph{Mycoplasma}, \emph{Prevotella}, \emph{Rhodotorula}, \emph{Treponema}, \emph{Trichophyton}, \emph{Ureaplasma}.}
@ -146,6 +150,7 @@ as.mo("S. aureus")
as.mo("S aureus")
as.mo("Staphylococcus aureus")
as.mo("Staphylococcus aureus (MRSA)")
as.mo("Sthafilokkockus aaureuz") # handles incorrect spelling
as.mo("MRSA") # Methicillin Resistant S. aureus
as.mo("VISA") # Vancomycin Intermediate S. aureus
as.mo("VRSA") # Vancomycin Resistant S. aureus

View File

@ -4,7 +4,7 @@
\name{microorganisms.codes}
\alias{microorganisms.codes}
\title{Translation table for microorganism codes}
\format{A \code{\link{data.frame}} with 4,731 observations and 2 variables:
\format{A \code{\link{data.frame}} with 5,171 observations and 2 variables:
\describe{
\item{\code{certe}}{Commonly used code of a microorganism}
\item{\code{mo}}{ID of the microorganism in the \code{\link{microorganisms}} data set}

View File

@ -80,10 +80,11 @@ test_that("as.mo works", {
"staaur",
"S. aureus",
"S aureus",
"Sthafilokkockus aureeuzz",
"Staphylococcus aureus",
"MRSA",
"VISA"))),
rep("B_STPHY_AUR", 8))
rep("B_STPHY_AUR", 9))
expect_identical(
as.character(
as.mo(c('EHEC', 'EPEC', 'EIEC', 'STEC', 'ATEC'))),
@ -229,7 +230,7 @@ test_that("as.mo works", {
c("Microbacterium paraoxidans",
"Streptococcus suis (bovis gr)",
"Raoultella (here some text) terrigena")))),
c("B_MCRBC", "B_STRPT_SUI", "B_RLTLL_TER"))
c("B_MCRBC_PAR", "B_STRPT_SUI", "B_RLTLL_TER"))
print(mo_uncertainties())
# Salmonella (City) are all actually Salmonella enterica spp (City)