Compare commits
No files matched your search
@@ -50,38 +50,32 @@ 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: windows-latest, r: 'devel', allowfail: true}
|
||||
- {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: macOS-latest, r: 'oldrel', allowfail: false}
|
||||
|
||||
- {os: windows-latest, r: 'devel', allowfail: false}
|
||||
- {os: windows-latest, r: 'release', allowfail: false}
|
||||
- {os: windows-latest, r: 'oldrel', allowfail: false}
|
||||
|
||||
- {os: ubuntu-20.04, r: 'devel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
|
||||
# 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"}
|
||||
- {os: ubuntu-20.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.3', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
# - {os: ubuntu-20.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
# - {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.2', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.1', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
|
||||
- {os: ubuntu-16.04, r: 'devel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: 'oldrel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '4.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.3', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
# - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
# - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
|
||||
|
||||
env:
|
||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||
RSPM: ${{ matrix.config.rspm }}
|
||||
@@ -89,93 +83,77 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r@master
|
||||
- uses: r-lib/actions/setup-r@v1
|
||||
with:
|
||||
r-version: ${{ matrix.config.r }}
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@master
|
||||
|
||||
- name: Query dependencies
|
||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
||||
- name: Install Linux dependencies
|
||||
if: runner.os == 'Linux'
|
||||
# update the below with sysreqs::sysreqs("DESCRIPTION") and check the "DEB" entries (for Ubuntu).
|
||||
# we don't want to depend on the sysreqs pkg here, as it requires quite a recent R version
|
||||
# as of May 2021: https://sysreqs.r-hub.io/pkg/AMR,R,cleaner,curl,dplyr,ggplot2,ggtext,knitr,microbenchmark,pillar,readxl,rmarkdown,rstudioapi,rvest,skimr,tidyr,tinytest,xml2,backports,crayon,rlang,vctrs,evaluate,highr,markdown,stringr,yaml,xfun,cli,ellipsis,fansi,lifecycle,utf8,glue,mime,magrittr,stringi,generics,R6,tibble,tidyselect,pkgconfig,purrr,digest,gtable,isoband,MASS,mgcv,scales,withr,nlme,Matrix,farver,labeling,munsell,RColorBrewer,viridisLite,lattice,colorspace,gridtext,Rcpp,RCurl,png,jpeg,bitops,cellranger,progress,rematch,hms,prettyunits,htmltools,jsonlite,tinytex,base64enc,httr,selectr,openssl,askpass,sys,repr,cpp11
|
||||
run: |
|
||||
install.packages('remotes')
|
||||
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
|
||||
shell: Rscript {0}
|
||||
sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev libpng-dev
|
||||
|
||||
- name: Cache R packages
|
||||
if: runner.os != 'Windows' && matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
||||
- name: Restore cached R packages
|
||||
# this step will add the step 'Post Restore cached R packages' on a succesful run
|
||||
if: runner.os != 'Windows'
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ env.R_LIBS_USER }}
|
||||
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3-${{ hashFiles('.github/depends.Rds') }}
|
||||
restore-keys: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3-
|
||||
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: runner.os == 'Linux' && matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
||||
env:
|
||||
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
|
||||
- name: Unpack AMR and install R dependencies
|
||||
if: always()
|
||||
run: |
|
||||
Rscript -e "remotes::install_github('r-hub/sysreqs')"
|
||||
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
|
||||
sudo -s eval "$sysreqs"
|
||||
|
||||
- name: Install Linux dependencies on old R versions
|
||||
if: matrix.config.r == '3.0' || matrix.config.r == '3.1' || matrix.config.r == '3.2'
|
||||
env:
|
||||
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
|
||||
# update the below with sysreqs::sysreqs("DESCRIPTION") and check the "DEB" entries (for Ubuntu).
|
||||
# we don't want to depend on the sysreqs pkg here, as it requires a quite new R version
|
||||
run: |
|
||||
sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev
|
||||
|
||||
- name: Install macOS dependencies
|
||||
if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'devel'
|
||||
run: |
|
||||
brew install mariadb-connector-c
|
||||
|
||||
- name: Install package dependencies
|
||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
||||
run: |
|
||||
remotes::install_deps(dependencies = TRUE)
|
||||
remotes::install_cran("rcmdcheck")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Session info
|
||||
tar -xf data-raw/AMR_latest.tar.gz
|
||||
Rscript -e "source('data-raw/_install_deps.R')"
|
||||
shell: bash
|
||||
|
||||
- name: Show session info
|
||||
if: always()
|
||||
run: |
|
||||
options(width = 100)
|
||||
utils::sessionInfo()
|
||||
as.data.frame(utils::installed.packages())[, "Version", drop = FALSE]
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Run R CMD check
|
||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
||||
env:
|
||||
_R_CHECK_CRAN_INCOMING_: false
|
||||
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
||||
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Run R CMD check on older R versions
|
||||
if: matrix.config.r == '3.0' || matrix.config.r == '3.1' || matrix.config.r == '3.2'
|
||||
# - 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
|
||||
Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[!grepl('VignetteBuilder', readLines('AMR/DESCRIPTION'))], 'AMR/DESCRIPTION2')"
|
||||
rm AMR/DESCRIPTION
|
||||
mv AMR/DESCRIPTION2 AMR/DESCRIPTION
|
||||
shell: bash
|
||||
|
||||
- name: Run R CMD check
|
||||
if: always()
|
||||
env:
|
||||
_R_CHECK_CRAN_INCOMING_: false
|
||||
_R_CHECK_FORCE_SUGGESTS_: false
|
||||
_R_CHECK_DEPENDS_ONLY_: true
|
||||
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
||||
# during 'R CMD check', R_LIBS_USER will be overwritten, so:
|
||||
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
|
||||
R_RUN_TINYTEST: true
|
||||
run: |
|
||||
tar -xvf data-raw/AMR_latest.tar.gz
|
||||
R CMD check AMR --no-manual --no-build-vignettes
|
||||
|
||||
- name: Show testthat output
|
||||
if: always()
|
||||
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
|
||||
R CMD check --no-manual --run-donttest --run-dontrun AMR
|
||||
shell: bash
|
||||
|
||||
- name: Upload check results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@master
|
||||
- name: Show unit tests output
|
||||
if: always()
|
||||
run: |
|
||||
find . -name 'tinytest.Rout*' -exec cat '{}' \; || true
|
||||
shell: bash
|
||||
|
||||
- name: Upload artifacts
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
|
||||
path: check
|
||||
name: artifacts-${{ matrix.config.os }}-r${{ matrix.config.r }}
|
||||
path: AMR.Rcheck
|
||||
@@ -26,6 +26,7 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- premaster
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
@@ -41,31 +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-v4
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Unpack AMR and install R dependencies
|
||||
run: |
|
||||
install.packages(c("remotes"))
|
||||
remotes::install_deps(dependencies = TRUE)
|
||||
remotes::install_cran("covr")
|
||||
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
|
||||
run: 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"), quiet = FALSE)
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
R_RUN_TINYTEST: true
|
||||
run: |
|
||||
library(AMR)
|
||||
library(tinytest)
|
||||
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.9020
|
||||
Date: 2021-05-06
|
||||
Version: 1.7.0
|
||||
Date: 2021-05-26
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
@@ -43,9 +43,11 @@ Depends:
|
||||
R (>= 3.0.0)
|
||||
Suggests:
|
||||
cleaner,
|
||||
covr,
|
||||
curl,
|
||||
dplyr,
|
||||
ggplot2,
|
||||
ggtext,
|
||||
knitr,
|
||||
microbenchmark,
|
||||
pillar,
|
||||
@@ -54,8 +56,8 @@ Suggests:
|
||||
rstudioapi,
|
||||
rvest,
|
||||
skimr,
|
||||
testthat,
|
||||
tidyr,
|
||||
tinytest,
|
||||
xml2
|
||||
VignetteBuilder: knitr,rmarkdown
|
||||
URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Generated by roxygen2: do not edit by hand
|
||||
|
||||
S3method("!",mic)
|
||||
S3method("!=",ab_selector)
|
||||
S3method("!=",mic)
|
||||
S3method("%%",mic)
|
||||
S3method("%/%",mic)
|
||||
@@ -11,6 +12,7 @@ S3method("-",mic)
|
||||
S3method("/",mic)
|
||||
S3method("<",mic)
|
||||
S3method("<=",mic)
|
||||
S3method("==",ab_selector)
|
||||
S3method("==",mic)
|
||||
S3method(">",mic)
|
||||
S3method(">=",mic)
|
||||
@@ -37,7 +39,11 @@ S3method("|",mic)
|
||||
S3method(abs,mic)
|
||||
S3method(acos,mic)
|
||||
S3method(acosh,mic)
|
||||
S3method(all,ab_selector)
|
||||
S3method(all,ab_selector_any_all)
|
||||
S3method(all,mic)
|
||||
S3method(any,ab_selector)
|
||||
S3method(any,ab_selector_any_all)
|
||||
S3method(any,mic)
|
||||
S3method(as.data.frame,ab)
|
||||
S3method(as.data.frame,mo)
|
||||
@@ -59,6 +65,7 @@ S3method(barplot,disk)
|
||||
S3method(barplot,mic)
|
||||
S3method(barplot,rsi)
|
||||
S3method(c,ab)
|
||||
S3method(c,ab_selector)
|
||||
S3method(c,custom_eucast_rules)
|
||||
S3method(c,custom_mdro_guideline)
|
||||
S3method(c,disk)
|
||||
@@ -174,6 +181,7 @@ export(atc_online_ddd)
|
||||
export(atc_online_groups)
|
||||
export(atc_online_property)
|
||||
export(availability)
|
||||
export(betalactams)
|
||||
export(brmo)
|
||||
export(bug_drug_combinations)
|
||||
export(carbapenems)
|
||||
@@ -206,6 +214,7 @@ export(filter_4th_cephalosporins)
|
||||
export(filter_5th_cephalosporins)
|
||||
export(filter_ab_class)
|
||||
export(filter_aminoglycosides)
|
||||
export(filter_betalactams)
|
||||
export(filter_carbapenems)
|
||||
export(filter_cephalosporins)
|
||||
export(filter_first_isolate)
|
||||
|
||||
@@ -1,16 +1,38 @@
|
||||
# `AMR` 1.6.0.9020
|
||||
## <small>Last updated: 6 May 2021</small>
|
||||
# `AMR` 1.7.0
|
||||
|
||||
|
||||
### 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.
|
||||
```r
|
||||
# select columns with results for carbapenems
|
||||
example_isolates[, carbapenems()] # base R
|
||||
example_isolates %>% select(carbapenems()) # dplyr
|
||||
|
||||
# filter rows for resistance in any carbapenem
|
||||
example_isolates[any(carbapenems() == "R"), ] # base R
|
||||
example_isolates %>% filter(any(carbapenems() == "R")) # dplyr
|
||||
example_isolates %>% filter(if_any(carbapenems(), ~.x == "R")) # dplyr (formal)
|
||||
|
||||
# filter rows for resistance in all carbapenems
|
||||
example_isolates[all(carbapenems() == "R"), ] # base R
|
||||
example_isolates[carbapenems() == "R", ]
|
||||
example_isolates %>% filter(all(carbapenems() == "R")) # dplyr
|
||||
example_isolates %>% filter(carbapenems() == "R")
|
||||
```
|
||||
|
||||
### New
|
||||
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
||||
* Function `italicise_taxonomy()` to make taxonomic names within a string italic, with support for markdown and ANSI
|
||||
* Support for all four methods to determine first isolates as summarised by Hindler *et al.* (doi: [10.1086/511864](https://doi.org/10.1086/511864)): isolate-based, patient-based, episode-based and phenotype-based. The last method is now the default.
|
||||
* The `first_isolate()` function gained the argument `method` that has to be "phenotype-based", "episode-based", "patient-based", or "isolate-based". The old behaviour is equal to "episode-based". The new default is "phenotype-based" if antimicrobial test results are available, and "episode-based" otherwise. This new default will yield slightly more isolates for selection (which is a good thing).
|
||||
* Since fungal isolates can also be selected, the functions `key_antibiotics()` and `key_antibiotics_equal()` are now deprecated in favour of the `key_antimicrobials()` and `antimicrobial_equal()` functions. Also, the new `all_antimicrobials()` function works like the old `key_antibiotics()` function, but includes any column with antimicrobial test results. Using `key_antimicrobials()` still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new `antifungal` argument to set antifungal agents (antimycotics).
|
||||
* Since fungal isolates can also be selected, the functions `key_antibiotics()` and `key_antibiotics_equal()` are now deprecated in favour of the `key_antimicrobials()` and `antimicrobials_equal()` functions. Also, the new `all_antimicrobials()` function works like the old `key_antibiotics()` function, but includes any column with antimicrobial test results. Using `key_antimicrobials()` still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new `antifungal` argument to set antifungal agents (antimycotics).
|
||||
* Using `type == "points"` in the `first_isolate()` function for phenotype-based selection will now consider all antimicrobial drugs in the data set, using the new `all_antimicrobials()`
|
||||
* The `first_isolate()` function can now take a vector of values for `col_keyantibiotics` and can have an episode length of `Inf`
|
||||
* Since the phenotype-based method is the new default, `filter_first_isolate()` renders the `filter_first_weighted_isolate()` function redundant. For this reason, `filter_first_weighted_isolate()` is now deprecated.
|
||||
* The documentation of the `first_isolate()` and `key_antimicrobials()` functions has been completely rewritten.
|
||||
* Function `betalactams()` as additional antbiotic column selector and function `filter_betalactams()` as additional antbiotic column filter. The group of betalactams consists of all carbapenems, cephalosporins and penicillins.
|
||||
* A `ggplot()` method for `resistance_predict()`
|
||||
|
||||
|
||||
### Changed
|
||||
* Custom MDRO guidelines (`mdro()`, `custom_mdro_guideline()`):
|
||||
@@ -31,12 +53,21 @@
|
||||
* Altered the RStudio addin, so it now iterates over `%like%` -> `%unlike%` -> `%like_case%` -> `%unlike_case%` if you keep pressing your keyboard shortcut
|
||||
* Fixed an installation error on R-3.0
|
||||
* Added `info` argument to `as.mo()` to turn on/off the progress bar
|
||||
* Fixed a bug that `col_mo` for some functions (esp. `eucast_rules()` and `mdro()`) could not be column names of the `microorganisms` data set as it would throw an error
|
||||
* Fixed a bug where `col_mo` in some functions (esp. `eucast_rules()` and `mdro()`) could not be a column name of the `microorganisms` data set as it would throw an error
|
||||
* Fix for transforming numeric values to RSI (`as.rsi()`) when the `vctrs` package is loaded (i.e., when using tidyverse)
|
||||
* Colour fix for using `barplot()` on an RSI class
|
||||
* Added 25 common system codes for bacteria to the `microorganisms.codes` data set
|
||||
* Added 16 common system codes for antimicrobial agents to the `antibiotics` data set
|
||||
* Fix for using `skimr::skim()` on classes `mo`, `mic` and `disk` when using the just released `dplyr` v1.0.6
|
||||
* Updated `skimr::skim()` usage for MIC values to also include 25th and 75th percentiles
|
||||
* Fix for plotting missing MIC/disk diffusion values
|
||||
* 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
|
||||
* 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.
|
||||
|
||||
|
||||
# `AMR` 1.6.0
|
||||
@@ -875,7 +906,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
|
||||
|
||||
@@ -192,7 +192,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]
|
||||
}
|
||||
@@ -290,6 +290,15 @@ stop_ifnot_installed <- function(package) {
|
||||
return(invisible())
|
||||
}
|
||||
|
||||
pkg_is_available <- function(pkg, also_load = TRUE) {
|
||||
if (also_load == TRUE) {
|
||||
out <- suppressWarnings(require(pkg, character.only = TRUE, warn.conflicts = FALSE, quietly = TRUE))
|
||||
} else {
|
||||
out <- requireNamespace(pkg, quietly = TRUE)
|
||||
}
|
||||
isTRUE(out)
|
||||
}
|
||||
|
||||
import_fn <- function(name, pkg, error_on_fail = TRUE) {
|
||||
if (isTRUE(error_on_fail)) {
|
||||
stop_ifnot_installed(pkg)
|
||||
@@ -321,9 +330,7 @@ word_wrap <- function(...,
|
||||
msg <- paste0(c(...), collapse = "")
|
||||
|
||||
if (isTRUE(as_note)) {
|
||||
# \u2139 is a symbol officially named 'information source'
|
||||
# \ufe0f can add the blue square around it: \u2139\ufe0f
|
||||
msg <- paste0("\u2139 ", gsub("^note:? ?", "", msg, ignore.case = TRUE))
|
||||
msg <- paste0(pkg_env$info_icon, " ", gsub("^note:? ?", "", msg, ignore.case = TRUE))
|
||||
}
|
||||
|
||||
if (msg %like% "\n") {
|
||||
@@ -338,6 +345,9 @@ word_wrap <- function(...,
|
||||
collapse = "\n"))
|
||||
}
|
||||
|
||||
# correct for operators (will add the space later on)
|
||||
ops <- "([,./><\\]\\[])"
|
||||
msg <- gsub(paste0(ops, " ", ops), "\\1\\2", msg, perl = TRUE)
|
||||
# we need to correct for already applied style, that adds text like "\033[31m\"
|
||||
msg_stripped <- font_stripstyle(msg)
|
||||
# where are the spaces now?
|
||||
@@ -354,6 +364,8 @@ word_wrap <- function(...,
|
||||
# put it together
|
||||
msg <- unlist(strsplit(msg, " "))
|
||||
msg[replace_spaces] <- paste0(msg[replace_spaces], "\n")
|
||||
# add space around operators again
|
||||
msg <- gsub(paste0(ops, ops), "\\1 \\2", msg, perl = TRUE)
|
||||
msg <- paste0(msg, collapse = " ")
|
||||
msg <- gsub("\n ", "\n", msg, fixed = TRUE)
|
||||
|
||||
@@ -367,7 +379,7 @@ word_wrap <- function(...,
|
||||
msg <- gsub("\n", paste0("\n", strrep(" ", indentation)), msg, fixed = TRUE)
|
||||
# remove trailing empty characters
|
||||
msg <- gsub("(\n| )+$", "", msg)
|
||||
|
||||
|
||||
if (length(add_fn) > 0) {
|
||||
if (!is.list(add_fn)) {
|
||||
add_fn <- list(add_fn)
|
||||
@@ -495,14 +507,30 @@ dataset_UTF8_to_ASCII <- function(df) {
|
||||
}
|
||||
|
||||
# for eucast_rules() and mdro(), creates markdown output with URLs and names
|
||||
create_ab_documentation <- function(ab) {
|
||||
create_eucast_ab_documentation <- function() {
|
||||
x <- trimws(unique(toupper(unlist(strsplit(eucast_rules_file$then_change_these_antibiotics, ",")))))
|
||||
ab <- character()
|
||||
for (val in x) {
|
||||
if (val %in% ls(envir = asNamespace("AMR"))) {
|
||||
# antibiotic group names, as defined in data-raw/_internals.R, such as `CARBAPENEMS`
|
||||
val <- eval(parse(text = val), envir = asNamespace("AMR"))
|
||||
} else if (val %in% AB_lookup$ab) {
|
||||
# separate drugs, such as `AMX`
|
||||
val <- as.ab(val)
|
||||
} else {
|
||||
val <- as.rsi(NA)
|
||||
}
|
||||
ab <- c(ab, val)
|
||||
}
|
||||
ab <- unique(ab)
|
||||
atcs <- ab_atc(ab)
|
||||
# only keep ABx with an ATC code:
|
||||
ab <- ab[!is.na(atcs)]
|
||||
ab_names <- ab_name(ab, language = NULL, tolower = TRUE)
|
||||
ab <- ab[order(ab_names)]
|
||||
ab_names <- ab_names[order(ab_names)]
|
||||
atcs <- ab_atc(ab)
|
||||
atcs[!is.na(atcs)] <- paste0("[", atcs[!is.na(atcs)], "](", ab_url(ab[!is.na(atcs)]), ")")
|
||||
atcs[is.na(atcs)] <- "no ATC code"
|
||||
out <- paste0(ab_names, " (`", ab, "`, ", atcs, ")", collapse = ", ")
|
||||
atc_txt <- paste0("[", atcs[!is.na(atcs)], "](", ab_url(ab), ")")
|
||||
out <- paste0(ab_names, " (`", ab, "`, ", atc_txt, ")", collapse = ", ")
|
||||
substr(out, 1, 1) <- toupper(substr(out, 1, 1))
|
||||
out
|
||||
}
|
||||
@@ -539,7 +567,7 @@ vector_and <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE) {
|
||||
vector_or(v = v, quotes = quotes, reverse = reverse, sort = sort, last_sep = " and ")
|
||||
}
|
||||
|
||||
format_class <- function(class, plural) {
|
||||
format_class <- function(class, plural = FALSE) {
|
||||
class.bak <- class
|
||||
class[class == "numeric"] <- "number"
|
||||
class[class == "integer"] <- "whole number"
|
||||
@@ -553,9 +581,7 @@ format_class <- function(class, plural) {
|
||||
ifelse(plural, "s", ""))
|
||||
# exceptions
|
||||
class[class == "logical"] <- ifelse(plural, "a vector of `TRUE`/`FALSE`", "`TRUE` or `FALSE`")
|
||||
if ("data.frame" %in% class) {
|
||||
class <- "a data set"
|
||||
}
|
||||
class[class == "data.frame"] <- "a data set"
|
||||
if ("list" %in% class) {
|
||||
class <- "a list"
|
||||
}
|
||||
@@ -642,9 +668,10 @@ meet_criteria <- function(object,
|
||||
object <- tolower(object)
|
||||
is_in <- tolower(is_in)
|
||||
}
|
||||
stop_ifnot(all(object %in% is_in, na.rm = TRUE), "argument `", obj_name,
|
||||
"` must be ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1, "either ", ""),
|
||||
stop_ifnot(all(object %in% is_in, na.rm = TRUE), "argument `", obj_name, "` ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"must be either ",
|
||||
"must only contain values "),
|
||||
vector_or(is_in, quotes = !isTRUE(any(c("double", "numeric", "integer") %in% allow_class))),
|
||||
ifelse(allow_NA == TRUE, ", or NA", ""),
|
||||
call = call_depth)
|
||||
@@ -689,6 +716,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
|
||||
@@ -696,11 +728,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)) {
|
||||
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 (as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 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.
|
||||
@@ -714,6 +749,7 @@ get_current_data <- function(arg_name, call) {
|
||||
|
||||
# try a (base R) method, by going over the complete system call stack with sys.frames()
|
||||
not_set <- TRUE
|
||||
source <- "base_R"
|
||||
frms <- lapply(sys.frames(), function(el) {
|
||||
if (not_set == TRUE && ".Generic" %in% names(el)) {
|
||||
if (tryCatch(".data" %in% names(el) && is.data.frame(el$`.data`), error = function(e) FALSE)) {
|
||||
@@ -723,6 +759,7 @@ get_current_data <- function(arg_name, call) {
|
||||
# an element `.data` will be in the system call stack when using dplyr::select()
|
||||
# [but not when using dplyr::filter(), dplyr::mutate() or dplyr::summarise()]
|
||||
not_set <<- FALSE
|
||||
source <<- "dplyr_selector"
|
||||
el$`.data`
|
||||
} else if (tryCatch(any(c("x", "xx") %in% names(el)), error = function(e) FALSE)) {
|
||||
# - - - -
|
||||
@@ -750,7 +787,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(vars_df)
|
||||
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:
|
||||
@@ -824,8 +864,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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,14 +886,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
|
||||
|
||||
@@ -864,7 +901,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)) &&
|
||||
@@ -1085,7 +1122,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)
|
||||
@@ -1130,11 +1167,14 @@ percentage <- function(x, digits = NULL, ...) {
|
||||
if (is.null(digits)) {
|
||||
digits <- getdecimalplaces(x)
|
||||
}
|
||||
if (is.null(digits) || is.na(digits) || !is.numeric(digits)) {
|
||||
digits <- 2
|
||||
}
|
||||
|
||||
# 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, "%")
|
||||
@@ -1154,15 +1194,15 @@ 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)")
|
||||
paste("(until now:", trimws(round(as.double(Sys.time()) * 1000) - pkg_env$time_start), "ms)")
|
||||
}
|
||||
|
||||
# prevent dependency on package 'backports' ----
|
||||
# these functions were not available in previous versions of R (last checked: R 4.0.5)
|
||||
# these functions were not available in previous versions of R (last checked: R 4.1.0)
|
||||
# see here for the full list: https://github.com/r-lib/backports
|
||||
strrep <- function(x, times) {
|
||||
x <- as.character(x)
|
||||
@@ -1176,14 +1216,13 @@ strrep <- function(x, times) {
|
||||
paste0(replicate(times, x), collapse = "")
|
||||
}, list(x = x, times = times), MoreArgs = list()), use.names = FALSE)
|
||||
}
|
||||
trimws <- function(x, which = c("both", "left", "right")) {
|
||||
trimws <- function(x, which = c("both", "left", "right"), whitespace = "[ \t\r\n]") {
|
||||
which <- match.arg(which)
|
||||
mysub <- function(re, x) sub(re, "", x, perl = TRUE)
|
||||
if (which == "left")
|
||||
return(mysub("^[ \t\r\n]+", x))
|
||||
if (which == "right")
|
||||
return(mysub("[ \t\r\n]+$", x))
|
||||
mysub("[ \t\r\n]+$", mysub("^[ \t\r\n]+", x))
|
||||
switch(which,
|
||||
left = mysub(paste0("^", whitespace, "+"), x),
|
||||
right = mysub(paste0(whitespace, "+$"), x),
|
||||
both = mysub(paste0(whitespace, "+$"), mysub(paste0("^", whitespace, "+"), x)))
|
||||
}
|
||||
isFALSE <- function(x) {
|
||||
is.logical(x) && length(x) == 1L && !is.na(x) && !x
|
||||
@@ -1210,10 +1249,14 @@ lengths <- function(x, use.names = TRUE) {
|
||||
vapply(x, length, FUN.VALUE = NA_integer_, USE.NAMES = use.names)
|
||||
}
|
||||
|
||||
if (as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 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
|
||||
sinpi <- function(...) 1
|
||||
tanpi <- function(...) 1
|
||||
}
|
||||
dir.exists <- function (paths) {
|
||||
x = base::file.info(paths)$isdir
|
||||
!is.na(x) & x
|
||||
}
|
||||
@@ -27,8 +27,8 @@
|
||||
#'
|
||||
#' Use this function to determine the antibiotic code of one or more antibiotics. The data set [antibiotics] will be searched for abbreviations, official names and synonyms (brand names).
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x character vector to determine to antibiotic ID
|
||||
#' @param flag_multiple_results logical to indicate whether a note should be printed to the console that probably more than one antibiotic code or name can be retrieved from a single input value.
|
||||
#' @param x a [character] vector to determine to antibiotic ID
|
||||
#' @param flag_multiple_results a [logical] to indicate whether a note should be printed to the console that probably more than one antibiotic code or name can be retrieved from a single input value.
|
||||
#' @param info a [logical] to indicate whether a progress bar should be printed, defaults to `TRUE` only in interactive mode
|
||||
#' @param ... arguments passed on to internal functions
|
||||
#' @rdname as.ab
|
||||
@@ -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,15 +25,19 @@
|
||||
|
||||
#' Antibiotic Class Selectors
|
||||
#'
|
||||
#' These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \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 only_rsi_columns a logical to indicate whether only columns of class `<rsi>` must be selected (defaults to `FALSE`), see [as.rsi()]
|
||||
#' @inheritParams filter_ab_class
|
||||
#' @details \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}}
|
||||
#' @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(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, "."), "")}}
|
||||
#'
|
||||
#' All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the [antibiotics] data set. This means that a selector like e.g. [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
|
||||
#'
|
||||
#' 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()].
|
||||
#'
|
||||
#' All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) in the [antibiotics] data set. This means that a selector like e.g. [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
|
||||
#'
|
||||
#' The group of betalactams consists of all carbapenems, cephalosporins and penicillins.
|
||||
#' @rdname antibiotic_class_selectors
|
||||
#' @seealso [filter_ab_class()] for the `filter()` equivalent.
|
||||
#' @name antibiotic_class_selectors
|
||||
#' @export
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
@@ -42,11 +46,31 @@
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||
#' # Base R ------------------------------------------------------------------
|
||||
#'
|
||||
#' # select columns 'IPM' (imipenem) and 'MEM' (meropenem)
|
||||
#' example_isolates[, carbapenems()]
|
||||
#' # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
|
||||
#'
|
||||
#' # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
|
||||
#' example_isolates[, c("mo", aminoglycosides())]
|
||||
#'
|
||||
#' # filter using any() or all()
|
||||
#' example_isolates[any(carbapenems() == "R"), ]
|
||||
#' subset(example_isolates, any(carbapenems() == "R"))
|
||||
#'
|
||||
#' # filter on any or all results in the carbapenem columns (i.e., IPM, MEM):
|
||||
#' example_isolates[any(carbapenems()), ]
|
||||
#' example_isolates[all(carbapenems()), ]
|
||||
#'
|
||||
#' # filter with multiple antibiotic selectors using c()
|
||||
#' example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]
|
||||
#'
|
||||
#' # filter + select in one go: get penicillins in carbapenems-resistant strains
|
||||
#' example_isolates[any(carbapenems() == "R"), penicillins()]
|
||||
#'
|
||||
#'
|
||||
#' # dplyr -------------------------------------------------------------------
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||
@@ -57,6 +81,20 @@
|
||||
#' example_isolates %>%
|
||||
#' select(mo, aminoglycosides())
|
||||
#'
|
||||
#' # any() and all() work in dplyr's filter() too:
|
||||
#' example_isolates %>%
|
||||
#' filter(any(aminoglycosides() == "R"),
|
||||
#' all(cephalosporins_2nd() == "R"))
|
||||
#'
|
||||
#' # also works with c():
|
||||
#' example_isolates %>%
|
||||
#' filter(any(c(carbapenems(), aminoglycosides()) == "R"))
|
||||
#'
|
||||
#' # not setting any/all will automatically apply all():
|
||||
#' example_isolates %>%
|
||||
#' filter(aminoglycosides() == "R")
|
||||
#' #> i Assuming a filter on all 4 aminoglycosides.
|
||||
#'
|
||||
#' # this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
|
||||
#' example_isolates %>%
|
||||
#' select(mo, ab_class("mycobact"))
|
||||
@@ -75,10 +113,12 @@
|
||||
#' select(penicillins()) # only the 'J01CA01' column will be selected
|
||||
#'
|
||||
#'
|
||||
#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
|
||||
#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal:
|
||||
#' # (though the row names on the first are more correct)
|
||||
#' example_isolates %>% filter_carbapenems("R", "all")
|
||||
#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
|
||||
#' example_isolates[carbapenems() == "R", ]
|
||||
#' example_isolates %>% filter(carbapenems() == "R")
|
||||
#' example_isolates %>% filter(across(carbapenems(), ~.x == "R"))
|
||||
#' }
|
||||
#' }
|
||||
ab_class <- function(ab_class,
|
||||
only_rsi_columns = FALSE) {
|
||||
@@ -91,6 +131,11 @@ aminoglycosides <- function(only_rsi_columns = FALSE) {
|
||||
ab_selector("aminoglycoside", function_name = "aminoglycosides", only_rsi_columns = only_rsi_columns)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
#' @export
|
||||
betalactams <- function(only_rsi_columns = FALSE) {
|
||||
ab_selector("carbapenem|cephalosporin|penicillin", function_name = "betalactams", only_rsi_columns = only_rsi_columns)
|
||||
}
|
||||
#' @rdname antibiotic_class_selectors
|
||||
#' @export
|
||||
carbapenems <- function(only_rsi_columns = FALSE) {
|
||||
@@ -176,23 +221,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 (as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 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)
|
||||
pkg_env$ab_selector <- unique_call_id()
|
||||
pkg_env$ab_selector_cols <- ab_in_data
|
||||
} else {
|
||||
ab_in_data <- pkg_env$ab_selector_cols
|
||||
}
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns, sort = FALSE)
|
||||
|
||||
if (length(ab_in_data) == 0) {
|
||||
message_("No antimicrobial agents found.")
|
||||
@@ -212,6 +250,7 @@ ab_selector <- function(ab_class,
|
||||
}
|
||||
# get the columns with a group names in the chosen ab class
|
||||
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
||||
|
||||
if (message_not_thrown_before(function_name)) {
|
||||
if (length(agents) == 0) {
|
||||
message_("No antimicrobial agents of class ", ab_group, " found", examples, ".")
|
||||
@@ -221,13 +260,205 @@ ab_selector <- function(ab_class,
|
||||
need_name <- tolower(gsub("[^a-zA-Z]", "", agents)) != tolower(gsub("[^a-zA-Z]", "", agents_names))
|
||||
agents_formatted[need_name] <- paste0(agents_formatted[need_name],
|
||||
" (", agents_names[need_name], ")")
|
||||
message_("Selecting ", ab_group, ": ",
|
||||
ifelse(length(agents) == 1, "column ", "columns "),
|
||||
vector_and(agents_formatted, quotes = FALSE),
|
||||
as_note = FALSE,
|
||||
extra_indent = 6)
|
||||
message_("For `", function_name, "(", ifelse(function_name == "ab_class", paste0("\"", ab_class, "\""), ""), ")` using ",
|
||||
ifelse(length(agents) == 1, "column: ", "columns: "),
|
||||
vector_and(agents_formatted, quotes = FALSE))
|
||||
}
|
||||
remember_thrown_message(function_name)
|
||||
}
|
||||
unname(agents)
|
||||
|
||||
if (!is.null(attributes(vars_df)$type) &&
|
||||
attributes(vars_df)$type %in% c("dplyr_cur_data_all", "base_R") &&
|
||||
!any(as.character(sys.calls()) %like% paste0("(across|if_any|if_all)\\((c\\()?[a-z(), ]*", function_name))) {
|
||||
structure(unname(agents),
|
||||
class = c("ab_selector", "character"))
|
||||
} else {
|
||||
# don't return with "ab_selector" class if method is a dplyr selector,
|
||||
# dplyr::select() will complain:
|
||||
# > Subscript has the wrong type `ab_selector`.
|
||||
# > It must be numeric or character.
|
||||
unname(agents)
|
||||
}
|
||||
}
|
||||
|
||||
#' @method c ab_selector
|
||||
#' @export
|
||||
#' @noRd
|
||||
c.ab_selector <- function(...) {
|
||||
structure(unlist(lapply(list(...), as.character)),
|
||||
class = c("ab_selector", "character"))
|
||||
}
|
||||
|
||||
all_any_ab_selector <- function(type, ..., na.rm = TRUE) {
|
||||
cols_ab <- c(...)
|
||||
result <- cols_ab[toupper(cols_ab) %in% c("R", "S", "I")]
|
||||
if (length(result) == 0) {
|
||||
message_("Filtering ", type, " of columns ", vector_and(font_bold(cols_ab, collapse = NULL), quotes = "'"), ' to contain value "R", "S" or "I"')
|
||||
result <- c("R", "S", "I")
|
||||
}
|
||||
cols_ab <- cols_ab[!cols_ab %in% result]
|
||||
df <- get_current_data(arg_name = NA, call = -3)
|
||||
|
||||
if (type == "all") {
|
||||
scope_fn <- all
|
||||
} else {
|
||||
scope_fn <- any
|
||||
}
|
||||
|
||||
x_transposed <- as.list(as.data.frame(t(df[, cols_ab, drop = FALSE]), stringsAsFactors = FALSE))
|
||||
vapply(FUN.VALUE = logical(1),
|
||||
X = x_transposed,
|
||||
FUN = function(y) scope_fn(y %in% result, na.rm = na.rm),
|
||||
USE.NAMES = FALSE)
|
||||
}
|
||||
|
||||
#' @method all ab_selector
|
||||
#' @export
|
||||
#' @noRd
|
||||
all.ab_selector <- function(..., na.rm = FALSE) {
|
||||
# this is all() for
|
||||
all_any_ab_selector("all", ..., na.rm = na.rm)
|
||||
}
|
||||
|
||||
#' @method any ab_selector
|
||||
#' @export
|
||||
#' @noRd
|
||||
any.ab_selector <- function(..., na.rm = FALSE) {
|
||||
all_any_ab_selector("any", ..., na.rm = na.rm)
|
||||
}
|
||||
|
||||
|
||||
#' @method all ab_selector_any_all
|
||||
#' @export
|
||||
#' @noRd
|
||||
all.ab_selector_any_all <- function(..., na.rm = FALSE) {
|
||||
# this is all() on a logical vector from `==.ab_selector` or `!=.ab_selector`
|
||||
# e.g., example_isolates %>% filter(all(carbapenems() == "R"))
|
||||
# so just return the vector as is, only correcting for na.rm
|
||||
out <- unclass(c(...))
|
||||
if (na.rm == TRUE) {
|
||||
out <- out[!is.na(out)]
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#' @method any ab_selector_any_all
|
||||
#' @export
|
||||
#' @noRd
|
||||
any.ab_selector_any_all <- function(..., na.rm = FALSE) {
|
||||
# this is any() on a logical vector from `==.ab_selector` or `!=.ab_selector`
|
||||
# e.g., example_isolates %>% filter(any(carbapenems() == "R"))
|
||||
# so just return the vector as is, only correcting for na.rm
|
||||
out <- unclass(c(...))
|
||||
if (na.rm == TRUE) {
|
||||
out <- out[!is.na(out)]
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#' @method == ab_selector
|
||||
#' @export
|
||||
#' @noRd
|
||||
`==.ab_selector` <- function(e1, e2) {
|
||||
calls <- as.character(match.call())
|
||||
fn_name <- calls[2]
|
||||
# keep only the ... in c(...)
|
||||
fn_name <- gsub("^(c\\()(.*)(\\))$", "\\2", fn_name)
|
||||
if (is_any(fn_name)) {
|
||||
type <- "any"
|
||||
} else if (is_all(fn_name)) {
|
||||
type <- "all"
|
||||
} else {
|
||||
type <- "all"
|
||||
if (length(e1) > 1) {
|
||||
message_("Assuming a filter on ", type, " ", length(e1), " ", gsub("[\\(\\)]", "", fn_name),
|
||||
". Wrap around `all()` or `any()` to prevent this note.")
|
||||
}
|
||||
}
|
||||
structure(all_any_ab_selector(type = type, e1, e2),
|
||||
class = c("ab_selector_any_all", "logical"))
|
||||
}
|
||||
|
||||
#' @method != ab_selector
|
||||
#' @export
|
||||
#' @noRd
|
||||
`!=.ab_selector` <- function(e1, e2) {
|
||||
calls <- as.character(match.call())
|
||||
fn_name <- calls[2]
|
||||
# keep only the ... in c(...)
|
||||
fn_name <- gsub("^(c\\()(.*)(\\))$", "\\2", fn_name)
|
||||
if (is_any(fn_name)) {
|
||||
type <- "any"
|
||||
} else if (is_all(fn_name)) {
|
||||
type <- "all"
|
||||
} else {
|
||||
type <- "all"
|
||||
if (length(e1) > 1) {
|
||||
message_("Assuming a filter on ", type, " ", length(e1), " ", gsub("[\\(\\)]", "", fn_name),
|
||||
". Wrap around `all()` or `any()` to prevent this note.")
|
||||
}
|
||||
}
|
||||
# this is `!=`, so turn around the values
|
||||
rsi <- c("R", "S", "I")
|
||||
e2 <- rsi[rsi != e2]
|
||||
structure(all_any_ab_selector(type = type, e1, e2),
|
||||
class = c("ab_selector_any_all", "logical"))
|
||||
}
|
||||
|
||||
is_any <- function(el1) {
|
||||
syscall <- paste0(trimws(deparse(sys.calls()[[1]])), collapse = " ")
|
||||
el1 <- gsub("(.*),.*", "\\1", el1)
|
||||
syscall %like% paste0("[^_a-zA-Z0-9]any\\(", "(c\\()?", el1)
|
||||
}
|
||||
is_all <- function(el1) {
|
||||
syscall <- paste0(trimws(deparse(sys.calls()[[1]])), collapse = " ")
|
||||
el1 <- gsub("(.*),.*", "\\1", el1)
|
||||
syscall %like% paste0("[^_a-zA-Z0-9]all\\(", "(c\\()?", el1)
|
||||
}
|
||||
|
||||
|
||||
find_ab_group <- function(ab_class) {
|
||||
ab_class[ab_class == "carbapenem|cephalosporin|penicillin"] <- "betalactam"
|
||||
ab_class <- gsub("[^a-zA-Z0-9]", ".*", ab_class)
|
||||
ifelse(ab_class %in% c("aminoglycoside",
|
||||
"betalactam",
|
||||
"carbapenem",
|
||||
"cephalosporin",
|
||||
"fluoroquinolone",
|
||||
"glycopeptide",
|
||||
"macrolide",
|
||||
"oxazolidinone",
|
||||
"tetracycline"),
|
||||
paste0(ab_class, "s"),
|
||||
antibiotics %pm>%
|
||||
subset(group %like% ab_class |
|
||||
atc_group1 %like% ab_class |
|
||||
atc_group2 %like% ab_class) %pm>%
|
||||
pm_pull(group) %pm>%
|
||||
unique() %pm>%
|
||||
tolower() %pm>%
|
||||
sort() %pm>%
|
||||
paste(collapse = "/")
|
||||
)
|
||||
}
|
||||
|
||||
find_ab_names <- function(ab_group, n = 3) {
|
||||
ab_group <- gsub("[^a-zA-Z|0-9]", ".*", ab_group)
|
||||
|
||||
# try popular first, they have DDDs
|
||||
drugs <- antibiotics[which((!is.na(antibiotics$iv_ddd) | !is.na(antibiotics$oral_ddd)) &
|
||||
antibiotics$name %unlike% " " &
|
||||
antibiotics$group %like% ab_group &
|
||||
antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||
if (length(drugs) < n) {
|
||||
# now try it all
|
||||
drugs <- antibiotics[which((antibiotics$group %like% ab_group |
|
||||
antibiotics$atc_group1 %like% ab_group |
|
||||
antibiotics$atc_group2 %like% ab_group) &
|
||||
antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||
}
|
||||
vector_or(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE),
|
||||
tolower = TRUE,
|
||||
language = NULL),
|
||||
quotes = FALSE)
|
||||
}
|
||||
@@ -29,17 +29,17 @@
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param text text to analyse
|
||||
#' @param type type of property to search for, either `"drug"`, `"dose"` or `"administration"`, see *Examples*
|
||||
#' @param collapse character to pass on to `paste(, collapse = ...)` to only return one character per element of `text`, see *Examples*
|
||||
#' @param collapse a [character] to pass on to `paste(, collapse = ...)` to only return one [character] per element of `text`, see *Examples*
|
||||
#' @param translate_ab if `type = "drug"`: a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]. Defaults to `FALSE`. Using `TRUE` is equal to using "name".
|
||||
#' @param thorough_search logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to `TRUE` will take considerably more time than when using `FALSE`. At default, it will turn `TRUE` when all input elements contain a maximum of three words.
|
||||
#' @param info logical to indicate whether a progress bar should be printed, defaults to `TRUE` only in interactive mode
|
||||
#' @param thorough_search a [logical] to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to `TRUE` will take considerably more time than when using `FALSE`. At default, it will turn `TRUE` when all input elements contain a maximum of three words.
|
||||
#' @param info a [logical] to indicate whether a progress bar should be printed, defaults to `TRUE` only in interactive mode
|
||||
#' @param ... arguments passed on to [as.ab()]
|
||||
#' @details This function is also internally used by [as.ab()], although it then only searches for the first drug name and will throw a note if more drug names could have been returned. Note: the [as.ab()] function may use very long regular expression to match brand names of antimicrobial agents. This may fail on some systems.
|
||||
#'
|
||||
#' ## Argument `type`
|
||||
#' At default, the function will search for antimicrobial drug names. All text elements will be searched for official names, ATC codes and brand names. As it uses [as.ab()] internally, it will correct for misspelling.
|
||||
#'
|
||||
#' With `type = "dose"` (or similar, like "dosing", "doses"), all text elements will be searched for numeric values that are higher than 100 and do not resemble years. The output will be numeric. It supports any unit (g, mg, IE, etc.) and multiple values in one clinical text, see *Examples*.
|
||||
#' With `type = "dose"` (or similar, like "dosing", "doses"), all text elements will be searched for [numeric] values that are higher than 100 and do not resemble years. The output will be [numeric]. It supports any unit (g, mg, IE, etc.) and multiple values in one clinical text, see *Examples*.
|
||||
#'
|
||||
#' With `type = "administration"` (or abbreviations, like "admin", "adm"), all text elements will be searched for a form of drug administration. It supports the following forms (including common abbreviations): buccal, implant, inhalation, instillation, intravenous, nasal, oral, parenteral, rectal, sublingual, transdermal and vaginal. Abbreviations for oral (such as 'po', 'per os') will become "oral", all values for intravenous (such as 'iv', 'intraven') will become "iv". It supports multiple values in one clinical text, see *Examples*.
|
||||
#'
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
#' Use these functions to return a specific property of an antibiotic from the [antibiotics] data set. All input values will be evaluated internally with [as.ab()].
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x any (vector of) text that can be coerced to a valid antibiotic code with [as.ab()]
|
||||
#' @param tolower logical to indicate whether the first character of every output should be transformed to a lower case character. This will lead to e.g. "polymyxin B" and not "polymyxin b".
|
||||
#' @param tolower a [logical] to indicate whether the first [character] of every output should be transformed to a lower case [character]. This will lead to e.g. "polymyxin B" and not "polymyxin b".
|
||||
#' @param property one of the column names of one of the [antibiotics] data set
|
||||
#' @param language language of the returned text, defaults to system language (see [get_locale()]) and can also be set with `getOption("AMR_locale")`. Use `language = NULL` or `language = ""` to prevent translation.
|
||||
#' @param administration way of administration, either `"oral"` or `"iv"`
|
||||
#' @param units a logical to indicate whether the units instead of the DDDs itself must be returned, see *Examples*
|
||||
#' @param units a [logical] to indicate whether the units instead of the DDDs itself must be returned, see *Examples*
|
||||
#' @param open browse the URL using [utils::browseURL()]
|
||||
#' @param ... other arguments passed on to [as.ab()]
|
||||
#' @details All output [will be translated][translate] where possible.
|
||||
@@ -93,7 +93,7 @@ ab_name <- function(x, language = get_locale(), tolower = FALSE, ...) {
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(tolower, allow_class = "logical", has_length = 1)
|
||||
|
||||
x <- translate_AMR(ab_validate(x = x, property = "name", ...), language = language)
|
||||
x <- translate_AMR(ab_validate(x = x, property = "name", ...), language = language, only_affect_ab_names = TRUE)
|
||||
if (tolower == TRUE) {
|
||||
# use perl to only transform the first character
|
||||
# as we want "polymyxin B", not "polymyxin b"
|
||||
@@ -142,7 +142,7 @@ ab_tradenames <- function(x, ...) {
|
||||
ab_group <- function(x, language = get_locale(), ...) {
|
||||
meet_criteria(x, allow_NA = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
translate_AMR(ab_validate(x = x, property = "group", ...), language = language)
|
||||
translate_AMR(ab_validate(x = x, property = "group", ...), language = language, only_affect_ab_names = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname ab_property
|
||||
@@ -150,7 +150,7 @@ ab_group <- function(x, language = get_locale(), ...) {
|
||||
ab_atc_group1 <- function(x, language = get_locale(), ...) {
|
||||
meet_criteria(x, allow_NA = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
translate_AMR(ab_validate(x = x, property = "atc_group1", ...), language = language)
|
||||
translate_AMR(ab_validate(x = x, property = "atc_group1", ...), language = language, only_affect_ab_names = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname ab_property
|
||||
@@ -158,7 +158,7 @@ ab_atc_group1 <- function(x, language = get_locale(), ...) {
|
||||
ab_atc_group2 <- function(x, language = get_locale(), ...) {
|
||||
meet_criteria(x, allow_NA = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
translate_AMR(ab_validate(x = x, property = "atc_group2", ...), language = language)
|
||||
translate_AMR(ab_validate(x = x, property = "atc_group2", ...), language = language, only_affect_ab_names = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname ab_property
|
||||
|
||||
@@ -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 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 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.")
|
||||
reference <- rep(reference, length(x))
|
||||
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
|
||||
@@ -105,7 +121,7 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
#' @param na.rm a [logical] to indicate whether missing values should be removed
|
||||
#' @details To split ages, the input for the `split_at` argument can be:
|
||||
#'
|
||||
#' * A numeric vector. A value of e.g. `c(10, 20)` will split `x` on 0-9, 10-19 and 20+. A value of only `50` will split `x` on 0-49 and 50+.
|
||||
#' * A [numeric] vector. A value of e.g. `c(10, 20)` will split `x` on 0-9, 10-19 and 20+. A value of only `50` will split `x` on 0-49 and 50+.
|
||||
#' The default is to split on young children (0-11), youth (12-24), young adults (25-54), middle-aged adults (55-74) and elderly (75+).
|
||||
#' * A character:
|
||||
#' - `"children"` or `"kids"`, equivalent of: `c(0, 1, 2, 4, 6, 13, 18)`. This will split on 0, 1, 2-3, 4-5, 6-12, 13-17 and 18+.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#'
|
||||
#' Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic), such as the name, defined daily dose (DDD) or standard unit.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param atc_code a character or character vector with ATC code(s) of antibiotic(s)
|
||||
#' @param atc_code a [character] or [character] vector with ATC code(s) of antibiotic(s)
|
||||
#' @param property property of an ATC code. Valid values are `"ATC"`, `"Name"`, `"DDD"`, `"U"` (`"unit"`), `"Adm.R"`, `"Note"` and `groups`. For this last option, all hierarchical groups of an ATC code will be returned, see *Examples*.
|
||||
#' @param administration type of administration when using `property = "Adm.R"`, see *Details*
|
||||
#' @param url url of website of the WHOCC. The sign `%s` can be used as a placeholder for ATC codes.
|
||||
@@ -56,7 +56,7 @@
|
||||
#' - `"TU"` = thousand units
|
||||
#' - `"MU"` = million units
|
||||
#' - `"mmol"` = millimole
|
||||
#' - `"ml"` = milliliter (e.g. eyedrops)
|
||||
#' - `"ml"` = millilitre (e.g. eyedrops)
|
||||
#'
|
||||
#' **N.B. This function requires an internet connection and only works if the following packages are installed: `curl`, `rvest`, `xml2`.**
|
||||
#' @export
|
||||
@@ -65,13 +65,15 @@
|
||||
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' # oral DDD (Defined Daily Dose) of amoxicillin
|
||||
#' atc_online_property("J01CA04", "DDD", "O")
|
||||
#' if (requireNamespace("curl") && requireNamespace("rvest") && requireNamespace("xml2")) {
|
||||
#' # oral DDD (Defined Daily Dose) of amoxicillin
|
||||
#' atc_online_property("J01CA04", "DDD", "O")
|
||||
#'
|
||||
#' # parenteral DDD (Defined Daily Dose) of amoxicillin
|
||||
#' atc_online_property("J01CA04", "DDD", "P")
|
||||
#' # parenteral DDD (Defined Daily Dose) of amoxicillin
|
||||
#' atc_online_property("J01CA04", "DDD", "P")
|
||||
#'
|
||||
#' atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
|
||||
#' atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
|
||||
#' }
|
||||
#' }
|
||||
atc_online_property <- function(atc_code,
|
||||
property,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
#' Determine antimicrobial resistance (AMR) of all bug-drug combinations in your data set where at least 30 (default) isolates are available per species. Use [format()] on the result to prettify it to a publicable/printable format, see *Examples*.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @inheritParams eucast_rules
|
||||
#' @param combine_IR logical to indicate whether values R and I should be summed
|
||||
#' @param add_ab_group logical to indicate where the group of the antimicrobials must be included as a first column
|
||||
#' @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 function to call on the `mo` column to transform the microorganism IDs, defaults to [mo_shortname()]
|
||||
#' @param translate_ab character of length 1 containing column names of the [antibiotics] data set
|
||||
#' @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 translate_ab a [character] of length 1 containing column names of the [antibiotics] data set
|
||||
#' @param ... arguments passed on to `FUN`
|
||||
#' @inheritParams rsi_df
|
||||
#' @inheritParams base::formatC
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
#' custom_eucast_rules(TZP == "R" ~ carbapenems == "R"))
|
||||
#' x2
|
||||
custom_eucast_rules <- function(...) {
|
||||
|
||||
|
||||
dots <- tryCatch(list(...),
|
||||
error = function(e) "error")
|
||||
stop_if(identical(dots, "error"),
|
||||
@@ -150,7 +150,6 @@ custom_eucast_rules <- function(...) {
|
||||
result_group <- tryCatch(
|
||||
suppressWarnings(as.ab(result_group,
|
||||
fast_mode = TRUE,
|
||||
info = FALSE,
|
||||
flag_multiple_results = FALSE)),
|
||||
error = function(e) NA_character_)
|
||||
}
|
||||
@@ -203,7 +202,9 @@ print.custom_eucast_rules <- function(x, ...) {
|
||||
for (i in seq_len(length(x))) {
|
||||
rule <- x[[i]]
|
||||
rule$query <- format_custom_query_rule(rule$query)
|
||||
if (rule$result_value == "R") {
|
||||
if (is.na(rule$result_value)) {
|
||||
val <- font_red("<NA>")
|
||||
} else if (rule$result_value == "R") {
|
||||
val <- font_rsi_R_bg(font_black(" R "))
|
||||
} else if (rule$result_value == "S") {
|
||||
val <- font_rsi_S_bg(font_black(" S "))
|
||||
|
||||
@@ -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!
|
||||
@@ -178,9 +178,9 @@
|
||||
#' @format A [data.frame] with `r format(nrow(example_isolates), big.mark = ",")` observations and `r ncol(example_isolates)` variables:
|
||||
#' - `date`\cr date of receipt at the laboratory
|
||||
#' - `hospital_id`\cr ID of the hospital, from A to D
|
||||
#' - `ward_icu`\cr logical to determine if ward is an intensive care unit
|
||||
#' - `ward_clinical`\cr logical to determine if ward is a regular clinical ward
|
||||
#' - `ward_outpatient`\cr logical to determine if ward is an outpatient clinic
|
||||
#' - `ward_icu`\cr [logical] to determine if ward is an intensive care unit
|
||||
#' - `ward_clinical`\cr [logical] to determine if ward is a regular clinical ward
|
||||
#' - `ward_outpatient`\cr [logical] to determine if ward is an outpatient clinic
|
||||
#' - `age`\cr age of the patient
|
||||
#' - `gender`\cr gender of the patient
|
||||
#' - `patient_id`\cr ID of the patient
|
||||
@@ -217,8 +217,8 @@
|
||||
#' - `Sex`\cr Fictitious gender of patient
|
||||
#' - `Age`\cr Fictitious age of patient
|
||||
#' - `Age category`\cr Age group, can also be looked up using [age_groups()]
|
||||
#' - `Date of admission`\cr Date of hospital admission
|
||||
#' - `Specimen date`\cr Date when specimen was received at laboratory
|
||||
#' - `Date of admission`\cr [Date] of hospital admission
|
||||
#' - `Specimen date`\cr [Date] when specimen was received at laboratory
|
||||
#' - `Specimen type`\cr Specimen type or group
|
||||
#' - `Specimen type (Numeric)`\cr Translation of `"Specimen type"`
|
||||
#' - `Reason`\cr Reason of request with Differential Diagnosis
|
||||
@@ -231,7 +231,7 @@
|
||||
#' - `MRSA screening test`\cr Microorganism is possible MRSA?
|
||||
#' - `Inducible clindamycin resistance`\cr Clindamycin can be induced?
|
||||
#' - `Comment`\cr Other comments
|
||||
#' - `Date of data entry`\cr Date this data was entered in WHONET
|
||||
#' - `Date of data entry`\cr [Date] this data was entered in WHONET
|
||||
#' - `AMP_ND10:CIP_EE`\cr `r sum(vapply(FUN.VALUE = logical(1), WHONET, is.rsi))` different antibiotics. You can lookup the abbreviations in the [antibiotics] data set, or use e.g. [`ab_name("AMP")`][ab_name()] to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using [as.rsi()].
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
@@ -250,7 +250,7 @@
|
||||
#' - `disk_dose`\cr Dose of the used disk diffusion method
|
||||
#' - `breakpoint_S`\cr Lowest MIC value or highest number of millimetres that leads to "S"
|
||||
#' - `breakpoint_R`\cr Highest MIC value or lowest number of millimetres that leads to "R"
|
||||
#' - `uti`\cr A logical value (`TRUE`/`FALSE`) to indicate whether the rule applies to a urinary tract infection (UTI)
|
||||
#' - `uti`\cr A [logical] value (`TRUE`/`FALSE`) to indicate whether the rule applies to a urinary tract infection (UTI)
|
||||
#' @details The repository of this `AMR` package contains a file comprising this exact data set: <https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt>. This file **allows for machine reading EUCAST and CLSI guidelines**, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically.
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
@@ -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
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
#' Deprecated Functions
|
||||
#'
|
||||
#' These functions are so-called '[Deprecated]'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
|
||||
#' These functions are so-called '[Deprecated]'. **They will be removed in a future release.** Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
|
||||
#' @details 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()]).
|
||||
#' @inheritSection lifecycle Retired Lifecycle
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @keywords internal
|
||||
@@ -138,3 +139,364 @@ key_antibiotics_equal <- function(y,
|
||||
points_threshold = points_threshold,
|
||||
info = info)
|
||||
}
|
||||
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_ab_class <- function(x,
|
||||
ab_class,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
|
||||
.call_depth <- list(...)$`.call_depth`
|
||||
if (is.null(.call_depth)) {
|
||||
.call_depth <- 0
|
||||
}
|
||||
.x_name <- list(...)$`.x_name`
|
||||
if (is.null(.x_name)) {
|
||||
.x_name <- deparse(substitute(x))
|
||||
}
|
||||
.fn <- list(...)$`.fn`
|
||||
if (is.null(.fn)) {
|
||||
.fn <- "filter_ab_class"
|
||||
}
|
||||
.fn_old <- .fn
|
||||
# new way: using the ab selectors
|
||||
.fn <- gsub("filter_", "", .fn, fixed = TRUE)
|
||||
.fn <- gsub("^([1-5][a-z]+)_cephalosporins", "cephalosporins_\\1", .fn)
|
||||
|
||||
if (missing(x) || is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
# is also fix for using a grouped df as input (a dot as first argument)
|
||||
x <- get_current_data(arg_name = "x", call = -2 - .call_depth)
|
||||
.x_name <- "your_data"
|
||||
}
|
||||
meet_criteria(x, allow_class = "data.frame", .call_depth = .call_depth)
|
||||
meet_criteria(ab_class, allow_class = "character", has_length = 1, .call_depth = .call_depth)
|
||||
if (!is.null(result)) {
|
||||
# make result = "SI" works too:
|
||||
result <- toupper(unlist(strsplit(result, "")))
|
||||
}
|
||||
meet_criteria(result, allow_class = "character", has_length = c(1, 2, 3), is_in = c("S", "I", "R"), allow_NULL = TRUE, .call_depth = .call_depth)
|
||||
meet_criteria(scope, allow_class = "character", has_length = 1, is_in = c("all", "any"), .call_depth = .call_depth)
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1, .call_depth = .call_depth)
|
||||
|
||||
if (is.null(result)) {
|
||||
result <- c("S", "I", "R")
|
||||
}
|
||||
|
||||
# get e.g. carbapenems() from filter_carbapenems()
|
||||
fn <- get(.fn, envir = asNamespace("AMR"))
|
||||
if (scope == "any") {
|
||||
scope_fn <- any
|
||||
} else {
|
||||
scope_fn <- all
|
||||
}
|
||||
|
||||
# be nice here, be VERY extensive about how the AB selectors have taken over this function
|
||||
deprecated_fn <- paste0(.fn, "(", ifelse(.fn == "ab_class", paste0("\"", ab_class, "\""), ""), ")",
|
||||
ifelse(length(result) > 1,
|
||||
paste0(", c(", paste0("\"", result, "\"", collapse = ", "), ")"),
|
||||
ifelse(is.null(result),
|
||||
"",
|
||||
paste0(" == \"", result, "\""))))
|
||||
if (.x_name == ".") {
|
||||
.x_name <- "your_data"
|
||||
}
|
||||
warning_(paste0("`", .fn_old, "()` is deprecated. Use the antibiotic selector `", .fn, "()` instead.\n",
|
||||
"In dplyr:\n",
|
||||
" - ", .x_name, " %>% filter(", scope, "(", deprecated_fn, "))\n",
|
||||
ifelse(length(result) > 1,
|
||||
paste0(" - ", .x_name, " %>% filter(", scope, "(",
|
||||
.fn, "(", ifelse(.fn == "ab_class", paste0("\"", ab_class, "\""), ""), ") == \"R\"))\n"),
|
||||
""),
|
||||
"In base R:\n",
|
||||
" - ", .x_name, "[", scope, "(", deprecated_fn, "), ]\n",
|
||||
ifelse(length(result) > 1,
|
||||
paste0(" - ", .x_name, "[", scope, "(",
|
||||
.fn, "(", ifelse(.fn == "ab_class", paste0("\"", ab_class, "\""), ""), ") == \"R\"), ]\n"),
|
||||
""),
|
||||
" - subset(", .x_name, ", ", scope, "(", deprecated_fn, "))",
|
||||
ifelse(length(result) > 1,
|
||||
paste0("\n - subset(", .x_name, ", ", scope, "(",
|
||||
.fn, "(", ifelse(.fn == "ab_class", paste0("\"", ab_class, "\""), ""), ") == \"R\"))"),
|
||||
"")),
|
||||
call = FALSE)
|
||||
|
||||
if (.fn == "ab_class") {
|
||||
subset(x, scope_fn(fn(ab_class = ab_class), result))
|
||||
} else {
|
||||
subset(x, scope_fn(fn(), result))
|
||||
}
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_aminoglycosides <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "aminoglycoside",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_aminoglycosides",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_betalactams <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "carbapenem|cephalosporin|penicillin",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_betalactams",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_carbapenems <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "carbapenem",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_carbapenems",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporin",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_cephalosporins",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_1st_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (1st gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_1st_cephalosporins",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_2nd_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (2nd gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_2nd_cephalosporins",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_3rd_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (3rd gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_3rd_cephalosporins",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_4th_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (4th gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_4th_cephalosporins",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_5th_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (5th gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_5th_cephalosporins",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_fluoroquinolones <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "fluoroquinolone",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_fluoroquinolones",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_glycopeptides <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "glycopeptide",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_glycopeptides",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_macrolides <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "macrolide",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_macrolides",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_oxazolidinones <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "oxazolidinone",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_oxazolidinones",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_penicillins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "penicillin",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_penicillins",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_tetracyclines <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "tetracycline",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
.fn = "filter_tetracyclines",
|
||||
.x_name = deparse(substitute(x)),
|
||||
...)
|
||||
}
|
||||
@@ -29,7 +29,7 @@
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @rdname as.disk
|
||||
#' @param x vector
|
||||
#' @param na.rm a logical indicating whether missing values should be removed
|
||||
#' @param na.rm a [logical] indicating whether missing values should be removed
|
||||
#' @details Interpret disk values as RSI values with [as.rsi()]. It supports guidelines from EUCAST and CLSI.
|
||||
#' @return An [integer] with additional class [`disk`]
|
||||
#' @aliases disk
|
||||
@@ -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
|
||||
|
||||
@@ -50,16 +50,16 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
#' To improve the interpretation of the antibiogram before EUCAST rules are applied, some non-EUCAST rules can applied at default, see *Details*.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x data with antibiotic columns, such as `amox`, `AMX` and `AMC`
|
||||
#' @param info a logical to indicate whether progress should be printed to the console, defaults to only print while in interactive sessions
|
||||
#' @param rules a character vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"custom"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`. If using `"custom"`, be sure to fill in argument `custom_rules` too. Custom rules can be created with [custom_eucast_rules()].
|
||||
#' @param info a [logical] to indicate whether progress should be printed to the console, defaults to only print while in interactive sessions
|
||||
#' @param rules a [character] vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"custom"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`. If using `"custom"`, be sure to fill in argument `custom_rules` too. Custom rules can be created with [custom_eucast_rules()].
|
||||
#' @param verbose a [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way. Using Verbose mode takes a lot more time.
|
||||
#' @param version_breakpoints the version number to use for the EUCAST Clinical Breakpoints guideline. Can be either `r vector_or(names(EUCAST_VERSION_BREAKPOINTS), reverse = TRUE)`.
|
||||
#' @param version_expertrules the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be either `r vector_or(names(EUCAST_VERSION_EXPERT_RULES), reverse = TRUE)`.
|
||||
#' @param ampc_cephalosporin_resistance a character value that should be applied to cefotaxime, ceftriaxone and ceftazidime for AmpC de-repressed cephalosporin-resistant mutants, defaults to `NA`. Currently only works when `version_expertrules` is `3.2`; '*EUCAST Expert Rules v3.2 on Enterobacterales*' states that results of cefotaxime, ceftriaxone and ceftazidime should be reported with a note, or results should be suppressed (emptied) for these three agents. A value of `NA` (the default) for this argument will remove results for these three agents, while e.g. a value of `"R"` will make the results for these agents resistant. Use `NULL` or `FALSE` to not alter results for these three agents of AmpC de-repressed cephalosporin-resistant mutants. Using `TRUE` is equal to using `"R"`. \cr For *EUCAST Expert Rules* v3.2, this rule applies to: `r vector_and(gsub("[^a-zA-Z ]+", "", unlist(strsplit(eucast_rules_file[which(eucast_rules_file$reference.version == 3.2 & eucast_rules_file$reference.rule %like% "ampc"), "this_value"][1], "|", fixed = TRUE))), quotes = "*")`.
|
||||
#' @param ampc_cephalosporin_resistance a [character] value that should be applied to cefotaxime, ceftriaxone and ceftazidime for AmpC de-repressed cephalosporin-resistant mutants, defaults to `NA`. Currently only works when `version_expertrules` is `3.2`; '*EUCAST Expert Rules v3.2 on Enterobacterales*' states that results of cefotaxime, ceftriaxone and ceftazidime should be reported with a note, or results should be suppressed (emptied) for these three agents. A value of `NA` (the default) for this argument will remove results for these three agents, while e.g. a value of `"R"` will make the results for these agents resistant. Use `NULL` or `FALSE` to not alter results for these three agents of AmpC de-repressed cephalosporin-resistant mutants. Using `TRUE` is equal to using `"R"`. \cr For *EUCAST Expert Rules* v3.2, this rule applies to: `r vector_and(gsub("[^a-zA-Z ]+", "", unlist(strsplit(eucast_rules_file[which(eucast_rules_file$reference.version == 3.2 & eucast_rules_file$reference.rule %like% "ampc"), "this_value"][1], "|", fixed = TRUE))), quotes = "*")`.
|
||||
#' @param ... column name of an antibiotic, see section *Antibiotics* below
|
||||
#' @param ab any (vector of) text that can be coerced to a valid antibiotic code with [as.ab()]
|
||||
#' @param administration route of administration, either `r vector_or(dosage$administration)`
|
||||
#' @param only_rsi_columns a logical to indicate whether only antibiotic columns must be detected that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @param only_rsi_columns a [logical] to indicate whether only antibiotic columns must be detected that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @param custom_rules custom rules to apply, created with [custom_eucast_rules()]
|
||||
#' @inheritParams first_isolate
|
||||
#' @details
|
||||
@@ -93,9 +93,9 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
#' @section Antibiotics:
|
||||
#' To define antibiotics column names, leave as it is to determine it automatically with [guess_ab_col()] or input a text (case-insensitive), or use `NULL` to skip a column (e.g. `TIC = NULL` to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning.
|
||||
#'
|
||||
#' The following antibiotics are used for the functions [eucast_rules()] and [mdro()]. These are shown below in the format 'name (`antimicrobial ID`, [ATC code](https://www.whocc.no/atc/structure_and_principles/))', sorted alphabetically:
|
||||
#' The following antibiotics are eligible for the functions [eucast_rules()] and [mdro()]. These are shown below in the format 'name (`antimicrobial ID`, [ATC code](https://www.whocc.no/atc/structure_and_principles/))', sorted alphabetically:
|
||||
#'
|
||||
#' `r create_ab_documentation(c("AMC", "AMK", "AMP", "AMX", "APL", "APX", "ATM", "AVB", "AVO", "AZD", "AZL", "AZM", "BAM", "BPR", "CAC", "CAT", "CAZ", "CCP", "CCV", "CCX", "CDC", "CDR", "CDZ", "CEC", "CED", "CEI", "CEM", "CEP", "CFM", "CFM1", "CFP", "CFR", "CFS", "CFZ", "CHE", "CHL", "CIC", "CID", "CIP", "CLI", "CLM", "CLO", "CLR", "CMX", "CMZ", "CND", "COL", "CPD", "CPI", "CPL", "CPM", "CPO", "CPR", "CPT", "CPX", "CRB", "CRD", "CRN", "CRO", "CSL", "CTB", "CTC", "CTF", "CTL", "CTS", "CTT", "CTX", "CTZ", "CXM", "CYC", "CZA", "CZD", "CZO", "CZP", "CZX", "DAL", "DAP", "DIC", "DIR", "DIT", "DIX", "DIZ", "DKB", "DOR", "DOX", "ENX", "EPC", "ERY", "ETP", "FEP", "FLC", "FLE", "FLR1", "FOS", "FOV", "FOX", "FOX1", "FUS", "GAT", "GEM", "GEN", "GRX", "HAP", "HET", "IPM", "ISE", "JOS", "KAN", "LEN", "LEX", "LIN", "LNZ", "LOM", "LOR", "LTM", "LVX", "MAN", "MCM", "MEC", "MEM", "MET", "MEV", "MEZ", "MFX", "MID", "MNO", "MTM", "NAC", "NAF", "NAL", "NEO", "NET", "NIT", "NOR", "NOV", "NVA", "OFX", "OLE", "ORI", "OXA", "PAZ", "PEF", "PEN", "PHE", "PHN", "PIP", "PLB", "PME", "PNM", "PRC", "PRI", "PRL", "PRP", "PRU", "PVM", "QDA", "RAM", "RFL", "RID", "RIF", "ROK", "RST", "RXT", "SAM", "SBC", "SDI", "SDM", "SIS", "SLF", "SLF1", "SLF10", "SLF11", "SLF12", "SLF13", "SLF2", "SLF3", "SLF4", "SLF5", "SLF6", "SLF7", "SLF8", "SLF9", "SLT1", "SLT2", "SLT3", "SLT4", "SLT5", "SLT6", "SMX", "SPI", "SPX", "SRX", "STR", "STR1", "SUD", "SUL", "SUT", "SXT", "SZO", "TAL", "TAZ", "TCC", "TCM", "TCY", "TEC", "TEM", "TGC", "THA", "TIC", "TIO", "TLT", "TLV", "TMP", "TMX", "TOB", "TRL", "TVA", "TZD", "TZP", "VAN"))`
|
||||
#' `r create_eucast_ab_documentation()`
|
||||
#' @aliases EUCAST
|
||||
#' @rdname eucast_rules
|
||||
#' @export
|
||||
@@ -240,7 +240,13 @@ eucast_rules <- function(x,
|
||||
cat(font_subtle(" (no changes)\n"))
|
||||
} else {
|
||||
# opening
|
||||
cat(font_grey(" ("))
|
||||
if (n_added > 0 & n_changed == 0) {
|
||||
cat(font_green(" ("))
|
||||
} else if (n_added == 0 & n_changed > 0) {
|
||||
cat(font_blue(" ("))
|
||||
} else {
|
||||
cat(font_grey(" ("))
|
||||
}
|
||||
# additions
|
||||
if (n_added > 0) {
|
||||
if (n_added == 1) {
|
||||
@@ -262,7 +268,13 @@ eucast_rules <- function(x,
|
||||
}
|
||||
}
|
||||
# closing
|
||||
cat(font_grey(")\n"))
|
||||
if (n_added > 0 & n_changed == 0) {
|
||||
cat(font_green(")\n"))
|
||||
} else if (n_added == 0 & n_changed > 0) {
|
||||
cat(font_blue(")\n"))
|
||||
} else {
|
||||
cat(font_grey(")\n"))
|
||||
}
|
||||
}
|
||||
warned <<- FALSE
|
||||
}
|
||||
@@ -305,21 +317,23 @@ eucast_rules <- function(x,
|
||||
|
||||
# Some helper functions ---------------------------------------------------
|
||||
get_antibiotic_columns <- function(x, cols_ab) {
|
||||
x <- strsplit(x, ", *")[[1]]
|
||||
x <- trimws(unique(toupper(unlist(strsplit(x, ",")))))
|
||||
x_new <- character()
|
||||
for (val in x) {
|
||||
if (toupper(val) %in% ls(envir = asNamespace("AMR"))) {
|
||||
if (val %in% ls(envir = asNamespace("AMR"))) {
|
||||
# antibiotic group names, as defined in data-raw/_internals.R, such as `CARBAPENEMS`
|
||||
val <- eval(parse(text = toupper(val)), envir = asNamespace("AMR"))
|
||||
} else if (toupper(val) %in% AB_lookup$ab) {
|
||||
val <- eval(parse(text = val), envir = asNamespace("AMR"))
|
||||
} else if (val %in% AB_lookup$ab) {
|
||||
# separate drugs, such as `AMX`
|
||||
val <- as.ab(val)
|
||||
} else {
|
||||
stop_("antimicrobial agent (group) not found in EUCAST rules file: ", val, call = FALSE)
|
||||
stop_("unknown antimicrobial agent (group) in EUCAST rules file: ", val, call = FALSE)
|
||||
}
|
||||
x_new <- c(x_new, val)
|
||||
}
|
||||
cols_ab[match(x_new, names(cols_ab))]
|
||||
x_new <- unique(x_new)
|
||||
out <- cols_ab[match(x_new, names(cols_ab))]
|
||||
out[!is.na(out)]
|
||||
}
|
||||
get_antibiotic_names <- function(x) {
|
||||
x <- x %pm>%
|
||||
@@ -413,7 +427,7 @@ eucast_rules <- function(x,
|
||||
# join to microorganisms data set
|
||||
x <- left_join_microorganisms(x, by = col_mo, suffix = c("_oldcols", ""))
|
||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
||||
x$genus_species <- paste(x$genus, x$species)
|
||||
x$genus_species <- trimws(paste(x$genus, x$species))
|
||||
if (info == TRUE & NROW(x) > 10000) {
|
||||
message_(" OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||
}
|
||||
@@ -910,13 +924,15 @@ eucast_rules <- function(x,
|
||||
|
||||
if (length(warn_lacking_rsi_class) > 0) {
|
||||
warn_lacking_rsi_class <- unique(warn_lacking_rsi_class)
|
||||
# take order from original data set
|
||||
warn_lacking_rsi_class <- warn_lacking_rsi_class[order(colnames(x.bak))]
|
||||
warn_lacking_rsi_class <- warn_lacking_rsi_class[!is.na(warn_lacking_rsi_class)]
|
||||
warning_("Not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
|
||||
" ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" ", x_deparsed, " %>% mutate(across((is.rsi.eligible), as.rsi))\n",
|
||||
" ", x_deparsed, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
||||
" - ", x_deparsed, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
||||
warn_lacking_rsi_class,
|
||||
paste0(warn_lacking_rsi_class[1], ":", warn_lacking_rsi_class[length(warn_lacking_rsi_class)])),
|
||||
")",
|
||||
paste0(warn_lacking_rsi_class[1], ":", warn_lacking_rsi_class[length(warn_lacking_rsi_class)])), ")\n",
|
||||
" - ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" - ", x_deparsed, " %>% mutate(across(where(is.rsi.eligible), as.rsi))",
|
||||
call = FALSE)
|
||||
}
|
||||
|
||||
@@ -961,7 +977,7 @@ edit_rsi <- function(x,
|
||||
}
|
||||
txt_warning <- function() {
|
||||
if (warned == FALSE) {
|
||||
if (info == TRUE) cat("", font_yellow_bg(font_black(" WARNING ")))
|
||||
if (info == TRUE) cat(" ", font_rsi_I_bg(" WARNING "), sep = "")
|
||||
}
|
||||
warned <<- TRUE
|
||||
}
|
||||
@@ -982,13 +998,15 @@ edit_rsi <- function(x,
|
||||
TRUE
|
||||
})
|
||||
suppressWarnings(new_edits[rows, cols] <<- to)
|
||||
warning_('Value "', to, '" added to the factor levels of column(s) `', paste(cols, collapse = "`, `"), "` because this value was not an existing factor level. A better way is to use as.rsi() on beforehand on antimicrobial columns to guarantee the right structure.", call = FALSE)
|
||||
warning_("Value \"", to, "\" added to the factor levels of column", ifelse(length(cols) == 1, "", "s"),
|
||||
" ", vector_and(cols, quotes = "`", sort = FALSE),
|
||||
" because this value was not an existing factor level.",
|
||||
call = FALSE)
|
||||
txt_warning()
|
||||
warned <- FALSE
|
||||
} else {
|
||||
warning_(w$message, call = FALSE)
|
||||
txt_warning()
|
||||
cat("\n") # txt_warning() does not append a "\n" on itself
|
||||
}
|
||||
},
|
||||
error = function(e) {
|
||||
|
||||
@@ -1,432 +0,0 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Data Analysis for R #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# We created this package for both routine data analysis and academic #
|
||||
# research and it was publicly released in the hope that it will be #
|
||||
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
||||
# #
|
||||
# Visit our website for the full manual and a complete tutorial about #
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Filter Isolates on Result in Antimicrobial Class
|
||||
#'
|
||||
#' Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a data set
|
||||
#' @param ab_class an antimicrobial class, like `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value.
|
||||
#' @param result an antibiotic result: S, I or R (or a combination of more of them)
|
||||
#' @param scope the scope to check which variables to check, can be `"any"` (default) or `"all"`
|
||||
#' @param only_rsi_columns a logical to indicate whether only columns must be included that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @param ... arguments passed on to [filter_ab_class()]
|
||||
#' @details All columns of `x` will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a filter function like e.g. [filter_aminoglycosides()] will include column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
|
||||
#' @rdname filter_ab_class
|
||||
#' @seealso [antibiotic_class_selectors()] for the `select()` equivalent.
|
||||
#' @export
|
||||
#' @examples
|
||||
#' filter_aminoglycosides(example_isolates)
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # filter on isolates that have any result for any aminoglycoside
|
||||
#' example_isolates %>% filter_aminoglycosides()
|
||||
#' example_isolates %>% filter_ab_class("aminoglycoside")
|
||||
#'
|
||||
#' # this is essentially the same as (but without determination of column names):
|
||||
#' example_isolates %>%
|
||||
#' filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")),
|
||||
#' .vars_predicate = any_vars(. %in% c("S", "I", "R")))
|
||||
#'
|
||||
#'
|
||||
#' # filter on isolates that show resistance to ANY aminoglycoside
|
||||
#' example_isolates %>% filter_aminoglycosides("R", "any")
|
||||
#'
|
||||
#' # filter on isolates that show resistance to ALL aminoglycosides
|
||||
#' example_isolates %>% filter_aminoglycosides("R", "all")
|
||||
#'
|
||||
#' # filter on isolates that show resistance to
|
||||
#' # any aminoglycoside and any fluoroquinolone
|
||||
#' example_isolates %>%
|
||||
#' filter_aminoglycosides("R") %>%
|
||||
#' filter_fluoroquinolones("R")
|
||||
#'
|
||||
#' # filter on isolates that show resistance to
|
||||
#' # all aminoglycosides and all fluoroquinolones
|
||||
#' example_isolates %>%
|
||||
#' filter_aminoglycosides("R", "all") %>%
|
||||
#' filter_fluoroquinolones("R", "all")
|
||||
#'
|
||||
#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal:
|
||||
#' # (though the row names on the first are more correct)
|
||||
#' example_isolates %>% filter_carbapenems("R", "all")
|
||||
#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
|
||||
#' example_isolates %>% filter(across(carbapenems(), function(x) x == "R"))
|
||||
#' }
|
||||
#' }
|
||||
filter_ab_class <- function(x,
|
||||
ab_class,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
.call_depth <- list(...)$`.call_depth`
|
||||
if (is.null(.call_depth)) {
|
||||
.call_depth <- 0
|
||||
}
|
||||
meet_criteria(x, allow_class = "data.frame", .call_depth = .call_depth)
|
||||
meet_criteria(ab_class, allow_class = "character", has_length = 1, .call_depth = .call_depth)
|
||||
meet_criteria(result, allow_class = "character", has_length = c(1, 2, 3), allow_NULL = TRUE, .call_depth = .call_depth)
|
||||
meet_criteria(scope, allow_class = "character", has_length = 1, is_in = c("all", "any"), .call_depth = .call_depth)
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1, .call_depth = .call_depth)
|
||||
|
||||
check_dataset_integrity()
|
||||
|
||||
# save to return later
|
||||
x_class <- class(x)
|
||||
x.bak <- x
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
|
||||
if (is.null(result)) {
|
||||
result <- c("S", "I", "R")
|
||||
}
|
||||
# make result = "SI" works too:
|
||||
result <- unlist(strsplit(result, ""))
|
||||
|
||||
stop_ifnot(all(result %in% c("S", "I", "R")), "`result` must be one or more of: 'S', 'I', 'R'")
|
||||
stop_ifnot(all(scope %in% c("any", "all")), "`scope` must be one of: 'any', 'all'")
|
||||
|
||||
# get all columns in data with names that resemble antibiotics
|
||||
ab_in_data <- get_column_abx(x, info = FALSE, only_rsi_columns = only_rsi_columns)
|
||||
if (length(ab_in_data) == 0) {
|
||||
message_("No columns with class <rsi> found (see ?as.rsi), data left unchanged.")
|
||||
return(x.bak)
|
||||
}
|
||||
# get reference data
|
||||
ab_class.bak <- ab_class
|
||||
ab_class <- gsub("[^a-zA-Z0-9]+", ".*", ab_class)
|
||||
ab_class <- gsub("(ph|f)", "(ph|f)", ab_class)
|
||||
ab_class <- gsub("(t|th)", "(t|th)", ab_class)
|
||||
ab_reference <- subset(antibiotics,
|
||||
group %like% ab_class |
|
||||
atc_group1 %like% ab_class |
|
||||
atc_group2 %like% ab_class)
|
||||
ab_group <- find_ab_group(ab_class)
|
||||
if (ab_group == "") {
|
||||
message_("Unknown antimicrobial class '", ab_class.bak, "', data left unchanged.")
|
||||
return(x.bak)
|
||||
}
|
||||
# get the columns with a group names in the chosen ab class
|
||||
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
||||
if (length(agents) == 0) {
|
||||
message_("No antimicrobial agents of class ", ab_group,
|
||||
" found (such as ", find_ab_names(ab_class, 2),
|
||||
")",
|
||||
ifelse(only_rsi_columns == TRUE, " with class <rsi>,", ","),
|
||||
" data left unchanged.")
|
||||
return(x.bak)
|
||||
}
|
||||
|
||||
if (scope == "any") {
|
||||
scope_txt <- " or "
|
||||
scope_fn <- any
|
||||
} else {
|
||||
scope_txt <- " and "
|
||||
scope_fn <- all
|
||||
}
|
||||
if (length(agents) > 1) {
|
||||
operator <- " are"
|
||||
scope <- paste("values in", scope, "of columns ")
|
||||
} else {
|
||||
operator <- " is"
|
||||
scope <- "value in column "
|
||||
}
|
||||
if (length(result) > 1) {
|
||||
operator <- paste(operator, "either")
|
||||
}
|
||||
|
||||
# sort columns on official name
|
||||
agents <- agents[order(ab_name(names(agents), language = NULL))]
|
||||
|
||||
message_("Filtering on ", ab_group, ": ", scope,
|
||||
paste(paste0("`", font_bold(agents, collapse = NULL),
|
||||
"` (", ab_name(names(agents), tolower = TRUE, language = NULL), ")"),
|
||||
collapse = scope_txt),
|
||||
operator, " ", vector_or(result, quotes = TRUE),
|
||||
as_note = FALSE,
|
||||
extra_indent = 6)
|
||||
x_transposed <- as.list(as.data.frame(t(x[, agents, drop = FALSE]), stringsAsFactors = FALSE))
|
||||
filtered <- vapply(FUN.VALUE = logical(1), x_transposed, function(y) scope_fn(y %in% result, na.rm = TRUE))
|
||||
x <- x[which(filtered), , drop = FALSE]
|
||||
class(x) <- x_class
|
||||
x
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_aminoglycosides <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "aminoglycoside",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_carbapenems <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "carbapenem",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporin",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_1st_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (1st gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_2nd_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (2nd gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_3rd_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (3rd gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_4th_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (4th gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_5th_cephalosporins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "cephalosporins (5th gen.)",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_fluoroquinolones <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "fluoroquinolone",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_glycopeptides <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "glycopeptide",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_macrolides <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "macrolide",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_oxazolidinones <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "oxazolidinone",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_penicillins <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "penicillin",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @rdname filter_ab_class
|
||||
#' @export
|
||||
filter_tetracyclines <- function(x,
|
||||
result = NULL,
|
||||
scope = "any",
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
filter_ab_class(x = x,
|
||||
ab_class = "tetracycline",
|
||||
result = result,
|
||||
scope = scope,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
.call_depth = 1,
|
||||
...)
|
||||
}
|
||||
|
||||
find_ab_group <- function(ab_class) {
|
||||
ab_class <- gsub("[^a-zA-Z0-9]", ".*", ab_class)
|
||||
ifelse(ab_class %in% c("aminoglycoside",
|
||||
"carbapenem",
|
||||
"cephalosporin",
|
||||
"fluoroquinolone",
|
||||
"glycopeptide",
|
||||
"macrolide",
|
||||
"oxazolidinone",
|
||||
"tetracycline"),
|
||||
paste0(ab_class, "s"),
|
||||
antibiotics %pm>%
|
||||
subset(group %like% ab_class |
|
||||
atc_group1 %like% ab_class |
|
||||
atc_group2 %like% ab_class) %pm>%
|
||||
pm_pull(group) %pm>%
|
||||
unique() %pm>%
|
||||
tolower() %pm>%
|
||||
sort() %pm>%
|
||||
paste(collapse = "/")
|
||||
)
|
||||
}
|
||||
|
||||
find_ab_names <- function(ab_group, n = 3) {
|
||||
ab_group <- gsub("[^a-zA-Z0-9]", ".*", ab_group)
|
||||
drugs <- antibiotics[which(antibiotics$group %like% ab_group & antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||
paste0(sort(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE),
|
||||
tolower = TRUE, language = NULL)),
|
||||
collapse = ", ")
|
||||
}
|
||||
@@ -36,21 +36,21 @@
|
||||
#' @param col_icu column name of the logicals (`TRUE`/`FALSE`) whether a ward or department is an Intensive Care Unit (ICU)
|
||||
#' @param col_keyantimicrobials (only useful when `method = "phenotype-based"`) column name of the key antimicrobials to determine first (weighted) isolates, see [key_antimicrobials()]. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' or 'antimicrobials' (case insensitive). Use `col_keyantimicrobials = FALSE` to prevent this. Can also be the output of [key_antimicrobials()].
|
||||
#' @param episode_days episode in days after which a genus/species combination will be determined as 'first isolate' again. The default of 365 days is based on the guideline by CLSI, see *Source*.
|
||||
#' @param testcodes_exclude character vector with test codes that should be excluded (case-insensitive)
|
||||
#' @param icu_exclude logical to indicate whether ICU isolates should be excluded (rows with value `TRUE` in the column set with `col_icu`)
|
||||
#' @param testcodes_exclude a [character] vector with test codes that should be excluded (case-insensitive)
|
||||
#' @param icu_exclude a [logical] to indicate whether ICU isolates should be excluded (rows with value `TRUE` in the column set with `col_icu`)
|
||||
#' @param specimen_group value in the column set with `col_specimen` to filter on
|
||||
#' @param type type to determine weighed isolates; can be `"keyantimicrobials"` or `"points"`, see *Details*
|
||||
#' @param method the method to apply, either `"phenotype-based"`, `"episode-based"`, `"patient-based"` or `"isolate-based"` (can be abbreviated), see *Details*. The default is `"phenotype-based"` if antimicrobial test results are present in the data, and `"episode-based"` otherwise.
|
||||
#' @param ignore_I logical to indicate whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantimicrobials"`, see *Details*
|
||||
#' @param ignore_I [logical] to indicate whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantimicrobials"`, see *Details*
|
||||
#' @param points_threshold minimum number of points to require before differences in the antibiogram will lead to inclusion of an isolate when `type = "points"`, see *Details*
|
||||
#' @param info a [logical] to indicate info should be printed, defaults to `TRUE` only in interactive mode
|
||||
#' @param include_unknown logical to indicate whether 'unknown' microorganisms should be included too, i.e. microbial code `"UNKNOWN"`, which defaults to `FALSE`. For WHONET users, this means that all records with organism code `"con"` (*contamination*) will be excluded at default. Isolates with a microbial ID of `NA` will always be excluded as first isolate.
|
||||
#' @param include_untested_rsi logical to indicate whether also rows without antibiotic results are still eligible for becoming a first isolate. Use `include_untested_rsi = FALSE` to always return `FALSE` for such rows. This checks the data set for columns of class `<rsi>` and consequently requires transforming columns with antibiotic results using [as.rsi()] first.
|
||||
#' @param include_unknown a [logical] to indicate whether 'unknown' microorganisms should be included too, i.e. microbial code `"UNKNOWN"`, which defaults to `FALSE`. For WHONET users, this means that all records with organism code `"con"` (*contamination*) will be excluded at default. Isolates with a microbial ID of `NA` will always be excluded as first isolate.
|
||||
#' @param include_untested_rsi a [logical] to indicate whether also rows without antibiotic results are still eligible for becoming a first isolate. Use `include_untested_rsi = FALSE` to always return `FALSE` for such rows. This checks the data set for columns of class `<rsi>` and consequently requires transforming columns with antibiotic results using [as.rsi()] first.
|
||||
#' @param ... arguments passed on to [first_isolate()] when using [filter_first_isolate()], otherwise arguments passed on to [key_antimicrobials()] (such as `universal`, `gram_negative`, `gram_positive`)
|
||||
#' @details
|
||||
#' To conduct epidemiological analyses on antimicrobial resistance data, only so-called first isolates should be included to prevent overestimation and underestimation of antimicrobial resistance. Different methods can be used to do so, see below.
|
||||
#'
|
||||
#' These functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#' These functions are context-aware. This means that the `x` argument can be left blank if used inside a [data.frame] call, see *Examples*.
|
||||
#'
|
||||
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but more efficient for data sets containing microorganism codes or names.
|
||||
#'
|
||||
@@ -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
|
||||
@@ -435,7 +435,7 @@ first_isolate <- function(x = NULL,
|
||||
if (length(c(row.start:row.end)) == pm_n_distinct(x[c(row.start:row.end), col_mo, drop = TRUE])) {
|
||||
if (info == TRUE) {
|
||||
message_("=> Found ", font_bold(paste(length(c(row.start:row.end)), "first isolates")),
|
||||
", as all isolates were different microorganisms",
|
||||
", as all isolates were different microbial species",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
#' [g.test()] performs chi-squared contingency table tests and goodness-of-fit tests, just like [chisq.test()] but is more reliable (1). A *G*-test can be used to see whether the number of observations in each category fits a theoretical expectation (called a ***G*-test of goodness-of-fit**), or to see whether the proportions of one variable are different for different values of the other variable (called a ***G*-test of independence**).
|
||||
#' @inheritSection lifecycle Questioning Lifecycle
|
||||
#' @inherit stats::chisq.test params return
|
||||
#' @details If `x` is a matrix with one row or column, or if `x` is a vector and `y` is not given, then a *goodness-of-fit test* is performed (`x` is treated as a one-dimensional contingency table). The entries of `x` must be non-negative integers. In this case, the hypothesis tested is whether the population probabilities equal those in `p`, or are all equal if `p` is not given.
|
||||
#' @details If `x` is a [matrix] with one row or column, or if `x` is a vector and `y` is not given, then a *goodness-of-fit test* is performed (`x` is treated as a one-dimensional contingency table). The entries of `x` must be non-negative integers. In this case, the hypothesis tested is whether the population probabilities equal those in `p`, or are all equal if `p` is not given.
|
||||
#'
|
||||
#' If `x` is a matrix with at least two rows and columns, it is taken as a two-dimensional contingency table: the entries of `x` must be non-negative integers. Otherwise, `x` and `y` must be vectors or factors of the same length; cases with missing values are removed, the objects are coerced to factors, and the contingency table is computed from these. Then Pearson's chi-squared test is performed of the null hypothesis that the joint distribution of the cell counts in a 2-dimensional contingency table is the product of the row and column marginals.
|
||||
#' If `x` is a [matrix] with at least two rows and columns, it is taken as a two-dimensional contingency table: the entries of `x` must be non-negative integers. Otherwise, `x` and `y` must be vectors or factors of the same length; cases with missing values are removed, the objects are coerced to factors, and the contingency table is computed from these. Then Pearson's chi-squared test is performed of the null hypothesis that the joint distribution of the cell counts in a 2-dimensional contingency table is the product of the row and column marginals.
|
||||
#'
|
||||
#' The p-value is computed from the asymptotic chi-squared distribution of the test statistic.
|
||||
#'
|
||||
|
||||
@@ -33,18 +33,18 @@
|
||||
#' @param labels_textsize the size of the text used for the labels
|
||||
#' @param labels_text_placement adjustment factor the placement of the variable names (`>=1` means further away from the arrow head)
|
||||
#' @param groups an optional vector of groups for the labels, with the same length as `labels`. If set, the points and labels will be coloured according to these groups. When using the [pca()] function as input for `x`, this will be determined automatically based on the attribute `non_numeric_cols`, see [pca()].
|
||||
#' @param ellipse a logical to indicate whether a normal data ellipse should be drawn for each group (set with `groups`)
|
||||
#' @param ellipse a [logical] to indicate whether a normal data ellipse should be drawn for each group (set with `groups`)
|
||||
#' @param ellipse_prob statistical size of the ellipse in normal probability
|
||||
#' @param ellipse_size the size of the ellipse line
|
||||
#' @param ellipse_alpha the alpha (transparency) of the ellipse line
|
||||
#' @param points_size the size of the points
|
||||
#' @param points_alpha the alpha (transparency) of the points
|
||||
#' @param arrows a logical to indicate whether arrows should be drawn
|
||||
#' @param arrows a [logical] to indicate whether arrows should be drawn
|
||||
#' @param arrows_textsize the size of the text for variable names
|
||||
#' @param arrows_colour the colour of the arrow and their text
|
||||
#' @param arrows_size the size (thickness) of the arrow lines
|
||||
#' @param arrows_textsize the size of the text at the end of the arrows
|
||||
#' @param arrows_textangled a logical whether the text at the end of the arrows should be angled
|
||||
#' @param arrows_textangled a [logical] whether the text at the end of the arrows should be angled
|
||||
#' @param arrows_alpha the alpha (transparency) of the arrows and their text
|
||||
#' @param base_textsize the text size for all plot elements except the labels and arrows
|
||||
#' @param ... arguments passed on to functions
|
||||
@@ -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,
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#' @param position position adjustment of bars, either `"fill"`, `"stack"` or `"dodge"`
|
||||
#' @param x variable to show on x axis, either `"antibiotic"` (default) or `"interpretation"` or a grouping variable
|
||||
#' @param fill variable to categorise using the plots legend, either `"antibiotic"` (default) or `"interpretation"` or a grouping variable
|
||||
#' @param breaks numeric vector of positions
|
||||
#' @param limits numeric vector of length two providing limits of the scale, use `NA` to refer to the existing minimum or maximum
|
||||
#' @param breaks a [numeric] vector of positions
|
||||
#' @param limits a [numeric] vector of length two providing limits of the scale, use `NA` to refer to the existing minimum or maximum
|
||||
#' @param facet variable to split plots by, either `"interpretation"` (default) or `"antibiotic"` or a grouping variable
|
||||
#' @inheritParams proportion
|
||||
#' @param nrow (when using `facet`) number of rows
|
||||
@@ -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,36 +115,35 @@
|
||||
#' ggplot() +
|
||||
#' geom_col(aes(x = x, y = y, fill = z)) +
|
||||
#' scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R")
|
||||
#'
|
||||
#' # resistance of ciprofloxacine per age group
|
||||
#' example_isolates %>%
|
||||
#' mutate(first_isolate = first_isolate()) %>%
|
||||
#' filter(first_isolate == TRUE,
|
||||
#' mo == as.mo("E. coli")) %>%
|
||||
#' # age_groups() is also a function in this AMR package:
|
||||
#' group_by(age_group = age_groups(age)) %>%
|
||||
#' select(age_group,
|
||||
#' CIP) %>%
|
||||
#' ggplot_rsi(x = "age_group")
|
||||
#'
|
||||
#' # a shorter version which also adjusts data label colours:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi(colours = FALSE)
|
||||
#'
|
||||
#'
|
||||
#' # it also supports groups (don't forget to use the group var on `x` or `facet`):
|
||||
#' example_isolates %>%
|
||||
#' select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' ggplot_rsi(x = "hospital_id",
|
||||
#' facet = "antibiotic",
|
||||
#' nrow = 1,
|
||||
#' title = "AMR of Anti-UTI Drugs Per Hospital",
|
||||
#' x.title = "Hospital",
|
||||
#' datalabels = FALSE)
|
||||
#' }
|
||||
#'
|
||||
#' \donttest{
|
||||
#' # resistance of ciprofloxacine per age group
|
||||
#' example_isolates %>%
|
||||
#' mutate(first_isolate = first_isolate(.)) %>%
|
||||
#' filter(first_isolate == TRUE,
|
||||
#' mo == as.mo("E. coli")) %>%
|
||||
#' # age_groups() is also a function in this AMR package:
|
||||
#' group_by(age_group = age_groups(age)) %>%
|
||||
#' select(age_group,
|
||||
#' CIP) %>%
|
||||
#' ggplot_rsi(x = "age_group")
|
||||
#'
|
||||
#' # a shorter version which also adjusts data label colours:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi(colours = FALSE)
|
||||
#'
|
||||
#'
|
||||
#' # it also supports groups (don't forget to use the group var on `x` or `facet`):
|
||||
#' example_isolates %>%
|
||||
#' select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' ggplot_rsi(x = "hospital_id",
|
||||
#' facet = "antibiotic",
|
||||
#' nrow = 1,
|
||||
#' title = "AMR of Anti-UTI Drugs Per Hospital",
|
||||
#' x.title = "Hospital",
|
||||
#' datalabels = FALSE)
|
||||
#' }
|
||||
ggplot_rsi <- function(data,
|
||||
position = NULL,
|
||||
|
||||
@@ -60,6 +60,7 @@ CATALOGUE_OF_LIFE <- list(
|
||||
globalVariables(c(".rowid",
|
||||
"ab",
|
||||
"ab_txt",
|
||||
"affect_ab_name",
|
||||
"affect_mo_name",
|
||||
"angle",
|
||||
"antibiotic",
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame]
|
||||
#' @param search_string a text to search `x` for, will be checked with [as.ab()] if this value is not a column in `x`
|
||||
#' @param verbose a logical to indicate whether additional info should be printed
|
||||
#' @param only_rsi_columns a logical to indicate whether only antibiotic columns must be detected that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @param verbose a [logical] to indicate whether additional info should be printed
|
||||
#' @param only_rsi_columns a [logical] to indicate whether only antibiotic columns must be detected that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @details You can look for an antibiotic (trade) name or abbreviation and it will search `x` and the [antibiotics] data set for any column containing a name or code of that antibiotic. **Longer columns names take precedence over shorter column names.**
|
||||
#' @return A column name of `x`, or `NULL` when no result is found.
|
||||
#' @export
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#'
|
||||
#' According to the binomial nomenclature, the lowest four taxonomic levels (family, genus, species, subspecies) should be printed in italic. This function finds taxonomic names within strings and makes them italic.
|
||||
#' @inheritSection lifecycle Maturing Lifecycle
|
||||
#' @param string a character (vector)
|
||||
#' @param string a [character] (vector)
|
||||
#' @param type type of conversion of the taxonomic names, either "markdown" or "ansi", see *Details*
|
||||
#' @details
|
||||
#' This function finds the taxonomic names and makes them italic based on the [microorganisms] data set.
|
||||
@@ -42,6 +42,16 @@
|
||||
#' italicise_taxonomy("An overview of S. aureus isolates")
|
||||
#'
|
||||
#' cat(italicise_taxonomy("An overview of S. aureus isolates", type = "ansi"))
|
||||
#'
|
||||
#' # 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"
|
||||
|
||||
@@ -25,23 +25,24 @@
|
||||
|
||||
#' Join [microorganisms] to a Data Set
|
||||
#'
|
||||
#' Join the data set [microorganisms] easily to an existing table or character vector.
|
||||
#' Join the data set [microorganisms] easily to an existing data set or to a [character] vector.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @rdname join
|
||||
#' @name join
|
||||
#' @aliases join inner_join
|
||||
#' @param x existing table to join, or character vector
|
||||
#' @param x existing data set to join, or [character] vector. In case of a [character] vector, the resulting [data.frame] will contain a column 'x' with these values.
|
||||
#' @param by a variable to join by - if left empty will search for a column with class [`mo`] (created with [as.mo()]) or will be `"mo"` if that column name exists in `x`, could otherwise be a column name of `x` with values that exist in `microorganisms$mo` (such as `by = "bacteria_id"`), or another column in [microorganisms] (but then it should be named, like `by = c("bacteria_id" = "fullname")`)
|
||||
#' @param suffix if there are non-joined duplicate variables in `x` and `y`, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2.
|
||||
#' @param suffix if there are non-joined duplicate variables in `x` and `y`, these suffixes will be added to the output to disambiguate them. Should be a [character] vector of length 2.
|
||||
#' @param ... ignored, only in place to allow future extensions
|
||||
#' @details **Note:** As opposed to the `join()` functions of `dplyr`, [character] vectors are supported and at default existing columns will get a suffix `"2"` and the newly joined columns will not get a suffix.
|
||||
#'
|
||||
#' If the `dplyr` package is installed, their join functions will be used. Otherwise, the much slower [merge()] function from base R will be used.
|
||||
#' If the `dplyr` package is installed, their join functions will be used. Otherwise, the much slower [merge()] and [interaction()] functions from base R will be used.
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @return a [data.frame]
|
||||
#' @export
|
||||
#' @examples
|
||||
#' left_join_microorganisms(as.mo("K. pneumoniae"))
|
||||
#' left_join_microorganisms("B_KLBSL_PNE")
|
||||
#' left_join_microorganisms("B_KLBSL_PNMN")
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
@@ -65,28 +66,7 @@ inner_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
|
||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
||||
|
||||
check_dataset_integrity()
|
||||
x <- check_groups_before_join(x, "inner_join_microorganisms")
|
||||
checked <- joins_check_df(x, by)
|
||||
x_class <- get_prejoined_class(x)
|
||||
x <- checked$x
|
||||
by <- checked$by
|
||||
# use dplyr if available - it's much faster
|
||||
dplyr_inner <- import_fn("inner_join", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(dplyr_inner)) {
|
||||
join <- suppressWarnings(
|
||||
dplyr_inner(x = x, y = microorganisms, by = by, suffix = suffix, ...)
|
||||
)
|
||||
} else {
|
||||
join <- suppressWarnings(
|
||||
pm_inner_join(x = x, y = microorganisms, by = by, suffix = suffix, ...)
|
||||
)
|
||||
}
|
||||
if (NROW(join) > NROW(x)) {
|
||||
warning_("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.")
|
||||
}
|
||||
class(join) <- x_class
|
||||
join
|
||||
join_microorganisms(type = "inner_join", x = x, by = by, suffix = suffix, ...)
|
||||
}
|
||||
|
||||
#' @rdname join
|
||||
@@ -96,28 +76,7 @@ left_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
|
||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
||||
|
||||
check_dataset_integrity()
|
||||
x <- check_groups_before_join(x, "left_join_microorganisms")
|
||||
checked <- joins_check_df(x, by)
|
||||
x_class <- get_prejoined_class(x)
|
||||
x <- checked$x
|
||||
by <- checked$by
|
||||
# use dplyr if available - it's much faster
|
||||
dplyr_left <- import_fn("left_join", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(dplyr_left)) {
|
||||
join <- suppressWarnings(
|
||||
dplyr_left(x = x, y = microorganisms, by = by, suffix = suffix, ...)
|
||||
)
|
||||
} else {
|
||||
join <- suppressWarnings(
|
||||
pm_left_join(x = x, y = microorganisms, by = by, suffix = suffix, ...)
|
||||
)
|
||||
}
|
||||
if (NROW(join) > NROW(x)) {
|
||||
warning_("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.")
|
||||
}
|
||||
class(join) <- x_class
|
||||
join
|
||||
join_microorganisms(type = "left_join", x = x, by = by, suffix = suffix, ...)
|
||||
}
|
||||
|
||||
#' @rdname join
|
||||
@@ -127,28 +86,7 @@ right_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
|
||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
||||
|
||||
check_dataset_integrity()
|
||||
x <- check_groups_before_join(x, "right_join_microorganisms")
|
||||
checked <- joins_check_df(x, by)
|
||||
x_class <- get_prejoined_class(x)
|
||||
x <- checked$x
|
||||
by <- checked$by
|
||||
# use dplyr if available - it's much faster
|
||||
dplyr_right <- import_fn("right_join", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(dplyr_right)) {
|
||||
join <- suppressWarnings(
|
||||
dplyr_right(x = x, y = microorganisms, by = by, suffix = suffix, ...)
|
||||
)
|
||||
} else {
|
||||
join <- suppressWarnings(
|
||||
pm_right_join(x = x, y = microorganisms, by = by, suffix = suffix, ...)
|
||||
)
|
||||
}
|
||||
if (NROW(join) > NROW(x)) {
|
||||
warning_("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.")
|
||||
}
|
||||
class(join) <- x_class
|
||||
join
|
||||
join_microorganisms(type = "right_join", x = x, by = by, suffix = suffix, ...)
|
||||
}
|
||||
|
||||
#' @rdname join
|
||||
@@ -158,28 +96,7 @@ full_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
|
||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
||||
|
||||
check_dataset_integrity()
|
||||
x <- check_groups_before_join(x, "full_join_microorganisms")
|
||||
checked <- joins_check_df(x, by)
|
||||
x_class <- get_prejoined_class(x)
|
||||
x <- checked$x
|
||||
by <- checked$by
|
||||
# use dplyr if available - it's much faster
|
||||
dplyr_full <- import_fn("full_join", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(dplyr_full)) {
|
||||
join <- suppressWarnings(
|
||||
dplyr_full(x = x, y = microorganisms, by = by, suffix = suffix, ...)
|
||||
)
|
||||
} else {
|
||||
join <- suppressWarnings(
|
||||
pm_full_join(x = x, y = microorganisms, by = by, suffix = suffix, ...)
|
||||
)
|
||||
}
|
||||
if (NROW(join) > NROW(x)) {
|
||||
warning_("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.")
|
||||
}
|
||||
class(join) <- x_class
|
||||
join
|
||||
join_microorganisms(type = "full_join", x = x, by = by, suffix = suffix, ...)
|
||||
}
|
||||
|
||||
#' @rdname join
|
||||
@@ -188,25 +105,7 @@ semi_join_microorganisms <- function(x, by = NULL, ...) {
|
||||
meet_criteria(x, allow_class = c("data.frame", "character"))
|
||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||
|
||||
check_dataset_integrity()
|
||||
x <- check_groups_before_join(x, "semi_join_microorganisms")
|
||||
x_class <- get_prejoined_class(x)
|
||||
checked <- joins_check_df(x, by)
|
||||
x <- checked$x
|
||||
by <- checked$by
|
||||
# use dplyr if available - it's much faster
|
||||
dplyr_semi <- import_fn("semi_join", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(dplyr_semi)) {
|
||||
join <- suppressWarnings(
|
||||
dplyr_semi(x = x, y = microorganisms, by = by, ...)
|
||||
)
|
||||
} else {
|
||||
join <- suppressWarnings(
|
||||
pm_semi_join(x = x, y = microorganisms, by = by, ...)
|
||||
)
|
||||
}
|
||||
class(join) <- x_class
|
||||
join
|
||||
join_microorganisms(type = "semi_join", x = x, by = by, ...)
|
||||
}
|
||||
|
||||
#' @rdname join
|
||||
@@ -215,72 +114,64 @@ anti_join_microorganisms <- function(x, by = NULL, ...) {
|
||||
meet_criteria(x, allow_class = c("data.frame", "character"))
|
||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||
|
||||
check_dataset_integrity()
|
||||
x <- check_groups_before_join(x, "anti_join_microorganisms")
|
||||
checked <- joins_check_df(x, by)
|
||||
x_class <- get_prejoined_class(x)
|
||||
x <- checked$x
|
||||
by <- checked$by
|
||||
# use dplyr if available - it's much faster
|
||||
dplyr_anti <- import_fn("anti_join", "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(dplyr_anti)) {
|
||||
join <- suppressWarnings(
|
||||
dplyr_anti(x = x, y = microorganisms, by = by, ...)
|
||||
)
|
||||
} else {
|
||||
join <- suppressWarnings(
|
||||
pm_anti_join(x = x, y = microorganisms, by = by, ...)
|
||||
)
|
||||
}
|
||||
class(join) <- x_class
|
||||
join
|
||||
join_microorganisms(type = "anti_join", x = x, by = by, ...)
|
||||
}
|
||||
|
||||
joins_check_df <- function(x, by) {
|
||||
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
||||
x <- data.frame(mo = as.mo(x), stringsAsFactors = FALSE)
|
||||
if (is.null(by)) {
|
||||
by <- "mo"
|
||||
}
|
||||
join_microorganisms <- function(type, x, by, suffix, ...) {
|
||||
check_dataset_integrity()
|
||||
|
||||
if (!is.data.frame(x)) {
|
||||
x <- data.frame(mo = x, stringsAsFactors = FALSE)
|
||||
by <- "mo"
|
||||
}
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
if (is.null(by)) {
|
||||
# search for column with class `mo` and return first one found
|
||||
by <- colnames(x)[lapply(x, is.mo) == TRUE][1]
|
||||
if (is.na(by)) {
|
||||
if ("mo" %in% colnames(x)) {
|
||||
by <- "mo"
|
||||
x[, "mo"] <- as.mo(x[, "mo"])
|
||||
} else {
|
||||
stop("Cannot join - no column found with name 'mo' or with class <mo>.", call. = FALSE)
|
||||
}
|
||||
by <- search_type_in_df(x, "mo", info = FALSE)
|
||||
if (is.null(by) && NCOL(x) == 1) {
|
||||
by <- colnames(x)[1L]
|
||||
} else {
|
||||
stop_if(is.null(by), "no column with microorganism names or codes found, set this column with `by`", call = -2)
|
||||
}
|
||||
message_('Joining, by = "', by, '"', add_fn = font_black, as_note = FALSE) # message same as dplyr::join functions
|
||||
}
|
||||
if (!all(x[, by, drop = TRUE] %in% MO_lookup$mo, na.rm = TRUE)) {
|
||||
x$join.mo <- as.mo(x[, by, drop = TRUE])
|
||||
by <- c("join.mo" = "mo")
|
||||
} else {
|
||||
x[, by] <- as.mo(x[, by, drop = TRUE])
|
||||
}
|
||||
|
||||
if (is.null(names(by))) {
|
||||
joinby <- colnames(microorganisms)[1]
|
||||
names(joinby) <- by
|
||||
# will always be joined to microorganisms$mo, so add name to that
|
||||
by <- stats::setNames("mo", by)
|
||||
}
|
||||
|
||||
# use dplyr if available - it's much faster than poorman alternatives
|
||||
dplyr_join <- import_fn(name = type, pkg = "dplyr", error_on_fail = FALSE)
|
||||
if (!is.null(dplyr_join)) {
|
||||
join_fn <- dplyr_join
|
||||
} else {
|
||||
joinby <- by
|
||||
# otherwise use poorman, see R/aa_helper_pm_functions.R
|
||||
join_fn <- get(paste0("pm_", type), envir = asNamespace("AMR"))
|
||||
}
|
||||
list(x = x,
|
||||
by = joinby)
|
||||
}
|
||||
|
||||
get_prejoined_class <- function(x) {
|
||||
if (is.data.frame(x)) {
|
||||
class(x)
|
||||
if (type %like% "full|left|right|inner") {
|
||||
joined <- join_fn(x = x, y = AMR::microorganisms, by = by, suffix = suffix, ...)
|
||||
} else {
|
||||
"data.frame"
|
||||
joined <- join_fn(x = x, y = AMR::microorganisms, by = by, ...)
|
||||
}
|
||||
}
|
||||
|
||||
check_groups_before_join <- function(x, fn) {
|
||||
if (is.data.frame(x) && !is.null(attributes(x)$groups)) {
|
||||
x <- pm_ungroup(x)
|
||||
attr(x, "groups") <- NULL
|
||||
class(x) <- class(x)[class(x) %unlike% "group"]
|
||||
warning_("Groups are dropped, since the ", fn, "() function relies on merge() from base R.", call = FALSE)
|
||||
|
||||
if ("join.mo" %in% colnames(joined)) {
|
||||
if ("mo" %in% colnames(joined)) {
|
||||
ind_mo <- which(colnames(joined) %in% c("mo", "join.mo"))
|
||||
colnames(joined)[ind_mo[1L]] <- paste0("mo", suffix[1L])
|
||||
colnames(joined)[ind_mo[2L]] <- paste0("mo", suffix[2L])
|
||||
} else {
|
||||
colnames(joined)[colnames(joined) == "join.mo"] <- "mo"
|
||||
}
|
||||
}
|
||||
x
|
||||
|
||||
if (type %like% "full|left|right|inner" && NROW(joined) > NROW(x)) {
|
||||
warning_("The newly joined data set contains ", nrow(joined) - nrow(x), " rows more than the number of rows of `x`.", call = FALSE)
|
||||
}
|
||||
|
||||
joined
|
||||
}
|
||||
@@ -28,18 +28,18 @@
|
||||
#' These functions can be used to determine first weighted isolates by considering the phenotype for isolate selection (see [first_isolate()]). Using a phenotype-based method to determine first isolates is more reliable than methods that disregard phenotypes.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank to determine automatically
|
||||
#' @param y,z character vectors to compare
|
||||
#' @param y,z [character] vectors to compare
|
||||
#' @inheritParams first_isolate
|
||||
#' @param universal names of **broad-spectrum** antimicrobial agents, case-insensitive. Set to `NULL` to ignore. See *Details* for the default agents.
|
||||
#' @param gram_negative names of antibiotic agents for **Gram-positives**, case-insensitive. Set to `NULL` to ignore. See *Details* for the default agents.
|
||||
#' @param gram_positive names of antibiotic agents for **Gram-negatives**, case-insensitive. Set to `NULL` to ignore. See *Details* for the default agents.
|
||||
#' @param antifungal names of antifungal agents for **fungi**, case-insensitive. Set to `NULL` to ignore. See *Details* for the default agents.
|
||||
#' @param only_rsi_columns a logical to indicate whether only columns must be included that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @param only_rsi_columns a [logical] to indicate whether only columns must be included that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @param ... ignored, only in place to allow future extensions
|
||||
#' @details
|
||||
#' The [key_antimicrobials()] and [all_antimicrobials()] functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#' The [key_antimicrobials()] and [all_antimicrobials()] functions are context-aware. This means that the `x` argument can be left blank if used inside a [data.frame] call, see *Examples*.
|
||||
#'
|
||||
#' The function [key_antimicrobials()] returns a character vector with 12 antimicrobial results for every isolate. The function [all_antimicrobials()] returns a character vector with all antimicrobial results for every isolate. These vectors can then be compared using [antimicrobials_equal()], to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (`"."`) by [key_antimicrobials()] and ignored by [antimicrobials_equal()].
|
||||
#' The function [key_antimicrobials()] returns a [character] vector with 12 antimicrobial results for every isolate. The function [all_antimicrobials()] returns a [character] vector with all antimicrobial results for every isolate. These vectors can then be compared using [antimicrobials_equal()], to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (`"."`) by [key_antimicrobials()] and ignored by [antimicrobials_equal()].
|
||||
#'
|
||||
#' Please see the [first_isolate()] function how these important functions enable the 'phenotype-based' method for determination of first isolates.
|
||||
#'
|
||||
@@ -96,7 +96,7 @@
|
||||
#' # TRUE, because I is ignored (as well as missing values)
|
||||
#'
|
||||
#' antimicrobials_equal(strainA, strainB, type = "keyantimicrobials", ignore_I = FALSE)
|
||||
#' # FALSE, because I is not ignored and so the 4th character differs
|
||||
#' # FALSE, because I is not ignored and so the 4th [character] differs
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#' @description Kurtosis is a measure of the "tailedness" of the probability distribution of a real-valued random variable. A normal distribution has a kurtosis of 3 and a excess kurtosis of 0.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a vector of values, a [matrix] or a [data.frame]
|
||||
#' @param na.rm a logical to indicate whether `NA` values should be stripped before the computation proceeds
|
||||
#' @param excess a logical to indicate whether the *excess kurtosis* should be returned, defined as the kurtosis minus 3.
|
||||
#' @param na.rm a [logical] to indicate whether `NA` values should be stripped before the computation proceeds
|
||||
#' @param excess a [logical] to indicate whether the *excess kurtosis* should be returned, defined as the kurtosis minus 3.
|
||||
#' @seealso [skewness()]
|
||||
#' @rdname kurtosis
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#'
|
||||
#' Convenient wrapper around [grepl()] to match a pattern: `x %like% pattern`. It always returns a [`logical`] vector and is always case-insensitive (use `x %like_case% pattern` for case-sensitive matching). Also, `pattern` can be as long as `x` to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a character vector where matches are sought, or an object which can be coerced by [as.character()] to a character vector.
|
||||
#' @param pattern a character vector containing regular expressions (or a [character] string for `fixed = TRUE`) to be matched in the given character vector. Coerced by [as.character()] to a character string if possible.
|
||||
#' @param x a [character] vector where matches are sought, or an object which can be coerced by [as.character()] to a [character] vector.
|
||||
#' @param pattern a [character] vector containing regular expressions (or a [character] string for `fixed = TRUE`) to be matched in the given [character] vector. Coerced by [as.character()] to a [character] string if possible.
|
||||
#' @param ignore.case if `FALSE`, the pattern matching is *case sensitive* and if `TRUE`, case is ignored during matching.
|
||||
#' @return A [logical] vector
|
||||
#' @name like
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
#' @inheritParams eucast_rules
|
||||
#' @param pct_required_classes minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for *S. aureus*. Setting this `pct_required_classes` argument to `0.5` (default) means that for every *S. aureus* isolate at least 8 different classes must be available. Any lower number of available classes will return `NA` for that isolate.
|
||||
#' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so resistance is only considered when isolates are R, not I. As this is the default behaviour of the [mdro()] function, it follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. When using `combine_SI = FALSE`, resistance is considered when isolates are R or I.
|
||||
#' @param verbose a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.
|
||||
#' @param verbose a [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.
|
||||
#' @inheritSection eucast_rules Antibiotics
|
||||
#' @details
|
||||
#' These functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#' These functions are context-aware. This means that the `x` argument can be left blank if used inside a [data.frame] call, see *Examples*.
|
||||
#'
|
||||
#' For the `pct_required_classes` argument, values above 1 will be divided by 100. This is to support both fractions (`0.75` or `3/4`) and percentages (`75`).
|
||||
#'
|
||||
@@ -136,7 +136,7 @@
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @source
|
||||
#' See the supported guidelines above for the list of publications used for this function.
|
||||
#' See the supported guidelines above for the [list] of publications used for this function.
|
||||
#' @examples
|
||||
#' mdro(example_isolates, guideline = "EUCAST")
|
||||
#'
|
||||
@@ -232,7 +232,7 @@ mdro <- function(x = NULL,
|
||||
}
|
||||
}
|
||||
|
||||
# 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)
|
||||
|
||||
if (pct_required_classes > 1) {
|
||||
@@ -252,7 +252,7 @@ mdro <- function(x = NULL,
|
||||
if (info == TRUE) {
|
||||
txt <- paste0("Determining MDROs based on custom rules",
|
||||
ifelse(isTRUE(attributes(guideline)$as_factor),
|
||||
paste0(", resulting in factor levels: ", paste0(attributes(guideline)$values, collapse = " < ")),
|
||||
paste0(", resulting in [factor] levels: ", paste0(attributes(guideline)$values, collapse = " < ")),
|
||||
""),
|
||||
".")
|
||||
txt <- word_wrap(txt)
|
||||
@@ -306,7 +306,7 @@ mdro <- function(x = NULL,
|
||||
}
|
||||
if (is.null(col_mo) & guideline$code == "tb") {
|
||||
message_("No column found as input for `col_mo`, ",
|
||||
font_bold(paste0("assuming all records contain", font_italic("Mycobacterium tuberculosis"), ".")))
|
||||
font_bold(paste0("assuming all rows contain ", font_italic("Mycobacterium tuberculosis"), ".")))
|
||||
x$mo <- as.mo("Mycobacterium tuberculosis") # consider overkill at all times: MO_lookup[which(MO_lookup$fullname == "Mycobacterium tuberculosis"), "mo", drop = TRUE]
|
||||
col_mo <- "mo"
|
||||
}
|
||||
@@ -361,7 +361,7 @@ mdro <- function(x = NULL,
|
||||
if (guideline$code == "cmi2012") {
|
||||
cols_ab <- get_column_abx(x = x,
|
||||
soft_dependencies = c(
|
||||
# table 1 (S aureus):
|
||||
# [table] 1 (S aureus):
|
||||
"GEN",
|
||||
"RIF",
|
||||
"CPT",
|
||||
@@ -384,7 +384,7 @@ mdro <- function(x = NULL,
|
||||
"TCY",
|
||||
"DOX",
|
||||
"MNO",
|
||||
# table 2 (Enterococcus)
|
||||
# [table] 2 (Enterococcus)
|
||||
"GEH",
|
||||
"STH",
|
||||
"IPM",
|
||||
@@ -402,7 +402,7 @@ mdro <- function(x = NULL,
|
||||
"QDA",
|
||||
"DOX",
|
||||
"MNO",
|
||||
# table 3 (Enterobacteriaceae)
|
||||
# [table] 3 (Enterobacteriaceae)
|
||||
"GEN",
|
||||
"TOB",
|
||||
"AMK",
|
||||
@@ -434,7 +434,7 @@ mdro <- function(x = NULL,
|
||||
"TCY",
|
||||
"DOX",
|
||||
"MNO",
|
||||
# table 4 (Pseudomonas)
|
||||
# [table] 4 (Pseudomonas)
|
||||
"GEN",
|
||||
"TOB",
|
||||
"AMK",
|
||||
@@ -452,7 +452,7 @@ mdro <- function(x = NULL,
|
||||
"FOS",
|
||||
"COL",
|
||||
"PLB",
|
||||
# table 5 (Acinetobacter)
|
||||
# [table] 5 (Acinetobacter)
|
||||
"GEN",
|
||||
"TOB",
|
||||
"AMK",
|
||||
@@ -1340,7 +1340,7 @@ mdro <- function(x = NULL,
|
||||
ab
|
||||
}
|
||||
drug_is_R <- function(ab) {
|
||||
# returns logical vector
|
||||
# returns [logical] vector
|
||||
ab <- prepare_drug(ab)
|
||||
if (length(ab) == 0) {
|
||||
rep(FALSE, NROW(x))
|
||||
@@ -1351,7 +1351,7 @@ mdro <- function(x = NULL,
|
||||
}
|
||||
}
|
||||
drug_is_not_R <- function(ab) {
|
||||
# returns logical vector
|
||||
# returns [logical] vector
|
||||
ab <- prepare_drug(ab)
|
||||
if (length(ab) == 0) {
|
||||
rep(TRUE, NROW(x))
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
#' This ransforms vectors to a new class [`mic`], which treats the input as decimal numbers, while maintaining operators (such as ">=") and only allowing valid MIC values known to the field of (medical) microbiology.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @rdname as.mic
|
||||
#' @param x character or numeric vector
|
||||
#' @param na.rm a logical indicating whether missing values should be removed
|
||||
#' @param x a [character] or [numeric] vector
|
||||
#' @param na.rm a [logical] indicating whether missing values should be removed
|
||||
#' @details To interpret MIC values as RSI values, use [as.rsi()] on MIC values. It supports guidelines from EUCAST and CLSI.
|
||||
#'
|
||||
#' This class for MIC values is a quite a special data type: formally it is an ordered factor with valid MIC values as factor levels (to make sure only valid MIC values are retained), but for any mathematical operation it acts as decimal numbers:
|
||||
#' This class for MIC values is a quite a special data type: formally it is an ordered [factor] with valid MIC values as [factor] levels (to make sure only valid MIC values are retained), but for any mathematical operation it acts as decimal numbers:
|
||||
#'
|
||||
#' ```
|
||||
#' x <- random_mic(10)
|
||||
@@ -50,7 +50,7 @@
|
||||
#' #> [1] 26
|
||||
#' ```
|
||||
#'
|
||||
#' This makes it possible to maintain operators that often come with MIC values, such ">=" and "<=", even when filtering using numeric values in data analysis, e.g.:
|
||||
#' This makes it possible to maintain operators that often come with MIC values, such ">=" and "<=", even when filtering using [numeric] values in data analysis, e.g.:
|
||||
#'
|
||||
#' ```
|
||||
#' x[x > 4]
|
||||
@@ -69,7 +69,7 @@
|
||||
#' ```
|
||||
#'
|
||||
#' The following [generic functions][groupGeneric()] are implemented for the MIC class: `!`, `!=`, `%%`, `%/%`, `&`, `*`, `+`, `-`, `/`, `<`, `<=`, `==`, `>`, `>=`, `^`, `|`, [abs()], [acos()], [acosh()], [all()], [any()], [asin()], [asinh()], [atan()], [atanh()], [ceiling()], [cos()], [cosh()], [cospi()], [cummax()], [cummin()], [cumprod()], [cumsum()], [digamma()], [exp()], [expm1()], [floor()], [gamma()], [lgamma()], [log()], [log1p()], [log2()], [log10()], [max()], [mean()], [min()], [prod()], [range()], [round()], [sign()], [signif()], [sin()], [sinh()], [sinpi()], [sqrt()], [sum()], [tan()], [tanh()], [tanpi()], [trigamma()] and [trunc()]. Some functions of the `stats` package are also implemented: [median()], [quantile()], [mad()], [IQR()], [fivenum()]. Also, [boxplot.stats()] is supported. Since [sd()] and [var()] are non-generic functions, these could not be extended. Use [mad()] as an alternative, or use e.g. `sd(as.numeric(x))` where `x` is your vector of MIC values.
|
||||
#' @return Ordered [factor] with additional class [`mic`], that in mathematical operations acts as decimal numbers. Bare in mind that the outcome of any mathematical operation on MICs will return a numeric value.
|
||||
#' @return Ordered [factor] with additional class [`mic`], that in mathematical operations acts as decimal numbers. Bare in mind that the outcome of any mathematical operation on MICs will return a [numeric] value.
|
||||
#' @aliases mic
|
||||
#' @export
|
||||
#' @seealso [as.rsi()]
|
||||
@@ -81,7 +81,7 @@
|
||||
#' # this can also coerce combined MIC/RSI values:
|
||||
#' as.mic("<=0.002; S") # will return <=0.002
|
||||
#'
|
||||
#' # mathematical processing treats MICs as numeric values
|
||||
#' # mathematical processing treats MICs as [numeric] values
|
||||
#' fivenum(mic_data)
|
||||
#' quantile(mic_data)
|
||||
#' all(mic_data < 512)
|
||||
@@ -149,7 +149,7 @@ as.mic <- function(x, na.rm = FALSE) {
|
||||
## previously unempty values now empty - should return a warning later on
|
||||
x[x.bak != "" & x == ""] <- "invalid"
|
||||
|
||||
# these are allowed MIC values and will become factor levels
|
||||
# these are allowed MIC values and will become [factor] levels
|
||||
ops <- c("<", "<=", "", ">=", ">")
|
||||
lvls <- c(c(t(vapply(FUN.VALUE = character(9), ops, function(x) paste0(x, "0.00", 1:9)))),
|
||||
unique(c(t(vapply(FUN.VALUE = character(104), ops, function(x) paste0(x, sort(as.double(paste0("0.0",
|
||||
@@ -345,11 +345,12 @@ hist.mic <- function(x, ...) {
|
||||
get_skimmers.mic <- function(column) {
|
||||
skimr::sfl(
|
||||
skim_type = "mic",
|
||||
min = ~min(., na.rm = TRUE),
|
||||
max = ~max(., na.rm = TRUE),
|
||||
median = ~stats::median(., na.rm = TRUE),
|
||||
n_unique = ~length(unique(stats::na.omit(.))),
|
||||
hist_log2 = ~skimr::inline_hist(log2(stats::na.omit(.)))
|
||||
p0 = ~stats::quantile(., probs = 0, na.rm = TRUE, names = FALSE),
|
||||
p25 = ~stats::quantile(., probs = 0.25, na.rm = TRUE, names = FALSE),
|
||||
p50 = ~stats::quantile(., probs = 0.5, na.rm = TRUE, names = FALSE),
|
||||
p75 = ~stats::quantile(., probs = 0.75, na.rm = TRUE, names = FALSE),
|
||||
p100 = ~stats::quantile(., probs = 1, na.rm = TRUE, names = FALSE),
|
||||
hist = ~skimr::inline_hist(log2(stats::na.omit(.)), 5)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
#'
|
||||
#' Use this function to determine a valid microorganism ID ([`mo`]). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea and most microbial species from the kingdom Fungi (see *Source*). The input can be almost anything: a full name (like `"Staphylococcus aureus"`), an abbreviated name (such as `"S. aureus"`), an abbreviation known in the field (such as `"MRSA"`), or just a genus. See *Examples*.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a character vector or a [data.frame] with one or two columns
|
||||
#' @param Becker a logical to indicate whether staphylococci should be categorised into coagulase-negative staphylococci ("CoNS") and coagulase-positive staphylococci ("CoPS") instead of their own species, according to Karsten Becker *et al.* (1,2,3).
|
||||
#' @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).
|
||||
#'
|
||||
#' This excludes *Staphylococcus aureus* at default, use `Becker = "all"` to also categorise *S. aureus* as "CoPS".
|
||||
#' @param Lancefield a logical to indicate whether beta-haemolytic *Streptococci* should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield (4). These *Streptococci* will be categorised in their first group, e.g. *Streptococcus dysgalactiae* will be group C, although officially it was also categorised into groups G and L.
|
||||
#' @param Lancefield a [logical] to indicate whether beta-haemolytic *Streptococci* should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield (4). These *Streptococci* will be categorised in their first group, e.g. *Streptococcus dysgalactiae* will be group C, although officially it was also categorised into groups G and L.
|
||||
#'
|
||||
#' This excludes *Enterococci* at default (who are in group D), use `Lancefield = "all"` to also categorise all *Enterococci* as group D.
|
||||
#' @param allow_uncertain a number between `0` (or `"none"`) and `3` (or `"all"`), or `TRUE` (= `2`) or `FALSE` (= `0`) to indicate whether the input should be checked for less probable results, see *Details*
|
||||
@@ -245,10 +245,10 @@ is.mo <- function(x) {
|
||||
}
|
||||
|
||||
# param property a column name of microorganisms
|
||||
# param initial_search logical - is FALSE when coming from uncertain tries, which uses exec_as.mo internally too
|
||||
# param dyslexia_mode logical - also check for characters that resemble others
|
||||
# param debug logical - show different lookup texts while searching
|
||||
# param reference_data_to_use data.frame - the data set to check for
|
||||
# param initial_search [logical] - is FALSE when coming from uncertain tries, which uses exec_as.mo internally too
|
||||
# param dyslexia_mode [logical] - also check for characters that resemble others
|
||||
# param debug [logical] - show different lookup texts while searching
|
||||
# param reference_data_to_use [data.frame] - the data set to check for
|
||||
# param actual_uncertainty - (only for initial_search = FALSE) the actual uncertainty level used in the function for score calculation (sometimes passed as 2 or 3 by uncertain_fn())
|
||||
# param actual_input - (only for initial_search = FALSE) the actual, original input
|
||||
# param language - used for translating "no growth", etc.
|
||||
@@ -304,7 +304,7 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
|
||||
# `column` can be NULL for all columns, or a selection
|
||||
# returns a character (vector) - if `column` > length 1 then with columns as names
|
||||
# returns a [character] (vector) - if `column` > length 1 then with columns as names
|
||||
if (isTRUE(debug_mode)) {
|
||||
cat(font_silver("Looking up: ", substitute(needle), collapse = ""),
|
||||
"\n ", time_track())
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#'
|
||||
#' Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. See *Examples*.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x any character (vector) that can be coerced to a valid microorganism code with [as.mo()]. Can be left blank for auto-guessing the column containing microorganism codes if used in a data set, see *Examples*.
|
||||
#' @param x any [character] (vector) that can be coerced to a valid microorganism code with [as.mo()]. Can be left blank for auto-guessing the column containing microorganism codes if used in a data set, see *Examples*.
|
||||
#' @param property one of the column names of the [microorganisms] data set: `r vector_or(colnames(microorganisms), sort = FALSE, quotes = TRUE)`, or must be `"shortname"`
|
||||
#' @param language language of the returned text, defaults to system language (see [get_locale()]) and can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`, see [translate]. Also used to translate text like "no growth". Use `language = NULL` or `language = ""` to prevent translation.
|
||||
#' @param ... other arguments passed on to [as.mo()], such as 'allow_uncertain' and 'ignore_pattern'
|
||||
@@ -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
|
||||
@@ -178,7 +180,7 @@ mo_name <- function(x, language = get_locale(), ...) {
|
||||
translate_AMR(mo_validate(x = x, property = "fullname", language = language, ...),
|
||||
language = language,
|
||||
only_unknown = FALSE,
|
||||
affect_mo_name = TRUE)
|
||||
only_affect_mo_names = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname mo_property
|
||||
@@ -220,7 +222,7 @@ mo_shortname <- function(x, language = get_locale(), ...) {
|
||||
|
||||
shortnames[is.na(x.mo)] <- NA_character_
|
||||
load_mo_failures_uncertainties_renamed(metadata)
|
||||
translate_AMR(shortnames, language = language, only_unknown = FALSE, affect_mo_name = TRUE)
|
||||
translate_AMR(shortnames, language = language, only_unknown = FALSE, only_affect_mo_names = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname mo_property
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#'
|
||||
#' Performs a principal component analysis (PCA) based on a data set with automatic determination for afterwards plotting the groups and labels, and automatic filtering on only suitable (i.e. non-empty and numeric) variables.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame] containing numeric columns
|
||||
#' @param x a [data.frame] containing [numeric] columns
|
||||
#' @param ... columns of `x` to be selected for PCA, can be unquoted since it supports quasiquotation.
|
||||
#' @inheritParams stats::prcomp
|
||||
#' @details The [pca()] function takes a [data.frame] as input and performs the actual PCA with the \R function [prcomp()].
|
||||
#'
|
||||
#' The result of the [pca()] function is a [prcomp] object, with an additional attribute `non_numeric_cols` which is a vector with the column names of all columns that do not contain numeric values. These are probably the groups and labels, and will be used by [ggplot_pca()].
|
||||
#' The result of the [pca()] function is a [prcomp] object, with an additional attribute `non_numeric_cols` which is a vector with the column names of all columns that do not contain [numeric] values. These are probably the groups and labels, and will be used by [ggplot_pca()].
|
||||
#' @return An object of classes [pca] and [prcomp]
|
||||
#' @importFrom stats prcomp
|
||||
#' @export
|
||||
@@ -42,7 +42,6 @@
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' \donttest{
|
||||
#'
|
||||
#' if (require("dplyr")) {
|
||||
#' # calculate the resistance per group first
|
||||
#' resistance_data <- example_isolates %>%
|
||||
@@ -99,7 +98,7 @@ pca <- function(x,
|
||||
|
||||
x <- as.data.frame(new_list, stringsAsFactors = FALSE)
|
||||
if (any(vapply(FUN.VALUE = logical(1), x, function(y) !is.numeric(y)))) {
|
||||
warning_("Be sure to first calculate the resistance (or susceptibility) of variables with antimicrobial test results, since PCA works with numeric variables only. See Examples in ?pca.", call = FALSE)
|
||||
warning_("Be sure to first calculate the resistance (or susceptibility) of variables with antimicrobial test results, since PCA works with [numeric] variables only. See Examples in ?pca.", call = FALSE)
|
||||
}
|
||||
|
||||
# set column names
|
||||
@@ -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 (as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 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 {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#' @param guideline interpretation guideline to use, defaults to the latest included EUCAST guideline, see *Details*
|
||||
#' @param colours_RSI colours to use for filling in the bars, must be a vector of three values (in the order R, S and I). The default colours are colour-blind friendly.
|
||||
#' @param language language to be used to translate 'Susceptible', 'Increased exposure'/'Intermediate' and 'Resistant', defaults to system language (see [get_locale()]) and can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`, see [translate]. Use `language = NULL` or `language = ""` to prevent translation.
|
||||
#' @param expand logical to indicate whether the range on the x axis should be expanded between the lowest and highest value. For MIC values, intermediate values will be factors of 2 starting from the highest MIC value. For disk diameters, the whole diameter range will be filled.
|
||||
#' @param expand a [logical] to indicate whether the range on the x axis should be expanded between the lowest and highest value. For MIC values, intermediate values will be factors of 2 starting from the highest MIC value. For disk diameters, the whole diameter range will be filled.
|
||||
#' @details
|
||||
#' The interpretation of "I" will be named "Increased exposure" for all EUCAST guidelines since 2019, and will be named "Intermediate" in all other cases.
|
||||
#'
|
||||
@@ -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
|
||||
@@ -656,6 +658,8 @@ ggplot.rsi <- function(data,
|
||||
}
|
||||
|
||||
plot_prepare_table <- function(x, expand) {
|
||||
x <- x[!is.na(x)]
|
||||
stop_if(length(x) == 0, "no observations to plot", call = FALSE)
|
||||
if (is.mic(x)) {
|
||||
if (expand == TRUE) {
|
||||
# expand range for MIC by adding factors of 2 from lowest to highest so all MICs in between also print
|
||||
|
||||
@@ -31,18 +31,18 @@
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with [as.rsi()] if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See *Examples*.
|
||||
#' @param minimum the minimum allowed number of available (tested) isolates. Any isolate count lower than `minimum` will return `NA` with a warning. The default number of `30` isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see *Source*.
|
||||
#' @param as_percent a logical to indicate whether the output must be returned as a hundred fold with % sign (a character). A value of `0.123456` will then be returned as `"12.3%"`.
|
||||
#' @param only_all_tested (for combination therapies, i.e. using more than one variable for `...`): a logical to indicate that isolates must be tested for all antibiotics, see section *Combination Therapy* below
|
||||
#' @param as_percent a [logical] to indicate whether the output must be returned as a hundred fold with % sign (a character). A value of `0.123456` will then be returned as `"12.3%"`.
|
||||
#' @param only_all_tested (for combination therapies, i.e. using more than one variable for `...`): a [logical] to indicate that isolates must be tested for all antibiotics, see section *Combination Therapy* below
|
||||
#' @param data a [data.frame] containing columns with class [`rsi`] (see [as.rsi()])
|
||||
#' @param translate_ab a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]
|
||||
#' @inheritParams ab_property
|
||||
#' @param combine_SI a logical to indicate whether all values of S and I must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the argument `combine_IR`, but this now follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. Default is `TRUE`.
|
||||
#' @param combine_IR a logical to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. I+R (susceptible vs. non-susceptible). This is outdated, see argument `combine_SI`.
|
||||
#' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the argument `combine_IR`, but this now follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. Default is `TRUE`.
|
||||
#' @param combine_IR a [logical] to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. I+R (susceptible vs. non-susceptible). This is outdated, see argument `combine_SI`.
|
||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||
#' @details
|
||||
#' The function [resistance()] is equal to the function [proportion_R()]. The function [susceptibility()] is equal to the function [proportion_SI()].
|
||||
#'
|
||||
#' **Remember that you should filter your table to let it contain only first isolates!** This is needed to exclude duplicates and to reduce selection bias. Use [first_isolate()] to determine them in your data set.
|
||||
#' **Remember that you should filter your data to let it contain only first isolates!** This is needed to exclude duplicates and to reduce selection bias. Use [first_isolate()] to determine them in your data set.
|
||||
#'
|
||||
#' These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the [`count()`][AMR::count()] functions to count isolates. The function [susceptibility()] is essentially equal to `count_susceptible() / count_all()`. *Low counts can influence the outcome - the `proportion` functions may camouflage this, since they only return the proportion (albeit being dependent on the `minimum` argument).*
|
||||
#'
|
||||
@@ -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,
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#' These functions can be used for generating random MIC values and disk diffusion diameters, for AMR data analysis practice. By providing a microorganism and antimicrobial agent, the generated results will reflect reality as much as possible.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param size desired size of the returned vector
|
||||
#' @param mo any character that can be coerced to a valid microorganism code with [as.mo()]
|
||||
#' @param ab any character that can be coerced to a valid antimicrobial agent code with [as.ab()]
|
||||
#' @param mo any [character] that can be coerced to a valid microorganism code with [as.mo()]
|
||||
#' @param ab any [character] that can be coerced to a valid antimicrobial agent code with [as.ab()]
|
||||
#' @param prob_RSI a vector of length 3: the probabilities for R (1st value), S (2nd value) and I (3rd value)
|
||||
#' @param ... ignored, only in place to allow future extensions
|
||||
#' @details The base R function [sample()] is used for generating values.
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
#' @param year_every unit of sequence between lowest year found in the data and `year_max`
|
||||
#' @param minimum minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.
|
||||
#' @param model the statistical model of choice. This could be a generalised linear regression model with binomial distribution (i.e. using `glm(..., family = binomial)``, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See *Details* for all valid options.
|
||||
#' @param I_as_S a logical to indicate whether values `"I"` should be treated as `"S"` (will otherwise be treated as `"R"`). The default, `TRUE`, follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section *Interpretation of S, I and R* below.
|
||||
#' @param preserve_measurements a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be `NA`.
|
||||
#' @param info a logical to indicate whether textual analysis should be printed with the name and [summary()] of the statistical model.
|
||||
#' @param I_as_S a [logical] to indicate whether values `"I"` should be treated as `"S"` (will otherwise be treated as `"R"`). The default, `TRUE`, follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section *Interpretation of S, I and R* below.
|
||||
#' @param preserve_measurements a [logical] to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be `NA`.
|
||||
#' @param info a [logical] to indicate whether textual analysis should be printed with the name and [summary()] of the statistical model.
|
||||
#' @param main title of the plot
|
||||
#' @param ribbon a logical to indicate whether a ribbon should be shown (default) or error bars
|
||||
#' @param ribbon a [logical] to indicate whether a ribbon should be shown (default) or error bars
|
||||
#' @param ... arguments passed on to functions
|
||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||
#' @inheritParams first_isolate
|
||||
@@ -70,6 +70,7 @@
|
||||
#' year_min = 2010,
|
||||
#' model = "binomial")
|
||||
#' plot(x)
|
||||
#' \donttest{
|
||||
#' if (require("ggplot2")) {
|
||||
#' ggplot_rsi_predict(x)
|
||||
#' }
|
||||
@@ -97,8 +98,10 @@
|
||||
#' model = "binomial",
|
||||
#' 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,
|
||||
@@ -347,6 +351,20 @@ plot.resistance_predict <- function(x, main = paste("Resistance Prediction of",
|
||||
col = "grey40")
|
||||
}
|
||||
|
||||
|
||||
#' @method ggplot resistance_predict
|
||||
#' @rdname resistance_predict
|
||||
# will be exported using s3_register() in R/zzz.R
|
||||
ggplot.resistance_predict <- function(x,
|
||||
main = paste("Resistance Prediction of", x_name),
|
||||
ribbon = TRUE,
|
||||
...) {
|
||||
x_name <- paste0(ab_name(attributes(x)$ab), " (", attributes(x)$ab, ")")
|
||||
meet_criteria(main, allow_class = "character", has_length = 1)
|
||||
meet_criteria(ribbon, allow_class = "logical", has_length = 1)
|
||||
ggplot_rsi_predict(x = x, main = main, ribbon = ribbon, ...)
|
||||
}
|
||||
|
||||
#' @rdname resistance_predict
|
||||
#' @export
|
||||
ggplot_rsi_predict <- function(x,
|
||||
@@ -360,14 +378,14 @@ ggplot_rsi_predict <- function(x,
|
||||
stop_ifnot_installed("ggplot2")
|
||||
stop_ifnot(inherits(x, "resistance_predict"), "`x` must be a resistance prediction model created with resistance_predict()")
|
||||
|
||||
|
||||
if (attributes(x)$I_as_S == TRUE) {
|
||||
ylab <- "%R"
|
||||
} else {
|
||||
ylab <- "%IR"
|
||||
}
|
||||
|
||||
p <- ggplot2::ggplot(x, ggplot2::aes(x = year, y = value)) +
|
||||
p <- ggplot2::ggplot(as.data.frame(x, stringsAsFactors = FALSE),
|
||||
ggplot2::aes(x = year, y = value)) +
|
||||
ggplot2::geom_point(data = subset(x, !is.na(observations)),
|
||||
size = 2) +
|
||||
scale_y_percent(limits = c(0, 1)) +
|
||||
|
||||
@@ -25,17 +25,17 @@
|
||||
|
||||
#' Interpret MIC and Disk Values, or Clean Raw R/SI Data
|
||||
#'
|
||||
#' Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class [`rsi`], which is an ordered factor with levels `S < I < R`. Values that cannot be interpreted will be returned as `NA` with a warning.
|
||||
#' Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class [`rsi`], which is an ordered [factor] with levels `S < I < R`.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @rdname as.rsi
|
||||
#' @param x vector of values (for class [`mic`]: an MIC value in mg/L, for class [`disk`]: a disk diffusion radius in millimetres)
|
||||
#' @param mo any (vector of) text that can be coerced to a valid microorganism code with [as.mo()], can be left empty to determine it automatically
|
||||
#' @param x vector of values (for class [`mic`]: MIC values in mg/L, for class [`disk`]: a disk diffusion radius in millimetres)
|
||||
#' @param mo any (vector of) text that can be coerced to valid microorganism codes with [as.mo()], can be left empty to determine it automatically
|
||||
#' @param ab any (vector of) text that can be coerced to a valid antimicrobial code with [as.ab()]
|
||||
#' @param uti (Urinary Tract Infection) A vector with [logical]s (`TRUE` or `FALSE`) to specify whether a UTI specific interpretation from the guideline should be chosen. For using [as.rsi()] on a [data.frame], this can also be a column containing [logical]s or when left blank, the data set will be searched for a 'specimen' and rows containing 'urin' (such as 'urine', 'urina') in that column will be regarded isolates from a UTI. See *Examples*.
|
||||
#' @param uti (Urinary Tract Infection) A vector with [logical]s (`TRUE` or `FALSE`) to specify whether a UTI specific interpretation from the guideline should be chosen. For using [as.rsi()] on a [data.frame], this can also be a column containing [logical]s or when left blank, the data set will be searched for a column 'specimen', and rows within this column containing 'urin' (such as 'urine', 'urina') will be regarded isolates from a UTI. See *Examples*.
|
||||
#' @inheritParams first_isolate
|
||||
#' @param guideline defaults to the latest included EUCAST guideline, see *Details* for all options
|
||||
#' @param conserve_capped_values a logical to indicate that MIC values starting with `">"` (but not `">="`) must always return "R" , and that MIC values starting with `"<"` (but not `"<="`) must always return "S"
|
||||
#' @param add_intrinsic_resistance *(only useful when using a EUCAST guideline)* a logical to indicate whether intrinsic antibiotic resistance must also be considered for applicable bug-drug combinations, meaning that e.g. ampicillin will always return "R" in *Klebsiella* species. Determination is based on the [intrinsic_resistant] data set, that itself is based on `r format_eucast_version_nr(3.2)`.
|
||||
#' @param conserve_capped_values a [logical] to indicate that MIC values starting with `">"` (but not `">="`) must always return "R" , and that MIC values starting with `"<"` (but not `"<="`) must always return "S"
|
||||
#' @param add_intrinsic_resistance *(only useful when using a EUCAST guideline)* a [logical] to indicate whether intrinsic antibiotic resistance must also be considered for applicable bug-drug combinations, meaning that e.g. ampicillin will always return "R" in *Klebsiella* species. Determination is based on the [intrinsic_resistant] data set, that itself is based on `r format_eucast_version_nr(3.2)`.
|
||||
#' @param reference_data a [data.frame] to be used for interpretation, which defaults to the [rsi_translation] data set. Changing this argument allows for using own interpretation guidelines. This argument must contain a data set that is equal in structure to the [rsi_translation] data set (same column names and column types). Please note that the `guideline` argument will be ignored when `reference_data` is manually set.
|
||||
#' @param threshold maximum fraction of invalid antimicrobial interpretations of `x`, see *Examples*
|
||||
#' @param ... for using on a [data.frame]: names of columns to apply [as.rsi()] on (supports tidy selection like `AMX:VAN`). Otherwise: arguments passed on to methods.
|
||||
@@ -49,23 +49,23 @@
|
||||
#' 2. For **interpreting minimum inhibitory concentration (MIC) values** according to EUCAST or CLSI. You must clean your MIC values first using [as.mic()], that also gives your columns the new data class [`mic`]. Also, be sure to have a column with microorganism names or codes. It will be found automatically, but can be set manually using the `mo` argument.
|
||||
#' * Using `dplyr`, R/SI interpretation can be done very easily with either:
|
||||
#' ```
|
||||
#' your_data %>% mutate_if(is.mic, as.rsi) # until dplyr 1.0.0
|
||||
#' your_data %>% mutate(across((is.mic), as.rsi)) # since dplyr 1.0.0
|
||||
#' your_data %>% mutate_if(is.mic, as.rsi) # until dplyr 1.0.0
|
||||
#' your_data %>% mutate(across(where(is.mic), as.rsi)) # since dplyr 1.0.0
|
||||
#' ```
|
||||
#' * Operators like "<=" will be stripped before interpretation. When using `conserve_capped_values = TRUE`, an MIC value of e.g. ">2" will always return "R", even if the breakpoint according to the chosen guideline is ">=4". This is to prevent that capped values from raw laboratory data would not be treated conservatively. The default behaviour (`conserve_capped_values = FALSE`) considers ">2" to be lower than ">=4" and might in this case return "S" or "I".
|
||||
#'
|
||||
#' 3. For **interpreting disk diffusion diameters** according to EUCAST or CLSI. You must clean your disk zones first using [as.disk()], that also gives your columns the new data class [`disk`]. Also, be sure to have a column with microorganism names or codes. It will be found automatically, but can be set manually using the `mo` argument.
|
||||
#' * Using `dplyr`, R/SI interpretation can be done very easily with either:
|
||||
#' ```
|
||||
#' your_data %>% mutate_if(is.disk, as.rsi) # until dplyr 1.0.0
|
||||
#' your_data %>% mutate(across((is.disk), as.rsi)) # since dplyr 1.0.0
|
||||
#' your_data %>% mutate_if(is.disk, as.rsi) # until dplyr 1.0.0
|
||||
#' your_data %>% mutate(across(where(is.disk), as.rsi)) # since dplyr 1.0.0
|
||||
#' ```
|
||||
#'
|
||||
#' 4. For **interpreting a complete data set**, with automatic determination of MIC values, disk diffusion diameters, microorganism names or codes, and antimicrobial test results. This is done very simply by running `as.rsi(data)`.
|
||||
#'
|
||||
#' ## Supported Guidelines
|
||||
#'
|
||||
#' For interpreting MIC values as well as disk diffusion diameters, 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 supported guidelines to be used as input for the `guideline` argument are: `r vector_and(AMR::rsi_translation$guideline, quotes = TRUE, reverse = TRUE)`.
|
||||
#'
|
||||
#' 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.
|
||||
#'
|
||||
@@ -79,9 +79,9 @@
|
||||
#'
|
||||
#' ## Other
|
||||
#'
|
||||
#' The function [is.rsi()] detects if the input contains class `<rsi>`. If the input is a data.frame, it iterates over all columns and returns a logical vector.
|
||||
#' The function [is.rsi()] detects if the input contains class `<rsi>`. If the input is a [data.frame], it iterates over all columns and returns a [logical] vector.
|
||||
#'
|
||||
#' The function [is.rsi.eligible()] returns `TRUE` when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and `FALSE` otherwise. The threshold of 5% can be set with the `threshold` argument. If the input is a data.frame, it iterates over all columns and returns a logical vector.
|
||||
#' The function [is.rsi.eligible()] returns `TRUE` when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and `FALSE` otherwise. The threshold of 5% can be set with the `threshold` argument. If the input is a [data.frame], it iterates over all columns and returns a [logical] vector.
|
||||
#' @section Interpretation of R and S/I:
|
||||
#' In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories R and S/I as shown below (<https://www.eucast.org/newsiandr/>).
|
||||
#'
|
||||
@@ -93,7 +93,7 @@
|
||||
#' 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.
|
||||
#' @return Ordered factor with new class `<rsi>`
|
||||
#' @return Ordered [factor] with new class `<rsi>`
|
||||
#' @aliases rsi
|
||||
#' @export
|
||||
#' @seealso [as.mic()], [as.disk()], [as.mo()]
|
||||
@@ -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
|
||||
@@ -135,7 +135,7 @@
|
||||
#' if (require("dplyr")) {
|
||||
#' df %>% mutate_if(is.mic, as.rsi)
|
||||
#' df %>% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
|
||||
#' df %>% mutate(across((is.mic), as.rsi))
|
||||
#' df %>% mutate(across(where(is.mic), as.rsi))
|
||||
#' df %>% mutate_at(vars(AMP:TOB), as.rsi)
|
||||
#' df %>% mutate(across(AMP:TOB, as.rsi))
|
||||
#'
|
||||
@@ -181,7 +181,7 @@
|
||||
#'
|
||||
#' # note: from dplyr 1.0.0 on, this will be:
|
||||
#' # example_isolates %>%
|
||||
#' # mutate(across((is.rsi.eligible), as.rsi))
|
||||
#' # mutate(across(where(is.rsi.eligible), as.rsi))
|
||||
#' }
|
||||
#' }
|
||||
as.rsi <- function(x, ...) {
|
||||
@@ -215,7 +215,6 @@ is.rsi.eligible <- function(x, threshold = 0.05) {
|
||||
"ab",
|
||||
"Date",
|
||||
"POSIXt",
|
||||
"rsi",
|
||||
"raw",
|
||||
"hms",
|
||||
"mic",
|
||||
@@ -546,7 +545,7 @@ as.rsi.data.frame <- function(x,
|
||||
}
|
||||
if (!is.null(col_uti)) {
|
||||
if (is.logical(col_uti)) {
|
||||
# already a logical vector as input
|
||||
# already a [logical] vector as input
|
||||
if (length(col_uti) == 1) {
|
||||
uti <- rep(col_uti, NROW(x))
|
||||
} else {
|
||||
@@ -555,7 +554,7 @@ as.rsi.data.frame <- function(x,
|
||||
} else {
|
||||
# column found, transform to logical
|
||||
stop_if(length(col_uti) != 1 | !col_uti %in% colnames(x),
|
||||
"argument `uti` must be a logical vector, of must be a single column name of `x`")
|
||||
"argument `uti` must be a [logical] vector, of must be a single column name of `x`")
|
||||
uti <- as.logical(x[, col_uti, drop = TRUE])
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -150,7 +150,7 @@ rsi_calc <- function(...,
|
||||
if (message_not_thrown_before("rsi_calc")) {
|
||||
warning_("Increase speed by transforming to class <rsi> on beforehand:\n",
|
||||
" your_data %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" your_data %>% mutate(across((is.rsi.eligible), as.rsi))",
|
||||
" your_data %>% mutate(across(where(is.rsi.eligible), as.rsi))",
|
||||
call = FALSE)
|
||||
remember_thrown_message("rsi_calc")
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#' When negative ('left-skewed'): the left tail is longer; the mass of the distribution is concentrated on the right of a histogram. When positive ('right-skewed'): the right tail is longer; the mass of the distribution is concentrated on the left of a histogram. A normal distribution has a skewness of 0.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a vector of values, a [matrix] or a [data.frame]
|
||||
#' @param na.rm a logical value indicating whether `NA` values should be stripped before the computation proceeds
|
||||
#' @param na.rm a [logical] value indicating whether `NA` values should be stripped before the computation proceeds
|
||||
#' @seealso [kurtosis()]
|
||||
#' @rdname skewness
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
|
||||
@@ -123,7 +123,11 @@ coerce_language_setting <- function(lang) {
|
||||
}
|
||||
|
||||
# translate strings based on inst/translations.tsv
|
||||
translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE, affect_mo_name = FALSE) {
|
||||
translate_AMR <- function(from,
|
||||
language = get_locale(),
|
||||
only_unknown = FALSE,
|
||||
only_affect_ab_names = FALSE,
|
||||
only_affect_mo_names = FALSE) {
|
||||
|
||||
if (is.null(language)) {
|
||||
return(from)
|
||||
@@ -144,12 +148,20 @@ translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE, a
|
||||
|
||||
# only keep lines where translation is available for this language
|
||||
df_trans <- df_trans[which(!is.na(df_trans[, language, drop = TRUE])), , drop = FALSE]
|
||||
# and where the original string is not equal to the string in the target language
|
||||
df_trans <- df_trans[which(df_trans[, "pattern", drop = TRUE] != df_trans[, language, drop = TRUE]), , drop = FALSE]
|
||||
if (only_unknown == TRUE) {
|
||||
df_trans <- subset(df_trans, pattern %like% "unknown")
|
||||
}
|
||||
if (affect_mo_name == TRUE) {
|
||||
if (only_affect_ab_names == TRUE) {
|
||||
df_trans <- subset(df_trans, affect_ab_name == TRUE)
|
||||
}
|
||||
if (only_affect_mo_names == TRUE) {
|
||||
df_trans <- subset(df_trans, affect_mo_name == TRUE)
|
||||
}
|
||||
if (NROW(df_trans) == 0) {
|
||||
return(from)
|
||||
}
|
||||
|
||||
# default: case sensitive if value if 'case_sensitive' is missing:
|
||||
df_trans$case_sensitive[is.na(df_trans$case_sensitive)] <- TRUE
|
||||
|
||||
@@ -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.
|
||||
#'
|
||||
|
||||
@@ -27,6 +27,17 @@
|
||||
pkg_env <- new.env(hash = FALSE)
|
||||
pkg_env$mo_failed <- character(0)
|
||||
|
||||
# determine info icon for messages
|
||||
utf8_supported <- isTRUE(base::l10n_info()$`UTF-8`)
|
||||
is_latex <- tryCatch(import_fn("is_latex_output", "knitr", error_on_fail = FALSE)(),
|
||||
error = function(e) FALSE)
|
||||
if (utf8_supported && !is_latex) {
|
||||
# \u2139 is a symbol officially named 'information source'
|
||||
pkg_env$info_icon <- "\u2139"
|
||||
} else {
|
||||
pkg_env$info_icon <- "i"
|
||||
}
|
||||
|
||||
.onLoad <- function(libname, pkgname) {
|
||||
# Support for tibble headers (type_sum) and tibble columns content (pillar_shaft)
|
||||
# without the need to depend on other packages. This was suggested by the
|
||||
@@ -53,6 +64,7 @@ pkg_env$mo_failed <- character(0)
|
||||
s3_register("ggplot2::ggplot", "rsi")
|
||||
s3_register("ggplot2::ggplot", "mic")
|
||||
s3_register("ggplot2::ggplot", "disk")
|
||||
s3_register("ggplot2::ggplot", "resistance_predict")
|
||||
|
||||
# if mo source exists, fire it up (see mo_source())
|
||||
try({
|
||||
|
||||
@@ -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,7 @@ 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")`
|
||||
Bottom line: `install.packages("AMR", repos = "https://msberends.r-universe.dev")`
|
||||
|
||||
### Copyright
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ reference:
|
||||
desc: >
|
||||
Use these function for the analysis part. You can use `susceptibility()` or `resistance()` on any antibiotic column.
|
||||
Be sure to first select the isolates that are appropiate for analysis, by using `first_isolate()` or `is_new_episode()`.
|
||||
You can also filter your data on certain resistance in certain antibiotic classes (`filter_ab_class()`), or determine multi-drug resistant microorganisms (MDRO, `mdro()`).
|
||||
You can also filter your data on certain resistance in certain antibiotic classes (`carbapenems()`, `aminoglycosides()`), or determine multi-drug resistant microorganisms (MDRO, `mdro()`).
|
||||
contents:
|
||||
- "`proportion`"
|
||||
- "`count`"
|
||||
@@ -162,7 +162,6 @@ reference:
|
||||
- "`ggplot_rsi`"
|
||||
- "`bug_drug_combinations`"
|
||||
- "`antibiotic_class_selectors`"
|
||||
- "`filter_ab_class`"
|
||||
- "`resistance_predict`"
|
||||
- "`guess_ab_col`"
|
||||
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
* 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 has been archived on 22 May 2021 because of errors in the dplyr package, causing the skimr package to fail: <https://github.com/tidyverse/dplyr/issues/5881>. This AMR package contains a fix around this error. Perhaps an idea for future development of CRAN to send an automated email to a maintainer with a warning that a package will be archived in due time?
|
||||
|
||||
* This package continuously 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. This has been the case in the last releases as well. 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 earlier this year. We will add the paper as a vignette after publication in a next version. All data sets were compressed using `compression = "xz"` to make them as small as possible.
|
||||
@@ -23,31 +23,35 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
context("filter_ab_class.R")
|
||||
# some old R instances have trouble installing tinytest, so we ship it too
|
||||
install.packages("data-raw/tinytest_1.2.4.10.tar.gz")
|
||||
install.packages("data-raw/AMR_latest.tar.gz", dependencies = FALSE)
|
||||
install.packages("covr")
|
||||
|
||||
test_that("ATC-group filtering works", {
|
||||
skip_on_cran()
|
||||
|
||||
library(dplyr)
|
||||
expect_gt(example_isolates %>% filter_ab_class("carbapenem") %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_aminoglycosides() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_carbapenems() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_cephalosporins() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_1st_cephalosporins() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_2nd_cephalosporins() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_3rd_cephalosporins() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_4th_cephalosporins() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_5th_cephalosporins() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_fluoroquinolones() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_glycopeptides() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_macrolides() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_oxazolidinones() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_penicillins() %>% ncol(), 0)
|
||||
expect_gt(example_isolates %>% filter_tetracyclines() %>% ncol(), 0)
|
||||
pkg_suggests <- gsub("[^a-zA-Z0-9]+", "", unlist(strsplit(packageDescription("AMR", fields = "Suggests"), ", ?")))
|
||||
cat("Packages listed in Suggests:", paste(pkg_suggests, collapse = ", "), "\n")
|
||||
|
||||
expect_gt(example_isolates %>% filter_carbapenems("R", "all") %>% nrow(), 0)
|
||||
to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())]
|
||||
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),
|
||||
# message = function(m) invisible(),
|
||||
warning = function(w) message(w$message),
|
||||
error = function(e) message(e$message))
|
||||
}
|
||||
|
||||
expect_error(example_isolates %>% filter_carbapenems(result = "test"))
|
||||
expect_error(example_isolates %>% filter_carbapenems(scope = "test"))
|
||||
expect_message(example_isolates %>% select(1:3) %>% filter_carbapenems())
|
||||
})
|
||||
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),
|
||||
# message = function(m) invisible(),
|
||||
warning = function(w) message(w$message),
|
||||
error = function(e) message(e$message))
|
||||
}
|
||||
@@ -1,266 +1,266 @@
|
||||
pattern regular_expr case_sensitive affect_mo_name de nl es it fr pt
|
||||
Coagulase-negative Staphylococcus TRUE TRUE TRUE Koagulase-negative Staphylococcus Coagulase-negatieve Staphylococcus Staphylococcus coagulasa negativo Staphylococcus negativo coagulasi Staphylococcus à coagulase négative Staphylococcus coagulase negativo
|
||||
Coagulase-positive Staphylococcus TRUE TRUE TRUE Koagulase-positive Staphylococcus Coagulase-positieve Staphylococcus Staphylococcus coagulasa positivo Staphylococcus positivo coagulasi Staphylococcus à coagulase positif Staphylococcus coagulase positivo
|
||||
Beta-haemolytic Streptococcus TRUE TRUE TRUE Beta-hämolytischer Streptococcus Beta-hemolytische Streptococcus Streptococcus Beta-hemolítico Streptococcus Beta-emolitico Streptococcus Bêta-hémolytique Streptococcus Beta-hemolítico
|
||||
unknown Gram-negatives TRUE TRUE TRUE unbekannte Gramnegativen onbekende Gram-negatieven Gram negativos desconocidos Gram negativi sconosciuti Gram négatifs inconnus Gram negativos desconhecidos
|
||||
unknown Gram-positives TRUE TRUE TRUE unbekannte Grampositiven onbekende Gram-positieven Gram positivos desconocidos Gram positivi sconosciuti Gram positifs inconnus Gram positivos desconhecidos
|
||||
unknown fungus TRUE TRUE TRUE unbekannter Pilze onbekende schimmel hongo desconocido fungo sconosciuto champignon inconnu fungo desconhecido
|
||||
unknown yeast TRUE TRUE TRUE unbekannte Hefe onbekende gist levadura desconocida lievito sconosciuto levure inconnue levedura desconhecida
|
||||
unknown name TRUE TRUE TRUE unbekannte Name onbekende naam nombre desconocido nome sconosciuto nom inconnu nome desconhecido
|
||||
unknown kingdom TRUE TRUE TRUE unbekanntes Reich onbekend koninkrijk reino desconocido regno sconosciuto règme inconnu reino desconhecido
|
||||
unknown phylum TRUE TRUE TRUE unbekannter Stamm onbekend fylum filo desconocido phylum sconosciuto embranchement inconnu filo desconhecido
|
||||
unknown class TRUE TRUE TRUE unbekannte Klasse onbekende klasse clase desconocida classe sconosciuta classe inconnue classe desconhecida
|
||||
unknown order TRUE TRUE TRUE unbekannte Ordnung onbekende orde orden desconocido ordine sconosciuto ordre inconnu ordem desconhecido
|
||||
unknown family TRUE TRUE TRUE unbekannte Familie onbekende familie familia desconocida famiglia sconosciuta famille inconnue família desconhecida
|
||||
unknown genus TRUE TRUE TRUE unbekannte Gattung onbekend geslacht género desconocido genere sconosciuto genre inconnu gênero desconhecido
|
||||
unknown species TRUE TRUE TRUE unbekannte Art onbekende soort especie desconocida specie sconosciute espèce inconnue espécies desconhecida
|
||||
unknown subspecies TRUE TRUE TRUE unbekannte Unterart onbekende ondersoort subespecie desconocida sottospecie sconosciute sous-espèce inconnue subespécies desconhecida
|
||||
unknown rank TRUE TRUE TRUE unbekannter Rang onbekende rang rango desconocido grado sconosciuto rang inconnu classificação desconhecido
|
||||
CoNS FALSE TRUE TRUE KNS CNS SCN
|
||||
CoPS FALSE TRUE TRUE KPS CPS SCP
|
||||
Gram-negative TRUE TRUE FALSE Gramnegativ Gram-negatief Gram negativo Gram negativo Gram négatif Gram negativo
|
||||
Gram-positive TRUE TRUE FALSE Grampositiv Gram-positief Gram positivo Gram positivo Gram positif Gram positivo
|
||||
^Bacteria$ TRUE TRUE FALSE Bakterien Bacteriën Bacterias Batteri Bactéries Bactérias
|
||||
^Fungi$ TRUE TRUE FALSE Pilze Schimmels Hongos Funghi Champignons Fungos
|
||||
^Yeasts$ TRUE TRUE FALSE Hefen Gisten Levaduras Lieviti Levures Leveduras
|
||||
^Protozoa$ TRUE TRUE FALSE Protozoen Protozoën Protozoarios Protozoi Protozoaires Protozoários
|
||||
biogroup TRUE TRUE FALSE Biogruppe biogroep biogrupo biogruppo biogroupe biogrupo
|
||||
biotype TRUE TRUE FALSE Biotyp biotipo biotipo biótipo
|
||||
vegetative TRUE TRUE FALSE vegetativ vegetatief vegetativo vegetativo végétatif vegetativo
|
||||
([([ ]*?)group TRUE TRUE FALSE \\1Gruppe \\1groep \\1grupo \\1gruppo \\1groupe \\1grupo
|
||||
([([ ]*?)Group TRUE TRUE FALSE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo
|
||||
no .*growth TRUE FALSE FALSE keine? .*wachstum geen .*groei no .*crecimientonon sem .*crescimento pas .*croissance sem .*crescimento
|
||||
no|not TRUE FALSE FALSE keine? geen|niet no|sin sem non sem
|
||||
Susceptible TRUE FALSE FALSE Empfindlich Gevoelig Susceptible
|
||||
Intermediate TRUE FALSE FALSE Mittlere Intermediair Intermedio
|
||||
Incr. exposure TRUE FALSE FALSE Empfindlich, erh Belastung 'Incr. exposure' 'Incr. exposure'
|
||||
Resistant TRUE FALSE FALSE Resistent Resistent Resistente
|
||||
antibiotic TRUE TRUE FALSE Antibiotikum antibioticum antibiótico
|
||||
Antibiotic TRUE TRUE FALSE Antibiotikum Antibioticum Antibiótico
|
||||
Drug TRUE TRUE FALSE Medikament Middel Fármaco
|
||||
drug TRUE TRUE FALSE Medikament middel fármaco
|
||||
Frequency FALSE TRUE FALSE Zahl Aantal
|
||||
Minimum Inhibitory Concentration (mg/L) FALSE FALSE FALSE Minimale Hemm-Konzentration (mg/L) Minimale inhiberende concentratie (mg/L)
|
||||
Disk diffusion diameter (mm) FALSE FALSE FALSE Durchmesser der Scheibenzone (mm) Diameter diskzone (mm)
|
||||
Antimicrobial Interpretation FALSE FALSE FALSE Antimikrobielle Auswertung Antimicrobiële interpretatie
|
||||
4-aminosalicylic acid FALSE TRUE FALSE 4-Aminosalicylsäure 4-aminosalicylzuur Ácido 4-aminosalicílico
|
||||
Adefovir dipivoxil FALSE TRUE FALSE Adefovir Dipivoxil Adefovir Adefovir dipivoxil
|
||||
Aldesulfone sodium FALSE TRUE FALSE Aldesulfon-Natrium Aldesulfon Aldesulfona sódica
|
||||
Amikacin FALSE TRUE FALSE Amikacin Amikacine Amikacina
|
||||
Amoxicillin FALSE TRUE FALSE Amoxicillin Amoxicilline Amoxicilina
|
||||
Amoxicillin/beta-lactamase inhibitor FALSE TRUE FALSE Amoxicillin/Beta-Lactamase-Hemmer Amoxicilline/enzymremmer amoxicilina/inhib. de la beta-lactamasa
|
||||
Amphotericin B FALSE TRUE FALSE Amphotericin B Amfotericine B Anfotericina B
|
||||
Ampicillin FALSE TRUE FALSE Ampicillin Ampicilline Ampicilina
|
||||
Ampicillin/beta-lactamase inhibitor FALSE TRUE FALSE Ampicillin/Beta-Laktamase-Hemmer Ampicilline/enzymremmer Ampicilina/inhib. de la betalactamasa
|
||||
Anidulafungin FALSE TRUE FALSE Anidulafungin Anidulafungine Anidulafungina
|
||||
Azidocillin FALSE TRUE FALSE Azidocillin Azidocilline Azidocilina
|
||||
Azithromycin FALSE TRUE FALSE Azithromycin Azitromycine Azitromicina
|
||||
Azlocillin FALSE TRUE FALSE Azlocillin Azlocilline Azlocilina
|
||||
Bacampicillin FALSE TRUE FALSE Bacampicillin Bacampicilline Bacampicilina
|
||||
Bacitracin FALSE TRUE FALSE Bacitracin Bacitracine Bacitracina
|
||||
Benzathine benzylpenicillin FALSE TRUE FALSE Benzathin-Benzylpenicillin Benzylpenicillinebenzathine Bencilpenicilina benzatínica
|
||||
Benzathine phenoxymethylpenicillin FALSE TRUE FALSE Benzathin-Phenoxymethylpenicillin Fenoxymethylpenicillinebenzathine Fenoximetilpenicilina benzatínica
|
||||
Benzylpenicillin FALSE TRUE FALSE Benzylpenicillin Benzylpenicilline Bencilpenicilina
|
||||
Calcium aminosalicylate FALSE TRUE FALSE Kalzium-Aminosalicylat Aminosalicylzuur Aminosalicilato de calcio
|
||||
Capreomycin FALSE TRUE FALSE Capreomycin Capreomycine Capreomicina
|
||||
Carbenicillin FALSE TRUE FALSE Carbenicillin Carbenicilline Carbenicilina
|
||||
Carindacillin FALSE TRUE FALSE Carindacillin Carindacilline Carindacilina
|
||||
Caspofungin FALSE TRUE FALSE Caspofungin Caspofungine Caspofungina
|
||||
Ce(f|ph)acetrile TRUE TRUE FALSE Cefacetril Cefacetril Cefacetrilo
|
||||
Ce(f|ph)alotin TRUE TRUE FALSE Cefalotin Cefalotine Cefalotina
|
||||
Ce(f|ph)amandole TRUE TRUE FALSE Cefamandol Cefamandol Cefamandole
|
||||
Ce(f|ph)apirin TRUE TRUE FALSE Cefapirin Cefapirine Cefapirina
|
||||
Ce(f|ph)azedone TRUE TRUE FALSE Cefazedon Cefazedon Cefazedona
|
||||
Ce(f|ph)azolin TRUE TRUE FALSE Cefazolin Cefazoline Cefazolina
|
||||
Ce(f|ph)alothin TRUE TRUE FALSE Cefalothin Cefalotine Cefalotina
|
||||
Ce(f|ph)alexin TRUE TRUE FALSE Cefalexin Cefalexine Cefalexina
|
||||
Ce(f|ph)epime TRUE TRUE FALSE Cefepim Cefepim Cefepime
|
||||
Ce(f|ph)ixime TRUE TRUE FALSE Cefixim Cefixim Cefixima
|
||||
Ce(f|ph)menoxime TRUE TRUE FALSE Cefmenoxim Cefmenoxim Cefmenoxima
|
||||
Ce(f|ph)metazole TRUE TRUE FALSE Cefmetazol Cefmetazol Cefmetazol
|
||||
Ce(f|ph)odizime TRUE TRUE FALSE Cefodizim Cefodizim Cefodizima
|
||||
Ce(f|ph)onicid TRUE TRUE FALSE Cefonicid Cefonicide Cefonicid
|
||||
Ce(f|ph)operazone TRUE TRUE FALSE Cefoperazon Cefoperazon Cefoperazona
|
||||
Ce(f|ph)operazone/beta-lactamase inhibitor TRUE TRUE FALSE Cefoperazon/Beta-Lactamase-Hemmer Cefoperazon/enzymremmer Cefoperazona/inhib. de la betalactamasa
|
||||
Ce(f|ph)otaxime TRUE TRUE FALSE Cefotaxim Cefotaxim Cefotaxima
|
||||
Ce(f|ph)oxitin TRUE TRUE FALSE Cefoxitin Cefoxitine Cefoxitina
|
||||
Ce(f|ph)pirome TRUE TRUE FALSE Cefpirom Cefpirom Cefpirome
|
||||
Ce(f|ph)podoxime TRUE TRUE FALSE Cefpodoxim Cefpodoxim Cefpodoxima
|
||||
Ce(f|ph)radine TRUE TRUE FALSE Cefradin Cefradine Cefradina
|
||||
Ce(f|ph)sulodin TRUE TRUE FALSE Cefsulodin Cefsulodine Cefsulodina
|
||||
Ce(f|ph)tazidime TRUE TRUE FALSE Ceftazidim Ceftazidim Ceftazidima
|
||||
Ce(f|ph)tezole TRUE TRUE FALSE Ceftezol Ceftezol Ceftezol
|
||||
Ce(f|ph)tizoxime TRUE TRUE FALSE Ceftizoxim Ceftizoxim Ceftizoxima
|
||||
Ce(f|ph)triaxone TRUE TRUE FALSE Ceftriaxon Ceftriaxon Ceftriaxona
|
||||
Ce(f|ph)uroxime TRUE TRUE FALSE Cefuroxim Cefuroxim Cefuroxima
|
||||
Ce(f|ph)uroxime/metronidazole TRUE TRUE FALSE Cefuroxim/Metronidazol Cefuroxim/andere antibacteriele middelen Cefuroxima/metronidazol
|
||||
Chloramphenicol FALSE TRUE FALSE Chloramphenicol Chlooramfenicol Cloranfenicol
|
||||
Chlortetracycline FALSE TRUE FALSE Chlortetracyclin Chloortetracycline Clortetraciclina
|
||||
Cinoxacin FALSE TRUE FALSE Cinoxacin Cinoxacine Cinoxacina
|
||||
Ciprofloxacin FALSE TRUE FALSE Ciprofloxacin Ciprofloxacine Ciprofloxacina
|
||||
Clarithromycin FALSE TRUE FALSE Clarithromycin Claritromycine Claritromicina
|
||||
Clavulanic acid FALSE TRUE FALSE Clavulansäure Clavulaanzuur Ácido clavulánico
|
||||
clavulanic acid FALSE TRUE FALSE Clavulansäure clavulaanzuur ácido clavulánico
|
||||
Clindamycin FALSE TRUE FALSE Clindamycin Clindamycine Clindamicina
|
||||
Clometocillin FALSE TRUE FALSE Clometocillin Clometocilline Clometocilina
|
||||
Clotrimazole FALSE TRUE FALSE Clotrimazol Clotrimazol Clotrimazol
|
||||
Cloxacillin FALSE TRUE FALSE Cloxacillin Cloxacilline Cloxacilina
|
||||
Colistin FALSE TRUE FALSE Colistin Colistine Colistina
|
||||
Dapsone FALSE TRUE FALSE Dapson Dapson Dapsona
|
||||
Daptomycin FALSE TRUE FALSE Daptomycin Daptomycine Daptomicina
|
||||
Dibekacin FALSE TRUE FALSE Dibekacin Dibekacine Dibekacina
|
||||
Dicloxacillin FALSE TRUE FALSE Dicloxacillin Dicloxacilline Dicloxacilina
|
||||
Dirithromycin FALSE TRUE FALSE Dirithromycin Diritromycine Diritromicina
|
||||
Econazole FALSE TRUE FALSE Econazol Econazol Econazol
|
||||
Enoxacin FALSE TRUE FALSE Enoxacin Enoxacine Enoxacina
|
||||
Epicillin FALSE TRUE FALSE Epicillin Epicilline Epicilina
|
||||
Erythromycin FALSE TRUE FALSE Erythromycin Erytromycine Eritromicina
|
||||
Ethambutol/isoniazid FALSE TRUE FALSE Ethambutol/Isoniazid Ethambutol/isoniazide Etambutol/isoniazida
|
||||
Fleroxacin FALSE TRUE FALSE Fleroxacin Fleroxacine Fleroxacina
|
||||
Flucloxacillin FALSE TRUE FALSE Flucloxacillin Flucloxacilline Flucloxacilina
|
||||
Fluconazole FALSE TRUE FALSE Fluconazol Fluconazol Fluconazol
|
||||
Flucytosine FALSE TRUE FALSE Flucytosin Fluorocytosine Flucitosina
|
||||
Flurithromycin FALSE TRUE FALSE Flurithromycin Fluritromycine Fluritromicina
|
||||
Fosfomycin FALSE TRUE FALSE Fosfomycin Fosfomycine Fosfomicina
|
||||
Fusidic acid FALSE TRUE FALSE Fusidinsäure Fusidinezuur Ácido fusídico
|
||||
Gatifloxacin FALSE TRUE FALSE Gatifloxacin Gatifloxacine Gatifloxacina
|
||||
Gemifloxacin FALSE TRUE FALSE Gemifloxacin Gemifloxacine Gemifloxacina
|
||||
Gentamicin FALSE TRUE FALSE Gentamicin Gentamicine Gentamicina
|
||||
Grepafloxacin FALSE TRUE FALSE Grepafloxacin Grepafloxacine Grepafloxacina
|
||||
Hachimycin FALSE TRUE FALSE Hachimycin Hachimycine Hachimycin
|
||||
Hetacillin FALSE TRUE FALSE Hetacillin Hetacilline Hetacilina
|
||||
Imipenem/cilastatin FALSE TRUE FALSE Imipenem/Cilastatin Imipenem/enzymremmer Imipenem/cilastatina
|
||||
Inosine pranobex FALSE TRUE FALSE Inosin-Pranobex Inosiplex Inosina pranobex
|
||||
Isepamicin FALSE TRUE FALSE Isepamicin Isepamicine Isepamicina
|
||||
Isoconazole FALSE TRUE FALSE Isoconazol Isoconazol Isoconazol
|
||||
Isoniazid FALSE TRUE FALSE Isoniazid Isoniazide Isoniazida
|
||||
Itraconazole FALSE TRUE FALSE Itraconazol Itraconazol Itraconazol
|
||||
Josamycin FALSE TRUE FALSE Josamycin Josamycine Josamicina
|
||||
Kanamycin FALSE TRUE FALSE Kanamycin Kanamycine Kanamicina
|
||||
Ketoconazole FALSE TRUE FALSE Ketoconazol Ketoconazol Ketoconazol
|
||||
Levofloxacin FALSE TRUE FALSE Levofloxacin Levofloxacine Levofloxacina
|
||||
Lincomycin FALSE TRUE FALSE Lincomycin Lincomycine Lincomicina
|
||||
Lomefloxacin FALSE TRUE FALSE Lomefloxacin Lomefloxacine Lomefloxacina
|
||||
Lysozyme FALSE TRUE FALSE Lysozym Lysozym Lisozima
|
||||
Mandelic acid FALSE TRUE FALSE Mandelsäure Amandelzuur Ácido mandélico
|
||||
Metampicillin FALSE TRUE FALSE Metampicillin Metampicilline Metampicilina
|
||||
Meticillin FALSE TRUE FALSE Meticillin Meticilline Meticilina
|
||||
Metisazone FALSE TRUE FALSE Metisazon Metisazon Metisazona
|
||||
Metronidazole FALSE TRUE FALSE Metronidazol Metronidazol Metronidazol
|
||||
Mezlocillin FALSE TRUE FALSE Mezlocillin Mezlocilline Mezlocilina
|
||||
Micafungin FALSE TRUE FALSE Micafungin Micafungine Micafungina
|
||||
Miconazole FALSE TRUE FALSE Miconazol Miconazol Miconazol
|
||||
Midecamycin FALSE TRUE FALSE Midecamycin Midecamycine Midecamicina
|
||||
Miocamycin FALSE TRUE FALSE Miocamycin Miocamycine Miocamycin
|
||||
Moxifloxacin FALSE TRUE FALSE Moxifloxacin Moxifloxacine Moxifloxacina
|
||||
Mupirocin FALSE TRUE FALSE Mupirocin Mupirocine Mupirocina
|
||||
Nalidixic acid FALSE TRUE FALSE Nalidixinsäure Nalidixinezuur Ácido nalidíxico
|
||||
Neomycin FALSE TRUE FALSE Neomycin Neomycine Neomicina
|
||||
Netilmicin FALSE TRUE FALSE Netilmicin Netilmicine Netilmicina
|
||||
Nitrofurantoin FALSE TRUE FALSE Nitrofurantoin Nitrofurantoine Nitrofurantoína
|
||||
Norfloxacin FALSE TRUE FALSE Norfloxacin Norfloxacine Norfloxacina
|
||||
Novobiocin FALSE TRUE FALSE Novobiocin Novobiocine Novobiocina
|
||||
Nystatin FALSE TRUE FALSE Nystatin Nystatine Nistatina
|
||||
Ofloxacin FALSE TRUE FALSE Ofloxacin Ofloxacine Ofloxacina
|
||||
Oleandomycin FALSE TRUE FALSE Oleandomycin Oleandomycine Oleandomicina
|
||||
Ornidazole FALSE TRUE FALSE Ornidazol Ornidazol Ornidazol
|
||||
Oxacillin FALSE TRUE FALSE Oxacillin Oxacilline Oxacilina
|
||||
Oxolinic acid FALSE TRUE FALSE Oxolinsäure Oxolinezuur Ácido oxolínico
|
||||
Oxytetracycline FALSE TRUE FALSE Oxytetracyclin Oxytetracycline Oxitetraciclina
|
||||
Pazufloxacin FALSE TRUE FALSE Pazufloxacin Pazufloxacine Pazufloxacina
|
||||
Pefloxacin FALSE TRUE FALSE Pefloxacin Pefloxacine Pefloxacina
|
||||
Penamecillin FALSE TRUE FALSE Penamecillin Penamecilline Penamecilina
|
||||
Penicillin FALSE TRUE FALSE Penicillin Penicilline Penicilina
|
||||
Pheneticillin FALSE TRUE FALSE Pheneticillin Feneticilline Feneticilina
|
||||
Phenoxymethylpenicillin FALSE TRUE FALSE Phenoxymethylpenicillin Fenoxymethylpenicilline Fenoximetilpenicilina
|
||||
Pipemidic acid FALSE TRUE FALSE Pipemidinsäure Pipemidinezuur Ácido pipemídico
|
||||
Piperacillin FALSE TRUE FALSE Piperacillin Piperacilline Piperacilina
|
||||
Piperacillin/beta-lactamase inhibitor FALSE TRUE FALSE Piperacillin/Beta-Lactamase-Hemmer Piperacilline/enzymremmer Piperacilina/inhib. de la betalactamasa
|
||||
Piromidic acid FALSE TRUE FALSE Piromidinsäure Piromidinezuur Ácido piromídico
|
||||
Pivampicillin FALSE TRUE FALSE Pivampicillin Pivampicilline Pivampicilina
|
||||
Polymyxin B FALSE TRUE FALSE Polymyxin B Polymyxine B Polimixina B
|
||||
Posaconazole FALSE TRUE FALSE Posaconazol Posaconazol Posaconazol
|
||||
Pristinamycin FALSE TRUE FALSE Pristinamycin Pristinamycine Pristinamicina
|
||||
Procaine benzylpenicillin FALSE TRUE FALSE Procain-Benzylpenicillin Benzylpenicillineprocaine Bencilpenicilina procaína
|
||||
Propicillin FALSE TRUE FALSE Propicillin Propicilline Propicilina
|
||||
Prulifloxacin FALSE TRUE FALSE Prulifloxacin Prulifloxacine Prulifloxacina
|
||||
Quinupristin/dalfopristin FALSE TRUE FALSE Quinupristin/Dalfopristin Quinupristine/dalfopristine Quinupristina/dalfopristina
|
||||
Ribostamycin FALSE TRUE FALSE Ribostamycin Ribostamycine Ribostamicina
|
||||
Rifabutin FALSE TRUE FALSE Rifabutin Rifabutine Rifabutina
|
||||
Rifampicin FALSE TRUE FALSE Rifampicin Rifampicine Rifampicina
|
||||
Rifampicin/pyrazinamide/ethambutol/isoniazid FALSE TRUE FALSE Rifampicin/Pyrazinamid/Ethambutol/Isoniazid Rifampicine/pyrazinamide/ethambutol/isoniazide Rifampicina/pirazinamida/etambutol/isoniazida
|
||||
Rifampicin/pyrazinamide/isoniazid FALSE TRUE FALSE Rifampicin/Pyrazinamid/Isoniazid Rifampicine/pyrazinamide/isoniazide Rifampicina/pirazinamida/isoniazida
|
||||
Rifampicin/isoniazid FALSE TRUE FALSE Rifampicin/Isoniazid Rifampicine/isoniazide Rifampicina/isoniazida
|
||||
Rifamycin FALSE TRUE FALSE Rifamycin Rifamycine Rifamicina
|
||||
Rifaximin FALSE TRUE FALSE Rifaximin Rifaximine Rifaximina
|
||||
Rokitamycin FALSE TRUE FALSE Rokitamycin Rokitamycine Rokitamicina
|
||||
Rosoxacin FALSE TRUE FALSE Rosoxacin Rosoxacine Rosoxacina
|
||||
Roxithromycin FALSE TRUE FALSE Roxithromycin Roxitromycine Roxitromicina
|
||||
Rufloxacin FALSE TRUE FALSE Rufloxacin Rufloxacine Rufloxacina
|
||||
Sisomicin FALSE TRUE FALSE Sisomicin Sisomicine Sisomicina
|
||||
Sodium aminosalicylate FALSE TRUE FALSE Natrium-Aminosalicylat Aminosalicylzuur Aminosalicilato de sodio
|
||||
Sparfloxacin FALSE TRUE FALSE Sparfloxacin Sparfloxacine Esparfloxacina
|
||||
Spectinomycin FALSE TRUE FALSE Spectinomycin Spectinomycine Espectinomicina
|
||||
Spiramycin FALSE TRUE FALSE Spiramycin Spiramycine Espiramicina
|
||||
Spiramycin/metronidazole FALSE TRUE FALSE Spiramycin/Metronidazol Spiramycine/metronidazol Espiramicina/metronidazol
|
||||
Staphylococcus immunoglobulin FALSE TRUE FALSE Staphylococcus-Immunoglobulin Stafylokokkenimmunoglobuline Inmunoglobulina estafilocócica
|
||||
Streptoduocin FALSE TRUE FALSE Streptoduocin Streptoduocine Estreptoduocina
|
||||
Streptomycin FALSE TRUE FALSE Streptomycin Streptomycine Estreptomicina
|
||||
Streptomycin/isoniazid FALSE TRUE FALSE Streptomycin/Isoniazid Streptomycine/isoniazide Estreptomicina/isoniazida
|
||||
Sulbenicillin FALSE TRUE FALSE Sulbenicillin Sulbenicilline Sulbenicilina
|
||||
Sulfadiazine/tetroxoprim FALSE TRUE FALSE Sulfadiazin/Tetroxoprim Sulfadiazine/tetroxoprim Sulfadiazina/tetroxoprima
|
||||
Sulfadiazine/trimethoprim FALSE TRUE FALSE Sulfadiazin/Trimethoprim Sulfadiazine/trimethoprim Sulfadiazina/trimetoprima
|
||||
Sulfadimidine/trimethoprim FALSE TRUE FALSE Sulfadimidin/Trimethoprim Sulfadimidine/trimethoprim Sulfadimidina/trimetoprima
|
||||
Sulfafurazole FALSE TRUE FALSE Sulfafurazol Sulfafurazol Sulfafurazol
|
||||
Sulfaisodimidine FALSE TRUE FALSE Sulfaisodimidin Sulfisomidine Sulfaisodimidina
|
||||
Sulfalene FALSE TRUE FALSE Sulfalene Sulfaleen Sulfaleno
|
||||
Sulfamazone FALSE TRUE FALSE Sulfamazon Sulfamazon Sulfamazona
|
||||
Sulfamerazine/trimethoprim FALSE TRUE FALSE Sulfamerazin/Trimethoprim Sulfamerazine/trimethoprim Sulfamerazina/trimetoprima
|
||||
Sulfamethizole FALSE TRUE FALSE Sulfamethizol Sulfamethizol Sulfametozol
|
||||
Sulfamethoxazole FALSE TRUE FALSE Sulfamethoxazol Sulfamethoxazol Sulfametoxazol
|
||||
Sulfamethoxazole/trimethoprim FALSE TRUE FALSE Sulfamethoxazol/Trimethoprim Sulfamethoxazol/trimethoprim Sulfametoxazol/trimetoprima
|
||||
Sulfametoxydiazine FALSE TRUE FALSE Sulfametoxydiazin Sulfamethoxydiazine Sulfametoxidiazina
|
||||
Sulfametrole/trimethoprim FALSE TRUE FALSE Sulfametrole/Trimethoprim Sulfametrol/trimethoprim Sulfametrole/trimethoprim
|
||||
Sulfamoxole FALSE TRUE FALSE Sulfamoxol Sulfamoxol Sulfamoxole
|
||||
Sulfamoxole/trimethoprim FALSE TRUE FALSE Sulfamoxol/Trimethoprim Sulfamoxol/trimethoprim Sulfamoxol/trimetoprima
|
||||
Sulfaperin FALSE TRUE FALSE Sulfaperin Sulfaperine Sulfaproxeno
|
||||
Sulfaphenazole FALSE TRUE FALSE Sulfaphenazol Sulfafenazol Sulfafenazol
|
||||
Sulfathiazole FALSE TRUE FALSE Sulfathiazol Sulfathiazol Sulfatiazol
|
||||
Sulfathiourea FALSE TRUE FALSE Sulfathioharnstoff Sulfathioureum Sulfathiourea
|
||||
Sultamicillin FALSE TRUE FALSE Sultamicillin Sultamicilline Sultamicilina
|
||||
Talampicillin FALSE TRUE FALSE Talampicillin Talampicilline Talampicilina
|
||||
Teicoplanin FALSE TRUE FALSE Teicoplanin Teicoplanine Teicoplanina
|
||||
Telithromycin FALSE TRUE FALSE Telithromycin Telitromycine Telitromicina
|
||||
Temafloxacin FALSE TRUE FALSE Temafloxacin Temafloxacine Temafloxacina
|
||||
Temocillin FALSE TRUE FALSE Temocillin Temocilline Temocilina
|
||||
Tenofovir disoproxil FALSE TRUE FALSE Tenofovir Disoproxil Tenofovir Tenofovir disoproxil
|
||||
Terizidone FALSE TRUE FALSE Terizidon Terizidon Terizidona
|
||||
Thiamphenicol FALSE TRUE FALSE Thiamphenicol Thiamfenicol Tiamfenicol
|
||||
Thioacetazone/isoniazid FALSE TRUE FALSE Thioacetazon/Isoniazid Thioacetazon/isoniazide Tioacetazona/isoniazida
|
||||
Ticarcillin FALSE TRUE FALSE Ticarcillin Ticarcilline Ticarcilina
|
||||
Ticarcillin/beta-lactamase inhibitor FALSE TRUE FALSE Ticarcillin/Beta-Lactamase-Hemmer Ticarcilline/enzymremmer Ticarcilina/inhib. de la betalactamasa
|
||||
Ticarcillin/clavulanic acid FALSE TRUE FALSE Ticarcillin/Clavulansäure Ticarcilline/clavulaanzuur Ticarcilina/ácido clavulánico
|
||||
Tinidazole FALSE TRUE FALSE Tinidazol Tinidazol Tinidazol
|
||||
Tobramycin FALSE TRUE FALSE Tobramycin Tobramycine Tobramicina
|
||||
Trimethoprim/sulfamethoxazole FALSE TRUE FALSE Trimethoprim/Sulfamethoxazol Cotrimoxazol Trimetoprima/sulfametoxazol
|
||||
Troleandomycin FALSE TRUE FALSE Troleandomycin Troleandomycine Troleandomicina
|
||||
Trovafloxacin FALSE TRUE FALSE Trovafloxacin Trovafloxacine Trovafloxacina
|
||||
Vancomycin FALSE TRUE FALSE Vancomycin Vancomycine Vancomicina
|
||||
Voriconazole FALSE TRUE FALSE Voriconazol Voriconazol Voriconazol
|
||||
Aminoglycosides FALSE TRUE FALSE Aminoglykoside Aminoglycosiden Aminoglucósidos
|
||||
Amphenicols FALSE TRUE FALSE Amphenicole Amfenicolen Anfenicoles
|
||||
Antifungals/antimycotics FALSE TRUE FALSE Antimykotika/Antimykotika Antifungica/antimycotica Antifúngicos/antimicóticos
|
||||
Antimycobacterials FALSE TRUE FALSE Antimykobakterielle Mittel Antimycobacteriele middelen Antimicrobianos
|
||||
Beta-lactams/penicillins FALSE TRUE FALSE Beta-Lactame/Penicilline Beta-lactams/penicillines Beta-lactámicos/penicilinas
|
||||
Cephalosporins (1st gen.) FALSE TRUE FALSE Cephalosporine (1. Gen.) Cefalosporines (1e gen.) Cefalosporinas (1er gen.)
|
||||
Cephalosporins (2nd gen.) FALSE TRUE FALSE Cephalosporine (2. Gen.) Cefalosporines (2e gen.) Cefalosporinas (2do gen.)
|
||||
Cephalosporins (3rd gen.) FALSE TRUE FALSE Cephalosporine (3. Gen.) Cefalosporines (3e gen.) Cefalosporinas (3er gen.)
|
||||
Cephalosporins (4th gen.) FALSE TRUE FALSE Cephalosporine (4. Gen.) Cefalosporines (4e gen.) Cefalosporinas (4º gen.)
|
||||
Cephalosporins (5th gen.) FALSE TRUE FALSE Cephalosporine (5. Gen.) Cefalosporines (5e gen.) Cefalosporinas (5º gen.)
|
||||
Cephalosporins (unclassified gen.) FALSE TRUE FALSE Cephalosporine (unklassifiziert) Cefalosporines (ongeclassificeerd) Cefalosporinas (no clasificado)
|
||||
Cephalosporins FALSE TRUE FALSE Cephalosporine Cefalosporines Cefalosporinas
|
||||
Glycopeptides FALSE TRUE FALSE Glykopeptide Glycopeptiden Glicopéptidos
|
||||
Macrolides/lincosamides FALSE TRUE FALSE Makrolide/Linkosamide Macroliden/lincosamiden Macrólidos/lincosamidas
|
||||
Other antibacterials FALSE TRUE FALSE Andere Antibiotika Overige antibiotica Otros antibacterianos
|
||||
Polymyxins FALSE TRUE FALSE Polymyxine Polymyxines Polimixinas
|
||||
Quinolones FALSE TRUE FALSE Quinolone Quinolonen Quinolonas
|
||||
pattern regular_expr case_sensitive affect_ab_name affect_mo_name de nl es it fr pt
|
||||
Coagulase-negative Staphylococcus TRUE TRUE FALSE TRUE Koagulase-negative Staphylococcus Coagulase-negatieve Staphylococcus Staphylococcus coagulasa negativo Staphylococcus negativo coagulasi Staphylococcus à coagulase négative Staphylococcus coagulase negativo
|
||||
Coagulase-positive Staphylococcus TRUE TRUE FALSE TRUE Koagulase-positive Staphylococcus Coagulase-positieve Staphylococcus Staphylococcus coagulasa positivo Staphylococcus positivo coagulasi Staphylococcus à coagulase positif Staphylococcus coagulase positivo
|
||||
Beta-haemolytic Streptococcus TRUE TRUE FALSE TRUE Beta-hämolytischer Streptococcus Beta-hemolytische Streptococcus Streptococcus Beta-hemolítico Streptococcus Beta-emolitico Streptococcus Bêta-hémolytique Streptococcus Beta-hemolítico
|
||||
unknown Gram-negatives TRUE TRUE FALSE TRUE unbekannte Gramnegativen onbekende Gram-negatieven Gram negativos desconocidos Gram negativi sconosciuti Gram négatifs inconnus Gram negativos desconhecidos
|
||||
unknown Gram-positives TRUE TRUE FALSE TRUE unbekannte Grampositiven onbekende Gram-positieven Gram positivos desconocidos Gram positivi sconosciuti Gram positifs inconnus Gram positivos desconhecidos
|
||||
unknown fungus TRUE TRUE FALSE TRUE unbekannter Pilze onbekende schimmel hongo desconocido fungo sconosciuto champignon inconnu fungo desconhecido
|
||||
unknown yeast TRUE TRUE FALSE TRUE unbekannte Hefe onbekende gist levadura desconocida lievito sconosciuto levure inconnue levedura desconhecida
|
||||
unknown name TRUE TRUE FALSE TRUE unbekannte Name onbekende naam nombre desconocido nome sconosciuto nom inconnu nome desconhecido
|
||||
unknown kingdom TRUE TRUE FALSE TRUE unbekanntes Reich onbekend koninkrijk reino desconocido regno sconosciuto règme inconnu reino desconhecido
|
||||
unknown phylum TRUE TRUE FALSE TRUE unbekannter Stamm onbekend fylum filo desconocido phylum sconosciuto embranchement inconnu filo desconhecido
|
||||
unknown class TRUE TRUE FALSE TRUE unbekannte Klasse onbekende klasse clase desconocida classe sconosciuta classe inconnue classe desconhecida
|
||||
unknown order TRUE TRUE FALSE TRUE unbekannte Ordnung onbekende orde orden desconocido ordine sconosciuto ordre inconnu ordem desconhecido
|
||||
unknown family TRUE TRUE FALSE TRUE unbekannte Familie onbekende familie familia desconocida famiglia sconosciuta famille inconnue família desconhecida
|
||||
unknown genus TRUE TRUE FALSE TRUE unbekannte Gattung onbekend geslacht género desconocido genere sconosciuto genre inconnu gênero desconhecido
|
||||
unknown species TRUE TRUE FALSE TRUE unbekannte Art onbekende soort especie desconocida specie sconosciute espèce inconnue espécies desconhecida
|
||||
unknown subspecies TRUE TRUE FALSE TRUE unbekannte Unterart onbekende ondersoort subespecie desconocida sottospecie sconosciute sous-espèce inconnue subespécies desconhecida
|
||||
unknown rank TRUE TRUE FALSE TRUE unbekannter Rang onbekende rang rango desconocido grado sconosciuto rang inconnu classificação desconhecido
|
||||
CoNS FALSE TRUE FALSE TRUE KNS CNS SCN
|
||||
CoPS FALSE TRUE FALSE TRUE KPS CPS SCP
|
||||
Gram-negative TRUE TRUE FALSE FALSE Gramnegativ Gram-negatief Gram negativo Gram negativo Gram négatif Gram negativo
|
||||
Gram-positive TRUE TRUE FALSE FALSE Grampositiv Gram-positief Gram positivo Gram positivo Gram positif Gram positivo
|
||||
^Bacteria$ TRUE TRUE FALSE FALSE Bakterien Bacteriën Bacterias Batteri Bactéries Bactérias
|
||||
^Fungi$ TRUE TRUE FALSE FALSE Pilze Schimmels Hongos Funghi Champignons Fungos
|
||||
^Yeasts$ TRUE TRUE FALSE FALSE Hefen Gisten Levaduras Lieviti Levures Leveduras
|
||||
^Protozoa$ TRUE TRUE FALSE FALSE Protozoen Protozoën Protozoarios Protozoi Protozoaires Protozoários
|
||||
biogroup TRUE TRUE FALSE FALSE Biogruppe biogroep biogrupo biogruppo biogroupe biogrupo
|
||||
biotype TRUE TRUE FALSE FALSE Biotyp biotipo biotipo biótipo
|
||||
vegetative TRUE TRUE FALSE FALSE vegetativ vegetatief vegetativo vegetativo végétatif vegetativo
|
||||
([([ ]*?)group TRUE TRUE FALSE FALSE \\1Gruppe \\1groep \\1grupo \\1gruppo \\1groupe \\1grupo
|
||||
([([ ]*?)Group TRUE TRUE FALSE FALSE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo
|
||||
no .*growth TRUE FALSE FALSE FALSE keine? .*wachstum geen .*groei no .*crecimientonon sem .*crescimento pas .*croissance sem .*crescimento
|
||||
no|not TRUE FALSE FALSE FALSE keine? geen|niet no|sin sem non sem
|
||||
Susceptible TRUE FALSE FALSE FALSE Empfindlich Gevoelig Susceptible
|
||||
Intermediate TRUE FALSE FALSE FALSE Mittlere Intermediair Intermedio
|
||||
Incr. exposure TRUE FALSE FALSE FALSE Empfindlich, erh Belastung 'Incr. exposure' 'Incr. exposure'
|
||||
Resistant TRUE FALSE FALSE FALSE Resistent Resistent Resistente
|
||||
antibiotic TRUE TRUE FALSE FALSE Antibiotikum antibioticum antibiótico
|
||||
Antibiotic TRUE TRUE FALSE FALSE Antibiotikum Antibioticum Antibiótico
|
||||
Drug TRUE TRUE FALSE FALSE Medikament Middel Fármaco
|
||||
drug TRUE TRUE FALSE FALSE Medikament middel fármaco
|
||||
Frequency FALSE TRUE FALSE FALSE Zahl Aantal
|
||||
Minimum Inhibitory Concentration (mg/L) FALSE FALSE FALSE FALSE Minimale Hemm-Konzentration (mg/L) Minimale inhiberende concentratie (mg/L)
|
||||
Disk diffusion diameter (mm) FALSE FALSE FALSE FALSE Durchmesser der Scheibenzone (mm) Diameter diskzone (mm)
|
||||
Antimicrobial Interpretation FALSE FALSE FALSE FALSE Antimikrobielle Auswertung Antimicrobiële interpretatie
|
||||
4-aminosalicylic acid FALSE TRUE TRUE FALSE 4-Aminosalicylsäure 4-aminosalicylzuur Ácido 4-aminosalicílico
|
||||
Adefovir dipivoxil FALSE TRUE TRUE FALSE Adefovir Dipivoxil Adefovir Adefovir dipivoxil
|
||||
Aldesulfone sodium FALSE TRUE TRUE FALSE Aldesulfon-Natrium Aldesulfon Aldesulfona sódica
|
||||
Amikacin FALSE TRUE TRUE FALSE Amikacin Amikacine Amikacina
|
||||
Amoxicillin FALSE TRUE TRUE FALSE Amoxicillin Amoxicilline Amoxicilina
|
||||
Amoxicillin/beta-lactamase inhibitor FALSE TRUE TRUE FALSE Amoxicillin/Beta-Lactamase-Hemmer Amoxicilline/enzymremmer amoxicilina/inhib. de la beta-lactamasa
|
||||
Amphotericin B FALSE TRUE TRUE FALSE Amphotericin B Amfotericine B Anfotericina B
|
||||
Ampicillin FALSE TRUE TRUE FALSE Ampicillin Ampicilline Ampicilina
|
||||
Ampicillin/beta-lactamase inhibitor FALSE TRUE TRUE FALSE Ampicillin/Beta-Laktamase-Hemmer Ampicilline/enzymremmer Ampicilina/inhib. de la betalactamasa
|
||||
Anidulafungin FALSE TRUE TRUE FALSE Anidulafungin Anidulafungine Anidulafungina
|
||||
Azidocillin FALSE TRUE TRUE FALSE Azidocillin Azidocilline Azidocilina
|
||||
Azithromycin FALSE TRUE TRUE FALSE Azithromycin Azitromycine Azitromicina
|
||||
Azlocillin FALSE TRUE TRUE FALSE Azlocillin Azlocilline Azlocilina
|
||||
Bacampicillin FALSE TRUE TRUE FALSE Bacampicillin Bacampicilline Bacampicilina
|
||||
Bacitracin FALSE TRUE TRUE FALSE Bacitracin Bacitracine Bacitracina
|
||||
Benzathine benzylpenicillin FALSE TRUE TRUE FALSE Benzathin-Benzylpenicillin Benzylpenicillinebenzathine Bencilpenicilina benzatínica
|
||||
Benzathine phenoxymethylpenicillin FALSE TRUE TRUE FALSE Benzathin-Phenoxymethylpenicillin Fenoxymethylpenicillinebenzathine Fenoximetilpenicilina benzatínica
|
||||
Benzylpenicillin FALSE TRUE TRUE FALSE Benzylpenicillin Benzylpenicilline Bencilpenicilina
|
||||
Calcium aminosalicylate FALSE TRUE TRUE FALSE Kalzium-Aminosalicylat Aminosalicylzuur Aminosalicilato de calcio
|
||||
Capreomycin FALSE TRUE TRUE FALSE Capreomycin Capreomycine Capreomicina
|
||||
Carbenicillin FALSE TRUE TRUE FALSE Carbenicillin Carbenicilline Carbenicilina
|
||||
Carindacillin FALSE TRUE TRUE FALSE Carindacillin Carindacilline Carindacilina
|
||||
Caspofungin FALSE TRUE TRUE FALSE Caspofungin Caspofungine Caspofungina
|
||||
Ce(f|ph)acetrile TRUE TRUE TRUE FALSE Cefacetril Cefacetril Cefacetrilo
|
||||
Ce(f|ph)alotin TRUE TRUE TRUE FALSE Cefalotin Cefalotine Cefalotina
|
||||
Ce(f|ph)amandole TRUE TRUE TRUE FALSE Cefamandol Cefamandol Cefamandole
|
||||
Ce(f|ph)apirin TRUE TRUE TRUE FALSE Cefapirin Cefapirine Cefapirina
|
||||
Ce(f|ph)azedone TRUE TRUE TRUE FALSE Cefazedon Cefazedon Cefazedona
|
||||
Ce(f|ph)azolin TRUE TRUE TRUE FALSE Cefazolin Cefazoline Cefazolina
|
||||
Ce(f|ph)alothin TRUE TRUE TRUE FALSE Cefalothin Cefalotine Cefalotina
|
||||
Ce(f|ph)alexin TRUE TRUE TRUE FALSE Cefalexin Cefalexine Cefalexina
|
||||
Ce(f|ph)epime TRUE TRUE TRUE FALSE Cefepim Cefepim Cefepime
|
||||
Ce(f|ph)ixime TRUE TRUE TRUE FALSE Cefixim Cefixim Cefixima
|
||||
Ce(f|ph)menoxime TRUE TRUE TRUE FALSE Cefmenoxim Cefmenoxim Cefmenoxima
|
||||
Ce(f|ph)metazole TRUE TRUE TRUE FALSE Cefmetazol Cefmetazol Cefmetazol
|
||||
Ce(f|ph)odizime TRUE TRUE TRUE FALSE Cefodizim Cefodizim Cefodizima
|
||||
Ce(f|ph)onicid TRUE TRUE TRUE FALSE Cefonicid Cefonicide Cefonicid
|
||||
Ce(f|ph)operazone TRUE TRUE TRUE FALSE Cefoperazon Cefoperazon Cefoperazona
|
||||
Ce(f|ph)operazone/beta-lactamase inhibitor TRUE TRUE TRUE FALSE Cefoperazon/Beta-Lactamase-Hemmer Cefoperazon/enzymremmer Cefoperazona/inhib. de la betalactamasa
|
||||
Ce(f|ph)otaxime TRUE TRUE TRUE FALSE Cefotaxim Cefotaxim Cefotaxima
|
||||
Ce(f|ph)oxitin TRUE TRUE TRUE FALSE Cefoxitin Cefoxitine Cefoxitina
|
||||
Ce(f|ph)pirome TRUE TRUE TRUE FALSE Cefpirom Cefpirom Cefpirome
|
||||
Ce(f|ph)podoxime TRUE TRUE TRUE FALSE Cefpodoxim Cefpodoxim Cefpodoxima
|
||||
Ce(f|ph)radine TRUE TRUE TRUE FALSE Cefradin Cefradine Cefradina
|
||||
Ce(f|ph)sulodin TRUE TRUE TRUE FALSE Cefsulodin Cefsulodine Cefsulodina
|
||||
Ce(f|ph)tazidime TRUE TRUE TRUE FALSE Ceftazidim Ceftazidim Ceftazidima
|
||||
Ce(f|ph)tezole TRUE TRUE TRUE FALSE Ceftezol Ceftezol Ceftezol
|
||||
Ce(f|ph)tizoxime TRUE TRUE TRUE FALSE Ceftizoxim Ceftizoxim Ceftizoxima
|
||||
Ce(f|ph)triaxone TRUE TRUE TRUE FALSE Ceftriaxon Ceftriaxon Ceftriaxona
|
||||
Ce(f|ph)uroxime TRUE TRUE TRUE FALSE Cefuroxim Cefuroxim Cefuroxima
|
||||
Ce(f|ph)uroxime/metronidazole TRUE TRUE TRUE FALSE Cefuroxim/Metronidazol Cefuroxim/andere antibacteriele middelen Cefuroxima/metronidazol
|
||||
Chloramphenicol FALSE TRUE TRUE FALSE Chloramphenicol Chlooramfenicol Cloranfenicol
|
||||
Chlortetracycline FALSE TRUE TRUE FALSE Chlortetracyclin Chloortetracycline Clortetraciclina
|
||||
Cinoxacin FALSE TRUE TRUE FALSE Cinoxacin Cinoxacine Cinoxacina
|
||||
Ciprofloxacin FALSE TRUE TRUE FALSE Ciprofloxacin Ciprofloxacine Ciprofloxacina
|
||||
Clarithromycin FALSE TRUE TRUE FALSE Clarithromycin Claritromycine Claritromicina
|
||||
Clavulanic acid FALSE TRUE TRUE FALSE Clavulansäure Clavulaanzuur Ácido clavulánico
|
||||
clavulanic acid FALSE TRUE TRUE FALSE Clavulansäure clavulaanzuur ácido clavulánico
|
||||
Clindamycin FALSE TRUE TRUE FALSE Clindamycin Clindamycine Clindamicina
|
||||
Clometocillin FALSE TRUE TRUE FALSE Clometocillin Clometocilline Clometocilina
|
||||
Clotrimazole FALSE TRUE TRUE FALSE Clotrimazol Clotrimazol Clotrimazol
|
||||
Cloxacillin FALSE TRUE TRUE FALSE Cloxacillin Cloxacilline Cloxacilina
|
||||
Colistin FALSE TRUE TRUE FALSE Colistin Colistine Colistina
|
||||
Dapsone FALSE TRUE TRUE FALSE Dapson Dapson Dapsona
|
||||
Daptomycin FALSE TRUE TRUE FALSE Daptomycin Daptomycine Daptomicina
|
||||
Dibekacin FALSE TRUE TRUE FALSE Dibekacin Dibekacine Dibekacina
|
||||
Dicloxacillin FALSE TRUE TRUE FALSE Dicloxacillin Dicloxacilline Dicloxacilina
|
||||
Dirithromycin FALSE TRUE TRUE FALSE Dirithromycin Diritromycine Diritromicina
|
||||
Econazole FALSE TRUE TRUE FALSE Econazol Econazol Econazol
|
||||
Enoxacin FALSE TRUE TRUE FALSE Enoxacin Enoxacine Enoxacina
|
||||
Epicillin FALSE TRUE TRUE FALSE Epicillin Epicilline Epicilina
|
||||
Erythromycin FALSE TRUE TRUE FALSE Erythromycin Erytromycine Eritromicina
|
||||
Ethambutol/isoniazid FALSE TRUE TRUE FALSE Ethambutol/Isoniazid Ethambutol/isoniazide Etambutol/isoniazida
|
||||
Fleroxacin FALSE TRUE TRUE FALSE Fleroxacin Fleroxacine Fleroxacina
|
||||
Flucloxacillin FALSE TRUE TRUE FALSE Flucloxacillin Flucloxacilline Flucloxacilina
|
||||
Fluconazole FALSE TRUE TRUE FALSE Fluconazol Fluconazol Fluconazol
|
||||
Flucytosine FALSE TRUE TRUE FALSE Flucytosin Fluorocytosine Flucitosina
|
||||
Flurithromycin FALSE TRUE TRUE FALSE Flurithromycin Fluritromycine Fluritromicina
|
||||
Fosfomycin FALSE TRUE TRUE FALSE Fosfomycin Fosfomycine Fosfomicina
|
||||
Fusidic acid FALSE TRUE TRUE FALSE Fusidinsäure Fusidinezuur Ácido fusídico
|
||||
Gatifloxacin FALSE TRUE TRUE FALSE Gatifloxacin Gatifloxacine Gatifloxacina
|
||||
Gemifloxacin FALSE TRUE TRUE FALSE Gemifloxacin Gemifloxacine Gemifloxacina
|
||||
Gentamicin FALSE TRUE TRUE FALSE Gentamicin Gentamicine Gentamicina
|
||||
Grepafloxacin FALSE TRUE TRUE FALSE Grepafloxacin Grepafloxacine Grepafloxacina
|
||||
Hachimycin FALSE TRUE TRUE FALSE Hachimycin Hachimycine Hachimycin
|
||||
Hetacillin FALSE TRUE TRUE FALSE Hetacillin Hetacilline Hetacilina
|
||||
Imipenem/cilastatin FALSE TRUE TRUE FALSE Imipenem/Cilastatin Imipenem/enzymremmer Imipenem/cilastatina
|
||||
Inosine pranobex FALSE TRUE TRUE FALSE Inosin-Pranobex Inosiplex Inosina pranobex
|
||||
Isepamicin FALSE TRUE TRUE FALSE Isepamicin Isepamicine Isepamicina
|
||||
Isoconazole FALSE TRUE TRUE FALSE Isoconazol Isoconazol Isoconazol
|
||||
Isoniazid FALSE TRUE TRUE FALSE Isoniazid Isoniazide Isoniazida
|
||||
Itraconazole FALSE TRUE TRUE FALSE Itraconazol Itraconazol Itraconazol
|
||||
Josamycin FALSE TRUE TRUE FALSE Josamycin Josamycine Josamicina
|
||||
Kanamycin FALSE TRUE TRUE FALSE Kanamycin Kanamycine Kanamicina
|
||||
Ketoconazole FALSE TRUE TRUE FALSE Ketoconazol Ketoconazol Ketoconazol
|
||||
Levofloxacin FALSE TRUE TRUE FALSE Levofloxacin Levofloxacine Levofloxacina
|
||||
Lincomycin FALSE TRUE TRUE FALSE Lincomycin Lincomycine Lincomicina
|
||||
Lomefloxacin FALSE TRUE TRUE FALSE Lomefloxacin Lomefloxacine Lomefloxacina
|
||||
Lysozyme FALSE TRUE TRUE FALSE Lysozym Lysozym Lisozima
|
||||
Mandelic acid FALSE TRUE TRUE FALSE Mandelsäure Amandelzuur Ácido mandélico
|
||||
Metampicillin FALSE TRUE TRUE FALSE Metampicillin Metampicilline Metampicilina
|
||||
Meticillin FALSE TRUE TRUE FALSE Meticillin Meticilline Meticilina
|
||||
Metisazone FALSE TRUE TRUE FALSE Metisazon Metisazon Metisazona
|
||||
Metronidazole FALSE TRUE TRUE FALSE Metronidazol Metronidazol Metronidazol
|
||||
Mezlocillin FALSE TRUE TRUE FALSE Mezlocillin Mezlocilline Mezlocilina
|
||||
Micafungin FALSE TRUE TRUE FALSE Micafungin Micafungine Micafungina
|
||||
Miconazole FALSE TRUE TRUE FALSE Miconazol Miconazol Miconazol
|
||||
Midecamycin FALSE TRUE TRUE FALSE Midecamycin Midecamycine Midecamicina
|
||||
Miocamycin FALSE TRUE TRUE FALSE Miocamycin Miocamycine Miocamycin
|
||||
Moxifloxacin FALSE TRUE TRUE FALSE Moxifloxacin Moxifloxacine Moxifloxacina
|
||||
Mupirocin FALSE TRUE TRUE FALSE Mupirocin Mupirocine Mupirocina
|
||||
Nalidixic acid FALSE TRUE TRUE FALSE Nalidixinsäure Nalidixinezuur Ácido nalidíxico
|
||||
Neomycin FALSE TRUE TRUE FALSE Neomycin Neomycine Neomicina
|
||||
Netilmicin FALSE TRUE TRUE FALSE Netilmicin Netilmicine Netilmicina
|
||||
Nitrofurantoin FALSE TRUE TRUE FALSE Nitrofurantoin Nitrofurantoine Nitrofurantoína
|
||||
Norfloxacin FALSE TRUE TRUE FALSE Norfloxacin Norfloxacine Norfloxacina
|
||||
Novobiocin FALSE TRUE TRUE FALSE Novobiocin Novobiocine Novobiocina
|
||||
Nystatin FALSE TRUE TRUE FALSE Nystatin Nystatine Nistatina
|
||||
Ofloxacin FALSE TRUE TRUE FALSE Ofloxacin Ofloxacine Ofloxacina
|
||||
Oleandomycin FALSE TRUE TRUE FALSE Oleandomycin Oleandomycine Oleandomicina
|
||||
Ornidazole FALSE TRUE TRUE FALSE Ornidazol Ornidazol Ornidazol
|
||||
Oxacillin FALSE TRUE TRUE FALSE Oxacillin Oxacilline Oxacilina
|
||||
Oxolinic acid FALSE TRUE TRUE FALSE Oxolinsäure Oxolinezuur Ácido oxolínico
|
||||
Oxytetracycline FALSE TRUE TRUE FALSE Oxytetracyclin Oxytetracycline Oxitetraciclina
|
||||
Pazufloxacin FALSE TRUE TRUE FALSE Pazufloxacin Pazufloxacine Pazufloxacina
|
||||
Pefloxacin FALSE TRUE TRUE FALSE Pefloxacin Pefloxacine Pefloxacina
|
||||
Penamecillin FALSE TRUE TRUE FALSE Penamecillin Penamecilline Penamecilina
|
||||
Penicillin FALSE TRUE TRUE FALSE Penicillin Penicilline Penicilina
|
||||
Pheneticillin FALSE TRUE TRUE FALSE Pheneticillin Feneticilline Feneticilina
|
||||
Phenoxymethylpenicillin FALSE TRUE TRUE FALSE Phenoxymethylpenicillin Fenoxymethylpenicilline Fenoximetilpenicilina
|
||||
Pipemidic acid FALSE TRUE TRUE FALSE Pipemidinsäure Pipemidinezuur Ácido pipemídico
|
||||
Piperacillin FALSE TRUE TRUE FALSE Piperacillin Piperacilline Piperacilina
|
||||
Piperacillin/beta-lactamase inhibitor FALSE TRUE TRUE FALSE Piperacillin/Beta-Lactamase-Hemmer Piperacilline/enzymremmer Piperacilina/inhib. de la betalactamasa
|
||||
Piromidic acid FALSE TRUE TRUE FALSE Piromidinsäure Piromidinezuur Ácido piromídico
|
||||
Pivampicillin FALSE TRUE TRUE FALSE Pivampicillin Pivampicilline Pivampicilina
|
||||
Polymyxin B FALSE TRUE TRUE FALSE Polymyxin B Polymyxine B Polimixina B
|
||||
Posaconazole FALSE TRUE TRUE FALSE Posaconazol Posaconazol Posaconazol
|
||||
Pristinamycin FALSE TRUE TRUE FALSE Pristinamycin Pristinamycine Pristinamicina
|
||||
Procaine benzylpenicillin FALSE TRUE TRUE FALSE Procain-Benzylpenicillin Benzylpenicillineprocaine Bencilpenicilina procaína
|
||||
Propicillin FALSE TRUE TRUE FALSE Propicillin Propicilline Propicilina
|
||||
Prulifloxacin FALSE TRUE TRUE FALSE Prulifloxacin Prulifloxacine Prulifloxacina
|
||||
Quinupristin/dalfopristin FALSE TRUE TRUE FALSE Quinupristin/Dalfopristin Quinupristine/dalfopristine Quinupristina/dalfopristina
|
||||
Ribostamycin FALSE TRUE TRUE FALSE Ribostamycin Ribostamycine Ribostamicina
|
||||
Rifabutin FALSE TRUE TRUE FALSE Rifabutin Rifabutine Rifabutina
|
||||
Rifampicin FALSE TRUE TRUE FALSE Rifampicin Rifampicine Rifampicina
|
||||
Rifampicin/pyrazinamide/ethambutol/isoniazid FALSE TRUE TRUE FALSE Rifampicin/Pyrazinamid/Ethambutol/Isoniazid Rifampicine/pyrazinamide/ethambutol/isoniazide Rifampicina/pirazinamida/etambutol/isoniazida
|
||||
Rifampicin/pyrazinamide/isoniazid FALSE TRUE TRUE FALSE Rifampicin/Pyrazinamid/Isoniazid Rifampicine/pyrazinamide/isoniazide Rifampicina/pirazinamida/isoniazida
|
||||
Rifampicin/isoniazid FALSE TRUE TRUE FALSE Rifampicin/Isoniazid Rifampicine/isoniazide Rifampicina/isoniazida
|
||||
Rifamycin FALSE TRUE TRUE FALSE Rifamycin Rifamycine Rifamicina
|
||||
Rifaximin FALSE TRUE TRUE FALSE Rifaximin Rifaximine Rifaximina
|
||||
Rokitamycin FALSE TRUE TRUE FALSE Rokitamycin Rokitamycine Rokitamicina
|
||||
Rosoxacin FALSE TRUE TRUE FALSE Rosoxacin Rosoxacine Rosoxacina
|
||||
Roxithromycin FALSE TRUE TRUE FALSE Roxithromycin Roxitromycine Roxitromicina
|
||||
Rufloxacin FALSE TRUE TRUE FALSE Rufloxacin Rufloxacine Rufloxacina
|
||||
Sisomicin FALSE TRUE TRUE FALSE Sisomicin Sisomicine Sisomicina
|
||||
Sodium aminosalicylate FALSE TRUE TRUE FALSE Natrium-Aminosalicylat Aminosalicylzuur Aminosalicilato de sodio
|
||||
Sparfloxacin FALSE TRUE TRUE FALSE Sparfloxacin Sparfloxacine Esparfloxacina
|
||||
Spectinomycin FALSE TRUE TRUE FALSE Spectinomycin Spectinomycine Espectinomicina
|
||||
Spiramycin FALSE TRUE TRUE FALSE Spiramycin Spiramycine Espiramicina
|
||||
Spiramycin/metronidazole FALSE TRUE TRUE FALSE Spiramycin/Metronidazol Spiramycine/metronidazol Espiramicina/metronidazol
|
||||
Staphylococcus immunoglobulin FALSE TRUE TRUE FALSE Staphylococcus-Immunoglobulin Stafylokokkenimmunoglobuline Inmunoglobulina estafilocócica
|
||||
Streptoduocin FALSE TRUE TRUE FALSE Streptoduocin Streptoduocine Estreptoduocina
|
||||
Streptomycin FALSE TRUE TRUE FALSE Streptomycin Streptomycine Estreptomicina
|
||||
Streptomycin/isoniazid FALSE TRUE TRUE FALSE Streptomycin/Isoniazid Streptomycine/isoniazide Estreptomicina/isoniazida
|
||||
Sulbenicillin FALSE TRUE TRUE FALSE Sulbenicillin Sulbenicilline Sulbenicilina
|
||||
Sulfadiazine/tetroxoprim FALSE TRUE TRUE FALSE Sulfadiazin/Tetroxoprim Sulfadiazine/tetroxoprim Sulfadiazina/tetroxoprima
|
||||
Sulfadiazine/trimethoprim FALSE TRUE TRUE FALSE Sulfadiazin/Trimethoprim Sulfadiazine/trimethoprim Sulfadiazina/trimetoprima
|
||||
Sulfadimidine/trimethoprim FALSE TRUE TRUE FALSE Sulfadimidin/Trimethoprim Sulfadimidine/trimethoprim Sulfadimidina/trimetoprima
|
||||
Sulfafurazole FALSE TRUE TRUE FALSE Sulfafurazol Sulfafurazol Sulfafurazol
|
||||
Sulfaisodimidine FALSE TRUE TRUE FALSE Sulfaisodimidin Sulfisomidine Sulfaisodimidina
|
||||
Sulfalene FALSE TRUE TRUE FALSE Sulfalene Sulfaleen Sulfaleno
|
||||
Sulfamazone FALSE TRUE TRUE FALSE Sulfamazon Sulfamazon Sulfamazona
|
||||
Sulfamerazine/trimethoprim FALSE TRUE TRUE FALSE Sulfamerazin/Trimethoprim Sulfamerazine/trimethoprim Sulfamerazina/trimetoprima
|
||||
Sulfamethizole FALSE TRUE TRUE FALSE Sulfamethizol Sulfamethizol Sulfametozol
|
||||
Sulfamethoxazole FALSE TRUE TRUE FALSE Sulfamethoxazol Sulfamethoxazol Sulfametoxazol
|
||||
Sulfamethoxazole/trimethoprim FALSE TRUE TRUE FALSE Sulfamethoxazol/Trimethoprim Sulfamethoxazol/trimethoprim Sulfametoxazol/trimetoprima
|
||||
Sulfametoxydiazine FALSE TRUE TRUE FALSE Sulfametoxydiazin Sulfamethoxydiazine Sulfametoxidiazina
|
||||
Sulfametrole/trimethoprim FALSE TRUE TRUE FALSE Sulfametrole/Trimethoprim Sulfametrol/trimethoprim Sulfametrole/trimethoprim
|
||||
Sulfamoxole FALSE TRUE TRUE FALSE Sulfamoxol Sulfamoxol Sulfamoxole
|
||||
Sulfamoxole/trimethoprim FALSE TRUE TRUE FALSE Sulfamoxol/Trimethoprim Sulfamoxol/trimethoprim Sulfamoxol/trimetoprima
|
||||
Sulfaperin FALSE TRUE TRUE FALSE Sulfaperin Sulfaperine Sulfaproxeno
|
||||
Sulfaphenazole FALSE TRUE TRUE FALSE Sulfaphenazol Sulfafenazol Sulfafenazol
|
||||
Sulfathiazole FALSE TRUE TRUE FALSE Sulfathiazol Sulfathiazol Sulfatiazol
|
||||
Sulfathiourea FALSE TRUE TRUE FALSE Sulfathioharnstoff Sulfathioureum Sulfathiourea
|
||||
Sultamicillin FALSE TRUE TRUE FALSE Sultamicillin Sultamicilline Sultamicilina
|
||||
Talampicillin FALSE TRUE TRUE FALSE Talampicillin Talampicilline Talampicilina
|
||||
Teicoplanin FALSE TRUE TRUE FALSE Teicoplanin Teicoplanine Teicoplanina
|
||||
Telithromycin FALSE TRUE TRUE FALSE Telithromycin Telitromycine Telitromicina
|
||||
Temafloxacin FALSE TRUE TRUE FALSE Temafloxacin Temafloxacine Temafloxacina
|
||||
Temocillin FALSE TRUE TRUE FALSE Temocillin Temocilline Temocilina
|
||||
Tenofovir disoproxil FALSE TRUE TRUE FALSE Tenofovir Disoproxil Tenofovir Tenofovir disoproxil
|
||||
Terizidone FALSE TRUE TRUE FALSE Terizidon Terizidon Terizidona
|
||||
Thiamphenicol FALSE TRUE TRUE FALSE Thiamphenicol Thiamfenicol Tiamfenicol
|
||||
Thioacetazone/isoniazid FALSE TRUE TRUE FALSE Thioacetazon/Isoniazid Thioacetazon/isoniazide Tioacetazona/isoniazida
|
||||
Ticarcillin FALSE TRUE TRUE FALSE Ticarcillin Ticarcilline Ticarcilina
|
||||
Ticarcillin/beta-lactamase inhibitor FALSE TRUE TRUE FALSE Ticarcillin/Beta-Lactamase-Hemmer Ticarcilline/enzymremmer Ticarcilina/inhib. de la betalactamasa
|
||||
Ticarcillin/clavulanic acid FALSE TRUE TRUE FALSE Ticarcillin/Clavulansäure Ticarcilline/clavulaanzuur Ticarcilina/ácido clavulánico
|
||||
Tinidazole FALSE TRUE TRUE FALSE Tinidazol Tinidazol Tinidazol
|
||||
Tobramycin FALSE TRUE TRUE FALSE Tobramycin Tobramycine Tobramicina
|
||||
Trimethoprim/sulfamethoxazole FALSE TRUE TRUE FALSE Trimethoprim/Sulfamethoxazol Cotrimoxazol Trimetoprima/sulfametoxazol
|
||||
Troleandomycin FALSE TRUE TRUE FALSE Troleandomycin Troleandomycine Troleandomicina
|
||||
Trovafloxacin FALSE TRUE TRUE FALSE Trovafloxacin Trovafloxacine Trovafloxacina
|
||||
Vancomycin FALSE TRUE TRUE FALSE Vancomycin Vancomycine Vancomicina
|
||||
Voriconazole FALSE TRUE TRUE FALSE Voriconazol Voriconazol Voriconazol
|
||||
Aminoglycosides FALSE TRUE TRUE FALSE Aminoglykoside Aminoglycosiden Aminoglucósidos
|
||||
Amphenicols FALSE TRUE TRUE FALSE Amphenicole Amfenicolen Anfenicoles
|
||||
Antifungals/antimycotics FALSE TRUE TRUE FALSE Antimykotika/Antimykotika Antifungica/antimycotica Antifúngicos/antimicóticos
|
||||
Antimycobacterials FALSE TRUE TRUE FALSE Antimykobakterielle Mittel Antimycobacteriele middelen Antimicrobianos
|
||||
Beta-lactams/penicillins FALSE TRUE TRUE FALSE Beta-Lactame/Penicilline Beta-lactams/penicillines Beta-lactámicos/penicilinas
|
||||
Cephalosporins (1st gen.) FALSE TRUE TRUE FALSE Cephalosporine (1. Gen.) Cefalosporines (1e gen.) Cefalosporinas (1er gen.)
|
||||
Cephalosporins (2nd gen.) FALSE TRUE TRUE FALSE Cephalosporine (2. Gen.) Cefalosporines (2e gen.) Cefalosporinas (2do gen.)
|
||||
Cephalosporins (3rd gen.) FALSE TRUE TRUE FALSE Cephalosporine (3. Gen.) Cefalosporines (3e gen.) Cefalosporinas (3er gen.)
|
||||
Cephalosporins (4th gen.) FALSE TRUE TRUE FALSE Cephalosporine (4. Gen.) Cefalosporines (4e gen.) Cefalosporinas (4º gen.)
|
||||
Cephalosporins (5th gen.) FALSE TRUE TRUE FALSE Cephalosporine (5. Gen.) Cefalosporines (5e gen.) Cefalosporinas (5º gen.)
|
||||
Cephalosporins (unclassified gen.) FALSE TRUE TRUE FALSE Cephalosporine (unklassifiziert) Cefalosporines (ongeclassificeerd) Cefalosporinas (no clasificado)
|
||||
Cephalosporins FALSE TRUE TRUE FALSE Cephalosporine Cefalosporines Cefalosporinas
|
||||
Glycopeptides FALSE TRUE TRUE FALSE Glykopeptide Glycopeptiden Glicopéptidos
|
||||
Macrolides/lincosamides FALSE TRUE TRUE FALSE Makrolide/Linkosamide Macroliden/lincosamiden Macrólidos/lincosamidas
|
||||
Other antibacterials FALSE TRUE TRUE FALSE Andere Antibiotika Overige antibiotica Otros antibacterianos
|
||||
Polymyxins FALSE TRUE TRUE FALSE Polymyxine Polymyxines Polimixinas
|
||||
Quinolones FALSE TRUE TRUE FALSE Quinolone Quinolonen Quinolonas
|
||||
|
@@ -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.9020</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</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.9020</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</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: 51 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 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 |
@@ -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.0</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>
|
||||
|
||||
@@ -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.0</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 I I I I S S</span>
|
||||
<span class="co"># 2 R I S I I I</span>
|
||||
<span class="co"># 3 S R R R R I</span>
|
||||
<span class="co"># 4 S R S S R S</span>
|
||||
<span class="co"># 5 R S I R S R</span>
|
||||
<span class="co"># 6 R R R R I I</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"># 5 S</span>
|
||||
<span class="co"># 6 I</span></pre></div>
|
||||
<span class="co"># 2 I</span>
|
||||
<span class="co"># 3 S</span>
|
||||
<span class="co"># 4 R</span>
|
||||
<span class="co"># 5 I</span>
|
||||
<span class="co"># 6 I</span></code></pre></div>
|
||||
<p>We can now add the interpretation of MDR-TB to our data set. You can use:</p>
|
||||
<div class="sourceCode" id="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">3271</td>
|
||||
<td align="right">65.42%</td>
|
||||
<td align="right">3271</td>
|
||||
<td align="right">65.42%</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">949</td>
|
||||
<td align="right">18.98%</td>
|
||||
<td align="right">4220</td>
|
||||
<td align="right">84.40%</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">449</td>
|
||||
<td align="right">8.98%</td>
|
||||
<td align="right">4669</td>
|
||||
<td align="right">93.38%</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">240</td>
|
||||
<td align="right">4.80%</td>
|
||||
<td align="right">4909</td>
|
||||
<td align="right">98.18%</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">91</td>
|
||||
<td align="right">1.82%</td>
|
||||
<td align="right">5000</td>
|
||||
<td align="right">100.00%</td>
|
||||
</tr>
|
||||
|
||||
@@ -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.0</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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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, 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, 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, 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, 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, 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, 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, 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, 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 |
@@ -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.0</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">26 May 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">403,383 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>
|
||||
|
||||
@@ -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.0</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>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 |
@@ -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.0</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") 10.0 11.0 16.0 11.0 13.0 50 25</span>
|
||||
<span class="co"># as.mo("stau") 54.0 58.0 72.0 61.0 89.0 99 25</span>
|
||||
<span class="co"># as.mo("STAU") 53.0 55.0 67.0 56.0 91.0 95 25</span>
|
||||
<span class="co"># as.mo("staaur") 10.0 11.0 16.0 11.0 13.0 47 25</span>
|
||||
<span class="co"># as.mo("STAAUR") 10.0 11.0 17.0 12.0 13.0 58 25</span>
|
||||
<span class="co"># as.mo("S. aureus") 26.0 27.0 36.0 31.0 33.0 70 25</span>
|
||||
<span class="co"># as.mo("S aureus") 26.0 27.0 40.0 29.0 61.0 68 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus") 2.6 3.2 6.5 3.5 3.8 42 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 240.0 250.0 260.0 260.0 270.0 290 25</span>
|
||||
<span class="co"># as.mo("Sthafilokkockus aaureuz") 190.0 190.0 200.0 200.0 210.0 300 25</span>
|
||||
<span class="co"># as.mo("MRSA") 10.0 11.0 13.0 12.0 13.0 40 25</span>
|
||||
<span class="co"># as.mo("VISA") 18.0 19.0 32.0 20.0 24.0 130 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_EPDR B_STRPT_GRPA B_STPHY_AURS B_BCTRD_FRGL B_STPHY_HMNS</span>
|
||||
<span class="co"># [6] B_STPHY_CONS</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) 187 223 233 226 229 318 10</span></code></pre></div>
|
||||
<p>So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.226 seconds. That is 113 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 7.28 7.59 8.01 8.03 8.45 8.66 10</span>
|
||||
<span class="co"># B 23.00 24.10 30.30 25.50 27.30 75.30 10</span>
|
||||
<span class="co"># C 1.55 1.74 7.31 1.95 2.01 56.10 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.0019 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.42 1.45 1.56 1.50 1.57 2.00 10</span>
|
||||
<span class="co"># B 1.43 1.46 1.49 1.47 1.55 1.59 10</span>
|
||||
<span class="co"># C 1.41 1.43 1.58 1.49 1.57 2.19 10</span>
|
||||
<span class="co"># D 1.41 1.48 1.61 1.54 1.63 2.33 10</span>
|
||||
<span class="co"># E 1.41 1.45 1.64 1.51 1.56 2.68 10</span>
|
||||
<span class="co"># F 1.42 1.52 1.63 1.57 1.71 1.99 10</span>
|
||||
<span class="co"># G 1.41 1.46 1.65 1.56 1.90 1.98 10</span>
|
||||
<span class="co"># H 1.42 1.46 1.59 1.55 1.70 1.88 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 17.81 18.24 21.93 18.78 19.44 60.56 100</span>
|
||||
<span class="co"># de 28.82 29.53 37.92 30.33 32.62 81.75 100</span>
|
||||
<span class="co"># nl 32.65 33.61 44.22 34.43 37.44 193.90 100</span>
|
||||
<span class="co"># es 32.51 32.95 41.88 33.70 36.39 80.63 100</span>
|
||||
<span class="co"># it 22.00 22.57 27.98 23.15 25.14 67.04 100</span>
|
||||
<span class="co"># fr 21.71 22.22 27.20 22.83 24.41 66.08 100</span>
|
||||
<span class="co"># pt 21.71 22.54 26.97 23.06 23.94 67.41 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.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</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,13 +187,12 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="datasets_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="datasets_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="datasets_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>Data sets for download / own use</h1>
|
||||
|
||||
<h4 class="date">27 April 2021</h4>
|
||||
<h4 class="date">26 May 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>
|
||||
@@ -212,7 +211,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#microorganisms-currently-accepted-names" class="anchor"></a>Microorganisms (currently accepted names)</h2>
|
||||
<p>A data set with 70,026 rows and 16 columns, containing the following column names:<br><em>mo</em>, <em>fullname</em>, <em>kingdom</em>, <em>phylum</em>, <em>class</em>, <em>order</em>, <em>family</em>, <em>genus</em>, <em>species</em>, <em>subspecies</em>, <em>rank</em>, <em>ref</em>, <em>species_id</em>, <em>source</em>, <em>prevalence</em> and <em>snomed</em>.</p>
|
||||
<p>This data set is in R available as <code>microorganisms</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.html">here</a>.</p>
|
||||
<p>It was last updated on 11 March 2021 20:59:32 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.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/microorganisms.rds">R file</a> (2.2 MB)<br>
|
||||
@@ -433,7 +432,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<p>A data set with 14,100 rows and 4 columns, containing the following column names:<br><em>fullname</em>, <em>fullname_new</em>, <em>ref</em> and <em>prevalence</em>.</p>
|
||||
<p><strong>Note:</strong> remember that the ‘ref’ columns contains the scientific reference to the old taxonomic entries, i.e. of column <em>‘fullname’</em>. For the scientific reference of the new names, i.e. of column <em>‘fullname_new’</em>, see the <code>microorganisms</code> data set.</p>
|
||||
<p>This data set is in R available as <code>microorganisms.old</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.old.html">here</a>.</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/microorganisms.old.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/microorganisms.old.rds">R file</a> (0.2 MB)<br>
|
||||
@@ -498,7 +497,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#antibiotic-agents" class="anchor"></a>Antibiotic agents</h2>
|
||||
<p>A data set with 456 rows and 14 columns, containing the following column names:<br><em>ab</em>, <em>atc</em>, <em>cid</em>, <em>name</em>, <em>group</em>, <em>atc_group1</em>, <em>atc_group2</em>, <em>abbreviations</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em>, <em>iv_units</em> and <em>loinc</em>.</p>
|
||||
<p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p>It was last updated on 4 May 2021 13:38:27 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (32 kB)<br>
|
||||
@@ -666,7 +665,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#antiviral-agents" class="anchor"></a>Antiviral agents</h2>
|
||||
<p>A data set with 102 rows and 9 columns, containing the following column names:<br><em>atc</em>, <em>cid</em>, <em>name</em>, <em>atc_group</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em> and <em>iv_units</em>.</p>
|
||||
<p>This data set is in R available as <code>antivirals</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p>It was last updated on 29 August 2020 19:53:07 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antivirals.rds">R file</a> (5 kB)<br>
|
||||
@@ -793,7 +792,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#intrinsic-bacterial-resistance" class="anchor"></a>Intrinsic bacterial resistance</h2>
|
||||
<p>A data set with 93,892 rows and 2 columns, containing the following column names:<br><em>microorganism</em> and <em>antibiotic</em>.</p>
|
||||
<p>This data set is in R available as <code>intrinsic_resistant</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</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/intrinsic_resistant.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/intrinsic_resistant.rds">R file</a> (69 kB)<br>
|
||||
@@ -1008,7 +1007,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<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>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 27 April 2021 08:12:46 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 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><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>
|
||||
@@ -1138,7 +1137,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#dosage-guidelines-from-eucast" class="anchor"></a>Dosage guidelines from EUCAST</h2>
|
||||
<p>A data set with 169 rows and 9 columns, containing the following column names:<br><em>ab</em>, <em>name</em>, <em>type</em>, <em>dose</em>, <em>dose_times</em>, <em>administration</em>, <em>notes</em>, <em>original_txt</em> and <em>eucast_version</em>.</p>
|
||||
<p>This data set is in R available as <code>dosage</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/dosage.html">here</a>.</p>
|
||||
<p>It was last updated on 25 January 2021 20:58:20 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/dosage.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.rds">R file</a> (3 kB)<br>
|
||||
|
||||
@@ -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.9020</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</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.0</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: 65 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.0</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.9020</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -236,13 +236,14 @@
|
||||
<small class="dont-index">Source: <a href='https://github.com/msberends/AMR/blob/master/inst/CITATION'><code>inst/CITATION</code></a></small>
|
||||
</div>
|
||||
|
||||
<p>Berends MS, Luz CF et al. (2021). AMR - An R Package for Working with Antimicrobial Resistance Data. bioRxiv, https://doi.org/10.1101/810622</p>
|
||||
<p>Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C (2021). AMR - An R Package for Working with
|
||||
Antimicrobial Resistance Data. Journal of Statistical Software (accepted for publication), https://www.biorxiv.org/content/10.1101/810622v4</p>
|
||||
<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},
|
||||
journal = {bioRxiv},
|
||||
publisher = {Cold Spring Harbor Laboratory},
|
||||
doi = {10.1101/810622},
|
||||
journal = {Journal of Statistical Software},
|
||||
pages = {Accepted for publication},
|
||||
year = {2021},
|
||||
url = {https://www.biorxiv.org/content/10.1101/810622v4},
|
||||
}</pre>
|
||||
|
||||
@@ -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 {
|
||||
|
||||