Compare commits
20 Commits
65a8b58aa6
...
v1.7.1
Author | SHA1 | Date | |
---|---|---|---|
7e70403efb | |||
279376fccb | |||
bef0f42f66 | |||
f406319503 | |||
f1d9b489c5 | |||
41d279daa1 | |||
a12572c752 | |||
a33c8a51a2 | |||
55457d0ab6 | |||
d0f38a03d5 | |||
ac73a8d849 | |||
e5599bc694 | |||
4fbf9e1720 | |||
a13fd98e8b | |||
06302d296a | |||
07939b1a14 | |||
fa2f5214b9 | |||
adca43f8d9 | |||
0b1f59edec | |||
808024c5f4 |
21
.github/workflows/check.yaml
vendored
@ -50,17 +50,22 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
# these are the developmental version of R - we allow those tests to fail
|
||||
- {os: macOS-latest, r: 'devel', allowfail: true}
|
||||
- {os: macOS-latest, r: 'release', allowfail: false}
|
||||
- {os: macOS-latest, r: 'oldrel', allowfail: false}
|
||||
|
||||
- {os: windows-latest, r: 'devel', allowfail: true}
|
||||
- {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"}
|
||||
|
||||
# these are the current release of R
|
||||
- {os: macOS-latest, r: 'release', allowfail: false}
|
||||
- {os: windows-latest, r: 'release', allowfail: false}
|
||||
- {os: ubuntu-20.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
|
||||
# these are the previous release of R
|
||||
- {os: macOS-latest, r: 'oldrel', allowfail: false}
|
||||
- {os: windows-latest, r: 'oldrel', allowfail: false}
|
||||
- {os: ubuntu-20.04, r: 'oldrel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
|
||||
# test against all released versions of R >= 3.0, we support them all!
|
||||
- {os: ubuntu-20.04, r: '4.1', 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"}
|
||||
@ -74,6 +79,7 @@ jobs:
|
||||
env:
|
||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||
RSPM: ${{ matrix.config.rspm }}
|
||||
R_REPOSITORIES: "https://cran.rstudio.com"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -116,6 +122,7 @@ jobs:
|
||||
# - name: Only keep vignettes on release version
|
||||
- name: Remove vignettes
|
||||
# if: matrix.config.r != 'release'
|
||||
if: always()
|
||||
# writing to DESCRIPTION2 and then moving to DESCRIPTION is required for R < 3.3 as writeLines() cannot overwrite
|
||||
run: |
|
||||
rm -rf AMR/vignettes
|
||||
@ -136,7 +143,7 @@ jobs:
|
||||
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
|
||||
R_RUN_TINYTEST: true
|
||||
run: |
|
||||
R CMD check --no-manual AMR
|
||||
R CMD check --no-manual --run-donttest --run-dontrun AMR
|
||||
shell: bash
|
||||
|
||||
- name: Show unit tests output
|
||||
|
56
.github/workflows/codecovr.yaml
vendored
@ -30,7 +30,6 @@ on:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- premaster
|
||||
- master
|
||||
|
||||
name: code-coverage
|
||||
@ -43,39 +42,52 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r@master
|
||||
- uses: r-lib/actions/setup-r@v1
|
||||
with:
|
||||
r-version: release
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@master
|
||||
|
||||
- name: Query dependencies
|
||||
run: |
|
||||
install.packages('remotes')
|
||||
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
|
||||
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Cache R packages
|
||||
- name: Restore cached R packages
|
||||
# this step will add the step 'Post Restore cached R packages' on a succesful run
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ env.R_LIBS_USER }}
|
||||
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
|
||||
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
|
||||
key: macOS-latest-r-release-v5-codecovr
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Unpack AMR and install R dependencies
|
||||
run: |
|
||||
install.packages(c("remotes", "tinytest"))
|
||||
remotes::install_deps(dependencies = TRUE)
|
||||
remotes::install_cran("covr")
|
||||
remotes::install_local("data-raw/AMR_latest.tar.gz")
|
||||
tar -xf data-raw/AMR_latest.tar.gz
|
||||
Rscript -e "source('data-raw/_install_deps.R')"
|
||||
shell: bash
|
||||
|
||||
- name: Show session info
|
||||
run: |
|
||||
options(width = 100)
|
||||
utils::sessionInfo()
|
||||
as.data.frame(utils::installed.packages())[, "Version", drop = FALSE]
|
||||
shell: Rscript {0}
|
||||
|
||||
# - name: Test coverage
|
||||
# env:
|
||||
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
# run: |
|
||||
# library(AMR)
|
||||
# library(tinytest)
|
||||
# library(covr)
|
||||
# source_files <- list.files("R", pattern = ".R$", full.names = TRUE)
|
||||
# test_files <- list.files("inst/tinytest", full.names = TRUE)
|
||||
# cov <- file_coverage(source_files = source_files, test_files = test_files, parent_env = asNamespace("AMR"), line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R"))
|
||||
# attr(cov, which = "package") <- list(path = ".") # until https://github.com/r-lib/covr/issues/478 is solved
|
||||
# codecov(coverage = cov, quiet = FALSE)
|
||||
# shell: Rscript {0}
|
||||
|
||||
- name: Test coverage
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
R_RUN_TINYTEST: true
|
||||
run: |
|
||||
library(AMR)
|
||||
library(tinytest)
|
||||
source_files <- list.files("R", pattern = ".R$", full.names = TRUE)
|
||||
test_files <- list.files("inst/tinytest", full.names = TRUE)
|
||||
cov <- covr::file_coverage(source_files = source_files, test_files = test_files, line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R"))
|
||||
attr(cov, which = "package") <- list(path = ".") # until https://github.com/r-lib/covr/issues/478 is solved
|
||||
covr::codecov(cov, quiet = FALSE)
|
||||
covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R"))
|
||||
shell: Rscript {0}
|
||||
|
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 1.6.0.9056
|
||||
Date: 2021-05-21
|
||||
Version: 1.7.1
|
||||
Date: 2021-06-03
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
|
11
NEWS.md
@ -1,8 +1,8 @@
|
||||
# `AMR` 1.6.0.9056
|
||||
## <small>Last updated: 21 May 2021</small>
|
||||
# `AMR` 1.7.1
|
||||
|
||||
### Breaking change
|
||||
* All antibiotic class selectors (such as `carbapenems()`, `aminoglycosides()`) can now be used for filtering as well, making all their accompanying `filter_*()` functions redundant (such as `filter_carbapenems()`, `filter_aminoglycosides()`). These functions are now deprecated and will be removed in a next release.
|
||||
* Support for CLSI 2020 guideline for interpreting MICs and disk diffusion values (using `as.rsi()`)
|
||||
* All antibiotic class selectors (such as `carbapenems()`, `aminoglycosides()`) can now be used for filtering as well, making all their accompanying `filter_*()` functions redundant (such as `filter_carbapenems()`, `filter_aminoglycosides()`). These functions are now deprecated and will be removed in a next release. Examples of how the selectors can be used for filtering:
|
||||
```r
|
||||
# select columns with results for carbapenems
|
||||
example_isolates[, carbapenems()] # base R
|
||||
@ -35,6 +35,7 @@
|
||||
|
||||
|
||||
### Changed
|
||||
* `bug_drug_combinations()` now supports grouping using the `dplyr` package
|
||||
* Custom MDRO guidelines (`mdro()`, `custom_mdro_guideline()`):
|
||||
* Custom MDRO guidelines can now be combined with other custom MDRO guidelines using `c()`
|
||||
* Fix for applying the rules; in previous versions, rows were interpreted according to the last matched rule. Now, rows are interpreted according to the first matched rule
|
||||
@ -64,8 +65,10 @@
|
||||
* Updated join functions to always use `dplyr` join functions if the `dplyr` package is installed - now also preserving grouped variables
|
||||
* Antibiotic class selectors (such as `cephalosporins()`) now maintain the column order from the original data
|
||||
* Fix for selecting columns using `fluoroquinolones()`
|
||||
* `age()` now vectorises over both `x` and `reference`
|
||||
|
||||
### Other
|
||||
* As requested by CRAN administrators: decreased package size by 3 MB in costs of a slower loading time of the package
|
||||
* All unit tests are now processed by the `tinytest` package, instead of the `testthat` package. The `testthat` package unfortunately requires tons of dependencies that are also heavy and only usable for recent R versions, disallowing developers to test a package under any R 3.* version. On the contrary, the `tinytest` package is very lightweight and dependency-free.
|
||||
|
||||
|
||||
@ -905,7 +908,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
* Emphasised in manual that penicillin is meant as benzylpenicillin (ATC [J01CE01](https://www.whocc.no/atc_ddd_index/?code=J01CE01))
|
||||
* New info is returned when running this function, stating exactly what has been changed or added. Use `eucast_rules(..., verbose = TRUE)` to get a data set with all changed per bug and drug combination.
|
||||
* Removed data sets `microorganisms.oldDT`, `microorganisms.prevDT`, `microorganisms.unprevDT` and `microorganismsDT` since they were no longer needed and only contained info already available in the `microorganisms` data set
|
||||
* Added 65 antibiotics to the `antibiotics` data set, from the [Pharmaceuticals Community Register](http://ec.europa.eu/health/documents/community-register/html/atc.htm) of the European Commission
|
||||
* Added 65 antibiotics to the `antibiotics` data set, from the [Pharmaceuticals Community Register](https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm) of the European Commission
|
||||
* Removed columns `atc_group1_nl` and `atc_group2_nl` from the `antibiotics` data set
|
||||
* Functions `atc_ddd()` and `atc_groups()` have been renamed `atc_online_ddd()` and `atc_online_groups()`. The old functions are deprecated and will be removed in a future version.
|
||||
* Function `guess_mo()` is now deprecated in favour of `as.mo()` and will be removed in future versions
|
||||
|
@ -178,9 +178,7 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
found <- sort(colnames(x)[vapply(FUN.VALUE = logical(1), x, is.mo)])[1]
|
||||
} else if ("mo" %in% colnames(x) &
|
||||
suppressWarnings(
|
||||
all(x$mo %in% c(NA,
|
||||
microorganisms$mo,
|
||||
microorganisms.translation$mo_old)))) {
|
||||
all(x$mo %in% c(NA, microorganisms$mo)))) {
|
||||
found <- "mo"
|
||||
} else if (any(colnames(x) %like% "^(mo|microorganism|organism|bacteria|ba[ck]terie)s?$")) {
|
||||
found <- sort(colnames(x)[colnames(x) %like% "^(mo|microorganism|organism|bacteria|ba[ck]terie)s?$"])[1]
|
||||
@ -192,7 +190,7 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
|
||||
}
|
||||
# -- key antibiotics
|
||||
if (type == "keyantibiotics") {
|
||||
if (type %in% c("keyantibiotics", "keyantimicrobials")) {
|
||||
if (any(colnames(x) %like% "^key.*(ab|antibiotics|antimicrobials)")) {
|
||||
found <- sort(colnames(x)[colnames(x) %like% "^key.*(ab|antibiotics|antimicrobials)"])[1]
|
||||
}
|
||||
@ -716,6 +714,11 @@ meet_criteria <- function(object,
|
||||
}
|
||||
|
||||
get_current_data <- function(arg_name, call) {
|
||||
# check if retrieved before, then get it from package environment
|
||||
if (identical(unique_call_id(entire_session = FALSE), pkg_env$get_current_data.call)) {
|
||||
return(pkg_env$get_current_data.out)
|
||||
}
|
||||
|
||||
# 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
|
||||
@ -723,11 +726,14 @@ get_current_data <- function(arg_name, call) {
|
||||
if (!is.null(cur_data_all)) {
|
||||
out <- tryCatch(cur_data_all(), error = function(e) NULL)
|
||||
if (is.data.frame(out)) {
|
||||
return(structure(out, type = "dplyr_cur_data_all"))
|
||||
out <- structure(out, type = "dplyr_cur_data_all")
|
||||
pkg_env$get_current_data.call <- unique_call_id(entire_session = FALSE)
|
||||
pkg_env$get_current_data.out <- out
|
||||
return(out)
|
||||
}
|
||||
}
|
||||
|
||||
if (current_R_older_than(3.2)) {
|
||||
if (getRversion() < "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.
|
||||
@ -779,7 +785,10 @@ get_current_data <- function(arg_name, call) {
|
||||
# lookup the matched frame and return its value: a data.frame
|
||||
vars_df <- tryCatch(frms[[which(!vapply(FUN.VALUE = logical(1), frms, is.null))]], error = function(e) NULL)
|
||||
if (is.data.frame(vars_df)) {
|
||||
return(structure(vars_df, type = source))
|
||||
out <- structure(vars_df, type = source)
|
||||
pkg_env$get_current_data.call <- unique_call_id(entire_session = FALSE)
|
||||
pkg_env$get_current_data.out <- out
|
||||
return(out)
|
||||
}
|
||||
|
||||
# nothing worked, so:
|
||||
@ -853,8 +862,13 @@ unique_call_id <- function(entire_session = FALSE) {
|
||||
} else {
|
||||
# combination of environment ID (like "0x7fed4ee8c848")
|
||||
# and highest system call
|
||||
call <- paste0(deparse(sys.calls()[[1]]), collapse = "")
|
||||
if (!interactive() || call %like% "run_test_dir|test_all|tinytest|test_package|testthat") {
|
||||
# unit tests will keep the same call and environment - give them a unique ID
|
||||
call <- paste0(sample(c(c(0:9), letters[1:6]), size = 64, replace = TRUE), collapse = "")
|
||||
}
|
||||
c(envir = gsub("<environment: (.*)>", "\\1", utils::capture.output(sys.frames()[[1]])),
|
||||
call = paste0(deparse(sys.calls()[[1]]), collapse = ""))
|
||||
call = call)
|
||||
}
|
||||
}
|
||||
|
||||
@ -870,14 +884,6 @@ 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))
|
||||
}
|
||||
|
||||
reset_all_thrown_messages <- function() {
|
||||
# for unit tests, where the environment and highest system call do not change
|
||||
# can be found in tests/testthat/*.R
|
||||
pkg_env_contents <- ls(envir = pkg_env)
|
||||
rm(list = pkg_env_contents[pkg_env_contents %like% "^thrown_msg."],
|
||||
envir = pkg_env)
|
||||
}
|
||||
|
||||
has_colour <- function() {
|
||||
# this is a base R version of crayon::has_color, but disables colours on emacs
|
||||
|
||||
@ -893,7 +899,7 @@ has_colour <- function() {
|
||||
if (Sys.getenv("RSTUDIO", "") == "") {
|
||||
return(FALSE)
|
||||
}
|
||||
if ((cols <- Sys.getenv("RSTUDIO_CONSOLE_COLOR", "")) != "" && !is.na(as.numeric(cols))) {
|
||||
if ((cols <- Sys.getenv("RSTUDIO_CONSOLE_COLOR", "")) != "" && !is.na(as.double(cols))) {
|
||||
return(TRUE)
|
||||
}
|
||||
tryCatch(get("isAvailable", envir = asNamespace("rstudioapi"))(), error = function(e) return(FALSE)) &&
|
||||
@ -1114,7 +1120,7 @@ s3_register <- function(generic, class, method = NULL) {
|
||||
|
||||
# works exactly like round(), but rounds `round2(44.55, 1)` to 44.6 instead of 44.5
|
||||
# and adds decimal zeroes until `digits` is reached when force_zero = TRUE
|
||||
round2 <- function(x, digits = 0, force_zero = TRUE) {
|
||||
round2 <- function(x, digits = 1, force_zero = TRUE) {
|
||||
x <- as.double(x)
|
||||
# https://stackoverflow.com/a/12688836/4575331
|
||||
val <- (trunc((abs(x) * 10 ^ digits) + 0.5) / 10 ^ digits) * sign(x)
|
||||
@ -1166,7 +1172,7 @@ percentage <- function(x, digits = NULL, ...) {
|
||||
# round right: percentage(0.4455) and format(as.percentage(0.4455), 1) should return "44.6%", not "44.5%"
|
||||
x_formatted <- format(round2(as.double(x), digits = digits + 2) * 100,
|
||||
scientific = FALSE,
|
||||
digits = digits,
|
||||
digits = max(1, digits),
|
||||
nsmall = digits,
|
||||
...)
|
||||
x_formatted <- paste0(x_formatted, "%")
|
||||
@ -1186,15 +1192,11 @@ percentage <- function(x, digits = NULL, ...) {
|
||||
}
|
||||
|
||||
time_start_tracking <- function() {
|
||||
pkg_env$time_start <- round(as.numeric(Sys.time()) * 1000)
|
||||
pkg_env$time_start <- round(as.double(Sys.time()) * 1000)
|
||||
}
|
||||
|
||||
time_track <- function(name = NULL) {
|
||||
paste("(until now:", trimws(round(as.numeric(Sys.time()) * 1000) - pkg_env$time_start), "ms)")
|
||||
}
|
||||
|
||||
current_R_older_than <- function(version) {
|
||||
as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < version
|
||||
paste("(until now:", trimws(round(as.double(Sys.time()) * 1000) - pkg_env$time_start), "ms)")
|
||||
}
|
||||
|
||||
# prevent dependency on package 'backports' ----
|
||||
@ -1245,7 +1247,7 @@ lengths <- function(x, use.names = TRUE) {
|
||||
vapply(x, length, FUN.VALUE = NA_integer_, USE.NAMES = use.names)
|
||||
}
|
||||
|
||||
if (current_R_older_than(3.1)) {
|
||||
if (getRversion() < "3.1") {
|
||||
# R-3.0 does not contain these functions, set them here to prevent installation failure
|
||||
# (required for extension of the <mic> class)
|
||||
cospi <- function(...) 1
|
||||
|
5
R/ab.R
@ -50,7 +50,7 @@
|
||||
#'
|
||||
#' WHONET 2019 software: \url{http://www.whonet.org/software.html}
|
||||
#'
|
||||
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{http://ec.europa.eu/health/documents/community-register/html/atc.htm}
|
||||
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm}
|
||||
#' @aliases ab
|
||||
#' @return A [character] [vector] with additional class [`ab`]
|
||||
#' @seealso
|
||||
@ -82,7 +82,7 @@
|
||||
#' # they use as.ab() internally:
|
||||
#' ab_name("J01FA01") # "Erythromycin"
|
||||
#' ab_name("eryt") # "Erythromycin"
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # you can quickly rename <rsi> columns using dplyr >= 1.0.0:
|
||||
@ -90,6 +90,7 @@
|
||||
#' rename_with(as.ab, where(is.rsi))
|
||||
#'
|
||||
#' }
|
||||
#' }
|
||||
as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
meet_criteria(x, allow_class = c("character", "numeric", "integer", "factor"), allow_NA = TRUE)
|
||||
meet_criteria(flag_multiple_results, allow_class = "logical", has_length = 1)
|
||||
|
@ -25,11 +25,11 @@
|
||||
|
||||
#' Antibiotic Class Selectors
|
||||
#'
|
||||
#' These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \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, "."), "")}}
|
||||
#' These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(getRversion() < "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, "."), "")}}
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @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 ab_class an antimicrobial class, such as `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value.
|
||||
#' @param only_rsi_columns a [logical] to indicate whether only columns of class `<rsi>` must be selected (defaults to `FALSE`), see [as.rsi()]
|
||||
#' @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, "."), "")}}
|
||||
#' @details \strong{\Sexpr{ifelse(getRversion() < "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, "."), "")}}
|
||||
#'
|
||||
#'
|
||||
#' These functions can be used in data set calls for selecting columns and filtering rows, see *Examples*. They support base R, but work more convenient in dplyr functions such as [`select()`][dplyr::select()], [`filter()`][dplyr::filter()] and [`summarise()`][dplyr::summarise()].
|
||||
@ -70,9 +70,14 @@
|
||||
#'
|
||||
#'
|
||||
#' # dplyr -------------------------------------------------------------------
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # get AMR for all aminoglycosides e.g., per hospital:
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(across(aminoglycosides(), resistance))
|
||||
#'
|
||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||
#' example_isolates %>%
|
||||
#' select(carbapenems())
|
||||
@ -119,6 +124,7 @@
|
||||
#' example_isolates %>% filter(carbapenems() == "R")
|
||||
#' example_isolates %>% filter(across(carbapenems(), ~.x == "R"))
|
||||
#' }
|
||||
#' }
|
||||
ab_class <- function(ab_class,
|
||||
only_rsi_columns = FALSE) {
|
||||
ab_selector(ab_class, function_name = "ab_class", only_rsi_columns = only_rsi_columns)
|
||||
@ -220,23 +226,16 @@ ab_selector <- function(ab_class,
|
||||
meet_criteria(function_name, allow_class = "character", has_length = 1, .call_depth = 1)
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1, .call_depth = 1)
|
||||
|
||||
if (current_R_older_than(3.2)) {
|
||||
if (getRversion() < "3.2") {
|
||||
warning_("antibiotic class selectors such as ", function_name,
|
||||
"() require R version 3.2 or later - you have ", R.version.string,
|
||||
call = FALSE)
|
||||
return(NULL)
|
||||
}
|
||||
|
||||
# to improve speed, get_current_data() and get_column_abx() only run once when e.g. in a select or group call
|
||||
vars_df <- get_current_data(arg_name = NA, call = -3)
|
||||
|
||||
# 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, only_rsi_columns = only_rsi_columns, sort = 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.")
|
||||
|
34
R/age.R
@ -27,12 +27,14 @@
|
||||
#'
|
||||
#' Calculates age in years based on a reference date, which is the sytem date at default.
|
||||
#' @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 x date(s), [character] (vectors) will be coerced with [as.POSIXlt()]
|
||||
#' @param reference reference date(s) (defaults to today), [character] (vectors) 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).
|
||||
#' @param na.rm a [logical] to indicate whether missing values should be removed
|
||||
#' @param ... arguments passed on to [as.POSIXlt()], such as `origin`
|
||||
#' @details Ages below 0 will be returned as `NA` with a warning. Ages above 120 will only give a warning.
|
||||
#'
|
||||
#' This function vectorises over both `x` and `reference`, meaning that either can have a length of 1 while the other argument has a larger length.
|
||||
#' @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!
|
||||
@ -53,8 +55,13 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||
|
||||
if (length(x) != length(reference)) {
|
||||
stop_if(length(reference) != 1, "`x` and `reference` must be of same length, or `reference` must be of length 1.")
|
||||
if (length(x) == 1) {
|
||||
x <- rep(x, length(reference))
|
||||
} else if (length(reference) == 1) {
|
||||
reference <- rep(reference, length(x))
|
||||
} else {
|
||||
stop_("`x` and `reference` must be of same length, or `reference` must be of length 1.")
|
||||
}
|
||||
}
|
||||
x <- as.POSIXlt(x, ...)
|
||||
reference <- as.POSIXlt(reference, ...)
|
||||
@ -68,21 +75,26 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
# add decimals
|
||||
if (exact == TRUE) {
|
||||
# get dates of `x` when `x` would have the year of `reference`
|
||||
x_in_reference_year <- as.POSIXlt(paste0(format(reference, "%Y"), format(x, "-%m-%d")))
|
||||
x_in_reference_year <- as.POSIXlt(paste0(format(as.Date(reference), "%Y"),
|
||||
format(as.Date(x), "-%m-%d")),
|
||||
format = "%Y-%m-%d")
|
||||
# get differences in days
|
||||
n_days_x_rest <- as.double(difftime(reference, x_in_reference_year, units = "days"))
|
||||
n_days_x_rest <- as.double(difftime(as.Date(reference),
|
||||
as.Date(x_in_reference_year),
|
||||
units = "days"))
|
||||
# get numbers of days the years of `reference` has for a reliable denominator
|
||||
n_days_reference_year <- as.POSIXlt(paste0(format(reference, "%Y"), "-12-31"))$yday + 1
|
||||
n_days_reference_year <- as.POSIXlt(paste0(format(as.Date(reference), "%Y"), "-12-31"),
|
||||
format = "%Y-%m-%d")$yday + 1
|
||||
# add decimal parts of year
|
||||
mod <- n_days_x_rest / n_days_reference_year
|
||||
# negative mods are cases where `x_in_reference_year` > `reference` - so 'add' a year
|
||||
mod[mod < 0] <- 1 + mod[mod < 0]
|
||||
mod[!is.na(mod) & mod < 0] <- mod[!is.na(mod) & mod < 0] + 1
|
||||
# and finally add to ages
|
||||
ages <- ages + mod
|
||||
}
|
||||
|
||||
if (any(ages < 0, na.rm = TRUE)) {
|
||||
ages[ages < 0] <- NA
|
||||
ages[!is.na(ages) & ages < 0] <- NA
|
||||
warning_("NAs introduced for ages below 0.", call = TRUE)
|
||||
}
|
||||
if (any(ages > 120, na.rm = TRUE)) {
|
||||
@ -93,7 +105,11 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
ages <- ages[!is.na(ages)]
|
||||
}
|
||||
|
||||
ages
|
||||
if (exact == TRUE) {
|
||||
as.double(ages)
|
||||
} else {
|
||||
as.integer(ages)
|
||||
}
|
||||
}
|
||||
|
||||
#' Split Ages into Age Groups
|
||||
|
4
R/amr.R
@ -54,14 +54,14 @@
|
||||
#' @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!:
|
||||
#' 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 data 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)!
|
||||
#' 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 data 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).
|
||||
#' @section Contact Us:
|
||||
#' For suggestions, comments or questions, please contact us at:
|
||||
#'
|
||||
#' Matthijs S. Berends \cr
|
||||
#' m.s.berends \[at\] umcg \[dot\] nl \cr
|
||||
#' University of Groningen
|
||||
#' Department of Medical Microbiology
|
||||
#' Department of Medical Microbiology and Infection Prevention
|
||||
#' University Medical Center Groningen \cr
|
||||
#' Post Office Box 30001 \cr
|
||||
#' 9700 RB Groningen \cr
|
||||
|
@ -65,6 +65,7 @@
|
||||
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' if (requireNamespace("curl") && requireNamespace("rvest") && requireNamespace("xml2")) {
|
||||
#' # oral DDD (Defined Daily Dose) of amoxicillin
|
||||
#' atc_online_property("J01CA04", "DDD", "O")
|
||||
#'
|
||||
@ -73,6 +74,7 @@
|
||||
#'
|
||||
#' atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
|
||||
#' }
|
||||
#' }
|
||||
atc_online_property <- function(atc_code,
|
||||
property,
|
||||
administration = "O",
|
||||
|
@ -35,13 +35,14 @@
|
||||
#' @export
|
||||
#' @examples
|
||||
#' availability(example_isolates)
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' filter(mo == as.mo("E. coli")) %>%
|
||||
#' select_if(is.rsi) %>%
|
||||
#' availability()
|
||||
#' }
|
||||
#' }
|
||||
availability <- function(tbl, width = NULL) {
|
||||
meet_criteria(tbl, allow_class = "data.frame")
|
||||
meet_criteria(width, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)
|
||||
|
@ -31,7 +31,7 @@
|
||||
#' @param combine_IR a [logical] to indicate whether values R and I should be summed
|
||||
#' @param add_ab_group a [logical] to indicate where the group of the antimicrobials must be included as a first column
|
||||
#' @param remove_intrinsic_resistant [logical] to indicate that rows and columns with 100% resistance for all tested antimicrobials must be removed from the table
|
||||
#' @param FUN the function to call on the `mo` column to transform the microorganism IDs, defaults to [mo_shortname()]
|
||||
#' @param FUN the function to call on the `mo` column to transform the microorganism codes, defaults to [mo_shortname()]
|
||||
#' @param translate_ab a [character] of length 1 containing column names of the [antibiotics] data set
|
||||
#' @param ... arguments passed on to `FUN`
|
||||
#' @inheritParams rsi_df
|
||||
@ -74,13 +74,23 @@ bug_drug_combinations <- function(x,
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
}
|
||||
|
||||
x_class <- class(x)
|
||||
x.bak <- x
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
x[, col_mo] <- FUN(x[, col_mo, drop = TRUE], ...)
|
||||
x <- x[, c(col_mo, names(which(vapply(FUN.VALUE = logical(1), x, is.rsi)))), drop = FALSE]
|
||||
|
||||
unique_mo <- sort(unique(x[, col_mo, drop = TRUE]))
|
||||
|
||||
# select only groups and antibiotics
|
||||
if (inherits(x.bak, "grouped_df")) {
|
||||
data_has_groups <- TRUE
|
||||
groups <- setdiff(names(attributes(x.bak)$groups), ".rows")
|
||||
x <- x[, c(groups, col_mo, colnames(x)[vapply(FUN.VALUE = logical(1), x, is.rsi)]), drop = FALSE]
|
||||
} else {
|
||||
data_has_groups <- FALSE
|
||||
x <- x[, c(col_mo, names(which(vapply(FUN.VALUE = logical(1), x, is.rsi)))), drop = FALSE]
|
||||
}
|
||||
|
||||
run_it <- function(x) {
|
||||
out <- data.frame(mo = character(0),
|
||||
ab = character(0),
|
||||
S = integer(0),
|
||||
@ -88,6 +98,11 @@ bug_drug_combinations <- function(x,
|
||||
R = integer(0),
|
||||
total = integer(0),
|
||||
stringsAsFactors = FALSE)
|
||||
if (data_has_groups) {
|
||||
group_values <- unique(x[, which(colnames(x) %in% groups), drop = FALSE])
|
||||
rownames(group_values) <- NULL
|
||||
x <- x[, which(!colnames(x) %in% groups), drop = FALSE]
|
||||
}
|
||||
|
||||
for (i in seq_len(length(unique_mo))) {
|
||||
# filter on MO group and only select R/SI columns
|
||||
@ -105,11 +120,41 @@ bug_drug_combinations <- function(x,
|
||||
R = merged$R,
|
||||
total = merged$S + merged$I + merged$R,
|
||||
stringsAsFactors = FALSE)
|
||||
if (data_has_groups) {
|
||||
if (nrow(group_values) < nrow(out_group)) {
|
||||
# repeat group_values for the number of rows in out_group
|
||||
repeated <- rep(seq_len(nrow(group_values)),
|
||||
each = nrow(out_group) / nrow(group_values))
|
||||
group_values <- group_values[repeated, , drop = FALSE]
|
||||
}
|
||||
out_group <- cbind(group_values, out_group)
|
||||
}
|
||||
out <- rbind(out, out_group, stringsAsFactors = FALSE)
|
||||
}
|
||||
out
|
||||
}
|
||||
# based on pm_apply_grouped_function
|
||||
apply_group <- function(.data, fn, groups, drop = FALSE, ...) {
|
||||
grouped <- pm_split_into_groups(.data, groups, drop)
|
||||
res <- do.call(rbind, unname(lapply(grouped, fn, ...)))
|
||||
if (any(groups %in% colnames(res))) {
|
||||
class(res) <- c("grouped_data", class(res))
|
||||
res <- pm_set_groups(res, groups[groups %in% colnames(res)])
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
if (data_has_groups) {
|
||||
out <- apply_group(x, "run_it", groups)
|
||||
rownames(out) <- NULL
|
||||
set_clean_class(out,
|
||||
new_class = c("bug_drug_combinations", x_class))
|
||||
new_class = c("grouped", "bug_drug_combinations", "data.frame"))
|
||||
} else {
|
||||
out <- run_it(x)
|
||||
rownames(out) <- NULL
|
||||
set_clean_class(out,
|
||||
new_class = c("bug_drug_combinations", "data.frame"))
|
||||
}
|
||||
}
|
||||
|
||||
#' @method format bug_drug_combinations
|
||||
@ -137,6 +182,21 @@ format.bug_drug_combinations <- function(x,
|
||||
meet_criteria(decimal.mark, allow_class = "character", has_length = 1)
|
||||
meet_criteria(big.mark, allow_class = "character", has_length = 1)
|
||||
|
||||
if (inherits(x, "grouped")) {
|
||||
# bug_drug_combinations() has been run on groups, so de-group here
|
||||
warning_("formatting the output of `bug_drug_combinations()` does not support grouped variables, they are ignored", call = FALSE)
|
||||
idx <- split(seq_len(nrow(x)), paste0(x$mo, "%%", x$ab))
|
||||
x <- data.frame(mo = gsub("(.*)%%(.*)", "\\1", names(idx)),
|
||||
ab = gsub("(.*)%%(.*)", "\\2", names(idx)),
|
||||
S = sapply(idx, function(i) sum(y$S[i], na.rm = TRUE)),
|
||||
I = sapply(idx, function(i) sum(y$I[i], na.rm = TRUE)),
|
||||
R = sapply(idx, function(i) sum(y$R[i], na.rm = TRUE)),
|
||||
total = sapply(idx, function(i) sum(y$S[i], na.rm = TRUE) +
|
||||
sum(y$I[i], na.rm = TRUE) +
|
||||
sum(y$R[i], na.rm = TRUE)),
|
||||
stringsAsFactors = FALSE)
|
||||
}
|
||||
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
x <- subset(x, total >= minimum)
|
||||
|
||||
@ -249,7 +309,9 @@ format.bug_drug_combinations <- function(x,
|
||||
print.bug_drug_combinations <- function(x, ...) {
|
||||
x_class <- class(x)
|
||||
print(set_clean_class(x,
|
||||
new_class = x_class[x_class != "bug_drug_combinations"]),
|
||||
new_class = x_class[!x_class %in% c("bug_drug_combinations", "grouped")]),
|
||||
...)
|
||||
message_("Use 'format()' on this result to get a publishable/printable format.", as_note = FALSE)
|
||||
message_("Use 'format()' on this result to get a publishable/printable format.",
|
||||
ifelse(inherits(x, "grouped"), " Note: The grouping variable(s) will be ignored.", ""),
|
||||
as_note = FALSE)
|
||||
}
|
||||
|
@ -72,7 +72,7 @@
|
||||
#' count_susceptible(example_isolates$AMX)
|
||||
#' susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
||||
#'
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
@ -106,6 +106,7 @@
|
||||
#' group_by(hospital_id) %>%
|
||||
#' count_df(translate = FALSE)
|
||||
#' }
|
||||
#' }
|
||||
count_resistant <- function(..., only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = "R",
|
||||
|
6
R/data.R
@ -71,7 +71,7 @@
|
||||
#'
|
||||
#' 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>
|
||||
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: <https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm>
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection WHOCC WHOCC
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
@ -239,7 +239,7 @@
|
||||
|
||||
#' 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.
|
||||
#' Data set containing reference data to interpret MIC and disk diffusion to R/SI values, according to international guidelines. Currently implemented guidelines are EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`). 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:
|
||||
#' - `guideline`\cr Name of the guideline
|
||||
#' - `method`\cr Either `r vector_or(rsi_translation$method)`
|
||||
@ -269,12 +269,14 @@
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' intrinsic_resistant %>%
|
||||
#' filter(antibiotic == "Vancomycin", microorganism %like% "Enterococcus") %>%
|
||||
#' pull(microorganism)
|
||||
#' # [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"
|
||||
#' }
|
||||
#' }
|
||||
"intrinsic_resistant"
|
||||
|
||||
#' Data Set with Treatment Dosages as Defined by EUCAST
|
||||
|
2
R/disk.R
@ -85,7 +85,7 @@ as.disk <- function(x, na.rm = FALSE) {
|
||||
fixed = TRUE)
|
||||
x_clean <- gsub(remove, "", x, ignore.case = TRUE, fixed = fixed)
|
||||
# remove everything that is not a number or dot
|
||||
as.numeric(gsub("[^0-9.]+", "", x_clean))
|
||||
as.double(gsub("[^0-9.]+", "", x_clean))
|
||||
}
|
||||
|
||||
# round up and make it an integer
|
||||
|
@ -273,7 +273,7 @@ first_isolate <- function(x = NULL,
|
||||
# try to find columns based on type
|
||||
# -- mo
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo")
|
||||
col_mo <- search_type_in_df(x = x, type = "mo", info = info)
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ first_isolate <- function(x = NULL,
|
||||
x$keyantimicrobials <- all_antimicrobials(x, only_rsi_columns = FALSE)
|
||||
col_keyantimicrobials <- "keyantimicrobials"
|
||||
} else if (type == "keyantimicrobials" & is.null(col_keyantimicrobials)) {
|
||||
col_keyantimicrobials <- search_type_in_df(x = x, type = "keyantibiotics")
|
||||
col_keyantimicrobials <- search_type_in_df(x = x, type = "keyantimicrobials", info = info)
|
||||
if (is.null(col_keyantimicrobials)) {
|
||||
# still not found as a column, create it ourselves
|
||||
x$keyantimicrobials <- key_antimicrobials(x, only_rsi_columns = FALSE, col_mo = col_mo, ...)
|
||||
@ -310,7 +310,7 @@ first_isolate <- function(x = NULL,
|
||||
|
||||
# -- date
|
||||
if (is.null(col_date)) {
|
||||
col_date <- search_type_in_df(x = x, type = "date")
|
||||
col_date <- search_type_in_df(x = x, type = "date", info = info)
|
||||
stop_if(is.null(col_date), "`col_date` must be set")
|
||||
}
|
||||
|
||||
@ -322,14 +322,14 @@ first_isolate <- function(x = NULL,
|
||||
col_patient_id <- "patient_id"
|
||||
message_("Using combined columns '", font_bold("First name"), "', '", font_bold("Last name"), "' and '", font_bold("Sex"), "' as input for `col_patient_id`")
|
||||
} else {
|
||||
col_patient_id <- search_type_in_df(x = x, type = "patient_id")
|
||||
col_patient_id <- search_type_in_df(x = x, type = "patient_id", info = info)
|
||||
}
|
||||
stop_if(is.null(col_patient_id), "`col_patient_id` must be set")
|
||||
}
|
||||
|
||||
# -- specimen
|
||||
if (is.null(col_specimen) & !is.null(specimen_group)) {
|
||||
col_specimen <- search_type_in_df(x = x, type = "specimen")
|
||||
col_specimen <- search_type_in_df(x = x, type = "specimen", info = info)
|
||||
}
|
||||
|
||||
# check if columns exist
|
||||
@ -472,8 +472,8 @@ first_isolate <- function(x = NULL,
|
||||
as_note = FALSE)
|
||||
}
|
||||
if (type == "points") {
|
||||
message_("Basing inclusion on all antimicrobial results, using a points threshold of "
|
||||
, points_threshold,
|
||||
message_("Basing inclusion on all antimicrobial results, using a points threshold of ",
|
||||
points_threshold,
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
}
|
||||
|
@ -65,6 +65,7 @@
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' # See ?pca for more info about Principal Component Analysis (PCA).
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' pca_model <- example_isolates %>%
|
||||
#' filter(mo_genus(mo) == "Staphylococcus") %>%
|
||||
@ -84,6 +85,7 @@
|
||||
#' labs(title = "Title here")
|
||||
#' }
|
||||
#' }
|
||||
#' }
|
||||
ggplot_pca <- function(x,
|
||||
choices = 1:2,
|
||||
scale = 1,
|
||||
|
@ -67,6 +67,7 @@
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' if (require("ggplot2") & require("dplyr")) {
|
||||
#'
|
||||
#' # get antimicrobial results for drugs against a UTI:
|
||||
@ -114,12 +115,10 @@
|
||||
#' ggplot() +
|
||||
#' geom_col(aes(x = x, y = y, fill = z)) +
|
||||
#' scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R")
|
||||
#' }
|
||||
#'
|
||||
#' \donttest{
|
||||
#' # resistance of ciprofloxacine per age group
|
||||
#' example_isolates %>%
|
||||
#' mutate(first_isolate = first_isolate(.)) %>%
|
||||
#' mutate(first_isolate = first_isolate()) %>%
|
||||
#' filter(first_isolate == TRUE,
|
||||
#' mo == as.mo("E. coli")) %>%
|
||||
#' # age_groups() is also a function in this AMR package:
|
||||
@ -145,6 +144,7 @@
|
||||
#' x.title = "Hospital",
|
||||
#' datalabels = FALSE)
|
||||
#' }
|
||||
#' }
|
||||
ggplot_rsi <- function(data,
|
||||
position = NULL,
|
||||
x = "antibiotic",
|
||||
|
@ -104,6 +104,12 @@ get_column_abx <- function(x,
|
||||
only_rsi_columns = FALSE,
|
||||
sort = TRUE,
|
||||
...) {
|
||||
|
||||
# check if retrieved before, then get it from package environment
|
||||
if (identical(unique_call_id(entire_session = FALSE), pkg_env$get_column_abx.call)) {
|
||||
return(pkg_env$get_column_abx.out)
|
||||
}
|
||||
|
||||
meet_criteria(x, allow_class = "data.frame")
|
||||
meet_criteria(soft_dependencies, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(hard_dependencies, allow_class = "character", allow_NULL = TRUE)
|
||||
@ -184,6 +190,8 @@ get_column_abx <- function(x,
|
||||
if (info == TRUE) {
|
||||
message_("No columns found.")
|
||||
}
|
||||
pkg_env$get_column_abx.call <- unique_call_id(entire_session = FALSE)
|
||||
pkg_env$get_column_abx.out <- x
|
||||
return(x)
|
||||
}
|
||||
|
||||
@ -239,6 +247,9 @@ get_column_abx <- function(x,
|
||||
missing_msg)
|
||||
}
|
||||
}
|
||||
|
||||
pkg_env$get_column_abx.call <- unique_call_id(entire_session = FALSE)
|
||||
pkg_env$get_column_abx.out <- x
|
||||
x
|
||||
}
|
||||
|
||||
|
@ -45,12 +45,13 @@
|
||||
#'
|
||||
#' # since ggplot2 supports no markdown (yet), use
|
||||
#' # italicise_taxonomy() and the `ggtext` pkg for titles:
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("ggplot2") && require("ggtext")) {
|
||||
#' ggplot(example_isolates$AMC,
|
||||
#' title = italicise_taxonomy("Amoxi/clav in E. coli")) +
|
||||
#' theme(plot.title = ggtext::element_markdown())
|
||||
#' }
|
||||
#' }
|
||||
italicise_taxonomy <- function(string, type = c("markdown", "ansi")) {
|
||||
if (missing(type)) {
|
||||
type <- "markdown"
|
||||
|
@ -140,7 +140,7 @@ key_antimicrobials <- function(x = NULL,
|
||||
meet_criteria(antifungal, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
|
||||
# force regular [data.frame], not a tibble or data.table
|
||||
# force regular data.frame, not a tibble or data.table
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
cols <- get_column_abx(x, info = FALSE, only_rsi_columns = only_rsi_columns)
|
||||
|
||||
@ -237,7 +237,7 @@ all_antimicrobials <- function(x = NULL,
|
||||
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
|
||||
# force regular [data.frame], not a tibble or data.table
|
||||
# force regular data.frame, not a tibble or data.table
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
cols <- get_column_abx(x, only_rsi_columns = only_rsi_columns, info = FALSE, sort = FALSE)
|
||||
|
||||
|
71
R/mo.R
@ -23,9 +23,9 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Transform Input to a Microorganism ID
|
||||
#' Transform Input to a Microorganism Code
|
||||
#'
|
||||
#' 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*.
|
||||
#' Use this function to determine a valid microorganism code ([`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).
|
||||
@ -46,7 +46,7 @@
|
||||
#' @details
|
||||
#' ## General Info
|
||||
#'
|
||||
#' A microorganism ID from this package (class: [`mo`]) is human readable and typically looks like these examples:
|
||||
#' A microorganism (MO) code from this package (class: [`mo`]) is human readable and typically looks like these examples:
|
||||
#' ```
|
||||
#' Code Full name
|
||||
#' --------------- --------------------------------------
|
||||
@ -1817,8 +1817,7 @@ as.data.frame.mo <- function(x, ...) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(i)
|
||||
# must only contain valid MOs
|
||||
return_after_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
||||
as.character(microorganisms.translation$mo_old)))
|
||||
return_after_integrity_check(y, "microorganism code", as.character(microorganisms$mo))
|
||||
}
|
||||
#' @method [[<- mo
|
||||
#' @export
|
||||
@ -1827,8 +1826,7 @@ as.data.frame.mo <- function(x, ...) {
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(i)
|
||||
# must only contain valid MOs
|
||||
return_after_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
||||
as.character(microorganisms.translation$mo_old)))
|
||||
return_after_integrity_check(y, "microorganism code", as.character(microorganisms$mo))
|
||||
}
|
||||
#' @method c mo
|
||||
#' @export
|
||||
@ -1837,8 +1835,7 @@ c.mo <- function(...) {
|
||||
x <- list(...)[[1L]]
|
||||
y <- NextMethod()
|
||||
attributes(y) <- attributes(x)
|
||||
return_after_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
||||
as.character(microorganisms.translation$mo_old)))
|
||||
return_after_integrity_check(y, "microorganism code", as.character(microorganisms$mo))
|
||||
}
|
||||
|
||||
#' @method unique mo
|
||||
@ -2053,24 +2050,52 @@ parse_and_convert <- function(x) {
|
||||
}
|
||||
|
||||
replace_old_mo_codes <- function(x, property) {
|
||||
if (any(toupper(x) %in% microorganisms.translation$mo_old, na.rm = TRUE)) {
|
||||
ind <- x %like_case% "^[A-Z]_[A-Z_]+$" & !x %in% MO_lookup$mo
|
||||
if (any(ind)) {
|
||||
# get the ones that match
|
||||
matched <- match(toupper(x), microorganisms.translation$mo_old)
|
||||
# and their new codes
|
||||
mo_new <- microorganisms.translation$mo_new[matched]
|
||||
affected <- x[ind]
|
||||
affected_unique <- unique(affected)
|
||||
all_direct_matches <- TRUE
|
||||
# find their new codes, once per code
|
||||
solved_unique <- unlist(lapply(strsplit(affected_unique, ""),
|
||||
function(m) {
|
||||
kingdom <- paste0("^", m[1])
|
||||
name <- m[3:length(m)]
|
||||
name[name == "_"] <- " "
|
||||
name <- tolower(paste0(name, ".*", collapse = ""))
|
||||
name <- gsub(" .*", " ", name, fixed = TRUE)
|
||||
name <- paste0("^", name)
|
||||
results <- MO_lookup$mo[MO_lookup$kingdom %like_case% kingdom &
|
||||
MO_lookup$fullname_lower %like_case% name]
|
||||
if (length(results) > 1) {
|
||||
all_direct_matches <<- FALSE
|
||||
}
|
||||
results[1L]
|
||||
}), use.names = FALSE)
|
||||
solved <- solved_unique[match(affected, affected_unique)]
|
||||
# assign on places where a match was found
|
||||
x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))]
|
||||
n_matched <- length(matched[!is.na(matched)])
|
||||
if (property != "mo") {
|
||||
message_(font_blue(paste0("The input contained ", n_matched,
|
||||
" old MO code", ifelse(n_matched == 1, "", "s"),
|
||||
" (from a previous AMR package version). Please update your MO codes with `as.mo()`.")))
|
||||
x[ind] <- solved
|
||||
n_matched <- length(affected[!is.na(affected)])
|
||||
n_unique <- length(affected_unique[!is.na(affected_unique)])
|
||||
if (n_unique < n_matched) {
|
||||
n_unique <- paste0(n_unique, " unique, ")
|
||||
} else {
|
||||
message_(font_blue(paste0(n_matched, " old MO code", ifelse(n_matched == 1, "", "s"),
|
||||
" (from a previous AMR package version) ",
|
||||
n_unique <- ""
|
||||
}
|
||||
if (property != "mo") {
|
||||
warning_(paste0("The input contained ", n_matched,
|
||||
" old MO code", ifelse(n_matched == 1, "", "s"),
|
||||
" (", n_unique, "from a previous AMR package version). ",
|
||||
"Please update your MO codes with `as.mo()` to increase speed."),
|
||||
call = FALSE)
|
||||
} else {
|
||||
warning_(paste0(n_matched, " old MO code", ifelse(n_matched == 1, "", "s"),
|
||||
" (", n_unique, "from a previous AMR package version) ",
|
||||
ifelse(n_matched == 1, "was", "were"),
|
||||
" updated to ", ifelse(n_matched == 1, "a ", ""),
|
||||
"currently used MO code", ifelse(n_matched == 1, "", "s"), ".")))
|
||||
ifelse(all_direct_matches, " updated ", font_bold(" guessed ")),
|
||||
"to ", ifelse(n_matched == 1, "a ", ""),
|
||||
"currently used MO code", ifelse(n_matched == 1, "", "s"), "."),
|
||||
call = FALSE)
|
||||
}
|
||||
}
|
||||
x
|
||||
|
@ -152,6 +152,7 @@
|
||||
#' mo_is_yeast(c("Candida", "E. coli")) # TRUE, FALSE
|
||||
#'
|
||||
#' # gram stains and intrinsic resistance can also be used as a filter in dplyr verbs
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' filter(mo_is_gram_positive())
|
||||
@ -167,6 +168,7 @@
|
||||
#' # SNOMED codes, and URL to the online database
|
||||
#' mo_info("E. coli")
|
||||
#' }
|
||||
#' }
|
||||
mo_name <- function(x, language = get_locale(), ...) {
|
||||
if (missing(x)) {
|
||||
# this tries to find the data and an <mo> column
|
||||
|
@ -275,9 +275,9 @@ check_validity_mo_source <- function(x, refer_to_name = "`reference_df`", stop_o
|
||||
return(FALSE)
|
||||
}
|
||||
}
|
||||
if (!all(x$mo %in% c("", microorganisms$mo, microorganisms.translation$mo_old), na.rm = TRUE)) {
|
||||
if (!all(x$mo %in% c("", microorganisms$mo), na.rm = TRUE)) {
|
||||
if (stop_on_error == TRUE) {
|
||||
invalid <- x[which(!x$mo %in% c("", microorganisms$mo, microorganisms.translation$mo_old)), , drop = FALSE]
|
||||
invalid <- x[which(!x$mo %in% c("", microorganisms$mo)), , drop = FALSE]
|
||||
if (nrow(invalid) > 1) {
|
||||
plural <- "s"
|
||||
} else {
|
||||
|
3
R/pca.R
@ -42,7 +42,6 @@
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' \donttest{
|
||||
#'
|
||||
#' if (require("dplyr")) {
|
||||
#' # calculate the resistance per group first
|
||||
#' resistance_data <- example_isolates %>%
|
||||
@ -120,7 +119,7 @@ pca <- function(x,
|
||||
message_("Columns selected for PCA: ", vector_and(font_bold(colnames(pca_data), collapse = NULL), quotes = TRUE),
|
||||
". Total observations available: ", nrow(pca_data), ".")
|
||||
|
||||
if (current_R_older_than(3.4)) {
|
||||
if (getRversion() < "3.4.0") {
|
||||
# stats::prcomp prior to 3.4.0 does not have the 'rank.' argument
|
||||
pca_model <- prcomp(pca_data, retx = retx, center = center, scale. = scale., tol = tol)
|
||||
} else {
|
||||
|
2
R/plot.R
@ -61,11 +61,13 @@
|
||||
#' plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
|
||||
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("ggplot2")) {
|
||||
#' ggplot(some_mic_values)
|
||||
#' ggplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||
#' ggplot(some_rsi_values)
|
||||
#' }
|
||||
#' }
|
||||
NULL
|
||||
|
||||
#' @method plot mic
|
||||
|
@ -103,6 +103,7 @@
|
||||
#' proportion_IR(example_isolates$AMX)
|
||||
#' proportion_R(example_isolates$AMX)
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
@ -161,6 +162,7 @@
|
||||
#' group_by(hospital_id) %>%
|
||||
#' proportion_df(translate = FALSE)
|
||||
#' }
|
||||
#' }
|
||||
resistance <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
|
@ -70,6 +70,7 @@
|
||||
#' year_min = 2010,
|
||||
#' model = "binomial")
|
||||
#' plot(x)
|
||||
#' \donttest{
|
||||
#' if (require("ggplot2")) {
|
||||
#' ggplot_rsi_predict(x)
|
||||
#' }
|
||||
@ -98,7 +99,9 @@
|
||||
#' info = FALSE,
|
||||
#' minimum = 15)
|
||||
#'
|
||||
#' ggplot(data,
|
||||
#' ggplot(data)
|
||||
#'
|
||||
#' ggplot(as.data.frame(data),
|
||||
#' aes(x = year)) +
|
||||
#' geom_col(aes(y = value),
|
||||
#' fill = "grey75") +
|
||||
@ -114,6 +117,7 @@
|
||||
#' x = "Year") +
|
||||
#' theme_minimal(base_size = 13)
|
||||
#' }
|
||||
#' }
|
||||
resistance_predict <- function(x,
|
||||
col_ab,
|
||||
col_date = NULL,
|
||||
|
11
R/rsi.R
@ -65,9 +65,9 @@
|
||||
#'
|
||||
#' ## Supported Guidelines
|
||||
#'
|
||||
#' For interpreting MIC values as well as disk diffusion diameters, currently supported guidelines to be used as input for the `guideline` argument are: `r vector_and(AMR::rsi_translation$guideline, quotes = TRUE, reverse = TRUE)`.
|
||||
#' For interpreting MIC values as well as disk diffusion diameters, currently implemented guidelines are EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`).
|
||||
#'
|
||||
#' 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.
|
||||
#' Thus, the `guideline` argument must be set to e.g., ``r paste0('"', subset(rsi_translation, guideline %like% "EUCAST")$guideline[1], '"')`` or ``r paste0('"', subset(rsi_translation, guideline %like% "CLSI")$guideline[1], '"')``. By simply using `"EUCAST"` (the default) or `"CLSI"` as input, the latest version of that guideline will automatically be selected. You can set your own data set using the `reference_data` argument. The `guideline` argument will then be ignored.
|
||||
#'
|
||||
#' ## After Interpretation
|
||||
#'
|
||||
@ -92,7 +92,7 @@
|
||||
#' - **I = Increased exposure, but still susceptible**\cr
|
||||
#' A microorganism is categorised as *Susceptible, Increased exposure* when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
|
||||
#'
|
||||
#' This AMR package honours this new insight. Use [susceptibility()] (equal to [proportion_SI()]) to determine antimicrobial susceptibility and [count_susceptible()] (equal to [count_SI()]) to count susceptible isolates.
|
||||
#' This AMR package honours this (new) insight. Use [susceptibility()] (equal to [proportion_SI()]) to determine antimicrobial susceptibility and [count_susceptible()] (equal to [count_SI()]) to count susceptible isolates.
|
||||
#' @return Ordered [factor] with new class `<rsi>`
|
||||
#' @aliases rsi
|
||||
#' @export
|
||||
@ -101,12 +101,12 @@
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' summary(example_isolates) # see all R/SI results at a glance
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("skimr")) {
|
||||
#' # class <rsi> supported in skim() too:
|
||||
#' skim(example_isolates)
|
||||
#' }
|
||||
#'
|
||||
#' }
|
||||
#' # For INTERPRETING disk diffusion and MIC values -----------------------
|
||||
#'
|
||||
#' # a whole data set, even with combined MIC values and disk zones
|
||||
@ -215,7 +215,6 @@ is.rsi.eligible <- function(x, threshold = 0.05) {
|
||||
"ab",
|
||||
"Date",
|
||||
"POSIXt",
|
||||
"rsi",
|
||||
"raw",
|
||||
"hms",
|
||||
"mic",
|
||||
|
BIN
R/sysdata.rda
@ -28,7 +28,7 @@
|
||||
#' All antimicrobial drugs and their official names, ATC codes, ATC groups and defined daily dose (DDD) are included in this package, using the WHO Collaborating Centre for Drug Statistics Methodology.
|
||||
#' @section WHOCC:
|
||||
#' \if{html}{\figure{logo_who.png}{options: height=60px style=margin-bottom:5px} \cr}
|
||||
#' This package contains **all ~550 antibiotic, antimycotic and antiviral drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, <https://www.whocc.no>) and the Pharmaceuticals Community Register of the European Commission (<http://ec.europa.eu/health/documents/community-register/html/atc.htm>).
|
||||
#' This package contains **all ~550 antibiotic, antimycotic and antiviral drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, <https://www.whocc.no>) and the Pharmaceuticals Community Register of the European Commission (<https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm>).
|
||||
#'
|
||||
#' These have become the gold standard for international drug utilisation monitoring and research.
|
||||
#'
|
||||
|
72
R/zzz.R
@ -72,4 +72,76 @@ if (utf8_supported && !is_latex) {
|
||||
invisible(get_mo_source())
|
||||
}
|
||||
}, silent = TRUE)
|
||||
|
||||
|
||||
# reference data - they have additional columns compared to `antibiotics` and `microorganisms` to improve speed
|
||||
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"))
|
||||
# for mo_is_intrinsic_resistant() - saves a lot of time when executed on this vector
|
||||
assign(x = "INTRINSIC_R", value = create_intr_resistance(), envir = asNamespace("AMR"))
|
||||
}
|
||||
|
||||
|
||||
# Helper functions --------------------------------------------------------
|
||||
|
||||
create_AB_lookup <- function() {
|
||||
AB_lookup <- AMR::antibiotics
|
||||
AB_lookup$generalised_name <- generalise_antibiotic_name(AB_lookup$name)
|
||||
AB_lookup$generalised_synonyms <- lapply(AB_lookup$synonyms, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_abbreviations <- lapply(AB_lookup$abbreviations, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_loinc <- lapply(AB_lookup$loinc, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_all <- unname(lapply(as.list(as.data.frame(t(AB_lookup[,
|
||||
c("ab", "atc", "cid", "name",
|
||||
colnames(AB_lookup)[colnames(AB_lookup) %like% "generalised"]),
|
||||
drop = FALSE]),
|
||||
stringsAsFactors = FALSE)),
|
||||
function(x) {
|
||||
x <- generalise_antibiotic_name(unname(unlist(x)))
|
||||
x[x != ""]
|
||||
}))
|
||||
AB_lookup
|
||||
}
|
||||
|
||||
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, perl = TRUE)
|
||||
MO_lookup[ind, "fullname_lower"] <- tolower(MO_lookup[ind, "fullname"])
|
||||
MO_lookup$fullname_lower <- trimws(gsub("[^.a-z0-9/ \\-]+", "", MO_lookup$fullname_lower, perl = TRUE))
|
||||
|
||||
# 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])
|
||||
}
|
||||
|
10
README.md
@ -2,8 +2,6 @@
|
||||
|
||||
# `AMR` (for R)
|
||||
|
||||
[](https://cran.r-project.org/package=AMR)
|
||||
[](https://cran.r-project.org/package=AMR)
|
||||

|
||||
[](https://www.codefactor.io/repository/github/msberends/amr)
|
||||
[](https://codecov.io/gh/msberends/AMR?branch=master)
|
||||
@ -25,7 +23,13 @@ This is the development source of the `AMR` package for R. Not a developer? Then
|
||||
### How to get this package
|
||||
Please see [our website](https://msberends.github.io/AMR/#get-this-package).
|
||||
|
||||
Bottom line: `install.packages("AMR")`
|
||||
You can install or update the `AMR` package from CRAN using:
|
||||
|
||||
```r
|
||||
install.packages("AMR")
|
||||
```
|
||||
|
||||
It will be downloaded and installed automatically. For RStudio, click on the menu *Tools* > *Install Packages...* and then type in "AMR" and press <kbd>Install</kbd>.
|
||||
|
||||
### Copyright
|
||||
|
||||
|
@ -1 +1 @@
|
||||
* This package has a tarball size of over 7 MB and an installation size of over 5 MB, which will return a NOTE on R CMD CHECK. The package size is needed to offer users reference data for the complete taxonomy of microorganisms - one of the most important features of this package. This was written and explained in a manuscript that was accepted for publication in the Journal of Statistical Software 4 weeks ago. We will add the paper as a vignette in the next version. Please allow this exception in package size for CRAN. We already compressed all data sets using `compression = "xz"` to make them as small as possible.
|
||||
* This package now has a data folder size of ~2.8 MB (this was ~5.6 MB), which will return a NOTE on R CMD CHECK. This package size is needed to provide users reference data for the complete taxonomy of microorganisms - one of the most important features of this package, following 15 previous releases of this package. All data sets were compressed using `compression = "xz"` to make them as small as possible.
|
||||
|
1094
data-raw/DRGLST.txt
Normal file → Executable file
20996
data-raw/DRGLST1.txt
Executable file
@ -24,18 +24,17 @@
|
||||
# ==================================================================== #
|
||||
|
||||
# some old R instances have trouble installing tinytest, so we ship it too
|
||||
install.packages("data-raw/tinytest_1.2.4.patched.tar.gz")
|
||||
install.packages("data-raw/tinytest_1.2.4.10.tar.gz")
|
||||
install.packages("data-raw/AMR_latest.tar.gz", dependencies = FALSE)
|
||||
install.packages("covr", repos = "https://cran.rstudio.com/")
|
||||
|
||||
descr <- readLines("AMR/DESCRIPTION")
|
||||
pkg_suggests <- gsub(".*Suggests: (.*)*?[A-Z].*", "\\1", paste0(descr, "*", collapse = ""), perl = FALSE)
|
||||
pkg_suggests <- unlist(strsplit(pkg_suggests, "[,* ]"))
|
||||
pkg_suggests <- pkg_suggests[pkg_suggests != ""]
|
||||
pkg_suggests <- gsub("[^a-zA-Z0-9]+", "", unlist(strsplit(packageDescription("AMR", fields = "Suggests"), ", ?")))
|
||||
cat("Packages listed in Suggests:", paste(pkg_suggests, collapse = ", "), "\n")
|
||||
|
||||
to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())]
|
||||
to_update <- as.data.frame(utils::old.packages(repos = "https://cran.rstudio.com/"), stringsAsFactors = FALSE)
|
||||
to_update <- to_update[which(to_update$Package %in% pkg_suggests), "Package", drop = TRUE]
|
||||
|
||||
if (length(to_install) == 0) {
|
||||
message("\nNothing to install\n")
|
||||
}
|
||||
for (i in seq_len(length(to_install))) {
|
||||
cat("Installing package", to_install[i], "\n")
|
||||
tryCatch(install.packages(to_install[i], repos = "https://cran.rstudio.com/", dependencies = TRUE, quiet = TRUE),
|
||||
@ -44,6 +43,11 @@ for (i in seq_len(length(to_install))) {
|
||||
error = function(e) message(e$message))
|
||||
}
|
||||
|
||||
to_update <- as.data.frame(utils::old.packages(repos = "https://cran.rstudio.com/"), stringsAsFactors = FALSE)
|
||||
to_update <- to_update[which(to_update$Package %in% pkg_suggests), "Package", drop = TRUE]
|
||||
if (length(to_update) == 0) {
|
||||
message("\nNothing to update\n")
|
||||
}
|
||||
for (i in seq_len(length(to_update))) {
|
||||
cat("Updating package", to_update[i], "\n")
|
||||
tryCatch(update.packages(to_update[i], repos = "https://cran.rstudio.com/", ask = FALSE),
|
||||
|
@ -31,109 +31,6 @@ 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", "borealis", "caeli", "capitis", "caprae",
|
||||
"carnosus", "casei", "chromogenes", "cohnii", "condimenti",
|
||||
"croceilyticus",
|
||||
"debuckii", "devriesei", "edaphicus", "epidermidis",
|
||||
"equorum", "felis", "fleurettii", "gallinarum",
|
||||
"haemolyticus", "hominis", "jettensis", "kloosii",
|
||||
"lentus", "lugdunensis", "massiliensis", "microti",
|
||||
"muscae", "nepalensis", "pasteuri", "petrasii",
|
||||
"pettenkoferi", "piscifermentans", "pragensis", "pseudoxylosus",
|
||||
"pulvereri", "rostri", "saccharolyticus", "saprophyticus",
|
||||
"sciuri", "simulans", "stepanovicii", "succinus",
|
||||
"ureilyticus",
|
||||
"vitulinus", "vitulus", "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", "coagulans",
|
||||
"agnetis", "argenteus",
|
||||
"cornubiensis",
|
||||
"delphini", "lutrae",
|
||||
"hyicus", "intermedius",
|
||||
"pseudintermedius", "pseudointermedius",
|
||||
"schweitzeri", "simiae")
|
||||
| (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$generalised_all <- unname(lapply(as.list(as.data.frame(t(AB_lookup[,
|
||||
c("ab", "atc", "cid", "name",
|
||||
colnames(AB_lookup)[colnames(AB_lookup) %like% "generalised"]),
|
||||
drop = FALSE]),
|
||||
stringsAsFactors = FALSE)),
|
||||
function(x) {
|
||||
x <- generalise_antibiotic_name(unname(unlist(x)))
|
||||
x[x != ""]
|
||||
}))
|
||||
AB_lookup
|
||||
}
|
||||
|
||||
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 to R/sysdata.rda -------------------------------------
|
||||
|
||||
# See 'data-raw/eucast_rules.tsv' for the EUCAST reference file
|
||||
@ -170,24 +67,50 @@ translations_file <- utils::read.delim(file = "data-raw/translations.tsv",
|
||||
allowEscapes = TRUE, # else "\\1" will be imported as "\\\\1"
|
||||
quote = "")
|
||||
|
||||
# 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", colnames(translations_file)[nchar(colnames(translations_file)) == 2]))
|
||||
|
||||
# vectors of CoNS and CoPS, improves speed in as.mo()
|
||||
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", "borealis", "caeli", "capitis", "caprae",
|
||||
"carnosus", "casei", "chromogenes", "cohnii", "condimenti",
|
||||
"croceilyticus",
|
||||
"debuckii", "devriesei", "edaphicus", "epidermidis",
|
||||
"equorum", "felis", "fleurettii", "gallinarum",
|
||||
"haemolyticus", "hominis", "jettensis", "kloosii",
|
||||
"lentus", "lugdunensis", "massiliensis", "microti",
|
||||
"muscae", "nepalensis", "pasteuri", "petrasii",
|
||||
"pettenkoferi", "piscifermentans", "pragensis", "pseudoxylosus",
|
||||
"pulvereri", "rostri", "saccharolyticus", "saprophyticus",
|
||||
"sciuri", "simulans", "stepanovicii", "succinus",
|
||||
"ureilyticus",
|
||||
"vitulinus", "vitulus", "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", "coagulans",
|
||||
"agnetis", "argenteus",
|
||||
"cornubiensis",
|
||||
"delphini", "lutrae",
|
||||
"hyicus", "intermedius",
|
||||
"pseudintermedius", "pseudointermedius",
|
||||
"schweitzeri", "simiae")
|
||||
| (MO_staph$species == "schleiferi" & MO_staph$subspecies == "coagulans")),
|
||||
"mo", drop = TRUE]
|
||||
}
|
||||
}
|
||||
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()
|
||||
|
||||
# antibiotic groups
|
||||
# (these will also be used for eucast_rules() and understanding data-raw/eucast_rules.tsv)
|
||||
globalenv_before_ab <- c(ls(envir = globalenv()), "globalenv_before_ab")
|
||||
@ -220,14 +143,9 @@ DEFINED_AB_GROUPS <- DEFINED_AB_GROUPS[!DEFINED_AB_GROUPS %in% globalenv_before_
|
||||
# Export to package as internal data ----
|
||||
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,
|
||||
AMINOGLYCOSIDES,
|
||||
AMINOPENICILLINS,
|
||||
CARBAPENEMS,
|
||||
|
@ -872,12 +872,12 @@ View(old_new)
|
||||
# set new MO codes as names to existing data sets
|
||||
rsi_translation$mo <- mo_name(rsi_translation$mo, language = NULL)
|
||||
microorganisms.codes$mo <- mo_name(microorganisms.codes$mo, language = NULL)
|
||||
microorganisms.translation <- AMR:::microorganisms.translation %>%
|
||||
bind_rows(tibble(mo_old = AMR:::microorganisms.translation$mo_new, mo_new = mo_old)) %>%
|
||||
filter(!mo_old %in% MOs$mo) %>%
|
||||
mutate(mo_new = mo_name(mo_new, language = NULL)) %>%
|
||||
bind_rows(old_new %>% select(mo_old, mo_new)) %>%
|
||||
distinct(mo_old, .keep_all = TRUE)
|
||||
# microorganisms.translation <- AMR:::microorganisms.translation %>%
|
||||
# bind_rows(tibble(mo_old = AMR:::microorganisms.translation$mo_new, mo_new = mo_old)) %>%
|
||||
# filter(!mo_old %in% MOs$mo) %>%
|
||||
# mutate(mo_new = mo_name(mo_new, language = NULL)) %>%
|
||||
# bind_rows(old_new %>% select(mo_old, mo_new)) %>%
|
||||
# distinct(mo_old, .keep_all = TRUE)
|
||||
|
||||
# arrange the data sets to save
|
||||
MOs <- MOs %>% arrange(fullname)
|
||||
@ -911,23 +911,23 @@ devtools::load_all(".")
|
||||
rsi_translation$mo <- as.mo(rsi_translation$mo)
|
||||
microorganisms.codes$mo <- as.mo(microorganisms.codes$mo)
|
||||
class(microorganisms.codes$mo) <- c("mo", "character")
|
||||
microorganisms.translation <- microorganisms.translation %>%
|
||||
# (to do: add last package version to column pkg_version)
|
||||
left_join(microorganisms.old[, c("fullname", "fullname_new")], # microorganisms.old is now new and loaded
|
||||
by = c("mo_new" = "fullname")) %>%
|
||||
mutate(name = ifelse(!is.na(fullname_new), fullname_new, mo_new)) %>%
|
||||
left_join(microorganisms[, c("fullname", "mo")], # as is microorganisms
|
||||
by = c("name" = "fullname")) %>%
|
||||
select(mo_old, mo_new = mo) %>%
|
||||
filter(!is.na(mo_old), !is.na(mo_new))
|
||||
class(microorganisms.translation$mo_old) <- "character" # no class <mo> since those aren't valid MO codes
|
||||
class(microorganisms.translation$mo_new) <- c("mo", "character")
|
||||
# microorganisms.translation <- microorganisms.translation %>%
|
||||
# # (to do: add last package version to column pkg_version)
|
||||
# left_join(microorganisms.old[, c("fullname", "fullname_new")], # microorganisms.old is now new and loaded
|
||||
# by = c("mo_new" = "fullname")) %>%
|
||||
# mutate(name = ifelse(!is.na(fullname_new), fullname_new, mo_new)) %>%
|
||||
# left_join(microorganisms[, c("fullname", "mo")], # as is microorganisms
|
||||
# by = c("name" = "fullname")) %>%
|
||||
# select(mo_old, mo_new = mo) %>%
|
||||
# filter(!is.na(mo_old), !is.na(mo_new))
|
||||
# class(microorganisms.translation$mo_old) <- "character" # no class <mo> since those aren't valid MO codes
|
||||
# class(microorganisms.translation$mo_new) <- c("mo", "character")
|
||||
# save those to the package
|
||||
usethis::use_data(rsi_translation, overwrite = TRUE, version = 2)
|
||||
usethis::use_data(microorganisms.codes, overwrite = TRUE, version = 2)
|
||||
saveRDS(microorganisms.translation, file = "data-raw/microorganisms.translation.rds", version = 2)
|
||||
# saveRDS(microorganisms.translation, file = "data-raw/microorganisms.translation.rds", version = 2)
|
||||
# to save microorganisms.translation internally to the package
|
||||
source("data-raw/_internals.R")
|
||||
# source("data-raw/_internals.R")
|
||||
|
||||
# load new data sets again
|
||||
devtools::load_all(".")
|
||||
@ -935,7 +935,7 @@ devtools::load_all(".")
|
||||
# and check: these codes should not be missing (will otherwise throw a unit test error):
|
||||
AMR::microorganisms.codes %>% filter(!mo %in% MOs$mo)
|
||||
AMR::rsi_translation %>% filter(!mo %in% MOs$mo)
|
||||
AMR:::microorganisms.translation %>% filter(!mo_new %in% MOs$mo)
|
||||
# AMR:::microorganisms.translation %>% filter(!mo_new %in% MOs$mo)
|
||||
|
||||
# update the example_isolates data set
|
||||
example_isolates$mo <- as.mo(example_isolates$mo)
|
||||
|
@ -380,37 +380,37 @@ MOs.old <- microorganisms.old %>%
|
||||
# Keep old codes for translation ------------------------------------------
|
||||
|
||||
# add removed microbial IDs to the internal translation table so old package versions keep working
|
||||
MOs.translation <- microorganisms %>%
|
||||
filter(!mo %in% MOs$mo) %>%
|
||||
select(mo, fullname) %>%
|
||||
left_join(new_synonyms) %>%
|
||||
left_join(MOs %>% transmute(fullname_new = fullname, mo2 = as.character(mo))) %>%
|
||||
select(mo_old = mo, mo_new = mo2) %>%
|
||||
distinct()
|
||||
MOs.translation <- AMR:::microorganisms.translation %>%
|
||||
left_join(MOs.translation %>% select(mo_new_update = mo_new, mo_new = mo_old)) %>%
|
||||
mutate(mo_new = as.character(ifelse(!is.na(mo_new_update), mo_new_update, mo_new))) %>%
|
||||
select(-mo_new_update) %>%
|
||||
bind_rows(
|
||||
# old IDs used in microorganisms.codes must put in here as well
|
||||
microorganisms.codes %>%
|
||||
filter(!mo %in% MOs$mo) %>%
|
||||
transmute(mo_old = mo, fullname = mo_name(mo)) %>%
|
||||
left_join(MOs.old %>%
|
||||
select(fullname, fullname_new)) %>%
|
||||
left_join(MOs %>%
|
||||
select(mo_new = mo, fullname_new = fullname)) %>%
|
||||
transmute(mo_old = as.character(mo_old), mo_new)) %>%
|
||||
arrange(mo_old) %>%
|
||||
filter(mo_old != mo_new,
|
||||
!mo_old %in% MOs$mo) %>%
|
||||
left_join(., .,
|
||||
by = c("mo_new" = "mo_old"),
|
||||
suffix = c("", ".2")) %>%
|
||||
mutate(mo_new = ifelse(!is.na(mo_new.2), mo_new.2, mo_new)) %>%
|
||||
distinct(mo_old, mo_new) %>%
|
||||
# clean up
|
||||
df_remove_nonASCII()
|
||||
# MOs.translation <- microorganisms %>%
|
||||
# filter(!mo %in% MOs$mo) %>%
|
||||
# select(mo, fullname) %>%
|
||||
# left_join(new_synonyms) %>%
|
||||
# left_join(MOs %>% transmute(fullname_new = fullname, mo2 = as.character(mo))) %>%
|
||||
# select(mo_old = mo, mo_new = mo2) %>%
|
||||
# distinct()
|
||||
# MOs.translation <- AMR:::microorganisms.translation %>%
|
||||
# left_join(MOs.translation %>% select(mo_new_update = mo_new, mo_new = mo_old)) %>%
|
||||
# mutate(mo_new = as.character(ifelse(!is.na(mo_new_update), mo_new_update, mo_new))) %>%
|
||||
# select(-mo_new_update) %>%
|
||||
# bind_rows(
|
||||
# # old IDs used in microorganisms.codes must put in here as well
|
||||
# microorganisms.codes %>%
|
||||
# filter(!mo %in% MOs$mo) %>%
|
||||
# transmute(mo_old = mo, fullname = mo_name(mo)) %>%
|
||||
# left_join(MOs.old %>%
|
||||
# select(fullname, fullname_new)) %>%
|
||||
# left_join(MOs %>%
|
||||
# select(mo_new = mo, fullname_new = fullname)) %>%
|
||||
# transmute(mo_old = as.character(mo_old), mo_new)) %>%
|
||||
# arrange(mo_old) %>%
|
||||
# filter(mo_old != mo_new,
|
||||
# !mo_old %in% MOs$mo) %>%
|
||||
# left_join(., .,
|
||||
# by = c("mo_new" = "mo_old"),
|
||||
# suffix = c("", ".2")) %>%
|
||||
# mutate(mo_new = ifelse(!is.na(mo_new.2), mo_new.2, mo_new)) %>%
|
||||
# distinct(mo_old, mo_new) %>%
|
||||
# # clean up
|
||||
# df_remove_nonASCII()
|
||||
|
||||
message("microorganisms new: ", sum(!MOs$fullname %in% c(microorganisms$fullname, MOs.old$fullname)))
|
||||
message("microorganisms renamed: ", sum(!MOs.old$fullname %in% microorganisms.old$fullname))
|
||||
@ -424,12 +424,12 @@ class(MOs.translation$mo_new) <- c("mo", "character")
|
||||
|
||||
microorganisms <- MOs
|
||||
microorganisms.old <- MOs.old
|
||||
microorganisms.translation <- MOs.translation
|
||||
# microorganisms.translation <- MOs.translation
|
||||
|
||||
# on the server, do:
|
||||
usethis::use_data(microorganisms, overwrite = TRUE, version = 2, compress = "xz")
|
||||
usethis::use_data(microorganisms.old, overwrite = TRUE, version = 2)
|
||||
saveRDS(microorganisms.translation, file = "data-raw/microorganisms.translation.rds", version = 2)
|
||||
# saveRDS(microorganisms.translation, file = "data-raw/microorganisms.translation.rds", version = 2)
|
||||
rm(microorganisms)
|
||||
rm(microorganisms.old)
|
||||
rm(microorganisms.translation)
|
||||
|
@ -2,10 +2,9 @@ library(dplyr)
|
||||
library(readr)
|
||||
library(tidyr)
|
||||
|
||||
# Installed WHONET 2019 software on Windows (http://www.whonet.org/software.html),
|
||||
# opened C:\WHONET\Codes\WHONETCodes.mdb in MS Access
|
||||
# and exported table 'DRGLST1' to MS Excel
|
||||
DRGLST1 <- readxl::read_excel("data-raw/DRGLST1.xlsx", na = c("", "NA", "-"))
|
||||
# Installed WHONET software on Windows (http://www.whonet.org/software.html),
|
||||
# imported C:\WHONET\Codes\DRGLST1.txt
|
||||
DRGLST1 <- readr::read_tsv("data-raw/DRGLST1.txt", na = c("", "NA", "-"))
|
||||
rsi_trans <- DRGLST1 %>%
|
||||
# only keep CLSI and EUCAST guidelines:
|
||||
filter(GUIDELINES %like% "^(CLSI|EUCST)")
|
||||
@ -13,6 +12,9 @@ if (any(is.na(rsi_trans$BREAKPOINT_TYPE)) | !"Human" %in% rsi_trans$BREAKPOINT_T
|
||||
stop("Check column BREAKPOINT_TYPE - something is WRONG!")
|
||||
}
|
||||
rsi_trans <- rsi_trans %>%
|
||||
##### If looking for adding a specific guideline, do it here!
|
||||
# filter(GUIDELINES == "CLSI20") %>%
|
||||
#####
|
||||
filter(BREAKPOINT_TYPE == "Human") %>%
|
||||
mutate(DISK_S = ifelse(as.double(DISK_S) > 50, 50, DISK_S),
|
||||
MIC_R = ifelse(as.double(MIC_R) %in% c(1025, 129, 513), as.double(MIC_R) - 1, MIC_R)) %>%
|
||||
@ -50,7 +52,7 @@ rsi_trans <- bind_rows(tbl_mic, tbl_disk) %>%
|
||||
select(-ends_with("_mic"), -ends_with("_disk"))
|
||||
|
||||
# add extra CLSI general guidelines
|
||||
clsi_general <- read_tsv("data-raw/DRGLST.txt") %>%
|
||||
clsi_general <- readr::read_tsv("data-raw/DRGLST.txt") %>%
|
||||
filter(CLSI == "X") %>%
|
||||
select(WHON5_CODE,
|
||||
disk_dose = POTENCY,
|
||||
@ -76,13 +78,13 @@ 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
|
||||
|
||||
# 2020-04-14 did that now for 2019 and 2020
|
||||
rsi_trans <- rsi_trans %>%
|
||||
filter(guideline != "EUCAST 2019") %>%
|
||||
bind_rows(new_EUCAST) %>%
|
||||
bind_rows(clsi_general) %>%
|
||||
mutate(uti = site %like% "(UTI|urinary)") %>%
|
||||
mutate(uti = site %like% "(UTI|urinary|urine)") %>%
|
||||
as.data.frame(stringsAsFactors = FALSE) %>%
|
||||
# force classes again
|
||||
mutate(mo = as.mo(mo),
|
||||
|
@ -1 +1 @@
|
||||
aa80f169fc2cba97f5eedc1d24ca8c03
|
||||
1a7fe52f8185c9bb2c470712863d1887
|
||||
|
BIN
data-raw/tinytest_1.2.4.10.tar.gz
Normal file
@ -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.6.0.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</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.6.0.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
12
docs/articles/AMR_files/header-attrs-2.8/header-attrs.js
Normal file
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="fas fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
<span class="fas fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
<span class="fas fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
<span class="fas fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fa fa-database"></span>
|
||||
<span class="fas fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fa fa-compress"></span>
|
||||
<span class="fas fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
<span class="fas fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
<span class="fas fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
<span class="fas fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fa fa-book-open"></span>
|
||||
<span class="fas fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
<span class="fas fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
<span class="far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
<span class="fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@ -187,8 +187,7 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="EUCAST_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="EUCAST_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="EUCAST_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to apply EUCAST rules</h1>
|
||||
@ -216,8 +215,8 @@
|
||||
<a href="#examples" class="anchor"></a>Examples</h2>
|
||||
<p>These rules can be used to discard impossible bug-drug combinations in your data. For example, <em>Klebsiella</em> produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of <em>Klebsiella</em> is resistant to ampicillin.</p>
|
||||
<p>Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, <em>Klebsiella</em>). EUCAST expert rules solve this, that can be applied using <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="va">oops</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>mo <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">"Klebsiella"</span>,
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">oops</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
||||
<span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||
ampicillin <span class="op">=</span> <span class="st">"S"</span><span class="op">)</span>
|
||||
<span class="va">oops</span>
|
||||
@ -228,19 +227,19 @@
|
||||
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">oops</span>, info <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
|
||||
<span class="co"># mo ampicillin</span>
|
||||
<span class="co"># 1 Klebsiella R</span>
|
||||
<span class="co"># 2 Escherichia S</span></pre></div>
|
||||
<span class="co"># 2 Escherichia S</span></code></pre></div>
|
||||
<p>A more convenient function is <code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> that uses the same guideline, but allows to check for one or more specific microorganisms or antibiotics:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>, <span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>, <span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||
<span class="st">"ampicillin"</span><span class="op">)</span>
|
||||
<span class="co"># [1] TRUE FALSE</span>
|
||||
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"ampicillin"</span>, <span class="st">"kanamycin"</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="co"># [1] TRUE FALSE</span></pre></div>
|
||||
<span class="co"># [1] TRUE FALSE</span></code></pre></div>
|
||||
<p>EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called <em>interpretive reading</em>, is basically a form of imputation, and is part of the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function as well:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="va">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>mo <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">"Staphylococcus aureus"</span>,
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Staphylococcus aureus"</span>,
|
||||
<span class="st">"Enterococcus faecalis"</span>,
|
||||
<span class="st">"Escherichia coli"</span>,
|
||||
<span class="st">"Klebsiella pneumoniae"</span>,
|
||||
@ -252,9 +251,9 @@
|
||||
CXM <span class="op">=</span> <span class="st">"-"</span>, <span class="co"># Cefuroxime</span>
|
||||
PEN <span class="op">=</span> <span class="st">"S"</span>, <span class="co"># Benzylenicillin</span>
|
||||
FOX <span class="op">=</span> <span class="st">"S"</span>, <span class="co"># Cefoxitin</span>
|
||||
stringsAsFactors <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="va">data</span></pre></div>
|
||||
stringsAsFactors <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">data</span></code></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="left">mo</th>
|
||||
@ -319,8 +318,8 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span></code></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="left">mo</th>
|
||||
|
12
docs/articles/EUCAST_files/header-attrs-2.8/header-attrs.js
Normal file
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="fas fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
<span class="fas fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
<span class="fas fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
<span class="fas fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fa fa-database"></span>
|
||||
<span class="fas fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fa fa-compress"></span>
|
||||
<span class="fas fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
<span class="fas fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
<span class="fas fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
<span class="fas fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fa fa-book-open"></span>
|
||||
<span class="fas fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
<span class="fas fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
<span class="far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
<span class="fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@ -187,8 +187,7 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="MDR_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="MDR_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="MDR_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to determine multi-drug resistance (MDR)</h1>
|
||||
@ -244,27 +243,27 @@
|
||||
<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">
|
||||
<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></pre></div>
|
||||
<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">
|
||||
<span class="va">custom</span>
|
||||
<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. If CIP is "R" and age is higher than 60 then: Elderly Type A</span>
|
||||
<span class="co"># 2. If ERY is "R" and age is higher than 60 then: 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></pre></div>
|
||||
<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">
|
||||
<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>
|
||||
<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"># 1070 198 732</span></pre></div>
|
||||
<span class="co"># 1070 198 732</span></code></pre></div>
|
||||
<p>The rules set (the <code>custom</code> object in this case) could be exported to a shared file location using <code><a href="https://rdrr.io/r/base/readRDS.html">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>
|
||||
@ -273,15 +272,15 @@
|
||||
<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 data analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<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></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<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="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>
|
||||
<span class="co"># Warning: NA introduced for isolates where the available percentage of antimicrobial</span>
|
||||
<span class="co"># classes was below 50% (set with `pct_required_classes`)</span></pre></div>
|
||||
<span class="co"># classes was below 50% (set with `pct_required_classes`)</span></code></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: factor > ordered (numeric)<br>
|
||||
Length: 2,000<br>
|
||||
@ -317,8 +316,8 @@ Unique: 2</p>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>For another example, I will create a data set to determine multi-drug resistant TB:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="co"># random_rsi() is a helper function to generate</span>
|
||||
<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>,
|
||||
isoniazid <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>,
|
||||
@ -326,49 +325,49 @@ Unique: 2</p>
|
||||
ethambutol <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>,
|
||||
pyrazinamide <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
moxifloxacin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
kanamycin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></pre></div>
|
||||
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="cb7"><pre class="downlit">
|
||||
<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>,
|
||||
<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>,
|
||||
ETH <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>,
|
||||
PZA <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>,
|
||||
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></pre></div>
|
||||
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="cb8"><pre class="downlit">
|
||||
<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>
|
||||
<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 S S S R R</span>
|
||||
<span class="co"># 2 R S S S I R</span>
|
||||
<span class="co"># 3 R R I R I R</span>
|
||||
<span class="co"># 4 R R S S R I</span>
|
||||
<span class="co"># 5 R R R I I I</span>
|
||||
<span class="co"># 6 R I R R I I</span>
|
||||
<span class="co"># 1 S I R R R S</span>
|
||||
<span class="co"># 2 I R R R R R</span>
|
||||
<span class="co"># 3 S S S R I R</span>
|
||||
<span class="co"># 4 R I R R S S</span>
|
||||
<span class="co"># 5 I R S S R I</span>
|
||||
<span class="co"># 6 I S S R R R</span>
|
||||
<span class="co"># kanamycin</span>
|
||||
<span class="co"># 1 I</span>
|
||||
<span class="co"># 2 R</span>
|
||||
<span class="co"># 3 I</span>
|
||||
<span class="co"># 4 I</span>
|
||||
<span class="co"># 3 R</span>
|
||||
<span class="co"># 4 R</span>
|
||||
<span class="co"># 5 S</span>
|
||||
<span class="co"># 6 I</span></pre></div>
|
||||
<span class="co"># 6 S</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="cb9"><pre class="downlit">
|
||||
<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></pre></div>
|
||||
<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="cb10"><pre class="downlit">
|
||||
<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"># ℹ No column found as input for `col_mo`, assuming all records</span>
|
||||
<span class="co"># containMycobacterium tuberculosis.</span></pre></div>
|
||||
<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"># ℹ No column found as input for `col_mo`, assuming all rows contain</span>
|
||||
<span class="co"># Mycobacterium tuberculosis.</span></code></pre></div>
|
||||
<p>Create a frequency table of the results:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="downlit">
|
||||
<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></pre></div>
|
||||
<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>
|
||||
Length: 5,000<br>
|
||||
Levels: 5: Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant <…<br>
|
||||
Available: 5,000 (100%, NA: 0 = 0%)<br>
|
||||
Available: 5,000 (100.0%, NA: 0 = 0.0%)<br>
|
||||
Unique: 5</p>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
@ -383,40 +382,40 @@ Unique: 5</p>
|
||||
<tr class="odd">
|
||||
<td align="left">1</td>
|
||||
<td align="left">Mono-resistant</td>
|
||||
<td align="right">3165</td>
|
||||
<td align="right">63.30%</td>
|
||||
<td align="right">3165</td>
|
||||
<td align="right">63.30%</td>
|
||||
<td align="right">3187</td>
|
||||
<td align="right">63.74%</td>
|
||||
<td align="right">3187</td>
|
||||
<td align="right">63.74%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">2</td>
|
||||
<td align="left">Negative</td>
|
||||
<td align="right">1000</td>
|
||||
<td align="right">20.00%</td>
|
||||
<td align="right">4165</td>
|
||||
<td align="right">83.30%</td>
|
||||
<td align="right">1027</td>
|
||||
<td align="right">20.54%</td>
|
||||
<td align="right">4214</td>
|
||||
<td align="right">84.28%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">3</td>
|
||||
<td align="left">Multi-drug-resistant</td>
|
||||
<td align="right">463</td>
|
||||
<td align="right">9.26%</td>
|
||||
<td align="right">4628</td>
|
||||
<td align="right">92.56%</td>
|
||||
<td align="right">430</td>
|
||||
<td align="right">8.60%</td>
|
||||
<td align="right">4644</td>
|
||||
<td align="right">92.88%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">4</td>
|
||||
<td align="left">Poly-resistant</td>
|
||||
<td align="right">255</td>
|
||||
<td align="right">5.10%</td>
|
||||
<td align="right">4883</td>
|
||||
<td align="right">97.66%</td>
|
||||
<td align="right">245</td>
|
||||
<td align="right">4.90%</td>
|
||||
<td align="right">4889</td>
|
||||
<td align="right">97.78%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">5</td>
|
||||
<td align="left">Extensively drug-resistant</td>
|
||||
<td align="right">117</td>
|
||||
<td align="right">2.34%</td>
|
||||
<td align="right">111</td>
|
||||
<td align="right">2.22%</td>
|
||||
<td align="right">5000</td>
|
||||
<td align="right">100.00%</td>
|
||||
</tr>
|
||||
|
12
docs/articles/MDR_files/header-attrs-2.8/header-attrs.js
Normal file
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="fas fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
<span class="fas fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
<span class="fas fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
<span class="fas fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fa fa-database"></span>
|
||||
<span class="fas fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fa fa-compress"></span>
|
||||
<span class="fas fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
<span class="fas fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
<span class="fas fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
<span class="fas fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fa fa-book-open"></span>
|
||||
<span class="fas fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
<span class="fas fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
<span class="far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
<span class="fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@ -187,8 +187,7 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="PCA_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="PCA_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="PCA_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to conduct principal component analysis (PCA) for AMR</h1>
|
||||
@ -210,64 +209,64 @@
|
||||
<h1 class="hasAnchor">
|
||||
<a href="#transforming" class="anchor"></a>Transforming</h1>
|
||||
<p>For PCA, we need to transform our AMR data first. This is what the <code>example_isolates</code> data set in this package looks like:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<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://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">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="fu"><a href="https://tibble.tidyverse.org/reference/glimpse.html">glimpse</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://pillar.r-lib.org/reference/glimpse.html">glimpse</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
||||
<span class="co"># Rows: 2,000</span>
|
||||
<span class="co"># Columns: 49</span>
|
||||
<span class="co"># $ date <date> 2002-01-02, 2002-01-03, 2002-01-07, 2002-01-07, 2002…</span>
|
||||
<span class="co"># $ date <date> 2002-01-02, 2002-01-03, 2002-01-07, 2002-01-07, 2002-…</span>
|
||||
<span class="co"># $ hospital_id <fct> D, D, B, B, B, B, D, D, B, B, D, D, D, D, D, B, B, B, …</span>
|
||||
<span class="co"># $ ward_icu <lgl> FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, T…</span>
|
||||
<span class="co"># $ ward_clinical <lgl> TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, F…</span>
|
||||
<span class="co"># $ ward_outpatient <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALS…</span>
|
||||
<span class="co"># $ age <dbl> 65, 65, 45, 45, 45, 45, 78, 78, 45, 79, 67, 67, 71, 7…</span>
|
||||
<span class="co"># $ gender <chr> "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M"…</span>
|
||||
<span class="co"># $ patient_id <chr> "A77334", "A77334", "067927", "067927", "067927", "06…</span>
|
||||
<span class="co"># $ mo <mo> "B_ESCHR_COLI", "B_ESCHR_COLI", "B_STPHY_EPDR", "B_STP…</span>
|
||||
<span class="co"># $ ward_icu <lgl> FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TR…</span>
|
||||
<span class="co"># $ ward_clinical <lgl> TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FA…</span>
|
||||
<span class="co"># $ ward_outpatient <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE…</span>
|
||||
<span class="co"># $ age <dbl> 65, 65, 45, 45, 45, 45, 78, 78, 45, 79, 67, 67, 71, 71…</span>
|
||||
<span class="co"># $ gender <chr> "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M",…</span>
|
||||
<span class="co"># $ patient_id <chr> "A77334", "A77334", "067927", "067927", "067927", "067…</span>
|
||||
<span class="co"># $ mo <mo> "B_ESCHR_COLI", "B_ESCHR_COLI", "B_STPHY_EPDR", "B_STPH…</span>
|
||||
<span class="co"># $ PEN <rsi> R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, …</span>
|
||||
<span class="co"># $ OXA <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ OXA <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ FLC <rsi> NA, NA, R, R, R, R, S, S, R, S, S, S, NA, NA, NA, NA, …</span>
|
||||
<span class="co"># $ AMX <rsi> NA, NA, NA, NA, NA, NA, R, R, NA, NA, NA, NA, NA, NA, …</span>
|
||||
<span class="co"># $ AMC <rsi> I, I, NA, NA, NA, NA, S, S, NA, NA, S, S, I, I, R, I, …</span>
|
||||
<span class="co"># $ AMP <rsi> NA, NA, NA, NA, NA, NA, R, R, NA, NA, NA, NA, NA, NA, …</span>
|
||||
<span class="co"># $ TZP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ CZO <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ FEP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ CXM <rsi> I, I, R, R, R, R, S, S, R, S, S, S, S, S, NA, S, S, R…</span>
|
||||
<span class="co"># $ FOX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ TZP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ CZO <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ FEP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ CXM <rsi> I, I, R, R, R, R, S, S, R, S, S, S, S, S, NA, S, S, R,…</span>
|
||||
<span class="co"># $ FOX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ CTX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S, …</span>
|
||||
<span class="co"># $ CAZ <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, …</span>
|
||||
<span class="co"># $ CAZ <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, S…</span>
|
||||
<span class="co"># $ CRO <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S, …</span>
|
||||
<span class="co"># $ GEN <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ TOB <rsi> NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, S, S, N…</span>
|
||||
<span class="co"># $ AMK <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ KAN <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ TMP <rsi> R, R, S, S, R, R, R, R, S, S, NA, NA, S, S, S, S, S, …</span>
|
||||
<span class="co"># $ GEN <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ TOB <rsi> NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, S, S, NA…</span>
|
||||
<span class="co"># $ AMK <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ KAN <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ TMP <rsi> R, R, S, S, R, R, R, R, S, S, NA, NA, S, S, S, S, S, R…</span>
|
||||
<span class="co"># $ SXT <rsi> R, R, S, S, NA, NA, NA, NA, S, S, NA, NA, S, S, S, S, …</span>
|
||||
<span class="co"># $ NIT <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ FOS <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ LNZ <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span>
|
||||
<span class="co"># $ NIT <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ FOS <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ LNZ <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R,…</span>
|
||||
<span class="co"># $ CIP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, …</span>
|
||||
<span class="co"># $ MFX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ VAN <rsi> R, R, S, S, S, S, S, S, S, S, NA, NA, R, R, R, R, R, …</span>
|
||||
<span class="co"># $ TEC <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span>
|
||||
<span class="co"># $ TCY <rsi> R, R, S, S, S, S, S, S, S, I, S, S, NA, NA, I, R, R, …</span>
|
||||
<span class="co"># $ MFX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ VAN <rsi> R, R, S, S, S, S, S, S, S, S, NA, NA, R, R, R, R, R, S…</span>
|
||||
<span class="co"># $ TEC <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R,…</span>
|
||||
<span class="co"># $ TCY <rsi> R, R, S, S, S, S, S, S, S, I, S, S, NA, NA, I, R, R, S…</span>
|
||||
<span class="co"># $ TGC <rsi> NA, NA, S, S, S, S, S, S, S, NA, S, S, NA, NA, NA, R, …</span>
|
||||
<span class="co"># $ DOX <rsi> NA, NA, S, S, S, S, S, S, S, NA, S, S, NA, NA, NA, R, …</span>
|
||||
<span class="co"># $ ERY <rsi> R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R, …</span>
|
||||
<span class="co"># $ CLI <rsi> R, R, NA, NA, NA, R, NA, NA, NA, NA, NA, NA, R, R, R, …</span>
|
||||
<span class="co"># $ AZM <rsi> R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R, …</span>
|
||||
<span class="co"># $ IPM <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S, …</span>
|
||||
<span class="co"># $ MEM <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ MTR <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ CHL <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ COL <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, …</span>
|
||||
<span class="co"># $ MUP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ RIF <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span></pre></div>
|
||||
<span class="co"># $ MEM <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ MTR <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ CHL <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ COL <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, R…</span>
|
||||
<span class="co"># $ MUP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||
<span class="co"># $ RIF <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R,…</span></code></pre></div>
|
||||
<p>Now to transform this to a data set with only resistance percentages per taxonomic order and genus:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="va">resistance_data</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">resistance_data</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span>order <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, <span class="co"># group on anything, like order</span>
|
||||
genus <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</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="co"># and genus as we do here</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise_all.html">summarise_if</a></span><span class="op">(</span><span class="va">is.rsi</span>, <span class="va">resistance</span><span class="op">)</span> <span class="op">%>%</span> <span class="co"># then get resistance of all drugs</span>
|
||||
@ -284,26 +283,26 @@
|
||||
<span class="co"># 3 Bacteroidales Bacteroides NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 4 Campylobacteral… Campylobacter NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 5 Caryophanales Gemella NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 6 Caryophanales Listeria NA NA NA NA NA NA NA NA</span></pre></div>
|
||||
<span class="co"># 6 Caryophanales Listeria NA NA NA NA NA NA NA NA</span></code></pre></div>
|
||||
</div>
|
||||
<div id="perform-principal-component-analysis" class="section level1">
|
||||
<h1 class="hasAnchor">
|
||||
<a href="#perform-principal-component-analysis" class="anchor"></a>Perform principal component analysis</h1>
|
||||
<p>The new <code><a href="../reference/pca.html">pca()</a></code> function will automatically filter on rows that contain numeric values in all selected variables, so we now only need to do:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="va">pca_result</span> <span class="op"><-</span> <span class="fu"><a href="../reference/pca.html">pca</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">pca_result</span> <span class="op"><-</span> <span class="fu"><a href="../reference/pca.html">pca</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span>
|
||||
<span class="co"># ℹ Columns selected for PCA: "AMC", "CAZ", "CTX", "CXM", "GEN", "SXT", "TMP"</span>
|
||||
<span class="co"># and "TOB". Total observations available: 7.</span></pre></div>
|
||||
<span class="co"># and "TOB". Total observations available: 7.</span></code></pre></div>
|
||||
<p>The result can be reviewed with the good old <code><a href="https://rdrr.io/r/base/summary.html">summary()</a></code> function:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span>
|
||||
<span class="co"># Groups (n=4, named as 'order'):</span>
|
||||
<span class="co"># [1] "Caryophanales" "Enterobacterales" "Lactobacillales" "Pseudomonadales"</span>
|
||||
<span class="co"># Importance of components:</span>
|
||||
<span class="co"># PC1 PC2 PC3 PC4 PC5 PC6 PC7</span>
|
||||
<span class="co"># Standard deviation 2.1539 1.6807 0.6138 0.33879 0.20808 0.03140 5.121e-17</span>
|
||||
<span class="co"># Proportion of Variance 0.5799 0.3531 0.0471 0.01435 0.00541 0.00012 0.000e+00</span>
|
||||
<span class="co"># Cumulative Proportion 0.5799 0.9330 0.9801 0.99446 0.99988 1.00000 1.000e+00</span></pre></div>
|
||||
<span class="co"># Cumulative Proportion 0.5799 0.9330 0.9801 0.99446 0.99988 1.00000 1.000e+00</span></code></pre></div>
|
||||
<pre><code># Groups (n=4, named as 'order'):
|
||||
# [1] "Caryophanales" "Enterobacterales" "Lactobacillales" "Pseudomonadales"</code></pre>
|
||||
<p>Good news. The first two components explain a total of 93.3% of the variance (see the PC1 and PC2 values of the <em>Proportion of Variance</em>. We can create a so-called biplot with the base R <code><a href="https://rdrr.io/r/stats/biplot.html">biplot()</a></code> function, to see which antimicrobial resistance per drug explain the difference per microorganism.</p>
|
||||
@ -311,17 +310,17 @@
|
||||
<div id="plotting-the-results" class="section level1">
|
||||
<h1 class="hasAnchor">
|
||||
<a href="#plotting-the-results" class="anchor"></a>Plotting the results</h1>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="fu"><a href="https://rdrr.io/r/stats/biplot.html">biplot</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/stats/biplot.html">biplot</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="PCA_files/figure-html/unnamed-chunk-5-1.png" width="750"></p>
|
||||
<p>But we can’t see the explanation of the points. Perhaps this works better with our new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function, that automatically adds the right labels and even groups:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="PCA_files/figure-html/unnamed-chunk-6-1.png" width="750"></p>
|
||||
<p>You can also print an ellipse per group, and edit the appearance:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span>, ellipse <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> <span class="op">+</span>
|
||||
<span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html">labs</a></span><span class="op">(</span>title <span class="op">=</span> <span class="st">"An AMR/PCA biplot!"</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span>, ellipse <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> <span class="op">+</span>
|
||||
<span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html">labs</a></span><span class="op">(</span>title <span class="op">=</span> <span class="st">"An AMR/PCA biplot!"</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="PCA_files/figure-html/unnamed-chunk-7-1.png" width="750"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 94 KiB |
12
docs/articles/PCA_files/header-attrs-2.8/header-attrs.js
Normal file
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="fas fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
<span class="fas fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
<span class="fas fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
<span class="fas fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fa fa-database"></span>
|
||||
<span class="fas fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fa fa-compress"></span>
|
||||
<span class="fas fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
<span class="fas fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
<span class="fas fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
<span class="fas fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fa fa-book-open"></span>
|
||||
<span class="fas fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
<span class="fas fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
<span class="far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
<span class="fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@ -187,14 +187,13 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="SPSS_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="SPSS_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="SPSS_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to import data from SPSS / SAS / Stata</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">27 April 2021</h4>
|
||||
<h4 class="date">03 June 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>
|
||||
@ -229,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, <a href="https://stackoverflow.com/questions/tagged/r?sort=votes">398,952 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>
|
||||
<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">404,559 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>
|
||||
@ -248,8 +247,8 @@
|
||||
</li>
|
||||
</ul>
|
||||
<p>To demonstrate the first point:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="co"># not all values are valid MIC values:</span>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># not all values are valid MIC values:</span>
|
||||
<span class="fu"><a href="../reference/as.mic.html">as.mic</a></span><span class="op">(</span><span class="fl">0.125</span><span class="op">)</span>
|
||||
<span class="co"># Class <mic></span>
|
||||
<span class="co"># [1] 0.125</span>
|
||||
@ -280,7 +279,7 @@
|
||||
<span class="co"># [4] "fluclox" "flucloxacilina" "flucloxacillin" </span>
|
||||
<span class="co"># [7] "flucloxacilline" "flucloxacillinum" "fluorochloroxacillin"</span>
|
||||
<span class="fu"><a href="../reference/ab_property.html">ab_atc</a></span><span class="op">(</span><span class="st">"floxapen"</span><span class="op">)</span>
|
||||
<span class="co"># [1] "J01CF05"</span></pre></div>
|
||||
<span class="co"># [1] "J01CF05"</span></code></pre></div>
|
||||
</div>
|
||||
<div id="import-data-from-spsssasstata" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
@ -296,8 +295,8 @@
|
||||
<p><img src="https://github.com/msberends/AMR/raw/master/docs/import2.png"></p>
|
||||
<p>If you want named variables to be imported as factors so it resembles SPSS more, use <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>.</p>
|
||||
<p>The difference is this:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="va">SPSS_data</span>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">SPSS_data</span>
|
||||
<span class="co"># # A tibble: 4,203 x 4</span>
|
||||
<span class="co"># v001 sex status statusage</span>
|
||||
<span class="co"># <dbl> <dbl+lbl> <dbl+lbl> <dbl></span>
|
||||
@ -327,74 +326,74 @@
|
||||
<span class="co"># 8 10011 Male alive 73.1</span>
|
||||
<span class="co"># 9 10017 Male alive 56.7</span>
|
||||
<span class="co"># 10 10018 Female alive 66.6</span>
|
||||
<span class="co"># # … with 4,193 more rows</span></pre></div>
|
||||
<span class="co"># # … with 4,193 more rows</span></code></pre></div>
|
||||
</div>
|
||||
<div id="base-r" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#base-r" class="anchor"></a>Base R</h3>
|
||||
<p>To import data from SPSS, SAS or Stata, you can use the <a href="https://haven.tidyverse.org/">great <code>haven</code> package</a> yourself:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="co"># download and install the latest version:</span>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># download and install the latest version:</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"haven"</span><span class="op">)</span>
|
||||
<span class="co"># load the package you just installed:</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="http://haven.tidyverse.org">haven</a></span><span class="op">)</span> </pre></div>
|
||||
<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://haven.tidyverse.org">haven</a></span><span class="op">)</span> </code></pre></div>
|
||||
<p>You can now import files as follows:</p>
|
||||
<div id="spss" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#spss" class="anchor"></a>SPSS</h4>
|
||||
<p>To read files from SPSS into R:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="co"># read any SPSS file based on file extension (best way):</span>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># read any SPSS file based on file extension (best way):</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_spss</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># read .sav or .zsav file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_sav</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># read .por file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_por</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_por</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></code></pre></div>
|
||||
<p>Do not forget about <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>, as mentioned above.</p>
|
||||
<p>To export your R objects to the SPSS file format:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="co"># save as .sav file:</span>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># save as .sav file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># save as compressed .zsav file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, compress <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, compress <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
|
||||
</div>
|
||||
<div id="sas" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#sas" class="anchor"></a>SAS</h4>
|
||||
<p>To read files from SAS into R:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="co"># read .sas7bdat + .sas7bcat files:</span>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># read .sas7bdat + .sas7bcat files:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">read_sas</a></span><span class="op">(</span>data_file <span class="op">=</span> <span class="st">"path/to/file"</span>, catalog_file <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># read SAS transport files (version 5 and version 8):</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">read_xpt</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">read_xpt</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></code></pre></div>
|
||||
<p>To export your R objects to the SAS file format:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||
<span class="co"># save as regular SAS file:</span>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># save as regular SAS file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">write_sas</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># the SAS transport format is an open format </span>
|
||||
<span class="co"># (required for submission of the data to the FDA)</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">write_xpt</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, version <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">write_xpt</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, version <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></code></pre></div>
|
||||
</div>
|
||||
<div id="stata" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#stata" class="anchor"></a>Stata</h4>
|
||||
<p>To read files from Stata into R:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||
<span class="co"># read .dta file:</span>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># read .dta file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_stata</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># works exactly the same:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_dta</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_dta</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span></code></pre></div>
|
||||
<p>To export your R objects to the Stata file format:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit">
|
||||
<span class="co"># save as .dta file, Stata version 14:</span>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># save as .dta file, Stata version 14:</span>
|
||||
<span class="co"># (supports Stata v8 until v15 at the time of writing)</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">write_dta</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"/path/to/file"</span>, version <span class="op">=</span> <span class="fl">14</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">write_dta</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"/path/to/file"</span>, version <span class="op">=</span> <span class="fl">14</span><span class="op">)</span></code></pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
12
docs/articles/SPSS_files/header-attrs-2.8/header-attrs.js
Normal file
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="fas fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
<span class="fas fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
<span class="fas fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
<span class="fas fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fa fa-database"></span>
|
||||
<span class="fas fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fa fa-compress"></span>
|
||||
<span class="fas fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
<span class="fas fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
<span class="fas fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
<span class="fas fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fa fa-book-open"></span>
|
||||
<span class="fas fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
<span class="fas fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
<span class="far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
<span class="fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@ -187,8 +187,7 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="WHONET_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="WHONET_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="WHONET_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to work with WHONET data</h1>
|
||||
@ -206,42 +205,42 @@
|
||||
<a href="#import-of-data" class="anchor"></a>Import of data</h3>
|
||||
<p>This tutorial assumes you already imported the WHONET data with e.g. the <a href="https://readxl.tidyverse.org/"><code>readxl</code> package</a>. In RStudio, this can be done using the menu button ‘Import Dataset’ in the tab ‘Environment’. Choose the option ‘From Excel’ and select your exported file. Make sure date fields are imported correctly.</p>
|
||||
<p>An example syntax could look like this:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<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://readxl.tidyverse.org">readxl</a></span><span class="op">)</span>
|
||||
<span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://readxl.tidyverse.org/reference/read_excel.html">read_excel</a></span><span class="op">(</span>path <span class="op">=</span> <span class="st">"path/to/your/file.xlsx"</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://readxl.tidyverse.org">readxl</a></span><span class="op">)</span>
|
||||
<span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://readxl.tidyverse.org/reference/read_excel.html">read_excel</a></span><span class="op">(</span>path <span class="op">=</span> <span class="st">"path/to/your/file.xlsx"</span><span class="op">)</span></code></pre></div>
|
||||
<p>This package comes with an <a href="https://msberends.github.io/AMR/reference/WHONET.html">example data set <code>WHONET</code></a>. We will use it for this analysis.</p>
|
||||
</div>
|
||||
<div id="preparation" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#preparation" class="anchor"></a>Preparation</h3>
|
||||
<p>First, load the relevant packages if you did not yet did this. I use the tidyverse for all of my analyses. All of them. If you don’t know it yet, I suggest you read about it on their website: <a href="https://www.tidyverse.org/" class="uri">https://www.tidyverse.org/</a>.</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<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"># part of tidyverse</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="http://ggplot2.tidyverse.org">ggplot2</a></span><span class="op">)</span> <span class="co"># part of tidyverse</span>
|
||||
<div class="sourceCode" id="cb2"><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"># part of tidyverse</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://ggplot2.tidyverse.org">ggplot2</a></span><span class="op">)</span> <span class="co"># part of tidyverse</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://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span> <span class="co"># this package</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></pre></div>
|
||||
<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>
|
||||
<p>We will have to transform some variables to simplify and automate the analysis:</p>
|
||||
<ul>
|
||||
<li>Microorganisms should be transformed to our own microorganism IDs (called an <code>mo</code>) using <a href="https://msberends.github.io/AMR/reference/catalogue_of_life">our Catalogue of Life reference data set</a>, which contains all ~70,000 microorganisms from the taxonomic kingdoms Bacteria, Fungi and Protozoa. We do the tranformation with <code><a href="../reference/as.mo.html">as.mo()</a></code>. This function also recognises almost all WHONET abbreviations of microorganisms.</li>
|
||||
<li>Microorganisms should be transformed to our own microorganism codes (called an <code>mo</code>) using <a href="https://msberends.github.io/AMR/reference/catalogue_of_life">our Catalogue of Life reference data set</a>, which contains all ~70,000 microorganisms from the taxonomic kingdoms Bacteria, Fungi and Protozoa. We do the tranformation with <code><a href="../reference/as.mo.html">as.mo()</a></code>. This function also recognises almost all WHONET abbreviations of microorganisms.</li>
|
||||
<li>Antimicrobial results or interpretations have to be clean and valid. In other words, they should only contain values <code>"S"</code>, <code>"I"</code> or <code>"R"</code>. That is exactly where the <code><a href="../reference/as.rsi.html">as.rsi()</a></code> function is for.</li>
|
||||
</ul>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="co"># transform variables</span>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># transform variables</span>
|
||||
<span class="va">data</span> <span class="op"><-</span> <span class="va">WHONET</span> <span class="op">%>%</span>
|
||||
<span class="co"># get microbial ID based on given organism</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/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">Organism</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="co"># transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">AMP_ND10</span><span class="op">:</span><span class="va">CIP_EE</span><span class="op">)</span>, <span class="va">as.rsi</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">AMP_ND10</span><span class="op">:</span><span class="va">CIP_EE</span><span class="op">)</span>, <span class="va">as.rsi</span><span class="op">)</span></code></pre></div>
|
||||
<p>No errors or warnings, so all values are transformed succesfully.</p>
|
||||
<p>We also created a package dedicated to data cleaning and checking, called the <code>cleaner</code> package. Its <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> function can be used to create frequency tables.</p>
|
||||
<p>So let’s check our data, with a couple of frequency tables:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="co"># our newly created `mo` variable, put in the mo_name() function</span>
|
||||
<span class="va">data</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="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, nmax <span class="op">=</span> <span class="fl">10</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># our newly created `mo` variable, put in the mo_name() function</span>
|
||||
<span class="va">data</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="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, nmax <span class="op">=</span> <span class="fl">10</span><span class="op">)</span></code></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: character<br>
|
||||
Length: 500<br>
|
||||
Available: 500 (100%, NA: 0 = 0%)<br>
|
||||
Available: 500 (100.0%, NA: 0 = 0.0%)<br>
|
||||
Unique: 37</p>
|
||||
<p>Shortest: 11<br>
|
||||
Longest: 40</p>
|
||||
@ -338,10 +337,10 @@ Longest: 40</p>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>(omitted 27 entries, n = 56 [11.20%])</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="co"># our transformed antibiotic columns</span>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># our transformed antibiotic columns</span>
|
||||
<span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span>
|
||||
<span class="va">data</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="va">AMC_ND2</span><span class="op">)</span></pre></div>
|
||||
<span class="va">data</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="va">AMC_ND2</span><span class="op">)</span></code></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: factor > ordered > rsi (numeric)<br>
|
||||
Length: 500<br>
|
||||
@ -392,11 +391,11 @@ Drug group: Beta-lactams/penicillins<br>
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#a-first-glimpse-at-results" class="anchor"></a>A first glimpse at results</h3>
|
||||
<p>An easy <code>ggplot</code> will already give a lot of information, using the included <code><a href="../reference/ggplot_rsi.html">ggplot_rsi()</a></code> function:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="va">data</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">data</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">Country</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">Country</span>, <span class="va">AMP_ND2</span>, <span class="va">AMC_ED20</span>, <span class="va">CAZ_ED10</span>, <span class="va">CIP_ED5</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/ggplot_rsi.html">ggplot_rsi</a></span><span class="op">(</span>translate_ab <span class="op">=</span> <span class="st">'ab'</span>, facet <span class="op">=</span> <span class="st">"Country"</span>, datalabels <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="../reference/ggplot_rsi.html">ggplot_rsi</a></span><span class="op">(</span>translate_ab <span class="op">=</span> <span class="st">'ab'</span>, facet <span class="op">=</span> <span class="st">"Country"</span>, datalabels <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="WHONET_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
12
docs/articles/WHONET_files/header-attrs-2.8/header-attrs.js
Normal file
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -187,7 +187,7 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="benchmarks_files/header-attrs-2.7/header-attrs.js"></script><div class="row">
|
||||
</header><script src="benchmarks_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>Benchmarks</h1>
|
||||
@ -224,21 +224,21 @@
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"MRSA"</span><span class="op">)</span>, <span class="co"># Methicillin Resistant S. aureus</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"VISA"</span><span class="op">)</span>, <span class="co"># Vancomycin Intermediate S. aureus</span>
|
||||
times <span class="op">=</span> <span class="fl">25</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">S.aureus</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">2</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">S.aureus</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">2</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># as.mo("sau") 9.6 10.0 12.0 10 11.0 42 25</span>
|
||||
<span class="co"># as.mo("stau") 52.0 55.0 74.0 59 94.0 110 25</span>
|
||||
<span class="co"># as.mo("STAU") 51.0 53.0 73.0 57 91.0 100 25</span>
|
||||
<span class="co"># as.mo("staaur") 9.5 9.9 11.0 10 12.0 13 25</span>
|
||||
<span class="co"># as.mo("STAAUR") 9.4 10.0 18.0 10 12.0 52 25</span>
|
||||
<span class="co"># as.mo("S. aureus") 24.0 26.0 31.0 26 29.0 62 25</span>
|
||||
<span class="co"># as.mo("S aureus") 25.0 25.0 42.0 29 62.0 68 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus") 2.5 2.9 3.2 3 3.5 4 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 240.0 240.0 260.0 250 260.0 390 25</span>
|
||||
<span class="co"># as.mo("Sthafilokkockus aaureuz") 150.0 190.0 190.0 190 190.0 250 25</span>
|
||||
<span class="co"># as.mo("MRSA") 8.7 10.0 15.0 11 12.0 49 25</span>
|
||||
<span class="co"># as.mo("VISA") 17.0 19.0 25.0 21 22.0 57 25</span></code></pre></div>
|
||||
<span class="co"># as.mo("sau") 13.0 13.0 16.0 15.0 16.0 44 25</span>
|
||||
<span class="co"># as.mo("stau") 55.0 58.0 75.0 62.0 94.0 110 25</span>
|
||||
<span class="co"># as.mo("STAU") 55.0 59.0 77.0 89.0 94.0 100 25</span>
|
||||
<span class="co"># as.mo("staaur") 11.0 13.0 20.0 14.0 16.0 48 25</span>
|
||||
<span class="co"># as.mo("STAAUR") 11.0 13.0 17.0 15.0 16.0 49 25</span>
|
||||
<span class="co"># as.mo("S. aureus") 26.0 30.0 41.0 32.0 60.0 68 25</span>
|
||||
<span class="co"># as.mo("S aureus") 27.0 29.0 44.0 32.0 58.0 160 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus") 3.3 3.9 5.5 4.2 4.7 37 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 250.0 260.0 280.0 280.0 290.0 320 25</span>
|
||||
<span class="co"># as.mo("Sthafilokkockus aaureuz") 170.0 200.0 210.0 200.0 220.0 250 25</span>
|
||||
<span class="co"># as.mo("MRSA") 12.0 14.0 21.0 15.0 17.0 56 25</span>
|
||||
<span class="co"># as.mo("VISA") 20.0 23.0 33.0 25.0 51.0 59 25</span></code></pre></div>
|
||||
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="750"></p>
|
||||
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 200 milliseconds, this is only 5 input values per second. It is clear that accepted taxonomic names are extremely fast, but some variations are up to 200 times slower to determine.</p>
|
||||
<p>To improve performance, we implemented two important algorithms to save unnecessary calculations: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
|
||||
@ -260,8 +260,8 @@
|
||||
<span class="co"># what do these values look like? They are of class <mo>:</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||
<span class="co"># Class <mo></span>
|
||||
<span class="co"># [1] B_KLBSL_PNMN B_STPHY_EPDR B_STRPT_PNMN B_STRPT_EQNS B_ESCHR_COLI</span>
|
||||
<span class="co"># [6] B_KLBSL_PNMN</span>
|
||||
<span class="co"># [1] B_STPHY_CONS B_ESCHR_COLI B_STPHY_AURS B_STRPT_PYGN B_ESCHR_COLI</span>
|
||||
<span class="co"># [6] B_HMPHL_INFL</span>
|
||||
|
||||
<span class="co"># as the example_isolates data set has 2,000 rows, we should have 2 million items</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/length.html">length</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||
@ -274,11 +274,11 @@
|
||||
<span class="co"># now let's see:</span>
|
||||
<span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>,
|
||||
times <span class="op">=</span> <span class="fl">10</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># mo_name(x) 155 182 233 228 242 350 10</span></code></pre></div>
|
||||
<p>So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.228 seconds. That is 114 nanoseconds on average. You only lose time on your unique input values.</p>
|
||||
<span class="co"># mo_name(x) 165 238 258 246 253 369 10</span></code></pre></div>
|
||||
<p>So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.246 seconds. That is 123 nanoseconds on average. You only lose time on your unique input values.</p>
|
||||
</div>
|
||||
<div id="precalculated-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -289,13 +289,13 @@
|
||||
B <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"S. aureus"</span><span class="op">)</span>,
|
||||
C <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"Staphylococcus aureus"</span><span class="op">)</span>,
|
||||
times <span class="op">=</span> <span class="fl">10</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># A 6.62 6.84 7.30 6.91 8.10 8.74 10</span>
|
||||
<span class="co"># B 22.20 23.10 33.20 24.50 27.70 70.80 10</span>
|
||||
<span class="co"># C 1.37 1.50 1.66 1.71 1.81 1.84 10</span></code></pre></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0017 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<span class="co"># A 8.20 8.33 13.30 8.53 9.71 53.2 10</span>
|
||||
<span class="co"># B 22.80 23.50 29.20 24.60 26.80 69.3 10</span>
|
||||
<span class="co"># C 1.82 2.04 2.25 2.16 2.38 2.9 10</span></code></pre></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0022 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>A <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span><span class="op">(</span><span class="st">"aureus"</span><span class="op">)</span>,
|
||||
B <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"Staphylococcus"</span><span class="op">)</span>,
|
||||
@ -306,17 +306,17 @@
|
||||
G <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_phylum</a></span><span class="op">(</span><span class="st">"Firmicutes"</span><span class="op">)</span>,
|
||||
H <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_kingdom</a></span><span class="op">(</span><span class="st">"Bacteria"</span><span class="op">)</span>,
|
||||
times <span class="op">=</span> <span class="fl">10</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># A 1.19 1.21 1.43 1.28 1.65 2.03 10</span>
|
||||
<span class="co"># B 1.19 1.24 1.38 1.26 1.53 1.83 10</span>
|
||||
<span class="co"># C 1.24 1.28 1.45 1.36 1.41 2.24 10</span>
|
||||
<span class="co"># D 1.20 1.22 1.33 1.23 1.41 1.77 10</span>
|
||||
<span class="co"># E 1.21 1.22 1.35 1.27 1.38 1.69 10</span>
|
||||
<span class="co"># F 1.20 1.21 1.34 1.26 1.37 1.71 10</span>
|
||||
<span class="co"># G 1.17 1.22 1.31 1.27 1.31 1.71 10</span>
|
||||
<span class="co"># H 1.21 1.27 1.42 1.37 1.47 1.84 10</span></code></pre></div>
|
||||
<span class="co"># A 1.66 1.70 1.86 1.77 1.90 2.41 10</span>
|
||||
<span class="co"># B 1.61 1.71 1.99 1.84 2.37 2.56 10</span>
|
||||
<span class="co"># C 1.64 1.72 1.79 1.74 1.77 2.14 10</span>
|
||||
<span class="co"># D 1.68 1.71 2.06 2.06 2.23 2.77 10</span>
|
||||
<span class="co"># E 1.63 1.71 1.85 1.75 1.92 2.43 10</span>
|
||||
<span class="co"># F 1.61 1.67 1.80 1.75 1.86 2.22 10</span>
|
||||
<span class="co"># G 1.63 1.67 4.37 1.96 2.58 25.70 10</span>
|
||||
<span class="co"># H 1.67 1.73 1.88 1.83 2.01 2.28 10</span></code></pre></div>
|
||||
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> anyway, there is no point in calculating the result. And because this package contains all phyla of all known bacteria, it can just return the initial value immediately.</p>
|
||||
</div>
|
||||
<div id="results-in-other-languages" class="section level3">
|
||||
@ -341,16 +341,16 @@
|
||||
fr <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"CoNS"</span>, language <span class="op">=</span> <span class="st">"fr"</span><span class="op">)</span>,
|
||||
pt <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"CoNS"</span>, language <span class="op">=</span> <span class="st">"pt"</span><span class="op">)</span>,
|
||||
times <span class="op">=</span> <span class="fl">100</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">4</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">4</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># en 17.19 17.50 22.00 17.76 18.54 61.02 100</span>
|
||||
<span class="co"># de 31.08 31.53 39.66 32.04 35.34 76.23 100</span>
|
||||
<span class="co"># nl 30.19 31.41 40.64 32.30 35.93 79.53 100</span>
|
||||
<span class="co"># es 30.50 31.33 41.70 31.84 35.90 181.80 100</span>
|
||||
<span class="co"># it 20.94 21.37 25.27 21.63 22.44 69.84 100</span>
|
||||
<span class="co"># fr 20.62 21.00 27.09 21.41 23.12 79.50 100</span>
|
||||
<span class="co"># pt 20.41 21.23 25.33 21.56 22.22 70.65 100</span></code></pre></div>
|
||||
<span class="co"># en 19.99 20.43 25.64 21.15 22.38 82.52 100</span>
|
||||
<span class="co"># de 31.03 31.96 38.34 32.88 35.27 82.31 100</span>
|
||||
<span class="co"># nl 35.25 36.19 43.25 37.63 39.66 85.19 100</span>
|
||||
<span class="co"># es 35.01 35.85 40.89 36.91 38.58 83.68 100</span>
|
||||
<span class="co"># it 24.35 24.90 30.43 25.81 28.03 78.90 100</span>
|
||||
<span class="co"># fr 23.87 25.02 31.72 26.03 27.46 83.88 100</span>
|
||||
<span class="co"># pt 24.00 24.99 31.16 26.05 28.06 80.74 100</span></code></pre></div>
|
||||
<p>Currently supported non-English languages are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -192,7 +192,7 @@
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>Data sets for download / own use</h1>
|
||||
|
||||
<h4 class="date">21 May 2021</h4>
|
||||
<h4 class="date">03 June 2021</h4>
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>datasets.Rmd</code></div>
|
||||
@ -1005,27 +1005,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 20,486 rows and 10 columns, containing the following column names:<br><em>guideline</em>, <em>method</em>, <em>site</em>, <em>mo</em>, <em>ab</em>, <em>ref_tbl</em>, <em>disk_dose</em>, <em>breakpoint_S</em>, <em>breakpoint_R</em> and <em>uti</em>.</p>
|
||||
<p>A data set with 21,996 rows and 10 columns, containing the following column names:<br><em>guideline</em>, <em>method</em>, <em>site</em>, <em>mo</em>, <em>ab</em>, <em>ref_tbl</em>, <em>disk_dose</em>, <em>breakpoint_S</em>, <em>breakpoint_R</em> and <em>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 5 March 2021 09:46:55 UTC. 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 1 June 2021 14:47:11 UTC. 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> (34 kB)<br>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.rds">R file</a> (37 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.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.7 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.8 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.5 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.8 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.8 MB)<br>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.sav">SPSS file</a> (2.4 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.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.5 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-2021).</p>
|
||||
<p>This data set contains interpretation rules for MIC values and disk diffusion diameters. Included guidelines are CLSI (2010-2020) and EUCAST (2011-2021).</p>
|
||||
</div>
|
||||
<div id="example-content-5" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
|
@ -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.6.0.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</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.6.0.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="fas fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
<span class="fas fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
<span class="fas fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
<span class="fas fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fa fa-database"></span>
|
||||
<span class="fas fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fa fa-compress"></span>
|
||||
<span class="fas fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
<span class="fas fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
<span class="fas fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
<span class="fas fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fa fa-book-open"></span>
|
||||
<span class="fas fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
<span class="fas fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
<span class="far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
<span class="fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@ -187,8 +187,7 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="resistance_predict_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="resistance_predict_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="resistance_predict_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to predict antimicrobial resistance</h1>
|
||||
@ -206,37 +205,37 @@
|
||||
<a href="#needed-r-packages" class="anchor"></a>Needed R packages</h2>
|
||||
<p>As with many uses in R, we need some additional packages for AMR data analysis. Our package works closely together with the <a href="https://www.tidyverse.org">tidyverse packages</a> <a href="https://dplyr.tidyverse.org/"><code>dplyr</code></a> and <a href="https://ggplot2.tidyverse.org"><code>ggplot2</code></a> by Dr Hadley Wickham. The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.</p>
|
||||
<p>Our <code>AMR</code> package depends on these packages and even extends their use and functions.</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<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="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://ggplot2.tidyverse.org">ggplot2</a></span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">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="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://ggplot2.tidyverse.org">ggplot2</a></span><span class="op">)</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://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||
|
||||
<span class="co"># (if not yet installed, install with:)</span>
|
||||
<span class="co"># install.packages(c("tidyverse", "AMR"))</span></pre></div>
|
||||
<span class="co"># install.packages(c("tidyverse", "AMR"))</span></code></pre></div>
|
||||
</div>
|
||||
<div id="prediction-analysis" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#prediction-analysis" class="anchor"></a>Prediction analysis</h2>
|
||||
<p>Our package contains a function <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>, which takes the same input as functions for <a href="./AMR.html">other AMR data analysis</a>. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.</p>
|
||||
<p>It is basically as easy as:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="co"># resistance prediction of piperacillin/tazobactam (TZP):</span></a>
|
||||
<a class="sourceLine" id="cb2-2" title="2"><span class="kw">resistance_predict</span>(<span class="dt">tbl =</span> example_isolates, <span class="dt">col_date =</span> <span class="st">"date"</span>, <span class="dt">col_ab =</span> <span class="st">"TZP"</span>, <span class="dt">model =</span> <span class="st">"binomial"</span>)</a>
|
||||
<a class="sourceLine" id="cb2-3" title="3"></a>
|
||||
<a class="sourceLine" id="cb2-4" title="4"><span class="co"># or:</span></a>
|
||||
<a class="sourceLine" id="cb2-5" title="5">example_isolates <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb2-6" title="6"><span class="st"> </span><span class="kw">resistance_predict</span>(<span class="dt">col_ab =</span> <span class="st">"TZP"</span>,</a>
|
||||
<a class="sourceLine" id="cb2-7" title="7"> model <span class="st">"binomial"</span>)</a>
|
||||
<a class="sourceLine" id="cb2-8" title="8"></a>
|
||||
<a class="sourceLine" id="cb2-9" title="9"><span class="co"># to bind it to object 'predict_TZP' for example:</span></a>
|
||||
<a class="sourceLine" id="cb2-10" title="10">predict_TZP <-<span class="st"> </span>example_isolates <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb2-11" title="11"><span class="st"> </span><span class="kw">resistance_predict</span>(<span class="dt">col_ab =</span> <span class="st">"TZP"</span>,</a>
|
||||
<a class="sourceLine" id="cb2-12" title="12"> <span class="dt">model =</span> <span class="st">"binomial"</span>)</a></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># resistance prediction of piperacillin/tazobactam (TZP):</span></span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">resistance_predict</span>(<span class="at">tbl =</span> example_isolates, <span class="at">col_date =</span> <span class="st">"date"</span>, <span class="at">col_ab =</span> <span class="st">"TZP"</span>, <span class="at">model =</span> <span class="st">"binomial"</span>)</span>
|
||||
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co"># or:</span></span>
|
||||
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>example_isolates <span class="sc">%>%</span> </span>
|
||||
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">resistance_predict</span>(<span class="at">col_ab =</span> <span class="st">"TZP"</span>,</span>
|
||||
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> model <span class="st">"binomial"</span>)</span>
|
||||
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="co"># to bind it to object 'predict_TZP' for example:</span></span>
|
||||
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a>predict_TZP <span class="ot"><-</span> example_isolates <span class="sc">%>%</span> </span>
|
||||
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">resistance_predict</span>(<span class="at">col_ab =</span> <span class="st">"TZP"</span>,</span>
|
||||
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="at">model =</span> <span class="st">"binomial"</span>)</span></code></pre></div>
|
||||
<p>The function will look for a date column itself if <code>col_date</code> is not set.</p>
|
||||
<p>When running any of these commands, a summary of the regression model will be printed unless using <code><a href="../reference/resistance_predict.html">resistance_predict(..., info = FALSE)</a></code>.</p>
|
||||
<pre><code># ℹ Using column 'date' as input for `col_date`.</code></pre>
|
||||
<p>This text is only a printed summary - the actual result (output) of the function is a <code>data.frame</code> containing for each year: the number of observations, the actual observed resistance, the estimated resistance and the standard error below and above the estimation:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="va">predict_TZP</span>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">predict_TZP</span>
|
||||
<span class="co"># year value se_min se_max observations observed estimated</span>
|
||||
<span class="co"># 1 2002 0.20000000 NA NA 15 0.20000000 0.05616378</span>
|
||||
<span class="co"># 2 2003 0.06250000 NA NA 32 0.06250000 0.06163839</span>
|
||||
@ -267,30 +266,31 @@
|
||||
<span class="co"># 27 2028 0.43730688 0.3418075 0.5328063 NA NA 0.43730688</span>
|
||||
<span class="co"># 28 2029 0.46175755 0.3597639 0.5637512 NA NA 0.46175755</span>
|
||||
<span class="co"># 29 2030 0.48639359 0.3782932 0.5944939 NA NA 0.48639359</span>
|
||||
<span class="co"># 30 2031 0.51109592 0.3973697 0.6248221 NA NA 0.51109592</span></pre></div>
|
||||
<span class="co"># 30 2031 0.51109592 0.3973697 0.6248221 NA NA 0.51109592</span></code></pre></div>
|
||||
<p>The function <code>plot</code> is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-4-1.png" width="720"></p>
|
||||
<p>This is the fastest way to plot the result. It automatically adds the right axes, error bars, titles, number of available observations and type of model.</p>
|
||||
<p>We also support the <code>ggplot2</code> package with our custom function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> to create more appealing plots:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-5-1.png" width="720"></p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># choose for error bars instead of a ribbon</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span>, ribbon <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span>, ribbon <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-5-2.png" width="720"></p>
|
||||
<div id="choosing-the-right-model" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#choosing-the-right-model" class="anchor"></a>Choosing the right model</h3>
|
||||
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram-positive bacteria, the spread (i.e. standard error) is enormous:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">example_isolates</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_gramstain</a></span><span class="op">(</span><span class="va">mo</span>, language <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Gram-positive"</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span>col_ab <span class="op">=</span> <span class="st">"VAN"</span>, year_min <span class="op">=</span> <span class="fl">2010</span>, info <span class="op">=</span> <span class="cn">FALSE</span>, model <span class="op">=</span> <span class="st">"binomial"</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span>
|
||||
<span class="co"># ℹ Using column 'date' as input for `col_date`.</span></code></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-6-1.png" width="720"></p>
|
||||
<p>Vancomycin resistance could be 100% in ten years, but might also stay around 0%.</p>
|
||||
<p>You can define the model with the <code>model</code> parameter. The model chosen above is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.</p>
|
||||
@ -331,16 +331,17 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<p>For the vancomycin resistance in Gram-positive bacteria, a linear model might be more appropriate since no binomial distribution is to be expected based on the observed years:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit">
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">example_isolates</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_gramstain</a></span><span class="op">(</span><span class="va">mo</span>, language <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Gram-positive"</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span>col_ab <span class="op">=</span> <span class="st">"VAN"</span>, year_min <span class="op">=</span> <span class="fl">2010</span>, info <span class="op">=</span> <span class="cn">FALSE</span>, model <span class="op">=</span> <span class="st">"linear"</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span></pre></div>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span>
|
||||
<span class="co"># ℹ Using column 'date' as input for `col_date`.</span></code></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
|
||||
<p>This seems more likely, doesn’t it?</p>
|
||||
<p>The model itself is also available from the object, as an <code>attribute</code>:</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit">
|
||||
<span class="va">model</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/attributes.html">attributes</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span><span class="op">$</span><span class="va">model</span>
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">model</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/attributes.html">attributes</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span><span class="op">$</span><span class="va">model</span>
|
||||
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span><span class="op">$</span><span class="va">family</span>
|
||||
<span class="co"># </span>
|
||||
@ -350,7 +351,7 @@
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span><span class="op">$</span><span class="va">coefficients</span>
|
||||
<span class="co"># Estimate Std. Error z value Pr(>|z|)</span>
|
||||
<span class="co"># (Intercept) -200.67944891 46.17315349 -4.346237 1.384932e-05</span>
|
||||
<span class="co"># year 0.09883005 0.02295317 4.305725 1.664395e-05</span></pre></div>
|
||||
<span class="co"># year 0.09883005 0.02295317 4.305725 1.664395e-05</span></code></pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="fas fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
<span class="fas fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
<span class="fas fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
<span class="fas fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fa fa-database"></span>
|
||||
<span class="fas fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fa fa-compress"></span>
|
||||
<span class="fas fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
<span class="fas fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
<span class="fas fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
<span class="fas fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fa fa-book-open"></span>
|
||||
<span class="fas fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
<span class="fas fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
<span class="far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
<span class="fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@ -187,8 +187,7 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="welcome_to_AMR_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="welcome_to_AMR_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="welcome_to_AMR_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>Welcome to the AMR package</h1>
|
||||
|
@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||
var i, h, a;
|
||||
for (i = 0; i < hs.length; i++) {
|
||||
h = hs[i];
|
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes;
|
||||
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||
}
|
||||
});
|
@ -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.6.0.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -241,7 +241,7 @@ Antimicrobial Resistance Data. Journal of Statistical Software (accepted for pub
|
||||
<pre>@Article{,
|
||||
title = {AMR - An R Package for Working with Antimicrobial Resistance Data},
|
||||
author = {M S Berends and C F Luz and A W Friedrich and B N M Sinha and C J Albers and C Glasner},
|
||||
doi = {1.24720276528394e-05},
|
||||
doi = {10.1101/810622},
|
||||
journal = {Journal of Statistical Software},
|
||||
pages = {Accepted for publication},
|
||||
year = {2021},
|
||||
|
@ -222,6 +222,9 @@ table a:not(.btn) {
|
||||
table a:not(.btn):hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.template-article thead th {
|
||||
text-align: inherit;
|
||||
}
|
||||
|
||||
/* text below header in manual overview */
|
||||
.template-reference-index h2 ~ p {
|
||||
|
@ -42,7 +42,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.6.0.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -377,7 +377,7 @@
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#latest-released-version" class="anchor"></a>Latest released version</h4>
|
||||
<p><a href="https://cran.r-project.org/package=AMR"><img src="https://www.r-pkg.org/badges/version-ago/AMR" alt="CRAN"></a> <a href="https://cran.r-project.org/package=AMR"><img src="https://cranlogs.r-pkg.org/badges/grand-total/AMR" alt="CRANlogs"></a></p>
|
||||
<p>This package is available <a href="https://cran.r-project.org/package=AMR">here on the official R network (CRAN)</a>, which has a peer-reviewed submission process. Install this package in R from CRAN by using the command:</p>
|
||||
<p>This package is available <a href="https://cran.r-project.org/package=AMR">here on the official R network (CRAN)</a>. Install this package in R from CRAN by using the command:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"AMR"</span><span class="op">)</span></code></pre></div>
|
||||
<p>It will be downloaded and installed automatically. For RStudio, click on the menu <em>Tools</em> > <em>Install Packages…</em> and then type in “AMR” and press <kbd>Install</kbd>.</p>
|
||||
@ -386,11 +386,23 @@
|
||||
<div id="latest-development-version" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#latest-development-version" class="anchor"></a>Latest development version</h4>
|
||||
<p><img src="https://github.com/msberends/AMR/workflows/R-code-check/badge.svg?branch=master" alt="R-code-check"><a href="https://www.codefactor.io/repository/github/msberends/amr"><img src="https://www.codefactor.io/repository/github/msberends/amr/badge" alt="CodeFactor"></a> <a href="https://codecov.io/gh/msberends/AMR?branch=master"><img src="https://codecov.io/gh/msberends/AMR/branch/master/graph/badge.svg" alt="Codecov"></a></p>
|
||||
<p>The latest and unpublished development version can be installed from GitHub using:</p>
|
||||
<p><img src="https://github.com/msberends/AMR/workflows/R-code-check/badge.svg?branch=master" alt="R-code-check"><img src="https://www.codefactor.io/repository/github/msberends/amr" alt="CodeFactor"><img src="https://codecov.io/gh/msberends/AMR?branch=master" alt="Codecov"></p>
|
||||
<p>The latest and unpublished development version can be installed from GitHub in two ways:</p>
|
||||
<ol>
|
||||
<li>
|
||||
<p>Directly, using:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"remotes"</span><span class="op">)</span> <span class="co"># if you haven't already</span>
|
||||
<span class="fu">remotes</span><span class="fu">::</span><span class="fu"><a href="https://remotes.r-lib.org/reference/install_github.html">install_github</a></span><span class="op">(</span><span class="st">"msberends/AMR"</span><span class="op">)</span></code></pre></div>
|
||||
</li>
|
||||
<li>
|
||||
<p>From the <a href="https://ropensci.org/r-universe/">rOpenSci R-universe platform</a>, by adding <a href="https://msberends.r-universe.dev">our R-universe address</a> to your list of repositories (‘repos’):</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>repos <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="fu"><a href="https://rdrr.io/r/base/options.html">getOption</a></span><span class="op">(</span><span class="st">"repos"</span><span class="op">)</span>,
|
||||
msberends <span class="op">=</span> <span class="st">"https://msberends.r-universe.dev"</span><span class="op">)</span><span class="op">)</span></code></pre></div>
|
||||
<p>After this, you can install and update this <code>AMR</code> package like any official release (using <code><a href="https://rdrr.io/r/utils/install.packages.html">install.packages("AMR")</a></code> or in RStudio via <em>Tools</em> > <em>Check of Package Updates…</em>).</p>
|
||||
</li>
|
||||
</ol>
|
||||
<p>You can also download the latest build from our repository: <a href="https://github.com/msberends/AMR/raw/master/data-raw/AMR_latest.tar.gz" class="uri">https://github.com/msberends/AMR/raw/master/data-raw/AMR_latest.tar.gz</a></p>
|
||||
</div>
|
||||
</div>
|
||||
@ -411,7 +423,7 @@
|
||||
<div id="antimicrobial-reference-data" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#antimicrobial-reference-data" class="anchor"></a>Antimicrobial reference data</h4>
|
||||
<p>This package contains <strong>all ~550 antibiotic, antimycotic and antiviral drugs</strong> and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD, oral and IV) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, <a href="https://www.whocc.no" class="uri">https://www.whocc.no</a>) and the <a href="http://ec.europa.eu/health/documents/community-register/html/atc.htm">Pharmaceuticals Community Register of the European Commission</a>.</p>
|
||||
<p>This package contains <strong>all ~550 antibiotic, antimycotic and antiviral drugs</strong> and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD, oral and IV) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, <a href="https://www.whocc.no" class="uri">https://www.whocc.no</a>) and the <a href="https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm">Pharmaceuticals Community Register of the European Commission</a>.</p>
|
||||
<p><strong>NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package. See <a href="https://www.whocc.no/copyright_disclaimer/" class="uri">https://www.whocc.no/copyright_disclaimer/</a>.</strong></p>
|
||||
<p>Read more about the data from WHOCC <a href="./reference/WHOCC.html">in our manual</a>.</p>
|
||||
</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.6.0.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,19 +236,16 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1609056" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0.9056">
|
||||
<a href="#amr-1609056" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9056</h1>
|
||||
<div id="last-updated-21-may-2021" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-21-may-2021" class="anchor"></a><small>Last updated: 21 May 2021</small>
|
||||
</h2>
|
||||
<div id="amr-171" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.7.1">
|
||||
<a href="#amr-171" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.7.1</h1>
|
||||
<div id="breaking-change" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#breaking-change" class="anchor"></a>Breaking change</h3>
|
||||
<ul>
|
||||
<li><p>Support for CLSI 2020 guideline for interpreting MICs and disk diffusion values (using <code><a href="../reference/as.rsi.html">as.rsi()</a></code>)</p></li>
|
||||
<li>
|
||||
<p>All antibiotic class selectors (such as <code><a href="../reference/antibiotic_class_selectors.html">carbapenems()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>) can now be used for filtering as well, making all their accompanying <code>filter_*()</code> functions redundant (such as <code><a href="../reference/AMR-deprecated.html">filter_carbapenems()</a></code>, <code><a href="../reference/AMR-deprecated.html">filter_aminoglycosides()</a></code>). These functions are now deprecated and will be removed in a next release.</p>
|
||||
<p>All antibiotic class selectors (such as <code><a href="../reference/antibiotic_class_selectors.html">carbapenems()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>) can now be used for filtering as well, making all their accompanying <code>filter_*()</code> functions redundant (such as <code><a href="../reference/AMR-deprecated.html">filter_carbapenems()</a></code>, <code><a href="../reference/AMR-deprecated.html">filter_aminoglycosides()</a></code>). These functions are now deprecated and will be removed in a next release. Examples of how the selectors can be used for filtering:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># select columns with results for carbapenems</span>
|
||||
@ -296,6 +293,8 @@
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> now supports grouping using the <code>dplyr</code> package</li>
|
||||
<li>Custom MDRO guidelines (<code><a href="../reference/mdro.html">mdro()</a></code>, <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code>):
|
||||
<ul>
|
||||
<li>Custom MDRO guidelines can now be combined with other custom MDRO guidelines using <code><a href="https://rdrr.io/r/base/c.html">c()</a></code>
|
||||
@ -335,16 +334,19 @@
|
||||
<li>Antibiotic class selectors (such as <code><a href="../reference/antibiotic_class_selectors.html">cephalosporins()</a></code>) now maintain the column order from the original data</li>
|
||||
<li>Fix for selecting columns using <code><a href="../reference/antibiotic_class_selectors.html">fluoroquinolones()</a></code>
|
||||
</li>
|
||||
<li>
|
||||
<code><a href="../reference/age.html">age()</a></code> now vectorises over both <code>x</code> and <code>reference</code>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="other" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#other" class="anchor"></a>Other</h3>
|
||||
<ul>
|
||||
<li>As requested by CRAN administrators: decreased package size by 3 MB in costs of a slower loading time of the package</li>
|
||||
<li>All unit tests are now processed by the <code>tinytest</code> package, instead of the <code>testthat</code> package. The <code>testthat</code> package unfortunately requires tons of dependencies that are also heavy and only usable for recent R versions, disallowing developers to test a package under any R 3.* version. On the contrary, the <code>tinytest</code> package is very lightweight and dependency-free.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="amr-160" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0">
|
||||
@ -1574,7 +1576,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</ul>
|
||||
</li>
|
||||
<li>Removed data sets <code>microorganisms.oldDT</code>, <code>microorganisms.prevDT</code>, <code>microorganisms.unprevDT</code> and <code>microorganismsDT</code> since they were no longer needed and only contained info already available in the <code>microorganisms</code> data set</li>
|
||||
<li>Added 65 antibiotics to the <code>antibiotics</code> data set, from the <a href="http://ec.europa.eu/health/documents/community-register/html/atc.htm">Pharmaceuticals Community Register</a> of the European Commission</li>
|
||||
<li>Added 65 antibiotics to the <code>antibiotics</code> data set, from the <a href="https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm">Pharmaceuticals Community Register</a> of the European Commission</li>
|
||||
<li>Removed columns <code>atc_group1_nl</code> and <code>atc_group2_nl</code> from the <code>antibiotics</code> data set</li>
|
||||
<li>Functions <code>atc_ddd()</code> and <code>atc_groups()</code> have been renamed <code><a href="../reference/atc_online_property.html">atc_online_ddd()</a></code> and <code><a href="../reference/atc_online_property.html">atc_online_groups()</a></code>. The old functions are deprecated and will be removed in a future version.</li>
|
||||
<li>Function <code>guess_mo()</code> is now deprecated in favour of <code><a href="../reference/as.mo.html">as.mo()</a></code> and will be removed in future versions</li>
|
||||
|
@ -1,4 +1,4 @@
|
||||
pandoc: 2.11.2
|
||||
pandoc: 2.11.4
|
||||
pkgdown: 1.6.1
|
||||
pkgdown_sha: ~
|
||||
articles:
|
||||
@ -12,7 +12,7 @@ articles:
|
||||
datasets: datasets.html
|
||||
resistance_predict: resistance_predict.html
|
||||
welcome_to_AMR: welcome_to_AMR.html
|
||||
last_built: 2021-05-21T18:27Z
|
||||
last_built: 2021-06-03T13:04Z
|
||||
urls:
|
||||
reference: https://msberends.github.io/AMR//reference
|
||||
article: https://msberends.github.io/AMR//articles
|
||||
|
@ -82,7 +82,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.6.0.9055</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -431,7 +431,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>retired</
|
||||
|
||||
|
||||
|
||||
<p>On our website <a href='https://msberends.github.io/AMR/'>https://msberends.github.io/AMR/</a> you can find <a href='https://msberends.github.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR data analysis, the <a href='https://msberends.github.io/AMR/reference/'>complete documentation of all functions</a> and <a href='https://msberends.github.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>. As we would like to better understand the backgrounds and needs of our users, please <a href='https://msberends.github.io/AMR/survey.html'>participate in our survey</a>!</p>
|
||||
<p>On our website <a href='https://msberends.github.io/AMR/'>https://msberends.github.io/AMR/</a> you can find <a href='https://msberends.github.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR data analysis, the <a href='https://msberends.github.io/AMR/reference/'>complete documentation of all functions</a> and <a href='https://msberends.github.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
|
||||
|