diff --git a/DESCRIPTION b/DESCRIPTION index d6127fe9..3545cce0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.5.0.9018 -Date: 2021-02-09 +Version: 1.5.0.9019 +Date: 2021-02-17 Title: Antimicrobial Resistance Data Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index a1c220a0..9a3278f5 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.5.0.9018 -## Last updated: 9 February 2021 +# AMR 1.5.0.9019 +## Last updated: 17 February 2021 ### New * Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the `eucast_rules()` function and in `as.rsi()` to interpret MIC and disk diffusion values. This is now the default guideline in this package. @@ -7,10 +7,10 @@ * Added data set `dosage` to fuel the new `eucast_dosage()` function and to make this data available in a structured way * Existing data set `example_isolates` now reflects the latest EUCAST rules * Added argument `only_rsi_columns` for some functions, which defaults to `FALSE`, to indicate if the functions must only be applied to columns that are of class `` (i.e., transformed with `as.rsi()`). This increases speed since automatic determination of antibiotic columns is not needed anymore. Affected functions are: - * All antibiotic selector functions (`ab_class()` and its wrappers, such as `aminoglocysides()`, `carbapenems()`, `penicillins()`) - * All antibiotic filter functions (`filter_ab_class()` and its wrappers, such as `filter_aminoglocysides()`, `filter_carbapenems()`, `filter_penicillins()`) + * All antibiotic selector functions (`ab_class()` and its wrappers, such as `aminoglycosides()`, `carbapenems()`, `penicillins()`) + * All antibiotic filter functions (`filter_ab_class()` and its wrappers, such as `filter_aminoglycosides()`, `filter_carbapenems()`, `filter_penicillins()`) * `eucast_rules()` - * `mdro()` (including wrappers such as `brmo()`, `mrgn` and `eucast_exceptional_phenotypes()`) + * `mdro()` (including wrappers such as `brmo()`, `mrgn()` and `eucast_exceptional_phenotypes()`) * `guess_ab_col()` * Functions `oxazolidinones()` (an antibiotic selector function) and `filter_oxazolidinones()` (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid ```r diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index d63cf6e9..7d507fb2 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -82,20 +82,27 @@ check_dataset_integrity <- function() { # exception for example_isolates overwritten <- overwritten[overwritten != "example_isolates"] if (length(overwritten) > 0) { - warning_(ifelse(length(overwritten) == 1, - "The following data set is overwritten by your global environment and prevents the AMR package from working correctly: ", - "The following data sets are overwritten by your global environment and prevent the AMR package from working correctly: "), + if (length(overwritten) > 1) { + plural <- c("s are", "", "s") + } else { + plural <- c(" is", "s", "") + } + warning_("The following data set", plural[1], + " overwritten by your global environment and prevent", plural[2], + " the AMR package from working correctly: ", vector_and(overwritten, quotes = "'"), - ".\nPlease rename your object(s).", call = FALSE) + ".\nPlease rename your object", plural[3], ".", call = FALSE) } # check if other packages did not overwrite our data sets + valid_microorganisms <- TRUE + valid_antibiotics <- TRUE tryCatch({ - check_microorganisms <- all(c("mo", "fullname", "kingdom", "phylum", + valid_microorganisms <- all(c("mo", "fullname", "kingdom", "phylum", "class", "order", "family", "genus", "species", "subspecies", "rank", "species_id", "source", "ref", "prevalence") %in% colnames(microorganisms), na.rm = TRUE) - check_antibiotics <- all(c("ab", "atc", "cid", "name", "group", + valid_antibiotics <- all(c("ab", "atc", "cid", "name", "group", "atc_group1", "atc_group2", "abbreviations", "synonyms", "oral_ddd", "oral_units", "iv_ddd", "iv_units", "loinc") %in% colnames(antibiotics), @@ -104,7 +111,7 @@ check_dataset_integrity <- function() { # package not yet loaded require("AMR") }) - stop_if(!check_microorganisms | !check_antibiotics, + stop_if(!valid_microorganisms | !valid_antibiotics, "the data set `microorganisms` or `antibiotics` was overwritten in your environment because another package with the same object names was loaded _after_ the AMR package, preventing the AMR package from working correctly. Please load the AMR package last.") invisible(TRUE) } diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R index 53b1fe6b..4df43510 100644 --- a/R/ab_class_selectors.R +++ b/R/ab_class_selectors.R @@ -43,7 +43,7 @@ #' # See ?example_isolates. #' #' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): -#' example_isolates[, c(carbapenems())] +#' example_isolates[, carbapenems()] #' # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB': #' example_isolates[, c("mo", aminoglycosides())] #' diff --git a/R/mo.R b/R/mo.R index 847254af..6ca15e83 100755 --- a/R/mo.R +++ b/R/mo.R @@ -1806,7 +1806,9 @@ print.mo_uncertainties <- function(x, ...) { candidates <- candidates[order(1 - scores)] scores_formatted <- trimws(formatC(round(scores, 3), format = "f", digits = 3)) n_candidates <- length(candidates) - candidates <- vector_and(paste0(candidates, " (", scores_formatted[order(1 - scores)], ")"), quotes = FALSE) + candidates <- vector_and(paste0(candidates, " (", scores_formatted[order(1 - scores)], ")"), + quotes = FALSE, + sort = FALSE) # align with input after arrow candidates <- paste0("\n", strwrap(paste0("Also matched", diff --git a/README.md b/README.md index 81d4cb12..d4d1592f 100755 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This package is fully independent of any other R package and works on Windows, m This is the development source of the `AMR` package for R. Not a developer? Then please visit our website [https://msberends.github.io/AMR/](https://msberends.github.io/AMR/) to read more about this package. -*NOTE: this source code is on GitHub (https://github.com/msberends/AMR), but also automatically mirrored to GitLab (https://gitlab.com/msberends/AMR).* +*NOTE: this source code is on GitHub (https://github.com/msberends/AMR), but also automatically mirrored to our university's Gitea server (https://git.web.rug.nl/P281424/AMR) and to GitLab (https://gitlab.com/msberends/AMR).* ### How to get this package Please see [our website](https://msberends.github.io/AMR/#get-this-package). diff --git a/data-raw/AMR_1.5.0.9018.tar.gz b/data-raw/AMR_1.5.0.9019.tar.gz similarity index 88% rename from data-raw/AMR_1.5.0.9018.tar.gz rename to data-raw/AMR_1.5.0.9019.tar.gz index 867e430b..1b685946 100644 Binary files a/data-raw/AMR_1.5.0.9018.tar.gz and b/data-raw/AMR_1.5.0.9019.tar.gz differ diff --git a/data-raw/reproduction_of_microorganisms.R b/data-raw/reproduction_of_microorganisms.R index 88487ee2..7bacef5b 100644 --- a/data-raw/reproduction_of_microorganisms.R +++ b/data-raw/reproduction_of_microorganisms.R @@ -25,8 +25,9 @@ # Reproduction of the `microorganisms` data set -# Data retrieved from the Catalogue of Life (CoL) through the Encyclopaedia of Life: -# https://opendata.eol.org/dataset/catalogue-of-life/ +# Data retrieved from the Catalogue of Life (CoL): +# https://download.catalogueoflife.org/col/monthly/life/ +# (download latest dwca, such as https://download.catalogueoflife.org/col/monthly/2020-12-01_dwca.zip) # Data retrieved from the Global Biodiversity Information Facility (GBIF): # https://doi.org/10.15468/rffz4x # @@ -38,7 +39,7 @@ library(AMR) # also needed: data.table, httr, jsonlite, cleaner, stringr # unzip and extract taxa.txt (both around 1.5 GB, 3.7-3.9M rows) from Col and GBIF, then: -data_col_raw <- data.table::fread("data-raw/taxon.tab", quote = "") +data_col_raw <- data.table::fread("data-raw/taxon.tsv", quote = "") data_gbif <- data.table::fread("data-raw/taxa.txt", quote = "") # merge the two diff --git a/docs/404.html b/docs/404.html index 48b6c031..43c4fad1 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9018 + 1.5.0.9019 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index bf77346f..6d5d1e4f 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9018 + 1.5.0.9019 diff --git a/docs/articles/index.html b/docs/articles/index.html index ad832dd2..e05b9bd2 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9018 + 1.5.0.9019 diff --git a/docs/authors.html b/docs/authors.html index 471ce3c5..8d83429d 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9018 + 1.5.0.9019 diff --git a/docs/extra.css b/docs/extra.css index da89ffc2..0ebc198f 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -88,7 +88,7 @@ a pre[href], a pre[href]:hover, a pre[href]:focus { /* adjusted colour for all real links; having href attribute */ color: #128f76; } -.ot, .dv { +.ot, .dv, .fl, .cn { /* numbers and TRUE/FALSE */ color: slategray; } @@ -187,10 +187,13 @@ div[id^=last-updated] h2 { } /* tables, make them look like scientific ones */ -.table { +table { font-size: 90%; } -.table td { +table * { + vertical-align: middle !important; +} +table td { padding: 4px !important; } thead { diff --git a/docs/index.html b/docs/index.html index c442e626..7b6fc433 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.5.0.9018 + 1.5.0.9019 diff --git a/docs/news/index.html b/docs/news/index.html index e771b466..bff725b8 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9018 + 1.5.0.9019 @@ -236,13 +236,13 @@ Source: NEWS.md -
-

-AMR 1.5.0.9018 Unreleased +
+

+AMR 1.5.0.9019 Unreleased

-
+

-Last updated: 9 February 2021 +Last updated: 17 February 2021

@@ -259,11 +259,11 @@
  • Added argument only_rsi_columns for some functions, which defaults to FALSE, to indicate if the functions must only be applied to columns that are of class <rsi> (i.e., transformed with as.rsi()). This increases speed since automatic determination of antibiotic columns is not needed anymore. Affected functions are:

  • @@ -651,7 +651,7 @@

    Making this package independent of especially the tidyverse (e.g. packages dplyr and tidyr) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Good for users, but hard for package maintainers. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.

    Negative effects of this change are:

      -
    • Function freq() that was borrowed from the cleaner package was removed. Use cleaner::freq(), or run library("cleaner") before you use freq().
    • +
    • Function freq() that was borrowed from the cleaner package was removed. Use cleaner::freq(), or run library("cleaner") before you use freq().
    • Printing values of class mo or rsi in a tibble will no longer be in colour and printing rsi in a tibble will show the class <ord>, not <rsi> anymore. This is purely a visual effect.
    • All functions from the mo_* family (like mo_name() and mo_gramstain()) are noticeably slower when running on hundreds of thousands of rows.
    • For developers: classes mo and ab now both also inherit class character, to support any data transformation. This change invalidates code that checks for class length == 1.
    • @@ -988,7 +988,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ #> invalid microorganism code, NA generated

    This is important, because a value like "testvalue" could never be understood by e.g. mo_name(), although the class would suggest a valid microbial code.

    -
  • Function freq() has moved to a new package, clean (CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq() function still works, since it is re-exported from the clean package (which will be installed automatically upon updating this AMR package).

  • +
  • Function freq() has moved to a new package, clean (CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq() function still works, since it is re-exported from the clean package (which will be installed automatically upon updating this AMR package).

  • Renamed data set septic_patients to example_isolates

  • @@ -1257,7 +1257,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • The age() function gained a new argument exact to determine ages with decimals
  • Removed deprecated functions guess_mo(), guess_atc(), EUCAST_rules(), interpretive_reading(), rsi()
  • -
  • Frequency tables (freq()): +
  • Frequency tables (freq()):
    • speed improvement for microbial IDs

    • fixed factor level names for R Markdown

    • @@ -1267,12 +1267,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
       
       septic_patients %>% 
      -  freq(age) %>% 
      +  freq(age) %>% 
         boxplot()
       # grouped boxplots:
       septic_patients %>% 
         group_by(hospital_id) %>% 
      -  freq(age) %>%
      +  freq(age) %>%
         boxplot()
    @@ -1282,7 +1282,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Added ceftazidim intrinsic resistance to Streptococci
  • Changed default settings for age_groups(), to let groups of fives and tens end with 100+ instead of 120+
  • -
  • Fix for freq() for when all values are NA +
  • Fix for freq() for when all values are NA
  • Fix for first_isolate() for when dates are missing
  • Improved speed of guess_ab_col() @@ -1523,7 +1523,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • -
  • Frequency tables (freq() function): +
  • Frequency tables (freq() function):
    • Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:

      @@ -1533,15 +1533,15 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # OLD WAY septic_patients %>% mutate(genus = mo_genus(mo)) %>% - freq(genus) + freq(genus) # NEW WAY septic_patients %>% - freq(mo_genus(mo)) + freq(mo_genus(mo)) # Even supports grouping variables: septic_patients %>% group_by(gender) %>% - freq(mo_genus(mo))
  • + freq(mo_genus(mo))
  • Header info is now available as a list, with the header function

  • The argument header is now set to TRUE at default, even for markdown

  • @@ -1624,7 +1624,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Using portion_* functions now throws a warning when total available isolate is below argument minimum

  • Functions as.mo, as.rsi, as.mic, as.atc and freq will not set package name as attribute anymore

  • -

    Frequency tables - freq():

    +

    Frequency tables - freq():

    • Support for grouping variables, test with:

      @@ -1632,14 +1632,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ septic_patients %>% group_by(hospital_id) %>% - freq(gender)
  • + freq(gender)
  • Support for (un)selecting columns:

     
     septic_patients %>% 
    -  freq(hospital_id) %>% 
    +  freq(hospital_id) %>% 
       select(-count, -cum_count) # only get item, percent, cum_percent
  • Check for hms::is.hms

  • @@ -1657,7 +1657,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Removed diacritics from all authors (columns microorganisms$ref and microorganisms.old$ref) to comply with CRAN policy to only allow ASCII characters

  • Fix for mo_property not working properly

  • Fix for eucast_rules where some Streptococci would become ceftazidime R in EUCAST rule 4.5

  • -
  • Support for named vectors of class mo, useful for top_freq()

  • +
  • Support for named vectors of class mo, useful for top_freq()

  • ggplot_rsi and scale_y_percent have breaks argument

  • AI improvements for as.mo:

    @@ -1825,13 +1825,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
     
     my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2))
    -freq(my_matrix)
    +freq(my_matrix)

    For lists, subsetting is possible:

     
     my_list = list(age = septic_patients$age, gender = septic_patients$gender)
    -my_list %>% freq(age)
    -my_list %>% freq(gender)
    +my_list %>% freq(age) +my_list %>% freq(gender)
  • @@ -1905,13 +1905,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/