diff --git a/DESCRIPTION b/DESCRIPTION index 4eb24628..be68c898 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.7.1.9053 -Date: 2021-11-01 +Version: 1.7.1.9054 +Date: 2021-11-28 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by @@ -10,8 +10,12 @@ Authors@R: c( person(given = c("Matthijs", "S."), family = "Berends", email = "m.s.berends@umcg.nl", - role = c("aut", "cre"), + role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7620-1800")), + person(given = c("Christian", "F."), + family = "Luz", + role = c("aut", "ctb"), + comment = c(ORCID = "0000-0001-5809-5995")), person(given = "Dennis", family = "Souverein", role = c("aut", "ctb"), @@ -19,10 +23,6 @@ Authors@R: c( person(given = c("Erwin", "E.", "A."), family = "Hassing", role = c("aut", "ctb")), - person(given = c("Christian", "F."), - family = "Luz", - role = c("aut", "ctb"), - comment = c(ORCID = "0000-0001-5809-5995")), person(given = c("Casper", "J."), family = "Albers", role = "ths", @@ -30,7 +30,7 @@ Authors@R: c( person(given = c("Judith", "M."), family = "Fonville", role = "ctb"), - person(given = c("Alexander", "W."), + person(given = c("Alex", "W."), family = "Friedrich", role = "ths", comment = c(ORCID = "0000-0003-4881-038X")), diff --git a/NAMESPACE b/NAMESPACE index 1212a99a..891736ed 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -157,6 +157,9 @@ export("%like%") export("%like_case%") export("%unlike%") export("%unlike_case%") +export(NA_disk_) +export(NA_mic_) +export(NA_rsi_) export(ab_atc) export(ab_atc_group1) export(ab_atc_group2) diff --git a/NEWS.md b/NEWS.md index 88c8b7dd..e61be989 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.7.1.9053 -## Last updated: 1 November 2021 +# `AMR` 1.7.1.9054 +## Last updated: 28 November 2021 ### Breaking changes * Removed `p_symbol()` and all `filter_*()` functions (except for `filter_first_isolate()`), which were all deprecated in a previous package version @@ -7,6 +7,7 @@ * Removed all previously implemented `ggplot2::ggplot()` generics for classes ``, ``, `` and `` as they did not follow the `ggplot2` logic. They were replaced with `ggplot2::autoplot()` generics. ### New +* Support for EUCAST Intrinsic Resistance and Unusual Phenotypes v3.3 (October 2021), effective in the `eucast_rules()` function. This is now the default guideline (all other guidelines are still available). * Function `set_ab_names()` to rename data set columns that resemble antimicrobial drugs. This allows for quickly renaming columns to official names, ATC codes, etc. * Support for Danish, and also added missing translations of all antimicrobial drugs in Italian, French and Portuguese @@ -34,12 +35,14 @@ * Fix for using selectors multiple times in one call (e.g., using them in `dplyr::filter()` and immediately after in `dplyr::select()`) * Added argument `only_treatable`, which defaults to `TRUE` and will exclude drugs that are only for laboratory tests and not for treating patients (such as imipenem/EDTA and gentamicin-high) * Fixed the Gram stain (`mo_gramstain()`) determination of the taxonomic class Negativicutes within the phylum of Firmicutes - they were considered Gram-positives because of their phylum but are actually Gram-negative. This impacts 137 taxonomic species, genera and families, such as *Negativicoccus* and *Veillonella*. +* Dramatic speed improvement for `first_isolate()` * Fix to prevent introducing `NA`s for old MO codes when running `as.mo()` on them * Added more informative error messages when any of the `proportion_*()` and `count_*()` functions fail * When printing a tibble with any old MO code, a warning will be thrown that old codes should be updated using `as.mo()` * Improved automatic column selector when `col_*` arguments are left blank, e.g. in `first_isolate()` * The right input types for `random_mic()`, `random_disk()` and `random_rsi()` are now enforced -* `as.rsi()` can now correct for textual input (such as "Susceptible", "Resistant") in Danish, Dutch, English, French, German, Italian, Portuguese and Spanish +* `as.rsi()` has an improved algorithm and can now also correct for textual input (such as "Susceptible", "Resistant") in Danish, Dutch, English, French, German, Italian, Portuguese and Spanish +* `as.mic()` has an improved algorithm * When warnings are thrown because of too few isolates in any `count_*()`, `proportion_*()` function (or `resistant()` or `susceptible()`), the `dplyr` group will be shown, if available * Fix for legends created with `scale_rsi_colours()` when using `ggplot2` v3.3.4 or higher (this is ggplot2 bug 4511, soon to be fixed) * Fix for minor translation errors @@ -48,9 +51,12 @@ * Improved plot legends for MICs and disk diffusion values * Improved speed of `as.ab()` and all `ab_*()` functions * Added `fortify()` extensions for plotting methods +* `NA` values of the classes ``, `` and `` are now exported objects of this package, e.g. `NA_mic_` is an `NA` of class `mic` (just like the base R `NA_character_` is an `NA` of class `character`) +* The `proportion_df()`, `count_df()` and `rsi_df()` functions now return with the additional S3 class 'rsi_df' so they can be extended by other packages +* The `mdro()` function now returns `NA` for all rows that have no test results ### Other -* This package is now being maintained by two epidemiologists and a data scientist from two different non-profit healthcare organisations. All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated yearly from now on. +* This package is now being maintained by two epidemiologists and a data scientist from two different non-profit healthcare organisations. All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months from now on. # AMR 1.7.1 diff --git a/R/ab.R b/R/ab.R index 318c310b..8efb8eed 100755 --- a/R/ab.R +++ b/R/ab.R @@ -119,6 +119,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) { x <- iconv(x, from = "UTF-8", to = "ASCII//TRANSLIT") x <- gsub('"', "", x, fixed = TRUE) x <- gsub("(specimen|specimen date|specimen_date|spec_date|gender|^dates?$)", "", x, ignore.case = TRUE, perl = TRUE) + # penicillin is a special case: we call it so, but then mean benzylpenicillin + x[x %like_case% "^PENICILLIN" & x %unlike_case% "[ /+-]"] <- "benzylpenicillin" x_bak_clean <- x if (already_regex == FALSE) { x_bak_clean <- generalise_antibiotic_name(x_bak_clean) @@ -227,6 +229,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) { } x_spelling <- x[i] if (already_regex == FALSE) { + x_spelling <- gsub("[IY]+", "[IY]+", x_spelling, perl = TRUE) x_spelling <- gsub("(C|K|Q|QU|S|Z|X|KS)+", "(C|K|Q|QU|S|Z|X|KS)+", x_spelling, perl = TRUE) x_spelling <- gsub("(PH|F|V)+", "(PH|F|V)+", x_spelling, perl = TRUE) diff --git a/R/custom_eucast_rules.R b/R/custom_eucast_rules.R index dafda412..f4efcf87 100644 --- a/R/custom_eucast_rules.R +++ b/R/custom_eucast_rules.R @@ -26,7 +26,7 @@ #' Define Custom EUCAST Rules #' #' Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in [eucast_rules()]. -#' @inheritSection lifecycle Maturing Lifecycle +#' @inheritSection lifecycle Stable Lifecycle #' @param ... rules in formula notation, see *Examples* #' @details #' Some organisations have their own adoption of EUCAST rules. This function can be used to define custom EUCAST rules to be used in the [eucast_rules()] function. diff --git a/R/disk.R b/R/disk.R index 064b83d8..a11ff0f9 100644 --- a/R/disk.R +++ b/R/disk.R @@ -119,6 +119,12 @@ all_valid_disks <- function(x) { !any(is.na(x_disk)) && !all(is.na(x)) } +#' @rdname as.disk +#' @details `NA_disk_` is a missing value of the new `` class. +#' @export +NA_disk_ <- set_clean_class(as.integer(NA_real_), + new_class = c("disk", "integer")) + #' @rdname as.disk #' @export is.disk <- function(x) { diff --git a/R/episode.R b/R/episode.R index d029e9bf..150d4e62 100644 --- a/R/episode.R +++ b/R/episode.R @@ -108,8 +108,8 @@ get_episode <- function(x, episode_days, ...) { meet_criteria(x, allow_class = c("Date", "POSIXt")) meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE) - exec_episode(type = "sequential", - x = x, + exec_episode(x = x, + type = "sequential", episode_days = episode_days, ... = ...) } @@ -120,13 +120,13 @@ is_new_episode <- function(x, episode_days, ...) { meet_criteria(x, allow_class = c("Date", "POSIXt")) meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE) - exec_episode(type = "logical", - x = x, + exec_episode(x = x, + type = "logical", episode_days = episode_days, ... = ...) } -exec_episode <- function(type, x, episode_days, ...) { +exec_episode <- function(x, type, episode_days, ...) { x <- as.double(as.POSIXct(x)) # as.POSIXct() required for Date classes # since x is now in seconds, get seconds from episode_days as well episode_seconds <- episode_days * 60 * 60 * 24 @@ -155,7 +155,7 @@ exec_episode <- function(type, x, episode_days, ...) { # I asked on StackOverflow: # https://stackoverflow.com/questions/42122245/filter-one-row-every-year - exec <- function(x, episode_seconds) { + run_episodes <- function(x, episode_seconds) { indices <- integer() start <- x[1] ind <- 1 @@ -181,11 +181,6 @@ exec_episode <- function(type, x, episode_days, ...) { } } - df <- data.frame(x = x, - y = seq_len(length(x))) %pm>% - pm_arrange(x) - df$new <- exec(df$x, episode_seconds) - df %pm>% - pm_arrange(y) %pm>% - pm_pull(new) + ord <- order(x) + run_episodes(x[ord], episode_seconds)[ord] } diff --git a/R/eucast_rules.R b/R/eucast_rules.R index 9775536a..9f9a5dfe 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -23,6 +23,10 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # +# ====================================================== # +# || Change the EUCAST version numbers in R/globals.R || # +# ====================================================== # + format_eucast_version_nr <- function(version, markdown = TRUE) { # for documentation - adds title, version number, year and url in markdown language lst <- c(EUCAST_VERSION_BREAKPOINTS, EUCAST_VERSION_EXPERT_RULES) @@ -105,6 +109,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) { #' Leclercq et al. **EUCAST expert rules in antimicrobial susceptibility testing.** *Clin Microbiol Infect.* 2013;19(2):141-60; \doi{https://doi.org/10.1111/j.1469-0691.2011.03703.x} #' - EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf) #' - EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.2, 2020. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf) +#' - EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.3, 2021. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2021/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.3_20211018.pdf) #' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 9.0, 2019. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_9.0_Breakpoint_Tables.xlsx) #' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 10.0, 2020. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_10.0_Breakpoint_Tables.xlsx) #' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 11.0, 2021. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_11.0_Breakpoint_Tables.xlsx) @@ -159,7 +164,7 @@ eucast_rules <- function(x, rules = getOption("AMR_eucastrules", default = c("breakpoints", "expert")), verbose = FALSE, version_breakpoints = 11.0, - version_expertrules = 3.2, + version_expertrules = 3.3, ampc_cephalosporin_resistance = NA, only_rsi_columns = FALSE, custom_rules = NULL, @@ -316,25 +321,6 @@ eucast_rules <- function(x, } # Some helper functions --------------------------------------------------- - get_antibiotic_columns <- function(x, cols_ab) { - x <- trimws(unique(toupper(unlist(strsplit(x, ","))))) - x_new <- character() - for (val in x) { - if (paste0("AB_", val) %in% ls(envir = asNamespace("AMR"))) { - # antibiotic group names, as defined in data-raw/_internals.R, such as `AB_CARBAPENEMS` - val <- eval(parse(text = paste0("AB_", val)), envir = asNamespace("AMR")) - } else if (val %in% AB_lookup$ab) { - # separate drugs, such as `AMX` - val <- as.ab(val) - } else { - stop_("unknown antimicrobial agent (group) in EUCAST rules file: ", val, call = FALSE) - } - x_new <- c(x_new, val) - } - x_new <- unique(x_new) - out <- cols_ab[match(x_new, names(cols_ab))] - out[!is.na(out)] - } get_antibiotic_names <- function(x) { x <- x %pm>% strsplit(",") %pm>% @@ -580,6 +566,7 @@ eucast_rules <- function(x, (reference.rule_group %like% "expert" & reference.version == version_expertrules)) } # filter out AmpC de-repressed cephalosporin-resistant mutants ---- + # no need to filter on version number here - the rules contain these version number, so are inherently filtered # cefotaxime, ceftriaxone, ceftazidime if (is.null(ampc_cephalosporin_resistance) || isFALSE(ampc_cephalosporin_resistance)) { eucast_rules_df <- subset(eucast_rules_df, @@ -720,7 +707,7 @@ eucast_rules <- function(x, rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value), error = function(e) integer(0)) } else { - source_antibiotics <- get_antibiotic_columns(source_antibiotics, cols_ab) + source_antibiotics <- get_ab_from_namespace(source_antibiotics, cols_ab) if (length(source_value) == 1 & length(source_antibiotics) > 1) { source_value <- rep(source_value, length(source_antibiotics)) } @@ -748,7 +735,7 @@ eucast_rules <- function(x, } } - cols <- get_antibiotic_columns(target_antibiotics, cols_ab) + cols <- get_ab_from_namespace(target_antibiotics, cols_ab) # Apply rule on data ------------------------------------------------------ # this will return the unique number of changes diff --git a/R/first_isolate.R b/R/first_isolate.R index 39440fb6..36965ca5 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -238,7 +238,7 @@ first_isolate <- function(x = NULL, meet_criteria(testcodes_exclude, allow_class = "character", allow_NULL = TRUE) meet_criteria(icu_exclude, allow_class = "logical", has_length = 1) meet_criteria(specimen_group, allow_class = "character", has_length = 1, allow_NULL = TRUE) - meet_criteria(type, allow_class = "character", has_length = 1) + meet_criteria(type, allow_class = "character", has_length = 1, is_in = c("points", "keyantimicrobials")) meet_criteria(ignore_I, allow_class = "logical", has_length = 1) meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE) meet_criteria(info, allow_class = "logical", has_length = 1) @@ -250,7 +250,8 @@ first_isolate <- function(x = NULL, any_col_contains_rsi <- any(vapply(FUN.VALUE = logical(1), X = x, - FUN = function(x) any(as.character(x) %in% c("R", "S", "I"), na.rm = TRUE), + # check only first 10,000 rows + FUN = function(x) any(as.character(x[1:10000]) %in% c("R", "S", "I"), na.rm = TRUE), USE.NAMES = FALSE)) if (method == "phenotype-based" & !any_col_contains_rsi) { method <- "episode-based" @@ -443,17 +444,6 @@ first_isolate <- function(x = NULL, !is.na(x$newvar_mo)), , drop = FALSE]) # Analysis of first isolate ---- - x$other_pat_or_mo <- ifelse(x$newvar_patient_id == pm_lag(x$newvar_patient_id) & - x$newvar_genus_species == pm_lag(x$newvar_genus_species), - FALSE, - TRUE) - x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species) - x$more_than_episode_ago <- unlist(lapply(split(x$newvar_date, - x$episode_group), - is_new_episode, - episode_days = episode_days), - use.names = FALSE) - if (!is.null(col_keyantimicrobials)) { if (info == TRUE & message_not_thrown_before("first_isolate.type")) { if (type == "keyantimicrobials") { @@ -470,23 +460,38 @@ first_isolate <- function(x = NULL, as_note = FALSE) } } - type_param <- type - + } + + x$other_pat_or_mo <- ifelse(x$newvar_patient_id == pm_lag(x$newvar_patient_id) & + x$newvar_genus_species == pm_lag(x$newvar_genus_species), + FALSE, + TRUE) + + x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species) + x$more_than_episode_ago <- unlist(lapply(split(x$newvar_date, + x$episode_group), + exec_episode, # this will skip meet_criteria() in is_new_episode(), saving time + type = "logical", + episode_days = episode_days), + use.names = FALSE) + + if (!is.null(col_keyantimicrobials)) { + # with key antibiotics x$other_key_ab <- !antimicrobials_equal(y = x$newvar_key_ab, z = pm_lag(x$newvar_key_ab), - type = type_param, + type = type, ignore_I = ignore_I, points_threshold = points_threshold) - # with key antibiotics x$newvar_first_isolate <- pm_if_else(x$newvar_row_index_sorted >= row.start & x$newvar_row_index_sorted <= row.end & x$newvar_genus_species != "" & (x$other_pat_or_mo | x$more_than_episode_ago | x$other_key_ab), TRUE, FALSE) - } else { # no key antibiotics + x1 <<- x$other_pat_or_mo + x2 <<- x$more_than_episode_ago x$newvar_first_isolate <- pm_if_else(x$newvar_row_index_sorted >= row.start & x$newvar_row_index_sorted <= row.end & x$newvar_genus_species != "" & @@ -566,7 +571,7 @@ first_isolate <- function(x = NULL, } # arrange back according to original sorting again - x <- x[order(x$newvar_row_index), ] + x <- x[order(x$newvar_row_index), , drop = FALSE] rownames(x) <- NULL if (info == TRUE) { diff --git a/R/globals.R b/R/globals.R index cae03d25..601dd424 100755 --- a/R/globals.R +++ b/R/globals.R @@ -40,6 +40,10 @@ EUCAST_VERSION_EXPERT_RULES <- list("3.1" = list(version_txt = "v3.1", "3.2" = list(version_txt = "v3.2", year = 2020, title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'", + url = "https://www.eucast.org/expert_rules_and_intrinsic_resistance/"), + "3.3" = list(version_txt = "v3.3", + year = 2021, + title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'", url = "https://www.eucast.org/expert_rules_and_intrinsic_resistance/")) SNOMED_VERSION <- list(title = "Public Health Information Network Vocabulary Access and Distribution System (PHIN VADS)", diff --git a/R/guess_ab_col.R b/R/guess_ab_col.R index e52901fc..3646aa9b 100755 --- a/R/guess_ab_col.R +++ b/R/guess_ab_col.R @@ -293,6 +293,28 @@ get_column_abx <- function(x, out } +get_ab_from_namespace <- function(x, cols_ab) { + # cols_ab comes from get_column_abx() + + x <- trimws(unique(toupper(unlist(strsplit(x, ","))))) + x_new <- character() + for (val in x) { + if (paste0("AB_", val) %in% ls(envir = asNamespace("AMR"))) { + # antibiotic group names, as defined in data-raw/_internals.R, such as `AB_CARBAPENEMS` + val <- eval(parse(text = paste0("AB_", val)), envir = asNamespace("AMR")) + } else if (val %in% AB_lookup$ab) { + # separate drugs, such as `AMX` + val <- as.ab(val) + } else { + stop_("unknown antimicrobial agent (group): ", val, call = FALSE) + } + x_new <- c(x_new, val) + } + x_new <- unique(x_new) + out <- cols_ab[match(x_new, names(cols_ab))] + out[!is.na(out)] +} + generate_warning_abs_missing <- function(missing, any = FALSE) { missing <- paste0(missing, " (", ab_name(missing, tolower = TRUE, language = NULL), ")") if (any == TRUE) { diff --git a/R/italicise_taxonomy.R b/R/italicise_taxonomy.R index 89f9dafb..2e568775 100644 --- a/R/italicise_taxonomy.R +++ b/R/italicise_taxonomy.R @@ -26,7 +26,7 @@ #' Italicise Taxonomic Families, Genera, Species, Subspecies #' #' According to the binomial nomenclature, the lowest four taxonomic levels (family, genus, species, subspecies) should be printed in italic. This function finds taxonomic names within strings and makes them italic. -#' @inheritSection lifecycle Maturing Lifecycle +#' @inheritSection lifecycle Stable Lifecycle #' @param string a [character] (vector) #' @param type type of conversion of the taxonomic names, either "markdown" or "ansi", see *Details* #' @details diff --git a/R/key_antimicrobials.R b/R/key_antimicrobials.R index 49da34c1..ff429367 100755 --- a/R/key_antimicrobials.R +++ b/R/key_antimicrobials.R @@ -250,16 +250,16 @@ generate_antimcrobials_string <- function(df) { if (NROW(df) == 0) { return(character(0)) } - out <- tryCatch( + tryCatch({ do.call(paste0, lapply(as.list(df), function(x) { x <- toupper(as.character(x)) x[!x %in% c("R", "S", "I")] <- "." paste(x) - })), - error = function(e) rep(strrep(".", NCOL(df)), NROW(df))) - out + })) + }, + error = function(e) rep(strrep(".", NCOL(df)), NROW(df))) } #' @rdname key_antimicrobials @@ -279,10 +279,20 @@ antimicrobials_equal <- function(y, stop_ifnot(length(y) == length(z), "length of `y` and `z` must be equal") key2rsi <- function(val) { - as.double(as.rsi(gsub(".", NA_character_, unlist(strsplit(val, "")), fixed = TRUE))) + val <- strsplit(val, "")[[1L]] + val.int <- rep(NA_real_, length(val)) + val.int[val == "S"] <- 1 + val.int[val == "I"] <- 2 + val.int[val == "R"] <- 3 + val.int } - y <- lapply(y, key2rsi) - z <- lapply(z, key2rsi) + # only run on uniques + uniq <- unique(c(y, z)) + uniq_list <- lapply(uniq, key2rsi) + names(uniq_list) <- uniq + + y <- uniq_list[match(y, names(uniq_list))] + z <- uniq_list[match(z, names(uniq_list))] determine_equality <- function(a, b, type, points_threshold, ignore_I) { if (length(a) != length(b)) { diff --git a/R/mdro.R b/R/mdro.R index 533dfef0..9ec6aab2 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -536,6 +536,13 @@ mdro <- function(x = NULL, only_rsi_columns = only_rsi_columns, ...) } + if (!"AMP" %in% names(cols_ab) & "AMX" %in% names(cols_ab)) { + # ampicillin column is missing, but amoxicillin is available + if (info == TRUE) { + message_("Using column '", cols_ab[names(cols_ab) == "AMX"], "' as input for ampicillin since many EUCAST rules depend on it.") + } + cols_ab <- c(cols_ab, c(AMP = unname(cols_ab[names(cols_ab) == "AMX"]))) + } # nolint start AMC <- cols_ab["AMC"] @@ -738,7 +745,8 @@ mdro <- function(x = NULL, x[rows, "columns_nonsusceptible"] <<- vapply(FUN.VALUE = character(1), rows, function(row, group_vct = cols) { - cols_nonsus <- vapply(FUN.VALUE = logical(1), x[row, group_vct, drop = FALSE], + cols_nonsus <- vapply(FUN.VALUE = logical(1), + x[row, group_vct, drop = FALSE], function(y) y %in% search_result) paste(sort(c(unlist(strsplit(x[row, "columns_nonsusceptible", drop = TRUE], ", ")), names(cols_nonsus)[cols_nonsus])), @@ -752,17 +760,20 @@ mdro <- function(x = NULL, } x_transposed <- as.list(as.data.frame(t(x[, cols, drop = FALSE]), stringsAsFactors = FALSE)) - row_filter <- vapply(FUN.VALUE = logical(1), x_transposed, function(y) search_function(y %in% search_result, na.rm = TRUE)) - row_filter <- x[which(row_filter), "row_number", drop = TRUE] - rows <- rows[rows %in% row_filter] - x[rows, "MDRO"] <<- to - x[rows, "reason"] <<- paste0(any_all, - " of the required antibiotics ", - ifelse(any_all == "any", "is", "are"), - " R", - ifelse(!isTRUE(combine_SI), " or I", "")) + rows_affected <- vapply(FUN.VALUE = logical(1), + x_transposed, + function(y) search_function(y %in% search_result, na.rm = TRUE)) + rows_affected <- x[which(rows_affected), "row_number", drop = TRUE] + rows_to_change <- rows[rows %in% rows_affected] + x[rows_to_change, "MDRO"] <<- to + x[rows_to_change, "reason"] <<- paste0(any_all, + " of the required antibiotics ", + ifelse(any_all == "any", "is", "are"), + " R", + ifelse(!isTRUE(combine_SI), " or I", "")) } } + trans_tbl2 <- function(txt, rows, lst) { if (info == TRUE) { message_(txt, "...", appendLF = FALSE, as_note = FALSE) @@ -1382,16 +1393,6 @@ mdro <- function(x = NULL, x$reason <- "PDR/MDR/XDR criteria were met" } - if (info.bak == TRUE) { - cat(group_msg) - if (sum(!is.na(x$MDRO)) == 0) { - cat(font_bold(paste0("=> Found 0 MDROs since no isolates are covered by the guideline"))) - } else { - cat(font_bold(paste0("=> Found ", sum(x$MDRO %in% c(2:5), na.rm = TRUE), " ", guideline$type, " out of ", sum(!is.na(x$MDRO)), - " isolates (", trimws(percentage(sum(x$MDRO %in% c(2:5), na.rm = TRUE) / sum(!is.na(x$MDRO)))), ")\n"))) - } - } - # some more info on negative results if (verbose == TRUE) { if (guideline$code == "cmi2012") { @@ -1406,6 +1407,31 @@ mdro <- function(x = NULL, } } + if (info.bak == TRUE) { + cat(group_msg) + if (sum(!is.na(x$MDRO)) == 0) { + cat(font_bold(paste0("=> Found 0 MDROs since no isolates are covered by the guideline"))) + } else { + cat(font_bold(paste0("=> Found ", sum(x$MDRO %in% c(2:5), na.rm = TRUE), " ", guideline$type, " out of ", sum(!is.na(x$MDRO)), + " isolates (", trimws(percentage(sum(x$MDRO %in% c(2:5), na.rm = TRUE) / sum(!is.na(x$MDRO)))), ")"))) + } + } + + # Fill in blanks ---- + # for rows that have no results + x_transposed <- as.list(as.data.frame(t(x[, cols_ab, drop = FALSE]), + stringsAsFactors = FALSE)) + rows_empty <- which(vapply(FUN.VALUE = logical(1), + x_transposed, + function(y) all(is.na(y)))) + if (length(rows_empty) > 0) { + cat(font_italic(paste0(" (", length(rows_empty), " isolates had no test results)\n"))) + x[rows_empty, "MDRO"] <- NA + x[rows_empty, "reason"] <- "none of the antibiotics have test results" + } else { + cat("\n") + } + # Results ---- if (guideline$code == "cmi2012") { if (any(x$MDRO == -1, na.rm = TRUE)) { diff --git a/R/mic.R b/R/mic.R index a944e7c1..e7674cf2 100755 --- a/R/mic.R +++ b/R/mic.R @@ -23,9 +23,26 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # +# these are allowed MIC values and will become [factor] levels +ops <- c("<", "<=", "", ">=", ">") +valid_mic_levels <- c(c(t(vapply(FUN.VALUE = character(9), ops, + function(x) paste0(x, "0.00", 1:9)))), + unique(c(t(vapply(FUN.VALUE = character(104), ops, + function(x) paste0(x, sort(as.double(paste0("0.0", + sort(c(1:99, 125, 128, 256, 512, 625)))))))))), + unique(c(t(vapply(FUN.VALUE = character(103), ops, + function(x) paste0(x, sort(as.double(paste0("0.", + c(1:99, 125, 128, 256, 512))))))))), + c(t(vapply(FUN.VALUE = character(10), ops, + function(x) paste0(x, sort(c(1:9, 1.5)))))), + c(t(vapply(FUN.VALUE = character(45), ops, + function(x) paste0(x, c(10:98)[9:98 %% 2 == TRUE])))), + c(t(vapply(FUN.VALUE = character(15), ops, + function(x) paste0(x, sort(c(2 ^ c(7:10), 80 * c(2:12)))))))) + #' Transform Input to Minimum Inhibitory Concentrations (MIC) #' -#' This ransforms vectors to a new class [`mic`], which treats the input as decimal numbers, while maintaining operators (such as ">=") and only allowing valid MIC values known to the field of (medical) microbiology. +#' This transforms vectors to a new class [`mic`], which treats the input as decimal numbers, while maintaining operators (such as ">=") and only allowing valid MIC values known to the field of (medical) microbiology. #' @inheritSection lifecycle Stable Lifecycle #' @rdname as.mic #' @param x a [character] or [numeric] vector @@ -117,6 +134,8 @@ as.mic <- function(x, na.rm = FALSE) { # transform Unicode for >= and <= x <- gsub("\u2264", "<=", x, fixed = TRUE) x <- gsub("\u2265", ">=", x, fixed = TRUE) + # remove other invalid characters + x <- gsub("[^a-zA-Z0-9.><= ]+", "", x, perl = TRUE) # remove space between operator and number ("<= 0.002" -> "<=0.002") x <- gsub("(<|=|>) +", "\\1", x, perl = TRUE) # transform => to >= and =< to <= @@ -141,27 +160,14 @@ as.mic <- function(x, na.rm = FALSE) { x[x %like% "[.]"] <- gsub("0+$", "", x[x %like% "[.]"]) # never end with dot x <- gsub("[.]$", "", x, perl = TRUE) - # force to be character - x <- as.character(x) # trim it x <- trimws(x) ## previously unempty values now empty - should return a warning later on x[x.bak != "" & x == ""] <- "invalid" - # these are allowed MIC values and will become [factor] levels - ops <- c("<", "<=", "", ">=", ">") - lvls <- c(c(t(vapply(FUN.VALUE = character(9), ops, function(x) paste0(x, "0.00", 1:9)))), - unique(c(t(vapply(FUN.VALUE = character(104), ops, function(x) paste0(x, sort(as.double(paste0("0.0", - sort(c(1:99, 125, 128, 256, 512, 625)))))))))), - unique(c(t(vapply(FUN.VALUE = character(103), ops, function(x) paste0(x, sort(as.double(paste0("0.", - c(1:99, 125, 128, 256, 512))))))))), - c(t(vapply(FUN.VALUE = character(10), ops, function(x) paste0(x, sort(c(1:9, 1.5)))))), - c(t(vapply(FUN.VALUE = character(45), ops, function(x) paste0(x, c(10:98)[9:98 %% 2 == TRUE])))), - c(t(vapply(FUN.VALUE = character(15), ops, function(x) paste0(x, sort(c(2 ^ c(7:10), 80 * c(2:12)))))))) - na_before <- x[is.na(x) | x == ""] %pm>% length() - x[!x %in% lvls] <- NA + x[!x %in% valid_mic_levels] <- NA na_after <- x[is.na(x) | x == ""] %pm>% length() if (na_before != na_after) { @@ -175,7 +181,7 @@ as.mic <- function(x, na.rm = FALSE) { list_missing, call = FALSE) } - set_clean_class(factor(x, levels = lvls, ordered = TRUE), + set_clean_class(factor(x, levels = valid_mic_levels, ordered = TRUE), new_class = c("mic", "ordered", "factor")) } } @@ -189,6 +195,12 @@ all_valid_mics <- function(x) { !any(is.na(x_mic)) && !all(is.na(x)) } +#' @rdname as.mic +#' @details `NA_mic_` is a missing value of the new `` class. +#' @export +NA_mic_ <- set_clean_class(factor(NA, levels = valid_mic_levels, ordered = TRUE), + new_class = c("mic", "ordered", "factor")) + #' @rdname as.mic #' @export is.mic <- function(x) { diff --git a/R/plot.R b/R/plot.R index a8c3c296..7a36781a 100644 --- a/R/plot.R +++ b/R/plot.R @@ -26,7 +26,7 @@ #' Plotting for Classes `rsi`, `mic` and `disk` #' #' Functions to plot classes `rsi`, `mic` and `disk`, with support for base \R and `ggplot2`. -#' @inheritSection lifecycle Maturing Lifecycle +#' @inheritSection lifecycle Stable Lifecycle #' @inheritSection AMR Read more on Our Website! #' @param x,object values created with [as.mic()], [as.disk()] or [as.rsi()] (or their `random_*` variants, such as [random_mic()]) #' @param mo any (vector of) text that can be coerced to a valid microorganism code with [as.mo()] diff --git a/R/rsi.R b/R/rsi.R index 6b2abab4..b4bf9e05 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -188,6 +188,12 @@ as.rsi <- function(x, ...) { UseMethod("as.rsi") } +#' @rdname as.rsi +#' @details `NA_rsi_` is a missing value of the new `` class. +#' @export +NA_rsi_ <- set_clean_class(factor(NA, levels = c("S", "I", "R"), ordered = TRUE), + new_class = c("rsi", "ordered", "factor")) + #' @rdname as.rsi #' @export is.rsi <- function(x) { @@ -257,12 +263,12 @@ as.rsi.default <- function(x, ...) { return(x) } - if (inherits(x, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) { - x.bak <- x - x <- as.character(x) # this is needed to prevent the vctrs pkg from throwing an error - + x.bak <- x + x <- as.character(x) # this is needed to prevent the vctrs pkg from throwing an error + + if (inherits(x.bak, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) { # support haven package for importing e.g., from SPSS - it adds the 'labels' attribute - lbls <- attributes(x)$labels + lbls <- attributes(x.bak)$labels if (!is.null(lbls) && all(c("R", "S", "I") %in% names(lbls)) && all(c(1:3) %in% lbls)) { x[x.bak == 1] <- names(lbls[lbls == 1]) x[x.bak == 2] <- names(lbls[lbls == 2]) @@ -278,9 +284,9 @@ as.rsi.default <- function(x, ...) { if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) { # check if they are actually MICs or disks if (all_valid_mics(x)) { - warning_("The input seems to be MIC values. Transform them with `as.mic()` before running `as.rsi()` to interpret them.") + warning_("The input seems to contain MIC values. You can transform them with `as.mic()` before running `as.rsi()` to interpret them.", call = FALSE) } else if (all_valid_disks(x)) { - warning_("The input seems to be disk diffusion values. Transform them with `as.disk()` before running `as.rsi()` to interpret them.") + warning_("The input seems to contain disk diffusion values. You can transform them with `as.disk()` before running `as.rsi()` to interpret them.", call = FALSE) } } @@ -303,26 +309,17 @@ as.rsi.default <- function(x, ...) { x[x %like% "([^a-z]|^)res(is(tant)?)?"] <- "R" x[x %like% "([^a-z]|^)sus(cep(tible)?)?"] <- "S" x[x %like% "([^a-z]|^)int(er(mediate)?)?|incr.*exp"] <- "I" - # remove all spaces - x <- gsub(" +", "", x) - # remove all MIC-like values: numbers, operators and periods - x <- gsub("[0-9.,;:<=>]+", "", x) - # remove everything between brackets, and 'high' and 'low' - x <- gsub("([(].*[)])", "", x) - x <- gsub("(high|low)", "", x, ignore.case = TRUE) + # remove other invalid characters + x <- gsub("[^rsiRSIHi]+", "", x, perl = TRUE) # some labs now report "H" instead of "I" to not interfere with EUCAST prior to 2019 x <- gsub("H", "I", x, ignore.case = TRUE) - # disallow more than 3 characters - x[nchar(x) > 3] <- NA # set to capitals x <- toupper(x) - # remove all invalid characters - x <- gsub("[^RSI]+", "", x) # in cases of "S;S" keep S, but in case of "S;I" make it NA x <- gsub("^S+$", "S", x) x <- gsub("^I+$", "I", x) x <- gsub("^R+$", "R", x) - x[!x %in% c("S", "I", "R")] <- NA + x[!x %in% c("S", "I", "R")] <- NA_character_ na_after <- length(x[is.na(x) | x == ""]) if (!isFALSE(list(...)$warn)) { # so as.rsi(..., warn = FALSE) will never throw a warning diff --git a/R/rsi_calc.R b/R/rsi_calc.R index 4f8dd672..d70e7544 100755 --- a/R/rsi_calc.R +++ b/R/rsi_calc.R @@ -344,6 +344,7 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both" } rownames(out) <- NULL + class(out) <- c("rsi_df", class(out)) out } diff --git a/R/sysdata.rda b/R/sysdata.rda index 2f8e1c7d..022212a1 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 53db11ff..12e22ef0 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/data-raw/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.3_20211018.pdf b/data-raw/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.3_20211018.pdf new file mode 100644 index 00000000..7dfadfe1 Binary files /dev/null and b/data-raw/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.3_20211018.pdf differ diff --git a/data-raw/ab.md5 b/data-raw/ab.md5 index afa628c3..ff308ad4 100644 --- a/data-raw/ab.md5 +++ b/data-raw/ab.md5 @@ -1 +1 @@ -9f708801889d2eaf974c6eb85c83a8e7 +f7c99b5734e4cdf37f51c55faca6ac2b diff --git a/data-raw/antibiotics.dta b/data-raw/antibiotics.dta index 85e9c143..6b16df1f 100644 Binary files a/data-raw/antibiotics.dta and b/data-raw/antibiotics.dta differ diff --git a/data-raw/antibiotics.rds b/data-raw/antibiotics.rds index 879d2ead..adff95a8 100644 Binary files a/data-raw/antibiotics.rds and b/data-raw/antibiotics.rds differ diff --git a/data-raw/antibiotics.sas b/data-raw/antibiotics.sas index 008c428d..1538c7df 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 66510076..523d0c81 100644 Binary files a/data-raw/antibiotics.sav and b/data-raw/antibiotics.sav differ diff --git a/data-raw/antibiotics.txt b/data-raw/antibiotics.txt index a7c2592f..21226a77 100644 --- a/data-raw/antibiotics.txt +++ b/data-raw/antibiotics.txt @@ -214,7 +214,7 @@ "GAT" 5379 "Gatifloxacin" "Quinolones" "c(\"J01MA16\", \"S01AE06\")" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"gati\")" "c(\"gatiflo\", \"gatifloxacin\", \"gatifloxacine\", \"gatifloxcin\", \"gatilox\", \"gatiquin\", \"gatispan\", \"tequin\", \"tequin and zymar\", \"zymaxid\")" 0.4 "g" 0.4 "g" "character(0)" "GEM" 9571107 "Gemifloxacin" "Quinolones" "J01MA15" "Quinolone antibacterials" "Fluoroquinolones" "" "c(\"factiv\", \"factive\", \"gemifioxacin\", \"gemifloxacin\", \"gemifloxacine\", \"gemifloxacino\", \"gemifloxacinum\")" 0.32 "g" "character(0)" "GEN" 3467 "Gentamicin" "Aminoglycosides" "c(\"D06AX07\", \"J01GB03\", \"S01AA11\", \"S02AA14\", \"S03AA06\")" "Aminoglycoside antibacterials" "Other aminoglycosides" "c(\"cn\", \"gen\", \"gent\", \"gm\")" "c(\"apogen\", \"centicin\", \"cidomycin\", \"garasol\", \"genoptic liquifilm\", \"genoptic s.o.p.\", \"gentacycol\", \"gentafair\", \"gentak\", \"gentamar\", \"gentamcin sulfate\", \"gentamicin\", \"gentamicina\", \"gentamicine\", \"gentamicins\", \"gentamicinum\", \"gentamycin\", \"gentamycins\", \"gentamycinum\", \"gentavet\", \"gentocin\", \"jenamicin\", \"lyramycin\", \"oksitselanim\", \"refobacin\", \"refobacin tm\", \"septigen\", \"uromycine\")" 0.24 "g" "c(\"13561-6\", \"13562-4\", \"15106-8\", \"22746-2\", \"22747-0\", \"31091-2\", \"31092-0\", \"31093-8\", \"35668-3\", \"3663-2\", \"3664-0\", \"3665-7\", \"39082-3\", \"47109-4\", \"59379-8\", \"80971-5\", \"88111-0\")" -"GEH" "Gentamicin-high" "Aminoglycosides" "c(\"g_h\", \"gehl\", \"genta high\", \"gentamicin high\")" "" "" +"GEH" "Gentamicin-high" "Aminoglycosides" "c(\"gehi\", \"gehl\", \"genta high\", \"gentamicin high\")" "" "" "GEP" 25101874 "Gepotidacin" "Other antibacterials" "" "gepotidacin" "character(0)" "GRX" 72474 "Grepafloxacin" "Quinolones" "J01MA11" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"grep\")" "grepafloxacin" 0.4 "g" "character(0)" "GRI" 441140 "Griseofulvin" "Antifungals/antimycotics" "c(\"D01AA08\", \"D01BA01\")" "" "c(\"amudane\", \"curling factor\", \"delmofulvina\", \"fulcin\", \"fulcine\", \"fulvican grisactin\", \"fulvicin\", \"fulvicin bolus\", \"fulvidex\", \"fulvina\", \"fulvinil\", \"fulvistatin\", \"fungivin\", \"greosin\", \"gresfeed\", \"gricin\", \"grifulin\", \"grifulvin\", \"grifulvin v\", \"grisactin\", \"grisactin ultra\", \"grisactin v\", \"griscofulvin\", \"grise ostatin\", \"grisefuline\", \"griseo\", \"griseofulvin\", \"griseofulvin forte\", \"griseofulvina\", \"griseofulvine\", \"griseofulvinum\", \"griseomix\", \"griseostatin\", \"grisetin\", \"grisofulvin\", @@ -403,7 +403,7 @@ "SPM" "Spiramycin/metronidazole" "Other antibacterials" "J01RA04" "Combinations of antibacterials" "Combinations of antibacterials" "" "" "" "STR" "Streptoduocin" "Aminoglycosides" "J01GA02" "Aminoglycoside antibacterials" "Streptomycins" "" "" 1 "g" "" "STR1" 19649 "Streptomycin" "Aminoglycosides" "c(\"A07AA04\", \"J01GA01\")" "Aminoglycoside antibacterials" "Streptomycins" "c(\"s\", \"stm\", \"str\", \"stre\")" "c(\"agrept\", \"agrimycin\", \"chemform\", \"estreptomicina\", \"neodiestreptopab\", \"strepcen\", \"streptomicina\", \"streptomycin\", \"streptomycin a\", \"streptomycin spx\", \"streptomycin sulfate\", \"streptomycine\", \"streptomyzin\", \"vetstrep\")" 1 "g" "4039-4" -"STH" "Streptomycin-high" "Aminoglycosides" "c(\"s_h\", \"sthl\", \"strepto high\", \"streptomycin high\")" "" "" +"STH" "Streptomycin-high" "Aminoglycosides" "c(\"sthi\", \"sthl\", \"strepto high\", \"streptomycin high\")" "" "" "STI" "Streptomycin/isoniazid" "Antimycobacterials" "J04AM01" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" "" "SUL" 130313 "Sulbactam" "Beta-lactams/penicillins" "J01CG01" "Beta-lactam antibacterials, penicillins" "Beta-lactamase inhibitors" "" "c(\"betamaze\", \"sulbactam\", \"sulbactam acid\", \"sulbactam free acid\", \"sulbactamum\")" 1 "g" "character(0)" "SBC" 20055036 "Sulbenicillin" "Beta-lactams/penicillins" "J01CA16" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"kedacillina\", \"sulbenicilina\", \"sulbenicilline\", \"sulbenicillinum\")" 15 "g" "character(0)" diff --git a/data-raw/ex2.R b/data-raw/ex2.R new file mode 100644 index 00000000..a1d0e69b --- /dev/null +++ b/data-raw/ex2.R @@ -0,0 +1,13 @@ +ex2 <- example_isolates +for (extra_id in seq_len(50)) { + ex2 <- ex2 %>% + bind_rows(example_isolates %>% mutate(patient_id = paste0(patient_id, extra_id))) +} +# randomly clear antibibiograms of 2% +clr <- sort(sample(x = seq_len(nrow(ex2)), + size = nrow(ex2) * 0.02)) +for (row in which(is.rsi(ex2))) { + ex2[clr, row] <- NA_rsi_ +} + + diff --git a/data-raw/ex2.rds b/data-raw/ex2.rds new file mode 100644 index 00000000..39f81fc2 Binary files /dev/null and b/data-raw/ex2.rds differ diff --git a/data-raw/reproduction_of_antibiotics.R b/data-raw/reproduction_of_antibiotics.R index b28ab2fd..1a1d864c 100644 --- a/data-raw/reproduction_of_antibiotics.R +++ b/data-raw/reproduction_of_antibiotics.R @@ -546,8 +546,8 @@ antibiotics[which(antibiotics$ab == "FEP"), "abbreviations"][[1]] <- list(c(anti antibiotics[which(antibiotics$ab == "CTC"), "abbreviations"][[1]] <- list(c("xctl")) antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]], "xct")) # High level Gentamcin and Streptomycin -antibiotics[which(antibiotics$ab == "GEH"), "abbreviations"][[1]] <- list(c("gehl", "gentamicin high", "genta high")) -antibiotics[which(antibiotics$ab == "STH"), "abbreviations"][[1]] <- list(c("sthl", "streptomycin high", "strepto high")) +antibiotics[which(antibiotics$ab == "GEH"), "abbreviations"][[1]] <- list(c("gehl", "gentamicin high", "genta high", "gehi")) +antibiotics[which(antibiotics$ab == "STH"), "abbreviations"][[1]] <- list(c("sthl", "streptomycin high", "strepto high", "sthi")) # add imi and "imipenem/cilastatine" to imipenem antibiotics[which(antibiotics$ab == "IPM"), "abbreviations"][[1]] <- list(c("imip", "imi", "imp")) antibiotics[which(antibiotics$ab == "IPM"), "synonyms"][[1]] <- list(sort(c(antibiotics[which(antibiotics$ab == "IPM"), "synonyms"][[1]], "imipenem/cilastatin"))) diff --git a/data/antibiotics.rda b/data/antibiotics.rda index f60f64db..02b6512f 100755 Binary files a/data/antibiotics.rda and b/data/antibiotics.rda differ diff --git a/docs/404.html b/docs/404.html index 53cb884f..94f847d0 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1,38 +1,79 @@ + - - - - + + + + Page not found (404) • AMR (for R) - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + -
+ + +
+
-
- - + + diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index cc8b9dd0..a6f88e01 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -57,8 +57,6 @@ - - @@ -70,15 +68,9 @@ - - - - - -
@@ -503,11 +495,11 @@ END OF TERMS AND CONDITIONS @@ -516,8 +508,6 @@ END OF TERMS AND CONDITIONS - - diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html index f7f79dbb..e4a3c303 100644 --- a/docs/articles/SPSS.html +++ b/docs/articles/SPSS.html @@ -30,8 +30,6 @@ - -
@@ -202,17 +200,17 @@

-SPSS / SAS / Stata

+SPSS / SAS / Stata

SPSS (Statistical Package for the Social Sciences) is probably the most well-known software package for statistical analysis. SPSS is easier to learn than R, because in SPSS you only have to click a menu to run parts of your analysis. Because of its user-friendliness, it is taught at universities and particularly useful for students who are new to statistics. From my experience, I would guess that pretty much all (bio)medical students know it at the time they graduate. SAS and Stata are comparable statistical packages popular in big industries.

-Compared to R

+Compared to R

As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major downsides when comparing it with R:

  • R is highly modular.

    -

    The official R network (CRAN) features more than 16,000 packages at the time of writing, our AMR package being one of them. All these packages were peer-reviewed before publication. Aside from this official channel, there are also developers who choose not to submit to CRAN, but rather keep it on their own public repository, like GitHub. So there may even be a lot more than 14,000 packages out there.

    +

    The official R network (CRAN) features more than 16,000 packages at the time of writing, our AMR package being one of them. All these packages were peer-reviewed before publication. Aside from this official channel, there are also developers who choose not to submit to CRAN, but rather keep it on their own public repository, like GitHub. So there may even be a lot more than 14,000 packages out there.

    Bottom line is, you can really extend it yourself or ask somebody to do this for you. Take for example our AMR package. Among other things, it adds reliable reference data to R to help you with the data cleaning and analysis. SPSS, SAS and Stata will never know what a valid MIC value is or what the Gram stain of E. coli is. Or that all species of Klebiella are resistant to amoxicillin and that Floxapen® is a trade name of flucloxacillin. These facts and properties are often needed to clean existing data, which would be very inconvenient in a software package without reliable reference data. See below for a demonstration.

  • @@ -221,27 +219,27 @@
  • R can be easily automated.

    -

    Over the last years, R Markdown has really made an interesting development. With R Markdown, you can very easily produce reports, whether the format has to be Word, PowerPoint, a website, a PDF document or just the raw data to Excel. It even allows the use of a reference file containing the layout style (e.g. fonts and colours) of your organisation. I use this a lot to generate weekly and monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like.

    -

    For an even more professional environment, you could create Shiny apps: live manipulation of data using a custom made website. The webdesign knowledge needed (JavaScript, CSS, HTML) is almost zero.

    +

    Over the last years, R Markdown has really made an interesting development. With R Markdown, you can very easily produce reports, whether the format has to be Word, PowerPoint, a website, a PDF document or just the raw data to Excel. It even allows the use of a reference file containing the layout style (e.g. fonts and colours) of your organisation. I use this a lot to generate weekly and monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like.

    +

    For an even more professional environment, you could create Shiny apps: live manipulation of data using a custom made website. The webdesign knowledge needed (JavaScript, CSS, HTML) is almost zero.

  • R has a huge community.

    -

    Many R users just ask questions on websites like StackOverflow.com, the largest online community for programmers. At the time of writing, 415,751 R-related questions have already been asked on this platform (that covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.

    +

    Many R users just ask questions on websites like StackOverflow.com, the largest online community for programmers. At the time of writing, 427,872 R-related questions have already been asked on this platform (that covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.

  • R understands any data type, including SPSS/SAS/Stata.

    -

    And that’s not vice versa I’m afraid. You can import data from any source into R. For example from SPSS, SAS and Stata (link), from Minitab, Epi Info and EpiData (link), from Excel (link), from flat files like CSV, TXT or TSV (link), or directly from databases and datawarehouses from anywhere on the world (link). You can even scrape websites to download tables that are live on the internet (link) or get the results of an API call and transform it into data in only one command (link).

    +

    And that’s not vice versa I’m afraid. You can import data from any source into R. For example from SPSS, SAS and Stata (link), from Minitab, Epi Info and EpiData (link), from Excel (link), from flat files like CSV, TXT or TSV (link), or directly from databases and datawarehouses from anywhere on the world (link). You can even scrape websites to download tables that are live on the internet (link) or get the results of an API call and transform it into data in only one command (link).

    And the best part - you can export from R to most data formats as well. So you can import an SPSS file, do your analysis neatly in R and export the resulting tables to Excel files for sharing.

  • R is completely free and open-source.

    -

    No strings attached. It was created and is being maintained by volunteers who believe that (data) science should be open and publicly available to everybody. SPSS, SAS and Stata are quite expensive. IBM SPSS Staticstics only comes with subscriptions nowadays, varying between USD 1,300 and USD 8,500 per user per year. SAS Analytics Pro costs around USD 10,000 per computer. Stata also has a business model with subscription fees, varying between USD 600 and USD 2,800 per computer per year, but lower prices come with a limitation of the number of variables you can work with. And still they do not offer the above benefits of R.

    +

    No strings attached. It was created and is being maintained by volunteers who believe that (data) science should be open and publicly available to everybody. SPSS, SAS and Stata are quite expensive. IBM SPSS Staticstics only comes with subscriptions nowadays, varying between USD 1,300 and USD 8,500 per user per year. SAS Analytics Pro costs around USD 10,000 per computer. Stata also has a business model with subscription fees, varying between USD 600 and USD 2,800 per computer per year, but lower prices come with a limitation of the number of variables you can work with. And still they do not offer the above benefits of R.

    If you are working at a midsized or small company, you can save it tens of thousands of dollars by using R instead of e.g. SPSS - gaining even more functions and flexibility. And all R enthousiasts can do as much PR as they want (like I do here), because nobody is officially associated with or affiliated by R. It is really free.

  • R is (nowadays) the preferred analysis software in academic papers.

    -

    At present, R is among the world most powerful statistical languages, and it is generally very popular in science (Bollmann et al., 2017). For all the above reasons, the number of references to R as an analysis method in academic papers is rising continuously and has even surpassed SPSS for academic use (Muenchen, 2014).

    -

    I believe that the thing with SPSS is, that it has always had a great user interface which is very easy to learn and use. Back when they developed it, they had very little competition, let alone from R. R didn’t even had a professional user interface until the last decade (called RStudio, see below). How people used R between the nineties and 2010 is almost completely incomparable to how R is being used now. The language itself has been restyled completely by volunteers who are dedicated professionals in the field of data science. SPSS was great when there was nothing else that could compete. But now in 2021, I don’t see any reason why SPSS would be of any better use than R.

    +

    At present, R is among the world most powerful statistical languages, and it is generally very popular in science (Bollmann et al., 2017). For all the above reasons, the number of references to R as an analysis method in academic papers is rising continuously and has even surpassed SPSS for academic use (Muenchen, 2014).

    +

    I believe that the thing with SPSS is, that it has always had a great user interface which is very easy to learn and use. Back when they developed it, they had very little competition, let alone from R. R didn’t even had a professional user interface until the last decade (called RStudio, see below). How people used R between the nineties and 2010 is almost completely incomparable to how R is being used now. The language itself has been restyled completely by volunteers who are dedicated professionals in the field of data science. SPSS was great when there was nothing else that could compete. But now in 2021, I don’t see any reason why SPSS would be of any better use than R.

To demonstrate the first point:

@@ -253,13 +251,11 @@ as.mic("testvalue") # Class <mic> # [1] <NA> - # the Gram stain is available for all bacteria: mo_gramstain("E. coli") # [1] "Gram-negative" - # Klebsiella is intrinsic resistant to amoxicillin, according to EUCAST: -klebsiella_test <- data.frame(mo = "klebsiella", +klebsiella_test <- data.frame(mo = "klebsiella", amox = "S", stringsAsFactors = FALSE) klebsiella_test # (our original data) @@ -267,8 +263,7 @@ # 1 klebsiella S eucast_rules(klebsiella_test, info = FALSE) # (the edited data by EUCAST rules) # mo amox -# 1 klebsiella R - +# 1 klebsiella S # hundreds of trade names can be translated to a name, trade name or an ATC code: ab_name("floxapen") # [1] "Flucloxacillin" @@ -281,17 +276,17 @@

-Import data from SPSS/SAS/Stata

+Import data from SPSS/SAS/Stata

-RStudio

-

To work with R, probably the best option is to use RStudio. It is an open-source and free desktop environment which not only allows you to run R code, but also supports project management, version management, package management and convenient import menus to work with other data sources. You can also install RStudio Server on a private or corporate server, which brings nothing less than the complete RStudio software to you as a website (at home or at work).

+RStudio +

To work with R, probably the best option is to use RStudio. It is an open-source and free desktop environment which not only allows you to run R code, but also supports project management, version management, package management and convenient import menus to work with other data sources. You can also install RStudio Server on a private or corporate server, which brings nothing less than the complete RStudio software to you as a website (at home or at work).

To import a data file, just click Import Dataset in the Environment tab:

If additional packages are needed, RStudio will ask you if they should be installed on beforehand.

In the the window that opens, you can define all options (parameters) that should be used for import and you’re ready to go:

-

If you want named variables to be imported as factors so it resembles SPSS more, use as_factor().

+

If you want named variables to be imported as factors so it resembles SPSS more, use as_factor().

The difference is this:

 SPSS_data
@@ -328,70 +323,70 @@
 

-Base R

-

To import data from SPSS, SAS or Stata, you can use the great haven package yourself:

+Base R +

To import data from SPSS, SAS or Stata, you can use the great haven package yourself:

 # download and install the latest version:
-install.packages("haven")
+install.packages("haven")
 # load the package you just installed:
-library(haven) 
+library(haven)

You can now import files as follows:

-SPSS

+SPSS

To read files from SPSS into R:

 # read any SPSS file based on file extension (best way):
-read_spss(file = "path/to/file")
+read_spss(file = "path/to/file")
 
 # read .sav or .zsav file:
-read_sav(file = "path/to/file")
+read_sav(file = "path/to/file")
 
 # read .por file:
-read_por(file = "path/to/file")
-

Do not forget about as_factor(), as mentioned above.

+read_por(file = "path/to/file")
+

Do not forget about as_factor(), as mentioned above.

To export your R objects to the SPSS file format:

 # save as .sav file:
-write_sav(data = yourdata, path = "path/to/file")
+write_sav(data = yourdata, path = "path/to/file")
 
 # save as compressed .zsav file:
-write_sav(data = yourdata, path = "path/to/file", compress = TRUE)
+write_sav(data = yourdata, path = "path/to/file", compress = TRUE)

-SAS

+SAS

To read files from SAS into R:

 # read .sas7bdat + .sas7bcat files:
-read_sas(data_file = "path/to/file", catalog_file = NULL)
+read_sas(data_file = "path/to/file", catalog_file = NULL)
 
 # read SAS transport files (version 5 and version 8):
-read_xpt(file = "path/to/file")
+read_xpt(file = "path/to/file")

To export your R objects to the SAS file format:

 # save as regular SAS file:
-write_sas(data = yourdata, path = "path/to/file")
+write_sas(data = yourdata, path = "path/to/file")
 
 # the SAS transport format is an open format 
 # (required for submission of the data to the FDA)
-write_xpt(data = yourdata, path = "path/to/file", version = 8)
+write_xpt(data = yourdata, path = "path/to/file", version = 8)

-Stata

+Stata

To read files from Stata into R:

 # read .dta file:
-read_stata(file = "/path/to/file")
+read_stata(file = "/path/to/file")
 
 # works exactly the same:
-read_dta(file = "/path/to/file")
+read_dta(file = "/path/to/file")

To export your R objects to the Stata file format:

 # save as .dta file, Stata version 14:
 # (supports Stata v8 until v15 at the time of writing)
-write_dta(data = yourdata, path = "/path/to/file", version = 14)
+write_dta(data = yourdata, path = "/path/to/file", version = 14)
@@ -408,13 +403,11 @@ @@ -423,7 +416,5 @@ - - diff --git a/docs/articles/SPSS_files/header-attrs-2.11/header-attrs.js b/docs/articles/SPSS_files/header-attrs-2.11/header-attrs.js new file mode 100644 index 00000000..dd57d92e --- /dev/null +++ b/docs/articles/SPSS_files/header-attrs-2.11/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 18d20f54..7951205c 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -42,7 +42,7 @@ AMR (for R) - 1.7.1.9053 + 1.7.1.9054 @@ -188,7 +188,7 @@
diff --git a/docs/articles/index.html b/docs/articles/index.html index 73937905..b8676a5d 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -57,8 +57,6 @@ - - @@ -70,15 +68,9 @@ - - - - - -
@@ -272,11 +264,11 @@ @@ -285,8 +277,6 @@ - - diff --git a/docs/articles/welcome_to_AMR.html b/docs/articles/welcome_to_AMR.html index 21b7dd24..5d432d95 100644 --- a/docs/articles/welcome_to_AMR.html +++ b/docs/articles/welcome_to_AMR.html @@ -30,8 +30,6 @@ - -
-

Note: to keep the package as small as possible, we only included this vignette. You can read more vignettes on our website about how to conduct AMR data analysis, determine MDRO’s, find explanation of EUCAST rules, and much more: https://msberends.github.io/AMR/articles/.

+

Note: to keep the package size as small as possible, we only included this vignette on CRAN. You can read more vignettes on our website about how to conduct AMR data analysis, determine MDRO’s, find explanation of EUCAST rules, and much more: https://msberends.github.io/AMR/articles/.


-

AMR is a free, open-source and independent R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. Our aim is to provide a standard for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting.

-

After installing this package, R knows ~70,000 distinct microbial species and all ~560 antibiotic, antimycotic and antiviral drugs by name and code (including ATC, EARS-NET, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data.

+

AMR is a free, open-source and independent R package (see Copyright) to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. Our aim is to provide a standard for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting.

+

After installing this package, R knows ~71,000 distinct microbial species and all ~560 antibiotic, antimycotic and antiviral drugs by name and code (including ATC, EARS-Net, PubChem, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data. Antimicrobial names and group names are available in Danish, Dutch, English, French, German, Italian, Portuguese and Spanish.

This package is fully independent of any other R package and works on Windows, macOS and Linux with all versions of R since R-3.0.0 (April 2013). It was designed to work in any setting, including those with very limited resources. Since its first public release in early 2018, this package has been downloaded from more than 160 countries.

This package can be used for:

    @@ -223,7 +221,7 @@
  • Principal component analysis for AMR

All reference data sets (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) in this AMR package are publicly and freely available. We continually export our data sets to formats for use in R, SPSS, SAS, Stata and Excel. We also supply flat files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please find all download links on our website, which is automatically updated with every code change.

-

The package was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the University of Groningen, in collaboration with non-profit organisations Certe Medical Diagnostics and Advice and University Medical Center Groningen. This R package is actively maintained (see Changelog) and is free software (see Copyright).

+

This R package was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the University of Groningen, in collaboration with non-profit organisations Certe Medical Diagnostics and Advice Foundation and University Medical Center Groningen. This R package formed the basis of two PhD theses (DOI 10.33612/diss.177417131 and DOI 10.33612/diss.177417131) but is actively and durably maintained (see changelog)) by two public healthcare organisations in the Netherlands.

-
  • Matthijs S. Berends. Author, maintainer. @@ -277,27 +278,27 @@ Antimicrobial Resistance Data. Journal of Statistical Software (accepted for pub

  • -

    Alexander W. Friedrich. Thesis advisor. +

    Dennis Souverein. Author, contributor.

  • -

    Bhanu N. M. Sinha. Thesis advisor. +

    Erwin E. A. Hassing. Author, contributor.

  • Casper J. Albers. Thesis advisor.

  • -
  • -

    Corinna Glasner. Thesis advisor. -

    -
  • Judith M. Fonville. Contributor.

  • -

    Erwin E. A. Hassing. Contributor. +

    Alex W. Friedrich. Thesis advisor. +

    +
  • +
  • +

    Corinna Glasner. Thesis advisor.

  • @@ -325,7 +326,7 @@ Antimicrobial Resistance Data. Journal of Statistical Software (accepted for pub

  • -

    Dennis Souverein. Contributor. +

    Bhanu N. M. Sinha. Thesis advisor.

  • @@ -333,7 +334,7 @@ Antimicrobial Resistance Data. Journal of Statistical Software (accepted for pub

- +
@@ -342,11 +343,11 @@ Antimicrobial Resistance Data. Journal of Statistical Software (accepted for pub @@ -355,8 +356,6 @@ Antimicrobial Resistance Data. Journal of Statistical Software (accepted for pub - - diff --git a/docs/countries.png b/docs/countries.png index 37b14061..fa8cf7eb 100644 Binary files a/docs/countries.png and b/docs/countries.png differ diff --git a/docs/countries_large.png b/docs/countries_large.png index 5c81f9dc..afdd09dc 100644 Binary files a/docs/countries_large.png and b/docs/countries_large.png differ diff --git a/docs/extra.css b/docs/extra.css index 84f4f6a6..4d62d65f 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -104,10 +104,7 @@ a pre[href], a pre[href]:hover, a pre[href]:focus { /* syntax font */ pre, code { - font-family: 'Courier New', monospace; - font-size: 100% !important; - font-weight: bold; - /*background-color: #f4f4f4*/; + font-size: 95% !important; } pre code { word-wrap: normal !important; diff --git a/docs/extra.js b/docs/extra.js index 7f02db35..8a0a87a5 100644 --- a/docs/extra.js +++ b/docs/extra.js @@ -95,10 +95,12 @@ $(document).ready(function() { function doct_tit(x) { if (typeof(x) != "undefined") { // authors - x = x.replace(/Author, maintainer/g, "Main developer"); - x = x.replace(/Author, contributor/g, "Main contributor"); + x = x.replace(/Author, maintainer/g, "Maintainer"); + x = x.replace(/Author, contributor/g, "Maintainer"); x = x.replace(/Author, thesis advisor/g, "Doctoral advisor"); + x = x.replace(/Thesis advisor/g, "Doctoral advisor"); x = x.replace("Matthijs", "Dr. Matthijs"); + x = x.replace("Christian", "Dr. Christian"); x = x.replace("Alex", "Prof. Alex"); x = x.replace("Bhanu", "Prof. Bhanu"); x = x.replace("Casper", "Prof. Casper"); diff --git a/docs/index.html b/docs/index.html index 94753cb5..6cfc0a27 100644 --- a/docs/index.html +++ b/docs/index.html @@ -33,8 +33,6 @@ - -

-Get started

+Get started

To find out how to conduct AMR data analysis, please continue reading here to get started or click a link in the ‘How to’ menu.

-Short introduction

+Short introduction

-Microbial (taxonomic) reference data

-

This package contains the complete taxonomic tree of almost all ~70,000 microorganisms from the authoritative and comprehensive Catalogue of Life (CoL, www.catalogueoflife.org), supplemented by data from the List of Prokaryotic names with Standing in Nomenclature (LPSN, lpsn.dsmz.de). This supplementation is needed until the CoL+ project is finished, which we await. With catalogue_of_life_version() can be checked which version of the CoL is included in this package.

+Microbial (taxonomic) reference data +

This package contains the complete taxonomic tree of almost all ~70,000 microorganisms from the authoritative and comprehensive Catalogue of Life (CoL, www.catalogueoflife.org), supplemented by data from the List of Prokaryotic names with Standing in Nomenclature (LPSN, lpsn.dsmz.de). This supplementation is needed until the CoL+ project is finished, which we await. With catalogue_of_life_version() can be checked which version of the CoL is included in this package.

Read more about which data from the Catalogue of Life in our manual.

-Antimicrobial reference data

-

This package contains all ~550 antibiotic, antimycotic and antiviral drugs and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD, oral and IV) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, https://www.whocc.no) and the Pharmaceuticals Community Register of the European Commission.

-

NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package. See https://www.whocc.no/copyright_disclaimer/.

+Antimicrobial reference data +

This package contains all ~550 antibiotic, antimycotic and antiviral drugs and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD, oral and IV) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, https://www.whocc.no) and the Pharmaceuticals Community Register of the European Commission.

+

NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package. See https://www.whocc.no/copyright_disclaimer/.

Read more about the data from WHOCC in our manual.

-WHONET / EARS-Net

+WHONET / EARS-Net

We support WHONET and EARS-Net data. Exported files from WHONET can be imported into R and can be analysed easily using this package. For education purposes, we created an example data set WHONET with the exact same structure as a WHONET export file. Furthermore, this package also contains a data set antibiotics with all EARS-Net antibiotic abbreviations, and knows almost all WHONET abbreviations for microorganisms. When using WHONET data as input for analysis, all input parameters will be set automatically.

Read our tutorial about how to work with WHONET data here.

-Overview of functions

+Overview of functions

The AMR package basically does four important things:

-
    +
    1. It cleanses existing data by providing new classes for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect:

        @@ -446,13 +444,13 @@
      • It enhances existing data and adds new data from data sets included in this package.

          -
        • Use eucast_rules() to apply EUCAST expert rules to isolates (not the translation from MIC to R/SI values, use as.rsi() for that).
        • -
        • Use first_isolate() to identify the first isolates of every patient using guidelines from the CLSI (Clinical and Laboratory Standards Institute). +
        • Use eucast_rules() to apply EUCAST expert rules to isolates (not the translation from MIC to R/SI values, use as.rsi() for that).
        • +
        • Use first_isolate() to identify the first isolates of every patient using guidelines from the CLSI (Clinical and Laboratory Standards Institute).
          • You can also identify first weighted isolates of every patient, an adjusted version of the CLSI guideline. This takes into account key antibiotics of every strain and compares them.
        • -
        • Use mdro() to determine which micro-organisms are multi-drug resistant organisms (MDRO). It supports a variety of international guidelines, such as the MDR-paper by Magiorakos et al. (2012, PMID 21793988), the exceptional phenotype definitions of EUCAST and the WHO guideline on multi-drug resistant TB. It also supports the national guidelines of the Netherlands and Germany.
        • +
        • Use mdro() to determine which micro-organisms are multi-drug resistant organisms (MDRO). It supports a variety of international guidelines, such as the MDR-paper by Magiorakos et al. (2012, PMID 21793988), the exceptional phenotype definitions of EUCAST and the WHO guideline on multi-drug resistant TB. It also supports the national guidelines of the Netherlands and Germany.
        • The data set microorganisms contains the complete taxonomic tree of ~70,000 microorganisms. Furthermore, some colloquial names and all Gram stains are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like mo_genus(), mo_family(), mo_gramstain() or even mo_phylum(). Use mo_snomed() to look up any SNOMED CT code associated with a microorganism. As all these function use as.mo() internally, they also use the same intelligent rules for determination. For example, mo_genus("MRSA") and mo_genus("S. aureus") will both return "Staphylococcus". They also come with support for German, Danish, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.
        • The data set antibiotics contains ~450 antimicrobial drugs with their EARS-Net code, ATC code, PubChem compound ID, LOINC code, official name, common LIS codes and DDDs of both oral and parenteral administration. It also contains all (thousands of) trade names found in PubChem. Use functions like ab_name(), ab_group(), ab_atc(), ab_loinc() and ab_tradenames() to look up values. The ab_* functions use as.ab() internally so they support the same intelligent rules to guess the most probable result. For example, ab_name("Fluclox"), ab_name("Floxapen") and ab_name("J01CF05") will all return "Flucloxacillin". These functions can again be used to add new variables to your data.
        @@ -460,7 +458,7 @@
      • It analyses the data with convenient functions that use well-known methods.

        @@ -482,7 +480,7 @@
@@ -571,7 +563,5 @@ - - diff --git a/docs/news/index.html b/docs/news/index.html index afe58a39..fab82545 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -84,7 +84,7 @@ AMR (for R) - 1.7.1.9053 + 1.7.1.9054
@@ -232,12 +232,12 @@ Source: NEWS.md
-
-

- Unreleased AMR 1.7.1.9053

-
+
+

+ Unreleased AMR 1.7.1.9054

+

-Last updated: 1 November 2021 +Last updated: 28 November 2021

@@ -253,6 +253,7 @@

New

    +
  • Support for EUCAST Intrinsic Resistance and Unusual Phenotypes v3.3 (October 2021), effective in the eucast_rules() function. This is now the default guideline (all other guidelines are still available).
  • Function set_ab_names() to rename data set columns that resemble antimicrobial drugs. This allows for quickly renaming columns to official names, ATC codes, etc.
  • Support for Danish, and also added missing translations of all antimicrobial drugs in Italian, French and Portuguese
@@ -297,6 +298,8 @@
  • Fixed the Gram stain (mo_gramstain()) determination of the taxonomic class Negativicutes within the phylum of Firmicutes - they were considered Gram-positives because of their phylum but are actually Gram-negative. This impacts 137 taxonomic species, genera and families, such as Negativicoccus and Veillonella.
  • +
  • Dramatic speed improvement for first_isolate() +
  • Fix to prevent introducing NAs for old MO codes when running as.mo() on them
  • Added more informative error messages when any of the proportion_*() and count_*() functions fail
  • When printing a tibble with any old MO code, a warning will be thrown that old codes should be updated using as.mo() @@ -305,7 +308,9 @@
  • The right input types for random_mic(), random_disk() and random_rsi() are now enforced
  • -as.rsi() can now correct for textual input (such as “Susceptible”, “Resistant”) in Danish, Dutch, English, French, German, Italian, Portuguese and Spanish
  • +as.rsi() has an improved algorithm and can now also correct for textual input (such as “Susceptible”, “Resistant”) in Danish, Dutch, English, French, German, Italian, Portuguese and Spanish +
  • +as.mic() has an improved algorithm
  • When warnings are thrown because of too few isolates in any count_*(), proportion_*() function (or resistant() or susceptible()), the dplyr group will be shown, if available
  • Fix for legends created with scale_rsi_colours() when using ggplot2 v3.3.4 or higher (this is ggplot2 bug 4511, soon to be fixed)
  • Fix for minor translation errors
  • @@ -315,13 +320,17 @@
  • Improved plot legends for MICs and disk diffusion values
  • Improved speed of as.ab() and all ab_*() functions
  • Added fortify() extensions for plotting methods
  • +
  • +NA values of the classes <mic>, <disk> and <rsi> are now exported objects of this package, e.g. NA_mic_ is an NA of class mic (just like the base R NA_character_ is an NA of class character)
  • +
  • The proportion_df(), count_df() and rsi_df() functions now return with the additional S3 class ‘rsi_df’ so they can be extended by other packages
  • +
  • The mdro() function now returns NA for all rows that have no test results
  • Other

      -
    • This package is now being maintained by two epidemiologists and a data scientist from two different non-profit healthcare organisations. All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated yearly from now on.
    • +
    • This package is now being maintained by two epidemiologists and a data scientist from two different non-profit healthcare organisations. All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months from now on.
    @@ -2312,7 +2321,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    diff --git a/docs/pkgdown.css b/docs/pkgdown.css index e788b18a..1273238d 100644 --- a/docs/pkgdown.css +++ b/docs/pkgdown.css @@ -264,16 +264,21 @@ table { /* Syntax highlighting ---------------------------------------------------- */ -pre, pre code { - background-color: #f8f8f8; - color: #333; - white-space: pre-wrap; - word-break: break-all; - overflow-wrap: break-word; +pre { + word-wrap: normal; + word-break: normal; + border: 1px solid #eee; } -pre { - border: 1px solid #eee; +pre, code { + background-color: #f8f8f8; + color: #333; +} + +pre code { + overflow: auto; + word-wrap: normal; + white-space: pre; } pre .img { @@ -300,8 +305,9 @@ a.sourceLine:hover { .kw {color: #264D66;} /* keyword */ .co {color: #888888;} /* comment */ -.error {font-weight: bolder;} -.warning {font-weight: bolder;} +.message { color: black; font-weight: bolder;} +.error { color: orange; font-weight: bolder;} +.warning { color: #6A0366; font-weight: bolder;} /* Clipboard --------------------------*/ diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 956ef70a..7e7048fa 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -80,7 +80,7 @@ $(document).ready(function() { var copyButton = ""; - $("div.sourceCode").addClass("hasCopyButton"); + $(".examples, div.sourceCode").addClass("hasCopyButton"); // Insert copy buttons: $(copyButton).prependTo(".hasCopyButton"); diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index a3f37ada..a84594c2 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,6 +1,6 @@ -pandoc: 2.11.4 -pkgdown: 1.6.1.9001 -pkgdown_sha: ce9781a15c7ea07df9fb17a11295ba4abec0b54b +pandoc: 2.14.0.3 +pkgdown: 1.6.1 +pkgdown_sha: ~ articles: AMR: AMR.html EUCAST: EUCAST.html @@ -12,8 +12,8 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2021-10-06T11:20Z +last_built: 2021-11-28T21:59Z urls: - reference: https://msberends.github.io/AMR/reference - article: https://msberends.github.io/AMR/articles + reference: https://msberends.github.io/AMR//reference + article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/as.disk.html b/docs/reference/as.disk.html index 29856af2..c1e5f570 100644 --- a/docs/reference/as.disk.html +++ b/docs/reference/as.disk.html @@ -58,8 +58,6 @@ - - @@ -71,15 +69,9 @@ - - - - - -
    @@ -238,7 +230,7 @@
    @@ -246,9 +238,11 @@

    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)
    +    
    as.disk(x, na.rm = FALSE)
     
    -is.disk(x)
    +NA_disk_ + +is.disk(x)

    Arguments

    @@ -263,12 +257,16 @@
    +

    Format

    + +

    An object of class disk (inherits from integer) of length 1.

    Value

    An integer with additional class disk

    Details

    Interpret disk values as RSI values with as.rsi(). It supports guidelines from EUCAST and CLSI.

    +

    NA_disk_ is a missing value of the new <disk> class.

    Stable Lifecycle

    @@ -286,7 +284,7 @@ The lifecycle of this function is stable

    as.rsi()

    Examples

    -
    # \donttest{
    +    
    # \donttest{
     # transform existing disk zones to the `disk` class
     df <- data.frame(microorganism = "E. coli",
                      AMP = 20,
    @@ -305,7 +303,7 @@ The lifecycle of this function is stableas.rsi(df)
     # }
    -
    +
    @@ -330,8 +328,6 @@ The lifecycle of this function is stable diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index 3ea86718..cfcf73b5 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -49,7 +49,7 @@ - + @@ -58,8 +58,6 @@ - - @@ -71,15 +69,9 @@ - - - - - -
    @@ -238,17 +230,19 @@
    -

    This ransforms vectors to a new class mic, which treats the input as decimal numbers, while maintaining operators (such as ">=") and only allowing valid MIC values known to the field of (medical) microbiology.

    +

    This transforms vectors to a new class mic, which treats the input as decimal numbers, while maintaining operators (such as ">=") and only allowing valid MIC values known to the field of (medical) microbiology.

    -
    as.mic(x, na.rm = FALSE)
    +    
    as.mic(x, na.rm = FALSE)
     
    -is.mic(x)
    +NA_mic_ + +is.mic(x)

    Arguments

    @@ -263,13 +257,16 @@
    +

    Format

    + +

    An object of class mic (inherits from ordered, factor) of length 1.

    Value

    Ordered factor with additional class mic, that in mathematical operations acts as decimal numbers. Bare in mind that the outcome of any mathematical operation on MICs will return a numeric value.

    Details

    To interpret MIC values as RSI values, use as.rsi() on MIC values. It supports guidelines from EUCAST and CLSI.

    -

    This class for MIC values is a quite a special data type: formally it is an ordered factor with valid MIC values as factor levels (to make sure only valid MIC values are retained), but for any mathematical operation it acts as decimal numbers:

    x <- random_mic(10)
    +

    This class for MIC values is a quite a special data type: formally it is an ordered factor with valid MIC values as factor levels (to make sure only valid MIC values are retained), but for any mathematical operation it acts as decimal numbers:

    x <- random_mic(10)
     x
     #> Class <mic>
     #>  [1] 16     1      8      8      64     >=128  0.0625 32     32     16
    @@ -282,9 +279,9 @@
     
     median(x)
     #> [1] 26
    -
    +
    -

    This makes it possible to maintain operators that often come with MIC values, such ">=" and "<=", even when filtering using numeric values in data analysis, e.g.:

    x[x > 4]
    +

    This makes it possible to maintain operators that often come with MIC values, such ">=" and "<=", even when filtering using numeric values in data analysis, e.g.:

    x[x > 4]
     #> Class <mic>
     #> [1] 16    8     8     64    >=128 32    32    16
     
    @@ -297,9 +294,10 @@
     #> 8     32        A
     #> 9     32        A
     #> 10    16        A
    -
    +

    The following generic functions are implemented for the MIC class: !, !=, %%, %/%, &, *, +, -, /, <, <=, ==, >, >=, ^, |, abs(), acos(), acosh(), all(), any(), asin(), asinh(), atan(), atanh(), ceiling(), cos(), cosh(), cospi(), cummax(), cummin(), cumprod(), cumsum(), digamma(), exp(), expm1(), floor(), gamma(), lgamma(), log(), log1p(), log2(), log10(), max(), mean(), min(), prod(), range(), round(), sign(), signif(), sin(), sinh(), sinpi(), sqrt(), sum(), tan(), tanh(), tanpi(), trigamma() and trunc(). Some functions of the stats package are also implemented: median(), quantile(), mad(), IQR(), fivenum(). Also, boxplot.stats() is supported. Since sd() and var() are non-generic functions, these could not be extended. Use mad() as an alternative, or use e.g. sd(as.numeric(x)) where x is your vector of MIC values.

    +

    NA_mic_ is a missing value of the new <mic> class.

    Stable Lifecycle

    @@ -317,7 +315,7 @@ The lifecycle of this function is stable

    as.rsi()

    Examples

    -
    mic_data <- as.mic(c(">=32", "1.0", "1", "1.00", 8, "<=0.128", "8", "16", "16"))
    +    
    mic_data <- as.mic(c(">=32", "1.0", "1", "1.00", 8, "<=0.128", "8", "16", "16"))
     is.mic(mic_data)
     
     # this can also coerce combined MIC/RSI values:
    @@ -341,7 +339,7 @@ The lifecycle of this function is stable# plot MIC values, see ?plot
     plot(mic_data)
     plot(mic_data, mo = "E. coli", ab = "cipro")
    -
    +
    @@ -240,6 +240,8 @@
    as.rsi(x, ...)
     
    +NA_rsi_
    +
     is.rsi(x)
     
     is.rsi.eligible(x, threshold = 0.05)
    @@ -330,6 +332,9 @@
         
         
     
    +    

    Format

    + +

    An object of class rsi (inherits from ordered, factor) of length 1.

    Value

    Ordered factor with new class <rsi>

    @@ -378,6 +383,7 @@

    The function is.rsi() detects if the input contains class <rsi>. If the input is a data.frame, it iterates over all columns and returns a logical vector.

    The function is.rsi.eligible() returns TRUE when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and FALSE otherwise. The threshold of 5% can be set with the threshold argument. If the input is a data.frame, it iterates over all columns and returns a logical vector.

    +

    NA_rsi_ is a missing value of the new <rsi> class.

    Interpretation of R and S/I

    @@ -509,7 +515,7 @@ The lifecycle of this function is stable
    diff --git a/docs/reference/custom_eucast_rules.html b/docs/reference/custom_eucast_rules.html index e9b3dc68..dda78059 100644 --- a/docs/reference/custom_eucast_rules.html +++ b/docs/reference/custom_eucast_rules.html @@ -58,8 +58,6 @@ - - @@ -71,15 +69,9 @@ - - - - - -
    @@ -238,7 +230,7 @@
    @@ -246,7 +238,7 @@

    Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in eucast_rules().

    -
    custom_eucast_rules(...)
    +
    custom_eucast_rules(...)

    Arguments

    @@ -267,14 +259,14 @@ -

    Basics

    +

    Basics

    -

    If you are familiar with the case_when() function of the dplyr package, you will recognise the input method to set your own rules. Rules must be set using what R considers to be the 'formula notation'. The rule itself is written before the tilde (~) and the consequence of the rule is written after the tilde:

    x <- custom_eucast_rules(TZP == "S" ~ aminopenicillins == "S",
    +

    If you are familiar with the case_when() function of the dplyr package, you will recognise the input method to set your own rules. Rules must be set using what R considers to be the 'formula notation'. The rule itself is written before the tilde (~) and the consequence of the rule is written after the tilde:

    x <- custom_eucast_rules(TZP == "S" ~ aminopenicillins == "S",
                              TZP == "R" ~ aminopenicillins == "R")
    -
    +
    -

    These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work:

    x
    +

    These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work:

    x
     #> A set of custom EUCAST rules:
     #> 
     #>   1. If TZP is S then set to S:
    @@ -282,9 +274,9 @@
     #> 
     #>   2. If TZP is R then set to R:
     #>      amoxicillin (AMX), ampicillin (AMP)
    -
    +
    -

    The rules (the part before the tilde, in above example TZP == "S" and TZP == "R") must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column TZP must exist. We will create a sample data set and test the rules set:

    df <- data.frame(mo = c("E. coli", "K. pneumoniae"),
    +

    The rules (the part before the tilde, in above example TZP == "S" and TZP == "R") must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column TZP must exist. We will create a sample data set and test the rules set:

    df <- data.frame(mo = c("E. coli", "K. pneumoniae"),
                      TZP = "R",
                      amox = "",
                      AMP = "")
    @@ -297,23 +289,23 @@
     #>              mo TZP amox AMP
     #> 1       E. coli   R    R   R     
     #> 2 K. pneumoniae   R    R   R  
    -
    +
    -

    Using taxonomic properties in rules

    +

    Using taxonomic properties in rules

    -

    There is one exception in variables used for the rules: all column names of the microorganisms data set can also be used, but do not have to exist in the data set. These column names are: mo, fullname, kingdom, phylum, class, order, family, genus, species, subspecies, rank, ref, species_id, source, prevalence and snomed. Thus, this next example will work as well, despite the fact that the df data set does not contain a column genus:

    y <- custom_eucast_rules(TZP == "S" & genus == "Klebsiella" ~ aminopenicillins == "S",
    +

    There is one exception in variables used for the rules: all column names of the microorganisms data set can also be used, but do not have to exist in the data set. These column names are: mo, fullname, kingdom, phylum, class, order, family, genus, species, subspecies, rank, ref, species_id, source, prevalence and snomed. Thus, this next example will work as well, despite the fact that the df data set does not contain a column genus:

    y <- custom_eucast_rules(TZP == "S" & genus == "Klebsiella" ~ aminopenicillins == "S",
                              TZP == "R" & genus == "Klebsiella" ~ aminopenicillins == "R")
     
     eucast_rules(df, rules = "custom", custom_rules = y)
     #>              mo TZP amox AMP
     #> 1       E. coli   R         
     #> 2 K. pneumoniae   R    R   R
    -
    +
    -

    Usage of antibiotic group names

    +

    Usage of antibiotic group names

    It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part after the tilde. In above examples, the antibiotic group aminopenicillins is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the agents that will be matched when running the rule.

      @@ -348,12 +340,13 @@
    -

    Maturing Lifecycle

    +

    Stable Lifecycle

    -


    -The lifecycle of this function is maturing. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome to suggest changes at our repository or write us an email (see section 'Contact Us').

    +


    +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 argument 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!

    @@ -361,7 +354,7 @@ The lifecycle of this function is maturing<

    On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR data analysis, the complete documentation of all functions and an example analysis using WHONET data.

    Examples

    -
    x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
    +    
    x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
                              AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
     eucast_rules(example_isolates,
                  rules = "custom",
    @@ -372,7 +365,7 @@ The lifecycle of this function is maturing<
     x2 <- c(x,
             custom_eucast_rules(TZP == "R" ~ carbapenems == "R"))
     x2
    -
    + @@ -247,7 +247,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied rules = getOption("AMR_eucastrules", default = c("breakpoints", "expert")), verbose = FALSE, version_breakpoints = 11, - version_expertrules = 3.2, + version_expertrules = 3.3, ampc_cephalosporin_resistance = NA, only_rsi_columns = FALSE, custom_rules = NULL, @@ -285,7 +285,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
    - + @@ -321,6 +321,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied Leclercq et al. EUCAST expert rules in antimicrobial susceptibility testing. Clin Microbiol Infect. 2013;19(2):141-60; doi: 10.1111/j.1469-0691.2011.03703.x

  • EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016. (link)

  • EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.2, 2020. (link)

  • +
  • EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.3, 2021. (link)

  • EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 9.0, 2019. (link)

  • EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 10.0, 2020. (link)

  • EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 11.0, 2021. (link)

  • @@ -434,7 +435,7 @@ The lifecycle of this function is stable
    diff --git a/docs/reference/index.html b/docs/reference/index.html index f940b4b5..b8087c6b 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -84,7 +84,7 @@ AMR (for R) - 1.7.1.9053 + 1.7.1.9054
    @@ -322,19 +322,19 @@
    @@ -681,7 +681,7 @@
    diff --git a/docs/reference/italicise_taxonomy.html b/docs/reference/italicise_taxonomy.html index 9df7ec0d..b1d852e6 100644 --- a/docs/reference/italicise_taxonomy.html +++ b/docs/reference/italicise_taxonomy.html @@ -58,8 +58,6 @@ - - @@ -71,15 +69,9 @@ - - - - - -
    @@ -238,7 +230,7 @@
    @@ -246,9 +238,9 @@

    According to the binomial nomenclature, the lowest four taxonomic levels (family, genus, species, subspecies) should be printed in italic. This function finds taxonomic names within strings and makes them italic.

    -
    italicise_taxonomy(string, type = c("markdown", "ansi"))
    +    
    italicise_taxonomy(string, type = c("markdown", "ansi"))
     
    -italicize_taxonomy(string, type = c("markdown", "ansi"))
    +italicize_taxonomy(string, type = c("markdown", "ansi"))

    Arguments

    version_expertrules

    the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be either "3.2" or "3.1".

    the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be either "3.3", "3.2" or "3.1".

    ampc_cephalosporin_resistance
    -

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

    +

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

    Interpret MIC and Disk Values, or Clean Raw R/SI Data

    -

    as.mic() is.mic()

    +

    as.mic() NA_mic_ is.mic()

    Transform Input to Minimum Inhibitory Concentrations (MIC)

    -

    as.disk() is.disk()

    +

    as.disk() NA_disk_ is.disk()

    Transform Input to Disk Diffusion Diameters

    @@ -268,12 +260,13 @@

    This function finds the taxonomic names and makes them italic based on the microorganisms data set.

    The taxonomic names can be italicised using markdown (the default) by adding * before and after the taxonomic names, or using ANSI colours by adding \033[3m before and \033[23m after the taxonomic names. If multiple ANSI colours are not available, no conversion will occur.

    This function also supports abbreviation of the genus if it is followed by a species, such as "E. coli" and "K. pneumoniae ozaenae".

    -

    Maturing Lifecycle

    +

    Stable Lifecycle

    -


    -The lifecycle of this function is maturing. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome to suggest changes at our repository or write us an email (see section 'Contact Us').

    +


    +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 argument 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!

    @@ -281,7 +274,7 @@ The lifecycle of this function is maturing<

    On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR data analysis, the complete documentation of all functions and an example analysis using WHONET data.

    Examples

    -
    italicise_taxonomy("An overview of Staphylococcus aureus isolates")
    +    
    italicise_taxonomy("An overview of Staphylococcus aureus isolates")
     italicise_taxonomy("An overview of S. aureus isolates")
     
     cat(italicise_taxonomy("An overview of S. aureus isolates", type = "ansi"))
    @@ -295,7 +288,7 @@ The lifecycle of this function is maturing<
         theme(plot.title = ggtext::element_markdown())
     }
     # }
    -
    + @@ -254,7 +254,7 @@ ) # S3 method for mic -autoplot( +autoplot( object, mo = NULL, ab = NULL, @@ -269,7 +269,7 @@ ) # S3 method for mic -fortify(object, ...) +fortify(object, ...) # S3 method for disk plot( @@ -287,7 +287,7 @@ ) # S3 method for disk -autoplot( +autoplot( object, mo = NULL, ab = NULL, @@ -302,7 +302,7 @@ ) # S3 method for disk -fortify(object, ...) +fortify(object, ...) # S3 method for rsi plot( @@ -314,7 +314,7 @@ ) # S3 method for rsi -autoplot( +autoplot( object, title = paste("Resistance Overview of", deparse(substitute(object))), xlab = "Antimicrobial Interpretation", @@ -325,7 +325,7 @@ ) # S3 method for rsi -fortify(object, ...) +fortify(object, ...)

    Arguments

    @@ -381,12 +381,13 @@

    The interpretation of "I" will be named "Increased exposure" for all EUCAST guidelines since 2019, and will be named "Intermediate" in all other cases.

    For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the guideline argument are: "EUCAST 2021", "EUCAST 2020", "EUCAST 2019", "EUCAST 2018", "EUCAST 2017", "EUCAST 2016", "EUCAST 2015", "EUCAST 2014", "EUCAST 2013", "EUCAST 2012", "EUCAST 2011", "CLSI 2020", "CLSI 2019", "CLSI 2018", "CLSI 2017", "CLSI 2016", "CLSI 2015", "CLSI 2014", "CLSI 2013", "CLSI 2012", "CLSI 2011" and "CLSI 2010".

    Simply using "CLSI" or "EUCAST" as input will automatically select the latest version of that guideline.

    -

    Maturing Lifecycle

    +

    Stable Lifecycle

    -


    -The lifecycle of this function is maturing. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome to suggest changes at our repository or write us an email (see section 'Contact Us').

    +


    +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 argument 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!

    @@ -425,7 +426,7 @@ The lifecycle of this function is maturing<
    diff --git a/docs/sitemap.xml b/docs/sitemap.xml index f25e4d27..26ef4cd7 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -1,219 +1,198 @@ - https://msberends.github.io/AMR/404.html + https://msberends.github.io/AMR//index.html - https://msberends.github.io/AMR/LICENSE-text.html + https://msberends.github.io/AMR//reference/AMR-deprecated.html - https://msberends.github.io/AMR/articles/AMR.html + https://msberends.github.io/AMR//reference/AMR.html - https://msberends.github.io/AMR/articles/EUCAST.html + https://msberends.github.io/AMR//reference/WHOCC.html - https://msberends.github.io/AMR/articles/MDR.html + https://msberends.github.io/AMR//reference/WHONET.html - https://msberends.github.io/AMR/articles/PCA.html + https://msberends.github.io/AMR//reference/ab_from_text.html - https://msberends.github.io/AMR/articles/SPSS.html + https://msberends.github.io/AMR//reference/ab_property.html - https://msberends.github.io/AMR/articles/WHONET.html + https://msberends.github.io/AMR//reference/age.html - https://msberends.github.io/AMR/articles/benchmarks.html + https://msberends.github.io/AMR//reference/age_groups.html - https://msberends.github.io/AMR/articles/datasets.html + https://msberends.github.io/AMR//reference/antibiotic_class_selectors.html - https://msberends.github.io/AMR/articles/index.html + https://msberends.github.io/AMR//reference/antibiotics.html - https://msberends.github.io/AMR/articles/resistance_predict.html + https://msberends.github.io/AMR//reference/as.ab.html - https://msberends.github.io/AMR/articles/welcome_to_AMR.html + https://msberends.github.io/AMR//reference/as.disk.html - https://msberends.github.io/AMR/authors.html + https://msberends.github.io/AMR//reference/as.mic.html - https://msberends.github.io/AMR/index.html + https://msberends.github.io/AMR//reference/as.mo.html - https://msberends.github.io/AMR/news/index.html + https://msberends.github.io/AMR//reference/as.rsi.html - https://msberends.github.io/AMR/reference/AMR-deprecated.html + https://msberends.github.io/AMR//reference/atc_online.html - https://msberends.github.io/AMR/reference/AMR.html + https://msberends.github.io/AMR//reference/availability.html - https://msberends.github.io/AMR/reference/WHOCC.html + https://msberends.github.io/AMR//reference/bug_drug_combinations.html - https://msberends.github.io/AMR/reference/WHONET.html + https://msberends.github.io/AMR//reference/catalogue_of_life.html - https://msberends.github.io/AMR/reference/ab_from_text.html + https://msberends.github.io/AMR//reference/catalogue_of_life_version.html - https://msberends.github.io/AMR/reference/ab_property.html + https://msberends.github.io/AMR//reference/count.html - https://msberends.github.io/AMR/reference/age.html + https://msberends.github.io/AMR//reference/custom_eucast_rules.html - https://msberends.github.io/AMR/reference/age_groups.html + https://msberends.github.io/AMR//reference/dosage.html - https://msberends.github.io/AMR/reference/antibiotic_class_selectors.html + https://msberends.github.io/AMR//reference/eucast_rules.html - https://msberends.github.io/AMR/reference/antibiotics.html + https://msberends.github.io/AMR//reference/example_isolates.html - https://msberends.github.io/AMR/reference/as.ab.html + https://msberends.github.io/AMR//reference/example_isolates_unclean.html - https://msberends.github.io/AMR/reference/as.disk.html + https://msberends.github.io/AMR//reference/first_isolate.html - https://msberends.github.io/AMR/reference/as.mic.html + https://msberends.github.io/AMR//reference/g.test.html - https://msberends.github.io/AMR/reference/as.mo.html + https://msberends.github.io/AMR//reference/get_episode.html - https://msberends.github.io/AMR/reference/as.rsi.html + https://msberends.github.io/AMR//reference/ggplot_pca.html - https://msberends.github.io/AMR/reference/atc_online.html + https://msberends.github.io/AMR//reference/ggplot_rsi.html - https://msberends.github.io/AMR/reference/availability.html + https://msberends.github.io/AMR//reference/guess_ab_col.html - https://msberends.github.io/AMR/reference/bug_drug_combinations.html + https://msberends.github.io/AMR//reference/intrinsic_resistant.html - https://msberends.github.io/AMR/reference/catalogue_of_life.html + https://msberends.github.io/AMR//reference/italicise_taxonomy.html - https://msberends.github.io/AMR/reference/catalogue_of_life_version.html + https://msberends.github.io/AMR//reference/join.html - https://msberends.github.io/AMR/reference/count.html + https://msberends.github.io/AMR//reference/key_antimicrobials.html - https://msberends.github.io/AMR/reference/custom_eucast_rules.html + https://msberends.github.io/AMR//reference/kurtosis.html - https://msberends.github.io/AMR/reference/dosage.html + https://msberends.github.io/AMR//reference/lifecycle.html - https://msberends.github.io/AMR/reference/eucast_rules.html + https://msberends.github.io/AMR//reference/like.html - https://msberends.github.io/AMR/reference/example_isolates.html + https://msberends.github.io/AMR//reference/mdro.html - https://msberends.github.io/AMR/reference/example_isolates_unclean.html + https://msberends.github.io/AMR//reference/microorganisms.html - https://msberends.github.io/AMR/reference/first_isolate.html + https://msberends.github.io/AMR//reference/microorganisms.codes.html - https://msberends.github.io/AMR/reference/g.test.html + https://msberends.github.io/AMR//reference/microorganisms.old.html - https://msberends.github.io/AMR/reference/get_episode.html + https://msberends.github.io/AMR//reference/mo_matching_score.html - https://msberends.github.io/AMR/reference/ggplot_pca.html + https://msberends.github.io/AMR//reference/mo_property.html - https://msberends.github.io/AMR/reference/ggplot_rsi.html + https://msberends.github.io/AMR//reference/mo_source.html - https://msberends.github.io/AMR/reference/guess_ab_col.html + https://msberends.github.io/AMR//reference/pca.html - https://msberends.github.io/AMR/reference/index.html + https://msberends.github.io/AMR//reference/plot.html - https://msberends.github.io/AMR/reference/intrinsic_resistant.html + https://msberends.github.io/AMR//reference/proportion.html - https://msberends.github.io/AMR/reference/italicise_taxonomy.html + https://msberends.github.io/AMR//reference/random.html - https://msberends.github.io/AMR/reference/join.html + https://msberends.github.io/AMR//reference/resistance_predict.html - https://msberends.github.io/AMR/reference/key_antimicrobials.html + https://msberends.github.io/AMR//reference/rsi_translation.html - https://msberends.github.io/AMR/reference/kurtosis.html + https://msberends.github.io/AMR//reference/skewness.html - https://msberends.github.io/AMR/reference/lifecycle.html + https://msberends.github.io/AMR//reference/translate.html - https://msberends.github.io/AMR/reference/like.html + https://msberends.github.io/AMR//articles/AMR.html - https://msberends.github.io/AMR/reference/mdro.html + https://msberends.github.io/AMR//articles/EUCAST.html - https://msberends.github.io/AMR/reference/microorganisms.codes.html + https://msberends.github.io/AMR//articles/MDR.html - https://msberends.github.io/AMR/reference/microorganisms.html + https://msberends.github.io/AMR//articles/PCA.html - https://msberends.github.io/AMR/reference/microorganisms.old.html + https://msberends.github.io/AMR//articles/SPSS.html - https://msberends.github.io/AMR/reference/mo_matching_score.html + https://msberends.github.io/AMR//articles/WHONET.html - https://msberends.github.io/AMR/reference/mo_property.html + https://msberends.github.io/AMR//articles/benchmarks.html - https://msberends.github.io/AMR/reference/mo_source.html + https://msberends.github.io/AMR//articles/datasets.html - https://msberends.github.io/AMR/reference/pca.html + https://msberends.github.io/AMR//articles/resistance_predict.html - https://msberends.github.io/AMR/reference/plot.html - - - https://msberends.github.io/AMR/reference/proportion.html - - - https://msberends.github.io/AMR/reference/random.html - - - https://msberends.github.io/AMR/reference/resistance_predict.html - - - https://msberends.github.io/AMR/reference/rsi_translation.html - - - https://msberends.github.io/AMR/reference/skewness.html - - - https://msberends.github.io/AMR/reference/translate.html - - - https://msberends.github.io/AMR/survey.html + https://msberends.github.io/AMR//articles/welcome_to_AMR.html diff --git a/docs/survey.html b/docs/survey.html index 128ee16a..371f8683 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -57,8 +57,6 @@ - - @@ -70,15 +68,9 @@ - - - - - -
    @@ -255,11 +247,11 @@ @@ -268,8 +260,6 @@ - - diff --git a/index.md b/index.md index 709a3e0f..83c0c684 100644 --- a/index.md +++ b/index.md @@ -1,20 +1,20 @@ # `AMR` (for R) -> This package formed the basis of two PhD theses, of which the first was published and defended on 25 August 2021. Click here to read it: [DOI 10.33612/diss.177417131](https://doi.org/10.33612/diss.177417131). +> Update: The latest EUCAST guideline for intrinsic resistance (v3.3, October 2021) is now supported, and our taxonomy tables has been updated as well (5 October 2021). ### What is `AMR` (for R)? -`AMR` is a free, open-source and independent [R package](https://www.r-project.org) to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. **Our aim is to provide a standard** for clean and reproducible AMR data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting. +`AMR` is a free, open-source and independent [R package](https://www.r-project.org) (see [Copyright](#copyright)) to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. **Our aim is to provide a standard** for clean and reproducible AMR data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting. After installing this package, R knows [**~71,000 distinct microbial species**](./reference/microorganisms.html) and all [**~560 antibiotic, antimycotic and antiviral drugs**](./reference/antibiotics.html) by name and code (including ATC, EARS-Net, PubChem, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data. Antimicrobial names and group names are available in Danish, Dutch, English, French, German, Italian, Portuguese and Spanish. -This package is [fully independent of any other R package](https://en.wikipedia.org/wiki/Dependency_hell) and works on Windows, macOS and Linux with all versions of R since R-3.0.0 (April 2013). **It was designed to work in any setting, including those with very limited resources**. It was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the [University of Groningen](https://www.rug.nl), in collaboration with non-profit organisations [Certe Medical Diagnostics and Advice Foundation](https://www.certe.nl) and [University Medical Center Groningen](https://www.umcg.nl). This R package is [actively maintained](./news) and is free software (see [Copyright](#copyright)). +This package is [fully independent of any other R package](https://en.wikipedia.org/wiki/Dependency_hell) and works on Windows, macOS and Linux with all versions of R since R-3.0.0 (April 2013). **It was designed to work in any setting, including those with very limited resources**. It was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the [University of Groningen](https://www.rug.nl), in collaboration with non-profit organisations [Certe Medical Diagnostics and Advice Foundation](https://www.certe.nl) and [University Medical Center Groningen](https://www.umcg.nl). This R package formed the basis of two PhD theses ([DOI 10.33612/diss.177417131](https://doi.org/10.33612/diss.177417131) and [DOI 10.33612/diss.177417131](https://doi.org/10.33612/diss.192486375)) but is [actively and durably maintained](./news) by two public healthcare organisations in the Netherlands.

    - Used in 162 countries
    - Since its first public release in early 2018, this package has been downloaded from 162 countries. Click the map to enlarge and to see the country names.

    + Used in 175 countries
    + Since its first public release in early 2018, this R package has been used in almost all countries in the world. Click the map to enlarge and to see the country names.

    ##### With `AMR` (for R), there's always a knowledgeable microbiologist by your side! diff --git a/inst/CITATION b/inst/CITATION index 63e5f811..8774e047 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -8,9 +8,10 @@ citEntry( journal = "Journal of Statistical Software", pages = "Accepted for publication", year = 2021, - url = "https://www.biorxiv.org/content/10.1101/810622v4", + url = "https://www.biorxiv.org/content/10.1101/810622", textVersion = "Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C (2021). AMR - An R Package for Working with -Antimicrobial Resistance Data. Journal of Statistical Software (accepted for publication), https://www.biorxiv.org/content/10.1101/810622v4.") +Antimicrobial Resistance Data. Journal of Statistical Software (accepted for publication), https://www.biorxiv.org/content/10.1101/810622, doi: 10.1101/810622." +) citEntry( entry = "PhdThesis", @@ -19,7 +20,19 @@ citEntry( publisher = "University of Groningen", school = "University of Groningen", doi = "10.33612/diss.177417131", - pages = 288, + pages = 287, year = 2021, textVersion = "Berends, MS (2021). A New Instrument for Microbial Epidemiology: Empowering Antimicrobial Resistance Data Analysis (PhD thesis). University of Groningen, doi: 10.33612/diss.177417131." ) + +citEntry( + entry = "PhdThesis", + title = "Data Science for Infection Management & Antimicrobial Stewardship", + author = "C F Luz", + publisher = "University of Groningen", + school = "University of Groningen", + doi = "10.33612/diss.192486375", + pages = 326, + year = 2021, + textVersion = "Luz, CF (2021). Data Science for Infection Management & Antimicrobial Stewardship (PhD thesis). University of Groningen, doi: 10.33612/diss.192486375." +) diff --git a/man/as.disk.Rd b/man/as.disk.Rd index 4b239a88..864ae3ed 100644 --- a/man/as.disk.Rd +++ b/man/as.disk.Rd @@ -1,13 +1,20 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/disk.R +\docType{data} \name{as.disk} \alias{as.disk} \alias{disk} +\alias{NA_disk_} \alias{is.disk} \title{Transform Input to Disk Diffusion Diameters} +\format{ +An object of class \code{disk} (inherits from \code{integer}) of length 1. +} \usage{ as.disk(x, na.rm = FALSE) +NA_disk_ + is.disk(x) } \arguments{ @@ -23,6 +30,8 @@ This transforms a vector to a new class \code{\link{disk}}, which is a disk diff } \details{ Interpret disk values as RSI values with \code{\link[=as.rsi]{as.rsi()}}. It supports guidelines from EUCAST and CLSI. + +\code{NA_disk_} is a missing value of the new \verb{} class. } \section{Stable Lifecycle}{ @@ -61,3 +70,4 @@ as.rsi(df) \seealso{ \code{\link[=as.rsi]{as.rsi()}} } +\keyword{datasets} diff --git a/man/as.mic.Rd b/man/as.mic.Rd index 6f45fe9b..39c98e5f 100755 --- a/man/as.mic.Rd +++ b/man/as.mic.Rd @@ -1,13 +1,20 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/mic.R +\docType{data} \name{as.mic} \alias{as.mic} \alias{mic} +\alias{NA_mic_} \alias{is.mic} \title{Transform Input to Minimum Inhibitory Concentrations (MIC)} +\format{ +An object of class \code{mic} (inherits from \code{ordered}, \code{factor}) of length 1. +} \usage{ as.mic(x, na.rm = FALSE) +NA_mic_ + is.mic(x) } \arguments{ @@ -19,7 +26,7 @@ is.mic(x) Ordered \link{factor} with additional class \code{\link{mic}}, that in mathematical operations acts as decimal numbers. Bare in mind that the outcome of any mathematical operation on MICs will return a \link{numeric} value. } \description{ -This ransforms vectors to a new class \code{\link{mic}}, which treats the input as decimal numbers, while maintaining operators (such as ">=") and only allowing valid MIC values known to the field of (medical) microbiology. +This transforms vectors to a new class \code{\link{mic}}, which treats the input as decimal numbers, while maintaining operators (such as ">=") and only allowing valid MIC values known to the field of (medical) microbiology. } \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. @@ -55,6 +62,8 @@ subset(df, x > 4) # or with dplyr: df \%>\% filter(x > 4) } The following \link[=groupGeneric]{generic functions} are implemented for the MIC class: \code{!}, \code{!=}, \code{\%\%}, \code{\%/\%}, \code{&}, \code{*}, \code{+}, \code{-}, \code{/}, \code{<}, \code{<=}, \code{==}, \code{>}, \code{>=}, \code{^}, \code{|}, \code{\link[=abs]{abs()}}, \code{\link[=acos]{acos()}}, \code{\link[=acosh]{acosh()}}, \code{\link[=all]{all()}}, \code{\link[=any]{any()}}, \code{\link[=asin]{asin()}}, \code{\link[=asinh]{asinh()}}, \code{\link[=atan]{atan()}}, \code{\link[=atanh]{atanh()}}, \code{\link[=ceiling]{ceiling()}}, \code{\link[=cos]{cos()}}, \code{\link[=cosh]{cosh()}}, \code{\link[=cospi]{cospi()}}, \code{\link[=cummax]{cummax()}}, \code{\link[=cummin]{cummin()}}, \code{\link[=cumprod]{cumprod()}}, \code{\link[=cumsum]{cumsum()}}, \code{\link[=digamma]{digamma()}}, \code{\link[=exp]{exp()}}, \code{\link[=expm1]{expm1()}}, \code{\link[=floor]{floor()}}, \code{\link[=gamma]{gamma()}}, \code{\link[=lgamma]{lgamma()}}, \code{\link[=log]{log()}}, \code{\link[=log1p]{log1p()}}, \code{\link[=log2]{log2()}}, \code{\link[=log10]{log10()}}, \code{\link[=max]{max()}}, \code{\link[=mean]{mean()}}, \code{\link[=min]{min()}}, \code{\link[=prod]{prod()}}, \code{\link[=range]{range()}}, \code{\link[=round]{round()}}, \code{\link[=sign]{sign()}}, \code{\link[=signif]{signif()}}, \code{\link[=sin]{sin()}}, \code{\link[=sinh]{sinh()}}, \code{\link[=sinpi]{sinpi()}}, \code{\link[=sqrt]{sqrt()}}, \code{\link[=sum]{sum()}}, \code{\link[=tan]{tan()}}, \code{\link[=tanh]{tanh()}}, \code{\link[=tanpi]{tanpi()}}, \code{\link[=trigamma]{trigamma()}} and \code{\link[=trunc]{trunc()}}. Some functions of the \code{stats} package are also implemented: \code{\link[=median]{median()}}, \code{\link[=quantile]{quantile()}}, \code{\link[=mad]{mad()}}, \code{\link[=IQR]{IQR()}}, \code{\link[=fivenum]{fivenum()}}. Also, \code{\link[=boxplot.stats]{boxplot.stats()}} is supported. Since \code{\link[=sd]{sd()}} and \code{\link[=var]{var()}} are non-generic functions, these could not be extended. Use \code{\link[=mad]{mad()}} as an alternative, or use e.g. \code{sd(as.numeric(x))} where \code{x} is your vector of MIC values. + +\code{NA_mic_} is a missing value of the new \verb{} class. } \section{Stable Lifecycle}{ @@ -98,3 +107,4 @@ plot(mic_data, mo = "E. coli", ab = "cipro") \seealso{ \code{\link[=as.rsi]{as.rsi()}} } +\keyword{datasets} diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd index 21c7e4e5..a38a3892 100755 --- a/man/as.rsi.Rd +++ b/man/as.rsi.Rd @@ -1,17 +1,24 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/rsi.R +\docType{data} \name{as.rsi} \alias{as.rsi} \alias{rsi} +\alias{NA_rsi_} \alias{is.rsi} \alias{is.rsi.eligible} \alias{as.rsi.mic} \alias{as.rsi.disk} \alias{as.rsi.data.frame} \title{Interpret MIC and Disk Values, or Clean Raw R/SI Data} +\format{ +An object of class \code{rsi} (inherits from \code{ordered}, \code{factor}) of length 1. +} \usage{ as.rsi(x, ...) +NA_rsi_ + is.rsi(x) is.rsi.eligible(x, threshold = 0.05) @@ -125,6 +132,8 @@ The function \code{\link[=is.rsi]{is.rsi()}} detects if the input contains class The function \code{\link[=is.rsi.eligible]{is.rsi.eligible()}} returns \code{TRUE} when a columns contains at most 5\% invalid antimicrobial interpretations (not S and/or I and/or R), and \code{FALSE} otherwise. The threshold of 5\% can be set with the \code{threshold} argument. If the input is a \link{data.frame}, it iterates over all columns and returns a \link{logical} vector. } + +\code{NA_rsi_} is a missing value of the new \verb{} class. } \section{Interpretation of R and S/I}{ @@ -247,3 +256,4 @@ if (require("dplyr")) { \seealso{ \code{\link[=as.mic]{as.mic()}}, \code{\link[=as.disk]{as.disk()}}, \code{\link[=as.mo]{as.mo()}} } +\keyword{datasets} diff --git a/man/custom_eucast_rules.Rd b/man/custom_eucast_rules.Rd index 67bb980a..46628b92 100644 --- a/man/custom_eucast_rules.Rd +++ b/man/custom_eucast_rules.Rd @@ -100,10 +100,12 @@ It is possible to define antibiotic groups instead of single antibiotics for the } } -\section{Maturing Lifecycle}{ +\section{Stable Lifecycle}{ -\if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \cr} -The \link[=lifecycle]{lifecycle} of this function is \strong{maturing}. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome \href{https://github.com/msberends/AMR/issues}{to suggest changes at our repository} or \link[=AMR]{write us an email (see section 'Contact Us')}. +\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 argument 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/eucast_rules.Rd b/man/eucast_rules.Rd index a0e45465..4508378e 100644 --- a/man/eucast_rules.Rd +++ b/man/eucast_rules.Rd @@ -11,6 +11,7 @@ Leclercq et al. \strong{EUCAST expert rules in antimicrobial susceptibility testing.} \emph{Clin Microbiol Infect.} 2013;19(2):141-60; \doi{https://doi.org/10.1111/j.1469-0691.2011.03703.x} \item EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016. \href{https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}{(link)} \item EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.2, 2020. \href{https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf}{(link)} +\item EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.3, 2021. \href{https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2021/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.3_20211018.pdf}{(link)} \item EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 9.0, 2019. \href{https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_9.0_Breakpoint_Tables.xlsx}{(link)} \item EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 10.0, 2020. \href{https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_10.0_Breakpoint_Tables.xlsx}{(link)} \item EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 11.0, 2021. \href{https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_11.0_Breakpoint_Tables.xlsx}{(link)} @@ -24,7 +25,7 @@ eucast_rules( rules = getOption("AMR_eucastrules", default = c("breakpoints", "expert")), verbose = FALSE, version_breakpoints = 11, - version_expertrules = 3.2, + version_expertrules = 3.3, ampc_cephalosporin_resistance = NA, only_rsi_columns = FALSE, custom_rules = NULL, @@ -46,7 +47,7 @@ eucast_dosage(ab, administration = "iv", version_breakpoints = 11) \item{version_breakpoints}{the version number to use for the EUCAST Clinical Breakpoints guideline. Can be either "11.0" or "10.0".} -\item{version_expertrules}{the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be either "3.2" or "3.1".} +\item{version_expertrules}{the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be either "3.3", "3.2" or "3.1".} \item{ampc_cephalosporin_resistance}{a \link{character} value that should be applied to cefotaxime, ceftriaxone and ceftazidime for AmpC de-repressed cephalosporin-resistant mutants, defaults to \code{NA}. Currently only works when \code{version_expertrules} is \code{3.2}; '\emph{EUCAST Expert Rules v3.2 on Enterobacterales}' states that results of cefotaxime, ceftriaxone and ceftazidime should be reported with a note, or results should be suppressed (emptied) for these three agents. A value of \code{NA} (the default) for this argument will remove results for these three agents, while e.g. a value of \code{"R"} will make the results for these agents resistant. Use \code{NULL} or \code{FALSE} to not alter results for these three agents of AmpC de-repressed cephalosporin-resistant mutants. Using \code{TRUE} is equal to using \code{"R"}. \cr For \emph{EUCAST Expert Rules} v3.2, this rule applies to: \emph{Citrobacter braakii}, \emph{Citrobacter freundii}, \emph{Citrobacter gillenii}, \emph{Citrobacter murliniae}, \emph{Citrobacter rodenticum}, \emph{Citrobacter sedlakii}, \emph{Citrobacter werkmanii}, \emph{Citrobacter youngae}, \emph{Enterobacter}, \emph{Hafnia alvei}, \emph{Klebsiella aerogenes}, \emph{Morganella morganii}, \emph{Providencia} and \emph{Serratia}.} diff --git a/man/italicise_taxonomy.Rd b/man/italicise_taxonomy.Rd index c4073ae4..20edd3b5 100644 --- a/man/italicise_taxonomy.Rd +++ b/man/italicise_taxonomy.Rd @@ -24,10 +24,12 @@ The taxonomic names can be italicised using markdown (the default) by adding \co This function also supports abbreviation of the genus if it is followed by a species, such as "E. coli" and "K. pneumoniae ozaenae". } -\section{Maturing Lifecycle}{ +\section{Stable Lifecycle}{ -\if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \cr} -The \link[=lifecycle]{lifecycle} of this function is \strong{maturing}. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome \href{https://github.com/msberends/AMR/issues}{to suggest changes at our repository} or \link[=AMR]{write us an email (see section 'Contact Us')}. +\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 argument 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/plot.Rd b/man/plot.Rd index 484f5fdc..2ebf7f66 100644 --- a/man/plot.Rd +++ b/man/plot.Rd @@ -129,10 +129,12 @@ For interpreting MIC values as well as disk diffusion diameters, supported guide Simply using \code{"CLSI"} or \code{"EUCAST"} as input will automatically select the latest version of that guideline. } -\section{Maturing Lifecycle}{ +\section{Stable Lifecycle}{ -\if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \cr} -The \link[=lifecycle]{lifecycle} of this function is \strong{maturing}. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome \href{https://github.com/msberends/AMR/issues}{to suggest changes at our repository} or \link[=AMR]{write us an email (see section 'Contact Us')}. +\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 argument 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/pkgdown/extra.css b/pkgdown/extra.css index 84f4f6a6..4d62d65f 100644 --- a/pkgdown/extra.css +++ b/pkgdown/extra.css @@ -104,10 +104,7 @@ a pre[href], a pre[href]:hover, a pre[href]:focus { /* syntax font */ pre, code { - font-family: 'Courier New', monospace; - font-size: 100% !important; - font-weight: bold; - /*background-color: #f4f4f4*/; + font-size: 95% !important; } pre code { word-wrap: normal !important; diff --git a/pkgdown/extra.js b/pkgdown/extra.js index 7f02db35..8a0a87a5 100644 --- a/pkgdown/extra.js +++ b/pkgdown/extra.js @@ -95,10 +95,12 @@ $(document).ready(function() { function doct_tit(x) { if (typeof(x) != "undefined") { // authors - x = x.replace(/Author, maintainer/g, "Main developer"); - x = x.replace(/Author, contributor/g, "Main contributor"); + x = x.replace(/Author, maintainer/g, "Maintainer"); + x = x.replace(/Author, contributor/g, "Maintainer"); x = x.replace(/Author, thesis advisor/g, "Doctoral advisor"); + x = x.replace(/Thesis advisor/g, "Doctoral advisor"); x = x.replace("Matthijs", "Dr. Matthijs"); + x = x.replace("Christian", "Dr. Christian"); x = x.replace("Alex", "Prof. Alex"); x = x.replace("Bhanu", "Prof. Bhanu"); x = x.replace("Casper", "Prof. Casper"); diff --git a/pkgdown/logos/countries.png b/pkgdown/logos/countries.png index 37b14061..fa8cf7eb 100644 Binary files a/pkgdown/logos/countries.png and b/pkgdown/logos/countries.png differ diff --git a/pkgdown/logos/countries_large.png b/pkgdown/logos/countries_large.png index 5c81f9dc..afdd09dc 100644 Binary files a/pkgdown/logos/countries_large.png and b/pkgdown/logos/countries_large.png differ diff --git a/vignettes/welcome_to_AMR.Rmd b/vignettes/welcome_to_AMR.Rmd index db35480a..96308f53 100644 --- a/vignettes/welcome_to_AMR.Rmd +++ b/vignettes/welcome_to_AMR.Rmd @@ -22,13 +22,13 @@ knitr::opts_chunk$set( ) ``` -Note: to keep the package as small as possible, we only included this vignette. You can read more vignettes on our website about how to conduct AMR data analysis, determine MDRO's, find explanation of EUCAST rules, and much more: . +Note: to keep the package size as small as possible, we only included this vignette on CRAN. You can read more vignettes on our website about how to conduct AMR data analysis, determine MDRO's, find explanation of EUCAST rules, and much more: . ---- -`AMR` is a free, open-source and independent R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. **Our aim is to provide a standard** for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting. +`AMR` is a free, open-source and independent R package (see [Copyright](https://msberends.github.io/AMR/#copyright)) to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. **Our aim is to provide a standard** for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting. -After installing this package, R knows `r AMR:::format_included_data_number(AMR::microorganisms)` distinct microbial species and all `r AMR:::format_included_data_number(rbind(AMR::antibiotics[, "atc", drop = FALSE], AMR::antivirals[, "atc", drop = FALSE]))` antibiotic, antimycotic and antiviral drugs by name and code (including ATC, EARS-NET, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data. +After installing this package, R knows `r AMR:::format_included_data_number(AMR::microorganisms)` distinct microbial species and all `r AMR:::format_included_data_number(rbind(AMR::antibiotics[, "atc", drop = FALSE], AMR::antivirals[, "atc", drop = FALSE]))` antibiotic, antimycotic and antiviral drugs by name and code (including ATC, EARS-Net, PubChem, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data. Antimicrobial names and group names are available in Danish, Dutch, English, French, German, Italian, Portuguese and Spanish. This package is fully independent of any other R package and works on Windows, macOS and Linux with all versions of R since R-3.0.0 (April 2013). **It was designed to work in any setting, including those with very limited resources**. Since its first public release in early 2018, this package has been downloaded from more than 160 countries. @@ -53,4 +53,4 @@ This package can be used for: All reference data sets (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) in this `AMR` package are publicly and freely available. We continually export our data sets to formats for use in R, SPSS, SAS, Stata and Excel. We also supply flat files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please find [all download links on our website](https://msberends.github.io/AMR/articles/datasets.html), which is automatically updated with every code change. -The package was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the University of Groningen, in collaboration with non-profit organisations Certe Medical Diagnostics and Advice and University Medical Center Groningen. This R package is actively maintained (see [Changelog](https://msberends.github.io/AMR/news/index.html)) and is free software (see [Copyright](https://msberends.github.io/AMR/#copyright)). +This R package was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the [University of Groningen](https://www.rug.nl), in collaboration with non-profit organisations [Certe Medical Diagnostics and Advice Foundation](https://www.certe.nl) and [University Medical Center Groningen](https://www.umcg.nl). This R package formed the basis of two PhD theses ([DOI 10.33612/diss.177417131](https://doi.org/10.33612/diss.177417131) and [DOI 10.33612/diss.177417131](https://doi.org/10.33612/diss.192486375)) but is actively and durably maintained (see [changelog)](https://msberends.github.io/AMR/news/index.html)) by two public healthcare organisations in the Netherlands.