diff --git a/DESCRIPTION b/DESCRIPTION index a5e62c98f..8290e2587 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.3.0.9013 -Date: 2020-08-29 +Version: 1.3.0.9014 +Date: 2020-09-03 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), @@ -49,6 +49,7 @@ Suggests: microbenchmark, readxl, rmarkdown, + rstudioapi, rvest, testthat, tidyr, diff --git a/NEWS.md b/NEWS.md index 33844c703..1d1edb1d9 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ -# AMR 1.3.0.9013 -## Last updated: 29 August 2020 +# AMR 1.3.0.9014 +## Last updated: 3 September 2020 + +Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly! ### New * A new vignette and website page with info about all our public and freely available data sets, that can be downloaded as flat files or in formats for use in R, SPSS, SAS, Stata and Excel: https://msberends.github.io/AMR/articles/datasets.html @@ -16,6 +18,7 @@ ``` ### Changed +* Although advertised that this package should work under R 3.0.0, we still had a dependency on R 3.6.0. This is fixed, meaning that our package should now work under R 3.0.0. * Improvements for `as.rsi()`: * Support for using `dplyr`'s `across()` to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes. ```r @@ -35,6 +38,10 @@ #> Class #> [1] 24 24 ``` +* Improvements for `as.mo()`: + * Big speed improvement for already valid microorganism ID. This also means an significant speed improvement for using `mo_*` functions like `mo_name()` on microoganism IDs. + * Added parameter `ignore_pattern` to `as.mo()` which can also be given to `mo_*` functions like `mo_name()`, to exclude known non-relevant input from analysing. This can also be set with the option `AMR_ignore_pattern`. +* `get_locale()` now uses `Sys.getlocale()` instead of `Sys.getlocale("LC_COLLATE")` * Speed improvement for `eucast_rules()` * Overall speed improvement by tweaking joining functions * Function `mo_shortname()` now returns the genus for input where the species is unknown @@ -42,6 +49,10 @@ * Added a feature from AMR 1.1.0 and earlier again, but now without other package dependencies: `tibble` printing support for classes ``, ``, ``, `` and ``. When using `tibble`s containing antimicrobial columns (class ``), "S" will print in green, "I" will print in yellow and "R" will print in red. Microbial IDs (class ``) will emphasise on the genus and species, not on the kingdom. * Names of antiviral agents in data set `antivirals` now have a starting capital letter, like it is the case in the `antibiotics` data set +### Other +* Removed unnecessary references to the `base` package +* Added packages that could be useful for some functions to the `Suggests` field of the `DESCRIPTION` file + # AMR 1.3.0 ### New diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index d163e286a..944499837 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -48,7 +48,7 @@ distinct.default <- function(.data, ..., .keep_all = FALSE) { distinct.grouped_data <- function(.data, ..., .keep_all = FALSE) { apply_grouped_function(.data, "distinct", ..., .keep_all = .keep_all) } -# faster implementation of left_join than using base::merge() by poorman - we use base::match(): +# faster implementation of left_join than using merge() by poorman - we use match(): left_join <- function(x, y, by = NULL, suffix = c(".x", ".y")) { if (is.null(by)) { by <- intersect(names(x), names(y))[1L] @@ -606,7 +606,7 @@ percentage <- function(x, digits = NULL, ...) { } # prevent dependency on package 'backports' -# these functions were not available in previous versions of R (last checked: R 4.0.0) +# these functions were not available in previous versions of R (last checked: R 4.0.2) # see here for the full list: https://github.com/r-lib/backports strrep <- function(x, times) { x <- as.character(x) @@ -636,8 +636,14 @@ deparse1 <- function(expr, collapse = " ", width.cutoff = 500L, ...) { paste(deparse(expr, width.cutoff, ...), collapse = collapse) } file.size <- function(...) { - base::file.info(...)$size + file.info(...)$size } file.mtime <- function(...) { - base::file.info(...)$mtime + file.info(...)$mtime +} +str2lang <- function(s) { + stopifnot(length(s) == 1L) + ex <- parse(text = s, keep.source=FALSE) + stopifnot(length(ex) == 1L) + ex[[1L]] } diff --git a/R/ab.R b/R/ab.R index 93220bf27..ae1d0153e 100755 --- a/R/ab.R +++ b/R/ab.R @@ -19,7 +19,7 @@ # Visit our website for more info: https://msberends.github.io/AMR. # # ==================================================================== # -#' Transform to antibiotic ID +#' Transform input to an antibiotic ID #' #' Use this function to determine the antibiotic code of one or more antibiotics. The data set [antibiotics] will be searched for abbreviations, official names and synonyms (brand names). #' @inheritSection lifecycle Maturing lifecycle diff --git a/R/ab_property.R b/R/ab_property.R index fd09b1959..a7afbea25 100644 --- a/R/ab_property.R +++ b/R/ab_property.R @@ -19,7 +19,7 @@ # Visit our website for more info: https://msberends.github.io/AMR. # # ==================================================================== # -#' Property of an antibiotic +#' Get properties of an antibiotic #' #' Use these functions to return a specific property of an antibiotic from the [antibiotics] data set. All input values will be evaluated internally with [as.ab()]. #' @inheritSection lifecycle Stable lifecycle @@ -172,7 +172,7 @@ ab_ddd <- function(x, administration = "oral", units = FALSE, ...) { #' @export ab_info <- function(x, language = get_locale(), ...) { x <- as.ab(x, ...) - base::list(ab = as.character(x), + list(ab = as.character(x), atc = ab_atc(x), cid = ab_cid(x), name = ab_name(x, language = language), diff --git a/R/atc_online.R b/R/atc_online.R index a72728af5..fcf178bef 100644 --- a/R/atc_online.R +++ b/R/atc_online.R @@ -21,10 +21,8 @@ #' Get ATC properties from WHOCC website #' -#' @inheritSection lifecycle Questioning lifecycle +#' @inheritSection lifecycle Stable lifecycle #' @description Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit. -#' -#' **This function requires an internet connection.** #' @param atc_code a character or character vector with ATC code(s) of antibiotic(s) #' @param property property of an ATC code. Valid values are `"ATC"`, `"Name"`, `"DDD"`, `"U"` (`"unit"`), `"Adm.R"`, `"Note"` and `groups`. For this last option, all hierarchical groups of an ATC code will be returned, see Examples. #' @param administration type of administration when using `property = "Adm.R"`, see Details @@ -54,6 +52,8 @@ #' - `"MU"` = million units #' - `"mmol"` = millimole #' - `"ml"` = milliliter (e.g. eyedrops) +#' +#' **N.B. This function requires an internet connection and only works if the following packages are installed: `curl`, `rvest`, `xml2`.** #' @export #' @rdname atc_online #' @inheritSection AMR Read more on our website! diff --git a/R/availability.R b/R/availability.R index 7a8a77cfb..0430e3083 100644 --- a/R/availability.R +++ b/R/availability.R @@ -47,11 +47,11 @@ #' } availability <- function(tbl, width = NULL) { stop_ifnot(is.data.frame(tbl), "`tbl` must be a data.frame") - x <- base::sapply(tbl, function(x) { - 1 - base::sum(base::is.na(x)) / base::length(x) + x <- sapply(tbl, function(x) { + 1 - sum(is.na(x)) / length(x) }) - n <- base::sapply(tbl, function(x) base::length(x[!base::is.na(x)])) - R <- base::sapply(tbl, function(x) base::ifelse(is.rsi(x), resistance(x, minimum = 0), NA)) + n <- sapply(tbl, function(x) length(x[!is.na(x)])) + R <- sapply(tbl, function(x) ifelse(is.rsi(x), resistance(x, minimum = 0), NA)) R_print <- character(length(R)) R_print[!is.na(R)] <- percentage(R[!is.na(R)]) R_print[is.na(R)] <- "" diff --git a/R/bug_drug_combinations.R b/R/bug_drug_combinations.R index f287bde36..672d4b6b6 100644 --- a/R/bug_drug_combinations.R +++ b/R/bug_drug_combinations.R @@ -33,8 +33,6 @@ #' @inheritParams rsi_df #' @inheritParams base::formatC #' @details The function [format()] calculates the resistance per bug-drug combination. Use `combine_IR = FALSE` (default) to test R vs. S+I and `combine_IR = TRUE` to test R+I vs. S. -#' -#' The language of the output can be overwritten with `options(AMR_locale)`, please see [translate]. #' @export #' @rdname bug_drug_combinations #' @return The function [bug_drug_combinations()] returns a [`data.frame`] with columns "mo", "ab", "S", "I", "R" and "total". @@ -71,7 +69,7 @@ bug_drug_combinations <- function(x, x_class <- class(x) x <- as.data.frame(x, stringsAsFactors = FALSE) - x[, col_mo] <- FUN(x[, col_mo, drop = TRUE]) + x[, col_mo] <- FUN(x[, col_mo, drop = TRUE], ...) x <- x[, c(col_mo, names(which(sapply(x, is.rsi)))), drop = FALSE] unique_mo <- sort(unique(x[, col_mo, drop = TRUE])) diff --git a/R/data.R b/R/data.R index 0eda68d65..4e3cb3756 100755 --- a/R/data.R +++ b/R/data.R @@ -149,7 +149,7 @@ catalogue_of_life <- list( #' @seealso [as.mo()] [mo_property()] [microorganisms] "microorganisms.old" -#' Translation table with `r format(nrow(microorganisms.codes), big.mark = ",")` common microorganism codes +#' Data set with `r format(nrow(microorganisms.codes), big.mark = ",")` common microorganism codes #' #' A data set containing commonly used codes for microorganisms, from laboratory systems and WHONET. Define your own with [set_mo_source()]. They will all be searched when using [as.mo()] and consequently all the [`mo_*`][mo_property()] functions. #' @format A [`data.frame`] with `r format(nrow(microorganisms.codes), big.mark = ",")` observations and `r ncol(microorganisms.codes)` variables: @@ -194,17 +194,17 @@ catalogue_of_life <- list( #' Data set with `r format(nrow(WHONET), big.mark = ",")` isolates - WHONET example #' -#' This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our [example_isolates] data set. +#' This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The antibiotic results are based on our [example_isolates] data set. All patient names are created using online surname generators and are only in place for practice purposes. #' @format A [`data.frame`] with `r format(nrow(WHONET), big.mark = ",")` observations and `r ncol(WHONET)` variables: #' - `Identification number`\cr ID of the sample #' - `Specimen number`\cr ID of the specimen #' - `Organism`\cr Name of the microorganism. Before analysis, you should transform this to a valid microbial class, using [as.mo()]. #' - `Country`\cr Country of origin #' - `Laboratory`\cr Name of laboratory -#' - `Last name`\cr Last name of patient -#' - `First name`\cr Initial of patient -#' - `Sex`\cr Gender of patient -#' - `Age`\cr Age of patient +#' - `Last name`\cr Fictitious last name of patient +#' - `First name`\cr Fictitious initial of patient +#' - `Sex`\cr Fictitious gender of patient +#' - `Age`\cr Fictitious age of patient #' - `Age category`\cr Age group, can also be looked up using [age_groups()] #' - `Date of admission`\cr Date of hospital admission #' - `Specimen date`\cr Date when specimen was received at laboratory diff --git a/R/disk.R b/R/disk.R index 50f331f5a..54d67fcdd 100644 --- a/R/disk.R +++ b/R/disk.R @@ -19,9 +19,9 @@ # Visit our website for more info: https://msberends.github.io/AMR. # # ==================================================================== # -#' Class 'disk' +#' Transform input to disk diffusion diameters #' -#' This transforms a vector to a new class [`disk`], which is a growth zone size (around an antibiotic disk) in millimetres between 6 and 50. +#' This transforms a vector to a new class [`disk`], which is a disk diffusion growth zone size (around an antibiotic disk) in millimetres between 6 and 50. #' @inheritSection lifecycle Stable lifecycle #' @rdname as.disk #' @param x vector diff --git a/R/first_isolate.R b/R/first_isolate.R index d8558532a..c616ad211 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -411,11 +411,11 @@ first_isolate <- function(x, rownames(x) <- NULL if (info == TRUE) { - n_found <- base::sum(x$newvar_first_isolate, na.rm = TRUE) + n_found <- sum(x$newvar_first_isolate, na.rm = TRUE) p_found_total <- percentage(n_found / nrow(x[which(!is.na(x$newvar_mo)), , drop = FALSE])) p_found_scope <- percentage(n_found / scope.size) # mark up number of found - n_found <- base::format(n_found, big.mark = big.mark, decimal.mark = decimal.mark) + n_found <- format(n_found, big.mark = big.mark, decimal.mark = decimal.mark) if (p_found_total != p_found_scope) { msg_txt <- paste0("=> Found ", font_bold(paste0(n_found, " first ", weighted.notice, "isolates")), diff --git a/R/guess_ab_col.R b/R/guess_ab_col.R index 526205273..55256e2d5 100755 --- a/R/guess_ab_col.R +++ b/R/guess_ab_col.R @@ -172,7 +172,7 @@ get_column_abx <- function(x, # sort on name x <- x[order(names(x), x)] - duplicates <- c(x[base::duplicated(x)], x[base::duplicated(names(x))]) + duplicates <- c(x[duplicated(x)], x[duplicated(names(x))]) duplicates <- duplicates[unique(names(duplicates))] x <- c(x[!names(x) %in% names(duplicates)], duplicates) x <- x[order(names(x), x)] diff --git a/R/kurtosis.R b/R/kurtosis.R index a50fadd80..542423427 100755 --- a/R/kurtosis.R +++ b/R/kurtosis.R @@ -42,20 +42,20 @@ kurtosis.default <- function(x, na.rm = FALSE) { x <- x[!is.na(x)] } n <- length(x) - n * base::sum((x - base::mean(x, na.rm = na.rm))^4, na.rm = na.rm) / - (base::sum((x - base::mean(x, na.rm = na.rm))^2, na.rm = na.rm)^2) + n * sum((x - mean(x, na.rm = na.rm))^4, na.rm = na.rm) / + (sum((x - mean(x, na.rm = na.rm))^2, na.rm = na.rm)^2) } #' @method kurtosis matrix #' @rdname kurtosis #' @export kurtosis.matrix <- function(x, na.rm = FALSE) { - base::apply(x, 2, kurtosis.default, na.rm = na.rm) + apply(x, 2, kurtosis.default, na.rm = na.rm) } #' @method kurtosis data.frame #' @rdname kurtosis #' @export kurtosis.data.frame <- function(x, na.rm = FALSE) { - base::sapply(x, kurtosis.default, na.rm = na.rm) + sapply(x, kurtosis.default, na.rm = na.rm) } diff --git a/R/like.R b/R/like.R index daf4b9d99..de95aaff0 100755 --- a/R/like.R +++ b/R/like.R @@ -32,14 +32,14 @@ #' @export #' @details #' The `%like%` function: -#' * Is case insensitive (use `%like_case%` for case-sensitive matching) +#' * Is case-insensitive (use `%like_case%` for case-sensitive matching) #' * Supports multiple patterns #' * Checks if `pattern` is a regular expression and sets `fixed = TRUE` if not, to greatly improve speed #' * Tries again with `perl = TRUE` if regex fails #' #' Using RStudio? This function can also be inserted from the Addins menu and can have its own Keyboard Shortcut like `Ctrl+Shift+L` or `Cmd+Shift+L` (see `Tools` > `Modify Keyboard Shortcuts...`). #' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/master/R/like.R) -#' @seealso [base::grep()] +#' @seealso [grep()] #' @inheritSection AMR Read more on our website! #' @examples #' # simple test @@ -71,13 +71,25 @@ like <- function(x, pattern, ignore.case = TRUE) { pattern <- tolower(pattern) } + if (length(pattern) > 1 & length(x) == 1) { + x <- rep(x, length(pattern)) + } + if (length(pattern) > 1) { + res <- vector(length = length(pattern)) if (length(x) != length(pattern)) { if (length(x) == 1) { x <- rep(x, length(pattern)) } # return TRUE for every 'x' that matches any 'pattern', FALSE otherwise - res <- sapply(pattern, function(pttrn) base::grepl(pttrn, x, ignore.case = FALSE, fixed = fixed)) + for (i in seq_len(length(res))) { + if (is.factor(x[i])) { + res[i] <- as.integer(x[i]) %in% grep(pattern[i], levels(x[i]), ignore.case = FALSE, fixed = fixed) + } else { + res[i] <- grepl(pattern[i], x[i], ignore.case = FALSE, fixed = fixed) + } + } + res <- sapply(pattern, function(pttrn) grepl(pttrn, x, ignore.case = FALSE, fixed = fixed)) res2 <- as.logical(rowSums(res)) # get only first item of every hit in pattern res2[duplicated(res)] <- FALSE @@ -85,12 +97,11 @@ like <- function(x, pattern, ignore.case = TRUE) { return(res2) } else { # x and pattern are of same length, so items with each other - res <- vector(length = length(pattern)) for (i in seq_len(length(res))) { if (is.factor(x[i])) { - res[i] <- as.integer(x[i]) %in% base::grep(pattern[i], levels(x[i]), ignore.case = FALSE, fixed = fixed) + res[i] <- as.integer(x[i]) %in% grep(pattern[i], levels(x[i]), ignore.case = FALSE, fixed = fixed) } else { - res[i] <- base::grepl(pattern[i], x[i], ignore.case = FALSE, fixed = fixed) + res[i] <- grepl(pattern[i], x[i], ignore.case = FALSE, fixed = fixed) } } return(res) @@ -99,13 +110,13 @@ like <- function(x, pattern, ignore.case = TRUE) { # the regular way how grepl works; just one pattern against one or more x if (is.factor(x)) { - as.integer(x) %in% base::grep(pattern, levels(x), ignore.case = FALSE, fixed = fixed) + as.integer(x) %in% grep(pattern, levels(x), ignore.case = FALSE, fixed = fixed) } else { - tryCatch(base::grepl(pattern, x, ignore.case = FALSE, fixed = fixed), + tryCatch(grepl(pattern, x, ignore.case = FALSE, fixed = fixed), error = function(e) { if (grepl("invalid reg(ular )?exp", e$message, ignore.case = TRUE)) { # try with perl = TRUE: - return(base::grepl(pattern = pattern, + return(grepl(pattern = pattern, x = x, ignore.case = FALSE, fixed = fixed, diff --git a/R/mdro.R b/R/mdro.R index 6ee9162f8..ffdb01856 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -728,10 +728,10 @@ mdro <- function(x, } # not enough classes available - x[which(x$MDRO %in% c(1, 3) & x$classes_available < base::floor(x$classes_in_guideline * pct_required_classes)), "MDRO"] <- -1 + x[which(x$MDRO %in% c(1, 3) & x$classes_available < floor(x$classes_in_guideline * pct_required_classes)), "MDRO"] <- -1 if (verbose == TRUE) { x[which(x$MDRO == -1), "reason"] <- paste0("not enough classes available: ", x$classes_available[which(x$MDRO == -1)], - " of required ", (base::floor(x$classes_in_guideline * pct_required_classes))[which(x$MDRO == -1)], + " of required ", (floor(x$classes_in_guideline * pct_required_classes))[which(x$MDRO == -1)], " (~", percentage(pct_required_classes), " of ", x$classes_in_guideline[which(x$MDRO == -1)], ")") } diff --git a/R/mic.R b/R/mic.R index 1118c5e58..79e571b43 100755 --- a/R/mic.R +++ b/R/mic.R @@ -19,9 +19,9 @@ # Visit our website for more info: https://msberends.github.io/AMR. # # ==================================================================== # -#' Class 'mic' +#' Transform input to minimum inhibitory concentrations #' -#' This transforms a vector to a new class [`mic`], which is an ordered [`factor`] with valid MIC values as levels. Invalid MIC values will be translated as `NA` with a warning. +#' This transforms a vector to a new class [`mic`], which is an ordered [`factor`] with valid minimum inhibitory concentrations (MIC) as levels. Invalid MIC values will be translated as `NA` with a warning. #' @inheritSection lifecycle Stable lifecycle #' @rdname as.mic #' @param x vector diff --git a/R/mo.R b/R/mo.R index 3af0e7055..6ed7543dd 100755 --- a/R/mo.R +++ b/R/mo.R @@ -19,7 +19,7 @@ # Visit our website for more info: https://msberends.github.io/AMR. # # ==================================================================== # -#' Transform to microorganism ID +#' Transform input to a microorganism ID #' #' Use this function to determine a valid microorganism ID ([`mo`]). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like `"Staphylococcus aureus"`), an abbreviated name (like `"S. aureus"`), an abbreviation known in the field (like `"MRSA"`), or just a genus. Please see *Examples*. #' @inheritSection lifecycle Stable lifecycle @@ -32,6 +32,7 @@ #' This excludes *Enterococci* at default (who are in group D), use `Lancefield = "all"` to also categorise all *Enterococci* as group D. #' @param allow_uncertain a number between `0` (or `"none"`) and `3` (or `"all"`), or `TRUE` (= `2`) or `FALSE` (= `0`) to indicate whether the input should be checked for less probable results, please see *Details* #' @param reference_df a [`data.frame`] to be used for extra reference when translating `x` to a valid [`mo`]. See [set_mo_source()] and [get_mo_source()] to automate the usage of your own codes (e.g. used in your analysis or organisation). +#' @param ignore_pattern a regular expression (case-insensitive) of which all matches in `x` must return `NA`. This can be convenient to exclude known non-relevant input and can also be set with the option `AMR_ignore_pattern`, e.g. `options(AMR_ignore_pattern = "(not reported|contaminated flora)")`. #' @param ... other parameters passed on to functions #' @rdname as.mo #' @aliases mo @@ -39,7 +40,7 @@ #' @details #' ## General info #' -#' A microorganism ID from this package (class: [`mo`]) typically looks like these examples: +#' A microorganism ID from this package (class: [`mo`]) is human readable and typically looks like these examples: #' ``` #' Code Full name #' --------------- -------------------------------------- @@ -48,10 +49,10 @@ #' B_KLBSL_PNMN_RHNS Klebsiella pneumoniae rhinoscleromatis #' | | | | #' | | | | -#' | | | ---> subspecies, a 4-5 letter acronym -#' | | ----> species, a 4-5 letter acronym -#' | ----> genus, a 5-7 letter acronym -#' ----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria), +#' | | | \---> subspecies, a 4-5 letter acronym +#' | | \----> species, a 4-5 letter acronym +#' | \----> genus, a 5-7 letter acronym +#' \----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria), #' C (Chromista), F (Fungi), P (Protozoa) #' ``` #' @@ -172,7 +173,8 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, - reference_df = get_mo_source(), + reference_df = get_mo_source(), + ignore_pattern = getOption("AMR_ignore_pattern"), ...) { check_dataset_integrity() @@ -181,10 +183,12 @@ as.mo <- function(x, x <- parse_and_convert(x) # replace mo codes used in older package versions x <- replace_old_mo_codes(x, property = "mo") + # ignore cases that match the ignore pattern + x <- replace_ignore_pattern(x, ignore_pattern) # 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 + # Laboratory systems: remove entries like "no growth", etc. x[trimws2(x) %like% "(no .*growth|keine? .*wachtstum|geen .*groei|no .*crecimientonon|sem .*crescimento|pas .*croissance)"] <- NA_character_ x[trimws2(x) %like% "^(no|not|kein|geen|niet|non|sem) [a-z]+"] <- "UNKNOWN" @@ -226,6 +230,7 @@ as.mo <- function(x, y <- mo_validate(x = x, property = "mo", Becker = Becker, Lancefield = Lancefield, allow_uncertain = uncertainty_level, reference_df = reference_df, + ignore_pattern = ignore_pattern, ...) } @@ -257,6 +262,7 @@ exec_as.mo <- function(x, initial_search = TRUE, dyslexia_mode = FALSE, debug = FALSE, + ignore_pattern = getOption("AMR_ignore_pattern"), reference_data_to_use = MO_lookup) { check_dataset_integrity() @@ -294,6 +300,8 @@ exec_as.mo <- function(x, x <- parse_and_convert(x) # replace mo codes used in older package versions x <- replace_old_mo_codes(x, property) + # ignore cases that match the ignore pattern + x <- replace_ignore_pattern(x, ignore_pattern) # WHONET: xxx = no growth x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ @@ -360,37 +368,31 @@ exec_as.mo <- function(x, # all in reference df colnames(reference_df)[1] <- "x" suppressWarnings( - x <- data.frame(x = x, stringsAsFactors = FALSE) %>% - left_join(reference_df, by = "x") %>% - left_join(microorganisms, by = "mo") %>% - pull(property) + x <- MO_lookup[match(reference_df[match(x, reference_df$x), "mo", drop = TRUE], MO_lookup$mo), property, drop = TRUE] ) } else if (all(x %in% reference_data_to_use$mo)) { - x <- data.frame(mo = x, stringsAsFactors = FALSE) %>% - left_join_microorganisms(by = "mo") %>% - pull(property) + x <- MO_lookup[match(x, MO_lookup$mo), property, drop = TRUE] } else if (all(tolower(x) %in% reference_data_to_use$fullname_lower)) { # we need special treatment for very prevalent full names, they are likely! # e.g. as.mo("Staphylococcus aureus") - x <- data.frame(fullname_lower = tolower(x), stringsAsFactors = FALSE) %>% - left_join_MO_lookup(by = "fullname_lower") %>% - pull(property) - + x <- MO_lookup[match(tolower(x), MO_lookup$fullname_lower), property, drop = TRUE] + } else if (all(x %in% reference_data_to_use$fullname)) { # we need special treatment for very prevalent full names, they are likely! # e.g. as.mo("Staphylococcus aureus") - x <- data.frame(fullname = x, stringsAsFactors = FALSE) %>% - left_join_MO_lookup(by = "fullname") %>% - pull(property) + x <- MO_lookup[match(x, MO_lookup$fullname), property, drop = TRUE] } else if (all(toupper(x) %in% microorganisms.codes$code)) { # commonly used MO codes - x <- data.frame(code = toupper(x), stringsAsFactors = FALSE) %>% - left_join(microorganisms.codes, by = "code") %>% - left_join_MO_lookup(by = "mo") %>% - pull(property) + x <- MO_lookup[match(microorganisms.codes[match(toupper(x), + microorganisms.codes$code), + "mo", + drop = TRUE], + MO_lookup$mo), + property, + drop = TRUE] } else if (!all(x %in% microorganisms[, property])) { @@ -1466,7 +1468,7 @@ exec_as.mo <- function(x, df_input <- data.frame(input = as.character(x_input), stringsAsFactors = FALSE) - # super fast using base::match() which is a lot faster than base::merge() + # super fast using match() which is a lot faster than merge() x <- df_found$found[match(df_input$input, df_found$input)] if (property == "mo") { @@ -1800,11 +1802,11 @@ levenshtein_fraction <- function(input, output) { levenshtein <- double(length = length(input)) for (i in seq_len(length(input))) { # determine Levenshtein distance, but maximise to nchar of output - levenshtein[i] <- base::min(base::as.double(utils::adist(input[i], output[i], ignore.case = TRUE)), - base::nchar(output[i])) + levenshtein[i] <- min(as.double(utils::adist(input[i], output[i], ignore.case = TRUE)), + nchar(output[i])) } # self-made score between 0 and 1 (for % certainty, so 0 means huge distance, 1 means no distance) - (base::nchar(output) - 0.5 * levenshtein) / nchar(output) + (nchar(output) - 0.5 * levenshtein) / nchar(output) } trimws2 <- function(x) { @@ -1850,6 +1852,19 @@ replace_old_mo_codes <- function(x, property) { x } +replace_ignore_pattern <- function(x, ignore_pattern) { + if (!is.null(ignore_pattern) && !identical(trimws2(ignore_pattern), "")) { + ignore_cases <- x %like% ignore_pattern + if (sum(ignore_cases) > 0) { + message(font_blue(paste0("NOTE: the following input was ignored by `ignore_pattern = \"", ignore_pattern, "\"`: ", + paste0("'", sort(unique(x[x %like% ignore_pattern])), "'", collapse = ", "), + collapse = ", "))) + x[x %like% ignore_pattern] <- NA_character_ + } + } + 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 bae87e835..c40e99df3 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -19,14 +19,14 @@ # Visit our website for more info: https://msberends.github.io/AMR. # # ==================================================================== # -#' Property of a microorganism +#' Get properties of a microorganism #' -#' Use these functions to return a specific property of a microorganism. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. Please see *Examples*. +#' Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. Please see *Examples*. #' @inheritSection lifecycle Stable lifecycle #' @param x any (vector of) text that can be coerced to a valid microorganism code with [as.mo()] #' @param property one of the column names of the [microorganisms] data set or `"shortname"` -#' @param language language of the returned text, defaults to system language (see [get_locale()]) and can also be set with `getOption("AMR_locale")`. Use `language = NULL` or `language = ""` to prevent translation. -#' @param ... other parameters passed on to [as.mo()] +#' @param language language of the returned text, defaults to system language (see [get_locale()]) and can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`, see [translate]. Use `language = NULL` or `language = ""` to prevent translation. +#' @param ... other parameters passed on to [as.mo()], such as 'allow_uncertain' and 'ignore_pattern' #' @param open browse the URL using [utils::browseURL()] #' @details All functions will return the most recently known taxonomic property according to the Catalogue of Life, except for [mo_ref()], [mo_authors()] and [mo_year()]. Please refer to this example, knowing that *Escherichia blattae* was renamed to *Shimwellia blattae* in 2010: #' - `mo_name("Escherichia blattae")` will return `"Shimwellia blattae"` (with a message about the renaming) @@ -309,7 +309,7 @@ mo_taxonomy <- function(x, language = get_locale(), ...) { x <- as.mo(x, ...) metadata <- get_mo_failures_uncertainties_renamed() - result <- base::list(kingdom = mo_kingdom(x, language = language), + result <- list(kingdom = mo_kingdom(x, language = language), phylum = mo_phylum(x, language = language), class = mo_class(x, language = language), order = mo_order(x, language = language), @@ -414,6 +414,11 @@ mo_validate <- function(x, property, ...) { check_dataset_integrity() + if (tryCatch(all(x %in% MO_lookup$mo) & length(list(...)) == 0, error = function(e) FALSE)) { + # special case for mo_* functions where class is already + return(MO_lookup[match(x, MO_lookup$mo), property, drop = TRUE]) + } + dots <- list(...) Becker <- dots$Becker if (is.null(Becker)) { diff --git a/R/mo_source.R b/R/mo_source.R index fc16819c1..e9582e3d8 100644 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -112,6 +112,7 @@ set_mo_source <- function(path) { file_location <- path.expand("~/mo_source.rds") + stop_ifnot(interactive(), "This function can only be used in interactive mode, since it must ask for the user's permission to write a file to their home folder.") stop_ifnot(length(path) == 1, "`path` must be of length 1") if (is.null(path) || path %in% c(FALSE, "")) { @@ -176,6 +177,19 @@ set_mo_source <- function(path) { action <- "Updated" } else { action <- "Created" + # only ask when file is created, not when it is updated + txt <- paste0("This will write create the new file '", + file_location, + "', for which your permission is needed.\n\nDo you agree that this file will be created? ") + if ("rsasdtudioapi" %in% rownames(utils::installed.packages())) { + showQuestion <- import_fn("showQuestion", "rstudioapi") + q_continue <- showQuestion("Create new file in home directory", txt) + } else { + q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt) + } + if (q_continue %in% c(FALSE, 2)) { + return(invisible()) + } } saveRDS(df, file_location) options(mo_source = path) diff --git a/R/rsi.R b/R/rsi.R index 2698a445e..549fad89f 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -19,7 +19,7 @@ # Visit our website for more info: https://msberends.github.io/AMR. # # ==================================================================== # -#' Class 'rsi' +#' Interpret MIC and disk, or clean raw R/SI data #' #' Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class [`rsi`], which is an ordered factor with levels `S < I < R`. Values that cannot be interpreted will be returned as `NA` with a warning. #' @inheritSection lifecycle Stable lifecycle diff --git a/R/rsi_calc.R b/R/rsi_calc.R index 7136fd1a0..e7089016a 100755 --- a/R/rsi_calc.R +++ b/R/rsi_calc.R @@ -45,7 +45,7 @@ rsi_calc <- function(..., dots_df <- as.data.frame(dots_df, stringsAsFactors = FALSE) } - dots <- base::eval(base::substitute(base::alist(...))) + dots <- eval(substitute(alist(...))) stop_if(length(dots) == 0, "no variables selected", call = -2) stop_if("also_single_tested" %in% names(dots), @@ -118,12 +118,12 @@ rsi_calc <- function(..., # no NAs in any column y <- apply(X = as.data.frame(lapply(x, as.integer), stringsAsFactors = FALSE), MARGIN = 1, - FUN = base::min) + FUN = min) numerator <- sum(as.integer(y) %in% as.integer(ab_result), na.rm = TRUE) denominator <- sum(sapply(x_transposed, function(y) !(any(is.na(y))))) } else { # may contain NAs in any column - other_values <- base::setdiff(c(NA, levels(ab_result)), ab_result) + other_values <- setdiff(c(NA, levels(ab_result)), ab_result) numerator <- sum(sapply(x_transposed, function(y) any(y %in% ab_result, na.rm = TRUE))) denominator <- sum(sapply(x_transposed, function(y) !(all(y %in% other_values) & any(is.na(y))))) } diff --git a/R/skewness.R b/R/skewness.R index aea1e6aa1..78b50cb92 100755 --- a/R/skewness.R +++ b/R/skewness.R @@ -44,19 +44,19 @@ skewness.default <- function(x, na.rm = FALSE) { x <- x[!is.na(x)] } n <- length(x) - (base::sum((x - base::mean(x))^3) / n) / (base::sum((x - base::mean(x)) ^ 2) / n) ^ (3 / 2) + (sum((x - mean(x))^3) / n) / (sum((x - mean(x)) ^ 2) / n) ^ (3 / 2) } #' @method skewness matrix #' @rdname skewness #' @export skewness.matrix <- function(x, na.rm = FALSE) { - base::apply(x, 2, skewness.default, na.rm = na.rm) + apply(x, 2, skewness.default, na.rm = na.rm) } #' @method skewness data.frame #' @rdname skewness #' @export skewness.data.frame <- function(x, na.rm = FALSE) { - base::sapply(x, skewness.default, na.rm = na.rm) + sapply(x, skewness.default, na.rm = na.rm) } diff --git a/R/sysdata.rda b/R/sysdata.rda index 539ecb67d..2d2f2c6da 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/translate.R b/R/translate.R index fe9f282d2..ca1d255d1 100755 --- a/R/translate.R +++ b/R/translate.R @@ -23,15 +23,13 @@ #' #' For language-dependent output of AMR functions, like [mo_name()], [mo_gramstain()], [mo_type()] and [ab_name()]. #' @inheritSection lifecycle Stable lifecycle -#' @details Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: . +#' @details Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: . This file will be read by all functions where a translated output can be desired, like all [mo_property()] functions ([mo_name()], [mo_gramstain()], [mo_type()], etc.). #' -#' Currently supported languages are (besides English): `r paste(sort(gsub(";.*", "", ISOcodes::ISO_639_2[which(ISOcodes::ISO_639_2$Alpha_2 %in% unique(AMR:::translations_file$lang)), "Name"])), collapse = ", ")`. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names. +#' Currently supported languages are: `r paste(sort(gsub(";.*", "", ISOcodes::ISO_639_2[which(ISOcodes::ISO_639_2$Alpha_2 %in% LANGUAGES_SUPPORTED), "Name"])), collapse = ", ")`. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names. #' #' Please suggest your own translations [by creating a new issue on our repository](https://github.com/msberends/AMR/issues/new?title=Translations). #' -#' This file will be read by all functions where a translated output can be desired, like all [mo_property()] functions ([mo_name()], [mo_gramstain()], [mo_type()], etc.). -#' -#' The system language will be used at default, if that language is supported. The system language can be overwritten with `Sys.setenv(AMR_locale = yourlanguage)`. +#' The system language will be used at default (as returned by [Sys.getlocale()]), if that language is supported. The language to be used can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`. #' @inheritSection AMR Read more on our website! #' @rdname translate #' @name translate @@ -66,10 +64,16 @@ #' #> "Staphylococcus coagulase negativo (CoNS)" get_locale <- function() { if (!is.null(getOption("AMR_locale", default = NULL))) { - return(getOption("AMR_locale")) + if (!language %in% LANGUAGES_SUPPORTED) { + stop_("unsupported language: '", language, "' - use one of: ", + paste0("'", LANGUAGES_SUPPORTED, "'", collapse = ", "), + call = FALSE) + } else { + return(getOption("AMR_locale")) + } } - lang <- Sys.getlocale("LC_COLLATE") + lang <- Sys.getlocale() # Check the locale settings for a start with one of these languages: @@ -107,10 +111,13 @@ translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE) { } df_trans <- translations_file # internal data file + from.bak <- from + from_unique <- unique(from) + from_unique_translated <- from_unique - stop_ifnot(language %in% df_trans$lang, + stop_ifnot(language %in% LANGUAGES_SUPPORTED, "unsupported language: '", language, "' - use one of: ", - paste0("'", sort(unique(df_trans$lang)), "'", collapse = ", "), + paste0("'", LANGUAGES_SUPPORTED, "'", collapse = ", "), call = FALSE) df_trans <- subset(df_trans, lang == language) @@ -124,7 +131,7 @@ translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE) { df_trans$fixed[is.na(df_trans$fixed)] <- TRUE # check if text to look for is in one of the patterns - any_form_in_patterns <- tryCatch(any(from %like% paste0("(", paste(df_trans$pattern, collapse = "|"), ")")), + any_form_in_patterns <- tryCatch(any(from_unique %like% paste0("(", paste(df_trans$pattern, collapse = "|"), ")")), error = function(e) { warning("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).", call. = FALSE) return(FALSE) @@ -133,15 +140,16 @@ translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE) { return(from) } - for (i in seq_len(nrow(df_trans))) { - from <- gsub(x = from, - pattern = df_trans$pattern[i], - replacement = df_trans$replacement[i], - fixed = df_trans$fixed[i], - ignore.case = df_trans$ignore.case[i]) - } + lapply(seq_len(nrow(df_trans)), + function(i) from_unique_translated <<- gsub(pattern = df_trans$pattern[i], + replacement = df_trans$replacement[i], + x = from_unique_translated, + ignore.case = df_trans$ignore.case[i], + fixed = df_trans$fixed[i])) # force UTF-8 for diacritics - base::enc2utf8(from) - + from_unique_translated <- enc2utf8(from_unique_translated) + + # a kind of left join to get all results back + from_unique_translated[match(from.bak, from_unique)] } diff --git a/R/zzz.R b/R/zzz.R index 49375558f..3538a6ee9 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -28,6 +28,10 @@ value = create_MO.old_lookup(), envir = asNamespace("AMR")) + assign(x = "LANGUAGES_SUPPORTED", + value = sort(c("en", unique(AMR:::translations_file$lang))), + envir = asNamespace("AMR")) + # support for tibble headers (type_sum) and tibble columns content (pillar_shaft) # without the need to depend on other packages s3_register("pillar::pillar_shaft", "ab") diff --git a/_pkgdown.yml b/_pkgdown.yml index b45e0394f..e12196033 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -44,7 +44,7 @@ navbar: - text: "Predict antimicrobial resistance" icon: "fa-dice" href: "articles/resistance_predict.html" - - text: "Download our reference data sets for own use" + - text: "Data sets for download / own use" icon: "fa-database" href: "articles/datasets.html" - text: "Conduct principal component analysis for AMR" @@ -64,10 +64,10 @@ navbar: href: "articles/EUCAST.html" - text: "Get properties of a microorganism" icon: "fa-bug" - href: "reference/mo_property.html" # reference instead of article + href: "reference/mo_property.html" # reference instead of an article - text: "Get properties of an antibiotic" icon: "fa-capsules" - href: "reference/ab_property.html" # reference instead of article + href: "reference/ab_property.html" # reference instead of an article - text: "Other: benchmarks" icon: "fa-shipping-fast" href: "articles/benchmarks.html" @@ -89,67 +89,7 @@ navbar: href: "survey.html" reference: - - title: "Cleaning your data" - desc: > - Functions for cleaning and optimising your data, to be able to add - variables later on (like taxonomic properties) or to fix and extend - antibiotic interpretations by applying [EUCAST rules](http://www.eucast.org/expert_rules_and_intrinsic_resistance/). - contents: - - starts_with("as.") - - "`eucast_rules`" - - "`ab_from_text`" - - "`guess_ab_col`" - - "`mo_source`" - - title: "Enhancing your data" - desc: > - Functions to add new data to your existing data, such as the determination - of first isolates, multi-drug resistant microorganisms (MDRO), getting - properties of microorganisms or antibiotics and determining the age of - patients or divide ages into age groups. - contents: - - "`ab_property`" - - "`age_groups`" - - "`age`" - - "`atc_online_property`" - - "`first_isolate`" - - "`join`" - - "`key_antibiotics`" - - "`mdro`" - - "`mo_property`" - - "`p_symbol`" - - title: "Analysing your data" - desc: > - Functions for conducting AMR analysis, like counting isolates, calculating - resistance or susceptibility, or make plots. - contents: - - "`proportion`" - - "`count`" - - "`availability`" - - "`bug_drug_combinations`" - - "`resistance_predict`" - - "`pca`" - - "`antibiotic_class_selectors`" - - "`filter_ab_class`" - - "`g.test`" - - "`ggplot_rsi`" - - "`ggplot_pca`" - - "`kurtosis`" - - "`skewness`" - - title: "Included data sets" - desc: > - Scientifically reliable references for microorganisms and - antibiotics, and example data sets to use for practise. - contents: - - "`microorganisms`" - - "`antibiotics`" - - "`intrinsic_resistant`" - - "`example_isolates`" - - "`example_isolates_unclean`" - - "`rsi_translation`" - - "`microorganisms.codes`" - - "`microorganisms.old`" - - "`WHONET`" - - title: "Background information" + - title: "Background information on included data" desc: > Some pages about our package and its external sources. Be sure to read our [How To's](./../articles/index.html) for more information about how to work with functions in this package. @@ -159,7 +99,66 @@ reference: - "`catalogue_of_life_version`" - "`WHOCC`" - "`lifecycle`" - - title: "Other functions" + - "`microorganisms`" + - "`antibiotics`" + - "`intrinsic_resistant`" + - "`example_isolates`" + - "`example_isolates_unclean`" + - "`rsi_translation`" + - "`microorganisms.codes`" + - "`microorganisms.old`" + - "`WHONET`" + + - title: "Preparing data: microorganisms" + desc: > + These functions are meant to get taxonomically valid properties of microorganisms from any input. + Use `mo_source()` to teach this package how to translate your own codes to valid microorganism codes. + contents: + - "`as.mo`" + - "`mo_property`" + - "`mo_source`" + + - title: "Preparing data: antibiotics" + desc: > + Use these functions to get valid properties of antibiotics from any input or to clean your input. + You can even retrieve drug names and doses from clinical text records, using `ab_from_text()`. + contents: + - "`as.ab`" + - "`ab_property`" + - "`ab_from_text`" + - "`atc_online_property`" + + - title: "Preparing data: antimicrobial resistance" + desc: > + With `as.mic()` and `as.disk()` you can transform your raw input to valid MIC or disk diffusion values. + Use `as.rsi()` for cleaning raw data to let it only contain "R", "I" and "S", or to interpret MIC or disk diffusion values as R/SI based on the lastest EUCAST and CLSI guidelines. + Afterwards, you can extend antibiotic interpretations by applying [EUCAST rules](http://www.eucast.org/expert_rules_and_intrinsic_resistance/) with `eucast_rules()`. + contents: + - "`as.rsi`" + - "`as.mic`" + - "`as.disk`" + - "`eucast_rules`" + + - title: "Analysing data: antimicrobial resistance" + desc: > + Use these function for the analysis part. You can use `susceptibility()` or `resistance()` on any antibiotic column. + Be sure to first select the isolates that are appropiate for analysis, by using `first_isolate()`. + You can also filter your data on certain resistance in certain antibiotic classes (`filter_ab_class()`), or determine multi-drug resistant microorganisms (MDRO, `mdro()`). + contents: + - "`proportion`" + - "`count`" + - "`first_isolate`" + - "`key_antibiotics`" + - "`mdro`" + - "`count`" + - "`ggplot_rsi`" + - "`bug_drug_combinations`" + - "`antibiotic_class_selectors`" + - "`filter_ab_class`" + - "`resistance_predict`" + - "`guess_ab_col`" + + - title: "Other: miscellaneous functions" desc: > These functions are mostly for internal use, but some of them may also be suitable for your analysis. Especially the @@ -167,7 +166,23 @@ reference: contents: - "`get_locale`" - "`like`" - - title: "Deprecated functions" + - "`age_groups`" + - "`age`" + - "`join`" + - "`availability`" + - "`pca`" + - "`ggplot_pca`" + + - title: "Other: statistical tests" + desc: > + Some statistical tests or methods are not part of base R and are added to this package for convenience. + contents: + - "`g.test`" + - "`kurtosis`" + - "`skewness`" + - "`p_symbol`" + + - title: "Other: deprecated functions" desc: > These functions are deprecated, meaning that they will still work but show a warning with every use and will be removed diff --git a/data-raw/antibiotics.dta b/data-raw/antibiotics.dta index 3ffbf63c5..edfa549c9 100644 Binary files a/data-raw/antibiotics.dta and b/data-raw/antibiotics.dta differ diff --git a/data-raw/antibiotics.sas b/data-raw/antibiotics.sas index a405b1982..a98869dab 100644 Binary files a/data-raw/antibiotics.sas and b/data-raw/antibiotics.sas differ diff --git a/data-raw/antibiotics.sav b/data-raw/antibiotics.sav index aad6ac180..e29f56b7d 100644 Binary files a/data-raw/antibiotics.sav and b/data-raw/antibiotics.sav differ diff --git a/data-raw/antibiotics.xlsx b/data-raw/antibiotics.xlsx index 33c412098..b18c74b1f 100644 Binary files a/data-raw/antibiotics.xlsx and b/data-raw/antibiotics.xlsx differ diff --git a/data-raw/antivirals.dta b/data-raw/antivirals.dta index db7e983e8..9f845af02 100644 Binary files a/data-raw/antivirals.dta and b/data-raw/antivirals.dta differ diff --git a/data-raw/antivirals.sas b/data-raw/antivirals.sas index c2d525f92..3e24b2392 100644 Binary files a/data-raw/antivirals.sas and b/data-raw/antivirals.sas differ diff --git a/data-raw/antivirals.sav b/data-raw/antivirals.sav index f4fe0270c..dd824013f 100644 Binary files a/data-raw/antivirals.sav and b/data-raw/antivirals.sav differ diff --git a/data-raw/antivirals.xlsx b/data-raw/antivirals.xlsx index 0d884f5c3..e5586625d 100644 Binary files a/data-raw/antivirals.xlsx and b/data-raw/antivirals.xlsx differ diff --git a/data-raw/intrinsic_resistant.dta b/data-raw/intrinsic_resistant.dta index 85da97fef..1949b6596 100644 Binary files a/data-raw/intrinsic_resistant.dta and b/data-raw/intrinsic_resistant.dta differ diff --git a/data-raw/intrinsic_resistant.sas b/data-raw/intrinsic_resistant.sas index 197444e02..c2c8bed20 100644 Binary files a/data-raw/intrinsic_resistant.sas and b/data-raw/intrinsic_resistant.sas differ diff --git a/data-raw/intrinsic_resistant.sav b/data-raw/intrinsic_resistant.sav index 5ba9cd9fd..82221c5ba 100644 Binary files a/data-raw/intrinsic_resistant.sav and b/data-raw/intrinsic_resistant.sav differ diff --git a/data-raw/intrinsic_resistant.xlsx b/data-raw/intrinsic_resistant.xlsx index 47a2485cd..8432e2220 100644 Binary files a/data-raw/intrinsic_resistant.xlsx and b/data-raw/intrinsic_resistant.xlsx differ diff --git a/data-raw/microorganisms.dta b/data-raw/microorganisms.dta index 196da5364..7c9723b8a 100644 Binary files a/data-raw/microorganisms.dta and b/data-raw/microorganisms.dta differ diff --git a/data-raw/microorganisms.old.dta b/data-raw/microorganisms.old.dta index 74bc9b860..0b8658b63 100644 Binary files a/data-raw/microorganisms.old.dta and b/data-raw/microorganisms.old.dta differ diff --git a/data-raw/microorganisms.old.sas b/data-raw/microorganisms.old.sas index 55ddd0cc5..c03417d5f 100644 Binary files a/data-raw/microorganisms.old.sas and b/data-raw/microorganisms.old.sas differ diff --git a/data-raw/microorganisms.old.sav b/data-raw/microorganisms.old.sav index 6db067463..4b40d83b6 100644 Binary files a/data-raw/microorganisms.old.sav and b/data-raw/microorganisms.old.sav differ diff --git a/data-raw/microorganisms.old.xlsx b/data-raw/microorganisms.old.xlsx index 85de98ed3..211c56c2f 100644 Binary files a/data-raw/microorganisms.old.xlsx and b/data-raw/microorganisms.old.xlsx differ diff --git a/data-raw/microorganisms.sas b/data-raw/microorganisms.sas index ee1e251fb..10fdb0752 100644 Binary files a/data-raw/microorganisms.sas and b/data-raw/microorganisms.sas differ diff --git a/data-raw/microorganisms.sav b/data-raw/microorganisms.sav index 080c4041d..c7ff63dd4 100644 Binary files a/data-raw/microorganisms.sav and b/data-raw/microorganisms.sav differ diff --git a/data-raw/microorganisms.xlsx b/data-raw/microorganisms.xlsx index 7199ea8e2..05ffcdd7d 100644 Binary files a/data-raw/microorganisms.xlsx and b/data-raw/microorganisms.xlsx differ diff --git a/data-raw/reproduction_of_microorganisms.R b/data-raw/reproduction_of_microorganisms.R index 764dcf4d8..fc9e92ab5 100644 --- a/data-raw/reproduction_of_microorganisms.R +++ b/data-raw/reproduction_of_microorganisms.R @@ -955,11 +955,10 @@ microorganisms <- microorganisms %>% class(microorganisms$mo) <- c("mo", "character") microorganisms.old <- microorganisms.old %>% filter(fullname != "Mycobacterium tuberculosis") -usethis::use_data(microorganisms, overwrite = TRUE, version = 2) +usethis::use_data(microorganisms, overwrite = TRUE, version = 2, compress = "xz") usethis::use_data(microorganisms.old, overwrite = TRUE, version = 2) - # OLD CODE ---------------------------------------------------------------- # to keep all the old IDs: diff --git a/data-raw/rsi_translation.dta b/data-raw/rsi_translation.dta index ca7be2381..7a25f8ae4 100644 Binary files a/data-raw/rsi_translation.dta and b/data-raw/rsi_translation.dta differ diff --git a/data-raw/rsi_translation.sas b/data-raw/rsi_translation.sas index c750bd3a9..9921ba93a 100644 Binary files a/data-raw/rsi_translation.sas and b/data-raw/rsi_translation.sas differ diff --git a/data-raw/rsi_translation.sav b/data-raw/rsi_translation.sav index acdbe5b38..2e48a4cf1 100644 Binary files a/data-raw/rsi_translation.sav and b/data-raw/rsi_translation.sav differ diff --git a/data-raw/rsi_translation.xlsx b/data-raw/rsi_translation.xlsx index a0324d42b..426c29ce8 100644 Binary files a/data-raw/rsi_translation.xlsx and b/data-raw/rsi_translation.xlsx differ diff --git a/data-raw/translations.tsv b/data-raw/translations.tsv index d0a9aa459..b533a956f 100644 --- a/data-raw/translations.tsv +++ b/data-raw/translations.tsv @@ -26,6 +26,8 @@ de biotype Biotyp FALSE FALSE de vegetative vegetativ FALSE FALSE de ([([ ]*?)group \\1Gruppe FALSE FALSE de ([([ ]*?)Group \\1Gruppe FALSE FALSE +de no .*growth keine? .*wachstum FALSE TRUE + nl Coagulase-negative Staphylococcus Coagulase-negatieve Staphylococcus FALSE FALSE nl Coagulase-positive Staphylococcus Coagulase-positieve Staphylococcus FALSE FALSE nl Beta-haemolytic Streptococcus Beta-hemolytische Streptococcus FALSE FALSE @@ -56,6 +58,7 @@ nl antibiotic antibioticum FALSE FALSE nl Antibiotic Antibioticum FALSE FALSE nl Drug Middel FALSE FALSE nl drug middel FALSE FALSE + es Coagulase-negative Staphylococcus Staphylococcus coagulasa negativo FALSE FALSE es Coagulase-positive Staphylococcus Staphylococcus coagulasa positivo FALSE FALSE es Beta-haemolytic Streptococcus Streptococcus Beta-hemolítico FALSE FALSE @@ -83,6 +86,7 @@ es biotype biotipo FALSE FALSE es vegetative vegetativo FALSE FALSE es ([([ ]*?)group \\1grupo FALSE FALSE es ([([ ]*?)Group \\1Grupo FALSE FALSE + it Coagulase-negative Staphylococcus Staphylococcus negativo coagulasi FALSE FALSE it Coagulase-positive Staphylococcus Staphylococcus positivo coagulasi FALSE FALSE it Beta-haemolytic Streptococcus Streptococcus Beta-emolitico FALSE FALSE @@ -108,6 +112,7 @@ it biotype biotipo FALSE FALSE it vegetative vegetativo FALSE FALSE it ([([ ]*?)group \\1gruppo FALSE FALSE it ([([ ]*?)Group \\1Gruppo FALSE FALSE + fr Coagulase-negative Staphylococcus Staphylococcus à coagulase négative FALSE FALSE fr Coagulase-positive Staphylococcus Staphylococcus à coagulase positif FALSE FALSE fr Beta-haemolytic Streptococcus Streptococcus Bêta-hémolytique FALSE FALSE @@ -132,6 +137,7 @@ fr biogroup biogroupe FALSE FALSE fr vegetative végétatif FALSE FALSE fr ([([ ]*?)group \\1groupe FALSE FALSE fr ([([ ]*?)Group \\1Groupe FALSE FALSE + pt Coagulase-negative Staphylococcus Staphylococcus coagulase negativo FALSE FALSE pt Coagulase-positive Staphylococcus Staphylococcus coagulase positivo FALSE FALSE pt Beta-haemolytic Streptococcus Streptococcus Beta-hemolítico FALSE FALSE diff --git a/data/microorganisms.rda b/data/microorganisms.rda index fa170c1b9..cd87a16f3 100644 Binary files a/data/microorganisms.rda and b/data/microorganisms.rda differ diff --git a/docs/404.html b/docs/404.html index 94de964b7..e84e4f016 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9013 + 1.3.0.9014 @@ -121,7 +121,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 9ec10afe1..a3cde3adf 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9013 + 1.3.0.9014 @@ -121,7 +121,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index acf508e75..e58082982 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.3.0.9012 + 1.3.0.9014 @@ -79,7 +79,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -210,8 +210,8 @@ If you are reading this page from within R, please Microorganisms (currently accepted names)

    A data set with 67,151 rows and 16 columns, containing the following column names:
    ‘mo’, ‘fullname’, ‘kingdom’, ‘phylum’, ‘class’, ‘order’, ‘family’, ‘genus’, ‘species’, ‘subspecies’, ‘rank’, ‘ref’, ‘species_id’, ‘source’, ‘prevalence’, ‘snomed’.

    This data set is in R available as microorganisms, after you load the AMR package.

    -

    It was last updated on 28 July 2020 20:52:40 CEST. Find more info about the structure of this data set here.

    -

    Direct download links:

    +

    It was last updated on 1 September 2020 11:07:11 CEST. Find more info about the structure of this data set here.

    +

    Direct download links:

    Source

    @@ -417,7 +417,7 @@ If you are reading this page from within R, please here.

    -

    Direct download links:

    +

    Direct download links:

    Source

    @@ -469,7 +469,7 @@ If you are reading this page from within R, please here.

    -

    Direct download links:

    +

    Direct download links:

    Source

    @@ -623,8 +623,8 @@ If you are reading this page from within R, please Antiviral agents

    A data set with 102 rows and 9 columns, containing the following column names:
    ‘atc’, ‘cid’, ‘name’, ‘atc_group’, ‘synonyms’, ‘oral_ddd’, ‘oral_units’, ‘iv_ddd’, ‘iv_units’.

    This data set is in R available as antivirals, after you load the AMR package.

    -

    It was last updated on 29 August 2020 21:36:44 CEST. Find more info about the structure of this data set here.

    -

    Direct download links:

    +

    It was last updated on 29 August 2020 21:53:07 CEST. Find more info about the structure of this data set here.

    +

    Direct download links:

    Source

    @@ -738,7 +738,7 @@ If you are reading this page from within R, please here.

    -

    Direct download links:

    +

    Direct download links:

    Source

    @@ -840,7 +840,7 @@ If you are reading this page from within R, please here.

    -

    Direct download links:

    +

    Direct download links:

    Source

    diff --git a/docs/articles/index.html b/docs/articles/index.html index 18b077add..de06fcab0 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9013 + 1.3.0.9014
    @@ -121,7 +121,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • diff --git a/docs/authors.html b/docs/authors.html index c09537f1f..ac61e7867 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9013 + 1.3.0.9014 @@ -121,7 +121,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • diff --git a/docs/extra.css b/docs/extra.css index 214d451bb..5e507034a 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -276,8 +276,9 @@ table a:not(.btn):hover, .table a:not(.btn):hover { display: none; } .dataset-download-button { - margin-right: 10px; + margin-right: 2%; } .dataset-download-button img { - height: 100px !important; + width: 80px !important; + max-width: 14% !important; } diff --git a/docs/index.html b/docs/index.html index f7a002650..b8a54c9dc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.3.0.9013 + 1.3.0.9014 @@ -83,7 +83,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • diff --git a/docs/news/index.html b/docs/news/index.html index 71b4d12ee..2d25331f9 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9013 + 1.3.0.9014 @@ -121,7 +121,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -236,14 +236,15 @@ Source: NEWS.md -
    -

    -AMR 1.3.0.9013 Unreleased +
    +

    +AMR 1.3.0.9014 Unreleased

    -
    +

    -Last updated: 29 August 2020 +Last updated: 3 September 2020

    +

    Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly!

    New

    @@ -267,6 +268,7 @@

    Changed

      +
    • Although advertised that this package should work under R 3.0.0, we still had a dependency on R 3.6.0. This is fixed, meaning that our package should now work under R 3.0.0.

    • Improvements for as.rsi():

        @@ -294,6 +296,14 @@ #> [1] 24 24

  • +
  • +

    Improvements for as.mo():

    +
      +
    • Big speed improvement for already valid microorganism ID. This also means an significant speed improvement for using mo_* functions like mo_name() on microoganism IDs.
    • +
    • Added parameter ignore_pattern to as.mo() which can also be given to mo_* functions like mo_name(), to exclude known non-relevant input from analysing. This can also be set with the option AMR_ignore_pattern.
    • +
    +
  • +
  • get_locale() now uses Sys.getlocale() instead of Sys.getlocale("LC_COLLATE")

  • Speed improvement for eucast_rules()

  • Overall speed improvement by tweaking joining functions

  • Function mo_shortname() now returns the genus for input where the species is unknown

  • @@ -302,6 +312,14 @@
  • Names of antiviral agents in data set antivirals now have a starting capital letter, like it is the case in the antibiotics data set

  • +
    +

    +Other

    +
      +
    • Removed unnecessary references to the base package
    • +
    • Added packages that could be useful for some functions to the Suggests field of the DESCRIPTION file
    • +
    +
    @@ -379,9 +397,9 @@
  • Fixed a bug where as.mic() could not handle dots without a leading zero (like "<=.25)

  • -
    +

    -Other

    +Other
    • Moved primary location of this project from GitLab to GitHub, giving us native support for automated syntax checking without being dependent on external services such as AppVeyor and Travis CI.
    @@ -441,9 +459,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Added abbreviation “cfsc” for Cefoxitin and “cfav” for Ceftazidime/avibactam
  • -
    +

    -Other

    +Other
    • Removed previously deprecated function p.symbol() - it was replaced with p_symbol()
    • @@ -483,9 +501,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • Added generic CLSI rules for R/SI interpretation using as.rsi() for years 2010-2019 (thanks to Anthony Underwood)
    -
    +

    -Other

    +Other
    • Support for the upcoming dplyr version 1.0.0
    • More robust assigning for classes rsi and mic @@ -587,9 +605,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    -
    +

    -Other

    +Other
    • Add a CITATION file
    • Full support for the upcoming R 4.0
    • @@ -695,9 +713,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    -
    +

    -Other

    +Other
    • Rewrote the complete documentation to markdown format, to be able to use the very latest version of the great Roxygen2, released in November 2019. This tremously improved the documentation quality, since the rewrite forced us to go over all texts again and make changes where needed.
    • Change dependency on clean to cleaner, as this package was renamed accordingly upon CRAN request
    • @@ -861,9 +879,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • Added more MIC factor levels (as.mic())
    -
    +

    -Other

    +Other
    • Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors
    • Cleaned the coding style of every single syntax line in this package with the help of the lintr package
    • @@ -948,9 +966,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    -
    +

    -Other

    +Other
    • Fixed a note thrown by CRAN tests
    @@ -1044,9 +1062,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Fix for mo_shortname() where species would not be determined correctly
  • -
    +

    -Other

    +Other
    • Support for R 3.6.0 and later by providing support for staged install
    • @@ -1311,9 +1329,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • if using different lengths of pattern and x in %like%, it will now return the call
    -
    +

    -Other

    +Other
    • Updated licence text to emphasise GPL 2.0 and that this is an R package.
    @@ -1433,9 +1451,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Percentages will now will rounded more logically (e.g. in freq function)

  • -
    +

    -Other

    +Other
    • New dependency on package crayon, to support formatted text in the console
    • Dependency tidyr is now mandatory (went to Import field) since portion_df and count_df rely on it
    • @@ -1584,9 +1602,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    -
    +

    -Other

    +Other
    • More unit tests to ensure better integrity of functions
    @@ -1713,9 +1731,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Other small fixes
  • -
    +

    -Other

    +Other
    • Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher
        @@ -1775,9 +1793,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
      • Functions as.rsi and as.mic now add the package name and version as attributes
    -
    +

    -Other

    +Other
    • Expanded README.md with more examples
    • Added ORCID of authors to DESCRIPTION file
    • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 3f4415e83..edc9c0193 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 2.7.3 pkgdown: 1.5.1.9000 pkgdown_sha: eae56f08694abebf93cdfc0dd8e9ede06d8c815f articles: [] -last_built: 2020-08-29T19:52Z +last_built: 2020-09-03T10:29Z urls: reference: https://msberends.github.io/AMR/reference article: https://msberends.github.io/AMR/articles diff --git a/docs/reference/WHONET.html b/docs/reference/WHONET.html index a2ba65932..2e3b7599e 100644 --- a/docs/reference/WHONET.html +++ b/docs/reference/WHONET.html @@ -49,7 +49,7 @@ - + @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9007 + 1.3.0.9014
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -239,7 +239,7 @@
  • -

    This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our example_isolates data set.

    +

    This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The antibiotic results are based on our example_isolates data set. All patient names are created using online surname generators and are only in place for practice purposes.

    WHONET
    @@ -253,10 +253,10 @@
  • Organism
    Name of the microorganism. Before analysis, you should transform this to a valid microbial class, using as.mo().

  • Country
    Country of origin

  • Laboratory
    Name of laboratory

  • -
  • Last name
    Last name of patient

  • -
  • First name
    Initial of patient

  • -
  • Sex
    Gender of patient

  • -
  • Age
    Age of patient

  • +
  • Last name
    Fictitious last name of patient

  • +
  • First name
    Fictitious initial of patient

  • +
  • Sex
    Fictitious gender of patient

  • +
  • Age
    Fictitious age of patient

  • Age category
    Age group, can also be looked up using age_groups()

  • Date of admission
    Date of hospital admission

  • Specimen date
    Date when specimen was received at laboratory

  • diff --git a/docs/reference/ab_property.html b/docs/reference/ab_property.html index f7012182f..90ff7ad0b 100644 --- a/docs/reference/ab_property.html +++ b/docs/reference/ab_property.html @@ -6,7 +6,7 @@ -Property of an antibiotic — ab_property • AMR (for R) +Get properties of an antibiotic — ab_property • AMR (for R) @@ -48,7 +48,7 @@ - + @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9007 + 1.3.0.9014
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -233,7 +233,7 @@
    diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html index 8e0b035d4..d8d5d3c7e 100644 --- a/docs/reference/as.ab.html +++ b/docs/reference/as.ab.html @@ -6,7 +6,7 @@ -Transform to antibiotic ID — as.ab • AMR (for R) +Transform input to an antibiotic ID — as.ab • AMR (for R) @@ -48,7 +48,7 @@ - + @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9007 + 1.3.0.9014
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -233,7 +233,7 @@
    diff --git a/docs/reference/as.disk.html b/docs/reference/as.disk.html index 38174ce7d..37799bf1f 100644 --- a/docs/reference/as.disk.html +++ b/docs/reference/as.disk.html @@ -6,7 +6,7 @@ -Class 'disk' — as.disk • AMR (for R) +Transform input to disk diffusion diameters — as.disk • AMR (for R) @@ -48,8 +48,8 @@ - - + + @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9006 + 1.3.0.9014
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -233,13 +233,13 @@
    -

    This transforms a vector to a new class disk, which is a growth zone size (around an antibiotic disk) in millimetres between 6 and 50.

    +

    This transforms a vector to a new class disk, which is a disk diffusion growth zone size (around an antibiotic disk) in millimetres between 6 and 50.

    as.disk(x, na.rm = FALSE)
    diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html
    index 5c3280a50..80eeff941 100644
    --- a/docs/reference/as.mic.html
    +++ b/docs/reference/as.mic.html
    @@ -6,7 +6,7 @@
     
     
     
    -Class 'mic' — as.mic • AMR (for R)
    +Transform input to minimum inhibitory concentrations — as.mic • AMR (for R)
     
     
     
    @@ -48,8 +48,8 @@
       
       
     
    -
    -
    +
    +
     
     
     
    @@ -82,7 +82,7 @@
           
           
             AMR (for R)
    -        1.3.0.9006
    +        1.3.0.9014
           
         
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -233,13 +233,13 @@
    -

    This transforms a vector to a new class mic, which is an ordered factor with valid MIC values as levels. Invalid MIC values will be translated as NA with a warning.

    +

    This transforms a vector to a new class mic, which is an ordered factor with valid minimum inhibitory concentrations (MIC) as levels. Invalid MIC values will be translated as NA with a warning.

    as.mic(x, na.rm = FALSE)
    diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html
    index 8b167a169..9d9a4a1ff 100644
    --- a/docs/reference/as.mo.html
    +++ b/docs/reference/as.mo.html
    @@ -6,7 +6,7 @@
     
     
     
    -Transform to microorganism ID — as.mo • AMR (for R)
    +Transform input to a microorganism ID — as.mo • AMR (for R)
     
     
     
    @@ -48,7 +48,7 @@
       
       
     
    -
    +
     
     
     
    @@ -82,7 +82,7 @@
           
           
             AMR (for R)
    -        1.3.0.9010
    +        1.3.0.9014
           
         
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -233,7 +233,7 @@
    @@ -248,6 +248,7 @@ Lancefield = FALSE, allow_uncertain = TRUE, reference_df = get_mo_source(), + ignore_pattern = getOption("AMR_ignore_pattern"), ... ) @@ -284,6 +285,10 @@ reference_df

    a data.frame to be used for extra reference when translating x to a valid mo. See set_mo_source() and get_mo_source() to automate the usage of your own codes (e.g. used in your analysis or organisation).

    + + ignore_pattern +

    a regular expression (case-insensitive) of which all matches in x must return NA. This can be convenient to exclude known non-relevant input and can also be set with the option AMR_ignore_pattern, e.g. options(AMR_ignore_pattern = "(not reported|contaminated flora)").

    + ...

    other parameters passed on to functions

    @@ -299,17 +304,17 @@

    General info

    -

    A microorganism ID from this package (class: mo) typically looks like these examples:

      Code               Full name
    +

    A microorganism ID from this package (class: mo) is human readable and typically looks like these examples:

      Code               Full name
       ---------------    --------------------------------------
       B_KLBSL            Klebsiella
       B_KLBSL_PNMN       Klebsiella pneumoniae
       B_KLBSL_PNMN_RHNS  Klebsiella pneumoniae rhinoscleromatis
       |   |    |    |
       |   |    |    |
    -  |   |    |     ---> subspecies, a 4-5 letter acronym
    -  |   |     ----> species, a 4-5 letter acronym
    -  |    ----> genus, a 5-7 letter acronym
    -   ----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
    +  |   |    |    \---> subspecies, a 4-5 letter acronym
    +  |   |    \----> species, a 4-5 letter acronym
    +  |   \----> genus, a 5-7 letter acronym
    +  \----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
                                 C (Chromista), F (Fungi), P (Protozoa)
     
    diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index f40dcb3e4..f66af5681 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -6,7 +6,7 @@ -Class 'rsi' — as.rsi • AMR (for R) +Interpret MIC and disk, or clean raw R/SI data — as.rsi • AMR (for R) @@ -48,7 +48,7 @@ - + @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9007 + 1.3.0.9014
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -233,7 +233,7 @@
    diff --git a/docs/reference/atc_online.html b/docs/reference/atc_online.html index 8a7f02cd5..30d420031 100644 --- a/docs/reference/atc_online.html +++ b/docs/reference/atc_online.html @@ -49,8 +49,7 @@ - + @@ -83,7 +82,7 @@ This function requires an internet connection." /> AMR (for R) - 1.3.0.9006 + 1.3.0.9014
    @@ -123,7 +122,7 @@ This function requires an internet connection." /> - Download our reference data sets for own use + Data sets for download / own use
  • @@ -241,7 +240,6 @@ This function requires an internet connection." />

    Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit.

    -

    This function requires an internet connection.

    atc_online_property(
    @@ -309,12 +307,14 @@ This function requires an internet connection." />
     
  • "ml" = milliliter (e.g. eyedrops)

  • -

    Questioning lifecycle

    +

    N.B. This function requires an internet connection and only works if the following packages are installed: curl, rvest, xml2.

    +

    Stable lifecycle

    -


    -The lifecycle of this function is questioning. This function might be no longer be optimal approach, or is it questionable whether this function should be in this AMR package at all.

    +


    +The lifecycle of this function is stable. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.

    +

    If the unlying code needs breaking changes, they will occur gradually. For example, a parameter will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.

    Read more on our website!

    diff --git a/docs/reference/bug_drug_combinations.html b/docs/reference/bug_drug_combinations.html index 60bdbea37..b1126fcc7 100644 --- a/docs/reference/bug_drug_combinations.html +++ b/docs/reference/bug_drug_combinations.html @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9010 + 1.3.0.9014
  • @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -328,7 +328,6 @@

    Details

    The function format() calculates the resistance per bug-drug combination. Use combine_IR = FALSE (default) to test R vs. S+I and combine_IR = TRUE to test R+I vs. S.

    -

    The language of the output can be overwritten with options(AMR_locale), please see translate.

    Stable lifecycle

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 3bba9997d..7d43708b3 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9013 + 1.3.0.9014
  • @@ -121,7 +121,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -246,8 +246,8 @@ -

    Cleaning your data

    -

    Functions for cleaning and optimising your data, to be able to add variables later on (like taxonomic properties) or to fix and extend antibiotic interpretations by applying EUCAST rules.

    +

    Background information on included data

    +

    Some pages about our package and its external sources. Be sure to read our How To’s for more information about how to work with functions in this package.

    @@ -258,236 +258,35 @@ -

    as.ab() is.ab()

    +

    AMR

    -

    Transform to antibiotic ID

    +

    The AMR Package

    -

    as.disk() is.disk()

    +

    catalogue_of_life

    -

    Class 'disk'

    +

    The Catalogue of Life

    -

    as.mic() is.mic()

    +

    catalogue_of_life_version()

    -

    Class 'mic'

    +

    Version info of included Catalogue of Life

    -

    as.mo() is.mo() mo_failures() mo_uncertainties() mo_renamed()

    +

    WHOCC

    -

    Transform to microorganism ID

    +

    WHOCC: WHO Collaborating Centre for Drug Statistics Methodology

    -

    as.rsi() is.rsi() is.rsi.eligible()

    +

    lifecycle

    -

    Class 'rsi'

    +

    Lifecycles of functions in the AMR package

    - -

    eucast_rules()

    - -

    Apply EUCAST rules

    - - - -

    ab_from_text()

    - -

    Retrieve antimicrobial drug names and doses from clinical text

    - - - -

    guess_ab_col()

    - -

    Guess antibiotic column

    - - - -

    set_mo_source() get_mo_source()

    - -

    User-defined reference data set for microorganisms

    - - - - -

    Enhancing your data

    -

    Functions to add new data to your existing data, such as the determination of first isolates, multi-drug resistant microorganisms (MDRO), getting properties of microorganisms or antibiotics and determining the age of patients or divide ages into age groups.

    - - - - - - - - - - -

    ab_name() ab_atc() ab_cid() ab_synonyms() ab_tradenames() ab_group() ab_atc_group1() ab_atc_group2() ab_loinc() ab_ddd() ab_info() ab_url() ab_property()

    - -

    Property of an antibiotic

    - - - -

    age_groups()

    - -

    Split ages into age groups

    - - - -

    age()

    - -

    Age in years of individuals

    - - - -

    atc_online_property() atc_online_groups() atc_online_ddd()

    - -

    Get ATC properties from WHOCC website

    - - - -

    first_isolate() filter_first_isolate() filter_first_weighted_isolate()

    - -

    Determine first (weighted) isolates

    - - - -

    inner_join_microorganisms() left_join_microorganisms() right_join_microorganisms() full_join_microorganisms() semi_join_microorganisms() anti_join_microorganisms()

    - -

    Join microorganisms to a data set

    - - - -

    key_antibiotics() key_antibiotics_equal()

    - -

    Key antibiotics for first weighted isolates

    - - - -

    mdro() brmo() mrgn() mdr_tb() mdr_cmi2012() eucast_exceptional_phenotypes()

    - -

    Determine multidrug-resistant organisms (MDRO)

    - - - -

    mo_name() mo_fullname() mo_shortname() mo_subspecies() mo_species() mo_genus() mo_family() mo_order() mo_class() mo_phylum() mo_kingdom() mo_domain() mo_type() mo_gramstain() mo_snomed() mo_ref() mo_authors() mo_year() mo_rank() mo_taxonomy() mo_synonyms() mo_info() mo_url() mo_property()

    - -

    Property of a microorganism

    - - - -

    p_symbol()

    - -

    Symbol of a p-value

    - - - - -

    Analysing your data

    -

    Functions for conducting AMR analysis, like counting isolates, calculating resistance or susceptibility, or make plots.

    - - - - - - - - - - -

    resistance() susceptibility() proportion_R() proportion_IR() proportion_I() proportion_SI() proportion_S() proportion_df() rsi_df()

    - -

    Calculate microbial resistance

    - - - -

    count_resistant() count_susceptible() count_R() count_IR() count_I() count_SI() count_S() count_all() n_rsi() count_df()

    - -

    Count available isolates

    - - - -

    availability()

    - -

    Check availability of columns

    - - - -

    bug_drug_combinations() format(<bug_drug_combinations>)

    - -

    Determine bug-drug combinations

    - - - -

    resistance_predict() rsi_predict() plot(<resistance_predict>) ggplot_rsi_predict()

    - -

    Predict antimicrobial resistance

    - - - -

    pca()

    - -

    Principal Component Analysis (for AMR)

    - - - -

    ab_class() aminoglycosides() carbapenems() cephalosporins() cephalosporins_1st() cephalosporins_2nd() cephalosporins_3rd() cephalosporins_4th() cephalosporins_5th() fluoroquinolones() glycopeptides() macrolides() penicillins() tetracyclines()

    - -

    Antibiotic class selectors

    - - - -

    filter_ab_class() filter_aminoglycosides() filter_carbapenems() filter_cephalosporins() filter_1st_cephalosporins() filter_2nd_cephalosporins() filter_3rd_cephalosporins() filter_4th_cephalosporins() filter_5th_cephalosporins() filter_fluoroquinolones() filter_glycopeptides() filter_macrolides() filter_penicillins() filter_tetracyclines()

    - -

    Filter isolates on result in antimicrobial class

    - - - -

    g.test()

    - -

    G-test for Count Data

    - - - -

    ggplot_rsi() geom_rsi() facet_rsi() scale_y_percent() scale_rsi_colours() theme_rsi() labels_rsi_count()

    - -

    AMR plots with ggplot2

    - - - -

    ggplot_pca()

    - -

    PCA biplot with ggplot2

    - - - -

    kurtosis()

    - -

    Kurtosis of the sample

    - - - -

    skewness()

    - -

    Skewness of the sample

    - - - - -

    Included data sets

    -

    Scientifically reliable references for microorganisms and antibiotics, and example data sets to use for practise.

    - - - - - - - - -

    microorganisms

    @@ -527,7 +326,7 @@

    microorganisms.codes

    -

    Translation table with 5,583 common microorganism codes

    +

    Data set with 5,583 common microorganism codes

    @@ -544,8 +343,8 @@ -

    Background information

    -

    Some pages about our package and its external sources. Be sure to read our How To’s for more information about how to work with functions in this package.

    +

    Preparing data: microorganisms

    +

    These functions are meant to get taxonomically valid properties of microorganisms from any input. Use mo_source() to teach this package how to translate your own codes to valid microorganism codes.

    @@ -556,38 +355,179 @@ -

    AMR

    +

    as.mo() is.mo() mo_failures() mo_uncertainties() mo_renamed()

    -

    The AMR Package

    +

    Transform input to a microorganism ID

    -

    catalogue_of_life

    +

    mo_name() mo_fullname() mo_shortname() mo_subspecies() mo_species() mo_genus() mo_family() mo_order() mo_class() mo_phylum() mo_kingdom() mo_domain() mo_type() mo_gramstain() mo_snomed() mo_ref() mo_authors() mo_year() mo_rank() mo_taxonomy() mo_synonyms() mo_info() mo_url() mo_property()

    -

    The Catalogue of Life

    +

    Get properties of a microorganism

    -

    catalogue_of_life_version()

    +

    set_mo_source() get_mo_source()

    -

    Version info of included Catalogue of Life

    - - - -

    WHOCC

    - -

    WHOCC: WHO Collaborating Centre for Drug Statistics Methodology

    - - - -

    lifecycle

    - -

    Lifecycles of functions in the AMR package

    +

    User-defined reference data set for microorganisms

    -

    Other functions

    +

    Preparing data: antibiotics

    +

    Use these functions to get valid properties of antibiotics from any input or to clean your input. You can even retrieve drug names and doses from clinical text records, using ab_from_text().

    + + + + + + + + + + +

    as.ab() is.ab()

    + +

    Transform input to an antibiotic ID

    + + + +

    ab_name() ab_atc() ab_cid() ab_synonyms() ab_tradenames() ab_group() ab_atc_group1() ab_atc_group2() ab_loinc() ab_ddd() ab_info() ab_url() ab_property()

    + +

    Get properties of an antibiotic

    + + + +

    ab_from_text()

    + +

    Retrieve antimicrobial drug names and doses from clinical text

    + + + +

    atc_online_property() atc_online_groups() atc_online_ddd()

    + +

    Get ATC properties from WHOCC website

    + + + + +

    Preparing data: antimicrobial resistance

    +

    With as.mic() and as.disk() you can transform your raw input to valid MIC or disk diffusion values. Use as.rsi() for cleaning raw data to let it only contain “R”, “I” and “S”, or to interpret MIC or disk diffusion values as R/SI based on the lastest EUCAST and CLSI guidelines. Afterwards, you can extend antibiotic interpretations by applying EUCAST rules with eucast_rules().

    + + + + + + + + + + +

    as.rsi() is.rsi() is.rsi.eligible()

    + +

    Interpret MIC and disk, or clean raw R/SI data

    + + + +

    as.mic() is.mic()

    + +

    Transform input to minimum inhibitory concentrations

    + + + +

    as.disk() is.disk()

    + +

    Transform input to disk diffusion diameters

    + + + +

    eucast_rules()

    + +

    Apply EUCAST rules

    + + + + +

    Analysing data: antimicrobial resistance

    +

    Use these function for the analysis part. You can use susceptibility() or resistance() on any antibiotic column. Be sure to first select the isolates that are appropiate for analysis, by using first_isolate(). You can also filter your data on certain resistance in certain antibiotic classes (filter_ab_class()), or determine multi-drug resistant microorganisms (MDRO, mdro()).

    + + + + + + + + + + +

    resistance() susceptibility() proportion_R() proportion_IR() proportion_I() proportion_SI() proportion_S() proportion_df() rsi_df()

    + +

    Calculate microbial resistance

    + + + +

    count_resistant() count_susceptible() count_R() count_IR() count_I() count_SI() count_S() count_all() n_rsi() count_df()

    + +

    Count available isolates

    + + + +

    first_isolate() filter_first_isolate() filter_first_weighted_isolate()

    + +

    Determine first (weighted) isolates

    + + + +

    key_antibiotics() key_antibiotics_equal()

    + +

    Key antibiotics for first weighted isolates

    + + + +

    mdro() brmo() mrgn() mdr_tb() mdr_cmi2012() eucast_exceptional_phenotypes()

    + +

    Determine multidrug-resistant organisms (MDRO)

    + + + +

    ggplot_rsi() geom_rsi() facet_rsi() scale_y_percent() scale_rsi_colours() theme_rsi() labels_rsi_count()

    + +

    AMR plots with ggplot2

    + + + +

    bug_drug_combinations() format(<bug_drug_combinations>)

    + +

    Determine bug-drug combinations

    + + + +

    ab_class() aminoglycosides() carbapenems() cephalosporins() cephalosporins_1st() cephalosporins_2nd() cephalosporins_3rd() cephalosporins_4th() cephalosporins_5th() fluoroquinolones() glycopeptides() macrolides() penicillins() tetracyclines()

    + +

    Antibiotic class selectors

    + + + +

    filter_ab_class() filter_aminoglycosides() filter_carbapenems() filter_cephalosporins() filter_1st_cephalosporins() filter_2nd_cephalosporins() filter_3rd_cephalosporins() filter_4th_cephalosporins() filter_5th_cephalosporins() filter_fluoroquinolones() filter_glycopeptides() filter_macrolides() filter_penicillins() filter_tetracyclines()

    + +

    Filter isolates on result in antimicrobial class

    + + + +

    resistance_predict() rsi_predict() plot(<resistance_predict>) ggplot_rsi_predict()

    + +

    Predict antimicrobial resistance

    + + + +

    guess_ab_col()

    + +

    Guess antibiotic column

    + + + + +

    Other: miscellaneous functions

    These functions are mostly for internal use, but some of them may also be suitable for your analysis. Especially the ‘like’ function can be useful: if (x %like% y) {...}.

    @@ -608,11 +548,84 @@

    like() `%like%` `%like_case%`

    Pattern Matching

    + + + +

    age_groups()

    + +

    Split ages into age groups

    + + + +

    age()

    + +

    Age in years of individuals

    + + + +

    inner_join_microorganisms() left_join_microorganisms() right_join_microorganisms() full_join_microorganisms() semi_join_microorganisms() anti_join_microorganisms()

    + +

    Join microorganisms to a data set

    + + + +

    availability()

    + +

    Check availability of columns

    + + + +

    pca()

    + +

    Principal Component Analysis (for AMR)

    + + + +

    ggplot_pca()

    + +

    PCA biplot with ggplot2

    -

    Deprecated functions

    +

    Other: statistical tests

    +

    Some statistical tests or methods are not part of base R and are added to this package for convenience.

    + + + + + + + + + + +

    g.test()

    + +

    G-test for Count Data

    + + + +

    kurtosis()

    + +

    Kurtosis of the sample

    + + + +

    skewness()

    + +

    Skewness of the sample

    + + + +

    p_symbol()

    + +

    Symbol of a p-value

    + + + + +

    Other: deprecated functions

    These functions are deprecated, meaning that they will still work but show a warning with every use and will be removed in a future version.

    diff --git a/docs/reference/like.html b/docs/reference/like.html index 17a95d4af..6da492e39 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9006 + 1.3.0.9014
  • @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -274,7 +274,7 @@

    Details

    The %like% function:

      -
    • Is case insensitive (use %like_case% for case-sensitive matching)

    • +
    • Is case-insensitive (use %like_case% for case-sensitive matching)

    • Supports multiple patterns

    • Checks if pattern is a regular expression and sets fixed = TRUE if not, to greatly improve speed

    • Tries again with perl = TRUE if regex fails

    • @@ -295,7 +295,7 @@ The lifecycle of this function is stableOn our website https://msberends.github.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

      See also

      - +

      Examples

      # simple test
      diff --git a/docs/reference/microorganisms.codes.html b/docs/reference/microorganisms.codes.html
      index 1d5be99c4..ba2f5b8d9 100644
      --- a/docs/reference/microorganisms.codes.html
      +++ b/docs/reference/microorganisms.codes.html
      @@ -6,7 +6,7 @@
       
       
       
      -Translation table with 5,583 common microorganism codes — microorganisms.codes • AMR (for R)
      +Data set with 5,583 common microorganism codes — microorganisms.codes • AMR (for R)
       
       
       
      @@ -48,7 +48,7 @@
         
         
       
      -
      +
       
       
       
      @@ -82,7 +82,7 @@
             
             
               AMR (for R)
      -        1.3.0.9010
      +        1.3.0.9014
             
           
  • @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -233,7 +233,7 @@
    diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index 8b9b175f4..d9de47176 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -6,7 +6,7 @@ -Property of a microorganism — mo_property • AMR (for R) +Get properties of a microorganism — mo_property • AMR (for R) @@ -48,8 +48,8 @@ - - + + @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9007 + 1.3.0.9014
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -233,13 +233,13 @@
    -

    Use these functions to return a specific property of a microorganism. All input values will be evaluated internally with as.mo(), which makes it possible to use microbial abbreviations, codes and names as input. Please see Examples.

    +

    Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with as.mo(), which makes it possible to use microbial abbreviations, codes and names as input. Please see Examples.

    mo_name(x, language = get_locale(), ...)
    @@ -299,11 +299,11 @@
         
         
           language
    -      

    language of the returned text, defaults to system language (see get_locale()) and can also be set with getOption("AMR_locale"). Use language = NULL or language = "" to prevent translation.

    +

    language of the returned text, defaults to system language (see get_locale()) and can be overwritten by setting the option AMR_locale, e.g. options(AMR_locale = "de"), see translate. Use language = NULL or language = "" to prevent translation.

    ... -

    other parameters passed on to as.mo()

    +

    other parameters passed on to as.mo(), such as 'allow_uncertain' and 'ignore_pattern'

    open diff --git a/docs/reference/translate.html b/docs/reference/translate.html index 90457980f..40195b029 100644 --- a/docs/reference/translate.html +++ b/docs/reference/translate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.3.0.9006 + 1.3.0.9014
    @@ -122,7 +122,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • @@ -247,11 +247,10 @@

    Details

    -

    Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: https://github.com/msberends/AMR/blob/master/data-raw/translations.tsv.

    -

    Currently supported languages are (besides English): Dutch, French, German, Italian, Portuguese, Spanish. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names.

    +

    Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: https://github.com/msberends/AMR/blob/master/data-raw/translations.tsv. This file will be read by all functions where a translated output can be desired, like all mo_property() functions (mo_name(), mo_gramstain(), mo_type(), etc.).

    +

    Currently supported languages are: Dutch, English, French, German, Italian, Portuguese, Spanish. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names.

    Please suggest your own translations by creating a new issue on our repository.

    -

    This file will be read by all functions where a translated output can be desired, like all mo_property() functions (mo_name(), mo_gramstain(), mo_type(), etc.).

    -

    The system language will be used at default, if that language is supported. The system language can be overwritten with Sys.setenv(AMR_locale = yourlanguage).

    +

    The system language will be used at default (as returned by Sys.getlocale()), if that language is supported. The language to be used can be overwritten by setting the option AMR_locale, e.g. options(AMR_locale = "de").

    Stable lifecycle

    diff --git a/docs/survey.html b/docs/survey.html index 928f14e0d..252145a7f 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9013 + 1.3.0.9014
  • @@ -121,7 +121,7 @@ - Download our reference data sets for own use + Data sets for download / own use
  • diff --git a/man/WHONET.Rd b/man/WHONET.Rd index c8c03740f..ebd34b803 100644 --- a/man/WHONET.Rd +++ b/man/WHONET.Rd @@ -12,10 +12,10 @@ A \code{\link{data.frame}} with 500 observations and 53 variables: \item \code{Organism}\cr Name of the microorganism. Before analysis, you should transform this to a valid microbial class, using \code{\link[=as.mo]{as.mo()}}. \item \code{Country}\cr Country of origin \item \code{Laboratory}\cr Name of laboratory -\item \verb{Last name}\cr Last name of patient -\item \verb{First name}\cr Initial of patient -\item \code{Sex}\cr Gender of patient -\item \code{Age}\cr Age of patient +\item \verb{Last name}\cr Fictitious last name of patient +\item \verb{First name}\cr Fictitious initial of patient +\item \code{Sex}\cr Fictitious gender of patient +\item \code{Age}\cr Fictitious age of patient \item \verb{Age category}\cr Age group, can also be looked up using \code{\link[=age_groups]{age_groups()}} \item \verb{Date of admission}\cr Date of hospital admission \item \verb{Specimen date}\cr Date when specimen was received at laboratory @@ -39,7 +39,7 @@ A \code{\link{data.frame}} with 500 observations and 53 variables: WHONET } \description{ -This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our \link{example_isolates} data set. +This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The antibiotic results are based on our \link{example_isolates} data set. All patient names are created using online surname generators and are only in place for practice purposes. } \section{Reference data publicly available}{ diff --git a/man/ab_property.Rd b/man/ab_property.Rd index 19d33c19d..e31194420 100644 --- a/man/ab_property.Rd +++ b/man/ab_property.Rd @@ -15,7 +15,7 @@ \alias{ab_ddd} \alias{ab_info} \alias{ab_url} -\title{Property of an antibiotic} +\title{Get properties of an antibiotic} \usage{ ab_name(x, language = get_locale(), tolower = FALSE, ...) diff --git a/man/as.ab.Rd b/man/as.ab.Rd index f53ff8025..98ef6213b 100644 --- a/man/as.ab.Rd +++ b/man/as.ab.Rd @@ -4,7 +4,7 @@ \alias{as.ab} \alias{ab} \alias{is.ab} -\title{Transform to antibiotic ID} +\title{Transform input to an antibiotic ID} \usage{ as.ab(x, flag_multiple_results = TRUE, info = TRUE, ...) diff --git a/man/as.disk.Rd b/man/as.disk.Rd index f8b349da7..23bc498c4 100644 --- a/man/as.disk.Rd +++ b/man/as.disk.Rd @@ -4,7 +4,7 @@ \alias{as.disk} \alias{disk} \alias{is.disk} -\title{Class 'disk'} +\title{Transform input to disk diffusion diameters} \usage{ as.disk(x, na.rm = FALSE) @@ -19,7 +19,7 @@ is.disk(x) An \code{\link{integer}} with additional new class \code{\link{disk}} } \description{ -This transforms a vector to a new class \code{\link{disk}}, which is a growth zone size (around an antibiotic disk) in millimetres between 6 and 50. +This transforms a vector to a new class \code{\link{disk}}, which is a disk diffusion growth zone size (around an antibiotic disk) in millimetres between 6 and 50. } \details{ Interpret disk values as RSI values with \code{\link[=as.rsi]{as.rsi()}}. It supports guidelines from EUCAST and CLSI. diff --git a/man/as.mic.Rd b/man/as.mic.Rd index 6c648cee9..35a42364a 100755 --- a/man/as.mic.Rd +++ b/man/as.mic.Rd @@ -4,7 +4,7 @@ \alias{as.mic} \alias{mic} \alias{is.mic} -\title{Class 'mic'} +\title{Transform input to minimum inhibitory concentrations} \usage{ as.mic(x, na.rm = FALSE) @@ -19,7 +19,7 @@ is.mic(x) Ordered \code{\link{factor}} with new class \code{\link{mic}} } \description{ -This transforms a vector to a new class \code{\link{mic}}, which is an ordered \code{\link{factor}} with valid MIC values as levels. Invalid MIC values will be translated as \code{NA} with a warning. +This transforms a vector to a new class \code{\link{mic}}, which is an ordered \code{\link{factor}} with valid minimum inhibitory concentrations (MIC) as levels. Invalid MIC values will be translated as \code{NA} with a warning. } \details{ To interpret MIC values as RSI values, use \code{\link[=as.rsi]{as.rsi()}} on MIC values. It supports guidelines from EUCAST and CLSI. diff --git a/man/as.mo.Rd b/man/as.mo.Rd index c39ce545f..9571edbcc 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -7,7 +7,7 @@ \alias{mo_failures} \alias{mo_uncertainties} \alias{mo_renamed} -\title{Transform to microorganism ID} +\title{Transform input to a microorganism ID} \usage{ as.mo( x, @@ -15,6 +15,7 @@ as.mo( Lancefield = FALSE, allow_uncertain = TRUE, reference_df = get_mo_source(), + ignore_pattern = getOption("AMR_ignore_pattern"), ... ) @@ -41,6 +42,8 @@ This excludes \emph{Enterococci} at default (who are in group D), use \code{Lanc \item{reference_df}{a \code{\link{data.frame}} to be used for extra reference when translating \code{x} to a valid \code{\link{mo}}. See \code{\link[=set_mo_source]{set_mo_source()}} and \code{\link[=get_mo_source]{get_mo_source()}} to automate the usage of your own codes (e.g. used in your analysis or organisation).} +\item{ignore_pattern}{a regular expression (case-insensitive) of which all matches in \code{x} must return \code{NA}. This can be convenient to exclude known non-relevant input and can also be set with the option \code{AMR_ignore_pattern}, e.g. \code{options(AMR_ignore_pattern = "(not reported|contaminated flora)")}.} + \item{...}{other parameters passed on to functions} } \value{ @@ -52,17 +55,17 @@ Use this function to determine a valid microorganism ID (\code{\link{mo}}). Dete \details{ \subsection{General info}{ -A microorganism ID from this package (class: \code{\link{mo}}) typically looks like these examples:\preformatted{ Code Full name +A microorganism ID from this package (class: \code{\link{mo}}) is human readable and typically looks like these examples:\preformatted{ Code Full name --------------- -------------------------------------- B_KLBSL Klebsiella B_KLBSL_PNMN Klebsiella pneumoniae B_KLBSL_PNMN_RHNS Klebsiella pneumoniae rhinoscleromatis | | | | | | | | - | | | ---> subspecies, a 4-5 letter acronym - | | ----> species, a 4-5 letter acronym - | ----> genus, a 5-7 letter acronym - ----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria), + | | | \\---> subspecies, a 4-5 letter acronym + | | \\----> species, a 4-5 letter acronym + | \\----> genus, a 5-7 letter acronym + \\----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria), C (Chromista), F (Fungi), P (Protozoa) } diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd index a1d713efb..c65ca610c 100755 --- a/man/as.rsi.Rd +++ b/man/as.rsi.Rd @@ -8,7 +8,7 @@ \alias{as.rsi.mic} \alias{as.rsi.disk} \alias{as.rsi.data.frame} -\title{Class 'rsi'} +\title{Interpret MIC and disk, or clean raw R/SI data} \usage{ as.rsi(x, ...) diff --git a/man/atc_online.Rd b/man/atc_online.Rd index d61944857..2abb65184 100644 --- a/man/atc_online.Rd +++ b/man/atc_online.Rd @@ -33,8 +33,6 @@ atc_online_ddd(atc_code, ...) } \description{ Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit. - -\strong{This function requires an internet connection.} } \details{ Options for parameter \code{administration}: @@ -62,11 +60,15 @@ Abbreviations of return values when using \code{property = "U"} (unit): \item \code{"mmol"} = millimole \item \code{"ml"} = milliliter (e.g. eyedrops) } -} -\section{Questioning lifecycle}{ -\if{html}{\figure{lifecycle_questioning.svg}{options: style=margin-bottom:5px} \cr} -The \link[=lifecycle]{lifecycle} of this function is \strong{questioning}. This function might be no longer be optimal approach, or is it questionable whether this function should be in this \code{AMR} package at all. +\strong{N.B. This function requires an internet connection and only works if the following packages are installed: \code{curl}, \code{rvest}, \code{xml2}.} +} +\section{Stable lifecycle}{ + +\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr} +The \link[=lifecycle]{lifecycle} of this function is \strong{stable}. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided. + +If the unlying code needs breaking changes, they will occur gradually. For example, a parameter will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error. } \section{Read more on our website!}{ diff --git a/man/bug_drug_combinations.Rd b/man/bug_drug_combinations.Rd index 5026d8a05..c504c5472 100644 --- a/man/bug_drug_combinations.Rd +++ b/man/bug_drug_combinations.Rd @@ -62,8 +62,6 @@ Determine antimicrobial resistance (AMR) of all bug-drug combinations in your da } \details{ The function \code{\link[=format]{format()}} calculates the resistance per bug-drug combination. Use \code{combine_IR = FALSE} (default) to test R vs. S+I and \code{combine_IR = TRUE} to test R+I vs. S. - -The language of the output can be overwritten with \code{options(AMR_locale)}, please see \link{translate}. } \section{Stable lifecycle}{ diff --git a/man/like.Rd b/man/like.Rd index ed322c12e..24be196b8 100755 --- a/man/like.Rd +++ b/man/like.Rd @@ -31,7 +31,7 @@ Convenient wrapper around \code{\link[=grep]{grep()}} to match a pattern: \code{ \details{ The \verb{\%like\%} function: \itemize{ -\item Is case insensitive (use \verb{\%like_case\%} for case-sensitive matching) +\item Is case-insensitive (use \verb{\%like_case\%} for case-sensitive matching) \item Supports multiple patterns \item Checks if \code{pattern} is a regular expression and sets \code{fixed = TRUE} if not, to greatly improve speed \item Tries again with \code{perl = TRUE} if regex fails @@ -75,5 +75,5 @@ example_isolates \%>\% } } \seealso{ -\code{\link[base:grep]{base::grep()}} +\code{\link[=grep]{grep()}} } diff --git a/man/microorganisms.codes.Rd b/man/microorganisms.codes.Rd index 5a23c10a5..4ffcce2c6 100644 --- a/man/microorganisms.codes.Rd +++ b/man/microorganisms.codes.Rd @@ -3,7 +3,7 @@ \docType{data} \name{microorganisms.codes} \alias{microorganisms.codes} -\title{Translation table with 5,583 common microorganism codes} +\title{Data set with 5,583 common microorganism codes} \format{ A \code{\link{data.frame}} with 5,583 observations and 2 variables: \itemize{ diff --git a/man/mo_property.Rd b/man/mo_property.Rd index 523071db3..fe7900d5d 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -25,7 +25,7 @@ \alias{mo_synonyms} \alias{mo_info} \alias{mo_url} -\title{Property of a microorganism} +\title{Get properties of a microorganism} \usage{ mo_name(x, language = get_locale(), ...) @@ -78,9 +78,9 @@ mo_property(x, property = "fullname", language = get_locale(), ...) \arguments{ \item{x}{any (vector of) text that can be coerced to a valid microorganism code with \code{\link[=as.mo]{as.mo()}}} -\item{language}{language of the returned text, defaults to system language (see \code{\link[=get_locale]{get_locale()}}) and can also be set with \code{getOption("AMR_locale")}. Use \code{language = NULL} or \code{language = ""} to prevent translation.} +\item{language}{language of the returned text, defaults to system language (see \code{\link[=get_locale]{get_locale()}}) and can be overwritten by setting the option \code{AMR_locale}, e.g. \code{options(AMR_locale = "de")}, see \link{translate}. Use \code{language = NULL} or \code{language = ""} to prevent translation.} -\item{...}{other parameters passed on to \code{\link[=as.mo]{as.mo()}}} +\item{...}{other parameters passed on to \code{\link[=as.mo]{as.mo()}}, such as 'allow_uncertain' and 'ignore_pattern'} \item{open}{browse the URL using \code{\link[utils:browseURL]{utils::browseURL()}}} @@ -96,7 +96,7 @@ mo_property(x, property = "fullname", language = get_locale(), ...) } } \description{ -Use these functions to return a specific property of a microorganism. All input values will be evaluated internally with \code{\link[=as.mo]{as.mo()}}, which makes it possible to use microbial abbreviations, codes and names as input. Please see \emph{Examples}. +Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with \code{\link[=as.mo]{as.mo()}}, which makes it possible to use microbial abbreviations, codes and names as input. Please see \emph{Examples}. } \details{ All functions will return the most recently known taxonomic property according to the Catalogue of Life, except for \code{\link[=mo_ref]{mo_ref()}}, \code{\link[=mo_authors]{mo_authors()}} and \code{\link[=mo_year]{mo_year()}}. Please refer to this example, knowing that \emph{Escherichia blattae} was renamed to \emph{Shimwellia blattae} in 2010: diff --git a/man/translate.Rd b/man/translate.Rd index 6cbdb57eb..ce48cba2e 100644 --- a/man/translate.Rd +++ b/man/translate.Rd @@ -11,15 +11,13 @@ get_locale() For language-dependent output of AMR functions, like \code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}} and \code{\link[=ab_name]{ab_name()}}. } \details{ -Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: \url{https://github.com/msberends/AMR/blob/master/data-raw/translations.tsv}. +Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: \url{https://github.com/msberends/AMR/blob/master/data-raw/translations.tsv}. This file will be read by all functions where a translated output can be desired, like all \code{\link[=mo_property]{mo_property()}} functions (\code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}}, etc.). -Currently supported languages are (besides English): Dutch, French, German, Italian, Portuguese, Spanish. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names. +Currently supported languages are: Dutch, English, French, German, Italian, Portuguese, Spanish. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names. Please suggest your own translations \href{https://github.com/msberends/AMR/issues/new?title=Translations}{by creating a new issue on our repository}. -This file will be read by all functions where a translated output can be desired, like all \code{\link[=mo_property]{mo_property()}} functions (\code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}}, etc.). - -The system language will be used at default, if that language is supported. The system language can be overwritten with \code{Sys.setenv(AMR_locale = yourlanguage)}. +The system language will be used at default (as returned by \code{\link[=Sys.getlocale]{Sys.getlocale()}}), if that language is supported. The language to be used can be overwritten by setting the option \code{AMR_locale}, e.g. \code{options(AMR_locale = "de")}. } \section{Stable lifecycle}{ diff --git a/pkgdown/extra.css b/pkgdown/extra.css index 214d451bb..5e507034a 100644 --- a/pkgdown/extra.css +++ b/pkgdown/extra.css @@ -276,8 +276,9 @@ table a:not(.btn):hover, .table a:not(.btn):hover { display: none; } .dataset-download-button { - margin-right: 10px; + margin-right: 2%; } .dataset-download-button img { - height: 100px !important; + width: 80px !important; + max-width: 14% !important; } diff --git a/tests/testthat/test-ab_property.R b/tests/testthat/test-ab_property.R index bbe425f09..8ca75e0cb 100644 --- a/tests/testthat/test-ab_property.R +++ b/tests/testthat/test-ab_property.R @@ -24,30 +24,30 @@ context("ab_property.R") test_that("ab_property works", { skip_on_cran() - expect_identical(ab_name("AMX"), "Amoxicillin") + expect_identical(ab_name("AMX", language = NULL), "Amoxicillin") expect_identical(as.character(ab_atc("AMX")), "J01CA04") expect_identical(ab_cid("AMX"), as.integer(33613)) expect_equal(class(ab_tradenames("AMX")), "character") expect_equal(class(ab_tradenames(c("AMX", "AMX"))), "list") - expect_identical(ab_group("AMX"), "Beta-lactams/penicillins") - expect_identical(ab_atc_group1("AMX"), "Beta-lactam antibacterials, penicillins") - expect_identical(ab_atc_group2("AMX"), "Penicillins with extended spectrum") + expect_identical(ab_group("AMX", language = NULL), "Beta-lactams/penicillins") + expect_identical(ab_atc_group1("AMX", language = NULL), "Beta-lactam antibacterials, penicillins") + expect_identical(ab_atc_group2("AMX", language = NULL), "Penicillins with extended spectrum") - expect_identical(ab_name("Fluclox"), "Flucloxacillin") - expect_identical(ab_name("fluklox"), "Flucloxacillin") - expect_identical(ab_name("floxapen"), "Flucloxacillin") - expect_identical(ab_name(21319), "Flucloxacillin") - expect_identical(ab_name("J01CF05"), "Flucloxacillin") + expect_identical(ab_name("Fluclox", language = NULL), "Flucloxacillin") + expect_identical(ab_name("fluklox", language = NULL), "Flucloxacillin") + expect_identical(ab_name("floxapen", language = NULL), "Flucloxacillin") + expect_identical(ab_name(21319, language = NULL), "Flucloxacillin") + expect_identical(ab_name("J01CF05", language = NULL), "Flucloxacillin") expect_identical(ab_ddd("AMX", "oral"), 1) expect_identical(ab_ddd("AMX", "oral", units = TRUE), "g") expect_identical(ab_ddd("AMX", "iv"), 1) expect_identical(ab_ddd("AMX", "iv", units = TRUE), "g") - expect_identical(ab_name(x = c("AMC", "PLB")), c("Amoxicillin/clavulanic acid", "Polymyxin B")) - expect_identical(ab_name(x = c("AMC", "PLB"), tolower = TRUE), + expect_identical(ab_name(x = c("AMC", "PLB"), language = NULL), c("Amoxicillin/clavulanic acid", "Polymyxin B")) + expect_identical(ab_name(x = c("AMC", "PLB"), tolower = TRUE, language = NULL), c("amoxicillin/clavulanic acid", "polymyxin B")) expect_equal(class(ab_info("AMX")), "list") diff --git a/vignettes/datasets.Rmd b/vignettes/datasets.Rmd index 63af4eba6..0605e83d9 100644 --- a/vignettes/datasets.Rmd +++ b/vignettes/datasets.Rmd @@ -3,7 +3,7 @@ title: "Data sets for download / own use" output: rmarkdown::html_vignette: toc: true - toc_depth: 2 + toc_depth: 1 vignette: > %\VignetteIndexEntry{Data sets for download / own use} %\VignetteEncoding{UTF-8} @@ -52,7 +52,7 @@ download_txt <- function(filename) { excel <- paste0(filename, ".xlsx") create_txt <- function(filename, type) { paste0('', - '', + '', '') }