mirror of
https://github.com/msberends/AMR.git
synced 2025-07-10 10:21:56 +02:00
Compare commits
13 Commits
v1.5.0
...
331c1f6508
Author | SHA1 | Date | |
---|---|---|---|
331c1f6508 | |||
24eb4453db | |||
286eaa9699 | |||
1a88caa119 | |||
1ba44776a1 | |||
27f084d819 | |||
4eab095306 | |||
e95218c0d1 | |||
e699de955c | |||
7ebc534ccd | |||
6745f3fb17 | |||
bc00470dca | |||
d014955ce0 |
@ -25,7 +25,6 @@
|
||||
^vignettes/AMR.Rmd$
|
||||
^vignettes/benchmarks.Rmd$
|
||||
^vignettes/EUCAST.Rmd$
|
||||
^vignettes/MDR.Rmd$
|
||||
^vignettes/PCA.Rmd$
|
||||
^vignettes/resistance_predict.Rmd$
|
||||
^vignettes/SPSS.Rmd$
|
||||
|
23
.github/workflows/check.yaml
vendored
23
.github/workflows/check.yaml
vendored
@ -56,12 +56,17 @@ jobs:
|
||||
- {os: windows-latest, r: 'devel', allowfail: false}
|
||||
- {os: windows-latest, r: 'release', allowfail: false}
|
||||
- {os: windows-latest, r: 'oldrel', allowfail: false}
|
||||
- {os: ubuntu-20.04, r: 'devel', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: 'release', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: 'oldrel', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.0', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: 'devel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: 'oldrel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '4.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
# - {os: ubuntu-20.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
# - {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-16.04, r: 'devel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: 'oldrel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
@ -69,9 +74,9 @@ jobs:
|
||||
- {os: ubuntu-16.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.3', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
# - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
# - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
|
||||
env:
|
||||
|
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 1.5.0
|
||||
Date: 2021-01-05
|
||||
Version: 1.5.0.9012
|
||||
Date: 2021-01-25
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
|
13
NAMESPACE
13
NAMESPACE
@ -2,22 +2,27 @@
|
||||
|
||||
S3method("[",ab)
|
||||
S3method("[",disk)
|
||||
S3method("[",isolate_identifier)
|
||||
S3method("[",mic)
|
||||
S3method("[",mo)
|
||||
S3method("[<-",ab)
|
||||
S3method("[<-",disk)
|
||||
S3method("[<-",isolate_identifier)
|
||||
S3method("[<-",mic)
|
||||
S3method("[<-",mo)
|
||||
S3method("[<-",rsi)
|
||||
S3method("[[",ab)
|
||||
S3method("[[",disk)
|
||||
S3method("[[",isolate_identifier)
|
||||
S3method("[[",mic)
|
||||
S3method("[[",mo)
|
||||
S3method("[[<-",ab)
|
||||
S3method("[[<-",disk)
|
||||
S3method("[[<-",isolate_identifier)
|
||||
S3method("[[<-",mic)
|
||||
S3method("[[<-",mo)
|
||||
S3method("[[<-",rsi)
|
||||
S3method(all.equal,isolate_identifier)
|
||||
S3method(as.data.frame,ab)
|
||||
S3method(as.data.frame,mo)
|
||||
S3method(as.double,mic)
|
||||
@ -31,6 +36,7 @@ S3method(barplot,mic)
|
||||
S3method(barplot,rsi)
|
||||
S3method(c,ab)
|
||||
S3method(c,disk)
|
||||
S3method(c,isolate_identifier)
|
||||
S3method(c,mic)
|
||||
S3method(c,mo)
|
||||
S3method(c,rsi)
|
||||
@ -47,7 +53,9 @@ S3method(plot,rsi)
|
||||
S3method(print,ab)
|
||||
S3method(print,bug_drug_combinations)
|
||||
S3method(print,catalogue_of_life_version)
|
||||
S3method(print,custom_mdro_guideline)
|
||||
S3method(print,disk)
|
||||
S3method(print,isolate_identifier)
|
||||
S3method(print,mic)
|
||||
S3method(print,mo)
|
||||
S3method(print,mo_renamed)
|
||||
@ -61,6 +69,7 @@ S3method(summary,mo)
|
||||
S3method(summary,rsi)
|
||||
S3method(unique,ab)
|
||||
S3method(unique,disk)
|
||||
S3method(unique,isolate_identifier)
|
||||
S3method(unique,mic)
|
||||
S3method(unique,mo)
|
||||
S3method(unique,rsi)
|
||||
@ -113,6 +122,8 @@ export(count_all)
|
||||
export(count_df)
|
||||
export(count_resistant)
|
||||
export(count_susceptible)
|
||||
export(custom_mdro_guideline)
|
||||
export(eucast_dosage)
|
||||
export(eucast_exceptional_phenotypes)
|
||||
export(eucast_rules)
|
||||
export(facet_rsi)
|
||||
@ -153,6 +164,7 @@ export(is.mo)
|
||||
export(is.rsi)
|
||||
export(is.rsi.eligible)
|
||||
export(is_new_episode)
|
||||
export(isolate_identifier)
|
||||
export(key_antibiotics)
|
||||
export(key_antibiotics_equal)
|
||||
export(kurtosis)
|
||||
@ -175,6 +187,7 @@ export(mo_info)
|
||||
export(mo_is_gram_negative)
|
||||
export(mo_is_gram_positive)
|
||||
export(mo_is_intrinsic_resistant)
|
||||
export(mo_is_yeast)
|
||||
export(mo_kingdom)
|
||||
export(mo_matching_score)
|
||||
export(mo_name)
|
||||
|
46
NEWS.md
46
NEWS.md
@ -1,6 +1,48 @@
|
||||
# AMR 1.5.0
|
||||
# AMR 1.5.0.9012
|
||||
## <small>Last updated: 25 January 2021</small>
|
||||
|
||||
*Note: the rules of 'EUCAST Clinical Breakpoints v11.0 (2021)' will be added in the next release, to be expected in February/March 2021.*
|
||||
### New
|
||||
* Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the `eucast_rules()` function and in `as.rsi()` to interpret MIC and disk diffusion values. This is now the default guideline in this package.
|
||||
* Data set `dosage` to fuel the new `eucast_dosage()` function and to make this data available in a structured way
|
||||
* Function `eucast_dosage()` to get a `data.frame` with advised dosages of a certain bug-drug combination, which is based on the new `dosage` data set
|
||||
* Support for custom MDRO guidelines, using the new `custom_mdro_guideline()` function, please see `mdro()` for additional info
|
||||
* Function `isolate_identifier()`, which will paste a microorganism code with all antimicrobial results of a data set into one string for each row. This is useful to compare isolates, e.g. between institutions or regions, when there is no genotyping available.
|
||||
* Function `mo_is_yeast()`, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:
|
||||
```r
|
||||
mo_kingdom(c("Aspergillus", "Candida"))
|
||||
#> [1] "Fungi" "Fungi"
|
||||
|
||||
mo_is_yeast(c("Aspergillus", "Candida"))
|
||||
#> [1] FALSE TRUE
|
||||
|
||||
# usage for filtering data:
|
||||
example_isolates[which(mo_is_yeast()), ] # base R
|
||||
example_isolates %>% filter(mo_is_yeast()) # dplyr
|
||||
```
|
||||
The `mo_type()` function has also been updated to reflect this change:
|
||||
```r
|
||||
mo_type(c("Aspergillus", "Candida"))
|
||||
# [1] "Fungi" "Yeasts"
|
||||
mo_type(c("Aspergillus", "Candida"), language = "es") # also supported: de, nl, fr, it, pt
|
||||
#> [1] "Hongos" "Levaduras"
|
||||
```
|
||||
|
||||
### Changed
|
||||
* Using functions without setting a data set (e.g., `mo_is_gram_negative()`, `mo_is_gram_positive()`, `mo_is_intrinsic_resistant()`, `first_isolate()`, `mdro()`) now work with `dplyr`s `group_by()` again
|
||||
* Updated the data set `microorganisms.codes` (which contains popular LIS and WHONET codes for microorganisms) for some species of *Mycobacterium* that previously incorrectly returned *M. africanum*
|
||||
* Added Pretomanid (PMD, J04AK08) to the `antibiotics` data set
|
||||
* WHONET code `"PNV"` will now correctly be interpreted as `PHN`, the antibiotic code for phenoxymethylpenicillin ('peni V')
|
||||
* Fix for verbose output of `mdro(..., verbose = TRUE)` for German guideline (3MGRN and 4MGRN) and Dutch guideline (BRMO, only *P. aeruginosa*)
|
||||
* `is.rsi.eligible()` now returns `FALSE` immediately if the input does not contain any of the values "R", "S" or "I". This drastically improves speed, also for a lot of other functions that rely on automatic determination of antibiotic columns.
|
||||
* Functions `get_episode()` and `is_new_episode()` now support less than a day as value for argument `episode_days` (e.g., to include one patient/test per hour)
|
||||
* Argument `ampc_cephalosporin_resistance` in `eucast_rules()` now also applies to value "I" (not only "S")
|
||||
|
||||
### Other
|
||||
* Big documentation updates
|
||||
* Loading the package (i.e., `library(AMR)`) now is ~50 times faster than before, in costs of package size (increased with ~3 MB)
|
||||
|
||||
|
||||
# AMR 1.5.0
|
||||
|
||||
### New
|
||||
* Functions `get_episode()` and `is_new_episode()` to determine (patient) episodes which are not necessarily based on microorganisms. The `get_episode()` function returns the index number of the episode per group, while the `is_new_episode()` function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode. They also support `dplyr`s grouping (i.e. using `group_by()`):
|
||||
|
@ -81,10 +81,13 @@ check_dataset_integrity <- function() {
|
||||
overwritten <- data_in_pkg[data_in_pkg %in% data_in_globalenv]
|
||||
# exception for example_isolates
|
||||
overwritten <- overwritten[overwritten != "example_isolates"]
|
||||
stop_if(length(overwritten) > 0,
|
||||
"the following data set is overwritten by your global environment and prevents the AMR package from working correctly:\n",
|
||||
paste0("'", overwritten, "'", collapse = ", "),
|
||||
".\nPlease rename your object before using this function.", call = FALSE)
|
||||
if (length(overwritten) > 0) {
|
||||
warning_(ifelse(length(overwritten) == 1,
|
||||
"The following data set is overwritten by your global environment and prevents the AMR package from working correctly: ",
|
||||
"The following data sets are overwritten by your global environment and prevent the AMR package from working correctly: "),
|
||||
paste0("'", overwritten, "'", collapse = ", "),
|
||||
".\nPlease rename your object(s).", call = FALSE)
|
||||
}
|
||||
# check if other packages did not overwrite our data sets
|
||||
tryCatch({
|
||||
check_microorganisms <- all(c("mo", "fullname", "kingdom", "phylum",
|
||||
@ -439,12 +442,71 @@ create_ab_documentation <- function(ab) {
|
||||
out
|
||||
}
|
||||
|
||||
vector_or <- function(v, quotes = TRUE, reverse = FALSE, last_sep = " or ") {
|
||||
# makes unique and sorts, and this also removed NAs
|
||||
v <- sort(unique(v))
|
||||
if (length(v) == 1) {
|
||||
return(paste0(ifelse(quotes, '"', ""), v, ifelse(quotes, '"', "")))
|
||||
}
|
||||
if (reverse == TRUE) {
|
||||
v <- rev(v)
|
||||
}
|
||||
if (identical(v, c("I", "R", "S"))) {
|
||||
# class <rsi> should be sorted like this
|
||||
v <- c("R", "S", "I")
|
||||
}
|
||||
if (isTRUE(quotes)) {
|
||||
quotes <- '"'
|
||||
} else if (isFALSE(quotes)) {
|
||||
quotes <- ""
|
||||
}
|
||||
# all commas except for last item, so will become '"val1", "val2", "val3" or "val4"'
|
||||
paste0(paste0(quotes, v[seq_len(length(v) - 1)], quotes, collapse = ", "),
|
||||
last_sep, paste0(quotes, v[length(v)], quotes))
|
||||
}
|
||||
|
||||
format_class <- function(class, plural) {
|
||||
class.bak <- class
|
||||
class[class == "numeric"] <- "number"
|
||||
class[class == "integer"] <- "whole number"
|
||||
if (all(c("numeric", "integer") %in% class.bak, na.rm = TRUE)) {
|
||||
class[class %in% c("number", "whole number")] <- "(whole) number"
|
||||
}
|
||||
class[class == "character"] <- "text string"
|
||||
class[class %in% c("Date", "POSIXt")] <- "date"
|
||||
class[class != class.bak] <- paste0(ifelse(plural, "", "a "),
|
||||
class[class != class.bak],
|
||||
ifelse(plural, "s", ""))
|
||||
# exceptions
|
||||
class[class == "logical"] <- ifelse(plural, "a vector of `TRUE`/`FALSE`", "`TRUE` or `FALSE`")
|
||||
if ("data.frame" %in% class) {
|
||||
class <- "a data set"
|
||||
}
|
||||
if ("list" %in% class) {
|
||||
class <- "a list"
|
||||
}
|
||||
if ("matrix" %in% class) {
|
||||
class <- "a matrix"
|
||||
}
|
||||
if ("isolate_identifier" %in% class) {
|
||||
class <- "created with isolate_identifier()"
|
||||
}
|
||||
if (any(c("mo", "ab", "rsi", "disk", "mic") %in% class)) {
|
||||
class <- paste0("of class <", class[1L], ">")
|
||||
}
|
||||
class[class == class.bak] <- paste0("of class <", class[class == class.bak], ">")
|
||||
# output
|
||||
vector_or(class, quotes = FALSE)
|
||||
}
|
||||
|
||||
# a check for every single argument in all functions
|
||||
meet_criteria <- function(object,
|
||||
allow_class = NULL,
|
||||
has_length = NULL,
|
||||
looks_like = NULL,
|
||||
is_in = NULL,
|
||||
is_positive = NULL,
|
||||
is_finite = NULL,
|
||||
contains_column_class = NULL,
|
||||
allow_NULL = FALSE,
|
||||
allow_NA = FALSE,
|
||||
@ -453,6 +515,16 @@ meet_criteria <- function(object,
|
||||
|
||||
obj_name <- deparse(substitute(object))
|
||||
call_depth <- -2 - abs(.call_depth)
|
||||
|
||||
# if object is missing, or another error:
|
||||
tryCatch(invisible(object),
|
||||
error = function(e) pkg_env$meet_criteria_error_txt <- e$message)
|
||||
if (!is.null(pkg_env$meet_criteria_error_txt)) {
|
||||
error_txt <- pkg_env$meet_criteria_error_txt
|
||||
pkg_env$meet_criteria_error_txt <- NULL
|
||||
stop(error_txt, call. = FALSE)
|
||||
}
|
||||
pkg_env$meet_criteria_error_txt <- NULL
|
||||
|
||||
if (is.null(object)) {
|
||||
stop_if(allow_NULL == FALSE, "argument `", obj_name, "` must not be NULL", call = call_depth)
|
||||
@ -463,20 +535,10 @@ meet_criteria <- function(object,
|
||||
return(invisible())
|
||||
}
|
||||
|
||||
vector_or <- function(v, quotes) {
|
||||
if (length(v) == 1) {
|
||||
return(paste0(ifelse(quotes, '"', ""), v, ifelse(quotes, '"', "")))
|
||||
}
|
||||
# all commas except for last item, so will become '"val1", "val2", "val3" or "val4"'
|
||||
paste0(paste0(ifelse(quotes, '"', ""), v[seq_len(length(v) - 1)], ifelse(quotes, '"', ""), collapse = ", "),
|
||||
" or ", paste0(ifelse(quotes, '"', ""), v[length(v)], ifelse(quotes, '"', "")))
|
||||
}
|
||||
|
||||
if (!is.null(allow_class)) {
|
||||
stop_ifnot(inherits(object, allow_class), "argument `", obj_name,
|
||||
"` must ", # ifelse(allow_NULL, "be NULL or must ", ""),
|
||||
"be of class ", vector_or(allow_class, quotes = TRUE),
|
||||
", not \"", paste(class(object), collapse = "/"), "\"",
|
||||
"` must be ", format_class(allow_class, plural = isTRUE(has_length > 1)),
|
||||
", i.e. not be ", format_class(class(object), plural = isTRUE(has_length > 1)),
|
||||
call = call_depth)
|
||||
# check data.frames for data
|
||||
if (inherits(object, "data.frame")) {
|
||||
@ -507,11 +569,29 @@ meet_criteria <- function(object,
|
||||
}
|
||||
stop_ifnot(all(object %in% is_in, na.rm = TRUE), "argument `", obj_name,
|
||||
"` must be ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1, "one of: ", ""),
|
||||
vector_or(is_in, quotes = TRUE),
|
||||
", not ", paste0("\"", object, "\"", collapse = "/"), "",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1, "either ", ""),
|
||||
vector_or(is_in, quotes = !isTRUE(any(c("double", "numeric", "integer") %in% allow_class))),
|
||||
ifelse(allow_NA == TRUE, ", or NA", ""),
|
||||
call = call_depth)
|
||||
}
|
||||
if (!is.null(is_positive)) {
|
||||
stop_if(is.numeric(object) && !all(object > 0, na.rm = TRUE), "argument `", obj_name,
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"be a positive number",
|
||||
"all be positive numbers"),
|
||||
" (higher than zero)",
|
||||
call = call_depth)
|
||||
}
|
||||
if (!is.null(is_finite)) {
|
||||
stop_if(is.numeric(object) && !all(is.finite(object[!is.na(object)]), na.rm = TRUE), "argument `", obj_name,
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"be a finite number",
|
||||
"all be finite numbers"),
|
||||
" (i.e., not be infinite)",
|
||||
call = call_depth)
|
||||
}
|
||||
if (!is.null(contains_column_class)) {
|
||||
stop_ifnot(any(vapply(FUN.VALUE = logical(1),
|
||||
object,
|
||||
@ -527,8 +607,21 @@ meet_criteria <- function(object,
|
||||
}
|
||||
|
||||
get_current_data <- function(arg_name, call) {
|
||||
# try dplyr::cur_data_all() first to support dplyr groups
|
||||
# only useful for e.g. dplyr::filter(), dplyr::mutate() and dplyr::summarise()
|
||||
# not useful (throws error) with e.g. dplyr::select() - but that will be caught later in this function
|
||||
cur_data_all <- import_fn("cur_data_all", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(cur_data_all)) {
|
||||
out <- tryCatch(cur_data_all(), error = function(e) NULL)
|
||||
if (is.data.frame(out)) {
|
||||
return(out)
|
||||
}
|
||||
}
|
||||
|
||||
if (as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2) {
|
||||
# R-3.0 and R-3.1 do not have an `x` element in the call stack, rendering this function useless
|
||||
if (is.na(arg_name)) {
|
||||
# like in carbapenems() etc.
|
||||
warning_("this function can only be used in R >= 3.2", call = call)
|
||||
return(data.frame())
|
||||
} else {
|
||||
@ -539,12 +632,13 @@ get_current_data <- function(arg_name, call) {
|
||||
# try a (base R) method, by going over the complete system call stack with sys.frames()
|
||||
not_set <- TRUE
|
||||
frms <- lapply(sys.frames(), function(el) {
|
||||
if (".Generic" %in% names(el)) {
|
||||
if (tryCatch(not_set == TRUE && ".data" %in% names(el) && is.data.frame(el$`.data`), error = function(e) FALSE)) {
|
||||
if (not_set == TRUE && ".Generic" %in% names(el)) {
|
||||
if (tryCatch(".data" %in% names(el) && is.data.frame(el$`.data`), error = function(e) FALSE)) {
|
||||
# dplyr? - an element `.data` will be in the system call stack
|
||||
# will be used in dplyr::select() (but not in dplyr::filter(), dplyr::mutate() or dplyr::summarise())
|
||||
not_set <<- FALSE
|
||||
el$`.data`
|
||||
} else if (tryCatch(not_set == TRUE && any(c("x", "xx") %in% names(el)), error = function(e) FALSE)) {
|
||||
} else if (tryCatch(any(c("x", "xx") %in% names(el)), error = function(e) FALSE)) {
|
||||
# otherwise try base R:
|
||||
# an element `x` will be in this environment for only cols, e.g. `example_isolates[, carbapenems()]`
|
||||
# an element `xx` will be in this environment for rows + cols, e.g. `example_isolates[c(1:3), carbapenems()]`
|
||||
@ -564,6 +658,7 @@ get_current_data <- function(arg_name, call) {
|
||||
NULL
|
||||
}
|
||||
})
|
||||
|
||||
vars_df <- tryCatch(frms[[which(!vapply(FUN.VALUE = logical(1), frms, is.null))]], error = function(e) NULL)
|
||||
if (is.data.frame(vars_df)) {
|
||||
return(vars_df)
|
||||
@ -574,9 +669,7 @@ get_current_data <- function(arg_name, call) {
|
||||
stop_("this function must be used inside valid dplyr selection verbs or inside a data.frame call",
|
||||
call = call)
|
||||
} else {
|
||||
stop_("argument `", arg_name, "` is missing with no default ",
|
||||
"or function not used inside a valid dplyr verb",
|
||||
call = call)
|
||||
stop_("argument `", arg_name, "` is missing with no default", call = call)
|
||||
}
|
||||
}
|
||||
|
||||
@ -595,19 +688,19 @@ unique_call_id <- function(entire_session = FALSE) {
|
||||
remember_thrown_message <- function(fn, entire_session = FALSE) {
|
||||
# this is to prevent that messages/notes will be printed for every dplyr group
|
||||
# e.g. this would show a msg 4 times: example_isolates %>% group_by(hospital_id) %>% filter(mo_is_gram_negative())
|
||||
assign(x = paste0("thrown_msg_", fn),
|
||||
assign(x = paste0("thrown_msg.", fn),
|
||||
value = unique_call_id(entire_session = entire_session),
|
||||
envir = pkg_env)
|
||||
}
|
||||
|
||||
message_not_thrown_before <- function(fn, entire_session = FALSE) {
|
||||
is.null(pkg_env[[paste0("thrown_msg_", fn)]]) || !identical(pkg_env[[paste0("thrown_msg_", fn)]], unique_call_id(entire_session))
|
||||
is.null(pkg_env[[paste0("thrown_msg.", fn)]]) || !identical(pkg_env[[paste0("thrown_msg.", fn)]], unique_call_id(entire_session))
|
||||
}
|
||||
|
||||
reset_all_thrown_messages <- function() {
|
||||
# for unit tests, where the environment and highest system call do not change
|
||||
pkg_env_contents <- ls(envir = pkg_env)
|
||||
rm(list = pkg_env_contents[pkg_env_contents %like% "^thrown_msg_"],
|
||||
rm(list = pkg_env_contents[pkg_env_contents %like% "^thrown_msg."],
|
||||
envir = pkg_env)
|
||||
}
|
||||
|
||||
|
24
R/ab.R
24
R/ab.R
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Transform input to an antibiotic ID
|
||||
#' Transform Input to an Antibiotic ID
|
||||
#'
|
||||
#' Use this function to determine the antibiotic code of one or more antibiotics. The data set [antibiotics] will be searched for abbreviations, official names and synonyms (brand names).
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x character vector to determine to antibiotic ID
|
||||
#' @param flag_multiple_results logical to indicate whether a note should be printed to the console that probably more than one antibiotic code or name can be retrieved from a single input value.
|
||||
#' @param info logical to indicate whether a progress bar should be printed
|
||||
@ -42,7 +42,7 @@
|
||||
#' * Switching two characters (such as "mreopenem", often the case in clinical data, when doctors typed too fast)
|
||||
#' * Digitalised paper records, leaving artefacts like 0/o/O (zero and O's), B/8, n/r, etc.
|
||||
#'
|
||||
#' Use the [`ab_*`][ab_property()] functions to get properties based on the returned antibiotic ID, see Examples.
|
||||
#' Use the [`ab_*`][ab_property()] functions to get properties based on the returned antibiotic ID, see *Examples*.
|
||||
#'
|
||||
#' Note: the [as.ab()] and [`ab_*`][ab_property()] functions may use very long regular expression to match brand names of antimicrobial agents. This may fail on some systems.
|
||||
#' @section Source:
|
||||
@ -56,8 +56,8 @@
|
||||
#' @seealso
|
||||
#' * [antibiotics] for the [data.frame] that is being used to determine ATCs
|
||||
#' * [ab_from_text()] for a function to retrieve antimicrobial drugs from clinical text (from health care records)
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @export
|
||||
#' @examples
|
||||
#' # these examples all return "ERY", the ID of erythromycin:
|
||||
@ -82,6 +82,14 @@
|
||||
#' # they use as.ab() internally:
|
||||
#' ab_name("J01FA01") # "Erythromycin"
|
||||
#' ab_name("eryt") # "Erythromycin"
|
||||
#'
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # you can quickly rename <rsi> columns using dplyr >= 1.0.0:
|
||||
#' example_isolates %>%
|
||||
#' rename_with(as.ab, where(is.rsi))
|
||||
#'
|
||||
#' }
|
||||
as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
||||
meet_criteria(x, allow_class = c("character", "numeric", "integer", "factor"), allow_NA = TRUE)
|
||||
meet_criteria(flag_multiple_results, allow_class = "logical", has_length = 1)
|
||||
@ -160,6 +168,12 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
||||
from_text <- character(0)
|
||||
}
|
||||
|
||||
# old code for phenoxymethylpenicillin (Peni V)
|
||||
if (x[i] == "PNV") {
|
||||
x_new[i] <- "PHN"
|
||||
next
|
||||
}
|
||||
|
||||
# exact name
|
||||
found <- antibiotics[which(AB_lookup$generalised_name == x[i]), ]$ab
|
||||
if (length(found) > 0) {
|
||||
|
@ -23,9 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Antibiotic class selectors
|
||||
#' Antibiotic Class Selectors
|
||||
#'
|
||||
#' These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @inheritParams filter_ab_class
|
||||
#' @details \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}}
|
||||
#'
|
||||
@ -34,10 +35,10 @@
|
||||
#' @seealso [filter_ab_class()] for the `filter()` equivalent.
|
||||
#' @name antibiotic_class_selectors
|
||||
#' @export
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # `example_isolates` is a dataset available in the AMR package.
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||
@ -172,7 +173,15 @@ ab_selector <- function(ab_class, function_name) {
|
||||
}
|
||||
|
||||
vars_df <- get_current_data(arg_name = NA, call = -3)
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE)
|
||||
|
||||
# improve speed here so it will only run once when e.g. in one select call
|
||||
if (!identical(pkg_env$ab_selector, unique_call_id())) {
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE)
|
||||
pkg_env$ab_selector <- unique_call_id()
|
||||
pkg_env$ab_selector_cols <- ab_in_data
|
||||
} else {
|
||||
ab_in_data <- pkg_env$ab_selector_cols
|
||||
}
|
||||
|
||||
if (length(ab_in_data) == 0) {
|
||||
message_("No antimicrobial agents found.")
|
||||
@ -198,13 +207,14 @@ ab_selector <- function(ab_class, function_name) {
|
||||
} else {
|
||||
agents_formatted <- paste0("column '", font_bold(agents, collapse = NULL), "'")
|
||||
agents_names <- ab_name(names(agents), tolower = TRUE, language = NULL)
|
||||
agents_formatted[agents != agents_names] <- paste0(agents_formatted[agents != agents_names],
|
||||
" (", agents_names[agents != agents_names], ")")
|
||||
need_name <- tolower(gsub("[^a-zA-Z]", "", agents)) != tolower(gsub("[^a-zA-Z]", "", agents_names))
|
||||
agents_formatted[need_name] <- paste0(agents_formatted[need_name],
|
||||
" (", agents_names[need_name], ")")
|
||||
message_("Selecting ", ab_group, ": ", paste(agents_formatted, collapse = ", "),
|
||||
as_note = FALSE,
|
||||
extra_indent = nchar(paste0("Selecting ", ab_group, ": ")))
|
||||
extra_indent = 4)
|
||||
}
|
||||
remember_thrown_message(function_name)
|
||||
}
|
||||
remember_thrown_message(function_name)
|
||||
}
|
||||
unname(agents)
|
||||
}
|
||||
|
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Retrieve antimicrobial drug names and doses from clinical text
|
||||
#' Retrieve Antimicrobial Drug Names and Doses from Clinical Text
|
||||
#'
|
||||
#' Use this function on e.g. clinical texts from health care records. It returns a [list] with all antimicrobial drugs, doses and forms of administration found in the texts.
|
||||
#' @inheritSection lifecycle Maturing lifecycle
|
||||
#' @inheritSection lifecycle Maturing Lifecycle
|
||||
#' @param text text to analyse
|
||||
#' @param type type of property to search for, either `"drug"`, `"dose"` or `"administration"`, see *Examples*
|
||||
#' @param collapse character to pass on to `paste(..., collapse = ...)` to only return one character per element of `text`, see *Examples*
|
||||
@ -52,7 +52,7 @@
|
||||
#' `df %>% mutate(abx = ab_from_text(clinical_text, collapse = "|"))`
|
||||
#' @export
|
||||
#' @return A [list], or a [character] if `collapse` is not `NULL`
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # mind the bad spelling of amoxicillin in this line,
|
||||
#' # straight from a true health care record:
|
||||
|
@ -23,16 +23,16 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Get properties of an antibiotic
|
||||
#' Get Properties of an Antibiotic
|
||||
#'
|
||||
#' Use these functions to return a specific property of an antibiotic from the [antibiotics] data set. All input values will be evaluated internally with [as.ab()].
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x any (vector of) text that can be coerced to a valid antibiotic code with [as.ab()]
|
||||
#' @param tolower logical to indicate whether the first character of every output should be transformed to a lower case character. This will lead to e.g. "polymyxin B" and not "polymyxin b".
|
||||
#' @param property one of the column names of one of the [antibiotics] data set
|
||||
#' @param language language of the returned text, defaults to system language (see [get_locale()]) and can also be set with `getOption("AMR_locale")`. Use `language = NULL` or `language = ""` to prevent translation.
|
||||
#' @param administration way of administration, either `"oral"` or `"iv"`
|
||||
#' @param units a logical to indicate whether the units instead of the DDDs itself must be returned, see Examples
|
||||
#' @param units a logical to indicate whether the units instead of the DDDs itself must be returned, see *Examples*
|
||||
#' @param open browse the URL using [utils::browseURL()]
|
||||
#' @param ... other arguments passed on to [as.ab()]
|
||||
#' @details All output will be [translate]d where possible.
|
||||
@ -48,8 +48,8 @@
|
||||
#' - A [character] in all other cases
|
||||
#' @export
|
||||
#' @seealso [antibiotics]
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # all properties:
|
||||
#' ab_name("AMX") # "Amoxicillin"
|
||||
|
18
R/age.R
18
R/age.R
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Age in years of individuals
|
||||
#' Age in Years of Individuals
|
||||
#'
|
||||
#' Calculates age in years based on a reference date, which is the sytem date at default.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x date(s), will be coerced with [as.POSIXlt()]
|
||||
#' @param reference reference date(s) (defaults to today), will be coerced with [as.POSIXlt()]
|
||||
#' @param exact a logical to indicate whether age calculation should be exact, i.e. with decimals. It divides the number of days of [year-to-date](https://en.wikipedia.org/wiki/Year-to-date) (YTD) of `x` by the number of days in the year of `reference` (either 365 or 366).
|
||||
@ -35,7 +35,7 @@
|
||||
#' @details Ages below 0 will be returned as `NA` with a warning. Ages above 120 will only give a warning.
|
||||
#' @return An [integer] (no decimals) if `exact = FALSE`, a [double] (with decimals) otherwise
|
||||
#' @seealso To split ages into groups, use the [age_groups()] function.
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @export
|
||||
#' @examples
|
||||
#' # 10 random birth dates
|
||||
@ -96,12 +96,12 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
ages
|
||||
}
|
||||
|
||||
#' Split ages into age groups
|
||||
#' Split Ages into Age Groups
|
||||
#'
|
||||
#' Split ages into age groups defined by the `split` argument. This allows for easier demographic (antimicrobial resistance) analysis.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x age, e.g. calculated with [age()]
|
||||
#' @param split_at values to split `x` at, defaults to age groups 0-11, 12-24, 25-54, 55-74 and 75+. See Details.
|
||||
#' @param split_at values to split `x` at, defaults to age groups 0-11, 12-24, 25-54, 55-74 and 75+. See *Details*.
|
||||
#' @param na.rm a [logical] to indicate whether missing values should be removed
|
||||
#' @details To split ages, the input for the `split_at` argument can be:
|
||||
#'
|
||||
@ -115,7 +115,7 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
#' @return Ordered [factor]
|
||||
#' @seealso To determine ages, based on one or more reference dates, use the [age()] function.
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' ages <- c(3, 8, 16, 54, 31, 76, 101, 43, 21)
|
||||
#'
|
||||
@ -149,8 +149,8 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
#' }
|
||||
#' }
|
||||
age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
|
||||
meet_criteria(x, allow_class = c("numeric", "integer"))
|
||||
meet_criteria(split_at, allow_class = c("numeric", "integer", "character"))
|
||||
meet_criteria(x, allow_class = c("numeric", "integer"), is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(split_at, allow_class = c("numeric", "integer", "character"), is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||
|
||||
if (any(x < 0, na.rm = TRUE)) {
|
||||
|
10
R/amr.R
10
R/amr.R
@ -51,9 +51,9 @@
|
||||
#' - Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI
|
||||
#' - Principal component analysis for AMR
|
||||
#'
|
||||
#' @section Reference data publicly available:
|
||||
#' @section Reference Data Publicly Available:
|
||||
#' All reference data sets (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) in this `AMR` package are publicly and freely available. We continually export our data sets to formats for use in R, SPSS, SAS, Stata and Excel. We also supply flat files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please find [all download links on our website](https://msberends.github.io/AMR/articles/datasets.html), which is automatically updated with every code change.
|
||||
#' @section Read more on our website!:
|
||||
#' @section Read more on Our Website!:
|
||||
#' On our website <https://msberends.github.io/AMR/> you can find [a comprehensive tutorial](https://msberends.github.io/AMR/articles/AMR.html) about how to conduct AMR analysis, the [complete documentation of all functions](https://msberends.github.io/AMR/reference/) and [an example analysis using WHONET data](https://msberends.github.io/AMR/articles/WHONET.html). As we would like to better understand the backgrounds and needs of our users, please [participate in our survey](https://msberends.github.io/AMR/survey.html)!
|
||||
#' @section Contact Us:
|
||||
#' For suggestions, comments or questions, please contact us at:
|
||||
@ -74,11 +74,11 @@
|
||||
#' @rdname AMR
|
||||
NULL
|
||||
|
||||
#' Plotting for classes `rsi`, `mic` and `disk`
|
||||
#' Plotting for Classes `rsi`, `mic` and `disk`
|
||||
#'
|
||||
#' Functions to print classes of the `AMR` package.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @param ... Arguments passed on to functions
|
||||
#' @inheritParams base::plot
|
||||
#' @inheritParams graphics::barplot
|
||||
|
@ -23,13 +23,13 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Get ATC properties from WHOCC website
|
||||
#' Get ATC Properties from WHOCC Website
|
||||
#'
|
||||
#' Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic), such as the name, defined daily dose (DDD) or standard unit.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param atc_code a character or character vector with ATC code(s) of antibiotic(s)
|
||||
#' @param property property of an ATC code. Valid values are `"ATC"`, `"Name"`, `"DDD"`, `"U"` (`"unit"`), `"Adm.R"`, `"Note"` and `groups`. For this last option, all hierarchical groups of an ATC code will be returned, see Examples.
|
||||
#' @param administration type of administration when using `property = "Adm.R"`, see Details
|
||||
#' @param property property of an ATC code. Valid values are `"ATC"`, `"Name"`, `"DDD"`, `"U"` (`"unit"`), `"Adm.R"`, `"Note"` and `groups`. For this last option, all hierarchical groups of an ATC code will be returned, see *Examples*.
|
||||
#' @param administration type of administration when using `property = "Adm.R"`, see *Details*
|
||||
#' @param url url of website of the WHOCC. The sign `%s` can be used as a placeholder for ATC codes.
|
||||
#' @param url_vet url of website of the WHOCC for veterinary medicine. The sign `%s` can be used as a placeholder for ATC_vet codes (that all start with "Q").
|
||||
#' @param ... arguments to pass on to `atc_property`
|
||||
@ -61,7 +61,7 @@
|
||||
#' **N.B. This function requires an internet connection and only works if the following packages are installed: `curl`, `rvest`, `xml2`.**
|
||||
#' @export
|
||||
#' @rdname atc_online
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
|
@ -23,15 +23,15 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Check availability of columns
|
||||
#' Check Availability of Columns
|
||||
#'
|
||||
#' Easy check for data availability of all columns in a data set. This makes it easy to get an idea of which antimicrobial combinations can be used for calculation with e.g. [susceptibility()] and [resistance()].
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param tbl a [data.frame] or [list]
|
||||
#' @param width number of characters to present the visual availability, defaults to filling the width of the console
|
||||
#' @details The function returns a [data.frame] with columns `"resistant"` and `"visual_resistance"`. The values in that columns are calculated with [resistance()].
|
||||
#' @return [data.frame] with column names of `tbl` as row names
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @export
|
||||
#' @examples
|
||||
#' availability(example_isolates)
|
||||
@ -44,7 +44,7 @@
|
||||
#' }
|
||||
availability <- function(tbl, width = NULL) {
|
||||
meet_criteria(tbl, allow_class = "data.frame")
|
||||
meet_criteria(width, allow_class = "numeric", allow_NULL = TRUE)
|
||||
meet_criteria(width, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)
|
||||
|
||||
x <- vapply(FUN.VALUE = double(1), tbl, function(x) {
|
||||
1 - sum(is.na(x)) / length(x)
|
||||
|
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Determine bug-drug combinations
|
||||
#' Determine Bug-Drug Combinations
|
||||
#'
|
||||
#' Determine antimicrobial resistance (AMR) of all bug-drug combinations in your data set where at least 30 (default) isolates are available per species. Use [format()] on the result to prettify it to a publicable/printable format, see Examples.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' Determine antimicrobial resistance (AMR) of all bug-drug combinations in your data set where at least 30 (default) isolates are available per species. Use [format()] on the result to prettify it to a publicable/printable format, see *Examples*.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @inheritParams eucast_rules
|
||||
#' @param combine_IR logical to indicate whether values R and I should be summed
|
||||
#' @param add_ab_group logical to indicate where the group of the antimicrobials must be included as a first column
|
||||
@ -41,7 +41,7 @@
|
||||
#' @rdname bug_drug_combinations
|
||||
#' @return The function [bug_drug_combinations()] returns a [data.frame] with columns "mo", "ab", "S", "I", "R" and "total".
|
||||
#' @source \strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, *Clinical and Laboratory Standards Institute (CLSI)*. <https://clsi.org/standards/products/microbiology/documents/m39/>.
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' x <- bug_drug_combinations(example_isolates)
|
||||
@ -69,8 +69,10 @@ bug_drug_combinations <- function(x,
|
||||
# -- mo
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo")
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
} else {
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
}
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
|
||||
x_class <- class(x)
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
@ -127,7 +129,7 @@ format.bug_drug_combinations <- function(x,
|
||||
meet_criteria(x, allow_class = "data.frame")
|
||||
meet_criteria(translate_ab, allow_class = c("character", "logical"), has_length = 1, allow_NA = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(combine_SI, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(combine_IR, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(add_ab_group, allow_class = "logical", has_length = 1)
|
||||
|
@ -47,7 +47,7 @@ format_included_data_number <- function(data) {
|
||||
#' This package contains the complete taxonomic tree of almost all microorganisms (~70,000 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 LSPN were included in this package with [catalogue_of_life_version()].
|
||||
#' @section Included taxa:
|
||||
#' @section Included Taxa:
|
||||
#' Included are:
|
||||
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom %in% c("Archeae", "Bacteria", "Chromista", "Protozoa")), ])` (sub)species from the kingdoms of Archaea, Bacteria, Chromista and Protozoa
|
||||
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Fungi" & microorganisms$order %in% c("Eurotiales", "Microascales", "Mucorales", "Onygenales", "Pneumocystales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales")), ])` (sub)species from these orders of the kingdom of Fungi: Eurotiales, Microascales, Mucorales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales, as well as `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Fungi" & !microorganisms$order %in% c("Eurotiales", "Microascales", "Mucorales", "Onygenales", "Pneumocystales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales")), ])` other fungal (sub)species. The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant fungi are covered (such as all species of *Aspergillus*, *Candida*, *Cryptococcus*, *Histplasma*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*).
|
||||
@ -59,7 +59,7 @@ format_included_data_number <- function(data) {
|
||||
#' The Catalogue of Life (<http://www.catalogueoflife.org>) is the most comprehensive and authoritative global index of species currently available. It holds essential information on the names, relationships and distributions of over 1.9 million species. The Catalogue of Life is used to support the major biodiversity and conservation information services such as the Global Biodiversity Information Facility (GBIF), Encyclopedia of Life (EoL) and the International Union for Conservation of Nature Red List. It is recognised by the Convention on Biological Diversity as a significant component of the Global Taxonomy Initiative and a contribution to Target 1 of the Global Strategy for Plant Conservation.
|
||||
#'
|
||||
#' The syntax used to transform the original data to a cleansed \R format, can be found here: <https://github.com/msberends/AMR/blob/master/data-raw/reproduction_of_microorganisms.R>.
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @name catalogue_of_life
|
||||
#' @rdname catalogue_of_life
|
||||
#' @seealso Data set [microorganisms] for the actual data. \cr
|
||||
@ -102,7 +102,7 @@ NULL
|
||||
#' @details For DSMZ, see [microorganisms].
|
||||
#' @return a [list], which prints in pretty format
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @export
|
||||
catalogue_of_life_version <- function() {
|
||||
|
||||
|
10
R/count.R
10
R/count.R
@ -23,12 +23,12 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Count available isolates
|
||||
#' Count Available Isolates
|
||||
#'
|
||||
#' @description These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in `summarise()` from the `dplyr` package and also support grouped variables, please see *Examples*.
|
||||
#' @description These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in `summarise()` from the `dplyr` package and also support grouped variables, see *Examples*.
|
||||
#'
|
||||
#' [count_resistant()] should be used to count resistant isolates, [count_susceptible()] should be used to count susceptible isolates.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with [as.rsi()] if needed.
|
||||
#' @inheritParams proportion
|
||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||
@ -39,13 +39,13 @@
|
||||
#' The function [n_rsi()] is an alias of [count_all()]. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal to `n_distinct()`. Their function is equal to `count_susceptible(...) + count_resistant(...)`.
|
||||
#'
|
||||
#' The function [count_df()] takes any variable from `data` that has an [`rsi`] class (created with [as.rsi()]) and counts the number of S's, I's and R's. It also supports grouped variables. The function [rsi_df()] works exactly like [count_df()], but adds the percentage of S, I and R.
|
||||
#' @inheritSection proportion Combination therapy
|
||||
#' @inheritSection proportion Combination Therapy
|
||||
#' @seealso [`proportion_*`][proportion] to calculate microbial resistance and susceptibility.
|
||||
#' @return An [integer]
|
||||
#' @rdname count
|
||||
#' @name count
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # example_isolates is a data set available in the AMR package.
|
||||
#' ?example_isolates
|
||||
|
93
R/data.R
93
R/data.R
@ -23,11 +23,11 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Data sets with `r format(nrow(antibiotics) + nrow(antivirals), big.mark = ",")` antimicrobials
|
||||
#' Data Sets with `r format(nrow(antibiotics) + nrow(antivirals), big.mark = ",")` Antimicrobials
|
||||
#'
|
||||
#' Two data sets containing all antibiotics/antimycotics and antivirals. Use [as.ab()] or one of the [`ab_*`][ab_property()] functions to retrieve values from the [antibiotics] data set. Three identifiers are included in this data set: an antibiotic ID (`ab`, primarily used in this package) as defined by WHONET/EARS-Net, an ATC code (`atc`) as defined by the WHO, and a Compound ID (`cid`) as found in PubChem. Other properties in this data set are derived from one or more of these codes.
|
||||
#' @format
|
||||
#' ### For the [antibiotics] data set: a [data.frame] with `r nrow(antibiotics)` observations and `r ncol(antibiotics)` variables:
|
||||
#' ## For the [antibiotics] data set: a [data.frame] with `r nrow(antibiotics)` observations and `r ncol(antibiotics)` variables:
|
||||
#' - `ab`\cr Antibiotic ID as used in this package (such as `AMC`), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available
|
||||
#' - `atc`\cr ATC code (Anatomical Therapeutic Chemical) as defined by the WHOCC, like `J01CR02`
|
||||
#' - `cid`\cr Compound ID as found in PubChem
|
||||
@ -43,7 +43,7 @@
|
||||
#' - `iv_units`\cr Units of `iv_ddd`
|
||||
#' - `loinc`\cr All LOINC codes (Logical Observation Identifiers Names and Codes) associated with the name of the antimicrobial agent. Use [ab_loinc()] to retrieve them quickly, see [ab_property()].
|
||||
#'
|
||||
#' ### For the [antivirals] data set: a [data.frame] with `r nrow(antivirals)` observations and `r ncol(antivirals)` variables:
|
||||
#' ## For the [antivirals] data set: a [data.frame] with `r nrow(antivirals)` observations and `r ncol(antivirals)` variables:
|
||||
#' - `atc`\cr ATC code (Anatomical Therapeutic Chemical) as defined by the WHOCC
|
||||
#' - `cid`\cr Compound ID as found in PubChem
|
||||
#' - `name`\cr Official name as used by WHONET/EARS-Net or the WHO
|
||||
@ -57,7 +57,7 @@
|
||||
#'
|
||||
#' Synonyms (i.e. trade names) are derived from the Compound ID (`cid`) and consequently only available where a CID is available.
|
||||
#'
|
||||
#' ### Direct download
|
||||
#' ## Direct download
|
||||
#' These data sets are available as 'flat files' for use even without \R - you can find the files here:
|
||||
#'
|
||||
#' * <https://github.com/msberends/AMR/raw/master/data-raw/antibiotics.txt>
|
||||
@ -72,16 +72,16 @@
|
||||
#' WHONET 2019 software: <http://www.whonet.org/software.html>
|
||||
#'
|
||||
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: <http://ec.europa.eu/health/documents/community-register/html/atc.htm>
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection WHOCC WHOCC
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @seealso [microorganisms], [intrinsic_resistant]
|
||||
"antibiotics"
|
||||
|
||||
#' @rdname antibiotics
|
||||
"antivirals"
|
||||
|
||||
#' Data set with `r format(nrow(microorganisms), big.mark = ",")` microorganisms
|
||||
#' Data Set with `r format(nrow(microorganisms), big.mark = ",")` Microorganisms
|
||||
#'
|
||||
#' A data set containing the microbial taxonomy of six kingdoms from the Catalogue of Life. MO codes can be looked up using [as.mo()].
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
@ -92,10 +92,17 @@
|
||||
#' - `rank`\cr Text of the taxonomic rank of the microorganism, like `"species"` or `"genus"`
|
||||
#' - `ref`\cr Author(s) and year of concerning scientific publication
|
||||
#' - `species_id`\cr ID of the species as used by the Catalogue of Life
|
||||
#' - `source`\cr Either "CoL", "DSMZ" (see Source) or "manually added"
|
||||
#' - `source`\cr Either "CoL", "DSMZ" (see *Source*) or "manually added"
|
||||
#' - `prevalence`\cr Prevalence of the microorganism, see [as.mo()]
|
||||
#' - `snomed`\cr SNOMED code of the microorganism. Use [mo_snomed()] to retrieve it quickly, see [mo_property()].
|
||||
#' @details Manually added were:
|
||||
#' @details
|
||||
#' Please note that entries are only based on the Catalogue of Life and the LPSN (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect.
|
||||
#'
|
||||
#' For example, *Staphylococcus pettenkoferi* was newly named in Diagnostic Microbiology and Infectious Disease in 2002 (PMID 12106949), but it was not before 2007 that a publication in IJSEM followed (PMID 17625191). Consequently, the AMR package returns 2007 for `mo_year("S. pettenkoferi")`.
|
||||
#'
|
||||
#' ## Manually additions
|
||||
#' For convenience, some entries were added manually:
|
||||
#'
|
||||
#' - 11 entries of *Streptococcus* (beta-haemolytic: groups A, B, C, D, F, G, H, K and unspecified; other: viridans, milleri)
|
||||
#' - 2 entries of *Staphylococcus* (coagulase-negative (CoNS) and coagulase-positive (CoPS))
|
||||
#' - 3 entries of *Trichomonas* (*Trichomonas vaginalis*, and its family and genus)
|
||||
@ -105,7 +112,7 @@
|
||||
#' - 6 families under the Enterobacterales order, according to Adeolu *et al.* (2016, PMID 27620848), that are not (yet) in the Catalogue of Life
|
||||
#' - `r format(nrow(subset(microorganisms, source == "DSMZ")), big.mark = ",")` species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) since the DSMZ contain the latest taxonomic information based on recent publications
|
||||
#'
|
||||
#' ### Direct download
|
||||
#' ## Direct download
|
||||
#' This data set is available as 'flat file' for use even without \R - you can find the file here:
|
||||
#'
|
||||
#' * <https://github.com/msberends/AMR/raw/master/data-raw/microorganisms.txt>
|
||||
@ -113,7 +120,7 @@
|
||||
#' The file in \R format (with preserved data structure) can be found here:
|
||||
#'
|
||||
#' * <https://github.com/msberends/AMR/raw/master/data/microorganisms.rda>
|
||||
#' @section About the records from DSMZ (see source):
|
||||
#' @section About the Records from DSMZ (see *Source*):
|
||||
#' Names of prokaryotes are defined as being validly published by the International Code of Nomenclature of Bacteria. Validly published are all names which are included in the Approved Lists of Bacterial Names and the names subsequently published in the International Journal of Systematic Bacteriology (IJSB) and, from January 2000, in the International Journal of Systematic and Evolutionary Microbiology (IJSEM) as original articles or in the validation lists.
|
||||
#' *(from <https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date>)*
|
||||
#'
|
||||
@ -123,8 +130,8 @@
|
||||
#' Parte, A.C. (2018). LPSN — List of Prokaryotic names with Standing in Nomenclature (bacterio.net), 20 years on. International Journal of Systematic and Evolutionary Microbiology, 68, 1825-1829; \doi{10.1099/ijsem.0.002786}
|
||||
#'
|
||||
#' Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures, Germany, Prokaryotic Nomenclature Up-to-Date, <https://www.dsmz.de/services/online-tools/prokaryotic-nomenclature-up-to-date> and <https://lpsn.dsmz.de> (check included version with [catalogue_of_life_version()]).
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @seealso [as.mo()], [mo_property()], [microorganisms.codes], [intrinsic_resistant]
|
||||
"microorganisms"
|
||||
|
||||
@ -136,7 +143,7 @@ catalogue_of_life <- list(
|
||||
yearmonth_DSMZ = "May 2020"
|
||||
)
|
||||
|
||||
#' Data set with previously accepted taxonomic names
|
||||
#' Data Set with Previously Accepted Taxonomic Names
|
||||
#'
|
||||
#' A data set containing old (previously valid or accepted) taxonomic names according to the Catalogue of Life. This data set is used internally by [as.mo()].
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
@ -148,24 +155,24 @@ catalogue_of_life <- list(
|
||||
#' @source Catalogue of Life: Annual Checklist (public online taxonomic database), <http://www.catalogueoflife.org> (check included annual version with [catalogue_of_life_version()]).
|
||||
#'
|
||||
#' Parte, A.C. (2018). LPSN — List of Prokaryotic names with Standing in Nomenclature (bacterio.net), 20 years on. International Journal of Systematic and Evolutionary Microbiology, 68, 1825-1829; \doi{10.1099/ijsem.0.002786}
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @seealso [as.mo()] [mo_property()] [microorganisms]
|
||||
"microorganisms.old"
|
||||
|
||||
#' Data set with `r format(nrow(microorganisms.codes), big.mark = ",")` common microorganism codes
|
||||
#' Data Set with `r format(nrow(microorganisms.codes), big.mark = ",")` Common Microorganism Codes
|
||||
#'
|
||||
#' A data set containing commonly used codes for microorganisms, from laboratory systems and WHONET. Define your own with [set_mo_source()]. They will all be searched when using [as.mo()] and consequently all the [`mo_*`][mo_property()] functions.
|
||||
#' @format A [data.frame] with `r format(nrow(microorganisms.codes), big.mark = ",")` observations and `r ncol(microorganisms.codes)` variables:
|
||||
#' - `code`\cr Commonly used code of a microorganism
|
||||
#' - `mo`\cr ID of the microorganism in the [microorganisms] data set
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @seealso [as.mo()] [microorganisms]
|
||||
"microorganisms.codes"
|
||||
|
||||
#' Data set with `r format(nrow(example_isolates), big.mark = ",")` example isolates
|
||||
#' Data Set with `r format(nrow(example_isolates), big.mark = ",")` Example Isolates
|
||||
#'
|
||||
#' A data set containing `r format(nrow(example_isolates), big.mark = ",")` microbial isolates with their full antibiograms. The data set reflects reality and can be used to practice AMR analysis. For examples, please read [the tutorial on our website](https://msberends.github.io/AMR/articles/AMR.html).
|
||||
#' @format A [data.frame] with `r format(nrow(example_isolates), big.mark = ",")` observations and `r ncol(example_isolates)` variables:
|
||||
@ -179,11 +186,11 @@ catalogue_of_life <- list(
|
||||
#' - `patient_id`\cr ID of the patient
|
||||
#' - `mo`\cr ID of microorganism created with [as.mo()], see also [microorganisms]
|
||||
#' - `PEN:RIF`\cr `r sum(vapply(FUN.VALUE = logical(1), example_isolates, is.rsi))` different antibiotics with class [`rsi`] (see [as.rsi()]); these column names occur in the [antibiotics] data set and can be translated with [ab_name()]
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
"example_isolates"
|
||||
|
||||
#' Data set with unclean data
|
||||
#' Data Set with Unclean Data
|
||||
#'
|
||||
#' A data set containing `r format(nrow(example_isolates_unclean), big.mark = ",")` microbial isolates that are not cleaned up and consequently not ready for AMR analysis. This data set can be used for practice.
|
||||
#' @format A [data.frame] with `r format(nrow(example_isolates_unclean), big.mark = ",")` observations and `r ncol(example_isolates_unclean)` variables:
|
||||
@ -192,11 +199,11 @@ catalogue_of_life <- list(
|
||||
#' - `hospital`\cr ID of the hospital, from A to C
|
||||
#' - `bacteria`\cr info about microorganism that can be transformed with [as.mo()], see also [microorganisms]
|
||||
#' - `AMX:GEN`\cr 4 different antibiotics that have to be transformed with [as.rsi()]
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
"example_isolates_unclean"
|
||||
|
||||
#' Data set with `r format(nrow(WHONET), big.mark = ",")` isolates - WHONET example
|
||||
#' Data Set with `r format(nrow(WHONET), big.mark = ",")` Isolates - WHONET Example
|
||||
#'
|
||||
#' This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The antibiotic results are from our [example_isolates] data set. All patient names are created using online surname generators and are only in place for practice purposes.
|
||||
#' @format A [data.frame] with `r format(nrow(WHONET), big.mark = ",")` observations and `r ncol(WHONET)` variables:
|
||||
@ -226,11 +233,11 @@ catalogue_of_life <- list(
|
||||
#' - `Comment`\cr Other comments
|
||||
#' - `Date of data entry`\cr Date this data was entered in WHONET
|
||||
#' - `AMP_ND10:CIP_EE`\cr `r sum(vapply(FUN.VALUE = logical(1), WHONET, is.rsi))` different antibiotics. You can lookup the abbreviations in the [antibiotics] data set, or use e.g. [`ab_name("AMP")`][ab_name()] to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using [as.rsi()].
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
"WHONET"
|
||||
|
||||
#' Data set for R/SI interpretation
|
||||
#' Data Set for R/SI Interpretation
|
||||
#'
|
||||
#' Data set to interpret MIC and disk diffusion to R/SI values. Included guidelines are 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)))`) and 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)))`). Use [as.rsi()] to transform MICs or disks measurements to R/SI values.
|
||||
#' @format A [data.frame] with `r format(nrow(rsi_translation), big.mark = ",")` observations and `r ncol(rsi_translation)` variables:
|
||||
@ -245,12 +252,12 @@ catalogue_of_life <- list(
|
||||
#' - `breakpoint_R`\cr Highest MIC value or lowest number of millimetres that leads to "R"
|
||||
#' - `uti`\cr A logical value (`TRUE`/`FALSE`) to indicate whether the rule applies to a urinary tract infection (UTI)
|
||||
#' @details The repository of this `AMR` package contains a file comprising this exact data set: <https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt>. This file **allows for machine reading EUCAST and CLSI guidelines**, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically.
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @seealso [intrinsic_resistant]
|
||||
"rsi_translation"
|
||||
|
||||
#' Data set with bacterial intrinsic resistance
|
||||
#' Data Set with Bacterial Intrinsic Resistance
|
||||
#'
|
||||
#' Data set containing defined intrinsic resistance by EUCAST of all bug-drug combinations.
|
||||
#' @format A [data.frame] with `r format(nrow(intrinsic_resistant), big.mark = ",")` observations and `r ncol(intrinsic_resistant)` variables:
|
||||
@ -259,8 +266,8 @@ catalogue_of_life <- list(
|
||||
#' @details The repository of this `AMR` package contains a file comprising this exact data set: <https://github.com/msberends/AMR/blob/master/data-raw/intrinsic_resistant.txt>. This file **allows for machine reading EUCAST guidelines about intrinsic resistance**, which is almost impossible with the Excel and PDF files distributed by EUCAST. The file is updated automatically.
|
||||
#'
|
||||
#' This data set is based on `r format_eucast_version_nr(3.2)`.
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' if (require("dplyr")) {
|
||||
#' intrinsic_resistant %>%
|
||||
@ -269,3 +276,21 @@ catalogue_of_life <- list(
|
||||
#' # [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"
|
||||
#' }
|
||||
"intrinsic_resistant"
|
||||
|
||||
#' Data Set with Treatment Dosages as Defined by EUCAST
|
||||
#'
|
||||
#' EUCAST breakpoints used in this package are based on the dosages in this data set. They can be retrieved with [eucast_dosage()].
|
||||
#' @format A [data.frame] with `r format(nrow(dosage), big.mark = ",")` observations and `r ncol(dosage)` variables:
|
||||
#' - `ab`\cr Antibiotic ID as used in this package (such as `AMC`), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available
|
||||
#' - `name`\cr Official name of the antimicrobial agent as used by WHONET/EARS-Net or the WHO
|
||||
#' - `type`\cr Type of the dosage, either `r vector_or(dosage$type)`
|
||||
#' - `dose`\cr Dose, such as "2 g" or "25 mg/kg"
|
||||
#' - `dose_times`\cr Number of times a dose must be administered
|
||||
#' - `administration`\cr Route of administration, either `r vector_or(dosage$administration)`
|
||||
#' - `notes`\cr Additional dosage notes
|
||||
#' - `original_txt`\cr Original text in the PDF file of EUCAST
|
||||
#' - `eucast_version`\cr Version number of the EUCAST Clinical Breakpoints guideline to which these dosages apply
|
||||
#' @details `r format_eucast_version_nr(11.0)` are based on the dosages in this data set.
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
"dosage"
|
||||
|
@ -23,11 +23,11 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Deprecated functions
|
||||
#' Deprecated Functions
|
||||
#'
|
||||
#' These functions are so-called '[Deprecated]'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
|
||||
#' @inheritSection lifecycle Retired lifecycle
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection lifecycle Retired Lifecycle
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @keywords internal
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
|
8
R/disk.R
8
R/disk.R
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Transform input to disk diffusion diameters
|
||||
#' Transform Input to Disk Diffusion Diameters
|
||||
#'
|
||||
#' This transforms a vector to a new class [`disk`], which is a disk diffusion growth zone size (around an antibiotic disk) in millimetres between 6 and 50.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @rdname as.disk
|
||||
#' @param x vector
|
||||
#' @param na.rm a logical indicating whether missing values should be removed
|
||||
@ -35,7 +35,7 @@
|
||||
#' @aliases disk
|
||||
#' @export
|
||||
#' @seealso [as.rsi()]
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' # transform existing disk zones to the `disk` class
|
||||
@ -61,7 +61,7 @@ as.disk <- function(x, na.rm = FALSE) {
|
||||
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||
|
||||
if (!is.disk(x)) {
|
||||
x <- x %pm>% unlist()
|
||||
x <- unlist(x)
|
||||
if (na.rm == TRUE) {
|
||||
x <- x[!is.na(x)]
|
||||
}
|
||||
|
38
R/episode.R
38
R/episode.R
@ -23,13 +23,13 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Determine (new) episodes for patients
|
||||
#' Determine (New) Episodes for Patients
|
||||
#'
|
||||
#' These functions determine which items in a vector can be considered (the start of) a new episode, based on the argument `episode_days`. This can be used to determine clinical episodes for any epidemiological analysis. The [get_episode()] function returns the index number of the episode per group, while the [is_new_episode()] function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x vector of dates (class `Date` or `POSIXt`)
|
||||
#' @param episode_days length of the required episode in days, please see *Details*
|
||||
#' @param ... arguments passed on to [as.Date()]
|
||||
#' @param episode_days required episode length in days, can also be less than a day, see *Details*
|
||||
#' @param ... currently not used
|
||||
#' @details
|
||||
#' Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least `episode_days` days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least `episode_days` days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.
|
||||
#'
|
||||
@ -42,17 +42,22 @@
|
||||
#' @seealso [first_isolate()]
|
||||
#' @rdname get_episode
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # `example_isolates` is a dataset available in the AMR package.
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' get_episode(example_isolates$date, episode_days = 60)
|
||||
#' is_new_episode(example_isolates$date, episode_days = 60)
|
||||
#' get_episode(example_isolates$date, episode_days = 60) # indices
|
||||
#' is_new_episode(example_isolates$date, episode_days = 60) # TRUE/FALSE
|
||||
#'
|
||||
#' # filter on results from the third 60-day episode only, using base R
|
||||
#' example_isolates[which(get_episode(example_isolates$date, 60) == 3), ]
|
||||
#'
|
||||
#' # the functions also work for less than a day, e.g. to include one per hour:
|
||||
#' get_episode(c(Sys.time(),
|
||||
#' Sys.time() + 60 * 60),
|
||||
#' episode_days = 1/24)
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' # is_new_episode() can also be used in dplyr verbs to determine patient
|
||||
@ -100,7 +105,7 @@
|
||||
#' }
|
||||
get_episode <- function(x, episode_days, ...) {
|
||||
meet_criteria(x, allow_class = c("Date", "POSIXt"))
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "double", "integer"), has_length = 1)
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
|
||||
exec_episode(type = "sequential",
|
||||
x = x,
|
||||
@ -112,7 +117,7 @@ get_episode <- function(x, episode_days, ...) {
|
||||
#' @export
|
||||
is_new_episode <- function(x, episode_days, ...) {
|
||||
meet_criteria(x, allow_class = c("Date", "POSIXt"))
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "double", "integer"), has_length = 1)
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
|
||||
exec_episode(type = "logical",
|
||||
x = x,
|
||||
@ -121,7 +126,10 @@ is_new_episode <- function(x, episode_days, ...) {
|
||||
}
|
||||
|
||||
exec_episode <- function(type, x, episode_days, ...) {
|
||||
x <- as.double(as.Date(x, ...)) # as.Date() for POSIX classes
|
||||
x <- as.double(as.POSIXct(x)) # as.POSIXct() for Date classes
|
||||
# since x is now in seconds, get seconds from episode_days as well
|
||||
episode_seconds <- episode_days * 60 * 60 * 24
|
||||
|
||||
if (length(x) == 1) {
|
||||
if (type == "logical") {
|
||||
return(TRUE)
|
||||
@ -129,7 +137,7 @@ exec_episode <- function(type, x, episode_days, ...) {
|
||||
return(1)
|
||||
}
|
||||
} else if (length(x) == 2) {
|
||||
if (max(x) - min(x) >= episode_days) {
|
||||
if (max(x) - min(x) >= episode_seconds) {
|
||||
if (type == "logical") {
|
||||
return(c(TRUE, TRUE))
|
||||
} else if (type == "sequential") {
|
||||
@ -146,13 +154,13 @@ exec_episode <- function(type, x, episode_days, ...) {
|
||||
|
||||
# I asked on StackOverflow:
|
||||
# https://stackoverflow.com/questions/42122245/filter-one-row-every-year
|
||||
exec <- function(x, episode_days) {
|
||||
exec <- function(x, episode_seconds) {
|
||||
indices <- integer()
|
||||
start <- x[1]
|
||||
ind <- 1
|
||||
indices[1] <- 1
|
||||
for (i in 2:length(x)) {
|
||||
if (isTRUE((x[i] - start) >= episode_days)) {
|
||||
if (isTRUE((x[i] - start) >= episode_seconds)) {
|
||||
ind <- ind + 1
|
||||
if (type == "logical") {
|
||||
indices[ind] <- i
|
||||
@ -175,7 +183,7 @@ exec_episode <- function(type, x, episode_days, ...) {
|
||||
df <- data.frame(x = x,
|
||||
y = seq_len(length(x))) %pm>%
|
||||
pm_arrange(x)
|
||||
df$new <- exec(df$x, episode_days)
|
||||
df$new <- exec(df$x, episode_seconds)
|
||||
df %pm>%
|
||||
pm_arrange(y) %pm>%
|
||||
pm_pull(new)
|
||||
|
115
R/eucast_rules.R
115
R/eucast_rules.R
@ -23,12 +23,16 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
# add new version numbers here, and add the rules themselves to "data-raw/eucast_rules.tsv"
|
||||
# (running "data-raw/internals.R" will process that TSV file)
|
||||
EUCAST_VERSION_BREAKPOINTS <- list("10.0" = list(version_txt = "v10.0",
|
||||
# add new version numbers here, and add the rules themselves to "data-raw/eucast_rules.tsv" and rsi_translation
|
||||
# (running "data-raw/internals.R" will process the TSV file)
|
||||
EUCAST_VERSION_BREAKPOINTS <- list("11.0" = list(version_txt = "v11.0",
|
||||
year = 2021,
|
||||
title = "'EUCAST Clinical Breakpoint Tables'",
|
||||
url = "https://www.eucast.org/clinical_breakpoints/"),
|
||||
"10.0" = list(version_txt = "v10.0",
|
||||
year = 2020,
|
||||
title = "'EUCAST Clinical Breakpoints'",
|
||||
url = "https://www.eucast.org/clinical_breakpoints/"))
|
||||
title = "'EUCAST Clinical Breakpoint Tables'",
|
||||
url = "https://www.eucast.org/ast_of_bacteria/previous_versions_of_documents/"))
|
||||
EUCAST_VERSION_EXPERT_RULES <- list("3.1" = list(version_txt = "v3.1",
|
||||
year = 2016,
|
||||
title = "'EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes'",
|
||||
@ -41,32 +45,38 @@ EUCAST_VERSION_EXPERT_RULES <- list("3.1" = list(version_txt = "v3.1",
|
||||
format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
# for documentation - adds title, version number, year and url in markdown language
|
||||
lst <- c(EUCAST_VERSION_BREAKPOINTS, EUCAST_VERSION_EXPERT_RULES)
|
||||
version <- format(version, nsmall = 1)
|
||||
if (markdown == TRUE) {
|
||||
paste0("[", lst[[version]]$title, " ", lst[[version]]$version_txt, "](", lst[[version]]$url, ")",
|
||||
" from ", lst[[version]]$year)
|
||||
} else {
|
||||
paste0(lst[[version]]$title, " ", lst[[version]]$version_txt,
|
||||
" from ", lst[[version]]$year)
|
||||
version <- format(unique(version), nsmall = 1)
|
||||
txt <- character(0)
|
||||
for (i in seq_len(length(version))) {
|
||||
v <- version[i]
|
||||
if (markdown == TRUE) {
|
||||
txt <- c(txt, paste0("[", lst[[v]]$title, " ", lst[[v]]$version_txt, "](", lst[[v]]$url, ")",
|
||||
" (", lst[[v]]$year, ")"))
|
||||
} else {
|
||||
txt <- c(txt, paste0(lst[[version]]$title, " ", lst[[v]]$version_txt,
|
||||
" (", lst[[v]]$year, ")"))
|
||||
}
|
||||
}
|
||||
paste0(txt, collapse = ", ")
|
||||
}
|
||||
|
||||
#' Apply EUCAST rules
|
||||
#' Apply EUCAST Rules
|
||||
#'
|
||||
#' @description
|
||||
#' Apply rules for clinical breakpoints and intrinsic resistance as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, <https://eucast.org>), see *Source*.
|
||||
#' Apply rules for clinical breakpoints and intrinsic resistance as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, <https://eucast.org>), see *Source*. Use [eucast_dosage()] to get a [data.frame] with advised dosages of a certain bug-drug combination, which is based on the [dosage] data set.
|
||||
#'
|
||||
#' To improve the interpretation of the antibiogram before EUCAST rules are applied, some non-EUCAST rules can applied at default, see Details.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' To improve the interpretation of the antibiogram before EUCAST rules are applied, some non-EUCAST rules can applied at default, see *Details*.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x data with antibiotic columns, such as `amox`, `AMX` and `AMC`
|
||||
#' @param info a logical to indicate whether progress should be printed to the console, defaults to only print while in interactive sessions
|
||||
#' @param rules a character vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`.
|
||||
#' @param verbose a [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way. Using Verbose mode takes a lot more time.
|
||||
#' @param version_breakpoints the version number to use for the EUCAST Clinical Breakpoints guideline. Currently supported: `r paste0(names(EUCAST_VERSION_BREAKPOINTS), collapse = ", ")`.
|
||||
#' @param version_expertrules the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Currently supported: `r paste0(names(EUCAST_VERSION_EXPERT_RULES), collapse = ", ")`.
|
||||
#' @param ampc_cephalosporin_resistance a character value that should be applied for AmpC de-repressed cephalosporin-resistant mutants, defaults to `NA`. Currently only works when `version_expertrules` is `3.2`; '*EUCAST Expert Rules v3.2 on Enterobacterales*' states that susceptible (S) results of cefotaxime, ceftriaxone and ceftazidime should be reported with a note, or results should be suppressed (emptied) for these agents. A value of `NA` for this argument will remove results for these agents, while e.g. a value of `"R"` will make the results for these agents resistant. Use `NULL` to not alter the results for AmpC de-repressed cephalosporin-resistant mutants. \cr For *EUCAST Expert Rules* v3.2, this rule applies to: *`r gsub("[)(^]", "", gsub("|", ", ", eucast_rules_file[which(eucast_rules_file$reference.version == 3.2 & eucast_rules_file$reference.rule %like% "ampc"), "this_value"][1], fixed = TRUE))`*.
|
||||
#'
|
||||
#' @param ... column name of an antibiotic, please see section *Antibiotics* below
|
||||
#' @param version_breakpoints the version number to use for the EUCAST Clinical Breakpoints guideline. Can be either `r vector_or(names(EUCAST_VERSION_BREAKPOINTS), reverse = TRUE)`.
|
||||
#' @param version_expertrules the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be either `r vector_or(names(EUCAST_VERSION_EXPERT_RULES), reverse = TRUE)`.
|
||||
#' @param ampc_cephalosporin_resistance a character value that should be applied for AmpC de-repressed cephalosporin-resistant mutants, defaults to `NA`. Currently only works when `version_expertrules` is `3.2`; '*EUCAST Expert Rules v3.2 on Enterobacterales*' states that results of cefotaxime, ceftriaxone and ceftazidime should be reported with a note, or results should be suppressed (emptied) for these agents. A value of `NA` for this argument will remove results for these agents, while e.g. a value of `"R"` will make the results for these agents resistant. Use `NULL` to not alter the results for AmpC de-repressed cephalosporin-resistant mutants. \cr For *EUCAST Expert Rules* v3.2, this rule applies to: `r vector_or(gsub("[^a-zA-Z ]+", "", unlist(strsplit(eucast_rules_file[which(eucast_rules_file$reference.version == 3.2 & eucast_rules_file$reference.rule %like% "ampc"), "this_value"][1], "|", fixed = TRUE))), quotes = "*", last_sep = " and ")`.
|
||||
#' @param ... column name of an antibiotic, see section *Antibiotics* below
|
||||
#' @param ab any (vector of) text that can be coerced to a valid antibiotic code with [as.ab()]
|
||||
#' @param administration route of administration, either `r vector_or(dosage$administration)`
|
||||
#' @inheritParams first_isolate
|
||||
#' @details
|
||||
#' **Note:** This function does not translate MIC values to RSI values. Use [as.rsi()] for that. \cr
|
||||
@ -74,7 +84,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
#'
|
||||
#' The file containing all EUCAST rules is located here: <https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv>.
|
||||
#'
|
||||
#' ## 'Other' rules
|
||||
#' ## 'Other' Rules
|
||||
#'
|
||||
#' Before further processing, two non-EUCAST rules about drug combinations can be applied to improve the efficacy of the EUCAST rules, and the reliability of your data (analysis). These rules are:
|
||||
#'
|
||||
@ -101,8 +111,9 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
#' - EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.2, 2020. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf)
|
||||
#' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 9.0, 2019. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_9.0_Breakpoint_Tables.xlsx)
|
||||
#' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 10.0, 2020. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_10.0_Breakpoint_Tables.xlsx)
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 11.0, 2021. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_11.0_Breakpoint_Tables.xlsx)
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' a <- data.frame(mo = c("Staphylococcus aureus",
|
||||
@ -144,12 +155,14 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
#' # containing all details about the transformations:
|
||||
#' c <- eucast_rules(a, verbose = TRUE)
|
||||
#' }
|
||||
#'
|
||||
#' eucast_dosage(c("tobra", "genta", "cipro"), "iv")
|
||||
eucast_rules <- function(x,
|
||||
col_mo = NULL,
|
||||
info = interactive(),
|
||||
rules = getOption("AMR_eucastrules", default = c("breakpoints", "expert")),
|
||||
verbose = FALSE,
|
||||
version_breakpoints = 10.0,
|
||||
version_breakpoints = 11.0,
|
||||
version_expertrules = 3.2,
|
||||
ampc_cephalosporin_resistance = NA,
|
||||
...) {
|
||||
@ -158,9 +171,9 @@ eucast_rules <- function(x,
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(rules, allow_class = "character", has_length = c(1, 2, 3, 4), is_in = c("breakpoints", "expert", "other", "all"))
|
||||
meet_criteria(verbose, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(version_breakpoints, allow_class = "numeric", has_length = 1)
|
||||
meet_criteria(version_expertrules, allow_class = "numeric", has_length = 1)
|
||||
meet_criteria(ampc_cephalosporin_resistance, allow_class = c("rsi", "character"), has_length = 1, allow_NA = TRUE, allow_NULL = TRUE, is_in = c("R", "S", "I"))
|
||||
meet_criteria(version_breakpoints, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_BREAKPOINTS)))
|
||||
meet_criteria(version_expertrules, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_EXPERT_RULES)))
|
||||
meet_criteria(ampc_cephalosporin_resistance, has_length = 1, allow_NA = TRUE, allow_NULL = TRUE, is_in = c("R", "S", "I"))
|
||||
|
||||
x_deparsed <- deparse(substitute(x))
|
||||
if (length(x_deparsed) > 1 || !all(x_deparsed %like% "[a-z]+")) {
|
||||
@ -169,12 +182,6 @@ eucast_rules <- function(x,
|
||||
|
||||
check_dataset_integrity()
|
||||
|
||||
version_breakpoints <- as.double(gsub("[^0-9.]+", "", version_breakpoints))
|
||||
version_expertrules <- as.double(gsub("[^0-9.]+", "", version_expertrules))
|
||||
stop_ifnot(version_breakpoints %in% as.double(names(EUCAST_VERSION_BREAKPOINTS)),
|
||||
"EUCAST version ", version_breakpoints, " for clinical breakpoints not found")
|
||||
stop_ifnot(version_expertrules %in% as.double(names(EUCAST_VERSION_EXPERT_RULES)),
|
||||
"EUCAST version ", version_expertrules, " for expert rules/intrinsic resistance not found")
|
||||
breakpoints_info <- EUCAST_VERSION_BREAKPOINTS[[which(as.double(names(EUCAST_VERSION_BREAKPOINTS)) == version_breakpoints)]]
|
||||
expertrules_info <- EUCAST_VERSION_EXPERT_RULES[[which(as.double(names(EUCAST_VERSION_EXPERT_RULES)) == version_expertrules)]]
|
||||
|
||||
@ -203,8 +210,10 @@ eucast_rules <- function(x,
|
||||
# -- mo
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo", info = info)
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
} else {
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
}
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
|
||||
decimal.mark <- getOption("OutDec")
|
||||
big.mark <- ifelse(decimal.mark != ",", ",", ".")
|
||||
@ -1040,6 +1049,7 @@ eucast_rules <- function(x,
|
||||
warn_lacking_rsi_class <- unique(warn_lacking_rsi_class)
|
||||
warning_("Not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
|
||||
" ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" ", x_deparsed, " %>% mutate(across((is.rsi.eligible), as.rsi))\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)])),
|
||||
@ -1168,3 +1178,38 @@ edit_rsi <- function(x,
|
||||
}
|
||||
return(track_changes)
|
||||
}
|
||||
|
||||
#' @rdname eucast_rules
|
||||
#' @export
|
||||
eucast_dosage <- function(ab, administration = "iv", version_breakpoints = 11.0) {
|
||||
meet_criteria(ab, allow_class = c("character", "numeric", "integer", "factor"))
|
||||
meet_criteria(administration, allow_class = "character", is_in = dosage$administration[!is.na(dosage$administration)], has_length = 1)
|
||||
meet_criteria(version_breakpoints, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_BREAKPOINTS)))
|
||||
|
||||
# show used version_breakpoints number once per session (pkg_env will reload every session)
|
||||
if (message_not_thrown_before(paste0("eucast_dosage_v", gsub("[^0-9]", "", version_breakpoints)), entire_session = TRUE)) {
|
||||
message_("Dosages for antimicrobial drugs, as meant for ",
|
||||
format_eucast_version_nr(version_breakpoints, markdown = FALSE), ". ",
|
||||
font_red("This note will be shown once per session."))
|
||||
remember_thrown_message(paste0("eucast_dosage_v", gsub("[^0-9]", "", version_breakpoints)), entire_session = TRUE)
|
||||
}
|
||||
|
||||
ab <- as.ab(ab)
|
||||
lst <- vector("list", length = length(ab))
|
||||
for (i in seq_len(length(ab))) {
|
||||
df <- AMR::dosage[which(AMR::dosage$ab == ab[i] & AMR::dosage$administration == administration), , drop = FALSE]
|
||||
lst[[i]] <- list(ab = "",
|
||||
name = "",
|
||||
standard_dosage = ifelse("standard_dosage" %in% df$type,
|
||||
df[which(df$type == "standard_dosage"), ]$original_txt,
|
||||
NA_character_),
|
||||
high_dosage = ifelse("high_dosage" %in% df$type,
|
||||
df[which(df$type == "high_dosage"), ]$original_txt,
|
||||
NA_character_))
|
||||
}
|
||||
out <- do.call("rbind", lapply(lst, as.data.frame, stringsAsFactors = FALSE))
|
||||
rownames(out) <- NULL
|
||||
out$ab <- ab
|
||||
out$name <- ab_name(ab, language = NULL)
|
||||
out
|
||||
}
|
||||
|
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Filter isolates on result in antimicrobial class
|
||||
#' Filter Isolates on Result in Antimicrobial Class
|
||||
#'
|
||||
#' Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a data set
|
||||
#' @param ab_class an antimicrobial class, like `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value.
|
||||
#' @param result an antibiotic result: S, I or R (or a combination of more of them)
|
||||
@ -70,10 +70,11 @@
|
||||
#' filter_aminoglycosides("R", "all") %>%
|
||||
#' filter_fluoroquinolones("R", "all")
|
||||
#'
|
||||
#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
|
||||
#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal:
|
||||
#' # (though the row names on the first are more correct)
|
||||
#' example_isolates %>% filter_carbapenems("R", "all")
|
||||
#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
|
||||
#' example_isolates %>% filter(across(carbapenems(), function(x) x == "R"))
|
||||
#' }
|
||||
#' }
|
||||
filter_ab_class <- function(x,
|
||||
@ -129,7 +130,7 @@ filter_ab_class <- function(x,
|
||||
# get the columns with a group names in the chosen ab class
|
||||
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
||||
if (length(agents) == 0) {
|
||||
message_("NOTE: no antimicrobial agents of class ", ab_group,
|
||||
message_("no antimicrobial agents of class ", ab_group,
|
||||
" found (such as ", find_ab_names(ab_class, 2),
|
||||
"), data left unchanged.")
|
||||
return(x.bak)
|
||||
|
@ -23,39 +23,39 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Determine first (weighted) isolates
|
||||
#' Determine First (Weighted) Isolates
|
||||
#'
|
||||
#' Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use [is_new_episode()] that also supports grouping with the `dplyr` package.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @param x a [data.frame] containing isolates. Can be left blank when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()].
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame] containing isolates. Can be left blank for automatic determination.
|
||||
#' @param col_date column name of the result date (or date that is was received on the lab), defaults to the first column with a date class
|
||||
#' @param col_patient_id column name of the unique IDs of the patients, defaults to the first column that starts with 'patient' or 'patid' (case insensitive)
|
||||
#' @param col_mo column name of the IDs of the microorganisms (see [as.mo()]), defaults to the first column of class [`mo`]. Values will be coerced using [as.mo()].
|
||||
#' @param col_testcode column name of the test codes. Use `col_testcode = NULL` to **not** exclude certain test codes (such as test codes for screening). In that case `testcodes_exclude` will be ignored.
|
||||
#' @param col_specimen column name of the specimen type or group
|
||||
#' @param col_icu column name of the logicals (`TRUE`/`FALSE`) whether a ward or department is an Intensive Care Unit (ICU)
|
||||
#' @param col_keyantibiotics column name of the key antibiotics to determine first *weighted* isolates, see [key_antibiotics()]. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' (case insensitive). Use `col_keyantibiotics = FALSE` to prevent this.
|
||||
#' @param episode_days episode in days after which a genus/species combination will be determined as 'first isolate' again. The default of 365 days is based on the guideline by CLSI, see Source.
|
||||
#' @param col_keyantibiotics column name of the key antibiotics to determine first (weighted) isolates, see [key_antibiotics()]. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' (case insensitive). Use `col_keyantibiotics = FALSE` to prevent this.
|
||||
#' @param episode_days episode in days after which a genus/species combination will be determined as 'first isolate' again. The default of 365 days is based on the guideline by CLSI, see *Source*.
|
||||
#' @param testcodes_exclude character vector with test codes that should be excluded (case-insensitive)
|
||||
#' @param icu_exclude logical whether ICU isolates should be excluded (rows with value `TRUE` in the column set with `col_icu`)
|
||||
#' @param specimen_group value in the column set with `col_specimen` to filter on
|
||||
#' @param type type to determine weighed isolates; can be `"keyantibiotics"` or `"points"`, see Details
|
||||
#' @param ignore_I logical to determine whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantibiotics"`, see Details
|
||||
#' @param points_threshold points until the comparison of key antibiotics will lead to inclusion of an isolate when `type = "points"`, see Details
|
||||
#' @param type type to determine weighed isolates; can be `"keyantibiotics"` or `"points"`, see *Details*
|
||||
#' @param ignore_I logical to determine whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantibiotics"`, see *Details*
|
||||
#' @param points_threshold points until the comparison of key antibiotics will lead to inclusion of an isolate when `type = "points"`, see *Details*
|
||||
#' @param info print progress
|
||||
#' @param include_unknown logical to determine whether 'unknown' microorganisms should be included too, i.e. microbial code `"UNKNOWN"`, which defaults to `FALSE`. For WHONET users, this means that all records with organism code `"con"` (*contamination*) will be excluded at default. Isolates with a microbial ID of `NA` will always be excluded as first isolate.
|
||||
#' @param ... arguments passed on to [first_isolate()] when using [filter_first_isolate()], or arguments passed on to [key_antibiotics()] when using [filter_first_weighted_isolate()]
|
||||
#' @details
|
||||
#' These functions are context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be left blank, please see *Examples*.
|
||||
#' These functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#'
|
||||
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but more efficient for data sets containing microorganism codes or names.
|
||||
#'
|
||||
#' All isolates with a microbial ID of `NA` will be excluded as first isolate.
|
||||
#'
|
||||
#' ### Why this is so important
|
||||
#' ## Why this is so Important
|
||||
#' To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode [(Hindler *et al.* 2007)](https://pubmed.ncbi.nlm.nih.gov/17304462/). If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following week. The resistance percentage of oxacillin of all *S. aureus* isolates would be overestimated, because you included this MRSA more than once. It would be [selection bias](https://en.wikipedia.org/wiki/Selection_bias).
|
||||
#'
|
||||
#' ### `filter_*()` shortcuts
|
||||
#' ## `filter_*()` Shortcuts
|
||||
#'
|
||||
#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates.
|
||||
#'
|
||||
@ -77,8 +77,8 @@
|
||||
#' filter(only_weighted_firsts == TRUE) %>%
|
||||
#' select(-only_weighted_firsts, -keyab)
|
||||
#' ```
|
||||
#' @section Key antibiotics:
|
||||
#' There are two ways to determine whether isolates can be included as first *weighted* isolates which will give generally the same results:
|
||||
#' @section Key Antibiotics:
|
||||
#' There are two ways to determine whether isolates can be included as first weighted isolates which will give generally the same results:
|
||||
#'
|
||||
#' 1. Using `type = "keyantibiotics"` and argument `ignore_I`
|
||||
#'
|
||||
@ -94,9 +94,9 @@
|
||||
#' @source Methodology of this function is strictly based on:
|
||||
#'
|
||||
#' **M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition**, 2014, *Clinical and Laboratory Standards Institute (CLSI)*. <https://clsi.org/standards/products/microbiology/documents/m39/>.
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # `example_isolates` is a dataset available in the AMR package.
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' # basic filtering on first isolates
|
||||
@ -172,20 +172,20 @@ first_isolate <- function(x,
|
||||
col_keyantibiotics <- NULL
|
||||
}
|
||||
meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(testcodes_exclude, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(icu_exclude, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(specimen_group, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(type, allow_class = "character", has_length = 1)
|
||||
meet_criteria(ignore_I, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(include_unknown, allow_class = "logical", has_length = 1)
|
||||
|
||||
dots <- unlist(list(...))
|
||||
if (length(dots) != 0) {
|
||||
# backwards compatibility with old arguments
|
||||
dots.names <- dots %pm>% names()
|
||||
dots.names <- names(dots)
|
||||
if ("filter_specimen" %in% dots.names) {
|
||||
specimen_group <- dots[which(dots.names == "filter_specimen")]
|
||||
}
|
||||
@ -202,7 +202,6 @@ first_isolate <- function(x,
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo")
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
}
|
||||
|
||||
# -- date
|
||||
|
10
R/g.test.R
10
R/g.test.R
@ -26,7 +26,7 @@
|
||||
#' *G*-test for Count Data
|
||||
#'
|
||||
#' [g.test()] performs chi-squared contingency table tests and goodness-of-fit tests, just like [chisq.test()] but is more reliable (1). A *G*-test can be used to see whether the number of observations in each category fits a theoretical expectation (called a ***G*-test of goodness-of-fit**), or to see whether the proportions of one variable are different for different values of the other variable (called a ***G*-test of independence**).
|
||||
#' @inheritSection lifecycle Questioning lifecycle
|
||||
#' @inheritSection lifecycle Questioning Lifecycle
|
||||
#' @inherit stats::chisq.test params return
|
||||
#' @details If `x` is a matrix with one row or column, or if `x` is a vector and `y` is not given, then a *goodness-of-fit test* is performed (`x` is treated as a one-dimensional contingency table). The entries of `x` must be non-negative integers. In this case, the hypothesis tested is whether the population probabilities equal those in `p`, or are all equal if `p` is not given.
|
||||
#'
|
||||
@ -38,14 +38,14 @@
|
||||
#'
|
||||
#' In the goodness-of-fit case simulation is done by random sampling from the discrete distribution specified by `p`, each sample being of size `n = sum(x)`. This simulation is done in \R and may be slow.
|
||||
#'
|
||||
#' ## *G*-test of goodness-of-fit (likelihood ratio test)
|
||||
#' ## *G*-test Of Goodness-of-Fit (Likelihood Ratio Test)
|
||||
#' Use the *G*-test of goodness-of-fit when you have one nominal variable with two or more values (such as male and female, or red, pink and white flowers). You compare the observed counts of numbers of observations in each category with the expected counts, which you calculate using some kind of theoretical expectation (such as a 1:1 sex ratio or a 1:2:1 ratio in a genetic cross).
|
||||
#'
|
||||
#' If the expected number of observations in any category is too small, the *G*-test may give inaccurate results, and you should use an exact test instead ([fisher.test()]).
|
||||
#'
|
||||
#' The *G*-test of goodness-of-fit is an alternative to the chi-square test of goodness-of-fit ([chisq.test()]); each of these tests has some advantages and some disadvantages, and the results of the two tests are usually very similar.
|
||||
#'
|
||||
#' ## *G*-test of independence
|
||||
#' ## *G*-test of Independence
|
||||
#' Use the *G*-test of independence when you have two nominal variables, each with two or more possible values. You want to know whether the proportions for one variable are different among values of the other variable.
|
||||
#'
|
||||
#' It is also possible to do a *G*-test of independence with more than two nominal variables. For example, Jackson et al. (2013) also had data for children under 3, so you could do an analysis of old vs. young, thigh vs. arm, and reaction vs. no reaction, all analyzed together.
|
||||
@ -54,7 +54,7 @@
|
||||
#'
|
||||
#' The *G*-test of independence is an alternative to the chi-square test of independence ([chisq.test()]), and they will give approximately the same results.
|
||||
#'
|
||||
#' ## How the test works
|
||||
#' ## How the Test Works
|
||||
#' Unlike the exact test of goodness-of-fit ([fisher.test()]), the *G*-test does not directly calculate the probability of obtaining the observed results or something more extreme. Instead, like almost all statistical tests, the *G*-test has an intermediate step; it uses the data to calculate a test statistic that measures how far the observed data are from the null expectation. You then use a mathematical relationship, in this case the chi-square distribution, to estimate the probability of obtaining that value of the test statistic.
|
||||
#'
|
||||
#' The *G*-test uses the log of the ratio of two likelihoods as the test statistic, which is why it is also called a likelihood ratio test or log-likelihood ratio test. The formula to calculate a *G*-statistic is:
|
||||
@ -76,7 +76,7 @@
|
||||
#' - The possibility to simulate p values with `simulate.p.value` was removed
|
||||
#' @export
|
||||
#' @importFrom stats pchisq complete.cases
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # = EXAMPLE 1 =
|
||||
#' # Shivrain et al. (2006) crossed clearfield rice (which are resistant
|
||||
|
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' PCA biplot with `ggplot2`
|
||||
#' PCA Biplot with `ggplot2`
|
||||
#'
|
||||
#' Produces a `ggplot2` variant of a so-called [biplot](https://en.wikipedia.org/wiki/Biplot) for PCA (principal component analysis), but is more flexible and more appealing than the base \R [biplot()] function.
|
||||
#' @inheritSection lifecycle Maturing lifecycle
|
||||
#' @inheritSection lifecycle Maturing Lifecycle
|
||||
#' @param x an object returned by [pca()], [prcomp()] or [princomp()]
|
||||
#' @inheritParams stats::biplot.prcomp
|
||||
#' @param labels an optional vector of labels for the observations. If set, the labels will be placed below their respective points. When using the [pca()] function as input for `x`, this will be determined automatically based on the attribute `non_numeric_cols`, see [pca()].
|
||||
@ -61,7 +61,7 @@
|
||||
#' @rdname ggplot_pca
|
||||
#' @export
|
||||
#' @examples
|
||||
#' # `example_isolates` is a dataset available in the AMR package.
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' # See ?pca for more info about Principal Component Analysis (PCA).
|
||||
@ -109,26 +109,26 @@ ggplot_pca <- function(x,
|
||||
|
||||
stop_ifnot_installed("ggplot2")
|
||||
meet_criteria(x, allow_class = c("prcomp", "princomp", "PCA", "lda"))
|
||||
meet_criteria(choices, allow_class = c("numeric", "integer"), has_length = 2)
|
||||
meet_criteria(choices, allow_class = c("numeric", "integer"), has_length = 2, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(scale, allow_class = c("numeric", "integer", "logical"), has_length = 1)
|
||||
meet_criteria(pc.biplot, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(labels, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(labels_textsize, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(labels_text_placement, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(labels_textsize, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(labels_text_placement, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(groups, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(ellipse, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(ellipse_prob, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(ellipse_size, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(ellipse_alpha, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(points_size, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(points_alpha, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(ellipse_prob, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(ellipse_size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(ellipse_alpha, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(points_size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(points_alpha, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(arrows, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(arrows_colour, allow_class = "character", has_length = 1)
|
||||
meet_criteria(arrows_size, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(arrows_textsize, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(arrows_size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(arrows_textsize, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(arrows_textangled, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(arrows_alpha, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(base_textsize, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(arrows_alpha, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(base_textsize, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
|
||||
calculations <- pca_calculations(pca_model = x,
|
||||
groups = groups,
|
||||
|
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' AMR plots with `ggplot2`
|
||||
#' AMR Plots with `ggplot2`
|
||||
#'
|
||||
#' Use these functions to create bar plots for antimicrobial resistance analysis. All functions rely on [ggplot2][ggplot2::ggplot()] functions.
|
||||
#' @inheritSection lifecycle Maturing lifecycle
|
||||
#' @inheritSection lifecycle Maturing Lifecycle
|
||||
#' @param data a [data.frame] with column(s) of class [`rsi`] (see [as.rsi()])
|
||||
#' @param position position adjustment of bars, either `"fill"`, `"stack"` or `"dodge"`
|
||||
#' @param x variable to show on x axis, either `"antibiotic"` (default) or `"interpretation"` or a grouping variable
|
||||
@ -48,7 +48,7 @@
|
||||
#' @param ... other arguments passed on to [geom_rsi()]
|
||||
#' @details At default, the names of antibiotics will be shown on the plots using [ab_name()]. This can be set with the `translate_ab` argument. See [count_df()].
|
||||
#'
|
||||
#' ## The functions
|
||||
#' ## The Functions
|
||||
#' [geom_rsi()] will take any variable from the data that has an [`rsi`] class (created with [as.rsi()]) using [rsi_df()] and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.
|
||||
#'
|
||||
#' [facet_rsi()] creates 2d plots (at default based on S/I/R) using [ggplot2::facet_wrap()].
|
||||
@ -61,10 +61,10 @@
|
||||
#'
|
||||
#' [labels_rsi_count()] print datalabels on the bars with percentage and amount of isolates using [ggplot2::geom_text()].
|
||||
#'
|
||||
#' [ggplot_rsi()] is a wrapper around all above functions that uses data as first input. This makes it possible to use this function after a pipe (`%>%`). See Examples.
|
||||
#' [ggplot_rsi()] is a wrapper around all above functions that uses data as first input. This makes it possible to use this function after a pipe (`%>%`). See *Examples*.
|
||||
#' @rdname ggplot_rsi
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' if (require("ggplot2") & require("dplyr")) {
|
||||
#'
|
||||
@ -180,12 +180,12 @@ ggplot_rsi <- function(data,
|
||||
meet_criteria(translate_ab, allow_class = c("character", "logical"), has_length = 1, allow_NA = TRUE)
|
||||
meet_criteria(combine_SI, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(combine_IR, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_finite = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(nrow, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(nrow, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(colours, allow_class = c("character", "logical"))
|
||||
meet_criteria(datalabels, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(datalabels.size, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(datalabels.size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(datalabels.colour, allow_class = "character", has_length = 1)
|
||||
meet_criteria(title, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(subtitle, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
@ -279,7 +279,7 @@ geom_rsi <- function(position = NULL,
|
||||
meet_criteria(x, allow_class = "character", has_length = 1)
|
||||
meet_criteria(fill, allow_class = "character", has_length = 1)
|
||||
meet_criteria(translate_ab, allow_class = c("character", "logical"), has_length = 1, allow_NA = TRUE)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_finite = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(combine_SI, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(combine_IR, allow_class = "logical", has_length = 1)
|
||||
@ -327,7 +327,7 @@ facet_rsi <- function(facet = c("interpretation", "antibiotic"), nrow = NULL) {
|
||||
facet <- facet[1]
|
||||
stop_ifnot_installed("ggplot2")
|
||||
meet_criteria(facet, allow_class = "character", has_length = 1)
|
||||
meet_criteria(nrow, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(nrow, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)
|
||||
|
||||
# we work with aes_string later on
|
||||
facet_deparse <- deparse(substitute(facet))
|
||||
@ -414,11 +414,11 @@ labels_rsi_count <- function(position = NULL,
|
||||
meet_criteria(position, allow_class = "character", has_length = 1, is_in = c("fill", "stack", "dodge"), allow_NULL = TRUE)
|
||||
meet_criteria(x, allow_class = "character", has_length = 1)
|
||||
meet_criteria(translate_ab, allow_class = c("character", "logical"), has_length = 1, allow_NA = TRUE)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_finite = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(combine_SI, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(combine_IR, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(datalabels.size, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(datalabels.size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(datalabels.colour, allow_class = "character", has_length = 1)
|
||||
|
||||
if (is.null(position)) {
|
||||
|
@ -33,6 +33,9 @@ globalVariables(c(".rowid",
|
||||
"atc_group2",
|
||||
"code",
|
||||
"data",
|
||||
"dosage",
|
||||
"dose",
|
||||
"dose_times",
|
||||
"fullname",
|
||||
"fullname_lower",
|
||||
"g_species",
|
||||
@ -73,6 +76,7 @@ globalVariables(c(".rowid",
|
||||
"species_id",
|
||||
"total",
|
||||
"txt",
|
||||
"type",
|
||||
"value",
|
||||
"varname",
|
||||
"xvar",
|
||||
|
@ -23,17 +23,17 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Guess antibiotic column
|
||||
#' Guess Antibiotic Column
|
||||
#'
|
||||
#' This tries to find a column name in a data set based on information from the [antibiotics] data set. Also supports WHONET abbreviations.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame]
|
||||
#' @param search_string a text to search `x` for, will be checked with [as.ab()] if this value is not a column in `x`
|
||||
#' @param verbose a logical to indicate whether additional info should be printed
|
||||
#' @details You can look for an antibiotic (trade) name or abbreviation and it will search `x` and the [antibiotics] data set for any column containing a name or code of that antibiotic. **Longer columns names take precedence over shorter column names.**
|
||||
#' @return A column name of `x`, or `NULL` when no result is found.
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' df <- data.frame(amox = "S",
|
||||
#' tetr = "R")
|
||||
@ -122,7 +122,7 @@ get_column_abx <- function(x,
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
|
||||
if (info == TRUE) {
|
||||
message_("Auto-guessing columns suitable for analysis", appendLF = FALSE)
|
||||
message_("Auto-guessing columns suitable for analysis", appendLF = FALSE, as_note = FALSE)
|
||||
}
|
||||
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
@ -137,25 +137,25 @@ get_column_abx <- function(x,
|
||||
} else if (info == TRUE) {
|
||||
message_("...", appendLF = FALSE, as_note = FALSE)
|
||||
}
|
||||
x_bak <- x
|
||||
|
||||
# only check columns that are a valid AB code, ATC code, name, abbreviation or synonym,
|
||||
# or already have the <rsi> class (as.rsi)
|
||||
# and that they have no more than 50% invalid values
|
||||
vectr_antibiotics <- unique(toupper(unlist(antibiotics[, c("ab", "atc", "name", "abbreviations", "synonyms")])))
|
||||
vectr_antibiotics <- vectr_antibiotics[!is.na(vectr_antibiotics) & nchar(vectr_antibiotics) >= 3]
|
||||
x_columns <- vapply(FUN.VALUE = character(1), colnames(x), function(col, df = x_bak) {
|
||||
x_columns <- vapply(FUN.VALUE = character(1), colnames(x), function(col, df = x) {
|
||||
if (toupper(col) %in% vectr_antibiotics ||
|
||||
is.rsi(as.data.frame(df, stringsAsFactors = FALSE)[, col, drop = TRUE]) ||
|
||||
is.rsi.eligible(as.data.frame(df, stringsAsFactors = FALSE)[, col, drop = TRUE],
|
||||
threshold = 0.5)) {
|
||||
is.rsi(x[, col, drop = TRUE]) ||
|
||||
is.rsi.eligible(x[, col, drop = TRUE], threshold = 0.5)
|
||||
) {
|
||||
return(col)
|
||||
} else {
|
||||
return(NA_character_)
|
||||
}
|
||||
})
|
||||
|
||||
x_columns <- x_columns[!is.na(x_columns)]
|
||||
x <- x[, x_columns, drop = FALSE] # without drop = TRUE, x will become a vector when x_columns is length 1
|
||||
|
||||
df_trans <- data.frame(colnames = colnames(x),
|
||||
abcode = suppressWarnings(as.ab(colnames(x), info = FALSE)),
|
||||
stringsAsFactors = FALSE)
|
||||
@ -217,7 +217,6 @@ get_column_abx <- function(x,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!is.null(hard_dependencies)) {
|
||||
hard_dependencies <- unique(hard_dependencies)
|
||||
if (!all(hard_dependencies %in% names(x))) {
|
||||
|
203
R/isolate_identifier.R
Normal file
203
R/isolate_identifier.R
Normal file
@ -0,0 +1,203 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Analysis for R #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 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. #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# We created this package for both routine data analysis and academic #
|
||||
# research and it was publicly released in the hope that it will be #
|
||||
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
||||
# #
|
||||
# Visit our website for the full manual and a complete tutorial about #
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Create Identifier of an Isolate
|
||||
#'
|
||||
#' This function will paste the microorganism code with all antimicrobial results into one string for each row in a data set. This is useful to compare isolates, e.g. between institutions or regions, when there is no genotyping available.
|
||||
#' @inheritSection lifecycle Experimental Lifecycle
|
||||
#' @inheritParams eucast_rules
|
||||
#' @param cols_ab a character vector of column names of `x`, or (a combination with) an [antibiotic selector function]([ab_class()]), such as [carbapenems()] and [aminoglycosides()]
|
||||
#' @rdname isolate_identifier
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # automatic selection of microorganism and antibiotics (i.e., all <rsi> columns, see ?as.rsi)
|
||||
#' x <- isolate_identifier(example_isolates)
|
||||
#'
|
||||
#' # ignore microorganism codes, only use antimicrobial results
|
||||
#' x <- isolate_identifier(example_isolates, col_mo = FALSE, cols_ab = c("AMX", "TZP", "GEN", "TOB"))
|
||||
#'
|
||||
#' # select antibiotics from certain antibiotic classes
|
||||
#' x <- isolate_identifier(example_isolates, cols_ab = c(carbapenems(), aminoglycosides()))
|
||||
isolate_identifier <- function(x, col_mo = NULL, cols_ab = NULL) {
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x, "mo")
|
||||
if (is.null(col_mo)) {
|
||||
# no column found, then ignore the argument
|
||||
col_mo <- FALSE
|
||||
}
|
||||
}
|
||||
|
||||
if (isFALSE(col_mo)) {
|
||||
# is FALSE then ignore mo column
|
||||
x$col_mo <- ""
|
||||
col_mo <- "col_mo"
|
||||
} else if (!is.null(col_mo)) {
|
||||
x[, col_mo] <- paste0(as.mo(x[, col_mo, drop = TRUE]), "|")
|
||||
}
|
||||
|
||||
cols_ab <- deparse(substitute(cols_ab)) # support ab class selectors: isolate_identifier(x, cols_ab = carbapenems())
|
||||
if (identical(cols_ab, "NULL")) {
|
||||
cols_ab <- colnames(x)[vapply(FUN.VALUE = logical(1), x, is.rsi)]
|
||||
} else {
|
||||
cols_ab <- tryCatch(colnames(x[, eval(parse(text = cols_ab), envir = parent.frame())]),
|
||||
# tryCatch adds 4 calls, so total is -5
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
}
|
||||
|
||||
# cope with empty values
|
||||
if (length(cols_ab) == 0 && all(x[, col_mo, drop = TRUE] == "", na.rm = TRUE)) {
|
||||
warning_("in isolate_identifier(): no column with microorganisms and no columns with antimicrobial agents found", call = FALSE)
|
||||
} else if (length(cols_ab) == 0) {
|
||||
warning_("in isolate_identifier(): no columns with antimicrobial agents found", call = FALSE)
|
||||
}
|
||||
|
||||
out <- x[, c(col_mo, cols_ab), drop = FALSE]
|
||||
out <- do.call(paste, c(out, sep = ""))
|
||||
out <- gsub("NA", ".", out, fixed = TRUE)
|
||||
out <- set_clean_class(out, new_class = c("isolate_identifier", "character"))
|
||||
attr(out, "ab") <- cols_ab
|
||||
out
|
||||
}
|
||||
|
||||
#' @method all.equal isolate_identifier
|
||||
#' @inheritParams base::all.equal
|
||||
#' @param ignore_empty_results a logical to indicate whether empty results must be ignored, so that only values R, S and I will be compared
|
||||
#' @rdname isolate_identifier
|
||||
#' @export
|
||||
all.equal.isolate_identifier <- function(target, current, ignore_empty_results = TRUE, ...) {
|
||||
meet_criteria(target, allow_class = "isolate_identifier")
|
||||
meet_criteria(current, allow_class = "isolate_identifier")
|
||||
meet_criteria(ignore_empty_results, allow_class = "logical", has_length = 1)
|
||||
|
||||
if (isTRUE(all.equal.character(target, current))) {
|
||||
return(TRUE)
|
||||
}
|
||||
# vectorise over both target and current
|
||||
if (length(target) > 1 && length(current) == 1) {
|
||||
current <- rep(current, length(target))
|
||||
} else if (length(current) > 1 && length(target) == 1) {
|
||||
target <- rep(target, length(current))
|
||||
}
|
||||
stop_if(length(target) != length(current),
|
||||
"length of `target` and `current` must be the same, or one must be 1")
|
||||
|
||||
get_vector <- function(x) {
|
||||
if (grepl("|", x, fixed = TRUE)) {
|
||||
mo <- gsub("(.*)\\|.*", "\\1", x)
|
||||
} else {
|
||||
mo <- NULL
|
||||
}
|
||||
if (grepl("|", x, fixed = TRUE)) {
|
||||
ab <- gsub(".*\\|(.*)", "\\1", x)
|
||||
} else {
|
||||
ab <- x
|
||||
}
|
||||
ab <- strsplit(ab, "")[[1L]]
|
||||
if (is.null(mo)) {
|
||||
out <- as.character(ab)
|
||||
names(out) <- attributes(x)$ab
|
||||
} else {
|
||||
out <- as.character(c(mo, ab))
|
||||
names(out) <- c("mo", attributes(x)$ab)
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
# run it
|
||||
for (i in seq_len(length(target))) {
|
||||
if (i == 1) {
|
||||
df <- data.frame(object = paste0(c("target[", "current["), i, "]"))
|
||||
}
|
||||
trgt <- get_vector(target[i])
|
||||
crnt <- get_vector(current[i])
|
||||
if (ignore_empty_results == TRUE) {
|
||||
diff <- names(trgt[trgt != crnt & trgt != "." & crnt != "."])
|
||||
} else {
|
||||
diff <- names(trgt[trgt != crnt])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
stop("THIS FUNCTION IS WORK IN PROGRESS AND NOT AVAILABLE IN THIS BETA VERSION")
|
||||
|
||||
}
|
||||
|
||||
#' @method print isolate_identifier
|
||||
#' @export
|
||||
#' @noRd
|
||||
print.isolate_identifier <- function(x, ...) {
|
||||
print(as.character(x), ...)
|
||||
}
|
||||
|
||||
#' @method [ isolate_identifier
|
||||
#' @export
|
||||
#' @noRd
|
||||
"[.isolate_identifier" <- function(x, ...) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(x)
|
||||
y
|
||||
}
|
||||
#' @method [[ isolate_identifier
|
||||
#' @export
|
||||
#' @noRd
|
||||
"[[.isolate_identifier" <- function(x, ...) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(x)
|
||||
y
|
||||
}
|
||||
#' @method [<- isolate_identifier
|
||||
#' @export
|
||||
#' @noRd
|
||||
"[<-.isolate_identifier" <- function(i, j, ..., value) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(i)
|
||||
y
|
||||
}
|
||||
#' @method [[<- isolate_identifier
|
||||
#' @export
|
||||
#' @noRd
|
||||
"[[<-.isolate_identifier" <- function(i, j, ..., value) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(i)
|
||||
y
|
||||
}
|
||||
#' @method c isolate_identifier
|
||||
#' @export
|
||||
#' @noRd
|
||||
c.isolate_identifier <- function(x, ...) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(x)
|
||||
y
|
||||
}
|
||||
|
||||
#' @method unique isolate_identifier
|
||||
#' @export
|
||||
#' @noRd
|
||||
unique.isolate_identifier <- function(x, incomparables = FALSE, ...) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(x)
|
||||
y
|
||||
}
|
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Join [microorganisms] to a data set
|
||||
#' Join [microorganisms] to a Data Set
|
||||
#'
|
||||
#' Join the data set [microorganisms] easily to an existing table or character vector.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @rdname join
|
||||
#' @name join
|
||||
#' @aliases join inner_join
|
||||
@ -37,7 +37,7 @@
|
||||
#' @details **Note:** As opposed to the `join()` functions of `dplyr`, [character] vectors are supported and at default existing columns will get a suffix `"2"` and the newly joined columns will not get a suffix.
|
||||
#'
|
||||
#' If the `dplyr` package is installed, their join functions will be used. Otherwise, the much slower [merge()] function from base R will be used.
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @export
|
||||
#' @examples
|
||||
#' left_join_microorganisms(as.mo("K. pneumoniae"))
|
||||
|
@ -23,11 +23,11 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Key antibiotics for first *weighted* isolates
|
||||
#' Key Antibiotics for First (Weighted) Isolates
|
||||
#'
|
||||
#' These function can be used to determine first isolates (see [first_isolate()]). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first *weighted* isolates.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`.
|
||||
#' These function can be used to determine first isolates (see [first_isolate()]). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first 'weighted' isolates.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank to determine automatically
|
||||
#' @param y,z character vectors to compare
|
||||
#' @inheritParams first_isolate
|
||||
#' @param universal_1,universal_2,universal_3,universal_4,universal_5,universal_6 column names of **broad-spectrum** antibiotics, case-insensitive. See details for which antibiotics will be used at default (which are guessed with [guess_ab_col()]).
|
||||
@ -36,7 +36,7 @@
|
||||
#' @param warnings give a warning about missing antibiotic columns (they will be ignored)
|
||||
#' @param ... other arguments passed on to functions
|
||||
#' @details
|
||||
#' The [key_antibiotics()] function is context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be left blank, please see *Examples*.
|
||||
#' The [key_antibiotics()] function is context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#'
|
||||
#' The function [key_antibiotics()] returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using [key_antibiotics_equal()], to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (`"."`) by [key_antibiotics()] and ignored by [key_antibiotics_equal()].
|
||||
#'
|
||||
@ -71,13 +71,13 @@
|
||||
#' - Meropenem
|
||||
#'
|
||||
#' The function [key_antibiotics_equal()] checks the characters returned by [key_antibiotics()] for equality, and returns a [`logical`] vector.
|
||||
#' @inheritSection first_isolate Key antibiotics
|
||||
#' @inheritSection first_isolate Key Antibiotics
|
||||
#' @rdname key_antibiotics
|
||||
#' @export
|
||||
#' @seealso [first_isolate()]
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # `example_isolates` is a dataset available in the AMR package.
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' # output of the `key_antibiotics()` function could be like this:
|
||||
@ -158,7 +158,7 @@ key_antibiotics <- function(x,
|
||||
dots <- unlist(list(...))
|
||||
if (length(dots) != 0) {
|
||||
# backwards compatibility with old arguments
|
||||
dots.names <- dots %pm>% names()
|
||||
dots.names <- names(dots)
|
||||
if ("info" %in% dots.names) {
|
||||
warnings <- dots[which(dots.names == "info")]
|
||||
}
|
||||
@ -168,8 +168,10 @@ key_antibiotics <- function(x,
|
||||
# -- mo
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo")
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
} else {
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
}
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
|
||||
# check columns
|
||||
col.list <- c(universal_1, universal_2, universal_3, universal_4, universal_5, universal_6,
|
||||
@ -289,7 +291,7 @@ key_antibiotics_equal <- function(y,
|
||||
meet_criteria(z, allow_class = "character")
|
||||
meet_criteria(type, allow_class = "character", has_length = c(1, 2))
|
||||
meet_criteria(ignore_I, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
|
||||
stop_ifnot(length(y) == length(z), "length of `y` and `z` must be equal")
|
||||
|
@ -23,16 +23,16 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Kurtosis of the sample
|
||||
#' Kurtosis of the Sample
|
||||
#'
|
||||
#' @description Kurtosis is a measure of the "tailedness" of the probability distribution of a real-valued random variable. A normal distribution has a kurtosis of 3 and a excess kurtosis of 0.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a vector of values, a [matrix] or a [data.frame]
|
||||
#' @param na.rm a logical to indicate whether `NA` values should be stripped before the computation proceeds
|
||||
#' @param excess a logical to indicate whether the *excess kurtosis* should be returned, defined as the kurtosis minus 3.
|
||||
#' @seealso [skewness()]
|
||||
#' @rdname kurtosis
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @export
|
||||
kurtosis <- function(x, na.rm = FALSE, excess = FALSE) {
|
||||
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||
|
@ -27,28 +27,28 @@
|
||||
# NOTE TO SELF: could also have done this with the 'lifecycle' package, but why add a package dependency for such an easy job??
|
||||
###############
|
||||
|
||||
#' Lifecycles of functions in the `AMR` package
|
||||
#' Lifecycles of Functions in the `amr` Package
|
||||
#' @name lifecycle
|
||||
#' @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://www.Tidyverse.org/lifecycle).
|
||||
#'
|
||||
#' \if{html}{\figure{lifecycle_tidyverse.svg}{options: height=200px style=margin-bottom:5px} \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:
|
||||
#' @section Experimental Lifecycle:
|
||||
#' \if{html}{\figure{lifecycle_experimental.svg}{options: style=margin-bottom:5px} \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:
|
||||
#' @section Maturing Lifecycle:
|
||||
#' \if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \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:
|
||||
#' @section Stable Lifecycle:
|
||||
#' \if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \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, a argument will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.
|
||||
#' @section Retired lifecycle:
|
||||
#' @section Retired Lifecycle:
|
||||
#' \if{html}{\figure{lifecycle_retired.svg}{options: style=margin-bottom:5px} \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:
|
||||
#' @section Questioning Lifecycle:
|
||||
#' \if{html}{\figure{lifecycle_questioning.svg}{options: style=margin-bottom:5px} \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
|
||||
|
6
R/like.R
6
R/like.R
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Pattern matching with keyboard shortcut
|
||||
#' Pattern Matching with Keyboard Shortcut
|
||||
#'
|
||||
#' Convenient wrapper around [grep()] to match a pattern: `x %like% pattern`. It always returns a [`logical`] vector and is always case-insensitive (use `x %like_case% pattern` for case-sensitive matching). Also, `pattern` can be as long as `x` to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a character vector where matches are sought, or an object which can be coerced by [as.character()] to a character vector.
|
||||
#' @param pattern a character string containing a regular expression (or [character] string for `fixed = TRUE`) to be matched in the given character vector. Coerced by [as.character()] to a character string if possible. If a [character] vector of length 2 or more is supplied, the first element is used with a warning.
|
||||
#' @param ignore.case if `FALSE`, the pattern matching is *case sensitive* and if `TRUE`, case is ignored during matching.
|
||||
@ -44,7 +44,7 @@
|
||||
#' Using RStudio? The text `%like%` can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like `Ctrl+Shift+L` or `Cmd+Shift+L` (see `Tools` > `Modify Keyboard Shortcuts...`).
|
||||
#' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/master/R/like.R)
|
||||
#' @seealso [grep()]
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # simple test
|
||||
#' a <- "This is a test"
|
||||
|
359
R/mdro.R
359
R/mdro.R
@ -23,22 +23,28 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Determine multidrug-resistant organisms (MDRO)
|
||||
#' Determine Multidrug-Resistant Organisms (MDRO)
|
||||
#'
|
||||
#' Determine which isolates are multidrug-resistant organisms (MDRO) according to international and national guidelines.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()].
|
||||
#' @param guideline a specific guideline to follow. When left empty, the publication by Magiorakos *et al.* (2012, Clinical Microbiology and Infection) will be followed, please see *Details*.
|
||||
#' Determine which isolates are multidrug-resistant organisms (MDRO) according to international, national and custom guidelines.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank for automatic determination.
|
||||
#' @param guideline a specific guideline to follow, see sections *Supported international / national guidelines* and *Using Custom Guidelines* below. When left empty, the publication by Magiorakos *et al.* (see below) will be followed.
|
||||
#' @param ... in case of [custom_mdro_guideline()]: a set of rules, see section *Using Custom Guidelines* below. Otherwise: column name of an antibiotic, see section *Antibiotics* below.
|
||||
#' @param as_factor a [logical] to indicate whether the returned value should be an ordered [factor] (`TRUE`, default), or otherwise a [character] vector
|
||||
#' @inheritParams eucast_rules
|
||||
#' @param pct_required_classes minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for *S. aureus*. Setting this `pct_required_classes` argument to `0.5` (default) means that for every *S. aureus* isolate at least 8 different classes must be available. Any lower number of available classes will return `NA` for that isolate.
|
||||
#' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so resistance is only considered when isolates are R, not I. As this is the default behaviour of the [mdro()] function, it follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. When using `combine_SI = FALSE`, resistance is considered when isolates are R or I.
|
||||
#' @param verbose a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.
|
||||
#' @inheritSection eucast_rules Antibiotics
|
||||
#' @details
|
||||
#' These functions are context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be left blank, please see *Examples*.
|
||||
#' These functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#'
|
||||
#' For the `pct_required_classes` argument, values above 1 will be divided by 100. This is to support both fractions (`0.75` or `3/4`) and percentages (`75`).
|
||||
#'
|
||||
#' **Note:** Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named *order* Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu *et al.* in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this [mdro()] function makes sure that results from before 2016 and after 2016 are identical.
|
||||
#'
|
||||
#' @section Supported International / National Guidelines:
|
||||
#'
|
||||
#' Currently supported guidelines are (case-insensitive):
|
||||
#'
|
||||
#' * `guideline = "CMI2012"` (default)
|
||||
@ -67,7 +73,42 @@
|
||||
#'
|
||||
#' Please suggest your own (country-specific) guidelines by letting us know: <https://github.com/msberends/AMR/issues/new>.
|
||||
#'
|
||||
#' **Note:** Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named *order* Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu *et al.* in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this [mdro()] function makes sure that results from before 2016 and after 2016 are identical.
|
||||
#'
|
||||
#' @section Using Custom Guidelines:
|
||||
#'
|
||||
#' Custom guidelines can be set with the [custom_mdro_guideline()] 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.
|
||||
#'
|
||||
#' If you are familiar with `case_when()` of the `dplyr` 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':
|
||||
#'
|
||||
#' ```
|
||||
#' custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A",
|
||||
#' ERY == "R" & age > 60 ~ "Elderly Type B")
|
||||
#' ```
|
||||
#'
|
||||
#' If a row/an isolate matches the first rule, the value after the first `~` (in this case *'Elderly Type A'*) will be set as MDRO value. Otherwise, the second rule will be tried and so on. The number of rules is unlimited.
|
||||
#'
|
||||
#' You can print the rules set in the console for an overview. Colours will help reading it if your console supports colours.
|
||||
#'
|
||||
#' ```
|
||||
#' custom
|
||||
#' #> A set of custom MDRO rules:
|
||||
#' #> 1. CIP is "R" and age is higher than 60 -> Elderly Type A
|
||||
#' #> 2. ERY is "R" and age is higher than 60 -> Elderly Type B
|
||||
#' #> 3. Otherwise -> Negative
|
||||
#' #>
|
||||
#' #> Unmatched rows will return NA.
|
||||
#' ```
|
||||
#'
|
||||
#' The outcome of the function can be used for the `guideline` argument in the [mdro()] function:
|
||||
#'
|
||||
#' ```
|
||||
#' x <- mdro(example_isolates, guideline = custom)
|
||||
#' table(x)
|
||||
#' #> Elderly Type A Elderly Type B Negative
|
||||
#' #> 43 891 1066
|
||||
#' ```
|
||||
#'
|
||||
#' The rules set (the `custom` object in this case) could be exported to a shared file location using [saveRDS()] if you collaborate with multiple users. The custom rules set could then be imported using [readRDS()].
|
||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||
#' @return
|
||||
#' - CMI 2012 paper - function [mdr_cmi2012()] or [mdro()]:\cr
|
||||
@ -76,17 +117,21 @@
|
||||
#' Ordered [factor] with levels `Negative` < `Mono-resistant` < `Poly-resistant` < `Multi-drug-resistant` < `Extensively drug-resistant`
|
||||
#' - German guideline - function [mrgn()] or [`mdro(..., guideline = "MRGN")`][mdro()]:\cr
|
||||
#' Ordered [factor] with levels `Negative` < `3MRGN` < `4MRGN`
|
||||
#' - Everything else:\cr
|
||||
#' - Everything else, except for custom guidelines:\cr
|
||||
#' Ordered [factor] with levels `Negative` < `Positive, unconfirmed` < `Positive`. The value `"Positive, unconfirmed"` means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests
|
||||
#' @rdname mdro
|
||||
#' @aliases MDR XDR PDR BRMO 3MRGN 4MRGN
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @source
|
||||
#' Please see *Details* for the list of publications used for this function.
|
||||
#' See the supported guidelines above for the list of publications used for this function.
|
||||
#' @examples
|
||||
#' mdro(example_isolates, guideline = "EUCAST")
|
||||
#'
|
||||
#' mdro(example_isolates,
|
||||
#' guideline = custom_mdro_guideline(AMX == "R" ~ "Custom MDRO 1",
|
||||
#' VAN == "R" ~ "Custom MDRO 2"))
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
@ -113,7 +158,10 @@ mdro <- function(x,
|
||||
x <- get_current_data(arg_name = "x", call = -2)
|
||||
}
|
||||
meet_criteria(x, allow_class = "data.frame")
|
||||
meet_criteria(guideline, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(guideline, allow_class = c("list", "character"), allow_NULL = TRUE)
|
||||
if (!is.list(guideline)) {
|
||||
meet_criteria(guideline, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
}
|
||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, is_in = colnames(x), allow_NULL = TRUE)
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(pct_required_classes, allow_class = "numeric", has_length = 1)
|
||||
@ -138,9 +186,6 @@ mdro <- function(x,
|
||||
}
|
||||
}
|
||||
|
||||
stop_ifnot(is.data.frame(x), "`x` must be a data.frame")
|
||||
stop_if(any(dim(x) == 0), "`x` must contain rows and columns")
|
||||
|
||||
# force regular data.frame, not a tibble or data.table
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
|
||||
@ -151,11 +196,44 @@ mdro <- function(x,
|
||||
}
|
||||
|
||||
if (!is.null(list(...)$country)) {
|
||||
warning_("Using `country` is deprecated, use `guideline` instead. Please see ?mdro.", call = FALSE)
|
||||
warning_("Using `country` is deprecated, use `guideline` instead. See ?mdro.", call = FALSE)
|
||||
guideline <- list(...)$country
|
||||
}
|
||||
|
||||
guideline.bak <- guideline
|
||||
|
||||
guideline.bak <- guideline
|
||||
if (is.list(guideline)) {
|
||||
# Custom MDRO guideline ---------------------------------------------------
|
||||
stop_ifnot(inherits(guideline, "custom_mdro_guideline"), "use `custom_mdro_guideline()` to create custom guidelines")
|
||||
if (info == TRUE) {
|
||||
txt <- paste0("Determining MDROs based on custom rules",
|
||||
ifelse(isTRUE(attributes(guideline)$as_factor),
|
||||
paste0(", resulting in factor levels: ", paste0(attributes(guideline)$values, collapse = " < ")),
|
||||
""),
|
||||
".")
|
||||
txt <- word_wrap(txt)
|
||||
cat(txt, "\n", sep = "")
|
||||
}
|
||||
x <- run_custom_mdro_guideline(x, guideline)
|
||||
if (info == TRUE) {
|
||||
if (sum(!is.na(x$MDRO)) == 0) {
|
||||
cat(word_wrap(font_bold(paste0("=> Found 0 MDROs since no isolates are covered by the custom guideline"))))
|
||||
} else {
|
||||
cat(word_wrap(font_bold(paste0("=> Found ", sum(x$MDRO != "Negative", na.rm = TRUE),
|
||||
" custom defined MDROs out of ", sum(!is.na(x$MDRO)),
|
||||
" isolates (",
|
||||
trimws(percentage(sum(x$MDRO != "Negative", na.rm = TRUE) / sum(!is.na(x$MDRO)))),
|
||||
")\n"))))
|
||||
}
|
||||
}
|
||||
if (verbose == TRUE) {
|
||||
return(x[, c("row_number",
|
||||
"MDRO",
|
||||
"reason",
|
||||
"columns_nonsusceptible")])
|
||||
} else {
|
||||
return(x$MDRO)
|
||||
}
|
||||
}
|
||||
guideline <- tolower(gsub("[^a-zA-Z0-9.]+", "", guideline))
|
||||
if (is.null(guideline)) {
|
||||
# default to the paper by Magiorakos et al. (2012)
|
||||
@ -182,9 +260,9 @@ mdro <- function(x,
|
||||
}
|
||||
if (is.null(col_mo) & guideline$code == "tb") {
|
||||
message_("No column found as input for `col_mo`, ",
|
||||
font_bold("assuming all records contain", font_italic("Mycobacterium tuberculosis.")))
|
||||
x$mo <- as.mo("Mycobacterium tuberculosis")
|
||||
col_mo <- "mo"
|
||||
font_bold(paste0("assuming all records contain", font_italic("Mycobacterium tuberculosis"), ".")))
|
||||
x$mo <- as.mo("Mycobacterium tuberculosis") # consider overkill at all times: MO_lookup[which(MO_lookup$fullname == "Mycobacterium tuberculosis"), "mo", drop = TRUE]
|
||||
col_mo <- "mo"
|
||||
}
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
@ -586,6 +664,11 @@ mdro <- function(x,
|
||||
ab_NA <- function(x) {
|
||||
x[!is.na(x)]
|
||||
}
|
||||
try_ab <- function(expr) {
|
||||
out <- tryCatch(expr, error = function(e) FALSE)
|
||||
out[is.na(out)] <- FALSE
|
||||
out
|
||||
}
|
||||
|
||||
# antibiotic classes
|
||||
# nolint start
|
||||
@ -722,6 +805,7 @@ mdro <- function(x,
|
||||
x[which(x$genus == "Escherichia" & x$species == "hermannii"), ab_NA(c(TCC, TZP))] <- NA
|
||||
x[which((x$genus == "Citrobacter" & x$species == "freundii")
|
||||
| (x$genus == "Enterobacter" & x$species == "aerogenes")
|
||||
| (x$genus == "Klebsiella" & x$species == "aerogenes") # new name (2017)
|
||||
| (x$genus == "Enterobacter" & x$species == "cloacae")
|
||||
| (x$genus == "Hafnia" & x$species == "alvei")
|
||||
| (x$genus == "Morganella" & x$species == "morganii")
|
||||
@ -741,6 +825,7 @@ mdro <- function(x,
|
||||
x[which((x$genus == "Citrobacter" & x$species == "koseri")
|
||||
| (x$genus == "Citrobacter" & x$species == "freundii")
|
||||
| (x$genus == "Enterobacter" & x$species == "aerogenes")
|
||||
| (x$genus == "Klebsiella" & x$species == "aerogenes") # new name (2017)
|
||||
| (x$genus == "Enterobacter" & x$species == "cloacae")
|
||||
| (x$genus == "Escherichia" & x$species == "hermannii")
|
||||
| (x$genus == "Hafnia" & x$species == "alvei")
|
||||
@ -753,6 +838,7 @@ mdro <- function(x,
|
||||
| (x$genus == "Serratia" & x$species == "marcescens")), ab_NA(AMP)] <- NA
|
||||
x[which((x$genus == "Citrobacter" & x$species == "freundii")
|
||||
| (x$genus == "Enterobacter" & x$species == "aerogenes")
|
||||
| (x$genus == "Klebsiella" & x$species == "aerogenes") # new name (2017)
|
||||
| (x$genus == "Enterobacter" & x$species == "cloacae")
|
||||
| (x$genus == "Hafnia" & x$species == "alvei")
|
||||
| (x$genus == "Morganella" & x$species == "morganii")
|
||||
@ -762,6 +848,7 @@ mdro <- function(x,
|
||||
x[which((x$genus == "Citrobacter" & x$species == "freundii")
|
||||
| (x$genus == "Citrobacter" & x$species == "koseri")
|
||||
| (x$genus == "Enterobacter" & x$species == "aerogenes")
|
||||
| (x$genus == "Klebsiella" & x$species == "aerogenes") # new name (2017)
|
||||
| (x$genus == "Enterobacter" & x$species == "cloacae")
|
||||
| (x$genus == "Hafnia" & x$species == "alvei")
|
||||
| (x$genus == "Providencia" & x$species == "rettgeri")
|
||||
@ -873,7 +960,9 @@ mdro <- function(x,
|
||||
# MDR (=2): >=3 classes affected
|
||||
x[which(x$classes_affected >= 3), "MDRO"] <- 2
|
||||
if (verbose == TRUE) {
|
||||
x[which(x$classes_affected >= 3), "reason"] <- paste0("at least 3 classes contain R or I: ", x$classes_affected[which(x$classes_affected >= 3)],
|
||||
x[which(x$classes_affected >= 3), "reason"] <- paste0("at least 3 classes contain R",
|
||||
ifelse(!isTRUE(combine_SI), " or I", ""), ": ",
|
||||
x$classes_affected[which(x$classes_affected >= 3)],
|
||||
" out of ", x$classes_available[which(x$classes_affected >= 3)], " available classes")
|
||||
}
|
||||
|
||||
@ -1042,51 +1131,57 @@ mdro <- function(x,
|
||||
|
||||
if (guideline$code == "mrgn") {
|
||||
# Germany -----------------------------------------------------------------
|
||||
CTX_or_CAZ <- CTX %or% CAZ
|
||||
IPM_or_MEM <- IPM %or% MEM
|
||||
x$missing <- NA_character_
|
||||
if (is.na(PIP)) PIP <- "missing"
|
||||
if (is.na(CTX_or_CAZ)) CTX_or_CAZ <- "missing"
|
||||
if (is.na(IPM_or_MEM)) IPM_or_MEM <- "missing"
|
||||
if (is.na(IPM)) IPM <- "missing"
|
||||
if (is.na(MEM)) MEM <- "missing"
|
||||
if (is.na(CIP)) CIP <- "missing"
|
||||
|
||||
# Table 1
|
||||
x[which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
|
||||
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
|
||||
x[, PIP] == "R" &
|
||||
x[, CTX_or_CAZ] == "R" &
|
||||
x[, IPM_or_MEM] == "S" &
|
||||
x[, CIP] == "R"),
|
||||
"MDRO"] <- 2 # 2 = 3MRGN
|
||||
trans_tbl(2, # 3MRGN
|
||||
which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
|
||||
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
|
||||
try_ab(x[, PIP, drop = TRUE] == "R") &
|
||||
(try_ab(x[, CTX, drop = TRUE] == "R") | try_ab(x[, CAZ, drop = TRUE] == "R")) &
|
||||
(try_ab(x[, IPM, drop = TRUE] != "R") | try_ab(x[, MEM, drop = TRUE] != "R")) &
|
||||
try_ab(x[, CIP, drop = TRUE] == "R")),
|
||||
c(PIP, CTX, CAZ, IPM, MEM, CIP),
|
||||
"any")
|
||||
|
||||
x[which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
|
||||
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
|
||||
x[, PIP] == "R" &
|
||||
x[, CTX_or_CAZ] == "R" &
|
||||
x[, IPM_or_MEM] == "R" &
|
||||
x[, CIP] == "R"),
|
||||
"MDRO"] <- 3 # 3 = 4MRGN, overwrites 3MRGN if applicable
|
||||
trans_tbl(3, # 4MRGN, overwrites 3MRGN if applicable
|
||||
which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
|
||||
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
|
||||
try_ab(x[, PIP, drop = TRUE] == "R") &
|
||||
(try_ab(x[, CTX, drop = TRUE] == "R") | try_ab(x[, CAZ, drop = TRUE] == "R")) &
|
||||
(try_ab(x[, IPM, drop = TRUE] == "R") | try_ab(x[, MEM, drop = TRUE] == "R")) &
|
||||
try_ab(x[, CIP, drop = TRUE] == "R")),
|
||||
c(PIP, CTX, CAZ, IPM, MEM, CIP),
|
||||
"any")
|
||||
|
||||
x[which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
|
||||
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
|
||||
x[, IPM] == "R" | x[, MEM] == "R"),
|
||||
"MDRO"] <- 3 # 3 = 4MRGN, always when imipenem or meropenem is R
|
||||
trans_tbl(3, # 4MRGN, overwrites 3MRGN if applicable
|
||||
which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
|
||||
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
|
||||
(try_ab(x[, IPM, drop = TRUE] == "R") | try_ab(x[, MEM, drop = TRUE] == "R"))),
|
||||
c(IPM, MEM),
|
||||
"any")
|
||||
|
||||
x[which(x$genus == "Pseudomonas" & x$species == "aeruginosa" &
|
||||
(x[, PIP] == "S") +
|
||||
(x[, CTX_or_CAZ] == "S") +
|
||||
(x[, IPM_or_MEM] == "S") +
|
||||
(x[, CIP] == "S") == 1),
|
||||
"MDRO"] <- 2 # 2 = 3MRGN, if only 1 group is S
|
||||
trans_tbl(2, # 3MRGN, if only 1 group is S
|
||||
which(x$genus == "Pseudomonas" & x$species == "aeruginosa" &
|
||||
try_ab(x[, PIP, drop = TRUE] == "S") +
|
||||
try_ab(x[, CTX, drop = TRUE] == "S") +
|
||||
try_ab(x[, CAZ, drop = TRUE] == "S") +
|
||||
try_ab(x[, IPM, drop = TRUE] == "S") +
|
||||
try_ab(x[, MEM, drop = TRUE] == "S") +
|
||||
try_ab(x[, CIP, drop = TRUE] == "S") == 1),
|
||||
c(PIP, CTX, CAZ, IPM, MEM, CIP),
|
||||
"any")
|
||||
|
||||
x[which((x$genus == "Pseudomonas" & x$species == "aeruginosa") &
|
||||
x[, PIP] == "R" &
|
||||
x[, CTX_or_CAZ] == "R" &
|
||||
x[, IPM_or_MEM] == "R" &
|
||||
x[, CIP] == "R"),
|
||||
"MDRO"] <- 3 # 3 = 4MRGN
|
||||
trans_tbl(3, # 4MRGN otherwise
|
||||
which((x$genus == "Pseudomonas" & x$species == "aeruginosa") &
|
||||
try_ab(x[, PIP, drop = TRUE] == "R") &
|
||||
(try_ab(x[, CTX, drop = TRUE] == "R") | try_ab(x[, CAZ, drop = TRUE] == "R")) &
|
||||
(try_ab(x[, IPM, drop = TRUE] == "R") | try_ab(x[, MEM, drop = TRUE] == "R")) &
|
||||
try_ab(x[, CIP, drop = TRUE] == "R")),
|
||||
c(PIP, CTX, CAZ, IPM, MEM, CIP),
|
||||
"any")
|
||||
|
||||
x[which(x$MDRO == 2), "reason"] <- "3MRGN"
|
||||
x[which(x$MDRO == 3), "reason"] <- "4MRGN"
|
||||
}
|
||||
|
||||
if (guideline$code == "brmo") {
|
||||
@ -1139,17 +1234,21 @@ mdro <- function(x,
|
||||
& !ab_missing(CAZ)
|
||||
& !ab_missing(TZP)) {
|
||||
x$psae <- 0
|
||||
x[which(x[, MEM] == "R" | x[, IPM] == "R"), "psae"] <- 1 + x[which(x[, MEM] == "R" | x[, IPM] == "R"), "psae"]
|
||||
x[which(x[, GEN] == "R" & x[, TOB] == "R"), "psae"] <- 1 + x[which(x[, GEN] == "R" & x[, TOB] == "R"), "psae"]
|
||||
x[which(x[, CIP] == "R"), "psae"] <- 1 + x[which(x[, CIP] == "R"), "psae"]
|
||||
x[which(x[, CAZ] == "R"), "psae"] <- 1 + x[which(x[, CAZ] == "R"), "psae"]
|
||||
x[which(x[, TZP] == "R"), "psae"] <- 1 + x[which(x[, TZP] == "R"), "psae"]
|
||||
x[which(x[, MEM, drop = TRUE] == "R" | x[, IPM, drop = TRUE] == "R"), "psae"] <- 1 + x[which(x[, MEM, drop = TRUE] == "R" | x[, IPM, drop = TRUE] == "R"), "psae"]
|
||||
x[which(x[, GEN, drop = TRUE] == "R" & x[, TOB, drop = TRUE] == "R"), "psae"] <- 1 + x[which(x[, GEN, drop = TRUE] == "R" & x[, TOB, drop = TRUE] == "R"), "psae"]
|
||||
x[which(x[, CIP, drop = TRUE] == "R"), "psae"] <- 1 + x[which(x[, CIP, drop = TRUE] == "R"), "psae"]
|
||||
x[which(x[, CAZ, drop = TRUE] == "R"), "psae"] <- 1 + x[which(x[, CAZ, drop = TRUE] == "R"), "psae"]
|
||||
x[which(x[, TZP, drop = TRUE] == "R"), "psae"] <- 1 + x[which(x[, TZP, drop = TRUE] == "R"), "psae"]
|
||||
} else {
|
||||
x$psae <- 0
|
||||
}
|
||||
trans_tbl(3,
|
||||
which(x$genus == "Pseudomonas" & x$species == "aeruginosa" & x$psae >= 3),
|
||||
c(CAZ, CIP, GEN, IPM, MEM, TOB, TZP),
|
||||
"any")
|
||||
x[which(
|
||||
x$genus == "Pseudomonas" & x$species == "aeruginosa"
|
||||
& x$psae >= 3), "MDRO"] <- 3
|
||||
& x$psae >= 3), "reason"] <- paste0("at least 3 classes contain R", ifelse(!isTRUE(combine_SI), " or I", ""))
|
||||
|
||||
# Table 3
|
||||
trans_tbl(3,
|
||||
@ -1224,10 +1323,11 @@ mdro <- function(x,
|
||||
1))))
|
||||
# keep all real TB, make other species NA
|
||||
x$MDRO <- ifelse(x$fullname == "Mycobacterium tuberculosis", x$MDRO, NA_real_)
|
||||
x$reason <- "PDR/MDR/XDR criteria were met"
|
||||
}
|
||||
|
||||
if (info == TRUE) {
|
||||
if (sum(!is.na(x$MDRO) == 0)) {
|
||||
if (sum(!is.na(x$MDRO)) == 0) {
|
||||
cat(font_bold(paste0("=> Found 0 MDROs since no isolates are covered by the guideline")))
|
||||
} else {
|
||||
cat(font_bold(paste0("=> Found ", sum(x$MDRO %in% c(2:5), na.rm = TRUE), " ", guideline$type, " out of ", sum(!is.na(x$MDRO)),
|
||||
@ -1248,7 +1348,7 @@ mdro <- function(x,
|
||||
if (guideline$code == "cmi2012") {
|
||||
if (any(x$MDRO == -1, na.rm = TRUE)) {
|
||||
warning_("NA introduced for isolates where the available percentage of antimicrobial classes was below ",
|
||||
percentage(pct_required_classes), " (set with `pct_required_classes`)", call = FALSE)
|
||||
percentage(pct_required_classes), " (set with `pct_required_classes`)", call = FALSE)
|
||||
# set these -1s to NA
|
||||
x[which(x$MDRO == -1), "MDRO"] <- NA_integer_
|
||||
}
|
||||
@ -1280,14 +1380,133 @@ mdro <- function(x,
|
||||
col_mo,
|
||||
"MDRO",
|
||||
"reason",
|
||||
"columns_nonsusceptible")]
|
||||
#x
|
||||
"columns_nonsusceptible"),
|
||||
drop = FALSE]
|
||||
} else {
|
||||
x$MDRO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#' @rdname mdro
|
||||
#' @export
|
||||
custom_mdro_guideline <- function(..., as_factor = TRUE) {
|
||||
dots <- tryCatch(list(...),
|
||||
error = function(e) "error")
|
||||
stop_if(identical(dots, "error"),
|
||||
"rules must be a valid formula inputs (e.g., using '~'), see `?mdro`")
|
||||
n_dots <- length(dots)
|
||||
stop_if(n_dots == 0, "no custom rules were set. Please read the documentation using `?mdro`.")
|
||||
out <- vector("list", n_dots)
|
||||
for (i in seq_len(n_dots)) {
|
||||
stop_ifnot(inherits(dots[[i]], "formula"),
|
||||
"rule ", i, " must be a valid formula input (e.g., using '~'), see `?mdro`")
|
||||
|
||||
# Query
|
||||
qry <- dots[[i]][[2]]
|
||||
if (inherits(qry, "call")) {
|
||||
qry <- as.expression(qry)
|
||||
}
|
||||
qry <- as.character(qry)
|
||||
# these will prevent vectorisaton, so replace them:
|
||||
qry <- gsub("&&", "&", qry, fixed = TRUE)
|
||||
qry <- gsub("||", "|", qry, fixed = TRUE)
|
||||
# support filter()-like writing: custom_mdro_guideline('CIP == "R", AMX == "S"' ~ "result 1")
|
||||
qry <- gsub(" *, *", " & ", qry)
|
||||
# format nicely
|
||||
qry <- gsub(" *([&|+-/*^><==]+) *", " \\1 ", qry)
|
||||
qry <- gsub("'", "\"", qry, fixed = TRUE)
|
||||
out[[i]]$query <- as.expression(qry)
|
||||
|
||||
# Value
|
||||
val <- tryCatch(eval(dots[[i]][[3]]), error = function(e) NULL)
|
||||
stop_if(is.null(val), "rule ", i, " must return a valid value, it now returns an error: ", tryCatch(eval(dots[[i]][[3]]), error = function(e) e$message))
|
||||
stop_if(length(val) > 1, "rule ", i, " must return a value of length 1, not ", length(val))
|
||||
out[[i]]$value <- as.character(val)
|
||||
}
|
||||
|
||||
names(out) <- paste0("rule", seq_len(n_dots))
|
||||
out <- set_clean_class(out, new_class = c("custom_mdro_guideline", "list"))
|
||||
attr(out, "values") <- c("Negative", vapply(FUN.VALUE = character(1), out, function(x) x$value))
|
||||
attr(out, "as_factor") <- as_factor
|
||||
out
|
||||
}
|
||||
|
||||
#' @method print custom_mdro_guideline
|
||||
#' @export
|
||||
#' @noRd
|
||||
print.custom_mdro_guideline <- function(x, ...) {
|
||||
cat("A set of custom MDRO rules:\n")
|
||||
for (i in seq_len(length(x))) {
|
||||
rule <- x[[i]]
|
||||
rule$query <- gsub(" & ", " and ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" | ", " or ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" + ", " plus ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" - ", " minus ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" / ", " divided by ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" * ", " times ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" == ", " is ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" > ", " is higher than ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" < ", " is lower than ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" >= ", " is higher than or equal to ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" <= ", " is lower than or equal to ", rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" ^ ", " to the power of ", rule$query, fixed = TRUE)
|
||||
cat(" ", i, ". ", font_blue(as.character(rule$query)), " -> ", font_red(rule$value), "\n", sep = "")
|
||||
}
|
||||
cat(" ", i + 1, ". Otherwise -> ", font_red(paste0("Negative")), "\n", sep = "")
|
||||
cat("\nUnmatched rows will return ", font_red("NA"), ".\n", sep = "")
|
||||
if (isTRUE(attributes(x)$as_factor)) {
|
||||
cat("Results will be of class <factor>, with ordered levels: ", paste0(attributes(x)$values, collapse = " < "), "\n", sep = "")
|
||||
} else {
|
||||
cat("Results will be of class <character>.\n")
|
||||
}
|
||||
}
|
||||
|
||||
run_custom_mdro_guideline <- function(df, guideline) {
|
||||
n_dots <- length(guideline)
|
||||
stop_if(n_dots == 0, "no custom guidelines set", call = -2)
|
||||
out <- character(length = NROW(df))
|
||||
reasons <- character(length = NROW(df))
|
||||
for (i in seq_len(n_dots)) {
|
||||
qry <- tryCatch(eval(parse(text = guideline[[i]]$query), envir = df, enclos = parent.frame()),
|
||||
error = function(e) {
|
||||
pkg_env$err_msg <- e$message
|
||||
return("error")
|
||||
})
|
||||
if (identical(qry, "error")) {
|
||||
warning_("in custom_mdro_guideline(): rule ", i, " (`", guideline[[i]]$query, "`) was ignored because of this error message: ", pkg_env$err_msg,
|
||||
call = FALSE,
|
||||
add_fn = font_red)
|
||||
next
|
||||
}
|
||||
stop_ifnot(is.logical(qry), "in custom_mdro_guideline(): rule ", i, " (`", guideline[[i]]$query,
|
||||
"`) must return `TRUE` or `FALSE`, not ",
|
||||
format_class(class(qry), plural = FALSE), call = FALSE)
|
||||
val <- guideline[[i]]$value
|
||||
out[which(qry)] <- val
|
||||
reasons[which(qry)] <- paste0("matched rule ", gsub("rule", "", names(guideline)[i]), ": ", as.character(guideline[[i]]$query))
|
||||
}
|
||||
out[out == ""] <- "Negative"
|
||||
reasons[out == "Negative"] <- "no rules matched"
|
||||
|
||||
if (isTRUE(attributes(guideline)$as_factor)) {
|
||||
out <- factor(out, levels = attributes(guideline)$values, ordered = TRUE)
|
||||
}
|
||||
|
||||
rsi_cols <- vapply(FUN.VALUE = logical(1), df, function(x) is.rsi(x))
|
||||
columns_nonsusceptible <- as.data.frame(t(df[, rsi_cols] == "R"))
|
||||
columns_nonsusceptible <- vapply(FUN.VALUE = character(1),
|
||||
columns_nonsusceptible,
|
||||
function(x) paste0(rownames(columns_nonsusceptible)[which(x)], collapse = " "))
|
||||
columns_nonsusceptible[is.na(out)] <- NA_character_
|
||||
|
||||
data.frame(row_number = seq_len(NROW(df)),
|
||||
MDRO = out,
|
||||
reason = reasons,
|
||||
columns_nonsusceptible = columns_nonsusceptible,
|
||||
stringsAsFactors = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname mdro
|
||||
#' @export
|
||||
brmo <- function(x, guideline = "BRMO", ...) {
|
||||
|
8
R/mic.R
8
R/mic.R
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Transform input to minimum inhibitory concentrations (MIC)
|
||||
#' Transform Input to Minimum Inhibitory Concentrations (MIC)
|
||||
#'
|
||||
#' This transforms a vector to a new class [`mic`], which is an ordered [factor] with valid minimum inhibitory concentrations (MIC) as levels. Invalid MIC values will be translated as `NA` with a warning.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @rdname as.mic
|
||||
#' @param x vector
|
||||
#' @param na.rm a logical indicating whether missing values should be removed
|
||||
@ -35,7 +35,7 @@
|
||||
#' @aliases mic
|
||||
#' @export
|
||||
#' @seealso [as.rsi()]
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' mic_data <- as.mic(c(">=32", "1.0", "1", "1.00", 8, "<=0.128", "8", "16", "16"))
|
||||
#' is.mic(mic_data)
|
||||
@ -62,7 +62,7 @@ as.mic <- function(x, na.rm = FALSE) {
|
||||
if (is.mic(x)) {
|
||||
x
|
||||
} else {
|
||||
x <- x %pm>% unlist()
|
||||
x <- unlist(x)
|
||||
if (na.rm == TRUE) {
|
||||
x <- x[!is.na(x)]
|
||||
}
|
||||
|
69
R/mo.R
69
R/mo.R
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Transform input to a microorganism ID
|
||||
#' Transform Input to a Microorganism ID
|
||||
#'
|
||||
#' Use this function to determine a valid microorganism ID ([`mo`]). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like `"Staphylococcus aureus"`), an abbreviated name (such as `"S. aureus"`), an abbreviation known in the field (such as `"MRSA"`), or just a genus. Please see *Examples*.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' Use this function to determine a valid microorganism ID ([`mo`]). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea and most microbial species from the kingdom Fungi (see *Source*). The input can be almost anything: a full name (like `"Staphylococcus aureus"`), an abbreviated name (such as `"S. aureus"`), an abbreviation known in the field (such as `"MRSA"`), or just a genus. See *Examples*.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a character vector or a [data.frame] with one or two columns
|
||||
#' @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).
|
||||
#'
|
||||
@ -34,7 +34,7 @@
|
||||
#' @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.
|
||||
#'
|
||||
#' 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, please see *Details*
|
||||
#' @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)")`.
|
||||
#' @param language language to translate text like "no growth", which defaults to the system language (see [get_locale()])
|
||||
@ -43,7 +43,7 @@
|
||||
#' @aliases mo
|
||||
#' @keywords mo Becker becker Lancefield lancefield guess
|
||||
#' @details
|
||||
#' ## General info
|
||||
#' ## General Info
|
||||
#'
|
||||
#' A microorganism ID from this package (class: [`mo`]) is human readable and typically looks like these examples:
|
||||
#' ```
|
||||
@ -63,7 +63,7 @@
|
||||
#'
|
||||
#' Values that cannot be coerced will be considered 'unknown' and will get the MO code `UNKNOWN`.
|
||||
#'
|
||||
#' Use the [`mo_*`][mo_property()] functions to get properties based on the returned code, see Examples.
|
||||
#' Use the [`mo_*`][mo_property()] functions to get properties based on the returned code, see *Examples*.
|
||||
#'
|
||||
#' The algorithm uses data from the Catalogue of Life (see below) and from one other source (see [microorganisms]).
|
||||
#'
|
||||
@ -75,7 +75,7 @@
|
||||
#'
|
||||
#' This will lead to the effect that e.g. `"E. coli"` (a microorganism highly prevalent in humans) will return the microbial ID of *Escherichia coli* and not *Entamoeba coli* (a microorganism less prevalent in humans), although the latter would alphabetically come first.
|
||||
#'
|
||||
#' ## Coping with uncertain results
|
||||
#' ## Coping with Uncertain Results
|
||||
#'
|
||||
#' In addition, the [as.mo()] function can differentiate four levels of uncertainty to guess valid results:
|
||||
#' - Uncertainty level 0: no additional rules are applied;
|
||||
@ -91,14 +91,14 @@
|
||||
#' - `"Fluoroquinolone-resistant Neisseria gonorrhoeae"`. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result *Neisseria gonorrhoeae* (``r as.mo("Neisseria gonorrhoeae")``) needs review.
|
||||
#'
|
||||
#' There are three helper functions that can be run after using the [as.mo()] function:
|
||||
#' - Use [mo_uncertainties()] to get a [data.frame] that prints in a pretty format with all taxonomic names that were guessed. The output contains the matching score for all matches (see *Background on matching score*).
|
||||
#' - Use [mo_uncertainties()] to get a [data.frame] that prints in a pretty format with all taxonomic names that were guessed. The output contains the matching score for all matches (see *Matching Score for Microorganisms* below).
|
||||
#' - Use [mo_failures()] to get a [character] [vector] with all values that could not be coerced to a valid value.
|
||||
#' - Use [mo_renamed()] to get a [data.frame] with all values that could be coerced based on old, previously accepted taxonomic names.
|
||||
#'
|
||||
#' ## Microbial prevalence of pathogens in humans
|
||||
#' ## Microbial Prevalence of Pathogens in Humans
|
||||
#'
|
||||
#' The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the `prevalence` columns in the [microorganisms] and [microorganisms.old] data sets. The grouping into human pathogenic prevalence is explained in the section *Matching score for microorganisms* below.
|
||||
#' @inheritSection mo_matching_score Matching score for microorganisms
|
||||
#' The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the `prevalence` columns in the [microorganisms] and [microorganisms.old] data sets. The grouping into human pathogenic prevalence is explained in the section *Matching Score for Microorganisms* below.
|
||||
#' @inheritSection mo_matching_score Matching Score for Microorganisms
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
# (source as a section here, so it can be inherited by other man pages:)
|
||||
#' @section Source:
|
||||
@ -112,8 +112,8 @@
|
||||
#' @seealso [microorganisms] for the [data.frame] that is being used to determine ID's.
|
||||
#'
|
||||
#' The [`mo_*`][mo_property()] functions (such as [mo_genus()], [mo_gramstain()]) to get properties based on the returned code.
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' # These examples all return "B_STPHY_AURS", the ID of S. aureus:
|
||||
@ -756,7 +756,7 @@ exec_as.mo <- function(x,
|
||||
x[i] <- lookup(mo == "B_STRPT_HAEM", uncertainty = -1)
|
||||
next
|
||||
}
|
||||
# CoNS/CoPS in different languages (support for German, Dutch, Spanish, Portuguese) ----
|
||||
# CoNS/CoPS in different languages (support for German, Dutch, Spanish, Portuguese)
|
||||
if (x_backup_without_spp[i] %like_case% "[ck]oagulas[ea] negatie?[vf]"
|
||||
| x_trimmed[i] %like_case% "[ck]oagulas[ea] negatie?[vf]"
|
||||
| x_backup_without_spp[i] %like_case% "[ck]o?ns[^a-z]?$") {
|
||||
@ -841,8 +841,17 @@ exec_as.mo <- function(x,
|
||||
x[i] <- lookup(fullname == "Streptococcus pneumoniae", uncertainty = -1)
|
||||
next
|
||||
}
|
||||
# }
|
||||
|
||||
|
||||
if (x_backup[i] %in% pkg_env$mo_failed) {
|
||||
# previously failed already in this session ----
|
||||
# (at this point the latest reference_df has also be checked)
|
||||
x[i] <- lookup(mo == "UNKNOWN")
|
||||
if (initial_search == TRUE) {
|
||||
failures <- c(failures, x_backup[i])
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
# NOW RUN THROUGH DIFFERENT PREVALENCE LEVELS
|
||||
check_per_prevalence <- function(data_to_check,
|
||||
data.old_to_check,
|
||||
@ -1397,6 +1406,7 @@ exec_as.mo <- function(x,
|
||||
failures <- failures[!failures %in% c(NA, NULL, NaN)]
|
||||
if (length(failures) > 0 & initial_search == TRUE) {
|
||||
pkg_env$mo_failures <- sort(unique(failures))
|
||||
pkg_env$mo_failed <- c(pkg_env$mo_failed, pkg_env$mo_failures)
|
||||
plural <- c("value", "it", "was")
|
||||
if (pm_n_distinct(failures) > 1) {
|
||||
plural <- c("values", "them", "were")
|
||||
@ -1412,7 +1422,7 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
msg <- paste0(msg,
|
||||
".\nUse mo_failures() to review ", plural[2], ". Edit the `allow_uncertain` argument if needed (see ?as.mo).\n",
|
||||
"You can also use your own reference data, e.g.:\n",
|
||||
"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),
|
||||
@ -1430,7 +1440,7 @@ exec_as.mo <- function(x,
|
||||
plural <- c("s", "them", "were")
|
||||
}
|
||||
msg <- paste0("Translation to ", nr2char(length(uncertainties$input)), " microorganism", plural[1],
|
||||
" ", plural[3], " guessed with uncertainty. Use mo_uncertainties() to review ", plural[2], ".")
|
||||
" was guessed with uncertainty. Use mo_uncertainties() to review ", plural[2], ".")
|
||||
message_(msg)
|
||||
}
|
||||
|
||||
@ -1536,10 +1546,10 @@ exec_as.mo <- function(x,
|
||||
message_(word_wrap("- Try to use as many valid taxonomic names as possible for your input.",
|
||||
extra_indent = 2),
|
||||
as_note = FALSE)
|
||||
message_(word_wrap("- Save the output and use it as input for future calculations, e.g. create a new variable to your data using `as.mo()`. All functions in this package that rely on microorganism codes will automatically use that new column where possible. All `mo_*()` functions also do not require you to set their `x` argument as long as you have the dplyr package installed and you have a column of class <mo>.",
|
||||
message_(word_wrap("- Save the output and use it as input for future calculations, e.g. create a new variable to your data using `as.mo()`. All functions in this package that rely on microorganism codes will automatically use that new column where possible. All `mo_*()` functions also do not require you to set their `x` argument as long as you have a column of class <mo>.",
|
||||
extra_indent = 2),
|
||||
as_note = FALSE)
|
||||
message_(word_wrap("- Use `set_mo_source()` to continually transform your organisation codes to microorganisms codes used by this package, please see `?mo_source`.",
|
||||
message_(word_wrap("- Use `set_mo_source()` to continually transform your organisation codes to microorganisms codes used by this package, see `?mo_source`.",
|
||||
extra_indent = 2),
|
||||
as_note = FALSE)
|
||||
}
|
||||
@ -1785,7 +1795,7 @@ print.mo_uncertainties <- function(x, ...) {
|
||||
if (NROW(x) == 0) {
|
||||
return(NULL)
|
||||
}
|
||||
message_("Matching scores are based on human pathogenic prevalence and the resemblance between the input and the full taxonomic name. Please see ?mo_matching_score.", as_note = FALSE)
|
||||
message_("Matching scores are based on human pathogenic prevalence and the resemblance between the input and the full taxonomic name. See ?mo_matching_score.", as_note = FALSE)
|
||||
cat("\n")
|
||||
|
||||
msg <- ""
|
||||
@ -1960,12 +1970,12 @@ replace_old_mo_codes <- function(x, property) {
|
||||
x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))]
|
||||
n_matched <- length(matched[!is.na(matched)])
|
||||
if (property != "mo") {
|
||||
message_(font_blue("NOTE: The input contained old microbial codes (from previous package versions). Please update your MO codes with as.mo()."))
|
||||
message_(font_blue("The input contained old microbial codes (from previous package versions). Please update your MO codes with as.mo()."))
|
||||
} else {
|
||||
if (n_matched == 1) {
|
||||
message_(font_blue("NOTE: 1 old microbial code (from previous package versions) was updated to a current used MO code."))
|
||||
message_(font_blue("1 old microbial code (from previous package versions) was updated to a current used MO code."))
|
||||
} else {
|
||||
message_(font_blue("NOTE:", n_matched, "old microbial codes (from previous package versions) were updated to current used MO codes."))
|
||||
message_(font_blue(n_matched, "old microbial codes (from previous package versions) were updated to current used MO codes."))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2006,3 +2016,14 @@ repair_reference_df <- function(reference_df) {
|
||||
reference_df[, "mo"] <- as.mo(reference_df[, "mo", drop = TRUE])
|
||||
reference_df
|
||||
}
|
||||
|
||||
strip_words <- function(text, n, side = "right") {
|
||||
out <- lapply(strsplit(x, " "), function(x) {
|
||||
if (side %like% "^r" & length(x) > n) {
|
||||
x[seq_len(length(x) - n)]
|
||||
} else if (side %like% "^l" & length(x) > n) {
|
||||
x[2:length(x)]
|
||||
}
|
||||
})
|
||||
vapply(FUN.VALUE = character(1), out, paste, collapse = " ")
|
||||
}
|
||||
|
@ -23,31 +23,33 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Calculate the matching score for microorganisms
|
||||
#' Calculate the Matching Score for Microorganisms
|
||||
#'
|
||||
#' 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
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @author Matthijs S. 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:
|
||||
#' @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:
|
||||
#'
|
||||
#' \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}}}{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="300px" alt="mo matching score"}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )}}
|
||||
#'
|
||||
#' where:
|
||||
#'
|
||||
#' * \eqn{x} is the user input;
|
||||
#' * \eqn{n} is a taxonomic name (genus, species, and subspecies);
|
||||
#' * \eqn{l_n}{l_n} is the length of \eqn{n};
|
||||
#' * lev is the [Levenshtein distance function](https://en.wikipedia.org/wiki/Levenshtein_distance), which counts any insertion, deletion and substitution as 1 that is needed to change \eqn{x} into \eqn{n};
|
||||
#' * \eqn{p_n}{p_n} is the human pathogenic prevalence group of \eqn{n}, as described below;
|
||||
#' * \eqn{k_n}{p_n} is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.
|
||||
#' * \ifelse{html}{\out{<i>x</i> is the user input;}}{\eqn{x} is the user input;}
|
||||
#' * \ifelse{html}{\out{<i>n</i> is a taxonomic name (genus, species, and subspecies);}}{\eqn{n} is a taxonomic name (genus, species, and subspecies);}
|
||||
#' * \ifelse{html}{\out{<i>l<sub>n</sub></i> is the length of <i>n</i>;}}{l_n is the length of \eqn{n};}
|
||||
#' * \ifelse{html}{\out{<i>lev</i> is the <a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance function</a>, which counts any insertion, deletion and substitution as 1 that is needed to change <i>x</i> into <i>n</i>;}}{lev is the Levenshtein distance function, which counts any insertion, deletion and substitution as 1 that is needed to change \eqn{x} into \eqn{n};}
|
||||
#' * \ifelse{html}{\out{<i>p<sub>n</sub></i> is the human pathogenic prevalence group of <i>n</i>, as described below;}}{p_n is the human pathogenic prevalence group of \eqn{n}, as described below;}
|
||||
#' * \ifelse{html}{\out{<i>k<sub>n</sub></i> is the taxonomic kingdom of <i>n</i>, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.}}{l_n is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.}
|
||||
#'
|
||||
#' The grouping into human pathogenic prevalence (\eqn{p}) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. **Group 1** (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is *Enterococcus*, *Staphylococcus* or *Streptococcus*. This group consequently contains all common Gram-negative bacteria, such as *Pseudomonas* and *Legionella* and all species within the order Enterobacterales. **Group 2** consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is *Absidia*, *Acremonium*, *Actinotignum*, *Alternaria*, *Anaerosalibacter*, *Apophysomyces*, *Arachnia*, *Aspergillus*, *Aureobacterium*, *Aureobasidium*, *Bacteroides*, *Basidiobolus*, *Beauveria*, *Blastocystis*, *Branhamella*, *Calymmatobacterium*, *Candida*, *Capnocytophaga*, *Catabacter*, *Chaetomium*, *Chryseobacterium*, *Chryseomonas*, *Chrysonilia*, *Cladophialophora*, *Cladosporium*, *Conidiobolus*, *Cryptococcus*, *Curvularia*, *Exophiala*, *Exserohilum*, *Flavobacterium*, *Fonsecaea*, *Fusarium*, *Fusobacterium*, *Hendersonula*, *Hypomyces*, *Koserella*, *Lelliottia*, *Leptosphaeria*, *Leptotrichia*, *Malassezia*, *Malbranchea*, *Mortierella*, *Mucor*, *Mycocentrospora*, *Mycoplasma*, *Nectria*, *Ochroconis*, *Oidiodendron*, *Phoma*, *Piedraia*, *Pithomyces*, *Pityrosporum*, *Prevotella*,\\*Pseudallescheria*, *Rhizomucor*, *Rhizopus*, *Rhodotorula*, *Scolecobasidium*, *Scopulariopsis*, *Scytalidium*,*Sporobolomyces*, *Stachybotrys*, *Stomatococcus*, *Treponema*, *Trichoderma*, *Trichophyton*, *Trichosporon*, *Tritirachium* or *Ureaplasma*. **Group 3** consists of all other microorganisms.
|
||||
#'
|
||||
#' 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.
|
||||
#' @export
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' as.mo("E. coli")
|
||||
#' mo_uncertainties()
|
||||
|
@ -23,11 +23,11 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Get properties of a microorganism
|
||||
#' Get Properties of a Microorganism
|
||||
#'
|
||||
#' Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. Please see *Examples*.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @param x any character (vector) that can be coerced to a valid microorganism code with [as.mo()]. Can be left blank for auto-guessing the column containing microorganism codes when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()], please see *Examples*.
|
||||
#' Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. See *Examples*.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x any character (vector) that can be coerced to a valid microorganism code with [as.mo()]. Can be left blank for auto-guessing the column containing microorganism codes if used in a data set, see *Examples*.
|
||||
#' @param property one of the column names of the [microorganisms] data set: `r paste0('"``', colnames(microorganisms), '\``"', collapse = ", ")`, or must be `"shortname"`
|
||||
#' @param language language of the returned text, defaults to system language (see [get_locale()]) and can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`, see [translate]. Also used to translate text like "no growth". Use `language = NULL` or `language = ""` to prevent translation.
|
||||
#' @param ... other arguments passed on to [as.mo()], such as 'allow_uncertain' and 'ignore_pattern'
|
||||
@ -44,12 +44,14 @@
|
||||
#'
|
||||
#' The Gram stain - [mo_gramstain()] - will be determined based on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002, [PMID 11837318](https://pubmed.ncbi.nlm.nih.gov/11837318)), who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a value `NA`. Functions [mo_is_gram_negative()] and [mo_is_gram_positive()] 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.
|
||||
#'
|
||||
#' Determination of yeasts - [mo_is_yeast()] - will be based on the taxonomic phylum, class and order. Budding yeasts are true fungi of the phylum Ascomycetes, class Saccharomycetes (also called Hemiascomycetes). The true yeasts are separated into one main order Saccharomycetales. For all microorganisms that are in one of those two groups, the function will return `TRUE`. It returns `FALSE` for all other taxonomic entries.
|
||||
#'
|
||||
#' Intrinsic resistance - [mo_is_intrinsic_resistant()] - will be determined based on the [intrinsic_resistant] data set, which is based on `r format_eucast_version_nr(3.2)`. The [mo_is_intrinsic_resistant()] can be vectorised over arguments `x` (input for microorganisms) and over `ab` (input for antibiotics).
|
||||
#'
|
||||
#' All output will be [translate]d where possible.
|
||||
#'
|
||||
#' The function [mo_url()] will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species.
|
||||
#' @inheritSection mo_matching_score Matching score for microorganisms
|
||||
#' @inheritSection mo_matching_score Matching Score for Microorganisms
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @inheritSection as.mo Source
|
||||
#' @rdname mo_property
|
||||
@ -62,8 +64,8 @@
|
||||
#' - A [character] in all other cases
|
||||
#' @export
|
||||
#' @seealso [microorganisms]
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # taxonomic tree -----------------------------------------------------------
|
||||
#' mo_kingdom("E. coli") # "Bacteria"
|
||||
@ -145,6 +147,8 @@
|
||||
#'
|
||||
#' # other --------------------------------------------------------------------
|
||||
#'
|
||||
#' mo_is_yeast(c("Candida", "E. coli")) # TRUE, FALSE
|
||||
#'
|
||||
#' # gram stains and intrinsic resistance can also be used as a filter in dplyr verbs
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
@ -331,7 +335,10 @@ mo_type <- function(x, language = get_locale(), ...) {
|
||||
meet_criteria(x, allow_NA = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
|
||||
translate_AMR(mo_validate(x = x, property = "kingdom", language = language, ...), language = language, only_unknown = FALSE)
|
||||
x.mo <- as.mo(x, language = language, ...)
|
||||
out <- mo_kingdom(x.mo, language = NULL)
|
||||
out[which(mo_is_yeast(x.mo))] <- "Yeasts"
|
||||
translate_AMR(out, language = language, only_unknown = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname mo_property
|
||||
@ -410,6 +417,33 @@ mo_is_gram_positive <- function(x, language = get_locale(), ...) {
|
||||
out
|
||||
}
|
||||
|
||||
#' @rdname mo_property
|
||||
#' @export
|
||||
mo_is_yeast <- function(x, language = get_locale(), ...) {
|
||||
if (missing(x)) {
|
||||
# this tries to find the data and an <mo> column
|
||||
x <- find_mo_col(fn = "mo_is_yeast")
|
||||
}
|
||||
meet_criteria(x, allow_NA = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
|
||||
x.mo <- as.mo(x, language = language, ...)
|
||||
metadata <- get_mo_failures_uncertainties_renamed()
|
||||
|
||||
x.kingdom <- mo_kingdom(x.mo, language = NULL)
|
||||
x.phylum <- mo_phylum(x.mo, language = NULL)
|
||||
x.class <- mo_class(x.mo, language = NULL)
|
||||
x.order <- mo_order(x.mo, language = NULL)
|
||||
|
||||
load_mo_failures_uncertainties_renamed(metadata)
|
||||
|
||||
out <- rep(FALSE, length(x))
|
||||
out[x.kingdom == "Fungi" &
|
||||
((x.phylum == "Ascomycetes" & x.class == "Saccharomycetes") | x.order == "Saccharomycetales")] <- TRUE
|
||||
out[x.mo %in% c(NA_character_, "UNKNOWN")] <- NA
|
||||
out
|
||||
}
|
||||
|
||||
#' @rdname mo_property
|
||||
#' @export
|
||||
mo_is_intrinsic_resistant <- function(x, ab, language = get_locale(), ...) {
|
||||
|
@ -23,13 +23,13 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' User-defined reference data set for microorganisms
|
||||
#' User-Defined Reference Data Set for Microorganisms
|
||||
#'
|
||||
#' @description These functions can be used to predefine your own reference to be used in [as.mo()] and consequently all [`mo_*`][mo_property()] functions (such as [mo_genus()] and [mo_gramstain()]).
|
||||
#'
|
||||
#' This is **the fastest way** to have your organisation (or analysis) specific codes picked up and translated by this package, since you don't have to bother about it again after setting it up once.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @param path location of your reference file, see Details. Can be `""`, `NULL` or `FALSE` to delete the reference file.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param path location of your reference file, see *Details*. Can be `""`, `NULL` or `FALSE` to delete the reference file.
|
||||
#' @param destination destination of the compressed data file, default to the user's home directory.
|
||||
#' @rdname mo_source
|
||||
#' @name mo_source
|
||||
@ -44,7 +44,7 @@
|
||||
#'
|
||||
#' Reading an Excel file (`.xlsx`) with only one row has a size of 8-9 kB. The compressed file created with [set_mo_source()] will then have a size of 0.1 kB and can be read by [get_mo_source()] in only a couple of microseconds (millionths of a second).
|
||||
#'
|
||||
#' @section How to setup:
|
||||
#' @section How to Setup:
|
||||
#'
|
||||
#' Imagine this data on a sheet of an Excel file (mo codes were looked up in the [microorganisms] data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:
|
||||
#'
|
||||
@ -121,7 +121,7 @@
|
||||
#'
|
||||
#' If the original file (in the previous case an Excel file) is moved or deleted, the `mo_source.rds` file will be removed upon the next use of [as.mo()] or any [`mo_*`][mo_property()] function.
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_source.rds")) {
|
||||
meet_criteria(path, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(destination, allow_class = "character", has_length = 1)
|
||||
@ -200,8 +200,8 @@ set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_s
|
||||
"', for which your permission is needed.")),
|
||||
"\n\n",
|
||||
word_wrap("Do you agree that this file will be created?"))
|
||||
if ("rsasdtudioapi" %in% rownames(utils::installed.packages())) {
|
||||
showQuestion <- import_fn("showQuestion", "rstudioapi")
|
||||
showQuestion <- import_fn("showQuestion", "rstudioapi", error_on_fail = FALSE)
|
||||
if (!is.null(showQuestion)) {
|
||||
q_continue <- showQuestion("Create new file in home directory", txt)
|
||||
} else {
|
||||
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
|
||||
|
7
R/pca.R
7
R/pca.R
@ -26,7 +26,7 @@
|
||||
#' Principal Component Analysis (for AMR)
|
||||
#'
|
||||
#' Performs a principal component analysis (PCA) based on a data set with automatic determination for afterwards plotting the groups and labels, and automatic filtering on only suitable (i.e. non-empty and numeric) variables.
|
||||
#' @inheritSection lifecycle Maturing lifecycle
|
||||
#' @inheritSection lifecycle Maturing Lifecycle
|
||||
#' @param x a [data.frame] containing numeric columns
|
||||
#' @param ... columns of `x` to be selected for PCA, can be unquoted since it supports quasiquotation.
|
||||
#' @inheritParams stats::prcomp
|
||||
@ -36,8 +36,9 @@
|
||||
#' @return An object of classes [pca] and [prcomp]
|
||||
#' @importFrom stats prcomp
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # `example_isolates` is a dataset available in the AMR package.
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' \donttest{
|
||||
@ -98,7 +99,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. Please see Examples in ?pca.")
|
||||
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.")
|
||||
}
|
||||
|
||||
# set column names
|
||||
|
@ -23,16 +23,16 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Calculate microbial resistance
|
||||
#' Calculate Microbial Resistance
|
||||
#'
|
||||
#' @description These functions can be used to calculate the (co-)resistance or susceptibility of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in `summarise()` from the `dplyr` package and also support grouped variables, please see *Examples*.
|
||||
#' @description These functions can be used to calculate the (co-)resistance or susceptibility of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in `summarise()` from the `dplyr` package and also support grouped variables, see *Examples*.
|
||||
#'
|
||||
#' [resistance()] should be used to calculate resistance, [susceptibility()] should be used to calculate susceptibility.\cr
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with [as.rsi()] if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.
|
||||
#' @param minimum the minimum allowed number of available (tested) isolates. Any isolate count lower than `minimum` will return `NA` with a warning. The default number of `30` isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with [as.rsi()] if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See *Examples*.
|
||||
#' @param minimum the minimum allowed number of available (tested) isolates. Any isolate count lower than `minimum` will return `NA` with a warning. The default number of `30` isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see *Source*.
|
||||
#' @param as_percent a logical to indicate whether the output must be returned as a hundred fold with % sign (a character). A value of `0.123456` will then be returned as `"12.3%"`.
|
||||
#' @param only_all_tested (for combination therapies, i.e. using more than one variable for `...`): a logical to indicate that isolates must be tested for all antibiotics, see section *Combination therapy* below
|
||||
#' @param only_all_tested (for combination therapies, i.e. using more than one variable for `...`): a logical to indicate that isolates must be tested for all antibiotics, see section *Combination Therapy* below
|
||||
#' @param data a [data.frame] containing columns with class [`rsi`] (see [as.rsi()])
|
||||
#' @param translate_ab a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]
|
||||
#' @inheritParams ab_property
|
||||
@ -47,7 +47,7 @@
|
||||
#' These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the [`count()`][AMR::count()] functions to count isolates. The function [susceptibility()] is essentially equal to `count_susceptible() / count_all()`. *Low counts can influence the outcome - the `proportion` functions may camouflage this, since they only return the proportion (albeit being dependent on the `minimum` argument).*
|
||||
#'
|
||||
#' The function [proportion_df()] takes any variable from `data` that has an [`rsi`] class (created with [as.rsi()]) and calculates the proportions R, I and S. It also supports grouped variables. The function [rsi_df()] works exactly like [proportion_df()], but adds the number of isolates.
|
||||
#' @section Combination therapy:
|
||||
#' @section Combination Therapy:
|
||||
#' When using more than one variable for `...` (= combination therapy), use `only_all_tested` to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Drug A and Drug B, about how [susceptibility()] works to calculate the %SI:
|
||||
#'
|
||||
#' ```
|
||||
@ -88,7 +88,7 @@
|
||||
#' @aliases portion
|
||||
#' @name proportion
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # example_isolates is a data set available in the AMR package.
|
||||
#' ?example_isolates
|
||||
|
@ -23,10 +23,10 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Random MIC values/disk zones/RSI generation
|
||||
#' Random MIC Values/Disk Zones/RSI Generation
|
||||
#'
|
||||
#' These functions can be used for generating random MIC values and disk diffusion diameters, for AMR analysis practice.
|
||||
#' @inheritSection lifecycle Maturing lifecycle
|
||||
#' @inheritSection lifecycle Maturing Lifecycle
|
||||
#' @param size desired size of the returned vector
|
||||
#' @param mo any character that can be coerced to a valid microorganism code with [as.mo()]
|
||||
#' @param ab any character that can be coerced to a valid antimicrobial agent code with [as.ab()]
|
||||
@ -39,7 +39,7 @@
|
||||
#' @name random
|
||||
#' @rdname random
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' random_mic(100)
|
||||
#' random_disk(100)
|
||||
|
@ -26,14 +26,14 @@
|
||||
#' Predict antimicrobial resistance
|
||||
#'
|
||||
#' Create a prediction model to predict antimicrobial resistance for the next years on statistical solid ground. Standard errors (SE) will be returned as columns `se_min` and `se_max`. See *Examples* for a real live example.
|
||||
#' @inheritSection lifecycle Maturing lifecycle
|
||||
#' @inheritSection lifecycle Maturing Lifecycle
|
||||
#' @param col_ab column name of `x` containing antimicrobial interpretations (`"R"`, `"I"` and `"S"`)
|
||||
#' @param col_date column name of the date, will be used to calculate years if this column doesn't consist of years already, defaults to the first column of with a date class
|
||||
#' @param year_min lowest year to use in the prediction model, dafaults to the lowest year in `col_date`
|
||||
#' @param year_max highest year to use in the prediction model, defaults to 10 years after today
|
||||
#' @param year_every unit of sequence between lowest year found in the data and `year_max`
|
||||
#' @param minimum minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.
|
||||
#' @param model the statistical model of choice. This could be a generalised linear regression model with binomial distribution (i.e. using `glm(..., family = binomial)``, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for all valid options.
|
||||
#' @param model the statistical model of choice. This could be a generalised linear regression model with binomial distribution (i.e. using `glm(..., family = binomial)``, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See *Details* for all valid options.
|
||||
#' @param I_as_S a logical to indicate whether values `"I"` should be treated as `"S"` (will otherwise be treated as `"R"`). The default, `TRUE`, follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section *Interpretation of S, I and R* below.
|
||||
#' @param preserve_measurements a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be `NA`.
|
||||
#' @param info a logical to indicate whether textual analysis should be printed with the name and [summary()] of the statistical model.
|
||||
@ -56,14 +56,14 @@
|
||||
#' - `observed`, the original observed resistant percentages
|
||||
#' - `estimated`, the estimated resistant percentages, calculated by the model
|
||||
#'
|
||||
#' Furthermore, the model itself is available as an attribute: `attributes(x)$model`, please see *Examples*.
|
||||
#' Furthermore, the model itself is available as an attribute: `attributes(x)$model`, see *Examples*.
|
||||
#' @seealso The [proportion()] functions to calculate resistance
|
||||
#'
|
||||
#' Models: [lm()] [glm()]
|
||||
#' @rdname resistance_predict
|
||||
#' @export
|
||||
#' @importFrom stats predict glm lm
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' x <- resistance_predict(example_isolates,
|
||||
#' col_ab = "AMX",
|
||||
@ -129,10 +129,10 @@ resistance_predict <- function(x,
|
||||
meet_criteria(x, allow_class = "data.frame")
|
||||
meet_criteria(col_ab, allow_class = "character", has_length = 1, is_in = colnames(x))
|
||||
meet_criteria(col_date, allow_class = "character", has_length = 1, is_in = colnames(x), allow_NULL = TRUE)
|
||||
meet_criteria(year_min, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(year_max, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(year_every, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(year_min, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(year_max, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(year_every, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_finite = TRUE)
|
||||
meet_criteria(model, allow_class = c("character", "function"), has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(I_as_S, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(preserve_measurements, allow_class = "logical", has_length = 1)
|
||||
@ -143,7 +143,7 @@ resistance_predict <- function(x,
|
||||
dots <- unlist(list(...))
|
||||
if (length(dots) != 0) {
|
||||
# backwards compatibility with old arguments
|
||||
dots.names <- dots %pm>% names()
|
||||
dots.names <- names(dots)
|
||||
if ("tbl" %in% dots.names) {
|
||||
x <- dots[which(dots.names == "tbl")]
|
||||
}
|
||||
|
51
R/rsi.R
51
R/rsi.R
@ -23,24 +23,24 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Interpret MIC and disk values, or clean raw R/SI data
|
||||
#' Interpret MIC and Disk Values, or Clean Raw R/SI Data
|
||||
#'
|
||||
#' Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class [`rsi`], which is an ordered factor with levels `S < I < R`. Values that cannot be interpreted will be returned as `NA` with a warning.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @rdname as.rsi
|
||||
#' @param x vector of values (for class [`mic`]: an MIC value in mg/L, for class [`disk`]: a disk diffusion radius in millimetres)
|
||||
#' @param mo any (vector of) text that can be coerced to a valid microorganism code with [as.mo()], will be determined automatically if the `dplyr` package is installed
|
||||
#' @param mo any (vector of) text that can be coerced to a valid microorganism code with [as.mo()], can be left empty to determine it automatically
|
||||
#' @param ab any (vector of) text that can be coerced to a valid antimicrobial code with [as.ab()]
|
||||
#' @param uti (Urinary Tract Infection) A vector with [logical]s (`TRUE` or `FALSE`) to specify whether a UTI specific interpretation from the guideline should be chosen. For using [as.rsi()] on a [data.frame], this can also be a column containing [logical]s or when left blank, the data set will be searched for a 'specimen' and rows containing 'urin' (such as 'urine', 'urina') in that column will be regarded isolates from a UTI. See *Examples*.
|
||||
#' @inheritParams first_isolate
|
||||
#' @param guideline defaults to the latest included EUCAST guideline, see Details for all options
|
||||
#' @param guideline defaults to the latest included EUCAST guideline, see *Details* for all options
|
||||
#' @param conserve_capped_values a logical to indicate that MIC values starting with `">"` (but not `">="`) must always return "R" , and that MIC values starting with `"<"` (but not `"<="`) must always return "S"
|
||||
#' @param add_intrinsic_resistance *(only useful when using a EUCAST guideline)* a logical to indicate whether intrinsic antibiotic resistance must also be considered for applicable bug-drug combinations, meaning that e.g. ampicillin will always return "R" in *Klebsiella* species. Determination is based on the [intrinsic_resistant] data set, that itself is based on `r format_eucast_version_nr(3.2)`.
|
||||
#' @param reference_data a [data.frame] to be used for interpretation, which defaults to the [rsi_translation] data set. Changing this argument allows for using own interpretation guidelines. This argument must contain a data set that is equal in structure to the [rsi_translation] data set (same column names and column types). Please note that the `guideline` argument will be ignored when `reference_data` is manually set.
|
||||
#' @param threshold maximum fraction of invalid antimicrobial interpretations of `x`, please see *Examples*
|
||||
#' @param threshold maximum fraction of invalid antimicrobial interpretations of `x`, see *Examples*
|
||||
#' @param ... for using on a [data.frame]: names of columns to apply [as.rsi()] on (supports tidy selection like `AMX:VAN`). Otherwise: arguments passed on to methods.
|
||||
#' @details
|
||||
#' ## How it works
|
||||
#' ## How it Works
|
||||
#'
|
||||
#' The [as.rsi()] function works in four ways:
|
||||
#'
|
||||
@ -49,33 +49,33 @@
|
||||
#' 2. For **interpreting minimum inhibitory concentration (MIC) values** according to EUCAST or CLSI. You must clean your MIC values first using [as.mic()], that also gives your columns the new data class [`mic`]. Also, be sure to have a column with microorganism names or codes. It will be found automatically, but can be set manually using the `mo` argument.
|
||||
#' * Using `dplyr`, R/SI interpretation can be done very easily with either:
|
||||
#' ```
|
||||
#' your_data %>% mutate_if(is.mic, as.rsi) # until dplyr 1.0.0
|
||||
#' your_data %>% mutate(across(where(is.mic), as.rsi)) # since dplyr 1.0.0
|
||||
#' your_data %>% mutate_if(is.mic, as.rsi) # until dplyr 1.0.0
|
||||
#' your_data %>% mutate(across((is.mic), as.rsi)) # since dplyr 1.0.0
|
||||
#' ```
|
||||
#' * Operators like "<=" will be stripped before interpretation. When using `conserve_capped_values = TRUE`, an MIC value of e.g. ">2" will always return "R", even if the breakpoint according to the chosen guideline is ">=4". This is to prevent that capped values from raw laboratory data would not be treated conservatively. The default behaviour (`conserve_capped_values = FALSE`) considers ">2" to be lower than ">=4" and might in this case return "S" or "I".
|
||||
#'
|
||||
#' 3. For **interpreting disk diffusion diameters** according to EUCAST or CLSI. You must clean your disk zones first using [as.disk()], that also gives your columns the new data class [`disk`]. Also, be sure to have a column with microorganism names or codes. It will be found automatically, but can be set manually using the `mo` argument.
|
||||
#' * Using `dplyr`, R/SI interpretation can be done very easily with either:
|
||||
#' ```
|
||||
#' your_data %>% mutate_if(is.disk, as.rsi) # until dplyr 1.0.0
|
||||
#' your_data %>% mutate(across(where(is.disk), as.rsi)) # since dplyr 1.0.0
|
||||
#' your_data %>% mutate_if(is.disk, as.rsi) # until dplyr 1.0.0
|
||||
#' your_data %>% mutate(across((is.disk), as.rsi)) # since dplyr 1.0.0
|
||||
#' ```
|
||||
#'
|
||||
#' 4. For **interpreting a complete data set**, with automatic determination of MIC values, disk diffusion diameters, microorganism names or codes, and antimicrobial test results. This is done very simply by running `as.rsi(data)`.
|
||||
#'
|
||||
#' ## Supported guidelines
|
||||
#' ## Supported Guidelines
|
||||
#'
|
||||
#' For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the `guideline` argument are: `r paste0('"', sort(unique(AMR::rsi_translation$guideline)), '"', collapse = ", ")`.
|
||||
#'
|
||||
#' Simply using `"CLSI"` or `"EUCAST"` as input will automatically select the latest version of that guideline. You can set your own data set using the `reference_data` argument. The `guideline` argument will then be ignored.
|
||||
#'
|
||||
#' ## After interpretation
|
||||
#' ## After Interpretation
|
||||
#'
|
||||
#' After using [as.rsi()], you can use the [eucast_rules()] defined by EUCAST to (1) apply inferred susceptibility and resistance based on results of other antimicrobials and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.
|
||||
#'
|
||||
#' ## Machine readable interpretation guidelines
|
||||
#' ## Machine-Readable Interpretation Guidelines
|
||||
#'
|
||||
#' The repository of this package [contains a machine readable version](https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt) of all guidelines. This is a CSV file consisting of `r format(nrow(AMR::rsi_translation), big.mark = ",")` rows and `r ncol(AMR::rsi_translation)` columns. This file is machine readable, since it contains one row for every unique combination of the test method (MIC or disk diffusion), the antimicrobial agent and the microorganism. **This allows for easy implementation of these rules in laboratory information systems (LIS)**. Note that it only contains interpretation guidelines for humans - interpretation guidelines from CLSI for animals were removed.
|
||||
#' The repository of this package [contains a machine-readable version](https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt) of all guidelines. This is a CSV file consisting of `r format(nrow(AMR::rsi_translation), big.mark = ",")` rows and `r ncol(AMR::rsi_translation)` columns. This file is machine-readable, since it contains one row for every unique combination of the test method (MIC or disk diffusion), the antimicrobial agent and the microorganism. **This allows for easy implementation of these rules in laboratory information systems (LIS)**. Note that it only contains interpretation guidelines for humans - interpretation guidelines from CLSI for animals were removed.
|
||||
#'
|
||||
#' ## Other
|
||||
#'
|
||||
@ -95,8 +95,8 @@
|
||||
#' @aliases rsi
|
||||
#' @export
|
||||
#' @seealso [as.mic()], [as.disk()], [as.mo()]
|
||||
#' @inheritSection AMR Reference data publicly available
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' summary(example_isolates) # see all R/SI results at a glance
|
||||
#'
|
||||
@ -133,7 +133,7 @@
|
||||
#' if (require("dplyr")) {
|
||||
#' df %>% mutate_if(is.mic, as.rsi)
|
||||
#' df %>% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
|
||||
#' df %>% mutate(across(where(is.mic), as.rsi))
|
||||
#' df %>% mutate(across((is.mic), as.rsi))
|
||||
#' df %>% mutate_at(vars(AMP:TOB), as.rsi)
|
||||
#' df %>% mutate(across(AMP:TOB, as.rsi))
|
||||
#'
|
||||
@ -179,7 +179,7 @@
|
||||
#'
|
||||
#' # note: from dplyr 1.0.0 on, this will be:
|
||||
#' # example_isolates %>%
|
||||
#' # mutate(across(where(is.rsi.eligible), as.rsi))
|
||||
#' # mutate(across((is.rsi.eligible), as.rsi))
|
||||
#' }
|
||||
#' }
|
||||
as.rsi <- function(x, ...) {
|
||||
@ -202,14 +202,19 @@ is.rsi.eligible <- function(x, threshold = 0.05) {
|
||||
"numeric",
|
||||
"integer",
|
||||
"mo",
|
||||
"ab",
|
||||
"Date",
|
||||
"POSIXct",
|
||||
"POSIXt",
|
||||
"rsi",
|
||||
"raw",
|
||||
"hms")
|
||||
"hms",
|
||||
"mic",
|
||||
"disk")
|
||||
%in% class(x))) {
|
||||
# no transformation needed
|
||||
FALSE
|
||||
return(FALSE)
|
||||
} else if (!any(c("R", "S", "I") %in% x, na.rm = TRUE)) {
|
||||
return(FALSE)
|
||||
} else {
|
||||
x <- x[!is.na(x) & !is.null(x) & !identical(x, "")]
|
||||
if (length(x) == 0) {
|
||||
@ -474,7 +479,7 @@ as.rsi.data.frame <- function(x,
|
||||
uti = NULL,
|
||||
conserve_capped_values = FALSE,
|
||||
add_intrinsic_resistance = FALSE,
|
||||
reference_data = rsi_translation) {
|
||||
reference_data = AMR::rsi_translation) {
|
||||
meet_criteria(x, allow_class = "data.frame") # will also check for dimensions > 0
|
||||
meet_criteria(col_mo, allow_class = "character", is_in = colnames(x), allow_NULL = TRUE)
|
||||
meet_criteria(guideline, allow_class = "character", has_length = 1)
|
||||
@ -989,7 +994,7 @@ plot.rsi <- function(x,
|
||||
main = paste("Resistance Overview of", deparse(substitute(x))),
|
||||
axes = FALSE,
|
||||
...) {
|
||||
meet_criteria(lwd, allow_class = c("numeric", "integer"), has_length = 1)
|
||||
meet_criteria(lwd, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(ylim, allow_class = c("numeric", "integer"), allow_NULL = TRUE)
|
||||
meet_criteria(ylab, allow_class = "character", has_length = 1)
|
||||
meet_criteria(xlab, allow_class = "character", has_length = 1)
|
||||
|
@ -37,7 +37,7 @@ rsi_calc <- function(...,
|
||||
only_all_tested = FALSE,
|
||||
only_count = FALSE) {
|
||||
meet_criteria(ab_result, allow_class = c("character", "numeric", "integer"), has_length = c(1, 2, 3), .call_depth = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, .call_depth = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_finite = TRUE, .call_depth = 1)
|
||||
meet_criteria(as_percent, allow_class = "logical", has_length = 1, .call_depth = 1)
|
||||
meet_criteria(only_all_tested, allow_class = "logical", has_length = 1, .call_depth = 1)
|
||||
meet_criteria(only_count, allow_class = "logical", has_length = 1, .call_depth = 1)
|
||||
@ -148,7 +148,9 @@ rsi_calc <- function(...,
|
||||
|
||||
if (print_warning == TRUE) {
|
||||
if (message_not_thrown_before("rsi_calc")) {
|
||||
warning_("Increase speed by transforming to class <rsi> on beforehand: your_data %>% mutate_if(is.rsi.eligible, as.rsi)",
|
||||
warning_("Increase speed by transforming to class <rsi> on beforehand:\n",
|
||||
" your_data %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" your_data %>% mutate(across((is.rsi.eligible), as.rsi))",
|
||||
call = FALSE)
|
||||
remember_thrown_message("rsi_calc")
|
||||
}
|
||||
@ -189,7 +191,7 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
|
||||
meet_criteria(data, allow_class = "data.frame", contains_column_class = "rsi", .call_depth = 1)
|
||||
meet_criteria(translate_ab, allow_class = c("character", "logical"), has_length = 1, allow_NA = TRUE, .call_depth = 1)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE, .call_depth = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, .call_depth = 1)
|
||||
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_finite = TRUE, .call_depth = 1)
|
||||
meet_criteria(as_percent, allow_class = "logical", has_length = 1, .call_depth = 1)
|
||||
meet_criteria(combine_SI, allow_class = "logical", has_length = 1, .call_depth = 1)
|
||||
meet_criteria(combine_SI_missing, allow_class = "logical", has_length = 1, .call_depth = 1)
|
||||
|
@ -23,17 +23,17 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Skewness of the sample
|
||||
#' Skewness of the Sample
|
||||
#'
|
||||
#' @description Skewness is a measure of the asymmetry of the probability distribution of a real-valued random variable about its mean.
|
||||
#'
|
||||
#' When negative ('left-skewed'): the left tail is longer; the mass of the distribution is concentrated on the right of a histogram. When positive ('right-skewed'): the right tail is longer; the mass of the distribution is concentrated on the left of a histogram. A normal distribution has a skewness of 0.
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a vector of values, a [matrix] or a [data.frame]
|
||||
#' @param na.rm a logical value indicating whether `NA` values should be stripped before the computation proceeds
|
||||
#' @seealso [kurtosis()]
|
||||
#' @rdname skewness
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @export
|
||||
skewness <- function(x, na.rm = FALSE) {
|
||||
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||
|
BIN
R/sysdata.rda
BIN
R/sysdata.rda
Binary file not shown.
@ -23,24 +23,24 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Translate strings from AMR package
|
||||
#' Translate Strings from AMR Package
|
||||
#'
|
||||
#' For language-dependent output of AMR functions, like [mo_name()], [mo_gramstain()], [mo_type()] and [ab_name()].
|
||||
#' @inheritSection lifecycle Stable lifecycle
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @details Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: <https://github.com/msberends/AMR/blob/master/data-raw/translations.tsv>. This file will be read by all functions where a translated output can be desired, like all [`mo_*`][mo_property()] functions (such as [mo_name()], [mo_gramstain()], [mo_type()], etc.) and [`ab_*`][ab_property()] functions (such as [ab_name()], [ab_group()], etc.).
|
||||
#'
|
||||
#' Currently supported languages are: `r paste(sort(gsub(";.*", "", ISOcodes::ISO_639_2[which(ISOcodes::ISO_639_2$Alpha_2 %in% LANGUAGES_SUPPORTED), "Name"])), collapse = ", ")`. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names.
|
||||
#'
|
||||
#' Please suggest your own translations [by creating a new issue on our repository](https://github.com/msberends/AMR/issues/new?title=Translations).
|
||||
#'
|
||||
#' ## Changing the default language
|
||||
#' ## Changing the Default Language
|
||||
#' The system language will be used at default (as returned by `Sys.getenv("LANG")` or, if `LANG` is not set, [Sys.getlocale()]), if that language is supported. But the language to be used can be overwritten in two ways and will be checked in this order:
|
||||
#'
|
||||
#' 1. Setting the R option `AMR_locale`, e.g. by running `options(AMR_locale = "de")`
|
||||
#' 2. Setting the system variable `LANGUAGE` or `LANG`, e.g. by adding `LANGUAGE="de_DE.utf8"` to your `.Renviron` file in your home directory
|
||||
#'
|
||||
#' So if the R option `AMR_locale` is set, the system variables `LANGUAGE` and `LANG` will be ignored.
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @rdname translate
|
||||
#' @name translate
|
||||
#' @export
|
||||
|
@ -35,7 +35,7 @@
|
||||
#' The WHOCC is located in Oslo at the Norwegian Institute of Public Health and funded by the Norwegian government. The European Commission is the executive of the European Union and promotes its general interest.
|
||||
#'
|
||||
#' **NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package.** See <https://www.whocc.no/copyright_disclaimer/.>
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @name WHOCC
|
||||
#' @rdname WHOCC
|
||||
#' @examples
|
||||
|
114
R/zzz.R
114
R/zzz.R
@ -25,37 +25,9 @@
|
||||
|
||||
# set up package environment, used by numerous AMR functions
|
||||
pkg_env <- new.env(hash = FALSE)
|
||||
pkg_env$mo_failed <- character(0)
|
||||
|
||||
.onLoad <- function(libname, pkgname) {
|
||||
|
||||
assign(x = "AB_lookup",
|
||||
value = create_AB_lookup(),
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
assign(x = "MO_lookup",
|
||||
value = create_MO_lookup(),
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
assign(x = "MO.old_lookup",
|
||||
value = create_MO.old_lookup(),
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
assign(x = "INTRINSIC_R",
|
||||
value = create_intr_resistance(),
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
assign(x = "LANGUAGES_SUPPORTED",
|
||||
value = sort(c("en", unique(translations_file$lang))),
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
assign(x = "MO_CONS",
|
||||
value = create_species_cons_cops("CoNS"),
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
assign(x = "MO_COPS",
|
||||
value = create_species_cons_cops("CoPS"),
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
# Support for tibble headers (type_sum) and tibble columns content (pillar_shaft)
|
||||
# without the need to depend on other packages. This was suggested by the
|
||||
# developers of the vctrs package:
|
||||
@ -101,89 +73,5 @@ pkg_env <- new.env(hash = FALSE)
|
||||
font_bold("options(AMR_silentstart = TRUE)"), "]"))
|
||||
}
|
||||
|
||||
create_intr_resistance <- function() {
|
||||
# for mo_is_intrinsic_resistant() - saves a lot of time when executed on this vector
|
||||
paste(AMR::microorganisms[match(AMR::intrinsic_resistant$microorganism, AMR::microorganisms$fullname), "mo", drop = TRUE],
|
||||
AMR::antibiotics[match(AMR::intrinsic_resistant$antibiotic, AMR::antibiotics$name), "ab", drop = TRUE])
|
||||
}
|
||||
|
||||
create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
|
||||
# Determination of which staphylococcal species are CoNS/CoPS according to:
|
||||
# - Becker et al. 2014, PMID 25278577
|
||||
# - Becker et al. 2019, PMID 30872103
|
||||
# - Becker et al. 2020, PMID 32056452
|
||||
# this function returns class <mo>
|
||||
MO_staph <- AMR::microorganisms
|
||||
MO_staph <- MO_staph[which(MO_staph$genus == "Staphylococcus"), , drop = FALSE]
|
||||
if (type == "CoNS") {
|
||||
MO_staph[which(MO_staph$species %in% c("coagulase-negative", "argensis", "arlettae",
|
||||
"auricularis", "caeli", "capitis", "caprae",
|
||||
"carnosus", "chromogenes", "cohnii", "condimenti",
|
||||
"debuckii", "devriesei", "edaphicus", "epidermidis",
|
||||
"equorum", "felis", "fleurettii", "gallinarum",
|
||||
"haemolyticus", "hominis", "jettensis", "kloosii",
|
||||
"lentus", "lugdunensis", "massiliensis", "microti",
|
||||
"muscae", "nepalensis", "pasteuri", "petrasii",
|
||||
"pettenkoferi", "piscifermentans", "pseudoxylosus",
|
||||
"rostri", "saccharolyticus", "saprophyticus",
|
||||
"sciuri", "simulans", "stepanovicii", "succinus",
|
||||
"vitulinus", "warneri", "xylosus")
|
||||
| (MO_staph$species == "schleiferi" & MO_staph$subspecies %in% c("schleiferi", ""))),
|
||||
"mo", drop = TRUE]
|
||||
} else if (type == "CoPS") {
|
||||
MO_staph[which(MO_staph$species %in% c("coagulase-positive",
|
||||
"simiae", "agnetis",
|
||||
"delphini", "lutrae",
|
||||
"hyicus", "intermedius",
|
||||
"pseudintermedius", "pseudointermedius",
|
||||
"schweitzeri", "argenteus")
|
||||
| (MO_staph$species == "schleiferi" & MO_staph$subspecies == "coagulans")),
|
||||
"mo", drop = TRUE]
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
create_MO_lookup <- function() {
|
||||
MO_lookup <- AMR::microorganisms
|
||||
|
||||
MO_lookup$kingdom_index <- NA_real_
|
||||
MO_lookup[which(MO_lookup$kingdom == "Bacteria" | MO_lookup$mo == "UNKNOWN"), "kingdom_index"] <- 1
|
||||
MO_lookup[which(MO_lookup$kingdom == "Fungi"), "kingdom_index"] <- 2
|
||||
MO_lookup[which(MO_lookup$kingdom == "Protozoa"), "kingdom_index"] <- 3
|
||||
MO_lookup[which(MO_lookup$kingdom == "Archaea"), "kingdom_index"] <- 4
|
||||
# all the rest
|
||||
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)
|
||||
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))
|
||||
|
||||
# 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)
|
||||
|
||||
# so arrange data on prevalence first, then kingdom, then full name
|
||||
MO_lookup[order(MO_lookup$prevalence, MO_lookup$kingdom_index, MO_lookup$fullname_lower), ]
|
||||
}
|
||||
|
||||
create_MO.old_lookup <- function() {
|
||||
MO.old_lookup <- AMR::microorganisms.old
|
||||
MO.old_lookup$fullname_lower <- trimws(gsub("[^.a-z0-9/ \\-]+", "", tolower(trimws(MO.old_lookup$fullname))))
|
||||
|
||||
# add a column with only "e coli"-like combinations
|
||||
MO.old_lookup$g_species <- trimws(gsub("^([a-z])[a-z]+ ([a-z]+) ?.*", "\\1 \\2", MO.old_lookup$fullname_lower))
|
||||
|
||||
# so arrange data on prevalence first, then full name
|
||||
MO.old_lookup[order(MO.old_lookup$prevalence, MO.old_lookup$fullname_lower), ]
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
<img src="https://msberends.github.io/AMR/works_great_on.png" align="center" height="150px" />
|
||||
|
||||
The latest built **source package** (`AMR_x.x.x.tar.gz`) can be found in folder [/data-raw/](data-raw).
|
||||
|
||||
`AMR` is a free, open-source and independent R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. Our aim is to provide a standard for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting.
|
||||
|
||||
After installing this package, R knows ~70,000 distinct microbial species and all ~550 antibiotic, antimycotic and antiviral drugs by name and code (including ATC, EARS-NET, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data.
|
||||
|
14
_pkgdown.yml
14
_pkgdown.yml
@ -99,18 +99,19 @@ reference:
|
||||
for more information about how to work with functions in this package.
|
||||
contents:
|
||||
- "`AMR`"
|
||||
- "`example_isolates`"
|
||||
- "`microorganisms`"
|
||||
- "`microorganisms.codes`"
|
||||
- "`microorganisms.old`"
|
||||
- "`antibiotics`"
|
||||
- "`intrinsic_resistant`"
|
||||
- "`dosage`"
|
||||
- "`catalogue_of_life`"
|
||||
- "`catalogue_of_life_version`"
|
||||
- "`WHOCC`"
|
||||
- "`lifecycle`"
|
||||
- "`microorganisms`"
|
||||
- "`antibiotics`"
|
||||
- "`intrinsic_resistant`"
|
||||
- "`example_isolates`"
|
||||
- "`example_isolates_unclean`"
|
||||
- "`rsi_translation`"
|
||||
- "`microorganisms.codes`"
|
||||
- "`microorganisms.old`"
|
||||
- "`WHONET`"
|
||||
|
||||
- title: "Preparing data: microorganisms"
|
||||
@ -143,6 +144,7 @@ reference:
|
||||
- "`as.disk`"
|
||||
- "`eucast_rules`"
|
||||
- "`plot`"
|
||||
- "`isolate_identifier`"
|
||||
|
||||
- title: "Analysing data: antimicrobial resistance"
|
||||
desc: >
|
||||
|
@ -1 +1 @@
|
||||
* Since version 0.3.0 (2018-08-14), CHECK returns a NOTE for having a data directory over 3 MB. This is needed to offer users reference data for the complete taxonomy of microorganisms - one of the most important features of this package.
|
||||
* Ever since one of the first CRAN releases, CHECK returns a NOTE for having a data and R directory over 3 MB. This is needed to offer users reference data for the complete taxonomy of microorganisms - one of the most important features of this package.
|
||||
|
BIN
data-raw/AMR_1.5.0.9012.tar.gz
Normal file
BIN
data-raw/AMR_1.5.0.9012.tar.gz
Normal file
Binary file not shown.
Binary file not shown.
BIN
data-raw/Dosages_v_11.0_Breakpoint_Tables.xlsx
Normal file
BIN
data-raw/Dosages_v_11.0_Breakpoint_Tables.xlsx
Normal file
Binary file not shown.
@ -1 +1 @@
|
||||
a30faa0e4475d440d1bb8e44e6857062
|
||||
fa68ab044001078f290218a7de6cc5c4
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -37,6 +37,8 @@
|
||||
"BEK" 439318 "Bekanamycin" "Aminoglycosides" "" "c(\"aminodeoxykanamycin\", \"becanamicina\", \"bekanamycin\", \"bekanamycine\", \"bekanamycinum\", \"nebramycin v\")" "character(0)"
|
||||
"BNB" "J01CE08" "Benzathine benzylpenicillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "" 3.6 "g" ""
|
||||
"BNP" "J01CE10" 64725 "Benzathine phenoxymethylpenicillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"bicillin v\", \"biphecillin\")" 2 "g" "character(0)"
|
||||
"PEN" "J01CE01" 5904 "Benzylpenicillin" "Beta-lactams/penicillins" "Combinations of antibacterials" "Combinations of antibacterials" "c(\"bepe\", \"pen\", \"peni\", \"peni g\", \"penicillin\", \"penicillin g\", \"pg\")" "c(\"abbocillin\", \"ayercillin\", \"bencilpenicilina\", \"benzopenicillin\", \"benzyl penicillin\", \"benzylpenicillin\", \"benzylpenicillin g\", \"benzylpenicilline\", \"benzylpenicillinum\", \"bicillin\", \"cillora\", \"cilloral\", \"cilopen\", \"compocillin g\", \"cosmopen\", \"dropcillin\", \"free penicillin g\", \"free penicillin ii\", \"galofak\", \"gelacillin\", \"liquacillin\", \"megacillin\", \"pencillin g\", \"penicillin\", \"penicilling\", \"pentids\", \"permapen\", \"pfizerpen\", \"pfizerpen g\", \"pharmacillin\", \"pradupen\", \"specilline g\", \"ursopen\"
|
||||
)" 3.6 "g" "3913-1"
|
||||
"BES" 10178705 "Besifloxacin" "Quinolones" "" "besifloxacin" "character(0)"
|
||||
"BIA" 71339 "Biapenem" "Carbapenems" "" "c(\"biapenem\", \"biapenern\", \"bipenem\", \"omegacin\")" "character(0)"
|
||||
"BCZ" 65807 "Bicyclomycin (Bicozamycin)" "Other antibacterials" "" "c(\"aizumycin\", \"bacfeed\", \"bacteron\", \"bicozamicina\", \"bicozamycin\", \"bicozamycine\", \"bicozamycinum\")" "character(0)"
|
||||
@ -328,8 +330,6 @@
|
||||
"PAZ" "J01MA18" 65957 "Pazufloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "" "c(\"pazufloxacin\", \"pazufloxacine\", \"pazufloxacino\", \"pazufloxacinum\")" 1 "g" "character(0)"
|
||||
"PEF" "J01MA03" 51081 "Pefloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"pefl\")" "c(\"abactal\", \"labocton\", \"pefloxacin\", \"pefloxacine\", \"pefloxacino\", \"pefloxacinum\", \"perfloxacin\", \"silver pefloxacin\")" 0.8 "g" 0.8 "g" "3906-5"
|
||||
"PNM" "J01CE06" 10250769 "Penamecillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"hydroxymethyl\", \"penamecilina\", \"penamecillin\", \"penamecillina\", \"penamecilline\", \"penamecillinum\")" 1.05 "g" "character(0)"
|
||||
"PEN" "J01CE01" 5904 "Benzylpenicillin" "Beta-lactams/penicillins" "Combinations of antibacterials" "Combinations of antibacterials" "c(\"bepe\", \"pen\", \"peni\", \"peni g\", \"penicillin\", \"penicillin g\", \"pg\")" "c(\"abbocillin\", \"ayercillin\", \"bencilpenicilina\", \"benzopenicillin\", \"benzyl penicillin\", \"benzylpenicillin\", \"benzylpenicillin g\", \"benzylpenicilline\", \"benzylpenicillinum\", \"bicillin\", \"cillora\", \"cilloral\", \"cilopen\", \"compocillin g\", \"cosmopen\", \"dropcillin\", \"free penicillin g\", \"free penicillin ii\", \"galofak\", \"gelacillin\", \"liquacillin\", \"megacillin\", \"pencillin g\", \"penicillin\", \"penicilling\", \"pentids\", \"permapen\", \"pfizerpen\", \"pfizerpen g\", \"pharmacillin\", \"pradupen\", \"specilline g\", \"ursopen\"
|
||||
)" 3.6 "g" "3913-1"
|
||||
"PNO" "Penicillin/novobiocin" "Beta-lactams/penicillins" "" "" ""
|
||||
"PSU" "Penicillin/sulbactam" "Beta-lactams/penicillins" "" "" ""
|
||||
"PNM1" "J01AA10" 54686187 "Penimepicycline" "Tetracyclines" "Tetracyclines" "Tetracyclines" "" "c(\"duamine\", \"hydrocycline\", \"penetracyne\", \"penimepiciclina\", \"penimepicycline\", \"penimepicyclinum\")" "character(0)"
|
||||
@ -354,6 +354,7 @@
|
||||
"POS" "J02AC04" 468595 "Posaconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Triazole derivatives" "posa" "c(\"noxafil\", \"posaconazole\", \"posaconazole sp\", \"posconazole\")" 0.3 "g" 0.3 "g" "c(\"53731-6\", \"80545-7\")"
|
||||
"PRA" 9802884 "Pradofloxacin" "Quinolones" "" "pradofloxacin" "character(0)"
|
||||
"PRX" 71455 "Premafloxacin" "Quinolones" "" "premafloxacin" "character(0)"
|
||||
"PMD" "J04AK08" 456199 "Pretomanid" "Antimycobacterials" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "" "" ""
|
||||
"PRM" 6446787 "Primycin" "Macrolides/lincosamides" "" "" ""
|
||||
"PRI" "J01FG01" 11979535 "Pristinamycin" "Macrolides/lincosamides" "Macrolides, lincosamides and streptogramins" "Streptogramins" "c(\"\", \"pris\")" "c(\"eskalin v\", \"mikamycin\", \"mikamycine\", \"mikamycinum\", \"ostreogrycinum\", \"pristinamycine\", \"pristinamycinum\", \"stafac\", \"stafytracine\", \"staphylomycin\", \"starfac\", \"streptogramin\", \"vernamycin\", \"virgimycin\", \"virgimycine\", \"virginiamycina\", \"virginiamycine\", \"virginiamycinum\")" 2 "g" "character(0)"
|
||||
"PRB" "J01CE09" 5903 "Procaine benzylpenicillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"depocillin\", \"duphapen\", \"hostacillin\", \"hydracillin\", \"jenacillin o\", \"nopcaine\", \"penicillin procaine\", \"retardillin\", \"vetspen\", \"vitablend\")" 0.6 "g" "character(0)"
|
||||
|
Binary file not shown.
BIN
data-raw/dosage.dta
Normal file
BIN
data-raw/dosage.dta
Normal file
Binary file not shown.
1
data-raw/dosage.md5
Normal file
1
data-raw/dosage.md5
Normal file
@ -0,0 +1 @@
|
||||
58d6a0589aea598420e37045fb04a5ae
|
BIN
data-raw/dosage.rds
Normal file
BIN
data-raw/dosage.rds
Normal file
Binary file not shown.
BIN
data-raw/dosage.sas
Normal file
BIN
data-raw/dosage.sas
Normal file
Binary file not shown.
BIN
data-raw/dosage.sav
Normal file
BIN
data-raw/dosage.sav
Normal file
Binary file not shown.
170
data-raw/dosage.txt
Normal file
170
data-raw/dosage.txt
Normal file
@ -0,0 +1,170 @@
|
||||
"ab" "name" "type" "dose" "dose_times" "administration" "notes" "original_txt" "eucast_version"
|
||||
"AMK" "Amikacin" "standard_dosage" "25-30 mg/kg" 1 "iv" "" "25-30 mg/kg x 1 iv" 11
|
||||
"AMX" "Amoxicillin" "high_dosage" "2 g" 6 "iv" "" "2 g x 6 iv" 11
|
||||
"AMX" "Amoxicillin" "standard_dosage" "1 g" 3 "iv" "" "1 g x 3-4 iv" 11
|
||||
"AMX" "Amoxicillin" "high_dosage" "0.75-1 g" 3 "oral" "" "0.75-1 g x 3 oral" 11
|
||||
"AMX" "Amoxicillin" "standard_dosage" "0.5 g" 3 "oral" "" "0.5 g x 3 oral" 11
|
||||
"AMX" "Amoxicillin" "uncomplicated_uti" "0.5 g" 3 "oral" "" "0.5 g x 3 oral" 11
|
||||
"AMC" "Amoxicillin/clavulanic acid" "high_dosage" "2 g + 0.2 g" 3 "iv" "" "(2 g amoxicillin + 0.2 g clavulanic acid) x 3 iv" 11
|
||||
"AMC" "Amoxicillin/clavulanic acid" "standard_dosage" "1 g + 0.2 g" 3 "iv" "" "(1 g amoxicillin + 0.2 g clavulanic acid) x 3-4 iv" 11
|
||||
"AMC" "Amoxicillin/clavulanic acid" "high_dosage" "0.875 g + 0.125 g" 3 "oral" "" "(0.875 g amoxicillin + 0.125 g clavulanic acid) x 3 oral" 11
|
||||
"AMC" "Amoxicillin/clavulanic acid" "standard_dosage" "0.5 g + 0.125 g" 3 "oral" "" "(0.5 g amoxicillin + 0.125 g clavulanic acid) x 3 oral" 11
|
||||
"AMC" "Amoxicillin/clavulanic acid" "uncomplicated_uti" "0.5 g + 0.125 g" 3 "oral" "" "(0.5 g amoxicillin + 0.125 g clavulanic acid) x 3 oral" 11
|
||||
"AMP" "Ampicillin" "high_dosage" "2 g" 4 "iv" "" "2 g x 4 iv" 11
|
||||
"AMP" "Ampicillin" "standard_dosage" "2 g" 3 "iv" "" "2 g x 3 iv" 11
|
||||
"SAM" "Ampicillin/sulbactam" "high_dosage" "2 g + 1 g" 4 "iv" "" "(2 g ampicillin + 1 g sulbactam) x 4 iv" 11
|
||||
"SAM" "Ampicillin/sulbactam" "standard_dosage" "2 g + 1 g" 3 "iv" "" "(2 g ampicillin + 1 g sulbactam) x 3 iv" 11
|
||||
"AZM" "Azithromycin" "standard_dosage" "0.5 g" 1 "iv" "" "0.5 g x 1 iv" 11
|
||||
"AZM" "Azithromycin" "standard_dosage" "0.5 g" 1 "oral" "" "0.5 g x 1 oral" 11
|
||||
"ATM" "Aztreonam" "high_dosage" "2 g" 4 "iv" "" "2 g x 4 iv" 11
|
||||
"ATM" "Aztreonam" "standard_dosage" "1 g" 3 "iv" "" "1 g x 3 iv" 11
|
||||
"PEN" "Benzylpenicillin" "high_dosage" "1.2 g" 4 "iv" "" "1.2 g (2 MU) x 4-6 iv" 11
|
||||
"PEN" "Benzylpenicillin" "standard_dosage" "0.6 g" 4 "iv" "" "0.6 g (1 MU) x 4 iv" 11
|
||||
"CEC" "Cefaclor" "high_dosage" "1 g" 3 "oral" "" "1 g x 3 oral" 11
|
||||
"CEC" "Cefaclor" "standard_dosage" "0.25-0.5 g" 3 "oral" "" "0.25-0.5 g x 3 oral" 11
|
||||
"CFR" "Cefadroxil" "standard_dosage" "0.5-1 g" 2 "oral" "" "0.5-1 g x 2 oral" 11
|
||||
"CFR" "Cefadroxil" "uncomplicated_uti" "0.5-1 g" 2 "oral" "" "0.5-1 g x 2 oral" 11
|
||||
"CZO" "Cefazolin" "high_dosage" "2 g" 3 "iv" "" "2 g x 3 iv" 11
|
||||
"CZO" "Cefazolin" "standard_dosage" "1 g" 3 "iv" "" "1 g x 3 iv" 11
|
||||
"FEP" "Cefepime" "high_dosage" "2 g" 3 "iv" "" "2 g x 3 iv" 11
|
||||
"FEP" "Cefepime" "standard_dosage" "2 g" 2 "iv" "" "2 g x 2 iv" 11
|
||||
"FDC" "Cefiderocol" "standard_dosage" "2 g" 3 "iv" "over 3 hours" "2 g x 3 iv over 3 hours" 11
|
||||
"CFM" "Cefixime" "standard_dosage" "0.2-0.4 g" 2 "oral" "" "0.2-0.4 g x 2 oral" 11
|
||||
"CFM" "Cefixime" "uncomplicated_uti" "0.2-0.4 g" 2 "oral" "" "0.2-0.4 g x 2 oral" 11
|
||||
"CTX" "Cefotaxime" "high_dosage" "2 g" 3 "iv" "" "2 g x 3 iv" 11
|
||||
"CTX" "Cefotaxime" "standard_dosage" "1 g" 3 "iv" "" "1 g x 3 iv" 11
|
||||
"CPD" "Cefpodoxime" "standard_dosage" "0.1-0.2 g" 2 "oral" "" "0.1-0.2 g x 2 oral" 11
|
||||
"CPD" "Cefpodoxime" "uncomplicated_uti" "0.1-0.2 g" 2 "oral" "" "0.1-0.2 g x 2 oral" 11
|
||||
"CPT" "Ceftaroline" "high_dosage" "0.6 g" 3 "iv" "over 2 hours" "0.6 g x 3 iv over 2 hours" 11
|
||||
"CPT" "Ceftaroline" "standard_dosage" "0.6 g" 2 "iv" "over 1 hour" "0.6 g x 2 iv over 1 hour" 11
|
||||
"CAZ" "Ceftazidime" "high_dosage" "1 g" 6 "iv" "" "1 g x 6 iv" 11
|
||||
"CAZ" "Ceftazidime" "standard_dosage" "1 g" 3 "iv" "" "1 g x 3 iv" 11
|
||||
"CZA" "Ceftazidime/avibactam" "standard_dosage" "2 g + 0.5 g" 3 "iv" "over 2 hours" "(2 g ceftazidime + 0.5 g avibactam) x 3 iv over 2 hours" 11
|
||||
"CTB" "Ceftibuten" "standard_dosage" "0.4 g" 1 "oral" "" "0.4 g x 1 oral" 11
|
||||
"BPR" "Ceftobiprole" "standard_dosage" "0.5 g" 3 "iv" "over 2 hours" "0.5 g x 3 iv over 2 hours" 11
|
||||
"CZT" "Ceftolozane/tazobactam" "standard_dosage" "1 g + 0.5 g" 3 "iv" "over 1 hour" "(1 g ceftolozane + 0.5 g tazobactam) x 3 iv over 1 hour" 11
|
||||
"CZT" "Ceftolozane/tazobactam" "standard_dosage" "2 g + 1 g" 3 "iv" "over 1 hour" "(2 g ceftolozane + 1 g tazobactam) x 3 iv over 1 hour" 11
|
||||
"CRO" "Ceftriaxone" "high_dosage" "4 g" 1 "iv" "" "4 g x 1 iv" 11
|
||||
"CRO" "Ceftriaxone" "standard_dosage" "2 g" 1 "iv" "" "2 g x 1 iv" 11
|
||||
"CXM" "Cefuroxime" "high_dosage" "1.5 g" 3 "iv" "" "1.5 g x 3 iv" 11
|
||||
"CXM" "Cefuroxime" "standard_dosage" "0.75 g" 3 "iv" "" "0.75 g x 3 iv" 11
|
||||
"CXM" "Cefuroxime" "high_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11
|
||||
"CXM" "Cefuroxime" "standard_dosage" "0.25 g" 2 "oral" "" "0.25 g x 2 oral" 11
|
||||
"CXM" "Cefuroxime" "uncomplicated_uti" "0.25 g" 2 "oral" "" "0.25 g x 2 oral" 11
|
||||
"LEX" "Cephalexin" "standard_dosage" "0.25-1 g" 2 "oral" "" "0.25-1 g x 2-3 oral" 11
|
||||
"LEX" "Cephalexin" "uncomplicated_uti" "0.25-1 g" 2 "oral" "" "0.25-1 g x 2-3 oral" 11
|
||||
"CHL" "Chloramphenicol" "high_dosage" "2 g" 4 "iv" "" "2 g x 4 iv" 11
|
||||
"CHL" "Chloramphenicol" "standard_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11
|
||||
"CHL" "Chloramphenicol" "high_dosage" "2 g" 4 "oral" "" "2 g x 4 oral" 11
|
||||
"CHL" "Chloramphenicol" "standard_dosage" "1 g" 4 "oral" "" "1 g x 4 oral" 11
|
||||
"CIP" "Ciprofloxacin" "high_dosage" "0.4 g" 3 "iv" "" "0.4 g x 3 iv" 11
|
||||
"CIP" "Ciprofloxacin" "standard_dosage" "0.4 g" 2 "iv" "" "0.4 g x 2 iv" 11
|
||||
"CIP" "Ciprofloxacin" "high_dosage" "0.75 g" 2 "oral" "" "0.75 g x 2 oral" 11
|
||||
"CIP" "Ciprofloxacin" "standard_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11
|
||||
"CLR" "Clarithromycin" "high_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11
|
||||
"CLR" "Clarithromycin" "standard_dosage" "0.25 g" 2 "oral" "" "0.25 g x 2 oral" 11
|
||||
"CLI" "Clindamycin" "high_dosage" "0.9 g" 3 "iv" "" "0.9 g x 3 iv" 11
|
||||
"CLI" "Clindamycin" "standard_dosage" "0.6 g" 3 "iv" "" "0.6 g x 3 iv" 11
|
||||
"CLI" "Clindamycin" "high_dosage" "0.3 g" 4 "oral" "" "0.3 g x 4 oral" 11
|
||||
"CLI" "Clindamycin" "standard_dosage" "0.3 g" 2 "oral" "" "0.3 g x 2 oral" 11
|
||||
"CLO" "Cloxacillin" "high_dosage" "2 g" 6 "iv" "" "2 g x 6 iv" 11
|
||||
"CLO" "Cloxacillin" "standard_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11
|
||||
"CLO" "Cloxacillin" "high_dosage" "1 g" 4 "oral" "" "1 g x 4 oral" 11
|
||||
"CLO" "Cloxacillin" "standard_dosage" "0.5 g" 4 "oral" "" "0.5 g x 4 oral" 11
|
||||
"COL" "Colistin" "standard_dosage" "4.5 MU" 2 "iv" "loading dose of 9 MU" "4.5 MU x 2 iv with a loading dose of 9 MU" 11
|
||||
"DAL" "Dalbavancin" "standard_dosage" "1 g" 1 "iv" "over 30 minutes on day 8" "1 g x 1 iv over 30 minutes on day 1 If needed, 0.5 g x 1 iv over 30 minutes on day 8" 11
|
||||
"DAP" "Daptomycin" "standard_dosage" "4 mg/kg" 1 "iv" "" "4 mg/kg x 1 iv" 11
|
||||
"DAP" "Daptomycin" "standard_dosage" "6 mg/kg" 1 "iv" "" "6 mg/kg x 1 iv" 11
|
||||
"DFX" "Delafloxacin" "standard_dosage" "0.3 g" 2 "iv" "" "0.3 g x 2 iv" 11
|
||||
"DFX" "Delafloxacin" "standard_dosage" "0.45 g" 2 "oral" "" "0.45 g x 2 oral" 11
|
||||
"DIC" "Dicloxacillin" "high_dosage" "2 g" 6 "iv" "" "2 g x 6 iv" 11
|
||||
"DIC" "Dicloxacillin" "standard_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11
|
||||
"DIC" "Dicloxacillin" "high_dosage" "2 g" 4 "oral" "" "2 g x 4 oral" 11
|
||||
"DIC" "Dicloxacillin" "standard_dosage" "0.5-1 g" 4 "oral" "" "0.5-1 g x 4 oral" 11
|
||||
"DOR" "Doripenem" "high_dosage" "1 g" 3 "iv" "over 1 hour" "1 g x 3 iv over 1 hour" 11
|
||||
"DOR" "Doripenem" "standard_dosage" "0.5 g" 3 "iv" "over 1 hour" "0.5 g x 3 iv over 1 hour" 11
|
||||
"DOX" "Doxycycline" "high_dosage" "0.2 g" 1 "oral" "" "0.2 g x 1 oral" 11
|
||||
"DOX" "Doxycycline" "standard_dosage" "0.1 g" 1 "oral" "" "0.1 g x 1 oral" 11
|
||||
"ERV" "Eravacycline" "standard_dosage" "1 mg/kg" 2 "iv" "" "1 mg/kg x 2 iv" 11
|
||||
"ETP" "Ertapenem" "standard_dosage" "1 g" 1 "iv" "over 30 minutes" "1 g x 1 iv over 30 minutes" 11
|
||||
"ERY" "Erythromycin" "high_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11
|
||||
"ERY" "Erythromycin" "standard_dosage" "0.5 g" 2 "iv" "" "0.5 g x 2-4 iv" 11
|
||||
"ERY" "Erythromycin" "high_dosage" "1 g" 4 "oral" "" "1 g x 4 oral" 11
|
||||
"ERY" "Erythromycin" "standard_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2-4 oral" 11
|
||||
"FDX" "Fidaxomicin" "standard_dosage" "0.2 g" 2 "oral" "" "0.2 g x 2 oral" 11
|
||||
"FLC" "Flucloxacillin" "high_dosage" "2 g" 6 "iv" "" "2 g x 6 iv" 11
|
||||
"FLC" "Flucloxacillin" "standard_dosage" "2 g" 4 "iv" "" "2 g x 4 iv (or 1 g x 6 iv)" 11
|
||||
"FLC" "Flucloxacillin" "high_dosage" "1 g" 4 "oral" "" "1 g x 4 oral" 11
|
||||
"FLC" "Flucloxacillin" "standard_dosage" "1 g" 3 "oral" "" "1 g x 3 oral" 11
|
||||
"FOS" "Fosfomycin" "high_dosage" "8 g" 3 "iv" "" "8 g x 3 iv" 11
|
||||
"FOS" "Fosfomycin" "standard_dosage" "4 g" 3 "iv" "" "4 g x 3 iv" 11
|
||||
"FUS" "Fusidic acid" "high_dosage" "0.5 g" 3 "iv" "" "0.5 g x 3 iv" 11
|
||||
"FUS" "Fusidic acid" "standard_dosage" "0.5 g" 2 "iv" "" "0.5 g x 2 iv" 11
|
||||
"FUS" "Fusidic acid" "high_dosage" "0.5 g" 3 "oral" "" "0.5 g x 3 oral" 11
|
||||
"FUS" "Fusidic acid" "standard_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11
|
||||
"GEN" "Gentamicin" "standard_dosage" "6-7 mg/kg" 1 "iv" "" "6-7 mg/kg x 1 iv" 11
|
||||
"IPM" "Imipenem" "high_dosage" "1 g" 4 "iv" "over 30 minutes" "1 g x 4 iv over 30 minutes" 11
|
||||
"IPM" "Imipenem" "standard_dosage" "0.5 g" 4 "iv" "over 30 minutes" "0.5 g x 4 iv over 30 minutes" 11
|
||||
"IMR" "Imipenem/relebactam" "standard_dosage" "0.5 g + 0.25 g" 4 "iv" "over 30 minutes" "(0.5 g imipenem + 0.25 g relebactam) x 4 iv over 30 minutes" 11
|
||||
"IMR" "Imipenem/relebactam" "standard_dosage" "0.5 g + 0.25 g" 4 "iv" "over 30 minutes" "(0.5 g imipenem + 0.25 g relebactam) x 4 iv over 30 minutes" 11
|
||||
"LMU" "Lefamulin" "standard_dosage" "0.15 g" 2 "iv" "or 0.6 g x 2 oral" "0.15 g x 2 iv or 0.6 g x 2 oral" 11
|
||||
"LMU" "Lefamulin" "standard_dosage" "0.6 g" 2 "oral" "" "0.6 g x 2 oral" 11
|
||||
"LVX" "Levofloxacin" "high_dosage" "0.5 g" 2 "iv" "" "0.5 g x 2 iv" 11
|
||||
"LVX" "Levofloxacin" "standard_dosage" "0.5 g" 1 "iv" "" "0.5 g x 1 iv" 11
|
||||
"LVX" "Levofloxacin" "high_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11
|
||||
"LVX" "Levofloxacin" "standard_dosage" "0.5 g" 1 "oral" "" "0.5 g x 1 oral" 11
|
||||
"LNZ" "Linezolid" "standard_dosage" "0.6 g" 2 "iv" "" "0.6 g x 2 iv" 11
|
||||
"LNZ" "Linezolid" "standard_dosage" "0.6 g" 2 "oral" "" "0.6 g x 2 oral" 11
|
||||
"MEM" "Meropenem" "high_dosage" "2 g" 3 "iv" "over 3 hours" "2 g x 3 iv over 3 hours" 11
|
||||
"MEM" "Meropenem" "standard_dosage" "1 g" 3 "iv" "over 30 minutes" "1 g x 3 iv over 30 minutes" 11
|
||||
"MEV" "Meropenem/vaborbactam" "standard_dosage" "2 g + 2 g" 3 "iv" "over 3 hours" "(2 g meropenem + 2 g vaborbactam) x 3 iv over 3 hours" 11
|
||||
"MTR" "Metronidazole" "high_dosage" "0.5 g" 3 "iv" "" "0.5 g x 3 iv" 11
|
||||
"MTR" "Metronidazole" "standard_dosage" "0.4 g" 3 "iv" "" "0.4 g x 3 iv" 11
|
||||
"MTR" "Metronidazole" "high_dosage" "0.5 g" 3 "oral" "" "0.5 g x 3 oral" 11
|
||||
"MTR" "Metronidazole" "standard_dosage" "0.4 g" 3 "oral" "" "0.4 g x 3 oral" 11
|
||||
"MNO" "Minocycline" "standard_dosage" "0.1 g" 2 "oral" "" "0.1 g x 2 oral" 11
|
||||
"MFX" "Moxifloxacin" "standard_dosage" "0.4 g" 1 "iv" "" "0.4 g x 1 iv" 11
|
||||
"MFX" "Moxifloxacin" "standard_dosage" "0.4 g" 1 "oral" "" "0.4 g x 1 oral" 11
|
||||
"OFX" "Ofloxacin" "high_dosage" "0.4 g" 2 "iv" "" "0.4 g x 2 iv" 11
|
||||
"OFX" "Ofloxacin" "standard_dosage" "0.2 g" 2 "iv" "" "0.2 g x 2 iv" 11
|
||||
"OFX" "Ofloxacin" "high_dosage" "0.4 g" 2 "oral" "" "0.4 g x 2 oral" 11
|
||||
"OFX" "Ofloxacin" "standard_dosage" "0.2 g" 2 "oral" "" "0.2 g x 2 oral" 11
|
||||
"ORI" "Oritavancin" "standard_dosage" "1.2 g" 1 "iv" "" "1.2 g x 1 (single dose) iv over 3 hours" 11
|
||||
"OXA" "Oxacillin" "high_dosage" "1 g" 6 "iv" "" "1 g x 6 iv" 11
|
||||
"OXA" "Oxacillin" "standard_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11
|
||||
"PHN" "Phenoxymethylpenicillin" "standard_dosage" "0.5-2 g" 3 "oral" "" "0.5-2 g x 3-4 oral" 11
|
||||
"PIP" "Piperacillin" "high_dosage" "4 g" 4 "iv" "" "4 g x 4 iv by extended 3-hour infusion" 11
|
||||
"PIP" "Piperacillin" "standard_dosage" "4 g" 4 "iv" "" "4 g x 4 iv" 11
|
||||
"TZP" "Piperacillin/tazobactam" "high_dosage" "4 g + 0.5 g" 4 "iv" "" "(4 g piperacillin + 0.5 g tazobactam) x 4 iv by extended 3-hour infusion" 11
|
||||
"TZP" "Piperacillin/tazobactam" "standard_dosage" "4 g + 0.5 g" 4 "iv" "" "(4 g piperacillin + 0.5 g tazobactam) x 4 iv or x 3 by extended 4-hour infusion" 11
|
||||
"QDA" "Quinupristin/dalfopristin" "high_dosage" "7.5 mg/kg" 3 "iv" "" "7.5 mg/kg x 3 iv" 11
|
||||
"QDA" "Quinupristin/dalfopristin" "standard_dosage" "7.5 mg/kg" 2 "iv" "" "7.5 mg/kg x 2 iv" 11
|
||||
"RIF" "Rifampicin" "high_dosage" "0.6 g" 2 "iv" "" "0.6 g x 2 iv" 11
|
||||
"RIF" "Rifampicin" "standard_dosage" "0.6 g" 1 "iv" "" "0.6 g x 1 iv" 11
|
||||
"RIF" "Rifampicin" "high_dosage" "0.6 g" 2 "oral" "" "0.6 g x 2 oral" 11
|
||||
"RIF" "Rifampicin" "standard_dosage" "0.6 g" 1 "oral" "" "0.6 g x 1 oral" 11
|
||||
"RXT" "Roxithromycin" "standard_dosage" "0.15 g" 2 "oral" "" "0.15 g x 2 oral" 11
|
||||
"SPT" "Spectinomycin" "standard_dosage" "2 g" 1 "im" "" "2 g x 1 im" 11
|
||||
"TZD" "Tedizolid" "standard_dosage" "0.2 g" 1 "iv" "" "0.2 g x 1 iv" 11
|
||||
"TZD" "Tedizolid" "standard_dosage" "0.2 g" 1 "oral" "" "0.2 g x 1 oral" 11
|
||||
"TEC" "Teicoplanin" "high_dosage" "0.8 g" 1 "iv" "" "0.8 g x 1 iv" 11
|
||||
"TEC" "Teicoplanin" "standard_dosage" "0.4 g" 1 "iv" "" "0.4 g x 1 iv" 11
|
||||
"TLV" "Telavancin" "standard_dosage" "10 mg/kg" 1 "iv" "over 1 hour" "10 mg/kg x 1 iv over 1 hour" 11
|
||||
"TLT" "Telithromycin" "standard_dosage" "0.8 g" 1 "oral" "" "0.8 g x 1 oral" 11
|
||||
"TEM" "Temocillin" "high_dosage" "2 g" 3 "iv" "" "2 g x 3 iv" 11
|
||||
"TEM" "Temocillin" "standard_dosage" "2 g" 2 "iv" "" "2 g x 2 iv" 11
|
||||
"TCY" "Tetracycline" "high_dosage" "0.5 g" 4 "oral" "" "0.5 g x 4 oral" 11
|
||||
"TCY" "Tetracycline" "standard_dosage" "0.25 g" 4 "oral" "" "0.25 g x 4 oral" 11
|
||||
"TIC" "Ticarcillin" "high_dosage" "3 g" 6 "iv" "" "3 g x 6 iv" 11
|
||||
"TIC" "Ticarcillin" "standard_dosage" "3 g" 4 "iv" "" "3 g x 4 iv" 11
|
||||
"TCC" "Ticarcillin/clavulanic acid" "high_dosage" "3 g + 0.1 g" 6 "iv" "" "(3 g ticarcillin + 0.1 g clavulanic acid) x 6 iv" 11
|
||||
"TCC" "Ticarcillin/clavulanic acid" "standard_dosage" "3 g + 0.1-0.2 g" 4 "iv" "" "(3 g ticarcillin + 0.1-0.2 g clavulanic acid) x 4 iv" 11
|
||||
"TGC" "Tigecycline" "standard_dosage" "0.1 g" "loading dose followed by 50 mg x 2 iv" "0.1 g loading dose followed by 50 mg x 2 iv" 11
|
||||
"TOB" "Tobramycin" "standard_dosage" "6-7 mg/kg" 1 "iv" "" "6-7 mg/kg x 1 iv" 11
|
||||
"SXT" "Trimethoprim/sulfamethoxazole" "high_dosage" "0.24 g + 1.2 g" 2 "oral" "" "(0.24 g trimethoprim + 1.2 g sulfamethoxazole) x 2 oral" 11
|
||||
"SXT" "Trimethoprim/sulfamethoxazole" "high_dosage" "0.24 g + 1.2 g" 2 "oral" "" "(0.24 g trimethoprim + 1.2 g sulfamethoxazole) x 2 oral or (0.24 g trimethoprim + 1.2 g sulfamethoxazole) x 2 iv" 11
|
||||
"SXT" "Trimethoprim/sulfamethoxazole" "standard_dosage" "0.16 g + 0.8 g" 2 "oral" "" "(0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 oral" 11
|
||||
"SXT" "Trimethoprim/sulfamethoxazole" "standard_dosage" "0.16 g + 0.8 g" 2 "oral" "" "(0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 oral or (0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 iv" 11
|
||||
"SXT" "Trimethoprim/sulfamethoxazole" "uncomplicated_uti" "0.16 g + 0.8 g" 2 "oral" "" "(0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 oral" 11
|
||||
"SXT" "Trimethoprim/sulfamethoxazole" "uncomplicated_uti" "0.16 g + 0.8 g" 2 "oral" "" "(0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 oral" 11
|
||||
"VAN" "Vancomycin" "standard_dosage" "1 g" 2 "iv" "" "1 g x 2 iv or 2 g x 1 by continuous infusion" 11
|
BIN
data-raw/dosage.xlsx
Normal file
BIN
data-raw/dosage.xlsx
Normal file
Binary file not shown.
@ -115,6 +115,115 @@ genus_species is Kingella kingae TCY R DOX R Kingella kingae Breakpoints 10
|
||||
genus_species is Burkholderia pseudomallei TCY S DOX S Burkholderia pseudomallei Breakpoints 10
|
||||
genus_species is Burkholderia pseudomallei TCY I DOX I Burkholderia pseudomallei Breakpoints 10
|
||||
genus_species is Burkholderia pseudomallei TCY R DOX R Burkholderia pseudomallei Breakpoints 10
|
||||
order is Enterobacterales AMP S AMX S Enterobacterales (Order) Breakpoints 11
|
||||
order is Enterobacterales AMP I AMX I Enterobacterales (Order) Breakpoints 11
|
||||
order is Enterobacterales AMP R AMX R Enterobacterales (Order) Breakpoints 11
|
||||
genus is Staphylococcus PEN, FOX S AMP, AMX, PIP, TIC S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus PEN, FOX R, S OXA, FLC S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus FOX R all_betalactams R Staphylococcus Breakpoints 11
|
||||
genus_species is Staphylococcus saprophyticus AMP S AMX, AMC, PIP, TZP S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus FOX S carbapenems, cephalosporins_except_CAZ S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus FOX I carbapenems, cephalosporins_except_CAZ I Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus FOX R carbapenems, cephalosporins_except_CAZ R Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus NOR S CIP, LVX, MFX, OFX S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus ERY S AZM, CLR, RXT S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus ERY I AZM, CLR, RXT I Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus ERY R AZM, CLR, RXT R Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus TCY S DOX, MNO S Staphylococcus Breakpoints 11
|
||||
genus is Enterococcus AMP S AMX, AMC, PIP, TZP S Enterococcus Breakpoints 11
|
||||
genus is Enterococcus AMP I AMX, AMC, PIP, TZP I Enterococcus Breakpoints 11
|
||||
genus is Enterococcus AMP R AMX, AMC, PIP, TZP R Enterococcus Breakpoints 11
|
||||
genus is Enterococcus NOR S CIP, LVX S Enterococcus Breakpoints 11
|
||||
genus is Enterococcus NOR I CIP, LVX I Enterococcus Breakpoints 11
|
||||
genus is Enterococcus NOR R CIP, LVX R Enterococcus Breakpoints 11
|
||||
genus_species one_of Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G PEN S aminopenicillins, ureidopenicillins, cephalosporins_except_CAZ, carbapenems, FLC, AMC S Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species like Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G PEN I aminopenicillins, ureidopenicillins, cephalosporins_except_CAZ, carbapenems, FLC, AMC I Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species like Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G PEN R aminopenicillins, ureidopenicillins, cephalosporins_except_CAZ, carbapenems, FLC, AMC R Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species like Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G NOR S MFX S Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species like Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G NOR S LVX I Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species like Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G ERY S AZM, CLR, RXT S Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species like Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G ERY I AZM, CLR, RXT I Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species like Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G ERY R AZM, CLR, RXT R Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species like Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G TCY S DOX, MNO S Streptococcus groups A, B, C, G Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae PEN S AMP, AMX, AMC, PIP, TZP S Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae AMP S AMX, AMC, PIP, TZP S Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae AMP I AMX, AMC, PIP, TZP I Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae AMP R AMX, AMC, PIP, TZP R Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae NOR S MFX S Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae NOR S LVX I Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae ERY S AZM, CLR, RXT S Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae ERY I AZM, CLR, RXT I Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae ERY R AZM, CLR, RXT R Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species is Streptococcus pneumoniae TCY S DOX, MNO S Streptococcus pneumoniae Breakpoints 11
|
||||
genus_species like ^Streptococcus (anginosus|australis|bovis|constellatus|cristatus|equinus|gallolyticus|gordonii|infantarius|infantis|intermedius|mitis|mutans|oligofermentans|oralis|parasanguinis|peroris|pseudopneumoniae|salivarius|sanguinis|sinensis|sobrinus|thermophilus|vestibularis|viridans)$ PEN S AMP, AMX, AMC, PIP, TZP S Viridans group streptococci Breakpoints 11
|
||||
genus_species like ^Streptococcus (anginosus|australis|bovis|constellatus|cristatus|equinus|gallolyticus|gordonii|infantarius|infantis|intermedius|mitis|mutans|oligofermentans|oralis|parasanguinis|peroris|pseudopneumoniae|salivarius|sanguinis|sinensis|sobrinus|thermophilus|vestibularis|viridans)$ AMP S AMX, AMC, PIP, TZP S Viridans group streptococci Breakpoints 11
|
||||
genus_species like ^Streptococcus (anginosus|australis|bovis|constellatus|cristatus|equinus|gallolyticus|gordonii|infantarius|infantis|intermedius|mitis|mutans|oligofermentans|oralis|parasanguinis|peroris|pseudopneumoniae|salivarius|sanguinis|sinensis|sobrinus|thermophilus|vestibularis|viridans)$ AMP I AMX, AMC, PIP, TZP I Viridans group streptococci Breakpoints 11
|
||||
genus_species like ^Streptococcus (anginosus|australis|bovis|constellatus|cristatus|equinus|gallolyticus|gordonii|infantarius|infantis|intermedius|mitis|mutans|oligofermentans|oralis|parasanguinis|peroris|pseudopneumoniae|salivarius|sanguinis|sinensis|sobrinus|thermophilus|vestibularis|viridans)$ AMP R AMX, AMC, PIP, TZP R Viridans group streptococci Breakpoints 11
|
||||
genus_species is Haemophilus influenzae AMP S AMX, PIP S Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Haemophilus influenzae AMP I AMX, PIP I Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Haemophilus influenzae AMP R AMX, PIP R Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Haemophilus influenzae PEN S AMP, AMX, AMC, PIP, TZP S Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Haemophilus influenzae AMC S TZP S Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Haemophilus influenzae AMC I TZP I Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Haemophilus influenzae AMC R TZP R Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Haemophilus influenzae NAL S CIP, LVX, MFX, OFX S Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Haemophilus influenzae TCY S DOX, MNO S Haemophilus influenzae Breakpoints 11
|
||||
genus_species is Moraxella catarrhalis AMC S TZP S Moraxella catarrhalis Breakpoints 11
|
||||
genus_species is Moraxella catarrhalis AMC I TZP I Moraxella catarrhalis Breakpoints 11
|
||||
genus_species is Moraxella catarrhalis AMC R TZP R Moraxella catarrhalis Breakpoints 11
|
||||
genus_species is Moraxella catarrhalis NAL S CIP, LVX, MFX, OFX S Moraxella catarrhalis Breakpoints 11
|
||||
genus_species is Moraxella catarrhalis ERY S AZM, CLR, RXT S Moraxella catarrhalis Breakpoints 11
|
||||
genus_species is Moraxella catarrhalis ERY I AZM, CLR, RXT I Moraxella catarrhalis Breakpoints 11
|
||||
genus_species is Moraxella catarrhalis ERY R AZM, CLR, RXT R Moraxella catarrhalis Breakpoints 11
|
||||
genus_species is Moraxella catarrhalis TCY S DOX, MNO S Moraxella catarrhalis Breakpoints 11
|
||||
genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus, Propionibacterium PEN S AMP, AMX, PIP, TZP, TIC S Anaerobic Gram-positives Breakpoints 11
|
||||
genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus, Propionibacterium PEN I AMP, AMX, PIP, TZP, TIC I Anaerobic Gram-positives Breakpoints 11
|
||||
genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus, Propionibacterium PEN R AMP, AMX, PIP, TZP, TIC R Anaerobic Gram-positives Breakpoints 11
|
||||
genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella PEN S AMP, AMX, PIP, TZP, TIC S Anaerobic Gram-negatives Breakpoints 11
|
||||
genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella PEN I AMP, AMX, PIP, TZP, TIC I Anaerobic Gram-negatives Breakpoints 11
|
||||
genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella PEN R AMP, AMX, PIP, TZP, TIC R Anaerobic Gram-negatives Breakpoints 11
|
||||
genus_species is Pasteurella multocida PEN S AMP, AMX S Pasteurella multocida Breakpoints 11
|
||||
genus_species is Pasteurella multocida PEN I AMP, AMX I Pasteurella multocida Breakpoints 11
|
||||
genus_species is Pasteurella multocida PEN R AMP, AMX R Pasteurella multocida Breakpoints 11
|
||||
genus_species is Campylobacter coli ERY S AZM, CLR S Campylobacter coli Breakpoints 11
|
||||
genus_species is Campylobacter coli ERY I AZM, CLR I Campylobacter coli Breakpoints 11
|
||||
genus_species is Campylobacter coli ERY R AZM, CLR R Campylobacter coli Breakpoints 11
|
||||
genus_species is Campylobacter coli TCY S DOX S Campylobacter coli Breakpoints 11
|
||||
genus_species is Campylobacter coli TCY I DOX I Campylobacter coli Breakpoints 11
|
||||
genus_species is Campylobacter coli TCY R DOX R Campylobacter coli Breakpoints 11
|
||||
genus_species is Campylobacter jejuni ERY S AZM, CLR S Campylobacter jejuni Breakpoints 11
|
||||
genus_species is Campylobacter jejuni ERY I AZM, CLR I Campylobacter jejuni Breakpoints 11
|
||||
genus_species is Campylobacter jejuni ERY R AZM, CLR R Campylobacter jejuni Breakpoints 11
|
||||
genus_species is Campylobacter jejuni TCY S DOX S Campylobacter jejuni Breakpoints 11
|
||||
genus_species is Campylobacter jejuni TCY I DOX I Campylobacter jejuni Breakpoints 11
|
||||
genus_species is Campylobacter jejuni TCY R DOX R Campylobacter jejuni Breakpoints 11
|
||||
genus_species is Aerococcus sanguinicola NOR S fluoroquinolones S Aerococcus sanguinicola Breakpoints 11
|
||||
genus_species is Aerococcus sanguinicola NOR I fluoroquinolones I Aerococcus sanguinicola Breakpoints 11
|
||||
genus_species is Aerococcus sanguinicola NOR R fluoroquinolones R Aerococcus sanguinicola Breakpoints 11
|
||||
genus_species is Aerococcus sanguinicola CIP S LVX S Aerococcus sanguinicola Breakpoints 11
|
||||
genus_species is Aerococcus sanguinicola CIP I LVX I Aerococcus sanguinicola Breakpoints 11
|
||||
genus_species is Aerococcus sanguinicola CIP R LVX R Aerococcus urinae Breakpoints 11
|
||||
genus_species is Aerococcus urinae NOR S fluoroquinolones S Aerococcus urinae Breakpoints 11
|
||||
genus_species is Aerococcus urinae NOR I fluoroquinolones I Aerococcus urinae Breakpoints 11
|
||||
genus_species is Aerococcus urinae NOR R fluoroquinolones R Aerococcus urinae Breakpoints 11
|
||||
genus_species is Aerococcus urinae CIP S LVX S Aerococcus urinae Breakpoints 11
|
||||
genus_species is Aerococcus urinae CIP I LVX I Aerococcus urinae Breakpoints 11
|
||||
genus_species is Aerococcus urinae CIP R LVX R Aerococcus urinae Breakpoints 11
|
||||
genus_species is Kingella kingae PEN S AMP, AMX S Kingella kingae Breakpoints 11
|
||||
genus_species is Kingella kingae PEN I AMP, AMX I Kingella kingae Breakpoints 11
|
||||
genus_species is Kingella kingae PEN R AMP, AMX R Kingella kingae Breakpoints 11
|
||||
genus_species is Kingella kingae ERY S AZM, CLR S Kingella kingae Breakpoints 11
|
||||
genus_species is Kingella kingae ERY I AZM, CLR I Kingella kingae Breakpoints 11
|
||||
genus_species is Kingella kingae ERY R AZM, CLR R Kingella kingae Breakpoints 11
|
||||
genus_species is Kingella kingae TCY S DOX S Kingella kingae Breakpoints 11
|
||||
genus_species is Kingella kingae TCY I DOX I Kingella kingae Breakpoints 11
|
||||
genus_species is Kingella kingae TCY R DOX R Kingella kingae Breakpoints 11
|
||||
genus_species is Burkholderia pseudomallei TCY S DOX S Burkholderia pseudomallei Breakpoints 11
|
||||
genus_species is Burkholderia pseudomallei TCY I DOX I Burkholderia pseudomallei Breakpoints 11
|
||||
genus_species is Burkholderia pseudomallei TCY R DOX R Burkholderia pseudomallei Breakpoints 11
|
||||
genus is Bacillus NOR S fluoroquinolones S Bacillus Breakpoints 11 added in 11
|
||||
genus is Bacillus NOR I fluoroquinolones I Bacillus Breakpoints 11 added in 11
|
||||
genus is Bacillus NOR R fluoroquinolones R Bacillus Breakpoints 11 added in 11
|
||||
order is Enterobacterales PEN, glycopeptides, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
@ -300,6 +409,9 @@ genus_species is Moraxella catarrhalis NAL S fluoroquinolones S Expert Rules on
|
||||
genus_species is Moraxella catarrhalis NAL R fluoroquinolones R Expert Rules on Moraxella catarrhalis Expert Rules 3.2
|
||||
genus is Campylobacter ERY S CLR, AZM S Expert Rules on Campylobacter Expert Rules 3.2
|
||||
genus_species is Campylobacter ERY R CLR, AZM R Expert Rules on Campylobacter Expert Rules 3.2
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter (braakii|freundii|gillenii|murliniae|rodenticum|sedlakii|werkmanii|youngae)|Hafnia alvei|Serratia|Morganella morganii|Providencia) CTX S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter (braakii|freundii|gillenii|murliniae|rodenticum|sedlakii|werkmanii|youngae)|Hafnia alvei|Serratia|Morganella morganii|Providencia) CRO S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter (braakii|freundii|gillenii|murliniae|rodenticum|sedlakii|werkmanii|youngae)|Hafnia alvei|Serratia|Morganella morganii|Providencia) CAZ S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter braakii|Citrobacter freundii|Citrobacter gillenii|Citrobacter murliniae|Citrobacter rodenticum|Citrobacter sedlakii|Citrobacter werkmanii|Citrobacter youngae|Hafnia alvei|Serratia|Morganella morganii|Providencia) CTX S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter braakii|Citrobacter freundii|Citrobacter gillenii|Citrobacter murliniae|Citrobacter rodenticum|Citrobacter sedlakii|Citrobacter werkmanii|Citrobacter youngae|Hafnia alvei|Serratia|Morganella morganii|Providencia) CRO S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter braakii|Citrobacter freundii|Citrobacter gillenii|Citrobacter murliniae|Citrobacter rodenticum|Citrobacter sedlakii|Citrobacter werkmanii|Citrobacter youngae|Hafnia alvei|Serratia|Morganella morganii|Providencia) CAZ S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter braakii|Citrobacter freundii|Citrobacter gillenii|Citrobacter murliniae|Citrobacter rodenticum|Citrobacter sedlakii|Citrobacter werkmanii|Citrobacter youngae|Hafnia alvei|Serratia|Morganella morganii|Providencia) CTX I CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter braakii|Citrobacter freundii|Citrobacter gillenii|Citrobacter murliniae|Citrobacter rodenticum|Citrobacter sedlakii|Citrobacter werkmanii|Citrobacter youngae|Hafnia alvei|Serratia|Morganella morganii|Providencia) CRO I CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter braakii|Citrobacter freundii|Citrobacter gillenii|Citrobacter murliniae|Citrobacter rodenticum|Citrobacter sedlakii|Citrobacter werkmanii|Citrobacter youngae|Hafnia alvei|Serratia|Morganella morganii|Providencia) CAZ I CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 96.
|
@ -23,12 +23,108 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
# Run this file to update the package using: -------------------------------
|
||||
# Run this file to update the package using:
|
||||
# source("data-raw/internals.R")
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
library(dplyr, warn.conflicts = FALSE)
|
||||
devtools::load_all(quiet = TRUE)
|
||||
|
||||
old_globalenv <- ls(envir = globalenv())
|
||||
|
||||
# Helper functions --------------------------------------------------------
|
||||
|
||||
create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
|
||||
# Determination of which staphylococcal species are CoNS/CoPS according to:
|
||||
# - Becker et al. 2014, PMID 25278577
|
||||
# - Becker et al. 2019, PMID 30872103
|
||||
# - Becker et al. 2020, PMID 32056452
|
||||
# this function returns class <mo>
|
||||
MO_staph <- AMR::microorganisms
|
||||
MO_staph <- MO_staph[which(MO_staph$genus == "Staphylococcus"), , drop = FALSE]
|
||||
if (type == "CoNS") {
|
||||
MO_staph[which(MO_staph$species %in% c("coagulase-negative", "argensis", "arlettae",
|
||||
"auricularis", "caeli", "capitis", "caprae",
|
||||
"carnosus", "chromogenes", "cohnii", "condimenti",
|
||||
"debuckii", "devriesei", "edaphicus", "epidermidis",
|
||||
"equorum", "felis", "fleurettii", "gallinarum",
|
||||
"haemolyticus", "hominis", "jettensis", "kloosii",
|
||||
"lentus", "lugdunensis", "massiliensis", "microti",
|
||||
"muscae", "nepalensis", "pasteuri", "petrasii",
|
||||
"pettenkoferi", "piscifermentans", "pseudoxylosus",
|
||||
"rostri", "saccharolyticus", "saprophyticus",
|
||||
"sciuri", "simulans", "stepanovicii", "succinus",
|
||||
"vitulinus", "warneri", "xylosus")
|
||||
| (MO_staph$species == "schleiferi" & MO_staph$subspecies %in% c("schleiferi", ""))),
|
||||
"mo", drop = TRUE]
|
||||
} else if (type == "CoPS") {
|
||||
MO_staph[which(MO_staph$species %in% c("coagulase-positive",
|
||||
"simiae", "agnetis",
|
||||
"delphini", "lutrae",
|
||||
"hyicus", "intermedius",
|
||||
"pseudintermedius", "pseudointermedius",
|
||||
"schweitzeri", "argenteus")
|
||||
| (MO_staph$species == "schleiferi" & MO_staph$subspecies == "coagulans")),
|
||||
"mo", drop = TRUE]
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
create_MO_lookup <- function() {
|
||||
MO_lookup <- AMR::microorganisms
|
||||
|
||||
MO_lookup$kingdom_index <- NA_real_
|
||||
MO_lookup[which(MO_lookup$kingdom == "Bacteria" | MO_lookup$mo == "UNKNOWN"), "kingdom_index"] <- 1
|
||||
MO_lookup[which(MO_lookup$kingdom == "Fungi"), "kingdom_index"] <- 2
|
||||
MO_lookup[which(MO_lookup$kingdom == "Protozoa"), "kingdom_index"] <- 3
|
||||
MO_lookup[which(MO_lookup$kingdom == "Archaea"), "kingdom_index"] <- 4
|
||||
# all the rest
|
||||
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)
|
||||
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))
|
||||
|
||||
# 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)
|
||||
|
||||
# so arrange data on prevalence first, then kingdom, then full name
|
||||
MO_lookup[order(MO_lookup$prevalence, MO_lookup$kingdom_index, MO_lookup$fullname_lower), ]
|
||||
}
|
||||
|
||||
create_MO.old_lookup <- function() {
|
||||
MO.old_lookup <- AMR::microorganisms.old
|
||||
MO.old_lookup$fullname_lower <- trimws(gsub("[^.a-z0-9/ \\-]+", "", tolower(trimws(MO.old_lookup$fullname))))
|
||||
|
||||
# add a column with only "e coli"-like combinations
|
||||
MO.old_lookup$g_species <- trimws(gsub("^([a-z])[a-z]+ ([a-z]+) ?.*", "\\1 \\2", MO.old_lookup$fullname_lower))
|
||||
|
||||
# so arrange data on prevalence first, then full name
|
||||
MO.old_lookup[order(MO.old_lookup$prevalence, MO.old_lookup$fullname_lower), ]
|
||||
}
|
||||
|
||||
create_intr_resistance <- function() {
|
||||
# for mo_is_intrinsic_resistant() - saves a lot of time when executed on this vector
|
||||
paste(AMR::microorganisms[match(AMR::intrinsic_resistant$microorganism, AMR::microorganisms$fullname), "mo", drop = TRUE],
|
||||
AMR::antibiotics[match(AMR::intrinsic_resistant$antibiotic, AMR::antibiotics$name), "ab", drop = TRUE])
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Save internal data sets to R/sysdata.rda --------------------------------
|
||||
|
||||
# See 'data-raw/eucast_rules.tsv' for the EUCAST reference file
|
||||
library(dplyr, warn.conflicts = FALSE)
|
||||
eucast_rules_file <- utils::read.delim(file = "data-raw/eucast_rules.tsv",
|
||||
skip = 10,
|
||||
sep = "\t",
|
||||
@ -48,7 +144,7 @@ eucast_rules_file <- utils::read.delim(file = "data-raw/eucast_rules.tsv",
|
||||
mutate(reference.rule_group = as.character(reference.rule_group)) %>%
|
||||
select(-sorting_rule)
|
||||
|
||||
# Translations ----
|
||||
# Translations
|
||||
translations_file <- utils::read.delim(file = "data-raw/translations.tsv",
|
||||
sep = "\t",
|
||||
stringsAsFactors = FALSE,
|
||||
@ -62,23 +158,42 @@ translations_file <- utils::read.delim(file = "data-raw/translations.tsv",
|
||||
allowEscapes = TRUE, # else "\\1" will be imported as "\\\\1"
|
||||
quote = "")
|
||||
|
||||
# Old microorganism codes -------------------------------------------------
|
||||
|
||||
# Old microorganism codes
|
||||
microorganisms.translation <- readRDS("data-raw/microorganisms.translation.rds")
|
||||
|
||||
# for mo_is_intrinsic_resistant() - saves a lot of time when executed on this vector
|
||||
INTRINSIC_R <- create_intr_resistance()
|
||||
|
||||
# for checking input in `language` argument in e.g. mo_*() and ab_*() functions
|
||||
LANGUAGES_SUPPORTED <- sort(c("en", unique(translations_file$lang)))
|
||||
|
||||
# vectors of CoNS and CoPS, improves speed in as.mo()
|
||||
MO_CONS <- create_species_cons_cops("CoNS")
|
||||
MO_COPS <- create_species_cons_cops("CoPS")
|
||||
|
||||
# reference data - they have additional columns compared to `antibiotics` and `microorganisms` to improve speed
|
||||
AB_lookup <- create_AB_lookup()
|
||||
MO_lookup <- create_MO_lookup()
|
||||
MO.old_lookup <- create_MO.old_lookup()
|
||||
|
||||
# Export to package as internal data ----
|
||||
usethis::use_data(eucast_rules_file, translations_file, microorganisms.translation,
|
||||
usethis::use_data(eucast_rules_file,
|
||||
translations_file,
|
||||
microorganisms.translation,
|
||||
INTRINSIC_R,
|
||||
LANGUAGES_SUPPORTED,
|
||||
MO_CONS,
|
||||
MO_COPS,
|
||||
AB_lookup,
|
||||
MO_lookup,
|
||||
MO.old_lookup,
|
||||
internal = TRUE,
|
||||
overwrite = TRUE,
|
||||
version = 2,
|
||||
compress = "xz")
|
||||
|
||||
# Remove from global environment ----
|
||||
rm(eucast_rules_file)
|
||||
rm(translations_file)
|
||||
rm(microorganisms.translation)
|
||||
# Export data sets to the repository in different formats -----------------
|
||||
|
||||
# Save to raw data to repository ----
|
||||
write_md5 <- function(object) {
|
||||
conn <- file(paste0("data-raw/", deparse(substitute(object)), ".md5"))
|
||||
writeLines(digest::digest(object, "md5"), conn)
|
||||
@ -93,7 +208,7 @@ changed_md5 <- function(object) {
|
||||
}, error = function(e) TRUE)
|
||||
}
|
||||
usethis::ui_done(paste0("Saving raw data to {usethis::ui_value('/data-raw/')}"))
|
||||
devtools::load_all(quiet = TRUE)
|
||||
|
||||
# give official names to ABs and MOs
|
||||
rsi <- dplyr::mutate(rsi_translation, ab = ab_name(ab), mo = mo_name(mo))
|
||||
if (changed_md5(rsi)) {
|
||||
@ -159,5 +274,17 @@ if (changed_md5(intrinsic_resistant)) {
|
||||
try(openxlsx::write.xlsx(intrinsic_resistant, "data-raw/intrinsic_resistant.xlsx"), silent = TRUE)
|
||||
}
|
||||
|
||||
rm(write_md5)
|
||||
rm(changed_md5)
|
||||
if (changed_md5(dosage)) {
|
||||
write_md5(dosage)
|
||||
try(saveRDS(dosage, "data-raw/dosage.rds", version = 2, compress = "xz"), silent = TRUE)
|
||||
try(write.table(dosage, "data-raw/dosage.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
|
||||
try(haven::write_sas(dosage, "data-raw/dosage.sas"), silent = TRUE)
|
||||
try(haven::write_sav(dosage, "data-raw/dosage.sav"), silent = TRUE)
|
||||
try(haven::write_dta(dosage, "data-raw/dosage.dta"), silent = TRUE)
|
||||
try(openxlsx::write.xlsx(dosage, "data-raw/dosage.xlsx"), silent = TRUE)
|
||||
}
|
||||
|
||||
# remove leftovers from global env
|
||||
current_globalenv <- ls(envir = globalenv())
|
||||
rm(list = current_globalenv[!current_globalenv %in% old_globalenv])
|
||||
rm(current_globalenv)
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
library(openxlsx)
|
||||
library(dplyr)
|
||||
library(tidyr)
|
||||
library(cleaner)
|
||||
library(AMR)
|
||||
|
||||
@ -32,9 +33,18 @@ library(AMR)
|
||||
|
||||
read_EUCAST <- function(sheet, file, guideline_name) {
|
||||
|
||||
message("Getting sheet ", sheet)
|
||||
message("\nGetting sheet: ", sheet)
|
||||
sheet.bak <- sheet
|
||||
|
||||
uncertainties <- NULL
|
||||
add_uncertainties <- function(old, new) {
|
||||
if (is.null(old)) {
|
||||
new
|
||||
} else {
|
||||
bind_rows(old, new)
|
||||
}
|
||||
}
|
||||
|
||||
raw_data <- read.xlsx(xlsxFile = file,
|
||||
sheet = sheet,
|
||||
colNames = FALSE,
|
||||
@ -42,6 +52,12 @@ read_EUCAST <- function(sheet, file, guideline_name) {
|
||||
skipEmptyCols = FALSE,
|
||||
fillMergedCells = TRUE,
|
||||
na.strings = c("", "-", "NA", "IE", "IP"))
|
||||
probable_rows <- suppressWarnings(raw_data %>% mutate_all(as.double) %>% summarise_all(~sum(!is.na(.))) %>% unlist() %>% max())
|
||||
if (probable_rows == 0) {
|
||||
message("NO ROWS FOUND")
|
||||
message("------------------------")
|
||||
return(NULL)
|
||||
}
|
||||
|
||||
# in the info header in the Excel file, EUCAST mentions which genera are targeted
|
||||
if (sheet %like% "anaerob.*Gram.*posi") {
|
||||
@ -69,7 +85,8 @@ read_EUCAST <- function(sheet, file, guideline_name) {
|
||||
} else if (sheet %like% "PK.*PD") {
|
||||
sheet <- "UNKNOWN"
|
||||
}
|
||||
mo_sheet <- paste0(as.mo(unlist(strsplit(sheet, "_"))), collapse = "|")
|
||||
mo_sheet <- paste0(suppressMessages(as.mo(unlist(strsplit(sheet, "_")))), collapse = "|")
|
||||
if (!is.null(mo_uncertainties())) uncertainties <- add_uncertainties(uncertainties, mo_uncertainties())
|
||||
|
||||
set_columns_names <- function(x, cols) {
|
||||
colnames(x) <- cols[1:length(colnames(x))]
|
||||
@ -80,7 +97,8 @@ read_EUCAST <- function(sheet, file, guideline_name) {
|
||||
for (i in seq_len(length(x))) {
|
||||
y <- trimws(unlist(strsplit(x[i], "(,|and)")))
|
||||
y <- trimws(gsub("[(].*[)]", "", y))
|
||||
y <- suppressWarnings(as.mo(y, allow_uncertain = FALSE))
|
||||
y <- suppressWarnings(suppressMessages(as.mo(y, allow_uncertain = FALSE)))
|
||||
if (!is.null(mo_uncertainties())) uncertainties <<- add_uncertainties(uncertainties, mo_uncertainties())
|
||||
y <- y[!is.na(y) & y != "UNKNOWN"]
|
||||
x[i] <- paste(y, collapse = "|")
|
||||
}
|
||||
@ -153,7 +171,8 @@ read_EUCAST <- function(sheet, file, guideline_name) {
|
||||
mutate(drug = gsub(" ?[(, ].*$", "", drug),
|
||||
drug = gsub("[1-9]+$", "", drug),
|
||||
ab = as.ab(drug)) %>%
|
||||
select(ab, mo, everything(), -drug)
|
||||
select(ab, mo, everything(), -drug) %>%
|
||||
as.data.frame(stringsAsFactors = FALSE)
|
||||
|
||||
# new row for every different MO mentioned
|
||||
for (i in 1:nrow(cleaned)) {
|
||||
@ -162,7 +181,7 @@ read_EUCAST <- function(sheet, file, guideline_name) {
|
||||
mo_vect <- unlist(strsplit(mo, "|", fixed = TRUE))
|
||||
cleaned[i, "mo"] <- mo_vect[1]
|
||||
for (j in seq_len(length(mo_vect))) {
|
||||
cleaned <- bind_rows(cleaned, cleaned[i ,])
|
||||
cleaned <- bind_rows(cleaned, cleaned[i , , drop = FALSE])
|
||||
cleaned[nrow(cleaned), "mo"] <- mo_vect[j]
|
||||
}
|
||||
}
|
||||
@ -190,41 +209,26 @@ read_EUCAST <- function(sheet, file, guideline_name) {
|
||||
ref_tbl = sheet.bak,
|
||||
disk_dose = ifelse(!is.na(disk_dose), paste0(disk_dose, "ug"), NA_character_),
|
||||
breakpoint_S,
|
||||
breakpoint_R)
|
||||
breakpoint_R) %>%
|
||||
as.data.frame(stringsAsFactors = FALSE)
|
||||
|
||||
if (!is.null(uncertainties)) {
|
||||
print(uncertainties %>% distinct(input, mo, .keep_all = TRUE))
|
||||
}
|
||||
|
||||
message("Estimated: ", probable_rows, ", gained: ", cleaned %>% count(ab) %>% nrow())
|
||||
message("------------------------")
|
||||
cleaned
|
||||
}
|
||||
|
||||
sheets_to_analyse <- c("Enterobacterales",
|
||||
"Pseudomonas",
|
||||
"S.maltophilia",
|
||||
"Acinetobacter",
|
||||
"Staphylococcus",
|
||||
"Enterococcus",
|
||||
"Streptococcus A,B,C,G",
|
||||
"S.pneumoniae",
|
||||
"Viridans group streptococci",
|
||||
"H.influenzae",
|
||||
"M.catarrhalis",
|
||||
"N.gonorrhoeae",
|
||||
"N.meningitidis",
|
||||
"Anaerobes, Grampositive",
|
||||
"C.difficile",
|
||||
"Anaerobes, Gramnegative",
|
||||
"H.pylori",
|
||||
"L.monocytogenes",
|
||||
"P.multocida",
|
||||
"C.jejuni_C.coli",
|
||||
"Corynebacterium",
|
||||
"A.sanguinicola_A.urinae",
|
||||
"K.kingae",
|
||||
"Aeromonas",
|
||||
"B.pseudomallei",
|
||||
"M.tuberculosis",
|
||||
"PK PD breakpoints")
|
||||
|
||||
file <- "data-raw/v_10.0_Breakpoint_Tables.xlsx"
|
||||
guideline_name <- "EUCAST 2020"
|
||||
# Actual import -----------------------------------------------------------
|
||||
|
||||
file <- "data-raw/v_11.0_Breakpoint_Tables.xlsx"
|
||||
sheets <- readxl::excel_sheets(file)
|
||||
guideline_name <- "EUCAST 2021"
|
||||
|
||||
sheets_to_analyse <- sheets[!sheets %in% c("Content", "Changes", "Notes", "Guidance", "Dosages", "Technical uncertainty", "Topical agents")]
|
||||
|
||||
# takes the longest time:
|
||||
new_EUCAST <- read_EUCAST(sheet = sheets_to_analyse[1],
|
||||
|
@ -606,6 +606,20 @@ antibiotics <- antibiotics %>%
|
||||
TRUE ~ group))
|
||||
antibiotics[which(antibiotics$ab %in% c("CYC", "LNZ", "THA", "TZD")), "group"] <- "Oxazolidinones"
|
||||
|
||||
# add pretomanid
|
||||
antibiotics <- antibiotics %>%
|
||||
mutate(ab = as.character(ab)) %>%
|
||||
bind_rows(antibiotics %>%
|
||||
mutate(ab = as.character(ab)) %>%
|
||||
filter(ab == "SMF") %>%
|
||||
mutate(ab = "PMD",
|
||||
atc = "J04AK08",
|
||||
cid = 456199,
|
||||
name = "Pretomanid",
|
||||
abbreviations = list(""),
|
||||
oral_ddd = NA_real_))
|
||||
|
||||
|
||||
# update DDDs from WHOCC website
|
||||
ddd_oral <- double(length = nrow(antibiotics))
|
||||
ddd_iv <- double(length = nrow(antibiotics))
|
||||
|
159
data-raw/reproduction_of_dosage.R
Normal file
159
data-raw/reproduction_of_dosage.R
Normal file
@ -0,0 +1,159 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Analysis for R #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 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. #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# We created this package for both routine data analysis and academic #
|
||||
# research and it was publicly released in the hope that it will be #
|
||||
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
||||
# #
|
||||
# Visit our website for the full manual and a complete tutorial about #
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
library(dplyr)
|
||||
library(readxl)
|
||||
library(cleaner)
|
||||
|
||||
# URL:
|
||||
# https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/Dosages_v_11.0_Breakpoint_Tables.pdf
|
||||
# download the PDF file, open in Acrobat Pro and export as Excel workbook
|
||||
breakpoints_version <- 11
|
||||
|
||||
dosage_source <- read_excel("data-raw/Dosages_v_11.0_Breakpoint_Tables.xlsx", skip = 5, na = "None") %>%
|
||||
format_names(snake_case = TRUE, penicillins = "drug") %>%
|
||||
filter(!tolower(standard_dosage) %in% c("standard dosage_source", "under review")) %>%
|
||||
filter(!is.na(standard_dosage)) %>%
|
||||
# keep only one drug in the table
|
||||
arrange(desc(drug)) %>%
|
||||
mutate(drug = gsub("(.*) ([(]|iv|oral).*", "\\1", drug)) %>%
|
||||
#distinct(drug, .keep_all = TRUE) %>%
|
||||
arrange(drug) %>%
|
||||
mutate(ab = as.ab(drug),
|
||||
ab_name = ab_name(ab, language = NULL))
|
||||
|
||||
dosage_source <- bind_rows(
|
||||
# oral
|
||||
dosage_source %>%
|
||||
filter(standard_dosage %like% " oral") %>%
|
||||
mutate(standard_dosage = gsub("oral.*", "oral", standard_dosage),
|
||||
high_dosage = if_else(high_dosage %like% "oral",
|
||||
gsub("oral.*", "oral", high_dosage),
|
||||
NA_character_)),
|
||||
# iv
|
||||
dosage_source %>%
|
||||
filter(standard_dosage %like% " iv") %>%
|
||||
mutate(standard_dosage = gsub(".* or ", "", standard_dosage),
|
||||
high_dosage = if_else(high_dosage %like% "( or | iv)",
|
||||
gsub(".* or ", "", high_dosage),
|
||||
NA_character_)),
|
||||
# im
|
||||
dosage_source %>%
|
||||
filter(standard_dosage %like% " im")
|
||||
) %>%
|
||||
arrange(drug)
|
||||
|
||||
|
||||
get_dosage_lst <- function(col_data) {
|
||||
standard <- col_data %>%
|
||||
# remove new lines
|
||||
gsub(" ?(\n|\t)+ ?", " ", .) %>%
|
||||
# keep only the first suggestion, replace all after 'or' and more informative texts
|
||||
gsub("(.*?) (or|with|loading|depending|over|by) .*", "\\1", .) %>%
|
||||
# remove (1 MU)
|
||||
gsub(" [(][0-9] [A-Z]+[)]", "", .) %>%
|
||||
# remove parentheses
|
||||
gsub("[)(]", "", .) %>%
|
||||
# remove drug names
|
||||
gsub(" [a-z]{5,99}( |$)", " ", .) %>%
|
||||
gsub(" [a-z]{5,99}( |$)", " ", .) %>%
|
||||
gsub(" (acid|dose)", "", .)# %>%
|
||||
# keep lowest value only (25-30 mg -> 25 mg)
|
||||
# gsub("[-].*? ", " ", .)
|
||||
|
||||
dosage_lst <- lapply(strsplit(standard, " x "),
|
||||
function(x) {
|
||||
dose <- x[1]
|
||||
if (dose %like% "under") {
|
||||
dose <- NA_character_
|
||||
}
|
||||
admin <- x[2]
|
||||
|
||||
list(
|
||||
dose = trimws(dose),
|
||||
dose_times = gsub("^([0-9.]+).*", "\\1", admin),
|
||||
administration = clean_character(admin),
|
||||
notes = "",
|
||||
original_txt = ""
|
||||
)
|
||||
})
|
||||
for (i in seq_len(length(col_data))) {
|
||||
dosage_lst[[i]]$original_txt <- gsub("\n", " ", col_data[i])
|
||||
if (col_data[i] %like% " (or|with|loading|depending|over) ") {
|
||||
dosage_lst[[i]]$notes <- gsub("\n", " ", gsub(".* ((or|with|loading|depending|over) .*)", "\\1", col_data[i]))
|
||||
}
|
||||
}
|
||||
dosage_lst
|
||||
}
|
||||
|
||||
standard <- get_dosage_lst(dosage_source$standard_dosage)
|
||||
high <- get_dosage_lst(dosage_source$high_dosage)
|
||||
uti <- get_dosage_lst(dosage_source$uncomplicated_uti)
|
||||
dosage <- bind_rows(
|
||||
# standard dose
|
||||
data.frame(
|
||||
ab = dosage_source$ab,
|
||||
name = dosage_source$ab_name,
|
||||
type = "standard_dosage",
|
||||
dose = sapply(standard, function(x) x$dose),
|
||||
dose_times = sapply(standard, function(x) x$dose_times),
|
||||
administration = sapply(standard, function(x) x$administration),
|
||||
notes = sapply(standard, function(x) x$notes),
|
||||
original_txt = sapply(standard, function(x) x$original_txt),
|
||||
stringsAsFactors = FALSE
|
||||
),
|
||||
# high dose
|
||||
data.frame(
|
||||
ab = dosage_source$ab,
|
||||
name = dosage_source$ab_name,
|
||||
type = "high_dosage",
|
||||
dose = sapply(high, function(x) x$dose),
|
||||
dose_times = sapply(high, function(x) x$dose_times),
|
||||
administration = sapply(high, function(x) x$administration),
|
||||
notes = sapply(high, function(x) x$notes),
|
||||
original_txt = sapply(high, function(x) x$original_txt),
|
||||
stringsAsFactors = FALSE
|
||||
),
|
||||
# UTIs
|
||||
data.frame(
|
||||
ab = dosage_source$ab,
|
||||
name = dosage_source$ab_name,
|
||||
type = "uncomplicated_uti",
|
||||
dose = sapply(uti, function(x) x$dose),
|
||||
dose_times = sapply(uti, function(x) x$dose_times),
|
||||
administration = sapply(uti, function(x) x$administration),
|
||||
notes = sapply(uti, function(x) x$notes),
|
||||
original_txt = sapply(uti, function(x) x$original_txt),
|
||||
stringsAsFactors = FALSE
|
||||
)) %>%
|
||||
mutate(eucast_version = breakpoints_version,
|
||||
dose_times = as.integer(dose_times),
|
||||
administration = gsub("([a-z]+) .*", "\\1", administration)) %>%
|
||||
arrange(name, administration, type) %>%
|
||||
filter(!is.na(dose), dose != ".") %>%
|
||||
as.data.frame(stringsAsFactors = FALSE)
|
||||
rownames(dosage) <- NULL
|
||||
|
||||
usethis::use_data(dosage, internal = FALSE, overwrite = TRUE, version = 2)
|
@ -77,6 +77,7 @@ clsi_general <- read_tsv("data-raw/DRGLST.txt") %>%
|
||||
|
||||
# add new EUCAST with read_EUCAST.R
|
||||
# 2020-04-14 did that now for 2019 and 2020
|
||||
|
||||
rsi_trans <- rsi_trans %>%
|
||||
filter(guideline != "EUCAST 2019") %>%
|
||||
bind_rows(new_EUCAST) %>%
|
||||
@ -88,6 +89,17 @@ rsi_trans <- rsi_trans %>%
|
||||
ab = as.ab(ab)) %>%
|
||||
arrange(desc(guideline), ab, mo, method)
|
||||
|
||||
# 2021-01-12 did that now for 2021
|
||||
rsi_trans <- rsi_trans %>%
|
||||
mutate(mo = as.character(mo)) %>%
|
||||
bind_rows(new_EUCAST) %>%
|
||||
mutate(uti = site %like% "(UTI|urinary)") %>%
|
||||
as.data.frame(stringsAsFactors = FALSE) %>%
|
||||
# force classes again
|
||||
mutate(mo = as.mo(mo),
|
||||
ab = as.ab(ab)) %>%
|
||||
arrange(desc(guideline), ab, mo, method)
|
||||
|
||||
# save to package
|
||||
rsi_translation <- rsi_trans
|
||||
usethis::use_data(rsi_translation, overwrite = TRUE)
|
||||
|
@ -1 +1 @@
|
||||
c589396a6728f7c72def07b4dfb35e28
|
||||
f816b536ddd71d00e1adcdaba97d0329
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -19,7 +19,8 @@ de CoPS KPS TRUE FALSE
|
||||
de Gram-negative Gramnegativ FALSE FALSE
|
||||
de Gram-positive Grampositiv FALSE FALSE
|
||||
de Bacteria Bakterien FALSE FALSE
|
||||
de Fungi Hefen/Pilze FALSE FALSE
|
||||
de Fungi Pilze FALSE FALSE
|
||||
de Yeasts Hefen FALSE FALSE
|
||||
de Protozoa Protozoen FALSE FALSE
|
||||
de biogroup Biogruppe FALSE FALSE
|
||||
de biotype Biotyp FALSE FALSE
|
||||
@ -49,8 +50,9 @@ nl CoPS CPS TRUE FALSE
|
||||
nl Gram-negative Gram-negatief FALSE FALSE
|
||||
nl Gram-positive Gram-positief FALSE FALSE
|
||||
nl Bacteria Bacteriën FALSE FALSE
|
||||
nl Fungi Schimmels/gisten FALSE FALSE
|
||||
nl Protozoa protozoën FALSE FALSE
|
||||
nl Fungi Schimmels FALSE FALSE
|
||||
nl Yeasts Gisten FALSE FALSE
|
||||
nl Protozoa Protozoën FALSE FALSE
|
||||
nl biogroup biogroep FALSE FALSE
|
||||
nl vegetative vegetatief FALSE FALSE
|
||||
nl ([([ ]*?)group \\1groep FALSE FALSE
|
||||
@ -83,6 +85,7 @@ es Gram-negative Gram negativo FALSE FALSE
|
||||
es Gram-positive Gram positivo FALSE FALSE
|
||||
es Bacteria Bacterias FALSE FALSE
|
||||
es Fungi Hongos FALSE FALSE
|
||||
es Yeasts Levaduras FALSE FALSE
|
||||
es Protozoa Protozoarios FALSE FALSE
|
||||
es biogroup biogrupo FALSE FALSE
|
||||
es biotype biotipo FALSE FALSE
|
||||
@ -110,7 +113,8 @@ it unknown rank grado sconosciuto FALSE FALSE
|
||||
it Gram-negative Gram negativo FALSE FALSE
|
||||
it Gram-positive Gram positivo FALSE FALSE
|
||||
it Bacteria Batteri FALSE FALSE
|
||||
it Fungi Fungo FALSE FALSE
|
||||
it Fungi Funghi FALSE FALSE
|
||||
it Yeasts Lieviti FALSE FALSE
|
||||
it Protozoa Protozoi FALSE FALSE
|
||||
it biogroup biogruppo FALSE FALSE
|
||||
it biotype biotipo FALSE FALSE
|
||||
@ -139,6 +143,7 @@ fr Gram-negative Gram négatif FALSE FALSE
|
||||
fr Gram-positive Gram positif FALSE FALSE
|
||||
fr Bacteria Bactéries FALSE FALSE
|
||||
fr Fungi Champignons FALSE FALSE
|
||||
fr Yeasts Levures FALSE FALSE
|
||||
fr Protozoa Protozoaires FALSE FALSE
|
||||
fr biogroup biogroupe FALSE FALSE
|
||||
fr vegetative végétatif FALSE FALSE
|
||||
@ -166,6 +171,7 @@ pt Gram-negative Gram negativo FALSE FALSE
|
||||
pt Gram-positive Gram positivo FALSE FALSE
|
||||
pt Bacteria Bactérias FALSE FALSE
|
||||
pt Fungi Fungos FALSE FALSE
|
||||
pt Yeasts Leveduras FALSE FALSE
|
||||
pt Protozoa Protozoários FALSE FALSE
|
||||
pt biogroup biogrupo FALSE FALSE
|
||||
pt biotype biótipo FALSE FALSE
|
||||
|
|
BIN
data-raw/v_11.0_Breakpoint_Tables.xlsx
Normal file
BIN
data-raw/v_11.0_Breakpoint_Tables.xlsx
Normal file
Binary file not shown.
Binary file not shown.
BIN
data/dosage.rda
Normal file
BIN
data/dosage.rda
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -81,7 +81,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="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9012</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,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="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9012</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -39,7 +39,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="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9010</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -201,15 +201,15 @@
|
||||
|
||||
|
||||
<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 id="type-of-input" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#type-of-input" class="anchor"></a>Type of input</h4>
|
||||
<div id="type-of-input" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#type-of-input" class="anchor"></a>Type of input</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, like 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 id="guidelines" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#guidelines" class="anchor"></a>Guidelines</h4>
|
||||
<div id="guidelines" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#guidelines" class="anchor"></a>Guidelines</h3>
|
||||
<p>The function support multiple guidelines. You can select a guideline with the <code>guideline</code> parameter. Currently supported guidelines are (case-insensitive):</p>
|
||||
<ul>
|
||||
<li>
|
||||
@ -238,16 +238,44 @@
|
||||
</li>
|
||||
</ul>
|
||||
<p>Please suggest your own (country-specific) guidelines by letting us know: <a href="https://github.com/msberends/AMR/issues/new" class="uri">https://github.com/msberends/AMR/issues/new</a>.</p>
|
||||
</div>
|
||||
<div id="examples" class="section level4">
|
||||
<div id="custom-guidelines" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#examples" class="anchor"></a>Examples</h4>
|
||||
<a href="#custom-guidelines" class="anchor"></a>Custom Guidelines</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">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 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><a href="https://rdrr.io/r/base/tilde.html">~</a></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 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>
|
||||
<span class="co"># 1. CIP is "R" and age is higher than 60 -> Elderly Type A</span>
|
||||
<span class="co"># 2. ERY is "R" and age is higher than 60 -> Elderly Type B</span>
|
||||
<span class="co"># 3. Otherwise -> Negative</span>
|
||||
<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 [mdro()] 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="fu"><a href="https://rdrr.io/r/base/table.html">table</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||
<span class="co"># x</span>
|
||||
<span class="co"># Negative Elderly Type A Elderly Type B </span>
|
||||
<span class="co"># 1066 43 891</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">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">readRDS()</a></code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="examples" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#examples" class="anchor"></a>Examples</h3>
|
||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function always returns an ordered <code>factor</code>. 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 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<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">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">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">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="op">)</span> <span class="co"># show frequency table of the result</span>
|
||||
@ -272,23 +300,23 @@ Unique: 2</p>
|
||||
<tr class="odd">
|
||||
<td align="left">1</td>
|
||||
<td align="left">Negative</td>
|
||||
<td align="right">1616</td>
|
||||
<td align="right">92.50%</td>
|
||||
<td align="right">1616</td>
|
||||
<td align="right">92.50%</td>
|
||||
<td align="right">1617</td>
|
||||
<td align="right">92.56%</td>
|
||||
<td align="right">1617</td>
|
||||
<td align="right">92.56%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">2</td>
|
||||
<td align="left">Multi-drug-resistant (MDR)</td>
|
||||
<td align="right">131</td>
|
||||
<td align="right">7.50%</td>
|
||||
<td align="right">130</td>
|
||||
<td align="right">7.44%</td>
|
||||
<td align="right">1747</td>
|
||||
<td align="right">100.00%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>For another example, I will create a data set to determine multi-drug resistant TB:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<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>
|
||||
<span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>rifampicin <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>,
|
||||
@ -299,7 +327,7 @@ Unique: 2</p>
|
||||
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:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<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">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>,
|
||||
GAT <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>,
|
||||
@ -308,32 +336,32 @@ Unique: 2</p>
|
||||
MFX <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>,
|
||||
KAN <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>The data set now looks like this:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<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">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 S R S S I R</span>
|
||||
<span class="co"># 2 R I S I S I</span>
|
||||
<span class="co"># 3 I I R S I S</span>
|
||||
<span class="co"># 4 R S R I R S</span>
|
||||
<span class="co"># 5 I R I I I R</span>
|
||||
<span class="co"># 6 I R I R S R</span>
|
||||
<span class="co"># 1 I R I R I I</span>
|
||||
<span class="co"># 2 R R I S R I</span>
|
||||
<span class="co"># 3 I S S I S I</span>
|
||||
<span class="co"># 4 I I R S R I</span>
|
||||
<span class="co"># 5 I R I S S I</span>
|
||||
<span class="co"># 6 S I I I R R</span>
|
||||
<span class="co"># kanamycin</span>
|
||||
<span class="co"># 1 R</span>
|
||||
<span class="co"># 2 I</span>
|
||||
<span class="co"># 3 I</span>
|
||||
<span class="co"># 4 I</span>
|
||||
<span class="co"># 1 I</span>
|
||||
<span class="co"># 2 R</span>
|
||||
<span class="co"># 3 S</span>
|
||||
<span class="co"># 4 R</span>
|
||||
<span class="co"># 5 S</span>
|
||||
<span class="co"># 6 S</span></code></pre></div>
|
||||
<span class="co"># 6 I</span></code></pre></div>
|
||||
<p>We can now add the interpretation of MDR-TB to our data set. You can use:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/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>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdr_tb</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
||||
<span class="co"># NOTE: No column found as input for `col_mo`, assuming all records contain</span>
|
||||
<span class="co"># Mycobacterium tuberculosis.</span></code></pre></div>
|
||||
<span class="co"># NOTE: No column found as input for `col_mo`, assuming all records</span>
|
||||
<span class="co"># containMycobacterium tuberculosis.</span></code></pre></div>
|
||||
<p>Create a frequency table of the results:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span><span class="op">)</span></code></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: factor > ordered (numeric)<br>
|
||||
@ -354,40 +382,40 @@ Unique: 5</p>
|
||||
<tr class="odd">
|
||||
<td align="left">1</td>
|
||||
<td align="left">Mono-resistant</td>
|
||||
<td align="right">3286</td>
|
||||
<td align="right">65.72%</td>
|
||||
<td align="right">3286</td>
|
||||
<td align="right">65.72%</td>
|
||||
<td align="right">3228</td>
|
||||
<td align="right">64.56%</td>
|
||||
<td align="right">3228</td>
|
||||
<td align="right">64.56%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">2</td>
|
||||
<td align="left">Negative</td>
|
||||
<td align="right">992</td>
|
||||
<td align="right">19.84%</td>
|
||||
<td align="right">4278</td>
|
||||
<td align="right">85.56%</td>
|
||||
<td align="right">1017</td>
|
||||
<td align="right">20.34%</td>
|
||||
<td align="right">4245</td>
|
||||
<td align="right">84.90%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">3</td>
|
||||
<td align="left">Multi-drug-resistant</td>
|
||||
<td align="right">424</td>
|
||||
<td align="right">8.48%</td>
|
||||
<td align="right">4702</td>
|
||||
<td align="right">94.04%</td>
|
||||
<td align="right">421</td>
|
||||
<td align="right">8.42%</td>
|
||||
<td align="right">4666</td>
|
||||
<td align="right">93.32%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">4</td>
|
||||
<td align="left">Poly-resistant</td>
|
||||
<td align="right">214</td>
|
||||
<td align="right">4.28%</td>
|
||||
<td align="right">4916</td>
|
||||
<td align="right">98.32%</td>
|
||||
<td align="right">231</td>
|
||||
<td align="right">4.62%</td>
|
||||
<td align="right">4897</td>
|
||||
<td align="right">97.94%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">5</td>
|
||||
<td align="left">Extensively drug-resistant</td>
|
||||
<td align="right">84</td>
|
||||
<td align="right">1.68%</td>
|
||||
<td align="right">103</td>
|
||||
<td align="right">2.06%</td>
|
||||
<td align="right">5000</td>
|
||||
<td align="right">100.00%</td>
|
||||
</tr>
|
||||
|
@ -39,7 +39,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="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9010</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -193,7 +193,7 @@
|
||||
<h1 data-toc-skip>How to import data from SPSS / SAS / Stata</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">29 December 2020</h4>
|
||||
<h4 class="date">24 January 2021</h4>
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/SPSS.Rmd"><code>vignettes/SPSS.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>SPSS.Rmd</code></div>
|
||||
@ -228,7 +228,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<p><strong>R has a huge community.</strong></p>
|
||||
<p>Many R users just ask questions on websites like <a href="https://stackoverflow.com">StackOverflow.com</a>, the largest online community for programmers. At the time of writing, more than <a href="https://stackoverflow.com/questions/tagged/r?sort=votes">360,000 R-related questions</a> have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.</p>
|
||||
<p>Many R users just ask questions on websites like <a href="https://stackoverflow.com">StackOverflow.com</a>, the largest online community for programmers. At the time of writing, <a href="https://stackoverflow.com/questions/tagged/r?sort=votes">384,445 R-related questions</a> have already been asked on this platform (that covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><strong>R understands any data type, including SPSS/SAS/Stata.</strong></p>
|
||||
@ -243,7 +243,7 @@
|
||||
<li>
|
||||
<p><strong>R is (nowadays) the preferred analysis software in academic papers.</strong></p>
|
||||
<p>At present, R is among the world most powerful statistical languages, and it is generally very popular in science (Bollmann <em>et al.</em>, 2017). For all the above reasons, the number of references to R as an analysis method in academic papers <a href="https://r4stats.com/2014/08/20/r-passes-spss-in-scholarly-use-stata-growing-rapidly/">is rising continuously</a> and has even surpassed SPSS for academic use (Muenchen, 2014).</p>
|
||||
<p>I believe that the thing with SPSS is, that it has always had a great user interface which is very easy to learn and use. Back when they developed it, they had very little competition, let alone from R. R didn’t even had a professional user interface until the last decade (called RStudio, see below). How people used R between the nineties and 2010 is almost completely incomparable to how R is being used now. The language itself <a href="https://www.tidyverse.org/packages/">has been restyled completely</a> by volunteers who are dedicated professionals in the field of data science. SPSS was great when there was nothing else that could compete. But now in 2020, I don’t see any reason why SPSS would be of any better use than R.</p>
|
||||
<p>I believe that the thing with SPSS is, that it has always had a great user interface which is very easy to learn and use. Back when they developed it, they had very little competition, let alone from R. R didn’t even had a professional user interface until the last decade (called RStudio, see below). How people used R between the nineties and 2010 is almost completely incomparable to how R is being used now. The language itself <a href="https://www.tidyverse.org/packages/">has been restyled completely</a> by volunteers who are dedicated professionals in the field of data science. SPSS was great when there was nothing else that could compete. But now in 2021, I don’t see any reason why SPSS would be of any better use than R.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>To demonstrate the first point:</p>
|
||||
|
@ -39,7 +39,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="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9008</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -492,12 +492,12 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<div id="antibiotic-agents" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#antibiotic-agents" class="anchor"></a>Antibiotic agents</h2>
|
||||
<p>A data set with 455 rows and 14 columns, containing the following column names:<br><em>‘ab’, ‘atc’, ‘cid’, ‘name’, ‘group’, ‘atc_group1’, ‘atc_group2’, ‘abbreviations’, ‘synonyms’, ‘oral_ddd’, ‘oral_units’, ‘iv_ddd’, ‘iv_units’, ‘loinc’</em>.</p>
|
||||
<p>A data set with 456 rows and 14 columns, containing the following column names:<br><em>‘ab’, ‘atc’, ‘cid’, ‘name’, ‘group’, ‘atc_group1’, ‘atc_group2’, ‘abbreviations’, ‘synonyms’, ‘oral_ddd’, ‘oral_units’, ‘iv_ddd’, ‘iv_units’, ‘loinc’</em>.</p>
|
||||
<p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 24 September 2020 00:50:35 CEST. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p>It was last updated on 14 January 2021 16:04:41 CET. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (31 kB)<br>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (32 kB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.xlsx">Excel file</a> (65 kB)<br>
|
||||
</li>
|
||||
@ -528,17 +528,17 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<col width="1%">
|
||||
<col width="2%">
|
||||
<col width="3%">
|
||||
<col width="9%">
|
||||
<col width="8%">
|
||||
<col width="14%">
|
||||
<col width="19%">
|
||||
<col width="7%">
|
||||
<col width="13%">
|
||||
<col width="18%">
|
||||
<col width="6%">
|
||||
<col width="11%">
|
||||
<col width="14%">
|
||||
<col width="3%">
|
||||
<col width="3%">
|
||||
<col width="2%">
|
||||
<col width="3%">
|
||||
<col width="10%">
|
||||
<col width="9%">
|
||||
</colgroup>
|
||||
<thead><tr class="header">
|
||||
<th align="center">ab</th>
|
||||
@ -638,20 +638,20 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<td align="center">16420-2, 25233-8</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">CZO</td>
|
||||
<td align="center">J01DB04</td>
|
||||
<td align="center">33255</td>
|
||||
<td align="center">Cefazolin</td>
|
||||
<td align="center">Cephalosporins (1st gen.)</td>
|
||||
<td align="center">Other beta-lactam antibacterials</td>
|
||||
<td align="center">First-generation cephalosporins</td>
|
||||
<td align="center">cfz, cfzl, cz, …</td>
|
||||
<td align="center">atirin, cefamezin, cefamezine, …</td>
|
||||
<td align="center">PEN</td>
|
||||
<td align="center">J01CE01</td>
|
||||
<td align="center">5904</td>
|
||||
<td align="center">Benzylpenicillin</td>
|
||||
<td align="center">Beta-lactams/penicillins</td>
|
||||
<td align="center">Combinations of antibacterials</td>
|
||||
<td align="center">Combinations of antibacterials</td>
|
||||
<td align="center">bepe, pen, peni, …</td>
|
||||
<td align="center">abbocillin, ayercillin, bencilpenicilina, …</td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center">3.0</td>
|
||||
<td align="center">3.6</td>
|
||||
<td align="center">g</td>
|
||||
<td align="center">16566-2, 25235-3, 3442-1, …</td>
|
||||
<td align="center">3913-1</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -1002,27 +1002,27 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<div id="interpretation-from-mic-values-disk-diameters-to-rsi" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#interpretation-from-mic-values-disk-diameters-to-rsi" class="anchor"></a>Interpretation from MIC values / disk diameters to R/SI</h2>
|
||||
<p>A data set with 18,650 rows and 10 columns, containing the following column names:<br><em>‘guideline’, ‘method’, ‘site’, ‘mo’, ‘ab’, ‘ref_tbl’, ‘disk_dose’, ‘breakpoint_S’, ‘breakpoint_R’, ‘uti’</em>.</p>
|
||||
<p>A data set with 20,486 rows and 10 columns, containing the following column names:<br><em>‘guideline’, ‘method’, ‘site’, ‘mo’, ‘ab’, ‘ref_tbl’, ‘disk_dose’, ‘breakpoint_S’, ‘breakpoint_R’, ‘uti’</em>.</p>
|
||||
<p>This data set is in R available as <code>rsi_translation</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 29 July 2020 13:12:34 CEST. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/rsi_translation.html">here</a>.</p>
|
||||
<p>It was last updated on 14 January 2021 16:04:41 CET. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/rsi_translation.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.rds">R file</a> (32 kB)<br>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.rds">R file</a> (34 kB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.xlsx">Excel file</a> (0.6 MB)<br>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.xlsx">Excel file</a> (0.7 MB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.txt">plain text file</a> (1.5 MB)<br>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.txt">plain text file</a> (1.7 MB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.sas">SAS file</a> (3.2 MB)<br>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.sas">SAS file</a> (3.5 MB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.sav">SPSS file</a> (3.4 MB)<br>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.sav">SPSS file</a> (3.8 MB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.dta">Stata file</a> (3 MB)</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.dta">Stata file</a> (3.3 MB)</li>
|
||||
</ul>
|
||||
<div id="source-5" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#source-5" class="anchor"></a>Source</h3>
|
||||
<p>This data set contains interpretation rules for MIC values and disk diffusion diameters. Included guidelines are CLSI (2010-2019) and EUCAST (2011-2020).</p>
|
||||
<p>This data set contains interpretation rules for MIC values and disk diffusion diameters. Included guidelines are CLSI (2010-2019) and EUCAST (2011-2021).</p>
|
||||
</div>
|
||||
<div id="example-content-5" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -1054,7 +1054,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">EUCAST 2020</td>
|
||||
<td align="center">EUCAST 2021</td>
|
||||
<td align="center">DISK</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">Enterobacterales</td>
|
||||
@ -1066,7 +1066,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">EUCAST 2020</td>
|
||||
<td align="center">EUCAST 2021</td>
|
||||
<td align="center">DISK</td>
|
||||
<td align="center">UTI</td>
|
||||
<td align="center">Enterobacterales</td>
|
||||
@ -1078,7 +1078,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">EUCAST 2020</td>
|
||||
<td align="center">EUCAST 2021</td>
|
||||
<td align="center">MIC</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">Enterobacterales</td>
|
||||
@ -1090,7 +1090,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">EUCAST 2020</td>
|
||||
<td align="center">EUCAST 2021</td>
|
||||
<td align="center">MIC</td>
|
||||
<td align="center">UTI</td>
|
||||
<td align="center">Enterobacterales</td>
|
||||
@ -1102,7 +1102,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">EUCAST 2020</td>
|
||||
<td align="center">EUCAST 2021</td>
|
||||
<td align="center">MIC</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">Actinomyces</td>
|
||||
@ -1114,7 +1114,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">EUCAST 2020</td>
|
||||
<td align="center">EUCAST 2021</td>
|
||||
<td align="center">MIC</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">Bacteroides</td>
|
||||
@ -1128,6 +1128,118 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dosage-guidelines-from-eucast" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#dosage-guidelines-from-eucast" class="anchor"></a>Dosage guidelines from EUCAST</h2>
|
||||
<p>A data set with 135 rows and 9 columns, containing the following column names:<br><em>‘ab’, ‘name’, ‘type’, ‘dose’, ‘dose_times’, ‘administration’, ‘notes’, ‘original_txt’, ‘eucast_version’</em>.</p>
|
||||
<p>This data set is in R available as <code>dosage</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 14 January 2021 16:04:41 CET. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/dosage.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.rds">R file</a> (3 kB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.xlsx">Excel file</a> (13 kB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.txt">plain text file</a> (13 kB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.sas">SAS file</a> (48 kB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.sav">SPSS file</a> (37 kB)<br>
|
||||
</li>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.dta">Stata file</a> (38 kB)</li>
|
||||
</ul>
|
||||
<div id="source-6" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#source-6" class="anchor"></a>Source</h3>
|
||||
<p>EUCAST breakpoints used in this package are based on the dosages in this data set.</p>
|
||||
<p>Currently included dosages in the data set are meant for: <a href="https://www.eucast.org/clinical_breakpoints/">‘EUCAST Clinical Breakpoint Tables’ v11.0</a> (2021).</p>
|
||||
</div>
|
||||
<div id="example-content-6" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#example-content-6" class="anchor"></a>Example content</h3>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="center">ab</th>
|
||||
<th align="center">name</th>
|
||||
<th align="center">type</th>
|
||||
<th align="center">dose</th>
|
||||
<th align="center">dose_times</th>
|
||||
<th align="center">administration</th>
|
||||
<th align="center">notes</th>
|
||||
<th align="center">original_txt</th>
|
||||
<th align="center">eucast_version</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">AMK</td>
|
||||
<td align="center">Amikacin</td>
|
||||
<td align="center">standard_dosage</td>
|
||||
<td align="center">25-30 mg/kg</td>
|
||||
<td align="center">1</td>
|
||||
<td align="center">iv</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">25-30 mg/kg x 1 iv</td>
|
||||
<td align="center">11</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">AMX</td>
|
||||
<td align="center">Amoxicillin</td>
|
||||
<td align="center">high_dosage</td>
|
||||
<td align="center">2 g</td>
|
||||
<td align="center">6</td>
|
||||
<td align="center">iv</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">2 g x 6 iv</td>
|
||||
<td align="center">11</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">AMX</td>
|
||||
<td align="center">Amoxicillin</td>
|
||||
<td align="center">standard_dosage</td>
|
||||
<td align="center">1 g</td>
|
||||
<td align="center">3</td>
|
||||
<td align="center">iv</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">1 g x 3-4 iv</td>
|
||||
<td align="center">11</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">AMX</td>
|
||||
<td align="center">Amoxicillin</td>
|
||||
<td align="center">high_dosage</td>
|
||||
<td align="center">0.75-1 g</td>
|
||||
<td align="center">3</td>
|
||||
<td align="center">oral</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">0.75-1 g x 3 oral</td>
|
||||
<td align="center">11</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">AMX</td>
|
||||
<td align="center">Amoxicillin</td>
|
||||
<td align="center">standard_dosage</td>
|
||||
<td align="center">0.5 g</td>
|
||||
<td align="center">3</td>
|
||||
<td align="center">oral</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">0.5 g x 3 oral</td>
|
||||
<td align="center">11</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">AMX</td>
|
||||
<td align="center">Amoxicillin</td>
|
||||
<td align="center">uncomplicated_uti</td>
|
||||
<td align="center">0.5 g</td>
|
||||
<td align="center">3</td>
|
||||
<td align="center">oral</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">0.5 g x 3 oral</td>
|
||||
<td align="center">11</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,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="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9012</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,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="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9012</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -24,14 +24,6 @@
|
||||
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
*/
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.navbar-default {
|
||||
background-color: #213730;
|
||||
}
|
||||
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
|
||||
background-color: #355951;
|
||||
}
|
||||
}
|
||||
|
||||
/* R for Data Science (r4ds) */
|
||||
#r4ds a {
|
||||
@ -209,16 +201,6 @@ thead ~ tbody {
|
||||
/* only when it has a header */
|
||||
border-bottom: 2px solid black;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
thead {
|
||||
border-top: 2px solid white;
|
||||
border-bottom: 2px solid white;
|
||||
}
|
||||
thead ~ tbody {
|
||||
/* only when it has a header */
|
||||
border-bottom: 2px solid white;
|
||||
}
|
||||
}
|
||||
thead th {
|
||||
text-align: inherit;
|
||||
}
|
||||
|
@ -43,7 +43,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="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9012</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -223,20 +223,20 @@ Since you are one of our users, we would like to know how you use the package an
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>bacteria <span class="op">=</span> <span class="fu"><a href="reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="reference/mo_property.html">mo_is_gram_negative</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span>ab <span class="op">=</span> <span class="st">"cefotax"</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">mo</span>, <span class="fu"><a href="reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">bacteria</span>, <span class="fu"><a href="reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="co">#> NOTE: Using column 'mo' as input for mo_is_gram_negative()</span>
|
||||
<span class="co">#> NOTE: Using column 'mo' as input for mo_is_intrinsic_resistant()</span>
|
||||
<span class="co">#> NOTE: Determining intrinsic resistance based on 'EUCAST Expert Rules' and</span>
|
||||
<span class="co">#> 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.2 from 2020.</span>
|
||||
<span class="co">#> 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.2 (2020).</span>
|
||||
<span class="co">#> Selecting aminoglycosides: 'AMK' (amikacin), 'GEN' (gentamicin), </span>
|
||||
<span class="co">#> 'KAN' (kanamycin), 'TOB' (tobramycin)</span>
|
||||
<span class="co">#> Selecting carbapenems: 'IPM' (imipenem), 'MEM' (meropenem)</span></code></pre></div>
|
||||
<p>With only having defined a row filter on Gram-negative bacteria with intrinsic resistance to cefotaxime (<code><a href="reference/mo_property.html">mo_is_gram_negative()</a></code> and <code><a href="reference/mo_property.html">mo_is_intrinsic_resistant()</a></code>) and a column selection on two antibiotic groups (<code><a href="reference/antibiotic_class_selectors.html">aminoglycosides()</a></code> and <code><a href="reference/antibiotic_class_selectors.html">carbapenems()</a></code>), the reference data about <a href="./reference/microorganisms.html">all microorganisms</a> and <a href="./reference/antibiotics.html">all antibiotics</a> in the <code>AMR</code> package make sure you get what you meant:</p>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="left">mo</th>
|
||||
<th align="left">bacteria</th>
|
||||
<th align="center">AMK</th>
|
||||
<th align="center">GEN</th>
|
||||
<th align="center">KAN</th>
|
||||
@ -256,6 +256,24 @@ Since you are one of our users, we would like to know how you use the package an
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left"><em>Pseudomonas aeruginosa</em></td>
|
||||
<td align="center"></td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center"></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left"><em>Pseudomonas aeruginosa</em></td>
|
||||
<td align="center"></td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center"></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left"><em>Pseudomonas aeruginosa</em></td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
@ -299,14 +317,32 @@ Since you are one of our users, we would like to know how you use the package an
|
||||
<td align="center"></td>
|
||||
<td align="center">S</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left"><em>Pseudomonas aeruginosa</em></td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center"></td>
|
||||
<td align="center">S</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left"><em>Pseudomonas aeruginosa</em></td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>A base R equivalent would be:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">example_isolates</span><span class="op">$</span><span class="va">mo</span> <span class="op"><-</span> <span class="fu"><a href="reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">$</span><span class="va">mo</span><span class="op">)</span>
|
||||
<code class="sourceCode R"><span class="va">example_isolates</span><span class="op">$</span><span class="va">bacteria</span> <span class="op"><-</span> <span class="fu"><a href="reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">$</span><span class="va">mo</span><span class="op">)</span>
|
||||
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html">which</a></span><span class="op">(</span><span class="fu"><a href="reference/mo_property.html">mo_is_gram_negative</a></span><span class="op">(</span><span class="op">)</span> <span class="op">&</span>
|
||||
<span class="fu"><a href="reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span>ab <span class="op">=</span> <span class="st">"cefotax"</span><span class="op">)</span><span class="op">)</span>,
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"mo"</span>, <span class="fu"><a href="reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">]</span></code></pre></div>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"bacteria"</span>, <span class="fu"><a href="reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">]</span></code></pre></div>
|
||||
</div>
|
||||
<div id="partners" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user