diff --git a/DESCRIPTION b/DESCRIPTION index ca95dab4..dd487ba3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR Version: 0.5.0.9020 -Date: 2019-03-01 +Date: 2019-03-02 Title: Antimicrobial Resistance Analysis Authors@R: c( person( diff --git a/NEWS.md b/NEWS.md index 83092115..282d57a1 100755 --- a/NEWS.md +++ b/NEWS.md @@ -78,11 +78,18 @@ 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()`: +* 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: + ```r + mo_genus("qwerty", language = "es") + # Warning: + # one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it. + #> [1] "(género desconocido)" + ``` * Fix for vector containing only empty values * Finds better results when input is in other languages * Better handling for subspecies - * Better handling for *Salmonellae* + * Better handling for *Salmonellae*, especially the 'city like' serovars like *Salmonella London* * Understanding of highly virulent *E. coli* strains like EIEC, EPEC and STEC * There will be looked for uncertain results at default - these results will be returned with an informative warning * Manual (help page) now contains more info about the algorithms @@ -102,7 +109,9 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git * New colours for `scale_rsi_colours()` * Summaries of class `mo` will now return the top 3 and the unique count, e.g. using `summary(mo)` * Small text updates to summaries of class `rsi` and `mic` -* Function `as.rsi()` now gives a warning when inputting MIC values +* Function `as.rsi()`: + * Now gives a warning when inputting MIC values + * Now accepts high and low resistance: `"HIGH S"` will return `S` * Frequency tables (`freq()` function): * Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes: ```r diff --git a/R/data.R b/R/data.R index 8ff7db5f..3bfacf79 100755 --- a/R/data.R +++ b/R/data.R @@ -134,7 +134,7 @@ #' #' A data set containing the microbial taxonomy of six kingdoms from the Catalogue of Life. MO codes can be looked up using \code{\link{as.mo}}. #' @inheritSection catalogue_of_life Catalogue of Life -#' @format A \code{\link{data.frame}} with 57,158 observations and 14 variables: +#' @format A \code{\link{data.frame}} with 59,985 observations and 15 variables: #' \describe{ #' \item{\code{mo}}{ID of microorganism as used by this package} #' \item{\code{col_id}}{Catalogue of Life ID} @@ -150,6 +150,7 @@ #' \item{\code{rank}}{Taxonomic rank of the microorganism, like \code{"species"} or \code{"genus"}} #' \item{\code{ref}}{Author(s) and year of concerning scientific publication} #' \item{\code{species_id}}{ID of the species as used by the Catalogue of Life} +#' \item{\code{prevalence}}{Prevalence of the microorganism, see \code{?as.mo}} #' } #' @source Catalogue of Life: Annual Checklist (public online database), \url{www.catalogueoflife.org}. #' @details Manually added were: @@ -172,7 +173,7 @@ catalogue_of_life <- list( #' #' A data set containing old (previously valid or accepted) taxonomic names according to the Catalogue of Life. This data set is used internally by \code{\link{as.mo}}. #' @inheritSection catalogue_of_life Catalogue of Life -#' @format A \code{\link{data.frame}} with 14,487 observations and 4 variables: +#' @format A \code{\link{data.frame}} with 17,069 observations and 4 variables: #' \describe{ #' \item{\code{col_id}}{Catalogue of Life ID} #' \item{\code{tsn_new}}{New Catalogue of Life ID} diff --git a/R/mo.R b/R/mo.R index f3418b14..856f68ba 100755 --- a/R/mo.R +++ b/R/mo.R @@ -51,6 +51,8 @@ #' F (Fungi), P (Protozoa), PL (Plantae) or V (Viruses) #' } #' +#' Values that cannot be coered will be considered 'unknown' and have an MO code \code{UNKNOWN}. +#' #' Use the \code{\link{mo_property}} functions to get properties based on the returned code, see Examples. #' #' \strong{Artificial Intelligence} \cr @@ -275,7 +277,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, # only check the uniques, which is way faster x <- unique(x) # remove empty values (to later fill them in again with NAs) - x <- x[!is.na(x) & !is.null(x) & !identical(x, "")] + # ("xxx" is WHONET code for 'no growth') + x <- x[!is.na(x) & !is.null(x) & !identical(x, "") & !identical(x, "xxx")] # conversion of old MO codes from v0.5.0 (ITIS) to later versions (Catalogue of Life) if (any(x %like% "^[BFP]_[A-Z]{3,7}") & !all(x %in% microorganisms$mo)) { @@ -367,8 +370,6 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, 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) - # remove 'empty' genus and species values - x <- gsub("(no MO)", "", x, fixed = TRUE) # remove non-text in case of "E. coli" except dots and spaces x <- gsub("[^.a-zA-Z0-9/ \\-]+", "", x) # replace minus by a space @@ -419,12 +420,17 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, next } - if (tolower(x_trimmed[i]) %in% c("", "xxx", "other", "none", "unknown")) { - # empty and nonsense values, ignore without warning ("xxx" is WHONET code for 'no growth') + if (any(x_trimmed[i] %in% c(NA, ""))) { x[i] <- NA_character_ next } + if (tolower(x_trimmed[i]) %in% c("xxx", "other", "none", "unknown")) { + # empty and nonsense values, ignore without warning + x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]] + next + } + if (nchar(gsub("[^a-zA-Z]", "", x_trimmed[i])) < 3) { # check if search term was like "A. species", then return first genus found with ^A if (x_backup[i] %like% "[a-z]+ species" | x_backup[i] %like% "[a-z] spp[.]?") { @@ -441,14 +447,14 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, } } # fewer than 3 chars and not looked for species, add as failure - x[i] <- NA_character_ + x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]] failures <- c(failures, x_backup[i]) next } if (x_trimmed[i] %like% "virus") { # there is no fullname like virus, so don't try to coerce it - x[i] <- NA_character_ + x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]] failures <- c(failures, x_backup[i]) next } @@ -667,7 +673,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, 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]) - if (!is.na(x[i])) { + if (!empty_result(x[i])) { next } # THEN TRY PREVALENT IN HUMAN INFECTIONS ---- @@ -678,7 +684,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, 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]) - if (!is.na(x[i])) { + if (!empty_result(x[i])) { next } # THEN UNPREVALENT IN HUMAN INFECTIONS ---- @@ -689,7 +695,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, 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]) - if (!is.na(x[i])) { + if (!empty_result(x[i])) { next } @@ -765,7 +771,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, # (3) 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 (!is.na(found)) { + if (!empty_result(found)) { found_result <- found found <- microorganismsDT[mo == found, ..property][[1]] uncertainties <<- rbind(uncertainties, @@ -780,7 +786,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, 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 (!is.na(found) & nchar(b.x_trimmed) >= 6) { + if (!empty_result(found) & nchar(b.x_trimmed) >= 6) { found_result <- found found <- microorganismsDT[mo == found, ..property][[1]] uncertainties <<- rbind(uncertainties, @@ -797,7 +803,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, 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 (!is.na(found)) { + if (!empty_result(found)) { found_result <- found found <- microorganismsDT[mo == found, ..property][[1]] uncertainties <<- rbind(uncertainties, @@ -816,7 +822,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, 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))) - if (!is.na(found)) { + if (!empty_result(found)) { found_result <- found found <- microorganismsDT[mo == found, ..property][[1]] uncertainties <<- rbind(uncertainties, @@ -833,13 +839,15 @@ 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"]] - found <- microorganismsDT[mo == found_result[1L], ..property][[1]] - uncertainties <<- rbind(uncertainties, - data.frame(uncertainty = 3, - input = a.x_backup, - fullname = microorganismsDT[mo == found_result[1L], fullname][[1]], - mo = found_result[1L])) - return(found[1L]) + if (!empty_result(found_result)) { + found <- microorganismsDT[mo == found_result[1L], ..property][[1]] + uncertainties <<- rbind(uncertainties, + data.frame(uncertainty = 3, + input = a.x_backup, + fullname = microorganismsDT[mo == found_result[1L], fullname][[1]], + mo = found_result[1L])) + return(found[1L]) + } } # didn't found in uncertain results too @@ -847,13 +855,13 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, } 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 (!is.na(x[i])) { + if (!empty_result(x[i])) { next } } # not found ---- - x[i] <- NA_character_ + x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]] failures <- c(failures, x_backup[i]) } } @@ -862,15 +870,15 @@ 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") + plural <- c("value", "it", "is") if (n_distinct(failures) > 1) { - plural <- c("values", "them") + plural <- c("values", "them", "are") } 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 input ", plural[1], + msg <- paste0("\n", nr2char(n_distinct(failures)), " unique ", plural[1], " (^= ", percent(total_failures / total_n, round = 1, force_zero = TRUE), - ") could not be coerced to a valid MO code") + ") could not be coerced and ", plural[3], " considered 'unknown'") if (n_distinct(failures) <= 10) { msg <- paste0(msg, ": ", paste('"', unique(failures), '"', sep = "", collapse = ', ')) } @@ -887,7 +895,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, if (NROW(uncertainties) > 1) { plural <- c("values", "them") } - msg <- paste0("\nResults of ", nr2char(NROW(uncertainties)), " input ", plural[1], + msg <- paste0("\nResults of ", nr2char(NROW(uncertainties)), " ", plural[1], " was guessed with uncertainty. Use mo_uncertainties() to review ", plural[2], ".") warning(red(msg), call. = FALSE, @@ -951,7 +959,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, # Wrap up ---------------------------------------------------------------- # comply to x, which is also unique and without empty values - x_input_unique_nonempty <- unique(x_input[!is.na(x_input) & !is.null(x_input) & !identical(x_input, "")]) + x_input_unique_nonempty <- unique(x_input[!is.na(x_input) & !is.null(x_input) & !identical(x_input, "") & !identical(x_input, "xxx")]) # left join the found results to the original input values (x_input) df_found <- data.frame(input = as.character(x_input_unique_nonempty), @@ -984,6 +992,10 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, x } +empty_result <- function(x) { + x %in% c(NA, "UNKNOWN") +} + TEMPORARY_TAXONOMY <- function(x) { x[x %like% 'Cutibacterium'] <- gsub('Cutibacterium', 'Propionibacterium', x[x %like% 'Cutibacterium']) x diff --git a/R/mo_property.R b/R/mo_property.R index c6a2df7d..b3ece779 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -364,7 +364,7 @@ mo_translate <- function(x, language) { } x_tobetranslated <- grepl(x = x, - pattern = "(Coagulase Negative Staphylococcus|Coagulase Positive Staphylococcus|Beta-haemolytic Streptococcus|unknown Gram negatives|unknown Gram positives|CoNS|CoPS|no MO|Gram negative|Gram positive|Bacteria|Fungi|Protozoa|biogroup|biotype|vegetative|group|Group)") + pattern = "(Coagulase Negative Staphylococcus|Coagulase Positive Staphylococcus|Beta-haemolytic Streptococcus|unknown Gram negatives|unknown Gram positives|unknown name|unknown kingdom|unknown phylum|unknown class|unknown order|unknown family|unknown genus|unknown species|unknown subspecies|unknown rank|CoNS|CoPS|Gram negative|Gram positive|Bacteria|Fungi|Protozoa|biogroup|biotype|vegetative|group|Group)") if (sum(x_tobetranslated, na.rm = TRUE) == 0) { return(x) @@ -379,9 +379,18 @@ mo_translate <- function(x, language) { gsub("Beta-haemolytic Streptococcus", "Beta-h\u00e4molytischer Streptococcus", ., fixed = TRUE) %>% gsub("unknown Gram negatives", "unbekannte Gramnegativen", ., fixed = TRUE) %>% gsub("unknown Gram positives", "unbekannte Grampositiven", ., fixed = TRUE) %>% + gsub("unknown name", "unbekannte Name", ., fixed = TRUE) %>% + gsub("unknown kingdom", "unbekanntes Reich", ., fixed = TRUE) %>% + gsub("unknown phylum", "unbekannter Stamm", ., fixed = TRUE) %>% + gsub("unknown class", "unbekannte Klasse", ., fixed = TRUE) %>% + gsub("unknown order", "unbekannte Ordnung", ., fixed = TRUE) %>% + gsub("unknown family", "unbekannte Familie", ., fixed = TRUE) %>% + gsub("unknown genus", "unbekannte Gattung", ., fixed = TRUE) %>% + gsub("unknown species", "unbekannte Art", ., fixed = TRUE) %>% + gsub("unknown subspecies", "unbekannte Unterart", ., fixed = TRUE) %>% + gsub("unknown rank", "unbekannter Rang", ., fixed = TRUE) %>% gsub("(CoNS)", "(KNS)", ., fixed = TRUE) %>% gsub("(CoPS)", "(KPS)", ., fixed = TRUE) %>% - gsub("(no MO)", "(kein MO)", ., fixed = TRUE) %>% gsub("Gram negative", "Gramnegativ", ., fixed = TRUE) %>% gsub("Gram positive", "Grampositiv", ., fixed = TRUE) %>% gsub("Bacteria", "Bakterien", ., fixed = TRUE) %>% @@ -401,7 +410,16 @@ mo_translate <- function(x, language) { gsub("Beta-haemolytic Streptococcus", "Beta-hemolytische Streptococcus", ., fixed = TRUE) %>% gsub("unknown Gram negatives", "onbekende Gram-negatieven", ., fixed = TRUE) %>% gsub("unknown Gram positives", "onbekende Gram-positieven", ., fixed = TRUE) %>% - gsub("(no MO)", "(geen MO)", ., fixed = TRUE) %>% + gsub("unknown name", "onbekende naam", ., fixed = TRUE) %>% + gsub("unknown kingdom", "onbekend koninkrijk", ., fixed = TRUE) %>% + gsub("unknown phylum", "onbekende fylum", ., fixed = TRUE) %>% + gsub("unknown class", "onbekende klasse", ., fixed = TRUE) %>% + gsub("unknown order", "onbekende orde", ., fixed = TRUE) %>% + gsub("unknown family", "onbekende familie", ., fixed = TRUE) %>% + gsub("unknown genus", "onbekend geslacht", ., fixed = TRUE) %>% + gsub("unknown species", "onbekende soort", ., fixed = TRUE) %>% + gsub("unknown subspecies", "onbekende ondersoort", ., fixed = TRUE) %>% + gsub("unknown rank", "onbekende rang", ., fixed = TRUE) %>% gsub("(CoNS)", "(CNS)", ., fixed = TRUE) %>% gsub("(CoPS)", "(CPS)", ., fixed = TRUE) %>% gsub("Gram negative", "Gram-negatief", ., fixed = TRUE) %>% @@ -423,7 +441,16 @@ mo_translate <- function(x, language) { gsub("Beta-haemolytic Streptococcus", "Streptococcus Beta-hemol\u00edtico", ., fixed = TRUE) %>% gsub("unknown Gram negatives", "Gram negativos desconocidos", ., fixed = TRUE) %>% gsub("unknown Gram positives", "Gram positivos desconocidos", ., fixed = TRUE) %>% - gsub("(no MO)", "(sin MO)", ., fixed = TRUE) %>% + gsub("unknown name", "nombre desconocido", ., fixed = TRUE) %>% + gsub("unknown kingdom", "reino desconocido", ., fixed = TRUE) %>% + gsub("unknown phylum", "filo desconocido", ., fixed = TRUE) %>% + gsub("unknown class", "clase desconocida", ., fixed = TRUE) %>% + gsub("unknown order", "orden desconocido", ., fixed = TRUE) %>% + gsub("unknown family", "familia desconocida", ., fixed = TRUE) %>% + gsub("unknown genus", "g\u00e9nero desconocido", ., fixed = TRUE) %>% + gsub("unknown species", "especie desconocida", ., fixed = TRUE) %>% + gsub("unknown subspecies", "subespecie desconocida", ., fixed = TRUE) %>% + gsub("unknown rank", "rango desconocido", ., fixed = TRUE) %>% gsub("Gram negative", "Gram negativo", ., fixed = TRUE) %>% gsub("Gram positive", "Gram positivo", ., fixed = TRUE) %>% gsub("Bacteria", "Bacterias", ., fixed = TRUE) %>% @@ -443,7 +470,16 @@ mo_translate <- function(x, language) { gsub("Beta-haemolytic Streptococcus", "Streptococcus Beta-emolitico", ., fixed = TRUE) %>% gsub("unknown Gram negatives", "Gram negativi sconosciuti", ., fixed = TRUE) %>% gsub("unknown Gram positives", "Gram positivi sconosciuti", ., fixed = TRUE) %>% - gsub("(no MO)", "(non MO)", ., fixed = TRUE) %>% + gsub("unknown name", "nome sconosciuto", ., fixed = TRUE) %>% + gsub("unknown kingdom", "regno sconosciuto", ., fixed = TRUE) %>% + gsub("unknown phylum", "phylum sconosciuto", ., fixed = TRUE) %>% + gsub("unknown class", "classe sconosciuta", ., fixed = TRUE) %>% + gsub("unknown order", "ordine sconosciuto", ., fixed = TRUE) %>% + gsub("unknown family", "famiglia sconosciuta", ., fixed = TRUE) %>% + gsub("unknown genus", "genere sconosciuto", ., fixed = TRUE) %>% + gsub("unknown species", "specie sconosciute", ., fixed = TRUE) %>% + gsub("unknown subspecies", "sottospecie sconosciute", ., fixed = TRUE) %>% + gsub("unknown rank", "grado sconosciuto", ., fixed = TRUE) %>% gsub("Gram negative", "Gram negativo", ., fixed = TRUE) %>% gsub("Gram positive", "Gram positivo", ., fixed = TRUE) %>% gsub("Bacteria", "Batteri", ., fixed = TRUE) %>% @@ -462,7 +498,16 @@ mo_translate <- function(x, language) { gsub("Beta-haemolytic Streptococcus", "Streptococcus B\u00eata-h\u00e9molytique", ., fixed = TRUE) %>% gsub("unknown Gram negatives", "Gram n\u00e9gatifs inconnus", ., fixed = TRUE) %>% gsub("unknown Gram positives", "Gram positifs inconnus", ., fixed = TRUE) %>% - gsub("(no MO)", "(pas MO)", ., fixed = TRUE) %>% + gsub("unknown name", "nom inconnu", ., fixed = TRUE) %>% + gsub("unknown kingdom", "r\u00e8gme inconnu", ., fixed = TRUE) %>% + gsub("unknown phylum", "embranchement inconnu", ., fixed = TRUE) %>% + gsub("unknown class", "classe inconnue", ., fixed = TRUE) %>% + gsub("unknown order", "ordre inconnu", ., fixed = TRUE) %>% + gsub("unknown family", "famille inconnue", ., fixed = TRUE) %>% + gsub("unknown genus", "genre inconnu", ., fixed = TRUE) %>% + gsub("unknown species", "esp\u00e8ce inconnue", ., fixed = TRUE) %>% + gsub("unknown subspecies", "sous-esp\u00e8ce inconnue", ., fixed = TRUE) %>% + gsub("unknown rank", "rang inconnu", ., fixed = TRUE) %>% gsub("Gram negative", "Gram n\u00e9gatif", ., fixed = TRUE) %>% gsub("Gram positive", "Gram positif", ., fixed = TRUE) %>% gsub("Bacteria", "Bact\u00e9ries", ., fixed = TRUE) %>% @@ -482,7 +527,16 @@ mo_translate <- function(x, language) { gsub("Beta-haemolytic Streptococcus", "Streptococcus Beta-hemol\u00edtico", ., fixed = TRUE) %>% gsub("unknown Gram negatives", "Gram negativos desconhecidos", ., fixed = TRUE) %>% gsub("unknown Gram positives", "Gram positivos desconhecidos", ., fixed = TRUE) %>% - gsub("(no MO)", "(sem MO)", ., fixed = TRUE) %>% + gsub("unknown name", "nome desconhecido", ., fixed = TRUE) %>% + gsub("unknown kingdom", "reino desconhecido", ., fixed = TRUE) %>% + gsub("unknown phylum", "filo desconhecido", ., fixed = TRUE) %>% + gsub("unknown class", "classe desconhecida", ., fixed = TRUE) %>% + gsub("unknown order", "ordem desconhecido", ., fixed = TRUE) %>% + gsub("unknown family", "fam\u00edlia desconhecida", ., fixed = TRUE) %>% + gsub("unknown genus", "g\u00eanero desconhecido", ., fixed = TRUE) %>% + gsub("unknown species", "esp\u00e9cies desconhecida", ., fixed = TRUE) %>% + gsub("unknown subspecies", "subesp\u00e9cies desconhecida", ., fixed = TRUE) %>% + gsub("unknown rank", "classifica\u00e7\u00e3o desconhecido", ., fixed = TRUE) %>% gsub("Gram negative", "Gram negativo", ., fixed = TRUE) %>% gsub("Gram positive", "Gram positivo", ., fixed = TRUE) %>% gsub("Bacteria", "Bact\u00e9rias", ., fixed = TRUE) %>% diff --git a/R/rsi.R b/R/rsi.R index 12b17b67..cdbdf93b 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -76,6 +76,9 @@ as.rsi <- function(x) { x <- gsub(' +', '', x) # remove all MIC-like values: numbers, operators and periods x <- gsub('[0-9.,;:<=>]+', '', x) + # remove everything between brackets, and 'high' and 'low' + x <- gsub("([(].*[)])", "", x) + x <- gsub("(high|low)", "", x, ignore.case = TRUE) # disallow more than 3 characters x[nchar(x) > 3] <- NA # set to capitals diff --git a/R/zzz.R b/R/zzz.R index 1bd04758..78dccdcf 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -55,6 +55,7 @@ make <- function() { mutate(prevalence = case_when( class == "Gammaproteobacteria" | genus %in% c("Enterococcus", "Staphylococcus", "Streptococcus") + | mo == "UNKNOWN" ~ 1, phylum %in% c("Proteobacteria", "Firmicutes", diff --git a/data/microorganisms.rda b/data/microorganisms.rda index 0e3d9f6d..db3e616c 100755 Binary files a/data/microorganisms.rda and b/data/microorganisms.rda differ diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index ba2b021f..ca96704e 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -192,7 +192,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

@@ -201,7 +201,7 @@ -

Note: values on this page will change with every website update since they are based on randomly created values and the page was written in RMarkdown. However, the methodology remains unchanged. This page was generated on 01 March 2019.

+

Note: values on this page will change with every website update since they are based on randomly created values and the page was written in RMarkdown. However, the methodology remains unchanged. This page was generated on 02 March 2019.

Introduction

@@ -217,21 +217,21 @@ -2019-03-01 +2019-03-02 abcd Escherichia coli S S -2019-03-01 +2019-03-02 abcd Escherichia coli S R -2019-03-01 +2019-03-02 efgh Escherichia coli R @@ -327,53 +327,9 @@ -2017-06-13 -Z3 -Hospital D -Escherichia coli -R -S -S -S -F - - -2013-09-13 -A1 -Hospital D -Escherichia coli -R -S -S -S -M - - -2015-06-10 -L8 -Hospital B -Escherichia coli -S -R -S -S -M - - -2010-08-05 -A7 -Hospital D -Klebsiella pneumoniae -R -S -S -S -M - - -2011-08-25 -X4 -Hospital C +2012-06-30 +W5 +Hospital A Staphylococcus aureus S S @@ -382,14 +338,58 @@ F -2011-03-09 -B7 -Hospital D +2012-07-07 +T4 +Hospital B Escherichia coli R +R +R +S +F + + +2011-02-19 +H3 +Hospital B +Escherichia coli S S S +S +M + + +2012-12-15 +G10 +Hospital C +Klebsiella pneumoniae +R +S +R +S +M + + +2010-09-11 +L4 +Hospital D +Staphylococcus aureus +S +S +S +S +M + + +2011-03-27 +H5 +Hospital A +Escherichia coli +S +S +S +R M @@ -411,8 +411,8 @@ #> #> Item Count Percent Cum. Count Cum. Percent #> --- ----- ------- -------- ----------- ------------- -#> 1 M 10,311 51.6% 10,311 51.6% -#> 2 F 9,689 48.4% 20,000 100.0% +#> 1 M 10,433 52.2% 10,433 52.2% +#> 2 F 9,567 47.8% 20,000 100.0%

So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values M and F. From a researcher perspective: there are slightly more men. Nothing we didn’t already know.

The data is already quite clean, but we still need to transform some variables. The bacteria column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The mutate() function of the dplyr package makes this really easy:

data <- data %>%
@@ -443,10 +443,10 @@
 #> Kingella kingae (no changes)
 #> 
 #> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-#> Table 1:  Intrinsic resistance in Enterobacteriaceae (1364 changes)
+#> Table 1:  Intrinsic resistance in Enterobacteriaceae (1323 changes)
 #> Table 2:  Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)
 #> Table 3:  Intrinsic resistance in other Gram-negative bacteria (no changes)
-#> Table 4:  Intrinsic resistance in Gram-positive bacteria (2659 changes)
+#> Table 4:  Intrinsic resistance in Gram-positive bacteria (2834 changes)
 #> Table 8:  Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)
 #> Table 9:  Interpretive rules for B-lactam agents and Gram-negative rods (no changes)
 #> Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)
@@ -462,9 +462,9 @@
 #> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)
 #> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)
 #> 
-#> => EUCAST rules affected 7,366 out of 20,000 rows
+#> => EUCAST rules affected 7,524 out of 20,000 rows
 #>    -> added 0 test results
-#>    -> changed 4,023 test results (0 to S; 0 to I; 4,023 to R)
+#> -> changed 4,157 test results (0 to S; 0 to I; 4,157 to R)

@@ -489,8 +489,8 @@ #> NOTE: Using column `bacteria` as input for `col_mo`. #> NOTE: Using column `date` as input for `col_date`. #> NOTE: Using column `patient_id` as input for `col_patient_id`. -#> => Found 5,641 first isolates (28.2% of total)

-

So only 28.2% is suitable for resistance analysis! We can now filter on it with the filter() function, also from the dplyr package:

+#> => Found 5,698 first isolates (28.5% of total) +

So only 28.5% is suitable for resistance analysis! We can now filter on it with the filter() function, also from the dplyr package:

data_1st <- data %>% 
   filter(first == TRUE)

For future use, the above two syntaxes can be shortened with the filter_first_isolate() function:

@@ -516,10 +516,10 @@ 1 -2010-01-14 -K8 +2010-01-18 +C7 B_ESCHR_COL -R +S S S S @@ -527,30 +527,30 @@ 2 -2010-02-17 -K8 +2010-02-27 +C7 B_ESCHR_COL -R S -R +S +S S FALSE 3 -2010-03-01 -K8 +2010-04-22 +C7 B_ESCHR_COL S S -R +S S FALSE 4 -2010-03-11 -K8 +2010-06-09 +C7 B_ESCHR_COL S S @@ -560,54 +560,54 @@ 5 -2010-04-13 -K8 +2011-04-13 +C7 B_ESCHR_COL R S -R -R -FALSE +S +S +TRUE 6 -2010-08-30 -K8 +2011-04-25 +C7 B_ESCHR_COL S S -R +S S FALSE 7 -2010-11-05 -K8 +2011-08-02 +C7 B_ESCHR_COL +R S -S -S +R S FALSE 8 -2010-12-21 -K8 +2011-10-19 +C7 B_ESCHR_COL -S -S +R +I S S FALSE 9 -2010-12-21 -K8 +2011-10-23 +C7 B_ESCHR_COL -R +S S S S @@ -615,14 +615,14 @@ 10 -2011-03-20 -K8 +2011-11-10 +C7 B_ESCHR_COL S S R S -TRUE +FALSE @@ -637,7 +637,7 @@ #> NOTE: Using column `patient_id` as input for `col_patient_id`. #> NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this. #> [Criterion] Inclusion based on key antibiotics, ignoring I. -#> => Found 15,738 first weighted isolates (78.7% of total) +#> => Found 15,826 first weighted isolates (79.1% of total) @@ -654,10 +654,10 @@ - - + + - + @@ -666,94 +666,94 @@ - - + + - - + + - + - - + + - + - + - - + + - + - - + + - - - + + + - - + + - + - - + + + - - + - - + + - - + + - + - - + + - + @@ -762,23 +762,23 @@ - - + + - +
isolate
12010-01-14K82010-01-18C7 B_ESCHR_COLRS S S S
22010-02-17K82010-02-27C7 B_ESCHR_COLR SRSS S FALSETRUEFALSE
32010-03-01K82010-04-22C7 B_ESCHR_COL S SRS S FALSETRUEFALSE
42010-03-11K82010-06-09C7 B_ESCHR_COL S S S S FALSETRUEFALSE
52010-04-13K82011-04-13C7 B_ESCHR_COL R SRRFALSESSTRUE TRUE
62010-08-30K82011-04-25C7 B_ESCHR_COL S SRS S FALSE TRUE
72010-11-05K82011-08-02C7 B_ESCHR_COLR SSSR S FALSE TRUE
82010-12-21K82011-10-19C7 B_ESCHR_COLSSRI S S FALSEFALSETRUE
92010-12-21K82011-10-23C7 B_ESCHR_COLRS S S S
102011-03-20K82011-11-10C7 B_ESCHR_COL S S R STRUEFALSE TRUE
-

Instead of 2, now 9 isolates are flagged. In total, 78.7% of all isolates are marked ‘first weighted’ - 50.5% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

+

Instead of 2, now 7 isolates are flagged. In total, 79.1% of all isolates are marked ‘first weighted’ - 50.6% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

As with filter_first_isolate(), there’s a shortcut for this new algorithm too:

data_1st <- data %>% 
   filter_first_weighted_isolate()
-

So we end up with 15,738 isolates for analysis.

+

So we end up with 15,826 isolates for analysis.

We can remove unneeded columns:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -803,14 +803,14 @@ -1 -2017-06-13 -Z3 -Hospital D +2 +2012-07-07 +T4 +Hospital B B_ESCHR_COL R -S -S +R +R S F Gram negative @@ -820,12 +820,12 @@ 3 -2015-06-10 -L8 +2011-02-19 +H3 Hospital B B_ESCHR_COL S -R +S S S M @@ -835,69 +835,69 @@ TRUE -6 -2011-03-09 -B7 -Hospital D -B_ESCHR_COL +4 +2012-12-15 +G10 +Hospital C +B_KLBSL_PNE R S +R +S +M +Gram negative +Klebsiella +pneumoniae +TRUE + + +6 +2011-03-27 +H5 +Hospital A +B_ESCHR_COL S S +S +R M Gram negative Escherichia coli TRUE - -8 -2015-03-15 -O1 + +7 +2012-06-22 +Q8 Hospital A B_STPHY_AUR +S +S +R R -I -S -S F Gram positive Staphylococcus aureus TRUE - -9 -2012-09-07 -K5 -Hospital C + +8 +2015-06-27 +Q2 +Hospital B B_ESCHR_COL R S S S -M +F Gram negative Escherichia coli TRUE - -10 -2015-08-09 -R5 -Hospital D -B_STRPT_PNE -S -S -S -R -F -Gram positive -Streptococcus -pneumoniae -TRUE -

Time for the analysis!

@@ -915,9 +915,9 @@
freq(paste(data_1st$genus, data_1st$species))

Or can be used like the dplyr way, which is easier readable:

data_1st %>% freq(genus, species)
-

Frequency table of genus and species from a data.frame (15,738 x 13)

+

Frequency table of genus and species from a data.frame (15,826 x 13)

Columns: 2
-Length: 15,738 (of which NA: 0 = 0.00%)
+Length: 15,826 (of which NA: 0 = 0.00%)
Unique: 4

Shortest: 16
Longest: 24

@@ -934,33 +934,33 @@ Longest: 24

1 Escherichia coli -7,875 -50.0% -7,875 -50.0% +7,714 +48.7% +7,714 +48.7% 2 Staphylococcus aureus -3,897 -24.8% -11,772 -74.8% +3,977 +25.1% +11,691 +73.9% 3 Streptococcus pneumoniae -2,400 -15.2% -14,172 -90.0% +2,514 +15.9% +14,205 +89.8% 4 Klebsiella pneumoniae -1,566 -10.0% -15,738 +1,621 +10.2% +15,826 100.0% @@ -971,7 +971,7 @@ Longest: 24

Resistance percentages

The functions portion_R(), portion_RI(), portion_I(), portion_IS() and portion_S() can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:

data_1st %>% portion_IR(amox)
-#> [1] 0.4757911
+#> [1] 0.4830027

Or can be used in conjuction with group_by() and summarise(), both from the dplyr package:

data_1st %>% 
   group_by(hospital) %>% 
@@ -984,19 +984,19 @@ Longest: 24

Hospital A -0.4800594 +0.4798820 Hospital B -0.4737983 +0.4792835 Hospital C -0.4763514 +0.4863714 Hospital D -0.4724536 +0.4915730 @@ -1014,23 +1014,23 @@ Longest: 24

Hospital A -0.4800594 -4714 +0.4798820 +4747 Hospital B -0.4737983 -5534 +0.4792835 +5527 Hospital C -0.4763514 -2368 +0.4863714 +2348 Hospital D -0.4724536 -3122 +0.4915730 +3204 @@ -1050,27 +1050,27 @@ Longest: 24

Escherichia -0.7283810 -0.9015873 -0.9751111 +0.7313975 +0.8940887 +0.9752398 Klebsiella -0.7311622 -0.9157088 -0.9750958 +0.7143738 +0.8994448 +0.9697717 Staphylococcus -0.7251732 -0.9230177 -0.9799846 +0.7301986 +0.9104853 +0.9786271 Streptococcus -0.7345833 +0.7430390 0.0000000 -0.7345833 +0.7430390 diff --git a/docs/articles/AMR_files/figure-html/plot 1-1.png b/docs/articles/AMR_files/figure-html/plot 1-1.png index e2bd8a99..e7062639 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 1-1.png and b/docs/articles/AMR_files/figure-html/plot 1-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 3-1.png b/docs/articles/AMR_files/figure-html/plot 3-1.png index dc4fe583..80467329 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 3-1.png and b/docs/articles/AMR_files/figure-html/plot 3-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 4-1.png b/docs/articles/AMR_files/figure-html/plot 4-1.png index 44face47..cf9112de 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 4-1.png and b/docs/articles/AMR_files/figure-html/plot 4-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 5-1.png b/docs/articles/AMR_files/figure-html/plot 5-1.png index 0390712c..7149c905 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 5-1.png and b/docs/articles/AMR_files/figure-html/plot 5-1.png differ diff --git a/docs/articles/EUCAST.html b/docs/articles/EUCAST.html index 296ccfa7..5a814a68 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -192,7 +192,7 @@

How to apply EUCAST rules

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

diff --git a/docs/articles/G_test.html b/docs/articles/G_test.html index 7d2bafa2..e44668d0 100644 --- a/docs/articles/G_test.html +++ b/docs/articles/G_test.html @@ -192,7 +192,7 @@

How to use the G-test

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html index a5dbd596..574b0cd2 100644 --- a/docs/articles/WHONET.html +++ b/docs/articles/WHONET.html @@ -192,7 +192,7 @@

How to work with WHONET data

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

diff --git a/docs/articles/atc_property.html b/docs/articles/atc_property.html index 417e88ea..ab0fa610 100644 --- a/docs/articles/atc_property.html +++ b/docs/articles/atc_property.html @@ -192,7 +192,7 @@

How to get properties of an antibiotic

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 151dfbe7..e65cf80c 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -192,7 +192,7 @@

Benchmarks

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

@@ -217,14 +217,14 @@ times = 10) print(S.aureus, unit = "ms", signif = 3) #> Unit: milliseconds -#> expr min lq mean median uq max neval -#> as.mo("sau") 16.6 16.70 25.10 16.70 18.30 58.00 10 -#> as.mo("stau") 31.8 31.90 36.20 31.90 31.90 74.90 10 -#> as.mo("staaur") 16.7 16.80 30.70 16.90 57.80 72.20 10 -#> as.mo("STAAUR") 16.7 16.70 16.80 16.80 16.80 17.30 10 -#> as.mo("S. aureus") 24.6 24.70 33.60 24.70 25.00 70.40 10 -#> as.mo("S. aureus") 24.6 24.70 29.10 24.70 24.80 67.20 10 -#> as.mo("Staphylococcus aureus") 7.5 7.51 7.67 7.58 7.91 7.97 10
+#> expr min lq mean median uq max neval +#> as.mo("sau") 16.60 16.70 16.90 16.70 16.80 18.20 10 +#> as.mo("stau") 31.80 32.00 44.30 32.10 72.40 73.60 10 +#> as.mo("staaur") 16.70 16.70 16.80 16.70 16.80 17.30 10 +#> as.mo("STAAUR") 16.70 16.80 35.20 18.60 58.00 73.00 10 +#> as.mo("S. aureus") 24.60 24.60 33.50 24.70 24.90 68.70 10 +#> as.mo("S. aureus") 24.50 24.70 25.30 24.90 26.00 26.40 10 +#> as.mo("Staphylococcus aureus") 7.35 7.45 7.53 7.51 7.56 7.97 10

In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.

To achieve this speed, the as.mo function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of Thermus islandicus (B_THERMS_ISL), a bug probably never found before in humans:

T.islandicus <- microbenchmark(as.mo("theisl"),
@@ -236,11 +236,11 @@
 print(T.islandicus, unit = "ms", signif = 3)
 #> Unit: milliseconds
 #>                         expr   min    lq  mean median  uq max neval
-#>              as.mo("theisl") 262.0 264.0 297.0    306 310 376    10
-#>              as.mo("THEISL") 262.0 265.0 292.0    290 308 355    10
-#>       as.mo("T. islandicus") 142.0 142.0 161.0    148 185 186    10
-#>      as.mo("T.  islandicus") 141.0 142.0 184.0    174 188 340    10
-#>  as.mo("Thermus islandicus")  68.4  68.8  96.3    110 115 125    10
+#> as.mo("theisl") 265.0 268.0 294.0 307.0 312 321 10 +#> as.mo("THEISL") 264.0 264.0 312.0 307.0 316 464 10 +#> as.mo("T. islandicus") 142.0 142.0 159.0 143.0 187 216 10 +#> as.mo("T. islandicus") 142.0 143.0 173.0 185.0 187 190 10 +#> as.mo("Thermus islandicus") 68.1 68.4 81.9 68.6 111 115 10

That takes 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 Thermus islandicus) are almost fast - these are the most probable input from most data sets.

In the figure below, we compare Escherichia coli (which is very common) with Prevotella brevis (which is moderately common) and with Thermus islandicus (which is very uncommon):

par(mar = c(5, 16, 4, 2)) # set more space for left margin text (16)
@@ -287,8 +287,8 @@
 print(run_it, unit = "ms", signif = 3)
 #> Unit: milliseconds
 #>            expr min  lq mean median  uq  max neval
-#>  mo_fullname(x) 723 731  797    785 807 1010    10
-

So transforming 500,000 values (!!) of 50 unique values only takes 0.78 seconds (784 ms). You only lose time on your unique input values.

+#> mo_fullname(x) 732 772 823 819 858 1020 10 +

So transforming 500,000 values (!!) of 50 unique values only takes 0.82 seconds (819 ms). You only lose time on your unique input values.

@@ -300,10 +300,10 @@ times = 10) print(run_it, unit = "ms", signif = 3) #> Unit: milliseconds -#> expr min lq mean median uq max neval -#> A 11.20 11.300 12.100 11.800 12.200 15.500 10 -#> B 22.20 22.700 26.900 23.900 24.200 57.600 10 -#> C 0.53 0.552 0.652 0.591 0.781 0.803 10

+#> expr min lq mean median uq max neval +#> A 11.100 11.400 16.700 11.700 14.400 43.200 10 +#> B 22.300 22.400 22.800 22.700 22.900 24.100 10 +#> C 0.324 0.439 0.532 0.577 0.582 0.677 10

So going from mo_fullname("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0006 seconds - it doesn’t even start calculating if the result would be the same as the expected resulting value. That goes for all helper functions:

run_it <- microbenchmark(A = mo_species("aureus"),
                          B = mo_genus("Staphylococcus"),
@@ -317,14 +317,14 @@
 print(run_it, unit = "ms", signif = 3)
 #> Unit: milliseconds
 #>  expr   min    lq  mean median    uq   max neval
-#>     A 0.318 0.329 0.414  0.431 0.464 0.532    10
-#>     B 0.346 0.355 0.414  0.405 0.456 0.528    10
-#>     C 0.347 0.357 0.507  0.489 0.608 0.778    10
-#>     D 0.280 0.306 0.348  0.343 0.378 0.453    10
-#>     E 0.241 0.298 0.333  0.329 0.401 0.408    10
-#>     F 0.253 0.295 0.320  0.308 0.330 0.415    10
-#>     G 0.271 0.279 0.309  0.284 0.363 0.379    10
-#>     H 0.218 0.260 0.328  0.341 0.366 0.426    10
+#> A 0.322 0.338 0.397 0.384 0.415 0.569 10 +#> B 0.316 0.370 0.442 0.442 0.508 0.601 10 +#> C 0.335 0.385 0.502 0.504 0.566 0.724 10 +#> D 0.283 0.324 0.362 0.366 0.389 0.437 10 +#> E 0.252 0.274 0.317 0.323 0.355 0.383 10 +#> F 0.255 0.275 0.325 0.332 0.348 0.411 10 +#> G 0.259 0.272 0.307 0.299 0.318 0.412 10 +#> H 0.271 0.319 0.338 0.334 0.362 0.418 10

Of course, when running mo_phylum("Firmicutes") the function has zero knowledge about the actual microorganism, namely S. aureus. But since the result would be "Firmicutes" 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.

@@ -351,13 +351,13 @@ print(run_it, unit = "ms", signif = 4) #> Unit: milliseconds #> expr min lq mean median uq max neval -#> en 15.12 15.39 19.60 15.47 15.63 57.02 10 -#> de 23.37 23.62 24.02 24.01 24.09 25.10 10 -#> nl 23.44 23.94 24.05 24.02 24.14 25.02 10 -#> es 23.71 24.03 28.36 24.08 24.29 65.92 10 -#> it 23.65 23.94 24.08 24.03 24.07 25.12 10 -#> fr 23.94 23.99 32.58 24.17 25.14 66.00 10 -#> pt 23.30 23.63 28.51 24.06 24.78 68.87 10
+#> en 14.92 15.11 15.44 15.31 15.83 16.30 10 +#> de 27.88 27.89 32.32 28.03 28.37 69.82 10 +#> nl 27.39 28.01 40.70 28.48 69.20 70.26 10 +#> es 27.69 27.93 38.06 28.12 29.21 84.95 10 +#> it 27.73 27.95 28.16 28.00 28.15 29.40 10 +#> fr 27.13 27.65 32.76 28.41 29.50 69.48 10 +#> pt 27.08 27.34 27.89 27.99 28.05 29.40 10

Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.

diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png index 009e4b61..558d400a 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/freq.html b/docs/articles/freq.html index 244c9998..3fe5d762 100644 --- a/docs/articles/freq.html +++ b/docs/articles/freq.html @@ -192,7 +192,7 @@

How to create frequency tables

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

diff --git a/docs/articles/mo_property.html b/docs/articles/mo_property.html index 10b51035..8e0ffa73 100644 --- a/docs/articles/mo_property.html +++ b/docs/articles/mo_property.html @@ -192,7 +192,7 @@

How to get properties of a microorganism

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index e6cd2dd3..17450ab0 100644 --- a/docs/articles/resistance_predict.html +++ b/docs/articles/resistance_predict.html @@ -192,7 +192,7 @@

How to predict antimicrobial resistance

Matthijs S. Berends

-

01 March 2019

+

02 March 2019

diff --git a/docs/news/index.html b/docs/news/index.html index 13dac0f4..feff6917 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -328,12 +328,19 @@ These functions use as.atc()
  • 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(): +
  • Improvements for as.mo():\ + +
    mo_genus("qwerty", language = "es")
    +# Warning: 
    +# one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it.
    +#> [1] "(género desconocido)"