diff --git a/DESCRIPTION b/DESCRIPTION index cc5665274..7116d453f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.4.0.9043 -Date: 2020-12-22 +Version: 1.4.0.9044 +Date: 2020-12-24 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 97237e8cb..673ccb696 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.4.0.9043 -## Last updated: 22 December 2020 +# AMR 1.4.0.9044 +## Last updated: 24 December 2020 ### New * Function `is_new_episode()` to determine patient episodes which are not necessarily based on microorganisms. It also supports grouped variables with e.g. `mutate()`, `filter()` and `summarise()` of the `dplyr` package: @@ -45,12 +45,14 @@ * Fix for plotting MIC values with `plot()` * Added `plot()` generic to class `` * LA-MRSA and CA-MRSA are now recognised as an abbreviation for *Staphylococcus aureus*, meaning that e.g. `mo_genus("LA-MRSA")` will return `"Staphylococcus"` and `mo_is_gram_positive("LA-MRSA")` will return `TRUE`. +* Fix for printing class in tibbles when all values are `NA` +* Fix for `mo_shortname()` when the input contains `NA` +* If `as.mo()` takes more than 30 seconds, some suggestions will be done to improve speed ### Other * All messages and warnings thrown by this package now break sentences on whole words * More extensive unit tests * Internal calls to `options()` were all removed in favour of a new internal environment `mo_env` -* Our website now also has a dark theme, that switches on automatically based on system settings (such as Night Mode in macOS) # AMR 1.4.0 diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index e13659270..77b48c1d9 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -187,13 +187,16 @@ search_type_in_df <- function(x, type, info = TRUE) { } } } - + if (!is.null(found) & info == TRUE) { - msg <- paste0("Using column '", font_bold(found), "' as input for `col_", type, "`.") - if (type %in% c("keyantibiotics", "specimen")) { - msg <- paste(msg, "Use", font_bold(paste0("col_", type), "= FALSE"), "to prevent this.") + if (message_not_thrown_before(fn = paste0("search_", type))) { + msg <- paste0("Using column '", font_bold(found), "' as input for `col_", type, "`.") + if (type %in% c("keyantibiotics", "specimen")) { + msg <- paste(msg, "Use", font_bold(paste0("col_", type), "= FALSE"), "to prevent this.") + } + message_(msg) + remember_thrown_message(fn = paste0("search_", type)) } - message_(msg) } found } @@ -534,6 +537,20 @@ get_current_data <- function(arg_name, call) { call = call - 4)) } +get_root_env_address <- function() { + sub('', '\\1', utils::capture.output(sys.frames()[[1]])) +} + +remember_thrown_message <- function(fn) { + assign(x = paste0("address_", fn), + value = get_root_env_address(), + envir = mo_env) +} + +message_not_thrown_before <- function(fn) { + is.null(mo_env[[paste0("address_", fn)]]) || !identical(mo_env[[paste0("address_", fn)]], get_root_env_address()) +} + has_colour <- function() { # this is a base R version of crayon::has_color enabled <- getOption("crayon.enabled") diff --git a/R/count.R b/R/count.R index 43fbd5cb8..7ebb17da7 100755 --- a/R/count.R +++ b/R/count.R @@ -134,7 +134,10 @@ count_R <- function(..., only_all_tested = FALSE) { #' @rdname count #' @export count_IR <- function(..., only_all_tested = FALSE) { - warning_("Using 'count_IR' is discouraged; use 'count_resistant()' instead to not consider \"I\" being resistant.", call = FALSE) + if (message_not_thrown_before("count_IR")) { + warning_("Using count_IR() is discouraged; use count_resistant() instead to not consider \"I\" being resistant.", call = FALSE) + remember_thrown_message("count_IR") + } rsi_calc(..., ab_result = c("I", "R"), only_all_tested = only_all_tested, @@ -162,7 +165,10 @@ count_SI <- function(..., only_all_tested = FALSE) { #' @rdname count #' @export count_S <- function(..., only_all_tested = FALSE) { - warning_("Using 'count_S' is discouraged; use 'count_susceptible()' instead to also consider \"I\" being susceptible.", call = FALSE) + if (message_not_thrown_before("count_S")) { + warning_("Using count_S() is discouraged; use count_susceptible() instead to also consider \"I\" being susceptible.", call = FALSE) + remember_thrown_message("count_S") + } rsi_calc(..., ab_result = "S", only_all_tested = only_all_tested, diff --git a/R/eucast_rules.R b/R/eucast_rules.R index fc9cd5266..25bdb160d 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -87,7 +87,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) { #' #' The following antibiotics are used for the functions [eucast_rules()] and [mdro()]. These are shown below in the format 'name (`antimicrobial ID`, [ATC code](https://www.whocc.no/atc/structure_and_principles/))', sorted alphabetically: #' -#' `r create_ab_documentation(c("AMC", "AMK", "AMP", "AMX", "ATM", "AVO", "AZL", "AZM", "BAM", "BPR", "CAC", "CAP", "CAT", "CAZ", "CCV", "CDR", "CDZ", "CEC", "CED", "CEI", "CEP", "CFM", "CFM1", "CFP", "CFR", "CFS", "CHL", "CID", "CIP", "CLI", "CLR", "CMX", "CMZ", "CND", "COL", "CPD", "CPM", "CPO", "CPR", "CPT", "CRB", "CRD", "CRN", "CRO", "CSL", "CTB", "CTF", "CTL", "CTT", "CTX", "CTZ", "CXM", "CYC", "CZD", "CZO", "CZX", "DAL", "DAP", "DIR", "DIT", "DIZ", "DKB", "DOR", "DOX", "ENX", "EPC", "ERV", "ERY", "ETH", "ETP", "FDX", "FEP", "FLC", "FLE", "FLR1", "FOS", "FOX", "FOX1", "FUS", "GAT", "GEH", "GEM", "GEN", "GRX", "HAP", "HET", "INH", "IPM", "ISE", "JOS", "KAN", "LEX", "LIN", "LNZ", "LOM", "LOR", "LTM", "LVX", "MAN", "MCM", "MEC", "MEM", "MEV", "MEZ", "MFX", "MID", "MNO", "MTM", "MTR", "NAL", "NEO", "NET", "NIT", "NOR", "NOV", "NVA", "OFX", "OLE", "OMC", "ORI", "OXA", "PAZ", "PEF", "PEN", "PHN", "PIP", "PLB", "PME", "PRI", "PRL", "PRU", "PVM", "PZA", "QDA", "RAM", "RFL", "RFP", "RIB", "RID", "RIF", "ROK", "RST", "RXT", "SAM", "SBC", "SDI", "SDM", "SIS", "SLF", "SLF1", "SLF10", "SLF11", "SLF12", "SLF13", "SLF2", "SLF3", "SLF4", "SLF5", "SLF6", "SLF7", "SLF8", "SLF9", "SLT1", "SLT2", "SLT3", "SLT4", "SLT5", "SMX", "SPI", "SPT", "SPX", "STH", "STR", "STR1", "SUD", "SUT", "SXT", "SZO", "TAL", "TCC", "TCM", "TCY", "TEC", "TEM", "TGC", "THA", "TIC", "TLT", "TLV", "TMP", "TMX", "TOB", "TRL", "TVA", "TZD", "TZP", "VAN"))` +#' `r create_ab_documentation(c("AMC", "AMK", "AMP", "AMX", "ATM", "AVO", "AZL", "AZM", "BAM", "BPR", "CAC", "CAT", "CAZ", "CCP", "CCV", "CCX", "CDC", "CDR", "CDZ", "CEC", "CED", "CEI", "CEM", "CEP", "CFM", "CFM1", "CFP", "CFR", "CFS", "CFZ", "CHE", "CHL", "CID", "CIP", "CLI", "CLR", "CMX", "CMZ", "CND", "COL", "CPD", "CPI", "CPL", "CPM", "CPO", "CPR", "CPT", "CPX", "CRB", "CRD", "CRN", "CRO", "CSL", "CTB", "CTC", "CTF", "CTL", "CTS", "CTT", "CTX", "CTZ", "CXM", "CYC", "CZA", "CZD", "CZO", "CZP", "CZX", "DAL", "DAP", "DIR", "DIT", "DIX", "DIZ", "DKB", "DOR", "DOX", "ENX", "EPC", "ERY", "ETP", "FEP", "FLC", "FLE", "FLR1", "FOS", "FOV", "FOX", "FOX1", "FUS", "GAT", "GEM", "GEN", "GRX", "HAP", "HET", "IPM", "ISE", "JOS", "KAN", "LEX", "LIN", "LNZ", "LOM", "LOR", "LTM", "LVX", "MAN", "MCM", "MEC", "MEM", "MEV", "MEZ", "MFX", "MID", "MNO", "MTM", "NAL", "NEO", "NET", "NIT", "NOR", "NOV", "NVA", "OFX", "OLE", "ORI", "OXA", "PAZ", "PEF", "PEN", "PHN", "PIP", "PLB", "PME", "PRI", "PRL", "PRU", "PVM", "QDA", "RAM", "RFL", "RID", "RIF", "ROK", "RST", "RXT", "SAM", "SBC", "SDI", "SDM", "SIS", "SLF", "SLF1", "SLF10", "SLF11", "SLF12", "SLF13", "SLF2", "SLF3", "SLF4", "SLF5", "SLF6", "SLF7", "SLF8", "SLF9", "SLT1", "SLT2", "SLT3", "SLT4", "SLT5", "SMX", "SPI", "SPX", "STR", "STR1", "SUD", "SUT", "SXT", "SZO", "TAL", "TCC", "TCM", "TCY", "TEC", "TEM", "TGC", "THA", "TIC", "TIO", "TLT", "TLV", "TMP", "TMX", "TOB", "TRL", "TVA", "TZD", "TZP", "VAN"))` #' @aliases EUCAST #' @rdname eucast_rules #' @export @@ -278,53 +278,66 @@ eucast_rules <- function(x, CAC <- cols_ab["CAC"] CAT <- cols_ab["CAT"] CAZ <- cols_ab["CAZ"] + CCP <- cols_ab["CCP"] CCV <- cols_ab["CCV"] + CCX <- cols_ab["CCX"] + CDC <- cols_ab["CDC"] CDR <- cols_ab["CDR"] CDZ <- cols_ab["CDZ"] CEC <- cols_ab["CEC"] CED <- cols_ab["CED"] CEI <- cols_ab["CEI"] + CEM <- cols_ab["CEM"] CEP <- cols_ab["CEP"] CFM <- cols_ab["CFM"] CFM1 <- cols_ab["CFM1"] CFP <- cols_ab["CFP"] CFR <- cols_ab["CFR"] CFS <- cols_ab["CFS"] + CFZ <- cols_ab["CFZ"] + CHE <- cols_ab["CHE"] CHL <- cols_ab["CHL"] CID <- cols_ab["CID"] CIP <- cols_ab["CIP"] CLI <- cols_ab["CLI"] - CLI <- cols_ab["CLI"] CLR <- cols_ab["CLR"] CMX <- cols_ab["CMX"] CMZ <- cols_ab["CMZ"] CND <- cols_ab["CND"] COL <- cols_ab["COL"] CPD <- cols_ab["CPD"] + CPI <- cols_ab["CPI"] + CPL <- cols_ab["CPL"] CPM <- cols_ab["CPM"] CPO <- cols_ab["CPO"] CPR <- cols_ab["CPR"] CPT <- cols_ab["CPT"] + CPX <- cols_ab["CPX"] CRB <- cols_ab["CRB"] CRD <- cols_ab["CRD"] CRN <- cols_ab["CRN"] CRO <- cols_ab["CRO"] CSL <- cols_ab["CSL"] CTB <- cols_ab["CTB"] + CTC <- cols_ab["CTC"] CTF <- cols_ab["CTF"] CTL <- cols_ab["CTL"] + CTS <- cols_ab["CTS"] CTT <- cols_ab["CTT"] CTX <- cols_ab["CTX"] CTZ <- cols_ab["CTZ"] CXM <- cols_ab["CXM"] CYC <- cols_ab["CYC"] + CZA <- cols_ab["CZA"] CZD <- cols_ab["CZD"] CZO <- cols_ab["CZO"] + CZP <- cols_ab["CZP"] CZX <- cols_ab["CZX"] DAL <- cols_ab["DAL"] DAP <- cols_ab["DAP"] DIR <- cols_ab["DIR"] DIT <- cols_ab["DIT"] + DIX <- cols_ab["DIX"] DIZ <- cols_ab["DIZ"] DKB <- cols_ab["DKB"] DOR <- cols_ab["DOR"] @@ -338,6 +351,7 @@ eucast_rules <- function(x, FLE <- cols_ab["FLE"] FLR1 <- cols_ab["FLR1"] FOS <- cols_ab["FOS"] + FOV <- cols_ab["FOV"] FOX <- cols_ab["FOX"] FOX1 <- cols_ab["FOX1"] FUS <- cols_ab["FUS"] @@ -391,7 +405,6 @@ eucast_rules <- function(x, PRU <- cols_ab["PRU"] PVM <- cols_ab["PVM"] QDA <- cols_ab["QDA"] - QDA <- cols_ab["QDA"] RAM <- cols_ab["RAM"] RFL <- cols_ab["RFL"] RID <- cols_ab["RID"] @@ -441,6 +454,7 @@ eucast_rules <- function(x, TGC <- cols_ab["TGC"] THA <- cols_ab["THA"] TIC <- cols_ab["TIC"] + TIO <- cols_ab["TIO"] TLT <- cols_ab["TLT"] TLV <- cols_ab["TLV"] TMP <- cols_ab["TMP"] @@ -474,9 +488,10 @@ eucast_rules <- function(x, aminoglycosides <- c(AMK, DKB, GEN, ISE, KAN, NEO, NET, RST, SIS, STR, STR1, TOB) aminopenicillins <- c(AMP, AMX) carbapenems <- c(DOR, ETP, IPM, MEM, MEV) - cephalosporins <- c(CDZ, CAC, CEC, CFR, RID, MAN, CTZ, CZD, CZO, CDR, DIT, FEP, CAT, CFM, CMX, CMZ, DIZ, CID, CFP, CSL, CND, CTX, CTT, CTF, FOX, CPM, CPO, CPD, CPR, CRD, CFS, CPT, CAZ, CCV, CTL, CTB, CZX, BPR, CFM1, CEI, CRO, CXM, LEX, CEP, HAP, CED, LTM, LOR) + cephalosporins <- c(CDZ, CCP, CAC, CEC, CFR, RID, MAN, CTZ, CZD, CZO, CDR, DIT, FEP, CAT, CFM, CMX, CMZ, DIZ, CID, CFP, CSL, CND, CTX, CTT, CTF, FOX, CPM, CPO, CPD, CPR, CRD, CFS, CPT, CAZ, CCV, CTL, CTB, CZX, BPR, CFM1, CEI, CRO, CXM, LEX, CEP, HAP, CED, LTM, LOR) cephalosporins_1st <- c(CAC, CFR, RID, CTZ, CZD, CZO, CRD, CTL, LEX, CEP, HAP, CED) cephalosporins_2nd <- c(CEC, MAN, CMZ, CID, CND, CTT, CTF, FOX, CPR, CXM, LOR) + cephalosporins_3rd <- c(CDZ, CCP, CCX, CDR, DIT, DIX, CAT, CPI, CFM, CMX, DIZ, CFP, CSL, CTX, CTC, CTS, CHE, FOV, CFZ, CPM, CPD, CPX, CDC, CFS, CAZ, CZA, CCV, CEM, CPL, CTB, TIO, CZX, CZP, CRO, LTM) cephalosporins_except_CAZ <- cephalosporins[cephalosporins != ifelse(is.null(CAZ), "", CAZ)] fluoroquinolones <- c(CIP, ENX, FLE, GAT, GEM, GRX, LVX, LOM, MFX, NOR, OFX, PAZ, PEF, PRU, RFL, SPX, TMX, TVA) glycopeptides <- c(AVO, NVA, RAM, TEC, TCM, VAN) # dalba/orita/tela are in lipoglycopeptides @@ -796,7 +811,7 @@ eucast_rules <- function(x, word_wrap( expertrules_info$title, " (", font_red(paste0(expertrules_info$version_txt, ", ", expertrules_info$year)), ")\n")), - "")))) + ""))), "\n") } # Print rule ------------------------------------------------------------- if (rule_current != rule_previous) { diff --git a/R/mdro.R b/R/mdro.R index 3cb7eee3a..f4af4642d 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -192,7 +192,7 @@ mdro <- function(x, if (guideline$code == "cmi2012") { guideline$name <- "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." guideline$author <- "Magiorakos AP, Srinivasan A, Carey RB, ..., Vatopoulos A, Weber JT, Monnet DL" - guideline$version <- "N/A" + guideline$version <- NA guideline$source <- "Clinical Microbiology and Infection 18:3, 2012. DOI: 10.1111/j.1469-0691.2011.03570.x" guideline$type <- "MDRs/XDRs/PDRs" @@ -221,7 +221,7 @@ mdro <- function(x, } else if (guideline$code == "mrgn") { guideline$name <- "Cross-border comparison of the Dutch and German guidelines on multidrug-resistant Gram-negative microorganisms" guideline$author <- "M\u00fcller J, Voss A, K\u00f6ck R, ..., Kern WV, Wendt C, Friedrich AW" - guideline$version <- "N/A" + guideline$version <- NA guideline$source <- "Antimicrobial Resistance and Infection Control 4:7, 2015. DOI: 10.1186/s13756-015-0047-6" guideline$type <- "MRGNs" @@ -568,11 +568,13 @@ mdro <- function(x, } else { cat(font_red("\nResults with 'R' or 'I' are considered as resistance. Use `combine_SI = TRUE` to only consider 'R' as resistance.\n")) } - cat("\nDetermining multidrug-resistant organisms (MDRO), according to:\n", - font_bold("Guideline: "), font_italic(guideline$name), "\n", - font_bold("Version: "), guideline$version, "\n", - font_bold("Author: "), guideline$author, "\n", - font_bold("Source: "), guideline$source, "\n", + cat("\n", word_wrap("Determining multidrug-resistant organisms (MDRO), according to:"), "\n", + word_wrap(paste0(font_bold("Guideline: "), font_italic(guideline$name)), extra_indent = 11, as_note = FALSE), "\n", + word_wrap(paste0(font_bold("Author(s): "), guideline$author), extra_indent = 11, as_note = FALSE), "\n", + ifelse(!is.na(guideline$version), + paste0(word_wrap(paste0(font_bold("Version: "), guideline$version), extra_indent = 11, as_note = FALSE), "\n"), + ""), + word_wrap(paste0(font_bold("Source: "), guideline$source), extra_indent = 11, as_note = FALSE), "\n", "\n", sep = "") } @@ -1237,7 +1239,7 @@ mdro <- function(x, if (guideline$code == "cmi2012") { if (any(x$MDRO == -1, na.rm = TRUE)) { warning_("NA introduced for isolates where the available percentage of antimicrobial classes was below ", - percentage(pct_required_classes), " (set with `pct_required_classes`)") + percentage(pct_required_classes), " (set with `pct_required_classes`)", call = FALSE) # set these -1s to NA x[which(x$MDRO == -1), "MDRO"] <- NA_integer_ } diff --git a/R/mo.R b/R/mo.R index 950532997..6a4e84751 100755 --- a/R/mo.R +++ b/R/mo.R @@ -276,7 +276,7 @@ exec_as.mo <- function(x, meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) check_dataset_integrity() - + lookup <- function(needle, column = property, haystack = reference_data_to_use, @@ -358,6 +358,9 @@ exec_as.mo <- function(x, x[trimws2(x) %like% paste0("^(", translate_AMR("no|not", language = language), ") [a-z]+")] <- "UNKNOWN" if (initial_search == TRUE) { + # keep track of time - give some hints to improve speed if it takes a long time + start_time <- Sys.time() + mo_env$mo_failures <- NULL mo_env$mo_uncertainties <- NULL mo_env$mo_renamed <- NULL @@ -1524,8 +1527,24 @@ exec_as.mo <- function(x, } # this will save the uncertain items as attribute, so they can be bound to `uncertainties` in the uncertain_fn() function x <- structure(x, uncertainties = uncertainties) + } else { + # keep track of time - give some hints to improve speed if it takes a long time + end_time <- Sys.time() + delta_time <- difftime(end_time, start_time, units = "secs") + if (delta_time >= 30) { + message_("Using `as.mo()` took ", delta_time, " seconds, which is a long time. Some suggestions to improve speed include:") + message_(word_wrap("- Try to use as many valid taxonomic names as possible for your input.", + extra_indent = 2), + as_note = FALSE) + message_(word_wrap("- Save the output and use it as input for future calculations, e.g. create a new variable to your data using `as.mo()`. All functions in this package that rely on microorganism codes will automatically use that new column where possible. All `mo_*()` functions also do not require you to set their `x` argument as long as you have the dplyr package installed and you have a column of class .", + extra_indent = 2), + as_note = FALSE) + message_(word_wrap("- Use `set_mo_source()` to continually transform your organisation codes to microorganisms codes used by this package, please see `?mo_source`.", + extra_indent = 2), + as_note = FALSE) + } } - + x } @@ -1585,9 +1604,13 @@ pillar_shaft.mo <- function(x, ...) { out[x == "UNKNOWN"] <- font_na(" UNKNOWN") # make it always fit exactly + max_char <- max(nchar(x)) + if (is.na(max_char)) { + max_char <- 7 + } create_pillar_column(out, align = "left", - width = max(nchar(x)) + ifelse(any(x %in% c(NA, "UNKNOWN")), 2, 0)) + width = max_char + ifelse(any(x %in% c(NA, "UNKNOWN")), 2, 0)) } # will be exported using s3_register() in R/zzz.R diff --git a/R/mo_property.R b/R/mo_property.R index 8ac4c1031..41806f1e2 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -27,12 +27,12 @@ #' #' Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. Please see *Examples*. #' @inheritSection lifecycle Stable lifecycle -#' @param x any character (vector) that can be coerced to a valid microorganism code with [as.mo()]. Can be omitted for auto-guessing in `mo_is_*()` functions when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()], please see *Examples*. +#' @param x any character (vector) that can be coerced to a valid microorganism code with [as.mo()]. Can be omitted for auto-guessing the column containing microorganism codes when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()], please see *Examples*. #' @param property one of the column names of the [microorganisms] data set: `r paste0('"``', colnames(microorganisms), '\``"', collapse = ", ")`, or must be `"shortname"` #' @param language language of the returned text, defaults to system language (see [get_locale()]) and can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`, see [translate]. Also used to translate text like "no growth". Use `language = NULL` or `language = ""` to prevent translation. #' @param ... other arguments passed on to [as.mo()], such as 'allow_uncertain' and 'ignore_pattern' #' @param ab any (vector of) text that can be coerced to a valid antibiotic code with [as.ab()] -#' @param open browse the URL using [utils::browseURL()] +#' @param open browse the URL using [`browseURL()`][utils::browseURL()] #' @details All functions will return the most recently known taxonomic property according to the Catalogue of Life, except for [mo_ref()], [mo_authors()] and [mo_year()]. Please refer to this example, knowing that *Escherichia blattae* was renamed to *Shimwellia blattae* in 2010: #' - `mo_name("Escherichia blattae")` will return `"Shimwellia blattae"` (with a message about the renaming) #' - `mo_ref("Escherichia blattae")` will return `"Burgess et al., 1973"` (with a message about the renaming) @@ -161,9 +161,13 @@ #' mo_info("E. coli") #' } mo_name <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "fullname", language = language, ...), language = language, only_unknown = FALSE) } @@ -174,22 +178,26 @@ mo_fullname <- mo_name #' @rdname mo_property #' @export mo_shortname <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x.mo <- as.mo(x, language = language, ...) - + metadata <- get_mo_failures_uncertainties_renamed() - + replace_empty <- function(x) { x[x == ""] <- "spp." x } - + # get first char of genus and complete species in English genera <- mo_genus(x.mo, language = NULL) shortnames <- paste0(substr(genera, 1, 1), ". ", replace_empty(mo_species(x.mo, language = NULL))) - + # exceptions for where no species is known shortnames[shortnames %like% ".[.] spp[.]"] <- genera[shortnames %like% ".[.] spp[.]"] # exceptions for staphylococci @@ -199,7 +207,8 @@ mo_shortname <- function(x, language = get_locale(), ...) { shortnames[shortnames %like% "S. group [ABCDFGHK]"] <- paste0("G", gsub("S. group ([ABCDFGHK])", "\\1", shortnames[shortnames %like% "S. group [ABCDFGHK]"]), "S") # unknown species etc. shortnames[shortnames %like% "unknown"] <- paste0("(", trimws(gsub("[^a-zA-Z -]", "", shortnames[shortnames %like% "unknown"])), ")") - + + shortnames[is.na(x.mo)] <- NA_character_ load_mo_failures_uncertainties_renamed(metadata) translate_AMR(shortnames, language = language, only_unknown = FALSE) } @@ -207,72 +216,104 @@ mo_shortname <- function(x, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_subspecies <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "subspecies", language = language, ...), language = language, only_unknown = TRUE) } #' @rdname mo_property #' @export mo_species <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "species", language = language, ...), language = language, only_unknown = TRUE) } #' @rdname mo_property #' @export mo_genus <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "genus", language = language, ...), language = language, only_unknown = TRUE) } #' @rdname mo_property #' @export mo_family <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "family", language = language, ...), language = language, only_unknown = TRUE) } #' @rdname mo_property #' @export mo_order <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "order", language = language, ...), language = language, only_unknown = TRUE) } #' @rdname mo_property #' @export mo_class <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "class", language = language, ...), language = language, only_unknown = TRUE) } #' @rdname mo_property #' @export mo_phylum <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "phylum", language = language, ...), language = language, only_unknown = TRUE) } #' @rdname mo_property #' @export mo_kingdom <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "kingdom", language = language, ...), language = language, only_unknown = TRUE) } @@ -283,21 +324,29 @@ mo_domain <- mo_kingdom #' @rdname mo_property #' @export mo_type <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = "kingdom", language = language, ...), language = language, only_unknown = FALSE) } #' @rdname mo_property #' @export mo_gramstain <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x.mo <- as.mo(x, language = language, ...) metadata <- get_mo_failures_uncertainties_renamed() - + x.phylum <- mo_phylum(x.mo) # DETERMINE GRAM STAIN FOR BACTERIA # Source: https://itis.gov/servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value=956097 @@ -318,7 +367,7 @@ mo_gramstain <- function(x, language = get_locale(), ...) { "Firmicutes", "Tenericutes") | x.mo == "B_GRAMP"] <- "Gram-positive" - + load_mo_failures_uncertainties_renamed(metadata) translate_AMR(x, language = language, only_unknown = FALSE) } @@ -327,12 +376,12 @@ mo_gramstain <- function(x, language = get_locale(), ...) { #' @export mo_is_gram_negative <- function(x, language = get_locale(), ...) { if (missing(x)) { - # this supports using in dplyr verbs: ... %>% filter(mo_is_gram_negative()) - x <- find_mo_col("mo_is_gram_negative") + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x.mo <- as.mo(x, language = language, ...) metadata <- get_mo_failures_uncertainties_renamed() grams <- mo_gramstain(x.mo, language = NULL) @@ -346,12 +395,12 @@ mo_is_gram_negative <- function(x, language = get_locale(), ...) { #' @export mo_is_gram_positive <- function(x, language = get_locale(), ...) { if (missing(x)) { - # this supports using in dplyr verbs: ... %>% filter(mo_is_gram_positive()) - x <- find_mo_col("mo_is_gram_positive") + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x.mo <- as.mo(x, language = language, ...) metadata <- get_mo_failures_uncertainties_renamed() grams <- mo_gramstain(x.mo, language = NULL) @@ -399,27 +448,39 @@ mo_is_intrinsic_resistant <- function(x, ab, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_snomed <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + mo_validate(x = x, property = "snomed", language = language, ...) } #' @rdname mo_property #' @export mo_ref <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + mo_validate(x = x, property = "ref", language = language, ...) } #' @rdname mo_property #' @export mo_authors <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x <- mo_validate(x = x, property = "ref", language = language, ...) # remove last 4 digits and presumably the comma and space that preceed them x[!is.na(x)] <- gsub(",? ?[0-9]{4}", "", x[!is.na(x)]) @@ -429,9 +490,13 @@ mo_authors <- function(x, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_year <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x <- mo_validate(x = x, property = "ref", language = language, ...) # get last 4 digits x[!is.na(x)] <- gsub(".*([0-9]{4})$", "\\1", x[!is.na(x)]) @@ -441,21 +506,29 @@ mo_year <- function(x, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_rank <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + mo_validate(x = x, property = "rank", language = language, ...) } #' @rdname mo_property #' @export mo_taxonomy <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x <- as.mo(x, language = language, ...) metadata <- get_mo_failures_uncertainties_renamed() - + result <- list(kingdom = mo_kingdom(x, language = language), phylum = mo_phylum(x, language = language), class = mo_class(x, language = language), @@ -464,7 +537,7 @@ mo_taxonomy <- function(x, language = get_locale(), ...) { genus = mo_genus(x, language = language), species = mo_species(x, language = language), subspecies = mo_subspecies(x, language = language)) - + load_mo_failures_uncertainties_renamed(metadata) result } @@ -472,12 +545,16 @@ mo_taxonomy <- function(x, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_synonyms <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x <- as.mo(x, language = language, ...) metadata <- get_mo_failures_uncertainties_renamed() - + IDs <- mo_name(x = x, language = NULL) syns <- lapply(IDs, function(newname) { res <- sort(microorganisms.old[which(microorganisms.old$fullname_new == newname), "fullname"]) @@ -493,7 +570,7 @@ mo_synonyms <- function(x, language = get_locale(), ...) { } else { result <- unlist(syns) } - + load_mo_failures_uncertainties_renamed(metadata) result } @@ -501,12 +578,16 @@ mo_synonyms <- function(x, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_info <- function(x, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + x <- as.mo(x, language = language, ...) metadata <- get_mo_failures_uncertainties_renamed() - + info <- lapply(x, function(y) c(mo_taxonomy(y, language = language), list(synonyms = mo_synonyms(y), @@ -519,7 +600,7 @@ mo_info <- function(x, language = get_locale(), ...) { } else { result <- info[[1L]] } - + load_mo_failures_uncertainties_renamed(metadata) result } @@ -527,14 +608,18 @@ mo_info <- function(x, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_url <- function(x, open = FALSE, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(open, allow_class = "logical", has_length = 1) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + mo <- as.mo(x = x, language = language, ... = ...) mo_names <- mo_name(mo) metadata <- get_mo_failures_uncertainties_renamed() - + df <- data.frame(mo, stringsAsFactors = FALSE) %pm>% pm_left_join(pm_select(microorganisms, mo, source, species_id), by = "mo") df$url <- ifelse(df$source == "CoL", @@ -544,14 +629,14 @@ mo_url <- function(x, open = FALSE, language = get_locale(), ...) { NA_character_)) u <- df$url names(u) <- mo_names - + if (open == TRUE) { if (length(u) > 1) { warning_("Only the first URL will be opened, as `browseURL()` only suports one string.") } utils::browseURL(u[1L]) } - + load_mo_failures_uncertainties_renamed(metadata) u } @@ -560,21 +645,25 @@ mo_url <- function(x, open = FALSE, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_property <- function(x, property = "fullname", language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } meet_criteria(x, allow_NA = TRUE) meet_criteria(property, allow_class = "character", has_length = 1, is_in = colnames(microorganisms)) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + translate_AMR(mo_validate(x = x, property = property, language = language, ...), language = language, only_unknown = TRUE) } mo_validate <- function(x, property, language, ...) { check_dataset_integrity() - + if (tryCatch(all(x[!is.na(x)] %in% MO_lookup$mo) & length(list(...)) == 0, error = function(e) FALSE)) { # special case for mo_* functions where class is already return(MO_lookup[match(x, MO_lookup$mo), property, drop = TRUE]) } - + dots <- list(...) Becker <- dots$Becker if (is.null(Becker)) { @@ -584,12 +673,12 @@ mo_validate <- function(x, property, language, ...) { if (is.null(Lancefield)) { Lancefield <- FALSE } - + # try to catch an error when inputting an invalid argument # so the 'call.' can be set to FALSE tryCatch(x[1L] %in% MO_lookup[1, property, drop = TRUE], error = function(e) stop(e$message, call. = FALSE)) - + if (is.mo(x) & !Becker %in% c(TRUE, "all") & !Lancefield %in% c(TRUE, "all")) { @@ -601,7 +690,7 @@ mo_validate <- function(x, property, language, ...) { | Lancefield %in% c(TRUE, "all")) { x <- exec_as.mo(x, property = property, language = language, ...) } - + if (property == "mo") { return(set_clean_class(x, new_class = c("mo", "character"))) } else if (property == "snomed") { @@ -614,13 +703,16 @@ mo_validate <- function(x, property, language, ...) { find_mo_col <- function(fn) { # this function tries to find an mo column using dplyr::cur_data_all() for mo_is_*() functions, # which is useful when functions are used within dplyr verbs - df <- get_current_data("x", call = -3) # will return an error if not found + df <- get_current_data(arg_name = "x", call = -3) # will return an error if not found mo <- NULL try({ mo <- suppressMessages(search_type_in_df(df, "mo")) }, silent = TRUE) if (!is.null(df) && !is.null(mo) && is.data.frame(df)) { - message_("Using column '", font_bold(mo), "' as input for ", fn, "()") + if (message_not_thrown_before(fn = fn)) { + message_("Using column '", font_bold(mo), "' as input for ", fn, "()") + remember_thrown_message(fn = fn) + } return(df[, mo, drop = TRUE]) } else { stop_("argument `x` is missing and no column with info about microorganisms could be found.", call = -2) diff --git a/R/mo_source.R b/R/mo_source.R index 13f5c9667..97060b021 100644 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -25,9 +25,9 @@ #' User-defined reference data set for microorganisms #' -#' @description These functions can be used to predefine your own reference to be used in [as.mo()] and consequently all `mo_*` functions like [mo_genus()] and [mo_gramstain()]. +#' @description These functions can be used to predefine your own reference to be used in [as.mo()] and consequently all [`mo_*`][mo_property()] functions (such as [mo_genus()] and [mo_gramstain()]). #' -#' This is **the fastest way** to have your organisation (or analysis) specific codes picked up and translated by this package. +#' This is **the fastest way** to have your organisation (or analysis) specific codes picked up and translated by this package, since you don't have to bother about it again after setting it up once. #' @inheritSection lifecycle Stable lifecycle #' @param path location of your reference file, see Details. Can be `""`, `NULL` or `FALSE` to delete the reference file. #' @param destination destination of the compressed data file, default to the user's home directory. @@ -103,7 +103,7 @@ #' ``` #' as.mo("lab_mo_ecoli") #' #> NOTE: Updated mo_source file '/Users/me/mo_source.rds' (0.3 kB) from -#' #> '/Users/me/Documents/ourcodes.xlsx' (9 kB), columns +#' #> '/Users/me/Documents/ourcodes.xlsx' (9 kB), columns #' #> "Organisation XYZ" and "mo" #' #> Class #' #> [1] B_ESCHR_COLI @@ -119,7 +119,7 @@ #' #> Removed mo_source file '/Users/me/mo_source.rds' #' ``` #' -#' If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of [as.mo()]. +#' If the original file (in the previous case an Excel file) is moved or deleted, the `mo_source.rds` file will be removed upon the next use of [as.mo()] or any [`mo_*`][mo_property()] function. #' @export #' @inheritSection AMR Read more on our website! set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_source.rds")) { diff --git a/R/rsi.R b/R/rsi.R index 528280881..e8ba24e43 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -709,7 +709,10 @@ exec_as.rsi <- function(method, guideline_coerced <- get_guideline(guideline, reference_data) if (guideline_coerced != guideline) { - message_("Using guideline ", font_bold(guideline_coerced), " as input for `guideline`.") + if (message_not_thrown_before("as.rsi")) { + message_("Using guideline ", font_bold(guideline_coerced), " as input for `guideline`.") + remember_thrown_message("as.rsi") + } } new_rsi <- rep(NA_character_, length(x)) @@ -745,7 +748,10 @@ exec_as.rsi <- function(method, if (isTRUE(add_intrinsic_resistance) & is_intrinsic_r) { if (!guideline_coerced %like% "EUCAST") { - warning_("Using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.", call = FALSE) + if (message_not_thrown_before("as.rsi2")) { + warning_("Using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.", call = FALSE) + remember_thrown_message("as.rsi2") + } } else { new_rsi[i] <- "R" next @@ -811,7 +817,10 @@ exec_as.rsi <- function(method, if (any_is_intrinsic_resistant & guideline_coerced %like% "EUCAST" & !isTRUE(add_intrinsic_resistance)) { # found some intrinsic resistance, but was not applied message_("WARNING.", add_fn = list(font_yellow, font_bold), as_note = FALSE) - warning_("Found intrinsic resistance in some bug/drug combinations, although it was not applied.\nUse `as.rsi(..., add_intrinsic_resistance = TRUE)` to apply it.", call = FALSE) + if (message_not_thrown_before("as.rsi3")) { + warning_("Found intrinsic resistance in some bug/drug combinations, although it was not applied.\nUse `as.rsi(..., add_intrinsic_resistance = TRUE)` to apply it.", call = FALSE) + remember_thrown_message("as.rsi3") + } warned <- TRUE } diff --git a/R/rsi_calc.R b/R/rsi_calc.R index 768095250..3294ac935 100755 --- a/R/rsi_calc.R +++ b/R/rsi_calc.R @@ -147,8 +147,11 @@ rsi_calc <- function(..., } if (print_warning == TRUE) { - warning_("Increase speed by transforming to class on beforehand: your_data %pm>% mutate_if(is.rsi.eligible, as.rsi)", - call = FALSE) + if (message_not_thrown_before("rsi_calc")) { + warning_("Increase speed by transforming to class on beforehand: your_data %pm>% mutate_if(is.rsi.eligible, as.rsi)", + call = FALSE) + remember_thrown_message("rsi_calc") + } } if (only_count == TRUE) { diff --git a/R/zzz.R b/R/zzz.R index e5171e8cd..ed1bf02f8 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -75,6 +75,13 @@ s3_register("skimr::get_skimmers", "rsi") s3_register("skimr::get_skimmers", "mic") s3_register("skimr::get_skimmers", "disk") + + # if mo source exists, fire it up (see mo_source()) + try({ + if (file.exists(getOption("AMR_mo_source", "~/mo_source.rds"))) { + invisible(get_mo_source()) + } + }, silent = TRUE) } .onAttach <- function(...) { diff --git a/_pkgdown.yml b/_pkgdown.yml index d0bb5f754..d4c12e3cc 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -213,7 +213,8 @@ authors: template: # this requires the 'preferably' package, https://github.com/amirmasoudabdol/preferably/ - package: preferably + # package: preferably assets: "pkgdown/logos" # use logos in this folder params: noindex: false + template: "flatly" diff --git a/data-raw/eucast_rules.tsv b/data-raw/eucast_rules.tsv index 9ab899f1b..4ffbb0cfb 100644 --- a/data-raw/eucast_rules.tsv +++ b/data-raw/eucast_rules.tsv @@ -1,6 +1,6 @@ # ------------------------------------------------------------------------------------------------------------------------------- # For editing this EUCAST reference file, these values can all be used for targeting antibiotics: -# 'all_betalactams', 'aminoglycosides', 'aminopenicillins', 'carbapenems', 'cephalosporins', 'cephalosporins_1st', 'cephalosporins_2nd', 'cephalosporins_except_CAZ', +# 'all_betalactams', 'aminoglycosides', 'aminopenicillins', 'carbapenems', 'cephalosporins', 'cephalosporins_1st', 'cephalosporins_2nd', 'cephalosporins_3rd', 'cephalosporins_except_CAZ', # 'fluoroquinolones', 'glycopeptides', 'lincosamides', 'lipoglycopeptides', 'macrolides', 'oxazolidinones', 'polymyxins', 'streptogramins', 'tetracyclines', 'ureidopenicillins', # and all separate EARS-Net letter codes like 'AMC'. They can be separated by comma: 'AMC, fluoroquinolones'. # The 'if_mo_property' column can be any column name from the AMR::microorganisms data set, or "genus_species" or "gramstain". diff --git a/docs/404.html b/docs/404.html index a5772c5d9..d82222547 100644 --- a/docs/404.html +++ b/docs/404.html @@ -6,22 +6,6 @@ - - - - Page not found (404) • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -85,9 +58,6 @@ - - - - - - License • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -85,9 +58,6 @@ - - - -How to conduct AMR analysis • AMR (for R) +How to conduct AMR analysis • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044 @@ -210,7 +193,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

21 December 2020

+

24 December 2020

Source: vignettes/AMR.Rmd @@ -219,7 +202,7 @@ -

Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 21 December 2020.

+

Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 24 December 2020.

Introduction

@@ -250,21 +233,21 @@ -2020-12-21 +2020-12-24 abcd Escherichia coli S S -2020-12-21 +2020-12-24 abcd Escherichia coli S R -2020-12-21 +2020-12-24 efgh Escherichia coli R @@ -369,71 +352,71 @@ -2013-07-24 -S10 +2012-10-07 +D7 +Hospital B +Escherichia coli +R +S +R +S +M + + +2016-11-19 +V9 +Hospital A +Klebsiella pneumoniae +R +S +S +S +F + + +2015-03-30 +D9 Hospital D Staphylococcus aureus R S S S -F +M -2011-06-06 -X7 +2012-06-28 +Z4 Hospital B -Streptococcus pneumoniae -R +Staphylococcus aureus +S S S S F -2010-08-03 -E6 -Hospital B -Escherichia coli -R -I +2014-03-04 +M4 +Hospital C +Staphylococcus aureus +S +S S S M -2014-03-25 -S8 +2014-08-18 +D2 Hospital B Escherichia coli -S R -S -S -F - - -2010-09-19 -J1 -Hospital D -Klebsiella pneumoniae -I R S S M - -2017-05-11 -T3 -Hospital A -Escherichia coli -S -S -S -S -F -

Now, let’s start the cleaning and the analysis!

@@ -466,16 +449,16 @@ Longest: 1

1 M -10,348 -51.74% -10,348 -51.74% +10,392 +51.96% +10,392 +51.96% 2 F -9,652 -48.26% +9,608 +48.04% 20,000 100.00% @@ -532,7 +515,7 @@ Longest: 1

First weighted isolates

-

We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient R5, sorted on date:

+

We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient M9, sorted on date:

@@ -548,8 +531,8 @@ Longest: 1

- - + + @@ -559,19 +542,19 @@ Longest: 1

- - + + - + - - + + @@ -581,30 +564,30 @@ Longest: 1

- - + + + - - - + + - - + + - - + + @@ -614,60 +597,56 @@ Longest: 1

- - + + + + + + + + + + + + + - - - - - - - - - - - - - + + - + - - + + + + - - - +
isolate
12010-02-05R52010-01-25M9 B_ESCHR_COLI S S
22010-04-22R52010-02-01M9 B_ESCHR_COLI S SRS S FALSE
32010-05-16R52010-02-22M9 B_ESCHR_COLI S S
42010-05-29R52010-08-12M9 B_ESCHR_COLII S SR S FALSE
52010-06-16R52010-08-17M9 B_ESCHR_COLI RSSRR S FALSE
62010-10-06R52010-09-18M9 B_ESCHR_COLI S S
72010-12-22R52011-07-05M9 B_ESCHR_COLI R SRSTRUE
82011-07-19M9B_ESCHR_COLIRR S S FALSE
82011-04-14R5B_ESCHR_COLISSSSTRUE
92011-11-27R52011-07-20M9 B_ESCHR_COLI S S SRS FALSE
102012-11-12R52011-09-04M9 B_ESCHR_COLIRI S SSSTRUEFALSE
-

Only 3 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics() function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.

+

Only 2 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics() function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.

If a column exists with a name like ‘key(…)ab’ the first_isolate() function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:

 data <- data %>% 
   mutate(keyab = key_antibiotics(.)) %>% 
   mutate(first_weighted = first_isolate(.))
-# NOTE: Using column 'bacteria' as input for `col_mo`.
-# NOTE: Using column 'bacteria' as input for `col_mo`.
-# NOTE: Using column 'date' as input for `col_date`.
-# NOTE: Using column 'patient_id' as input for `col_patient_id`.
 # NOTE: Using column 'keyab' as input for `col_keyantibiotics`. Use
 #       col_keyantibiotics = FALSE to prevent this.
@@ -686,8 +665,8 @@ Longest: 1

- - + + @@ -698,20 +677,8 @@ Longest: 1

- - - - - - - - - - - - - - + + @@ -720,34 +687,46 @@ Longest: 1

+ + + + + + + + + + + + - - + + + - - + - - + + - - + + - - + + @@ -758,60 +737,60 @@ Longest: 1

- - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + - + - - + + + + - - - +
12010-02-05R52010-01-25M9 B_ESCHR_COLI S S
22010-04-22R5B_ESCHR_COLISSRSFALSEFALSE
32010-05-16R52010-02-01M9 B_ESCHR_COLI S S FALSE TRUE
32010-02-22M9B_ESCHR_COLISSSSFALSEFALSE
42010-05-29R52010-08-12M9 B_ESCHR_COLII S SR S FALSETRUEFALSE
52010-06-16R52010-08-17M9 B_ESCHR_COLI RSSRR S FALSE TRUE
62010-10-06R52010-09-18M9 B_ESCHR_COLI S S
72010-12-22R52011-07-05M9 B_ESCHR_COLI R SRSTRUETRUE
82011-07-19M9B_ESCHR_COLIRR S S FALSE TRUE
82011-04-14R5B_ESCHR_COLISSSSTRUETRUE
92011-11-27R52011-07-20M9 B_ESCHR_COLI S S SRS FALSE TRUE
102012-11-12R52011-09-04M9 B_ESCHR_COLIRI S SSSTRUEFALSE TRUE
-

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

+

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

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

 data_1st <- data %>% 
   filter_first_weighted_isolate()
-

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

+

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

We can remove unneeded columns:

 data_1st <- data_1st %>% 
@@ -821,6 +800,7 @@ Longest: 1

head(data_1st)
+@@ -836,6 +816,7 @@ Longest: 1

+ @@ -852,27 +833,77 @@ Longest: 1

- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + + + + + + + + + + + + + + + + + + - - + + @@ -881,62 +912,18 @@ Longest: 1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + + - - - - - - - - - - - - - - - - @@ -962,8 +949,8 @@ Longest: 1

data_1st %>% freq(genus, species)

Frequency table

Class: character
-Length: 15,689
-Available: 15,689 (100%, NA: 0 = 0%)
+Length: 15,683
+Available: 15,683 (100%, NA: 0 = 0%)
Unique: 4

Shortest: 16
Longest: 24

@@ -980,33 +967,33 @@ Longest: 24

- - - - + + + + - - - - + + + + - - - - + + + + - - - + + + @@ -1020,7 +1007,6 @@ Longest: 24

data_1st %>% bug_drug_combinations() %>% head() # show first 6 rows -
# NOTE: Using column 'bacteria' as input for `col_mo`.
date patient_id hospital
2013-07-24S1012012-10-07D7Hospital BB_ESCHR_COLIRSRSMGram-negativeEscherichiacoliTRUE
22016-11-19V9Hospital AB_KLBSL_PNMNRSSSFGram-negativeKlebsiellapneumoniaeTRUE
32015-03-30D9 Hospital D B_STPHY_AURS R S S SFM Gram-positive Staphylococcus aureus TRUE
2011-06-06X7Hospital B52014-03-04M4Hospital CB_STPHY_AURSSSSSMGram-positiveStaphylococcusaureusTRUE
72011-02-08S3Hospital D B_STRPT_PNMNRRSS S R F pneumoniae TRUE
2010-08-03E6Hospital BB_ESCHR_COLIRISSMGram-negativeEscherichiacoliTRUE
2014-03-25S8Hospital BB_ESCHR_COLIRRSSFGram-negativeEscherichiacoliTRUE
2010-09-19J182015-12-31I5 Hospital DB_KLBSL_PNMNB_ESCHR_COLIR R RS S M Gram-negativeKlebsiellapneumoniaeTRUE
2017-05-11T3Hospital AB_ESCHR_COLISSSSFGram-negative Escherichia coli TRUE
1 Escherichia coli7,85950.09%7,85950.09%7,81549.83%7,81549.83%
2 Staphylococcus aureus3,81924.34%11,67874.43%4,00125.51%11,81675.34%
3 Streptococcus pneumoniae2,39115.24%14,06989.67%2,33014.86%14,14690.20%
4 Klebsiella pneumoniae1,62010.33%15,6891,5379.80%15,683 100.00%
@@ -1034,60 +1020,59 @@ Longest: 24

- - - - + + + + - - - - + + + + - + - - + + - + - - + + - - + + - - - - + + + +
mo
E. coli AMX378425638197859374425738147815
E. coli AMC619030813617859618529413367815
E. coli CIP59485934 01911785918817815
E. coli GEN71107005 074978598107815
K. pneumoniae AMX 0 01620162015371537
K. pneumoniae AMC12705429616201225452671537

Using Tidyverse selections, you can also select columns based on the antibiotic class they are in:

-
+
 data_1st %>% 
   select(bacteria, fluoroquinolones()) %>% 
   bug_drug_combinations()
-
# Selecting fluoroquinolones: 'CIP' (ciprofloxacin)
-# NOTE: Using column 'bacteria' as input for `col_mo`.
+
# Selecting fluoroquinolones: 'CIP' (ciprofloxacin)
@@ -1101,34 +1086,34 @@ Longest: 24

- + - - + + - + - - + + - + - - + + - + - - + +
mo
E. coli CIP59485934 01911785918817815
K. pneumoniae CIP12321189 038816203481537
S. aureus CIP29433064 087638199374001
S. pneumoniae CIP17971780 059423915502330
@@ -1139,11 +1124,11 @@ Longest: 24

Resistance percentages

The functions resistance() and susceptibility() can be used to calculate antimicrobial resistance or susceptibility. For more specific analyses, the functions proportion_S(), proportion_SI(), proportion_I(), proportion_IR() and proportion_R() can be used to determine the proportion of a specific antimicrobial outcome.

As per the EUCAST guideline of 2019, we calculate resistance as the proportion of R (proportion_R(), equal to resistance()) and susceptibility as the proportion of S and I (proportion_SI(), equal to susceptibility()). These functions can be used on their own:

-
+
 data_1st %>% resistance(AMX)
-# [1] 0.5359806
+# [1] 0.5342728

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

-
+
 data_1st %>% 
   group_by(hospital) %>% 
   summarise(amoxicillin = resistance(AMX))
@@ -1156,24 +1141,24 @@ Longest: 24

Hospital A -0.5285074 +0.5253802 Hospital B -0.5438369 +0.5367779 Hospital C -0.5389447 +0.5470814 Hospital D -0.5314924 +0.5334627

Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the n_rsi() can be used, which works exactly like n_distinct() from the dplyr package. It counts all isolates available for every group (i.e. values S, I or R):

-
+
 data_1st %>% 
   group_by(hospital) %>% 
   summarise(amoxicillin = resistance(AMX),
@@ -1188,28 +1173,28 @@ Longest: 24

Hospital A -0.5285074 -4683 +0.5253802 +4669 Hospital B -0.5438369 -5395 +0.5367779 +5574 Hospital C -0.5389447 -2388 +0.5470814 +2347 Hospital D -0.5314924 -3223 +0.5334627 +3093

These functions can also be used to get the proportion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:

-
+
 data_1st %>% 
   group_by(genus) %>% 
   summarise(amoxiclav = susceptibility(AMC),
@@ -1226,32 +1211,32 @@ Longest: 24

Escherichia -0.8268228 -0.9046953 -0.9846036 +0.8290467 +0.8963532 +0.9843890 Klebsiella -0.8172840 -0.8950617 -0.9827160 +0.8262850 +0.9095641 +0.9837345 Staphylococcus -0.8292747 -0.9193506 -0.9832417 +0.8307923 +0.9122719 +0.9872532 Streptococcus -0.5411962 +0.5351931 0.0000000 -0.5411962 +0.5351931

To make a transition to the next part, let’s see how this difference could be plotted:

-
+
 data_1st %>% 
   group_by(genus) %>% 
   summarise("1. Amoxi/clav" = susceptibility(AMC),
@@ -1270,7 +1255,7 @@ Longest: 24

Plots

To show results in plots, most R users would nowadays use the ggplot2 package. This package lets you create plots in layers. You can read more about it on their website. A quick example would look like these syntaxes:

-
+
 ggplot(data = a_data_set,
        mapping = aes(x = year,
                      y = value)) +
@@ -1284,13 +1269,13 @@ Longest: 24

ggplot(a_data_set) + geom_bar(aes(year))

The AMR package contains functions to extend this ggplot2 package, for example geom_rsi(). It automatically transforms data with count_df() or proportion_df() and show results in stacked bars. Its simplest and shortest example:

-
+
 ggplot(data_1st) +
   geom_rsi(translate_ab = FALSE)

Omit the translate_ab = FALSE to have the antibiotic codes (AMX, AMC, CIP, GEN) translated to official WHO names (amoxicillin, amoxicillin/clavulanic acid, ciprofloxacin, gentamicin).

If we group on e.g. the genus column and add some additional functions from our package, we can create this:

-
+
 # group the data on `genus`
 ggplot(data_1st %>% group_by(genus)) + 
   # create bars with genus on x axis
@@ -1313,7 +1298,7 @@ Longest: 24

theme(axis.text.y = element_text(face = "italic"))

To simplify this, we also created the ggplot_rsi() function, which combines almost all above functions:

-
+
 data_1st %>% 
   group_by(genus) %>%
   ggplot_rsi(x = "genus",
@@ -1328,7 +1313,7 @@ Longest: 24

Independence test

The next example uses the example_isolates data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR analysis.

We will compare the resistance to fosfomycin (column FOS) in hospital A and D. The input for the fisher.test() can be retrieved with a transformation like this:

-
+
 # use package 'tidyr' to pivot data:
 library(tidyr)
 
@@ -1347,7 +1332,7 @@ Longest: 24

# [1,] 25 77 # [2,] 24 33

We can apply the test now with:

-
+
 # do Fisher's Exact Test
 fisher.test(check_FOS)                            
 # 
@@ -1381,7 +1366,7 @@ Longest: 24

-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/AMR_files/figure-html/plot 1-1.png b/docs/articles/AMR_files/figure-html/plot 1-1.png index 8612585d2..e63aea5e6 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 1-1.png and b/docs/articles/AMR_files/figure-html/plot 1-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 3-1.png b/docs/articles/AMR_files/figure-html/plot 3-1.png index 6327eadd5..39bcc1471 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 3-1.png and b/docs/articles/AMR_files/figure-html/plot 3-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 4-1.png b/docs/articles/AMR_files/figure-html/plot 4-1.png index eb02d16b2..b58a3e740 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 4-1.png and b/docs/articles/AMR_files/figure-html/plot 4-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 5-1.png b/docs/articles/AMR_files/figure-html/plot 5-1.png index 81e1f8648..5817821ca 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 5-1.png and b/docs/articles/AMR_files/figure-html/plot 5-1.png differ diff --git a/docs/articles/EUCAST.html b/docs/articles/EUCAST.html index 35e50ba83..d1e919d31 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -5,32 +5,15 @@ - -How to apply EUCAST rules • AMR (for R) +How to apply EUCAST rules • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044
@@ -419,7 +402,7 @@
-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/MDR.html b/docs/articles/MDR.html index 3d8a28871..c638f0e5f 100644 --- a/docs/articles/MDR.html +++ b/docs/articles/MDR.html @@ -5,32 +5,15 @@ - -How to determine multi-drug resistance (MDR) • AMR (for R) +How to determine multi-drug resistance (MDR) • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044
@@ -268,7 +251,7 @@ example_isolates %>% mdro() %>% freq() # show frequency table of the result -# Warning in warning_("NA introduced for isolates where the available percentage of antimicrobial classes was below ", : NA introduced for isolates where the available percentage of antimicrobial +# Warning: NA introduced for isolates where the available percentage of antimicrobial # classes was below 50% (set with `pct_required_classes`)

Frequency table

Class: factor > ordered (numeric)
@@ -306,48 +289,41 @@ Unique: 2

For another example, I will create a data set to determine multi-drug resistant TB:

-# a helper function to get a random vector with values S, I and R
-# with the probabilities 50% - 10% - 40%
-sample_rsi <- function() {
-  sample(c("S", "I", "R"),
-         size = 5000,
-         prob = c(0.5, 0.1, 0.4),
-         replace = TRUE)
-}
-
-my_TB_data <- data.frame(rifampicin = sample_rsi(),
-                         isoniazid = sample_rsi(),
-                         gatifloxacin = sample_rsi(),
-                         ethambutol = sample_rsi(),
-                         pyrazinamide = sample_rsi(),
-                         moxifloxacin = sample_rsi(),
-                         kanamycin = sample_rsi())
+# random_rsi() is a helper function to generate +# a random vector with values S, I and R +my_TB_data <- data.frame(rifampicin = random_rsi(5000), + isoniazid = random_rsi(5000), + gatifloxacin = random_rsi(5000), + ethambutol = random_rsi(5000), + pyrazinamide = random_rsi(5000), + moxifloxacin = random_rsi(5000), + kanamycin = random_rsi(5000))

Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same:

-my_TB_data <- data.frame(RIF = sample_rsi(),
-                         INH = sample_rsi(),
-                         GAT = sample_rsi(),
-                         ETH = sample_rsi(),
-                         PZA = sample_rsi(),
-                         MFX = sample_rsi(),
-                         KAN = sample_rsi())
+my_TB_data <- data.frame(RIF = random_rsi(5000), + INH = random_rsi(5000), + GAT = random_rsi(5000), + ETH = random_rsi(5000), + PZA = random_rsi(5000), + MFX = random_rsi(5000), + KAN = random_rsi(5000))

The data set now looks like this:

 head(my_TB_data)
 #   rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
-# 1          S         R            S          R            R            S
-# 2          S         R            S          S            S            S
-# 3          S         S            S          S            R            S
-# 4          S         R            S          R            S            S
-# 5          R         S            R          S            R            S
-# 6          S         R            R          R            S            S
+# 1          S         S            R          I            R            S
+# 2          I         S            R          I            I            R
+# 3          R         R            R          S            I            R
+# 4          I         I            R          R            S            S
+# 5          I         R            I          S            S            R
+# 6          I         R            I          I            S            I
 #   kanamycin
-# 1         S
+# 1         R
 # 2         S
-# 3         S
-# 4         S
-# 5         R
-# 6         S
+# 3 I +# 4 I +# 5 I +# 6 R

We can now add the interpretation of MDR-TB to our data set. You can use:

 mdro(my_TB_data, guideline = "TB")
@@ -378,40 +354,40 @@ Unique: 5

1 Mono-resistant -3314 -66.28% -3314 -66.28% +3214 +64.28% +3214 +64.28% 2 Negative -637 -12.74% -3951 -79.02% +997 +19.94% +4211 +84.22% 3 Multi-drug-resistant -565 -11.30% -4516 -90.32% +442 +8.84% +4653 +93.06% 4 Poly-resistant -298 -5.96% -4814 -96.28% +239 +4.78% +4892 +97.84% 5 Extensively drug-resistant -186 -3.72% +108 +2.16% 5000 100.00% @@ -433,7 +409,7 @@ Unique: 5

-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/PCA.html b/docs/articles/PCA.html index e45199c90..58207a79a 100644 --- a/docs/articles/PCA.html +++ b/docs/articles/PCA.html @@ -5,32 +5,15 @@ - -How to conduct principal component analysis (PCA) for AMR • AMR (for R) +How to conduct principal component analysis (PCA) for AMR • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044
@@ -353,7 +336,7 @@
-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html index cc56111d7..110bc6fae 100644 --- a/docs/articles/SPSS.html +++ b/docs/articles/SPSS.html @@ -5,32 +5,15 @@ - -How to import data from SPSS / SAS / Stata • AMR (for R) +How to import data from SPSS / SAS / Stata • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044
@@ -210,7 +193,7 @@

How to import data from SPSS / SAS / Stata

Matthijs S. Berends

-

21 December 2020

+

24 December 2020

Source: vignettes/SPSS.Rmd @@ -431,7 +414,7 @@
-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html index 73d25f65d..1e024b431 100644 --- a/docs/articles/WHONET.html +++ b/docs/articles/WHONET.html @@ -5,32 +5,15 @@ - -How to work with WHONET data • AMR (for R) +How to work with WHONET data • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044
@@ -430,7 +413,7 @@ Drug group: Beta-lactams/penicillins
-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 1ffc6dbc6..2da29ea75 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -5,32 +5,15 @@ - -Benchmarks • AMR (for R) +Benchmarks • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044
@@ -244,20 +227,20 @@ times = 10) print(S.aureus, unit = "ms", signif = 2) # Unit: milliseconds -# expr min lq mean median uq max -# as.mo("sau") 10.0 11.0 20.0 13.0 38.0 41.0 -# as.mo("stau") 100.0 110.0 120.0 110.0 140.0 140.0 -# as.mo("STAU") 100.0 110.0 130.0 140.0 140.0 160.0 -# as.mo("staaur") 10.0 12.0 23.0 14.0 38.0 58.0 -# as.mo("STAAUR") 10.0 11.0 18.0 13.0 14.0 42.0 -# as.mo("S. aureus") 26.0 30.0 46.0 44.0 58.0 78.0 -# as.mo("S aureus") 26.0 27.0 32.0 31.0 31.0 56.0 -# as.mo("Staphylococcus aureus") 2.0 2.4 2.6 2.7 2.8 3.1 -# as.mo("Staphylococcus aureus (MRSA)") 890.0 910.0 920.0 920.0 930.0 960.0 -# as.mo("Sthafilokkockus aaureuz") 380.0 390.0 400.0 390.0 400.0 430.0 -# as.mo("MRSA") 9.9 11.0 16.0 14.0 14.0 41.0 -# as.mo("VISA") 17.0 19.0 28.0 21.0 45.0 52.0 -# as.mo("VRSA") 17.0 19.0 26.0 21.0 22.0 53.0 +# expr min lq mean median uq max +# as.mo("sau") 9.9 12.0 15.0 13.0 13.0 42.0 +# as.mo("stau") 100.0 100.0 130.0 120.0 140.0 190.0 +# as.mo("STAU") 110.0 110.0 130.0 130.0 140.0 150.0 +# as.mo("staaur") 9.8 12.0 26.0 13.0 41.0 60.0 +# as.mo("STAAUR") 11.0 11.0 15.0 13.0 13.0 41.0 +# as.mo("S. aureus") 26.0 28.0 50.0 58.0 63.0 75.0 +# as.mo("S aureus") 26.0 27.0 46.0 51.0 60.0 67.0 +# as.mo("Staphylococcus aureus") 1.9 2.2 2.5 2.5 2.8 3.1 +# as.mo("Staphylococcus aureus (MRSA)") 870.0 880.0 1100.0 910.0 1000.0 2400.0 +# as.mo("Sthafilokkockus aaureuz") 360.0 370.0 400.0 380.0 420.0 540.0 +# as.mo("MRSA") 9.7 11.0 17.0 12.0 13.0 66.0 +# as.mo("VISA") 19.0 19.0 36.0 35.0 53.0 56.0 +# as.mo("VRSA") 17.0 20.0 20.0 21.0 21.0 23.0 # neval # 10 # 10 @@ -301,8 +284,8 @@ print(run_it, unit = "ms", signif = 3) # Unit: milliseconds # expr min lq mean median uq max neval -# mo_name(x) 128 167 205 195 232 298 10
-

So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.195 seconds. You only lose time on your unique input values.

+# mo_name(x) 134 167 201 179 207 310 10
+

So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.179 seconds. You only lose time on your unique input values.

@@ -316,10 +299,10 @@ print(run_it, unit = "ms", signif = 3) # Unit: milliseconds # expr min lq mean median uq max neval -# A 7.35 7.70 8.15 8.11 8.68 8.96 10 -# B 22.50 22.80 28.10 24.30 25.70 62.60 10 -# C 1.84 1.98 2.13 2.13 2.17 2.43 10

-

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

+# A 7.59 7.93 8.24 8.09 8.66 9.06 10 +# B 23.60 23.70 29.20 24.30 27.10 66.10 10 +# C 1.84 2.13 2.22 2.19 2.35 2.62 10 +

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

 run_it <- microbenchmark(A = mo_species("aureus"),
                          B = mo_genus("Staphylococcus"),
@@ -333,14 +316,14 @@
 print(run_it, unit = "ms", signif = 3)
 # Unit: milliseconds
 #  expr  min   lq mean median   uq  max neval
-#     A 1.60 1.63 1.74   1.70 1.83 2.02    10
-#     B 1.37 1.40 1.62   1.54 1.74 2.07    10
-#     C 1.39 1.45 1.63   1.65 1.77 1.86    10
-#     D 1.37 1.40 1.58   1.51 1.62 2.27    10
-#     E 1.44 1.64 1.70   1.66 1.81 2.13    10
-#     F 1.38 1.42 1.57   1.58 1.67 1.81    10
-#     G 1.38 1.62 1.64   1.63 1.70 1.82    10
-#     H 1.44 1.65 1.84   1.82 1.99 2.60    10
+# A 1.69 1.77 1.82 1.83 1.86 1.92 10 +# B 1.78 1.79 1.89 1.91 1.95 2.06 10 +# C 1.74 1.79 1.88 1.87 1.94 2.06 10 +# D 1.75 1.77 1.94 1.95 1.99 2.41 10 +# E 1.70 1.75 1.84 1.81 1.87 2.08 10 +# F 1.66 1.70 1.76 1.74 1.80 1.89 10 +# G 1.68 1.70 1.82 1.75 1.93 2.09 10 +# H 1.66 1.69 1.75 1.74 1.80 1.92 10

Of course, when running mo_phylum("Firmicutes") the function has zero knowledge about the actual microorganism, namely S. aureus. But since the result would be "Firmicutes" anyway, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.

@@ -367,14 +350,14 @@ times = 100) print(run_it, unit = "ms", signif = 4) # Unit: milliseconds -# expr min lq mean median uq max neval -# en 15.77 16.36 18.40 16.85 17.50 53.58 100 -# de 19.03 19.70 24.60 20.14 21.06 59.83 100 -# nl 30.93 32.03 36.58 32.80 33.78 85.59 100 -# es 18.78 19.62 24.49 19.98 20.60 58.73 100 -# it 18.80 19.50 22.68 19.92 20.89 63.99 100 -# fr 18.78 19.59 21.99 19.90 20.75 58.87 100 -# pt 18.79 19.65 23.04 20.08 20.82 59.30 100
+# expr min lq mean median uq max neval +# en 15.91 16.98 21.87 17.54 18.34 168.50 100 +# de 18.98 20.14 26.30 20.74 22.64 66.68 100 +# nl 31.02 32.71 37.56 33.84 35.81 82.77 100 +# es 19.13 20.06 22.96 20.54 21.42 65.26 100 +# it 18.90 19.84 24.26 20.59 22.80 60.30 100 +# fr 18.89 19.92 23.46 20.49 21.72 62.85 100 +# pt 18.90 19.99 23.80 20.70 22.17 61.42 100

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

@@ -392,7 +375,7 @@
-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png index e3bc14d72..e00371786 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 5d7605867..6b0d3dac9 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -5,32 +5,15 @@ - -Data sets for download / own use • AMR (for R) +Data sets for download / own use • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044 @@ -1163,7 +1146,7 @@ If you are reading this page from within R, please -

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/index.html b/docs/articles/index.html index 1ca61f0bc..b5e7b58cc 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -6,22 +6,6 @@ - - - - Articles • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -85,9 +58,6 @@ - - - -How to predict antimicrobial resistance • AMR (for R) +How to predict antimicrobial resistance • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044 @@ -305,8 +288,7 @@ example_isolates %>% filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>% resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "binomial") %>% - ggplot_rsi_predict() -# NOTE: Using column 'date' as input for `col_date`. + ggplot_rsi_predict()

Vancomycin resistance could be 100% in ten years, but might also stay around 0%.

You can define the model with the model parameter. The model chosen above is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.

@@ -351,8 +333,7 @@ example_isolates %>% filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>% resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "linear") %>% - ggplot_rsi_predict() -# NOTE: Using column 'date' as input for `col_date`. + ggplot_rsi_predict()

This seems more likely, doesn’t it?

The model itself is also available from the object, as an attribute:

@@ -387,7 +368,7 @@
-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/welcome_to_AMR.html b/docs/articles/welcome_to_AMR.html index f87c91b9c..afd135717 100644 --- a/docs/articles/welcome_to_AMR.html +++ b/docs/articles/welcome_to_AMR.html @@ -5,32 +5,15 @@ - -Welcome to the AMR package • AMR (for R) +Welcome to the AMR package • AMR (for R) - - - - - - + + @@ -56,7 +39,7 @@ AMR (for R) - 1.4.0.9042 + 1.4.0.9044 @@ -266,7 +249,7 @@
-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/authors.html b/docs/authors.html index 6b5a267d0..65f35e465 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -6,22 +6,6 @@ - - - - Citation and Authors • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -85,9 +58,6 @@ - - - -Antimicrobial Resistance Analysis • AMR (for R) +Antimicrobial Resistance Analysis • AMR (for R) - - - - - - + + @@ -60,7 +43,7 @@ AMR (for R) - 1.4.0.9043 + 1.4.0.9044 @@ -531,7 +514,7 @@ Since you are one of our users, we would like to know how you use the package an
-

Made with pkgdown 1.6.1, using preferably template.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/news/index.html b/docs/news/index.html index 4220546bd..134fa8328 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -6,22 +6,6 @@ - - - - Changelog • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -85,9 +58,6 @@ - - - - - - Deprecated functions — AMR-deprecated • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - The AMR Package — AMR • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - WHOCC: WHO Collaborating Centre for Drug Statistics Methodology — WHOCC • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Data set with 500 isolates - WHONET example — WHONET • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Retrieve antimicrobial drug names and doses from clinical text — ab_from_text • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Get properties of an antibiotic — ab_property • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Age in years of individuals — age • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Split ages into age groups — age_groups • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Antibiotic class selectors — antibiotic_class_selectors • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Data sets with 557 antimicrobials — antibiotics • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Transform input to an antibiotic ID — as.ab • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Transform input to disk diffusion diameters — as.disk • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Transform input to minimum inhibitory concentrations (MIC) — as.mic • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Transform input to a microorganism ID — as.mo • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Interpret MIC and disk values, or clean raw R/SI data — as.rsi • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Get ATC properties from WHOCC website — atc_online_property • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Check availability of columns — availability • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Determine bug-drug combinations — bug_drug_combinations • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - The Catalogue of Life — catalogue_of_life • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Version info of included Catalogue of Life — catalogue_of_life_version • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Count available isolates — count • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -87,9 +60,6 @@ count_resistant() should be used to count resistant isolates, count_susceptible( - - - - - - Apply EUCAST rules — eucast_rules • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -87,9 +60,6 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied - - - - - - Data set with 2,000 example isolates — example_isolates • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Data set with unclean data — example_isolates_unclean • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Filter isolates on result in antimicrobial class — filter_ab_class • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Determine first (weighted) isolates — first_isolate • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - G-test for Count Data — g.test • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - PCA biplot with ggplot2 — ggplot_pca • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - AMR plots with ggplot2 — ggplot_rsi • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Guess antibiotic column — guess_ab_col • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Function reference • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -85,9 +58,6 @@ - - - - - - Data set with bacterial intrinsic resistance — intrinsic_resistant • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Determine (new) episodes for patients — is_new_episode • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Join microorganisms to a data set — join • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Key antibiotics for first weighted isolates — key_antibiotics • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Kurtosis of the sample — kurtosis • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Lifecycles of functions in the AMR package — lifecycle • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -88,9 +61,6 @@ This page contains a section for every lifecycle (with text borrowed from the af - - - - - - Pattern matching with keyboard shortcut — like • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Determine multidrug-resistant organisms (MDRO) — mdro • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Data set with 5,583 common microorganism codes — microorganisms.codes • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Data set with 67,151 microorganisms — microorganisms • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Data set with previously accepted taxonomic names — microorganisms.old • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Calculate the matching score for microorganisms — mo_matching_score • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Get properties of a microorganism — mo_property • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - User-defined reference data set for microorganisms — mo_source • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -76,8 +49,8 @@ - + @@ -87,9 +60,6 @@ This is the fastest way to have your organisation (or analysis) specific codes p - - - - - - Principal Component Analysis (for AMR) — pca • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Plotting for classes rsi, mic and disk — plot • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Calculate microbial resistance — proportion • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -87,9 +60,6 @@ resistance() should be used to calculate resistance, susceptibility() should be - - - - - - Random MIC values/disk zones/RSI generation — random • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Predict antimicrobial resistance — resistance_predict • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Data set for R/SI interpretation — rsi_translation • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Skewness of the sample — skewness • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -87,9 +60,6 @@ When negative ('left-skewed'): the left tail is longer; the mass of the distribu - - - - - - Translate strings from AMR package — translate • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -86,9 +59,6 @@ - - - - - - Survey • AMR (for R) @@ -36,21 +20,10 @@ + + - - - - - - - - - - - - - @@ -85,9 +58,6 @@ - - -