Compare commits
16 Commits
ed22b83c28
...
v1.8.1
Author | SHA1 | Date | |
---|---|---|---|
ccb09706e4 | |||
7b0f1596bd | |||
0fb9a1b194 | |||
45e9546538 | |||
1b0983e382 | |||
8c9feea087 | |||
08d387b5ce | |||
ad82bb4ce0 | |||
dedbe92322 | |||
3b2b2be5f8 | |||
18e8525d10 | |||
be792cc9eb | |||
f5dcf0ad58 | |||
25cef46c59 | |||
3f4ff260d2 | |||
75dac113b6 |
@@ -32,3 +32,5 @@
|
||||
^vignettes/resistance_predict.Rmd$
|
||||
^vignettes/SPSS.Rmd$
|
||||
^vignettes/WHONET.Rmd$
|
||||
^logo.svg$
|
||||
^CRAN-SUBMISSION$
|
||||
|
2
.github/workflows/check.yaml
vendored
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
2
.github/workflows/codecovr.yaml
vendored
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
2
.github/workflows/lintr.yaml
vendored
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
3
CRAN-SUBMISSION
Normal file
@@ -0,0 +1,3 @@
|
||||
Version: 1.8.1
|
||||
Date: 2022-03-16 18:22:51 UTC
|
||||
SHA: 7b0f1596bd65fbb72681a7e3a6a7e4e469a891e8
|
13
DESCRIPTION
@@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 1.7.1.9075
|
||||
Date: 2021-12-14
|
||||
Version: 1.8.1
|
||||
Date: 2022-03-17
|
||||
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
|
||||
@@ -9,7 +9,7 @@ Description: Functions to simplify and standardise antimicrobial resistance (AMR
|
||||
Authors@R: c(
|
||||
person(given = c("Matthijs", "S."),
|
||||
family = "Berends",
|
||||
email = "m.s.berends@umcg.nl",
|
||||
email = "m.berends@certe.nl",
|
||||
role = c("aut", "cre"),
|
||||
comment = c(ORCID = "0000-0001-7620-1800")),
|
||||
person(given = c("Christian", "F."),
|
||||
@@ -66,12 +66,13 @@ Authors@R: c(
|
||||
person(given = "Anthony",
|
||||
family = "Underwood",
|
||||
role = "ctb",
|
||||
comment = c(ORCID = "0000-0002-8547-427")))
|
||||
comment = c(ORCID = "0000-0002-8547-4277")))
|
||||
Depends: R (>= 3.0.0)
|
||||
Enhances:
|
||||
cleaner,
|
||||
skimr,
|
||||
ggplot2
|
||||
ggplot2,
|
||||
tidyselect
|
||||
Suggests:
|
||||
curl,
|
||||
dplyr,
|
||||
@@ -84,7 +85,7 @@ Suggests:
|
||||
tinytest,
|
||||
xml2
|
||||
VignetteBuilder: knitr,rmarkdown
|
||||
URL: https://msberends.github.io/AMR, https://github.com/msberends/AMR
|
||||
URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR
|
||||
BugReports: https://github.com/msberends/AMR/issues
|
||||
License: GPL-2 | file LICENSE
|
||||
Encoding: UTF-8
|
||||
|
30
NEWS.md
@@ -1,7 +1,27 @@
|
||||
# `AMR` 1.7.1.9075
|
||||
## <small>Last updated: 14 December 2021</small>
|
||||
# `AMR` 1.8.1
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
* Fix for using `as.rsi()` on values containing capped values (such as `>=`), sometimes leading to `NA`
|
||||
* 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"
|
||||
```
|
||||
* More informative warning messages
|
||||
* Added 192 as valid MIC
|
||||
* Updated MIC printing in tibbles
|
||||
* Increased speed for loading the package
|
||||
|
||||
### Other
|
||||
* Fix for unit testing on R 3.3
|
||||
* Fix for size of some image elements, as requested by CRAN
|
||||
|
||||
|
||||
# `AMR` 1.8.0
|
||||
|
||||
### Breaking changes
|
||||
* Removed `p_symbol()` and all `filter_*()` functions (except for `filter_first_isolate()`), which were all deprecated in a previous package version
|
||||
@@ -256,7 +276,7 @@ All functions in this package are now all considered to be stable. Updates to th
|
||||
filter(is_new_episode(date, episode_days = 60))
|
||||
```
|
||||
* Functions `mo_is_gram_negative()` and `mo_is_gram_positive()` as wrappers around `mo_gramstain()`. They always return `TRUE` or `FALSE` (except when the input is `NA` or the MO code is `UNKNOWN`), thus always return `FALSE` for species outside the taxonomic kingdom of Bacteria.
|
||||
* Function `mo_is_intrinsic_resistant()` to test for intrinsic resistance, based on [EUCAST Intrinsic Resistance and Unusual Phenotypes v3.2](https://www.eucast.org/expert_rules_and_intrinsic_resistance/) from 2020.
|
||||
* Function `mo_is_intrinsic_resistant()` to test for intrinsic resistance, based on EUCAST Intrinsic Resistance and Unusual Phenotypes v3.2 from 2020.
|
||||
* Functions `random_mic()`, `random_disk()` and `random_rsi()` for random value generation. The functions `random_mic()` and `random_disk()` take microorganism names and antibiotic names as input to make generation more realistic.
|
||||
|
||||
### Changed
|
||||
@@ -1352,7 +1372,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
* Function `guess_atc` to **determine the ATC** of an antibiotic based on name, trade name, or known abbreviations
|
||||
* Function `freq` to create **frequency tables**, with additional info in a header
|
||||
* Function `MDRO` to **determine Multi Drug Resistant Organisms (MDRO)** with support for country-specific guidelines.
|
||||
* [Exceptional resistances defined by EUCAST](https://www.eucast.org/expert_rules_and_intrinsic_resistance/) are also supported instead of countries alone
|
||||
* Exceptional resistances defined by EUCAST are also supported instead of countries alone
|
||||
* Functions `BRMO` and `MRGN` are wrappers for Dutch and German guidelines, respectively
|
||||
* New algorithm to determine weighted isolates, can now be `"points"` or `"keyantibiotics"`, see `?first_isolate`
|
||||
* New print format for `tibble`s and `data.table`s
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -36,15 +36,15 @@ EUCAST_VERSION_BREAKPOINTS <- list("11.0" = list(version_txt = "v11.0",
|
||||
EUCAST_VERSION_EXPERT_RULES <- list("3.1" = list(version_txt = "v3.1",
|
||||
year = 2016,
|
||||
title = "'EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_intrinsic_resistance/"),
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"),
|
||||
"3.2" = list(version_txt = "v3.2",
|
||||
year = 2020,
|
||||
title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_intrinsic_resistance/"),
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"),
|
||||
"3.3" = list(version_txt = "v3.3",
|
||||
year = 2021,
|
||||
title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_intrinsic_resistance/"))
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"))
|
||||
|
||||
SNOMED_VERSION <- list(title = "Public Health Information Network Vocabulary Access and Distribution System (PHIN VADS)",
|
||||
current_source = "US Edition of SNOMED CT from 1 September 2020",
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -206,7 +206,7 @@ check_dataset_integrity <- function() {
|
||||
" overwritten by your global environment and prevent", plural[2],
|
||||
" the AMR package from working correctly: ",
|
||||
vector_and(overwritten, quotes = "'"),
|
||||
".\nPlease rename your object", plural[3], ".", call = FALSE)
|
||||
".\nPlease rename your object", plural[3], ".")
|
||||
}
|
||||
}
|
||||
# check if other packages did not overwrite our data sets
|
||||
@@ -492,7 +492,7 @@ message_ <- function(...,
|
||||
warning_ <- function(...,
|
||||
add_fn = list(),
|
||||
immediate = FALSE,
|
||||
call = TRUE) {
|
||||
call = FALSE) {
|
||||
warning(word_wrap(...,
|
||||
add_fn = add_fn,
|
||||
as_note = FALSE),
|
||||
@@ -559,7 +559,7 @@ stop_ifnot <- function(expr, ..., call = TRUE) {
|
||||
|
||||
return_after_integrity_check <- function(value, type, check_vector) {
|
||||
if (!all(value[!is.na(value)] %in% check_vector)) {
|
||||
warning_(paste0("invalid ", type, ", NA generated"), call = FALSE)
|
||||
warning_(paste0("invalid ", type, ", NA generated"))
|
||||
value[!value %in% check_vector] <- NA
|
||||
}
|
||||
value
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
30
R/ab.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -48,8 +48,6 @@
|
||||
#' @section Source:
|
||||
#' World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/}
|
||||
#'
|
||||
#' WHONET 2019 software: \url{http://www.whonet.org/software.html}
|
||||
#'
|
||||
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm}
|
||||
#' @aliases ab
|
||||
#' @return A [character] [vector] with additional class [`ab`]
|
||||
@@ -133,8 +131,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
note_if_more_than_one_found <- function(found, index, from_text) {
|
||||
if (initial_search == TRUE & isTRUE(length(from_text) > 1)) {
|
||||
abnames <- ab_name(from_text, tolower = TRUE, initial_search = FALSE)
|
||||
if (ab_name(found[1L], language = NULL) %like% "clavulanic acid") {
|
||||
abnames <- abnames[!abnames == "clavulanic acid"]
|
||||
if (ab_name(found[1L], language = NULL) %like% "(clavulanic acid|avibactam)") {
|
||||
abnames <- abnames[!abnames %in% c("clavulanic acid", "avibactam")]
|
||||
}
|
||||
if (length(abnames) > 1) {
|
||||
message_("More than one result was found for item ", index, ": ",
|
||||
@@ -222,6 +220,16 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
next
|
||||
}
|
||||
|
||||
# length of input is quite long, and Levenshtein distance is only max 2
|
||||
if (nchar(x[i]) >= 10) {
|
||||
levenshtein <- as.double(utils::adist(x[i], AB_lookup$generalised_name))
|
||||
if (any(levenshtein <= 2)) {
|
||||
found <- AB_lookup$ab[which(levenshtein <= 2)]
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
next
|
||||
}
|
||||
}
|
||||
|
||||
# allow characters that resemble others, but only continue when having more than 3 characters
|
||||
if (nchar(x[i]) <= 3) {
|
||||
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
|
||||
@@ -238,7 +246,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
x_spelling <- gsub("E+", "E+", x_spelling, perl = TRUE)
|
||||
x_spelling <- gsub("O+", "O+", x_spelling, perl = TRUE)
|
||||
# allow any ending of -in/-ine and -im/-ime
|
||||
x_spelling <- gsub("(\\[IY\\]\\+(N|M)|\\[IY\\]\\+(N|M)E\\+)$", "[IY]+(N|M)E*", x_spelling, perl = TRUE)
|
||||
x_spelling <- gsub("(\\[IY\\]\\+(N|M)|\\[IY\\]\\+(N|M)E\\+?)$", "[IY]+(N|M)E*", x_spelling, perl = TRUE)
|
||||
# allow any ending of -ol/-ole
|
||||
x_spelling <- gsub("(O\\+L|O\\+LE\\+)$", "O+LE*", x_spelling, perl = TRUE)
|
||||
# allow any ending of -on/-one
|
||||
@@ -447,15 +455,13 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
x_unknown_ATCs <- x_unknown[x_unknown %like% "[A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9]"]
|
||||
x_unknown <- x_unknown[!x_unknown %in% x_unknown_ATCs]
|
||||
if (length(x_unknown_ATCs) > 0 & fast_mode == FALSE) {
|
||||
warning_("These ATC codes are not (yet) in the antibiotics data set: ",
|
||||
vector_and(x_unknown_ATCs), ".",
|
||||
call = FALSE)
|
||||
warning_("in `as.ab()`: these ATC codes are not (yet) in the antibiotics data set: ",
|
||||
vector_and(x_unknown_ATCs), ".")
|
||||
}
|
||||
|
||||
if (length(x_unknown) > 0 & fast_mode == FALSE) {
|
||||
warning_("These values could not be coerced to a valid antimicrobial ID: ",
|
||||
vector_and(x_unknown), ".",
|
||||
call = FALSE)
|
||||
warning_("in `as.ab()`: these values could not be coerced to a valid antimicrobial ID: ",
|
||||
vector_and(x_unknown), ".")
|
||||
}
|
||||
|
||||
x_result <- x_new[match(x_bak_clean, x)]
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -240,8 +240,8 @@ ab_ddd <- function(x, administration = "oral", ...) {
|
||||
units <- list(...)$units
|
||||
if (!is.null(units) && isTRUE(units)) {
|
||||
if (message_not_thrown_before("ab_ddd", entire_session = TRUE)) {
|
||||
warning_("Using `ab_ddd(..., units = TRUE)` is deprecated, use `ab_ddd_units()` to retrieve units instead. ",
|
||||
"This warning will be shown once per session.", call = FALSE)
|
||||
warning_("in `ab_ddd()`: using `ab_ddd(..., units = TRUE)` is deprecated, use `ab_ddd_units()` to retrieve units instead.",
|
||||
"This warning will be shown once per session.")
|
||||
}
|
||||
ddd_prop <- paste0(ddd_prop, "_units")
|
||||
} else {
|
||||
@@ -250,9 +250,9 @@ ab_ddd <- function(x, administration = "oral", ...) {
|
||||
out <- ab_validate(x = x, property = ddd_prop)
|
||||
|
||||
if (any(ab_name(x, language = NULL) %like% "/" & is.na(out))) {
|
||||
warning_("DDDs of some combined products are available for different dose combinations and not (yet) part of the AMR package. ",
|
||||
warning_("in `ab_ddd()`: DDDs of some combined products are available for different dose combinations and not (yet) part of the AMR package.",
|
||||
"Please refer to the WHOCC website:\n",
|
||||
"www.whocc.no/ddd/list_of_ddds_combined_products/", call = FALSE)
|
||||
"www.whocc.no/ddd/list_of_ddds_combined_products/")
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -265,9 +265,9 @@ ab_ddd_units <- function(x, administration = "oral", ...) {
|
||||
|
||||
x <- as.ab(x, ...)
|
||||
if (any(ab_name(x, language = NULL) %like% "/")) {
|
||||
warning_("DDDs of combined products are available for different dose combinations and not (yet) part of the AMR package. ",
|
||||
warning_("in `ab_ddd_units()`: DDDs of combined products are available for different dose combinations and not (yet) part of the AMR package.",
|
||||
"Please refer to the WHOCC website:\n",
|
||||
"www.whocc.no/ddd/list_of_ddds_combined_products/", call = FALSE)
|
||||
"www.whocc.no/ddd/list_of_ddds_combined_products/")
|
||||
}
|
||||
|
||||
ddd_prop <- paste0(administration, "_units")
|
||||
@@ -311,12 +311,12 @@ ab_url <- function(x, open = FALSE, ...) {
|
||||
|
||||
NAs <- ab_name(ab, tolower = TRUE, language = NULL)[!is.na(ab) & is.na(atcs)]
|
||||
if (length(NAs) > 0) {
|
||||
warning_("No ATC code available for ", vector_and(NAs, quotes = FALSE), ".")
|
||||
warning_("in `ab_url()`: no ATC code available for ", vector_and(NAs, quotes = FALSE), ".")
|
||||
}
|
||||
|
||||
if (open == TRUE) {
|
||||
if (length(u) > 1 & !is.na(u[1L])) {
|
||||
warning_("Only the first URL will be opened, as `browseURL()` only suports one string.")
|
||||
warning_("in `ab_url()`: only the first URL will be opened, as `browseURL()` only suports one string.")
|
||||
}
|
||||
if (!is.na(u[1L])) {
|
||||
utils::browseURL(u[1L])
|
||||
@@ -385,7 +385,8 @@ set_ab_names <- function(data, ..., property = "name", language = get_AMR_locale
|
||||
},
|
||||
USE.NAMES = FALSE)
|
||||
if (any(x %in% c("", NA))) {
|
||||
warning_("No ", property, " found for column(s): ", vector_and(vars[x %in% c("", NA)], sort = FALSE), call = FALSE)
|
||||
warning_("in `set_ab_names()`: no ", property, " found for column(s): ",
|
||||
vector_and(vars[x %in% c("", NA)], sort = FALSE))
|
||||
x[x %in% c("", NA)] <- vars[x %in% c("", NA)]
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -481,14 +481,13 @@ ab_select_exec <- function(function_name,
|
||||
untreatable <- antibiotics[which(antibiotics$name %like% "-high|EDTA|polysorbate|macromethod|screening|/nacubactam"), "ab", drop = TRUE]
|
||||
if (any(untreatable %in% names(ab_in_data))) {
|
||||
if (message_not_thrown_before(function_name, "ab_class", "untreatable", entire_session = TRUE)) {
|
||||
warning_("Some agents in `", function_name, "()` were ignored since they cannot be used for treating patients: ",
|
||||
warning_("in `", function_name, "()`: some agents were ignored since they cannot be used for treating patients: ",
|
||||
vector_and(ab_name(names(ab_in_data)[names(ab_in_data) %in% untreatable],
|
||||
language = NULL,
|
||||
tolower = TRUE),
|
||||
quotes = FALSE,
|
||||
sort = TRUE), ". They can be included using `", function_name, "(only_treatable = FALSE)`. ",
|
||||
"This warning will be shown once per session.",
|
||||
call = FALSE)
|
||||
"This warning will be shown once per session.")
|
||||
}
|
||||
ab_in_data <- ab_in_data[!names(ab_in_data) %in% untreatable]
|
||||
}
|
||||
|
8
R/age.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -95,10 +95,10 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
|
||||
if (any(ages < 0, na.rm = TRUE)) {
|
||||
ages[!is.na(ages) & ages < 0] <- NA
|
||||
warning_("NAs introduced for ages below 0.", call = TRUE)
|
||||
warning_("in `age()`: NAs introduced for ages below 0.")
|
||||
}
|
||||
if (any(ages > 120, na.rm = TRUE)) {
|
||||
warning_("Some ages are above 120.", call = TRUE)
|
||||
warning_("in `age()`: some ages are above 120.")
|
||||
}
|
||||
|
||||
if (isTRUE(na.rm)) {
|
||||
@@ -171,7 +171,7 @@ age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
|
||||
|
||||
if (any(x < 0, na.rm = TRUE)) {
|
||||
x[x < 0] <- NA
|
||||
warning_("NAs introduced for ages below 0.", call = TRUE)
|
||||
warning_("in `age_groups()`: NAs introduced for ages below 0.")
|
||||
}
|
||||
if (is.character(split_at)) {
|
||||
split_at <- split_at[1L]
|
||||
|
2
R/amr.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -175,7 +175,7 @@ atc_online_property <- function(atc_code,
|
||||
colnames(out) <- gsub("^atc.*", "atc", tolower(colnames(out)))
|
||||
|
||||
if (length(out) == 0) {
|
||||
warning_("ATC not found: ", atc_code[i], ". Please check ", atc_url, ".", call = FALSE)
|
||||
warning_("in `atc_online_property()`: ATC not found: ", atc_code[i], ". Please check ", atc_url, ".")
|
||||
returnvalue[i] <- NA
|
||||
next
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -184,7 +184,7 @@ format.bug_drug_combinations <- function(x,
|
||||
|
||||
if (inherits(x, "grouped")) {
|
||||
# bug_drug_combinations() has been run on groups, so de-group here
|
||||
warning_("formatting the output of `bug_drug_combinations()` does not support grouped variables, they are ignored", call = FALSE)
|
||||
warning_("in `format()`: formatting the output of `bug_drug_combinations()` does not support grouped variables, they were ignored")
|
||||
idx <- split(seq_len(nrow(x)), paste0(x$mo, "%%", x$ab))
|
||||
x <- data.frame(mo = gsub("(.*)%%(.*)", "\\1", names(idx)),
|
||||
ab = gsub("(.*)%%(.*)", "\\2", names(idx)),
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -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()].
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
4
R/data.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -69,8 +69,6 @@
|
||||
#' * <https://github.com/msberends/AMR/raw/main/data/antivirals.rda>
|
||||
#' @source World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): <https://www.whocc.no/atc_ddd_index/>
|
||||
#'
|
||||
#' WHONET 2019 software: <http://www.whonet.org/software.html>
|
||||
#'
|
||||
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: <https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm>
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection WHOCC WHOCC
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
6
R/disk.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -100,10 +100,10 @@ as.disk <- function(x, na.rm = FALSE) {
|
||||
unique() %pm>%
|
||||
sort() %pm>%
|
||||
vector_and(quotes = TRUE)
|
||||
warning_(na_after - na_before, " results truncated (",
|
||||
warning_("in `as.disk()`: ", na_after - na_before, " results truncated (",
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid disk zones: ",
|
||||
list_missing, call = FALSE)
|
||||
list_missing)
|
||||
}
|
||||
}
|
||||
set_clean_class(as.integer(x),
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -181,8 +181,7 @@ eucast_rules <- function(x,
|
||||
meet_criteria(custom_rules, allow_class = "custom_eucast_rules", allow_NULL = TRUE)
|
||||
|
||||
if ("custom" %in% rules & is.null(custom_rules)) {
|
||||
warning_("No custom rules were set with the `custom_rules` argument",
|
||||
call = FALSE,
|
||||
warning_("in `eucast_rules()`: no custom rules were set with the `custom_rules` argument",
|
||||
immediate = TRUE)
|
||||
rules <- rules[rules != "custom"]
|
||||
if (length(rules) == 0) {
|
||||
@@ -915,13 +914,12 @@ eucast_rules <- function(x,
|
||||
# take order from original data set
|
||||
warn_lacking_rsi_class <- warn_lacking_rsi_class[order(colnames(x.bak))]
|
||||
warn_lacking_rsi_class <- warn_lacking_rsi_class[!is.na(warn_lacking_rsi_class)]
|
||||
warning_("Not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
|
||||
warning_("in `eucast_rules()`: not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
|
||||
" - ", x_deparsed, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
||||
warn_lacking_rsi_class,
|
||||
paste0(warn_lacking_rsi_class[1], ":", warn_lacking_rsi_class[length(warn_lacking_rsi_class)])), ")\n",
|
||||
" - ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" - ", x_deparsed, " %>% mutate(across(where(is.rsi.eligible), as.rsi))",
|
||||
call = FALSE)
|
||||
" - ", x_deparsed, " %>% mutate(across(where(is.rsi.eligible), as.rsi))")
|
||||
}
|
||||
|
||||
# Return data set ---------------------------------------------------------
|
||||
@@ -986,14 +984,14 @@ edit_rsi <- function(x,
|
||||
TRUE
|
||||
})
|
||||
suppressWarnings(new_edits[rows, cols] <<- to)
|
||||
warning_("Value \"", to, "\" added to the factor levels of column", ifelse(length(cols) == 1, "", "s"),
|
||||
warning_("in `eucast_rules()`: value \"", to, "\" added to the factor levels of column",
|
||||
ifelse(length(cols) == 1, "", "s"),
|
||||
" ", vector_and(cols, quotes = "`", sort = FALSE),
|
||||
" because this value was not an existing factor level.",
|
||||
call = FALSE)
|
||||
" because this value was not an existing factor level.")
|
||||
txt_warning()
|
||||
warned <- FALSE
|
||||
} else {
|
||||
warning_(w$message, call = FALSE)
|
||||
warning_("in `eucast_rules()`: ", w$message)
|
||||
txt_warning()
|
||||
}
|
||||
},
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -267,7 +267,6 @@ get_column_abx <- function(x,
|
||||
", as it is already set for ",
|
||||
names(already_set_as), " (", ab_name(names(already_set_as), tolower = TRUE, language = NULL), ")"),
|
||||
add_fn = font_red,
|
||||
call = FALSE,
|
||||
immediate = verbose)
|
||||
}
|
||||
}
|
||||
@@ -338,6 +337,5 @@ generate_warning_abs_missing <- function(missing, any = FALSE) {
|
||||
}
|
||||
warning_(paste0("Introducing NAs since", any_txt[1], " these antimicrobials ", any_txt[2], " required: ",
|
||||
vector_and(missing, quotes = FALSE)),
|
||||
immediate = TRUE,
|
||||
call = FALSE)
|
||||
immediate = TRUE)
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -170,7 +170,7 @@ join_microorganisms <- function(type, x, by, suffix, ...) {
|
||||
}
|
||||
|
||||
if (type %like% "full|left|right|inner" && NROW(joined) > NROW(x)) {
|
||||
warning_("The newly joined data set contains ", nrow(joined) - nrow(x), " rows more than the number of rows of `x`.", call = FALSE)
|
||||
warning_("in `", type, "_join()`: the newly joined data set contains ", nrow(joined) - nrow(x), " rows more than the number of rows of `x`.")
|
||||
}
|
||||
|
||||
joined
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -150,7 +150,7 @@ key_antimicrobials <- function(x = NULL,
|
||||
col_mo <- search_type_in_df(x = x, type = "mo", info = FALSE)
|
||||
}
|
||||
if (is.null(col_mo)) {
|
||||
warning_("No column found for `col_mo`, ignoring antibiotics set in `gram_negative` and `gram_positive`, and antimycotics set in `antifungal`", call = FALSE)
|
||||
warning_("in `key_antimicrobials()`: no column found for `col_mo`, ignoring antibiotics set in `gram_negative` and `gram_positive`, and antimycotics set in `antifungal`")
|
||||
gramstain <- NA_character_
|
||||
kingdom <- NA_character_
|
||||
} else {
|
||||
@@ -172,11 +172,11 @@ key_antimicrobials <- function(x = NULL,
|
||||
if (values_new_length < values_old_length &
|
||||
any(filter, na.rm = TRUE) &
|
||||
message_not_thrown_before("key_antimicrobials", name)) {
|
||||
warning_(ifelse(values_new_length == 0,
|
||||
warning_("in `key_antimicrobials()`: ",
|
||||
ifelse(values_new_length == 0,
|
||||
"No columns available ",
|
||||
paste0("Only using ", values_new_length, " out of ", values_old_length, " defined columns ")),
|
||||
"as key antimicrobials for ", name, "s. See ?key_antimicrobials.",
|
||||
call = FALSE)
|
||||
"as key antimicrobials for ", name, "s. See ?key_antimicrobials.")
|
||||
}
|
||||
|
||||
generate_antimcrobials_string(x[which(filter), c(universal, values), drop = FALSE])
|
||||
@@ -217,7 +217,7 @@ key_antimicrobials <- function(x = NULL,
|
||||
cols = cols)
|
||||
|
||||
if (length(unique(key_ab)) == 1) {
|
||||
warning_("No distinct key antibiotics determined.", call = FALSE)
|
||||
warning_("in `key_antimicrobials()`: no distinct key antibiotics determined.")
|
||||
}
|
||||
|
||||
key_ab
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -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.
|
||||
#' 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 a 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
|
||||
|
2
R/like.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
14
R/mdro.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -65,7 +65,7 @@
|
||||
#'
|
||||
#' * `guideline = "TB"`
|
||||
#'
|
||||
#' The international guideline for multi-drug resistant tuberculosis - World Health Organization "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" ([link](https://www.who.int/tb/publications/pmdt_companionhandbook/en/))
|
||||
#' The international guideline for multi-drug resistant tuberculosis - World Health Organization "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" ([link](https://www.who.int/publications/i/item/9789241548809))
|
||||
#'
|
||||
#' * `guideline = "MRGN"`
|
||||
#'
|
||||
@@ -240,7 +240,7 @@ mdro <- function(x = NULL,
|
||||
}
|
||||
|
||||
if (!is.null(list(...)$country)) {
|
||||
warning_("Using `country` is deprecated, use `guideline` instead. See ?mdro.", call = FALSE)
|
||||
warning_("in `mdro()`: using `country` is deprecated, use `guideline` instead. See ?mdro")
|
||||
guideline <- list(...)$country
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ mdro <- function(x = NULL,
|
||||
guideline$name <- "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis"
|
||||
guideline$author <- "WHO (World Health Organization)"
|
||||
guideline$version <- "WHO/HTM/TB/2014.11, 2014"
|
||||
guideline$source_url <- "https://www.who.int/tb/publications/pmdt_companionhandbook/en/"
|
||||
guideline$source_url <- "https://www.who.int/publications/i/item/9789241548809"
|
||||
guideline$type <- "MDR-TB's"
|
||||
|
||||
# support per country:
|
||||
@@ -1550,8 +1550,8 @@ mdro <- function(x = NULL,
|
||||
if (guideline$code == "cmi2012") {
|
||||
if (any(x$MDRO == -1, na.rm = TRUE)) {
|
||||
if (message_not_thrown_before("mdro", "availability")) {
|
||||
warning_("NA introduced for isolates where the available percentage of antimicrobial classes was below ",
|
||||
percentage(pct_required_classes), " (set with `pct_required_classes`)", call = FALSE)
|
||||
warning_("in `mdro()`: NA introduced for isolates where the available percentage of antimicrobial classes was below ",
|
||||
percentage(pct_required_classes), " (set with `pct_required_classes`)")
|
||||
}
|
||||
# set these -1s to NA
|
||||
x[which(x$MDRO == -1), "MDRO"] <- NA_integer_
|
||||
@@ -1709,7 +1709,7 @@ run_custom_mdro_guideline <- function(df, guideline, info) {
|
||||
return("error")
|
||||
})
|
||||
if (identical(qry, "error")) {
|
||||
warning_("in custom_mdro_guideline(): rule ", i,
|
||||
warning_("in `custom_mdro_guideline()`: rule ", i,
|
||||
" (`", as.character(guideline[[i]]$query), "`) was ignored because of this error message: ",
|
||||
pkg_env$err_msg,
|
||||
call = FALSE,
|
||||
|
20
R/mic.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -37,8 +37,8 @@ valid_mic_levels <- c(c(t(vapply(FUN.VALUE = character(9), ops,
|
||||
function(x) paste0(x, sort(c(1:9, 1.5)))))),
|
||||
c(t(vapply(FUN.VALUE = character(45), ops,
|
||||
function(x) paste0(x, c(10:98)[9:98 %% 2 == TRUE])))),
|
||||
c(t(vapply(FUN.VALUE = character(16), ops,
|
||||
function(x) paste0(x, sort(c(2 ^ c(7:11), 80 * c(2:12))))))))
|
||||
c(t(vapply(FUN.VALUE = character(17), ops,
|
||||
function(x) paste0(x, sort(c(2 ^ c(7:11), 192, 80 * c(2:12))))))))
|
||||
|
||||
#' Transform Input to Minimum Inhibitory Concentrations (MIC)
|
||||
#'
|
||||
@@ -175,7 +175,7 @@ as.mic <- function(x, na.rm = FALSE) {
|
||||
unique() %pm>%
|
||||
sort() %pm>%
|
||||
vector_and(quotes = TRUE)
|
||||
warning_(na_after - na_before, " results truncated (",
|
||||
warning_("in `as.mic()`: ", na_after - na_before, " results truncated (",
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid MICs: ",
|
||||
list_missing, call = FALSE)
|
||||
@@ -243,12 +243,12 @@ droplevels.mic <- function(x, exclude = if (any(is.na(levels(x)))) NULL else NA,
|
||||
pillar_shaft.mic <- function(x, ...) {
|
||||
crude_numbers <- as.double(x)
|
||||
operators <- gsub("[^<=>]+", "", as.character(x))
|
||||
pasted <- trimws(paste0(operators, trimws(format(crude_numbers))))
|
||||
out <- pasted
|
||||
operators[!is.na(operators) & operators != ""] <- font_silver(operators[!is.na(operators) & operators != ""], collapse = NULL)
|
||||
out <- trimws(paste0(operators, trimws(format(crude_numbers))))
|
||||
out[is.na(x)] <- font_na(NA)
|
||||
out <- gsub("(<|=|>)", font_silver("\\1"), out)
|
||||
out <- gsub("([.]?0+)$", font_white("\\1"), out)
|
||||
create_pillar_column(out, align = "right", width = max(nchar(pasted)))
|
||||
# maketrailing zeroes almost invisible
|
||||
out[out %like% "[.]"] <- gsub("([.]?0+)$", font_white("\\1"), out[out %like% "[.]"], perl = TRUE)
|
||||
create_pillar_column(out, align = "right", width = max(nchar(font_stripstyle(out))))
|
||||
}
|
||||
|
||||
# will be exported using s3_register() in R/zzz.R
|
||||
@@ -358,7 +358,7 @@ sort.mic <- function(x, decreasing = FALSE, ...) {
|
||||
#' @export
|
||||
#' @noRd
|
||||
hist.mic <- function(x, ...) {
|
||||
warning_("Use `plot()` or ggplot2's `autoplot()` for optimal plotting of MIC values", call = FALSE)
|
||||
warning_("in `hist()`: use `plot()` or ggplot2's `autoplot()` for optimal plotting of MIC values")
|
||||
hist(log2(x))
|
||||
}
|
||||
|
||||
|
141
R/mo.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -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)")`.
|
||||
@@ -1003,6 +1003,35 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
}
|
||||
|
||||
# try splitting of characters in the middle and then find ID based on old names ----
|
||||
# only when text length is 6 or lower
|
||||
# like esco = E. coli, klpn = K. pneumoniae, stau = S. aureus, staaur = S. aureus
|
||||
if (nchar(g.x_backup_without_spp) <= 6) {
|
||||
x_length <- nchar(g.x_backup_without_spp)
|
||||
x_split <- paste0("^",
|
||||
g.x_backup_without_spp %pm>% substr(1, x_length / 2),
|
||||
".* ",
|
||||
g.x_backup_without_spp %pm>% substr((x_length / 2) + 1, x_length))
|
||||
found <- lookup(fullname_lower %like_case% x_split,
|
||||
haystack = MO.old_lookup,
|
||||
column = NULL)
|
||||
if (!all(is.na(found))) {
|
||||
# it's an old name, so return it
|
||||
if (property == "ref") {
|
||||
x[i] <- found["ref"]
|
||||
} else {
|
||||
x[i] <- lookup(fullname == found["fullname_new"], haystack = MO_lookup)
|
||||
}
|
||||
pkg_env$mo_renamed_last_run <- found["fullname"]
|
||||
was_renamed(name_old = found["fullname"],
|
||||
name_new = lookup(fullname == found["fullname_new"], "fullname", haystack = MO_lookup),
|
||||
ref_old = found["ref"],
|
||||
ref_new = lookup(fullname == found["fullname_new"], "ref", haystack = MO_lookup),
|
||||
mo = lookup(fullname == found["fullname_new"], "mo", haystack = MO_lookup))
|
||||
return(x[i])
|
||||
}
|
||||
}
|
||||
|
||||
# try fullname without start and without nchar limit of >= 6 ----
|
||||
# like "K. pneu rhino" >> "Klebsiella pneumoniae (rhinoscleromatis)" = KLEPNERH
|
||||
found <- lookup(fullname_lower %like_case% e.x_withspaces_start_only,
|
||||
@@ -1188,9 +1217,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 +1278,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 +1307,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 +1333,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 +1369,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 +1396,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 +1424,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, "'")
|
||||
@@ -1460,9 +1518,8 @@ exec_as.mo <- function(x,
|
||||
"You can also use your own reference data with set_mo_source() or directly, e.g.:\n",
|
||||
' as.mo("mycode", reference_df = data.frame(own = "mycode", mo = "', MO_lookup$mo[match("Escherichia coli", MO_lookup$fullname)], '"))\n',
|
||||
' mo_name("mycode", reference_df = data.frame(own = "mycode", mo = "', MO_lookup$mo[match("Escherichia coli", MO_lookup$fullname)], '"))\n')
|
||||
warning_(paste0("\n", msg),
|
||||
warning_(paste0("\nin `as.mo()`: ", msg),
|
||||
add_fn = font_red,
|
||||
call = FALSE,
|
||||
immediate = TRUE) # thus will always be shown, even if >= warnings
|
||||
}
|
||||
# handling uncertainties ----
|
||||
@@ -1502,12 +1559,11 @@ exec_as.mo <- function(x,
|
||||
# comment below code if all staphylococcal species are categorised as CoNS/CoPS
|
||||
if (any(x %in% MO_lookup[which(MO_lookup$species %in% post_Becker), property])) {
|
||||
if (message_not_thrown_before("as.mo", "becker")) {
|
||||
warning_("Becker ", font_italic("et al."), " (2014, 2019, 2020) does not contain these species named after their publication: ",
|
||||
warning_("in `as.mo()`: Becker ", font_italic("et al."), " (2014, 2019, 2020) does not contain these species named after their publication: ",
|
||||
font_italic(paste("S.",
|
||||
sort(mo_species(unique(x[x %in% MO_lookup[which(MO_lookup$species %in% post_Becker), property]]))),
|
||||
collapse = ", ")),
|
||||
". Categorisation to CoNS/CoPS was taken from the original scientific publication(s).",
|
||||
call = FALSE,
|
||||
immediate = TRUE)
|
||||
}
|
||||
}
|
||||
@@ -1680,8 +1736,7 @@ pillar_shaft.mo <- function(x, ...) {
|
||||
col <- "The data"
|
||||
}
|
||||
warning_(col, " contains old MO codes (from a previous AMR package version). ",
|
||||
"Please update your MO codes with `as.mo()`.",
|
||||
call = FALSE)
|
||||
"Please update your MO codes with `as.mo()`.")
|
||||
}
|
||||
|
||||
# make it always fit exactly
|
||||
@@ -1755,8 +1810,7 @@ print.mo <- function(x, print.shortnames = FALSE, ...) {
|
||||
names(x) <- x_names
|
||||
if (!all(x[!is.na(x)] %in% MO_lookup$mo)) {
|
||||
warning_("Some MO codes are from a previous AMR package version. ",
|
||||
"Please update these MO codes with `as.mo()`.",
|
||||
call = FALSE)
|
||||
"Please update the MO codes with `as.mo()`.")
|
||||
}
|
||||
print.default(x, quote = FALSE)
|
||||
}
|
||||
@@ -1785,8 +1839,7 @@ summary.mo <- function(object, ...) {
|
||||
as.data.frame.mo <- function(x, ...) {
|
||||
if (!all(x[!is.na(x)] %in% MO_lookup$mo)) {
|
||||
warning_("The data contains old MO codes (from a previous AMR package version). ",
|
||||
"Please update your MO codes with `as.mo()`.",
|
||||
call = FALSE)
|
||||
"Please update your MO codes with `as.mo()`.")
|
||||
}
|
||||
nm <- deparse1(substitute(x))
|
||||
if (!"nm" %in% names(list(...))) {
|
||||
@@ -1882,7 +1935,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))) {
|
||||
@@ -2090,24 +2143,22 @@ replace_old_mo_codes <- function(x, property) {
|
||||
n_unique <- ""
|
||||
}
|
||||
if (property != "mo") {
|
||||
warning_(paste0("The input contained ", n_matched,
|
||||
" old MO code", ifelse(n_matched == 1, "", "s"),
|
||||
" (", n_unique, "from a previous AMR package version). ",
|
||||
"Please update your MO codes with `as.mo()` to increase speed."),
|
||||
call = FALSE)
|
||||
warning_("in `mo_", property, "()`: the input contained ", n_matched,
|
||||
" old MO code", ifelse(n_matched == 1, "", "s"),
|
||||
" (", n_unique, "from a previous AMR package version). ",
|
||||
"Please update your MO codes with `as.mo()` to increase speed.")
|
||||
} else {
|
||||
warning_(paste0("The input contained ", n_matched,
|
||||
" old MO code", ifelse(n_matched == 1, "", "s"),
|
||||
" (", n_unique, "from a previous AMR package version). ",
|
||||
n_solved, " old MO code", ifelse(n_solved == 1, "", "s"),
|
||||
ifelse(n_solved == 1, " was", " were"),
|
||||
ifelse(all_direct_matches, " updated ", font_bold(" guessed ")),
|
||||
"to ", ifelse(n_solved == 1, "a ", ""),
|
||||
"currently used MO code", ifelse(n_solved == 1, "", "s"),
|
||||
ifelse(n_unsolved > 0,
|
||||
paste0(" and ", n_unsolved, " old MO code", ifelse(n_unsolved == 1, "", "s"), " could not be updated."),
|
||||
".")),
|
||||
call = FALSE)
|
||||
warning_("in `as.mo()`: the input contained ", n_matched,
|
||||
" old MO code", ifelse(n_matched == 1, "", "s"),
|
||||
" (", n_unique, "from a previous AMR package version). ",
|
||||
n_solved, " old MO code", ifelse(n_solved == 1, "", "s"),
|
||||
ifelse(n_solved == 1, " was", " were"),
|
||||
ifelse(all_direct_matches, " updated ", font_bold(" guessed ")),
|
||||
"to ", ifelse(n_solved == 1, "a ", ""),
|
||||
"currently used MO code", ifelse(n_solved == 1, "", "s"),
|
||||
ifelse(n_unsolved > 0,
|
||||
paste0(" and ", n_unsolved, " old MO code", ifelse(n_unsolved == 1, "", "s"), " could not be updated."),
|
||||
"."))
|
||||
}
|
||||
}
|
||||
x
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -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 @@
|
||||
#' 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) {
|
||||
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) {
|
||||
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]))
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -684,7 +684,7 @@ mo_url <- function(x, open = FALSE, language = get_AMR_locale(), ...) {
|
||||
|
||||
if (isTRUE(open)) {
|
||||
if (length(u) > 1) {
|
||||
warning_("Only the first URL will be opened, as `browseURL()` only suports one string.")
|
||||
warning_("in `mo_url()`: only the first URL will be opened, as `browseURL()` only suports one string.")
|
||||
}
|
||||
utils::browseURL(u[1L])
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
4
R/pca.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -98,7 +98,7 @@ pca <- function(x,
|
||||
|
||||
x <- as.data.frame(new_list, stringsAsFactors = FALSE)
|
||||
if (any(vapply(FUN.VALUE = logical(1), x, function(y) !is.numeric(y)))) {
|
||||
warning_("Be sure to first calculate the resistance (or susceptibility) of variables with antimicrobial test results, since PCA works with [numeric] variables only. See Examples in ?pca.", call = FALSE)
|
||||
warning_("in `pca()`: be sure to first calculate the resistance (or susceptibility) of variables with antimicrobial test results, since PCA works with numeric variables only. See Examples in ?pca.", call = FALSE)
|
||||
}
|
||||
|
||||
# set column names
|
||||
|
2
R/plot.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -106,7 +106,7 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) {
|
||||
if (nrow(df_new) > 0) {
|
||||
df <- df_new
|
||||
} else {
|
||||
warning_("No rows found that match mo '", mo, "', ignoring argument `mo`", call = FALSE)
|
||||
warning_("in `random_", tolower(type), "()`: no rows found that match mo '", mo, "', ignoring argument `mo`")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) {
|
||||
if (nrow(df_new) > 0) {
|
||||
df <- df_new
|
||||
} else {
|
||||
warning_("No rows found that match ab '", ab, "', ignoring argument `ab`", call = FALSE)
|
||||
warning_("in `random_", tolower(type), "()`: no rows found that match ab '", ab, "', ignoring argument `ab`")
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -153,7 +153,7 @@ resistance_predict <- function(x,
|
||||
x <- dots[which(dots.names == "tbl")]
|
||||
}
|
||||
if ("I_as_R" %in% dots.names) {
|
||||
warning_("`I_as_R is deprecated - use I_as_S instead.", call = FALSE)
|
||||
warning_("in `resistance_predict()`: I_as_R is deprecated - use I_as_S instead.")
|
||||
}
|
||||
}
|
||||
|
||||
|
383
R/rsi.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -67,7 +67,7 @@
|
||||
#'
|
||||
#' For interpreting MIC values as well as disk diffusion diameters, currently implemented guidelines are EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`).
|
||||
#'
|
||||
#' Thus, the `guideline` argument must be set to e.g., ``r paste0('"', subset(rsi_translation, guideline %like% "EUCAST")$guideline[1], '"')`` or ``r paste0('"', subset(rsi_translation, guideline %like% "CLSI")$guideline[1], '"')``. By simply using `"EUCAST"` (the default) or `"CLSI"` as input, the latest version of that guideline will automatically be selected. You can set your own data set using the `reference_data` argument. The `guideline` argument will then be ignored.
|
||||
#' Thus, the `guideline` argument must be set to e.g., ``r paste0('"', subset(rsi_translation, guideline %like% "EUCAST")$guideline[1], '"')`` or ``r paste0('"', subset(rsi_translation, guideline %like% "CLSI")$guideline[1], '"')``. By simply using `"EUCAST"` (the default) or `"CLSI"` as input, the latest included version of that guideline will automatically be selected. You can set your own data set using the `reference_data` argument. The `guideline` argument will then be ignored.
|
||||
#'
|
||||
#' ## After Interpretation
|
||||
#'
|
||||
@@ -233,9 +233,9 @@ is.rsi.eligible <- function(x, threshold = 0.05) {
|
||||
} else if (!any(c("R", "S", "I") %in% x, na.rm = TRUE) & !all(is.na(x))) {
|
||||
return(FALSE)
|
||||
} else {
|
||||
x <- x[!is.na(x) & !is.null(x) & x != ""]
|
||||
x <- x[!is.na(x) & !is.null(x) & !x %in% c("", "-", "NULL")]
|
||||
if (length(x) == 0) {
|
||||
# no other values than NA or ""
|
||||
# no other values than empty
|
||||
cur_col <- get_current_column()
|
||||
if (!is.null(cur_col)) {
|
||||
ab <- suppressWarnings(as.ab(cur_col, fast_mode = TRUE, info = FALSE))
|
||||
@@ -257,7 +257,7 @@ is.rsi.eligible <- function(x, threshold = 0.05) {
|
||||
}
|
||||
|
||||
#' @export
|
||||
# extra param: warn (never throw warning)
|
||||
# extra param: warn (logical, to never throw a warning)
|
||||
as.rsi.default <- function(x, ...) {
|
||||
if (is.rsi(x)) {
|
||||
return(x)
|
||||
@@ -278,22 +278,23 @@ as.rsi.default <- function(x, ...) {
|
||||
x[x.bak == 2] <- "I"
|
||||
x[x.bak == 3] <- "R"
|
||||
}
|
||||
|
||||
|
||||
} else if (!all(is.na(x)) && !identical(levels(x), c("R", "S", "I")) && !all(x %in% c("R", "S", "I", NA))) {
|
||||
|
||||
|
||||
if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) {
|
||||
# check if they are actually MICs or disks
|
||||
if (all_valid_mics(x)) {
|
||||
warning_("The input seems to contain MIC values. You can transform them with `as.mic()` before running `as.rsi()` to interpret them.", call = FALSE)
|
||||
warning_("in `as.rsi()`: the input seems to contain MIC values. You can transform them with `as.mic()` before running `as.rsi()` to interpret them.")
|
||||
} else if (all_valid_disks(x)) {
|
||||
warning_("The input seems to contain disk diffusion values. You can transform them with `as.disk()` before running `as.rsi()` to interpret them.", call = FALSE)
|
||||
warning_("in `as.rsi()`: the input seems to contain disk diffusion values. You can transform them with `as.disk()` before running `as.rsi()` to interpret them.")
|
||||
}
|
||||
}
|
||||
|
||||
# trim leading and trailing spaces, new lines, etc.
|
||||
x <- trimws2(as.character(unlist(x)))
|
||||
x[x %in% c(NA, "", "-", "NULL")] <- NA_character_
|
||||
x.bak <- x
|
||||
na_before <- length(x[is.na(x) | x == ""])
|
||||
na_before <- length(x[is.na(x)])
|
||||
|
||||
# correct for translations
|
||||
trans_R <- unlist(TRANSLATIONS[which(TRANSLATIONS$pattern == "Resistant"),
|
||||
@@ -310,11 +311,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)
|
||||
@@ -328,11 +333,20 @@ as.rsi.default <- function(x, ...) {
|
||||
unique() %pm>%
|
||||
sort() %pm>%
|
||||
vector_and(quotes = TRUE)
|
||||
warning_(na_after - na_before, " results truncated (",
|
||||
warning_("in `as.rsi()`: ", na_after - na_before, " results truncated (",
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid antimicrobial interpretations: ",
|
||||
list_missing, call = FALSE)
|
||||
}
|
||||
if (any(toupper(x.bak[!is.na(x.bak)]) == "U") && message_not_thrown_before("as.rsi", "U")) {
|
||||
warning_("in `as.rsi()`: 'U' was interpreted as 'S', following some laboratory systems")
|
||||
}
|
||||
if (any(toupper(x.bak[!is.na(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")
|
||||
}
|
||||
if (any(toupper(x.bak[!is.na(x.bak)]) == "H") && message_not_thrown_before("as.rsi", "H")) {
|
||||
warning_("in `as.rsi()`: 'H' was interpreted as 'I', following some laboratory systems")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,89 +365,17 @@ as.rsi.mic <- function(x,
|
||||
add_intrinsic_resistance = FALSE,
|
||||
reference_data = AMR::rsi_translation,
|
||||
...) {
|
||||
meet_criteria(x)
|
||||
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
|
||||
meet_criteria(ab, allow_class = c("ab", "character"))
|
||||
meet_criteria(guideline, allow_class = "character", has_length = 1)
|
||||
meet_criteria(uti, allow_class = "logical", has_length = c(1, length(x)))
|
||||
meet_criteria(conserve_capped_values, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(add_intrinsic_resistance, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(reference_data, allow_class = "data.frame")
|
||||
check_reference_data(reference_data)
|
||||
|
||||
# for dplyr's across()
|
||||
cur_column_dplyr <- import_fn("cur_column", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(cur_column_dplyr) && tryCatch(is.data.frame(get_current_data("ab", call = 0)), error = function(e) FALSE)) {
|
||||
# try to get current column, which will only be available when in across()
|
||||
ab <- tryCatch(cur_column_dplyr(),
|
||||
error = function(e) ab)
|
||||
}
|
||||
|
||||
# for auto-determining mo
|
||||
mo_var_found <- ""
|
||||
if (is.null(mo)) {
|
||||
tryCatch({
|
||||
df <- get_current_data(arg_name = "mo", call = -3) # will return an error if not found
|
||||
mo <- NULL
|
||||
try({
|
||||
mo <- suppressMessages(search_type_in_df(df, "mo"))
|
||||
}, silent = TRUE)
|
||||
if (!is.null(df) && !is.null(mo) && is.data.frame(df)) {
|
||||
mo_var_found <- paste0(" based on column '", font_bold(mo), "'")
|
||||
mo <- df[, mo, drop = TRUE]
|
||||
}
|
||||
}, error = function(e)
|
||||
stop_('No information was supplied about the microorganisms (missing argument `mo`). See ?as.rsi.\n\n',
|
||||
"To transform certain columns with e.g. mutate_at(), use `data %>% mutate_at(vars(...), as.rsi, mo = .$x)`, where x is your column with microorganisms.\n",
|
||||
"To tranform all disk diffusion zones in a data set, use `data %>% as.rsi()` or data %>% mutate_if(is.disk, as.rsi).", call = FALSE)
|
||||
)
|
||||
}
|
||||
if (length(ab) == 1 && ab %like% "as.mic") {
|
||||
stop_('No unambiguous name was supplied about the antibiotic (argument `ab`). See ?as.rsi.', call = FALSE)
|
||||
}
|
||||
|
||||
ab_coerced <- suppressWarnings(as.ab(ab))
|
||||
mo_coerced <- suppressWarnings(as.mo(mo))
|
||||
guideline_coerced <- get_guideline(guideline, reference_data)
|
||||
if (is.na(ab_coerced)) {
|
||||
message_("Returning NAs for unknown drug: '", font_bold(ab),
|
||||
"'. Rename this column to a drug name or code, and check the output with `as.ab()`.",
|
||||
add_fn = font_red,
|
||||
as_note = FALSE)
|
||||
return(as.rsi(rep(NA, length(x))))
|
||||
}
|
||||
if (length(mo_coerced) == 1) {
|
||||
mo_coerced <- rep(mo_coerced, length(x))
|
||||
}
|
||||
if (length(uti) == 1) {
|
||||
uti <- rep(uti, length(x))
|
||||
}
|
||||
|
||||
agent_formatted <- paste0("'", font_bold(ab), "'")
|
||||
agent_name <- ab_name(ab_coerced, tolower = TRUE, language = NULL)
|
||||
if (generalise_antibiotic_name(ab) != generalise_antibiotic_name(agent_name)) {
|
||||
agent_formatted <- paste0(agent_formatted, " (", ab_coerced, ", ", agent_name, ")")
|
||||
}
|
||||
message_("=> Interpreting MIC values of ", ifelse(isTRUE(list(...)$is_data.frame), "column ", ""),
|
||||
agent_formatted,
|
||||
mo_var_found,
|
||||
" according to ", ifelse(identical(reference_data, AMR::rsi_translation),
|
||||
font_bold(guideline_coerced),
|
||||
"manually defined 'reference_data'"),
|
||||
"... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE)
|
||||
|
||||
result <- exec_as.rsi(method = "mic",
|
||||
x = x,
|
||||
mo = mo_coerced,
|
||||
ab = ab_coerced,
|
||||
guideline = guideline_coerced,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data) # exec_as.rsi will return message 'OK'
|
||||
result
|
||||
as_rsi_method(method_short = "mic",
|
||||
method_long = "MIC values",
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname as.rsi
|
||||
@@ -446,88 +388,17 @@ as.rsi.disk <- function(x,
|
||||
add_intrinsic_resistance = FALSE,
|
||||
reference_data = AMR::rsi_translation,
|
||||
...) {
|
||||
meet_criteria(x)
|
||||
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
|
||||
meet_criteria(ab, allow_class = c("ab", "character"))
|
||||
meet_criteria(guideline, allow_class = "character", has_length = 1)
|
||||
meet_criteria(uti, allow_class = "logical", has_length = c(1, length(x)))
|
||||
meet_criteria(add_intrinsic_resistance, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(reference_data, allow_class = "data.frame")
|
||||
check_reference_data(reference_data)
|
||||
|
||||
# for dplyr's across()
|
||||
cur_column_dplyr <- import_fn("cur_column", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(cur_column_dplyr) && tryCatch(is.data.frame(get_current_data("ab", call = 0)), error = function(e) FALSE)) {
|
||||
# try to get current column, which will only be available when in across()
|
||||
ab <- tryCatch(cur_column_dplyr(),
|
||||
error = function(e) ab)
|
||||
}
|
||||
|
||||
# for auto-determining mo
|
||||
mo_var_found <- ""
|
||||
if (is.null(mo)) {
|
||||
tryCatch({
|
||||
df <- get_current_data(arg_name = "mo", call = -3) # will return an error if not found
|
||||
mo <- NULL
|
||||
try({
|
||||
mo <- suppressMessages(search_type_in_df(df, "mo"))
|
||||
}, silent = TRUE)
|
||||
if (!is.null(df) && !is.null(mo) && is.data.frame(df)) {
|
||||
mo_var_found <- paste0(" based on column '", font_bold(mo), "'")
|
||||
mo <- df[, mo, drop = TRUE]
|
||||
}
|
||||
}, error = function(e)
|
||||
stop_('No information was supplied about the microorganisms (missing argument `mo`). See ?as.rsi.\n\n',
|
||||
"To transform certain columns with e.g. mutate_at(), use `data %>% mutate_at(vars(...), as.rsi, mo = .$x)`, where x is your column with microorganisms.\n",
|
||||
"To tranform all disk diffusion zones in a data set, use `data %>% as.rsi()` or data %>% mutate_if(is.disk, as.rsi).", call = FALSE)
|
||||
)
|
||||
}
|
||||
if (length(ab) == 1 && ab %like% "as.disk") {
|
||||
stop_('No unambiguous name was supplied about the antibiotic (argument `ab`). See ?as.rsi.', call = FALSE)
|
||||
}
|
||||
|
||||
ab_coerced <- suppressWarnings(as.ab(ab))
|
||||
mo_coerced <- suppressWarnings(as.mo(mo))
|
||||
guideline_coerced <- get_guideline(guideline, reference_data)
|
||||
if (is.na(ab_coerced)) {
|
||||
message_("Returning NAs for unknown drug: '", font_bold(ab),
|
||||
"'. Rename this column to a drug name or code, and check the output with `as.ab()`.",
|
||||
add_fn = font_red,
|
||||
as_note = FALSE)
|
||||
return(as.rsi(rep(NA, length(x))))
|
||||
}
|
||||
if (length(mo_coerced) == 1) {
|
||||
mo_coerced <- rep(mo_coerced, length(x))
|
||||
}
|
||||
if (length(uti) == 1) {
|
||||
uti <- rep(uti, length(x))
|
||||
}
|
||||
|
||||
agent_formatted <- paste0("'", font_bold(ab), "'")
|
||||
agent_name <- ab_name(ab_coerced, tolower = TRUE, language = NULL)
|
||||
if (generalise_antibiotic_name(ab) != generalise_antibiotic_name(agent_name)) {
|
||||
agent_formatted <- paste0(agent_formatted, " (", ab_coerced, ", ", agent_name, ")")
|
||||
}
|
||||
message_("=> Interpreting disk zones of ", ifelse(isTRUE(list(...)$is_data.frame), "column ", ""),
|
||||
agent_formatted,
|
||||
mo_var_found,
|
||||
" according to ", ifelse(identical(reference_data, AMR::rsi_translation),
|
||||
font_bold(guideline_coerced),
|
||||
"manually defined 'reference_data'"),
|
||||
"... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE)
|
||||
|
||||
result <- exec_as.rsi(method = "disk",
|
||||
x = x,
|
||||
mo = mo_coerced,
|
||||
ab = ab_coerced,
|
||||
guideline = guideline_coerced,
|
||||
uti = uti,
|
||||
conserve_capped_values = FALSE,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data) # exec_as.rsi will return message 'OK'
|
||||
result
|
||||
as_rsi_method(method_short = "disk",
|
||||
method_long = "disk diffusion zones",
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
conserve_capped_values = FALSE,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname as.rsi
|
||||
@@ -547,7 +418,7 @@ as.rsi.data.frame <- function(x,
|
||||
meet_criteria(conserve_capped_values, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(add_intrinsic_resistance, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(reference_data, allow_class = "data.frame")
|
||||
|
||||
|
||||
x.bak <- x
|
||||
for (i in seq_len(ncol(x))) {
|
||||
# don't keep factors, overwriting them is hard
|
||||
@@ -561,7 +432,7 @@ as.rsi.data.frame <- function(x,
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo", info = FALSE)
|
||||
}
|
||||
|
||||
|
||||
# -- UTIs
|
||||
col_uti <- uti
|
||||
if (is.null(col_uti)) {
|
||||
@@ -602,7 +473,7 @@ as.rsi.data.frame <- function(x,
|
||||
uti <- FALSE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
i <- 0
|
||||
if (tryCatch(length(list(...)) > 0, error = function(e) TRUE)) {
|
||||
sel <- colnames(pm_select(x, ...))
|
||||
@@ -612,7 +483,7 @@ as.rsi.data.frame <- function(x,
|
||||
if (!is.null(col_mo)) {
|
||||
sel <- sel[sel != col_mo]
|
||||
}
|
||||
|
||||
|
||||
ab_cols <- colnames(x)[vapply(FUN.VALUE = logical(1), x, function(y) {
|
||||
i <<- i + 1
|
||||
check <- is.mic(y) | is.disk(y)
|
||||
@@ -635,7 +506,7 @@ as.rsi.data.frame <- function(x,
|
||||
return(FALSE)
|
||||
}
|
||||
})]
|
||||
|
||||
|
||||
stop_if(length(ab_cols) == 0,
|
||||
"no columns with MIC values, disk zones or antibiotic column names found in this data set. Use as.mic() or as.disk() to transform antimicrobial columns.")
|
||||
# set type per column
|
||||
@@ -654,7 +525,7 @@ as.rsi.data.frame <- function(x,
|
||||
}
|
||||
x_mo <- as.mo(x[, col_mo, drop = TRUE])
|
||||
}
|
||||
|
||||
|
||||
for (i in seq_len(length(ab_cols))) {
|
||||
if (types[i] == "mic") {
|
||||
x[, ab_cols[i]] <- as.rsi(x = x %pm>%
|
||||
@@ -732,6 +603,105 @@ get_guideline <- function(guideline, reference_data) {
|
||||
guideline_param
|
||||
}
|
||||
|
||||
as_rsi_method <- function(method_short = "mic",
|
||||
method_long = "MIC values",
|
||||
x = x,
|
||||
mo = NULL,
|
||||
ab = deparse(substitute(x)),
|
||||
guideline = "EUCAST",
|
||||
uti = FALSE,
|
||||
conserve_capped_values = FALSE,
|
||||
add_intrinsic_resistance = FALSE,
|
||||
reference_data = AMR::rsi_translation,
|
||||
...) {
|
||||
meet_criteria(x)
|
||||
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
|
||||
meet_criteria(ab, allow_class = c("ab", "character"))
|
||||
meet_criteria(guideline, allow_class = "character", has_length = 1)
|
||||
meet_criteria(uti, allow_class = "logical", has_length = c(1, length(x)))
|
||||
meet_criteria(conserve_capped_values, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(add_intrinsic_resistance, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(reference_data, allow_class = "data.frame")
|
||||
check_reference_data(reference_data)
|
||||
|
||||
# for dplyr's across()
|
||||
cur_column_dplyr <- import_fn("cur_column", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(cur_column_dplyr) && tryCatch(is.data.frame(get_current_data("ab", call = 0)), error = function(e) FALSE)) {
|
||||
# try to get current column, which will only be available when in across()
|
||||
ab <- tryCatch(cur_column_dplyr(),
|
||||
error = function(e) ab)
|
||||
}
|
||||
|
||||
# for auto-determining mo
|
||||
mo_var_found <- ""
|
||||
if (is.null(mo)) {
|
||||
tryCatch({
|
||||
df <- get_current_data(arg_name = "mo", call = -3) # will return an error if not found
|
||||
mo <- NULL
|
||||
try({
|
||||
mo <- suppressMessages(search_type_in_df(df, "mo"))
|
||||
}, silent = TRUE)
|
||||
if (!is.null(df) && !is.null(mo) && is.data.frame(df)) {
|
||||
mo_var_found <- paste0(" based on column '", font_bold(mo), "'")
|
||||
mo <- df[, mo, drop = TRUE]
|
||||
}
|
||||
}, error = function(e) {
|
||||
mo <- NULL
|
||||
})
|
||||
}
|
||||
if (is.null(mo)) {
|
||||
stop_("No information was supplied about the microorganisms (missing argument `mo` and no column of class <mo> found). See ?as.rsi.\n\n",
|
||||
"To transform certain columns with e.g. mutate(), use `data %>% mutate(across(..., as.rsi, mo = x))`, where x is your column with microorganisms.\n",
|
||||
"To tranform all ", method_long, " in a data set, use `data %>% as.rsi()` or `data %>% mutate(across(where(is.", method_short, "), as.rsi))`.", call = FALSE)
|
||||
}
|
||||
|
||||
if (length(ab) == 1 && ab %like% paste0("as.", method_short)) {
|
||||
stop_('No unambiguous name was supplied about the antibiotic (argument `ab`). See ?as.rsi.', call = FALSE)
|
||||
}
|
||||
|
||||
ab_coerced <- suppressWarnings(as.ab(ab))
|
||||
mo_coerced <- suppressWarnings(as.mo(mo))
|
||||
guideline_coerced <- get_guideline(guideline, reference_data)
|
||||
if (is.na(ab_coerced)) {
|
||||
message_("Returning NAs for unknown drug: '", font_bold(ab),
|
||||
"'. Rename this column to a drug name or code, and check the output with `as.ab()`.",
|
||||
add_fn = font_red,
|
||||
as_note = FALSE)
|
||||
return(as.rsi(rep(NA, length(x))))
|
||||
}
|
||||
if (length(mo_coerced) == 1) {
|
||||
mo_coerced <- rep(mo_coerced, length(x))
|
||||
}
|
||||
if (length(uti) == 1) {
|
||||
uti <- rep(uti, length(x))
|
||||
}
|
||||
|
||||
agent_formatted <- paste0("'", font_bold(ab), "'")
|
||||
agent_name <- ab_name(ab_coerced, tolower = TRUE, language = NULL)
|
||||
if (generalise_antibiotic_name(ab) != generalise_antibiotic_name(agent_name)) {
|
||||
agent_formatted <- paste0(agent_formatted, " (", ab_coerced, ", ", agent_name, ")")
|
||||
}
|
||||
message_("=> Interpreting ", method_long, " of ", ifelse(isTRUE(list(...)$is_data.frame), "column ", ""),
|
||||
agent_formatted,
|
||||
mo_var_found,
|
||||
" according to ", ifelse(identical(reference_data, AMR::rsi_translation),
|
||||
font_bold(guideline_coerced),
|
||||
"manually defined 'reference_data'"),
|
||||
"... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE)
|
||||
result <- exec_as.rsi(method = method_short,
|
||||
x = x,
|
||||
mo = mo_coerced,
|
||||
ab = ab_coerced,
|
||||
guideline = guideline_coerced,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data) # exec_as.rsi will return message 'OK'
|
||||
result
|
||||
}
|
||||
|
||||
exec_as.rsi <- function(method,
|
||||
x,
|
||||
mo,
|
||||
@@ -744,7 +714,7 @@ exec_as.rsi <- function(method,
|
||||
metadata_mo <- get_mo_failures_uncertainties_renamed()
|
||||
|
||||
x_bak <- data.frame(x_mo = paste0(x, mo), stringsAsFactors = FALSE)
|
||||
df <- unique(data.frame(x, mo), stringsAsFactors = FALSE)
|
||||
df <- unique(data.frame(x, mo, x_mo = paste0(x, mo), stringsAsFactors = FALSE))
|
||||
x <- df$x
|
||||
mo <- df$mo
|
||||
|
||||
@@ -754,7 +724,7 @@ exec_as.rsi <- function(method,
|
||||
x <- as.disk(x) # when as.rsi.disk is called directly
|
||||
}
|
||||
|
||||
warned <- FALSE
|
||||
rise_warning <- FALSE
|
||||
method_param <- toupper(method)
|
||||
|
||||
genera <- mo_genus(mo, language = NULL)
|
||||
@@ -799,13 +769,6 @@ exec_as.rsi <- function(method,
|
||||
lookup_lancefield <- paste(mo_lancefield, ab)
|
||||
lookup_other <- paste(mo_other, ab)
|
||||
|
||||
if (length(unique(paste(trans$mo, trans$ab))) == length(unique(paste(trans$mo, trans$ab, trans$uti))) &&
|
||||
any(trans$uti == TRUE, na.rm = TRUE) && all(uti == FALSE)) {
|
||||
message_("WARNING.", add_fn = list(font_yellow, font_bold), as_note = FALSE)
|
||||
warning_("Introducing NA: interpretation of ", font_bold(ab_name(ab, tolower = TRUE)), " for some microorganisms is only available for (uncomplicated) urinary tract infections (UTI). Use argument `uti` to set which isolates are from urine. See ?as.rsi.", call = FALSE)
|
||||
warned <- TRUE
|
||||
}
|
||||
|
||||
any_is_intrinsic_resistant <- FALSE
|
||||
|
||||
for (i in seq_len(length(x))) {
|
||||
@@ -815,7 +778,7 @@ exec_as.rsi <- function(method,
|
||||
if (isTRUE(add_intrinsic_resistance) & is_intrinsic_r) {
|
||||
if (guideline_coerced %unlike% "EUCAST") {
|
||||
if (message_not_thrown_before("as.rsi", "msg2")) {
|
||||
warning_("Using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.", call = FALSE)
|
||||
warning_("in `as.rsi()`: using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.")
|
||||
}
|
||||
} else {
|
||||
new_rsi[i] <- "R"
|
||||
@@ -824,7 +787,7 @@ exec_as.rsi <- function(method,
|
||||
}
|
||||
|
||||
get_record <- trans %pm>%
|
||||
# no subsetting to UTI for now
|
||||
# no subsetting to UTI here
|
||||
subset(lookup %in% c(lookup_mo[i],
|
||||
lookup_genus[i],
|
||||
lookup_family[i],
|
||||
@@ -833,6 +796,11 @@ exec_as.rsi <- function(method,
|
||||
lookup_lancefield[i],
|
||||
lookup_other[i]))
|
||||
|
||||
if (any(get_record$uti == TRUE, na.rm = TRUE) && message_not_thrown_before("as.rsi", "msg3", ab)) {
|
||||
warning_("in `as.rsi()`: interpretation of ", font_bold(ab_name(ab, tolower = TRUE)), " is only available for (uncomplicated) urinary tract infections (UTI) for some microorganisms. Use argument `uti` to set which isolates are from urine. See ?as.rsi.")
|
||||
rise_warning <- TRUE
|
||||
}
|
||||
|
||||
if (isTRUE(uti[i])) {
|
||||
get_record <- get_record %pm>%
|
||||
# be as specific as possible (i.e. prefer species over genus):
|
||||
@@ -843,7 +811,7 @@ exec_as.rsi <- function(method,
|
||||
pm_filter(uti == FALSE) %pm>% # 'uti' is a column in rsi_translation
|
||||
pm_arrange(rank_index)
|
||||
}
|
||||
|
||||
|
||||
get_record <- get_record[1L, , drop = FALSE]
|
||||
|
||||
if (NROW(get_record) > 0) {
|
||||
@@ -872,20 +840,21 @@ exec_as.rsi <- function(method,
|
||||
|
||||
if (any_is_intrinsic_resistant & guideline_coerced %like% "EUCAST" & !isTRUE(add_intrinsic_resistance)) {
|
||||
# found some intrinsic resistance, but was not applied
|
||||
message_("WARNING.", add_fn = list(font_yellow, font_bold), as_note = FALSE)
|
||||
if (message_not_thrown_before("as.rsi", "msg3")) {
|
||||
warning_("Found intrinsic resistance in some bug/drug combinations, although it was not applied.\nUse `as.rsi(..., add_intrinsic_resistance = TRUE)` to apply it.", call = FALSE)
|
||||
if (message_not_thrown_before("as.rsi", "msg4")) {
|
||||
warning_("in `as.rsi()`: found intrinsic resistance in some bug/drug combinations, although it was not applied.\nUse `as.rsi(..., add_intrinsic_resistance = TRUE)` to apply it.")
|
||||
}
|
||||
warned <- TRUE
|
||||
rise_warning <- TRUE
|
||||
}
|
||||
|
||||
new_rsi <- x_bak %pm>%
|
||||
pm_left_join(data.frame(x_mo = paste0(df$x, df$mo), new_rsi,
|
||||
pm_left_join(data.frame(x_mo = paste0(x, mo), new_rsi,
|
||||
stringsAsFactors = FALSE),
|
||||
by = "x_mo") %pm>%
|
||||
pm_pull(new_rsi)
|
||||
|
||||
if (warned == FALSE) {
|
||||
if (isTRUE(rise_warning)) {
|
||||
message_("WARNING.", add_fn = list(font_yellow, font_bold), as_note = FALSE)
|
||||
} else {
|
||||
message_(" OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||
}
|
||||
|
||||
@@ -937,13 +906,13 @@ freq.rsi <- function(x, ...) {
|
||||
.add_header = list(
|
||||
Drug = paste0(ab_name(ab, language = NULL), " (", ab, ", ", paste(ab_atc(ab), collapse = "/"), ")"),
|
||||
`Drug group` = ab_group(ab, language = NULL),
|
||||
`%SI` = percentage(susceptibility(x, minimum = 0, as_percent = FALSE),
|
||||
digits = digits)))
|
||||
`%SI` = trimws(percentage(susceptibility(x, minimum = 0, as_percent = FALSE),
|
||||
digits = digits))))
|
||||
} else {
|
||||
cleaner::freq.default(x = x, ...,
|
||||
.add_header = list(
|
||||
`%SI` = percentage(susceptibility(x, minimum = 0, as_percent = FALSE),
|
||||
digits = digits)))
|
||||
`%SI` = trimws(percentage(susceptibility(x, minimum = 0, as_percent = FALSE),
|
||||
digits = digits))))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -95,7 +95,7 @@ rsi_calc <- function(...,
|
||||
}
|
||||
|
||||
if (is.null(x)) {
|
||||
warning_("argument is NULL (check if columns exist): returning NA", call = FALSE)
|
||||
warning_("argument is NULL (check if columns exist): returning NA")
|
||||
if (as_percent == TRUE) {
|
||||
return(NA_character_)
|
||||
} else {
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
BIN
R/sysdata.rda
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -193,7 +193,7 @@ translate_AMR <- function(from,
|
||||
any_form_in_patterns <- tryCatch(
|
||||
any(from_unique %like% paste0("(", paste(gsub(" +\\(.*", "", df_trans$pattern), collapse = "|"), ")")),
|
||||
error = function(e) {
|
||||
warning_("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).", call = FALSE)
|
||||
warning_("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).")
|
||||
return(FALSE)
|
||||
})
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -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.
|
||||
|
40
R/zzz.R
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -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`)
|
||||
@@ -57,10 +62,12 @@ if (utf8_supported && !is_latex) {
|
||||
s3_register("cleaner::freq", "mo")
|
||||
s3_register("cleaner::freq", "rsi")
|
||||
# Support for skim() from the skimr package
|
||||
s3_register("skimr::get_skimmers", "mo")
|
||||
s3_register("skimr::get_skimmers", "rsi")
|
||||
s3_register("skimr::get_skimmers", "mic")
|
||||
s3_register("skimr::get_skimmers", "disk")
|
||||
if (pkg_is_available("skimr", also_load = FALSE, min_version = "2.0.0")) {
|
||||
s3_register("skimr::get_skimmers", "mo")
|
||||
s3_register("skimr::get_skimmers", "rsi")
|
||||
s3_register("skimr::get_skimmers", "mic")
|
||||
s3_register("skimr::get_skimmers", "disk")
|
||||
}
|
||||
# Support for autoplot() from the ggplot2 package
|
||||
s3_register("ggplot2::autoplot", "rsi")
|
||||
s3_register("ggplot2::autoplot", "mic")
|
||||
@@ -109,21 +116,7 @@ if (utf8_supported && !is_latex) {
|
||||
# Helper functions --------------------------------------------------------
|
||||
|
||||
create_AB_lookup <- function() {
|
||||
AB_lookup <- AMR::antibiotics
|
||||
AB_lookup$generalised_name <- generalise_antibiotic_name(AB_lookup$name)
|
||||
AB_lookup$generalised_synonyms <- lapply(AB_lookup$synonyms, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_abbreviations <- lapply(AB_lookup$abbreviations, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_loinc <- lapply(AB_lookup$loinc, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_all <- unname(lapply(as.list(as.data.frame(t(AB_lookup[,
|
||||
c("ab", "atc", "cid", "name",
|
||||
colnames(AB_lookup)[colnames(AB_lookup) %like% "generalised"]),
|
||||
drop = FALSE]),
|
||||
stringsAsFactors = FALSE)),
|
||||
function(x) {
|
||||
x <- generalise_antibiotic_name(unname(unlist(x)))
|
||||
x[x != ""]
|
||||
}))
|
||||
AB_lookup
|
||||
cbind(AMR::antibiotics, AB_LOOKUP)
|
||||
}
|
||||
|
||||
create_MO_lookup <- function() {
|
||||
@@ -138,12 +131,7 @@ create_MO_lookup <- function() {
|
||||
MO_lookup[which(is.na(MO_lookup$kingdom_index)), "kingdom_index"] <- 5
|
||||
|
||||
# use this paste instead of `fullname` to work with Viridans Group Streptococci, etc.
|
||||
MO_lookup$fullname_lower <- tolower(trimws(paste(MO_lookup$genus,
|
||||
MO_lookup$species,
|
||||
MO_lookup$subspecies)))
|
||||
ind <- MO_lookup$genus == "" | grepl("^[(]unknown ", MO_lookup$fullname, perl = TRUE)
|
||||
MO_lookup[ind, "fullname_lower"] <- tolower(MO_lookup[ind, "fullname"])
|
||||
MO_lookup$fullname_lower <- trimws(gsub("[^.a-z0-9/ \\-]+", "", MO_lookup$fullname_lower, perl = TRUE))
|
||||
MO_lookup$fullname_lower <- MO_FULLNAME_LOWER
|
||||
|
||||
# add a column with only "e coli" like combinations
|
||||
MO_lookup$g_species <- gsub("^([a-z])[a-z]+ ([a-z]+) ?.*", "\\1 \\2", MO_lookup$fullname_lower, perl = TRUE)
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||

|
||||
[](https://www.codefactor.io/repository/github/msberends/amr)
|
||||
[](https://codecov.io/gh/msberends/AMR?branch=main)
|
||||
[](https://app.codecov.io/gh/msberends/AMR?branch=main)
|
||||
|
||||
<img src="https://msberends.github.io/AMR/AMR_intro.svg" align="center" height="300px" />
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -1 +1,2 @@
|
||||
* This package now has a data folder size of ~2.8 MB (this was ~5.6 MB), which will return a NOTE on R CMD CHECK. This package size is needed to provide users reference data for the complete taxonomy of microorganisms - one of the most important features of this package, following 15 previous releases of this package. All data sets were compressed using `compression = "xz"` to make them as small as possible.
|
||||
Extra release for fixing image options, as requested by CRAN team on 17 February 2022 (Kurt Hornik).
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -122,9 +122,21 @@ create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
|
||||
"mo", drop = TRUE]
|
||||
}
|
||||
}
|
||||
create_MO_fullname_lower <- function() {
|
||||
MO_lookup <- AMR::microorganisms
|
||||
# use this paste instead of `fullname` to work with Viridans Group Streptococci, etc.
|
||||
MO_lookup$fullname_lower <- tolower(trimws(paste(MO_lookup$genus,
|
||||
MO_lookup$species,
|
||||
MO_lookup$subspecies)))
|
||||
ind <- MO_lookup$genus == "" | grepl("^[(]unknown ", MO_lookup$fullname, perl = TRUE)
|
||||
MO_lookup[ind, "fullname_lower"] <- tolower(MO_lookup[ind, "fullname"])
|
||||
MO_lookup$fullname_lower <- trimws(gsub("[^.a-z0-9/ \\-]+", "", MO_lookup$fullname_lower, perl = TRUE))
|
||||
MO_lookup$fullname_lower
|
||||
}
|
||||
MO_CONS <- create_species_cons_cops("CoNS")
|
||||
MO_COPS <- create_species_cons_cops("CoPS")
|
||||
MO_STREP_ABCG <- as.mo(MO_lookup[which(MO_lookup$genus == "Streptococcus"), "mo", drop = TRUE], Lancefield = TRUE) %in% c("B_STRPT_GRPA", "B_STRPT_GRPB", "B_STRPT_GRPC", "B_STRPT_GRPG")
|
||||
MO_FULLNAME_LOWER <- create_MO_fullname_lower()
|
||||
|
||||
# antibiotic groups
|
||||
# (these will also be used for eucast_rules() and understanding data-raw/eucast_rules.tsv)
|
||||
@@ -160,6 +172,24 @@ AB_BETALACTAMS <- c(AB_PENICILLINS, AB_CEPHALOSPORINS, AB_CARBAPENEMS)
|
||||
# this will be used for documentation:
|
||||
DEFINED_AB_GROUPS <- ls(envir = globalenv())
|
||||
DEFINED_AB_GROUPS <- DEFINED_AB_GROUPS[!DEFINED_AB_GROUPS %in% globalenv_before_ab]
|
||||
create_AB_lookup <- function() {
|
||||
AB_lookup <- AMR::antibiotics
|
||||
AB_lookup$generalised_name <- generalise_antibiotic_name(AB_lookup$name)
|
||||
AB_lookup$generalised_synonyms <- lapply(AB_lookup$synonyms, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_abbreviations <- lapply(AB_lookup$abbreviations, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_loinc <- lapply(AB_lookup$loinc, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_all <- unname(lapply(as.list(as.data.frame(t(AB_lookup[,
|
||||
c("ab", "atc", "cid", "name",
|
||||
colnames(AB_lookup)[colnames(AB_lookup) %like% "generalised"]),
|
||||
drop = FALSE]),
|
||||
stringsAsFactors = FALSE)),
|
||||
function(x) {
|
||||
x <- generalise_antibiotic_name(unname(unlist(x)))
|
||||
x[x != ""]
|
||||
}))
|
||||
AB_lookup[, colnames(AB_lookup)[colnames(AB_lookup) %like% "^generalised"]]
|
||||
}
|
||||
AB_LOOKUP <- create_AB_lookup()
|
||||
|
||||
# Export to package as internal data ----
|
||||
usethis::use_data(EUCAST_RULES_DF,
|
||||
@@ -169,6 +199,8 @@ usethis::use_data(EUCAST_RULES_DF,
|
||||
MO_CONS,
|
||||
MO_COPS,
|
||||
MO_STREP_ABCG,
|
||||
MO_FULLNAME_LOWER,
|
||||
AB_LOOKUP,
|
||||
AB_AMINOGLYCOSIDES,
|
||||
AB_AMINOPENICILLINS,
|
||||
AB_ANTIFUNGALS,
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
@@ -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
|
||||
#
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# (c) 2018-2022 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
|
@@ -43,7 +43,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="https://msberends.github.io/AMR/index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.7.1.9071</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -205,12 +205,14 @@ Content not found. Please use links in the navbar.
|
||||
|
||||
<footer><div class="copyright">
|
||||
<p></p>
|
||||
<p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein, Erwin E. A. Hassing.</p>
|
||||
<p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein,
|
||||
Erwin E. A. Hassing.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p></p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.0.</p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a>
|
||||
2.0.2.</p>
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
|
@@ -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.7.1.9071</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -416,11 +416,13 @@ END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
<footer><div class="copyright">
|
||||
<p></p><p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein, Erwin E. A. Hassing.</p>
|
||||
<p></p><p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein,
|
||||
Erwin E. A. Hassing.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.0.</p>
|
||||
<p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a>
|
||||
2.0.2.</p>
|
||||
</div>
|
||||
|
||||
</footer></div>
|
||||
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 48 KiB |
@@ -1,12 +0,0 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@@ -1,12 +0,0 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@@ -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.7.1.9068</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -201,18 +201,39 @@
|
||||
<div class="section level2">
|
||||
<h2 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
|
||||
</h2>
|
||||
<p>What are EUCAST rules? The European Committee on Antimicrobial Susceptibility Testing (EUCAST) states <a href="https://www.eucast.org/expert_rules_and_intrinsic_resistance/" class="external-link">on their website</a>:</p>
|
||||
<p>What are EUCAST rules? The European Committee on Antimicrobial
|
||||
Susceptibility Testing (EUCAST) states <a href="https://www.eucast.org/expert_rules_and_intrinsic_resistance/" class="external-link">on
|
||||
their website</a>:</p>
|
||||
<blockquote>
|
||||
<p><em>EUCAST expert rules are a tabulated collection of expert knowledge on intrinsic resistances, exceptional resistance phenotypes and interpretive rules that may be applied to antimicrobial susceptibility testing in order to reduce errors and make appropriate recommendations for reporting particular resistances.</em></p>
|
||||
<p><em>EUCAST expert rules are a tabulated collection of expert
|
||||
knowledge on intrinsic resistances, exceptional resistance phenotypes
|
||||
and interpretive rules that may be applied to antimicrobial
|
||||
susceptibility testing in order to reduce errors and make appropriate
|
||||
recommendations for reporting particular resistances.</em></p>
|
||||
</blockquote>
|
||||
<p>In Europe, a lot of medical microbiological laboratories already apply these rules (<a href="https://www.eurosurveillance.org/content/10.2807/1560-7917.ES2015.20.2.21008" class="external-link">Brown <em>et al.</em>, 2015</a>). Our package features their latest insights on intrinsic resistance and unusual phenotypes (v3.3, 2021).</p>
|
||||
<p>Moreover, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function we use for this purpose can also apply additional rules, like forcing <help title="ATC: J01CA01">ampicillin</help> = R in isolates when <help title="ATC: J01CR02">amoxicillin/clavulanic acid</help> = R.</p>
|
||||
<p>In Europe, a lot of medical microbiological laboratories already
|
||||
apply these rules (<a href="https://www.eurosurveillance.org/content/10.2807/1560-7917.ES2015.20.2.21008" class="external-link">Brown
|
||||
<em>et al.</em>, 2015</a>). Our package features their latest insights
|
||||
on intrinsic resistance and unusual phenotypes (v3.3, 2021).</p>
|
||||
<p>Moreover, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function we use for this
|
||||
purpose can also apply additional rules, like forcing
|
||||
<help title="ATC: J01CA01">ampicillin</help> = R in isolates when
|
||||
<help title="ATC: J01CR02">amoxicillin/clavulanic acid</help> = R.</p>
|
||||
</div>
|
||||
<div class="section level2">
|
||||
<h2 id="examples">Examples<a class="anchor" aria-label="anchor" href="#examples"></a>
|
||||
</h2>
|
||||
<p>These rules can be used to discard impossible bug-drug combinations in your data. For example, <em>Klebsiella</em> produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of <em>Klebsiella</em> is resistant to ampicillin.</p>
|
||||
<p>Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, <em>Klebsiella</em>). EUCAST expert rules solve this, that can be applied using <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:</p>
|
||||
<p>These rules can be used to discard impossible bug-drug combinations
|
||||
in your data. For example, <em>Klebsiella</em> produces beta-lactamase
|
||||
that prevents ampicillin (or amoxicillin) from working against it. In
|
||||
other words, practically every strain of <em>Klebsiella</em> is
|
||||
resistant to ampicillin.</p>
|
||||
<p>Sometimes, laboratory data can still contain such strains with
|
||||
ampicillin being susceptible to ampicillin. This could be because an
|
||||
antibiogram is available before an identification is available, and the
|
||||
antibiogram is then not re-interpreted based on the identification
|
||||
(namely, <em>Klebsiella</em>). EUCAST expert rules solve this, that can
|
||||
be applied using <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">oops</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>mo <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">"Klebsiella"</span>,
|
||||
<span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||
@@ -226,7 +247,10 @@
|
||||
<span class="co"># mo ampicillin</span>
|
||||
<span class="co"># 1 Klebsiella R</span>
|
||||
<span class="co"># 2 Escherichia S</span></code></pre></div>
|
||||
<p>A more convenient function is <code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> that uses the same guideline, but allows to check for one or more specific microorganisms or antibiotics:</p>
|
||||
<p>A more convenient function is
|
||||
<code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> that uses the same guideline,
|
||||
but allows to check for one or more specific microorganisms or
|
||||
antibiotics:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</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">"Klebsiella"</span>, <span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||
<span class="st">"ampicillin"</span><span class="op">)</span>
|
||||
@@ -235,7 +259,11 @@
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="st">"Klebsiella"</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">"ampicillin"</span>, <span class="st">"kanamycin"</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="co"># [1] TRUE FALSE</span></code></pre></div>
|
||||
<p>EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called <em>interpretive reading</em>, is basically a form of imputation, and is part of the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function as well:</p>
|
||||
<p>EUCAST rules can not only be used for correction, they can also be
|
||||
used for filling in known resistance and susceptibility based on results
|
||||
of other antimicrobials drugs. This process is called <em>interpretive
|
||||
reading</em>, is basically a form of imputation, and is part of the
|
||||
<code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function as well:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>mo <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">"Staphylococcus aureus"</span>,
|
||||
<span class="st">"Enterococcus faecalis"</span>,
|
||||
@@ -397,12 +425,14 @@
|
||||
|
||||
<footer><div class="copyright">
|
||||
<p></p>
|
||||
<p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein, Erwin E. A. Hassing.</p>
|
||||
<p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein,
|
||||
Erwin E. A. Hassing.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p></p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.0.</p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a>
|
||||
2.0.2.</p>
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
|
@@ -1,12 +0,0 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@@ -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.7.1.9068</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -188,7 +188,8 @@
|
||||
</header><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to determine multi-drug resistance (MDR)</h1>
|
||||
<h1 data-toc-skip>How to determine multi-drug resistance
|
||||
(MDR)</h1>
|
||||
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/HEAD/vignettes/MDR.Rmd" class="external-link"><code>vignettes/MDR.Rmd</code></a></small>
|
||||
@@ -198,54 +199,87 @@
|
||||
|
||||
|
||||
|
||||
<p>With the function <code><a href="../reference/mdro.html">mdro()</a></code>, you can determine which micro-organisms are multi-drug resistant organisms (MDRO).</p>
|
||||
<p>With the function <code><a href="../reference/mdro.html">mdro()</a></code>, you can determine which
|
||||
micro-organisms are multi-drug resistant organisms (MDRO).</p>
|
||||
<div class="section level3">
|
||||
<h3 id="type-of-input">Type of input<a class="anchor" aria-label="anchor" href="#type-of-input"></a>
|
||||
</h3>
|
||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function takes a data set as input, such as a regular <code>data.frame</code>. It tries to automatically determine the right columns for info about your isolates, such as the name of the species and all columns with results of antimicrobial agents. See the help page for more info about how to set the right settings for your data with the command <code><a href="../reference/mdro.html">?mdro</a></code>.</p>
|
||||
<p>For WHONET data (and most other data), all settings are automatically set correctly.</p>
|
||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function takes a data set as input, such as a
|
||||
regular <code>data.frame</code>. It tries to automatically determine the
|
||||
right columns for info about your isolates, such as the name of the
|
||||
species and all columns with results of antimicrobial agents. See the
|
||||
help page for more info about how to set the right settings for your
|
||||
data with the command <code><a href="../reference/mdro.html">?mdro</a></code>.</p>
|
||||
<p>For WHONET data (and most other data), all settings are automatically
|
||||
set correctly.</p>
|
||||
</div>
|
||||
<div class="section level3">
|
||||
<h3 id="guidelines">Guidelines<a class="anchor" aria-label="anchor" href="#guidelines"></a>
|
||||
</h3>
|
||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function support multiple guidelines. You can select a guideline with the <code>guideline</code> parameter. Currently supported guidelines are (case-insensitive):</p>
|
||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function support multiple guidelines. You can
|
||||
select a guideline with the <code>guideline</code> parameter. Currently
|
||||
supported guidelines are (case-insensitive):</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p><code>guideline = "CMI2012"</code> (default)</p>
|
||||
<p>Magiorakos AP, Srinivasan A <em>et al.</em> “Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance.” Clinical Microbiology and Infection (2012) (<a href="https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext" class="external-link">link</a>)</p>
|
||||
<p>Magiorakos AP, Srinivasan A <em>et al.</em> “Multidrug-resistant,
|
||||
extensively drug-resistant and pandrug-resistant bacteria: an
|
||||
international expert proposal for interim standard definitions for
|
||||
acquired resistance.” Clinical Microbiology and Infection (2012) (<a href="https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext" class="external-link">link</a>)</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><code>guideline = "EUCAST3.2"</code> (or simply <code>guideline = "EUCAST"</code>)</p>
|
||||
<p>The European international guideline - EUCAST Expert Rules Version 3.2 “Intrinsic Resistance and Unusual Phenotypes” (<a href="https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf" class="external-link">link</a>)</p>
|
||||
<p><code>guideline = "EUCAST3.2"</code> (or simply
|
||||
<code>guideline = "EUCAST"</code>)</p>
|
||||
<p>The European international guideline - EUCAST Expert Rules Version
|
||||
3.2 “Intrinsic Resistance and Unusual Phenotypes” (<a href="https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf" class="external-link">link</a>)</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><code>guideline = "EUCAST3.1"</code></p>
|
||||
<p>The European international guideline - EUCAST Expert Rules Version 3.1 “Intrinsic Resistance and Exceptional Phenotypes Tables” (<a href="https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf" class="external-link">link</a>)</p>
|
||||
<p>The European international guideline - EUCAST Expert Rules Version
|
||||
3.1 “Intrinsic Resistance and Exceptional Phenotypes Tables” (<a href="https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf" class="external-link">link</a>)</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><code>guideline = "TB"</code></p>
|
||||
<p>The international guideline for multi-drug resistant tuberculosis - World Health Organization “Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis” (<a href="https://www.who.int/tb/publications/pmdt_companionhandbook/en/" class="external-link">link</a>)</p>
|
||||
<p>The international guideline for multi-drug resistant tuberculosis -
|
||||
World Health Organization “Companion handbook to the WHO guidelines for
|
||||
the programmatic management of drug-resistant tuberculosis” (<a href="https://www.who.int/tb/publications/pmdt_companionhandbook/en/" class="external-link">link</a>)</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><code>guideline = "MRGN"</code></p>
|
||||
<p>The German national guideline - Mueller <em>et al.</em> (2015) Antimicrobial Resistance and Infection Control 4:7. DOI: 10.1186/s13756-015-0047-6</p>
|
||||
<p>The German national guideline - Mueller <em>et al.</em> (2015)
|
||||
Antimicrobial Resistance and Infection Control 4:7. DOI:
|
||||
10.1186/s13756-015-0047-6</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><code>guideline = "BRMO"</code></p>
|
||||
<p>The Dutch national guideline - Rijksinstituut voor Volksgezondheid en Milieu “WIP-richtlijn BRMO (Bijzonder Resistente Micro-Organismen) (ZKH)” (<a href="https://www.rivm.nl/wip-richtlijn-brmo-bijzonder-resistente-micro-organismen-zkh" class="external-link">link</a>)</p>
|
||||
<p>The Dutch national guideline - Rijksinstituut voor Volksgezondheid en
|
||||
Milieu “WIP-richtlijn BRMO (Bijzonder Resistente Micro-Organismen)
|
||||
(ZKH)” (<a href="https://www.rivm.nl/wip-richtlijn-brmo-bijzonder-resistente-micro-organismen-zkh" class="external-link">link</a>)</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Please suggest your own (country-specific) guidelines by letting us know: <a href="https://github.com/msberends/AMR/issues/new" class="external-link uri">https://github.com/msberends/AMR/issues/new</a>.</p>
|
||||
<p>Please suggest your own (country-specific) guidelines by letting us
|
||||
know: <a href="https://github.com/msberends/AMR/issues/new" class="external-link uri">https://github.com/msberends/AMR/issues/new</a>.</p>
|
||||
<div class="section level4">
|
||||
<h4 id="custom-guidelines">Custom Guidelines<a class="anchor" aria-label="anchor" href="#custom-guidelines"></a>
|
||||
</h4>
|
||||
<p>You can also use your own custom guideline. Custom guidelines can be set with the <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data.</p>
|
||||
<p>If you are familiar with <code><a href="https://dplyr.tidyverse.org/reference/case_when.html" class="external-link">case_when()</a></code> of the <code>dplyr</code> package, you will recognise the input method to set your own rules. Rules must be set using what R considers to be the ‘formula notation’:</p>
|
||||
<p>You can also use your own custom guideline. Custom guidelines can be
|
||||
set with the <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function. This is of
|
||||
great importance if you have custom rules to determine MDROs in your
|
||||
hospital, e.g., rules that are dependent on ward, state of contact
|
||||
isolation or other variables in your data.</p>
|
||||
<p>If you are familiar with <code><a href="https://dplyr.tidyverse.org/reference/case_when.html" class="external-link">case_when()</a></code> of the
|
||||
<code>dplyr</code> package, you will recognise the input method to set
|
||||
your own rules. Rules must be set using what R considers to be the
|
||||
‘formula notation’:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">custom</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">custom_mdro_guideline</a></span><span class="op">(</span><span class="va">CIP</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type A"</span>,
|
||||
<span class="va">ERY</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type B"</span><span class="op">)</span></code></pre></div>
|
||||
<p>If a row/an isolate matches the first rule, the value after the first <code>~</code> (in this case <em>‘Elderly Type A’</em>) will be set as MDRO value. Otherwise, the second rule will be tried and so on. The maximum number of rules is unlimited.</p>
|
||||
<p>You can print the rules set in the console for an overview. Colours will help reading it if your console supports colours.</p>
|
||||
<p>If a row/an isolate matches the first rule, the value after the first
|
||||
<code>~</code> (in this case <em>‘Elderly Type A’</em>) will be set as
|
||||
MDRO value. Otherwise, the second rule will be tried and so on. The
|
||||
maximum number of rules is unlimited.</p>
|
||||
<p>You can print the rules set in the console for an overview. Colours
|
||||
will help reading it if your console supports colours.</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">custom</span>
|
||||
<span class="co"># A set of custom MDRO rules:</span>
|
||||
@@ -255,7 +289,8 @@
|
||||
<span class="co"># </span>
|
||||
<span class="co"># Unmatched rows will return NA.</span>
|
||||
<span class="co"># Results will be of class <factor>, with ordered levels: Negative < Elderly Type A < Elderly Type B</span></code></pre></div>
|
||||
<p>The outcome of the function can be used for the <code>guideline</code> argument in the <code><a href="../reference/mdro.html">mdro()</a></code> function:</p>
|
||||
<p>The outcome of the function can be used for the
|
||||
<code>guideline</code> argument in the <code><a href="../reference/mdro.html">mdro()</a></code> function:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">example_isolates</span>, guideline <span class="op">=</span> <span class="va">custom</span><span class="op">)</span>
|
||||
<span class="co"># Determining MDROs based on custom rules, resulting in factor levels:</span>
|
||||
@@ -266,14 +301,25 @@
|
||||
<span class="co"># x</span>
|
||||
<span class="co"># Negative Elderly Type A Elderly Type B </span>
|
||||
<span class="co"># 1070 198 732</span></code></pre></div>
|
||||
<p>The rules set (the <code>custom</code> object in this case) could be exported to a shared file location using <code><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">saveRDS()</a></code> if you collaborate with multiple users. The custom rules set could then be imported using <code><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">readRDS()</a></code>.</p>
|
||||
<p>The rules set (the <code>custom</code> object in this case) could be
|
||||
exported to a shared file location using <code><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">saveRDS()</a></code> if you
|
||||
collaborate with multiple users. The custom rules set could then be
|
||||
imported using <code><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">readRDS()</a></code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section level3">
|
||||
<h3 id="examples">Examples<a class="anchor" aria-label="anchor" href="#examples"></a>
|
||||
</h3>
|
||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function always returns an ordered <code>factor</code> for predefined guidelines. For example, the output of the default guideline by Magiorakos <em>et al.</em> returns a <code>factor</code> with levels ‘Negative’, ‘MDR’, ‘XDR’ or ‘PDR’ in that order.</p>
|
||||
<p>The next example uses the <code>example_isolates</code> data set. This is a data set included with this package and contains full antibiograms of 2,000 microbial isolates. It reflects reality and can be used to practise AMR data analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:</p>
|
||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function always returns an ordered
|
||||
<code>factor</code> for predefined guidelines. For example, the output
|
||||
of the default guideline by Magiorakos <em>et al.</em> returns a
|
||||
<code>factor</code> with levels ‘Negative’, ‘MDR’, ‘XDR’ or ‘PDR’ in
|
||||
that order.</p>
|
||||
<p>The next example uses the <code>example_isolates</code> data set.
|
||||
This is a data set included with this package and contains full
|
||||
antibiograms of 2,000 microbial isolates. It reflects reality and can be
|
||||
used to practise AMR data analysis. If we test the MDR/XDR/PDR guideline
|
||||
on this data set, we get:</p>
|
||||
<div class="sourceCode" id="cb4"><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="co"># to support pipes: %>%</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://github.com/msberends/cleaner" class="external-link">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></code></pre></div>
|
||||
@@ -295,18 +341,34 @@
|
||||
<span class="co"># Table 3 - Enterobacteriaceae... OK.</span>
|
||||
<span class="co"># Table 4 - Pseudomonas aeruginosa... OK.</span>
|
||||
<span class="co"># Table 5 - Acinetobacter spp.... OK.</span>
|
||||
<span class="co"># Warning: NA introduced for isolates where the available percentage of antimicrobial</span>
|
||||
<span class="co"># classes was below 50% (set with `pct_required_classes`)</span></code></pre></div>
|
||||
<p>Only results with ‘R’ are considered as resistance. Use <code>combine_SI = FALSE</code> to also consider ‘I’ as resistance.</p>
|
||||
<p>Determining multidrug-resistant organisms (MDRO), according to: Guideline: Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance. Author(s): Magiorakos AP, Srinivasan A, Carey RB, …, Vatopoulos A, Weber JT, Monnet DL Source: Clinical Microbiology and Infection 18:3, 2012; doi: 10.1111/j.1469-0691.2011.03570.x</p>
|
||||
<span class="co"># Warning: in `mdro()`: NA introduced for isolates where the available percentage of</span>
|
||||
<span class="co"># antimicrobial classes was below 50% (set with `pct_required_classes`)</span></code></pre></div>
|
||||
<p>Only results with ‘R’ are considered as resistance. Use
|
||||
<code>combine_SI = FALSE</code> to also consider ‘I’ as resistance.</p>
|
||||
<p>Determining multidrug-resistant organisms (MDRO), according to:
|
||||
Guideline: Multidrug-resistant, extensively drug-resistant and
|
||||
pandrug-resistant bacteria: an international expert proposal for interim
|
||||
standard definitions for acquired resistance. Author(s): Magiorakos AP,
|
||||
Srinivasan A, Carey RB, …, Vatopoulos A, Weber JT, Monnet DL Source:
|
||||
Clinical Microbiology and Infection 18:3, 2012; doi:
|
||||
10.1111/j.1469-0691.2011.03570.x</p>
|
||||
<p>(16 isolates had no test results)</p>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: factor > ordered (numeric)<br>
|
||||
Length: 2,000<br>
|
||||
Levels: 4: Negative < Multi-drug-resistant (MDR) < Extensively drug-resistant …<br>
|
||||
Levels: 4: Negative < Multi-drug-resistant (MDR) < Extensively
|
||||
drug-resistant …<br>
|
||||
Available: 1,729 (86.45%, NA: 271 = 13.55%)<br>
|
||||
Unique: 2</p>
|
||||
<table class="table">
|
||||
<table style="width:100%;" class="table">
|
||||
<colgroup>
|
||||
<col width="4%">
|
||||
<col width="38%">
|
||||
<col width="9%">
|
||||
<col width="12%">
|
||||
<col width="16%">
|
||||
<col width="19%">
|
||||
</colgroup>
|
||||
<thead><tr class="header">
|
||||
<th align="left"></th>
|
||||
<th align="left">Item</th>
|
||||
@@ -320,21 +382,22 @@ Unique: 2</p>
|
||||
<td align="left">1</td>
|
||||
<td align="left">Negative</td>
|
||||
<td align="right">1601</td>
|
||||
<td align="right">92.60%</td>
|
||||
<td align="right">92.6%</td>
|
||||
<td align="right">1601</td>
|
||||
<td align="right">92.60%</td>
|
||||
<td align="right">92.6%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">2</td>
|
||||
<td align="left">Multi-drug-resistant (MDR)</td>
|
||||
<td align="right">128</td>
|
||||
<td align="right">7.40%</td>
|
||||
<td align="right">7.4%</td>
|
||||
<td align="right">1729</td>
|
||||
<td align="right">100.00%</td>
|
||||
<td align="right">100.0%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>For another example, I will create a data set to determine multi-drug resistant TB:</p>
|
||||
<p>For another example, I will create a data set to determine multi-drug
|
||||
resistant TB:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># random_rsi() is a helper function to generate</span>
|
||||
<span class="co"># a random vector with values S, I and R</span>
|
||||
@@ -345,7 +408,8 @@ Unique: 2</p>
|
||||
pyrazinamide <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
moxifloxacin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
kanamycin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></code></pre></div>
|
||||
<p>Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same way:</p>
|
||||
<p>Because all column names are automatically verified for valid drug
|
||||
names or codes, this would have worked exactly the same way:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>RIF <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
INH <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
@@ -358,20 +422,21 @@ Unique: 2</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/head.html" class="external-link">head</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
||||
<span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span>
|
||||
<span class="co"># 1 R R I S I I</span>
|
||||
<span class="co"># 2 I I I I R S</span>
|
||||
<span class="co"># 3 I R S I R S</span>
|
||||
<span class="co"># 4 R S I I I R</span>
|
||||
<span class="co"># 5 S S R I I S</span>
|
||||
<span class="co"># 6 R R R I S R</span>
|
||||
<span class="co"># 1 I S I I S S</span>
|
||||
<span class="co"># 2 R S I S R R</span>
|
||||
<span class="co"># 3 I R I S R S</span>
|
||||
<span class="co"># 4 I I I R S R</span>
|
||||
<span class="co"># 5 R S I R S I</span>
|
||||
<span class="co"># 6 S S I S R R</span>
|
||||
<span class="co"># kanamycin</span>
|
||||
<span class="co"># 1 I</span>
|
||||
<span class="co"># 2 R</span>
|
||||
<span class="co"># 1 R</span>
|
||||
<span class="co"># 2 I</span>
|
||||
<span class="co"># 3 S</span>
|
||||
<span class="co"># 4 R</span>
|
||||
<span class="co"># 5 R</span>
|
||||
<span class="co"># 4 S</span>
|
||||
<span class="co"># 5 S</span>
|
||||
<span class="co"># 6 R</span></code></pre></div>
|
||||
<p>We can now add the interpretation of MDR-TB to our data set. You can use:</p>
|
||||
<p>We can now add the interpretation of MDR-TB to our data set. You can
|
||||
use:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">my_TB_data</span>, guideline <span class="op">=</span> <span class="st">"TB"</span><span class="op">)</span></code></pre></div>
|
||||
<p>or its shortcut <code><a href="../reference/mdro.html">mdr_tb()</a></code>:</p>
|
||||
@@ -397,10 +462,19 @@ Unique: 2</p>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: factor > ordered (numeric)<br>
|
||||
Length: 5,000<br>
|
||||
Levels: 5: Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant <…<br>
|
||||
Available: 5,000 (100.0%, NA: 0 = 0.0%)<br>
|
||||
Levels: 5: Negative < Mono-resistant < Poly-resistant <
|
||||
Multi-drug-resistant <…<br>
|
||||
Available: 5,000 (100%, NA: 0 = 0%)<br>
|
||||
Unique: 5</p>
|
||||
<table class="table">
|
||||
<table style="width:100%;" class="table">
|
||||
<colgroup>
|
||||
<col width="4%">
|
||||
<col width="38%">
|
||||
<col width="9%">
|
||||
<col width="12%">
|
||||
<col width="16%">
|
||||
<col width="19%">
|
||||
</colgroup>
|
||||
<thead><tr class="header">
|
||||
<th align="left"></th>
|
||||
<th align="left">Item</th>
|
||||
@@ -413,40 +487,40 @@ Unique: 5</p>
|
||||
<tr class="odd">
|
||||
<td align="left">1</td>
|
||||
<td align="left">Mono-resistant</td>
|
||||
<td align="right">3246</td>
|
||||
<td align="right">64.92%</td>
|
||||
<td align="right">3246</td>
|
||||
<td align="right">64.92%</td>
|
||||
<td align="right">3261</td>
|
||||
<td align="right">65.22%</td>
|
||||
<td align="right">3261</td>
|
||||
<td align="right">65.22%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">2</td>
|
||||
<td align="left">Negative</td>
|
||||
<td align="right">999</td>
|
||||
<td align="right">19.98%</td>
|
||||
<td align="right">4245</td>
|
||||
<td align="right">84.90%</td>
|
||||
<td align="right">987</td>
|
||||
<td align="right">19.74%</td>
|
||||
<td align="right">4248</td>
|
||||
<td align="right">84.96%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">3</td>
|
||||
<td align="left">Multi-drug-resistant</td>
|
||||
<td align="right">437</td>
|
||||
<td align="right">8.74%</td>
|
||||
<td align="right">4682</td>
|
||||
<td align="right">93.64%</td>
|
||||
<td align="right">4685</td>
|
||||
<td align="right">93.70%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">4</td>
|
||||
<td align="left">Poly-resistant</td>
|
||||
<td align="right">218</td>
|
||||
<td align="right">4.36%</td>
|
||||
<td align="right">4900</td>
|
||||
<td align="right">98.00%</td>
|
||||
<td align="right">4903</td>
|
||||
<td align="right">98.06%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">5</td>
|
||||
<td align="left">Extensively drug-resistant</td>
|
||||
<td align="right">100</td>
|
||||
<td align="right">2.00%</td>
|
||||
<td align="right">97</td>
|
||||
<td align="right">1.94%</td>
|
||||
<td align="right">5000</td>
|
||||
<td align="right">100.00%</td>
|
||||
</tr>
|
||||
@@ -465,12 +539,14 @@ Unique: 5</p>
|
||||
|
||||
<footer><div class="copyright">
|
||||
<p></p>
|
||||
<p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein, Erwin E. A. Hassing.</p>
|
||||
<p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein,
|
||||
Erwin E. A. Hassing.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p></p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.0.</p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a>
|
||||
2.0.2.</p>
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
|
@@ -1,12 +0,0 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@@ -1,12 +0,0 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@@ -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.7.1.9068</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -188,7 +188,8 @@
|
||||
</header><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to conduct principal component analysis (PCA) for AMR</h1>
|
||||
<h1 data-toc-skip>How to conduct principal component analysis
|
||||
(PCA) for AMR</h1>
|
||||
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/HEAD/vignettes/PCA.Rmd" class="external-link"><code>vignettes/PCA.Rmd</code></a></small>
|
||||
@@ -198,17 +199,19 @@
|
||||
|
||||
|
||||
|
||||
<p><strong>NOTE: This page will be updated soon, as the pca() function is currently being developed.</strong></p>
|
||||
<div class="section level1">
|
||||
<h1 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
|
||||
</h1>
|
||||
<p><strong>NOTE: This page will be updated soon, as the pca() function
|
||||
is currently being developed.</strong></p>
|
||||
<div class="section level2">
|
||||
<h2 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="section level1">
|
||||
<h1 id="transforming">Transforming<a class="anchor" aria-label="anchor" href="#transforming"></a>
|
||||
</h1>
|
||||
<p>For PCA, we need to transform our AMR data first. This is what the <code>example_isolates</code> data set in this package looks like:</p>
|
||||
<div class="section level2">
|
||||
<h2 id="transforming">Transforming<a class="anchor" aria-label="anchor" href="#transforming"></a>
|
||||
</h2>
|
||||
<p>For PCA, we need to transform our AMR data first. This is what the
|
||||
<code>example_isolates</code> data set in this package looks like:</p>
|
||||
<div class="sourceCode" id="cb1"><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>
|
||||
<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>
|
||||
<span class="fu"><a href="https://pillar.r-lib.org/reference/glimpse.html" class="external-link">glimpse</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
||||
<span class="co"># Rows: 2,000</span>
|
||||
@@ -262,7 +265,8 @@
|
||||
<span class="co"># $ COL <span style="color: #949494; font-style: italic;"><rsi></span> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, R…</span>
|
||||
<span class="co"># $ MUP <span style="color: #949494; font-style: italic;"><rsi></span> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ RIF <span style="color: #949494; font-style: italic;"><rsi></span> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R,…</span></code></pre></div>
|
||||
<p>Now to transform this to a data set with only resistance percentages per taxonomic order and genus:</p>
|
||||
<p>Now to transform this to a data set with only resistance percentages
|
||||
per taxonomic order and genus:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">resistance_data</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">%>%</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>order <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, <span class="co"># group on anything, like order</span>
|
||||
@@ -283,15 +287,18 @@
|
||||
<span class="co"># <span style="color: #BCBCBC;">5</span> Caryophanales Gemella <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span></span>
|
||||
<span class="co"># <span style="color: #BCBCBC;">6</span> Caryophanales Listeria <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span></span></code></pre></div>
|
||||
</div>
|
||||
<div class="section level1">
|
||||
<h1 id="perform-principal-component-analysis">Perform principal component analysis<a class="anchor" aria-label="anchor" href="#perform-principal-component-analysis"></a>
|
||||
</h1>
|
||||
<p>The new <code><a href="../reference/pca.html">pca()</a></code> function will automatically filter on rows that contain numeric values in all selected variables, so we now only need to do:</p>
|
||||
<div class="section level2">
|
||||
<h2 id="perform-principal-component-analysis">Perform principal component analysis<a class="anchor" aria-label="anchor" href="#perform-principal-component-analysis"></a>
|
||||
</h2>
|
||||
<p>The new <code><a href="../reference/pca.html">pca()</a></code> function will automatically filter on rows
|
||||
that contain numeric values in all selected variables, so we now only
|
||||
need to do:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">pca_result</span> <span class="op"><-</span> <span class="fu"><a href="../reference/pca.html">pca</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span>
|
||||
<span class="co"># ℹ Columns selected for PCA: "AMC", "CAZ", "CTX", "CXM", "GEN", "SXT", "TMP"</span>
|
||||
<span class="co"># and "TOB". Total observations available: 7.</span></code></pre></div>
|
||||
<p>The result can be reviewed with the good old <code><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary()</a></code> function:</p>
|
||||
<p>The result can be reviewed with the good old <code><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary()</a></code>
|
||||
function:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span>
|
||||
<span class="co"># Groups (n=4, named as 'order'):</span>
|
||||
@@ -303,15 +310,21 @@
|
||||
<span class="co"># Cumulative Proportion 0.5799 0.9330 0.9801 0.99446 0.99988 1.00000 1.000e+00</span></code></pre></div>
|
||||
<pre><code><span class="co"># Groups (n=4, named as 'order'):</span>
|
||||
<span class="co"># [1] "Caryophanales" "Enterobacterales" "Lactobacillales" "Pseudomonadales"</span></code></pre>
|
||||
<p>Good news. The first two components explain a total of 93.3% of the variance (see the PC1 and PC2 values of the <em>Proportion of Variance</em>. We can create a so-called biplot with the base R <code><a href="https://rdrr.io/r/stats/biplot.html" class="external-link">biplot()</a></code> function, to see which antimicrobial resistance per drug explain the difference per microorganism.</p>
|
||||
<p>Good news. The first two components explain a total of 93.3% of the
|
||||
variance (see the PC1 and PC2 values of the <em>Proportion of
|
||||
Variance</em>. We can create a so-called biplot with the base R
|
||||
<code><a href="https://rdrr.io/r/stats/biplot.html" class="external-link">biplot()</a></code> function, to see which antimicrobial resistance
|
||||
per drug explain the difference per microorganism.</p>
|
||||
</div>
|
||||
<div class="section level1">
|
||||
<h1 id="plotting-the-results">Plotting the results<a class="anchor" aria-label="anchor" href="#plotting-the-results"></a>
|
||||
</h1>
|
||||
<div class="section level2">
|
||||
<h2 id="plotting-the-results">Plotting the results<a class="anchor" aria-label="anchor" href="#plotting-the-results"></a>
|
||||
</h2>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/stats/biplot.html" class="external-link">biplot</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="PCA_files/figure-html/unnamed-chunk-5-1.png" width="750"></p>
|
||||
<p>But we can’t see the explanation of the points. Perhaps this works better with our new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function, that automatically adds the right labels and even groups:</p>
|
||||
<p>But we can’t see the explanation of the points. Perhaps this works
|
||||
better with our new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function, that
|
||||
automatically adds the right labels and even groups:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="PCA_files/figure-html/unnamed-chunk-6-1.png" width="750"></p>
|
||||
@@ -335,12 +348,14 @@
|
||||
|
||||
<footer><div class="copyright">
|
||||
<p></p>
|
||||
<p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein, Erwin E. A. Hassing.</p>
|
||||
<p>Developed by Matthijs S. Berends, Christian F. Luz, Dennis Souverein,
|
||||
Erwin E. A. Hassing.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p></p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.0.</p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a>
|
||||
2.0.2.</p>
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 94 KiB |