diff --git a/DESCRIPTION b/DESCRIPTION index 32c86901..823db869 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.2.0.9034 -Date: 2020-07-13 +Version: 1.2.0.9035 +Date: 2020-07-22 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 5f4b3cf9..99a83252 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.2.0.9034 -## Last updated: 13-Jul-2020 +# AMR 1.2.0.9035 +## Last updated: 22 July 2020 ### New * Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally @@ -19,8 +19,11 @@ * Added Monuril as trade name for fosfomycin ### Changed +* Big speed improvement for using any function on microorganism codes from earlier package versions (prior to `AMR` v1.2.0), such as `as.mo()`, `mo_name()`, `first_isolate()`, `eucast_rules()`, `mdro()`, etc. + + As a consequence, very old microbial codes (from `AMR` v0.5.0 and lower) **are not supported anymore**. Use `as.mo()` on your microorganism names or codes to transform them to current abbreviations used in this package. * Improvements for `susceptibility()` and `resistance()` and all `count_*()`, `proportion_*()` functions: - * 95% speed improvement (!) by using other base R functions for calculation + * 95% speed improvement by using other base R functions for calculation * Using unexisting columns wil now return an error instead of dropping them silently * Using variables for column names (as well as selectors like `dplyr::all_of()`) now works again * Improvements for `as.ab()`: @@ -33,7 +36,7 @@ * Fixed a bug for using grouped versions of `rsi_df()`, `proportion_df()` and `count_df()`, and fixed a bug where not all different antimicrobial results were added as rows * Improved auto-determination for columns of types `` and `` * Fixed a bug in `bug_drug_combinations()` for when only one antibiotic was in the input data -* Changed the summary for class ``, to highlight the %SI vs. %R +* Changed the summary for class ``, to highlight the %SI vs. %R * Improved error handling, giving more useful info when functions return an error * Any progress bar will now only show in interactive mode (i.e. not in R Markdown) * Speed improvement for `mdro()` and `filter_ab_class()` diff --git a/R/data.R b/R/data.R index a069744b..9070a3db 100755 --- a/R/data.R +++ b/R/data.R @@ -94,6 +94,7 @@ #' - 11 entries of *Streptococcus* (beta-haemolytic: groups A, B, C, D, F, G, H, K and unspecified; other: viridans, milleri) #' - 2 entries of *Staphylococcus* (coagulase-negative (CoNS) and coagulase-positive (CoPS)) #' - 3 entries of *Trichomonas* (*Trichomonas vaginalis*, and its family and genus) +#' - 1 entry of *Candida* (*Candida krusei*), that is not (yet) in the Catalogue of Life #' - 1 entry of *Blastocystis* (*Blastocystis hominis*), although it officially does not exist (Noel *et al.* 2005, PMID 15634993) #' - 5 other 'undefined' entries (unknown, unknown Gram negatives, unknown Gram positives, unknown yeast and unknown fungus) #' - 6 families under the Enterobacterales order, according to Adeolu *et al.* (2016, PMID 27620848), that are not (yet) in the Catalogue of Life @@ -109,13 +110,14 @@ #' * #' @section About the records from DSMZ (see source): #' Names of prokaryotes are defined as being validly published by the International Code of Nomenclature of Bacteria. Validly published are all names which are included in the Approved Lists of Bacterial Names and the names subsequently published in the International Journal of Systematic Bacteriology (IJSB) and, from January 2000, in the International Journal of Systematic and Evolutionary Microbiology (IJSEM) as original articles or in the validation lists. -#' -#' From: +#' *(from )* +#' +#' In February 2020, the DSMZ records were merged with the List of Prokaryotic names with Standing in Nomenclature (LPSN). #' @source Catalogue of Life: Annual Checklist (public online taxonomic database), (check included annual version with [catalogue_of_life_version()]). #' #' Parte, A.C. (2018). LPSN — List of Prokaryotic names with Standing in Nomenclature (bacterio.net), 20 years on. International Journal of Systematic and Evolutionary Microbiology, 68, 1825-1829; doi: 10.1099/ijsem.0.002786 #' -#' Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures, Germany, Prokaryotic Nomenclature Up-to-Date, (check included version with [catalogue_of_life_version()]). +#' Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures, Germany, Prokaryotic Nomenclature Up-to-Date, and (check included version with [catalogue_of_life_version()]). #' @inheritSection AMR Read more on our website! #' @seealso [as.mo()], [mo_property()], [microorganisms.codes] "microorganisms" @@ -231,6 +233,6 @@ catalogue_of_life <- list( #' - `breakpoint_S`\cr Lowest MIC value or highest number of millimetres that leads to "S" #' - `breakpoint_R`\cr Highest MIC value or lowest number of millimetres that leads to "R" #' - `uti`\cr A logical value (`TRUE`/`FALSE`) to indicate whether the rule applies to a urinary tract infection (UTI) -#' @details The repository of this `AMR` package contains a file comprising this exact data set: . This file **allows for machine reading EUCAST and CLSI guidelines**, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file is updated automatically. +#' @details The repository of this `AMR` package contains a file comprising this exact data set: . This file **allows for machine reading EUCAST and CLSI guidelines**, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically. #' @inheritSection AMR Read more on our website! "rsi_translation" diff --git a/R/first_isolate.R b/R/first_isolate.R index 943217a8..d8558532 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -174,10 +174,6 @@ first_isolate <- function(x, col_date <- search_type_in_df(x = x, type = "date") stop_if(is.null(col_date), "`col_date` must be set") } - # convert to Date - dates <- as.Date(x[, col_date, drop = TRUE]) - dates[is.na(dates)] <- as.Date("1970-01-01") - x[, col_date] <- dates # -- patient id if (is.null(col_patient_id)) { @@ -223,12 +219,17 @@ first_isolate <- function(x, check_columns_existance(col_icu) check_columns_existance(col_keyantibiotics) + # convert dates to Date + dates <- as.Date(x[, col_date, drop = TRUE]) + dates[is.na(dates)] <- as.Date("1970-01-01") + x[, col_date] <- dates + # create original row index x$newvar_row_index <- seq_len(nrow(x)) - x$newvar_mo <- x %>% pull(col_mo) %>% as.mo() + x$newvar_mo <- x[, col_mo, drop = TRUE] x$newvar_genus_species <- paste(mo_genus(x$newvar_mo), mo_species(x$newvar_mo)) - x$newvar_date <- x %>% pull(col_date) - x$newvar_patient_id <- x %>% pull(col_patient_id) + x$newvar_date <- x[, col_date, drop = TRUE] + x$newvar_patient_id <- x[, col_patient_id, drop = TRUE] if (is.null(col_testcode)) { testcodes_exclude <- NULL @@ -317,10 +318,10 @@ first_isolate <- function(x, } # Analysis of first isolate ---- - x$other_pat_or_mo <- if_else(x$newvar_patient_id == lag(x$newvar_patient_id) & - x$newvar_genus_species == lag(x$newvar_genus_species), - FALSE, - TRUE) + x$other_pat_or_mo <- ifelse(x$newvar_patient_id == lag(x$newvar_patient_id) & + x$newvar_genus_species == lag(x$newvar_genus_species), + FALSE, + TRUE) x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species) x$more_than_episode_ago <- unlist(lapply(unique(x$episode_group), function(g, diff --git a/R/globals.R b/R/globals.R index 2e2c7751..a86baa5c 100755 --- a/R/globals.R +++ b/R/globals.R @@ -19,100 +19,47 @@ # Visit our website for more info: https://msberends.github.io/AMR. # # ==================================================================== # -globalVariables(c(".", - "..property", - "ab", +globalVariables(c("ab", "ab_txt", - "abbreviations", "angle", - "antibiotic", "antibiotics", "atc_group1", "atc_group2", - "CNS_CPS", "code", - "col_id", - "count", - "count.x", "data", - "date_lab", - "diff.percent", - "First name", - "first_isolate_row_index", "fullname", "fullname_lower", "g_species", "genus", "gr", - "gramstain", "group", "hjust", - "index", "input", - "interpretation", "isolates", - "item", - "key_ab", - "key_ab_lag", - "key_ab_other", - "kingdom", - "kingdom_index", "lang", - "Last name", "lookup", - "mdr", - "MDRO", - "median", "microorganisms", "microorganisms.codes", "microorganisms.old", - "missing_names", "mo", - "mo_new", - "mo_old", - "mono_count", - "more_than_episode_ago", "name", "new", - "newvar_date", - "newvar_genus_species", - "newvar_mo", - "newvar_patient_id", - "newvar_row_index", - "newvar_row_index_sorted", "observations", - "observed", "old", "old_name", - "other_pat_or_mo", - "package_version", - "patient_id", "pattern", - "plural", - "prevalence", "R", - "real_first_isolate", - "ref", "rsi_translation", "rule_group", "rule_name", - "S", "se_max", "se_min", - "second", - "Sex", "species", "species_id", - "subspecies", - "synonyms", "total", "txt", - "uncertainty_level", "value", "varname", - "x", - "xdr", "xvar", - "y", "year", "yvar")) diff --git a/R/guess_ab_col.R b/R/guess_ab_col.R index 06d1b46f..d42b46d1 100755 --- a/R/guess_ab_col.R +++ b/R/guess_ab_col.R @@ -40,7 +40,7 @@ #' # [1] "tetr" #' #' guess_ab_col(df, "J01AA07", verbose = TRUE) -#' # Note: Using column `tetr` as input for "J01AA07". +#' # NOTE: Using column `tetr` as input for `J01AA07` (tetracycline). #' # [1] "tetr" #' #' # WHONET codes diff --git a/R/mdro.R b/R/mdro.R index 9414bd4a..6ee9162f 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -968,12 +968,12 @@ mdro <- function(x, } x$mono_count <- 0 - x[drug_is_R(INH), "mono_count"] <- x[drug_is_R(INH), "mono_count"] + 1 - x[drug_is_R(RIF), "mono_count"] <- x[drug_is_R(RIF), "mono_count"] + 1 - x[drug_is_R(ETH), "mono_count"] <- x[drug_is_R(ETH), "mono_count"] + 1 - x[drug_is_R(PZA), "mono_count"] <- x[drug_is_R(PZA), "mono_count"] + 1 - x[drug_is_R(RIB), "mono_count"] <- x[drug_is_R(RIB), "mono_count"] + 1 - x[drug_is_R(RFP), "mono_count"] <- x[drug_is_R(RFP), "mono_count"] + 1 + x[drug_is_R(INH), "mono_count"] <- x[drug_is_R(INH), "mono_count", drop = TRUE] + 1 + x[drug_is_R(RIF), "mono_count"] <- x[drug_is_R(RIF), "mono_count", drop = TRUE] + 1 + x[drug_is_R(ETH), "mono_count"] <- x[drug_is_R(ETH), "mono_count", drop = TRUE] + 1 + x[drug_is_R(PZA), "mono_count"] <- x[drug_is_R(PZA), "mono_count", drop = TRUE] + 1 + x[drug_is_R(RIB), "mono_count"] <- x[drug_is_R(RIB), "mono_count", drop = TRUE] + 1 + x[drug_is_R(RFP), "mono_count"] <- x[drug_is_R(RFP), "mono_count", drop = TRUE] + 1 x$mono <- x$mono_count > 0 x$poly <- x$mono_count > 1 & drug_is_not_R(RIF) & drug_is_not_R(INH) diff --git a/R/mo.R b/R/mo.R index 2f644a31..33678255 100755 --- a/R/mo.R +++ b/R/mo.R @@ -55,7 +55,7 @@ #' C (Chromista), F (Fungi), P (Protozoa) #' ``` #' -#' Values that cannot be coered will be considered 'unknown' and will get the MO code `UNKNOWN`. +#' Values that cannot be coerced will be considered 'unknown' and will get the MO code `UNKNOWN`. #' #' Use the [`mo_*`][mo_property()] functions to get properties based on the returned code, see Examples. #' @@ -77,27 +77,27 @@ #' - Uncertainty level 2: allow all of level 1, strip values between brackets, inverse the words of the input, strip off text elements from the end keeping at least two elements; #' - Uncertainty level 3: allow all of level 1 and 2, strip off text elements from the end, allow any part of a taxonomic name. #' -#' This leads to e.g.: +#' The level of uncertainty can be set using the argument `allow_uncertain`. The default is `allow_uncertain = TRUE`, which is equal to uncertainty level 2. Using `allow_uncertain = FALSE` is equal to uncertainty level 0 and will skip all rules. You can also use e.g. `as.mo(..., allow_uncertain = 1)` to only allow up to level 1 uncertainty. +#' +#' With the default setting (`allow_uncertain = TRUE`, level 2), below examples will lead to valid results: #' - `"Streptococcus group B (known as S. agalactiae)"`. The text between brackets will be removed and a warning will be thrown that the result *Streptococcus group B* (``r as.mo("Streptococcus group B")``) needs review. #' - `"S. aureus - please mind: MRSA"`. The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result *Staphylococcus aureus* (``r as.mo("Staphylococcus aureus")``) needs review. #' - `"Fluoroquinolone-resistant Neisseria gonorrhoeae"`. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result *Neisseria gonorrhoeae* (``r as.mo("Neisseria gonorrhoeae")``) needs review. -#' -#' The level of uncertainty can be set using the argument `allow_uncertain`. The default is `allow_uncertain = TRUE`, which is equal to uncertainty level 2. Using `allow_uncertain = FALSE` is equal to uncertainty level 0 and will skip all rules. You can also use e.g. `as.mo(..., allow_uncertain = 1)` to only allow up to level 1 uncertainty. #' -#' There are three helper functions that can be run after then [as.mo()] function: -#' - Use [mo_uncertainties()] to get a [`data.frame`] with all values that were coerced to a valid value, but with uncertainty. The output contains a score, that is calculated as \eqn{(n - 0.5 * L) / n}, where *n* is the number of characters of the returned full name of the microorganism, and *L* is the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between that full name and the user input. -#' - Use [mo_failures()] to get a [`vector`] with all values that could not be coerced to a valid value. -#' - Use [mo_renamed()] to get a [`data.frame`] with all values that could be coerced based on an old, previously accepted taxonomic name. +#' There are three helper functions that can be run after using the [as.mo()] function: +#' - Use [mo_uncertainties()] to get a [`data.frame`] with all values that were coerced to a valid value, but with uncertainty. The output contains a score, that is calculated as \eqn{(n - 0.5 * L) / n}, where *n* is the number of characters of the full taxonomic name of the microorganism, and *L* is the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between that full name and the user input. +#' - Use [mo_failures()] to get a [`character`] [`vector`] with all values that could not be coerced to a valid value. +#' - Use [mo_renamed()] to get a [`data.frame`] with all values that could be coerced based on old, previously accepted taxonomic names. #' #' ## Microbial prevalence of pathogens in humans #' #' The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the `prevalence` columns in the [microorganisms] and [microorganisms.old] data sets. The grouping into prevalence groups is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. #' -#' Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is *Enterococcus*, *Staphylococcus* or *Streptococcus*. This group consequently contains all common Gram-negative bacteria, such as *Pseudomonas* and *Legionella* and all species within the order Enterobacteriales. +#' Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is *Enterococcus*, *Staphylococcus* or *Streptococcus*. This group consequently contains all common Gram-negative bacteria, such as *Klebsiella*, *Pseudomonas* and *Legionella*. #' -#' Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is *Aspergillus*, *Bacteroides*, *Candida*, *Capnocytophaga*, *Chryseobacterium*, *Cryptococcus*, *Elisabethkingia*, *Flavobacterium*, *Fusobacterium*, *Giardia*, *Leptotrichia*, *Mycoplasma*, *Prevotella*, *Rhodotorula*, *Treponema*, *Trichophyton* or *Ureaplasma*. +#' Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is *Aspergillus*, *Bacteroides*, *Candida*, *Capnocytophaga*, *Chryseobacterium*, *Cryptococcus*, *Elisabethkingia*, *Flavobacterium*, *Fusobacterium*, *Giardia*, *Leptotrichia*, *Mycoplasma*, *Prevotella*, *Rhodotorula*, *Treponema*, *Trichophyton* or *Ureaplasma*. This group consequently contains all less common and rare human pathogens. #' -#' Group 3 (least prevalent microorganisms) consists of all other microorganisms. +#' Group 3 (least prevalent microorganisms) consists of all other microorganisms. This group contains microorganisms most probably not found in humans. #' @inheritSection catalogue_of_life Catalogue of Life # (source as a section here, so it can be inherited by other man pages:) #' @section Source: @@ -106,7 +106,7 @@ #' 3. Lancefield RC **A serological differentiation of human and other groups of hemolytic streptococci**. 1933. J Exp Med. 57(4): 571–95. #' 4. Catalogue of Life: Annual Checklist (public online taxonomic database), (check included annual version with [catalogue_of_life_version()]). #' @export -#' @return A [`character`] vector with class [`mo`] +#' @return A [`character`] [`vector`] with additional class [`mo`] #' @seealso [microorganisms] for the [`data.frame`] that is being used to determine ID's. #' #' The [mo_property()] functions (like [mo_genus()], [mo_gramstain()]) to get properties based on the returned code. @@ -177,7 +177,9 @@ as.mo <- function(x, # start off with replaced language-specific non-ASCII characters with ASCII characters x <- parse_and_convert(x) - + # replace mo codes used in older package versions + x <- replace_old_mo_codes(x) + # WHONET: xxx = no growth x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ # Laboratory systems: remove entries like "no growth" etc @@ -288,6 +290,8 @@ exec_as.mo <- function(x, # start off with replaced language-specific non-ASCII characters with ASCII characters x <- parse_and_convert(x) + # replace mo codes used in older package versions + x <- replace_old_mo_codes(x) # WHONET: xxx = no growth x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ @@ -324,30 +328,6 @@ exec_as.mo <- function(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_case% "^[BFP]_[A-Z]{3,7}") & !all(x %in% microorganisms$mo)) { - leftpart <- gsub("^([BFP]_[A-Z]{3,7}).*", "\\1", x) - if (any(leftpart %in% names(mo_codes_v0.5.0))) { - old_mo_warning <- TRUE - rightpart <- gsub("^[BFP]_[A-Z]{3,7}(.*)", "\\1", x) - leftpart <- mo_codes_v0.5.0[leftpart] - x[!is.na(leftpart)] <- paste0(leftpart[!is.na(leftpart)], rightpart[!is.na(leftpart)]) - } - # now check if some are still old - still_old <- x[x %in% names(mo_codes_v0.5.0)] - if (length(still_old) > 0) { - old_mo_warning <- TRUE - x[x %in% names(mo_codes_v0.5.0)] <- data.frame(old = still_old, stringsAsFactors = FALSE) %>% - left_join(data.frame(old = names(mo_codes_v0.5.0), - new = mo_codes_v0.5.0, - stringsAsFactors = FALSE), by = "old") %>% - # if they couldn't be found, replace them with the old ones again, - # so they will throw a warning in the end - mutate(new = ifelse(is.na(new), old, new)) %>% - pull(new) - } - } - # defined df to check for if (!is.null(reference_df)) { mo_source_isvalid(reference_df) @@ -412,15 +392,6 @@ exec_as.mo <- function(x, # on = "mo", # ..property][[1]] - } else if (all(x %in% microorganisms.translation$mo_old)) { - # is an old mo code, used in previous versions of this package - old_mo_warning <- TRUE - x <- data.frame(mo_old = toupper(x), stringsAsFactors = FALSE) %>% - left_join(microorganisms.translation, by = "mo_old") %>% - rename(mo = mo_new) %>% - left_join_MO_lookup(by = "mo") %>% - pull(property) - } else if (!all(x %in% microorganisms[, property])) { strip_whitespace <- function(x, dyslexia_mode) { @@ -592,18 +563,6 @@ exec_as.mo <- function(x, next } - # old mo code, used in previous versions of this package ---- - if (x_backup[i] %in% microorganisms.translation$mo_old) { - old_mo_warning <- TRUE - found <- lookup(mo_old == toupper(x_backup[i]), column = "mo_new", haystack = microorganisms.translation) - found <- lookup(mo == found) - if (!is.na(found)) { - # get property - x[i] <- found[1L] - next - } - } - if (x_backup[i] %like_case% "\\(unknown [a-z]+\\)" | tolower(x_backup_without_spp[i]) %in% c("other", "none", "unknown")) { # empty and nonsense values, ignore without warning x[i] <- lookup(mo == "UNKNOWN") @@ -1584,12 +1543,14 @@ summary.mo <- function(object, ...) { x <- as.mo(object) # force again, could be mo from older pkg version top <- as.data.frame(table(x), responseName = "n", stringsAsFactors = FALSE) top_3 <- top[order(-top$n), 1][1:3] - c("Class" = "mo", + value <- c("Class" = "mo", "" = length(x[is.na(x)]), "Unique" = n_distinct(x[!is.na(x)]), "#1" = top_3[1], "#2" = top_3[2], "#3" = top_3[3]) + class(value) <- c("summaryDefault", "table") + value } #' @method as.data.frame mo @@ -1821,6 +1782,18 @@ parse_and_convert <- function(x) { parsed } +replace_old_mo_codes <- function(x) { + if (any(toupper(x) %in% microorganisms.translation$mo_old, na.rm = TRUE)) { + # get the ones that match + matched <- match(toupper(x), microorganisms.translation$mo_old) + # and their new codes + mo_new <- microorganisms.translation$mo_new[matched] + # assign on places where a match was found + x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))] + } + x +} + left_join_MO_lookup <- function(x, ...) { left_join(x = x, y = MO_lookup, ...) } diff --git a/R/mo_property.R b/R/mo_property.R index ef2211af..5836cf4f 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -437,8 +437,6 @@ mo_validate <- function(x, property, ...) { if (property == "mo") { return(to_class_mo(x)) - } else if (property == "col_id") { - return(as.integer(x)) } else if (property == "snomed") { return(as.double(eval(parse(text = x)))) } else { diff --git a/R/rsi.R b/R/rsi.R index c39d95cb..fa8d8a86 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -550,13 +550,15 @@ summary.rsi <- function(object, ...) { S <- sum(x == "S", na.rm = TRUE) I <- sum(x == "I", na.rm = TRUE) R <- sum(x == "R", na.rm = TRUE) - c( + value <- c( "Class" = "rsi", "%R" = paste0(percentage(R / n), " (n=", R, ")"), "%SI" = paste0(percentage((S + I) / n), " (n=", S + I, ")"), "- %S" = paste0(percentage(S / n), " (n=", S, ")"), "- %I" = paste0(percentage(I / n), " (n=", I, ")") ) + class(value) <- c("summaryDefault", "table") + value } #' @method plot rsi diff --git a/R/sysdata.rda b/R/sysdata.rda index b5248225..55f0a9e1 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/zzz.R b/R/zzz.R index 528e7f3a..1bfbe11b 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -27,10 +27,6 @@ assign(x = "MO.old_lookup", value = create_MO.old_lookup(), envir = asNamespace("AMR")) - - assign(x = "mo_codes_v0.5.0", - value = make_trans_tbl(), - envir = asNamespace("AMR")) } # maybe add survey later: "https://www.surveymonkey.com/r/AMR_for_R" @@ -44,8 +40,7 @@ create_MO_lookup <- function() { MO_lookup[which(MO_lookup$kingdom == "Protozoa"), "kingdom_index"] <- 3 MO_lookup[which(MO_lookup$kingdom == "Archaea"), "kingdom_index"] <- 4 - # use this paste instead of `fullname` to - # work with Viridans Group Streptococci, etc. + # use this paste instead of `fullname` to work with Viridans Group Streptococci, etc. MO_lookup$fullname_lower <- tolower(trimws(paste(MO_lookup$genus, MO_lookup$species, MO_lookup$subspecies))) @@ -62,9 +57,6 @@ create_MO_lookup <- function() { create_MO.old_lookup <- function() { MO.old_lookup <- AMR::microorganisms.old - - # use this paste instead of `fullname` to - # work with Viridans Group Streptococci, etc. MO.old_lookup$fullname_lower <- gsub("[^.a-z0-9/ \\-]+", "", tolower(trimws(MO.old_lookup$fullname))) # add a column with only "e coli" like combinations @@ -73,202 +65,3 @@ create_MO.old_lookup <- function() { # so arrange data on prevalence first, then full name MO.old_lookup[order(MO.old_lookup$prevalence, MO.old_lookup$fullname_lower), ] } - -make_trans_tbl <- function() { - # conversion of old MO codes from v0.5.0 (ITIS) to later versions (Catalogue of Life) - c(B_ACHRMB = "B_ACHRM", B_ANNMA = "B_ACTNS", B_ACLLS = "B_ALCYC", - B_AHNGM = "B_ARCHN", B_ARMTM = "B_ARMTMN", B_ARTHR = "B_ARTHRB", B_ARTHRS = "B_ARTHR", - B_APHLS = "B_AZRHZP", B_BRCHA = "B_BRCHY", B_BCTRM = "B_BRVBCT", - B_CLRBCT = "B_CLRBC", B_CTRDM = "B_CLSTR", B_CPRMM = "B_CYLND", - B_DLCLN = "B_DPLCL", B_DMCLM = "B_DSLFT", B_DSLFVB = "B_DSLFV", - B_FCTRM = "B_FSBCT", B_GNRLA = "B_GRDNR", B_HNRBM = "B_HLNRB", - B_HPHGA = "B_HNPHGA", B_HCCCS = "B_HYDRC", B_MCRCLS = "B_MCRCL", - B_MTHYLS = "B_MLSMA", B_MARCLS = "B_MRCLS", B_MGCLS = "B_MSTGC", - B_MCLLA = "B_MTHYLC", B_MYCPLS = "B_MYCPL", B_NBCTR = "B_NTRBC", - B_OCLLS = "B_OCNBC", B_PTHRX = "B_PLNKT", B_PCCCS = "B_PRCHL", - B_PSPHN = "B_PRPHY", B_PDMNS = "B_PSDMN", B_SCCHRP = "B_SCCHR", - B_SRBCTR = "B_SHRBCTR", B_STRPTC = "B_STRPT", B_SHMNS = "B_SYNTR", - B_TRBCTR = "B_THRMN", P_ALBMN = "C_ABMNA", F_ACHLY = "C_ACHLY", - P_ACINT = "C_ACINT", P_ARTCL = "C_ACLNA", P_ACRVL = "C_ACRVL", - P_ADRCT = "C_ADRCT", P_AMPHS = "C_AHSRS", F_ALBUG = "C_ALBUG", - P_ALCNT = "C_ALCNT", P_ALFRD = "C_ALFRD", P_ALLGR = "C_ALLGR", - P_AMPHL = "C_ALPTS", F_ALTHR = "C_ALTHR", P_AMLLA = "C_AMLLA", - P_ANMLN = "C_AMLNA", P_AMMBC = "C_AMMBC", P_AMMDS = "C_AMMDS", - P_AMMLG = "C_AMMLG", P_AMMMR = "C_AMMMR", P_AMMMS = "C_AMMMS", - P_AMMON = "C_AMMON", P_AMMSC = "C_AMMSC", P_AMMSP = "C_AMMSP", - P_AMMST = "C_AMMST", P_AMMTM = "C_AMMTM", F_AMYCS = "C_AMYCS", - P_ANARM = "C_ANARM", P_ANGLD = "C_ANGLD", P_ANGLG = "C_ANGLG", - P_ANNLC = "C_ANNLC", F_ANSLP = "C_ANSLP", F_APDCH = "C_APDCH", - F_APHND = "C_APHND", F_APLNC = "C_APLNC", F_AQLND = "C_AQLND", - P_ARCHS = "C_ARCHAS", P_ASTRN = "C_ARNNN", P_ARNPR = "C_ARNPR", - F_ARSPR = "C_ARSPR", P_ARTST = "C_ARTSTR", P_AMPHC = "C_ARYNA", - P_ASCHM = "C_ASCHM", P_ASPDS = "C_ASPDS", P_ASTCL = "C_ASTCL", - P_ASTRG = "C_ASTRGR", P_ASTRM = "C_ASTRMM", P_ASTRR = "C_ASTRR", - P_ASTRT = "C_ASTRTR", F_ATKNS = "C_ATKNS", F_AYLLA = "C_AYLLA", - P_BAGGN = "C_BAGGN", P_BCCLL = "C_BCCLL", P_BDLLD = "C_BDLLD", - P_BGNRN = "C_BGNRN", P_BLCLN = "C_BLCLN", P_BLMND = "C_BLMND", - P_BLMNL = "C_BLMNL", P_BLPHR = "C_BLPHR", P_BLVNT = "C_BLVNT", - P_BOLVN = "C_BOLVN", P_BORLS = "C_BORLS", P_BRNNM = "C_BRNNM", - P_BRSLN = "C_BRSLN", P_BRSRD = "C_BRSRD", F_BRVLG = "C_BRVLG", - F_BNLLA = "C_BRVLGN", P_BSCCM = "C_BSCCM", F_BSDPH = "C_BSDPH", - P_BTHYS = "C_BTHYS", P_BTLLN = "C_BTLLN", P_BULMN = "C_BULMN", - P_CCLDM = "C_CCLDM", P_CDNLL = "C_CDNLL", P_CLPSS = "C_CDNLLP", - P_CHLDN = "C_CHLDNL", P_CHLST = "C_CHLST", P_CHNLM = "C_CHNLM", - P_CHRYS = "C_CHRYSL", P_CHTSP = "C_CHTSP", P_CBCDS = "C_CIBCDS", - P_CLCRN = "C_CLCRN", P_CLMNA = "C_CLMNA", P_CLPDM = "C_CLPDM", - P_CLPHR = "C_CLPHRY", P_CLVLN = "C_CLVLN", P_CMPNL = "C_CMPNL", - P_CNCRS = "C_CNCRS", P_CNTCH = "C_CNTCH", F_CNTRM = "C_CNTRMY", - P_COLPD = "C_COLPD", P_COLPS = "C_COLPS", P_CPRDS = "C_CPRDS", - P_CRNSP = "C_CPRMA", P_CRBNL = "C_CRBNL", P_CRBRB = "C_CRBRB", - P_CRBRG = "C_CRBRG", P_CRBRS = "C_CRBRS", P_CRCHS = "C_CRCHS", - P_CRCLC = "C_CRCLC", P_CRNLC = "C_CRNLC", P_CRNTH = "C_CRNTH", - P_CRPNT = "C_CRPNT", P_CRSTG = "C_CRSTG", P_CRTHN = "C_CRTHN", - P_CRTRN = "C_CRTRN", P_CYMBL = "C_CRTTA", P_CRYPT = "C_CRYPT", - P_CSHMN = "C_CSHMNL", P_CSSDL = "C_CSSDL", P_CLNDS = "C_CSSDLN", - P_CHRNA = "C_CTHRN", P_CTPSS = "C_CTPSS", P_CUNLN = "C_CUNLN", - P_CYLND = "C_CVLNA", P_CYCLC = "C_CYCLCB", P_CDNTA = "C_CYCLD", - P_CYCLG = "C_CYCLG", P_CYCLM = "C_CYCLM", P_CYRTL = "C_CYRTL", - P_CYSTM = "C_CYSTM", P_DCHLM = "C_DCHLM", P_DCRBS = "C_DCRBS", - P_DCTYC = "C_DCTYC", P_DIDNM = "C_DIDNM", P_DLPTS = "C_DLPTS", - P_DNTLN = "C_DNTLN", P_DNTST = "C_DNTST", P_DORTH = "C_DORTH", - P_DCTYP = "C_DPHMS", F_DPLCY = "C_DPLCY", P_DNDRT = "C_DRTNA", - P_DSCMM = "C_DSCMM", P_DSCRB = "C_DSCRB", P_DSCRN = "C_DSCRN", - P_DSCSP = "C_DSCSP", P_DSNBR = "C_DSNBR", P_DYCBC = "C_DYCBC", - F_DCTYC = "C_DYCHS", F_ECTRG = "C_ECTRG", B_EDWRD = "C_EDWRD", - P_EGGRL = "C_EGGRL", P_EHLYS = "C_EHLYS", P_EHRNB = "C_EHRNB", - P_ELPHD = "C_ELPHD", P_ENCHL = "C_ELYDM", P_EPHDM = "C_EPHDM", - P_EPLTS = "C_EPLTS", P_EPLXL = "C_EPLXL", P_EPNDL = "C_EPNDL", - P_EPNDS = "C_EPNDS", P_ENLLA = "C_EPSTM", P_EPSTY = "C_EPSTY", - F_ERYCH = "C_ERYCH", F_ESMDM = "C_ESMDM", P_ESSYR = "C_ESSYR", - P_FSCHR = "C_FHRNA", P_FLRLS = "C_FLRLS", P_FLNTN = "C_FNTNA", - P_FRNDC = "C_FRNDC", P_FRNTN = "C_FRNTN", P_FRSNK = "C_FRSNK", - P_FNLLA = "C_FSCHRN", P_FSSRN = "C_FSSRN", P_FVCSS = "C_FVCSS", - P_GDRYN = "C_GDRYN", F_GELGN = "C_GELGN", P_GERDA = "C_GERDA", - P_GLACM = "C_GLACM", P_GLBBL = "C_GLBBL", P_GLBGR = "C_GLBGR", - P_GLBLN = "C_GLBLN", P_GRTLA = "C_GLBRT", P_GLBTX = "C_GLBTX", - P_GLLNA = "C_GLLNA", P_GLMSP = "C_GLMSP", P_GLNDL = "C_GLNDL", - F_GNMCH = "C_GNMCH", P_GOSLL = "C_GOSLL", P_GRNDS = "C_GRNDS", - P_GRNTA = "C_GRNTA", P_GLBRT = "C_GTLLA", P_GTTLN = "C_GTTLN", - P_GVLNP = "C_GVLNP", P_GYPSN = "C_GYPSN", P_GYRDN = "C_GYRDN", - P_HALTR = "C_HALTR", P_HANZW = "C_HANZW", P_HAURN = "C_HAURN", - P_HELNN = "C_HELNN", P_HLPHR = "C_HHRYA", P_HLNTA = "C_HLNTA", - F_HLPHT = "C_HLPHT", P_HLSTC = "C_HLSTC", P_HMSPH = "C_HMSPH", - P_HMTRM = "C_HMTRM", P_HPKNS = "C_HPKNS", P_HPLPH = "C_HPLPH", - P_HPPCR = "C_HPPCR", P_HNLLA = "C_HPPCRP", P_HRMSN = "C_HRMSN", - P_HRNLL = "C_HRNLL", F_HRPCH = "C_HRPCH", P_HSTGR = "C_HSTGR", - P_HSTTL = "C_HSTTL", P_HTRST = "C_HTGNA", P_HTRLL = "C_HTRLL", - P_HTRPH = "C_HTRPH", F_HYPHC = "C_HYPHC", P_HYPRM = "C_HYPRM", - P_INTRN = "C_INTRN", P_IRIDI = "C_IRIDI", P_ISLND = "C_ISLND", - P_JCLLL = "C_JCLLL", P_KHLLL = "C_KHLLL", P_KRNPS = "C_KRNPS", - P_KRRRL = "C_KRRRL", P_LABOE = "C_LABOE", P_LAGEN = "C_LAGEN", - P_LBSLL = "C_LBSLL", F_LTHLA = "C_LBYRN", P_LCRYM = "C_LCRYM", - P_LEMBS = "C_LEMBS", F_LGNDM = "C_LGNDM", P_LGNMM = "C_LGNMM", - P_LGNPH = "C_LGNPHR", F_LGNSM = "C_LGNSM", P_LGYNP = "C_LGYNP", - P_LITTB = "C_LITTB", P_LITUL = "C_LITUL", P_LMBDN = "C_LMBDN", - P_LMRCK = "C_LMRCK", F_LBYRN = "C_LMYXA", P_LNGLN = "C_LNGLN", - P_LNTCL = "C_LNTCL", P_LOXDS = "C_LOXDS", F_LPTLG = "C_LPTLG", - F_LNLLA = "C_LPTLGN", F_LPTMT = "C_LPTMT", P_LRYNG = "C_LRYNG", - P_LTCRN = "C_LTCRN", P_LTHPL = "C_LTHPL", P_LTNTS = "C_LTNTS", - F_LTRST = "C_LTRST", P_LXPHY = "C_LXPHY", P_MCRTH = "C_MCRTH", - P_MELNS = "C_MELNS", P_MSDNM = "C_MESDNM", P_METPS = "C_METPS", - P_MIMSN = "C_MIMSN", P_MINCN = "C_MINCN", P_MLLNL = "C_MLLNL", - P_MLMMN = "C_MLMMN", F_MNDNL = "C_MNDNL", P_MNLYS = "C_MNLYS", - P_MNPSS = "C_MNPSS", P_MRGNL = "C_MRGNL", P_MRGNP = "C_MRGNP", - P_MRSPL = "C_MRSPL", P_MRTNT = "C_MRTNT", P_MSSLN = "C_MSSLN", - P_MSSSS = "C_MSSSS", P_MTCNT = "C_MTCNT", P_MYCHS = "C_MYCHS", - P_MYSCH = "C_MYSCH", F_MYZCY = "C_MYZCY", P_NASSL = "C_NASSL", - P_NBCLN = "C_NBCLN", P_NBCLR = "C_NBCLR", P_NCNRB = "C_NCNRB", - P_NDBCL = "C_NDBCL", P_NRLLA = "C_NDBCLR", P_NMMLC = "C_NMMLC", - F_NMTPH = "C_NMTPH", P_NNNLL = "C_NNNLL", P_NODSR = "C_NODSR", - P_NONIN = "C_NONIN", P_NOURI = "C_NOURI", P_OCLNA = "C_OCLNA", - P_OGLNA = "C_OGLNA", P_OPHTH = "C_OLMDM", F_OLPDP = "C_OLPDP", - P_ONYCH = "C_OMPSS", P_OOLIN = "C_OOLIN", P_OPRCL = "C_OPRCL", - P_ORBLN = "C_ORBLN", F_ORCAD = "C_ORCAD", P_ORDRS = "C_ORDRS", - P_OPHRY = "C_ORYDM", P_OSNGL = "C_OSNGL", P_OXYTR = "C_OXYTR", - P_PARRN = "C_PARRN", P_PATRS = "C_PATRS", P_PAVNN = "C_PAVNN", - P_PTYCH = "C_PCYLS", P_PDPHR = "C_PDPHR", P_PELSN = "C_PELSN", - F_PHGMY = "C_PHGMY", F_PSDSP = "C_PHRTA", P_PHRYG = "C_PHRYG", - P_PHYSL = "C_PHYSL", F_PHYTP = "C_PHYTP", P_PLACS = "C_PLACS", - P_PLCPS = "C_PLCPS", P_PLCPSL = "C_PLCPSL", P_PLCTN = "C_PLCTN", - P_PLGPH = "C_PLGPH", B_PLGTH = "C_PLGTH", P_PLMRN = "C_PLMRN", - P_PLNCT = "C_PLNCT", P_PLNDSC = "C_PLNDSC", P_PLNGY = "C_PLNGY", - P_PLNRBL = "C_PLNLLA", P_PLNLN = "C_PLNLN", P_PLNLR = "C_PLNLR", - P_PLNRB = "C_PLNRB", P_PLNSP = "C_PLNSPR", P_PLRNM = "C_PLRNM", - P_PLRST = "C_PLRST", P_PLRTR = "C_PLRTR", F_PLSMD = "C_PLSMD", - P_PLTYC = "C_PLTYC", P_PSDBL = "C_PLVNA", P_PLYMR = "C_PLYMR", - P_PLTYN = "C_PNMTM", P_PNRPL = "C_PNRPL", F_PNTSM = "C_PNTSM", - P_PRCNT = "C_PRCNT", P_PRFSS = "C_PRFSS", P_PRMCM = "C_PRMCUM", - F_PRNSP = "C_PRNSP", P_PRPND = "C_PRPND", P_PRPYX = "C_PRPYX", - P_PRRDN = "C_PRRDN", P_PSDDF = "C_PSDDF", P_PSDMC = "C_PSDMC", - P_PSDND = "C_PSDND", P_PSDNN = "C_PSDNN", P_PSDPL = "C_PSDPLY", - P_PSMMS = "C_PSMMS", P_PTLLN = "C_PTLLN", P_PTLLND = "C_PTLLND", - F_PTRSN = "C_PTRSN", P_PULLN = "C_PULLN", P_PUTLN = "C_PUTLN", - P_PRTTR = "C_PYMNA", P_PYRGL = "C_PYRGL", P_PYRGO = "C_PYRGO", - P_PYRLN = "C_PYRLN", F_PYTHM = "C_PYTHIM", F_PYTHL = "C_PYTHL", - P_PYXCL = "C_PYXCL", P_QNQLC = "C_QNQLC", P_RAMLN = "C_RAMLN", - P_RBRTN = "C_RBRTN", P_RCRVD = "C_RCRVD", P_RCTBL = "C_RCTBL", - P_RCTCB = "C_RCTCB", P_RCTGL = "C_RCTGL", P_RCTVG = "C_RCTVG", - P_RDGDR = "C_RDGDR", P_REMNC = "C_REMNC", P_REPHX = "C_REPHX", - P_RHBDM = "C_RHBDMM", F_RHBDS = "C_RHBDSP", P_RHPDD = "C_RHPDD", - F_RHPDM = "C_RHPDM", F_RHZDMY = "C_RHZDM", P_RHZMM = "C_RHZMM", - P_RIVRN = "C_RIVRN", P_ROSLN = "C_ROSLN", P_ROTAL = "C_ROTAL", - P_RPHDP = "C_RPHDP", P_RPRTN = "C_RPRTN", P_RSSLL = "C_RSSLL", - P_RTLMM = "C_RTLMM", P_RTYLA = "C_RTYLA", P_RUGID = "C_RUGID", - F_RZLLP = "C_RZLLP", P_SAGRN = "C_SAGRN", P_SCCMM = "C_SCCMM", - P_SCCRH = "C_SCCRH", P_SCHLM = "C_SCHLM", F_SCLRS = "C_SCLRS", - P_SCTLR = "C_SCTLR", P_SEBRK = "C_SEBRK", P_SGMLN = "C_SGMLN", - P_SGMLP = "C_SGMLP", P_SGMMR = "C_SGMMR", P_SGMVR = "C_SGMVR", - F_SMMRS = "C_SMMRS", P_SNNDS = "C_SNNDS", P_SORTS = "C_SORTS", - P_SPHGN = "C_SPHGN", P_SPHNN = "C_SPHNN", P_SNLLA = "C_SPHNNL", - P_SPHTR = "C_SPHTR", P_SPHTX = "C_SPHTX", P_SPHVG = "C_SPHVG", - P_SPRDT = "C_SPRDT", P_SPRLC = "C_SPRLC", F_SPRLG = "C_SPRLG", - P_SPRLL = "C_SPRLL", F_SPRMY = "C_SPRMY", P_SPRPL = "C_SPRPL", - P_SPRSG = "C_SPRSG", P_SPRST = "C_SPRST", P_SPHNP = "C_SPRTA", - P_SPRZN = "C_SPRZN", P_SPHRG = "C_SPSNA", P_STHDM = "C_SPTHD", - P_SRCNR = "C_SRCNR", F_SRLPD = "C_SRLPD", F_SPNGS = "C_SSPRA", - F_STEIN = "C_STEIN", P_SPTHD = "C_STHDDS", P_STHRP = "C_STHRP", - P_STNFR = "C_STNFR", P_STNSM = "C_STNSM", P_STNTR = "C_STNTR", - P_STRBL = "C_STRBL", P_STRMB = "C_STRMB", P_STTSN = "C_STTSN", - P_STYLN = "C_SYCHA", F_SCHZC = "C_SYTRM", P_TBNLL = "C_TBNLL", - P_TRCHL = "C_TCHLS", P_TCHNT = "C_TCHNT", P_THRCL = "C_THRCL", - P_THRMM = "C_THRMM", P_TIARN = "C_TIARN", P_TKPHR = "C_TKPHR", - P_TLNMA = "C_TLNMA", P_TLYPM = "C_TLYPM", P_TMNDS = "C_TMNDS", - P_TMNTA = "C_TMNTA", P_TNTNN = "C_TNNDM", P_TTNNS = "C_TNTNN", - P_TNPSS = "C_TNTNNP", P_TONTN = "C_TONTN", P_TOSAI = "C_TOSAI", - P_TPHTR = "C_TPHTR", P_TRCHH = "C_TRCHH", P_TRPHS = "C_TRCHLR", - P_TMMNA = "C_TRCHM", P_TRCHS = "C_TRCHSP", P_TRFRN = "C_TRFRN", - P_TRLCL = "C_TRLCL", P_TRTXL = "C_TRTXL", P_TRTXS = "C_TRTXS", - P_TTRHY = "C_TTRHY", F_TTRMY = "C_TTRMY", P_TXTLR = "C_TXTLR", - F_THRST = "C_TYTRM", P_URLPT = "C_ULPTS", P_UNGLT = "C_UNGLT", - P_URCNT = "C_URCNT", P_URONM = "C_URONM", P_UROSM = "C_UROSM", - P_URTRC = "C_URTRC", P_URSTY = "C_UTYLA", P_UVGRN = "C_UVGRN", - P_VLVLN = "C_VALVLN", P_VGNLN = "C_VGNLN", P_VGNLNP = "C_VGNLNP", - P_VLNRA = "C_VLVLN", P_VGNCL = "C_VNCLA", P_VRGLN = "C_VRGLN", - P_VRGLNP = "C_VRGLNP", P_VRTCL = "C_VRTCL", P_WBBNL = "C_WBBNL", - P_WEBBN = "C_WEBBN", P_WSNRL = "C_WSNRL", P_ZTHMN = "C_ZHMNM", - B_ZOOGL = "C_ZOOGL", F_DDSCS = "F_DPDSC", F_SCCHR = "F_SMYCS", - P_AMTRN = "P_ACNTH", F_AMBDM = "P_AMBDM", F_ARCYR = "P_ARCYR", - F_BADHM = "P_BADHM", F_BDHMP = "P_BDHMP", F_BRBYL = "P_BRBYL", - F_BRFLD = "P_BRFLD", F_CLMYX = "P_CLMYX", F_CLSTD = "P_CLSTD", - F_CMTRC = "P_CMTRC", F_CRBRR = "P_CRBRR", F_CRTMY = "P_CRTMY", - F_CRTRM = "P_CRTRM", F_DCTYD = "P_DCTYD", F_DDYMM = "P_DDYMM", - F_DIACH = "P_DIACH", F_DIANM = "P_DIANM", F_DIDRM = "P_DIDRM", - F_ELMYX = "P_ELMYX", F_ESTLM = "P_ESTLM", F_FULIG = "P_FULIG", - F_HMTRC = "P_HMTRC", F_LCRPS = "P_LCRPS", F_LICEA = "P_LICEA", - F_LMPRD = "P_LMPRD", F_LPTDR = "P_LPTDR", F_LSTRL = "P_LSTRL", - F_LYCGL = "P_LYCGL", F_MCBRD = "P_MCBRD", F_MNKTL = "P_MNKTL", - F_MTTRC = "P_MTTRC", F_MUCLG = "P_MUCLG", F_PHYSR = "P_PHYSR", - F_PRCHN = "P_PRCHN", F_PRMBD = "P_PRMBD", F_PRTPH = "P_PRTPH", - F_PSRNA = "P_PSRNA", F_PYSRM = "P_PYSRM", F_RTCLR = "P_RTCLR", - F_STMNT = "P_STMNT", F_SYMPH = "P_SYMPH", F_TRBRK = "P_TRBRK", - F_TRICH = "P_TRICH", F_TUBFR = "P_TUBFR", - B_GRDNR = "B_GRLLA", B_SGMNS = "B_SNGMNS", B_TCLLS = "B_THBCL", - F_CCCCS = "F_CRYPT", - # renamings of old genus + species - # putting full names here will throw notes with new taxonomic names - F_CANDD_GLB = "F_CANDD_GLA", F_CANDD_KRU = "Candida krusei", - F_CANDD_GUI = "Candida guilliermondii", F_HNSNL_ANO = "Hansenula anomala", - F_CANDD_LUS = "Candida lusitaniae", B_STRPT_TUS = "B_STRPT", - B_PRVTL_OLA = "B_PRVTL_OULO", B_FSBCT_RUM = "B_FSBCT", - B_CRYNB_EYI = "B_CRYNB_FRE", B_OLGLL_LIS = "B_OLGLL_URE") -} diff --git a/data-raw/microorganisms.translation.rds b/data-raw/microorganisms.translation.rds index 2f176826..20f2eb05 100644 Binary files a/data-raw/microorganisms.translation.rds and b/data-raw/microorganisms.translation.rds differ diff --git a/data-raw/microorganisms.txt b/data-raw/microorganisms.txt index 17dfbede..07a44561 100644 --- a/data-raw/microorganisms.txt +++ b/data-raw/microorganisms.txt @@ -11207,6 +11207,7 @@ "F_CANDD_KAZU" "Candida kazuoi" "Fungi" "Ascomycota" "Saccharomycetes" "Saccharomycetales" "(unknown family)" "Candida" "kazuoi" "" "species" "Nakase et al., 2007" "3d20db459296758ec4a5beb7a56e3a44" "CoL" 2 "F_CANDD_KRSN" "Candida keroseneae" "Fungi" "Ascomycota" "Saccharomycetes" "Saccharomycetales" "(unknown family)" "Candida" "keroseneae" "" "species" "Buddie et al., 2011" "83b3ea8ab59f4c455de8a30e5b4d6a28" "CoL" 2 "F_CANDD_KH-T" "Candida khao-thaluensis" "Fungi" "Ascomycota" "Saccharomycetes" "Saccharomycetales" "(unknown family)" "Candida" "khao-thaluensis" "" "species" "Groenew et al., 2011" "3767929e75dd19022c79bde32143733f" "CoL" 2 +"F_CANDD_KRUS" "Candida krusei" "Fungi" "Ascomycota" "Saccharomycetes" "Saccharomycetales" "(unknown family)" "Candida" "krusei" "" "species" "" "manually added" 2 "444877006" "F_CANDD_KUOI" "Candida kuoi" "Fungi" "Ascomycota" "Saccharomycetes" "Saccharomycetales" "(unknown family)" "Candida" "kuoi" "" "species" "Kurtzman, 2012" "2ddb2646cbee79c1aaaa725927e2e4c6" "CoL" 2 "F_CANDD_LBDR" "Candida labiduridarum" "Fungi" "Ascomycota" "Saccharomycetes" "Saccharomycetales" "(unknown family)" "Candida" "labiduridarum" "" "species" "Suh et al., 2008" "79db540254156bc73399caaca772652e" "CoL" 2 "F_CANDD_LCT-" "Candida lactis-condensi" "Fungi" "Ascomycota" "Saccharomycetes" "Saccharomycetales" "(unknown family)" "Candida" "lactis-condensi" "" "species" "Mey et al., 1978" "9f04e19bd4cba3af175dbebad0f84bf0" "CoL" 2 diff --git a/data-raw/reproduction_of_microorganisms.R b/data-raw/reproduction_of_microorganisms.R index 3abec2f7..764dcf4d 100644 --- a/data-raw/reproduction_of_microorganisms.R +++ b/data-raw/reproduction_of_microorganisms.R @@ -667,7 +667,16 @@ MOs <- MOs %>% ref = NA_character_, species_id = "", source = "manually added"), - # Blastocystis hominis does not exist (it means 'got a Bastocystis from humans', PMID 15634993) + # Candida krusei + MOs %>% + filter(genus == "Candida", species == "glabrata") %>% .[1,] %>% + mutate(mo = gsub("(.*)_(.*)_.*", "\\1_\\2_KRUS", mo), + species = "krusei" , + fullname = "Candida krusei", + ref = NA_character_, + species_id = "", + source = "manually added"), + # Blastocystis hominis does not exist (it means 'got a Blastocystis from humans', PMID 15634993) # but let's be nice to the clinical people in microbiology MOs %>% filter(fullname == "Blastocystis") %>% @@ -897,6 +906,7 @@ rsi_translation$mo <- as.mo(rsi_translation$mo) microorganisms.codes$mo <- as.mo(microorganisms.codes$mo) class(microorganisms.codes$mo) <- c("mo", "character") microorganisms.translation <- microorganisms.translation %>% + # (to do: add last package version to column pkg_version) left_join(microorganisms.old[, c("fullname", "fullname_new")], # microorganisms.old is now new and loaded by = c("mo_new" = "fullname")) %>% mutate(name = ifelse(!is.na(fullname_new), fullname_new, mo_new)) %>% diff --git a/data/microorganisms.rda b/data/microorganisms.rda index a0714ce5..fa170c1b 100644 Binary files a/data/microorganisms.rda and b/data/microorganisms.rda differ diff --git a/docs/404.html b/docs/404.html index 957e8dba..591f1d48 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9034 + 1.2.0.9035 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 7c94fc60..9748df79 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9034 + 1.2.0.9035 diff --git a/docs/articles/index.html b/docs/articles/index.html index 37a60b14..a3f5a8d4 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9034 + 1.2.0.9035 diff --git a/docs/authors.html b/docs/authors.html index 1326325d..74951f3f 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9034 + 1.2.0.9035 diff --git a/docs/extra.js b/docs/extra.js index e2163abb..c1268b17 100644 --- a/docs/extra.js +++ b/docs/extra.js @@ -24,7 +24,7 @@ // Add updated Font Awesome 5.8.2 library $('head').append(''); -$( document ).ready(function() { +$(document).ready(function() { // add SurveyMonkey // $('body').append(''); @@ -90,8 +90,9 @@ $( document ).ready(function() { } $(".template-authors").html(doct_tit($(".template-authors").html())); $(".template-citation-authors").html(doct_tit($(".template-citation-authors").html())); + $('.template-citation-authors h1').eq(0).text('How to cite'); + $('.template-citation-authors h1').eq(1).text('All contributors'); $(".developers").html(doct_tit($(".developers").html())); - // $("footer").html(doct_tit($("footer").html())); // Edit title of manual $('.template-reference-index h1').text('Manual'); diff --git a/docs/index.html b/docs/index.html index b3f81ac0..039525cd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.2.0.9034 + 1.2.0.9035 diff --git a/docs/news/index.html b/docs/news/index.html index 5f8225cf..795cb454 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9034 + 1.2.0.9035 @@ -229,13 +229,13 @@ Source: NEWS.md -
-

-AMR 1.2.0.9034 Unreleased +
+

+AMR 1.2.0.9035 Unreleased

-
+

-Last updated: 13-Jul-2020 +Last updated: 22 July 2020

@@ -262,14 +262,20 @@

Changed

    -
  • Improvements for susceptibility() and resistance() and all count_*(), proportion_*() functions: +
  • +

    Big speed improvement for using any function on microorganism codes from earlier package versions (prior to AMR v1.2.0), such as as.mo(), mo_name(), first_isolate(), eucast_rules(), mdro(), etc.

    +

    As a consequence, very old microbial codes (from AMR v0.5.0 and lower) are not supported anymore. Use as.mo() on your microorganism names or codes to transform them to current abbreviations used in this package.

    +
  • +
  • +

    Improvements for susceptibility() and resistance() and all count_*(), proportion_*() functions:

      -
    • 95% speed improvement (!) by using other base R functions for calculation
    • +
    • 95% speed improvement by using other base R functions for calculation
    • Using unexisting columns wil now return an error instead of dropping them silently
    • Using variables for column names (as well as selectors like dplyr::all_of()) now works again
  • -
  • Improvements for as.ab(): +
  • +

    Improvements for as.ab():

    • Dramatic improvement of the algorithm behind as.ab(), making many more input errors translatable, such as digitalised health care records, using too few or too many vowels or consonants and many more
    • Added progress bar
    • @@ -277,17 +283,15 @@
    • The as.ab() function will now throw a note if more than 1 antimicrobial drug could be retrieved from a single input value.
  • -
  • Fixed a bug where eucast_rules() would not work on a tibble when the tibble or dplyr package was loaded
  • -
  • All *_join_microorganisms() functions and bug_drug_combinations() now return the original data class (e.g. tibbles and data.tables)
  • -
  • Fixed a bug for using grouped versions of rsi_df(), proportion_df() and count_df(), and fixed a bug where not all different antimicrobial results were added as rows
  • -
  • Improved auto-determination for columns of types <mo> and <Date> -
  • -
  • Fixed a bug in bug_drug_combinations() for when only one antibiotic was in the input data
  • -
  • Changed the summary for class <mo>, to highlight the %SI vs. %R
  • -
  • Improved error handling, giving more useful info when functions return an error
  • -
  • Any progress bar will now only show in interactive mode (i.e. not in R Markdown)
  • -
  • Speed improvement for mdro() and filter_ab_class() -
  • +
  • Fixed a bug where eucast_rules() would not work on a tibble when the tibble or dplyr package was loaded

  • +
  • All *_join_microorganisms() functions and bug_drug_combinations() now return the original data class (e.g. tibbles and data.tables)

  • +
  • Fixed a bug for using grouped versions of rsi_df(), proportion_df() and count_df(), and fixed a bug where not all different antimicrobial results were added as rows

  • +
  • Improved auto-determination for columns of types <mo> and <Date>

  • +
  • Fixed a bug in bug_drug_combinations() for when only one antibiotic was in the input data

  • +
  • Changed the summary for class <rsi>, to highlight the %SI vs. %R

  • +
  • Improved error handling, giving more useful info when functions return an error

  • +
  • Any progress bar will now only show in interactive mode (i.e. not in R Markdown)

  • +
  • Speed improvement for mdro() and filter_ab_class()

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 6fa19287..bd833476 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: WHONET: WHONET.html benchmarks: benchmarks.html resistance_predict: resistance_predict.html -last_built: 2020-07-13T07:17Z +last_built: 2020-07-22T08:18Z urls: reference: https://msberends.github.io/AMR/reference article: https://msberends.github.io/AMR/articles diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index 722a1926..9584cf37 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -82,7 +82,7 @@ AMR (for R) - 1.2.0.9032 + 1.2.0.9035
@@ -285,7 +285,7 @@

Value

-

A character vector with class mo

+

A character vector with additional class mo

Details

@@ -306,7 +306,7 @@ C (Chromista), F (Fungi), P (Protozoa) -

Values that cannot be coered will be considered 'unknown' and will get the MO code UNKNOWN.

+

Values that cannot be coerced will be considered 'unknown' and will get the MO code UNKNOWN.

Use the mo_* functions to get properties based on the returned code, see Examples.

The algorithm uses data from the Catalogue of Life (see below) and from one other source (see microorganisms).

The as.mo() function uses several coercion rules for fast and logical results. It assesses the input matching criteria in the following order:

    @@ -327,17 +327,17 @@
  1. Uncertainty level 3: allow all of level 1 and 2, strip off text elements from the end, allow any part of a taxonomic name.

  2. -

    This leads to e.g.:

      +

      The level of uncertainty can be set using the argument allow_uncertain. The default is allow_uncertain = TRUE, which is equal to uncertainty level 2. Using allow_uncertain = FALSE is equal to uncertainty level 0 and will skip all rules. You can also use e.g. as.mo(..., allow_uncertain = 1) to only allow up to level 1 uncertainty.

      +

      With the default setting (allow_uncertain = TRUE, level 2), below examples will lead to valid results:

      • "Streptococcus group B (known as S. agalactiae)". The text between brackets will be removed and a warning will be thrown that the result Streptococcus group B (B_STRPT_GRPB) needs review.

      • "S. aureus - please mind: MRSA". The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result Staphylococcus aureus (B_STPHY_AURS) needs review.

      • "Fluoroquinolone-resistant Neisseria gonorrhoeae". The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result Neisseria gonorrhoeae (B_NESSR_GNRR) needs review.

      -

      The level of uncertainty can be set using the argument allow_uncertain. The default is allow_uncertain = TRUE, which is equal to uncertainty level 2. Using allow_uncertain = FALSE is equal to uncertainty level 0 and will skip all rules. You can also use e.g. as.mo(..., allow_uncertain = 1) to only allow up to level 1 uncertainty.

      -

      There are three helper functions that can be run after then as.mo() function:

        -
      • Use mo_uncertainties() to get a data.frame with all values that were coerced to a valid value, but with uncertainty. The output contains a score, that is calculated as \((n - 0.5 * L) / n\), where n is the number of characters of the returned full name of the microorganism, and L is the Levenshtein distance between that full name and the user input.

      • -
      • Use mo_failures() to get a vector with all values that could not be coerced to a valid value.

      • -
      • Use mo_renamed() to get a data.frame with all values that could be coerced based on an old, previously accepted taxonomic name.

      • +

        There are three helper functions that can be run after using the as.mo() function:

          +
        • Use mo_uncertainties() to get a data.frame with all values that were coerced to a valid value, but with uncertainty. The output contains a score, that is calculated as \((n - 0.5 * L) / n\), where n is the number of characters of the full taxonomic name of the microorganism, and L is the Levenshtein distance between that full name and the user input.

        • +
        • Use mo_failures() to get a character vector with all values that could not be coerced to a valid value.

        • +
        • Use mo_renamed() to get a data.frame with all values that could be coerced based on old, previously accepted taxonomic names.

        @@ -345,9 +345,9 @@

        The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the prevalence columns in the microorganisms and microorganisms.old data sets. The grouping into prevalence groups is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence.

        -

        Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is Enterococcus, Staphylococcus or Streptococcus. This group consequently contains all common Gram-negative bacteria, such as Pseudomonas and Legionella and all species within the order Enterobacteriales.

        -

        Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is Aspergillus, Bacteroides, Candida, Capnocytophaga, Chryseobacterium, Cryptococcus, Elisabethkingia, Flavobacterium, Fusobacterium, Giardia, Leptotrichia, Mycoplasma, Prevotella, Rhodotorula, Treponema, Trichophyton or Ureaplasma.

        -

        Group 3 (least prevalent microorganisms) consists of all other microorganisms.

        +

        Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is Enterococcus, Staphylococcus or Streptococcus. This group consequently contains all common Gram-negative bacteria, such as Klebsiella, Pseudomonas and Legionella.

        +

        Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is Aspergillus, Bacteroides, Candida, Capnocytophaga, Chryseobacterium, Cryptococcus, Elisabethkingia, Flavobacterium, Fusobacterium, Giardia, Leptotrichia, Mycoplasma, Prevotella, Rhodotorula, Treponema, Trichophyton or Ureaplasma. This group consequently contains all less common and rare human pathogens.

        +

        Group 3 (least prevalent microorganisms) consists of all other microorganisms. This group contains microorganisms most probably not found in humans.

        Source

        diff --git a/docs/reference/guess_ab_col.html b/docs/reference/guess_ab_col.html index def158da..3ea6ae7f 100644 --- a/docs/reference/guess_ab_col.html +++ b/docs/reference/guess_ab_col.html @@ -82,7 +82,7 @@ AMR (for R) - 1.2.0.9032 + 1.2.0.9035
@@ -282,7 +282,7 @@ The lifecycle of this function is maturing< # [1] "tetr" guess_ab_col(df, "J01AA07", verbose = TRUE) -# Note: Using column `tetr` as input for "J01AA07". +# NOTE: Using column `tetr` as input for `J01AA07` (tetracycline). # [1] "tetr" # WHONET codes diff --git a/docs/reference/index.html b/docs/reference/index.html index 546c551a..7ef22ddb 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9034 + 1.2.0.9035
@@ -484,7 +484,7 @@

microorganisms

-

Data set with 67,150 microorganisms

+

Data set with 67,151 microorganisms

diff --git a/docs/reference/microorganisms.html b/docs/reference/microorganisms.html index 6fd58dce..2ff8e2da 100644 --- a/docs/reference/microorganisms.html +++ b/docs/reference/microorganisms.html @@ -6,7 +6,7 @@ -Data set with 67,150 microorganisms — microorganisms • AMR (for R) +Data set with 67,151 microorganisms — microorganisms • AMR (for R) @@ -48,7 +48,7 @@ - + @@ -82,7 +82,7 @@ AMR (for R) - 1.2.0.9032 + 1.2.0.9035
@@ -226,7 +226,7 @@
@@ -240,7 +240,7 @@

Format

-

A data.frame with 67,150 observations and 16 variables:

    +

    A data.frame with 67,151 observations and 16 variables:

    • mo
      ID of microorganism as used by this package

    • fullname
      Full name, like "Escherichia coli"

    • kingdom, phylum, class, order, family, genus, species, subspecies
      Taxonomic rank of the microorganism

    • @@ -256,13 +256,14 @@

      Catalogue of Life: Annual Checklist (public online taxonomic database), http://www.catalogueoflife.org (check included annual version with catalogue_of_life_version()).

      Parte, A.C. (2018). LPSN — List of Prokaryotic names with Standing in Nomenclature (bacterio.net), 20 years on. International Journal of Systematic and Evolutionary Microbiology, 68, 1825-1829; doi: 10.1099/ijsem.0.002786

      -

      Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures, Germany, Prokaryotic Nomenclature Up-to-Date, https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date (check included version with catalogue_of_life_version()).

      +

      Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures, Germany, Prokaryotic Nomenclature Up-to-Date, https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date and https://lpsn.dsmz.de (check included version with catalogue_of_life_version()).

      Details

      Manually added were:

      • 11 entries of Streptococcus (beta-haemolytic: groups A, B, C, D, F, G, H, K and unspecified; other: viridans, milleri)

      • 2 entries of Staphylococcus (coagulase-negative (CoNS) and coagulase-positive (CoPS))

      • 3 entries of Trichomonas (Trichomonas vaginalis, and its family and genus)

      • +
      • 1 entry of Candida (Candida krusei), that is not (yet) in the Catalogue of Life

      • 1 entry of Blastocystis (Blastocystis hominis), although it officially does not exist (Noel et al. 2005, PMID 15634993)

      • 5 other 'undefined' entries (unknown, unknown Gram negatives, unknown Gram positives, unknown yeast and unknown fungus)

      • 6 families under the Enterobacterales order, according to Adeolu et al. (2016, PMID 27620848), that are not (yet) in the Catalogue of Life

      • @@ -284,8 +285,9 @@ -

        Names of prokaryotes are defined as being validly published by the International Code of Nomenclature of Bacteria. Validly published are all names which are included in the Approved Lists of Bacterial Names and the names subsequently published in the International Journal of Systematic Bacteriology (IJSB) and, from January 2000, in the International Journal of Systematic and Evolutionary Microbiology (IJSEM) as original articles or in the validation lists.

        -

        From: https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date/complete-list-readme

        +

        Names of prokaryotes are defined as being validly published by the International Code of Nomenclature of Bacteria. Validly published are all names which are included in the Approved Lists of Bacterial Names and the names subsequently published in the International Journal of Systematic Bacteriology (IJSB) and, from January 2000, in the International Journal of Systematic and Evolutionary Microbiology (IJSEM) as original articles or in the validation lists. +(from https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date/complete-list-readme)

        +

        In February 2020, the DSMZ records were merged with the List of Prokaryotic names with Standing in Nomenclature (LPSN).

        Catalogue of Life

        diff --git a/docs/reference/rsi_translation.html b/docs/reference/rsi_translation.html index 268029c2..eafa4c81 100644 --- a/docs/reference/rsi_translation.html +++ b/docs/reference/rsi_translation.html @@ -82,7 +82,7 @@ AMR (for R) - 1.2.0.9032 + 1.2.0.9035
@@ -255,7 +255,7 @@

Details

-

The repository of this AMR package contains a file comprising this exact data set: https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt. This file allows for machine reading EUCAST and CLSI guidelines, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file is updated automatically.

+

The repository of this AMR package contains a file comprising this exact data set: https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt. This file allows for machine reading EUCAST and CLSI guidelines, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically.

Read more on our website!

diff --git a/git_premaster.sh b/git_premaster.sh index 1aa872dd..38ac696a 100755 --- a/git_premaster.sh +++ b/git_premaster.sh @@ -85,7 +85,7 @@ if [ -z "$3" ]; then # combine tag (e.g. 0.1.0) and commit number (like 40) increased by 9000 to indicate beta version new_version="$current_tag.$((current_commit + 9000))" # results in 0.1.0.9040 # add date to 2nd line of NEWS.md when no version number was set - sed -i -- "2s/.*/## \Last updated: $(date '+%d-%b-%Y')\<\/small\>/" NEWS.md + sed -i -- "2s/.*/## \Last updated: $(date '+%e %B %Y')\<\/small\>/" NEWS.md else # version number set in command new_version=$3 diff --git a/man/as.mo.Rd b/man/as.mo.Rd index 49dacd78..7a1b9295 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -44,7 +44,7 @@ This excludes \emph{Enterococci} at default (who are in group D), use \code{Lanc \item{...}{other parameters passed on to functions} } \value{ -A \code{\link{character}} vector with class \code{\link{mo}} +A \code{\link{character}} \code{\link{vector}} with additional class \code{\link{mo}} } \description{ Use this function to determine a valid microorganism ID (\code{\link{mo}}). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea 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 \emph{Examples}. @@ -66,7 +66,7 @@ A microorganism ID from this package (class: \code{\link{mo}}) typically looks l C (Chromista), F (Fungi), P (Protozoa) } -Values that cannot be coered will be considered 'unknown' and will get the MO code \code{UNKNOWN}. +Values that cannot be coerced will be considered 'unknown' and will get the MO code \code{UNKNOWN}. Use the \code{\link[=mo_property]{mo_*}} functions to get properties based on the returned code, see Examples. @@ -92,20 +92,20 @@ In addition, the \code{\link[=as.mo]{as.mo()}} function can differentiate four l \item Uncertainty level 3: allow all of level 1 and 2, strip off text elements from the end, allow any part of a taxonomic name. } -This leads to e.g.: +The level of uncertainty can be set using the argument \code{allow_uncertain}. The default is \code{allow_uncertain = TRUE}, which is equal to uncertainty level 2. Using \code{allow_uncertain = FALSE} is equal to uncertainty level 0 and will skip all rules. You can also use e.g. \code{as.mo(..., allow_uncertain = 1)} to only allow up to level 1 uncertainty. + +With the default setting (\code{allow_uncertain = TRUE}, level 2), below examples will lead to valid results: \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_GRPB}) needs review. \item \code{"S. aureus - please mind: MRSA"}. The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result \emph{Staphylococcus aureus} (\code{B_STPHY_AURS}) needs review. \item \code{"Fluoroquinolone-resistant Neisseria gonorrhoeae"}. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result \emph{Neisseria gonorrhoeae} (\code{B_NESSR_GNRR}) needs review. } -The level of uncertainty can be set using the argument \code{allow_uncertain}. The default is \code{allow_uncertain = TRUE}, which is equal to uncertainty level 2. Using \code{allow_uncertain = FALSE} is equal to uncertainty level 0 and will skip all rules. You can also use e.g. \code{as.mo(..., allow_uncertain = 1)} to only allow up to level 1 uncertainty. - -There are three helper functions that can be run after then \code{\link[=as.mo]{as.mo()}} function: +There are three helper functions that can be run after using the \code{\link[=as.mo]{as.mo()}} function: \itemize{ -\item Use \code{\link[=mo_uncertainties]{mo_uncertainties()}} to get a \code{\link{data.frame}} with all values that were coerced to a valid value, but with uncertainty. The output contains a score, that is calculated as \eqn{(n - 0.5 * L) / n}, where \emph{n} is the number of characters of the returned full name of the microorganism, and \emph{L} is the \href{https://en.wikipedia.org/wiki/Levenshtein_distance}{Levenshtein distance} between that full name and the user input. -\item Use \code{\link[=mo_failures]{mo_failures()}} to get a \code{\link{vector}} with all values that could not be coerced to a valid value. -\item Use \code{\link[=mo_renamed]{mo_renamed()}} to get a \code{\link{data.frame}} with all values that could be coerced based on an old, previously accepted taxonomic name. +\item Use \code{\link[=mo_uncertainties]{mo_uncertainties()}} to get a \code{\link{data.frame}} with all values that were coerced to a valid value, but with uncertainty. The output contains a score, that is calculated as \eqn{(n - 0.5 * L) / n}, where \emph{n} is the number of characters of the full taxonomic name of the microorganism, and \emph{L} is the \href{https://en.wikipedia.org/wiki/Levenshtein_distance}{Levenshtein distance} between that full name and the user input. +\item Use \code{\link[=mo_failures]{mo_failures()}} to get a \code{\link{character}} \code{\link{vector}} with all values that could not be coerced to a valid value. +\item Use \code{\link[=mo_renamed]{mo_renamed()}} to get a \code{\link{data.frame}} with all values that could be coerced based on old, previously accepted taxonomic names. } } @@ -113,11 +113,11 @@ There are three helper functions that can be run after then \code{\link[=as.mo]{ The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the \code{prevalence} columns in the \link{microorganisms} and \link{microorganisms.old} data sets. The grouping into prevalence groups is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. -Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is \emph{Enterococcus}, \emph{Staphylococcus} or \emph{Streptococcus}. This group consequently contains all common Gram-negative bacteria, such as \emph{Pseudomonas} and \emph{Legionella} and all species within the order Enterobacteriales. +Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is \emph{Enterococcus}, \emph{Staphylococcus} or \emph{Streptococcus}. This group consequently contains all common Gram-negative bacteria, such as \emph{Klebsiella}, \emph{Pseudomonas} and \emph{Legionella}. -Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is \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} or \emph{Ureaplasma}. +Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is \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} or \emph{Ureaplasma}. This group consequently contains all less common and rare human pathogens. -Group 3 (least prevalent microorganisms) consists of all other microorganisms. +Group 3 (least prevalent microorganisms) consists of all other microorganisms. This group contains microorganisms most probably not found in humans. } } \section{Source}{ diff --git a/man/guess_ab_col.Rd b/man/guess_ab_col.Rd index a6893c4a..71b1931a 100644 --- a/man/guess_ab_col.Rd +++ b/man/guess_ab_col.Rd @@ -43,7 +43,7 @@ guess_ab_col(df, "J01AA07") # ATC code of tetracycline # [1] "tetr" guess_ab_col(df, "J01AA07", verbose = TRUE) -# Note: Using column `tetr` as input for "J01AA07". +# NOTE: Using column `tetr` as input for `J01AA07` (tetracycline). # [1] "tetr" # WHONET codes diff --git a/man/microorganisms.Rd b/man/microorganisms.Rd index a23c19dd..afd9f2c7 100755 --- a/man/microorganisms.Rd +++ b/man/microorganisms.Rd @@ -3,9 +3,9 @@ \docType{data} \name{microorganisms} \alias{microorganisms} -\title{Data set with 67,150 microorganisms} +\title{Data set with 67,151 microorganisms} \format{ -A \code{\link{data.frame}} with 67,150 observations and 16 variables: +A \code{\link{data.frame}} with 67,151 observations and 16 variables: \itemize{ \item \code{mo}\cr ID of microorganism as used by this package \item \code{fullname}\cr Full name, like \code{"Escherichia coli"} @@ -23,7 +23,7 @@ Catalogue of Life: Annual Checklist (public online taxonomic database), \url{htt Parte, A.C. (2018). LPSN — List of Prokaryotic names with Standing in Nomenclature (bacterio.net), 20 years on. International Journal of Systematic and Evolutionary Microbiology, 68, 1825-1829; doi: 10.1099/ijsem.0.002786 -Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures, Germany, Prokaryotic Nomenclature Up-to-Date, \url{https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date} (check included version with \code{\link[=catalogue_of_life_version]{catalogue_of_life_version()}}). +Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures, Germany, Prokaryotic Nomenclature Up-to-Date, \url{https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date} and \url{https://lpsn.dsmz.de} (check included version with \code{\link[=catalogue_of_life_version]{catalogue_of_life_version()}}). } \usage{ microorganisms @@ -37,6 +37,7 @@ Manually added were: \item 11 entries of \emph{Streptococcus} (beta-haemolytic: groups A, B, C, D, F, G, H, K and unspecified; other: viridans, milleri) \item 2 entries of \emph{Staphylococcus} (coagulase-negative (CoNS) and coagulase-positive (CoPS)) \item 3 entries of \emph{Trichomonas} (\emph{Trichomonas vaginalis}, and its family and genus) +\item 1 entry of \emph{Candida} (\emph{Candida krusei}), that is not (yet) in the Catalogue of Life \item 1 entry of \emph{Blastocystis} (\emph{Blastocystis hominis}), although it officially does not exist (Noel \emph{et al.} 2005, PMID 15634993) \item 5 other 'undefined' entries (unknown, unknown Gram negatives, unknown Gram positives, unknown yeast and unknown fungus) \item 6 families under the Enterobacterales order, according to Adeolu \emph{et al.} (2016, PMID 27620848), that are not (yet) in the Catalogue of Life @@ -58,8 +59,9 @@ The file in R format (with preserved data structure) can be found here: \section{About the records from DSMZ (see source)}{ Names of prokaryotes are defined as being validly published by the International Code of Nomenclature of Bacteria. Validly published are all names which are included in the Approved Lists of Bacterial Names and the names subsequently published in the International Journal of Systematic Bacteriology (IJSB) and, from January 2000, in the International Journal of Systematic and Evolutionary Microbiology (IJSEM) as original articles or in the validation lists. +\emph{(from \url{https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date/complete-list-readme})} -From: \url{https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date/complete-list-readme} +In February 2020, the DSMZ records were merged with the List of Prokaryotic names with Standing in Nomenclature (LPSN). } \section{Catalogue of Life}{ diff --git a/man/rsi_translation.Rd b/man/rsi_translation.Rd index 23dd966b..7b2134f2 100644 --- a/man/rsi_translation.Rd +++ b/man/rsi_translation.Rd @@ -26,7 +26,7 @@ rsi_translation Data set to interpret MIC and disk diffusion to R/SI values. Included guidelines are CLSI (2011-2019) and EUCAST (2011-2020). Use \code{\link[=as.rsi]{as.rsi()}} to transform MICs or disks measurements to R/SI values. } \details{ -The repository of this \code{AMR} package contains a file comprising this exact data set: \url{https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt}. This file \strong{allows for machine reading EUCAST and CLSI guidelines}, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file is updated automatically. +The repository of this \code{AMR} package contains a file comprising this exact data set: \url{https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt}. This file \strong{allows for machine reading EUCAST and CLSI guidelines}, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically. } \section{Read more on our website!}{ diff --git a/pkgdown/extra.js b/pkgdown/extra.js index e2163abb..c1268b17 100644 --- a/pkgdown/extra.js +++ b/pkgdown/extra.js @@ -24,7 +24,7 @@ // Add updated Font Awesome 5.8.2 library $('head').append(''); -$( document ).ready(function() { +$(document).ready(function() { // add SurveyMonkey // $('body').append(''); @@ -90,8 +90,9 @@ $( document ).ready(function() { } $(".template-authors").html(doct_tit($(".template-authors").html())); $(".template-citation-authors").html(doct_tit($(".template-citation-authors").html())); + $('.template-citation-authors h1').eq(0).text('How to cite'); + $('.template-citation-authors h1').eq(1).text('All contributors'); $(".developers").html(doct_tit($(".developers").html())); - // $("footer").html(doct_tit($("footer").html())); // Edit title of manual $('.template-reference-index h1').text('Manual'); diff --git a/tests/testthat/test-data.R b/tests/testthat/test-data.R index ff5ab5d1..3f01a127 100644 --- a/tests/testthat/test-data.R +++ b/tests/testthat/test-data.R @@ -38,6 +38,7 @@ test_that("data sets are valid", { expect_true(all(rsi_translation$mo %in% microorganisms$mo)) expect_false(any(is.na(microorganisms.codes$code))) expect_false(any(is.na(microorganisms.codes$mo))) + expect_false(any(microorganisms.translation$mo_old %in% microorganisms$mo)) # antibiotic names must always be coercible to their original AB code expect_identical(antibiotics$ab, as.ab(antibiotics$name)) @@ -62,10 +63,7 @@ test_that("creation of data sets is valid", { olddf <- create_MO.old_lookup() expect_true(all(c("fullname", "fullname_new", "ref", "prevalence", "fullname_lower", "g_species") %in% colnames(olddf))) - - old <- make_trans_tbl() - expect_gt(length(old), 0) - + }) test_that("CoL version info works", { diff --git a/tests/testthat/test-mo.R b/tests/testthat/test-mo.R index 4006b6d0..61790de7 100644 --- a/tests/testthat/test-mo.R +++ b/tests/testthat/test-mo.R @@ -24,6 +24,8 @@ context("mo.R") test_that("as.mo works", { skip_on_cran() + + library(dplyr) MOs <- microorganisms %>% filter(!is.na(mo), nchar(mo) > 3) expect_identical(as.character(MOs$mo), as.character(as.mo(MOs$mo))) @@ -50,7 +52,6 @@ test_that("as.mo works", { expect_equal(as.character(as.mo("Streptococcus")), "B_STRPT") # not Peptostreptoccus expect_equal(as.character(as.mo("Estreptococos grupo B")), "B_STRPT_GRPB") expect_equal(as.character(as.mo("Group B Streptococci")), "B_STRPT_GRPB") - expect_equal(as.character(suppressWarnings(as.mo("B_STRPTC"))), "B_STRPT") # old MO code (<=v0.5.0) expect_equal(as.character(suppressWarnings(as.mo("B_STRPT_PNE"))), "B_STRPT_PNMN") # old MO code (<=v0.8.0) expect_equal(as.character(as.mo(c("GAS", "GBS"))), c("B_STRPT_GRPA", "B_STRPT_GRPB")) @@ -144,9 +145,7 @@ test_that("as.mo works", { expect_identical(as.character(as.mo("S. sanguinis", Lancefield = TRUE)), "B_STRPT_GRPH") # group H expect_identical(as.character(as.mo("S. salivarius", Lancefield = FALSE)), "B_STRPT_SLVR") expect_identical(as.character(as.mo("S. salivarius", Lancefield = TRUE)), "B_STRPT_GRPK") # group K - - library(dplyr) - + # select with one column expect_identical( example_isolates[1:10, ] %>% @@ -259,11 +258,7 @@ test_that("as.mo works", { expect_true(example_isolates %>% pull(mo) %>% is.mo()) expect_error(translate_allow_uncertain(5)) - - # very old MO codes (<= v0.5.0) - expect_equal(suppressWarnings(as.character(as.mo("F_CCCCS_NEO"))), "F_CRYPT_NFRM") - expect_equal(suppressWarnings(as.character(as.mo("F_CANDD_GLB"))), "F_CANDD_GLBR") - + # debug mode expect_output(print(suppressMessages(suppressWarnings(as.mo("kshgcjkhsdgkshjdfsfvsdfv", debug = TRUE, allow_uncertain = 3)))))