diff --git a/DESCRIPTION b/DESCRIPTION index 10399d02..593eaf2e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.5.0.9030 +Version: 1.5.0.9031 Date: 2021-03-05 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/NAMESPACE b/NAMESPACE index 60de0112..9f3e549a 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,17 @@ # Generated by roxygen2: do not edit by hand +S3method("!=",mic) +S3method("%%",mic) +S3method("%/%",mic) +S3method("*",mic) +S3method("+",mic) +S3method("-",mic) +S3method("/",mic) +S3method("<",mic) +S3method("<=",mic) +S3method("==",mic) +S3method(">",mic) +S3method(">=",mic) S3method("[",ab) S3method("[",disk) S3method("[",isolate_identifier) @@ -22,7 +34,10 @@ S3method("[[<-",isolate_identifier) S3method("[[<-",mic) S3method("[[<-",mo) S3method("[[<-",rsi) +S3method("^",mic) +S3method(all,mic) S3method(all.equal,isolate_identifier) +S3method(any,mic) S3method(as.data.frame,ab) S3method(as.data.frame,mo) S3method(as.double,mic) @@ -41,12 +56,19 @@ S3method(c,isolate_identifier) S3method(c,mic) S3method(c,mo) S3method(c,rsi) +S3method(ceiling,mic) S3method(droplevels,mic) S3method(droplevels,rsi) +S3method(floor,mic) S3method(format,bug_drug_combinations) +S3method(hist,mic) S3method(kurtosis,data.frame) S3method(kurtosis,default) S3method(kurtosis,matrix) +S3method(max,mic) +S3method(mean,mic) +S3method(median,mic) +S3method(min,mic) S3method(plot,disk) S3method(plot,mic) S3method(plot,resistance_predict) @@ -63,10 +85,14 @@ S3method(print,mo_renamed) S3method(print,mo_uncertainties) S3method(print,pca) S3method(print,rsi) +S3method(quantile,mic) +S3method(range,mic) S3method(rep,mo) S3method(skewness,data.frame) S3method(skewness,default) S3method(skewness,matrix) +S3method(sort,mic) +S3method(sum,mic) S3method(summary,mic) S3method(summary,mo) S3method(summary,pca) diff --git a/NEWS.md b/NEWS.md index 0f743a4e..d80d9ab4 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.5.0.9030 +# AMR 1.5.0.9031 ## Last updated: 5 March 2021 ### New @@ -43,6 +43,7 @@ mo_type(c("Aspergillus", "Candida"), language = "es") # also supported: de, nl, fr, it, pt #> [1] "Hongos" "Levaduras" ``` +* Added Pretomanid (PMD, J04AK08) to the `antibiotics` data set ### Changed * Updated the bacterial taxonomy to 3 March 2021 (using [LSPN](https://lpsn.dsmz.de)) @@ -56,8 +57,8 @@ * `is.rsi()` and `is.rsi.eligible()` now return a vector of `TRUE`/`FALSE` when the input is a data set, by iterating over all columns * Using functions without setting a data set (e.g., `mo_is_gram_negative()`, `mo_is_gram_positive()`, `mo_is_intrinsic_resistant()`, `first_isolate()`, `mdro()`) now work with `dplyr`s `group_by()` again * `first_isolate()` can be used with `group_by()` (also when using a dot `.` as input for the data) and now returns the names of the groups +* MIC values now allow for any mathematical processing, such as usage inside functions `min()`, `max()`, `range()`, and with binary operators (+, -, etc.). This also enables other functions, such as `fivenum()`. * Updated the data set `microorganisms.codes` (which contains popular LIS and WHONET codes for microorganisms) for some species of *Mycobacterium* that previously incorrectly returned *M. africanum* -* Added Pretomanid (PMD, J04AK08) to the `antibiotics` data set * WHONET code `"PNV"` will now correctly be interpreted as `PHN`, the antibiotic code for phenoxymethylpenicillin ('peni V') * Fix for verbose output of `mdro(..., verbose = TRUE)` for German guideline (3MGRN and 4MGRN) and Dutch guideline (BRMO, only *P. aeruginosa*) * `is.rsi.eligible()` now detects if the column name resembles an antibiotic name or code and now returns `TRUE` immediately if the input contains any of the values "R", "S" or "I". This drastically improves speed, also for a lot of other functions that rely on automatic determination of antibiotic columns. diff --git a/R/amr.R b/R/amr.R index 20f6fa0e..cae8b4c3 100644 --- a/R/amr.R +++ b/R/amr.R @@ -29,7 +29,7 @@ #' @details #' `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 ~550 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 format_included_data_number(microorganisms)` distinct microbial species and all `r format_included_data_number(rbind(antibiotics[, "atc", drop = FALSE], 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. #' #' 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. It 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 and free software; you can freely use and distribute it for both personal and commercial (but not patent) purposes under the terms of the GNU General Public License version 2.0 (GPL-2), as published by the Free Software Foundation. #' diff --git a/R/catalogue_of_life.R b/R/catalogue_of_life.R index 986b90e6..d3b2c265 100755 --- a/R/catalogue_of_life.R +++ b/R/catalogue_of_life.R @@ -44,7 +44,7 @@ format_included_data_number <- function(data) { #' This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life. #' @section Catalogue of Life: #' \if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} -#' This package contains the complete taxonomic tree of almost all microorganisms (~70,000 species) from the authoritative and comprehensive Catalogue of Life (CoL, ). The CoL is the most comprehensive and authoritative global index of species currently available. Nonetheless, we supplemented the CoL data with data from the List of Prokaryotic names with Standing in Nomenclature (LPSN, [lpsn.dsmz.de](https://lpsn.dsmz.de)). This supplementation is needed until the [CoL+ project](https://github.com/CatalogueOfLife/general) is finished, which we await. +#' This package contains the complete taxonomic tree of almost all microorganisms (`r format_included_data_number(microorganisms)` species) from the authoritative and comprehensive Catalogue of Life (CoL, ). The CoL is the most comprehensive and authoritative global index of species currently available. Nonetheless, we supplemented the CoL data with data from the List of Prokaryotic names with Standing in Nomenclature (LPSN, [lpsn.dsmz.de](https://lpsn.dsmz.de)). This supplementation is needed until the [CoL+ project](https://github.com/CatalogueOfLife/general) is finished, which we await. #' #' [Click here][catalogue_of_life] for more information about the included taxa. Check which versions of the CoL and LPSN were included in this package with [catalogue_of_life_version()]. #' @section Included Taxa: diff --git a/R/mic.R b/R/mic.R index 3bfe19d2..66177588 100755 --- a/R/mic.R +++ b/R/mic.R @@ -42,6 +42,11 @@ #' #' # this can also coerce combined MIC/RSI values: #' as.mic("<=0.002; S") # will return <=0.002 +#' +#' # mathematical processing treats MICs as numeric values +#' fivenum(mic_data) +#' quantile(mic_data) +#' all(mic_data < 512) #' #' # interpret MIC values #' as.rsi(x = as.mic(2), @@ -276,6 +281,222 @@ unique.mic <- function(x, incomparables = FALSE, ...) { y } +#' @method range mic +#' @export +#' @noRd +range.mic <- function(..., na.rm = FALSE) { + rng <- sort(c(...)) + if (na.rm == TRUE) { + rng <- rng[!is.na(rng)] + } + out <- c(as.character(rng[1]), as.character(rng[length(rng)])) + as.double(as.mic(out)) +} + +#' @method min mic +#' @export +#' @noRd +min.mic <- function(..., na.rm = FALSE) { + rng <- sort(c(...)) + if (na.rm == TRUE) { + rng <- rng[!is.na(rng)] + } + as.double(as.mic(as.character(rng[1]))) +} + +#' @method max mic +#' @export +#' @noRd +max.mic <- function(..., na.rm = FALSE) { + rng <- sort(c(...)) + if (na.rm == TRUE) { + rng <- rng[!is.na(rng)] + } + as.double(as.mic(as.character(rng[length(rng)]))) +} + +#' @method sum mic +#' @export +#' @noRd +sum.mic <- function(..., na.rm = FALSE) { + rng <- sort(c(...)) + if (na.rm == TRUE) { + rng <- rng[!is.na(rng)] + } + sum(as.double(rng)) +} + +#' @method all mic +#' @export +#' @noRd +all.mic <- function(..., na.rm = FALSE) { + rng <- sort(c(...)) + if (na.rm == TRUE) { + rng <- rng[!is.na(rng)] + } + all(as.double(rng)) +} + +#' @method any mic +#' @export +#' @noRd +any.mic <- function(..., na.rm = FALSE) { + rng <- sort(c(...)) + if (na.rm == TRUE) { + rng <- rng[!is.na(rng)] + } + any(as.double(rng)) +} + +#' @method mean mic +#' @export +#' @noRd +mean.mic <- function(x, na.rm = FALSE, ...) { + mean(as.double(x), na.rm = na.rm, ...) +} + +#' @method median mic +#' @export +#' @noRd +median.mic <- function(x, na.rm = FALSE, ...) { + median(as.double(x), na.rm = na.rm, ...) +} + +#' @method quantile mic +#' @export +#' @noRd +quantile.mic <- function(x, probs = seq(0, 1, 0.25), na.rm = FALSE, + names = TRUE, type = 7, ...) { + quantile(as.double(x), props = props, na.rm = na.rm, names = names, type = type, ...) +} + +#' @method floor mic +#' @export +#' @noRd +floor.mic <- function(x) { + floor(as.double(x)) +} + +#' @method ceiling mic +#' @export +#' @noRd +ceiling.mic <- function(x) { + ceiling(as.double(x)) +} + +#' @method + mic +#' @export +#' @noRd +`+.mic` <- function(e1, e2) { + as.double(e1) + as.double(e2) +} + +#' @method - mic +#' @export +#' @noRd +`-.mic` <- function(e1, e2) { + as.double(e1) - as.double(e2) +} + +#' @method * mic +#' @export +#' @noRd +`*.mic` <- function(e1, e2) { + as.double(e1) * as.double(e2) +} + +#' @method / mic +#' @export +#' @noRd +`/.mic` <- function(e1, e2) { + as.double(e1) / as.double(e2) +} + +#' @method ^ mic +#' @export +#' @noRd +`^.mic` <- function(e1, e2) { + as.double(e1) ^ as.double(e2) +} + +#' @method %% mic +#' @export +#' @noRd +`%%.mic` <- function(e1, e2) { + as.double(e1) %% as.double(e2) +} + +#' @method %/% mic +#' @export +#' @noRd +`%/%.mic` <- function(e1, e2) { + as.double(e1) %/% as.double(e2) +} + +#' @method == mic +#' @export +#' @noRd +`==.mic` <- function(e1, e2) { + as.double(e1) == as.double(e2) +} + +#' @method != mic +#' @export +#' @noRd +`!=.mic` <- function(e1, e2) { + as.double(e1) != as.double(e2) +} + +#' @method < mic +#' @export +#' @noRd +`<.mic` <- function(e1, e2) { + as.double(e1) < as.double(e2) +} + +#' @method <= mic +#' @export +#' @noRd +`<=.mic` <- function(e1, e2) { + as.double(e1) <= as.double(e2) +} + +#' @method >= mic +#' @export +#' @noRd +`>=.mic` <- function(e1, e2) { + as.double(e1) >= as.double(e2) +} + +#' @method > mic +#' @export +#' @noRd +`>.mic` <- function(e1, e2) { + as.double(e1) > as.double(e2) +} + +#' @method sort mic +#' @export +#' @noRd +sort.mic <- function(x, decreasing = FALSE, ...) { + if (decreasing == TRUE) { + ord <- order(-as.double(x)) + } else { + ord <- order(as.double(x)) + } + x[ord] +} + + + +#' @method hist mic +#' @export +#' @noRd +hist.mic <- function(x, ...) { + warning_("Use `plot()` or `ggplot()` for plotting MIC values", call = FALSE) + hist(as.double(x), ...) +} + # will be exported using s3_register() in R/zzz.R get_skimmers.mic <- function(column) { skimr::sfl( diff --git a/R/mo.R b/R/mo.R index 5010b75b..5faf5b47 100755 --- a/R/mo.R +++ b/R/mo.R @@ -1474,8 +1474,8 @@ exec_as.mo <- function(x, if (length(uncertainties$input) > 1) { plural <- c("s", "them", "were") } - msg <- paste0("Translation to ", nr2char(length(uncertainties$input)), " microorganism", plural[1], - " was guessed with uncertainty. Use `mo_uncertainties()` to review ", plural[2], ".") + msg <- paste0("Translation is uncertain of ", nr2char(length(uncertainties$input)), " microorganism", plural[1], + ". Use `mo_uncertainties()` to review ", plural[2], ".") message_(msg) } x[already_known] <- x_known diff --git a/R/plot.R b/R/plot.R index 48dffc79..1fbaf3da 100644 --- a/R/plot.R +++ b/R/plot.R @@ -261,7 +261,6 @@ ggplot.mic <- function(data, ggplot2::labs(title = title, x = xlab, y = ylab, subtitle = cols_sub$sub) } - #' @method plot disk #' @export #' @importFrom graphics barplot axis mtext legend diff --git a/R/random.R b/R/random.R index bc3b6d17..b4db99a4 100644 --- a/R/random.R +++ b/R/random.R @@ -51,9 +51,9 @@ #' random_mic(100, "Klebsiella pneumoniae", "meropenem") # range 0.0625-16 #' random_mic(100, "Streptococcus pneumoniae", "meropenem") # range 0.0625-4 #' -#' random_disk(100, "Klebsiella pneumoniae") # range 11-50 -#' random_disk(100, "Klebsiella pneumoniae", "ampicillin") # range 6-14 -#' random_disk(100, "Streptococcus pneumoniae", "ampicillin") # range 16-22 +#' random_disk(100, "Klebsiella pneumoniae") # range 8-50 +#' random_disk(100, "Klebsiella pneumoniae", "ampicillin") # range 11-17 +#' random_disk(100, "Streptococcus pneumoniae", "ampicillin") # range 12-27 #' } random_mic <- function(size, mo = NULL, ab = NULL, ...) { random_exec("MIC", size = size, mo = mo, ab = ab) diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 17ffa7f2..58082bf8 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/404.html b/docs/404.html index ec86223d..aaec4254 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9030 + 1.5.0.9031 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 64188ba0..90b478fb 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9030 + 1.5.0.9031 diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 30f7e18c..b1317cca 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.5.0.9030 + 1.5.0.9031 @@ -211,7 +211,7 @@ If you are reading this page from within R, please Microorganisms (currently accepted names)

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

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

-

It was last updated on 5 March 2021 09:32:45 CET. Find more info about the structure of this data set here.

+

It was last updated on 5 March 2021 10:46:55 CET. Find more info about the structure of this data set here.

Direct download links: