Browse Source

(v1.8.0.9001) as.mo improvement, fixes #52

new-mo-algorithm
parent
commit
18e8525d10
  1. 4
      DESCRIPTION
  2. 17
      NEWS.md
  3. 2
      R/catalogue_of_life.R
  4. 12
      R/lifecycle.R
  5. 63
      R/mo.R
  6. 17
      R/mo_matching_score.R
  7. 19
      R/rsi.R
  8. 2
      R/whocc.R
  9. 5
      R/zzz.R
  10. BIN
      data-raw/AMR_latest.tar.gz
  11. 4
      data-raw/reproduction_of_microorganisms.R
  12. 4
      docs/articles/datasets.html
  13. 130
      docs/news/index.html
  14. 7
      docs/reference/AMR-deprecated.html
  15. 7
      docs/reference/WHOCC.html
  16. 12
      docs/reference/ab_from_text.html
  17. 13
      docs/reference/ab_property.html
  18. 10
      docs/reference/age.html
  19. 10
      docs/reference/age_groups.html
  20. 12
      docs/reference/antibiotic_class_selectors.html
  21. 13
      docs/reference/antibiotics.html
  22. 15
      docs/reference/as.ab.html
  23. 12
      docs/reference/as.disk.html
  24. 12
      docs/reference/as.mic.html
  25. 21
      docs/reference/as.mo.html
  26. 12
      docs/reference/as.rsi.html
  27. 12
      docs/reference/atc_online.html
  28. 10
      docs/reference/availability.html
  29. 12
      docs/reference/bug_drug_combinations.html
  30. 7
      docs/reference/catalogue_of_life.html
  31. 10
      docs/reference/catalogue_of_life_version.html
  32. 12
      docs/reference/count.html
  33. 10
      docs/reference/custom_eucast_rules.html
  34. 12
      docs/reference/eucast_rules.html
  35. 12
      docs/reference/first_isolate.html
  36. 10
      docs/reference/g.test.html
  37. 12
      docs/reference/get_episode.html
  38. 12
      docs/reference/ggplot_pca.html
  39. 12
      docs/reference/ggplot_rsi.html
  40. 12
      docs/reference/guess_ab_col.html
  41. 4
      docs/reference/index.html
  42. 12
      docs/reference/italicise_taxonomy.html
  43. 12
      docs/reference/join.html
  44. 12
      docs/reference/key_antimicrobials.html
  45. 12
      docs/reference/kurtosis.html
  46. 17
      docs/reference/lifecycle.html
  47. 12
      docs/reference/like.html
  48. 12
      docs/reference/mdro.html
  49. 10
      docs/reference/microorganisms.codes.html
  50. 10
      docs/reference/microorganisms.html
  51. 10
      docs/reference/microorganisms.old.html
  52. 15
      docs/reference/mo_matching_score.html
  53. 17
      docs/reference/mo_property.html
  54. 12
      docs/reference/mo_source.html
  55. 12
      docs/reference/pca.html
  56. 12
      docs/reference/plot.html
  57. 12
      docs/reference/proportion.html
  58. 12
      docs/reference/random.html
  59. 12
      docs/reference/resistance_predict.html
  60. 12
      docs/reference/skewness.html
  61. 10
      docs/reference/translate.html
  62. 2
      man/AMR-deprecated.Rd
  63. 2
      man/WHOCC.Rd
  64. 2
      man/ab_from_text.Rd
  65. 2
      man/ab_property.Rd
  66. 2
      man/age.Rd
  67. 2
      man/age_groups.Rd
  68. 2
      man/antibiotic_class_selectors.Rd
  69. 2
      man/antibiotics.Rd
  70. 4
      man/as.ab.Rd
  71. 2
      man/as.disk.Rd
  72. 2
      man/as.mic.Rd
  73. 12
      man/as.mo.Rd
  74. 2
      man/as.rsi.Rd
  75. 2
      man/atc_online.Rd
  76. 2
      man/availability.Rd
  77. 2
      man/bug_drug_combinations.Rd
  78. 2
      man/catalogue_of_life.Rd
  79. 2
      man/catalogue_of_life_version.Rd
  80. 2
      man/count.Rd
  81. 2
      man/custom_eucast_rules.Rd
  82. 2
      man/eucast_rules.Rd
  83. 2
      man/first_isolate.Rd
  84. 2
      man/g.test.Rd
  85. 2
      man/get_episode.Rd
  86. 2
      man/ggplot_pca.Rd
  87. 2
      man/ggplot_rsi.Rd
  88. 2
      man/guess_ab_col.Rd
  89. 2
      man/italicise_taxonomy.Rd
  90. 2
      man/join.Rd
  91. 2
      man/key_antimicrobials.Rd
  92. 2
      man/kurtosis.Rd
  93. 12
      man/lifecycle.Rd
  94. 2
      man/like.Rd
  95. 2
      man/mdro.Rd
  96. 2
      man/microorganisms.Rd
  97. 2
      man/microorganisms.codes.Rd
  98. 2
      man/microorganisms.old.Rd
  99. 8
      man/mo_matching_score.Rd
  100. 8
      man/mo_property.Rd
  101. Some files were not shown because too many files have changed in this diff Show More

4
DESCRIPTION

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Package: AMR
Version: 1.8.0.9000
Date: 2022-02-01
Version: 1.8.0.9001
Date: 2022-02-26
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
data analysis and to work with microbial and antimicrobial properties by

17
NEWS.md

@ -1,14 +1,23 @@ @@ -1,14 +1,23 @@
# `AMR` 1.8.0.9000
## <small>Last updated: 1 February 2022</small>
# `AMR` 1.8.0.9001
## <small>Last updated: 26 February 2022</small>
All functions in this package are considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months.
### Changed
* Support for antibiotic interpretations of the MIPS laboratory system: `"U"` for S ('susceptible urine'), `"D"` for I ('susceptible dose-dependent')
* Improved algorithm of `as.mo()`, especially for ignoring non-taxonomic text, such as:
```r
mo_name("methicillin-resistant S. aureus (MRSA)")
#> [1] "Staphylococcus aureus"
```
### Other
* Fix for unit testing on R 3.3
* Fix for size of some image elements, as requested by CRAN
# `AMR` 1.8.0
All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months from now on.
### Breaking changes
* Removed `p_symbol()` and all `filter_*()` functions (except for `filter_first_isolate()`), which were all deprecated in a previous package version
* Removed the `key_antibiotics()` and `key_antibiotics_equal()` functions, which were deprecated and superseded by `key_antimicrobials()` and `antimicrobials_equal()`

2
R/catalogue_of_life.R

@ -43,7 +43,7 @@ format_included_data_number <- function(data) { @@ -43,7 +43,7 @@ format_included_data_number <- function(data) {
#'
#' This package contains the complete taxonomic tree (last updated: `r CATALOGUE_OF_LIFE$yearmonth_LPSN`) of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (CoL), supplemented with data from the List of Prokaryotic names with Standing in Nomenclature (LPSN).
#' @section Catalogue of Life:
#' \if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr}
#' \if{html}{\figure{logo_col.png}{options: height="40" style=margin-bottom:"5"} \cr}
#' 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, <http://www.catalogueoflife.org>). 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()].

12
R/lifecycle.R

@ -32,23 +32,23 @@ @@ -32,23 +32,23 @@
#' @rdname lifecycle
#' @description Functions in this `AMR` package are categorised using [the lifecycle circle of the Tidyverse as found on www.tidyverse.org/lifecycle](https://lifecycle.r-lib.org/articles/stages.html).
#'
#' \if{html}{\figure{lifecycle_tidyverse.svg}{options: height=200px style=margin-bottom:5px} \cr}
#' \if{html}{\figure{lifecycle_tidyverse.svg}{options: height="200" style=margin-bottom:"5"} \cr}
#' This page contains a section for every lifecycle (with text borrowed from the aforementioned Tidyverse website), so they can be used in the manual pages of the functions.
#' @section Experimental Lifecycle:
#' \if{html}{\figure{lifecycle_experimental.svg}{options: style=margin-bottom:5px} \cr}
#' \if{html}{\figure{lifecycle_experimental.svg}{options: style=margin-bottom:"5"} \cr}
#' The [lifecycle][AMR::lifecycle] of this function is **experimental**. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this `AMR` package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough.
#' @section Maturing Lifecycle:
#' \if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \cr}
#' \if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:"5"} \cr}
#' The [lifecycle][AMR::lifecycle] of this function is **maturing**. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome [to suggest changes at our repository](https://github.com/msberends/AMR/issues) or [write us an email (see section 'Contact Us')][AMR::AMR].
#' @section Stable Lifecycle:
#' \if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr}
#' \if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:"5"} \cr}
#' The [lifecycle][AMR::lifecycle] of this function is **stable**. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.
#'
#' If the unlying code needs breaking changes, they will occur gradually. For example, an argument will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.
#' @section Retired Lifecycle:
#' \if{html}{\figure{lifecycle_retired.svg}{options: style=margin-bottom:5px} \cr}
#' \if{html}{\figure{lifecycle_retired.svg}{options: style=margin-bottom:"5"} \cr}
#' The [lifecycle][AMR::lifecycle] of this function is **retired**. A retired function is no longer under active development, and (if appropiate) a better alternative is available. No new arguments will be added, and only the most critical bugs will be fixed. In a future version, this function will be removed.
#' @section Questioning Lifecycle:
#' \if{html}{\figure{lifecycle_questioning.svg}{options: style=margin-bottom:5px} \cr}
#' \if{html}{\figure{lifecycle_questioning.svg}{options: style=margin-bottom:"5"} \cr}
#' The [lifecycle][AMR::lifecycle] of this function is **questioning**. This function might be no longer be optimal approach, or is it questionable whether this function should be in this `AMR` package at all.
NULL

63
R/mo.R

@ -31,9 +31,9 @@ @@ -31,9 +31,9 @@
#' @param Becker a [logical] to indicate whether staphylococci should be categorised into coagulase-negative staphylococci ("CoNS") and coagulase-positive staphylococci ("CoPS") instead of their own species, according to Karsten Becker *et al.* (1,2,3).
#'
#' This excludes *Staphylococcus aureus* at default, use `Becker = "all"` to also categorise *S. aureus* as "CoPS".
#' @param Lancefield a [logical] to indicate whether beta-haemolytic *Streptococci* should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield (4). These *Streptococci* will be categorised in their first group, e.g. *Streptococcus dysgalactiae* will be group C, although officially it was also categorised into groups G and L.
#' @param Lancefield a [logical] to indicate whether a beta-haemolytic *Streptococcus* should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield (4). These streptococci will be categorised in their first group, e.g. *Streptococcus dysgalactiae* will be group C, although officially it was also categorised into groups G and L.
#'
#' This excludes *Enterococci* at default (who are in group D), use `Lancefield = "all"` to also categorise all *Enterococci* as group D.
#' This excludes enterococci at default (who are in group D), use `Lancefield = "all"` to also categorise all enterococci as group D.
#' @param allow_uncertain a number between `0` (or `"none"`) and `3` (or `"all"`), or `TRUE` (= `2`) or `FALSE` (= `0`) to indicate whether the input should be checked for less probable results, see *Details*
#' @param reference_df a [data.frame] to be used for extra reference when translating `x` to a valid [`mo`]. See [set_mo_source()] and [get_mo_source()] to automate the usage of your own codes (e.g. used in your analysis or organisation).
#' @param ignore_pattern a regular expression (case-insensitive) of which all matches in `x` must return `NA`. This can be convenient to exclude known non-relevant input and can also be set with the option `AMR_ignore_pattern`, e.g. `options(AMR_ignore_pattern = "(not reported|contaminated flora)")`.
@ -1188,9 +1188,38 @@ exec_as.mo <- function(x, @@ -1188,9 +1188,38 @@ exec_as.mo <- function(x,
return(found)
}
# (6) try to strip off half an element from end and check the remains ----
# (6) remove non-taxonomic prefix and suffix ----
if (isTRUE(debug)) {
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (6) try to strip off half an element from end and check the remains\n"))
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (6) remove non-taxonomic prefix and suffix\n"))
}
x_without_nontax <- gsub("(^[a-zA-Z]+[./-]+[a-zA-Z]+[^a-zA-Z]* )([a-zA-Z.]+ [a-zA-Z]+.*)",
"\\2", a.x_backup, perl = TRUE)
x_without_nontax <- gsub("( *[(].*[)] *)[^a-zA-Z]*$", "", x_without_nontax, perl = TRUE)
if (isTRUE(debug)) {
message("Running '", x_without_nontax, "'")
}
# first try without dyslexia mode
found <- suppressMessages(suppressWarnings(exec_as.mo(x_without_nontax, initial_search = FALSE, dyslexia_mode = FALSE, allow_uncertain = FALSE, debug = debug, reference_data_to_use = uncertain.reference_data_to_use, actual_uncertainty = 2, actual_input = x_without_nontax)))
if (empty_result(found)) {
# then with dyslexia mode
found <- suppressMessages(suppressWarnings(exec_as.mo(x_without_nontax, initial_search = FALSE, dyslexia_mode = TRUE, allow_uncertain = FALSE, debug = debug, reference_data_to_use = uncertain.reference_data_to_use, actual_uncertainty = 2, actual_input = x_without_nontax)))
}
if (!empty_result(found) & nchar(g.x_backup_without_spp) >= 6) {
# we ran with actual_input = x_without_nontax, so now correct for a.x_backup:
uncertain_df <- attr(found, which = "uncertainties", exact = TRUE)
uncertain_df$input <- a.x_backup
found_result <- found
uncertainties <<- rbind(uncertainties,
uncertain_df,
stringsAsFactors = FALSE)
found <- lookup(mo == found)
return(found)
}
# (7) try to strip off half an element from end and check the remains ----
if (isTRUE(debug)) {
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (7) try to strip off half an element from end and check the remains\n"))
}
x_strip <- a.x_backup %pm>% strsplit("[ .]") %pm>% unlist()
if (length(x_strip) > 1) {
@ -1220,9 +1249,9 @@ exec_as.mo <- function(x, @@ -1220,9 +1249,9 @@ exec_as.mo <- function(x,
}
}
}
# (7) try to strip off one element from end and check the remains ----
# (8) try to strip off one element from end and check the remains ----
if (isTRUE(debug)) {
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (7) try to strip off one element from end and check the remains\n"))
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (8) try to strip off one element from end and check the remains\n"))
}
if (length(x_strip) > 1) {
for (i in seq_len(length(x_strip) - 1)) {
@ -1249,9 +1278,9 @@ exec_as.mo <- function(x, @@ -1249,9 +1278,9 @@ exec_as.mo <- function(x,
}
}
}
# (8) check for unknown yeasts/fungi ----
# (9) check for unknown yeasts/fungi ----
if (isTRUE(debug)) {
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (8) check for unknown yeasts/fungi\n"))
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (9) check for unknown yeasts/fungi\n"))
}
if (b.x_trimmed %like_case% "yeast") {
found <- "F_YEAST"
@ -1275,9 +1304,9 @@ exec_as.mo <- function(x, @@ -1275,9 +1304,9 @@ exec_as.mo <- function(x,
stringsAsFactors = FALSE)
return(found)
}
# (9) try to strip off one element from start and check the remains (only allow >= 2-part name outcome) ----
# (10) try to strip off one element from start and check the remains (only allow >= 2-part name outcome) ----
if (isTRUE(debug)) {
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (9) try to strip off one element from start and check the remains (only allow >= 2-part name outcome)\n"))
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (10) try to strip off one element from start and check the remains (only allow >= 2-part name outcome)\n"))
}
x_strip <- a.x_backup %pm>% strsplit("[ .]") %pm>% unlist()
if (length(x_strip) > 1 & nchar(g.x_backup_without_spp) >= 6) {
@ -1311,9 +1340,9 @@ exec_as.mo <- function(x, @@ -1311,9 +1340,9 @@ exec_as.mo <- function(x,
if (uncertainty_level >= 3) {
now_checks_for_uncertainty_level <- 3
# (10) try to strip off one element from start and check the remains (any text size) ----
# (11) try to strip off one element from start and check the remains (any text size) ----
if (isTRUE(debug)) {
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (10) try to strip off one element from start and check the remains (any text size)\n"))
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (11) try to strip off one element from start and check the remains (any text size)\n"))
}
x_strip <- a.x_backup %pm>% strsplit("[ .]") %pm>% unlist()
if (length(x_strip) > 1 & nchar(g.x_backup_without_spp) >= 6) {
@ -1338,10 +1367,10 @@ exec_as.mo <- function(x, @@ -1338,10 +1367,10 @@ exec_as.mo <- function(x,
}
}
}
# (11) try to strip off one element from end and check the remains (any text size) ----
# (12) try to strip off one element from end and check the remains (any text size) ----
# (this is in fact 7 but without nchar limit of >=6)
if (isTRUE(debug)) {
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (11) try to strip off one element from end and check the remains (any text size)\n"))
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (12) try to strip off one element from end and check the remains (any text size)\n"))
}
if (length(x_strip) > 1) {
for (i in seq_len(length(x_strip) - 1)) {
@ -1366,9 +1395,9 @@ exec_as.mo <- function(x, @@ -1366,9 +1395,9 @@ exec_as.mo <- function(x,
}
}
# (12) part of a name (very unlikely match) ----
# (13) part of a name (very unlikely match) ----
if (isTRUE(debug)) {
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (12) part of a name (very unlikely match)\n"))
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (13) part of a name (very unlikely match)\n"))
}
if (isTRUE(debug)) {
message("Running '", f.x_withspaces_end_only, "'")
@ -1882,7 +1911,7 @@ print.mo_uncertainties <- function(x, ...) { @@ -1882,7 +1911,7 @@ print.mo_uncertainties <- function(x, ...) {
if (NROW(x) == 0) {
return(NULL)
}
cat(word_wrap("Matching scores", ifelse(has_colour(), " (in blue)", ""), " are based on human pathogenic prevalence and the resemblance between the input and the full taxonomic name. See `?mo_matching_score`.\n\n", add_fn = font_blue))
cat(word_wrap("Matching scores", ifelse(has_colour(), " (in blue)", ""), " are based on pathogenicity in humans and the resemblance between the input and the full taxonomic name. See `?mo_matching_score`.\n\n", add_fn = font_blue))
txt <- ""
for (i in seq_len(nrow(x))) {

17
R/mo_matching_score.R

@ -27,13 +27,13 @@ @@ -27,13 +27,13 @@
#'
#' This algorithm is used by [as.mo()] and all the [`mo_*`][mo_property()] functions to determine the most probable match of taxonomic records based on user input.
#' @inheritSection lifecycle Stable Lifecycle
#' @author Dr. Matthijs Berends
#' @author Dr Matthijs Berends
#' @param x Any user input value(s)
#' @param n A full taxonomic name, that exists in [`microorganisms$fullname`][microorganisms]
#' @section Matching Score for Microorganisms:
#' With ambiguous user input in [as.mo()] and all the [`mo_*`][mo_property()] functions, the returned results are chosen based on their matching score using [mo_matching_score()]. This matching score \eqn{m}, is calculated as:
#'
#' \ifelse{latex}{\deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \textrm{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}}{\ifelse{html}{\figure{mo_matching_score.png}{options: width="300px" alt="mo matching score"}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )}}
#' \ifelse{latex}{\deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \textrm{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}}{\ifelse{html}{\figure{mo_matching_score.png}{options: width="300" alt="mo matching score"}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )}}
#'
#' where:
#'
@ -49,6 +49,8 @@ @@ -49,6 +49,8 @@
#' All characters in \eqn{x} and \eqn{n} are ignored that are other than A-Z, a-z, 0-9, spaces and parentheses.
#'
#' All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., `"E. coli"` will return the microbial ID of *Escherichia coli* (\eqn{m = `r round(mo_matching_score("E. coli", "Escherichia coli"), 3)`}, a highly prevalent microorganism found in humans) and not *Entamoeba coli* (\eqn{m = `r round(mo_matching_score("E. coli", "Entamoeba coli"), 3)`}, a less prevalent microorganism in humans), although the latter would alphabetically come first.
#'
#' Since `AMR` version 1.8.1, common microorganism abbreviations are ignored in determining the matching score. These abbreviations are currently: `r vector_and(pkg_env$mo_field_abbreviations, quotes = FALSE)`.
#' @export
#' @inheritSection AMR Reference Data Publicly Available
#' @inheritSection AMR Read more on Our Website!
@ -65,9 +67,16 @@ mo_matching_score <- function(x, n) { @@ -65,9 +67,16 @@ mo_matching_score <- function(x, n) {
x <- parse_and_convert(x)
# no dots and other non-whitespace characters
x <- gsub("[^a-zA-Z0-9 \\(\\)]+", "", x)
# remove abbreviations known to the field
x <- gsub(paste0("(^|[^a-z0-9]+)(",
paste0(pkg_env$mo_field_abbreviations, collapse = "|"),
")([^a-z0-9]+|$)"),
"", x, perl = TRUE, ignore.case = TRUE)
# only keep one space
x <- gsub(" +", " ", x)
# n is always a taxonomically valid full name
if (length(n) == 1) {
n <- rep(n, length(x))
@ -82,7 +91,7 @@ mo_matching_score <- function(x, n) { @@ -82,7 +91,7 @@ mo_matching_score <- function(x, n) {
l_n.lev <- double(length = length(x))
for (i in seq_len(length(x))) {
# determine Levenshtein distance, but maximise to nchar of n
lev[i] <- utils::adist(x[i], n[i], ignore.case = FALSE, fixed = TRUE)
lev[i] <- utils::adist(x[i], n[i], ignore.case = FALSE, fixed = TRUE, costs = c(ins = 1, del = 1, sub = 1))
# minimum of (l_n, Levenshtein distance)
l_n.lev[i] <- min(l_n[i], as.double(lev[i]))
}

19
R/rsi.R

@ -310,11 +310,15 @@ as.rsi.default <- function(x, ...) { @@ -310,11 +310,15 @@ as.rsi.default <- function(x, ...) {
x[x %like% "([^a-z]|^)sus(cep(tible)?)?"] <- "S"
x[x %like% "([^a-z]|^)int(er(mediate)?)?|incr.*exp"] <- "I"
# remove other invalid characters
x <- gsub("[^rsiRSIHi]+", "", x, perl = TRUE)
# some labs now report "H" instead of "I" to not interfere with EUCAST prior to 2019
x <- gsub("H", "I", x, ignore.case = TRUE)
# set to capitals
x <- toupper(x)
x <- gsub("[^RSIHDU]+", "", x, perl = TRUE)
# some labs now report "H" instead of "I" to not interfere with EUCAST prior to 2019
x <- gsub("^H$", "I", x, perl = TRUE)
# and MIPS uses D for Dose-dependent (which is I, but it will throw a note)
x <- gsub("^D$", "I", x, perl = TRUE)
# and MIPS uses U for "susceptible urine"
x <- gsub("^U$", "S", x, perl = TRUE)
# in cases of "S;S" keep S, but in case of "S;I" make it NA
x <- gsub("^S+$", "S", x)
x <- gsub("^I+$", "I", x)
@ -333,6 +337,15 @@ as.rsi.default <- function(x, ...) { @@ -333,6 +337,15 @@ as.rsi.default <- function(x, ...) {
"%) that were invalid antimicrobial interpretations: ",
list_missing, call = FALSE)
}
if (any(toupper(x.bak) == "U") && message_not_thrown_before("as.rsi", "U")) {
warning_("in as.rsi(): 'U' was interpreted as 'S', following some laboratory systems", call = FALSE)
}
if (any(toupper(x.bak) == "D") && message_not_thrown_before("as.rsi", "D")) {
warning_("in as.rsi(): 'D' (dose-dependent) was interpreted as 'I', following some laboratory systems", call = FALSE)
}
if (any(toupper(x.bak) == "H") && message_not_thrown_before("as.rsi", "H")) {
warning_("in as.rsi(): 'H' was interpreted as 'I', following some laboratory systems", call = FALSE)
}
}
}

2
R/whocc.R

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
#'
#' All antimicrobial drugs and their official names, ATC codes, ATC groups and defined daily dose (DDD) are included in this package, using the WHO Collaborating Centre for Drug Statistics Methodology.
#' @section WHOCC:
#' \if{html}{\figure{logo_who.png}{options: height=60px style=margin-bottom:5px} \cr}
#' \if{html}{\figure{logo_who.png}{options: height="60" style=margin-bottom:"5"} \cr}
#' This package contains **all ~550 antibiotic, antimycotic and antiviral drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, <https://www.whocc.no>) and the Pharmaceuticals Community Register of the European Commission (<https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm>).
#'
#' These have become the gold standard for international drug utilisation monitoring and research.

5
R/zzz.R

@ -26,6 +26,11 @@ @@ -26,6 +26,11 @@
# set up package environment, used by numerous AMR functions
pkg_env <- new.env(hash = FALSE)
pkg_env$mo_failed <- character(0)
pkg_env$mo_field_abbreviations <- c("AIEC", "ATEC", "BORSA", "CRSM", "DAEC", "EAEC",
"EHEC", "EIEC", "EPEC", "ETEC", "GISA", "MRPA",
"MRSA", "MRSE", "MSSA", "MSSE", "NMEC", "PISP",
"PRSP", "STEC", "UPEC", "VISA", "VISP", "VRE",
"VRSA", "VRSP")
# determine info icon for messages
utf8_supported <- isTRUE(base::l10n_info()$`UTF-8`)

BIN
data-raw/AMR_latest.tar.gz

Binary file not shown.

4
data-raw/reproduction_of_microorganisms.R

@ -26,8 +26,8 @@ @@ -26,8 +26,8 @@
# Reproduction of the `microorganisms` data set
# 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)
# https://download.catalogueoflife.org/col/monthly/
# (download latest dwca, such as https://download.catalogueoflife.org/col/monthly/2022-01-14_dwca.zip)
# Data retrieved from the Global Biodiversity Information Facility (GBIF):
# https://doi.org/10.15468/rffz4x
#

4
docs/articles/datasets.html

@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9001</span>
</span>
</div>
@ -190,7 +190,7 @@ @@ -190,7 +190,7 @@
<div class="page-header toc-ignore">
<h1 data-toc-skip>Data sets for download / own use</h1>
<h4 data-toc-skip class="date">01 February 2022</h4>
<h4 data-toc-skip class="date">26 February 2022</h4>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/HEAD/vignettes/datasets.Rmd" class="external-link"><code>vignettes/datasets.Rmd</code></a></small>
<div class="hidden name"><code>datasets.Rmd</code></div>

130
docs/news/index.html

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9001</span>
</span>
</div>
@ -157,16 +157,32 @@ @@ -157,16 +157,32 @@
</div>
<div class="section level2">
<h2 class="page-header" data-toc-text="1.8.0.9000" id="amr-1809000">
<code>AMR</code> 1.8.0.9000<a class="anchor" aria-label="anchor" href="#amr-1809000"></a></h2>
<h2 class="page-header" data-toc-text="1.8.0.9001" id="amr-1809001">
<code>AMR</code> 1.8.0.9001<a class="anchor" aria-label="anchor" href="#amr-1809001"></a></h2>
<div class="section level3">
<h3 id="last-updated-february-1-8-0-9000"><small>Last updated: 1 February 2022</small><a class="anchor" aria-label="anchor" href="#last-updated-february-1-8-0-9000"></a></h3>
<h3 id="last-updated-february-1-8-0-9001"><small>Last updated: 26 February 2022</small><a class="anchor" aria-label="anchor" href="#last-updated-february-1-8-0-9001"></a></h3>
<p>All functions in this package are considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months.</p>
<div class="section level4">
<h4 id="changed-1-8-0-9001">Changed<a class="anchor" aria-label="anchor" href="#changed-1-8-0-9001"></a></h4>
<ul><li><p>Support for antibiotic interpretations of the MIPS laboratory system: <code>"U"</code> for S (‘susceptible urine’), <code>"D"</code> for I (‘susceptible dose-dependent’)</p></li>
<li>
<p>Improved algorithm of <code><a href="../reference/as.mo.html">as.mo()</a></code>, especially for ignoring non-taxonomic text, such as:</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"methicillin-resistant S. aureus (MRSA)"</span><span class="op">)</span>
<span class="co">#&gt; [1] "Staphylococcus aureus"</span></code></pre></div>
</li>
</ul></div>
<div class="section level4">
<h4 id="other-1-8-0-9001">Other<a class="anchor" aria-label="anchor" href="#other-1-8-0-9001"></a></h4>
<ul><li>Fix for unit testing on R 3.3</li>
<li>Fix for size of some image elements, as requested by CRAN</li>
</ul></div>
</div>
</div>
<div class="section level2">
<h2 class="page-header" data-toc-text="1.8.0" id="amr-180">
<code>AMR</code> 1.8.0<small>2022-01-07</small><a class="anchor" aria-label="anchor" href="#amr-180"></a></h2>
<p>All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months from now on.</p>
<div class="section level4">
<h4 id="breaking-changes-1-8-0">Breaking changes<a class="anchor" aria-label="anchor" href="#breaking-changes-1-8-0"></a></h4>
<ul><li>Removed <code>p_symbol()</code> and all <code>filter_*()</code> functions (except for <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>), which were all deprecated in a previous package version</li>
@ -182,7 +198,7 @@ @@ -182,7 +198,7 @@
<li><p>Support for all antimicrobial drug (group) names and colloquial microorganism names in Danish, Dutch, English, French, German, Italian, Portuguese, Russian, Spanish and Swedish</p></li>
<li>
<p>Function <code><a href="../reference/ab_property.html">set_ab_names()</a></code> to rename data set columns that resemble antimicrobial drugs. This allows for quickly renaming columns to official names, ATC codes, etc. Its second argument can be a tidyverse way of selecting:</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/ab_property.html">set_ab_names</a></span><span class="op">(</span><span class="fu">where</span><span class="op">(</span><span class="va">is.rsi</span><span class="op">)</span><span class="op">)</span>
<span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/ab_property.html">set_ab_names</a></span><span class="op">(</span><span class="va">AMC</span><span class="op">:</span><span class="va">GEN</span>, property <span class="op">=</span> <span class="st">"atc"</span><span class="op">)</span></code></pre></div>
@ -208,14 +224,14 @@ @@ -208,14 +224,14 @@
<li><p>Added more selectors for antibiotic classes: <code><a href="../reference/antibiotic_class_selectors.html">aminopenicillins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">antifungals()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">antimycobacterials()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">lincosamides()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">lipoglycopeptides()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">polymyxins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">quinolones()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">streptogramins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">trimethoprims()</a></code> and <code><a href="../reference/antibiotic_class_selectors.html">ureidopenicillins()</a></code></p></li>
<li>
<p>Added specific selectors for certain types for treatment: <code><a href="../reference/antibiotic_class_selectors.html">administrable_per_os()</a></code> and <code><a href="../reference/antibiotic_class_selectors.html">administrable_iv()</a></code>, which are based on available Defined Daily Doses (DDDs), as defined by the WHOCC. These are ideal for e.g. analysing pathogens in primary care where IV treatment is not an option. They can be combined with other AB selectors, e.g. to select penicillins that are only administrable per os (i.e., orally):</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">example_isolates</span><span class="op">[</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">penicillins</a></span><span class="op">(</span><span class="op">)</span> <span class="op">&amp;</span> <span class="fu"><a href="../reference/antibiotic_class_selectors.html">administrable_per_os</a></span><span class="op">(</span><span class="op">)</span><span class="op">]</span> <span class="co"># base R</span>
<span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">penicillins</a></span><span class="op">(</span><span class="op">)</span> <span class="op">&amp;</span> <span class="fu"><a href="../reference/antibiotic_class_selectors.html">administrable_per_os</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span></code></pre></div>
</li>
<li>
<p>Added the selector <code><a href="../reference/antibiotic_class_selectors.html">ab_selector()</a></code>, which accepts a filter to be used internally on the <code>antibiotics</code> data set, yielding great flexibility on drug properties, such as selecting antibiotic columns with an oral DDD of at least 1 gram:</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">example_isolates</span><span class="op">[</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">ab_selector</a></span><span class="op">(</span><span class="va">oral_ddd</span> <span class="op">&gt;</span> <span class="fl">1</span> <span class="op">&amp;</span> <span class="va">oral_units</span> <span class="op">==</span> <span class="st">"g"</span><span class="op">)</span><span class="op">]</span> <span class="co"># base R</span>
<span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">ab_selector</a></span><span class="op">(</span><span class="va">oral_ddd</span> <span class="op">&gt;</span> <span class="fl">1</span> <span class="op">&amp;</span> <span class="va">oral_units</span> <span class="op">==</span> <span class="st">"g"</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span></code></pre></div>
@ -273,7 +289,7 @@ @@ -273,7 +289,7 @@
<h4 id="breaking-change-1-7-1">Breaking change<a class="anchor" aria-label="anchor" href="#breaking-change-1-7-1"></a></h4>
<ul><li>
<p>All antibiotic class selectors (such as <code><a href="../reference/antibiotic_class_selectors.html">carbapenems()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>) can now be used for filtering as well, making all their accompanying <code>filter_*()</code> functions redundant (such as <code>filter_carbapenems()</code>, <code>filter_aminoglycosides()</code>). These functions are now deprecated and will be removed in a next release. Examples of how the selectors can be used for filtering:</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># select columns with results for carbapenems</span>
<span class="va">example_isolates</span><span class="op">[</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">]</span> <span class="co"># base R</span>
@ -328,7 +344,7 @@ @@ -328,7 +344,7 @@
<ul><li><p>Now checks if <code>pattern</code> is a <em>valid</em> regular expression</p></li>
<li>
<p>Added <code>%unlike%</code> and <code>%unlike_case%</code> (as negations of the existing <code>%like%</code> and <code>%like_case%</code>). This greatly improves readability:</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html" class="external-link">grepl</a></span><span class="op">(</span><span class="st">"EUCAST"</span>, <span class="va">guideline</span><span class="op">)</span><span class="op">)</span> <span class="va">...</span>
<span class="co"># same:</span>
@ -381,7 +397,7 @@ @@ -381,7 +397,7 @@
</ul></li>
<li>
<p>Functions <code><a href="../reference/antibiotic_class_selectors.html">oxazolidinones()</a></code> (an antibiotic selector function) and <code>filter_oxazolidinones()</code> (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid</p>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span>
<span class="va">x</span> <span class="op">&lt;-</span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">date</span>, <span class="va">hospital_id</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">oxazolidinones</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>
@ -394,7 +410,7 @@ @@ -394,7 +410,7 @@
<li><p><code>ggplot()</code> generics for classes <code>&lt;mic&gt;</code> and <code>&lt;disk&gt;</code></p></li>
<li>
<p>Function <code><a href="../reference/mo_property.html">mo_is_yeast()</a></code>, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/mo_property.html">mo_kingdom</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"Aspergillus"</span>, <span class="st">"Candida"</span><span class="op">)</span><span class="op">)</span>
<span class="co">#&gt; [1] "Fungi" "Fungi"</span>
@ -406,7 +422,7 @@ @@ -406,7 +422,7 @@
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html" class="external-link">which</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_is_yeast</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>, <span class="op">]</span> <span class="co"># base R</span>
<span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_is_yeast</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span></code></pre></div>
<p>The <code><a href="../reference/mo_property.html">mo_type()</a></code> function has also been updated to reflect this change:</p>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/mo_property.html">mo_type</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"Aspergillus"</span>, <span class="st">"Candida"</span><span class="op">)</span><span class="op">)</span>
<span class="co"># [1] "Fungi" "Yeasts"</span>
@ -416,7 +432,7 @@ @@ -416,7 +432,7 @@
<li><p>Added Pretomanid (PMD, J04AK08) to the <code>antibiotics</code> data set</p></li>
<li>
<p>MIC values (see <code><a href="../reference/as.mic.html">as.mic()</a></code>) can now be used in any mathematical processing, such as usage inside functions <code><a href="https://rdrr.io/r/base/Extremes.html" class="external-link">min()</a></code>, <code><a href="https://rdrr.io/r/base/Extremes.html" class="external-link">max()</a></code>, <code><a href="https://rdrr.io/r/base/range.html" class="external-link">range()</a></code>, and with binary operators (<code>+</code>, <code>-</code>, etc.). This allows for easy distribution analysis and fast filtering on MIC values:</p>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">x</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/random.html">random_mic</a></span><span class="op">(</span><span class="fl">10</span><span class="op">)</span>
<span class="va">x</span>
@ -485,7 +501,7 @@ @@ -485,7 +501,7 @@
<h4 id="new-1-5-0">New<a class="anchor" aria-label="anchor" href="#new-1-5-0"></a></h4>
<ul><li>
<p>Functions <code><a href="../reference/get_episode.html">get_episode()</a></code> and <code><a href="../reference/get_episode.html">is_new_episode()</a></code> to determine (patient) episodes which are not necessarily based on microorganisms. The <code><a href="../reference/get_episode.html">get_episode()</a></code> function returns the index number of the episode per group, while the <code><a href="../reference/get_episode.html">is_new_episode()</a></code> function returns values <code>TRUE</code>/<code>FALSE</code> to indicate whether an item in a vector is the start of a new episode. They also support <code>dplyr</code>s grouping (i.e. using <code><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by()</a></code>):</p>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span>
<span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
@ -530,7 +546,7 @@ @@ -530,7 +546,7 @@
<li>
<code><a href="../reference/mdro.html">mdr_cmi2012()</a></code>,</li>
<li><code><a href="../reference/mdro.html">eucast_exceptional_phenotypes()</a></code></li>
</ul><div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
</ul><div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># to select first isolates that are Gram-negative </span>
<span class="co"># and view results of cephalosporins and aminoglycosides:</span>
@ -542,7 +558,7 @@ @@ -542,7 +558,7 @@
</li>
<li>
<p>For antibiotic selection functions (such as <code><a href="../reference/antibiotic_class_selectors.html">cephalosporins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>) to select columns based on a certain antibiotic group, the dependency on the <code>tidyselect</code> package was removed, meaning that they can now also be used without the need to have this package installed and now also work in base R function calls (they rely on R 3.2 or later):</p>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># above example in base R:</span>
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html" class="external-link">which</a></span><span class="op">(</span><span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="op">)</span> <span class="op">&amp;</span> <span class="fu"><a href="../reference/mo_property.html">mo_is_gram_negative</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>,
@ -585,7 +601,7 @@ @@ -585,7 +601,7 @@
<li>
<p>Data set <code>intrinsic_resistant</code>. This data set contains all bug-drug combinations where the ‘bug’ is intrinsic resistant to the ‘drug’ according to the latest EUCAST insights. It contains just two columns: <code>microorganism</code> and <code>antibiotic</code>.</p>
<p>Curious about which enterococci are actually intrinsic resistant to vancomycin?</p>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span>
@ -604,7 +620,7 @@ @@ -604,7 +620,7 @@
<p>Improvements for <code><a href="../reference/as.rsi.html">as.rsi()</a></code>:</p>
<ul><li>
<p>Support for using <code>dplyr</code>’s <code><a href="https://dplyr.tidyverse.org/reference/across.html" class="external-link">across()</a></code> to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># until dplyr 1.0.0</span>
<span class="va">your_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html" class="external-link">mutate_if</a></span><span class="op">(</span><span class="va">is.mic</span>, <span class="va">as.rsi</span><span class="op">)</span>
@ -621,7 +637,7 @@ @@ -621,7 +637,7 @@
</ul></li>
<li>
<p>Added intelligent data cleaning to <code><a href="../reference/as.disk.html">as.disk()</a></code>, so numbers can also be extracted from text and decimal numbers will always be rounded up:</p>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/as.disk.html">as.disk</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"disk zone: 23.4 mm"</span>, <span class="fl">23.4</span><span class="op">)</span><span class="op">)</span>
<span class="co">#&gt; Class &lt;disk&gt;</span>
@ -670,7 +686,7 @@ @@ -670,7 +686,7 @@
<ul><li><p>Function <code><a href="../reference/ab_from_text.html">ab_from_text()</a></code> to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses <code><a href="../reference/as.ab.html">as.ab()</a></code> internally</p></li>
<li>
<p><a href="https://tidyselect.r-lib.org/reference/language.html" class="external-link">Tidyverse selection helpers</a> for antibiotic classes, that help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. They can be used in any function that allows selection helpers, like <code><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">dplyr::select()</a></code> and <code><a href="https://tidyr.tidyverse.org/reference/pivot_longer.html" class="external-link">tidyr::pivot_longer()</a></code>:</p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span>
@ -811,7 +827,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -811,7 +827,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<ul><li><p>Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline</p></li>
<li>
<p>Interpretation from MIC values (and disk zones) to R/SI can now be used with <code><a href="https://dplyr.tidyverse.org/reference/mutate_all.html" class="external-link">mutate_at()</a></code> of the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">yourdata</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html" class="external-link">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html" class="external-link">vars</a></span><span class="op">(</span><span class="va">antibiotic1</span><span class="op">:</span><span class="va">antibiotic25</span><span class="op">)</span>, <span class="va">as.rsi</span>, mo <span class="op">=</span> <span class="st">"E. coli"</span><span class="op">)</span>
@ -834,7 +850,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -834,7 +850,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li>Support for LOINC and SNOMED codes
<ul><li>
<p>Support for LOINC codes in the <code>antibiotics</code> data set. Use <code><a href="../reference/ab_property.html">ab_loinc()</a></code> to retrieve LOINC codes, or use a LOINC code for input in any <code>ab_*</code> function:</p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/ab_property.html">ab_loinc</a></span><span class="op">(</span><span class="st">"ampicillin"</span><span class="op">)</span>
<span class="co">#&gt; [1] "21066-6" "3355-5" "33562-0" "33919-2" "43883-8" "43884-6" "87604-5"</span>
@ -845,7 +861,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -845,7 +861,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
<li>
<p>Support for SNOMED CT codes in the <code>microorganisms</code> data set. Use <code><a href="../reference/mo_property.html">mo_snomed()</a></code> to retrieve SNOMED codes, or use a SNOMED code for input in any <code>mo_*</code> function:</p>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/mo_property.html">mo_snomed</a></span><span class="op">(</span><span class="st">"S. aureus"</span><span class="op">)</span>
<span class="co">#&gt; [1] 115329001 3092008 113961008</span>
@ -893,11 +909,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -893,11 +909,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<ul><li>Adopted Adeolu <em>et al.</em> (2016), <a href="https:/pubmed.ncbi.nlm.nih.gov/27620848/">PMID 27620848</a> for the <code>microorganisms</code> data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like <em>Morganellaceae</em> and <em>Yersiniaceae</em>). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with <code><a href="../reference/mdro.html">mdro()</a></code> will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
<ul><li>
<p>If you were dependent on the old Enterobacteriaceae family e.g. by using in your code:</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_family</a></span><span class="op">(</span><span class="va">somebugs</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Enterobacteriaceae"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
<p>then please adjust this to:</p>
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">somebugs</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Enterobacterales"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
</li>
@ -907,7 +923,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -907,7 +923,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<h4 id="new-0-9-0">New<a class="anchor" aria-label="anchor" href="#new-0-9-0"></a></h4>
<ul><li>
<p>Functions <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> as aliases of <code><a href="../reference/proportion.html">proportion_SI()</a></code> and <code><a href="../reference/proportion.html">proportion_R()</a></code>, respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.</p>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span>
<span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
@ -930,7 +946,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -930,7 +946,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>More intelligent way of coping with some consonants like “l” and “r”</p></li>
<li>
<p>Added a score (a certainty percentage) to <code><a href="../reference/as.mo.html">mo_uncertainties()</a></code>, that is calculated using the <a href="https://en.wikipedia.org/wiki/Levenshtein_distance" class="external-link">Levenshtein distance</a>:</p>
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"Stafylococcus aureus"</span>,
<span class="st">"staphylokok aureuz"</span><span class="op">)</span><span class="op">)</span>
@ -978,14 +994,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -978,14 +994,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<h4 id="breaking-0-8-0">Breaking<a class="anchor" aria-label="anchor" href="#breaking-0-8-0"></a></h4>
<ul><li>
<p>Determination of first isolates now <strong>excludes</strong> all ‘unknown’ microorganisms at default, i.e. microbial code <code>"UNKNOWN"</code>. They can be included with the new argument <code>include_unknown</code>:</p>
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="va">...</span>, include_unknown <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
<p>For WHONET users, this means that all records/isolates with organism code <code>"con"</code> (<em>contamination</em>) will be excluded at default, since <code>as.mo("con") = "UNKNOWN"</code>. The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.</p>
</li>
<li>
<p>For code consistency, classes <code>ab</code> and <code>mo</code> will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in <code>NA</code>:</p>
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># how it works in base R:</span>
<span class="va">x</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html" class="external-link">factor</a></span><span class="op">(</span><span class="st">"A"</span><span class="op">)</span>
@ -1007,7 +1023,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1007,7 +1023,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<h4 id="new-0-8-0">New<a class="anchor" aria-label="anchor" href="#new-0-8-0"></a></h4>
<ul><li>
<p>Function <code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> to quickly get a <code>data.frame</code> with the results of all bug-drug combinations in a data set. The column containing microorganism codes is guessed automatically and its input is transformed with <code><a href="../reference/mo_property.html">mo_shortname()</a></code> at default:</p>
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">x</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/bug_drug_combinations.html">bug_drug_combinations</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
<span class="co">#&gt; NOTE: Using column `mo` as input for `col_mo`.</span>
@ -1030,13 +1046,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1030,13 +1046,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<span class="co">#&gt; 4 Gram-negative AMX 227 0 405 632</span>
<span class="co">#&gt; NOTE: Use 'format()' on this result to get a publicable/printable format.</span></code></pre></div>
<p>You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R <code><a href="https://rdrr.io/r/base/format.html" class="external-link">format()</a></code> function:</p>
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="https://rdrr.io/r/base/format.html" class="external-link">format</a></span><span class="op">(</span><span class="va">x</span>, combine_IR <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
</li>
<li>
<p>Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibility of a combination therapy. A new argument <code>only_all_tested</code> (<strong>which defaults to <code>FALSE</code></strong>) replaces the old <code>also_single_tested</code> and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># --------------------------------------------------------------------</span>
<span class="co"># only_all_tested = FALSE only_all_tested = TRUE</span>
@ -1058,7 +1074,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1058,7 +1074,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
<li>
<p><code>tibble</code> printing support for classes <code>rsi</code>, <code>mic</code>, <code>disk</code>, <code>ab</code> <code>mo</code>. When using <code>tibble</code>s containing antimicrobial columns, values <code>S</code> will print in green, values <code>I</code> will print in yellow and values <code>R</code> will print in red. Microbial IDs (class <code>mo</code>) will emphasise on the genus and species, not on the kingdom.</p>
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># (run this on your own console, as this page does not support colour printing)</span>
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span>
@ -1126,7 +1142,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1126,7 +1142,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<h5 id="new-0-7-1">New<a class="anchor" aria-label="anchor" href="#new-0-7-1"></a></h5>
<ul><li>
<p>Function <code><a href="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> to immediately show resistance percentages and number of available isolates:</p>
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">AMX</span>, <span class="va">CIP</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
@ -1151,7 +1167,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1151,7 +1167,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li>STEC (Shiga-toxin producing <em>E. coli</em>)</li>
<li>UPEC (Uropathogenic <em>E. coli</em>)</li>
</ul><p>All these lead to the microbial ID of <em>E. coli</em>:</p>
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"UPEC"</span><span class="op">)</span>
<span class="co"># B_ESCHR_COL</span>
@ -1235,7 +1251,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1235,7 +1251,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>when all values are unique it now shows a message instead of a warning</p></li>
<li>
<p>support for boxplots:</p>
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
<span class="fu">freq</span><span class="op">(</span><span class="va">age</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
@ -1310,7 +1326,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1310,7 +1326,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</ul></li>
<li>
<p>New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:</p>
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu">filter_aminoglycosides</span><span class="op">(</span><span class="op">)</span>
<span class="fu">filter_carbapenems</span><span class="op">(</span><span class="op">)</span>
@ -1324,7 +1340,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1324,7 +1340,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<span class="fu">filter_macrolides</span><span class="op">(</span><span class="op">)</span>
<span class="fu">filter_tetracyclines</span><span class="op">(</span><span class="op">)</span></code></pre></div>
<p>The <code>antibiotics</code> data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the <code>antibiotics</code> data set. For example:</p>
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu">filter_glycopeptides</span><span class="op">(</span>result <span class="op">=</span> <span class="st">"R"</span><span class="op">)</span>
<span class="co"># Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R</span>
@ -1333,7 +1349,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1333,7 +1349,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
<li>
<p>All <code>ab_*</code> functions are deprecated and replaced by <code>atc_*</code> functions:</p>
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">ab_property</span> <span class="op">-&gt;</span> <span class="fu">atc_property</span><span class="op">(</span><span class="op">)</span>
<span class="va">ab_name</span> <span class="op">-&gt;</span> <span class="fu">atc_name</span><span class="op">(</span><span class="op">)</span>
@ -1354,7 +1370,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1354,7 +1370,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>New function <code><a href="../reference/age_groups.html">age_groups()</a></code> to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic AMR data analysis per age group.</p></li>
<li>
<p>New function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> as well as the base R <code><a href="../reference/plot.html">plot()</a></code> function can now be used for resistance prediction calculated with <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>:</p>
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">x</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span><span class="va">septic_patients</span>, col_ab <span class="op">=</span> <span class="st">"amox"</span><span class="op">)</span>
<span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
@ -1362,13 +1378,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1362,13 +1378,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
<li>
<p>Functions <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code>filter_first_weighted_isolate()</code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.:</p>
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="va">...</span><span class="op">)</span>
<span class="co"># or</span>
<span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="va">...</span><span class="op">)</span></code></pre></div>
<p>is equal to:</p>
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html" class="external-link">mutate</a></span><span class="op">(</span>only_firsts <span class="op">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="va">...</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
@ -1395,7 +1411,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1395,7 +1411,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li>Improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code>:
<ul><li>
<p>Now handles incorrect spelling, like <code>i</code> instead of <code>y</code> and <code>f</code> instead of <code>ph</code>:</p>
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># mo_fullname() uses as.mo() internally</span>
@ -1407,7 +1423,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1407,7 +1423,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
<li>
<p>Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default <code>allow_uncertain = TRUE</code> is equal to uncertainty level 2. Run <code><a href="../reference/as.mo.html">?as.mo</a></code> for more info about these levels.</p>
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># equal:</span>
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">...</span>, allow_uncertain <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>
@ -1458,7 +1474,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1458,7 +1474,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li>Frequency tables (<code>freq()</code> function):
<ul><li>
<p>Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:</p>
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="co"># Determine genus of microorganisms (mo) in `septic_patients` data set:</span>
<span class="co"># OLD WAY</span>
@ -1528,7 +1544,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1528,7 +1544,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>Fewer than 3 characters as input for <code>as.mo</code> will return NA</p></li>
<li>
<p>Function <code>as.mo</code> (and all <code>mo_*</code> wrappers) now supports genus abbreviations with “species” attached</p>
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"E. species"</span><span class="op">)</span> <span class="co"># B_ESCHR</span>
<span class="fu"><a href="../reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="st">"E. spp."</span><span class="op">)</span> <span class="co"># "Escherichia species"</span>
@ -1544,7 +1560,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1544,7 +1560,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<p>Frequency tables - <code>freq()</code>:</p>
<ul><li>
<p>Support for grouping variables, test with:</p>
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">hospital_id</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span>
@ -1552,7 +1568,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ @@ -1552,7 +1568,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
<li>
<p>Support for (un)selecting columns:</p>
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</span> <span