Compare commits
73 Commits
v1.6.0
...
f1d9b489c5
| Author | SHA1 | Date | |
|---|---|---|---|
| f1d9b489c5 | |||
| 41d279daa1 | |||
| a12572c752 | |||
| a33c8a51a2 | |||
| 55457d0ab6 | |||
| d0f38a03d5 | |||
| ac73a8d849 | |||
| e5599bc694 | |||
| 4fbf9e1720 | |||
| a13fd98e8b | |||
| 06302d296a | |||
| 07939b1a14 | |||
| fa2f5214b9 | |||
| adca43f8d9 | |||
| 0b1f59edec | |||
| 808024c5f4 | |||
| 65a8b58aa6 | |||
| b210f1327c | |||
| fecc5d183c | |||
| 69a656abc0 | |||
| 4a2a48b7c1 | |||
| d1b1828ab8 | |||
| 04ef5b28e7 | |||
| 9a2879cba9 | |||
| 2413efd5c1 | |||
| 6920c0be41 | |||
| 7028dcfa5b | |||
| d67371acd1 | |||
| cfb7df823e | |||
| be49131ed7 | |||
| 83fec69a03 | |||
| 916df6e90c | |||
| 00496e45b7 | |||
| 6c3ab19e3a | |||
| 3619c1327c | |||
| 73fb0374c3 | |||
| 229e1bb407 | |||
| 6e60ddf8d7 | |||
| 54dd868b22 | |||
| 0ce9fb4da2 | |||
| 86736ab9a7 | |||
| d8c91d5876 | |||
| 9a381c8d18 | |||
| c17acbe712 | |||
| 9ed2f6490f | |||
| 5b9fb8daf4 | |||
| b1d942be91 | |||
| 994d157aa6 | |||
| 9d9d62eba4 | |||
| aeea00881e | |||
| 655b813e99 | |||
| 29dbfa2f49 | |||
| 3319fbae58 | |||
| 5899678b74 | |||
| 0aca719929 | |||
| 5679ccdaf9 | |||
| f33e61bac7 | |||
| 12a8d59869 | |||
| e405de079c | |||
| a9fd4aa49f | |||
| 5e06b20d43 | |||
| c5fff1c95c | |||
| 93683a4ae2 | |||
| 5f9e7bd3ee | |||
| 70b803dbb6 | |||
| c6289c3fc3 | |||
| de66eccf43 | |||
| 24ac18a99d | |||
| 9842ef9660 | |||
| 00d3e437a8 | |||
| d277d58475 | |||
| 6ff5448192 | |||
| 7a3139f7cc |
@@ -1,3 +1,4 @@
|
|||||||
|
^.*\.RData$
|
||||||
^.*\.Rproj$
|
^.*\.Rproj$
|
||||||
^\.Renviron$
|
^\.Renviron$
|
||||||
^\.Rprofile$
|
^\.Rprofile$
|
||||||
|
|||||||
146
.github/workflows/check.yaml
vendored
@@ -50,37 +50,31 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config:
|
||||||
- {os: macOS-latest, r: 'devel', allowfail: false}
|
# 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: '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: '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"}
|
- {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"}
|
- {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: '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.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.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.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
- {os: ubuntu-20.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '3.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.2', allowfail: false, 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.1', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
- {os: ubuntu-20.04, r: '3.0', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '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: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
|
||||||
# - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
|
||||||
# - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
|
||||||
- {os: ubuntu-16.04, r: '3.0', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||||
@@ -89,89 +83,77 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: r-lib/actions/setup-r@master
|
- uses: r-lib/actions/setup-r@v1
|
||||||
with:
|
with:
|
||||||
r-version: ${{ matrix.config.r }}
|
r-version: ${{ matrix.config.r }}
|
||||||
|
|
||||||
- uses: r-lib/actions/setup-pandoc@master
|
- name: Install Linux dependencies
|
||||||
|
if: runner.os == 'Linux'
|
||||||
- name: Query dependencies
|
# update the below with sysreqs::sysreqs("DESCRIPTION") and check the "DEB" entries (for Ubuntu).
|
||||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
# 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: |
|
run: |
|
||||||
install.packages('remotes')
|
sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev libpng-dev
|
||||||
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
|
|
||||||
shell: Rscript {0}
|
|
||||||
|
|
||||||
- name: Cache R packages
|
- name: Restore cached R packages
|
||||||
if: runner.os != 'Windows' && matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
# this step will add the step 'Post Restore cached R packages' on a succesful run
|
||||||
|
if: runner.os != 'Windows'
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ env.R_LIBS_USER }}
|
path: ${{ env.R_LIBS_USER }}
|
||||||
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3-${{ hashFiles('.github/depends.Rds') }}
|
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4
|
||||||
restore-keys: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3-
|
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
- name: Unpack AMR and install R dependencies
|
||||||
if: runner.os == 'Linux' && matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
if: always()
|
||||||
env:
|
|
||||||
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
|
|
||||||
run: |
|
run: |
|
||||||
Rscript -e "remotes::install_github('r-hub/sysreqs')"
|
tar -xf data-raw/AMR_latest.tar.gz
|
||||||
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
|
Rscript -e "source('data-raw/_install_deps.R')"
|
||||||
sudo -s eval "$sysreqs"
|
shell: bash
|
||||||
|
|
||||||
- name: Install Linux dependencies on old R versions
|
- name: Show session info
|
||||||
if: matrix.config.r == '3.0' || matrix.config.r == '3.1' || matrix.config.r == '3.2'
|
if: always()
|
||||||
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
|
|
||||||
run: |
|
run: |
|
||||||
options(width = 100)
|
options(width = 100)
|
||||||
utils::sessionInfo()
|
utils::sessionInfo()
|
||||||
as.data.frame(utils::installed.packages())[, "Version", drop = FALSE]
|
as.data.frame(utils::installed.packages())[, "Version", drop = FALSE]
|
||||||
shell: Rscript {0}
|
shell: Rscript {0}
|
||||||
|
|
||||||
- name: Run R CMD check
|
# - name: Only keep vignettes on release version
|
||||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
- name: Remove vignettes
|
||||||
env:
|
# if: matrix.config.r != 'release'
|
||||||
_R_CHECK_CRAN_INCOMING_: false
|
if: always()
|
||||||
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
|
# writing to DESCRIPTION2 and then moving to DESCRIPTION is required for R < 3.3 as writeLines() cannot overwrite
|
||||||
shell: Rscript {0}
|
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 on older R versions
|
- name: Run R CMD check
|
||||||
if: matrix.config.r == '3.0' || matrix.config.r == '3.1' || matrix.config.r == '3.2'
|
if: always()
|
||||||
env:
|
env:
|
||||||
_R_CHECK_CRAN_INCOMING_: false
|
_R_CHECK_CRAN_INCOMING_: false
|
||||||
_R_CHECK_FORCE_SUGGESTS_: false
|
_R_CHECK_FORCE_SUGGESTS_: false
|
||||||
|
_R_CHECK_DEPENDS_ONLY_: true
|
||||||
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||||
_R_CHECK_LENGTH_1_LOGIC2_: 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: |
|
run: |
|
||||||
R CMD check data-raw/AMR_latest.tar.gz --no-manual --no-build-vignettes
|
R CMD check --no-manual --run-donttest --run-dontrun AMR
|
||||||
|
|
||||||
- name: Show testthat output
|
|
||||||
if: always()
|
|
||||||
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
|
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Upload check results
|
- name: Show unit tests output
|
||||||
if: failure()
|
if: always()
|
||||||
uses: actions/upload-artifact@master
|
run: |
|
||||||
|
find . -name 'tinytest.Rout*' -exec cat '{}' \; || true
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
|
name: artifacts-${{ matrix.config.os }}-r${{ matrix.config.r }}
|
||||||
path: check
|
path: AMR.Rcheck
|
||||||
|
|||||||
54
.github/workflows/codecovr.yaml
vendored
@@ -26,6 +26,7 @@
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- premaster
|
||||||
- master
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
@@ -41,31 +42,52 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- 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
|
- uses: r-lib/actions/setup-pandoc@master
|
||||||
|
|
||||||
- name: Query dependencies
|
- name: Restore cached R packages
|
||||||
run: |
|
# this step will add the step 'Post Restore cached R packages' on a succesful 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
|
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ env.R_LIBS_USER }}
|
path: ${{ env.R_LIBS_USER }}
|
||||||
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
|
key: macOS-latest-r-release-v4
|
||||||
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Unpack AMR and install R dependencies
|
||||||
run: |
|
run: |
|
||||||
install.packages(c("remotes"))
|
tar -xf data-raw/AMR_latest.tar.gz
|
||||||
remotes::install_deps(dependencies = TRUE)
|
Rscript -e "source('data-raw/_install_deps.R')"
|
||||||
remotes::install_cran("covr")
|
shell: bash
|
||||||
|
|
||||||
|
- name: Show session info
|
||||||
|
run: |
|
||||||
|
options(width = 100)
|
||||||
|
utils::sessionInfo()
|
||||||
|
as.data.frame(utils::installed.packages())[, "Version", drop = FALSE]
|
||||||
shell: Rscript {0}
|
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
|
- 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}
|
shell: Rscript {0}
|
||||||
|
|||||||
17
DESCRIPTION
@@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.6.0
|
Version: 1.7.0
|
||||||
Date: 2021-03-14
|
Date: 2021-05-26
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(role = c("aut", "cre"),
|
person(role = c("aut", "cre"),
|
||||||
@@ -35,18 +35,19 @@ Authors@R: c(
|
|||||||
family = "Souverein", given = "Dennis", email = "d.souvereing@streeklabhaarlem.nl"),
|
family = "Souverein", given = "Dennis", email = "d.souvereing@streeklabhaarlem.nl"),
|
||||||
person(role = "ctb",
|
person(role = "ctb",
|
||||||
family = "Underwood", given = "Anthony", email = "au3@sanger.ac.uk"))
|
family = "Underwood", given = "Anthony", email = "au3@sanger.ac.uk"))
|
||||||
Description: Functions to simplify the analysis and prediction of Antimicrobial
|
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||||
Resistance (AMR) and to work with microbial and antimicrobial properties by
|
data analysis and to work with microbial and antimicrobial properties by
|
||||||
using evidence-based methods, like those defined by Leclercq et al. (2013)
|
using evidence-based methods and reliable reference data such as LPSN
|
||||||
<doi:10.1111/j.1469-0691.2011.03703.x> and containing reference data such as
|
<doi:10.1099/ijsem.0.004332>.
|
||||||
LPSN <doi:10.1099/ijsem.0.004332>.
|
|
||||||
Depends:
|
Depends:
|
||||||
R (>= 3.0.0)
|
R (>= 3.0.0)
|
||||||
Suggests:
|
Suggests:
|
||||||
cleaner,
|
cleaner,
|
||||||
|
covr,
|
||||||
curl,
|
curl,
|
||||||
dplyr,
|
dplyr,
|
||||||
ggplot2,
|
ggplot2,
|
||||||
|
ggtext,
|
||||||
knitr,
|
knitr,
|
||||||
microbenchmark,
|
microbenchmark,
|
||||||
pillar,
|
pillar,
|
||||||
@@ -55,8 +56,8 @@ Suggests:
|
|||||||
rstudioapi,
|
rstudioapi,
|
||||||
rvest,
|
rvest,
|
||||||
skimr,
|
skimr,
|
||||||
testthat,
|
|
||||||
tidyr,
|
tidyr,
|
||||||
|
tinytest,
|
||||||
xml2
|
xml2
|
||||||
VignetteBuilder: knitr,rmarkdown
|
VignetteBuilder: knitr,rmarkdown
|
||||||
URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR
|
URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR
|
||||||
|
|||||||
22
NAMESPACE
@@ -1,6 +1,7 @@
|
|||||||
# Generated by roxygen2: do not edit by hand
|
# Generated by roxygen2: do not edit by hand
|
||||||
|
|
||||||
S3method("!",mic)
|
S3method("!",mic)
|
||||||
|
S3method("!=",ab_selector)
|
||||||
S3method("!=",mic)
|
S3method("!=",mic)
|
||||||
S3method("%%",mic)
|
S3method("%%",mic)
|
||||||
S3method("%/%",mic)
|
S3method("%/%",mic)
|
||||||
@@ -11,6 +12,7 @@ S3method("-",mic)
|
|||||||
S3method("/",mic)
|
S3method("/",mic)
|
||||||
S3method("<",mic)
|
S3method("<",mic)
|
||||||
S3method("<=",mic)
|
S3method("<=",mic)
|
||||||
|
S3method("==",ab_selector)
|
||||||
S3method("==",mic)
|
S3method("==",mic)
|
||||||
S3method(">",mic)
|
S3method(">",mic)
|
||||||
S3method(">=",mic)
|
S3method(">=",mic)
|
||||||
@@ -37,12 +39,18 @@ S3method("|",mic)
|
|||||||
S3method(abs,mic)
|
S3method(abs,mic)
|
||||||
S3method(acos,mic)
|
S3method(acos,mic)
|
||||||
S3method(acosh,mic)
|
S3method(acosh,mic)
|
||||||
|
S3method(all,ab_selector)
|
||||||
|
S3method(all,ab_selector_any_all)
|
||||||
S3method(all,mic)
|
S3method(all,mic)
|
||||||
|
S3method(any,ab_selector)
|
||||||
|
S3method(any,ab_selector_any_all)
|
||||||
S3method(any,mic)
|
S3method(any,mic)
|
||||||
S3method(as.data.frame,ab)
|
S3method(as.data.frame,ab)
|
||||||
S3method(as.data.frame,mo)
|
S3method(as.data.frame,mo)
|
||||||
S3method(as.double,mic)
|
S3method(as.double,mic)
|
||||||
S3method(as.integer,mic)
|
S3method(as.integer,mic)
|
||||||
|
S3method(as.list,custom_eucast_rules)
|
||||||
|
S3method(as.list,custom_mdro_guideline)
|
||||||
S3method(as.matrix,mic)
|
S3method(as.matrix,mic)
|
||||||
S3method(as.numeric,mic)
|
S3method(as.numeric,mic)
|
||||||
S3method(as.rsi,data.frame)
|
S3method(as.rsi,data.frame)
|
||||||
@@ -57,6 +65,9 @@ S3method(barplot,disk)
|
|||||||
S3method(barplot,mic)
|
S3method(barplot,mic)
|
||||||
S3method(barplot,rsi)
|
S3method(barplot,rsi)
|
||||||
S3method(c,ab)
|
S3method(c,ab)
|
||||||
|
S3method(c,ab_selector)
|
||||||
|
S3method(c,custom_eucast_rules)
|
||||||
|
S3method(c,custom_mdro_guideline)
|
||||||
S3method(c,disk)
|
S3method(c,disk)
|
||||||
S3method(c,mic)
|
S3method(c,mic)
|
||||||
S3method(c,mo)
|
S3method(c,mo)
|
||||||
@@ -97,6 +108,7 @@ S3method(plot,rsi)
|
|||||||
S3method(print,ab)
|
S3method(print,ab)
|
||||||
S3method(print,bug_drug_combinations)
|
S3method(print,bug_drug_combinations)
|
||||||
S3method(print,catalogue_of_life_version)
|
S3method(print,catalogue_of_life_version)
|
||||||
|
S3method(print,custom_eucast_rules)
|
||||||
S3method(print,custom_mdro_guideline)
|
S3method(print,custom_mdro_guideline)
|
||||||
S3method(print,disk)
|
S3method(print,disk)
|
||||||
S3method(print,mic)
|
S3method(print,mic)
|
||||||
@@ -137,6 +149,8 @@ S3method(unique,mo)
|
|||||||
S3method(unique,rsi)
|
S3method(unique,rsi)
|
||||||
export("%like%")
|
export("%like%")
|
||||||
export("%like_case%")
|
export("%like_case%")
|
||||||
|
export("%unlike%")
|
||||||
|
export("%unlike_case%")
|
||||||
export(ab_atc)
|
export(ab_atc)
|
||||||
export(ab_atc_group1)
|
export(ab_atc_group1)
|
||||||
export(ab_atc_group2)
|
export(ab_atc_group2)
|
||||||
@@ -154,8 +168,10 @@ export(ab_tradenames)
|
|||||||
export(ab_url)
|
export(ab_url)
|
||||||
export(age)
|
export(age)
|
||||||
export(age_groups)
|
export(age_groups)
|
||||||
|
export(all_antimicrobials)
|
||||||
export(aminoglycosides)
|
export(aminoglycosides)
|
||||||
export(anti_join_microorganisms)
|
export(anti_join_microorganisms)
|
||||||
|
export(antimicrobials_equal)
|
||||||
export(as.ab)
|
export(as.ab)
|
||||||
export(as.disk)
|
export(as.disk)
|
||||||
export(as.mic)
|
export(as.mic)
|
||||||
@@ -165,6 +181,7 @@ export(atc_online_ddd)
|
|||||||
export(atc_online_groups)
|
export(atc_online_groups)
|
||||||
export(atc_online_property)
|
export(atc_online_property)
|
||||||
export(availability)
|
export(availability)
|
||||||
|
export(betalactams)
|
||||||
export(brmo)
|
export(brmo)
|
||||||
export(bug_drug_combinations)
|
export(bug_drug_combinations)
|
||||||
export(carbapenems)
|
export(carbapenems)
|
||||||
@@ -184,6 +201,7 @@ export(count_all)
|
|||||||
export(count_df)
|
export(count_df)
|
||||||
export(count_resistant)
|
export(count_resistant)
|
||||||
export(count_susceptible)
|
export(count_susceptible)
|
||||||
|
export(custom_eucast_rules)
|
||||||
export(custom_mdro_guideline)
|
export(custom_mdro_guideline)
|
||||||
export(eucast_dosage)
|
export(eucast_dosage)
|
||||||
export(eucast_exceptional_phenotypes)
|
export(eucast_exceptional_phenotypes)
|
||||||
@@ -196,6 +214,7 @@ export(filter_4th_cephalosporins)
|
|||||||
export(filter_5th_cephalosporins)
|
export(filter_5th_cephalosporins)
|
||||||
export(filter_ab_class)
|
export(filter_ab_class)
|
||||||
export(filter_aminoglycosides)
|
export(filter_aminoglycosides)
|
||||||
|
export(filter_betalactams)
|
||||||
export(filter_carbapenems)
|
export(filter_carbapenems)
|
||||||
export(filter_cephalosporins)
|
export(filter_cephalosporins)
|
||||||
export(filter_first_isolate)
|
export(filter_first_isolate)
|
||||||
@@ -227,8 +246,11 @@ export(is.mo)
|
|||||||
export(is.rsi)
|
export(is.rsi)
|
||||||
export(is.rsi.eligible)
|
export(is.rsi.eligible)
|
||||||
export(is_new_episode)
|
export(is_new_episode)
|
||||||
|
export(italicise_taxonomy)
|
||||||
|
export(italicize_taxonomy)
|
||||||
export(key_antibiotics)
|
export(key_antibiotics)
|
||||||
export(key_antibiotics_equal)
|
export(key_antibiotics_equal)
|
||||||
|
export(key_antimicrobials)
|
||||||
export(kurtosis)
|
export(kurtosis)
|
||||||
export(labels_rsi_count)
|
export(labels_rsi_count)
|
||||||
export(left_join_microorganisms)
|
export(left_join_microorganisms)
|
||||||
|
|||||||
115
NEWS.md
@@ -1,6 +1,77 @@
|
|||||||
# AMR 1.6.0
|
# `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 `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()`):
|
||||||
|
* Custom MDRO guidelines can now be combined with other custom MDRO guidelines using `c()`
|
||||||
|
* Fix for applying the rules; in previous versions, rows were interpreted according to the last matched rule. Now, rows are interpreted according to the first matched rule
|
||||||
|
* Fix for `age_groups()` for persons aged zero
|
||||||
|
* The `example_isolates` data set now contains some (fictitious) zero-year old patients
|
||||||
|
* Fix for minor translation errors
|
||||||
|
* Printing of microbial codes in a `data.frame` or `tibble` now gives a warning if the data contains old microbial codes (from a previous AMR package version)
|
||||||
|
* Extended the `like()` functions:
|
||||||
|
* Now checks if `pattern` is a *valid* regular expression
|
||||||
|
* Added `%unlike%` and `%unlike_case%` (as negations of the existing `%like%` and `%like_case%`). This greatly improves readability:
|
||||||
|
```r
|
||||||
|
if (!grepl("EUCAST", guideline)) ...
|
||||||
|
# same:
|
||||||
|
if (guideline %unlike% "EUCAST") ...
|
||||||
|
```
|
||||||
|
* 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 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
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the `eucast_rules()` function and in `as.rsi()` to interpret MIC and disk diffusion values. This is now the default guideline in this package.
|
* Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the `eucast_rules()` function and in `as.rsi()` to interpret MIC and disk diffusion values. This is now the default guideline in this package.
|
||||||
* Added function `eucast_dosage()` to get a `data.frame` with advised dosages of a certain bug-drug combination, which is based on the new `dosage` data set
|
* Added function `eucast_dosage()` to get a `data.frame` with advised dosages of a certain bug-drug combination, which is based on the new `dosage` data set
|
||||||
@@ -59,7 +130,7 @@
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Updated the bacterial taxonomy to 3 March 2021 (using [LSPN](https://lpsn.dsmz.de))
|
* Updated the bacterial taxonomy to 3 March 2021 (using [LPSN](https://lpsn.dsmz.de))
|
||||||
* Added 3,372 new species and 1,523 existing species became synomyms
|
* Added 3,372 new species and 1,523 existing species became synomyms
|
||||||
* The URL of a bacterial species (`mo_url()`) will now lead to https://lpsn.dsmz.de
|
* The URL of a bacterial species (`mo_url()`) will now lead to https://lpsn.dsmz.de
|
||||||
* Big update for plotting classes `rsi`, `<mic>`, and `<disk>`:
|
* Big update for plotting classes `rsi`, `<mic>`, and `<disk>`:
|
||||||
@@ -93,7 +164,7 @@
|
|||||||
* Loading the package (i.e., `library(AMR)`) now is ~50 times faster than before, in costs of package size (which increased by ~3 MB)
|
* Loading the package (i.e., `library(AMR)`) now is ~50 times faster than before, in costs of package size (which increased by ~3 MB)
|
||||||
|
|
||||||
|
|
||||||
# AMR 1.5.0
|
# `AMR` 1.5.0
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Functions `get_episode()` and `is_new_episode()` to determine (patient) episodes which are not necessarily based on microorganisms. The `get_episode()` function returns the index number of the episode per group, while the `is_new_episode()` function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode. They also support `dplyr`s grouping (i.e. using `group_by()`):
|
* Functions `get_episode()` and `is_new_episode()` to determine (patient) episodes which are not necessarily based on microorganisms. The `get_episode()` function returns the index number of the episode per group, while the `is_new_episode()` function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode. They also support `dplyr`s grouping (i.e. using `group_by()`):
|
||||||
@@ -170,7 +241,7 @@
|
|||||||
* Added CodeFactor as a continuous code review to this package: <https://www.codefactor.io/repository/github/msberends/amr/>
|
* Added CodeFactor as a continuous code review to this package: <https://www.codefactor.io/repository/github/msberends/amr/>
|
||||||
* Added Dr. Rogier Schade as contributor
|
* Added Dr. Rogier Schade as contributor
|
||||||
|
|
||||||
# AMR 1.4.0
|
# `AMR` 1.4.0
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Support for 'EUCAST Expert Rules' / 'EUCAST Intrinsic Resistance and Unusual Phenotypes' version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the `eucast_rules()` function can now correct for more than 180 different antibiotics and the `mdro()` function can determine multidrug resistance based on more than 150 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The `eucast_rules()` function consequently gained the arguments `version_breakpoints` (at the moment defaults to v10.0, 2020) and `version_expertrules` (at the moment defaults to v3.2, 2020). The `example_isolates` data set now also reflects the change from v3.1 to v3.2. The `mdro()` function now accepts `guideline == "EUCAST3.1"` and `guideline == "EUCAST3.2"`.
|
* Support for 'EUCAST Expert Rules' / 'EUCAST Intrinsic Resistance and Unusual Phenotypes' version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the `eucast_rules()` function can now correct for more than 180 different antibiotics and the `mdro()` function can determine multidrug resistance based on more than 150 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The `eucast_rules()` function consequently gained the arguments `version_breakpoints` (at the moment defaults to v10.0, 2020) and `version_expertrules` (at the moment defaults to v3.2, 2020). The `example_isolates` data set now also reflects the change from v3.1 to v3.2. The `mdro()` function now accepts `guideline == "EUCAST3.1"` and `guideline == "EUCAST3.2"`.
|
||||||
@@ -242,7 +313,7 @@
|
|||||||
* Removed unnecessary references to the `base` package
|
* Removed unnecessary references to the `base` package
|
||||||
* Added packages that could be useful for some functions to the `Suggests` field of the `DESCRIPTION` file
|
* Added packages that could be useful for some functions to the `Suggests` field of the `DESCRIPTION` file
|
||||||
|
|
||||||
# AMR 1.3.0
|
# `AMR` 1.3.0
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally
|
* Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally
|
||||||
@@ -295,7 +366,7 @@
|
|||||||
### Other
|
### Other
|
||||||
* Moved primary location of this project from GitLab to [GitHub](https://github.com/msberends/AMR), giving us native support for automated syntax checking without being dependent on external services such as AppVeyor and Travis CI.
|
* Moved primary location of this project from GitLab to [GitHub](https://github.com/msberends/AMR), giving us native support for automated syntax checking without being dependent on external services such as AppVeyor and Travis CI.
|
||||||
|
|
||||||
# AMR 1.2.0
|
# `AMR` 1.2.0
|
||||||
|
|
||||||
### Breaking
|
### Breaking
|
||||||
* Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users.
|
* Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users.
|
||||||
@@ -333,7 +404,7 @@
|
|||||||
* Removed previously deprecated function `p.symbol()` - it was replaced with `p_symbol()`
|
* Removed previously deprecated function `p.symbol()` - it was replaced with `p_symbol()`
|
||||||
* Removed function `read.4d()`, that was only useful for reading data from an old test database.
|
* Removed function `read.4d()`, that was only useful for reading data from an old test database.
|
||||||
|
|
||||||
# AMR 1.1.0
|
# `AMR` 1.1.0
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Support for easy principal component analysis for AMR, using the new `pca()` function
|
* Support for easy principal component analysis for AMR, using the new `pca()` function
|
||||||
@@ -355,7 +426,7 @@
|
|||||||
* Support for the upcoming `dplyr` version 1.0.0
|
* Support for the upcoming `dplyr` version 1.0.0
|
||||||
* More robust assigning for classes `rsi` and `mic`
|
* More robust assigning for classes `rsi` and `mic`
|
||||||
|
|
||||||
# AMR 1.0.1
|
# `AMR` 1.0.1
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline
|
* Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline
|
||||||
@@ -371,7 +442,7 @@
|
|||||||
* Added `uti` (as abbreviation of urinary tract infections) as argument to `as.rsi()`, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs
|
* Added `uti` (as abbreviation of urinary tract infections) as argument to `as.rsi()`, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs
|
||||||
* Info printing in functions `eucast_rules()`, `first_isolate()`, `mdro()` and `resistance_predict()` will now at default only print when R is in an interactive mode (i.e. not in RMarkdown)
|
* Info printing in functions `eucast_rules()`, `first_isolate()`, `mdro()` and `resistance_predict()` will now at default only print when R is in an interactive mode (i.e. not in RMarkdown)
|
||||||
|
|
||||||
# AMR 1.0.0
|
# `AMR` 1.0.0
|
||||||
|
|
||||||
This software is now out of beta and considered stable. Nonetheless, this package will be developed continually.
|
This software is now out of beta and considered stable. Nonetheless, this package will be developed continually.
|
||||||
|
|
||||||
@@ -419,7 +490,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
|||||||
* Full support for the upcoming R 4.0
|
* Full support for the upcoming R 4.0
|
||||||
* Removed unnecessary `AMR::` calls
|
* Removed unnecessary `AMR::` calls
|
||||||
|
|
||||||
# AMR 0.9.0
|
# `AMR` 0.9.0
|
||||||
|
|
||||||
### Breaking
|
### Breaking
|
||||||
* Adopted Adeolu *et al.* (2016), [PMID 27620848](https:/pubmed.ncbi.nlm.nih.gov/27620848/) for the `microorganisms` data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like *Morganellaceae* and *Yersiniaceae*). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with `mdro()` will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
|
* Adopted Adeolu *et al.* (2016), [PMID 27620848](https:/pubmed.ncbi.nlm.nih.gov/27620848/) for the `microorganisms` data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like *Morganellaceae* and *Yersiniaceae*). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with `mdro()` will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
|
||||||
@@ -485,7 +556,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
|||||||
* Change dependency on `clean` to `cleaner`, as this package was renamed accordingly upon CRAN request
|
* Change dependency on `clean` to `cleaner`, as this package was renamed accordingly upon CRAN request
|
||||||
* Added Dr. Sofia Ny as contributor
|
* Added Dr. Sofia Ny as contributor
|
||||||
|
|
||||||
# AMR 0.8.0
|
# `AMR` 0.8.0
|
||||||
|
|
||||||
### Breaking
|
### Breaking
|
||||||
* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new argument `include_unknown`:
|
* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new argument `include_unknown`:
|
||||||
@@ -614,7 +685,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
|||||||
* Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors
|
* Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors
|
||||||
* Cleaned the coding style of every single syntax line in this package with the help of the `lintr` package
|
* Cleaned the coding style of every single syntax line in this package with the help of the `lintr` package
|
||||||
|
|
||||||
# AMR 0.7.1
|
# `AMR` 0.7.1
|
||||||
|
|
||||||
#### New
|
#### New
|
||||||
* Function `rsi_df()` to transform a `data.frame` to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions `count_df()` and `portion_df()` to immediately show resistance percentages and number of available isolates:
|
* Function `rsi_df()` to transform a `data.frame` to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions `count_df()` and `portion_df()` to immediately show resistance percentages and number of available isolates:
|
||||||
@@ -675,7 +746,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
|||||||
#### Other
|
#### Other
|
||||||
* Fixed a note thrown by CRAN tests
|
* Fixed a note thrown by CRAN tests
|
||||||
|
|
||||||
# AMR 0.7.0
|
# `AMR` 0.7.0
|
||||||
|
|
||||||
#### New
|
#### New
|
||||||
* Support for translation of disk diffusion and MIC values to RSI values (i.e. antimicrobial interpretations). Supported guidelines are EUCAST (2011 to 2019) and CLSI (2011 to 2019). Use `as.rsi()` on an MIC value (created with `as.mic()`), a disk diffusion value (created with the new `as.disk()`) or on a complete date set containing columns with MIC or disk diffusion values.
|
* Support for translation of disk diffusion and MIC values to RSI values (i.e. antimicrobial interpretations). Supported guidelines are EUCAST (2011 to 2019) and CLSI (2011 to 2019). Use `as.rsi()` on an MIC value (created with `as.mic()`), a disk diffusion value (created with the new `as.disk()`) or on a complete date set containing columns with MIC or disk diffusion values.
|
||||||
@@ -733,13 +804,13 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
|||||||
#### Other
|
#### Other
|
||||||
* Support for R 3.6.0 and later by providing support for [staged install](https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html)
|
* Support for R 3.6.0 and later by providing support for [staged install](https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html)
|
||||||
|
|
||||||
# AMR 0.6.1
|
# `AMR` 0.6.1
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
* Fixed a critical bug when using `eucast_rules()` with `verbose = TRUE`
|
* Fixed a critical bug when using `eucast_rules()` with `verbose = TRUE`
|
||||||
* Coercion of microbial IDs are now written to the package namespace instead of the user's home folder, to comply with the CRAN policy
|
* Coercion of microbial IDs are now written to the package namespace instead of the user's home folder, to comply with the CRAN policy
|
||||||
|
|
||||||
# AMR 0.6.0
|
# `AMR` 0.6.0
|
||||||
|
|
||||||
**New website!**
|
**New website!**
|
||||||
|
|
||||||
@@ -835,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))
|
* 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.
|
* 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
|
* 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
|
* 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.
|
* 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
|
* Function `guess_mo()` is now deprecated in favour of `as.mo()` and will be removed in future versions
|
||||||
@@ -932,7 +1003,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
|||||||
#### Other
|
#### Other
|
||||||
* Updated licence text to emphasise GPL 2.0 and that this is an R package.
|
* Updated licence text to emphasise GPL 2.0 and that this is an R package.
|
||||||
|
|
||||||
# AMR 0.5.0
|
# `AMR` 0.5.0
|
||||||
|
|
||||||
#### New
|
#### New
|
||||||
* Repository moved to GitLab
|
* Repository moved to GitLab
|
||||||
@@ -1015,7 +1086,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
|||||||
* Updated vignettes to comply with README
|
* Updated vignettes to comply with README
|
||||||
|
|
||||||
|
|
||||||
# AMR 0.4.0
|
# `AMR` 0.4.0
|
||||||
|
|
||||||
#### New
|
#### New
|
||||||
* The data set `microorganisms` now contains **all microbial taxonomic data from ITIS** (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via https://itis.gov. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set `microorganisms.old` contains all previously known taxonomic names from those kingdoms.
|
* The data set `microorganisms` now contains **all microbial taxonomic data from ITIS** (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via https://itis.gov. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set `microorganisms.old` contains all previously known taxonomic names from those kingdoms.
|
||||||
@@ -1126,7 +1197,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
|||||||
#### Other
|
#### Other
|
||||||
* More unit tests to ensure better integrity of functions
|
* More unit tests to ensure better integrity of functions
|
||||||
|
|
||||||
# AMR 0.3.0
|
# `AMR` 0.3.0
|
||||||
|
|
||||||
#### New
|
#### New
|
||||||
* **BREAKING**: `rsi_df` was removed in favour of new functions `portion_R`, `portion_IR`, `portion_I`, `portion_SI` and `portion_S` to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old `rsi` function. The old function still works, but is deprecated.
|
* **BREAKING**: `rsi_df` was removed in favour of new functions `portion_R`, `portion_IR`, `portion_I`, `portion_SI` and `portion_S` to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old `rsi` function. The old function still works, but is deprecated.
|
||||||
@@ -1196,7 +1267,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
|||||||
* Windows: https://ci.appveyor.com/project/msberends/amr
|
* Windows: https://ci.appveyor.com/project/msberends/amr
|
||||||
* Added thesis advisors to DESCRIPTION file
|
* Added thesis advisors to DESCRIPTION file
|
||||||
|
|
||||||
# AMR 0.2.0
|
# `AMR` 0.2.0
|
||||||
|
|
||||||
#### New
|
#### New
|
||||||
* Full support for Windows, Linux and macOS
|
* Full support for Windows, Linux and macOS
|
||||||
@@ -1231,7 +1302,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
|||||||
* Added build tests for Linux and macOS using Travis CI (https://travis-ci.org/msberends/AMR)
|
* Added build tests for Linux and macOS using Travis CI (https://travis-ci.org/msberends/AMR)
|
||||||
* Added line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R)
|
* Added line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R)
|
||||||
|
|
||||||
# AMR 0.1.1
|
# `AMR` 0.1.1
|
||||||
|
|
||||||
* `EUCAST_rules` applies for amoxicillin even if ampicillin is missing
|
* `EUCAST_rules` applies for amoxicillin even if ampicillin is missing
|
||||||
* Edited column names to comply with GLIMS, the laboratory information system
|
* Edited column names to comply with GLIMS, the laboratory information system
|
||||||
@@ -1239,6 +1310,6 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
|||||||
* Renamed 'Daily Defined Dose' to 'Defined Daily Dose'
|
* Renamed 'Daily Defined Dose' to 'Defined Daily Dose'
|
||||||
* Added barplots for `rsi` and `mic` classes
|
* Added barplots for `rsi` and `mic` classes
|
||||||
|
|
||||||
# AMR 0.1.0
|
# `AMR` 0.1.0
|
||||||
|
|
||||||
* First submission to CRAN.
|
* First submission to CRAN.
|
||||||
|
|||||||
@@ -71,7 +71,49 @@ addin_insert_in <- function() {
|
|||||||
|
|
||||||
# No export, no Rd
|
# No export, no Rd
|
||||||
addin_insert_like <- function() {
|
addin_insert_like <- function() {
|
||||||
import_fn("insertText", "rstudioapi")(" %like% ")
|
# we want Shift + Ctrl/Cmd + L to iterate over %like%, %unlike%, %like_case%, and %unlike_case%
|
||||||
|
|
||||||
|
getActiveDocumentContext <- import_fn("getActiveDocumentContext", "rstudioapi")
|
||||||
|
insertText <- import_fn("insertText", "rstudioapi")
|
||||||
|
modifyRange <- import_fn("modifyRange", "rstudioapi")
|
||||||
|
document_range <- import_fn("document_range", "rstudioapi")
|
||||||
|
document_position <- import_fn("document_position", "rstudioapi")
|
||||||
|
|
||||||
|
context <- getActiveDocumentContext()
|
||||||
|
current_row <- context$selection[[1]]$range$end[1]
|
||||||
|
current_col <- context$selection[[1]]$range$end[2]
|
||||||
|
current_row_txt <- context$contents[current_row]
|
||||||
|
if (is.null(current_row) || current_row_txt %unlike% "%(un)?like") {
|
||||||
|
insertText(" %like% ")
|
||||||
|
return(invisible())
|
||||||
|
}
|
||||||
|
|
||||||
|
pos_preceded_by <- function(txt) {
|
||||||
|
if (tryCatch(substr(current_row_txt, current_col - nchar(trimws(txt, which = "right")), current_col) == trimws(txt, which = "right"),
|
||||||
|
error = function(e) FALSE)) {
|
||||||
|
return(TRUE)
|
||||||
|
}
|
||||||
|
tryCatch(substr(current_row_txt, current_col - nchar(txt), current_col) %like% paste0("^", txt),
|
||||||
|
error = function(e) FALSE)
|
||||||
|
}
|
||||||
|
replace_pos <- function(old, with) {
|
||||||
|
modifyRange(document_range(document_position(current_row, current_col - nchar(old)),
|
||||||
|
document_position(current_row, current_col)),
|
||||||
|
text = with,
|
||||||
|
id = context$id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos_preceded_by(" %like% ")) {
|
||||||
|
replace_pos(" %like% ", with = " %unlike% ")
|
||||||
|
} else if (pos_preceded_by(" %unlike% ")) {
|
||||||
|
replace_pos(" %unlike% ", with = " %like_case% ")
|
||||||
|
} else if (pos_preceded_by(" %like_case% ")) {
|
||||||
|
replace_pos(" %like_case% ", with = " %unlike_case% ")
|
||||||
|
} else if (pos_preceded_by(" %unlike_case% ")) {
|
||||||
|
replace_pos(" %unlike_case% ", with = " %like% ")
|
||||||
|
} else {
|
||||||
|
insertText(" %like% ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_dataset_integrity <- function() {
|
check_dataset_integrity <- function() {
|
||||||
@@ -87,11 +129,14 @@ check_dataset_integrity <- function() {
|
|||||||
} else {
|
} else {
|
||||||
plural <- c(" is", "s", "")
|
plural <- c(" is", "s", "")
|
||||||
}
|
}
|
||||||
|
if (message_not_thrown_before("dataset_overwritten")) {
|
||||||
warning_("The following data set", plural[1],
|
warning_("The following data set", plural[1],
|
||||||
" overwritten by your global environment and prevent", plural[2],
|
" overwritten by your global environment and prevent", plural[2],
|
||||||
" the AMR package from working correctly: ",
|
" the AMR package from working correctly: ",
|
||||||
vector_and(overwritten, quotes = "'"),
|
vector_and(overwritten, quotes = "'"),
|
||||||
".\nPlease rename your object", plural[3], ".", call = FALSE)
|
".\nPlease rename your object", plural[3], ".", call = FALSE)
|
||||||
|
remember_thrown_message("dataset_overwritten")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# check if other packages did not overwrite our data sets
|
# check if other packages did not overwrite our data sets
|
||||||
valid_microorganisms <- TRUE
|
valid_microorganisms <- TRUE
|
||||||
@@ -147,9 +192,9 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
# -- key antibiotics
|
# -- key antibiotics
|
||||||
if (type == "keyantibiotics") {
|
if (type %in% c("keyantibiotics", "keyantimicrobials")) {
|
||||||
if (any(colnames(x) %like% "^key.*(ab|antibiotics)")) {
|
if (any(colnames(x) %like% "^key.*(ab|antibiotics|antimicrobials)")) {
|
||||||
found <- sort(colnames(x)[colnames(x) %like% "^key.*(ab|antibiotics)"])[1]
|
found <- sort(colnames(x)[colnames(x) %like% "^key.*(ab|antibiotics|antimicrobials)"])[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# -- date
|
# -- date
|
||||||
@@ -211,10 +256,21 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
|||||||
found
|
found
|
||||||
}
|
}
|
||||||
|
|
||||||
is_possibly_regex <- function(x) {
|
is_valid_regex <- function(x) {
|
||||||
tryCatch(vapply(FUN.VALUE = character(1), strsplit(x, ""),
|
regex_at_all <- tryCatch(vapply(FUN.VALUE = logical(1),
|
||||||
function(y) any(y %in% c("$", "(", ")", "*", "+", "-", ".", "?", "[", "]", "^", "{", "|", "}", "\\"), na.rm = TRUE)),
|
X = strsplit(x, ""),
|
||||||
|
FUN = function(y) any(y %in% c("$", "(", ")", "*", "+", "-",
|
||||||
|
".", "?", "[", "]", "^", "{",
|
||||||
|
"|", "}", "\\"),
|
||||||
|
na.rm = TRUE),
|
||||||
|
USE.NAMES = FALSE),
|
||||||
error = function(e) rep(TRUE, length(x)))
|
error = function(e) rep(TRUE, length(x)))
|
||||||
|
regex_valid <- vapply(FUN.VALUE = logical(1),
|
||||||
|
X = x,
|
||||||
|
FUN = function(y) !"try-error" %in% class(try(grepl(y, "", perl = TRUE),
|
||||||
|
silent = TRUE)),
|
||||||
|
USE.NAMES = FALSE)
|
||||||
|
regex_at_all & regex_valid
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_ifnot_installed <- function(package) {
|
stop_ifnot_installed <- function(package) {
|
||||||
@@ -223,8 +279,8 @@ stop_ifnot_installed <- function(package) {
|
|||||||
vapply(FUN.VALUE = character(1), package, function(pkg)
|
vapply(FUN.VALUE = character(1), package, function(pkg)
|
||||||
tryCatch(get(".packageName", envir = asNamespace(pkg)),
|
tryCatch(get(".packageName", envir = asNamespace(pkg)),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
if (package == "rstudioapi") {
|
if (pkg == "rstudioapi") {
|
||||||
stop("This function only works in RStudio.", call. = FALSE)
|
stop("This function only works in RStudio when using R >= 3.2.", call. = FALSE)
|
||||||
} else if (pkg != "base") {
|
} else if (pkg != "base") {
|
||||||
stop("This requires the '", pkg, "' package.",
|
stop("This requires the '", pkg, "' package.",
|
||||||
"\nTry to install it with: install.packages(\"", pkg, "\")",
|
"\nTry to install it with: install.packages(\"", pkg, "\")",
|
||||||
@@ -234,6 +290,15 @@ stop_ifnot_installed <- function(package) {
|
|||||||
return(invisible())
|
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) {
|
import_fn <- function(name, pkg, error_on_fail = TRUE) {
|
||||||
if (isTRUE(error_on_fail)) {
|
if (isTRUE(error_on_fail)) {
|
||||||
stop_ifnot_installed(pkg)
|
stop_ifnot_installed(pkg)
|
||||||
@@ -265,7 +330,7 @@ word_wrap <- function(...,
|
|||||||
msg <- paste0(c(...), collapse = "")
|
msg <- paste0(c(...), collapse = "")
|
||||||
|
|
||||||
if (isTRUE(as_note)) {
|
if (isTRUE(as_note)) {
|
||||||
msg <- paste0("NOTE: ", gsub("^note:? ?", "", msg, ignore.case = TRUE))
|
msg <- paste0(pkg_env$info_icon, " ", gsub("^note:? ?", "", msg, ignore.case = TRUE))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg %like% "\n") {
|
if (msg %like% "\n") {
|
||||||
@@ -280,6 +345,9 @@ word_wrap <- function(...,
|
|||||||
collapse = "\n"))
|
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\"
|
# we need to correct for already applied style, that adds text like "\033[31m\"
|
||||||
msg_stripped <- font_stripstyle(msg)
|
msg_stripped <- font_stripstyle(msg)
|
||||||
# where are the spaces now?
|
# where are the spaces now?
|
||||||
@@ -296,11 +364,13 @@ word_wrap <- function(...,
|
|||||||
# put it together
|
# put it together
|
||||||
msg <- unlist(strsplit(msg, " "))
|
msg <- unlist(strsplit(msg, " "))
|
||||||
msg[replace_spaces] <- paste0(msg[replace_spaces], "\n")
|
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 <- paste0(msg, collapse = " ")
|
||||||
msg <- gsub("\n ", "\n", msg, fixed = TRUE)
|
msg <- gsub("\n ", "\n", msg, fixed = TRUE)
|
||||||
|
|
||||||
if (msg_stripped %like% "^NOTE: ") {
|
if (msg_stripped %like% "\u2139 ") {
|
||||||
indentation <- 6 + extra_indent
|
indentation <- 2 + extra_indent
|
||||||
} else if (msg_stripped %like% "^=> ") {
|
} else if (msg_stripped %like% "^=> ") {
|
||||||
indentation <- 3 + extra_indent
|
indentation <- 3 + extra_indent
|
||||||
} else {
|
} else {
|
||||||
@@ -403,7 +473,7 @@ stop_ifnot <- function(expr, ..., call = TRUE) {
|
|||||||
ifelse(!is.na(y), y, NA))
|
ifelse(!is.na(y), y, NA))
|
||||||
}
|
}
|
||||||
|
|
||||||
class_integrity_check <- function(value, type, check_vector) {
|
return_after_integrity_check <- function(value, type, check_vector) {
|
||||||
if (!all(value[!is.na(value)] %in% check_vector)) {
|
if (!all(value[!is.na(value)] %in% check_vector)) {
|
||||||
warning_(paste0("invalid ", type, ", NA generated"), call = FALSE)
|
warning_(paste0("invalid ", type, ", NA generated"), call = FALSE)
|
||||||
value[!value %in% check_vector] <- NA
|
value[!value %in% check_vector] <- NA
|
||||||
@@ -437,14 +507,30 @@ dataset_UTF8_to_ASCII <- function(df) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# for eucast_rules() and mdro(), creates markdown output with URLs and names
|
# 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_names <- ab_name(ab, language = NULL, tolower = TRUE)
|
||||||
ab <- ab[order(ab_names)]
|
ab <- ab[order(ab_names)]
|
||||||
ab_names <- ab_names[order(ab_names)]
|
ab_names <- ab_names[order(ab_names)]
|
||||||
atcs <- ab_atc(ab)
|
atc_txt <- paste0("[", atcs[!is.na(atcs)], "](", ab_url(ab), ")")
|
||||||
atcs[!is.na(atcs)] <- paste0("[", atcs[!is.na(atcs)], "](", ab_url(ab[!is.na(atcs)]), ")")
|
out <- paste0(ab_names, " (`", ab, "`, ", atc_txt, ")", collapse = ", ")
|
||||||
atcs[is.na(atcs)] <- "no ATC code"
|
|
||||||
out <- paste0(ab_names, " (`", ab, "`, ", atcs, ")", collapse = ", ")
|
|
||||||
substr(out, 1, 1) <- toupper(substr(out, 1, 1))
|
substr(out, 1, 1) <- toupper(substr(out, 1, 1))
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
@@ -481,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 ")
|
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.bak <- class
|
||||||
class[class == "numeric"] <- "number"
|
class[class == "numeric"] <- "number"
|
||||||
class[class == "integer"] <- "whole number"
|
class[class == "integer"] <- "whole number"
|
||||||
@@ -495,17 +581,15 @@ format_class <- function(class, plural) {
|
|||||||
ifelse(plural, "s", ""))
|
ifelse(plural, "s", ""))
|
||||||
# exceptions
|
# exceptions
|
||||||
class[class == "logical"] <- ifelse(plural, "a vector of `TRUE`/`FALSE`", "`TRUE` or `FALSE`")
|
class[class == "logical"] <- ifelse(plural, "a vector of `TRUE`/`FALSE`", "`TRUE` or `FALSE`")
|
||||||
if ("data.frame" %in% class) {
|
class[class == "data.frame"] <- "a data set"
|
||||||
class <- "a data set"
|
|
||||||
}
|
|
||||||
if ("list" %in% class) {
|
if ("list" %in% class) {
|
||||||
class <- "a list"
|
class <- "a list"
|
||||||
}
|
}
|
||||||
if ("matrix" %in% class) {
|
if ("matrix" %in% class) {
|
||||||
class <- "a matrix"
|
class <- "a matrix"
|
||||||
}
|
}
|
||||||
if ("isolate_identifier" %in% class) {
|
if ("custom_eucast_rules" %in% class) {
|
||||||
class <- "created with isolate_identifier()"
|
class <- "input created with `custom_eucast_rules()`"
|
||||||
}
|
}
|
||||||
if (any(c("mo", "ab", "rsi") %in% class)) {
|
if (any(c("mo", "ab", "rsi") %in% class)) {
|
||||||
class <- paste0("of class <", class[1L], ">")
|
class <- paste0("of class <", class[1L], ">")
|
||||||
@@ -522,6 +606,7 @@ meet_criteria <- function(object,
|
|||||||
looks_like = NULL,
|
looks_like = NULL,
|
||||||
is_in = NULL,
|
is_in = NULL,
|
||||||
is_positive = NULL,
|
is_positive = NULL,
|
||||||
|
is_positive_or_zero = NULL,
|
||||||
is_finite = NULL,
|
is_finite = NULL,
|
||||||
contains_column_class = NULL,
|
contains_column_class = NULL,
|
||||||
allow_NULL = FALSE,
|
allow_NULL = FALSE,
|
||||||
@@ -583,23 +668,31 @@ meet_criteria <- function(object,
|
|||||||
object <- tolower(object)
|
object <- tolower(object)
|
||||||
is_in <- tolower(is_in)
|
is_in <- tolower(is_in)
|
||||||
}
|
}
|
||||||
stop_ifnot(all(object %in% is_in, na.rm = TRUE), "argument `", obj_name,
|
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,
|
||||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1, "either ", ""),
|
"must be either ",
|
||||||
|
"must only contain values "),
|
||||||
vector_or(is_in, quotes = !isTRUE(any(c("double", "numeric", "integer") %in% allow_class))),
|
vector_or(is_in, quotes = !isTRUE(any(c("double", "numeric", "integer") %in% allow_class))),
|
||||||
ifelse(allow_NA == TRUE, ", or NA", ""),
|
ifelse(allow_NA == TRUE, ", or NA", ""),
|
||||||
call = call_depth)
|
call = call_depth)
|
||||||
}
|
}
|
||||||
if (!is.null(is_positive)) {
|
if (isTRUE(is_positive)) {
|
||||||
stop_if(is.numeric(object) && !all(object > 0, na.rm = TRUE), "argument `", obj_name,
|
stop_if(is.numeric(object) && !all(object > 0, na.rm = TRUE), "argument `", obj_name,
|
||||||
"` must ",
|
"` must ",
|
||||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||||
"be a positive number",
|
"be a number higher than zero",
|
||||||
"all be positive numbers"),
|
"all be numbers higher than zero"),
|
||||||
" (higher than zero)",
|
|
||||||
call = call_depth)
|
call = call_depth)
|
||||||
}
|
}
|
||||||
if (!is.null(is_finite)) {
|
if (isTRUE(is_positive_or_zero)) {
|
||||||
|
stop_if(is.numeric(object) && !all(object >= 0, na.rm = TRUE), "argument `", obj_name,
|
||||||
|
"` must ",
|
||||||
|
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||||
|
"be zero or a positive number",
|
||||||
|
"all be zero or numbers higher than zero"),
|
||||||
|
call = call_depth)
|
||||||
|
}
|
||||||
|
if (isTRUE(is_finite)) {
|
||||||
stop_if(is.numeric(object) && !all(is.finite(object[!is.na(object)]), na.rm = TRUE), "argument `", obj_name,
|
stop_if(is.numeric(object) && !all(is.finite(object[!is.na(object)]), na.rm = TRUE), "argument `", obj_name,
|
||||||
"` must ",
|
"` must ",
|
||||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||||
@@ -623,6 +716,11 @@ meet_criteria <- function(object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_current_data <- function(arg_name, call) {
|
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
|
# try dplyr::cur_data_all() first to support dplyr groups
|
||||||
# only useful for e.g. dplyr::filter(), dplyr::mutate() and dplyr::summarise()
|
# 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
|
# not useful (throws error) with e.g. dplyr::select() - but that will be caught later in this function
|
||||||
@@ -630,32 +728,43 @@ get_current_data <- function(arg_name, call) {
|
|||||||
if (!is.null(cur_data_all)) {
|
if (!is.null(cur_data_all)) {
|
||||||
out <- tryCatch(cur_data_all(), error = function(e) NULL)
|
out <- tryCatch(cur_data_all(), error = function(e) NULL)
|
||||||
if (is.data.frame(out)) {
|
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)
|
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
|
# 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)) {
|
if (is.na(arg_name)) {
|
||||||
# like in carbapenems() etc.
|
# like in carbapenems() etc.
|
||||||
warning_("this function can only be used in R >= 3.2", call = call)
|
warning_("this function can only be used in R >= 3.2", call = call)
|
||||||
return(data.frame())
|
return(data.frame())
|
||||||
} else {
|
} else {
|
||||||
|
# mimic a default R error, e.g. for example_isolates[which(mo_name() %like% "^ent"), ]
|
||||||
stop_("argument `", arg_name, "` is missing with no default", call = call)
|
stop_("argument `", arg_name, "` is missing with no default", call = call)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# try a (base R) method, by going over the complete system call stack with sys.frames()
|
# try a (base R) method, by going over the complete system call stack with sys.frames()
|
||||||
not_set <- TRUE
|
not_set <- TRUE
|
||||||
|
source <- "base_R"
|
||||||
frms <- lapply(sys.frames(), function(el) {
|
frms <- lapply(sys.frames(), function(el) {
|
||||||
if (not_set == TRUE && ".Generic" %in% names(el)) {
|
if (not_set == TRUE && ".Generic" %in% names(el)) {
|
||||||
if (tryCatch(".data" %in% names(el) && is.data.frame(el$`.data`), error = function(e) FALSE)) {
|
if (tryCatch(".data" %in% names(el) && is.data.frame(el$`.data`), error = function(e) FALSE)) {
|
||||||
# dplyr? - an element `.data` will be in the system call stack
|
# - - - -
|
||||||
# will be used in dplyr::select() (but not in dplyr::filter(), dplyr::mutate() or dplyr::summarise())
|
# dplyr
|
||||||
|
# - - - -
|
||||||
|
# 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
|
not_set <<- FALSE
|
||||||
|
source <<- "dplyr_selector"
|
||||||
el$`.data`
|
el$`.data`
|
||||||
} else if (tryCatch(any(c("x", "xx") %in% names(el)), error = function(e) FALSE)) {
|
} else if (tryCatch(any(c("x", "xx") %in% names(el)), error = function(e) FALSE)) {
|
||||||
# otherwise try base R:
|
# - - - -
|
||||||
|
# base R
|
||||||
|
# - - - -
|
||||||
# an element `x` will be in this environment for only cols, e.g. `example_isolates[, carbapenems()]`
|
# an element `x` will be in this environment for only cols, e.g. `example_isolates[, carbapenems()]`
|
||||||
# an element `xx` will be in this environment for rows + cols, e.g. `example_isolates[c(1:3), carbapenems()]`
|
# an element `xx` will be in this environment for rows + cols, e.g. `example_isolates[c(1:3), carbapenems()]`
|
||||||
if (tryCatch(is.data.frame(el$xx), error = function(e) FALSE)) {
|
if (tryCatch(is.data.frame(el$xx), error = function(e) FALSE)) {
|
||||||
@@ -675,9 +784,13 @@ 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)
|
vars_df <- tryCatch(frms[[which(!vapply(FUN.VALUE = logical(1), frms, is.null))]], error = function(e) NULL)
|
||||||
if (is.data.frame(vars_df)) {
|
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:
|
# nothing worked, so:
|
||||||
@@ -751,8 +864,13 @@ unique_call_id <- function(entire_session = FALSE) {
|
|||||||
} else {
|
} else {
|
||||||
# combination of environment ID (like "0x7fed4ee8c848")
|
# combination of environment ID (like "0x7fed4ee8c848")
|
||||||
# and highest system call
|
# 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]])),
|
c(envir = gsub("<environment: (.*)>", "\\1", utils::capture.output(sys.frames()[[1]])),
|
||||||
call = paste0(deparse(sys.calls()[[1]]), collapse = ""))
|
call = call)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,13 +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))
|
is.null(pkg_env[[paste0("thrown_msg.", fn)]]) || !identical(pkg_env[[paste0("thrown_msg.", fn)]], unique_call_id(entire_session))
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_all_thrown_messages <- function() {
|
|
||||||
# for unit tests, where the environment and highest system call do not change
|
|
||||||
pkg_env_contents <- ls(envir = pkg_env)
|
|
||||||
rm(list = pkg_env_contents[pkg_env_contents %like% "^thrown_msg."],
|
|
||||||
envir = pkg_env)
|
|
||||||
}
|
|
||||||
|
|
||||||
has_colour <- function() {
|
has_colour <- function() {
|
||||||
# this is a base R version of crayon::has_color, but disables colours on emacs
|
# this is a base R version of crayon::has_color, but disables colours on emacs
|
||||||
|
|
||||||
@@ -790,7 +901,7 @@ has_colour <- function() {
|
|||||||
if (Sys.getenv("RSTUDIO", "") == "") {
|
if (Sys.getenv("RSTUDIO", "") == "") {
|
||||||
return(FALSE)
|
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)
|
return(TRUE)
|
||||||
}
|
}
|
||||||
tryCatch(get("isAvailable", envir = asNamespace("rstudioapi"))(), error = function(e) return(FALSE)) &&
|
tryCatch(get("isAvailable", envir = asNamespace("rstudioapi"))(), error = function(e) return(FALSE)) &&
|
||||||
@@ -913,8 +1024,8 @@ font_stripstyle <- function(x) {
|
|||||||
gsub("(?:(?:\\x{001b}\\[)|\\x{009b})(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\\x{001b}[A-M]", "", x, perl = TRUE)
|
gsub("(?:(?:\\x{001b}\\[)|\\x{009b})(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\\x{001b}[A-M]", "", x, perl = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_ticker <- function(n = 1, n_min = 0, ...) {
|
progress_ticker <- function(n = 1, n_min = 0, print = TRUE, ...) {
|
||||||
if (!interactive() || n < n_min) {
|
if (print == FALSE || n < n_min) {
|
||||||
pb <- list()
|
pb <- list()
|
||||||
pb$tick <- function() {
|
pb$tick <- function() {
|
||||||
invisible()
|
invisible()
|
||||||
@@ -1011,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
|
# 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
|
# 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)
|
x <- as.double(x)
|
||||||
# https://stackoverflow.com/a/12688836/4575331
|
# https://stackoverflow.com/a/12688836/4575331
|
||||||
val <- (trunc((abs(x) * 10 ^ digits) + 0.5) / 10 ^ digits) * sign(x)
|
val <- (trunc((abs(x) * 10 ^ digits) + 0.5) / 10 ^ digits) * sign(x)
|
||||||
@@ -1056,11 +1167,14 @@ percentage <- function(x, digits = NULL, ...) {
|
|||||||
if (is.null(digits)) {
|
if (is.null(digits)) {
|
||||||
digits <- getdecimalplaces(x)
|
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%"
|
# 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,
|
x_formatted <- format(round2(as.double(x), digits = digits + 2) * 100,
|
||||||
scientific = FALSE,
|
scientific = FALSE,
|
||||||
digits = digits,
|
digits = max(1, digits),
|
||||||
nsmall = digits,
|
nsmall = digits,
|
||||||
...)
|
...)
|
||||||
x_formatted <- paste0(x_formatted, "%")
|
x_formatted <- paste0(x_formatted, "%")
|
||||||
@@ -1080,15 +1194,15 @@ percentage <- function(x, digits = NULL, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
time_start_tracking <- function() {
|
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) {
|
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'
|
# prevent dependency on package 'backports' ----
|
||||||
# these functions were not available in previous versions of R (last checked: R 4.0.3)
|
# 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
|
# see here for the full list: https://github.com/r-lib/backports
|
||||||
strrep <- function(x, times) {
|
strrep <- function(x, times) {
|
||||||
x <- as.character(x)
|
x <- as.character(x)
|
||||||
@@ -1102,14 +1216,13 @@ strrep <- function(x, times) {
|
|||||||
paste0(replicate(times, x), collapse = "")
|
paste0(replicate(times, x), collapse = "")
|
||||||
}, list(x = x, times = times), MoreArgs = list()), use.names = FALSE)
|
}, 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)
|
which <- match.arg(which)
|
||||||
mysub <- function(re, x) sub(re, "", x, perl = TRUE)
|
mysub <- function(re, x) sub(re, "", x, perl = TRUE)
|
||||||
if (which == "left")
|
switch(which,
|
||||||
return(mysub("^[ \t\r\n]+", x))
|
left = mysub(paste0("^", whitespace, "+"), x),
|
||||||
if (which == "right")
|
right = mysub(paste0(whitespace, "+$"), x),
|
||||||
return(mysub("[ \t\r\n]+$", x))
|
both = mysub(paste0(whitespace, "+$"), mysub(paste0("^", whitespace, "+"), x)))
|
||||||
mysub("[ \t\r\n]+$", mysub("^[ \t\r\n]+", x))
|
|
||||||
}
|
}
|
||||||
isFALSE <- function(x) {
|
isFALSE <- function(x) {
|
||||||
is.logical(x) && length(x) == 1L && !is.na(x) && !x
|
is.logical(x) && length(x) == 1L && !is.na(x) && !x
|
||||||
@@ -1135,3 +1248,15 @@ isNamespaceLoaded <- function(pkg) {
|
|||||||
lengths <- function(x, use.names = TRUE) {
|
lengths <- function(x, use.names = TRUE) {
|
||||||
vapply(x, length, FUN.VALUE = NA_integer_, USE.NAMES = use.names)
|
vapply(x, length, FUN.VALUE = NA_integer_, USE.NAMES = use.names)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|||||||
32
R/ab.R
@@ -27,9 +27,9 @@
|
|||||||
#'
|
#'
|
||||||
#' 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).
|
#' Use this function to determine the antibiotic code of one or more antibiotics. The data set [antibiotics] will be searched for abbreviations, official names and synonyms (brand names).
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x character vector to determine to antibiotic ID
|
#' @param x a [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 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 logical to indicate whether a progress bar should be printed
|
#' @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
|
#' @param ... arguments passed on to internal functions
|
||||||
#' @rdname as.ab
|
#' @rdname as.ab
|
||||||
#' @inheritSection WHOCC WHOCC
|
#' @inheritSection WHOCC WHOCC
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
#'
|
#'
|
||||||
#' WHONET 2019 software: \url{http://www.whonet.org/software.html}
|
#' 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
|
#' @aliases ab
|
||||||
#' @return A [character] [vector] with additional class [`ab`]
|
#' @return A [character] [vector] with additional class [`ab`]
|
||||||
#' @seealso
|
#' @seealso
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
#' # they use as.ab() internally:
|
#' # they use as.ab() internally:
|
||||||
#' ab_name("J01FA01") # "Erythromycin"
|
#' ab_name("J01FA01") # "Erythromycin"
|
||||||
#' ab_name("eryt") # "Erythromycin"
|
#' ab_name("eryt") # "Erythromycin"
|
||||||
#'
|
#' \donttest{
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#'
|
#'
|
||||||
#' # you can quickly rename <rsi> columns using dplyr >= 1.0.0:
|
#' # you can quickly rename <rsi> columns using dplyr >= 1.0.0:
|
||||||
@@ -90,7 +90,8 @@
|
|||||||
#' rename_with(as.ab, where(is.rsi))
|
#' rename_with(as.ab, where(is.rsi))
|
||||||
#'
|
#'
|
||||||
#' }
|
#' }
|
||||||
as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
#' }
|
||||||
|
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(x, allow_class = c("character", "numeric", "integer", "factor"), allow_NA = TRUE)
|
||||||
meet_criteria(flag_multiple_results, allow_class = "logical", has_length = 1)
|
meet_criteria(flag_multiple_results, allow_class = "logical", has_length = 1)
|
||||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||||
@@ -155,7 +156,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (initial_search == TRUE) {
|
if (initial_search == TRUE) {
|
||||||
progress <- progress_ticker(n = length(x), n_min = ifelse(isTRUE(info), 25, length(x) + 1)) # start if n >= 25
|
progress <- progress_ticker(n = length(x), n_min = 25, print = info) # start if n >= 25
|
||||||
on.exit(close(progress))
|
on.exit(close(progress))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,8 +170,6 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
|||||||
next
|
next
|
||||||
}
|
}
|
||||||
if (identical(x[i], "") |
|
if (identical(x[i], "") |
|
||||||
# no short names:
|
|
||||||
nchar(x[i]) <= 2 |
|
|
||||||
# prevent "bacteria" from coercing to TMP, since Bacterial is a brand name of it:
|
# prevent "bacteria" from coercing to TMP, since Bacterial is a brand name of it:
|
||||||
identical(tolower(x[i]), "bacteria")) {
|
identical(tolower(x[i]), "bacteria")) {
|
||||||
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
|
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
|
||||||
@@ -238,7 +237,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
|||||||
|
|
||||||
# exact abbreviation
|
# exact abbreviation
|
||||||
abbr_found <- unlist(lapply(AB_lookup$generalised_abbreviations,
|
abbr_found <- unlist(lapply(AB_lookup$generalised_abbreviations,
|
||||||
function(s) x[i] %in% s))
|
# require at least 2 characters for abbreviations
|
||||||
|
function(s) x[i] %in% s & nchar(x[i]) >= 2))
|
||||||
found <- antibiotics$ab[abbr_found == TRUE]
|
found <- antibiotics$ab[abbr_found == TRUE]
|
||||||
if (length(found) > 0) {
|
if (length(found) > 0) {
|
||||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||||
@@ -389,7 +389,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
|||||||
|
|
||||||
# first 5 except for cephalosporins, then first 7 (those cephalosporins all start quite the same!)
|
# first 5 except for cephalosporins, then first 7 (those cephalosporins all start quite the same!)
|
||||||
found <- suppressWarnings(as.ab(substr(x[i], 1, 5), initial_search = FALSE))
|
found <- suppressWarnings(as.ab(substr(x[i], 1, 5), initial_search = FALSE))
|
||||||
if (!is.na(found) && !ab_group(found, initial_search = FALSE) %like% "cephalosporins") {
|
if (!is.na(found) && ab_group(found, initial_search = FALSE) %unlike% "cephalosporins") {
|
||||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
@@ -477,7 +477,6 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
|||||||
if (length(x_unknown) > 0 & fast_mode == FALSE) {
|
if (length(x_unknown) > 0 & fast_mode == FALSE) {
|
||||||
warning_("These values could not be coerced to a valid antimicrobial ID: ",
|
warning_("These values could not be coerced to a valid antimicrobial ID: ",
|
||||||
vector_and(x_unknown), ".",
|
vector_and(x_unknown), ".",
|
||||||
".",
|
|
||||||
call = FALSE)
|
call = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,7 +551,7 @@ as.data.frame.ab <- function(x, ...) {
|
|||||||
"[<-.ab" <- function(i, j, ..., value) {
|
"[<-.ab" <- function(i, j, ..., value) {
|
||||||
y <- NextMethod()
|
y <- NextMethod()
|
||||||
attributes(y) <- attributes(i)
|
attributes(y) <- attributes(i)
|
||||||
class_integrity_check(y, "antimicrobial code", antibiotics$ab)
|
return_after_integrity_check(y, "antimicrobial code", antibiotics$ab)
|
||||||
}
|
}
|
||||||
#' @method [[<- ab
|
#' @method [[<- ab
|
||||||
#' @export
|
#' @export
|
||||||
@@ -560,15 +559,16 @@ as.data.frame.ab <- function(x, ...) {
|
|||||||
"[[<-.ab" <- function(i, j, ..., value) {
|
"[[<-.ab" <- function(i, j, ..., value) {
|
||||||
y <- NextMethod()
|
y <- NextMethod()
|
||||||
attributes(y) <- attributes(i)
|
attributes(y) <- attributes(i)
|
||||||
class_integrity_check(y, "antimicrobial code", antibiotics$ab)
|
return_after_integrity_check(y, "antimicrobial code", antibiotics$ab)
|
||||||
}
|
}
|
||||||
#' @method c ab
|
#' @method c ab
|
||||||
#' @export
|
#' @export
|
||||||
#' @noRd
|
#' @noRd
|
||||||
c.ab <- function(x, ...) {
|
c.ab <- function(...) {
|
||||||
|
x <- list(...)[[1L]]
|
||||||
y <- NextMethod()
|
y <- NextMethod()
|
||||||
attributes(y) <- attributes(x)
|
attributes(y) <- attributes(x)
|
||||||
class_integrity_check(y, "antimicrobial code", antibiotics$ab)
|
return_after_integrity_check(y, "antimicrobial code", antibiotics$ab)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @method unique ab
|
#' @method unique ab
|
||||||
|
|||||||
@@ -25,15 +25,19 @@
|
|||||||
|
|
||||||
#' Antibiotic Class Selectors
|
#' Antibiotic Class Selectors
|
||||||
#'
|
#'
|
||||||
#' These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \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
|
#' @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()]
|
#' @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.
|
||||||
#' @inheritParams filter_ab_class
|
#' @param only_rsi_columns a [logical] to indicate whether only columns of class `<rsi>` must be selected (defaults to `FALSE`), see [as.rsi()]
|
||||||
#' @details \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}}
|
#' @details \strong{\Sexpr{ifelse(getRversion() < "3.2", paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}}
|
||||||
#'
|
#'
|
||||||
#' 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
|
#' @rdname antibiotic_class_selectors
|
||||||
#' @seealso [filter_ab_class()] for the `filter()` equivalent.
|
|
||||||
#' @name antibiotic_class_selectors
|
#' @name antibiotic_class_selectors
|
||||||
#' @export
|
#' @export
|
||||||
#' @inheritSection AMR Reference Data Publicly Available
|
#' @inheritSection AMR Reference Data Publicly Available
|
||||||
@@ -42,11 +46,31 @@
|
|||||||
#' # `example_isolates` is a data set available in the AMR package.
|
#' # `example_isolates` is a data set available in the AMR package.
|
||||||
#' # See ?example_isolates.
|
#' # See ?example_isolates.
|
||||||
#'
|
#'
|
||||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
#' # Base R ------------------------------------------------------------------
|
||||||
|
#'
|
||||||
|
#' # select columns 'IPM' (imipenem) and 'MEM' (meropenem)
|
||||||
#' example_isolates[, carbapenems()]
|
#' 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())]
|
#' 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")) {
|
#' if (require("dplyr")) {
|
||||||
#'
|
#'
|
||||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||||
@@ -57,6 +81,20 @@
|
|||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' select(mo, aminoglycosides())
|
#' 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'):
|
#' # this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' select(mo, ab_class("mycobact"))
|
#' select(mo, ab_class("mycobact"))
|
||||||
@@ -75,10 +113,12 @@
|
|||||||
#' select(penicillins()) # only the 'J01CA01' column will be selected
|
#' 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)
|
#' # (though the row names on the first are more correct)
|
||||||
#' example_isolates %>% filter_carbapenems("R", "all")
|
#' example_isolates[carbapenems() == "R", ]
|
||||||
#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
|
#' example_isolates %>% filter(carbapenems() == "R")
|
||||||
|
#' example_isolates %>% filter(across(carbapenems(), ~.x == "R"))
|
||||||
|
#' }
|
||||||
#' }
|
#' }
|
||||||
ab_class <- function(ab_class,
|
ab_class <- function(ab_class,
|
||||||
only_rsi_columns = FALSE) {
|
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)
|
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
|
#' @rdname antibiotic_class_selectors
|
||||||
#' @export
|
#' @export
|
||||||
carbapenems <- function(only_rsi_columns = FALSE) {
|
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(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)
|
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,
|
warning_("antibiotic class selectors such as ", function_name,
|
||||||
"() require R version 3.2 or later - you have ", R.version.string,
|
"() require R version 3.2 or later - you have ", R.version.string,
|
||||||
call = FALSE)
|
call = FALSE)
|
||||||
return(NULL)
|
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)
|
vars_df <- get_current_data(arg_name = NA, call = -3)
|
||||||
|
ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns, sort = FALSE)
|
||||||
# improve speed here so it will only run once when e.g. in one select call
|
|
||||||
if (!identical(pkg_env$ab_selector, unique_call_id())) {
|
|
||||||
ab_in_data <- get_column_abx(vars_df, info = FALSE, 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
|
|
||||||
}
|
|
||||||
|
|
||||||
if (length(ab_in_data) == 0) {
|
if (length(ab_in_data) == 0) {
|
||||||
message_("No antimicrobial agents found.")
|
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
|
# get the columns with a group names in the chosen ab class
|
||||||
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
||||||
|
|
||||||
if (message_not_thrown_before(function_name)) {
|
if (message_not_thrown_before(function_name)) {
|
||||||
if (length(agents) == 0) {
|
if (length(agents) == 0) {
|
||||||
message_("No antimicrobial agents of class ", ab_group, " found", examples, ".")
|
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))
|
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_formatted[need_name] <- paste0(agents_formatted[need_name],
|
||||||
" (", agents_names[need_name], ")")
|
" (", agents_names[need_name], ")")
|
||||||
message_("Selecting ", ab_group, ": ",
|
message_("For `", function_name, "(", ifelse(function_name == "ab_class", paste0("\"", ab_class, "\""), ""), ")` using ",
|
||||||
ifelse(length(agents) == 1, "column ", "columns "),
|
ifelse(length(agents) == 1, "column: ", "columns: "),
|
||||||
vector_and(agents_formatted, quotes = FALSE),
|
vector_and(agents_formatted, quotes = FALSE))
|
||||||
as_note = FALSE,
|
|
||||||
extra_indent = 6)
|
|
||||||
}
|
}
|
||||||
remember_thrown_message(function_name)
|
remember_thrown_message(function_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
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,16 +29,17 @@
|
|||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param text text to analyse
|
#' @param text text to analyse
|
||||||
#' @param type type of property to search for, either `"drug"`, `"dose"` or `"administration"`, see *Examples*
|
#' @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 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 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()]
|
#' @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.
|
#' @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`
|
#' ## 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.
|
#' 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*.
|
#' 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*.
|
||||||
#'
|
#'
|
||||||
@@ -92,6 +93,7 @@ ab_from_text <- function(text,
|
|||||||
collapse = NULL,
|
collapse = NULL,
|
||||||
translate_ab = FALSE,
|
translate_ab = FALSE,
|
||||||
thorough_search = NULL,
|
thorough_search = NULL,
|
||||||
|
info = interactive(),
|
||||||
...) {
|
...) {
|
||||||
if (missing(type)) {
|
if (missing(type)) {
|
||||||
type <- type[1L]
|
type <- type[1L]
|
||||||
@@ -102,12 +104,13 @@ ab_from_text <- function(text,
|
|||||||
meet_criteria(collapse, has_length = 1, allow_NULL = TRUE)
|
meet_criteria(collapse, has_length = 1, allow_NULL = TRUE)
|
||||||
meet_criteria(translate_ab, allow_NULL = FALSE) # get_translate_ab() will be more informative about what's allowed
|
meet_criteria(translate_ab, allow_NULL = FALSE) # get_translate_ab() will be more informative about what's allowed
|
||||||
meet_criteria(thorough_search, allow_class = "logical", has_length = 1, allow_NULL = TRUE)
|
meet_criteria(thorough_search, allow_class = "logical", has_length = 1, allow_NULL = TRUE)
|
||||||
|
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
type <- tolower(trimws(type))
|
type <- tolower(trimws(type))
|
||||||
|
|
||||||
text <- tolower(as.character(text))
|
text <- tolower(as.character(text))
|
||||||
text_split_all <- strsplit(text, "[ ;.,:\\|]")
|
text_split_all <- strsplit(text, "[ ;.,:\\|]")
|
||||||
progress <- progress_ticker(n = length(text_split_all), n_min = 5)
|
progress <- progress_ticker(n = length(text_split_all), n_min = 5, print = info)
|
||||||
on.exit(close(progress))
|
on.exit(close(progress))
|
||||||
|
|
||||||
if (type %like% "(drug|ab|anti)") {
|
if (type %like% "(drug|ab|anti)") {
|
||||||
|
|||||||
@@ -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()].
|
#' Use these functions to return a specific property of an antibiotic from the [antibiotics] data set. All input values will be evaluated internally with [as.ab()].
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x any (vector of) text that can be coerced to a valid antibiotic code with [as.ab()]
|
#' @param 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 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 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 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 open browse the URL using [utils::browseURL()]
|
||||||
#' @param ... other arguments passed on to [as.ab()]
|
#' @param ... other arguments passed on to [as.ab()]
|
||||||
#' @details All output [will be translated][translate] where possible.
|
#' @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(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
meet_criteria(tolower, allow_class = "logical", has_length = 1)
|
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) {
|
if (tolower == TRUE) {
|
||||||
# use perl to only transform the first character
|
# use perl to only transform the first character
|
||||||
# as we want "polymyxin B", not "polymyxin b"
|
# as we want "polymyxin B", not "polymyxin b"
|
||||||
@@ -142,7 +142,7 @@ ab_tradenames <- function(x, ...) {
|
|||||||
ab_group <- function(x, language = get_locale(), ...) {
|
ab_group <- function(x, language = get_locale(), ...) {
|
||||||
meet_criteria(x, allow_NA = TRUE)
|
meet_criteria(x, allow_NA = TRUE)
|
||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, 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
|
#' @rdname ab_property
|
||||||
@@ -150,7 +150,7 @@ ab_group <- function(x, language = get_locale(), ...) {
|
|||||||
ab_atc_group1 <- function(x, language = get_locale(), ...) {
|
ab_atc_group1 <- function(x, language = get_locale(), ...) {
|
||||||
meet_criteria(x, allow_NA = TRUE)
|
meet_criteria(x, allow_NA = TRUE)
|
||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, 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
|
#' @rdname ab_property
|
||||||
@@ -158,7 +158,7 @@ ab_atc_group1 <- function(x, language = get_locale(), ...) {
|
|||||||
ab_atc_group2 <- function(x, language = get_locale(), ...) {
|
ab_atc_group2 <- function(x, language = get_locale(), ...) {
|
||||||
meet_criteria(x, allow_NA = TRUE)
|
meet_criteria(x, allow_NA = TRUE)
|
||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, 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
|
#' @rdname ab_property
|
||||||
|
|||||||
44
R/age.R
@@ -27,12 +27,14 @@
|
|||||||
#'
|
#'
|
||||||
#' Calculates age in years based on a reference date, which is the sytem date at default.
|
#' Calculates age in years based on a reference date, which is the sytem date at default.
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x date(s), will be coerced with [as.POSIXlt()]
|
#' @param x date(s), [character] (vectors) will be coerced with [as.POSIXlt()]
|
||||||
#' @param reference reference date(s) (defaults to today), 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 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 na.rm a [logical] to indicate whether missing values should be removed
|
||||||
#' @param ... arguments passed on to [as.POSIXlt()], such as `origin`
|
#' @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.
|
#' @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
|
#' @return An [integer] (no decimals) if `exact = FALSE`, a [double] (with decimals) otherwise
|
||||||
#' @seealso To split ages into groups, use the [age_groups()] function.
|
#' @seealso To split ages into groups, use the [age_groups()] function.
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
@@ -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)
|
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
if (length(x) != length(reference)) {
|
if (length(x) != length(reference)) {
|
||||||
stop_if(length(reference) != 1, "`x` and `reference` must be of same length, or `reference` must be of length 1.")
|
if (length(x) == 1) {
|
||||||
|
x <- rep(x, length(reference))
|
||||||
|
} else if (length(reference) == 1) {
|
||||||
reference <- rep(reference, length(x))
|
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, ...)
|
x <- as.POSIXlt(x, ...)
|
||||||
reference <- as.POSIXlt(reference, ...)
|
reference <- as.POSIXlt(reference, ...)
|
||||||
@@ -68,21 +75,26 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
|||||||
# add decimals
|
# add decimals
|
||||||
if (exact == TRUE) {
|
if (exact == TRUE) {
|
||||||
# get dates of `x` when `x` would have the year of `reference`
|
# 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
|
# 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
|
# 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
|
# add decimal parts of year
|
||||||
mod <- n_days_x_rest / n_days_reference_year
|
mod <- n_days_x_rest / n_days_reference_year
|
||||||
# negative mods are cases where `x_in_reference_year` > `reference` - so 'add' a 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
|
# and finally add to ages
|
||||||
ages <- ages + mod
|
ages <- ages + mod
|
||||||
}
|
}
|
||||||
|
|
||||||
if (any(ages < 0, na.rm = TRUE)) {
|
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)
|
warning_("NAs introduced for ages below 0.", call = TRUE)
|
||||||
}
|
}
|
||||||
if (any(ages > 120, na.rm = 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 <- ages[!is.na(ages)]
|
||||||
}
|
}
|
||||||
|
|
||||||
ages
|
if (exact == TRUE) {
|
||||||
|
as.double(ages)
|
||||||
|
} else {
|
||||||
|
as.integer(ages)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#' Split Ages into Age Groups
|
#' 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
|
#' @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:
|
#' @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+).
|
#' 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:
|
#' * 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+.
|
#' - `"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+.
|
||||||
@@ -149,8 +165,8 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
|||||||
#' }
|
#' }
|
||||||
#' }
|
#' }
|
||||||
age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
|
age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
|
||||||
meet_criteria(x, allow_class = c("numeric", "integer"), is_positive = TRUE, is_finite = TRUE)
|
meet_criteria(x, allow_class = c("numeric", "integer"), is_positive_or_zero = TRUE, is_finite = TRUE)
|
||||||
meet_criteria(split_at, allow_class = c("numeric", "integer", "character"), is_positive = TRUE, is_finite = TRUE)
|
meet_criteria(split_at, allow_class = c("numeric", "integer", "character"), is_positive_or_zero = TRUE, is_finite = TRUE)
|
||||||
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
if (any(x < 0, na.rm = TRUE)) {
|
if (any(x < 0, na.rm = TRUE)) {
|
||||||
|
|||||||
@@ -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.
|
#' Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic), such as the name, defined daily dose (DDD) or standard unit.
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param atc_code a character or character vector with ATC code(s) of antibiotic(s)
|
#' @param 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 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 administration type of administration when using `property = "Adm.R"`, see *Details*
|
||||||
#' @param url url of website of the WHOCC. The sign `%s` can be used as a placeholder for ATC codes.
|
#' @param url 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
|
#' - `"TU"` = thousand units
|
||||||
#' - `"MU"` = million units
|
#' - `"MU"` = million units
|
||||||
#' - `"mmol"` = millimole
|
#' - `"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`.**
|
#' **N.B. This function requires an internet connection and only works if the following packages are installed: `curl`, `rvest`, `xml2`.**
|
||||||
#' @export
|
#' @export
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
|
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
|
||||||
#' @examples
|
#' @examples
|
||||||
#' \donttest{
|
#' \donttest{
|
||||||
|
#' if (requireNamespace("curl") && requireNamespace("rvest") && requireNamespace("xml2")) {
|
||||||
#' # oral DDD (Defined Daily Dose) of amoxicillin
|
#' # oral DDD (Defined Daily Dose) of amoxicillin
|
||||||
#' atc_online_property("J01CA04", "DDD", "O")
|
#' atc_online_property("J01CA04", "DDD", "O")
|
||||||
#'
|
#'
|
||||||
@@ -73,6 +74,7 @@
|
|||||||
#'
|
#'
|
||||||
#' 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,
|
atc_online_property <- function(atc_code,
|
||||||
property,
|
property,
|
||||||
administration = "O",
|
administration = "O",
|
||||||
|
|||||||
@@ -35,13 +35,14 @@
|
|||||||
#' @export
|
#' @export
|
||||||
#' @examples
|
#' @examples
|
||||||
#' availability(example_isolates)
|
#' availability(example_isolates)
|
||||||
#'
|
#' \donttest{
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' filter(mo == as.mo("E. coli")) %>%
|
#' filter(mo == as.mo("E. coli")) %>%
|
||||||
#' select_if(is.rsi) %>%
|
#' select_if(is.rsi) %>%
|
||||||
#' availability()
|
#' availability()
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
availability <- function(tbl, width = NULL) {
|
availability <- function(tbl, width = NULL) {
|
||||||
meet_criteria(tbl, allow_class = "data.frame")
|
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)
|
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*.
|
#' 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
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @inheritParams eucast_rules
|
#' @inheritParams eucast_rules
|
||||||
#' @param combine_IR logical to indicate whether values R and I should be summed
|
#' @param combine_IR a [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 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 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 FUN the 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 translate_ab a [character] of length 1 containing column names of the [antibiotics] data set
|
||||||
#' @param ... arguments passed on to `FUN`
|
#' @param ... arguments passed on to `FUN`
|
||||||
#' @inheritParams rsi_df
|
#' @inheritParams rsi_df
|
||||||
#' @inheritParams base::formatC
|
#' @inheritParams base::formatC
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
#' count_susceptible(example_isolates$AMX)
|
#' count_susceptible(example_isolates$AMX)
|
||||||
#' susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
#' susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
||||||
#'
|
#'
|
||||||
#'
|
#' \donttest{
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' group_by(hospital_id) %>%
|
#' group_by(hospital_id) %>%
|
||||||
@@ -106,6 +106,7 @@
|
|||||||
#' group_by(hospital_id) %>%
|
#' group_by(hospital_id) %>%
|
||||||
#' count_df(translate = FALSE)
|
#' count_df(translate = FALSE)
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
count_resistant <- function(..., only_all_tested = FALSE) {
|
count_resistant <- function(..., only_all_tested = FALSE) {
|
||||||
rsi_calc(...,
|
rsi_calc(...,
|
||||||
ab_result = "R",
|
ab_result = "R",
|
||||||
|
|||||||
255
R/custom_eucast_rules.R
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
# ==================================================================== #
|
||||||
|
# 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/ #
|
||||||
|
# ==================================================================== #
|
||||||
|
|
||||||
|
#' Define Custom EUCAST Rules
|
||||||
|
#'
|
||||||
|
#' Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in [eucast_rules()].
|
||||||
|
#' @inheritSection lifecycle Maturing Lifecycle
|
||||||
|
#' @param ... rules in formula notation, see *Examples*
|
||||||
|
#' @details
|
||||||
|
#' Some organisations have their own adoption of EUCAST rules. This function can be used to define custom EUCAST rules to be used in the [eucast_rules()] function.
|
||||||
|
#'
|
||||||
|
#' @section How it works:
|
||||||
|
#'
|
||||||
|
#' ### Basics
|
||||||
|
#'
|
||||||
|
#' If you are familiar with the [`case_when()`][dplyr::case_when()] function of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation'. The rule itself is written *before* the tilde (`~`) and the consequence of the rule is written *after* the tilde:
|
||||||
|
#'
|
||||||
|
#' ```
|
||||||
|
#' x <- custom_eucast_rules(TZP == "S" ~ aminopenicillins == "S",
|
||||||
|
#' TZP == "R" ~ aminopenicillins == "R")
|
||||||
|
#' ```
|
||||||
|
#'
|
||||||
|
#' These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work:
|
||||||
|
#'
|
||||||
|
#' ```
|
||||||
|
#' x
|
||||||
|
#' #> A set of custom EUCAST rules:
|
||||||
|
#' #>
|
||||||
|
#' #> 1. If TZP is S then set to S:
|
||||||
|
#' #> amoxicillin (AMX), ampicillin (AMP)
|
||||||
|
#' #>
|
||||||
|
#' #> 2. If TZP is R then set to R:
|
||||||
|
#' #> amoxicillin (AMX), ampicillin (AMP)
|
||||||
|
#' ```
|
||||||
|
#'
|
||||||
|
#' The rules (the part *before* the tilde, in above example `TZP == "S"` and `TZP == "R"`) must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column `TZP` must exist. We will create a sample data set and test the rules set:
|
||||||
|
#'
|
||||||
|
#' ```
|
||||||
|
#' df <- data.frame(mo = c("E. coli", "K. pneumoniae"),
|
||||||
|
#' TZP = "R",
|
||||||
|
#' amox = "",
|
||||||
|
#' AMP = "")
|
||||||
|
#' df
|
||||||
|
#' #> mo TZP amox AMP
|
||||||
|
#' #> 1 E. coli R
|
||||||
|
#' #> 2 K. pneumoniae R
|
||||||
|
#'
|
||||||
|
#' eucast_rules(df, rules = "custom", custom_rules = x)
|
||||||
|
#' #> mo TZP amox AMP
|
||||||
|
#' #> 1 E. coli R R R
|
||||||
|
#' #> 2 K. pneumoniae R R R
|
||||||
|
#' ```
|
||||||
|
#'
|
||||||
|
#' ### Using taxonomic properties in rules
|
||||||
|
#'
|
||||||
|
#' There is one exception in variables used for the rules: all column names of the [microorganisms] data set can also be used, but do not have to exist in the data set. These column names are: `r vector_and(colnames(microorganisms), quote = "``", sort = FALSE)`. Thus, this next example will work as well, despite the fact that the `df` data set does not contain a column `genus`:
|
||||||
|
#'
|
||||||
|
#' ```
|
||||||
|
#' y <- custom_eucast_rules(TZP == "S" & genus == "Klebsiella" ~ aminopenicillins == "S",
|
||||||
|
#' TZP == "R" & genus == "Klebsiella" ~ aminopenicillins == "R")
|
||||||
|
#'
|
||||||
|
#' eucast_rules(df, rules = "custom", custom_rules = y)
|
||||||
|
#' #> mo TZP amox AMP
|
||||||
|
#' #> 1 E. coli R
|
||||||
|
#' #> 2 K. pneumoniae R R R
|
||||||
|
#' ```
|
||||||
|
#'
|
||||||
|
#' ### Usage of antibiotic group names
|
||||||
|
#'
|
||||||
|
#' It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part *after* the tilde. In above examples, the antibiotic group `aminopenicillins` is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the antibiotic agents that will be matched when running the rule.
|
||||||
|
#'
|
||||||
|
#' `r paste0(" * ", sapply(DEFINED_AB_GROUPS, function(x) paste0("``", tolower(x), "``\\cr(", paste0(sort(ab_name(eval(parse(text = x), envir = asNamespace("AMR")), language = NULL, tolower = TRUE)), collapse = ", "), ")"), USE.NAMES = FALSE), "\n", collapse = "")`
|
||||||
|
#' @returns A [list] containing the custom rules
|
||||||
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
|
#' @export
|
||||||
|
#' @examples
|
||||||
|
#' x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||||
|
#' AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
|
||||||
|
#' eucast_rules(example_isolates,
|
||||||
|
#' rules = "custom",
|
||||||
|
#' custom_rules = x,
|
||||||
|
#' info = FALSE)
|
||||||
|
#'
|
||||||
|
#' # combine rule sets
|
||||||
|
#' x2 <- c(x,
|
||||||
|
#' custom_eucast_rules(TZP == "R" ~ carbapenems == "R"))
|
||||||
|
#' x2
|
||||||
|
custom_eucast_rules <- function(...) {
|
||||||
|
|
||||||
|
dots <- tryCatch(list(...),
|
||||||
|
error = function(e) "error")
|
||||||
|
stop_if(identical(dots, "error"),
|
||||||
|
"rules must be a valid formula inputs (e.g., using '~'), see `?custom_eucast_rules`")
|
||||||
|
n_dots <- length(dots)
|
||||||
|
stop_if(n_dots == 0, "no custom rules were set. Please read the documentation using `?custom_eucast_rules`.")
|
||||||
|
out <- vector("list", n_dots)
|
||||||
|
for (i in seq_len(n_dots)) {
|
||||||
|
stop_ifnot(inherits(dots[[i]], "formula"),
|
||||||
|
"rule ", i, " must be a valid formula input (e.g., using '~'), see `?custom_eucast_rules`")
|
||||||
|
|
||||||
|
# Query
|
||||||
|
qry <- dots[[i]][[2]]
|
||||||
|
if (inherits(qry, "call")) {
|
||||||
|
qry <- as.expression(qry)
|
||||||
|
}
|
||||||
|
qry <- as.character(qry)
|
||||||
|
# these will prevent vectorisation, so replace them:
|
||||||
|
qry <- gsub("&&", "&", qry, fixed = TRUE)
|
||||||
|
qry <- gsub("||", "|", qry, fixed = TRUE)
|
||||||
|
# format nicely, setting spaces around operators
|
||||||
|
qry <- gsub(" *([&|+-/*^><==]+) *", " \\1 ", qry)
|
||||||
|
qry <- gsub(" ?, ?", ", ", qry)
|
||||||
|
qry <- gsub("'", "\"", qry, fixed = TRUE)
|
||||||
|
out[[i]]$query <- as.expression(qry)
|
||||||
|
|
||||||
|
# Resulting rule
|
||||||
|
result <- dots[[i]][[3]]
|
||||||
|
stop_ifnot(deparse(result) %like% "==",
|
||||||
|
"the result of rule ", i, " (the part after the `~`) must contain `==`, such as in `... ~ ampicillin == \"R\"`, see `?custom_eucast_rules`")
|
||||||
|
result_group <- as.character(result)[[2]]
|
||||||
|
if (paste0(toupper(result_group), "S") %in% DEFINED_AB_GROUPS) {
|
||||||
|
# support for e.g. 'aminopenicillin' if user meant 'aminopenicillins'
|
||||||
|
result_group <- paste0(result_group, "s")
|
||||||
|
}
|
||||||
|
if (toupper(result_group) %in% DEFINED_AB_GROUPS) {
|
||||||
|
result_group <- eval(parse(text = toupper(result_group)), envir = asNamespace("AMR"))
|
||||||
|
} else {
|
||||||
|
result_group <- tryCatch(
|
||||||
|
suppressWarnings(as.ab(result_group,
|
||||||
|
fast_mode = TRUE,
|
||||||
|
flag_multiple_results = FALSE)),
|
||||||
|
error = function(e) NA_character_)
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_if(any(is.na(result_group)),
|
||||||
|
"this result of rule ", i, " could not be translated to a single antimicrobial agent/group: \"",
|
||||||
|
as.character(result)[[2]], "\".\n\nThe input can be a name or code of an antimicrobial agent, or be one of: ",
|
||||||
|
vector_or(tolower(DEFINED_AB_GROUPS), quotes = FALSE), ".")
|
||||||
|
result_value <- as.character(result)[[3]]
|
||||||
|
result_value[result_value == "NA"] <- NA
|
||||||
|
stop_ifnot(result_value %in% c("R", "S", "I", NA),
|
||||||
|
"the resulting value of rule ", i, " must be either \"R\", \"S\", \"I\" or NA")
|
||||||
|
result_value <- as.rsi(result_value)
|
||||||
|
|
||||||
|
out[[i]]$result_group <- result_group
|
||||||
|
out[[i]]$result_value <- result_value
|
||||||
|
}
|
||||||
|
|
||||||
|
names(out) <- paste0("rule", seq_len(n_dots))
|
||||||
|
set_clean_class(out, new_class = c("custom_eucast_rules", "list"))
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @method c custom_eucast_rules
|
||||||
|
#' @noRd
|
||||||
|
#' @export
|
||||||
|
c.custom_eucast_rules <- function(x, ...) {
|
||||||
|
if (length(list(...)) == 0) {
|
||||||
|
return(x)
|
||||||
|
}
|
||||||
|
out <- unclass(x)
|
||||||
|
for (e in list(...)) {
|
||||||
|
out <- c(out, unclass(e))
|
||||||
|
}
|
||||||
|
names(out) <- paste0("rule", seq_len(length(out)))
|
||||||
|
set_clean_class(out, new_class = c("custom_eucast_rules", "list"))
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @method as.list custom_eucast_rules
|
||||||
|
#' @noRd
|
||||||
|
#' @export
|
||||||
|
as.list.custom_eucast_rules <- function(x, ...) {
|
||||||
|
c(x, ...)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @method print custom_eucast_rules
|
||||||
|
#' @export
|
||||||
|
#' @noRd
|
||||||
|
print.custom_eucast_rules <- function(x, ...) {
|
||||||
|
cat("A set of custom EUCAST rules:\n")
|
||||||
|
for (i in seq_len(length(x))) {
|
||||||
|
rule <- x[[i]]
|
||||||
|
rule$query <- format_custom_query_rule(rule$query)
|
||||||
|
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 "))
|
||||||
|
} else {
|
||||||
|
val <- font_rsi_I_bg(font_black(" I "))
|
||||||
|
}
|
||||||
|
agents <- paste0(font_blue(ab_name(rule$result_group, language = NULL, tolower = TRUE),
|
||||||
|
collapse = NULL),
|
||||||
|
" (", rule$result_group, ")")
|
||||||
|
agents <- sort(agents)
|
||||||
|
rule_if <- word_wrap(paste0(i, ". ", font_bold("If "), font_blue(rule$query), font_bold(" then "),
|
||||||
|
"set to {result}:"),
|
||||||
|
extra_indent = 5)
|
||||||
|
rule_if <- gsub("{result}", val, rule_if, fixed = TRUE)
|
||||||
|
rule_then <- paste0(" ", word_wrap(paste0(agents, collapse = ", "), extra_indent = 5))
|
||||||
|
cat("\n ", rule_if, "\n", rule_then, "\n", sep = "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
format_custom_query_rule <- function(query, colours = has_colour()) {
|
||||||
|
query <- gsub(" & ", font_black(font_bold(" and ")), query, fixed = TRUE)
|
||||||
|
query <- gsub(" | ", font_black(" or "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" + ", font_black(" plus "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" - ", font_black(" minus "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" / ", font_black(" divided by "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" * ", font_black(" times "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" == ", font_black(" is "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" > ", font_black(" is higher than "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" < ", font_black(" is lower than "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" >= ", font_black(" is higher than or equal to "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" <= ", font_black(" is lower than or equal to "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" ^ ", font_black(" to the power of "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" %in% ", font_black(" is one of "), query, fixed = TRUE)
|
||||||
|
query <- gsub(" %like% ", font_black(" resembles "), query, fixed = TRUE)
|
||||||
|
if (colours == TRUE) {
|
||||||
|
query <- gsub('"R"', font_rsi_R_bg(font_black(" R ")), query, fixed = TRUE)
|
||||||
|
query <- gsub('"S"', font_rsi_S_bg(font_black(" S ")), query, fixed = TRUE)
|
||||||
|
query <- gsub('"I"', font_rsi_I_bg(font_black(" I ")), query, fixed = TRUE)
|
||||||
|
}
|
||||||
|
# replace the black colour 'stops' with blue colour 'starts'
|
||||||
|
query <- gsub("\033[39m", "\033[34m", as.character(query), fixed = TRUE)
|
||||||
|
# start with blue
|
||||||
|
query <- paste0("\033[34m", query)
|
||||||
|
if (colours == FALSE) {
|
||||||
|
query <- font_stripstyle(query)
|
||||||
|
}
|
||||||
|
query
|
||||||
|
}
|
||||||
20
R/data.R
@@ -71,7 +71,7 @@
|
|||||||
#'
|
#'
|
||||||
#' WHONET 2019 software: <http://www.whonet.org/software.html>
|
#' 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 AMR Reference Data Publicly Available
|
||||||
#' @inheritSection WHOCC WHOCC
|
#' @inheritSection WHOCC WHOCC
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
#' @details
|
#' @details
|
||||||
#' Please note that entries are only based on the Catalogue of Life and the LPSN (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect.
|
#' Please note that entries are only based on the Catalogue of Life and the LPSN (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect.
|
||||||
#'
|
#'
|
||||||
#' For example, *Staphylococcus pettenkoferi* was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the AMR package returns 2007 for `mo_year("S. pettenkoferi")`.
|
#' For example, *Staphylococcus pettenkoferi* was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the `AMR` package returns 2007 for `mo_year("S. pettenkoferi")`.
|
||||||
#'
|
#'
|
||||||
#' ## Manual additions
|
#' ## Manual additions
|
||||||
#' For convenience, some entries were added manually:
|
#' For convenience, some entries were added manually:
|
||||||
@@ -178,9 +178,9 @@
|
|||||||
#' @format A [data.frame] with `r format(nrow(example_isolates), big.mark = ",")` observations and `r ncol(example_isolates)` variables:
|
#' @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
|
#' - `date`\cr date of receipt at the laboratory
|
||||||
#' - `hospital_id`\cr ID of the hospital, from A to D
|
#' - `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_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_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_outpatient`\cr [logical] to determine if ward is an outpatient clinic
|
||||||
#' - `age`\cr age of the patient
|
#' - `age`\cr age of the patient
|
||||||
#' - `gender`\cr gender of the patient
|
#' - `gender`\cr gender of the patient
|
||||||
#' - `patient_id`\cr ID of the patient
|
#' - `patient_id`\cr ID of the patient
|
||||||
@@ -217,8 +217,8 @@
|
|||||||
#' - `Sex`\cr Fictitious gender of patient
|
#' - `Sex`\cr Fictitious gender of patient
|
||||||
#' - `Age`\cr Fictitious age of patient
|
#' - `Age`\cr Fictitious age of patient
|
||||||
#' - `Age category`\cr Age group, can also be looked up using [age_groups()]
|
#' - `Age category`\cr Age group, can also be looked up using [age_groups()]
|
||||||
#' - `Date of admission`\cr Date of hospital admission
|
#' - `Date of admission`\cr [Date] of hospital admission
|
||||||
#' - `Specimen date`\cr Date when specimen was received at laboratory
|
#' - `Specimen date`\cr [Date] when specimen was received at laboratory
|
||||||
#' - `Specimen type`\cr Specimen type or group
|
#' - `Specimen type`\cr Specimen type or group
|
||||||
#' - `Specimen type (Numeric)`\cr Translation of `"Specimen type"`
|
#' - `Specimen type (Numeric)`\cr Translation of `"Specimen type"`
|
||||||
#' - `Reason`\cr Reason of request with Differential Diagnosis
|
#' - `Reason`\cr Reason of request with Differential Diagnosis
|
||||||
@@ -231,7 +231,7 @@
|
|||||||
#' - `MRSA screening test`\cr Microorganism is possible MRSA?
|
#' - `MRSA screening test`\cr Microorganism is possible MRSA?
|
||||||
#' - `Inducible clindamycin resistance`\cr Clindamycin can be induced?
|
#' - `Inducible clindamycin resistance`\cr Clindamycin can be induced?
|
||||||
#' - `Comment`\cr Other comments
|
#' - `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()].
|
#' - `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 Reference Data Publicly Available
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
@@ -250,7 +250,7 @@
|
|||||||
#' - `disk_dose`\cr Dose of the used disk diffusion method
|
#' - `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_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"
|
#' - `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.
|
#' @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 Reference Data Publicly Available
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
@@ -269,12 +269,14 @@
|
|||||||
#' @inheritSection AMR Reference Data Publicly Available
|
#' @inheritSection AMR Reference Data Publicly Available
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @examples
|
#' @examples
|
||||||
|
#' \donttest{
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' intrinsic_resistant %>%
|
#' intrinsic_resistant %>%
|
||||||
#' filter(antibiotic == "Vancomycin", microorganism %like% "Enterococcus") %>%
|
#' filter(antibiotic == "Vancomycin", microorganism %like% "Enterococcus") %>%
|
||||||
#' pull(microorganism)
|
#' pull(microorganism)
|
||||||
#' # [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"
|
#' # [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
"intrinsic_resistant"
|
"intrinsic_resistant"
|
||||||
|
|
||||||
#' Data Set with Treatment Dosages as Defined by EUCAST
|
#' Data Set with Treatment Dosages as Defined by EUCAST
|
||||||
|
|||||||
457
R/deprecated.R
@@ -25,7 +25,8 @@
|
|||||||
|
|
||||||
#' Deprecated Functions
|
#' Deprecated Functions
|
||||||
#'
|
#'
|
||||||
#' These functions are so-called '[Deprecated]'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
|
#' 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 lifecycle Retired Lifecycle
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @keywords internal
|
#' @keywords internal
|
||||||
@@ -45,3 +46,457 @@ p_symbol <- function(p, emptychar = " ") {
|
|||||||
|
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' @name AMR-deprecated
|
||||||
|
#' @export
|
||||||
|
filter_first_weighted_isolate <- function(x = NULL,
|
||||||
|
col_date = NULL,
|
||||||
|
col_patient_id = NULL,
|
||||||
|
col_mo = NULL,
|
||||||
|
...) {
|
||||||
|
|
||||||
|
.Deprecated(old = "filter_first_weighted_isolate()",
|
||||||
|
new = "filter_first_isolate()",
|
||||||
|
package = "AMR")
|
||||||
|
|
||||||
|
if (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 <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||||
|
}
|
||||||
|
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
||||||
|
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
|
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
|
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
|
|
||||||
|
filter_first_isolate(x = x, col_date = col_date, col_patient_id = col_patient_id, col_mo = col_mo, ...)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @name AMR-deprecated
|
||||||
|
#' @export
|
||||||
|
key_antibiotics <- function(x = NULL,
|
||||||
|
col_mo = NULL,
|
||||||
|
universal_1 = guess_ab_col(x, "amoxicillin"),
|
||||||
|
universal_2 = guess_ab_col(x, "amoxicillin/clavulanic acid"),
|
||||||
|
universal_3 = guess_ab_col(x, "cefuroxime"),
|
||||||
|
universal_4 = guess_ab_col(x, "piperacillin/tazobactam"),
|
||||||
|
universal_5 = guess_ab_col(x, "ciprofloxacin"),
|
||||||
|
universal_6 = guess_ab_col(x, "trimethoprim/sulfamethoxazole"),
|
||||||
|
GramPos_1 = guess_ab_col(x, "vancomycin"),
|
||||||
|
GramPos_2 = guess_ab_col(x, "teicoplanin"),
|
||||||
|
GramPos_3 = guess_ab_col(x, "tetracycline"),
|
||||||
|
GramPos_4 = guess_ab_col(x, "erythromycin"),
|
||||||
|
GramPos_5 = guess_ab_col(x, "oxacillin"),
|
||||||
|
GramPos_6 = guess_ab_col(x, "rifampin"),
|
||||||
|
GramNeg_1 = guess_ab_col(x, "gentamicin"),
|
||||||
|
GramNeg_2 = guess_ab_col(x, "tobramycin"),
|
||||||
|
GramNeg_3 = guess_ab_col(x, "colistin"),
|
||||||
|
GramNeg_4 = guess_ab_col(x, "cefotaxime"),
|
||||||
|
GramNeg_5 = guess_ab_col(x, "ceftazidime"),
|
||||||
|
GramNeg_6 = guess_ab_col(x, "meropenem"),
|
||||||
|
warnings = TRUE,
|
||||||
|
...) {
|
||||||
|
|
||||||
|
.Deprecated(old = "key_antibiotics()",
|
||||||
|
new = "key_antimicrobials()",
|
||||||
|
package = "AMR")
|
||||||
|
|
||||||
|
if (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 <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||||
|
}
|
||||||
|
|
||||||
|
key_antimicrobials(x = x,
|
||||||
|
col_mo = col_mo,
|
||||||
|
universal = c(universal_1, universal_2, universal_3, universal_4, universal_5, universal_6),
|
||||||
|
gram_negative = c(GramNeg_1, GramNeg_2, GramNeg_3, GramNeg_4, GramNeg_5, GramNeg_6),
|
||||||
|
gram_positive = c(GramPos_1, GramPos_2, GramPos_3, GramPos_4, GramPos_5, GramPos_6),
|
||||||
|
antifungal = NULL,
|
||||||
|
only_rsi_columns = FALSE,
|
||||||
|
...)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @name AMR-deprecated
|
||||||
|
#' @export
|
||||||
|
key_antibiotics_equal <- function(y,
|
||||||
|
z,
|
||||||
|
type = "keyantimicrobials",
|
||||||
|
ignore_I = TRUE,
|
||||||
|
points_threshold = 2,
|
||||||
|
info = FALSE,
|
||||||
|
na.rm = TRUE,
|
||||||
|
...) {
|
||||||
|
|
||||||
|
.Deprecated(old = "key_antibiotics_equal()",
|
||||||
|
new = "antimicrobials_equal()",
|
||||||
|
package = "AMR")
|
||||||
|
|
||||||
|
antimicrobials_equal(y = y,
|
||||||
|
z = z,
|
||||||
|
type = type,
|
||||||
|
ignore_I = ignore_I,
|
||||||
|
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)),
|
||||||
|
...)
|
||||||
|
}
|
||||||
|
|||||||
13
R/disk.R
@@ -29,7 +29,7 @@
|
|||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @rdname as.disk
|
#' @rdname as.disk
|
||||||
#' @param x vector
|
#' @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.
|
#' @details Interpret disk values as RSI values with [as.rsi()]. It supports guidelines from EUCAST and CLSI.
|
||||||
#' @return An [integer] with additional class [`disk`]
|
#' @return An [integer] with additional class [`disk`]
|
||||||
#' @aliases disk
|
#' @aliases disk
|
||||||
@@ -85,7 +85,7 @@ as.disk <- function(x, na.rm = FALSE) {
|
|||||||
fixed = TRUE)
|
fixed = TRUE)
|
||||||
x_clean <- gsub(remove, "", x, ignore.case = TRUE, fixed = fixed)
|
x_clean <- gsub(remove, "", x, ignore.case = TRUE, fixed = fixed)
|
||||||
# remove everything that is not a number or dot
|
# 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
|
# round up and make it an integer
|
||||||
@@ -182,11 +182,8 @@ print.disk <- function(x, ...) {
|
|||||||
#' @method c disk
|
#' @method c disk
|
||||||
#' @export
|
#' @export
|
||||||
#' @noRd
|
#' @noRd
|
||||||
c.disk <- function(x, ...) {
|
c.disk <- function(...) {
|
||||||
y <- NextMethod()
|
as.disk(unlist(lapply(list(...), as.character)))
|
||||||
y <- as.disk(y)
|
|
||||||
attributes(y) <- attributes(x)
|
|
||||||
y
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @method unique disk
|
#' @method unique disk
|
||||||
@@ -205,7 +202,7 @@ get_skimmers.disk <- function(column) {
|
|||||||
min = ~min(as.double(.), na.rm = TRUE),
|
min = ~min(as.double(.), na.rm = TRUE),
|
||||||
max = ~max(as.double(.), na.rm = TRUE),
|
max = ~max(as.double(.), na.rm = TRUE),
|
||||||
median = ~stats::median(as.double(.), na.rm = TRUE),
|
median = ~stats::median(as.double(.), na.rm = TRUE),
|
||||||
n_unique = ~pm_n_distinct(., na.rm = TRUE),
|
n_unique = ~length(unique(stats::na.omit(.))),
|
||||||
hist = ~skimr::inline_hist(stats::na.omit(as.double(.)))
|
hist = ~skimr::inline_hist(stats::na.omit(as.double(.)))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
21
R/episode.R
@@ -28,14 +28,14 @@
|
|||||||
#' These functions determine which items in a vector can be considered (the start of) a new episode, based on the argument `episode_days`. This can be used to determine clinical episodes for any epidemiological analysis. The [get_episode()] function returns the index number of the episode per group, while the [is_new_episode()] function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode.
|
#' These functions determine which items in a vector can be considered (the start of) a new episode, based on the argument `episode_days`. This can be used to determine clinical episodes for any epidemiological analysis. The [get_episode()] function returns the index number of the episode per group, while the [is_new_episode()] function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode.
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x vector of dates (class `Date` or `POSIXt`)
|
#' @param x vector of dates (class `Date` or `POSIXt`)
|
||||||
#' @param episode_days required episode length in days, can also be less than a day, see *Details*
|
#' @param episode_days required episode length in days, can also be less than a day or `Inf`, see *Details*
|
||||||
#' @param ... currently not used
|
#' @param ... ignored, only in place to allow future extensions
|
||||||
#' @details
|
#' @details
|
||||||
#' Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least `episode_days` days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least `episode_days` days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.
|
#' Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least `episode_days` days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least `episode_days` days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.
|
||||||
#'
|
#'
|
||||||
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but is more efficient for data sets containing microorganism codes or names.
|
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but is more efficient for data sets containing microorganism codes or names and allows for different isolate selection methods.
|
||||||
#'
|
#'
|
||||||
#' The `dplyr` package is not required for these functions to work, but these functions support [variable grouping][dplyr::group_by()] and work conveniently inside `dplyr` verbs such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()].
|
#' The `dplyr` package is not required for these functions to work, but these functions do support [variable grouping][dplyr::group_by()] and work conveniently inside `dplyr` verbs such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()].
|
||||||
#' @return
|
#' @return
|
||||||
#' * [get_episode()]: a [double] vector
|
#' * [get_episode()]: a [double] vector
|
||||||
#' * [is_new_episode()]: a [logical] vector
|
#' * [is_new_episode()]: a [logical] vector
|
||||||
@@ -85,10 +85,11 @@
|
|||||||
#' n_episodes_30 = sum(is_new_episode(date, episode_days = 30)))
|
#' n_episodes_30 = sum(is_new_episode(date, episode_days = 30)))
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' # grouping on patients and microorganisms leads to the same results
|
#' # grouping on patients and microorganisms leads to the same
|
||||||
#' # as first_isolate():
|
#' # results as first_isolate() when using 'episode-based':
|
||||||
#' x <- example_isolates %>%
|
#' x <- example_isolates %>%
|
||||||
#' filter(first_isolate(., include_unknown = TRUE))
|
#' filter_first_isolate(include_unknown = TRUE,
|
||||||
|
#' method = "episode-based")
|
||||||
#'
|
#'
|
||||||
#' y <- example_isolates %>%
|
#' y <- example_isolates %>%
|
||||||
#' group_by(patient_id, mo) %>%
|
#' group_by(patient_id, mo) %>%
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
#' }
|
#' }
|
||||||
get_episode <- function(x, episode_days, ...) {
|
get_episode <- function(x, episode_days, ...) {
|
||||||
meet_criteria(x, allow_class = c("Date", "POSIXt"))
|
meet_criteria(x, allow_class = c("Date", "POSIXt"))
|
||||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||||
|
|
||||||
exec_episode(type = "sequential",
|
exec_episode(type = "sequential",
|
||||||
x = x,
|
x = x,
|
||||||
@@ -117,7 +118,7 @@ get_episode <- function(x, episode_days, ...) {
|
|||||||
#' @export
|
#' @export
|
||||||
is_new_episode <- function(x, episode_days, ...) {
|
is_new_episode <- function(x, episode_days, ...) {
|
||||||
meet_criteria(x, allow_class = c("Date", "POSIXt"))
|
meet_criteria(x, allow_class = c("Date", "POSIXt"))
|
||||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||||
|
|
||||||
exec_episode(type = "logical",
|
exec_episode(type = "logical",
|
||||||
x = x,
|
x = x,
|
||||||
@@ -126,7 +127,7 @@ is_new_episode <- function(x, episode_days, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exec_episode <- function(type, x, episode_days, ...) {
|
exec_episode <- function(type, x, episode_days, ...) {
|
||||||
x <- as.double(as.POSIXct(x)) # as.POSIXct() for Date classes
|
x <- as.double(as.POSIXct(x)) # as.POSIXct() required for Date classes
|
||||||
# since x is now in seconds, get seconds from episode_days as well
|
# since x is now in seconds, get seconds from episode_days as well
|
||||||
episode_seconds <- episode_days * 60 * 60 * 24
|
episode_seconds <- episode_days * 60 * 60 * 24
|
||||||
|
|
||||||
|
|||||||
551
R/eucast_rules.R
@@ -50,22 +50,35 @@ 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*.
|
#' 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
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x data with antibiotic columns, such as `amox`, `AMX` and `AMC`
|
#' @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 info a [logical] to indicate whether progress should be printed to the console, defaults to only print while in interactive sessions
|
||||||
#' @param rules a character vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`.
|
#' @param 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 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_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 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 ... 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 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 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
|
#' @inheritParams first_isolate
|
||||||
#' @details
|
#' @details
|
||||||
#' **Note:** This function does not translate MIC values to RSI values. Use [as.rsi()] for that. \cr
|
#' **Note:** This function does not translate MIC values to RSI values. Use [as.rsi()] for that. \cr
|
||||||
#' **Note:** When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance.
|
#' **Note:** When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance. \cr
|
||||||
|
#'
|
||||||
|
#' The file containing all EUCAST rules is located here: <https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv>. **Note:** Old taxonomic names are replaced with the current taxonomy where applicable. For example, *Ochrobactrum anthropi* was renamed to *Brucella anthropi* in 2020; the original EUCAST rules v3.1 and v3.2 did not yet contain this new taxonomic name. The file used as input for this `AMR` package contains the taxonomy updated until [`r CATALOGUE_OF_LIFE$yearmonth_LPSN`][catalogue_of_life()].
|
||||||
|
#'
|
||||||
|
#' ## Custom Rules
|
||||||
|
#'
|
||||||
|
#' Custom rules can be created using [custom_eucast_rules()], e.g.:
|
||||||
|
#'
|
||||||
|
#' ```
|
||||||
|
#' x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||||
|
#' AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
|
||||||
|
#'
|
||||||
|
#' eucast_rules(example_isolates, rules = "custom", custom_rules = x)
|
||||||
|
#' ```
|
||||||
#'
|
#'
|
||||||
#' The file containing all EUCAST rules is located here: <https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv>.
|
|
||||||
#'
|
#'
|
||||||
#' ## 'Other' Rules
|
#' ## 'Other' Rules
|
||||||
#'
|
#'
|
||||||
@@ -80,9 +93,9 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
|||||||
#' @section Antibiotics:
|
#' @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.
|
#' 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
|
#' @aliases EUCAST
|
||||||
#' @rdname eucast_rules
|
#' @rdname eucast_rules
|
||||||
#' @export
|
#' @export
|
||||||
@@ -149,19 +162,34 @@ eucast_rules <- function(x,
|
|||||||
version_expertrules = 3.2,
|
version_expertrules = 3.2,
|
||||||
ampc_cephalosporin_resistance = NA,
|
ampc_cephalosporin_resistance = NA,
|
||||||
only_rsi_columns = FALSE,
|
only_rsi_columns = FALSE,
|
||||||
|
custom_rules = NULL,
|
||||||
...) {
|
...) {
|
||||||
meet_criteria(x, allow_class = "data.frame")
|
meet_criteria(x, allow_class = "data.frame")
|
||||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, is_in = colnames(x), allow_NULL = TRUE)
|
meet_criteria(col_mo, allow_class = "character", has_length = 1, is_in = colnames(x), allow_NULL = TRUE)
|
||||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||||
meet_criteria(rules, allow_class = "character", has_length = c(1, 2, 3, 4), is_in = c("breakpoints", "expert", "other", "all"))
|
meet_criteria(rules, allow_class = "character", has_length = c(1, 2, 3, 4, 5), is_in = c("breakpoints", "expert", "other", "all", "custom"))
|
||||||
meet_criteria(verbose, allow_class = "logical", has_length = 1)
|
meet_criteria(verbose, allow_class = "logical", has_length = 1)
|
||||||
meet_criteria(version_breakpoints, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_BREAKPOINTS)))
|
meet_criteria(version_breakpoints, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_BREAKPOINTS)))
|
||||||
meet_criteria(version_expertrules, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_EXPERT_RULES)))
|
meet_criteria(version_expertrules, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_EXPERT_RULES)))
|
||||||
meet_criteria(ampc_cephalosporin_resistance, allow_class = c("logical", "character", "rsi"), has_length = 1, allow_NA = TRUE, allow_NULL = TRUE)
|
meet_criteria(ampc_cephalosporin_resistance, allow_class = c("logical", "character", "rsi"), has_length = 1, allow_NA = TRUE, allow_NULL = TRUE)
|
||||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||||
|
meet_criteria(custom_rules, allow_class = "custom_eucast_rules", allow_NULL = TRUE)
|
||||||
|
|
||||||
|
if ("custom" %in% rules & is.null(custom_rules)) {
|
||||||
|
warning_("No custom rules were set with the `custom_rules` argument",
|
||||||
|
call = FALSE,
|
||||||
|
immediate = TRUE)
|
||||||
|
rules <- rules[rules != "custom"]
|
||||||
|
if (length(rules) == 0) {
|
||||||
|
if (info == TRUE) {
|
||||||
|
message_("No other rules were set, returning original data", add_fn = font_red, as_note = FALSE)
|
||||||
|
}
|
||||||
|
return(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
x_deparsed <- deparse(substitute(x))
|
x_deparsed <- deparse(substitute(x))
|
||||||
if (length(x_deparsed) > 1 || !all(x_deparsed %like% "[a-z]+")) {
|
if (length(x_deparsed) > 1 || any(x_deparsed %unlike% "[a-z]+")) {
|
||||||
x_deparsed <- "your_data"
|
x_deparsed <- "your_data"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,8 +224,6 @@ eucast_rules <- function(x,
|
|||||||
if (is.null(col_mo)) {
|
if (is.null(col_mo)) {
|
||||||
col_mo <- search_type_in_df(x = x, type = "mo", info = info)
|
col_mo <- search_type_in_df(x = x, type = "mo", info = info)
|
||||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||||
} else {
|
|
||||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
decimal.mark <- getOption("OutDec")
|
decimal.mark <- getOption("OutDec")
|
||||||
@@ -214,7 +240,13 @@ eucast_rules <- function(x,
|
|||||||
cat(font_subtle(" (no changes)\n"))
|
cat(font_subtle(" (no changes)\n"))
|
||||||
} else {
|
} else {
|
||||||
# opening
|
# opening
|
||||||
|
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(" ("))
|
cat(font_grey(" ("))
|
||||||
|
}
|
||||||
# additions
|
# additions
|
||||||
if (n_added > 0) {
|
if (n_added > 0) {
|
||||||
if (n_added == 1) {
|
if (n_added == 1) {
|
||||||
@@ -236,8 +268,14 @@ eucast_rules <- function(x,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# closing
|
# closing
|
||||||
|
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"))
|
cat(font_grey(")\n"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
warned <<- FALSE
|
warned <<- FALSE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,237 +302,12 @@ eucast_rules <- function(x,
|
|||||||
only_rsi_columns = only_rsi_columns,
|
only_rsi_columns = only_rsi_columns,
|
||||||
...)
|
...)
|
||||||
|
|
||||||
AMC <- cols_ab["AMC"]
|
if (!"AMP" %in% names(cols_ab) & "AMX" %in% names(cols_ab)) {
|
||||||
AMK <- cols_ab["AMK"]
|
|
||||||
AMP <- cols_ab["AMP"]
|
|
||||||
AMX <- cols_ab["AMX"]
|
|
||||||
APL <- cols_ab["APL"]
|
|
||||||
APX <- cols_ab["APX"]
|
|
||||||
ATM <- cols_ab["ATM"]
|
|
||||||
AVB <- cols_ab["AVB"]
|
|
||||||
AVO <- cols_ab["AVO"]
|
|
||||||
AZD <- cols_ab["AZD"]
|
|
||||||
AZL <- cols_ab["AZL"]
|
|
||||||
AZM <- cols_ab["AZM"]
|
|
||||||
BAM <- cols_ab["BAM"]
|
|
||||||
BPR <- cols_ab["BPR"]
|
|
||||||
CAC <- cols_ab["CAC"]
|
|
||||||
CAT <- cols_ab["CAT"]
|
|
||||||
CAZ <- cols_ab["CAZ"]
|
|
||||||
CCP <- cols_ab["CCP"]
|
|
||||||
CCV <- cols_ab["CCV"]
|
|
||||||
CCX <- cols_ab["CCX"]
|
|
||||||
CDC <- cols_ab["CDC"]
|
|
||||||
CDR <- cols_ab["CDR"]
|
|
||||||
CDZ <- cols_ab["CDZ"]
|
|
||||||
CEC <- cols_ab["CEC"]
|
|
||||||
CED <- cols_ab["CED"]
|
|
||||||
CEI <- cols_ab["CEI"]
|
|
||||||
CEM <- cols_ab["CEM"]
|
|
||||||
CEP <- cols_ab["CEP"]
|
|
||||||
CFM <- cols_ab["CFM"]
|
|
||||||
CFM1 <- cols_ab["CFM1"]
|
|
||||||
CFP <- cols_ab["CFP"]
|
|
||||||
CFR <- cols_ab["CFR"]
|
|
||||||
CFS <- cols_ab["CFS"]
|
|
||||||
CFZ <- cols_ab["CFZ"]
|
|
||||||
CHE <- cols_ab["CHE"]
|
|
||||||
CHL <- cols_ab["CHL"]
|
|
||||||
CIC <- cols_ab["CIC"]
|
|
||||||
CID <- cols_ab["CID"]
|
|
||||||
CIP <- cols_ab["CIP"]
|
|
||||||
CLI <- cols_ab["CLI"]
|
|
||||||
CLM <- cols_ab["CLM"]
|
|
||||||
CLO <- cols_ab["CLO"]
|
|
||||||
CLR <- cols_ab["CLR"]
|
|
||||||
CMX <- cols_ab["CMX"]
|
|
||||||
CMZ <- cols_ab["CMZ"]
|
|
||||||
CND <- cols_ab["CND"]
|
|
||||||
COL <- cols_ab["COL"]
|
|
||||||
CPD <- cols_ab["CPD"]
|
|
||||||
CPI <- cols_ab["CPI"]
|
|
||||||
CPL <- cols_ab["CPL"]
|
|
||||||
CPM <- cols_ab["CPM"]
|
|
||||||
CPO <- cols_ab["CPO"]
|
|
||||||
CPR <- cols_ab["CPR"]
|
|
||||||
CPT <- cols_ab["CPT"]
|
|
||||||
CPX <- cols_ab["CPX"]
|
|
||||||
CRB <- cols_ab["CRB"]
|
|
||||||
CRD <- cols_ab["CRD"]
|
|
||||||
CRN <- cols_ab["CRN"]
|
|
||||||
CRO <- cols_ab["CRO"]
|
|
||||||
CSL <- cols_ab["CSL"]
|
|
||||||
CTB <- cols_ab["CTB"]
|
|
||||||
CTC <- cols_ab["CTC"]
|
|
||||||
CTF <- cols_ab["CTF"]
|
|
||||||
CTL <- cols_ab["CTL"]
|
|
||||||
CTS <- cols_ab["CTS"]
|
|
||||||
CTT <- cols_ab["CTT"]
|
|
||||||
CTX <- cols_ab["CTX"]
|
|
||||||
CTZ <- cols_ab["CTZ"]
|
|
||||||
CXM <- cols_ab["CXM"]
|
|
||||||
CYC <- cols_ab["CYC"]
|
|
||||||
CZA <- cols_ab["CZA"]
|
|
||||||
CZD <- cols_ab["CZD"]
|
|
||||||
CZO <- cols_ab["CZO"]
|
|
||||||
CZP <- cols_ab["CZP"]
|
|
||||||
CZX <- cols_ab["CZX"]
|
|
||||||
DAL <- cols_ab["DAL"]
|
|
||||||
DAP <- cols_ab["DAP"]
|
|
||||||
DIC <- cols_ab["DIC"]
|
|
||||||
DIR <- cols_ab["DIR"]
|
|
||||||
DIT <- cols_ab["DIT"]
|
|
||||||
DIX <- cols_ab["DIX"]
|
|
||||||
DIZ <- cols_ab["DIZ"]
|
|
||||||
DKB <- cols_ab["DKB"]
|
|
||||||
DOR <- cols_ab["DOR"]
|
|
||||||
DOX <- cols_ab["DOX"]
|
|
||||||
ENX <- cols_ab["ENX"]
|
|
||||||
EPC <- cols_ab["EPC"]
|
|
||||||
ERY <- cols_ab["ERY"]
|
|
||||||
ETP <- cols_ab["ETP"]
|
|
||||||
FEP <- cols_ab["FEP"]
|
|
||||||
FLC <- cols_ab["FLC"]
|
|
||||||
FLE <- cols_ab["FLE"]
|
|
||||||
FLR1 <- cols_ab["FLR1"]
|
|
||||||
FOS <- cols_ab["FOS"]
|
|
||||||
FOV <- cols_ab["FOV"]
|
|
||||||
FOX <- cols_ab["FOX"]
|
|
||||||
FOX1 <- cols_ab["FOX1"]
|
|
||||||
FUS <- cols_ab["FUS"]
|
|
||||||
GAT <- cols_ab["GAT"]
|
|
||||||
GEM <- cols_ab["GEM"]
|
|
||||||
GEN <- cols_ab["GEN"]
|
|
||||||
GRX <- cols_ab["GRX"]
|
|
||||||
HAP <- cols_ab["HAP"]
|
|
||||||
HET <- cols_ab["HET"]
|
|
||||||
IPM <- cols_ab["IPM"]
|
|
||||||
ISE <- cols_ab["ISE"]
|
|
||||||
JOS <- cols_ab["JOS"]
|
|
||||||
KAN <- cols_ab["KAN"]
|
|
||||||
LEN <- cols_ab["LEN"]
|
|
||||||
LEX <- cols_ab["LEX"]
|
|
||||||
LIN <- cols_ab["LIN"]
|
|
||||||
LNZ <- cols_ab["LNZ"]
|
|
||||||
LOM <- cols_ab["LOM"]
|
|
||||||
LOR <- cols_ab["LOR"]
|
|
||||||
LTM <- cols_ab["LTM"]
|
|
||||||
LVX <- cols_ab["LVX"]
|
|
||||||
MAN <- cols_ab["MAN"]
|
|
||||||
MCM <- cols_ab["MCM"]
|
|
||||||
MEC <- cols_ab["MEC"]
|
|
||||||
MEM <- cols_ab["MEM"]
|
|
||||||
MET <- cols_ab["MET"]
|
|
||||||
MEV <- cols_ab["MEV"]
|
|
||||||
MEZ <- cols_ab["MEZ"]
|
|
||||||
MFX <- cols_ab["MFX"]
|
|
||||||
MID <- cols_ab["MID"]
|
|
||||||
MNO <- cols_ab["MNO"]
|
|
||||||
MTM <- cols_ab["MTM"]
|
|
||||||
NAC <- cols_ab["NAC"]
|
|
||||||
NAF <- cols_ab["NAF"]
|
|
||||||
NAL <- cols_ab["NAL"]
|
|
||||||
NEO <- cols_ab["NEO"]
|
|
||||||
NET <- cols_ab["NET"]
|
|
||||||
NIT <- cols_ab["NIT"]
|
|
||||||
NOR <- cols_ab["NOR"]
|
|
||||||
NOV <- cols_ab["NOV"]
|
|
||||||
NVA <- cols_ab["NVA"]
|
|
||||||
OFX <- cols_ab["OFX"]
|
|
||||||
OLE <- cols_ab["OLE"]
|
|
||||||
ORI <- cols_ab["ORI"]
|
|
||||||
OXA <- cols_ab["OXA"]
|
|
||||||
PAZ <- cols_ab["PAZ"]
|
|
||||||
PEF <- cols_ab["PEF"]
|
|
||||||
PEN <- cols_ab["PEN"]
|
|
||||||
PHE <- cols_ab["PHE"]
|
|
||||||
PHN <- cols_ab["PHN"]
|
|
||||||
PIP <- cols_ab["PIP"]
|
|
||||||
PLB <- cols_ab["PLB"]
|
|
||||||
PME <- cols_ab["PME"]
|
|
||||||
PNM <- cols_ab["PNM"]
|
|
||||||
PRC <- cols_ab["PRC"]
|
|
||||||
PRI <- cols_ab["PRI"]
|
|
||||||
PRL <- cols_ab["PRL"]
|
|
||||||
PRP <- cols_ab["PRP"]
|
|
||||||
PRU <- cols_ab["PRU"]
|
|
||||||
PVM <- cols_ab["PVM"]
|
|
||||||
QDA <- cols_ab["QDA"]
|
|
||||||
RAM <- cols_ab["RAM"]
|
|
||||||
RFL <- cols_ab["RFL"]
|
|
||||||
RID <- cols_ab["RID"]
|
|
||||||
RIF <- cols_ab["RIF"]
|
|
||||||
ROK <- cols_ab["ROK"]
|
|
||||||
RST <- cols_ab["RST"]
|
|
||||||
RXT <- cols_ab["RXT"]
|
|
||||||
SAM <- cols_ab["SAM"]
|
|
||||||
SBC <- cols_ab["SBC"]
|
|
||||||
SDI <- cols_ab["SDI"]
|
|
||||||
SDM <- cols_ab["SDM"]
|
|
||||||
SIS <- cols_ab["SIS"]
|
|
||||||
SLF <- cols_ab["SLF"]
|
|
||||||
SLF1 <- cols_ab["SLF1"]
|
|
||||||
SLF10 <- cols_ab["SLF10"]
|
|
||||||
SLF11 <- cols_ab["SLF11"]
|
|
||||||
SLF12 <- cols_ab["SLF12"]
|
|
||||||
SLF13 <- cols_ab["SLF13"]
|
|
||||||
SLF2 <- cols_ab["SLF2"]
|
|
||||||
SLF3 <- cols_ab["SLF3"]
|
|
||||||
SLF4 <- cols_ab["SLF4"]
|
|
||||||
SLF5 <- cols_ab["SLF5"]
|
|
||||||
SLF6 <- cols_ab["SLF6"]
|
|
||||||
SLF7 <- cols_ab["SLF7"]
|
|
||||||
SLF8 <- cols_ab["SLF8"]
|
|
||||||
SLF9 <- cols_ab["SLF9"]
|
|
||||||
SLT1 <- cols_ab["SLT1"]
|
|
||||||
SLT2 <- cols_ab["SLT2"]
|
|
||||||
SLT3 <- cols_ab["SLT3"]
|
|
||||||
SLT4 <- cols_ab["SLT4"]
|
|
||||||
SLT5 <- cols_ab["SLT5"]
|
|
||||||
SLT6 <- cols_ab["SLT6"]
|
|
||||||
SMX <- cols_ab["SMX"]
|
|
||||||
SPI <- cols_ab["SPI"]
|
|
||||||
SPX <- cols_ab["SPX"]
|
|
||||||
SRX <- cols_ab["SRX"]
|
|
||||||
STR <- cols_ab["STR"]
|
|
||||||
STR1 <- cols_ab["STR1"]
|
|
||||||
SUD <- cols_ab["SUD"]
|
|
||||||
SUL <- cols_ab["SUL"]
|
|
||||||
SUT <- cols_ab["SUT"]
|
|
||||||
SXT <- cols_ab["SXT"]
|
|
||||||
SZO <- cols_ab["SZO"]
|
|
||||||
TAL <- cols_ab["TAL"]
|
|
||||||
TAZ <- cols_ab["TAZ"]
|
|
||||||
TCC <- cols_ab["TCC"]
|
|
||||||
TCM <- cols_ab["TCM"]
|
|
||||||
TCY <- cols_ab["TCY"]
|
|
||||||
TEC <- cols_ab["TEC"]
|
|
||||||
TEM <- cols_ab["TEM"]
|
|
||||||
TGC <- cols_ab["TGC"]
|
|
||||||
THA <- cols_ab["THA"]
|
|
||||||
TIC <- cols_ab["TIC"]
|
|
||||||
TIO <- cols_ab["TIO"]
|
|
||||||
TLT <- cols_ab["TLT"]
|
|
||||||
TLV <- cols_ab["TLV"]
|
|
||||||
TMP <- cols_ab["TMP"]
|
|
||||||
TMX <- cols_ab["TMX"]
|
|
||||||
TOB <- cols_ab["TOB"]
|
|
||||||
TRL <- cols_ab["TRL"]
|
|
||||||
TVA <- cols_ab["TVA"]
|
|
||||||
TZD <- cols_ab["TZD"]
|
|
||||||
TZP <- cols_ab["TZP"]
|
|
||||||
VAN <- cols_ab["VAN"]
|
|
||||||
|
|
||||||
ab_missing <- function(ab) {
|
|
||||||
all(ab %in% c(NULL, NA))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ab_missing(AMP) & !ab_missing(AMX)) {
|
|
||||||
# ampicillin column is missing, but amoxicillin is available
|
# ampicillin column is missing, but amoxicillin is available
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message_("Using column '", font_bold(AMX), "' as input for ampicillin since many EUCAST rules depend on it.")
|
message_("Using column '", cols_ab[names(cols_ab) == "AMX"], "' as input for ampicillin since many EUCAST rules depend on it.")
|
||||||
}
|
}
|
||||||
AMP <- AMX
|
cols_ab <- c(cols_ab, c(AMP = unname(cols_ab[names(cols_ab) == "AMX"])))
|
||||||
}
|
}
|
||||||
|
|
||||||
# data preparation ----
|
# data preparation ----
|
||||||
@@ -502,62 +315,37 @@ eucast_rules <- function(x,
|
|||||||
message_("Preparing data...", appendLF = FALSE, as_note = FALSE)
|
message_("Preparing data...", appendLF = FALSE, as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
# nolint start
|
|
||||||
# antibiotic classes ----
|
|
||||||
aminoglycosides <- c(AMK, DKB, GEN, ISE, KAN, NEO, NET, RST, SIS, STR, STR1, TOB)
|
|
||||||
aminopenicillins <- c(AMP, AMX)
|
|
||||||
carbapenems <- c(DOR, ETP, IPM, MEM, MEV)
|
|
||||||
cephalosporins <- c(CDZ, CCP, CAC, CEC, CFR, RID, MAN, CTZ, CZD, CZO, CDR, DIT, FEP, CAT, CFM, CMX, CMZ, DIZ, CID, CFP, CSL, CND, CTX, CTT, CTF, FOX, CPM, CPO, CPD, CPR, CRD, CFS, CPT, CAZ, CCV, CTL, CTB, CZX, BPR, CFM1, CEI, CRO, CXM, LEX, CEP, HAP, CED, LTM, LOR)
|
|
||||||
cephalosporins_1st <- c(CAC, CFR, RID, CTZ, CZD, CZO, CRD, CTL, LEX, CEP, HAP, CED)
|
|
||||||
cephalosporins_2nd <- c(CEC, MAN, CMZ, CID, CND, CTT, CTF, FOX, CPR, CXM, LOR)
|
|
||||||
cephalosporins_3rd <- c(CDZ, CCP, CCX, CDR, DIT, DIX, CAT, CPI, CFM, CMX, DIZ, CFP, CSL, CTX, CTC, CTS, CHE, FOV, CFZ, CPM, CPD, CPX, CDC, CFS, CAZ, CZA, CCV, CEM, CPL, CTB, TIO, CZX, CZP, CRO, LTM)
|
|
||||||
cephalosporins_except_CAZ <- cephalosporins[cephalosporins != ifelse(is.null(CAZ), "", CAZ)]
|
|
||||||
fluoroquinolones <- c(CIP, ENX, FLE, GAT, GEM, GRX, LVX, LOM, MFX, NOR, OFX, PAZ, PEF, PRU, RFL, SPX, TMX, TVA)
|
|
||||||
glycopeptides <- c(AVO, NVA, RAM, TEC, TCM, VAN) # dalba/orita/tela are in lipoglycopeptides
|
|
||||||
lincosamides <- c(CLI, LIN, PRL)
|
|
||||||
lipoglycopeptides <- c(DAL, ORI, TLV)
|
|
||||||
macrolides <- c(AZM, CLR, DIR, ERY, FLR1, JOS, MID, MCM, OLE, ROK, RXT, SPI, TLT, TRL)
|
|
||||||
oxazolidinones <- c(CYC, LNZ, THA, TZD)
|
|
||||||
polymyxins <- c(PLB, COL)
|
|
||||||
streptogramins <- c(QDA, PRI)
|
|
||||||
tetracyclines <- c(DOX, MNO, TCY) # since EUCAST v3.1 tigecycline (TGC) is set apart
|
|
||||||
ureidopenicillins <- c(PIP, TZP, AZL, MEZ)
|
|
||||||
all_betalactams <- c(aminopenicillins, cephalosporins, carbapenems, ureidopenicillins, AMC, OXA, FLC, PEN)
|
|
||||||
# nolint end
|
|
||||||
|
|
||||||
# Some helper functions ---------------------------------------------------
|
# Some helper functions ---------------------------------------------------
|
||||||
get_antibiotic_columns <- function(x, df) {
|
get_antibiotic_columns <- function(x, cols_ab) {
|
||||||
x <- trimws(unlist(strsplit(x, ",", fixed = TRUE)))
|
x <- trimws(unique(toupper(unlist(strsplit(x, ",")))))
|
||||||
y <- character(0)
|
x_new <- character()
|
||||||
for (i in seq_len(length(x))) {
|
for (val in x) {
|
||||||
if (is.function(get(x[i]))) {
|
if (val %in% ls(envir = asNamespace("AMR"))) {
|
||||||
stop("Column ", x[i], " is also a function. Please create an issue on github.com/msberends/AMR/issues.")
|
# 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 {
|
||||||
|
stop_("unknown antimicrobial agent (group) in EUCAST rules file: ", val, call = FALSE)
|
||||||
}
|
}
|
||||||
y <- c(y, tryCatch(get(x[i]), error = function(e) ""))
|
x_new <- c(x_new, val)
|
||||||
}
|
}
|
||||||
y[y != "" & y %in% colnames(df)]
|
x_new <- unique(x_new)
|
||||||
}
|
out <- cols_ab[match(x_new, names(cols_ab))]
|
||||||
markup_italics_where_needed <- function(x) {
|
out[!is.na(out)]
|
||||||
# returns names found in family, genus or species as italics
|
|
||||||
if (!has_colour()) {
|
|
||||||
return(x)
|
|
||||||
}
|
|
||||||
x <- unlist(strsplit(x, " "))
|
|
||||||
ind <- gsub("[)(:]", "", x) %in% c(MO_lookup[which(MO_lookup$rank %in% c("family", "genus")), ]$fullname,
|
|
||||||
MO_lookup[which(MO_lookup$rank == "species"), ]$species)
|
|
||||||
x[ind] <- font_italic(x[ind], collapse = NULL)
|
|
||||||
paste(x, collapse = " ")
|
|
||||||
}
|
}
|
||||||
get_antibiotic_names <- function(x) {
|
get_antibiotic_names <- function(x) {
|
||||||
x <- x %pm>%
|
x <- x %pm>%
|
||||||
strsplit(",") %pm>%
|
strsplit(",") %pm>%
|
||||||
unlist() %pm>%
|
unlist() %pm>%
|
||||||
trimws() %pm>%
|
trimws() %pm>%
|
||||||
vapply(FUN.VALUE = character(1), function(x) if (x %in% antibiotics$ab) ab_name(x, language = NULL, tolower = TRUE) else x) %pm>%
|
vapply(FUN.VALUE = character(1), function(x) if (x %in% antibiotics$ab) ab_name(x, language = NULL, tolower = TRUE, fast_mode = TRUE) else x) %pm>%
|
||||||
sort() %pm>%
|
sort() %pm>%
|
||||||
paste(collapse = ", ")
|
paste(collapse = ", ")
|
||||||
x <- gsub("_", " ", x, fixed = TRUE)
|
x <- gsub("_", " ", x, fixed = TRUE)
|
||||||
x <- gsub("except CAZ", paste("except", ab_name("CAZ", language = NULL, tolower = TRUE)), x, fixed = TRUE)
|
x <- gsub("except CAZ", paste("except", ab_name("CAZ", language = NULL, tolower = TRUE)), x, fixed = TRUE)
|
||||||
|
x <- gsub("except TGC", paste("except", ab_name("TGC", language = NULL, tolower = TRUE)), x, fixed = TRUE)
|
||||||
x <- gsub("cephalosporins (1st|2nd|3rd|4th|5th)", "cephalosporins (\\1 gen.)", x)
|
x <- gsub("cephalosporins (1st|2nd|3rd|4th|5th)", "cephalosporins (\\1 gen.)", x)
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
@@ -633,10 +421,13 @@ eucast_rules <- function(x,
|
|||||||
pm_distinct(`.rowid`, .keep_all = TRUE) %pm>%
|
pm_distinct(`.rowid`, .keep_all = TRUE) %pm>%
|
||||||
as.data.frame(stringsAsFactors = FALSE)
|
as.data.frame(stringsAsFactors = FALSE)
|
||||||
x[, col_mo] <- as.mo(as.character(x[, col_mo, drop = TRUE]))
|
x[, col_mo] <- as.mo(as.character(x[, col_mo, drop = TRUE]))
|
||||||
x <- x %pm>%
|
# rename col_mo to prevent interference with joined columns
|
||||||
left_join_microorganisms(by = col_mo, suffix = c("_oldcols", ""))
|
colnames(x)[colnames(x) == col_mo] <- ".col_mo"
|
||||||
|
col_mo <- ".col_mo"
|
||||||
|
# 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$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) {
|
if (info == TRUE & NROW(x) > 10000) {
|
||||||
message_(" OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
message_(" OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||||
}
|
}
|
||||||
@@ -662,33 +453,47 @@ eucast_rules <- function(x,
|
|||||||
font_red(paste0("v", utils::packageDescription("AMR")$Version, ", ",
|
font_red(paste0("v", utils::packageDescription("AMR")$Version, ", ",
|
||||||
format(as.Date(utils::packageDescription("AMR")$Date), format = "%Y"))), "), see ?eucast_rules\n"))))
|
format(as.Date(utils::packageDescription("AMR")$Date), format = "%Y"))), "), see ?eucast_rules\n"))))
|
||||||
}
|
}
|
||||||
|
|
||||||
ab_enzyme <- subset(antibiotics, name %like% "/")[, c("ab", "name")]
|
ab_enzyme <- subset(antibiotics, name %like% "/")[, c("ab", "name")]
|
||||||
ab_enzyme$base_name <- gsub("^([a-zA-Z0-9]+).*", "\\1", ab_enzyme$name)
|
colnames(ab_enzyme) <- c("enzyme_ab", "enzyme_name")
|
||||||
ab_enzyme$base_ab <- as.ab(ab_enzyme$base_name)
|
ab_enzyme$base_name <- gsub("^([a-zA-Z0-9]+).*", "\\1", ab_enzyme$enzyme_name)
|
||||||
|
ab_enzyme$base_ab <- antibiotics[match(ab_enzyme$base_name, antibiotics$name), "ab", drop = TRUE]
|
||||||
|
ab_enzyme <- subset(ab_enzyme, !is.na(base_ab))
|
||||||
|
# make ampicillin and amoxicillin interchangable
|
||||||
|
ampi <- subset(ab_enzyme, base_ab == "AMX")
|
||||||
|
ampi$base_ab <- "AMP"
|
||||||
|
ampi$base_name <- ab_name("AMP", language = NULL)
|
||||||
|
amox <- subset(ab_enzyme, base_ab == "AMP")
|
||||||
|
amox$base_ab <- "AMX"
|
||||||
|
amox$base_name <- ab_name("AMX", language = NULL)
|
||||||
|
# merge and sort
|
||||||
|
ab_enzyme <- rbind(ab_enzyme, ampi, amox)
|
||||||
|
ab_enzyme <- ab_enzyme[order(ab_enzyme$enzyme_name), ]
|
||||||
|
|
||||||
for (i in seq_len(nrow(ab_enzyme))) {
|
for (i in seq_len(nrow(ab_enzyme))) {
|
||||||
if (all(c(ab_enzyme[i, ]$ab, ab_enzyme[i, ]$base_ab) %in% names(cols_ab), na.rm = TRUE)) {
|
# check if both base and base + enzyme inhibitor are part of the data set
|
||||||
ab_name_base <- ab_name(cols_ab[ab_enzyme[i, ]$base_ab], language = NULL, tolower = TRUE)
|
if (all(c(ab_enzyme$base_ab[i], ab_enzyme$enzyme_ab[i]) %in% names(cols_ab), na.rm = TRUE)) {
|
||||||
ab_name_enzyme <- ab_name(cols_ab[ab_enzyme[i, ]$ab], language = NULL, tolower = TRUE)
|
col_base <- unname(cols_ab[ab_enzyme$base_ab[i]])
|
||||||
|
col_enzyme <- unname(cols_ab[ab_enzyme$enzyme_ab[i]])
|
||||||
|
|
||||||
# Set base to R where base + enzyme inhibitor is R ----
|
# Set base to R where base + enzyme inhibitor is R ----
|
||||||
rule_current <- paste0("Set ", ab_name_base, " (", cols_ab[ab_enzyme[i, ]$base_ab], ") = R where ",
|
rule_current <- paste0(ab_enzyme$base_name[i], " ('", font_bold(col_base), "') = R if ",
|
||||||
ab_name_enzyme, " (", cols_ab[ab_enzyme[i, ]$ab], ") = R")
|
tolower(ab_enzyme$enzyme_name[i]), " ('", font_bold(col_enzyme), "') = R")
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
cat(word_wrap(rule_current))
|
cat(word_wrap(rule_current,
|
||||||
cat("\n")
|
width = getOption("width") - 30,
|
||||||
|
extra_indent = 6))
|
||||||
}
|
}
|
||||||
run_changes <- edit_rsi(x = x,
|
run_changes <- edit_rsi(x = x,
|
||||||
col_mo = col_mo,
|
|
||||||
to = "R",
|
to = "R",
|
||||||
rule = c(rule_current, "Other rules", "",
|
rule = c(rule_current, "Other rules", "",
|
||||||
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)),
|
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)),
|
||||||
rows = which(as.rsi_no_warning(x[, cols_ab[ab_enzyme[i, ]$ab]]) == "R"),
|
rows = which(as.rsi_no_warning(x[, col_enzyme, drop = TRUE]) == "R"),
|
||||||
cols = cols_ab[ab_enzyme[i, ]$base_ab],
|
cols = col_base,
|
||||||
last_verbose_info = verbose_info,
|
last_verbose_info = verbose_info,
|
||||||
original_data = x.bak,
|
original_data = x.bak,
|
||||||
warned = warned,
|
warned = warned,
|
||||||
info = info)
|
info = info,
|
||||||
|
verbose = verbose)
|
||||||
n_added <- n_added + run_changes$added
|
n_added <- n_added + run_changes$added
|
||||||
n_changed <- n_changed + run_changes$changed
|
n_changed <- n_changed + run_changes$changed
|
||||||
verbose_info <- run_changes$verbose_info
|
verbose_info <- run_changes$verbose_info
|
||||||
@@ -704,23 +509,25 @@ eucast_rules <- function(x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Set base + enzyme inhibitor to S where base is S ----
|
# Set base + enzyme inhibitor to S where base is S ----
|
||||||
rule_current <- paste0("Set ", ab_name_enzyme, " (", cols_ab[ab_enzyme[i, ]$ab], ") = S where ",
|
rule_current <- paste0(ab_enzyme$enzyme_name[i], " ('", font_bold(col_enzyme), "') = S if ",
|
||||||
ab_name_base, " (", cols_ab[ab_enzyme[i, ]$base_ab], ") = S")
|
tolower(ab_enzyme$base_name[i]), " ('", font_bold(col_base), "') = S")
|
||||||
|
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
cat(word_wrap(rule_current))
|
cat(word_wrap(rule_current,
|
||||||
cat("\n")
|
width = getOption("width") - 30,
|
||||||
|
extra_indent = 6))
|
||||||
}
|
}
|
||||||
run_changes <- edit_rsi(x = x,
|
run_changes <- edit_rsi(x = x,
|
||||||
col_mo = col_mo,
|
|
||||||
to = "S",
|
to = "S",
|
||||||
rule = c(rule_current, "Other rules", "",
|
rule = c(rule_current, "Other rules", "",
|
||||||
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)),
|
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)),
|
||||||
rows = which(as.rsi_no_warning(x[, cols_ab[ab_enzyme[i, ]$base_ab]]) == "S"),
|
rows = which(as.rsi_no_warning(x[, col_base, drop = TRUE]) == "S"),
|
||||||
cols = cols_ab[ab_enzyme[i, ]$ab],
|
cols = col_enzyme,
|
||||||
last_verbose_info = verbose_info,
|
last_verbose_info = verbose_info,
|
||||||
original_data = x.bak,
|
original_data = x.bak,
|
||||||
warned = warned,
|
warned = warned,
|
||||||
info = info)
|
info = info,
|
||||||
|
verbose = verbose)
|
||||||
n_added <- n_added + run_changes$added
|
n_added <- n_added + run_changes$added
|
||||||
n_changed <- n_changed + run_changes$changed
|
n_changed <- n_changed + run_changes$changed
|
||||||
verbose_info <- run_changes$verbose_info
|
verbose_info <- run_changes$verbose_info
|
||||||
@@ -740,10 +547,17 @@ eucast_rules <- function(x,
|
|||||||
} else {
|
} else {
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
cat("\n")
|
cat("\n")
|
||||||
message_("Skipping inheritance rules defined by this package, such as setting trimethoprim (TMP) = R where trimethoprim/sulfamethoxazole (SXT) = R. Use `eucast_rules(..., rules = \"all\")` to also apply those rules.")
|
message_("Skipping inheritance rules defined by this AMR package, such as setting trimethoprim (TMP) = R where trimethoprim/sulfamethoxazole (SXT) = R. Add \"other\" or \"all\" to the `rules` argument to apply those rules.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!any(c("all", "custom") %in% rules) & !is.null(custom_rules)) {
|
||||||
|
if (info == TRUE) {
|
||||||
|
message_("Skipping custom EUCAST rules, since the `rules` argument does not contain \"custom\".")
|
||||||
|
}
|
||||||
|
custom_rules <- NULL
|
||||||
|
}
|
||||||
|
|
||||||
# Official EUCAST rules ---------------------------------------------------
|
# Official EUCAST rules ---------------------------------------------------
|
||||||
eucast_notification_shown <- FALSE
|
eucast_notification_shown <- FALSE
|
||||||
if (!is.null(list(...)$eucast_rules_df)) {
|
if (!is.null(list(...)$eucast_rules_df)) {
|
||||||
@@ -757,19 +571,19 @@ eucast_rules <- function(x,
|
|||||||
# filter on user-set guideline versions ----
|
# filter on user-set guideline versions ----
|
||||||
if (any(c("all", "breakpoints") %in% rules)) {
|
if (any(c("all", "breakpoints") %in% rules)) {
|
||||||
eucast_rules_df <- subset(eucast_rules_df,
|
eucast_rules_df <- subset(eucast_rules_df,
|
||||||
!reference.rule_group %like% "breakpoint" |
|
reference.rule_group %unlike% "breakpoint" |
|
||||||
(reference.rule_group %like% "breakpoint" & reference.version == version_breakpoints))
|
(reference.rule_group %like% "breakpoint" & reference.version == version_breakpoints))
|
||||||
}
|
}
|
||||||
if (any(c("all", "expert") %in% rules)) {
|
if (any(c("all", "expert") %in% rules)) {
|
||||||
eucast_rules_df <- subset(eucast_rules_df,
|
eucast_rules_df <- subset(eucast_rules_df,
|
||||||
!reference.rule_group %like% "expert" |
|
reference.rule_group %unlike% "expert" |
|
||||||
(reference.rule_group %like% "expert" & reference.version == version_expertrules))
|
(reference.rule_group %like% "expert" & reference.version == version_expertrules))
|
||||||
}
|
}
|
||||||
# filter out AmpC de-repressed cephalosporin-resistant mutants ----
|
# filter out AmpC de-repressed cephalosporin-resistant mutants ----
|
||||||
# cefotaxime, ceftriaxone, ceftazidime
|
# cefotaxime, ceftriaxone, ceftazidime
|
||||||
if (is.null(ampc_cephalosporin_resistance) || isFALSE(ampc_cephalosporin_resistance)) {
|
if (is.null(ampc_cephalosporin_resistance) || isFALSE(ampc_cephalosporin_resistance)) {
|
||||||
eucast_rules_df <- subset(eucast_rules_df,
|
eucast_rules_df <- subset(eucast_rules_df,
|
||||||
!reference.rule %like% "ampc")
|
reference.rule %unlike% "ampc")
|
||||||
} else {
|
} else {
|
||||||
if (isTRUE(ampc_cephalosporin_resistance)) {
|
if (isTRUE(ampc_cephalosporin_resistance)) {
|
||||||
ampc_cephalosporin_resistance <- "R"
|
ampc_cephalosporin_resistance <- "R"
|
||||||
@@ -777,6 +591,7 @@ eucast_rules <- function(x,
|
|||||||
eucast_rules_df[which(eucast_rules_df$reference.rule %like% "ampc"), "to_value"] <- as.character(ampc_cephalosporin_resistance)
|
eucast_rules_df[which(eucast_rules_df$reference.rule %like% "ampc"), "to_value"] <- as.character(ampc_cephalosporin_resistance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Go over all rules and apply them ----
|
||||||
for (i in seq_len(nrow(eucast_rules_df))) {
|
for (i in seq_len(nrow(eucast_rules_df))) {
|
||||||
|
|
||||||
rule_previous <- eucast_rules_df[max(1, i - 1), "reference.rule", drop = TRUE]
|
rule_previous <- eucast_rules_df[max(1, i - 1), "reference.rule", drop = TRUE]
|
||||||
@@ -784,6 +599,14 @@ eucast_rules <- function(x,
|
|||||||
rule_next <- eucast_rules_df[min(nrow(eucast_rules_df), i + 1), "reference.rule", drop = TRUE]
|
rule_next <- eucast_rules_df[min(nrow(eucast_rules_df), i + 1), "reference.rule", drop = TRUE]
|
||||||
rule_group_previous <- eucast_rules_df[max(1, i - 1), "reference.rule_group", drop = TRUE]
|
rule_group_previous <- eucast_rules_df[max(1, i - 1), "reference.rule_group", drop = TRUE]
|
||||||
rule_group_current <- eucast_rules_df[i, "reference.rule_group", drop = TRUE]
|
rule_group_current <- eucast_rules_df[i, "reference.rule_group", drop = TRUE]
|
||||||
|
# don't apply rules if user doesn't want to apply them
|
||||||
|
if (rule_group_current %like% "breakpoint" & !any(c("all", "breakpoints") %in% rules)) {
|
||||||
|
next
|
||||||
|
}
|
||||||
|
if (rule_group_current %like% "expert" & !any(c("all", "expert") %in% rules)) {
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
if (isFALSE(info) | isFALSE(verbose)) {
|
if (isFALSE(info) | isFALSE(verbose)) {
|
||||||
rule_text <- ""
|
rule_text <- ""
|
||||||
} else {
|
} else {
|
||||||
@@ -804,17 +627,9 @@ eucast_rules <- function(x,
|
|||||||
rule_next <- ""
|
rule_next <- ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# don't apply rules if user doesn't want to apply them
|
|
||||||
if (rule_group_current %like% "breakpoint" & !any(c("all", "breakpoints") %in% rules)) {
|
|
||||||
next
|
|
||||||
}
|
|
||||||
if (rule_group_current %like% "expert" & !any(c("all", "expert") %in% rules)) {
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
# Print EUCAST intro ------------------------------------------------------
|
# Print EUCAST intro ------------------------------------------------------
|
||||||
if (!rule_group_current %like% "other" & eucast_notification_shown == FALSE) {
|
if (rule_group_current %unlike% "other" & eucast_notification_shown == FALSE) {
|
||||||
cat(
|
cat(
|
||||||
paste0("\n", font_grey(strrep("-", 0.95 * options()$width)), "\n",
|
paste0("\n", font_grey(strrep("-", 0.95 * options()$width)), "\n",
|
||||||
word_wrap("Rules by the ", font_bold("European Committee on Antimicrobial Susceptibility Testing (EUCAST)")), "\n",
|
word_wrap("Rules by the ", font_bold("European Committee on Antimicrobial Susceptibility Testing (EUCAST)")), "\n",
|
||||||
@@ -843,9 +658,10 @@ eucast_rules <- function(x,
|
|||||||
# Print rule -------------------------------------------------------------
|
# Print rule -------------------------------------------------------------
|
||||||
if (rule_current != rule_previous) {
|
if (rule_current != rule_previous) {
|
||||||
# is new rule within group, print its name
|
# is new rule within group, print its name
|
||||||
cat(markup_italics_where_needed(word_wrap(rule_current,
|
cat(italicise_taxonomy(word_wrap(rule_current,
|
||||||
width = getOption("width") - 30,
|
width = getOption("width") - 30,
|
||||||
extra_indent = 6)))
|
extra_indent = 6),
|
||||||
|
type = "ansi"))
|
||||||
warned <- FALSE
|
warned <- FALSE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -904,7 +720,7 @@ eucast_rules <- function(x,
|
|||||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value),
|
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value),
|
||||||
error = function(e) integer(0))
|
error = function(e) integer(0))
|
||||||
} else {
|
} else {
|
||||||
source_antibiotics <- get_antibiotic_columns(source_antibiotics, x)
|
source_antibiotics <- get_antibiotic_columns(source_antibiotics, cols_ab)
|
||||||
if (length(source_value) == 1 & length(source_antibiotics) > 1) {
|
if (length(source_value) == 1 & length(source_antibiotics) > 1) {
|
||||||
source_value <- rep(source_value, length(source_antibiotics))
|
source_value <- rep(source_value, length(source_antibiotics))
|
||||||
}
|
}
|
||||||
@@ -932,12 +748,11 @@ eucast_rules <- function(x,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cols <- get_antibiotic_columns(target_antibiotics, x)
|
cols <- get_antibiotic_columns(target_antibiotics, cols_ab)
|
||||||
|
|
||||||
# Apply rule on data ------------------------------------------------------
|
# Apply rule on data ------------------------------------------------------
|
||||||
# this will return the unique number of changes
|
# this will return the unique number of changes
|
||||||
run_changes <- edit_rsi(x = x,
|
run_changes <- edit_rsi(x = x,
|
||||||
col_mo = col_mo,
|
|
||||||
to = target_value,
|
to = target_value,
|
||||||
rule = c(rule_text, rule_group_current, rule_current,
|
rule = c(rule_text, rule_group_current, rule_current,
|
||||||
ifelse(rule_group_current %like% "breakpoint",
|
ifelse(rule_group_current %like% "breakpoint",
|
||||||
@@ -948,7 +763,8 @@ eucast_rules <- function(x,
|
|||||||
last_verbose_info = verbose_info,
|
last_verbose_info = verbose_info,
|
||||||
original_data = x.bak,
|
original_data = x.bak,
|
||||||
warned = warned,
|
warned = warned,
|
||||||
info = info)
|
info = info,
|
||||||
|
verbose = verbose)
|
||||||
n_added <- n_added + run_changes$added
|
n_added <- n_added + run_changes$added
|
||||||
n_changed <- n_changed + run_changes$changed
|
n_changed <- n_changed + run_changes$changed
|
||||||
verbose_info <- run_changes$verbose_info
|
verbose_info <- run_changes$verbose_info
|
||||||
@@ -962,6 +778,61 @@ eucast_rules <- function(x,
|
|||||||
n_added <- 0
|
n_added <- 0
|
||||||
n_changed <- 0
|
n_changed <- 0
|
||||||
}
|
}
|
||||||
|
} # end of going over all rules
|
||||||
|
|
||||||
|
# Apply custom rules ----
|
||||||
|
if (!is.null(custom_rules)) {
|
||||||
|
if (info == TRUE) {
|
||||||
|
cat("\n")
|
||||||
|
cat(font_bold("Custom EUCAST rules, set by user"), "\n")
|
||||||
|
}
|
||||||
|
for (i in seq_len(length(custom_rules))) {
|
||||||
|
rule <- custom_rules[[i]]
|
||||||
|
rows <- which(eval(parse(text = rule$query), envir = x))
|
||||||
|
cols <- as.character(rule$result_group)
|
||||||
|
cols <- c(cols[cols %in% colnames(x)], # direct column names
|
||||||
|
unname(cols_ab[names(cols_ab) %in% cols])) # based on previous cols_ab finding
|
||||||
|
cols <- unique(cols)
|
||||||
|
target_value <- as.character(rule$result_value)
|
||||||
|
rule_text <- paste0("report as '", target_value, "' when ",
|
||||||
|
format_custom_query_rule(rule$query, colours = FALSE), ": ",
|
||||||
|
get_antibiotic_names(cols))
|
||||||
|
if (info == TRUE) {
|
||||||
|
# print rule
|
||||||
|
cat(italicise_taxonomy(word_wrap(format_custom_query_rule(rule$query, colours = FALSE),
|
||||||
|
width = getOption("width") - 30,
|
||||||
|
extra_indent = 6),
|
||||||
|
type = "ansi"))
|
||||||
|
warned <- FALSE
|
||||||
|
}
|
||||||
|
run_changes <- edit_rsi(x = x,
|
||||||
|
to = target_value,
|
||||||
|
rule = c(rule_text,
|
||||||
|
"Custom EUCAST rules",
|
||||||
|
paste0("Custom EUCAST rule ", i),
|
||||||
|
paste0("Object '", deparse(substitute(custom_rules)),
|
||||||
|
"' consisting of ", length(custom_rules), " custom rules")),
|
||||||
|
rows = rows,
|
||||||
|
cols = cols,
|
||||||
|
last_verbose_info = verbose_info,
|
||||||
|
original_data = x.bak,
|
||||||
|
warned = warned,
|
||||||
|
info = info,
|
||||||
|
verbose = verbose)
|
||||||
|
n_added <- n_added + run_changes$added
|
||||||
|
n_changed <- n_changed + run_changes$changed
|
||||||
|
verbose_info <- run_changes$verbose_info
|
||||||
|
x <- run_changes$output
|
||||||
|
warn_lacking_rsi_class <- c(warn_lacking_rsi_class, run_changes$rsi_warn)
|
||||||
|
# Print number of new changes ---------------------------------------------
|
||||||
|
if (info == TRUE & rule_next != rule_current) {
|
||||||
|
# print only on last one of rules in this group
|
||||||
|
txt_ok(n_added = n_added, n_changed = n_changed, warned = warned)
|
||||||
|
# and reset counters
|
||||||
|
n_added <- 0
|
||||||
|
n_changed <- 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print overview ----------------------------------------------------------
|
# Print overview ----------------------------------------------------------
|
||||||
@@ -1053,13 +924,15 @@ eucast_rules <- function(x,
|
|||||||
|
|
||||||
if (length(warn_lacking_rsi_class) > 0) {
|
if (length(warn_lacking_rsi_class) > 0) {
|
||||||
warn_lacking_rsi_class <- unique(warn_lacking_rsi_class)
|
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",
|
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, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
||||||
" ", x_deparsed, " %>% mutate(across((is.rsi.eligible), as.rsi))\n",
|
|
||||||
" ", x_deparsed, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
|
||||||
warn_lacking_rsi_class,
|
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)
|
call = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1081,7 +954,6 @@ eucast_rules <- function(x,
|
|||||||
|
|
||||||
# helper function for editing the table ----
|
# helper function for editing the table ----
|
||||||
edit_rsi <- function(x,
|
edit_rsi <- function(x,
|
||||||
col_mo,
|
|
||||||
to,
|
to,
|
||||||
rule,
|
rule,
|
||||||
rows,
|
rows,
|
||||||
@@ -1089,7 +961,8 @@ edit_rsi <- function(x,
|
|||||||
last_verbose_info,
|
last_verbose_info,
|
||||||
original_data,
|
original_data,
|
||||||
warned,
|
warned,
|
||||||
info) {
|
info,
|
||||||
|
verbose) {
|
||||||
cols <- unique(cols[!is.na(cols) & !is.null(cols)])
|
cols <- unique(cols[!is.na(cols) & !is.null(cols)])
|
||||||
|
|
||||||
# for Verbose Mode, keep track of all changes and return them
|
# for Verbose Mode, keep track of all changes and return them
|
||||||
@@ -1104,7 +977,7 @@ edit_rsi <- function(x,
|
|||||||
}
|
}
|
||||||
txt_warning <- function() {
|
txt_warning <- function() {
|
||||||
if (warned == FALSE) {
|
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
|
warned <<- TRUE
|
||||||
}
|
}
|
||||||
@@ -1125,13 +998,15 @@ edit_rsi <- function(x,
|
|||||||
TRUE
|
TRUE
|
||||||
})
|
})
|
||||||
suppressWarnings(new_edits[rows, cols] <<- to)
|
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()
|
txt_warning()
|
||||||
warned <- FALSE
|
warned <- FALSE
|
||||||
} else {
|
} else {
|
||||||
warning_(w$message, call = FALSE)
|
warning_(w$message, call = FALSE)
|
||||||
txt_warning()
|
txt_warning()
|
||||||
cat("\n") # txt_warning() does not append a "\n" on itself
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
@@ -1146,7 +1021,7 @@ edit_rsi <- function(x,
|
|||||||
)
|
)
|
||||||
|
|
||||||
track_changes$output <- new_edits
|
track_changes$output <- new_edits
|
||||||
if (isTRUE(info) && !isTRUE(all.equal(x, track_changes$output))) {
|
if ((info == TRUE | verbose == TRUE) && !isTRUE(all.equal(x, track_changes$output))) {
|
||||||
get_original_rows <- function(rowids) {
|
get_original_rows <- function(rowids) {
|
||||||
as.integer(rownames(original_data[which(original_data$.rowid %in% rowids), , drop = FALSE]))
|
as.integer(rownames(original_data[which(original_data$.rowid %in% rowids), , drop = FALSE]))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 %like% "[0-9]$"), ]$name
|
|
||||||
paste0(sort(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE),
|
|
||||||
tolower = TRUE, language = NULL)),
|
|
||||||
collapse = ", ")
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#' Determine First (Weighted) Isolates
|
#' Determine First (Weighted) Isolates
|
||||||
#'
|
#'
|
||||||
#' Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use [is_new_episode()] that also supports grouping with the `dplyr` package.
|
#' Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. These functions support all four methods as summarised by Hindler *et al.* in 2007 (\doi{10.1086/511864}). To determine patient episodes not necessarily based on microorganisms, use [is_new_episode()] that also supports grouping with the `dplyr` package.
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x a [data.frame] containing isolates. Can be left blank for automatic determination, see *Examples*.
|
#' @param x a [data.frame] containing isolates. Can be left blank for automatic determination, see *Examples*.
|
||||||
#' @param col_date column name of the result date (or date that is was received on the lab), defaults to the first column with a date class
|
#' @param col_date column name of the result date (or date that is was received on the lab), defaults to the first column with a date class
|
||||||
@@ -34,74 +34,104 @@
|
|||||||
#' @param col_testcode column name of the test codes. Use `col_testcode = NULL` to **not** exclude certain test codes (such as test codes for screening). In that case `testcodes_exclude` will be ignored.
|
#' @param col_testcode column name of the test codes. Use `col_testcode = NULL` to **not** exclude certain test codes (such as test codes for screening). In that case `testcodes_exclude` will be ignored.
|
||||||
#' @param col_specimen column name of the specimen type or group
|
#' @param col_specimen column name of the specimen type or group
|
||||||
#' @param col_icu column name of the logicals (`TRUE`/`FALSE`) whether a ward or department is an Intensive Care Unit (ICU)
|
#' @param col_icu column name of the logicals (`TRUE`/`FALSE`) whether a ward or department is an Intensive Care Unit (ICU)
|
||||||
#' @param col_keyantibiotics column name of the key antibiotics to determine first (weighted) isolates, see [key_antibiotics()]. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' (case insensitive). Use `col_keyantibiotics = FALSE` to prevent this.
|
#' @param 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 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 testcodes_exclude a [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 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 specimen_group value in the column set with `col_specimen` to filter on
|
||||||
#' @param type type to determine weighed isolates; can be `"keyantibiotics"` or `"points"`, see *Details*
|
#' @param type type to determine weighed isolates; can be `"keyantimicrobials"` or `"points"`, see *Details*
|
||||||
#' @param ignore_I logical to indicate whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantibiotics"`, 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 points_threshold points until the comparison of key antibiotics will lead to inclusion of an isolate when `type = "points"`, see *Details*
|
#' @param ignore_I [logical] to indicate whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantimicrobials"`, see *Details*
|
||||||
#' @param info print progress
|
#' @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 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 info a [logical] to indicate info should be printed, defaults to `TRUE` only in interactive mode
|
||||||
#' @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 ... arguments passed on to [first_isolate()] when using [filter_first_isolate()], or arguments passed on to [key_antibiotics()] when using [filter_first_weighted_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
|
#' @details
|
||||||
#' These functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
#' 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 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.
|
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but more efficient for data sets containing microorganism codes or names.
|
||||||
#'
|
#'
|
||||||
#' All isolates with a microbial ID of `NA` will be excluded as first isolate.
|
#' All isolates with a microbial ID of `NA` will be excluded as first isolate.
|
||||||
#'
|
#'
|
||||||
#' ## Why this is so Important
|
#' ## Different methods
|
||||||
#' To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode [(Hindler *et al.* 2007)](https://pubmed.ncbi.nlm.nih.gov/17304462/). If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following week. The resistance percentage of oxacillin of all *S. aureus* isolates would be overestimated, because you included this MRSA more than once. It would be [selection bias](https://en.wikipedia.org/wiki/Selection_bias).
|
|
||||||
#'
|
#'
|
||||||
#' ## `filter_*()` Shortcuts
|
#' According to Hindler *et al.* (2007, \doi{10.1086/511864}), there are different methods (algorithms) to select first isolates with increasing reliability: isolate-based, patient-based, episode-based and phenotype-based. All methods select on a combination of the taxonomic genus and species (not subspecies).
|
||||||
#'
|
#'
|
||||||
#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates.
|
#' All mentioned methods are covered in the [first_isolate()] function:
|
||||||
#'
|
#'
|
||||||
#' The function [filter_first_isolate()] is essentially equal to either:
|
|
||||||
#'
|
#'
|
||||||
#' ```
|
#' | **Method** | **Function to apply** |
|
||||||
#' x[first_isolate(x, ...), ]
|
#' |--------------------------------------------------|-------------------------------------------------------|
|
||||||
|
#' | **Isolate-based** | `first_isolate(x, method = "isolate-based")` |
|
||||||
|
#' | *(= all isolates)* | |
|
||||||
|
#' | | |
|
||||||
|
#' | | |
|
||||||
|
#' | **Patient-based** | `first_isolate(x, method = "patient-based")` |
|
||||||
|
#' | *(= first isolate per patient)* | |
|
||||||
|
#' | | |
|
||||||
|
#' | | |
|
||||||
|
#' | **Episode-based** | `first_isolate(x, method = "episode-based")`, or: |
|
||||||
|
#' | *(= first isolate per episode)* | |
|
||||||
|
#' | - 7-Day interval from initial isolate | - `first_isolate(x, method = "e", episode_days = 7)` |
|
||||||
|
#' | - 30-Day interval from initial isolate | - `first_isolate(x, method = "e", episode_days = 30)` |
|
||||||
|
#' | | |
|
||||||
|
#' | | |
|
||||||
|
#' | **Phenotype-based** | `first_isolate(x, method = "phenotype-based")`, or: |
|
||||||
|
#' | *(= first isolate per phenotype)* | |
|
||||||
|
#' | - Major difference in any antimicrobial result | - `first_isolate(x, type = "points")` |
|
||||||
|
#' | - Any difference in key antimicrobial results | - `first_isolate(x, type = "keyantimicrobials")` |
|
||||||
#'
|
#'
|
||||||
#' x %>% filter(first_isolate(...))
|
#' ### Isolate-based
|
||||||
#' ```
|
|
||||||
#'
|
#'
|
||||||
#' The function [filter_first_weighted_isolate()] is essentially equal to:
|
#' This method does not require any selection, as all isolates should be included. It does, however, respect all arguments set in the [first_isolate()] function. For example, the default setting for `include_unknown` (`FALSE`) will omit selection of rows without a microbial ID.
|
||||||
#'
|
#'
|
||||||
#' ```
|
#' ### Patient-based
|
||||||
#' x %>%
|
|
||||||
#' mutate(keyab = key_antibiotics(.)) %>%
|
|
||||||
#' mutate(only_weighted_firsts = first_isolate(x,
|
|
||||||
#' col_keyantibiotics = "keyab", ...)) %>%
|
|
||||||
#' filter(only_weighted_firsts == TRUE) %>%
|
|
||||||
#' select(-only_weighted_firsts, -keyab)
|
|
||||||
#' ```
|
|
||||||
#' @section Key Antibiotics:
|
|
||||||
#' There are two ways to determine whether isolates can be included as first weighted isolates which will give generally the same results:
|
|
||||||
#'
|
#'
|
||||||
#' 1. Using `type = "keyantibiotics"` and argument `ignore_I`
|
#' To include every genus-species combination per patient once, set the `episode_days` to `Inf`. Although often inappropriate, this method makes sure that no duplicate isolates are selected from the same patient. In a large longitudinal data set, this could mean that isolates are *excluded* that were found years after the initial isolate.
|
||||||
#'
|
#'
|
||||||
#' Any difference from S to R (or vice versa) will (re)select an isolate as a first weighted isolate. With `ignore_I = FALSE`, also differences from I to S|R (or vice versa) will lead to this. This is a reliable method and 30-35 times faster than method 2. Read more about this in the [key_antibiotics()] function.
|
#' ### Episode-based
|
||||||
#'
|
#'
|
||||||
#' 2. Using `type = "points"` and argument `points_threshold`
|
#' To include every genus-species combination per patient episode once, set the `episode_days` to a sensible number of days. Depending on the type of analysis, this could be 14, 30, 60 or 365. Short episodes are common for analysing specific hospital or ward data, long episodes are common for analysing regional and national data.
|
||||||
#'
|
#'
|
||||||
#' A difference from I to S|R (or vice versa) means 0.5 points, a difference from S to R (or vice versa) means 1 point. When the sum of points exceeds `points_threshold`, which defaults to `2`, an isolate will be (re)selected as a first weighted isolate.
|
#' This is the most common method to correct for duplicate isolates. Patients are categorised into episodes based on their ID and dates (e.g., the date of specimen receipt or laboratory result). While this is a common method, it does not take into account antimicrobial test results. This means that e.g. a methicillin-resistant *Staphylococcus aureus* (MRSA) isolate cannot be differentiated from a wildtype *Staphylococcus aureus* isolate.
|
||||||
|
#'
|
||||||
|
#' ### Phenotype-based
|
||||||
|
#'
|
||||||
|
#' This is a more reliable method, since it also *weighs* the antibiogram (antimicrobial test results) yielding so-called 'first weighted isolates'. There are two different methods to weigh the antibiogram:
|
||||||
|
#'
|
||||||
|
#' 1. Using `type = "points"` and argument `points_threshold`
|
||||||
|
#'
|
||||||
|
#' This method weighs *all* antimicrobial agents available in the data set. Any difference from I to S or R (or vice versa) counts as 0.5 points, a difference from S to R (or vice versa) counts as 1 point. When the sum of points exceeds `points_threshold`, which defaults to `2`, an isolate will be selected as a first weighted isolate.
|
||||||
|
#'
|
||||||
|
#' All antimicrobials are internally selected using the [all_antimicrobials()] function. The output of this function does not need to be passed to the [first_isolate()] function.
|
||||||
|
#'
|
||||||
|
#'
|
||||||
|
#' 2. Using `type = "keyantimicrobials"` and argument `ignore_I`
|
||||||
|
#'
|
||||||
|
#' This method only weighs specific antimicrobial agents, called *key antimicrobials*. Any difference from S to R (or vice versa) in these key antimicrobials will select an isolate as a first weighted isolate. With `ignore_I = FALSE`, also differences from I to S or R (or vice versa) will lead to this.
|
||||||
|
#'
|
||||||
|
#' Key antimicrobials are internally selected using the [key_antimicrobials()] function, but can also be added manually as a variable to the data and set in the `col_keyantimicrobials` argument. Another option is to pass the output of the [key_antimicrobials()] function directly to the `col_keyantimicrobials` argument.
|
||||||
|
#'
|
||||||
|
#'
|
||||||
|
#' The default method is phenotype-based (using `type = "points"`) and episode-based (using `episode_days = 365`). This makes sure that every genus-species combination is selected per patient once per year, while taking into account all antimicrobial test results. If no antimicrobial test results are available in the data set, only the episode-based method is applied at default.
|
||||||
#' @rdname first_isolate
|
#' @rdname first_isolate
|
||||||
#' @seealso [key_antibiotics()]
|
#' @seealso [key_antimicrobials()]
|
||||||
#' @export
|
#' @export
|
||||||
#' @return A [`logical`] vector
|
#' @return A [`logical`] vector
|
||||||
#' @source Methodology of this function is strictly based on:
|
#' @source Methodology of this function is strictly based on:
|
||||||
#'
|
#'
|
||||||
#' **M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition**, 2014, *Clinical and Laboratory Standards Institute (CLSI)*. <https://clsi.org/standards/products/microbiology/documents/m39/>.
|
#' - **M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition**, 2014, *Clinical and Laboratory Standards Institute (CLSI)*. <https://clsi.org/standards/products/microbiology/documents/m39/>.
|
||||||
|
#'
|
||||||
|
#' - Hindler JF and Stelling J (2007). **Analysis and Presentation of Cumulative Antibiograms: A New Consensus Guideline from the Clinical and Laboratory Standards Institute.** Clinical Infectious Diseases, 44(6), 867–873. \doi{10.1086/511864}
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @examples
|
#' @examples
|
||||||
#' # `example_isolates` is a data set available in the AMR package.
|
#' # `example_isolates` is a data set available in the AMR package.
|
||||||
#' # See ?example_isolates.
|
#' # See ?example_isolates.
|
||||||
#'
|
#'
|
||||||
#' example_isolates[first_isolate(example_isolates), ]
|
#' example_isolates[first_isolate(example_isolates), ]
|
||||||
#'
|
|
||||||
#' \donttest{
|
#' \donttest{
|
||||||
#' # faster way, only works in R 3.2 and later:
|
#' # faster way, only works in R 3.2 and later:
|
||||||
#' example_isolates[first_isolate(), ]
|
#' example_isolates[first_isolate(), ]
|
||||||
@@ -114,11 +144,9 @@
|
|||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' filter(first_isolate())
|
#' filter(first_isolate())
|
||||||
#'
|
#'
|
||||||
#' # short-hand versions:
|
#' # short-hand version:
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' filter_first_isolate()
|
#' filter_first_isolate()
|
||||||
#' example_isolates %>%
|
|
||||||
#' filter_first_weighted_isolate()
|
|
||||||
#'
|
#'
|
||||||
#' # grouped determination of first isolates (also prints group names):
|
#' # grouped determination of first isolates (also prints group names):
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
@@ -132,14 +160,14 @@
|
|||||||
#' resistance = resistance(GEN)) # gentamicin resistance
|
#' resistance = resistance(GEN)) # gentamicin resistance
|
||||||
#'
|
#'
|
||||||
#' B <- example_isolates %>%
|
#' B <- example_isolates %>%
|
||||||
#' filter_first_weighted_isolate() %>% # the 1st isolate filter
|
#' filter_first_isolate() %>% # the 1st isolate filter
|
||||||
#' group_by(hospital_id) %>%
|
#' group_by(hospital_id) %>%
|
||||||
#' summarise(count = n_rsi(GEN), # gentamicin availability
|
#' summarise(count = n_rsi(GEN), # gentamicin availability
|
||||||
#' resistance = resistance(GEN)) # gentamicin resistance
|
#' resistance = resistance(GEN)) # gentamicin resistance
|
||||||
#'
|
#'
|
||||||
#' # Have a look at A and B.
|
#' # Have a look at A and B.
|
||||||
#' # B is more reliable because every isolate is counted only once.
|
#' # B is more reliable because every isolate is counted only once.
|
||||||
#' # Gentamicin resistance in hospital D appears to be 3.7% higher than
|
#' # Gentamicin resistance in hospital D appears to be 4.2% higher than
|
||||||
#' # when you (erroneously) would have used all isolates for analysis.
|
#' # when you (erroneously) would have used all isolates for analysis.
|
||||||
#' }
|
#' }
|
||||||
#' }
|
#' }
|
||||||
@@ -150,18 +178,32 @@ first_isolate <- function(x = NULL,
|
|||||||
col_testcode = NULL,
|
col_testcode = NULL,
|
||||||
col_specimen = NULL,
|
col_specimen = NULL,
|
||||||
col_icu = NULL,
|
col_icu = NULL,
|
||||||
col_keyantibiotics = NULL,
|
col_keyantimicrobials = NULL,
|
||||||
episode_days = 365,
|
episode_days = 365,
|
||||||
testcodes_exclude = NULL,
|
testcodes_exclude = NULL,
|
||||||
icu_exclude = FALSE,
|
icu_exclude = FALSE,
|
||||||
specimen_group = NULL,
|
specimen_group = NULL,
|
||||||
type = "keyantibiotics",
|
type = "points",
|
||||||
|
method = c("phenotype-based", "episode-based", "patient-based", "isolate-based"),
|
||||||
ignore_I = TRUE,
|
ignore_I = TRUE,
|
||||||
points_threshold = 2,
|
points_threshold = 2,
|
||||||
info = interactive(),
|
info = interactive(),
|
||||||
include_unknown = FALSE,
|
include_unknown = FALSE,
|
||||||
include_untested_rsi = TRUE,
|
include_untested_rsi = TRUE,
|
||||||
...) {
|
...) {
|
||||||
|
|
||||||
|
dots <- unlist(list(...))
|
||||||
|
if (length(dots) != 0) {
|
||||||
|
# backwards compatibility with old arguments
|
||||||
|
dots.names <- names(dots)
|
||||||
|
if ("filter_specimen" %in% dots.names) {
|
||||||
|
specimen_group <- dots[which(dots.names == "filter_specimen")]
|
||||||
|
}
|
||||||
|
if ("col_keyantibiotics" %in% dots.names) {
|
||||||
|
col_keyantimicrobials <- dots[which(dots.names == "col_keyantibiotics")]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (is_null_or_grouped_tbl(x)) {
|
if (is_null_or_grouped_tbl(x)) {
|
||||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
# 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)
|
# is also fix for using a grouped df as input (a dot as first argument)
|
||||||
@@ -177,11 +219,25 @@ first_isolate <- function(x = NULL,
|
|||||||
}
|
}
|
||||||
meet_criteria(col_specimen, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
meet_criteria(col_specimen, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
meet_criteria(col_icu, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
meet_criteria(col_icu, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
if (isFALSE(col_keyantibiotics)) {
|
# method
|
||||||
col_keyantibiotics <- NULL
|
method <- coerce_method(method)
|
||||||
|
meet_criteria(method, allow_class = "character", has_length = 1, is_in = c("phenotype-based", "episode-based", "patient-based", "isolate-based", "p", "e", "i"))
|
||||||
|
# key antimicrobials
|
||||||
|
if (length(col_keyantimicrobials) > 1) {
|
||||||
|
meet_criteria(col_keyantimicrobials, allow_class = "character", has_length = nrow(x))
|
||||||
|
x$keyabcol <- col_keyantimicrobials
|
||||||
|
col_keyantimicrobials <- "keyabcol"
|
||||||
|
} else {
|
||||||
|
if (isFALSE(col_keyantimicrobials)) {
|
||||||
|
col_keyantimicrobials <- NULL
|
||||||
|
# method cannot be phenotype-based anymore
|
||||||
|
if (method == "phenotype-based") {
|
||||||
|
method <- "episode-based"
|
||||||
}
|
}
|
||||||
meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
}
|
||||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
meet_criteria(col_keyantimicrobials, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
|
}
|
||||||
|
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||||
meet_criteria(testcodes_exclude, allow_class = "character", allow_NULL = TRUE)
|
meet_criteria(testcodes_exclude, allow_class = "character", allow_NULL = TRUE)
|
||||||
meet_criteria(icu_exclude, allow_class = "logical", has_length = 1)
|
meet_criteria(icu_exclude, allow_class = "logical", has_length = 1)
|
||||||
meet_criteria(specimen_group, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
meet_criteria(specimen_group, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||||
@@ -195,28 +251,66 @@ first_isolate <- function(x = NULL,
|
|||||||
# remove data.table, grouping from tibbles, etc.
|
# remove data.table, grouping from tibbles, etc.
|
||||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||||
|
|
||||||
dots <- unlist(list(...))
|
any_col_contains_rsi <- any(vapply(FUN.VALUE = logical(1),
|
||||||
if (length(dots) != 0) {
|
X = x,
|
||||||
# backwards compatibility with old arguments
|
FUN = function(x) any(as.character(x) %in% c("R", "S", "I"), na.rm = TRUE),
|
||||||
dots.names <- names(dots)
|
USE.NAMES = FALSE))
|
||||||
if ("filter_specimen" %in% dots.names) {
|
if (method == "phenotype-based" & !any_col_contains_rsi) {
|
||||||
specimen_group <- dots[which(dots.names == "filter_specimen")]
|
method <- "episode-based"
|
||||||
}
|
|
||||||
if ("tbl" %in% dots.names) {
|
|
||||||
x <- dots[which(dots.names == "tbl")]
|
|
||||||
}
|
}
|
||||||
|
if (info == TRUE & message_not_thrown_before("first_isolate.method")) {
|
||||||
|
message_(paste0("Determining first isolates using the '", font_bold(method), "' method",
|
||||||
|
ifelse(method %in% c("episode-based", "phenotype-based"),
|
||||||
|
ifelse(is.infinite(episode_days),
|
||||||
|
" without a specified episode length",
|
||||||
|
paste(" and an episode length of", episode_days, "days")),
|
||||||
|
"")),
|
||||||
|
as_note = FALSE,
|
||||||
|
add_fn = font_black)
|
||||||
|
remember_thrown_message("first_isolate.method")
|
||||||
}
|
}
|
||||||
|
|
||||||
# try to find columns based on type
|
# try to find columns based on type
|
||||||
# -- mo
|
# -- mo
|
||||||
if (is.null(col_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")
|
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# methods ----
|
||||||
|
if (method == "isolate-based") {
|
||||||
|
episode_days <- Inf
|
||||||
|
col_keyantimicrobials <- NULL
|
||||||
|
x$dummy_dates <- Sys.Date()
|
||||||
|
col_date <- "dummy_dates"
|
||||||
|
x$dummy_patients <- paste("dummy", seq_len(nrow(x))) # all 'patients' must be unique
|
||||||
|
col_patient_id <- "dummy_patients"
|
||||||
|
} else if (method == "patient-based") {
|
||||||
|
episode_days <- Inf
|
||||||
|
col_keyantimicrobials <- NULL
|
||||||
|
} else if (method == "episode-based") {
|
||||||
|
col_keyantimicrobials <- NULL
|
||||||
|
} else if (method == "phenotype-based") {
|
||||||
|
if (missing(type) & !is.null(col_keyantimicrobials)) {
|
||||||
|
# type = "points" is default, but not set explicitly, while col_keyantimicrobials is
|
||||||
|
type <- "keyantimicrobials"
|
||||||
|
}
|
||||||
|
if (type == "points") {
|
||||||
|
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 = "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, ...)
|
||||||
|
col_keyantimicrobials <- "keyantimicrobials"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# -- date
|
# -- date
|
||||||
if (is.null(col_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")
|
stop_if(is.null(col_date), "`col_date` must be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,19 +322,14 @@ first_isolate <- function(x = NULL,
|
|||||||
col_patient_id <- "patient_id"
|
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`")
|
message_("Using combined columns '", font_bold("First name"), "', '", font_bold("Last name"), "' and '", font_bold("Sex"), "' as input for `col_patient_id`")
|
||||||
} else {
|
} 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")
|
stop_if(is.null(col_patient_id), "`col_patient_id` must be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- key antibiotics
|
|
||||||
if (is.null(col_keyantibiotics)) {
|
|
||||||
col_keyantibiotics <- search_type_in_df(x = x, type = "keyantibiotics")
|
|
||||||
}
|
|
||||||
|
|
||||||
# -- specimen
|
# -- specimen
|
||||||
if (is.null(col_specimen) & !is.null(specimen_group)) {
|
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
|
# check if columns exist
|
||||||
@@ -256,7 +345,7 @@ first_isolate <- function(x = NULL,
|
|||||||
check_columns_existance(col_mo)
|
check_columns_existance(col_mo)
|
||||||
check_columns_existance(col_testcode)
|
check_columns_existance(col_testcode)
|
||||||
check_columns_existance(col_icu)
|
check_columns_existance(col_icu)
|
||||||
check_columns_existance(col_keyantibiotics)
|
check_columns_existance(col_keyantimicrobials)
|
||||||
|
|
||||||
# convert dates to Date
|
# convert dates to Date
|
||||||
dates <- as.Date(x[, col_date, drop = TRUE])
|
dates <- as.Date(x[, col_date, drop = TRUE])
|
||||||
@@ -274,10 +363,11 @@ first_isolate <- function(x = NULL,
|
|||||||
testcodes_exclude <- NULL
|
testcodes_exclude <- NULL
|
||||||
}
|
}
|
||||||
# remove testcodes
|
# remove testcodes
|
||||||
if (!is.null(testcodes_exclude) & info == TRUE) {
|
if (!is.null(testcodes_exclude) & info == TRUE & message_not_thrown_before("first_isolate.excludingtestcodes")) {
|
||||||
message_("[Criterion] Exclude test codes: ", toString(paste0("'", testcodes_exclude, "'")),
|
message_("Excluding test codes: ", toString(paste0("'", testcodes_exclude, "'")),
|
||||||
add_fn = font_black,
|
add_fn = font_black,
|
||||||
as_note = FALSE)
|
as_note = FALSE)
|
||||||
|
remember_thrown_message("first_isolate.excludingtestcodes")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is.null(col_specimen)) {
|
if (is.null(col_specimen)) {
|
||||||
@@ -287,14 +377,15 @@ first_isolate <- function(x = NULL,
|
|||||||
# filter on specimen group and keyantibiotics when they are filled in
|
# filter on specimen group and keyantibiotics when they are filled in
|
||||||
if (!is.null(specimen_group)) {
|
if (!is.null(specimen_group)) {
|
||||||
check_columns_existance(col_specimen, x)
|
check_columns_existance(col_specimen, x)
|
||||||
if (info == TRUE) {
|
if (info == TRUE & message_not_thrown_before("first_isolate.excludingspecimen")) {
|
||||||
message_("[Criterion] Exclude other than specimen group '", specimen_group, "'",
|
message_("Excluding other than specimen group '", specimen_group, "'",
|
||||||
add_fn = font_black,
|
add_fn = font_black,
|
||||||
as_note = FALSE)
|
as_note = FALSE)
|
||||||
|
remember_thrown_message("first_isolate.excludingspecimen")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is.null(col_keyantibiotics)) {
|
if (!is.null(col_keyantimicrobials)) {
|
||||||
x$newvar_key_ab <- x[, col_keyantibiotics, drop = TRUE]
|
x$newvar_key_ab <- x[, col_keyantimicrobials, drop = TRUE]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is.null(testcodes_exclude)) {
|
if (is.null(testcodes_exclude)) {
|
||||||
@@ -335,7 +426,7 @@ first_isolate <- function(x = NULL,
|
|||||||
}
|
}
|
||||||
if (row.start == row.end) {
|
if (row.start == row.end) {
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message_("=> Found ", font_bold("1 isolate"), ", as the data only contained 1 row",
|
message_("=> Found ", font_bold("1 first isolate"), ", as the data only contained 1 row",
|
||||||
add_fn = font_black,
|
add_fn = font_black,
|
||||||
as_note = FALSE)
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
@@ -343,8 +434,8 @@ 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 (length(c(row.start:row.end)) == pm_n_distinct(x[c(row.start:row.end), col_mo, drop = TRUE])) {
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message_("=> Found ", font_bold(paste(length(c(row.start:row.end)), "isolates")),
|
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,
|
add_fn = font_black,
|
||||||
as_note = FALSE)
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
@@ -363,40 +454,38 @@ first_isolate <- function(x = NULL,
|
|||||||
FALSE,
|
FALSE,
|
||||||
TRUE)
|
TRUE)
|
||||||
x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species)
|
x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species)
|
||||||
x$more_than_episode_ago <- unlist(lapply(unique(x$episode_group),
|
x$more_than_episode_ago <- unlist(lapply(split(x$newvar_date,
|
||||||
function(g,
|
x$episode_group),
|
||||||
df = x,
|
is_new_episode,
|
||||||
days = episode_days) {
|
episode_days = episode_days),
|
||||||
is_new_episode(x = df[which(df$episode_group == g), ]$newvar_date,
|
use.names = FALSE)
|
||||||
episode_days = days)
|
|
||||||
}))
|
|
||||||
|
|
||||||
weighted.notice <- ""
|
weighted.notice <- ""
|
||||||
if (!is.null(col_keyantibiotics)) {
|
if (!is.null(col_keyantimicrobials)) {
|
||||||
weighted.notice <- "weighted "
|
weighted.notice <- "weighted "
|
||||||
if (info == TRUE) {
|
if (info == TRUE & message_not_thrown_before("first_isolate.type")) {
|
||||||
if (type == "keyantibiotics") {
|
if (type == "keyantimicrobials") {
|
||||||
message_("[Criterion] Base inclusion on key antibiotics, ",
|
message_("Basing inclusion on key antimicrobials, ",
|
||||||
ifelse(ignore_I == FALSE, "not ", ""),
|
ifelse(ignore_I == FALSE, "not ", ""),
|
||||||
"ignoring I",
|
"ignoring I",
|
||||||
add_fn = font_black,
|
add_fn = font_black,
|
||||||
as_note = FALSE)
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
if (type == "points") {
|
if (type == "points") {
|
||||||
message_("[Criterion] Base inclusion on key antibiotics, using points threshold of "
|
message_("Basing inclusion on all antimicrobial results, using a points threshold of "
|
||||||
, points_threshold,
|
, points_threshold,
|
||||||
add_fn = font_black,
|
add_fn = font_black,
|
||||||
as_note = FALSE)
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
remember_thrown_message("first_isolate.type")
|
||||||
}
|
}
|
||||||
type_param <- type
|
type_param <- type
|
||||||
|
|
||||||
x$other_key_ab <- !key_antibiotics_equal(y = x$newvar_key_ab,
|
x$other_key_ab <- !antimicrobials_equal(y = x$newvar_key_ab,
|
||||||
z = pm_lag(x$newvar_key_ab),
|
z = pm_lag(x$newvar_key_ab),
|
||||||
type = type_param,
|
type = type_param,
|
||||||
ignore_I = ignore_I,
|
ignore_I = ignore_I,
|
||||||
points_threshold = points_threshold,
|
points_threshold = points_threshold)
|
||||||
info = info)
|
|
||||||
# with key antibiotics
|
# with key antibiotics
|
||||||
x$newvar_first_isolate <- pm_if_else(x$newvar_row_index_sorted >= row.start &
|
x$newvar_first_isolate <- pm_if_else(x$newvar_row_index_sorted >= row.start &
|
||||||
x$newvar_row_index_sorted <= row.end &
|
x$newvar_row_index_sorted <= row.end &
|
||||||
@@ -423,12 +512,12 @@ first_isolate <- function(x = NULL,
|
|||||||
}
|
}
|
||||||
if (!is.null(col_icu)) {
|
if (!is.null(col_icu)) {
|
||||||
if (icu_exclude == TRUE) {
|
if (icu_exclude == TRUE) {
|
||||||
message_("[Criterion] Exclude isolates from ICU.",
|
message_("Excluding isolates from ICU.",
|
||||||
add_fn = font_black,
|
add_fn = font_black,
|
||||||
as_note = FALSE)
|
as_note = FALSE)
|
||||||
x[which(as.logical(x[, col_icu, drop = TRUE])), "newvar_first_isolate"] <- FALSE
|
x[which(as.logical(x[, col_icu, drop = TRUE])), "newvar_first_isolate"] <- FALSE
|
||||||
} else {
|
} else {
|
||||||
message_("[Criterion] Include isolates from ICU.",
|
message_("Including isolates from ICU.",
|
||||||
add_fn = font_black,
|
add_fn = font_black,
|
||||||
as_note = FALSE)
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
@@ -453,7 +542,9 @@ first_isolate <- function(x = NULL,
|
|||||||
paste0('"', x, '"')
|
paste0('"', x, '"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
cat("\nGroup: ", paste0(names(group), " = ", group, collapse = ", "), "\n", sep = "")
|
message_("\nGroup: ", paste0(names(group), " = ", group, collapse = ", "), "\n",
|
||||||
|
as_note = FALSE,
|
||||||
|
add_fn = font_red)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -491,10 +582,10 @@ first_isolate <- function(x = NULL,
|
|||||||
n_found <- sum(x$newvar_first_isolate, na.rm = TRUE)
|
n_found <- sum(x$newvar_first_isolate, na.rm = TRUE)
|
||||||
p_found_total <- percentage(n_found / nrow(x[which(!is.na(x$newvar_mo)), , drop = FALSE]), digits = 1)
|
p_found_total <- percentage(n_found / nrow(x[which(!is.na(x$newvar_mo)), , drop = FALSE]), digits = 1)
|
||||||
p_found_scope <- percentage(n_found / scope.size, digits = 1)
|
p_found_scope <- percentage(n_found / scope.size, digits = 1)
|
||||||
if (!p_found_total %like% "[.]") {
|
if (p_found_total %unlike% "[.]") {
|
||||||
p_found_total <- gsub("%", ".0%", p_found_total, fixed = TRUE)
|
p_found_total <- gsub("%", ".0%", p_found_total, fixed = TRUE)
|
||||||
}
|
}
|
||||||
if (!p_found_scope %like% "[.]") {
|
if (p_found_scope %unlike% "[.]") {
|
||||||
p_found_scope <- gsub("%", ".0%", p_found_scope, fixed = TRUE)
|
p_found_scope <- gsub("%", ".0%", p_found_scope, fixed = TRUE)
|
||||||
}
|
}
|
||||||
# mark up number of found
|
# mark up number of found
|
||||||
@@ -502,11 +593,11 @@ first_isolate <- function(x = NULL,
|
|||||||
if (p_found_total != p_found_scope) {
|
if (p_found_total != p_found_scope) {
|
||||||
msg_txt <- paste0("=> Found ",
|
msg_txt <- paste0("=> Found ",
|
||||||
font_bold(paste0(n_found, " first ", weighted.notice, "isolates")),
|
font_bold(paste0(n_found, " first ", weighted.notice, "isolates")),
|
||||||
" (", p_found_scope, " within scope and ", p_found_total, " of total where a microbial ID was available)")
|
" (", method, ", ", p_found_scope, " within scope and ", p_found_total, " of total where a microbial ID was available)")
|
||||||
} else {
|
} else {
|
||||||
msg_txt <- paste0("=> Found ",
|
msg_txt <- paste0("=> Found ",
|
||||||
font_bold(paste0(n_found, " first ", weighted.notice, "isolates")),
|
font_bold(paste0(n_found, " first ", weighted.notice, "isolates")),
|
||||||
" (", p_found_total, " of total where a microbial ID was available)")
|
" (", method, ", ", p_found_total, " of total where a microbial ID was available)")
|
||||||
}
|
}
|
||||||
message_(msg_txt, add_fn = font_black, as_note = FALSE)
|
message_(msg_txt, add_fn = font_black, as_note = FALSE)
|
||||||
}
|
}
|
||||||
@@ -521,6 +612,8 @@ filter_first_isolate <- function(x = NULL,
|
|||||||
col_date = NULL,
|
col_date = NULL,
|
||||||
col_patient_id = NULL,
|
col_patient_id = NULL,
|
||||||
col_mo = NULL,
|
col_mo = NULL,
|
||||||
|
episode_days = 365,
|
||||||
|
method = c("phenotype-based", "episode-based", "patient-based", "isolate-based"),
|
||||||
...) {
|
...) {
|
||||||
if (is_null_or_grouped_tbl(x)) {
|
if (is_null_or_grouped_tbl(x)) {
|
||||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||||
@@ -531,47 +624,27 @@ filter_first_isolate <- function(x = NULL,
|
|||||||
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||||
|
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||||
|
method <- coerce_method(method)
|
||||||
|
meet_criteria(method, allow_class = "character", has_length = 1, is_in = c("phenotype-based", "episode-based", "patient-based", "isolate-based", "p", "e", "i"))
|
||||||
|
|
||||||
subset(x, first_isolate(x = x,
|
subset(x, first_isolate(x = x,
|
||||||
col_date = col_date,
|
col_date = col_date,
|
||||||
col_patient_id = col_patient_id,
|
col_patient_id = col_patient_id,
|
||||||
col_mo = col_mo,
|
col_mo = col_mo,
|
||||||
|
episode_days = episode_days,
|
||||||
|
method = method,
|
||||||
...))
|
...))
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname first_isolate
|
coerce_method <- function(method) {
|
||||||
#' @export
|
if (is.null(method)) {
|
||||||
filter_first_weighted_isolate <- function(x = NULL,
|
return(method)
|
||||||
col_date = NULL,
|
|
||||||
col_patient_id = NULL,
|
|
||||||
col_mo = NULL,
|
|
||||||
col_keyantibiotics = NULL,
|
|
||||||
...) {
|
|
||||||
if (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 <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
|
||||||
}
|
}
|
||||||
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
method <- tolower(as.character(method[1L]))
|
||||||
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
method[method %like% "^(p$|pheno)"] <- "phenotype-based"
|
||||||
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
method[method %like% "^(e$|episode)"] <- "episode-based"
|
||||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
method[method %like% "^patient"] <- "patient-based"
|
||||||
meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
method[method %like% "^(i$|iso)"] <- "isolate-based"
|
||||||
|
method
|
||||||
y <- x
|
|
||||||
if (is.null(col_keyantibiotics)) {
|
|
||||||
# first try to look for it
|
|
||||||
col_keyantibiotics <- search_type_in_df(x = x, type = "keyantibiotics")
|
|
||||||
# still NULL? Then create it since we are calling filter_first_WEIGHTED_isolate()
|
|
||||||
if (is.null(col_keyantibiotics)) {
|
|
||||||
y$keyab <- suppressMessages(key_antibiotics(x,
|
|
||||||
col_mo = col_mo,
|
|
||||||
...))
|
|
||||||
col_keyantibiotics <- "keyab"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
subset(x, first_isolate(x = y,
|
|
||||||
col_date = col_date,
|
|
||||||
col_patient_id = col_patient_id))
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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**).
|
#' [g.test()] performs chi-squared contingency table tests and goodness-of-fit tests, just like [chisq.test()] but is more reliable (1). A *G*-test can be used to see whether the number of observations in each category fits a theoretical expectation (called a ***G*-test of goodness-of-fit**), or to see whether the proportions of one variable are different for different values of the other variable (called a ***G*-test of independence**).
|
||||||
#' @inheritSection lifecycle Questioning Lifecycle
|
#' @inheritSection lifecycle Questioning Lifecycle
|
||||||
#' @inherit stats::chisq.test params return
|
#' @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.
|
#' The p-value is computed from the asymptotic chi-squared distribution of the test statistic.
|
||||||
#'
|
#'
|
||||||
|
|||||||
@@ -33,21 +33,21 @@
|
|||||||
#' @param labels_textsize the size of the text used for the labels
|
#' @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 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 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_prob statistical size of the ellipse in normal probability
|
||||||
#' @param ellipse_size the size of the ellipse line
|
#' @param ellipse_size the size of the ellipse line
|
||||||
#' @param ellipse_alpha the alpha (transparency) of the ellipse line
|
#' @param ellipse_alpha the alpha (transparency) of the ellipse line
|
||||||
#' @param points_size the size of the points
|
#' @param points_size the size of the points
|
||||||
#' @param points_alpha the alpha (transparency) 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_textsize the size of the text for variable names
|
||||||
#' @param arrows_colour the colour of the arrow and their text
|
#' @param arrows_colour the colour of the arrow and their text
|
||||||
#' @param arrows_size the size (thickness) of the arrow lines
|
#' @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_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 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 base_textsize the text size for all plot elements except the labels and arrows
|
||||||
#' @param ... Arguments passed on to functions
|
#' @param ... arguments passed on to functions
|
||||||
#' @source The [ggplot_pca()] function is based on the `ggbiplot()` function from the `ggbiplot` package by Vince Vu, as found on GitHub: <https://github.com/vqv/ggbiplot> (retrieved: 2 March 2020, their latest commit: [`7325e88`](https://github.com/vqv/ggbiplot/commit/7325e880485bea4c07465a0304c470608fffb5d9); 12 February 2015).
|
#' @source The [ggplot_pca()] function is based on the `ggbiplot()` function from the `ggbiplot` package by Vince Vu, as found on GitHub: <https://github.com/vqv/ggbiplot> (retrieved: 2 March 2020, their latest commit: [`7325e88`](https://github.com/vqv/ggbiplot/commit/7325e880485bea4c07465a0304c470608fffb5d9); 12 February 2015).
|
||||||
#'
|
#'
|
||||||
#' As per their GPL-2 licence that demands documentation of code changes, the changes made based on the source code were:
|
#' As per their GPL-2 licence that demands documentation of code changes, the changes made based on the source code were:
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
#' # See ?example_isolates.
|
#' # See ?example_isolates.
|
||||||
#'
|
#'
|
||||||
#' # See ?pca for more info about Principal Component Analysis (PCA).
|
#' # See ?pca for more info about Principal Component Analysis (PCA).
|
||||||
|
#' \donttest{
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' pca_model <- example_isolates %>%
|
#' pca_model <- example_isolates %>%
|
||||||
#' filter(mo_genus(mo) == "Staphylococcus") %>%
|
#' filter(mo_genus(mo) == "Staphylococcus") %>%
|
||||||
@@ -84,6 +85,7 @@
|
|||||||
#' labs(title = "Title here")
|
#' labs(title = "Title here")
|
||||||
#' }
|
#' }
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
ggplot_pca <- function(x,
|
ggplot_pca <- function(x,
|
||||||
choices = 1:2,
|
choices = 1:2,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
|
|||||||
@@ -31,8 +31,8 @@
|
|||||||
#' @param position position adjustment of bars, either `"fill"`, `"stack"` or `"dodge"`
|
#' @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 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 fill variable to categorise using the plots legend, either `"antibiotic"` (default) or `"interpretation"` or a grouping variable
|
||||||
#' @param breaks numeric vector of positions
|
#' @param breaks a [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 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
|
#' @param facet variable to split plots by, either `"interpretation"` (default) or `"antibiotic"` or a grouping variable
|
||||||
#' @inheritParams proportion
|
#' @inheritParams proportion
|
||||||
#' @param nrow (when using `facet`) number of rows
|
#' @param nrow (when using `facet`) number of rows
|
||||||
@@ -67,6 +67,7 @@
|
|||||||
#' @export
|
#' @export
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @examples
|
#' @examples
|
||||||
|
#' \donttest{
|
||||||
#' if (require("ggplot2") & require("dplyr")) {
|
#' if (require("ggplot2") & require("dplyr")) {
|
||||||
#'
|
#'
|
||||||
#' # get antimicrobial results for drugs against a UTI:
|
#' # get antimicrobial results for drugs against a UTI:
|
||||||
@@ -114,12 +115,10 @@
|
|||||||
#' ggplot() +
|
#' ggplot() +
|
||||||
#' geom_col(aes(x = x, y = y, fill = z)) +
|
#' geom_col(aes(x = x, y = y, fill = z)) +
|
||||||
#' scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R")
|
#' scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R")
|
||||||
#' }
|
|
||||||
#'
|
#'
|
||||||
#' \donttest{
|
|
||||||
#' # resistance of ciprofloxacine per age group
|
#' # resistance of ciprofloxacine per age group
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' mutate(first_isolate = first_isolate(.)) %>%
|
#' mutate(first_isolate = first_isolate()) %>%
|
||||||
#' filter(first_isolate == TRUE,
|
#' filter(first_isolate == TRUE,
|
||||||
#' mo == as.mo("E. coli")) %>%
|
#' mo == as.mo("E. coli")) %>%
|
||||||
#' # age_groups() is also a function in this AMR package:
|
#' # age_groups() is also a function in this AMR package:
|
||||||
@@ -145,6 +144,7 @@
|
|||||||
#' x.title = "Hospital",
|
#' x.title = "Hospital",
|
||||||
#' datalabels = FALSE)
|
#' datalabels = FALSE)
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
ggplot_rsi <- function(data,
|
ggplot_rsi <- function(data,
|
||||||
position = NULL,
|
position = NULL,
|
||||||
x = "antibiotic",
|
x = "antibiotic",
|
||||||
|
|||||||
@@ -60,12 +60,14 @@ CATALOGUE_OF_LIFE <- list(
|
|||||||
globalVariables(c(".rowid",
|
globalVariables(c(".rowid",
|
||||||
"ab",
|
"ab",
|
||||||
"ab_txt",
|
"ab_txt",
|
||||||
|
"affect_ab_name",
|
||||||
"affect_mo_name",
|
"affect_mo_name",
|
||||||
"angle",
|
"angle",
|
||||||
"antibiotic",
|
"antibiotic",
|
||||||
"antibiotics",
|
"antibiotics",
|
||||||
"atc_group1",
|
"atc_group1",
|
||||||
"atc_group2",
|
"atc_group2",
|
||||||
|
"base_ab",
|
||||||
"code",
|
"code",
|
||||||
"cols",
|
"cols",
|
||||||
"count",
|
"count",
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x a [data.frame]
|
#' @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 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 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 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.**
|
#' @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.
|
#' @return A column name of `x`, or `NULL` when no result is found.
|
||||||
#' @export
|
#' @export
|
||||||
@@ -102,13 +102,21 @@ get_column_abx <- function(x,
|
|||||||
verbose = FALSE,
|
verbose = FALSE,
|
||||||
info = TRUE,
|
info = TRUE,
|
||||||
only_rsi_columns = FALSE,
|
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(x, allow_class = "data.frame")
|
||||||
meet_criteria(soft_dependencies, allow_class = "character", allow_NULL = TRUE)
|
meet_criteria(soft_dependencies, allow_class = "character", allow_NULL = TRUE)
|
||||||
meet_criteria(hard_dependencies, allow_class = "character", allow_NULL = TRUE)
|
meet_criteria(hard_dependencies, allow_class = "character", allow_NULL = TRUE)
|
||||||
meet_criteria(verbose, allow_class = "logical", has_length = 1)
|
meet_criteria(verbose, allow_class = "logical", has_length = 1)
|
||||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||||
|
meet_criteria(sort, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message_("Auto-guessing columns suitable for analysis", appendLF = FALSE, as_note = FALSE)
|
message_("Auto-guessing columns suitable for analysis", appendLF = FALSE, as_note = FALSE)
|
||||||
@@ -182,15 +190,21 @@ get_column_abx <- function(x,
|
|||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message_("No columns found.")
|
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)
|
return(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
# sort on name
|
# sort on name
|
||||||
|
if (sort == TRUE) {
|
||||||
x <- x[order(names(x), x)]
|
x <- x[order(names(x), x)]
|
||||||
|
}
|
||||||
duplicates <- c(x[duplicated(x)], x[duplicated(names(x))])
|
duplicates <- c(x[duplicated(x)], x[duplicated(names(x))])
|
||||||
duplicates <- duplicates[unique(names(duplicates))]
|
duplicates <- duplicates[unique(names(duplicates))]
|
||||||
x <- c(x[!names(x) %in% names(duplicates)], duplicates)
|
x <- c(x[!names(x) %in% names(duplicates)], duplicates)
|
||||||
|
if (sort == TRUE) {
|
||||||
x <- x[order(names(x), x)]
|
x <- x[order(names(x), x)]
|
||||||
|
}
|
||||||
|
|
||||||
# succeeded with auto-guessing
|
# succeeded with auto-guessing
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
@@ -233,6 +247,9 @@ get_column_abx <- function(x,
|
|||||||
missing_msg)
|
missing_msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pkg_env$get_column_abx.call <- unique_call_id(entire_session = FALSE)
|
||||||
|
pkg_env$get_column_abx.out <- x
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
132
R/italicise_taxonomy.R
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
# ==================================================================== #
|
||||||
|
# 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/ #
|
||||||
|
# ==================================================================== #
|
||||||
|
|
||||||
|
#' Italicise Taxonomic Families, Genera, Species, Subspecies
|
||||||
|
#'
|
||||||
|
#' 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 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.
|
||||||
|
#'
|
||||||
|
#' The taxonomic names can be italicised using markdown (the default) by adding `*` before and after the taxonomic names, or using ANSI colours by adding `\033[3m` before and `\033[23m` after the taxonomic names. If multiple ANSI colours are not available, no conversion will occur.
|
||||||
|
#'
|
||||||
|
#' This function also supports abbreviation of the genus if it is followed by a species, such as "E. coli" and "K. pneumoniae ozaenae".
|
||||||
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
|
#' @export
|
||||||
|
#' @examples
|
||||||
|
#' italicise_taxonomy("An overview of Staphylococcus aureus isolates")
|
||||||
|
#' 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"
|
||||||
|
}
|
||||||
|
meet_criteria(string, allow_class = "character")
|
||||||
|
meet_criteria(type, allow_class = "character", has_length = 1, is_in = c("markdown", "ansi"))
|
||||||
|
|
||||||
|
if (type == "markdown") {
|
||||||
|
before <- "*"
|
||||||
|
after <- "*"
|
||||||
|
} else if (type == "ansi") {
|
||||||
|
if (!has_colour()) {
|
||||||
|
return(string)
|
||||||
|
}
|
||||||
|
before <- "\033[3m"
|
||||||
|
after <- "\033[23m"
|
||||||
|
}
|
||||||
|
|
||||||
|
vapply(FUN.VALUE = character(1),
|
||||||
|
string,
|
||||||
|
function(s) {
|
||||||
|
s_split <- unlist(strsplit(s, " "))
|
||||||
|
|
||||||
|
search_strings <- gsub("[^a-zA-Z-]", "", s_split)
|
||||||
|
|
||||||
|
ind_species <- search_strings != "" &
|
||||||
|
search_strings %in% MO_lookup[which(MO_lookup$rank %in% c("family",
|
||||||
|
"genus",
|
||||||
|
"species",
|
||||||
|
"subspecies",
|
||||||
|
"infraspecies",
|
||||||
|
"subsp.")),
|
||||||
|
"species",
|
||||||
|
drop = TRUE]
|
||||||
|
|
||||||
|
ind_fullname <- search_strings != "" &
|
||||||
|
search_strings %in% c(MO_lookup[which(MO_lookup$rank %in% c("family",
|
||||||
|
"genus",
|
||||||
|
"species",
|
||||||
|
"subspecies",
|
||||||
|
"infraspecies",
|
||||||
|
"subsp.")),
|
||||||
|
"fullname",
|
||||||
|
drop = TRUE],
|
||||||
|
MO_lookup[which(MO_lookup$rank %in% c("family",
|
||||||
|
"genus",
|
||||||
|
"species",
|
||||||
|
"subspecies",
|
||||||
|
"infraspecies",
|
||||||
|
"subsp.")),
|
||||||
|
"subspecies",
|
||||||
|
drop = TRUE])
|
||||||
|
|
||||||
|
# also support E. coli, add "E." to indices
|
||||||
|
has_previous_genera_abbr <- s_split[which(ind_species) - 1] %like_case% "^[A-Z][.]?$"
|
||||||
|
ind_species <- c(which(ind_species), which(ind_species)[has_previous_genera_abbr] - 1)
|
||||||
|
|
||||||
|
ind <- c(ind_species, which(ind_fullname))
|
||||||
|
|
||||||
|
s_split[ind] <- paste0(before, s_split[ind], after)
|
||||||
|
s_paste <- paste(s_split, collapse = " ")
|
||||||
|
|
||||||
|
# clean up a bit
|
||||||
|
s_paste <- gsub(paste0(after, " ", before), " ", s_paste, fixed = TRUE)
|
||||||
|
|
||||||
|
s_paste
|
||||||
|
},
|
||||||
|
USE.NAMES = FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @rdname italicise_taxonomy
|
||||||
|
#' @export
|
||||||
|
italicize_taxonomy <- function(string, type = c("markdown", "ansi")) {
|
||||||
|
if (missing(type)) {
|
||||||
|
type <- "markdown"
|
||||||
|
}
|
||||||
|
italicise_taxonomy(string = string, type = type)
|
||||||
|
}
|
||||||
@@ -25,23 +25,24 @@
|
|||||||
|
|
||||||
#' Join [microorganisms] to a Data Set
|
#' Join [microorganisms] to a Data Set
|
||||||
#'
|
#'
|
||||||
#' Join the data set [microorganisms] easily to an existing table or character vector.
|
#' Join the data set [microorganisms] easily to an existing data set or to a [character] vector.
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
#' @name join
|
#' @name join
|
||||||
#' @aliases join inner_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 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
|
#' @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.
|
#' @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!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
|
#' @return a [data.frame]
|
||||||
#' @export
|
#' @export
|
||||||
#' @examples
|
#' @examples
|
||||||
#' left_join_microorganisms(as.mo("K. pneumoniae"))
|
#' left_join_microorganisms(as.mo("K. pneumoniae"))
|
||||||
#' left_join_microorganisms("B_KLBSL_PNE")
|
#' left_join_microorganisms("B_KLBSL_PNMN")
|
||||||
#'
|
#'
|
||||||
#' \donttest{
|
#' \donttest{
|
||||||
#' if (require("dplyr")) {
|
#' 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(by, allow_class = "character", allow_NULL = TRUE)
|
||||||
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
||||||
|
|
||||||
check_dataset_integrity()
|
join_microorganisms(type = "inner_join", x = x, by = by, suffix = suffix, ...)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname join
|
#' @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(by, allow_class = "character", allow_NULL = TRUE)
|
||||||
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
||||||
|
|
||||||
check_dataset_integrity()
|
join_microorganisms(type = "left_join", x = x, by = by, suffix = suffix, ...)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname join
|
#' @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(by, allow_class = "character", allow_NULL = TRUE)
|
||||||
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
||||||
|
|
||||||
check_dataset_integrity()
|
join_microorganisms(type = "right_join", x = x, by = by, suffix = suffix, ...)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname join
|
#' @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(by, allow_class = "character", allow_NULL = TRUE)
|
||||||
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
meet_criteria(suffix, allow_class = "character", has_length = 2)
|
||||||
|
|
||||||
check_dataset_integrity()
|
join_microorganisms(type = "full_join", x = x, by = by, suffix = suffix, ...)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
@@ -188,25 +105,7 @@ semi_join_microorganisms <- function(x, by = NULL, ...) {
|
|||||||
meet_criteria(x, allow_class = c("data.frame", "character"))
|
meet_criteria(x, allow_class = c("data.frame", "character"))
|
||||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||||
|
|
||||||
check_dataset_integrity()
|
join_microorganisms(type = "semi_join", x = x, by = by, ...)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
@@ -215,72 +114,64 @@ anti_join_microorganisms <- function(x, by = NULL, ...) {
|
|||||||
meet_criteria(x, allow_class = c("data.frame", "character"))
|
meet_criteria(x, allow_class = c("data.frame", "character"))
|
||||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||||
|
|
||||||
check_dataset_integrity()
|
join_microorganisms(type = "anti_join", x = x, by = by, ...)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
joins_check_df <- function(x, by) {
|
join_microorganisms <- function(type, x, by, suffix, ...) {
|
||||||
if (!any(class(x) %in% c("data.frame", "matrix"))) {
|
check_dataset_integrity()
|
||||||
x <- data.frame(mo = as.mo(x), stringsAsFactors = FALSE)
|
|
||||||
if (is.null(by)) {
|
if (!is.data.frame(x)) {
|
||||||
|
x <- data.frame(mo = x, stringsAsFactors = FALSE)
|
||||||
by <- "mo"
|
by <- "mo"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
|
||||||
if (is.null(by)) {
|
if (is.null(by)) {
|
||||||
# search for column with class `mo` and return first one found
|
by <- search_type_in_df(x, "mo", info = FALSE)
|
||||||
by <- colnames(x)[lapply(x, is.mo) == TRUE][1]
|
if (is.null(by) && NCOL(x) == 1) {
|
||||||
if (is.na(by)) {
|
by <- colnames(x)[1L]
|
||||||
if ("mo" %in% colnames(x)) {
|
|
||||||
by <- "mo"
|
|
||||||
x[, "mo"] <- as.mo(x[, "mo"])
|
|
||||||
} else {
|
} else {
|
||||||
stop("Cannot join - no column found with name 'mo' or with class <mo>.", call. = FALSE)
|
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
|
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))) {
|
if (is.null(names(by))) {
|
||||||
joinby <- colnames(microorganisms)[1]
|
# will always be joined to microorganisms$mo, so add name to that
|
||||||
names(joinby) <- by
|
by <- stats::setNames("mo", by)
|
||||||
} else {
|
|
||||||
joinby <- by
|
|
||||||
}
|
|
||||||
list(x = x,
|
|
||||||
by = joinby)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_prejoined_class <- function(x) {
|
# use dplyr if available - it's much faster than poorman alternatives
|
||||||
if (is.data.frame(x)) {
|
dplyr_join <- import_fn(name = type, pkg = "dplyr", error_on_fail = FALSE)
|
||||||
class(x)
|
if (!is.null(dplyr_join)) {
|
||||||
|
join_fn <- dplyr_join
|
||||||
} else {
|
} else {
|
||||||
"data.frame"
|
# otherwise use poorman, see R/aa_helper_pm_functions.R
|
||||||
|
join_fn <- get(paste0("pm_", type), envir = asNamespace("AMR"))
|
||||||
|
}
|
||||||
|
if (type %like% "full|left|right|inner") {
|
||||||
|
joined <- join_fn(x = x, y = AMR::microorganisms, by = by, suffix = suffix, ...)
|
||||||
|
} else {
|
||||||
|
joined <- join_fn(x = x, y = AMR::microorganisms, by = by, ...)
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_groups_before_join <- function(x, fn) {
|
if (type %like% "full|left|right|inner" && NROW(joined) > NROW(x)) {
|
||||||
if (is.data.frame(x) && !is.null(attributes(x)$groups)) {
|
warning_("The newly joined data set contains ", nrow(joined) - nrow(x), " rows more than the number of rows of `x`.", call = FALSE)
|
||||||
x <- pm_ungroup(x)
|
|
||||||
attr(x, "groups") <- NULL
|
|
||||||
class(x) <- class(x)[!class(x) %like% "group"]
|
|
||||||
warning_("Groups are dropped, since the ", fn, "() function relies on merge() from base R.", call = FALSE)
|
|
||||||
}
|
}
|
||||||
x
|
|
||||||
|
joined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,380 +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/ #
|
|
||||||
# ==================================================================== #
|
|
||||||
|
|
||||||
#' Key Antibiotics for First (Weighted) Isolates
|
|
||||||
#'
|
|
||||||
#' These function can be used to determine first isolates (see [first_isolate()]). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first 'weighted' isolates.
|
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
|
||||||
#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank to determine automatically
|
|
||||||
#' @param y,z character vectors to compare
|
|
||||||
#' @inheritParams first_isolate
|
|
||||||
#' @param universal_1,universal_2,universal_3,universal_4,universal_5,universal_6 column names of **broad-spectrum** antibiotics, case-insensitive. See details for which antibiotics will be used at default (which are guessed with [guess_ab_col()]).
|
|
||||||
#' @param GramPos_1,GramPos_2,GramPos_3,GramPos_4,GramPos_5,GramPos_6 column names of antibiotics for **Gram-positives**, case-insensitive. See details for which antibiotics will be used at default (which are guessed with [guess_ab_col()]).
|
|
||||||
#' @param GramNeg_1,GramNeg_2,GramNeg_3,GramNeg_4,GramNeg_5,GramNeg_6 column names of antibiotics for **Gram-negatives**, case-insensitive. See details for which antibiotics will be used at default (which are guessed with [guess_ab_col()]).
|
|
||||||
#' @param warnings give a warning about missing antibiotic columns (they will be ignored)
|
|
||||||
#' @param ... other arguments passed on to functions
|
|
||||||
#' @details
|
|
||||||
#' The [key_antibiotics()] function is context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
|
||||||
#'
|
|
||||||
#' The function [key_antibiotics()] returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using [key_antibiotics_equal()], to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (`"."`) by [key_antibiotics()] and ignored by [key_antibiotics_equal()].
|
|
||||||
#'
|
|
||||||
#' The [first_isolate()] function only uses this function on the same microbial species from the same patient. Using this, e.g. an MRSA will be included after a susceptible *S. aureus* (MSSA) is found within the same patient episode. Without key antibiotic comparison it would not. See [first_isolate()] for more info.
|
|
||||||
#'
|
|
||||||
#' At default, the antibiotics that are used for **Gram-positive bacteria** are:
|
|
||||||
#' - Amoxicillin
|
|
||||||
#' - Amoxicillin/clavulanic acid
|
|
||||||
#' - Cefuroxime
|
|
||||||
#' - Piperacillin/tazobactam
|
|
||||||
#' - Ciprofloxacin
|
|
||||||
#' - Trimethoprim/sulfamethoxazole
|
|
||||||
#' - Vancomycin
|
|
||||||
#' - Teicoplanin
|
|
||||||
#' - Tetracycline
|
|
||||||
#' - Erythromycin
|
|
||||||
#' - Oxacillin
|
|
||||||
#' - Rifampin
|
|
||||||
#'
|
|
||||||
#' At default the antibiotics that are used for **Gram-negative bacteria** are:
|
|
||||||
#' - Amoxicillin
|
|
||||||
#' - Amoxicillin/clavulanic acid
|
|
||||||
#' - Cefuroxime
|
|
||||||
#' - Piperacillin/tazobactam
|
|
||||||
#' - Ciprofloxacin
|
|
||||||
#' - Trimethoprim/sulfamethoxazole
|
|
||||||
#' - Gentamicin
|
|
||||||
#' - Tobramycin
|
|
||||||
#' - Colistin
|
|
||||||
#' - Cefotaxime
|
|
||||||
#' - Ceftazidime
|
|
||||||
#' - Meropenem
|
|
||||||
#'
|
|
||||||
#' The function [key_antibiotics_equal()] checks the characters returned by [key_antibiotics()] for equality, and returns a [`logical`] vector.
|
|
||||||
#' @inheritSection first_isolate Key Antibiotics
|
|
||||||
#' @rdname key_antibiotics
|
|
||||||
#' @export
|
|
||||||
#' @seealso [first_isolate()]
|
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
|
||||||
#' @examples
|
|
||||||
#' # `example_isolates` is a data set available in the AMR package.
|
|
||||||
#' # See ?example_isolates.
|
|
||||||
#'
|
|
||||||
#' # output of the `key_antibiotics()` function could be like this:
|
|
||||||
#' strainA <- "SSSRR.S.R..S"
|
|
||||||
#' strainB <- "SSSIRSSSRSSS"
|
|
||||||
#'
|
|
||||||
#' # those strings can be compared with:
|
|
||||||
#' key_antibiotics_equal(strainA, strainB)
|
|
||||||
#' # TRUE, because I is ignored (as well as missing values)
|
|
||||||
#'
|
|
||||||
#' key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
|
|
||||||
#' # FALSE, because I is not ignored and so the 4th character differs
|
|
||||||
#'
|
|
||||||
#' \donttest{
|
|
||||||
#' if (require("dplyr")) {
|
|
||||||
#' # set key antibiotics to a new variable
|
|
||||||
#' my_patients <- example_isolates %>%
|
|
||||||
#' mutate(keyab = key_antibiotics()) %>% # no need to define `x`
|
|
||||||
#' mutate(
|
|
||||||
#' # now calculate first isolates
|
|
||||||
#' first_regular = first_isolate(col_keyantibiotics = FALSE),
|
|
||||||
#' # and first WEIGHTED isolates
|
|
||||||
#' first_weighted = first_isolate(col_keyantibiotics = "keyab")
|
|
||||||
#' )
|
|
||||||
#'
|
|
||||||
#' # Check the difference, in this data set it results in a lot more isolates:
|
|
||||||
#' sum(my_patients$first_regular, na.rm = TRUE)
|
|
||||||
#' sum(my_patients$first_weighted, na.rm = TRUE)
|
|
||||||
#' }
|
|
||||||
#' }
|
|
||||||
key_antibiotics <- function(x = NULL,
|
|
||||||
col_mo = NULL,
|
|
||||||
universal_1 = guess_ab_col(x, "amoxicillin"),
|
|
||||||
universal_2 = guess_ab_col(x, "amoxicillin/clavulanic acid"),
|
|
||||||
universal_3 = guess_ab_col(x, "cefuroxime"),
|
|
||||||
universal_4 = guess_ab_col(x, "piperacillin/tazobactam"),
|
|
||||||
universal_5 = guess_ab_col(x, "ciprofloxacin"),
|
|
||||||
universal_6 = guess_ab_col(x, "trimethoprim/sulfamethoxazole"),
|
|
||||||
GramPos_1 = guess_ab_col(x, "vancomycin"),
|
|
||||||
GramPos_2 = guess_ab_col(x, "teicoplanin"),
|
|
||||||
GramPos_3 = guess_ab_col(x, "tetracycline"),
|
|
||||||
GramPos_4 = guess_ab_col(x, "erythromycin"),
|
|
||||||
GramPos_5 = guess_ab_col(x, "oxacillin"),
|
|
||||||
GramPos_6 = guess_ab_col(x, "rifampin"),
|
|
||||||
GramNeg_1 = guess_ab_col(x, "gentamicin"),
|
|
||||||
GramNeg_2 = guess_ab_col(x, "tobramycin"),
|
|
||||||
GramNeg_3 = guess_ab_col(x, "colistin"),
|
|
||||||
GramNeg_4 = guess_ab_col(x, "cefotaxime"),
|
|
||||||
GramNeg_5 = guess_ab_col(x, "ceftazidime"),
|
|
||||||
GramNeg_6 = guess_ab_col(x, "meropenem"),
|
|
||||||
warnings = TRUE,
|
|
||||||
...) {
|
|
||||||
if (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 <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
|
||||||
}
|
|
||||||
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
|
||||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(universal_1, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(universal_2, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(universal_3, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(universal_4, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(universal_5, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(universal_6, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramPos_1, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramPos_2, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramPos_3, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramPos_4, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramPos_5, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramPos_6, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramNeg_1, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramNeg_2, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramNeg_3, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramNeg_4, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramNeg_5, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(GramNeg_6, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
|
||||||
meet_criteria(warnings, allow_class = "logical", has_length = 1)
|
|
||||||
|
|
||||||
# force regular data.frame, not a tibble or data.table
|
|
||||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
|
||||||
|
|
||||||
dots <- unlist(list(...))
|
|
||||||
if (length(dots) != 0) {
|
|
||||||
# backwards compatibility with old arguments
|
|
||||||
dots.names <- names(dots)
|
|
||||||
if ("info" %in% dots.names) {
|
|
||||||
warnings <- dots[which(dots.names == "info")]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# try to find columns based on type
|
|
||||||
# -- mo
|
|
||||||
if (is.null(col_mo)) {
|
|
||||||
col_mo <- search_type_in_df(x = x, type = "mo")
|
|
||||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
|
||||||
} else {
|
|
||||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
# check columns
|
|
||||||
col.list <- c(universal_1, universal_2, universal_3, universal_4, universal_5, universal_6,
|
|
||||||
GramPos_1, GramPos_2, GramPos_3, GramPos_4, GramPos_5, GramPos_6,
|
|
||||||
GramNeg_1, GramNeg_2, GramNeg_3, GramNeg_4, GramNeg_5, GramNeg_6)
|
|
||||||
check_available_columns <- function(x, col.list, warnings = TRUE) {
|
|
||||||
# check columns
|
|
||||||
col.list <- col.list[!is.na(col.list) & !is.null(col.list)]
|
|
||||||
names(col.list) <- col.list
|
|
||||||
col.list.bak <- col.list
|
|
||||||
# are they available as upper case or lower case then?
|
|
||||||
for (i in seq_len(length(col.list))) {
|
|
||||||
if (is.null(col.list[i]) | isTRUE(is.na(col.list[i]))) {
|
|
||||||
col.list[i] <- NA
|
|
||||||
} else if (toupper(col.list[i]) %in% colnames(x)) {
|
|
||||||
col.list[i] <- toupper(col.list[i])
|
|
||||||
} else if (tolower(col.list[i]) %in% colnames(x)) {
|
|
||||||
col.list[i] <- tolower(col.list[i])
|
|
||||||
} else if (!col.list[i] %in% colnames(x)) {
|
|
||||||
col.list[i] <- NA
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!all(col.list %in% colnames(x))) {
|
|
||||||
if (warnings == TRUE) {
|
|
||||||
warning_("Some columns do not exist and will be ignored: ",
|
|
||||||
col.list.bak[!(col.list %in% colnames(x))] %pm>% toString(),
|
|
||||||
".\nTHIS MAY STRONGLY INFLUENCE THE OUTCOME.",
|
|
||||||
immediate = TRUE,
|
|
||||||
call = FALSE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
col.list
|
|
||||||
}
|
|
||||||
|
|
||||||
col.list <- check_available_columns(x = x, col.list = col.list, warnings = warnings)
|
|
||||||
universal_1 <- col.list[universal_1]
|
|
||||||
universal_2 <- col.list[universal_2]
|
|
||||||
universal_3 <- col.list[universal_3]
|
|
||||||
universal_4 <- col.list[universal_4]
|
|
||||||
universal_5 <- col.list[universal_5]
|
|
||||||
universal_6 <- col.list[universal_6]
|
|
||||||
GramPos_1 <- col.list[GramPos_1]
|
|
||||||
GramPos_2 <- col.list[GramPos_2]
|
|
||||||
GramPos_3 <- col.list[GramPos_3]
|
|
||||||
GramPos_4 <- col.list[GramPos_4]
|
|
||||||
GramPos_5 <- col.list[GramPos_5]
|
|
||||||
GramPos_6 <- col.list[GramPos_6]
|
|
||||||
GramNeg_1 <- col.list[GramNeg_1]
|
|
||||||
GramNeg_2 <- col.list[GramNeg_2]
|
|
||||||
GramNeg_3 <- col.list[GramNeg_3]
|
|
||||||
GramNeg_4 <- col.list[GramNeg_4]
|
|
||||||
GramNeg_5 <- col.list[GramNeg_5]
|
|
||||||
GramNeg_6 <- col.list[GramNeg_6]
|
|
||||||
|
|
||||||
universal <- c(universal_1, universal_2, universal_3,
|
|
||||||
universal_4, universal_5, universal_6)
|
|
||||||
|
|
||||||
gram_positive <- c(universal,
|
|
||||||
GramPos_1, GramPos_2, GramPos_3,
|
|
||||||
GramPos_4, GramPos_5, GramPos_6)
|
|
||||||
gram_positive <- gram_positive[!is.null(gram_positive)]
|
|
||||||
gram_positive <- gram_positive[!is.na(gram_positive)]
|
|
||||||
if (length(gram_positive) < 12 & message_not_thrown_before("key_antibiotics.grampos")) {
|
|
||||||
warning_("Only using ", length(gram_positive), " different antibiotics as key antibiotics for Gram-positives. See ?key_antibiotics.", call = FALSE)
|
|
||||||
remember_thrown_message("key_antibiotics.grampos")
|
|
||||||
}
|
|
||||||
|
|
||||||
gram_negative <- c(universal,
|
|
||||||
GramNeg_1, GramNeg_2, GramNeg_3,
|
|
||||||
GramNeg_4, GramNeg_5, GramNeg_6)
|
|
||||||
gram_negative <- gram_negative[!is.null(gram_negative)]
|
|
||||||
gram_negative <- gram_negative[!is.na(gram_negative)]
|
|
||||||
if (length(gram_negative) < 12 & message_not_thrown_before("key_antibiotics.gramneg")) {
|
|
||||||
warning_("Only using ", length(gram_negative), " different antibiotics as key antibiotics for Gram-negatives. See ?key_antibiotics.", call = FALSE)
|
|
||||||
remember_thrown_message("key_antibiotics.gramneg")
|
|
||||||
}
|
|
||||||
|
|
||||||
x[, col_mo] <- as.mo(x[, col_mo, drop = TRUE])
|
|
||||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
|
||||||
x$key_ab <- NA_character_
|
|
||||||
|
|
||||||
# Gram +
|
|
||||||
x$key_ab <- pm_if_else(x$gramstain == "Gram-positive",
|
|
||||||
tryCatch(apply(X = x[, gram_positive],
|
|
||||||
MARGIN = 1,
|
|
||||||
FUN = function(x) paste(x, collapse = "")),
|
|
||||||
error = function(e) paste0(rep(".", 12), collapse = "")),
|
|
||||||
x$key_ab)
|
|
||||||
|
|
||||||
# Gram -
|
|
||||||
x$key_ab <- pm_if_else(x$gramstain == "Gram-negative",
|
|
||||||
tryCatch(apply(X = x[, gram_negative],
|
|
||||||
MARGIN = 1,
|
|
||||||
FUN = function(x) paste(x, collapse = "")),
|
|
||||||
error = function(e) paste0(rep(".", 12), collapse = "")),
|
|
||||||
x$key_ab)
|
|
||||||
|
|
||||||
# format
|
|
||||||
key_abs <- toupper(gsub("[^SIR]", ".", gsub("(NA|NULL)", ".", x$key_ab)))
|
|
||||||
|
|
||||||
if (pm_n_distinct(key_abs) == 1) {
|
|
||||||
warning_("No distinct key antibiotics determined.", call = FALSE)
|
|
||||||
}
|
|
||||||
|
|
||||||
key_abs
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#' @rdname key_antibiotics
|
|
||||||
#' @export
|
|
||||||
key_antibiotics_equal <- function(y,
|
|
||||||
z,
|
|
||||||
type = c("keyantibiotics", "points"),
|
|
||||||
ignore_I = TRUE,
|
|
||||||
points_threshold = 2,
|
|
||||||
info = FALSE) {
|
|
||||||
meet_criteria(y, allow_class = "character")
|
|
||||||
meet_criteria(z, allow_class = "character")
|
|
||||||
meet_criteria(type, allow_class = "character", has_length = c(1, 2))
|
|
||||||
meet_criteria(ignore_I, allow_class = "logical", has_length = 1)
|
|
||||||
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
|
||||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
|
||||||
|
|
||||||
stop_ifnot(length(y) == length(z), "length of `y` and `z` must be equal")
|
|
||||||
# y is active row, z is lag
|
|
||||||
x <- y
|
|
||||||
y <- z
|
|
||||||
|
|
||||||
type <- type[1]
|
|
||||||
|
|
||||||
# only show progress bar on points or when at least 5000 isolates
|
|
||||||
info_needed <- info == TRUE & (type == "points" | length(x) > 5000)
|
|
||||||
|
|
||||||
result <- logical(length(x))
|
|
||||||
|
|
||||||
if (info_needed == TRUE) {
|
|
||||||
p <- progress_ticker(length(x))
|
|
||||||
on.exit(close(p))
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i in seq_len(length(x))) {
|
|
||||||
|
|
||||||
if (info_needed == TRUE) {
|
|
||||||
p$tick()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is.na(x[i])) {
|
|
||||||
x[i] <- ""
|
|
||||||
}
|
|
||||||
if (is.na(y[i])) {
|
|
||||||
y[i] <- ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x[i] == y[i]) {
|
|
||||||
|
|
||||||
result[i] <- TRUE
|
|
||||||
|
|
||||||
} else if (nchar(x[i]) != nchar(y[i])) {
|
|
||||||
|
|
||||||
result[i] <- FALSE
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
x_split <- strsplit(x[i], "")[[1]]
|
|
||||||
y_split <- strsplit(y[i], "")[[1]]
|
|
||||||
|
|
||||||
if (type == "keyantibiotics") {
|
|
||||||
|
|
||||||
if (ignore_I == TRUE) {
|
|
||||||
x_split[x_split == "I"] <- "."
|
|
||||||
y_split[y_split == "I"] <- "."
|
|
||||||
}
|
|
||||||
|
|
||||||
y_split[x_split == "."] <- "."
|
|
||||||
x_split[y_split == "."] <- "."
|
|
||||||
|
|
||||||
result[i] <- all(x_split == y_split)
|
|
||||||
|
|
||||||
} else if (type == "points") {
|
|
||||||
# count points for every single character:
|
|
||||||
# - no change is 0 points
|
|
||||||
# - I <-> S|R is 0.5 point
|
|
||||||
# - S|R <-> R|S is 1 point
|
|
||||||
# use the levels of as.rsi (S = 1, I = 2, R = 3)
|
|
||||||
|
|
||||||
suppressWarnings(x_split <- x_split %pm>% as.rsi() %pm>% as.double())
|
|
||||||
suppressWarnings(y_split <- y_split %pm>% as.rsi() %pm>% as.double())
|
|
||||||
|
|
||||||
points <- (x_split - y_split) %pm>% abs() %pm>% sum(na.rm = TRUE) / 2
|
|
||||||
result[i] <- points >= points_threshold
|
|
||||||
|
|
||||||
} else {
|
|
||||||
stop("`", type, '` is not a valid value for type, must be "points" or "keyantibiotics". See ?key_antibiotics')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (info_needed == TRUE) {
|
|
||||||
close(p)
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
|
||||||
325
R/key_antimicrobials.R
Executable file
@@ -0,0 +1,325 @@
|
|||||||
|
# ==================================================================== #
|
||||||
|
# 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/ #
|
||||||
|
# ==================================================================== #
|
||||||
|
|
||||||
|
#' (Key) Antimicrobials for First Weighted Isolates
|
||||||
|
#'
|
||||||
|
#' 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
|
||||||
|
#' @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 ... ignored, only in place to allow future extensions
|
||||||
|
#' @details
|
||||||
|
#' 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()].
|
||||||
|
#'
|
||||||
|
#' Please see the [first_isolate()] function how these important functions enable the 'phenotype-based' method for determination of first isolates.
|
||||||
|
#'
|
||||||
|
#' The default antimicrobial agents used for **all rows** (set in `universal`) are:
|
||||||
|
#'
|
||||||
|
#' - Ampicillin
|
||||||
|
#' - Amoxicillin/clavulanic acid
|
||||||
|
#' - Cefuroxime
|
||||||
|
#' - Ciprofloxacin
|
||||||
|
#' - Piperacillin/tazobactam
|
||||||
|
#' - Trimethoprim/sulfamethoxazole
|
||||||
|
#'
|
||||||
|
#' The default antimicrobial agents used for **Gram-negative bacteria** (set in `gram_negative`) are:
|
||||||
|
#'
|
||||||
|
#' - Cefotaxime
|
||||||
|
#' - Ceftazidime
|
||||||
|
#' - Colistin
|
||||||
|
#' - Gentamicin
|
||||||
|
#' - Meropenem
|
||||||
|
#' - Tobramycin
|
||||||
|
#'
|
||||||
|
#' The default antimicrobial agents used for **Gram-positive bacteria** (set in `gram_positive`) are:
|
||||||
|
#'
|
||||||
|
#' - Erythromycin
|
||||||
|
#' - Oxacillin
|
||||||
|
#' - Rifampin
|
||||||
|
#' - Teicoplanin
|
||||||
|
#' - Tetracycline
|
||||||
|
#' - Vancomycin
|
||||||
|
#'
|
||||||
|
#'
|
||||||
|
#' The default antimicrobial agents used for **fungi** (set in `antifungal`) are:
|
||||||
|
#'
|
||||||
|
#' - Anidulafungin
|
||||||
|
#' - Caspofungin
|
||||||
|
#' - Fluconazole
|
||||||
|
#' - Miconazole
|
||||||
|
#' - Nystatin
|
||||||
|
#' - Voriconazole
|
||||||
|
#' @rdname key_antimicrobials
|
||||||
|
#' @export
|
||||||
|
#' @seealso [first_isolate()]
|
||||||
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
|
#' @examples
|
||||||
|
#' # `example_isolates` is a data set available in the AMR package.
|
||||||
|
#' # See ?example_isolates.
|
||||||
|
#'
|
||||||
|
#' # output of the `key_antimicrobials()` function could be like this:
|
||||||
|
#' strainA <- "SSSRR.S.R..S"
|
||||||
|
#' strainB <- "SSSIRSSSRSSS"
|
||||||
|
#'
|
||||||
|
#' # those strings can be compared with:
|
||||||
|
#' antimicrobials_equal(strainA, strainB, type = "keyantimicrobials")
|
||||||
|
#' # 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
|
||||||
|
#'
|
||||||
|
#' \donttest{
|
||||||
|
#' if (require("dplyr")) {
|
||||||
|
#' # set key antibiotics to a new variable
|
||||||
|
#' my_patients <- example_isolates %>%
|
||||||
|
#' mutate(keyab = key_antimicrobials(antifungal = NULL)) %>% # no need to define `x`
|
||||||
|
#' mutate(
|
||||||
|
#' # now calculate first isolates
|
||||||
|
#' first_regular = first_isolate(col_keyantimicrobials = FALSE),
|
||||||
|
#' # and first WEIGHTED isolates
|
||||||
|
#' first_weighted = first_isolate(col_keyantimicrobials = "keyab")
|
||||||
|
#' )
|
||||||
|
#'
|
||||||
|
#' # Check the difference, in this data set it results in more isolates:
|
||||||
|
#' sum(my_patients$first_regular, na.rm = TRUE)
|
||||||
|
#' sum(my_patients$first_weighted, na.rm = TRUE)
|
||||||
|
#' }
|
||||||
|
#' }
|
||||||
|
key_antimicrobials <- function(x = NULL,
|
||||||
|
col_mo = NULL,
|
||||||
|
universal = c("ampicillin", "amoxicillin/clavulanic acid", "cefuroxime",
|
||||||
|
"piperacillin/tazobactam", "ciprofloxacin", "trimethoprim/sulfamethoxazole"),
|
||||||
|
gram_negative = c("gentamicin", "tobramycin", "colistin",
|
||||||
|
"cefotaxime", "ceftazidime", "meropenem"),
|
||||||
|
gram_positive = c("vancomycin", "teicoplanin", "tetracycline",
|
||||||
|
"erythromycin", "oxacillin", "rifampin"),
|
||||||
|
antifungal = c("anidulafungin", "caspofungin", "fluconazole",
|
||||||
|
"miconazole", "nystatin", "voriconazole"),
|
||||||
|
only_rsi_columns = FALSE,
|
||||||
|
...) {
|
||||||
|
if (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 <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||||
|
}
|
||||||
|
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
||||||
|
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE, is_in = colnames(x))
|
||||||
|
meet_criteria(universal, allow_class = "character", allow_NULL = TRUE)
|
||||||
|
meet_criteria(gram_negative, allow_class = "character", allow_NULL = TRUE)
|
||||||
|
meet_criteria(gram_positive, allow_class = "character", allow_NULL = TRUE)
|
||||||
|
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
|
||||||
|
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||||
|
cols <- get_column_abx(x, info = FALSE, only_rsi_columns = only_rsi_columns)
|
||||||
|
|
||||||
|
# try to find columns based on type
|
||||||
|
# -- mo
|
||||||
|
if (is.null(col_mo)) {
|
||||||
|
col_mo <- search_type_in_df(x = x, type = "mo", info = FALSE)
|
||||||
|
}
|
||||||
|
if (is.null(col_mo)) {
|
||||||
|
warning_("No column found for `col_mo`, ignoring antibiotics set in `gram_negative` and `gram_positive`, and antimycotics set in `antifungal`", call = FALSE)
|
||||||
|
gramstain <- NA_character_
|
||||||
|
kingdom <- NA_character_
|
||||||
|
} else {
|
||||||
|
x.mo <- as.mo(x[, col_mo, drop = TRUE])
|
||||||
|
gramstain <- mo_gramstain(x.mo, language = NULL)
|
||||||
|
kingdom <- mo_kingdom(x.mo, language = NULL)
|
||||||
|
}
|
||||||
|
|
||||||
|
AMR_string <- function(x, values, name, filter, cols = cols) {
|
||||||
|
if (is.null(values)) {
|
||||||
|
return(rep(NA_character_, length(which(filter))))
|
||||||
|
}
|
||||||
|
|
||||||
|
values_old_length <- length(values)
|
||||||
|
values <- as.ab(values, flag_multiple_results = FALSE, info = FALSE)
|
||||||
|
values <- cols[names(cols) %in% values]
|
||||||
|
values_new_length <- length(values)
|
||||||
|
|
||||||
|
if (values_new_length < values_old_length &
|
||||||
|
any(filter, na.rm = TRUE) &
|
||||||
|
message_not_thrown_before(paste0("key_antimicrobials.", name))) {
|
||||||
|
warning_(ifelse(values_new_length == 0,
|
||||||
|
"No columns available ",
|
||||||
|
paste0("Only using ", values_new_length, " out of ", values_old_length, " defined columns ")),
|
||||||
|
"as key antimicrobials for ", name, "s. See ?key_antimicrobials.",
|
||||||
|
call = FALSE)
|
||||||
|
remember_thrown_message(paste0("key_antimicrobials.", name))
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_antimcrobials_string(x[which(filter), c(universal, values), drop = FALSE])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is.null(universal)) {
|
||||||
|
universal <- character(0)
|
||||||
|
} else {
|
||||||
|
universal <- as.ab(universal, flag_multiple_results = FALSE, info = FALSE)
|
||||||
|
universal <- cols[names(cols) %in% universal]
|
||||||
|
}
|
||||||
|
|
||||||
|
key_ab <- rep(NA_character_, nrow(x))
|
||||||
|
|
||||||
|
key_ab[which(gramstain == "Gram-negative")] <- AMR_string(x = x,
|
||||||
|
values = gram_negative,
|
||||||
|
name = "Gram-negative",
|
||||||
|
filter = gramstain == "Gram-negative",
|
||||||
|
cols = cols)
|
||||||
|
|
||||||
|
key_ab[which(gramstain == "Gram-positive")] <- AMR_string(x = x,
|
||||||
|
values = gram_positive,
|
||||||
|
name = "Gram-positive",
|
||||||
|
filter = gramstain == "Gram-positive",
|
||||||
|
cols = cols)
|
||||||
|
|
||||||
|
key_ab[which(kingdom == "Fungi")] <- AMR_string(x = x,
|
||||||
|
values = antifungal,
|
||||||
|
name = "antifungal",
|
||||||
|
filter = kingdom == "Fungi",
|
||||||
|
cols = cols)
|
||||||
|
|
||||||
|
# back-up - only use `universal`
|
||||||
|
key_ab[which(is.na(key_ab))] <- AMR_string(x = x,
|
||||||
|
values = character(0),
|
||||||
|
name = "",
|
||||||
|
filter = is.na(key_ab),
|
||||||
|
cols = cols)
|
||||||
|
|
||||||
|
if (length(unique(key_ab)) == 1) {
|
||||||
|
warning_("No distinct key antibiotics determined.", call = FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
|
key_ab
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @rdname key_antimicrobials
|
||||||
|
#' @export
|
||||||
|
all_antimicrobials <- function(x = NULL,
|
||||||
|
only_rsi_columns = FALSE,
|
||||||
|
...) {
|
||||||
|
if (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 <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||||
|
}
|
||||||
|
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
|
||||||
|
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||||
|
cols <- get_column_abx(x, only_rsi_columns = only_rsi_columns, info = FALSE, sort = FALSE)
|
||||||
|
|
||||||
|
generate_antimcrobials_string(x[ , cols, drop = FALSE])
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_antimcrobials_string <- function(df) {
|
||||||
|
if (NCOL(df) == 0) {
|
||||||
|
return(rep("", NROW(df)))
|
||||||
|
}
|
||||||
|
if (NROW(df) == 0) {
|
||||||
|
return(character(0))
|
||||||
|
}
|
||||||
|
out <- tryCatch(
|
||||||
|
do.call(paste0,
|
||||||
|
lapply(as.list(df),
|
||||||
|
function(x) {
|
||||||
|
x <- toupper(as.character(x))
|
||||||
|
x[!x %in% c("R", "S", "I")] <- "."
|
||||||
|
paste(x)
|
||||||
|
})),
|
||||||
|
error = function(e) rep(strrep(".", NCOL(df)), NROW(df)))
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @rdname key_antimicrobials
|
||||||
|
#' @export
|
||||||
|
antimicrobials_equal <- function(y,
|
||||||
|
z,
|
||||||
|
type = c("points", "keyantimicrobials"),
|
||||||
|
ignore_I = TRUE,
|
||||||
|
points_threshold = 2,
|
||||||
|
...) {
|
||||||
|
meet_criteria(y, allow_class = "character")
|
||||||
|
meet_criteria(z, allow_class = "character")
|
||||||
|
stop_if(missing(type), "argument \"type\" is missing, with no default")
|
||||||
|
meet_criteria(type, allow_class = "character", has_length = 1, is_in = c("points", "keyantimicrobials"))
|
||||||
|
meet_criteria(ignore_I, allow_class = "logical", has_length = 1)
|
||||||
|
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||||
|
stop_ifnot(length(y) == length(z), "length of `y` and `z` must be equal")
|
||||||
|
|
||||||
|
key2rsi <- function(val) {
|
||||||
|
as.double(as.rsi(gsub(".", NA_character_, unlist(strsplit(val, "")), fixed = TRUE)))
|
||||||
|
}
|
||||||
|
y <- lapply(y, key2rsi)
|
||||||
|
z <- lapply(z, key2rsi)
|
||||||
|
|
||||||
|
determine_equality <- function(a, b, type, points_threshold, ignore_I) {
|
||||||
|
if (length(a) != length(b)) {
|
||||||
|
# incomparable, so not equal
|
||||||
|
return(FALSE)
|
||||||
|
}
|
||||||
|
# ignore NAs on both sides
|
||||||
|
NA_ind <- which(is.na(a) | is.na(b))
|
||||||
|
a[NA_ind] <- NA_real_
|
||||||
|
b[NA_ind] <- NA_real_
|
||||||
|
|
||||||
|
if (type == "points") {
|
||||||
|
# count points for every single character:
|
||||||
|
# - no change is 0 points
|
||||||
|
# - I <-> S|R is 0.5 point
|
||||||
|
# - S|R <-> R|S is 1 point
|
||||||
|
# use the levels of as.rsi (S = 1, I = 2, R = 3)
|
||||||
|
# and divide by 2 (S = 0.5, I = 1, R = 1.5)
|
||||||
|
(sum(abs(a - b), na.rm = TRUE) / 2) < points_threshold
|
||||||
|
} else {
|
||||||
|
if (ignore_I == TRUE) {
|
||||||
|
ind <- which(a == 2 | b == 2) # since as.double(as.rsi("I")) == 2
|
||||||
|
a[ind] <- NA_real_
|
||||||
|
b[ind] <- NA_real_
|
||||||
|
}
|
||||||
|
all(a == b, na.rm = TRUE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out <- unlist(mapply(FUN = determine_equality,
|
||||||
|
y,
|
||||||
|
z,
|
||||||
|
MoreArgs = list(type = type,
|
||||||
|
points_threshold = points_threshold,
|
||||||
|
ignore_I = ignore_I),
|
||||||
|
SIMPLIFY = FALSE,
|
||||||
|
USE.NAMES = FALSE))
|
||||||
|
out[is.na(y) | is.na(z)] <- NA
|
||||||
|
out
|
||||||
|
}
|
||||||
@@ -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.
|
#' @description Kurtosis is a measure of the "tailedness" of the probability distribution of a real-valued random variable. A normal distribution has a kurtosis of 3 and a excess kurtosis of 0.
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x a vector of values, a [matrix] or a [data.frame]
|
#' @param 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 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 excess a [logical] to indicate whether the *excess kurtosis* should be returned, defined as the kurtosis minus 3.
|
||||||
#' @seealso [skewness()]
|
#' @seealso [skewness()]
|
||||||
#' @rdname kurtosis
|
#' @rdname kurtosis
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
|
|||||||
70
R/like.R
@@ -23,30 +23,29 @@
|
|||||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
#' Pattern Matching with Keyboard Shortcut
|
#' Vectorised Pattern Matching with Keyboard Shortcut
|
||||||
#'
|
#'
|
||||||
#' 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.
|
#' 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
|
#' @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 x a [character] vector where matches are sought, or an object which can be coerced by [as.character()] to a [character] vector.
|
||||||
#' @param pattern a character string containing a regular expression (or [character] string for `fixed = TRUE`) to be matched in the given character vector. Coerced by [as.character()] to a character string if possible. If a [character] vector of length 2 or more is supplied, the first element is used with a warning.
|
#' @param 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.
|
#' @param ignore.case if `FALSE`, the pattern matching is *case sensitive* and if `TRUE`, case is ignored during matching.
|
||||||
#' @return A [`logical`] vector
|
#' @return A [logical] vector
|
||||||
#' @name like
|
#' @name like
|
||||||
#' @rdname like
|
#' @rdname like
|
||||||
#' @export
|
#' @export
|
||||||
#' @details
|
#' @details
|
||||||
#' The `%like%` function:
|
#' These [like()] and `%like%`/`%unlike%` functions:
|
||||||
#' * Is case-insensitive (use `%like_case%` for case-sensitive matching)
|
#' * Are case-insensitive (use `%like_case%`/`%unlike_case%` for case-sensitive matching)
|
||||||
#' * Supports multiple patterns
|
#' * Support multiple patterns
|
||||||
#' * Checks if `pattern` is a regular expression and sets `fixed = TRUE` if not, to greatly improve speed
|
#' * Check if `pattern` is a valid regular expression and sets `fixed = TRUE` if not, to greatly improve speed (vectorised over `pattern`)
|
||||||
#' * Always uses compatibility with Perl
|
#' * Always use compatibility with Perl unless `fixed = TRUE`, to greatly improve speed
|
||||||
#'
|
#'
|
||||||
#' Using RStudio? The text `%like%` can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like `Ctrl+Shift+L` or `Cmd+Shift+L` (see `Tools` > `Modify Keyboard Shortcuts...`).
|
#' Using RStudio? The `%like%`/`%unlike%` functions can also be directly inserted in your code from the Addins menu and can have its own keyboard shortcut like `Shift+Ctrl+L` or `Shift+Cmd+L` (see menu `Tools` > `Modify Keyboard Shortcuts...`). If you keep pressing your shortcut, the inserted text will be iterated over `%like%` -> `%unlike%` -> `%like_case%` -> `%unlike_case%`.
|
||||||
#' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/master/R/like.R)
|
#' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R), although altered as explained in *Details*.
|
||||||
#' @seealso [grepl()]
|
#' @seealso [grepl()]
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @examples
|
#' @examples
|
||||||
#' # simple test
|
|
||||||
#' a <- "This is a test"
|
#' a <- "This is a test"
|
||||||
#' b <- "TEST"
|
#' b <- "TEST"
|
||||||
#' a %like% b
|
#' a %like% b
|
||||||
@@ -59,16 +58,23 @@
|
|||||||
#' b <- c( "case", "diff", "yet")
|
#' b <- c( "case", "diff", "yet")
|
||||||
#' a %like% b
|
#' a %like% b
|
||||||
#' #> TRUE TRUE TRUE
|
#' #> TRUE TRUE TRUE
|
||||||
|
#' a %unlike% b
|
||||||
|
#' #> FALSE FALSE FALSE
|
||||||
|
#'
|
||||||
#' a[1] %like% b
|
#' a[1] %like% b
|
||||||
#' #> TRUE FALSE FALSE
|
#' #> TRUE FALSE FALSE
|
||||||
#' a %like% b[1]
|
#' a %like% b[1]
|
||||||
#' #> TRUE FALSE FALSE
|
#' #> TRUE FALSE FALSE
|
||||||
#'
|
#'
|
||||||
#' # get isolates whose name start with 'Ent' or 'ent'
|
#' # get isolates whose name start with 'Ent' or 'ent'
|
||||||
|
#' example_isolates[which(mo_name(example_isolates$mo) %like% "^ent"), ]
|
||||||
#' \donttest{
|
#' \donttest{
|
||||||
|
#' # faster way, only works in R 3.2 and later:
|
||||||
|
#' example_isolates[which(mo_name() %like% "^ent"), ]
|
||||||
|
#'
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' filter(mo_name(mo) %like% "^ent")
|
#' filter(mo_name() %like% "^ent")
|
||||||
#' }
|
#' }
|
||||||
#' }
|
#' }
|
||||||
like <- function(x, pattern, ignore.case = TRUE) {
|
like <- function(x, pattern, ignore.case = TRUE) {
|
||||||
@@ -80,8 +86,9 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
|||||||
return(rep(FALSE, length(x)))
|
return(rep(FALSE, length(x)))
|
||||||
}
|
}
|
||||||
|
|
||||||
# set to fixed if no regex found
|
# set to fixed if no valid regex (vectorised)
|
||||||
fixed <- !any(is_possibly_regex(pattern))
|
fixed <- !is_valid_regex(pattern)
|
||||||
|
|
||||||
if (ignore.case == TRUE) {
|
if (ignore.case == TRUE) {
|
||||||
# set here, otherwise if fixed = TRUE, this warning will be thrown: argument `ignore.case = TRUE` will be ignored
|
# set here, otherwise if fixed = TRUE, this warning will be thrown: argument `ignore.case = TRUE` will be ignored
|
||||||
x <- tolower(x)
|
x <- tolower(x)
|
||||||
@@ -98,14 +105,19 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
|||||||
if (length(x) == 1) {
|
if (length(x) == 1) {
|
||||||
x <- rep(x, length(pattern))
|
x <- rep(x, length(pattern))
|
||||||
} else if (length(pattern) != length(x)) {
|
} else if (length(pattern) != length(x)) {
|
||||||
stop_("arguments `x` and `pattern` must be of same length, or either one must be 1")
|
stop_("arguments `x` and `pattern` must be of same length, or either one must be 1 ",
|
||||||
|
"(`x` has length ", length(x), " and `pattern` has length ", length(pattern), ")")
|
||||||
}
|
}
|
||||||
unlist(
|
unlist(
|
||||||
Map(f = grepl,
|
mapply(FUN = grepl,
|
||||||
pattern,
|
x = x,
|
||||||
x,
|
pattern = pattern,
|
||||||
MoreArgs = list(ignore.case = FALSE, fixed = fixed, perl = !fixed)),
|
fixed = fixed,
|
||||||
use.names = FALSE)
|
perl = !fixed,
|
||||||
|
MoreArgs = list(ignore.case = FALSE),
|
||||||
|
SIMPLIFY = FALSE,
|
||||||
|
USE.NAMES = FALSE)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +129,14 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
|||||||
like(x, pattern, ignore.case = TRUE)
|
like(x, pattern, ignore.case = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' @rdname like
|
||||||
|
#' @export
|
||||||
|
"%unlike%" <- function(x, pattern) {
|
||||||
|
meet_criteria(x, allow_NA = TRUE)
|
||||||
|
meet_criteria(pattern, allow_NA = FALSE)
|
||||||
|
!like(x, pattern, ignore.case = TRUE)
|
||||||
|
}
|
||||||
|
|
||||||
#' @rdname like
|
#' @rdname like
|
||||||
#' @export
|
#' @export
|
||||||
"%like_case%" <- function(x, pattern) {
|
"%like_case%" <- function(x, pattern) {
|
||||||
@@ -124,3 +144,11 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
|||||||
meet_criteria(pattern, allow_NA = FALSE)
|
meet_criteria(pattern, allow_NA = FALSE)
|
||||||
like(x, pattern, ignore.case = FALSE)
|
like(x, pattern, ignore.case = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' @rdname like
|
||||||
|
#' @export
|
||||||
|
"%unlike_case%" <- function(x, pattern) {
|
||||||
|
meet_criteria(x, allow_NA = TRUE)
|
||||||
|
meet_criteria(pattern, allow_NA = FALSE)
|
||||||
|
!like(x, pattern, ignore.case = FALSE)
|
||||||
|
}
|
||||||
|
|||||||
153
R/mdro.R
@@ -34,10 +34,10 @@
|
|||||||
#' @inheritParams eucast_rules
|
#' @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 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 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
|
#' @inheritSection eucast_rules Antibiotics
|
||||||
#' @details
|
#' @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`).
|
#' 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`).
|
||||||
#'
|
#'
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
#'
|
#'
|
||||||
#' Custom guidelines can be set with the [custom_mdro_guideline()] function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data.
|
#' Custom guidelines can be set with the [custom_mdro_guideline()] function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data.
|
||||||
#'
|
#'
|
||||||
#' If you are familiar with `case_when()` of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation':
|
#' If you are familiar with the [`case_when()`][dplyr::case_when()] function of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation'. The rule is written *before* the tilde (`~`) and the consequence of the rule is written *after* the tilde:
|
||||||
#'
|
#'
|
||||||
#' ```
|
#' ```
|
||||||
#' custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A",
|
#' custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A",
|
||||||
@@ -102,10 +102,22 @@
|
|||||||
#' The outcome of the function can be used for the `guideline` argument in the [mdro()] function:
|
#' The outcome of the function can be used for the `guideline` argument in the [mdro()] function:
|
||||||
#'
|
#'
|
||||||
#' ```
|
#' ```
|
||||||
#' x <- mdro(example_isolates, guideline = custom)
|
#' x <- mdro(example_isolates,
|
||||||
|
#' guideline = custom)
|
||||||
#' table(x)
|
#' table(x)
|
||||||
#' #> Elderly Type A Elderly Type B Negative
|
#' #> Negative Elderly Type A Elderly Type B
|
||||||
#' #> 43 891 1066
|
#' #> 1070 198 732
|
||||||
|
#' ```
|
||||||
|
#'
|
||||||
|
#' Rules can also be combined with other custom rules by using [c()]:
|
||||||
|
#'
|
||||||
|
#' ```
|
||||||
|
#' x <- mdro(example_isolates,
|
||||||
|
#' guideline = c(custom,
|
||||||
|
#' custom_mdro_guideline(ERY == "R" & age > 50 ~ "Elderly Type C")))
|
||||||
|
#' table(x)
|
||||||
|
#' #> Negative Elderly Type A Elderly Type B Elderly Type C
|
||||||
|
#' #> 961 198 732 109
|
||||||
#' ```
|
#' ```
|
||||||
#'
|
#'
|
||||||
#' The rules set (the `custom` object in this case) could be exported to a shared file location using [saveRDS()] if you collaborate with multiple users. The custom rules set could then be imported using [readRDS()].
|
#' The rules set (the `custom` object in this case) could be exported to a shared file location using [saveRDS()] if you collaborate with multiple users. The custom rules set could then be imported using [readRDS()].
|
||||||
@@ -124,7 +136,7 @@
|
|||||||
#' @export
|
#' @export
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @source
|
#' @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
|
#' @examples
|
||||||
#' mdro(example_isolates, guideline = "EUCAST")
|
#' mdro(example_isolates, guideline = "EUCAST")
|
||||||
#'
|
#'
|
||||||
@@ -220,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)
|
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||||
|
|
||||||
if (pct_required_classes > 1) {
|
if (pct_required_classes > 1) {
|
||||||
@@ -240,13 +252,13 @@ mdro <- function(x = NULL,
|
|||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
txt <- paste0("Determining MDROs based on custom rules",
|
txt <- paste0("Determining MDROs based on custom rules",
|
||||||
ifelse(isTRUE(attributes(guideline)$as_factor),
|
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)
|
txt <- word_wrap(txt)
|
||||||
cat(txt, "\n", sep = "")
|
cat(txt, "\n", sep = "")
|
||||||
}
|
}
|
||||||
x <- run_custom_mdro_guideline(x, guideline)
|
x <- run_custom_mdro_guideline(df = x, guideline = guideline, info = info)
|
||||||
if (info.bak == TRUE) {
|
if (info.bak == TRUE) {
|
||||||
cat(group_msg)
|
cat(group_msg)
|
||||||
if (sum(!is.na(x$MDRO)) == 0) {
|
if (sum(!is.na(x$MDRO)) == 0) {
|
||||||
@@ -294,12 +306,11 @@ mdro <- function(x = NULL,
|
|||||||
}
|
}
|
||||||
if (is.null(col_mo) & guideline$code == "tb") {
|
if (is.null(col_mo) & guideline$code == "tb") {
|
||||||
message_("No column found as input for `col_mo`, ",
|
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]
|
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"
|
col_mo <- "mo"
|
||||||
}
|
}
|
||||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
|
||||||
|
|
||||||
if (guideline$code == "cmi2012") {
|
if (guideline$code == "cmi2012") {
|
||||||
guideline$name <- "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance."
|
guideline$name <- "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance."
|
||||||
@@ -350,7 +361,7 @@ mdro <- function(x = NULL,
|
|||||||
if (guideline$code == "cmi2012") {
|
if (guideline$code == "cmi2012") {
|
||||||
cols_ab <- get_column_abx(x = x,
|
cols_ab <- get_column_abx(x = x,
|
||||||
soft_dependencies = c(
|
soft_dependencies = c(
|
||||||
# table 1 (S aureus):
|
# [table] 1 (S aureus):
|
||||||
"GEN",
|
"GEN",
|
||||||
"RIF",
|
"RIF",
|
||||||
"CPT",
|
"CPT",
|
||||||
@@ -373,7 +384,7 @@ mdro <- function(x = NULL,
|
|||||||
"TCY",
|
"TCY",
|
||||||
"DOX",
|
"DOX",
|
||||||
"MNO",
|
"MNO",
|
||||||
# table 2 (Enterococcus)
|
# [table] 2 (Enterococcus)
|
||||||
"GEH",
|
"GEH",
|
||||||
"STH",
|
"STH",
|
||||||
"IPM",
|
"IPM",
|
||||||
@@ -391,7 +402,7 @@ mdro <- function(x = NULL,
|
|||||||
"QDA",
|
"QDA",
|
||||||
"DOX",
|
"DOX",
|
||||||
"MNO",
|
"MNO",
|
||||||
# table 3 (Enterobacteriaceae)
|
# [table] 3 (Enterobacteriaceae)
|
||||||
"GEN",
|
"GEN",
|
||||||
"TOB",
|
"TOB",
|
||||||
"AMK",
|
"AMK",
|
||||||
@@ -423,7 +434,7 @@ mdro <- function(x = NULL,
|
|||||||
"TCY",
|
"TCY",
|
||||||
"DOX",
|
"DOX",
|
||||||
"MNO",
|
"MNO",
|
||||||
# table 4 (Pseudomonas)
|
# [table] 4 (Pseudomonas)
|
||||||
"GEN",
|
"GEN",
|
||||||
"TOB",
|
"TOB",
|
||||||
"AMK",
|
"AMK",
|
||||||
@@ -441,7 +452,7 @@ mdro <- function(x = NULL,
|
|||||||
"FOS",
|
"FOS",
|
||||||
"COL",
|
"COL",
|
||||||
"PLB",
|
"PLB",
|
||||||
# table 5 (Acinetobacter)
|
# [table] 5 (Acinetobacter)
|
||||||
"GEN",
|
"GEN",
|
||||||
"TOB",
|
"TOB",
|
||||||
"AMK",
|
"AMK",
|
||||||
@@ -749,7 +760,11 @@ mdro <- function(x = NULL,
|
|||||||
row_filter <- x[which(row_filter), "row_number", drop = TRUE]
|
row_filter <- x[which(row_filter), "row_number", drop = TRUE]
|
||||||
rows <- rows[rows %in% row_filter]
|
rows <- rows[rows %in% row_filter]
|
||||||
x[rows, "MDRO"] <<- to
|
x[rows, "MDRO"] <<- to
|
||||||
x[rows, "reason"] <<- paste0(any_all, " of the required antibiotics ", ifelse(any_all == "any", "is", "are"), " R")
|
x[rows, "reason"] <<- paste0(any_all,
|
||||||
|
" of the required antibiotics ",
|
||||||
|
ifelse(any_all == "any", "is", "are"),
|
||||||
|
" R",
|
||||||
|
ifelse(!isTRUE(combine_SI), " or I", ""))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trans_tbl2 <- function(txt, rows, lst) {
|
trans_tbl2 <- function(txt, rows, lst) {
|
||||||
@@ -802,6 +817,9 @@ mdro <- function(x = NULL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
x[, col_mo] <- as.mo(as.character(x[, col_mo, drop = TRUE]))
|
x[, col_mo] <- as.mo(as.character(x[, col_mo, drop = TRUE]))
|
||||||
|
# rename col_mo to prevent interference with joined columns
|
||||||
|
colnames(x)[colnames(x) == col_mo] <- ".col_mo"
|
||||||
|
col_mo <- ".col_mo"
|
||||||
# join to microorganisms data set
|
# join to microorganisms data set
|
||||||
x <- left_join_microorganisms(x, by = col_mo)
|
x <- left_join_microorganisms(x, by = col_mo)
|
||||||
x$MDRO <- ifelse(!is.na(x$genus), 1, NA_integer_)
|
x$MDRO <- ifelse(!is.na(x$genus), 1, NA_integer_)
|
||||||
@@ -1015,7 +1033,10 @@ mdro <- function(x = NULL,
|
|||||||
# PDR (=4): all agents are R
|
# PDR (=4): all agents are R
|
||||||
x[which(x$classes_affected == 999 & x$classes_in_guideline == x$classes_available), "MDRO"] <- 4
|
x[which(x$classes_affected == 999 & x$classes_in_guideline == x$classes_available), "MDRO"] <- 4
|
||||||
if (verbose == TRUE) {
|
if (verbose == TRUE) {
|
||||||
x[which(x$MDRO == 4), "reason"] <- paste("all antibiotics in all", x$classes_in_guideline[which(x$MDRO == 4)], "classes were tested R or I")
|
x[which(x$MDRO == 4), "reason"] <- paste("all antibiotics in all",
|
||||||
|
x$classes_in_guideline[which(x$MDRO == 4)],
|
||||||
|
"classes were tested R",
|
||||||
|
ifelse(!isTRUE(combine_SI), " or I", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
# not enough classes available
|
# not enough classes available
|
||||||
@@ -1319,7 +1340,7 @@ mdro <- function(x = NULL,
|
|||||||
ab
|
ab
|
||||||
}
|
}
|
||||||
drug_is_R <- function(ab) {
|
drug_is_R <- function(ab) {
|
||||||
# returns logical vector
|
# returns [logical] vector
|
||||||
ab <- prepare_drug(ab)
|
ab <- prepare_drug(ab)
|
||||||
if (length(ab) == 0) {
|
if (length(ab) == 0) {
|
||||||
rep(FALSE, NROW(x))
|
rep(FALSE, NROW(x))
|
||||||
@@ -1330,7 +1351,7 @@ mdro <- function(x = NULL,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
drug_is_not_R <- function(ab) {
|
drug_is_not_R <- function(ab) {
|
||||||
# returns logical vector
|
# returns [logical] vector
|
||||||
ab <- prepare_drug(ab)
|
ab <- prepare_drug(ab)
|
||||||
if (length(ab) == 0) {
|
if (length(ab) == 0) {
|
||||||
rep(TRUE, NROW(x))
|
rep(TRUE, NROW(x))
|
||||||
@@ -1378,7 +1399,12 @@ mdro <- function(x = NULL,
|
|||||||
# some more info on negative results
|
# some more info on negative results
|
||||||
if (verbose == TRUE) {
|
if (verbose == TRUE) {
|
||||||
if (guideline$code == "cmi2012") {
|
if (guideline$code == "cmi2012") {
|
||||||
x[which(x$MDRO == 1 & !is.na(x$classes_affected)), "reason"] <- paste0(x$classes_affected[which(x$MDRO == 1 & !is.na(x$classes_affected))], " of ", x$classes_available[which(x$MDRO == 1 & !is.na(x$classes_affected))], " available classes contain R or I (3 required for MDR)")
|
x[which(x$MDRO == 1 & !is.na(x$classes_affected)), "reason"] <- paste0(x$classes_affected[which(x$MDRO == 1 & !is.na(x$classes_affected))],
|
||||||
|
" of ",
|
||||||
|
x$classes_available[which(x$MDRO == 1 & !is.na(x$classes_affected))],
|
||||||
|
" available classes contain R",
|
||||||
|
ifelse(!isTRUE(combine_SI), " or I", ""),
|
||||||
|
" (3 required for MDR)")
|
||||||
} else {
|
} else {
|
||||||
x[which(x$MDRO == 1), "reason"] <- "too few antibiotics are R"
|
x[which(x$MDRO == 1), "reason"] <- "too few antibiotics are R"
|
||||||
}
|
}
|
||||||
@@ -1419,8 +1445,10 @@ mdro <- function(x = NULL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (verbose == TRUE) {
|
if (verbose == TRUE) {
|
||||||
|
colnames(x)[colnames(x) == col_mo] <- "microorganism"
|
||||||
|
x$microorganism <- mo_name(x$microorganism, language = NULL)
|
||||||
x[, c("row_number",
|
x[, c("row_number",
|
||||||
col_mo,
|
"microorganism",
|
||||||
"MDRO",
|
"MDRO",
|
||||||
"reason",
|
"reason",
|
||||||
"columns_nonsusceptible"),
|
"columns_nonsusceptible"),
|
||||||
@@ -1434,6 +1462,8 @@ mdro <- function(x = NULL,
|
|||||||
#' @rdname mdro
|
#' @rdname mdro
|
||||||
#' @export
|
#' @export
|
||||||
custom_mdro_guideline <- function(..., as_factor = TRUE) {
|
custom_mdro_guideline <- function(..., as_factor = TRUE) {
|
||||||
|
meet_criteria(as_factor, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
dots <- tryCatch(list(...),
|
dots <- tryCatch(list(...),
|
||||||
error = function(e) "error")
|
error = function(e) "error")
|
||||||
stop_if(identical(dots, "error"),
|
stop_if(identical(dots, "error"),
|
||||||
@@ -1470,11 +1500,49 @@ custom_mdro_guideline <- function(..., as_factor = TRUE) {
|
|||||||
|
|
||||||
names(out) <- paste0("rule", seq_len(n_dots))
|
names(out) <- paste0("rule", seq_len(n_dots))
|
||||||
out <- set_clean_class(out, new_class = c("custom_mdro_guideline", "list"))
|
out <- set_clean_class(out, new_class = c("custom_mdro_guideline", "list"))
|
||||||
attr(out, "values") <- c("Negative", vapply(FUN.VALUE = character(1), out, function(x) x$value))
|
attr(out, "values") <- unname(c("Negative", vapply(FUN.VALUE = character(1), unclass(out), function(x) x$value)))
|
||||||
attr(out, "as_factor") <- as_factor
|
attr(out, "as_factor") <- as_factor
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' @method c custom_mdro_guideline
|
||||||
|
#' @noRd
|
||||||
|
#' @export
|
||||||
|
c.custom_mdro_guideline <- function(x, ..., as_factor = NULL) {
|
||||||
|
if (length(list(...)) == 0) {
|
||||||
|
return(x)
|
||||||
|
}
|
||||||
|
if (!is.null(as_factor)) {
|
||||||
|
meet_criteria(as_factor, allow_class = "logical", has_length = 1)
|
||||||
|
} else {
|
||||||
|
as_factor <- attributes(x)$as_factor
|
||||||
|
}
|
||||||
|
for (g in list(...)) {
|
||||||
|
stop_ifnot(inherits(g, "custom_mdro_guideline"),
|
||||||
|
"for combining custom MDRO guidelines, all rules must be created with `custom_mdro_guideline()`",
|
||||||
|
call = FALSE)
|
||||||
|
vals <- attributes(x)$values
|
||||||
|
if (!all(attributes(g)$values %in% vals)) {
|
||||||
|
vals <- unname(unique(c(vals, attributes(g)$values)))
|
||||||
|
}
|
||||||
|
attributes(g) <- NULL
|
||||||
|
x <- c(unclass(x), unclass(g))
|
||||||
|
attr(x, "values") <- vals
|
||||||
|
}
|
||||||
|
names(x) <- paste0("rule", seq_len(length(x)))
|
||||||
|
x <- set_clean_class(x, new_class = c("custom_mdro_guideline", "list"))
|
||||||
|
attr(x, "values") <- vals
|
||||||
|
attr(x, "as_factor") <- as_factor
|
||||||
|
x
|
||||||
|
}
|
||||||
|
|
||||||
|
#' @method as.list custom_mdro_guideline
|
||||||
|
#' @noRd
|
||||||
|
#' @export
|
||||||
|
as.list.custom_mdro_guideline <- function(x, ...) {
|
||||||
|
c(x, ...)
|
||||||
|
}
|
||||||
|
|
||||||
#' @method print custom_mdro_guideline
|
#' @method print custom_mdro_guideline
|
||||||
#' @export
|
#' @export
|
||||||
#' @noRd
|
#' @noRd
|
||||||
@@ -1482,23 +1550,10 @@ print.custom_mdro_guideline <- function(x, ...) {
|
|||||||
cat("A set of custom MDRO rules:\n")
|
cat("A set of custom MDRO rules:\n")
|
||||||
for (i in seq_len(length(x))) {
|
for (i in seq_len(length(x))) {
|
||||||
rule <- x[[i]]
|
rule <- x[[i]]
|
||||||
rule$query <- gsub(" & ", font_black(font_italic(" and ")), rule$query, fixed = TRUE)
|
rule$query <- format_custom_query_rule(rule$query)
|
||||||
rule$query <- gsub(" | ", font_black(" or "), rule$query, fixed = TRUE)
|
cat(" ", i, ". ", font_bold("If "), font_blue(rule$query), font_bold(" then: "), font_red(rule$value), "\n", sep = "")
|
||||||
rule$query <- gsub(" + ", font_black(" plus "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" - ", font_black(" minus "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" / ", font_black(" divided by "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" * ", font_black(" times "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" == ", font_black(" is "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" > ", font_black(" is higher than "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" < ", font_black(" is lower than "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" >= ", font_black(" is higher than or equal to "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" <= ", font_black(" is lower than or equal to "), rule$query, fixed = TRUE)
|
|
||||||
rule$query <- gsub(" ^ ", font_black(" to the power of "), rule$query, fixed = TRUE)
|
|
||||||
# replace the black colour 'stops' with blue colour 'starts'
|
|
||||||
rule$query <- gsub("\033[39m", "\033[34m", as.character(rule$query), fixed = TRUE)
|
|
||||||
cat(" ", i, ". ", font_blue(rule$query), font_bold(" -> "), font_red(rule$value), "\n", sep = "")
|
|
||||||
}
|
}
|
||||||
cat(" ", i + 1, ". Otherwise", font_bold(" -> "), font_red(paste0("Negative")), "\n", sep = "")
|
cat(" ", i + 1, ". ", font_bold("Otherwise: "), font_red(paste0("Negative")), "\n", sep = "")
|
||||||
cat("\nUnmatched rows will return ", font_red("NA"), ".\n", sep = "")
|
cat("\nUnmatched rows will return ", font_red("NA"), ".\n", sep = "")
|
||||||
if (isTRUE(attributes(x)$as_factor)) {
|
if (isTRUE(attributes(x)$as_factor)) {
|
||||||
cat("Results will be of class <factor>, with ordered levels: ", paste0(attributes(x)$values, collapse = " < "), "\n", sep = "")
|
cat("Results will be of class <factor>, with ordered levels: ", paste0(attributes(x)$values, collapse = " < "), "\n", sep = "")
|
||||||
@@ -1507,7 +1562,7 @@ print.custom_mdro_guideline <- function(x, ...) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run_custom_mdro_guideline <- function(df, guideline) {
|
run_custom_mdro_guideline <- function(df, guideline, info) {
|
||||||
n_dots <- length(guideline)
|
n_dots <- length(guideline)
|
||||||
stop_if(n_dots == 0, "no custom guidelines set", call = -2)
|
stop_if(n_dots == 0, "no custom guidelines set", call = -2)
|
||||||
out <- character(length = NROW(df))
|
out <- character(length = NROW(df))
|
||||||
@@ -1520,7 +1575,7 @@ run_custom_mdro_guideline <- function(df, guideline) {
|
|||||||
})
|
})
|
||||||
if (identical(qry, "error")) {
|
if (identical(qry, "error")) {
|
||||||
warning_("in custom_mdro_guideline(): rule ", i,
|
warning_("in custom_mdro_guideline(): rule ", i,
|
||||||
" (`", guideline[[i]]$query, "`) was ignored because of this error message: ",
|
" (`", as.character(guideline[[i]]$query), "`) was ignored because of this error message: ",
|
||||||
pkg_env$err_msg,
|
pkg_env$err_msg,
|
||||||
call = FALSE,
|
call = FALSE,
|
||||||
add_fn = font_red)
|
add_fn = font_red)
|
||||||
@@ -1529,9 +1584,16 @@ run_custom_mdro_guideline <- function(df, guideline) {
|
|||||||
stop_ifnot(is.logical(qry), "in custom_mdro_guideline(): rule ", i, " (`", guideline[[i]]$query,
|
stop_ifnot(is.logical(qry), "in custom_mdro_guideline(): rule ", i, " (`", guideline[[i]]$query,
|
||||||
"`) must return `TRUE` or `FALSE`, not ",
|
"`) must return `TRUE` or `FALSE`, not ",
|
||||||
format_class(class(qry), plural = FALSE), call = FALSE)
|
format_class(class(qry), plural = FALSE), call = FALSE)
|
||||||
|
|
||||||
|
new_mdros <- which(qry == TRUE & out == "")
|
||||||
|
|
||||||
|
if (info == TRUE) {
|
||||||
|
cat(word_wrap("- Custom MDRO rule ", i, ": `", as.character(guideline[[i]]$query),
|
||||||
|
"` (", length(new_mdros), " rows matched)"), "\n", sep = "")
|
||||||
|
}
|
||||||
val <- guideline[[i]]$value
|
val <- guideline[[i]]$value
|
||||||
out[which(qry)] <- val
|
out[new_mdros] <- val
|
||||||
reasons[which(qry)] <- paste0("matched rule ", gsub("rule", "", names(guideline)[i]), ": ", as.character(guideline[[i]]$query))
|
reasons[new_mdros] <- paste0("matched rule ", gsub("rule", "", names(guideline)[i]), ": ", as.character(guideline[[i]]$query))
|
||||||
}
|
}
|
||||||
out[out == ""] <- "Negative"
|
out[out == ""] <- "Negative"
|
||||||
reasons[out == "Negative"] <- "no rules matched"
|
reasons[out == "Negative"] <- "no rules matched"
|
||||||
@@ -1540,8 +1602,7 @@ run_custom_mdro_guideline <- function(df, guideline) {
|
|||||||
out <- factor(out, levels = attributes(guideline)$values, ordered = TRUE)
|
out <- factor(out, levels = attributes(guideline)$values, ordered = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
rsi_cols <- vapply(FUN.VALUE = logical(1), df, function(x) is.rsi(x))
|
columns_nonsusceptible <- as.data.frame(t(df[, is.rsi(df)] == "R"))
|
||||||
columns_nonsusceptible <- as.data.frame(t(df[, rsi_cols] == "R"))
|
|
||||||
columns_nonsusceptible <- vapply(FUN.VALUE = character(1),
|
columns_nonsusceptible <- vapply(FUN.VALUE = character(1),
|
||||||
columns_nonsusceptible,
|
columns_nonsusceptible,
|
||||||
function(x) paste0(rownames(columns_nonsusceptible)[which(x)], collapse = " "))
|
function(x) paste0(rownames(columns_nonsusceptible)[which(x)], collapse = " "))
|
||||||
|
|||||||
33
R/mic.R
@@ -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.
|
#' 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
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @rdname as.mic
|
#' @rdname as.mic
|
||||||
#' @param x character or numeric vector
|
#' @param x a [character] or [numeric] 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 To interpret MIC values as RSI values, use [as.rsi()] on MIC values. It supports guidelines from EUCAST and CLSI.
|
#' @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)
|
#' x <- random_mic(10)
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
#' #> [1] 26
|
#' #> [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]
|
#' 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.
|
#' 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
|
#' @aliases mic
|
||||||
#' @export
|
#' @export
|
||||||
#' @seealso [as.rsi()]
|
#' @seealso [as.rsi()]
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
#' # this can also coerce combined MIC/RSI values:
|
#' # this can also coerce combined MIC/RSI values:
|
||||||
#' as.mic("<=0.002; S") # will return <=0.002
|
#' 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)
|
#' fivenum(mic_data)
|
||||||
#' quantile(mic_data)
|
#' quantile(mic_data)
|
||||||
#' all(mic_data < 512)
|
#' all(mic_data < 512)
|
||||||
@@ -133,7 +133,7 @@ as.mic <- function(x, na.rm = FALSE) {
|
|||||||
# keep only one zero before dot
|
# keep only one zero before dot
|
||||||
x <- gsub("0+[.]", "0.", x, perl = TRUE)
|
x <- gsub("0+[.]", "0.", x, perl = TRUE)
|
||||||
# starting 00 is probably 0.0 if there's no dot yet
|
# starting 00 is probably 0.0 if there's no dot yet
|
||||||
x[!x %like% "[.]"] <- gsub("^00", "0.0", x[!x %like% "[.]"])
|
x[x %unlike% "[.]"] <- gsub("^00", "0.0", x[!x %like% "[.]"])
|
||||||
# remove last zeroes
|
# remove last zeroes
|
||||||
x <- gsub("([.].?)0+$", "\\1", x, perl = TRUE)
|
x <- gsub("([.].?)0+$", "\\1", x, perl = TRUE)
|
||||||
x <- gsub("(.*[.])0+$", "\\10", x, perl = TRUE)
|
x <- gsub("(.*[.])0+$", "\\10", x, perl = TRUE)
|
||||||
@@ -149,7 +149,7 @@ as.mic <- function(x, na.rm = FALSE) {
|
|||||||
## previously unempty values now empty - should return a warning later on
|
## previously unempty values now empty - should return a warning later on
|
||||||
x[x.bak != "" & x == ""] <- "invalid"
|
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("<", "<=", "", ">=", ">")
|
ops <- c("<", "<=", "", ">=", ">")
|
||||||
lvls <- c(c(t(vapply(FUN.VALUE = character(9), ops, function(x) paste0(x, "0.00", 1:9)))),
|
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",
|
unique(c(t(vapply(FUN.VALUE = character(104), ops, function(x) paste0(x, sort(as.double(paste0("0.0",
|
||||||
@@ -307,10 +307,8 @@ as.matrix.mic <- function(x, ...) {
|
|||||||
#' @method c mic
|
#' @method c mic
|
||||||
#' @export
|
#' @export
|
||||||
#' @noRd
|
#' @noRd
|
||||||
c.mic <- function(x, ...) {
|
c.mic <- function(...) {
|
||||||
y <- unlist(lapply(list(...), as.character))
|
as.mic(unlist(lapply(list(...), as.character)))
|
||||||
x <- as.character(x)
|
|
||||||
as.mic(c(x, y))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @method unique mic
|
#' @method unique mic
|
||||||
@@ -347,11 +345,12 @@ hist.mic <- function(x, ...) {
|
|||||||
get_skimmers.mic <- function(column) {
|
get_skimmers.mic <- function(column) {
|
||||||
skimr::sfl(
|
skimr::sfl(
|
||||||
skim_type = "mic",
|
skim_type = "mic",
|
||||||
min = ~min(., na.rm = TRUE),
|
p0 = ~stats::quantile(., probs = 0, na.rm = TRUE, names = FALSE),
|
||||||
max = ~max(., na.rm = TRUE),
|
p25 = ~stats::quantile(., probs = 0.25, na.rm = TRUE, names = FALSE),
|
||||||
median = ~stats::median(., na.rm = TRUE),
|
p50 = ~stats::quantile(., probs = 0.5, na.rm = TRUE, names = FALSE),
|
||||||
n_unique = ~pm_n_distinct(., na.rm = TRUE),
|
p75 = ~stats::quantile(., probs = 0.75, na.rm = TRUE, names = FALSE),
|
||||||
hist_log2 = ~skimr::inline_hist(log2(stats::na.omit(.)))
|
p100 = ~stats::quantile(., probs = 1, na.rm = TRUE, names = FALSE),
|
||||||
|
hist = ~skimr::inline_hist(log2(stats::na.omit(.)), 5)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
100
R/mo.R
@@ -27,17 +27,18 @@
|
|||||||
#'
|
#'
|
||||||
#' Use this function to determine a valid microorganism ID ([`mo`]). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea and most microbial species from the kingdom Fungi (see *Source*). The input can be almost anything: a full name (like `"Staphylococcus aureus"`), an abbreviated name (such as `"S. aureus"`), an abbreviation known in the field (such as `"MRSA"`), or just a genus. See *Examples*.
|
#' Use this function to determine a valid microorganism 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
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x a character vector or a [data.frame] with one or two columns
|
#' @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 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".
|
#' 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.
|
#' This excludes *Enterococci* at default (who are in group D), use `Lancefield = "all"` to also categorise all *Enterococci* as group D.
|
||||||
#' @param allow_uncertain a number between `0` (or `"none"`) and `3` (or `"all"`), or `TRUE` (= `2`) or `FALSE` (= `0`) to indicate whether the input should be checked for less probable results, see *Details*
|
#' @param allow_uncertain a number between `0` (or `"none"`) and `3` (or `"all"`), or `TRUE` (= `2`) or `FALSE` (= `0`) to indicate whether the input should be checked for less probable results, see *Details*
|
||||||
#' @param reference_df a [data.frame] to be used for extra reference when translating `x` to a valid [`mo`]. See [set_mo_source()] and [get_mo_source()] to automate the usage of your own codes (e.g. used in your analysis or organisation).
|
#' @param reference_df a [data.frame] to be used for extra reference when translating `x` to a valid [`mo`]. See [set_mo_source()] and [get_mo_source()] to automate the usage of your own codes (e.g. used in your analysis or organisation).
|
||||||
#' @param ignore_pattern a regular expression (case-insensitive) of which all matches in `x` must return `NA`. This can be convenient to exclude known non-relevant input and can also be set with the option `AMR_ignore_pattern`, e.g. `options(AMR_ignore_pattern = "(not reported|contaminated flora)")`.
|
#' @param ignore_pattern a regular expression (case-insensitive) of which all matches in `x` must return `NA`. This can be convenient to exclude known non-relevant input and can also be set with the option `AMR_ignore_pattern`, e.g. `options(AMR_ignore_pattern = "(not reported|contaminated flora)")`.
|
||||||
#' @param language language to translate text like "no growth", which defaults to the system language (see [get_locale()])
|
#' @param language language to translate text like "no growth", which defaults to the system language (see [get_locale()])
|
||||||
|
#' @param info a [logical] to indicate if a progress bar should be printed if more than 25 items are to be coerced, defaults to `TRUE` only in interactive mode
|
||||||
#' @param ... other arguments passed on to functions
|
#' @param ... other arguments passed on to functions
|
||||||
#' @rdname as.mo
|
#' @rdname as.mo
|
||||||
#' @aliases mo
|
#' @aliases mo
|
||||||
@@ -161,6 +162,7 @@ as.mo <- function(x,
|
|||||||
reference_df = get_mo_source(),
|
reference_df = get_mo_source(),
|
||||||
ignore_pattern = getOption("AMR_ignore_pattern"),
|
ignore_pattern = getOption("AMR_ignore_pattern"),
|
||||||
language = get_locale(),
|
language = get_locale(),
|
||||||
|
info = interactive(),
|
||||||
...) {
|
...) {
|
||||||
meet_criteria(x, allow_class = c("mo", "data.frame", "list", "character", "numeric", "integer", "factor"), allow_NA = TRUE)
|
meet_criteria(x, allow_class = c("mo", "data.frame", "list", "character", "numeric", "integer", "factor"), allow_NA = TRUE)
|
||||||
meet_criteria(Becker, allow_class = c("logical", "character"), has_length = 1)
|
meet_criteria(Becker, allow_class = c("logical", "character"), has_length = 1)
|
||||||
@@ -169,6 +171,7 @@ as.mo <- function(x,
|
|||||||
meet_criteria(reference_df, allow_class = "data.frame", allow_NULL = TRUE)
|
meet_criteria(reference_df, allow_class = "data.frame", allow_NULL = TRUE)
|
||||||
meet_criteria(ignore_pattern, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
meet_criteria(ignore_pattern, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
|
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
check_dataset_integrity()
|
check_dataset_integrity()
|
||||||
|
|
||||||
@@ -227,6 +230,7 @@ as.mo <- function(x,
|
|||||||
reference_df = reference_df,
|
reference_df = reference_df,
|
||||||
ignore_pattern = ignore_pattern,
|
ignore_pattern = ignore_pattern,
|
||||||
language = language,
|
language = language,
|
||||||
|
info = info,
|
||||||
...)
|
...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,10 +245,10 @@ is.mo <- function(x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# param property a column name of microorganisms
|
# 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 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 dyslexia_mode [logical] - also check for characters that resemble others
|
||||||
# param debug logical - show different lookup texts while searching
|
# param debug [logical] - show different lookup texts while searching
|
||||||
# param reference_data_to_use data.frame - the data set to check for
|
# 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_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 actual_input - (only for initial_search = FALSE) the actual, original input
|
||||||
# param language - used for translating "no growth", etc.
|
# param language - used for translating "no growth", etc.
|
||||||
@@ -253,6 +257,7 @@ exec_as.mo <- function(x,
|
|||||||
Lancefield = FALSE,
|
Lancefield = FALSE,
|
||||||
allow_uncertain = TRUE,
|
allow_uncertain = TRUE,
|
||||||
reference_df = get_mo_source(),
|
reference_df = get_mo_source(),
|
||||||
|
info = interactive(),
|
||||||
property = "mo",
|
property = "mo",
|
||||||
initial_search = TRUE,
|
initial_search = TRUE,
|
||||||
dyslexia_mode = FALSE,
|
dyslexia_mode = FALSE,
|
||||||
@@ -299,7 +304,7 @@ exec_as.mo <- function(x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
# `column` can be NULL for all columns, or a selection
|
# `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)) {
|
if (isTRUE(debug_mode)) {
|
||||||
cat(font_silver("Looking up: ", substitute(needle), collapse = ""),
|
cat(font_silver("Looking up: ", substitute(needle), collapse = ""),
|
||||||
"\n ", time_track())
|
"\n ", time_track())
|
||||||
@@ -600,7 +605,7 @@ exec_as.mo <- function(x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (initial_search == TRUE) {
|
if (initial_search == TRUE) {
|
||||||
progress <- progress_ticker(n = length(x[!already_known]), n_min = 25) # start if n >= 25
|
progress <- progress_ticker(n = length(x[!already_known]), n_min = 25, print = info) # start if n >= 25
|
||||||
on.exit(close(progress))
|
on.exit(close(progress))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,7 +708,7 @@ exec_as.mo <- function(x,
|
|||||||
|
|
||||||
# check for very small input, but ignore the O antigens of E. coli
|
# check for very small input, but ignore the O antigens of E. coli
|
||||||
if (nchar(gsub("[^a-zA-Z]", "", x_trimmed[i])) < 3
|
if (nchar(gsub("[^a-zA-Z]", "", x_trimmed[i])) < 3
|
||||||
& !toupper(x_backup_without_spp[i]) %like_case% "O?(26|103|104|104|111|121|145|157)") {
|
& toupper(x_backup_without_spp[i]) %unlike_case% "O?(26|103|104|104|111|121|145|157)") {
|
||||||
# fewer than 3 chars and not looked for species, add as failure
|
# fewer than 3 chars and not looked for species, add as failure
|
||||||
x[i] <- lookup(mo == "UNKNOWN")
|
x[i] <- lookup(mo == "UNKNOWN")
|
||||||
if (initial_search == TRUE) {
|
if (initial_search == TRUE) {
|
||||||
@@ -855,7 +860,7 @@ exec_as.mo <- function(x,
|
|||||||
x[i] <- lookup(genus == "Salmonella", uncertainty = -1)
|
x[i] <- lookup(genus == "Salmonella", uncertainty = -1)
|
||||||
next
|
next
|
||||||
} else if (x_backup[i] %like_case% "[sS]almonella [A-Z][a-z]+ ?.*" &
|
} else if (x_backup[i] %like_case% "[sS]almonella [A-Z][a-z]+ ?.*" &
|
||||||
!x_backup[i] %like% "t[iy](ph|f)[iy]") {
|
x_backup[i] %unlike% "t[iy](ph|f)[iy]") {
|
||||||
# Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica
|
# Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica
|
||||||
# except for S. typhi, S. paratyphi, S. typhimurium
|
# except for S. typhi, S. paratyphi, S. typhimurium
|
||||||
x[i] <- lookup(fullname == "Salmonella enterica", uncertainty = -1)
|
x[i] <- lookup(fullname == "Salmonella enterica", uncertainty = -1)
|
||||||
@@ -911,7 +916,7 @@ exec_as.mo <- function(x,
|
|||||||
# FIRST TRY FULLNAMES AND CODES ----
|
# FIRST TRY FULLNAMES AND CODES ----
|
||||||
# if only genus is available, return only genus
|
# if only genus is available, return only genus
|
||||||
|
|
||||||
if (all(!c(x[i], b.x_trimmed) %like_case% " ")) {
|
if (all(c(x[i], b.x_trimmed) %unlike_case% " ")) {
|
||||||
found <- lookup(fullname_lower %in% c(h.x_species, i.x_trimmed_species),
|
found <- lookup(fullname_lower %in% c(h.x_species, i.x_trimmed_species),
|
||||||
haystack = data_to_check)
|
haystack = data_to_check)
|
||||||
if (!is.na(found)) {
|
if (!is.na(found)) {
|
||||||
@@ -1118,8 +1123,8 @@ exec_as.mo <- function(x,
|
|||||||
if (isTRUE(debug)) {
|
if (isTRUE(debug)) {
|
||||||
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (3) look for genus only, part of name\n"))
|
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (3) look for genus only, part of name\n"))
|
||||||
}
|
}
|
||||||
if (nchar(g.x_backup_without_spp) > 4 & !b.x_trimmed %like_case% " ") {
|
if (nchar(g.x_backup_without_spp) > 4 & b.x_trimmed %unlike_case% " ") {
|
||||||
if (!b.x_trimmed %like_case% "^[A-Z][a-z]+") {
|
if (b.x_trimmed %unlike_case% "^[A-Z][a-z]+") {
|
||||||
if (isTRUE(debug)) {
|
if (isTRUE(debug)) {
|
||||||
message("Running '", paste(b.x_trimmed, "species"), "'")
|
message("Running '", paste(b.x_trimmed, "species"), "'")
|
||||||
}
|
}
|
||||||
@@ -1263,7 +1268,7 @@ exec_as.mo <- function(x,
|
|||||||
stringsAsFactors = FALSE)
|
stringsAsFactors = FALSE)
|
||||||
return(found)
|
return(found)
|
||||||
}
|
}
|
||||||
if (b.x_trimmed %like_case% "(fungus|fungi)" & !b.x_trimmed %like_case% "fungiphrya") {
|
if (b.x_trimmed %like_case% "(fungus|fungi)" & b.x_trimmed %unlike_case% "fungiphrya") {
|
||||||
found <- "F_FUNGUS"
|
found <- "F_FUNGUS"
|
||||||
found_result <- found
|
found_result <- found
|
||||||
found <- lookup(mo == found)
|
found <- lookup(mo == found)
|
||||||
@@ -1659,6 +1664,24 @@ pillar_shaft.mo <- function(x, ...) {
|
|||||||
out[is.na(x)] <- font_na(" NA")
|
out[is.na(x)] <- font_na(" NA")
|
||||||
out[x == "UNKNOWN"] <- font_na(" UNKNOWN")
|
out[x == "UNKNOWN"] <- font_na(" UNKNOWN")
|
||||||
|
|
||||||
|
if (!all(x[!is.na(x)] %in% MO_lookup$mo)) {
|
||||||
|
# markup old mo codes
|
||||||
|
out[!x %in% MO_lookup$mo] <- font_italic(font_na(x[!x %in% MO_lookup$mo],
|
||||||
|
collapse = NULL),
|
||||||
|
collapse = NULL)
|
||||||
|
# throw a warning with the affected column name
|
||||||
|
mo <- tryCatch(search_type_in_df(get_current_data(arg_name = "x", call = 0), type = "mo", info = FALSE),
|
||||||
|
error = function(e) NULL)
|
||||||
|
if (!is.null(mo)) {
|
||||||
|
col <- paste0("Column '", mo, "'")
|
||||||
|
} else {
|
||||||
|
col <- "The data"
|
||||||
|
}
|
||||||
|
warning_(col, " contains old MO codes (from a previous AMR package version). ",
|
||||||
|
"Please update your MO codes with `as.mo()`.",
|
||||||
|
call = FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
# make it always fit exactly
|
# make it always fit exactly
|
||||||
max_char <- max(nchar(x))
|
max_char <- max(nchar(x))
|
||||||
if (is.na(max_char)) {
|
if (is.na(max_char)) {
|
||||||
@@ -1709,9 +1732,9 @@ freq.mo <- function(x, ...) {
|
|||||||
get_skimmers.mo <- function(column) {
|
get_skimmers.mo <- function(column) {
|
||||||
skimr::sfl(
|
skimr::sfl(
|
||||||
skim_type = "mo",
|
skim_type = "mo",
|
||||||
unique_total = ~pm_n_distinct(., na.rm = TRUE),
|
unique_total = ~length(unique(stats::na.omit(.))),
|
||||||
gram_negative = ~sum(mo_is_gram_negative(stats::na.omit(.))),
|
gram_negative = ~sum(mo_is_gram_negative(.), na.rm = TRUE),
|
||||||
gram_positive = ~sum(mo_is_gram_positive(stats::na.omit(.))),
|
gram_positive = ~sum(mo_is_gram_positive(.), na.rm = TRUE),
|
||||||
top_genus = ~names(sort(-table(mo_genus(stats::na.omit(.), language = NULL))))[1L],
|
top_genus = ~names(sort(-table(mo_genus(stats::na.omit(.), language = NULL))))[1L],
|
||||||
top_species = ~names(sort(-table(mo_name(stats::na.omit(.), language = NULL))))[1L]
|
top_species = ~names(sort(-table(mo_name(stats::na.omit(.), language = NULL))))[1L]
|
||||||
)
|
)
|
||||||
@@ -1728,6 +1751,11 @@ print.mo <- function(x, print.shortnames = FALSE, ...) {
|
|||||||
}
|
}
|
||||||
x <- as.character(x)
|
x <- as.character(x)
|
||||||
names(x) <- x_names
|
names(x) <- x_names
|
||||||
|
if (!all(x[!is.na(x)] %in% MO_lookup$mo)) {
|
||||||
|
warning_("Some MO codes are from a previous AMR package version. ",
|
||||||
|
"Please update these MO codes with `as.mo()`.",
|
||||||
|
call = FALSE)
|
||||||
|
}
|
||||||
print.default(x, quote = FALSE)
|
print.default(x, quote = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1753,11 +1781,16 @@ summary.mo <- function(object, ...) {
|
|||||||
#' @export
|
#' @export
|
||||||
#' @noRd
|
#' @noRd
|
||||||
as.data.frame.mo <- function(x, ...) {
|
as.data.frame.mo <- function(x, ...) {
|
||||||
|
if (!all(x[!is.na(x)] %in% MO_lookup$mo)) {
|
||||||
|
warning_("The data contains old MO codes (from a previous AMR package version). ",
|
||||||
|
"Please update your MO codes with `as.mo()`.",
|
||||||
|
call = FALSE)
|
||||||
|
}
|
||||||
nm <- deparse1(substitute(x))
|
nm <- deparse1(substitute(x))
|
||||||
if (!"nm" %in% names(list(...))) {
|
if (!"nm" %in% names(list(...))) {
|
||||||
as.data.frame.vector(as.mo(x), ..., nm = nm)
|
as.data.frame.vector(x, ..., nm = nm)
|
||||||
} else {
|
} else {
|
||||||
as.data.frame.vector(as.mo(x), ...)
|
as.data.frame.vector(x, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1784,7 +1817,7 @@ as.data.frame.mo <- function(x, ...) {
|
|||||||
y <- NextMethod()
|
y <- NextMethod()
|
||||||
attributes(y) <- attributes(i)
|
attributes(y) <- attributes(i)
|
||||||
# must only contain valid MOs
|
# must only contain valid MOs
|
||||||
class_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
return_after_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
||||||
as.character(microorganisms.translation$mo_old)))
|
as.character(microorganisms.translation$mo_old)))
|
||||||
}
|
}
|
||||||
#' @method [[<- mo
|
#' @method [[<- mo
|
||||||
@@ -1794,17 +1827,17 @@ as.data.frame.mo <- function(x, ...) {
|
|||||||
y <- NextMethod()
|
y <- NextMethod()
|
||||||
attributes(y) <- attributes(i)
|
attributes(y) <- attributes(i)
|
||||||
# must only contain valid MOs
|
# must only contain valid MOs
|
||||||
class_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
return_after_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
||||||
as.character(microorganisms.translation$mo_old)))
|
as.character(microorganisms.translation$mo_old)))
|
||||||
}
|
}
|
||||||
#' @method c mo
|
#' @method c mo
|
||||||
#' @export
|
#' @export
|
||||||
#' @noRd
|
#' @noRd
|
||||||
c.mo <- function(x, ...) {
|
c.mo <- function(...) {
|
||||||
|
x <- list(...)[[1L]]
|
||||||
y <- NextMethod()
|
y <- NextMethod()
|
||||||
attributes(y) <- attributes(x)
|
attributes(y) <- attributes(x)
|
||||||
# must only contain valid MOs
|
return_after_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
||||||
class_integrity_check(y, "microorganism code", c(as.character(microorganisms$mo),
|
|
||||||
as.character(microorganisms.translation$mo_old)))
|
as.character(microorganisms.translation$mo_old)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1875,6 +1908,7 @@ print.mo_uncertainties <- function(x, ...) {
|
|||||||
collapse = "")
|
collapse = "")
|
||||||
# after strwrap, make taxonomic names italic
|
# after strwrap, make taxonomic names italic
|
||||||
candidates <- gsub("([A-Za-z]+)", font_italic("\\1"), candidates, perl = TRUE)
|
candidates <- gsub("([A-Za-z]+)", font_italic("\\1"), candidates, perl = TRUE)
|
||||||
|
candidates <- gsub(font_italic("and"), "and", candidates, fixed = TRUE)
|
||||||
candidates <- gsub(paste(font_italic(c("Also", "matched"), collapse = NULL), collapse = " "),
|
candidates <- gsub(paste(font_italic(c("Also", "matched"), collapse = NULL), collapse = " "),
|
||||||
"Also matched",
|
"Also matched",
|
||||||
candidates, fixed = TRUE)
|
candidates, fixed = TRUE)
|
||||||
@@ -2028,13 +2062,15 @@ replace_old_mo_codes <- function(x, property) {
|
|||||||
x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))]
|
x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))]
|
||||||
n_matched <- length(matched[!is.na(matched)])
|
n_matched <- length(matched[!is.na(matched)])
|
||||||
if (property != "mo") {
|
if (property != "mo") {
|
||||||
message_(font_blue("The input contained old microbial codes (from previous package versions). Please update your MO codes with `as.mo()`."))
|
message_(font_blue(paste0("The input contained ", n_matched,
|
||||||
|
" old MO code", ifelse(n_matched == 1, "", "s"),
|
||||||
|
" (from a previous AMR package version). Please update your MO codes with `as.mo()`.")))
|
||||||
} else {
|
} else {
|
||||||
if (n_matched == 1) {
|
message_(font_blue(paste0(n_matched, " old MO code", ifelse(n_matched == 1, "", "s"),
|
||||||
message_(font_blue("1 old microbial code (from previous package versions) was updated to a current used MO code."))
|
" (from a previous AMR package version) ",
|
||||||
} else {
|
ifelse(n_matched == 1, "was", "were"),
|
||||||
message_(font_blue(n_matched, "old microbial codes (from previous package versions) were updated to current used MO codes."))
|
" updated to ", ifelse(n_matched == 1, "a ", ""),
|
||||||
}
|
"currently used MO code", ifelse(n_matched == 1, "", "s"), ".")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x
|
x
|
||||||
@@ -2069,7 +2105,7 @@ repair_reference_df <- function(reference_df) {
|
|||||||
reference_df[, "x"] <- as.character(reference_df[, "x", drop = TRUE])
|
reference_df[, "x"] <- as.character(reference_df[, "x", drop = TRUE])
|
||||||
reference_df[, "mo"] <- as.character(reference_df[, "mo", drop = TRUE])
|
reference_df[, "mo"] <- as.character(reference_df[, "mo", drop = TRUE])
|
||||||
|
|
||||||
# some microbial codes might be old
|
# some MO codes might be old
|
||||||
reference_df[, "mo"] <- as.mo(reference_df[, "mo", drop = TRUE])
|
reference_df[, "mo"] <- as.mo(reference_df[, "mo", drop = TRUE])
|
||||||
reference_df
|
reference_df
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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*.
|
#' 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
|
#' @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 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 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'
|
#' @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
|
#' mo_is_yeast(c("Candida", "E. coli")) # TRUE, FALSE
|
||||||
#'
|
#'
|
||||||
#' # gram stains and intrinsic resistance can also be used as a filter in dplyr verbs
|
#' # gram stains and intrinsic resistance can also be used as a filter in dplyr verbs
|
||||||
|
#' \donttest{
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' filter(mo_is_gram_positive())
|
#' filter(mo_is_gram_positive())
|
||||||
@@ -167,6 +168,7 @@
|
|||||||
#' # SNOMED codes, and URL to the online database
|
#' # SNOMED codes, and URL to the online database
|
||||||
#' mo_info("E. coli")
|
#' mo_info("E. coli")
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
mo_name <- function(x, language = get_locale(), ...) {
|
mo_name <- function(x, language = get_locale(), ...) {
|
||||||
if (missing(x)) {
|
if (missing(x)) {
|
||||||
# this tries to find the data and an <mo> column
|
# 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, ...),
|
translate_AMR(mo_validate(x = x, property = "fullname", language = language, ...),
|
||||||
language = language,
|
language = language,
|
||||||
only_unknown = FALSE,
|
only_unknown = FALSE,
|
||||||
affect_mo_name = TRUE)
|
only_affect_mo_names = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
@@ -220,7 +222,7 @@ mo_shortname <- function(x, language = get_locale(), ...) {
|
|||||||
|
|
||||||
shortnames[is.na(x.mo)] <- NA_character_
|
shortnames[is.na(x.mo)] <- NA_character_
|
||||||
load_mo_failures_uncertainties_renamed(metadata)
|
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
|
#' @rdname mo_property
|
||||||
@@ -729,14 +731,7 @@ mo_validate <- function(x, property, language, ...) {
|
|||||||
tryCatch(x[1L] %in% MO_lookup[1, property, drop = TRUE],
|
tryCatch(x[1L] %in% MO_lookup[1, property, drop = TRUE],
|
||||||
error = function(e) stop(e$message, call. = FALSE))
|
error = function(e) stop(e$message, call. = FALSE))
|
||||||
|
|
||||||
if (is.mo(x)
|
if (!all(x[!is.na(x)] %in% MO_lookup[, property, drop = TRUE]) | has_Becker_or_Lancefield) {
|
||||||
& !Becker %in% c(TRUE, "all")
|
|
||||||
& !Lancefield %in% c(TRUE, "all")) {
|
|
||||||
# this will not reset mo_uncertainties and mo_failures
|
|
||||||
# because it's already a valid MO
|
|
||||||
x <- exec_as.mo(x, property = property, initial_search = FALSE, language = language, ...)
|
|
||||||
} else if (!all(x %in% MO_lookup[, property, drop = TRUE])
|
|
||||||
| has_Becker_or_Lancefield) {
|
|
||||||
x <- exec_as.mo(x, property = property, language = language, ...)
|
x <- exec_as.mo(x, property = property, language = language, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
R/pca.R
@@ -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.
|
#' 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
|
#' @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.
|
#' @param ... columns of `x` to be selected for PCA, can be unquoted since it supports quasiquotation.
|
||||||
#' @inheritParams stats::prcomp
|
#' @inheritParams stats::prcomp
|
||||||
#' @details The [pca()] function takes a [data.frame] as input and performs the actual PCA with the \R function [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]
|
#' @return An object of classes [pca] and [prcomp]
|
||||||
#' @importFrom stats prcomp
|
#' @importFrom stats prcomp
|
||||||
#' @export
|
#' @export
|
||||||
@@ -42,7 +42,6 @@
|
|||||||
#' # See ?example_isolates.
|
#' # See ?example_isolates.
|
||||||
#'
|
#'
|
||||||
#' \donttest{
|
#' \donttest{
|
||||||
#'
|
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' # calculate the resistance per group first
|
#' # calculate the resistance per group first
|
||||||
#' resistance_data <- example_isolates %>%
|
#' resistance_data <- example_isolates %>%
|
||||||
@@ -99,7 +98,7 @@ pca <- function(x,
|
|||||||
|
|
||||||
x <- as.data.frame(new_list, stringsAsFactors = FALSE)
|
x <- as.data.frame(new_list, stringsAsFactors = FALSE)
|
||||||
if (any(vapply(FUN.VALUE = logical(1), x, function(y) !is.numeric(y)))) {
|
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
|
# 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),
|
message_("Columns selected for PCA: ", vector_and(font_bold(colnames(pca_data), collapse = NULL), quotes = TRUE),
|
||||||
". Total observations available: ", nrow(pca_data), ".")
|
". 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
|
# 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)
|
pca_model <- prcomp(pca_data, retx = retx, center = center, scale. = scale., tol = tol)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
221
R/plot.R
@@ -37,7 +37,7 @@
|
|||||||
#' @param guideline interpretation guideline to use, defaults to the latest included EUCAST guideline, see *Details*
|
#' @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 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 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
|
#' @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.
|
#' 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_mic_values, mo = "S. aureus", ab = "ampicillin")
|
||||||
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||||
#'
|
#'
|
||||||
|
#' \donttest{
|
||||||
#' if (require("ggplot2")) {
|
#' if (require("ggplot2")) {
|
||||||
#' ggplot(some_mic_values)
|
#' ggplot(some_mic_values)
|
||||||
#' ggplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
#' ggplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||||
#' ggplot(some_rsi_values)
|
#' ggplot(some_rsi_values)
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
#' @method plot mic
|
#' @method plot mic
|
||||||
@@ -93,6 +95,14 @@ plot.mic <- function(x,
|
|||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
|
# translate if not specifically set
|
||||||
|
if (missing(ylab)) {
|
||||||
|
ylab <- translate_AMR(ylab, language = language)
|
||||||
|
}
|
||||||
|
if (missing(xlab)) {
|
||||||
|
xlab <- translate_AMR(xlab, language = language)
|
||||||
|
}
|
||||||
|
|
||||||
if (length(colours_RSI) == 1) {
|
if (length(colours_RSI) == 1) {
|
||||||
colours_RSI <- rep(colours_RSI, 3)
|
colours_RSI <- rep(colours_RSI, 3)
|
||||||
}
|
}
|
||||||
@@ -142,6 +152,7 @@ plot.mic <- function(x,
|
|||||||
horiz = TRUE,
|
horiz = TRUE,
|
||||||
cex = 0.75,
|
cex = 0.75,
|
||||||
box.lwd = 0,
|
box.lwd = 0,
|
||||||
|
box.col = "#FFFFFF55",
|
||||||
bg = "#FFFFFF55")
|
bg = "#FFFFFF55")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,6 +181,14 @@ barplot.mic <- function(height,
|
|||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
|
# translate if not specifically set
|
||||||
|
if (missing(ylab)) {
|
||||||
|
ylab <- translate_AMR(ylab, language = language)
|
||||||
|
}
|
||||||
|
if (missing(xlab)) {
|
||||||
|
xlab <- translate_AMR(xlab, language = language)
|
||||||
|
}
|
||||||
|
|
||||||
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
||||||
|
|
||||||
plot(x = height,
|
plot(x = height,
|
||||||
@@ -209,6 +228,14 @@ ggplot.mic <- function(data,
|
|||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
|
# translate if not specifically set
|
||||||
|
if (missing(ylab)) {
|
||||||
|
ylab <- translate_AMR(ylab, language = language)
|
||||||
|
}
|
||||||
|
if (missing(xlab)) {
|
||||||
|
xlab <- translate_AMR(xlab, language = language)
|
||||||
|
}
|
||||||
|
|
||||||
if ("main" %in% names(list(...))) {
|
if ("main" %in% names(list(...))) {
|
||||||
title <- list(...)$main
|
title <- list(...)$main
|
||||||
}
|
}
|
||||||
@@ -285,6 +312,14 @@ plot.disk <- function(x,
|
|||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
|
# translate if not specifically set
|
||||||
|
if (missing(ylab)) {
|
||||||
|
ylab <- translate_AMR(ylab, language = language)
|
||||||
|
}
|
||||||
|
if (missing(xlab)) {
|
||||||
|
xlab <- translate_AMR(xlab, language = language)
|
||||||
|
}
|
||||||
|
|
||||||
if (length(colours_RSI) == 1) {
|
if (length(colours_RSI) == 1) {
|
||||||
colours_RSI <- rep(colours_RSI, 3)
|
colours_RSI <- rep(colours_RSI, 3)
|
||||||
}
|
}
|
||||||
@@ -335,6 +370,7 @@ plot.disk <- function(x,
|
|||||||
horiz = TRUE,
|
horiz = TRUE,
|
||||||
cex = 0.75,
|
cex = 0.75,
|
||||||
box.lwd = 0,
|
box.lwd = 0,
|
||||||
|
box.col = "#FFFFFF55",
|
||||||
bg = "#FFFFFF55")
|
bg = "#FFFFFF55")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -363,6 +399,14 @@ barplot.disk <- function(height,
|
|||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
|
# translate if not specifically set
|
||||||
|
if (missing(ylab)) {
|
||||||
|
ylab <- translate_AMR(ylab, language = language)
|
||||||
|
}
|
||||||
|
if (missing(xlab)) {
|
||||||
|
xlab <- translate_AMR(xlab, language = language)
|
||||||
|
}
|
||||||
|
|
||||||
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
||||||
|
|
||||||
plot(x = height,
|
plot(x = height,
|
||||||
@@ -402,6 +446,14 @@ ggplot.disk <- function(data,
|
|||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
|
# translate if not specifically set
|
||||||
|
if (missing(ylab)) {
|
||||||
|
ylab <- translate_AMR(ylab, language = language)
|
||||||
|
}
|
||||||
|
if (missing(xlab)) {
|
||||||
|
xlab <- translate_AMR(xlab, language = language)
|
||||||
|
}
|
||||||
|
|
||||||
if ("main" %in% names(list(...))) {
|
if ("main" %in% names(list(...))) {
|
||||||
title <- list(...)$main
|
title <- list(...)$main
|
||||||
}
|
}
|
||||||
@@ -454,79 +506,6 @@ ggplot.disk <- function(data,
|
|||||||
ggplot2::labs(title = title, x = xlab, y = ylab, subtitle = cols_sub$sub)
|
ggplot2::labs(title = title, x = xlab, y = ylab, subtitle = cols_sub$sub)
|
||||||
}
|
}
|
||||||
|
|
||||||
plot_prepare_table <- function(x, expand) {
|
|
||||||
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
|
|
||||||
extra_range <- max(x) / 2
|
|
||||||
while (min(extra_range) / 2 > min(x)) {
|
|
||||||
extra_range <- c(min(extra_range) / 2, extra_range)
|
|
||||||
}
|
|
||||||
nms <- extra_range
|
|
||||||
extra_range <- rep(0, length(extra_range))
|
|
||||||
names(extra_range) <- nms
|
|
||||||
x <- table(droplevels(x, as.mic = FALSE))
|
|
||||||
extra_range <- extra_range[!names(extra_range) %in% names(x)]
|
|
||||||
x <- as.table(c(x, extra_range))
|
|
||||||
} else {
|
|
||||||
x <- table(droplevels(x, as.mic = FALSE))
|
|
||||||
}
|
|
||||||
x <- x[order(as.double(as.mic(names(x))))]
|
|
||||||
} else if (is.disk(x)) {
|
|
||||||
if (expand == TRUE) {
|
|
||||||
# expand range for disks from lowest to highest so all mm's in between also print
|
|
||||||
extra_range <- rep(0, max(x) - min(x) - 1)
|
|
||||||
names(extra_range) <- seq(min(x) + 1, max(x) - 1)
|
|
||||||
x <- table(x)
|
|
||||||
extra_range <- extra_range[!names(extra_range) %in% names(x)]
|
|
||||||
x <- as.table(c(x, extra_range))
|
|
||||||
} else {
|
|
||||||
x <- table(x)
|
|
||||||
}
|
|
||||||
x <- x[order(as.double(names(x)))]
|
|
||||||
}
|
|
||||||
as.table(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
plot_name_of_I <- function(guideline) {
|
|
||||||
if (!guideline %like% "CLSI" && as.double(gsub("[^0-9]+", "", guideline)) >= 2019) {
|
|
||||||
# interpretation since 2019
|
|
||||||
"Incr. exposure"
|
|
||||||
} else {
|
|
||||||
# interpretation until 2019
|
|
||||||
"Intermediate"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plot_colours_subtitle_guideline <- function(x, mo, ab, guideline, colours_RSI, fn, language, ...) {
|
|
||||||
guideline <- get_guideline(guideline, AMR::rsi_translation)
|
|
||||||
if (!is.null(mo) && !is.null(ab)) {
|
|
||||||
# interpret and give colour based on MIC values
|
|
||||||
mo <- as.mo(mo)
|
|
||||||
ab <- as.ab(ab)
|
|
||||||
rsi <- suppressWarnings(suppressMessages(as.rsi(fn(names(x)), mo = mo, ab = ab, guideline = guideline, ...)))
|
|
||||||
cols <- character(length = length(rsi))
|
|
||||||
cols[is.na(rsi)] <- "#BEBEBE"
|
|
||||||
cols[rsi == "R"] <- colours_RSI[1]
|
|
||||||
cols[rsi == "S"] <- colours_RSI[2]
|
|
||||||
cols[rsi == "I"] <- colours_RSI[3]
|
|
||||||
moname <- mo_name(mo, language = language)
|
|
||||||
abname <- ab_name(ab, language = language)
|
|
||||||
if (all(cols == "#BEBEBE")) {
|
|
||||||
message_("No ", guideline, " interpretations found for ",
|
|
||||||
ab_name(ab, language = NULL, tolower = TRUE), " in ", moname)
|
|
||||||
guideline_txt <- ""
|
|
||||||
} else {
|
|
||||||
guideline_txt <- paste0("(", guideline, ")")
|
|
||||||
}
|
|
||||||
sub <- bquote(.(abname)~"in"~italic(.(moname))~.(guideline_txt))
|
|
||||||
} else {
|
|
||||||
cols <- "#BEBEBE"
|
|
||||||
sub <- NULL
|
|
||||||
}
|
|
||||||
list(cols = cols, count = as.double(x), sub = sub, guideline = guideline)
|
|
||||||
}
|
|
||||||
|
|
||||||
#' @method plot rsi
|
#' @method plot rsi
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom graphics plot text axis
|
#' @importFrom graphics plot text axis
|
||||||
@@ -599,8 +578,18 @@ barplot.rsi <- function(height,
|
|||||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
|
# translate if not specifically set
|
||||||
|
if (missing(ylab)) {
|
||||||
|
ylab <- translate_AMR(ylab, language = language)
|
||||||
|
}
|
||||||
|
if (missing(xlab)) {
|
||||||
|
xlab <- translate_AMR(xlab, language = language)
|
||||||
|
}
|
||||||
|
|
||||||
if (length(colours_RSI) == 1) {
|
if (length(colours_RSI) == 1) {
|
||||||
colours_RSI <- rep(colours_RSI, 3)
|
colours_RSI <- rep(colours_RSI, 3)
|
||||||
|
} else {
|
||||||
|
colours_RSI <- c(colours_RSI[2], colours_RSI[3], colours_RSI[1])
|
||||||
}
|
}
|
||||||
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
||||||
|
|
||||||
@@ -624,6 +613,7 @@ ggplot.rsi <- function(data,
|
|||||||
xlab = "Antimicrobial Interpretation",
|
xlab = "Antimicrobial Interpretation",
|
||||||
ylab = "Frequency",
|
ylab = "Frequency",
|
||||||
colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
|
colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
|
||||||
|
language = get_locale(),
|
||||||
...) {
|
...) {
|
||||||
stop_ifnot_installed("ggplot2")
|
stop_ifnot_installed("ggplot2")
|
||||||
meet_criteria(title, allow_class = "character", allow_NULL = TRUE)
|
meet_criteria(title, allow_class = "character", allow_NULL = TRUE)
|
||||||
@@ -631,6 +621,14 @@ ggplot.rsi <- function(data,
|
|||||||
meet_criteria(xlab, allow_class = "character", has_length = 1)
|
meet_criteria(xlab, allow_class = "character", has_length = 1)
|
||||||
meet_criteria(colours_RSI, allow_class = "character", has_length = c(1, 3))
|
meet_criteria(colours_RSI, allow_class = "character", has_length = c(1, 3))
|
||||||
|
|
||||||
|
# translate if not specifically set
|
||||||
|
if (missing(ylab)) {
|
||||||
|
ylab <- translate_AMR(ylab, language = language)
|
||||||
|
}
|
||||||
|
if (missing(xlab)) {
|
||||||
|
xlab <- translate_AMR(xlab, language = language)
|
||||||
|
}
|
||||||
|
|
||||||
if ("main" %in% names(list(...))) {
|
if ("main" %in% names(list(...))) {
|
||||||
title <- list(...)$main
|
title <- list(...)$main
|
||||||
}
|
}
|
||||||
@@ -658,3 +656,78 @@ ggplot.rsi <- function(data,
|
|||||||
ggplot2::labs(title = title, x = xlab, y = ylab) +
|
ggplot2::labs(title = title, x = xlab, y = ylab) +
|
||||||
ggplot2::theme(legend.position = "none")
|
ggplot2::theme(legend.position = "none")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
extra_range <- max(x) / 2
|
||||||
|
while (min(extra_range) / 2 > min(x)) {
|
||||||
|
extra_range <- c(min(extra_range) / 2, extra_range)
|
||||||
|
}
|
||||||
|
nms <- extra_range
|
||||||
|
extra_range <- rep(0, length(extra_range))
|
||||||
|
names(extra_range) <- nms
|
||||||
|
x <- table(droplevels(x, as.mic = FALSE))
|
||||||
|
extra_range <- extra_range[!names(extra_range) %in% names(x)]
|
||||||
|
x <- as.table(c(x, extra_range))
|
||||||
|
} else {
|
||||||
|
x <- table(droplevels(x, as.mic = FALSE))
|
||||||
|
}
|
||||||
|
x <- x[order(as.double(as.mic(names(x))))]
|
||||||
|
} else if (is.disk(x)) {
|
||||||
|
if (expand == TRUE) {
|
||||||
|
# expand range for disks from lowest to highest so all mm's in between also print
|
||||||
|
extra_range <- rep(0, max(x) - min(x) - 1)
|
||||||
|
names(extra_range) <- seq(min(x) + 1, max(x) - 1)
|
||||||
|
x <- table(x)
|
||||||
|
extra_range <- extra_range[!names(extra_range) %in% names(x)]
|
||||||
|
x <- as.table(c(x, extra_range))
|
||||||
|
} else {
|
||||||
|
x <- table(x)
|
||||||
|
}
|
||||||
|
x <- x[order(as.double(names(x)))]
|
||||||
|
}
|
||||||
|
as.table(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
plot_name_of_I <- function(guideline) {
|
||||||
|
if (guideline %unlike% "CLSI" && as.double(gsub("[^0-9]+", "", guideline)) >= 2019) {
|
||||||
|
# interpretation since 2019
|
||||||
|
"Incr. exposure"
|
||||||
|
} else {
|
||||||
|
# interpretation until 2019
|
||||||
|
"Intermediate"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plot_colours_subtitle_guideline <- function(x, mo, ab, guideline, colours_RSI, fn, language, ...) {
|
||||||
|
guideline <- get_guideline(guideline, AMR::rsi_translation)
|
||||||
|
if (!is.null(mo) && !is.null(ab)) {
|
||||||
|
# interpret and give colour based on MIC values
|
||||||
|
mo <- as.mo(mo)
|
||||||
|
ab <- as.ab(ab)
|
||||||
|
rsi <- suppressWarnings(suppressMessages(as.rsi(fn(names(x)), mo = mo, ab = ab, guideline = guideline, ...)))
|
||||||
|
cols <- character(length = length(rsi))
|
||||||
|
cols[is.na(rsi)] <- "#BEBEBE"
|
||||||
|
cols[rsi == "R"] <- colours_RSI[1]
|
||||||
|
cols[rsi == "S"] <- colours_RSI[2]
|
||||||
|
cols[rsi == "I"] <- colours_RSI[3]
|
||||||
|
moname <- mo_name(mo, language = language)
|
||||||
|
abname <- ab_name(ab, language = language)
|
||||||
|
if (all(cols == "#BEBEBE")) {
|
||||||
|
message_("No ", guideline, " interpretations found for ",
|
||||||
|
ab_name(ab, language = NULL, tolower = TRUE), " in ", moname)
|
||||||
|
guideline_txt <- ""
|
||||||
|
} else {
|
||||||
|
guideline_txt <- paste0("(", guideline, ")")
|
||||||
|
}
|
||||||
|
sub <- bquote(.(abname)~"-"~italic(.(moname))~.(guideline_txt))
|
||||||
|
} else {
|
||||||
|
cols <- "#BEBEBE"
|
||||||
|
sub <- NULL
|
||||||
|
}
|
||||||
|
list(cols = cols, count = as.double(x), sub = sub, guideline = guideline)
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,18 +31,18 @@
|
|||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with [as.rsi()] if needed. 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 ... 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 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 as_percent a [logical] to indicate whether the output must be returned as a hundred fold with % sign (a character). A value of `0.123456` will then be returned as `"12.3%"`.
|
||||||
#' @param only_all_tested (for combination therapies, i.e. using more than one variable for `...`): a logical to indicate that isolates must be tested for all antibiotics, see section *Combination Therapy* below
|
#' @param only_all_tested (for combination therapies, i.e. using more than one variable for `...`): a [logical] to indicate that isolates must be tested for all antibiotics, see section *Combination Therapy* below
|
||||||
#' @param data a [data.frame] containing columns with class [`rsi`] (see [as.rsi()])
|
#' @param 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()]
|
#' @param translate_ab a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]
|
||||||
#' @inheritParams 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_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_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
|
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||||
#' @details
|
#' @details
|
||||||
#' The function [resistance()] is equal to the function [proportion_R()]. The function [susceptibility()] is equal to the function [proportion_SI()].
|
#' 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).*
|
#' 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_IR(example_isolates$AMX)
|
||||||
#' proportion_R(example_isolates$AMX)
|
#' proportion_R(example_isolates$AMX)
|
||||||
#'
|
#'
|
||||||
|
#' \donttest{
|
||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' group_by(hospital_id) %>%
|
#' group_by(hospital_id) %>%
|
||||||
@@ -161,6 +162,7 @@
|
|||||||
#' group_by(hospital_id) %>%
|
#' group_by(hospital_id) %>%
|
||||||
#' proportion_df(translate = FALSE)
|
#' proportion_df(translate = FALSE)
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
resistance <- function(...,
|
resistance <- function(...,
|
||||||
minimum = 30,
|
minimum = 30,
|
||||||
as_percent = FALSE,
|
as_percent = FALSE,
|
||||||
|
|||||||
@@ -28,10 +28,10 @@
|
|||||||
#' 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.
|
#' 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
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param size desired size of the returned vector
|
#' @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 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 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 prob_RSI a vector of length 3: the probabilities for R (1st value), S (2nd value) and I (3rd value)
|
||||||
#' @param ... extension for future versions, not used at the moment
|
#' @param ... ignored, only in place to allow future extensions
|
||||||
#' @details The base R function [sample()] is used for generating values.
|
#' @details The base R function [sample()] is used for generating values.
|
||||||
#'
|
#'
|
||||||
#' Generated values are based on the latest EUCAST guideline implemented in the [rsi_translation] data set. To create specific generated values per bug or drug, set the `mo` and/or `ab` argument.
|
#' Generated values are based on the latest EUCAST guideline implemented in the [rsi_translation] data set. To create specific generated values per bug or drug, set the `mo` and/or `ab` argument.
|
||||||
|
|||||||
@@ -34,11 +34,11 @@
|
|||||||
#' @param year_every unit of sequence between lowest year found in the data and `year_max`
|
#' @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 minimum minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.
|
||||||
#' @param model the statistical model of choice. This could be a generalised linear regression model with binomial distribution (i.e. using `glm(..., family = binomial)``, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See *Details* for all valid options.
|
#' @param model the statistical model of choice. This could be a generalised linear regression model with binomial distribution (i.e. using `glm(..., family = binomial)``, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See *Details* for all valid options.
|
||||||
#' @param I_as_S a logical to indicate whether values `"I"` should be treated as `"S"` (will otherwise be treated as `"R"`). The default, `TRUE`, follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section *Interpretation of S, I and R* below.
|
#' @param 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 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 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 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
|
#' @param ... arguments passed on to functions
|
||||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||||
#' @inheritParams first_isolate
|
#' @inheritParams first_isolate
|
||||||
@@ -70,6 +70,7 @@
|
|||||||
#' year_min = 2010,
|
#' year_min = 2010,
|
||||||
#' model = "binomial")
|
#' model = "binomial")
|
||||||
#' plot(x)
|
#' plot(x)
|
||||||
|
#' \donttest{
|
||||||
#' if (require("ggplot2")) {
|
#' if (require("ggplot2")) {
|
||||||
#' ggplot_rsi_predict(x)
|
#' ggplot_rsi_predict(x)
|
||||||
#' }
|
#' }
|
||||||
@@ -98,7 +99,9 @@
|
|||||||
#' info = FALSE,
|
#' info = FALSE,
|
||||||
#' minimum = 15)
|
#' minimum = 15)
|
||||||
#'
|
#'
|
||||||
#' ggplot(data,
|
#' ggplot(data)
|
||||||
|
#'
|
||||||
|
#' ggplot(as.data.frame(data),
|
||||||
#' aes(x = year)) +
|
#' aes(x = year)) +
|
||||||
#' geom_col(aes(y = value),
|
#' geom_col(aes(y = value),
|
||||||
#' fill = "grey75") +
|
#' fill = "grey75") +
|
||||||
@@ -114,6 +117,7 @@
|
|||||||
#' x = "Year") +
|
#' x = "Year") +
|
||||||
#' theme_minimal(base_size = 13)
|
#' theme_minimal(base_size = 13)
|
||||||
#' }
|
#' }
|
||||||
|
#' }
|
||||||
resistance_predict <- function(x,
|
resistance_predict <- function(x,
|
||||||
col_ab,
|
col_ab,
|
||||||
col_date = NULL,
|
col_date = NULL,
|
||||||
@@ -347,6 +351,20 @@ plot.resistance_predict <- function(x, main = paste("Resistance Prediction of",
|
|||||||
col = "grey40")
|
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
|
#' @rdname resistance_predict
|
||||||
#' @export
|
#' @export
|
||||||
ggplot_rsi_predict <- function(x,
|
ggplot_rsi_predict <- function(x,
|
||||||
@@ -360,14 +378,14 @@ ggplot_rsi_predict <- function(x,
|
|||||||
stop_ifnot_installed("ggplot2")
|
stop_ifnot_installed("ggplot2")
|
||||||
stop_ifnot(inherits(x, "resistance_predict"), "`x` must be a resistance prediction model created with resistance_predict()")
|
stop_ifnot(inherits(x, "resistance_predict"), "`x` must be a resistance prediction model created with resistance_predict()")
|
||||||
|
|
||||||
|
|
||||||
if (attributes(x)$I_as_S == TRUE) {
|
if (attributes(x)$I_as_S == TRUE) {
|
||||||
ylab <- "%R"
|
ylab <- "%R"
|
||||||
} else {
|
} else {
|
||||||
ylab <- "%IR"
|
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)),
|
ggplot2::geom_point(data = subset(x, !is.na(observations)),
|
||||||
size = 2) +
|
size = 2) +
|
||||||
scale_y_percent(limits = c(0, 1)) +
|
scale_y_percent(limits = c(0, 1)) +
|
||||||
|
|||||||
88
R/rsi.R
@@ -25,17 +25,17 @@
|
|||||||
|
|
||||||
#' Interpret MIC and Disk Values, or Clean Raw R/SI Data
|
#' Interpret MIC and Disk Values, or Clean Raw R/SI Data
|
||||||
#'
|
#'
|
||||||
#' Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class [`rsi`], which is an ordered factor with levels `S < I < R`. Values that cannot be interpreted will be returned as `NA` with a warning.
|
#' 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
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @rdname as.rsi
|
#' @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 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 a valid microorganism code with [as.mo()], can be left empty to determine it automatically
|
#' @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 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
|
#' @inheritParams first_isolate
|
||||||
#' @param guideline defaults to the latest included EUCAST guideline, see *Details* for all options
|
#' @param guideline defaults to the latest included EUCAST guideline, see *Details* for all options
|
||||||
#' @param conserve_capped_values a logical to indicate that MIC values starting with `">"` (but not `">="`) must always return "R" , and that MIC values starting with `"<"` (but not `"<="`) must always return "S"
|
#' @param 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 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 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 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.
|
#' @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.
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
#' * Using `dplyr`, R/SI interpretation can be done very easily with either:
|
#' * 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_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(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".
|
#' * 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".
|
||||||
#'
|
#'
|
||||||
@@ -58,14 +58,14 @@
|
|||||||
#' * Using `dplyr`, R/SI interpretation can be done very easily with either:
|
#' * 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_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(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)`.
|
#' 4. For **interpreting a complete data set**, with automatic determination of MIC values, disk diffusion diameters, microorganism names or codes, and antimicrobial test results. This is done very simply by running `as.rsi(data)`.
|
||||||
#'
|
#'
|
||||||
#' ## Supported Guidelines
|
#' ## Supported Guidelines
|
||||||
#'
|
#'
|
||||||
#' For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the `guideline` argument are: `r 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.
|
#' 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
|
#' ## 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:
|
#' @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/>).
|
#' 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.
|
#' A microorganism is categorised as *Susceptible, Increased exposure* when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
|
||||||
#'
|
#'
|
||||||
#' This AMR package honours this new insight. Use [susceptibility()] (equal to [proportion_SI()]) to determine antimicrobial susceptibility and [count_susceptible()] (equal to [count_SI()]) to count susceptible isolates.
|
#' This AMR package honours this new insight. Use [susceptibility()] (equal to [proportion_SI()]) to determine antimicrobial susceptibility and [count_susceptible()] (equal to [count_SI()]) to count susceptible isolates.
|
||||||
#' @return Ordered factor with new class `<rsi>`
|
#' @return Ordered [factor] with new class `<rsi>`
|
||||||
#' @aliases rsi
|
#' @aliases rsi
|
||||||
#' @export
|
#' @export
|
||||||
#' @seealso [as.mic()], [as.disk()], [as.mo()]
|
#' @seealso [as.mic()], [as.disk()], [as.mo()]
|
||||||
@@ -101,12 +101,12 @@
|
|||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @examples
|
#' @examples
|
||||||
#' summary(example_isolates) # see all R/SI results at a glance
|
#' summary(example_isolates) # see all R/SI results at a glance
|
||||||
#'
|
#' \donttest{
|
||||||
#' if (require("skimr")) {
|
#' if (require("skimr")) {
|
||||||
#' # class <rsi> supported in skim() too:
|
#' # class <rsi> supported in skim() too:
|
||||||
#' skim(example_isolates)
|
#' skim(example_isolates)
|
||||||
#' }
|
#' }
|
||||||
#'
|
#' }
|
||||||
#' # For INTERPRETING disk diffusion and MIC values -----------------------
|
#' # For INTERPRETING disk diffusion and MIC values -----------------------
|
||||||
#'
|
#'
|
||||||
#' # a whole data set, even with combined MIC values and disk zones
|
#' # a whole data set, even with combined MIC values and disk zones
|
||||||
@@ -135,7 +135,7 @@
|
|||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' df %>% mutate_if(is.mic, as.rsi)
|
#' df %>% mutate_if(is.mic, as.rsi)
|
||||||
#' df %>% mutate_if(function(x) is.mic(x) | is.disk(x), 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_at(vars(AMP:TOB), as.rsi)
|
||||||
#' df %>% mutate(across(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:
|
#' # note: from dplyr 1.0.0 on, this will be:
|
||||||
#' # example_isolates %>%
|
#' # example_isolates %>%
|
||||||
#' # mutate(across((is.rsi.eligible), as.rsi))
|
#' # mutate(across(where(is.rsi.eligible), as.rsi))
|
||||||
#' }
|
#' }
|
||||||
#' }
|
#' }
|
||||||
as.rsi <- function(x, ...) {
|
as.rsi <- function(x, ...) {
|
||||||
@@ -215,7 +215,6 @@ is.rsi.eligible <- function(x, threshold = 0.05) {
|
|||||||
"ab",
|
"ab",
|
||||||
"Date",
|
"Date",
|
||||||
"POSIXt",
|
"POSIXt",
|
||||||
"rsi",
|
|
||||||
"raw",
|
"raw",
|
||||||
"hms",
|
"hms",
|
||||||
"mic",
|
"mic",
|
||||||
@@ -259,13 +258,24 @@ as.rsi.default <- function(x, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inherits(x, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) {
|
if (inherits(x, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) {
|
||||||
x[x == 1] <- "S"
|
x.bak <- x
|
||||||
x[x == 2] <- "I"
|
x <- as.character(x) # this is needed to prevent the vctrs pkg from throwing an error
|
||||||
x[x == 3] <- "R"
|
|
||||||
|
|
||||||
} else if (!all(is.na(x)) && !identical(levels(x), c("S", "I", "R"))) {
|
# support haven package for importing e.g., from SPSS - it adds the 'labels' attribute
|
||||||
|
lbls <- attributes(x)$labels
|
||||||
|
if (!is.null(lbls) && all(c("R", "S", "I") %in% names(lbls)) && all(c(1:3) %in% lbls)) {
|
||||||
|
x[x.bak == 1] <- names(lbls[lbls == 1])
|
||||||
|
x[x.bak == 2] <- names(lbls[lbls == 2])
|
||||||
|
x[x.bak == 3] <- names(lbls[lbls == 3])
|
||||||
|
} else {
|
||||||
|
x[x.bak == 1] <- "S"
|
||||||
|
x[x.bak == 2] <- "I"
|
||||||
|
x[x.bak == 3] <- "R"
|
||||||
|
}
|
||||||
|
|
||||||
if (!any(x %like% "(R|S|I)", na.rm = TRUE)) {
|
} else if (!all(is.na(x)) && !identical(levels(x), c("R", "S", "I")) && !all(x %in% c("R", "S", "I", NA))) {
|
||||||
|
|
||||||
|
if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) {
|
||||||
# check if they are actually MICs or disks
|
# check if they are actually MICs or disks
|
||||||
if (all_valid_mics(x)) {
|
if (all_valid_mics(x)) {
|
||||||
warning_("The input seems to be MIC values. Transform them with `as.mic()` before running `as.rsi()` to interpret them.")
|
warning_("The input seems to be MIC values. Transform them with `as.mic()` before running `as.rsi()` to interpret them.")
|
||||||
@@ -535,7 +545,7 @@ as.rsi.data.frame <- function(x,
|
|||||||
}
|
}
|
||||||
if (!is.null(col_uti)) {
|
if (!is.null(col_uti)) {
|
||||||
if (is.logical(col_uti)) {
|
if (is.logical(col_uti)) {
|
||||||
# already a logical vector as input
|
# already a [logical] vector as input
|
||||||
if (length(col_uti) == 1) {
|
if (length(col_uti) == 1) {
|
||||||
uti <- rep(col_uti, NROW(x))
|
uti <- rep(col_uti, NROW(x))
|
||||||
} else {
|
} else {
|
||||||
@@ -544,7 +554,7 @@ as.rsi.data.frame <- function(x,
|
|||||||
} else {
|
} else {
|
||||||
# column found, transform to logical
|
# column found, transform to logical
|
||||||
stop_if(length(col_uti) != 1 | !col_uti %in% colnames(x),
|
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])
|
uti <- as.logical(x[, col_uti, drop = TRUE])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -683,7 +693,7 @@ get_guideline <- function(guideline, reference_data) {
|
|||||||
if (guideline_param %in% c("CLSI", "EUCAST")) {
|
if (guideline_param %in% c("CLSI", "EUCAST")) {
|
||||||
guideline_param <- rev(sort(subset(reference_data, guideline %like% guideline_param)$guideline))[1L]
|
guideline_param <- rev(sort(subset(reference_data, guideline %like% guideline_param)$guideline))[1L]
|
||||||
}
|
}
|
||||||
if (!guideline_param %like% " ") {
|
if (guideline_param %unlike% " ") {
|
||||||
# like 'EUCAST2020', should be 'EUCAST 2020'
|
# like 'EUCAST2020', should be 'EUCAST 2020'
|
||||||
guideline_param <- gsub("([a-z]+)([0-9]+)", "\\1 \\2", guideline_param, ignore.case = TRUE)
|
guideline_param <- gsub("([a-z]+)([0-9]+)", "\\1 \\2", guideline_param, ignore.case = TRUE)
|
||||||
}
|
}
|
||||||
@@ -776,7 +786,7 @@ exec_as.rsi <- function(method,
|
|||||||
any_is_intrinsic_resistant <- any_is_intrinsic_resistant | is_intrinsic_r
|
any_is_intrinsic_resistant <- any_is_intrinsic_resistant | is_intrinsic_r
|
||||||
|
|
||||||
if (isTRUE(add_intrinsic_resistance) & is_intrinsic_r) {
|
if (isTRUE(add_intrinsic_resistance) & is_intrinsic_r) {
|
||||||
if (!guideline_coerced %like% "EUCAST") {
|
if (guideline_coerced %unlike% "EUCAST") {
|
||||||
if (message_not_thrown_before("as.rsi2")) {
|
if (message_not_thrown_before("as.rsi2")) {
|
||||||
warning_("Using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.", call = FALSE)
|
warning_("Using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.", call = FALSE)
|
||||||
remember_thrown_message("as.rsi2")
|
remember_thrown_message("as.rsi2")
|
||||||
@@ -923,28 +933,16 @@ get_skimmers.rsi <- function(column) {
|
|||||||
# get the variable name 'skim_variable'
|
# get the variable name 'skim_variable'
|
||||||
name_call <- function(.data) {
|
name_call <- function(.data) {
|
||||||
calls <- sys.calls()
|
calls <- sys.calls()
|
||||||
|
frms <- sys.frames()
|
||||||
calls_txt <- vapply(calls, function(x) paste(deparse(x), collapse = ""), FUN.VALUE = character(1))
|
calls_txt <- vapply(calls, function(x) paste(deparse(x), collapse = ""), FUN.VALUE = character(1))
|
||||||
if (any(calls_txt %like% "skim_variable", na.rm = TRUE)) {
|
if (any(calls_txt %like% "skim_variable", na.rm = TRUE)) {
|
||||||
ind <- which(calls_txt %like% "skim_variable")[1L]
|
ind <- which(calls_txt %like% "skim_variable")[1L]
|
||||||
vars <- tryCatch(eval(parse(text = ".data$skim_variable"), envir = sys.frame(ind)),
|
vars <- tryCatch(eval(parse(text = ".data$skim_variable$rsi"), envir = frms[[ind]]),
|
||||||
error = function(e) NULL)
|
error = function(e) NULL)
|
||||||
|
tryCatch(ab_name(as.character(calls[[length(calls)]][[2]]), language = NULL),
|
||||||
|
error = function(e) NA_character_)
|
||||||
} else {
|
} else {
|
||||||
vars <- NULL
|
|
||||||
}
|
|
||||||
i <- tryCatch(attributes(calls[[length(calls)]])$position,
|
|
||||||
error = function(e) NULL)
|
|
||||||
if (is.null(vars) | is.null(i)) {
|
|
||||||
NA_character_
|
NA_character_
|
||||||
} else {
|
|
||||||
lengths <- vapply(FUN.VALUE = double(1), vars, length)
|
|
||||||
when_starts_rsi <- which(names(vapply(FUN.VALUE = double(1), vars, length)) == "rsi")
|
|
||||||
offset <- sum(lengths[c(1:when_starts_rsi - 1)])
|
|
||||||
var <- vars$rsi[i - offset]
|
|
||||||
if (!isFALSE(var == "data")) {
|
|
||||||
NA_character_
|
|
||||||
} else{
|
|
||||||
ab_name(var)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,10 +1025,8 @@ summary.rsi <- function(object, ...) {
|
|||||||
#' @method c rsi
|
#' @method c rsi
|
||||||
#' @export
|
#' @export
|
||||||
#' @noRd
|
#' @noRd
|
||||||
c.rsi <- function(x, ...) {
|
c.rsi <- function(...) {
|
||||||
y <- unlist(lapply(list(...), as.character))
|
as.rsi(unlist(lapply(list(...), as.character)))
|
||||||
x <- as.character(x)
|
|
||||||
as.rsi(c(x, y))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @method unique rsi
|
#' @method unique rsi
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ rsi_calc <- function(...,
|
|||||||
if (message_not_thrown_before("rsi_calc")) {
|
if (message_not_thrown_before("rsi_calc")) {
|
||||||
warning_("Increase speed by transforming to class <rsi> on beforehand:\n",
|
warning_("Increase speed by transforming to class <rsi> on beforehand:\n",
|
||||||
" your_data %>% mutate_if(is.rsi.eligible, as.rsi)\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)
|
call = FALSE)
|
||||||
remember_thrown_message("rsi_calc")
|
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.
|
#' When negative ('left-skewed'): the left tail is longer; the mass of the distribution is concentrated on the right of a histogram. When positive ('right-skewed'): the right tail is longer; the mass of the distribution is concentrated on the left of a histogram. A normal distribution has a skewness of 0.
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x a vector of values, a [matrix] or a [data.frame]
|
#' @param 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()]
|
#' @seealso [kurtosis()]
|
||||||
#' @rdname skewness
|
#' @rdname skewness
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
|
|||||||
BIN
R/sysdata.rda
@@ -123,7 +123,11 @@ coerce_language_setting <- function(lang) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# translate strings based on inst/translations.tsv
|
# 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)) {
|
if (is.null(language)) {
|
||||||
return(from)
|
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
|
# only keep lines where translation is available for this language
|
||||||
df_trans <- df_trans[which(!is.na(df_trans[, language, drop = TRUE])), , drop = FALSE]
|
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) {
|
if (only_unknown == TRUE) {
|
||||||
df_trans <- subset(df_trans, pattern %like% "unknown")
|
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)
|
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:
|
# default: case sensitive if value if 'case_sensitive' is missing:
|
||||||
df_trans$case_sensitive[is.na(df_trans$case_sensitive)] <- TRUE
|
df_trans$case_sensitive[is.na(df_trans$case_sensitive)] <- TRUE
|
||||||
@@ -157,11 +169,13 @@ translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE, a
|
|||||||
df_trans$regular_expr[is.na(df_trans$regular_expr)] <- FALSE
|
df_trans$regular_expr[is.na(df_trans$regular_expr)] <- FALSE
|
||||||
|
|
||||||
# check if text to look for is in one of the patterns
|
# check if text to look for is in one of the patterns
|
||||||
any_form_in_patterns <- tryCatch(any(from_unique %like% paste0("(", paste(df_trans$pattern, collapse = "|"), ")")),
|
any_form_in_patterns <- tryCatch(
|
||||||
|
any(from_unique %like% paste0("(", paste(gsub(" +\\(.*", "", df_trans$pattern), collapse = "|"), ")")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
warning_("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).", call = FALSE)
|
warning_("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).", call = FALSE)
|
||||||
return(FALSE)
|
return(FALSE)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (NROW(df_trans) == 0 | !any_form_in_patterns) {
|
if (NROW(df_trans) == 0 | !any_form_in_patterns) {
|
||||||
return(from)
|
return(from)
|
||||||
}
|
}
|
||||||
@@ -170,7 +184,7 @@ translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE, a
|
|||||||
function(i) from_unique_translated <<- gsub(pattern = df_trans$pattern[i],
|
function(i) from_unique_translated <<- gsub(pattern = df_trans$pattern[i],
|
||||||
replacement = df_trans[i, language, drop = TRUE],
|
replacement = df_trans[i, language, drop = TRUE],
|
||||||
x = from_unique_translated,
|
x = from_unique_translated,
|
||||||
ignore.case = !df_trans$case_sensitive[i],
|
ignore.case = !df_trans$case_sensitive[i] & df_trans$regular_expr[i],
|
||||||
fixed = !df_trans$regular_expr[i],
|
fixed = !df_trans$regular_expr[i],
|
||||||
perl = df_trans$regular_expr[i]))
|
perl = df_trans$regular_expr[i]))
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
#' 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:
|
#' @section WHOCC:
|
||||||
#' \if{html}{\figure{logo_who.png}{options: height=60px style=margin-bottom:5px} \cr}
|
#' \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.
|
#' These have become the gold standard for international drug utilisation monitoring and research.
|
||||||
#'
|
#'
|
||||||
|
|||||||
29
R/zzz.R
@@ -27,6 +27,17 @@
|
|||||||
pkg_env <- new.env(hash = FALSE)
|
pkg_env <- new.env(hash = FALSE)
|
||||||
pkg_env$mo_failed <- character(0)
|
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) {
|
.onLoad <- function(libname, pkgname) {
|
||||||
# Support for tibble headers (type_sum) and tibble columns content (pillar_shaft)
|
# 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
|
# 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", "rsi")
|
||||||
s3_register("ggplot2::ggplot", "mic")
|
s3_register("ggplot2::ggplot", "mic")
|
||||||
s3_register("ggplot2::ggplot", "disk")
|
s3_register("ggplot2::ggplot", "disk")
|
||||||
|
s3_register("ggplot2::ggplot", "resistance_predict")
|
||||||
|
|
||||||
# if mo source exists, fire it up (see mo_source())
|
# if mo source exists, fire it up (see mo_source())
|
||||||
try({
|
try({
|
||||||
@@ -61,20 +73,3 @@ pkg_env$mo_failed <- character(0)
|
|||||||
}
|
}
|
||||||
}, silent = TRUE)
|
}, silent = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
.onAttach <- function(...) {
|
|
||||||
# show notice in 10% of cases in interactive session
|
|
||||||
if (!interactive() || stats::runif(1) > 0.1 || isTRUE(as.logical(getOption("AMR_silentstart", FALSE)))) {
|
|
||||||
return()
|
|
||||||
}
|
|
||||||
packageStartupMessage(word_wrap("Thank you for using the AMR package! ",
|
|
||||||
"If you have a minute, please anonymously fill in this short questionnaire to improve the package and its functionalities: ",
|
|
||||||
font_blue("https://msberends.github.io/AMR/survey.html\n"),
|
|
||||||
"[prevent his notice with ",
|
|
||||||
font_bold("suppressPackageStartupMessages(library(AMR))"),
|
|
||||||
" or use ",
|
|
||||||
font_bold("options(AMR_silentstart = TRUE)"), "]"))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
# `AMR` (for R)
|
# `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://www.codefactor.io/repository/github/msberends/amr)
|
||||||
[](https://codecov.io/gh/msberends/AMR?branch=master)
|
[](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
|
### How to get this package
|
||||||
Please see [our website](https://msberends.github.io/AMR/#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
|
### Copyright
|
||||||
|
|
||||||
|
|||||||
@@ -143,25 +143,25 @@ reference:
|
|||||||
- "`as.mic`"
|
- "`as.mic`"
|
||||||
- "`as.disk`"
|
- "`as.disk`"
|
||||||
- "`eucast_rules`"
|
- "`eucast_rules`"
|
||||||
|
- "`custom_eucast_rules`"
|
||||||
|
|
||||||
- title: "Analysing data: antimicrobial resistance"
|
- title: "Analysing data: antimicrobial resistance"
|
||||||
desc: >
|
desc: >
|
||||||
Use these function for the analysis part. You can use `susceptibility()` or `resistance()` on any antibiotic column.
|
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()`.
|
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:
|
contents:
|
||||||
- "`proportion`"
|
- "`proportion`"
|
||||||
- "`count`"
|
- "`count`"
|
||||||
- "`is_new_episode`"
|
- "`is_new_episode`"
|
||||||
- "`first_isolate`"
|
- "`first_isolate`"
|
||||||
- "`key_antibiotics`"
|
- "`key_antimicrobials`"
|
||||||
- "`mdro`"
|
- "`mdro`"
|
||||||
- "`count`"
|
- "`count`"
|
||||||
- "`plot`"
|
- "`plot`"
|
||||||
- "`ggplot_rsi`"
|
- "`ggplot_rsi`"
|
||||||
- "`bug_drug_combinations`"
|
- "`bug_drug_combinations`"
|
||||||
- "`antibiotic_class_selectors`"
|
- "`antibiotic_class_selectors`"
|
||||||
- "`filter_ab_class`"
|
|
||||||
- "`resistance_predict`"
|
- "`resistance_predict`"
|
||||||
- "`guess_ab_col`"
|
- "`guess_ab_col`"
|
||||||
|
|
||||||
@@ -176,6 +176,7 @@ reference:
|
|||||||
- "`availability`"
|
- "`availability`"
|
||||||
- "`get_locale`"
|
- "`get_locale`"
|
||||||
- "`ggplot_pca`"
|
- "`ggplot_pca`"
|
||||||
|
- "`italicise_taxonomy`"
|
||||||
- "`join`"
|
- "`join`"
|
||||||
- "`like`"
|
- "`like`"
|
||||||
- "`mo_matching_score`"
|
- "`mo_matching_score`"
|
||||||
|
|||||||
@@ -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/ #
|
# 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", {
|
pkg_suggests <- gsub("[^a-zA-Z0-9]+", "", unlist(strsplit(packageDescription("AMR", fields = "Suggests"), ", ?")))
|
||||||
skip_on_cran()
|
cat("Packages listed in Suggests:", paste(pkg_suggests, collapse = ", "), "\n")
|
||||||
|
|
||||||
library(dplyr)
|
to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())]
|
||||||
expect_gt(example_isolates %>% filter_ab_class("carbapenem") %>% nrow(), 0)
|
if (length(to_install) == 0) {
|
||||||
expect_gt(example_isolates %>% filter_aminoglycosides() %>% ncol(), 0)
|
message("\nNothing to install\n")
|
||||||
expect_gt(example_isolates %>% filter_carbapenems() %>% ncol(), 0)
|
}
|
||||||
expect_gt(example_isolates %>% filter_cephalosporins() %>% ncol(), 0)
|
for (i in seq_len(length(to_install))) {
|
||||||
expect_gt(example_isolates %>% filter_1st_cephalosporins() %>% ncol(), 0)
|
cat("Installing package", to_install[i], "\n")
|
||||||
expect_gt(example_isolates %>% filter_2nd_cephalosporins() %>% ncol(), 0)
|
tryCatch(install.packages(to_install[i], repos = "https://cran.rstudio.com/", dependencies = TRUE, quiet = TRUE),
|
||||||
expect_gt(example_isolates %>% filter_3rd_cephalosporins() %>% ncol(), 0)
|
# message = function(m) invisible(),
|
||||||
expect_gt(example_isolates %>% filter_4th_cephalosporins() %>% ncol(), 0)
|
warning = function(w) message(w$message),
|
||||||
expect_gt(example_isolates %>% filter_5th_cephalosporins() %>% ncol(), 0)
|
error = function(e) message(e$message))
|
||||||
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)
|
|
||||||
|
|
||||||
expect_gt(example_isolates %>% filter_carbapenems("R", "all") %>% nrow(), 0)
|
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]
|
||||||
expect_error(example_isolates %>% filter_carbapenems(result = "test"))
|
if (length(to_update) == 0) {
|
||||||
expect_error(example_isolates %>% filter_carbapenems(scope = "test"))
|
message("\nNothing to update\n")
|
||||||
expect_message(example_isolates %>% select(1:3) %>% filter_carbapenems())
|
}
|
||||||
})
|
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))
|
||||||
|
}
|
||||||
@@ -134,7 +134,7 @@ create_intr_resistance <- function() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Save internal data sets to R/sysdata.rda --------------------------------
|
# Save internal data to R/sysdata.rda -------------------------------------
|
||||||
|
|
||||||
# See 'data-raw/eucast_rules.tsv' for the EUCAST reference file
|
# See 'data-raw/eucast_rules.tsv' for the EUCAST reference file
|
||||||
eucast_rules_file <- utils::read.delim(file = "data-raw/eucast_rules.tsv",
|
eucast_rules_file <- utils::read.delim(file = "data-raw/eucast_rules.tsv",
|
||||||
@@ -188,6 +188,35 @@ AB_lookup <- create_AB_lookup()
|
|||||||
MO_lookup <- create_MO_lookup()
|
MO_lookup <- create_MO_lookup()
|
||||||
MO.old_lookup <- create_MO.old_lookup()
|
MO.old_lookup <- create_MO.old_lookup()
|
||||||
|
|
||||||
|
# antibiotic groups
|
||||||
|
# (these will also be used for eucast_rules() and understanding data-raw/eucast_rules.tsv)
|
||||||
|
globalenv_before_ab <- c(ls(envir = globalenv()), "globalenv_before_ab")
|
||||||
|
AMINOGLYCOSIDES <- antibiotics %>% filter(group %like% "aminoglycoside") %>% pull(ab)
|
||||||
|
AMINOPENICILLINS <- as.ab(c("AMP", "AMX"))
|
||||||
|
CARBAPENEMS <- antibiotics %>% filter(group %like% "carbapenem") %>% pull(ab)
|
||||||
|
CEPHALOSPORINS <- antibiotics %>% filter(group %like% "cephalosporin") %>% pull(ab)
|
||||||
|
CEPHALOSPORINS_1ST <- antibiotics %>% filter(group %like% "cephalosporin.*1") %>% pull(ab)
|
||||||
|
CEPHALOSPORINS_2ND <- antibiotics %>% filter(group %like% "cephalosporin.*2") %>% pull(ab)
|
||||||
|
CEPHALOSPORINS_3RD <- antibiotics %>% filter(group %like% "cephalosporin.*3") %>% pull(ab)
|
||||||
|
CEPHALOSPORINS_EXCEPT_CAZ <- CEPHALOSPORINS[CEPHALOSPORINS != "CAZ"]
|
||||||
|
FLUOROQUINOLONES <- antibiotics %>% filter(atc_group2 %like% "fluoroquinolone") %>% pull(ab)
|
||||||
|
LIPOGLYCOPEPTIDES <- as.ab(c("DAL", "ORI", "TLV")) # dalba/orita/tela
|
||||||
|
GLYCOPEPTIDES <- antibiotics %>% filter(group %like% "glycopeptide") %>% pull(ab)
|
||||||
|
GLYCOPEPTIDES_EXCEPT_LIPO <- GLYCOPEPTIDES[!GLYCOPEPTIDES %in% LIPOGLYCOPEPTIDES]
|
||||||
|
LINCOSAMIDES <- antibiotics %>% filter(atc_group2 %like% "lincosamide") %>% pull(ab) %>% c("PRL")
|
||||||
|
MACROLIDES <- antibiotics %>% filter(atc_group2 %like% "macrolide") %>% pull(ab)
|
||||||
|
OXAZOLIDINONES <- antibiotics %>% filter(group %like% "oxazolidinone") %>% pull(ab)
|
||||||
|
PENICILLINS <- antibiotics %>% filter(group %like% "penicillin") %>% pull(ab)
|
||||||
|
POLYMYXINS <- antibiotics %>% filter(group %like% "polymyxin") %>% pull(ab)
|
||||||
|
STREPTOGRAMINS <- antibiotics %>% filter(atc_group2 %like% "streptogramin") %>% pull(ab)
|
||||||
|
TETRACYCLINES <- antibiotics %>% filter(atc_group2 %like% "tetracycline") %>% pull(ab)
|
||||||
|
TETRACYCLINES_EXCEPT_TGC <- TETRACYCLINES[TETRACYCLINES != "TGC"]
|
||||||
|
UREIDOPENICILLINS <- as.ab(c("PIP", "TZP", "AZL", "MEZ"))
|
||||||
|
BETALACTAMS <- c(PENICILLINS, CEPHALOSPORINS, CARBAPENEMS)
|
||||||
|
|
||||||
|
DEFINED_AB_GROUPS <- ls(envir = globalenv())
|
||||||
|
DEFINED_AB_GROUPS <- DEFINED_AB_GROUPS[!DEFINED_AB_GROUPS %in% globalenv_before_ab]
|
||||||
|
|
||||||
# Export to package as internal data ----
|
# Export to package as internal data ----
|
||||||
usethis::use_data(eucast_rules_file,
|
usethis::use_data(eucast_rules_file,
|
||||||
translations_file,
|
translations_file,
|
||||||
@@ -199,6 +228,29 @@ usethis::use_data(eucast_rules_file,
|
|||||||
AB_lookup,
|
AB_lookup,
|
||||||
MO_lookup,
|
MO_lookup,
|
||||||
MO.old_lookup,
|
MO.old_lookup,
|
||||||
|
AMINOGLYCOSIDES,
|
||||||
|
AMINOPENICILLINS,
|
||||||
|
CARBAPENEMS,
|
||||||
|
CEPHALOSPORINS,
|
||||||
|
CEPHALOSPORINS_1ST,
|
||||||
|
CEPHALOSPORINS_2ND,
|
||||||
|
CEPHALOSPORINS_3RD,
|
||||||
|
CEPHALOSPORINS_EXCEPT_CAZ,
|
||||||
|
FLUOROQUINOLONES,
|
||||||
|
LIPOGLYCOPEPTIDES,
|
||||||
|
GLYCOPEPTIDES,
|
||||||
|
GLYCOPEPTIDES_EXCEPT_LIPO,
|
||||||
|
LINCOSAMIDES,
|
||||||
|
MACROLIDES,
|
||||||
|
OXAZOLIDINONES,
|
||||||
|
PENICILLINS,
|
||||||
|
POLYMYXINS,
|
||||||
|
STREPTOGRAMINS,
|
||||||
|
TETRACYCLINES,
|
||||||
|
TETRACYCLINES_EXCEPT_TGC,
|
||||||
|
UREIDOPENICILLINS,
|
||||||
|
BETALACTAMS,
|
||||||
|
DEFINED_AB_GROUPS,
|
||||||
internal = TRUE,
|
internal = TRUE,
|
||||||
overwrite = TRUE,
|
overwrite = TRUE,
|
||||||
version = 2,
|
version = 2,
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
77f6cca42687a0e3b1b1045a2d70b226
|
f6b4a2325c4bf3a8d4da337c8cfa07be
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"ab" "atc" "cid" "name" "group" "atc_group1" "atc_group2" "abbreviations" "synonyms" "oral_ddd" "oral_units" "iv_ddd" "iv_units" "loinc"
|
"ab" "atc" "cid" "name" "group" "atc_group1" "atc_group2" "abbreviations" "synonyms" "oral_ddd" "oral_units" "iv_ddd" "iv_units" "loinc"
|
||||||
"AMA" "J04AA01" 4649 "4-aminosalicylic acid" "Antimycobacterials" "Drugs for treatment of tuberculosis" "Aminosalicylic acid and derivatives" "" "c(\"aminopar\", \"aminosalicylic\", \"aminosalicylic acid\", \"aminosalyl\", \"aminox\", \"apacil\", \"deapasil\", \"entepas\", \"ferrosan\", \"gabbropas\", \"helipidyl\", \"hellipidyl\", \"neopasalate\", \"osacyl\", \"pamacyl\", \"pamisyl\", \"paramycin\", \"parasal\", \"parasalicil\", \"parasalindon\", \"pasalon\", \"pasara\", \"pascorbic\", \"pasdium\", \"paser granules\", \"paskalium\", \"pasmed\", \"pasnodia\", \"pasolac\", \"propasa\", \"rezipas\", \"teebacin\", \"wln: zr cq dvq\")" 12 "g" "character(0)"
|
"AMA" "J04AA01" 4649 "4-aminosalicylic acid" "Antimycobacterials" "Drugs for treatment of tuberculosis" "Aminosalicylic acid and derivatives" "" "c(\"aminopar\", \"aminosalicylic\", \"aminosalicylic acid\", \"aminosalyl\", \"aminox\", \"apacil\", \"deapasil\", \"entepas\", \"ferrosan\", \"gabbropas\", \"helipidyl\", \"hellipidyl\", \"neopasalate\", \"osacyl\", \"pamacyl\", \"pamisyl\", \"paramycin\", \"parasal\", \"parasalicil\", \"parasalindon\", \"pasalon\", \"pasara\", \"pascorbic\", \"pasdium\", \"paser granules\", \"paskalium\", \"pasmed\", \"pasnodia\", \"pasolac\", \"propasa\", \"rezipas\", \"teebacin\", \"wln: zr cq dvq\")" 12 "g" "character(0)"
|
||||||
"FCT" "D01AE21" 3366 "5-fluorocytosine" "Antifungals/antimycotics" "Antifungals for topical use" "Other antifungals for topical use" "c(\"5flc\", \"fluo\")" "c(\"alcobon\", \"ancobon\", \"ancotil\", \"ancotyl\", \"flucitosina\", \"flucystine\", \"flucytosin\", \"flucytosine\", \"flucytosinum\", \"flucytosone\", \"fluocytosine\", \"fluorcytosine\")" "c(\"10974-4\", \"23805-5\", \"25142-1\", \"25143-9\", \"3639-2\", \"46218-4\")"
|
"FCT" "D01AE21" 3366 "5-fluorocytosine" "Antifungals/antimycotics" "Antifungals for topical use" "Other antifungals for topical use" "c(\"5flc\", \"fcu\", \"fluo\", \"fluy\")" "c(\"alcobon\", \"ancobon\", \"ancotil\", \"ancotyl\", \"flucitosina\", \"flucystine\", \"flucytosin\", \"flucytosine\", \"flucytosinum\", \"flucytosone\", \"fluocytosine\", \"fluorcytosine\")" "c(\"10974-4\", \"23805-5\", \"25142-1\", \"25143-9\", \"3639-2\", \"46218-4\")"
|
||||||
"ACM" 6450012 "Acetylmidecamycin" "Macrolides/lincosamides" "" "" ""
|
"ACM" 6450012 "Acetylmidecamycin" "Macrolides/lincosamides" "" "" ""
|
||||||
"ASP" 49787020 "Acetylspiramycin" "Macrolides/lincosamides" "" "c(\"acetylspiramycin\", \"foromacidin b\", \"spiramycin ii\")" "character(0)"
|
"ASP" 49787020 "Acetylspiramycin" "Macrolides/lincosamides" "" "c(\"acetylspiramycin\", \"foromacidin b\", \"spiramycin ii\")" "character(0)"
|
||||||
"ALS" "J04BA03" 8954 "Aldesulfone sodium" "Other antibacterials" "Drugs for treatment of lepra" "Drugs for treatment of lepra" "" "c(\"adesulfone sodium\", \"aldapsone\", \"aldesulfona sodica\", \"aldesulfone\", \"aldesulfone sodique\", \"aldesulfone sodium\", \"diamidin\", \"diasone\", \"diasone sodium\", \"diazon\", \"novotrone\", \"sodium aldesulphone\", \"sodium sulfoxone\", \"sulfoxone sodium\")" 0.33 "g" "character(0)"
|
"ALS" "J04BA03" 8954 "Aldesulfone sodium" "Other antibacterials" "Drugs for treatment of lepra" "Drugs for treatment of lepra" "" "c(\"adesulfone sodium\", \"aldapsone\", \"aldesulfona sodica\", \"aldesulfone\", \"aldesulfone sodique\", \"aldesulfone sodium\", \"diamidin\", \"diasone\", \"diasone sodium\", \"diazon\", \"novotrone\", \"sodium aldesulphone\", \"sodium sulfoxone\", \"sulfoxone sodium\")" 0.33 "g" "character(0)"
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
\"piramox\", \"robamox\", \"sawamox pm\", \"tolodina\", \"unicillin\", \"utimox\", \"vetramox\")" 1.5 "g" 3 "g" "c(\"16365-9\", \"25274-2\", \"3344-9\", \"80133-2\")"
|
\"piramox\", \"robamox\", \"sawamox pm\", \"tolodina\", \"unicillin\", \"utimox\", \"vetramox\")" 1.5 "g" 3 "g" "c(\"16365-9\", \"25274-2\", \"3344-9\", \"80133-2\")"
|
||||||
"AMC" "J01CR02" 23665637 "Amoxicillin/clavulanic acid" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "c(\"a/c\", \"amcl\", \"aml\", \"aug\", \"xl\")" "c(\"amocla\", \"amoclan\", \"amoclav\", \"amoxsiklav\", \"augmentan\", \"augmentin\", \"augmentin xr\", \"augmentine\", \"auspilic\", \"clamentin\", \"clamobit\", \"clavamox\", \"clavinex\", \"clavoxilin plus\", \"clavulin\", \"clavumox\", \"coamoxiclav\", \"eumetinex\", \"kmoxilin\", \"spectramox\", \"spektramox\", \"viaclav\", \"xiclav\")" 1.5 "g" 3 "g" "character(0)"
|
"AMC" "J01CR02" 23665637 "Amoxicillin/clavulanic acid" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "c(\"a/c\", \"amcl\", \"aml\", \"aug\", \"xl\")" "c(\"amocla\", \"amoclan\", \"amoclav\", \"amoxsiklav\", \"augmentan\", \"augmentin\", \"augmentin xr\", \"augmentine\", \"auspilic\", \"clamentin\", \"clamobit\", \"clavamox\", \"clavinex\", \"clavoxilin plus\", \"clavulin\", \"clavumox\", \"coamoxiclav\", \"eumetinex\", \"kmoxilin\", \"spectramox\", \"spektramox\", \"viaclav\", \"xiclav\")" 1.5 "g" 3 "g" "character(0)"
|
||||||
"AXS" 465441 "Amoxicillin/sulbactam" "Beta-lactams/penicillins" "" "" ""
|
"AXS" 465441 "Amoxicillin/sulbactam" "Beta-lactams/penicillins" "" "" ""
|
||||||
"AMB" "J02AA01" 5280965 "Amphotericin B" "Antifungals/antimycotics" "Antimycotics for systemic use" "Antibiotics" "c(\"amfb\", \"amph\")" "c(\"abelcet\", \"abelecet\", \"ambisome\", \"amfotericina b\", \"amphocin\", \"amphomoronal\", \"amphortericin b\", \"amphotec\", \"amphotericin\", \"amphotericin b\", \"amphotericine b\", \"amphotericinum b\", \"amphozone\", \"anfotericine b\", \"fungilin\", \"fungisome\", \"fungisone\", \"fungizone\", \"halizon\")" 35 "mg" "c(\"16370-9\", \"3353-0\", \"3354-8\", \"40707-2\", \"40757-7\", \"49859-2\")"
|
"AMB" "J02AA01" 5280965 "Amphotericin B" "Antifungals/antimycotics" "Antimycotics for systemic use" "Antibiotics" "c(\"amf\", \"amfb\", \"amph\")" "c(\"abelcet\", \"abelecet\", \"ambisome\", \"amfotericina b\", \"amphocin\", \"amphomoronal\", \"amphortericin b\", \"amphotec\", \"amphotericin\", \"amphotericin b\", \"amphotericine b\", \"amphotericinum b\", \"amphozone\", \"anfotericine b\", \"fungilin\", \"fungisome\", \"fungisone\", \"fungizone\", \"halizon\")" 35 "mg" "c(\"16370-9\", \"3353-0\", \"3354-8\", \"40707-2\", \"40757-7\", \"49859-2\")"
|
||||||
"AMH" "Amphotericin B-high" "Aminoglycosides" "c(\"amfo b high\", \"amhl\", \"ampho b high\", \"amphotericin high\")" "" ""
|
"AMH" "Amphotericin B-high" "Aminoglycosides" "c(\"amfo b high\", \"amhl\", \"ampho b high\", \"amphotericin high\")" "" ""
|
||||||
"AMP" "J01CA01" 6249 "Ampicillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"am\", \"amp\", \"ampi\")" "c(\"acillin\", \"adobacillin\", \"amblosin\", \"amcill\", \"amfipen\", \"amfipen v\", \"amipenix s\", \"ampichel\", \"ampicil\", \"ampicilina\", \"ampicillin\", \"ampicillin a\", \"ampicillin acid\", \"ampicillin anhydrate\", \"ampicillin anhydrous\", \"ampicillin base\", \"ampicillin sodium\", \"ampicillina\", \"ampicilline\", \"ampicillinum\", \"ampicin\", \"ampifarm\", \"ampikel\", \"ampimed\", \"ampipenin\", \"ampiscel\", \"ampisyn\", \"ampivax\", \"ampivet\", \"amplacilina\", \"amplin\", \"amplipenyl\", \"amplisom\", \"amplital\", \"anhydrous ampicillin\", \"austrapen\",
|
"AMP" "J01CA01" 6249 "Ampicillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"am\", \"amp\", \"ampi\")" "c(\"acillin\", \"adobacillin\", \"amblosin\", \"amcill\", \"amfipen\", \"amfipen v\", \"amipenix s\", \"ampichel\", \"ampicil\", \"ampicilina\", \"ampicillin\", \"ampicillin a\", \"ampicillin acid\", \"ampicillin anhydrate\", \"ampicillin anhydrous\", \"ampicillin base\", \"ampicillin sodium\", \"ampicillina\", \"ampicilline\", \"ampicillinum\", \"ampicin\", \"ampifarm\", \"ampikel\", \"ampimed\", \"ampipenin\", \"ampiscel\", \"ampisyn\", \"ampivax\", \"ampivet\", \"amplacilina\", \"amplin\", \"amplipenyl\", \"amplisom\", \"amplital\", \"anhydrous ampicillin\", \"austrapen\",
|
||||||
\"binotal\", \"bonapicillin\", \"britacil\", \"campicillin\", \"copharcilin\", \"delcillin\", \"deripen\", \"divercillin\", \"doktacillin\", \"duphacillin\", \"grampenil\", \"guicitrina\", \"guicitrine\", \"lifeampil\", \"marcillin\", \"morepen\", \"norobrittin\", \"nuvapen\", \"olin kid\", \"omnipen\", \"orbicilina\", \"pen a oral\", \"pen ampil\", \"penbristol\", \"penbritin\", \"penbritin paediatric\", \"penbritin syrup\", \"penbrock\", \"penicline\", \"penimic\", \"pensyn\", \"pentrex\", \"pentrexl\", \"pentrexyl\", \"pentritin\", \"pfizerpen a\", \"polycillin\", \"polyflex\",
|
\"binotal\", \"bonapicillin\", \"britacil\", \"campicillin\", \"copharcilin\", \"delcillin\", \"deripen\", \"divercillin\", \"doktacillin\", \"duphacillin\", \"grampenil\", \"guicitrina\", \"guicitrine\", \"lifeampil\", \"marcillin\", \"morepen\", \"norobrittin\", \"nuvapen\", \"olin kid\", \"omnipen\", \"orbicilina\", \"pen a oral\", \"pen ampil\", \"penbristol\", \"penbritin\", \"penbritin paediatric\", \"penbritin syrup\", \"penbrock\", \"penicline\", \"penimic\", \"pensyn\", \"pentrex\", \"pentrexl\", \"pentrexyl\", \"pentritin\", \"pfizerpen a\", \"polycillin\", \"polyflex\",
|
||||||
@@ -156,7 +156,7 @@
|
|||||||
"CTR" "G01AF02" 2812 "Clotrimazole" "Antifungals/antimycotics" "clot" "c(\"canesten\", \"canesten cream\", \"canesten solution\", \"canestene\", \"canestine\", \"canifug\", \"chlotrimazole\", \"cimitidine\", \"clomatin\", \"clotrimaderm\", \"clotrimaderm cream\", \"clotrimazol\", \"clotrimazole\", \"clotrimazolum\", \"cutistad\", \"desamix f\", \"diphenylmethane\", \"empecid\", \"esparol\", \"fem care\", \"femcare\", \"gyne lotrimin\", \"jidesheng\", \"kanesten\", \"klotrimazole\", \"lotrimax\", \"lotrimin\", \"lotrimin af\", \"lotrimin af cream\", \"lotrimin af lotion\", \"lotrimin af solution\", \"lotrimin cream\", \"lotrimin lotion\",
|
"CTR" "G01AF02" 2812 "Clotrimazole" "Antifungals/antimycotics" "clot" "c(\"canesten\", \"canesten cream\", \"canesten solution\", \"canestene\", \"canestine\", \"canifug\", \"chlotrimazole\", \"cimitidine\", \"clomatin\", \"clotrimaderm\", \"clotrimaderm cream\", \"clotrimazol\", \"clotrimazole\", \"clotrimazolum\", \"cutistad\", \"desamix f\", \"diphenylmethane\", \"empecid\", \"esparol\", \"fem care\", \"femcare\", \"gyne lotrimin\", \"jidesheng\", \"kanesten\", \"klotrimazole\", \"lotrimax\", \"lotrimin\", \"lotrimin af\", \"lotrimin af cream\", \"lotrimin af lotion\", \"lotrimin af solution\", \"lotrimin cream\", \"lotrimin lotion\",
|
||||||
\"lotrimin solution\", \"monobaycuten\", \"mycelax\", \"mycelex\", \"mycelex cream\", \"mycelex g\", \"mycelex otc\", \"mycelex solution\", \"mycelex troches\", \"mycelex twin pack\", \"myclo cream\", \"myclo solution\", \"myclo spray solution\", \"mycofug\", \"mycosporin\", \"mykosporin\", \"nalbix\", \"otomax\", \"pedisafe\", \"rimazole\", \"stiemazol\", \"tibatin\", \"trimysten\", \"veltrim\")" "character(0)"
|
\"lotrimin solution\", \"monobaycuten\", \"mycelax\", \"mycelex\", \"mycelex cream\", \"mycelex g\", \"mycelex otc\", \"mycelex solution\", \"mycelex troches\", \"mycelex twin pack\", \"myclo cream\", \"myclo solution\", \"myclo spray solution\", \"mycofug\", \"mycosporin\", \"mykosporin\", \"nalbix\", \"otomax\", \"pedisafe\", \"rimazole\", \"stiemazol\", \"tibatin\", \"trimysten\", \"veltrim\")" "character(0)"
|
||||||
"CLO" "J01CF02" 6098 "Cloxacillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "c(\"\", \"clox\")" "c(\"chloroxacillin\", \"clossacillina\", \"cloxacilina\", \"cloxacillin\", \"cloxacillin sodium\", \"cloxacilline\", \"cloxacillinna\", \"cloxacillinum\", \"cloxapen\", \"methocillin s\", \"orbenin\", \"syntarpen\", \"tegopen\")" 2 "g" 2 "g" "c(\"16628-0\", \"25250-2\")"
|
"CLO" "J01CF02" 6098 "Cloxacillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "c(\"\", \"clox\")" "c(\"chloroxacillin\", \"clossacillina\", \"cloxacilina\", \"cloxacillin\", \"cloxacillin sodium\", \"cloxacilline\", \"cloxacillinna\", \"cloxacillinum\", \"cloxapen\", \"methocillin s\", \"orbenin\", \"syntarpen\", \"tegopen\")" 2 "g" 2 "g" "c(\"16628-0\", \"25250-2\")"
|
||||||
"COL" "J01XB01" 5311054 "Colistin" "Polymyxins" "Other antibacterials" "Polymyxins" "c(\"cl\", \"coli\", \"cs\", \"ct\")" "c(\"belcomycine\", \"colimycin\", \"colimycin sulphate\", \"colisticin\", \"colistimethate\", \"colistimethate sodium\", \"colistin sulfate\", \"colistin sulphate\", \"colomycin\", \"coly-mycin\", \"polymyxin e\", \"polymyxin e. sulfate\", \"promixin\", \"totazina\")" 9 "MU" "c(\"16645-4\", \"29493-4\")"
|
"COL" "J01XB01" 5311054 "Colistin" "Polymyxins" "Other antibacterials" "Polymyxins" "c(\"cl\", \"coli\", \"cs\", \"cst\", \"ct\")" "c(\"belcomycine\", \"colimycin\", \"colimycin sulphate\", \"colisticin\", \"colistimethate\", \"colistimethate sodium\", \"colistin sulfate\", \"colistin sulphate\", \"colomycin\", \"coly-mycin\", \"polymyxin e\", \"polymyxin e. sulfate\", \"promixin\", \"totazina\")" 9 "MU" "c(\"16645-4\", \"29493-4\")"
|
||||||
"COP" "Colistin/polysorbate" "Other antibacterials" "" "" ""
|
"COP" "Colistin/polysorbate" "Other antibacterials" "" "" ""
|
||||||
"CYC" "J04AB01" 6234 "Cycloserine" "Oxazolidinones" "Drugs for treatment of tuberculosis" "Antibiotics" "cycl" "c(\"cicloserina\", \"closerin\", \"closina\", \"cyclorin\", \"cycloserin\", \"cycloserine\", \"cycloserinum\", \"farmiserina\", \"micoserina\", \"miroserina\", \"miroseryn\", \"novoserin\", \"oxamicina\", \"oxamycin\", \"seromycin\", \"tebemicina\", \"tisomycin\", \"wasserina\")" 0.75 "g" "c(\"16702-3\", \"25251-0\", \"3519-6\")"
|
"CYC" "J04AB01" 6234 "Cycloserine" "Oxazolidinones" "Drugs for treatment of tuberculosis" "Antibiotics" "cycl" "c(\"cicloserina\", \"closerin\", \"closina\", \"cyclorin\", \"cycloserin\", \"cycloserine\", \"cycloserinum\", \"farmiserina\", \"micoserina\", \"miroserina\", \"miroseryn\", \"novoserin\", \"oxamicina\", \"oxamycin\", \"seromycin\", \"tebemicina\", \"tisomycin\", \"wasserina\")" 0.75 "g" "c(\"16702-3\", \"25251-0\", \"3519-6\")"
|
||||||
"DAL" "J01XA04" 23724878 "Dalbavancin" "Glycopeptides" "Other antibacterials" "Glycopeptide antibacterials" "dalb" "c(\"dalbavancin\", \"dalvance\")" 1.5 "character(0)"
|
"DAL" "J01XA04" 23724878 "Dalbavancin" "Glycopeptides" "Other antibacterials" "Glycopeptide antibacterials" "dalb" "c(\"dalbavancin\", \"dalvance\")" 1.5 "character(0)"
|
||||||
@@ -198,23 +198,23 @@
|
|||||||
"FLO" 65864 "Flomoxef" "Other antibacterials" "" "c(\"flomoxef\", \"flomoxefo\", \"flomoxefum\")" "character(0)"
|
"FLO" 65864 "Flomoxef" "Other antibacterials" "" "c(\"flomoxef\", \"flomoxefo\", \"flomoxefum\")" "character(0)"
|
||||||
"FLR" 114811 "Florfenicol" "Other antibacterials" "" "c(\"aquafen\", \"florfenicol\", \"nuflor\", \"nuflor gold\")" "87599-7"
|
"FLR" 114811 "Florfenicol" "Other antibacterials" "" "c(\"aquafen\", \"florfenicol\", \"nuflor\", \"nuflor gold\")" "87599-7"
|
||||||
"FLC" "J01CF05" 21319 "Flucloxacillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "c(\"clox\", \"flux\")" "c(\"floxacillin\", \"floxapen\", \"floxapen sodium salt\", \"fluclox\", \"flucloxacilina\", \"flucloxacillin\", \"flucloxacilline\", \"flucloxacillinum\", \"fluorochloroxacillin\")" 2 "g" 2 "g" "character(0)"
|
"FLC" "J01CF05" 21319 "Flucloxacillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "c(\"clox\", \"flux\")" "c(\"floxacillin\", \"floxapen\", \"floxapen sodium salt\", \"fluclox\", \"flucloxacilina\", \"flucloxacillin\", \"flucloxacilline\", \"flucloxacillinum\", \"fluorochloroxacillin\")" 2 "g" 2 "g" "character(0)"
|
||||||
"FLU" "J02AC01" 3365 "Fluconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Triazole derivatives" "c(\"fluc\", \"fluz\")" "c(\"alflucoz\", \"alfumet\", \"biocanol\", \"biozole\", \"biozolene\", \"canzol\", \"cryptal\", \"diflazon\", \"diflucan\", \"dimycon\", \"elazor\", \"flucazol\", \"fluconazol\", \"fluconazole\", \"fluconazole capsules\", \"fluconazolum\", \"flucostat\", \"flukezol\", \"flunazol\", \"flunizol\", \"flusol\", \"fluzon\", \"fluzone\", \"forcan\", \"fuconal\", \"fungata\", \"loitin\", \"oxifugol\", \"pritenzol\", \"syscan\", \"trican\", \"triconal\", \"triflucan\", \"zoltec\")" 0.2 "g" 0.2 "g" "c(\"10987-6\", \"16870-8\", \"25255-1\", \"80530-9\")"
|
"FLU" "J02AC01" 3365 "Fluconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Triazole derivatives" "c(\"fluc\", \"fluz\", \"flz\")" "c(\"alflucoz\", \"alfumet\", \"biocanol\", \"biozole\", \"biozolene\", \"canzol\", \"cryptal\", \"diflazon\", \"diflucan\", \"dimycon\", \"elazor\", \"flucazol\", \"fluconazol\", \"fluconazole\", \"fluconazole capsules\", \"fluconazolum\", \"flucostat\", \"flukezol\", \"flunazol\", \"flunizol\", \"flusol\", \"fluzon\", \"fluzone\", \"forcan\", \"fuconal\", \"fungata\", \"loitin\", \"oxifugol\", \"pritenzol\", \"syscan\", \"trican\", \"triconal\", \"triflucan\", \"zoltec\")" 0.2 "g" 0.2 "g" "c(\"10987-6\", \"16870-8\", \"25255-1\", \"80530-9\")"
|
||||||
"FLM" "J01MB07" 3374 "Flumequine" "Quinolones" "Quinolone antibacterials" "Other quinolones" "" "c(\"apurone\", \"fantacin\", \"flumequine\", \"flumequino\", \"flumequinum\", \"flumigal\", \"flumiquil\", \"flumisol\", \"flumix\", \"imequyl\")" 1.2 "g" "character(0)"
|
"FLM" "J01MB07" 3374 "Flumequine" "Quinolones" "Quinolone antibacterials" "Other quinolones" "" "c(\"apurone\", \"fantacin\", \"flumequine\", \"flumequino\", \"flumequinum\", \"flumigal\", \"flumiquil\", \"flumisol\", \"flumix\", \"imequyl\")" 1.2 "g" "character(0)"
|
||||||
"FLR1" "J01FA14" 71260 "Flurithromycin" "Macrolides/lincosamides" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"flurithromicina\", \"flurithromycime\", \"flurithromycin\", \"flurithromycine\", \"flurithromycinum\", \"fluritromicina\", \"fluritromycinum\", \"flurizic\")" 0.75 "g" "character(0)"
|
"FLR1" "J01FA14" 71260 "Flurithromycin" "Macrolides/lincosamides" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"flurithromicina\", \"flurithromycime\", \"flurithromycin\", \"flurithromycine\", \"flurithromycinum\", \"fluritromicina\", \"fluritromycinum\", \"flurizic\")" 0.75 "g" "character(0)"
|
||||||
"FFL" 214356 "Fosfluconazole" "Antifungals/antimycotics" "" "c(\"fosfluconazole\", \"phosfluconazole\", \"procif\", \"prodif\")" "character(0)"
|
"FFL" 214356 "Fosfluconazole" "Antifungals/antimycotics" "" "c(\"fosfluconazole\", \"phosfluconazole\", \"procif\", \"prodif\")" "character(0)"
|
||||||
"FOS" "J01XX01" 446987 "Fosfomycin" "Other antibacterials" "Other antibacterials" "Other antibacterials" "c(\"ff\", \"fm\", \"fo\", \"fos\", \"fosf\")" "c(\"fosfocina\", \"fosfomicina\", \"fosfomycin\", \"fosfomycin sodium\", \"fosfomycine\", \"fosfomycinum\", \"fosfonomycin\", \"monuril\", \"monurol\", \"phosphonemycin\", \"phosphonomycin\", \"veramina\")" 3 "g" 8 "g" "character(0)"
|
"FOS" "J01XX01" 446987 "Fosfomycin" "Other antibacterials" "Other antibacterials" "Other antibacterials" "c(\"ff\", \"fm\", \"fo\", \"fof\", \"fos\", \"fosf\")" "c(\"fosfocina\", \"fosfomicina\", \"fosfomycin\", \"fosfomycin sodium\", \"fosfomycine\", \"fosfomycinum\", \"fosfonomycin\", \"monuril\", \"monurol\", \"phosphonemycin\", \"phosphonomycin\", \"veramina\")" 3 "g" 8 "g" "character(0)"
|
||||||
"FMD" 572 "Fosmidomycin" "Other antibacterials" "" "c(\"fosmidomycin\", \"fosmidomycina\", \"fosmidomycine\", \"fosmidomycinum\")" "character(0)"
|
"FMD" 572 "Fosmidomycin" "Other antibacterials" "" "c(\"fosmidomycin\", \"fosmidomycina\", \"fosmidomycine\", \"fosmidomycinum\")" "character(0)"
|
||||||
"FRM" 8378 "Framycetin" "Aminoglycosides" "c(\"\", \"fram\")" "c(\"actilin\", \"actiline\", \"antibiotique\", \"bycomycin\", \"endomixin\", \"enterfram\", \"fradiomycin\", \"fradiomycin b\", \"fradiomycinum\", \"framicetina\", \"framycetin\", \"framycetin sulfate\", \"framycetine\", \"framycetinum\", \"framygen\", \"fraquinol\", \"jernadex\", \"myacine\", \"myacyne\", \"mycerin\", \"mycifradin\", \"neobrettin\", \"neolate\", \"neomas\", \"neomcin\", \"neomicina\", \"neomin\", \"neomycin\", \"neomycin b\", \"neomycin b sulfate\", \"neomycin solution\", \"neomycin sulfate\", \"neomycin sulphate\", \"neomycinb\", \"neomycine\", \"neomycinum\",
|
"FRM" 8378 "Framycetin" "Aminoglycosides" "c(\"\", \"fram\")" "c(\"actilin\", \"actiline\", \"antibiotique\", \"bycomycin\", \"endomixin\", \"enterfram\", \"fradiomycin\", \"fradiomycin b\", \"fradiomycinum\", \"framicetina\", \"framycetin\", \"framycetin sulfate\", \"framycetine\", \"framycetinum\", \"framygen\", \"fraquinol\", \"jernadex\", \"myacine\", \"myacyne\", \"mycerin\", \"mycifradin\", \"neobrettin\", \"neolate\", \"neomas\", \"neomcin\", \"neomicina\", \"neomin\", \"neomycin\", \"neomycin b\", \"neomycin b sulfate\", \"neomycin solution\", \"neomycin sulfate\", \"neomycin sulphate\", \"neomycinb\", \"neomycine\", \"neomycinum\",
|
||||||
\"nivemycin\", \"pimavecort\", \"soframycin\", \"soframycine\", \"tuttomycin\", \"vonamycin\", \"vonamycin powder v\")" "character(0)"
|
\"nivemycin\", \"pimavecort\", \"soframycin\", \"soframycine\", \"tuttomycin\", \"vonamycin\", \"vonamycin powder v\")" "character(0)"
|
||||||
"FRZ" 5323714 "Furazolidone" "Other antibacterials" "" "c(\"bifuron\", \"corizium\", \"coryzium\", \"diafuron\", \"enterotoxon\", \"furall\", \"furaxon\", \"furaxone\", \"furazol\", \"furazolidine\", \"furazolidon\", \"furazolidona\", \"furazolidone\", \"furazolidonum\", \"furazolum\", \"furazon\", \"furidon\", \"furovag\", \"furox aerosol powder\", \"furoxal\", \"furoxane\", \"furoxon\", \"furoxone\", \"furoxone liquid\", \"furoxone swine mix\", \"furozolidine\", \"giardil\", \"giarlam\", \"medaron\", \"neftin\", \"nicolen\", \"nifulidone\", \"nifuran\", \"nifurazolidone\", \"nifurazolidonum\", \"nitrofurazolidone\", \"nitrofurazolidonum\",
|
"FRZ" 5323714 "Furazolidone" "Other antibacterials" "" "c(\"bifuron\", \"corizium\", \"coryzium\", \"diafuron\", \"enterotoxon\", \"furall\", \"furaxon\", \"furaxone\", \"furazol\", \"furazolidine\", \"furazolidon\", \"furazolidona\", \"furazolidone\", \"furazolidonum\", \"furazolum\", \"furazon\", \"furidon\", \"furovag\", \"furox aerosol powder\", \"furoxal\", \"furoxane\", \"furoxon\", \"furoxone\", \"furoxone liquid\", \"furoxone swine mix\", \"furozolidine\", \"giardil\", \"giarlam\", \"medaron\", \"neftin\", \"nicolen\", \"nifulidone\", \"nifuran\", \"nifurazolidone\", \"nifurazolidonum\", \"nitrofurazolidone\", \"nitrofurazolidonum\",
|
||||||
\"nitrofuroxon\", \"optazol\", \"ortazol\", \"puradin\", \"roptazol\", \"sclaventerol\", \"tikofuran\", \"topazone\", \"trichofuron\", \"tricofuron\", \"tricoron\", \"trifurox\", \"viofuragyn\")" "character(0)"
|
\"nitrofuroxon\", \"optazol\", \"ortazol\", \"puradin\", \"roptazol\", \"sclaventerol\", \"tikofuran\", \"topazone\", \"trichofuron\", \"tricofuron\", \"tricoron\", \"trifurox\", \"viofuragyn\")" "character(0)"
|
||||||
"FUS" "J01XC01" 3000226 "Fusidic acid" "Other antibacterials" "Other antibacterials" "Steroid antibacterials" "fusi" "c(\"acide fusidique\", \"acido fusidico\", \"acidum fusidicum\", \"flucidin\", \"fucidate\", \"fucidate sodium\", \"fucidic acid\", \"fucidin\", \"fucidin acid\", \"fucithalmic\", \"fusidate\", \"fusidate acid\", \"fusidic acid\", \"fusidine\", \"fusidinic acid\", \"ramycin\")" 1.5 "g" 1.5 "g" "character(0)"
|
"FUS" "J01XC01" 3000226 "Fusidic acid" "Other antibacterials" "Other antibacterials" "Steroid antibacterials" "c(\"fa\", \"fusi\")" "c(\"acide fusidique\", \"acido fusidico\", \"acidum fusidicum\", \"flucidin\", \"fucidate\", \"fucidate sodium\", \"fucidic acid\", \"fucidin\", \"fucidin acid\", \"fucithalmic\", \"fusidate\", \"fusidate acid\", \"fusidic acid\", \"fusidine\", \"fusidinic acid\", \"ramycin\")" 1.5 "g" 1.5 "g" "character(0)"
|
||||||
"GAM" 59364992 "Gamithromycin" "Macrolides/lincosamides" "" "gamithromycin" "character(0)"
|
"GAM" 59364992 "Gamithromycin" "Macrolides/lincosamides" "" "gamithromycin" "character(0)"
|
||||||
"GRN" 124093 "Garenoxacin" "Quinolones" "" "c(\"ganefloxacin\", \"garenfloxacin\", \"garenoxacin\")" "character(0)"
|
"GRN" 124093 "Garenoxacin" "Quinolones" "" "c(\"ganefloxacin\", \"garenfloxacin\", \"garenoxacin\")" "character(0)"
|
||||||
"GAT" "J01MA16" 5379 "Gatifloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"gati\")" "c(\"gatiflo\", \"gatifloxacin\", \"gatifloxacine\", \"gatifloxcin\", \"gatilox\", \"gatiquin\", \"gatispan\", \"tequin\", \"tequin and zymar\", \"zymaxid\")" 0.4 "g" 0.4 "g" "character(0)"
|
"GAT" "J01MA16" 5379 "Gatifloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"gati\")" "c(\"gatiflo\", \"gatifloxacin\", \"gatifloxacine\", \"gatifloxcin\", \"gatilox\", \"gatiquin\", \"gatispan\", \"tequin\", \"tequin and zymar\", \"zymaxid\")" 0.4 "g" 0.4 "g" "character(0)"
|
||||||
"GEM" "J01MA15" 9571107 "Gemifloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "" "c(\"factiv\", \"factive\", \"gemifioxacin\", \"gemifloxacin\", \"gemifloxacine\", \"gemifloxacino\", \"gemifloxacinum\")" 0.32 "character(0)"
|
"GEM" "J01MA15" 9571107 "Gemifloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "" "c(\"factiv\", \"factive\", \"gemifioxacin\", \"gemifloxacin\", \"gemifloxacine\", \"gemifloxacino\", \"gemifloxacinum\")" 0.32 "character(0)"
|
||||||
"GEN" "J01GB03" 3467 "Gentamicin" "Aminoglycosides" "Aminoglycoside antibacterials" "Other aminoglycosides" "c(\"cn\", \"gen\", \"gent\", \"gm\")" "c(\"apogen\", \"centicin\", \"cidomycin\", \"garasol\", \"genoptic liquifilm\", \"genoptic s.o.p.\", \"gentacycol\", \"gentafair\", \"gentak\", \"gentamar\", \"gentamcin sulfate\", \"gentamicin\", \"gentamicina\", \"gentamicine\", \"gentamicins\", \"gentamicinum\", \"gentamycin\", \"gentamycins\", \"gentamycinum\", \"gentavet\", \"gentocin\", \"jenamicin\", \"lyramycin\", \"oksitselanim\", \"refobacin\", \"refobacin tm\", \"septigen\", \"uromycine\")" 0.24 "g" "c(\"13561-6\", \"13562-4\", \"15106-8\", \"22746-2\", \"22747-0\", \"31091-2\", \"31092-0\", \"31093-8\", \"35668-3\", \"3663-2\", \"3664-0\", \"3665-7\", \"39082-3\", \"47109-4\", \"59379-8\", \"80971-5\", \"88111-0\")"
|
"GEN" "J01GB03" 3467 "Gentamicin" "Aminoglycosides" "Aminoglycoside antibacterials" "Other aminoglycosides" "c(\"cn\", \"gen\", \"gent\", \"gm\")" "c(\"apogen\", \"centicin\", \"cidomycin\", \"garasol\", \"genoptic liquifilm\", \"genoptic s.o.p.\", \"gentacycol\", \"gentafair\", \"gentak\", \"gentamar\", \"gentamcin sulfate\", \"gentamicin\", \"gentamicina\", \"gentamicine\", \"gentamicins\", \"gentamicinum\", \"gentamycin\", \"gentamycins\", \"gentamycinum\", \"gentavet\", \"gentocin\", \"jenamicin\", \"lyramycin\", \"oksitselanim\", \"refobacin\", \"refobacin tm\", \"septigen\", \"uromycine\")" 0.24 "g" "c(\"13561-6\", \"13562-4\", \"15106-8\", \"22746-2\", \"22747-0\", \"31091-2\", \"31092-0\", \"31093-8\", \"35668-3\", \"3663-2\", \"3664-0\", \"3665-7\", \"39082-3\", \"47109-4\", \"59379-8\", \"80971-5\", \"88111-0\")"
|
||||||
"GEH" "Gentamicin-high" "Aminoglycosides" "c(\"gehl\", \"genta high\", \"gentamicin high\")" "" ""
|
"GEH" "Gentamicin-high" "Aminoglycosides" "c(\"g_h\", \"gehl\", \"genta high\", \"gentamicin high\")" "" ""
|
||||||
"GEP" 25101874 "Gepotidacin" "Other antibacterials" "" "gepotidacin" "character(0)"
|
"GEP" 25101874 "Gepotidacin" "Other antibacterials" "" "gepotidacin" "character(0)"
|
||||||
"GRX" "J01MA11" 72474 "Grepafloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"grep\")" "grepafloxacin" 0.4 "g" "character(0)"
|
"GRX" "J01MA11" 72474 "Grepafloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"grep\")" "grepafloxacin" 0.4 "g" "character(0)"
|
||||||
"GRI" 441140 "Griseofulvin" "Antifungals/antimycotics" "" "c(\"amudane\", \"curling factor\", \"delmofulvina\", \"fulcin\", \"fulcine\", \"fulvican grisactin\", \"fulvicin\", \"fulvicin bolus\", \"fulvidex\", \"fulvina\", \"fulvinil\", \"fulvistatin\", \"fungivin\", \"greosin\", \"gresfeed\", \"gricin\", \"grifulin\", \"grifulvin\", \"grifulvin v\", \"grisactin\", \"grisactin ultra\", \"grisactin v\", \"griscofulvin\", \"grise ostatin\", \"grisefuline\", \"griseo\", \"griseofulvin\", \"griseofulvin forte\", \"griseofulvina\", \"griseofulvine\", \"griseofulvinum\", \"griseomix\", \"griseostatin\", \"grisetin\", \"grisofulvin\",
|
"GRI" 441140 "Griseofulvin" "Antifungals/antimycotics" "" "c(\"amudane\", \"curling factor\", \"delmofulvina\", \"fulcin\", \"fulcine\", \"fulvican grisactin\", \"fulvicin\", \"fulvicin bolus\", \"fulvidex\", \"fulvina\", \"fulvinil\", \"fulvistatin\", \"fungivin\", \"greosin\", \"gresfeed\", \"gricin\", \"grifulin\", \"grifulvin\", \"grifulvin v\", \"grisactin\", \"grisactin ultra\", \"grisactin v\", \"griscofulvin\", \"grise ostatin\", \"grisefuline\", \"griseo\", \"griseofulvin\", \"griseofulvin forte\", \"griseofulvina\", \"griseofulvine\", \"griseofulvinum\", \"griseomix\", \"griseostatin\", \"grisetin\", \"grisofulvin\",
|
||||||
@@ -238,9 +238,9 @@
|
|||||||
"ITR" "J02AC02" 3793 "Itraconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Triazole derivatives" "itra" "c(\"itraconazol\", \"itraconazole\", \"itraconazolum\", \"itraconzaole\", \"itrazole\", \"oriconazole\", \"sporanox\")" 0.2 "g" 0.2 "g" "c(\"10989-2\", \"12392-7\", \"25258-5\", \"27081-9\", \"32184-4\", \"32185-1\", \"80531-7\")"
|
"ITR" "J02AC02" 3793 "Itraconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Triazole derivatives" "itra" "c(\"itraconazol\", \"itraconazole\", \"itraconazolum\", \"itraconzaole\", \"itrazole\", \"oriconazole\", \"sporanox\")" 0.2 "g" 0.2 "g" "c(\"10989-2\", \"12392-7\", \"25258-5\", \"27081-9\", \"32184-4\", \"32185-1\", \"80531-7\")"
|
||||||
"JOS" "J01FA07" 5282165 "Josamycin" "Macrolides/lincosamides" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"josacine\", \"josamicina\", \"josamycin\", \"josamycine\", \"josamycinum\")" 2 "g" "character(0)"
|
"JOS" "J01FA07" 5282165 "Josamycin" "Macrolides/lincosamides" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"josacine\", \"josamicina\", \"josamycin\", \"josamycine\", \"josamycinum\")" 2 "g" "character(0)"
|
||||||
"KAN" "J01GB04" 6032 "Kanamycin" "Aminoglycosides" "Aminoglycoside antibacterials" "Other aminoglycosides" "c(\"hlk\", \"k\", \"kan\", \"kana\", \"km\")" "c(\"kanamicina\", \"kanamycin\", \"kanamycin a\", \"kanamycin base\", \"kanamycine\", \"kanamycinum\", \"kantrex\", \"kenamycin a\", \"klebcil\", \"liposomal kanamycin\")" 1 "g" "c(\"23889-9\", \"3698-8\", \"3699-6\", \"3700-2\", \"47395-9\")"
|
"KAN" "J01GB04" 6032 "Kanamycin" "Aminoglycosides" "Aminoglycoside antibacterials" "Other aminoglycosides" "c(\"hlk\", \"k\", \"kan\", \"kana\", \"km\")" "c(\"kanamicina\", \"kanamycin\", \"kanamycin a\", \"kanamycin base\", \"kanamycine\", \"kanamycinum\", \"kantrex\", \"kenamycin a\", \"klebcil\", \"liposomal kanamycin\")" 1 "g" "c(\"23889-9\", \"3698-8\", \"3699-6\", \"3700-2\", \"47395-9\")"
|
||||||
"KAH" "Kanamycin-high" "Aminoglycosides" "c(\"\", \"kahl\")" "" ""
|
"KAH" "Kanamycin-high" "Aminoglycosides" "c(\"\", \"k_h\", \"kahl\")" "" ""
|
||||||
"KAC" "Kanamycin/cephalexin" "Aminoglycosides" "" "" ""
|
"KAC" "Kanamycin/cephalexin" "Aminoglycosides" "" "" ""
|
||||||
"KET" "J02AB02" 456201 "Ketoconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Imidazole derivatives" "keto" "c(\"extina\", \"fungarest\", \"fungoral\", \"ketocanazole\", \"ketoconazol\", \"ketoconazole\", \"ketoconazolum\", \"ketoderm\", \"nizoral\", \"xolegel\")" 0.2 "g" "c(\"10990-0\", \"12393-5\", \"25259-3\", \"60091-6\", \"60092-4\")"
|
"KET" "J02AB02" 456201 "Ketoconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Imidazole derivatives" "c(\"keto\", \"ktc\")" "c(\"extina\", \"fungarest\", \"fungoral\", \"ketocanazole\", \"ketoconazol\", \"ketoconazole\", \"ketoconazolum\", \"ketoderm\", \"nizoral\", \"xolegel\")" 0.2 "g" "c(\"10990-0\", \"12393-5\", \"25259-3\", \"60091-6\", \"60092-4\")"
|
||||||
"KIT" "Kitasamycin (Leucomycin)" "Macrolides/lincosamides" "" "" ""
|
"KIT" "Kitasamycin (Leucomycin)" "Macrolides/lincosamides" "" "" ""
|
||||||
"LAS" 5360807 "Lasalocid" "Other antibacterials" "" "c(\"avatec\", \"lasalocid\", \"lasalocid a\", \"lasalocide\", \"lasalocide a\", \"lasalocido\", \"lasalocidum\")" "87598-9"
|
"LAS" 5360807 "Lasalocid" "Other antibacterials" "" "c(\"avatec\", \"lasalocid\", \"lasalocid a\", \"lasalocide\", \"lasalocide a\", \"lasalocido\", \"lasalocidum\")" "87598-9"
|
||||||
"LTM" "J01DD06" 47499 "Latamoxef" "Cephalosporins (3rd gen.)" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"mox\", \"moxa\")" "c(\"disodium moxalactam\", \"festamoxin\", \"lamoxactam\", \"latamoxef\", \"latamoxefum\", \"shiomarin\")" 4 "g" "character(0)"
|
"LTM" "J01DD06" 47499 "Latamoxef" "Cephalosporins (3rd gen.)" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"mox\", \"moxa\")" "c(\"disodium moxalactam\", \"festamoxin\", \"lamoxactam\", \"latamoxef\", \"latamoxefum\", \"shiomarin\")" 4 "g" "character(0)"
|
||||||
@@ -342,7 +342,7 @@
|
|||||||
"PPA" "J01MB04" 4831 "Pipemidic acid" "Quinolones" "Quinolone antibacterials" "Other quinolones" "c(\"pipz\", \"pizu\")" "c(\"acide pipemidique\", \"acido pipemidico\", \"acidum pipemidicum\", \"deblaston\", \"dolcol\", \"pipedac\", \"pipemid\", \"pipemidic\", \"pipemidic acid\", \"pipemidicacid\", \"pipram\", \"uromidin\")" 0.8 "g" "character(0)"
|
"PPA" "J01MB04" 4831 "Pipemidic acid" "Quinolones" "Quinolone antibacterials" "Other quinolones" "c(\"pipz\", \"pizu\")" "c(\"acide pipemidique\", \"acido pipemidico\", \"acidum pipemidicum\", \"deblaston\", \"dolcol\", \"pipedac\", \"pipemid\", \"pipemidic\", \"pipemidic acid\", \"pipemidicacid\", \"pipram\", \"uromidin\")" 0.8 "g" "character(0)"
|
||||||
"PIP" "J01CA12" 43672 "Piperacillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"pi\", \"pip\", \"pipc\", \"pipe\", \"pp\")" "c(\"isipen\", \"pentcillin\", \"peperacillin\", \"peracin\", \"piperacilina\", \"piperacillin\", \"piperacillin na\", \"piperacillin sodium\", \"piperacilline\", \"piperacillinum\", \"pipercillin\", \"pipracil\", \"pipril\")" 14 "g" "c(\"25268-4\", \"3972-7\")"
|
"PIP" "J01CA12" 43672 "Piperacillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"pi\", \"pip\", \"pipc\", \"pipe\", \"pp\")" "c(\"isipen\", \"pentcillin\", \"peperacillin\", \"peracin\", \"piperacilina\", \"piperacillin\", \"piperacillin na\", \"piperacillin sodium\", \"piperacilline\", \"piperacillinum\", \"pipercillin\", \"pipracil\", \"pipril\")" 14 "g" "c(\"25268-4\", \"3972-7\")"
|
||||||
"PIS" "Piperacillin/sulbactam" "Beta-lactams/penicillins" "" "" ""
|
"PIS" "Piperacillin/sulbactam" "Beta-lactams/penicillins" "" "" ""
|
||||||
"TZP" "J01CR05" 461573 "Piperacillin/tazobactam" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "c(\"p/t\", \"piptaz\", \"piptazo\", \"pita\", \"pt\", \"ptc\", \"ptz\", \"tzp\")" "c(\"\", \"tazocel\", \"tazocillin\", \"tazocin\", \"zosyn\")" 14 "g" "character(0)"
|
"TZP" "J01CR05" 461573 "Piperacillin/tazobactam" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "c(\"p/t\", \"piptaz\", \"piptazo\", \"pit\", \"pita\", \"pt\", \"ptc\", \"ptz\", \"tzp\")" "c(\"\", \"tazocel\", \"tazocillin\", \"tazocin\", \"zosyn\")" 14 "g" "character(0)"
|
||||||
"PRC" 71978 "Piridicillin" "Beta-lactams/penicillins" "" "piridicillin" "character(0)"
|
"PRC" 71978 "Piridicillin" "Beta-lactams/penicillins" "" "piridicillin" "character(0)"
|
||||||
"PRL" 157385 "Pirlimycin" "Other antibacterials" "" "c(\"pirlimycin\", \"pirlimycina\", \"pirlimycine\", \"pirlimycinum\", \"pirsue\")" "character(0)"
|
"PRL" 157385 "Pirlimycin" "Other antibacterials" "" "c(\"pirlimycin\", \"pirlimycina\", \"pirlimycine\", \"pirlimycinum\", \"pirsue\")" "character(0)"
|
||||||
"PIR" "J01MB03" 4855 "Piromidic acid" "Quinolones" "Quinolone antibacterials" "Other quinolones" "" "c(\"acide piromidique\", \"acido piromidico\", \"acidum piromidicum\", \"actrun c\", \"bactramyl\", \"enterol\", \"gastrurol\", \"panacid\", \"pirodal\", \"piromidic acid\", \"pyrido\", \"reelon\", \"septural\", \"urisept\", \"uropir\", \"zaomeal\")" 2 "g" "character(0)"
|
"PIR" "J01MB03" 4855 "Piromidic acid" "Quinolones" "Quinolone antibacterials" "Other quinolones" "" "c(\"acide piromidique\", \"acido piromidico\", \"acidum piromidicum\", \"actrun c\", \"bactramyl\", \"enterol\", \"gastrurol\", \"panacid\", \"pirodal\", \"piromidic acid\", \"pyrido\", \"reelon\", \"septural\", \"urisept\", \"uropir\", \"zaomeal\")" 2 "g" "character(0)"
|
||||||
@@ -397,13 +397,13 @@
|
|||||||
"SIT" 461399 "Sitafloxacin" "Quinolones" "" "c(\"gracevit\", \"sitafloxacinisomer\")" "character(0)"
|
"SIT" 461399 "Sitafloxacin" "Quinolones" "" "c(\"gracevit\", \"sitafloxacinisomer\")" "character(0)"
|
||||||
"SDA" "J04AA02" 2724368 "Sodium aminosalicylate" "Antimycobacterials" "Drugs for treatment of tuberculosis" "Aminosalicylic acid and derivatives" "" "c(\"bactylan\", \"decapasil\", \"lepasen\", \"monopas\", \"nippas\", \"p.a.s. sodium\", \"pamisyl sodium\", \"parasal sodium\", \"pas sodium\", \"pasade\", \"pasnal\", \"passodico\", \"salvis\", \"sanipirol\", \"sodiopas\", \"sodium p.a.s\", \"sodium pas\", \"teebacin\", \"tubersan\")" 14 "g" 14 "g" "character(0)"
|
"SDA" "J04AA02" 2724368 "Sodium aminosalicylate" "Antimycobacterials" "Drugs for treatment of tuberculosis" "Aminosalicylic acid and derivatives" "" "c(\"bactylan\", \"decapasil\", \"lepasen\", \"monopas\", \"nippas\", \"p.a.s. sodium\", \"pamisyl sodium\", \"parasal sodium\", \"pas sodium\", \"pasade\", \"pasnal\", \"passodico\", \"salvis\", \"sanipirol\", \"sodiopas\", \"sodium p.a.s\", \"sodium pas\", \"teebacin\", \"tubersan\")" 14 "g" 14 "g" "character(0)"
|
||||||
"SOL" 25242512 "Solithromycin" "Macrolides/lincosamides" "" "" ""
|
"SOL" 25242512 "Solithromycin" "Macrolides/lincosamides" "" "" ""
|
||||||
"SPX" "J01MA09" 60464 "Sparfloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"spar\")" "c(\"esparfloxacino\", \"sparfloxacin\", \"sparfloxacine\", \"sparfloxacinum\")" 0.2 "g" "character(0)"
|
"SPX" "J01MA09" 60464 "Sparfloxacin" "Quinolones" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"spa\", \"spar\")" "c(\"esparfloxacino\", \"sparfloxacin\", \"sparfloxacine\", \"sparfloxacinum\")" 0.2 "g" "character(0)"
|
||||||
"SPT" "J01XX04" 15541 "Spectinomycin" "Other antibacterials" "Other antibacterials" "Other antibacterials" "c(\"sc\", \"spe\", \"spec\", \"spt\")" "c(\"actinospectacina\", \"adspec\", \"espectinomicina\", \"prospec\", \"specitinomycin\", \"spectam\", \"spectinomicina\", \"spectinomycin\", \"spectinomycin di hcl\", \"spectinomycine\", \"spectinomycinum\", \"stanilo\", \"togamycin\", \"trobicin\")" 3 "g" "character(0)"
|
"SPT" "J01XX04" 15541 "Spectinomycin" "Other antibacterials" "Other antibacterials" "Other antibacterials" "c(\"sc\", \"spe\", \"spec\", \"spt\")" "c(\"actinospectacina\", \"adspec\", \"espectinomicina\", \"prospec\", \"specitinomycin\", \"spectam\", \"spectinomicina\", \"spectinomycin\", \"spectinomycin di hcl\", \"spectinomycine\", \"spectinomycinum\", \"stanilo\", \"togamycin\", \"trobicin\")" 3 "g" "character(0)"
|
||||||
"SPI" "J01FA02" 6419898 "Spiramycin" "Macrolides/lincosamides" "Macrolides, lincosamides and streptogramins" "Macrolides" "c(\"\", \"spir\")" "c(\"espiramicin\", \"provamycin\", \"rovamycin\", \"rovamycine\", \"sequamycin\", \"spiramycine\", \"spiramycinum\")" 3 "g" "character(0)"
|
"SPI" "J01FA02" 6419898 "Spiramycin" "Macrolides/lincosamides" "Macrolides, lincosamides and streptogramins" "Macrolides" "c(\"\", \"spir\")" "c(\"espiramicin\", \"provamycin\", \"rovamycin\", \"rovamycine\", \"sequamycin\", \"spiramycine\", \"spiramycinum\")" 3 "g" "character(0)"
|
||||||
"SPM" "J01RA04" "Spiramycin/metronidazole" "Other antibacterials" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
|
"SPM" "J01RA04" "Spiramycin/metronidazole" "Other antibacterials" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
|
||||||
"STR" "J01GA02" "Streptoduocin" "Aminoglycosides" "Aminoglycoside antibacterials" "Streptomycins" "" "" 1 "g" ""
|
"STR" "J01GA02" "Streptoduocin" "Aminoglycosides" "Aminoglycoside antibacterials" "Streptomycins" "" "" 1 "g" ""
|
||||||
"STR1" "J01GA01" 19649 "Streptomycin" "Aminoglycosides" "Aminoglycoside antibacterials" "Streptomycins" "c(\"s\", \"str\", \"stre\")" "c(\"agrept\", \"agrimycin\", \"chemform\", \"estreptomicina\", \"neodiestreptopab\", \"strepcen\", \"streptomicina\", \"streptomycin\", \"streptomycin a\", \"streptomycin spx\", \"streptomycin sulfate\", \"streptomycine\", \"streptomyzin\", \"vetstrep\")" 1 "g" "4039-4"
|
"STR1" "J01GA01" 19649 "Streptomycin" "Aminoglycosides" "Aminoglycoside antibacterials" "Streptomycins" "c(\"s\", \"stm\", \"str\", \"stre\")" "c(\"agrept\", \"agrimycin\", \"chemform\", \"estreptomicina\", \"neodiestreptopab\", \"strepcen\", \"streptomicina\", \"streptomycin\", \"streptomycin a\", \"streptomycin spx\", \"streptomycin sulfate\", \"streptomycine\", \"streptomyzin\", \"vetstrep\")" 1 "g" "4039-4"
|
||||||
"STH" "Streptomycin-high" "Aminoglycosides" "c(\"sthl\", \"strepto high\", \"streptomycin high\")" "" ""
|
"STH" "Streptomycin-high" "Aminoglycosides" "c(\"s_h\", \"sthl\", \"strepto high\", \"streptomycin high\")" "" ""
|
||||||
"STI" "J04AM01" "Streptomycin/isoniazid" "Antimycobacterials" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" ""
|
"STI" "J04AM01" "Streptomycin/isoniazid" "Antimycobacterials" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" ""
|
||||||
"SUL" "J01CG01" 130313 "Sulbactam" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase inhibitors" "" "c(\"betamaze\", \"sulbactam\", \"sulbactam acid\", \"sulbactam free acid\", \"sulbactamum\")" 1 "g" "character(0)"
|
"SUL" "J01CG01" 130313 "Sulbactam" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Beta-lactamase inhibitors" "" "c(\"betamaze\", \"sulbactam\", \"sulbactam acid\", \"sulbactam free acid\", \"sulbactamum\")" 1 "g" "character(0)"
|
||||||
"SBC" "J01CA16" 20055036 "Sulbenicillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"kedacillina\", \"sulbenicilina\", \"sulbenicilline\", \"sulbenicillinum\")" 15 "g" "character(0)"
|
"SBC" "J01CA16" 20055036 "Sulbenicillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"kedacillina\", \"sulbenicilina\", \"sulbenicilline\", \"sulbenicillinum\")" 15 "g" "character(0)"
|
||||||
@@ -479,7 +479,7 @@
|
|||||||
"TIA" 656958 "Tiamulin" "Other antibacterials" "" "c(\"denagard\", \"tiamulin\", \"tiamulin pamoate\", \"tiamulina\", \"tiamuline\", \"tiamulinum\")" "87589-8"
|
"TIA" 656958 "Tiamulin" "Other antibacterials" "" "c(\"denagard\", \"tiamulin\", \"tiamulin pamoate\", \"tiamulina\", \"tiamuline\", \"tiamulinum\")" "87589-8"
|
||||||
"TIC" "J01CA13" 36921 "Ticarcillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"tc\", \"ti\", \"tic\", \"tica\")" "c(\"ticarcilina\", \"ticarcillin\", \"ticarcilline\", \"ticarcillinum\", \"ticillin\")" 15 "g" "c(\"25254-4\", \"4054-3\", \"4055-0\")"
|
"TIC" "J01CA13" 36921 "Ticarcillin" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"tc\", \"ti\", \"tic\", \"tica\")" "c(\"ticarcilina\", \"ticarcillin\", \"ticarcilline\", \"ticarcillinum\", \"ticillin\")" 15 "g" "c(\"25254-4\", \"4054-3\", \"4055-0\")"
|
||||||
"TCC" "J01CR03" 6437075 "Ticarcillin/clavulanic acid" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "c(\"t/c\", \"tcc\", \"ticl\", \"tim\", \"tlc\")" "timentin" 15 "g" "character(0)"
|
"TCC" "J01CR03" 6437075 "Ticarcillin/clavulanic acid" "Beta-lactams/penicillins" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "c(\"t/c\", \"tcc\", \"ticl\", \"tim\", \"tlc\")" "timentin" 15 "g" "character(0)"
|
||||||
"TGC" "J01AA12" 54686904 "Tigecycline" "Tetracyclines" "Tetracyclines" "Tetracyclines" "c(\"tgc\", \"tige\")" "c(\"haizheng li xing\", \"tigeciclina\", \"tigecyclin\", \"tigecycline\", \"tigecycline hydrate\", \"tigecyclinum\", \"tigilcycline\", \"tygacil\")" 0.1 "g" "character(0)"
|
"TGC" "J01AA12" 54686904 "Tigecycline" "Tetracyclines" "Tetracyclines" "Tetracyclines" "c(\"tgc\", \"tig\", \"tige\")" "c(\"haizheng li xing\", \"tigeciclina\", \"tigecyclin\", \"tigecycline\", \"tigecycline hydrate\", \"tigecyclinum\", \"tigilcycline\", \"tygacil\")" 0.1 "g" "character(0)"
|
||||||
"TBQ" 65592 "Tilbroquinol" "Quinolones" "" "c(\"tilbroquinol\", \"tilbroquinolum\")" "character(0)"
|
"TBQ" 65592 "Tilbroquinol" "Quinolones" "" "c(\"tilbroquinol\", \"tilbroquinolum\")" "character(0)"
|
||||||
"TIP" 24860548 "Tildipirosin" "Macrolides/lincosamides" "" "c(\"tildipirosin\", \"zuprevo\")" "character(0)"
|
"TIP" 24860548 "Tildipirosin" "Macrolides/lincosamides" "" "c(\"tildipirosin\", \"zuprevo\")" "character(0)"
|
||||||
"TIL" 5282521 "Tilmicosin" "Macrolides/lincosamides" "" "c(\"micotil\", \"pulmotil\", \"tilmicosin\", \"tilmicosina\", \"tilmicosine\", \"tilmicosinum\")" "87588-0"
|
"TIL" 5282521 "Tilmicosin" "Macrolides/lincosamides" "" "c(\"micotil\", \"pulmotil\", \"tilmicosin\", \"tilmicosina\", \"tilmicosine\", \"tilmicosinum\")" "87588-0"
|
||||||
@@ -491,7 +491,7 @@
|
|||||||
"TOB" "J01GB01" 36294 "Tobramycin" "Aminoglycosides" "Aminoglycoside antibacterials" "Other aminoglycosides" "c(\"nn\", \"tm\", \"to\", \"tob\", \"tobr\")" "c(\"bethkis\", \"brulamycin\", \"deoxykanamycin b\", \"distobram\", \"gernebcin\", \"gotabiotic\", \"kitabis pak\", \"nebcin\", \"nebicin\", \"nebramycin\", \"nebramycin vi\", \"obramycin\", \"sybryx\", \"tenebrimycin\", \"tenemycin\", \"tobacin\", \"tobi podhaler\", \"tobracin\", \"tobradex\", \"tobradistin\", \"tobralex\", \"tobramaxin\", \"tobramicin\", \"tobramicina\", \"tobramitsetin\", \"tobramycetin\", \"tobramycin\", \"tobramycin base\", \"tobramycin sulfate\", \"tobramycine\", \"tobramycinum\", \"tobrased\", \"tobrasone\", \"tobrex\")" 0.24 "g" "c(\"13584-8\", \"17808-7\", \"22750-4\", \"22751-2\", \"22752-0\", \"31094-6\", \"31095-3\", \"31096-1\", \"35239-3\", \"35670-9\", \"4057-6\", \"4058-4\", \"4059-2\", \"50927-3\", \"52962-8\", \"59380-6\", \"80966-5\")"
|
"TOB" "J01GB01" 36294 "Tobramycin" "Aminoglycosides" "Aminoglycoside antibacterials" "Other aminoglycosides" "c(\"nn\", \"tm\", \"to\", \"tob\", \"tobr\")" "c(\"bethkis\", \"brulamycin\", \"deoxykanamycin b\", \"distobram\", \"gernebcin\", \"gotabiotic\", \"kitabis pak\", \"nebcin\", \"nebicin\", \"nebramycin\", \"nebramycin vi\", \"obramycin\", \"sybryx\", \"tenebrimycin\", \"tenemycin\", \"tobacin\", \"tobi podhaler\", \"tobracin\", \"tobradex\", \"tobradistin\", \"tobralex\", \"tobramaxin\", \"tobramicin\", \"tobramicina\", \"tobramitsetin\", \"tobramycetin\", \"tobramycin\", \"tobramycin base\", \"tobramycin sulfate\", \"tobramycine\", \"tobramycinum\", \"tobrased\", \"tobrasone\", \"tobrex\")" 0.24 "g" "c(\"13584-8\", \"17808-7\", \"22750-4\", \"22751-2\", \"22752-0\", \"31094-6\", \"31095-3\", \"31096-1\", \"35239-3\", \"35670-9\", \"4057-6\", \"4058-4\", \"4059-2\", \"50927-3\", \"52962-8\", \"59380-6\", \"80966-5\")"
|
||||||
"TOH" "Tobramycin-high" "Aminoglycosides" "c(\"tobra high\", \"tobramycin high\", \"tohl\")" "" ""
|
"TOH" "Tobramycin-high" "Aminoglycosides" "c(\"tobra high\", \"tobramycin high\", \"tohl\")" "" ""
|
||||||
"TFX" 5517 "Tosufloxacin" "Quinolones" "" "tosufloxacin" "character(0)"
|
"TFX" 5517 "Tosufloxacin" "Quinolones" "" "tosufloxacin" "character(0)"
|
||||||
"TMP" "J01EA01" 5578 "Trimethoprim" "Trimethoprims" "Sulfonamides and trimethoprim" "Trimethoprim and derivatives" "c(\"t\", \"tmp\", \"tr\", \"trim\", \"w\")" "c(\"abaprim\", \"alprim\", \"anitrim\", \"antrima\", \"antrimox\", \"bacdan\", \"bacidal\", \"bacide\", \"bacterial\", \"bacticel\", \"bactifor\", \"bactin\", \"bactoprim\", \"bactramin\", \"bactrim\", \"bencole\", \"bethaprim\", \"biosulten\", \"briscotrim\", \"chemotrin\", \"colizole\", \"colizole ds\", \"conprim\", \"cotrimel\", \"cotrimoxizole\", \"deprim\", \"dosulfin\", \"duocide\", \"esbesul\", \"espectrin\", \"euctrim\", \"exbesul\", \"fermagex\", \"fortrim\", \"idotrim\", \"ikaprim\", \"instalac\", \"kombinax\", \"lagatrim\", \"lagatrim forte\", \"lastrim\", \"lescot\",
|
"TMP" "J01EA01" 5578 "Trimethoprim" "Trimethoprims" "Sulfonamides and trimethoprim" "Trimethoprim and derivatives" "c(\"t\", \"tmp\", \"tr\", \"tri\", \"trim\", \"w\")" "c(\"abaprim\", \"alprim\", \"anitrim\", \"antrima\", \"antrimox\", \"bacdan\", \"bacidal\", \"bacide\", \"bacterial\", \"bacticel\", \"bactifor\", \"bactin\", \"bactoprim\", \"bactramin\", \"bactrim\", \"bencole\", \"bethaprim\", \"biosulten\", \"briscotrim\", \"chemotrin\", \"colizole\", \"colizole ds\", \"conprim\", \"cotrimel\", \"cotrimoxizole\", \"deprim\", \"dosulfin\", \"duocide\", \"esbesul\", \"espectrin\", \"euctrim\", \"exbesul\", \"fermagex\", \"fortrim\", \"idotrim\", \"ikaprim\", \"instalac\", \"kombinax\", \"lagatrim\", \"lagatrim forte\", \"lastrim\", \"lescot\",
|
||||||
\"methoprim\", \"metoprim\", \"monoprim\", \"monotrim\", \"monotrimin\", \"novotrimel\", \"omstat\", \"oraprim\", \"pancidim\", \"polytrim\", \"priloprim\", \"primosept\", \"primsol\", \"proloprim\", \"protrin\", \"purbal\", \"resprim\", \"resprim forte\", \"roubac\", \"roubal\", \"salvatrim\", \"septrin ds\", \"septrin forte\", \"septrin s\", \"setprin\", \"sinotrim\", \"stopan\", \"streptoplus\", \"sugaprim\", \"sulfamar\", \"sulfamethoprim\", \"sulfoxaprim\", \"sulthrim\", \"sultrex\", \"syraprim\", \"tiempe\", \"tmp smx\", \"toprim\", \"trimanyl\", \"trimethioprim\", \"trimethopim\",
|
\"methoprim\", \"metoprim\", \"monoprim\", \"monotrim\", \"monotrimin\", \"novotrimel\", \"omstat\", \"oraprim\", \"pancidim\", \"polytrim\", \"priloprim\", \"primosept\", \"primsol\", \"proloprim\", \"protrin\", \"purbal\", \"resprim\", \"resprim forte\", \"roubac\", \"roubal\", \"salvatrim\", \"septrin ds\", \"septrin forte\", \"septrin s\", \"setprin\", \"sinotrim\", \"stopan\", \"streptoplus\", \"sugaprim\", \"sulfamar\", \"sulfamethoprim\", \"sulfoxaprim\", \"sulthrim\", \"sultrex\", \"syraprim\", \"tiempe\", \"tmp smx\", \"toprim\", \"trimanyl\", \"trimethioprim\", \"trimethopim\",
|
||||||
\"trimethoprim\", \"trimethoprime\", \"trimethoprimum\", \"trimethopriom\", \"trimetoprim\", \"trimetoprima\", \"trimexazole\", \"trimexol\", \"trimezol\", \"trimogal\", \"trimono\", \"trimopan\", \"trimpex\", \"triprim\", \"trisul\", \"trisulcom\", \"trisulfam\", \"trisural\", \"uretrim\", \"urobactrim\", \"utetrin\", \"velaten\", \"wellcoprim\", \"wellcoprin\", \"xeroprim\", \"zamboprim\")" 0.4 "g" 0.4 "g" "c(\"11005-6\", \"17747-7\", \"25273-4\", \"32342-8\", \"4079-0\", \"4080-8\", \"4081-6\", \"55584-7\", \"80552-3\", \"80973-1\")"
|
\"trimethoprim\", \"trimethoprime\", \"trimethoprimum\", \"trimethopriom\", \"trimetoprim\", \"trimetoprima\", \"trimexazole\", \"trimexol\", \"trimezol\", \"trimogal\", \"trimono\", \"trimopan\", \"trimpex\", \"triprim\", \"trisul\", \"trisulcom\", \"trisulfam\", \"trisural\", \"uretrim\", \"urobactrim\", \"utetrin\", \"velaten\", \"wellcoprim\", \"wellcoprin\", \"xeroprim\", \"zamboprim\")" 0.4 "g" 0.4 "g" "c(\"11005-6\", \"17747-7\", \"25273-4\", \"32342-8\", \"4079-0\", \"4080-8\", \"4081-6\", \"55584-7\", \"80552-3\", \"80973-1\")"
|
||||||
"SXT" "J01EE01" 358641 "Trimethoprim/sulfamethoxazole" "Trimethoprims" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "c(\"cot\", \"cotrim\", \"sxt\", \"t/s\", \"trsu\", \"trsx\", \"ts\")" "c(\"bactrim\", \"bactrimel\", \"belcomycine\", \"colimycin\", \"colimycin sulphate\", \"colisticin\", \"colistimethate\", \"colistimethate sodium\", \"colistin sulfate\", \"colistin sulphate\", \"colomycin\", \"coly-mycin\", \"cotrimazole\", \"cotrimoxazole\", \"polymyxin e\", \"polymyxin e. sulfate\", \"promixin\", \"septra\", \"totazina\")" "character(0)"
|
"SXT" "J01EE01" 358641 "Trimethoprim/sulfamethoxazole" "Trimethoprims" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "c(\"cot\", \"cotrim\", \"sxt\", \"t/s\", \"trsu\", \"trsx\", \"ts\")" "c(\"bactrim\", \"bactrimel\", \"belcomycine\", \"colimycin\", \"colimycin sulphate\", \"colisticin\", \"colistimethate\", \"colistimethate sodium\", \"colistin sulfate\", \"colistin sulphate\", \"colomycin\", \"coly-mycin\", \"cotrimazole\", \"cotrimoxazole\", \"polymyxin e\", \"polymyxin e. sulfate\", \"promixin\", \"septra\", \"totazina\")" "character(0)"
|
||||||
@@ -506,6 +506,6 @@
|
|||||||
"VAM" "Vancomycin-macromethod" "Glycopeptides" "" "" ""
|
"VAM" "Vancomycin-macromethod" "Glycopeptides" "" "" ""
|
||||||
"VIO" 135398671 "Viomycin" "Antimycobacterials" "" "c(\"celiomycin\", \"florimycin\", \"floromycin\", \"viomicina\", \"viomycin\", \"viomycine\", \"viomycinum\")" "character(0)"
|
"VIO" 135398671 "Viomycin" "Antimycobacterials" "" "c(\"celiomycin\", \"florimycin\", \"floromycin\", \"viomicina\", \"viomycin\", \"viomycine\", \"viomycinum\")" "character(0)"
|
||||||
"VIR" 11979535 "Virginiamycine" "Other antibacterials" "" "c(\"eskalin v\", \"mikamycin\", \"mikamycine\", \"mikamycinum\", \"ostreogrycinum\", \"pristinamycine\", \"pristinamycinum\", \"stafac\", \"stafytracine\", \"staphylomycin\", \"starfac\", \"streptogramin\", \"vernamycin\", \"virgimycin\", \"virgimycine\", \"virginiamycina\", \"virginiamycine\", \"virginiamycinum\")" "character(0)"
|
"VIR" 11979535 "Virginiamycine" "Other antibacterials" "" "c(\"eskalin v\", \"mikamycin\", \"mikamycine\", \"mikamycinum\", \"ostreogrycinum\", \"pristinamycine\", \"pristinamycinum\", \"stafac\", \"stafytracine\", \"staphylomycin\", \"starfac\", \"streptogramin\", \"vernamycin\", \"virgimycin\", \"virgimycine\", \"virginiamycina\", \"virginiamycine\", \"virginiamycinum\")" "character(0)"
|
||||||
"VOR" "J02AC03" 71616 "Voriconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Triazole derivatives" "vori" "c(\"pfizer\", \"vfend i.v.\", \"voriconazol\", \"voriconazole\", \"voriconazolum\", \"vorikonazole\")" 0.4 "g" 0.4 "g" "c(\"38370-3\", \"53902-3\", \"73676-9\", \"80553-1\", \"80651-3\")"
|
"VOR" "J02AC03" 71616 "Voriconazole" "Antifungals/antimycotics" "Antimycotics for systemic use" "Triazole derivatives" "c(\"vori\", \"vrc\")" "c(\"pfizer\", \"vfend i.v.\", \"voriconazol\", \"voriconazole\", \"voriconazolum\", \"vorikonazole\")" 0.4 "g" 0.4 "g" "c(\"38370-3\", \"53902-3\", \"73676-9\", \"80553-1\", \"80651-3\")"
|
||||||
"XBR" "J01XX02" 72144 "Xibornol" "Other antibacterials" "Other antibacterials" "Other antibacterials" "" "c(\"bactacine\", \"bracen\", \"nanbacine\", \"xibornol\", \"xibornolo\", \"xibornolum\")" "character(0)"
|
"XBR" "J01XX02" 72144 "Xibornol" "Other antibacterials" "Other antibacterials" "Other antibacterials" "" "c(\"bactacine\", \"bracen\", \"nanbacine\", \"xibornol\", \"xibornolo\", \"xibornolum\")" "character(0)"
|
||||||
"ZID" 77846445 "Zidebactam" "Other antibacterials" "" "zidebactam" "character(0)"
|
"ZID" 77846445 "Zidebactam" "Other antibacterials" "" "zidebactam" "character(0)"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# -------------------------------------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------------------------------------
|
||||||
# For editing this EUCAST reference file, these values can all be used for targeting antibiotics:
|
# For editing this EUCAST reference file, these values can all be used for targeting antibiotics:
|
||||||
# 'all_betalactams', 'aminoglycosides', 'aminopenicillins', 'carbapenems', 'cephalosporins', 'cephalosporins_1st', 'cephalosporins_2nd', 'cephalosporins_3rd', 'cephalosporins_except_CAZ',
|
# 'betalactams', 'aminoglycosides', 'aminopenicillins', 'carbapenems', 'cephalosporins', 'cephalosporins_1st', 'cephalosporins_2nd', 'cephalosporins_3rd', 'cephalosporins_except_CAZ',
|
||||||
# 'fluoroquinolones', 'glycopeptides', 'lincosamides', 'lipoglycopeptides', 'macrolides', 'oxazolidinones', 'polymyxins', 'streptogramins', 'tetracyclines', 'ureidopenicillins',
|
# 'fluoroquinolones', 'glycopeptides', 'glycopeptides_except_lipo', 'lincosamides', 'lipoglycopeptides', 'macrolides', 'oxazolidinones', 'polymyxins', 'streptogramins', 'tetracyclines', 'tetracyclines_except_TGC', 'ureidopenicillins',
|
||||||
# and all separate EARS-Net letter codes like 'AMC'. They can be separated by comma: 'AMC, fluoroquinolones'.
|
# and all separate EARS-Net letter codes like 'AMC'. They can be separated by comma: 'AMC, fluoroquinolones'.
|
||||||
# The 'if_mo_property' column can be any column name from the AMR::microorganisms data set, or "genus_species" or "gramstain".
|
# The 'if_mo_property' column can be any column name from the AMR::microorganisms data set, or "genus_species" or "gramstain".
|
||||||
# The like.is.one_of column must be 'like' or 'is' or 'one_of' ('like' will read the 'this_value' column as regular expression)
|
# The like.is.one_of column must be 'like' or 'is' or 'one_of' ('like' will read the 'this_value' column as regular expression)
|
||||||
@@ -14,7 +14,7 @@ order is Enterobacterales AMP I AMX I Enterobacterales (Order) Breakpoints 10
|
|||||||
order is Enterobacterales AMP R AMX R Enterobacterales (Order) Breakpoints 10
|
order is Enterobacterales AMP R AMX R Enterobacterales (Order) Breakpoints 10
|
||||||
genus is Staphylococcus PEN, FOX S AMP, AMX, PIP, TIC S Staphylococcus Breakpoints 10
|
genus is Staphylococcus PEN, FOX S AMP, AMX, PIP, TIC S Staphylococcus Breakpoints 10
|
||||||
genus is Staphylococcus PEN, FOX R, S OXA, FLC S Staphylococcus Breakpoints 10
|
genus is Staphylococcus PEN, FOX R, S OXA, FLC S Staphylococcus Breakpoints 10
|
||||||
genus is Staphylococcus FOX R all_betalactams R Staphylococcus Breakpoints 10
|
genus is Staphylococcus FOX R betalactams R Staphylococcus Breakpoints 10
|
||||||
genus_species is Staphylococcus saprophyticus AMP S AMX, AMC, PIP, TZP S Staphylococcus Breakpoints 10
|
genus_species is Staphylococcus saprophyticus AMP S AMX, AMC, PIP, TZP S Staphylococcus Breakpoints 10
|
||||||
genus is Staphylococcus FOX S carbapenems, cephalosporins_except_CAZ S Staphylococcus Breakpoints 10
|
genus is Staphylococcus FOX S carbapenems, cephalosporins_except_CAZ S Staphylococcus Breakpoints 10
|
||||||
genus is Staphylococcus FOX I carbapenems, cephalosporins_except_CAZ I Staphylococcus Breakpoints 10
|
genus is Staphylococcus FOX I carbapenems, cephalosporins_except_CAZ I Staphylococcus Breakpoints 10
|
||||||
@@ -120,7 +120,7 @@ order is Enterobacterales AMP I AMX I Enterobacterales (Order) Breakpoints 11
|
|||||||
order is Enterobacterales AMP R AMX R Enterobacterales (Order) Breakpoints 11
|
order is Enterobacterales AMP R AMX R Enterobacterales (Order) Breakpoints 11
|
||||||
genus is Staphylococcus PEN, FOX S AMP, AMX, PIP, TIC S Staphylococcus Breakpoints 11
|
genus is Staphylococcus PEN, FOX S AMP, AMX, PIP, TIC S Staphylococcus Breakpoints 11
|
||||||
genus is Staphylococcus PEN, FOX R, S OXA, FLC S Staphylococcus Breakpoints 11
|
genus is Staphylococcus PEN, FOX R, S OXA, FLC S Staphylococcus Breakpoints 11
|
||||||
genus is Staphylococcus FOX R all_betalactams R Staphylococcus Breakpoints 11
|
genus is Staphylococcus FOX R betalactams R Staphylococcus Breakpoints 11
|
||||||
genus_species is Staphylococcus saprophyticus AMP S AMX, AMC, PIP, TZP S Staphylococcus Breakpoints 11
|
genus_species is Staphylococcus saprophyticus AMP S AMX, AMC, PIP, TZP S Staphylococcus Breakpoints 11
|
||||||
genus is Staphylococcus FOX S carbapenems, cephalosporins_except_CAZ S Staphylococcus Breakpoints 11
|
genus is Staphylococcus FOX S carbapenems, cephalosporins_except_CAZ S Staphylococcus Breakpoints 11
|
||||||
genus is Staphylococcus FOX I carbapenems, cephalosporins_except_CAZ I Staphylococcus Breakpoints 11
|
genus is Staphylococcus FOX I carbapenems, cephalosporins_except_CAZ I Staphylococcus Breakpoints 11
|
||||||
@@ -224,7 +224,7 @@ genus_species is Burkholderia pseudomallei TCY R DOX R Burkholderia pseudomallei
|
|||||||
genus is Bacillus NOR S fluoroquinolones S Bacillus Breakpoints 11 added in 11
|
genus is Bacillus NOR S fluoroquinolones S Bacillus Breakpoints 11 added in 11
|
||||||
genus is Bacillus NOR I fluoroquinolones I Bacillus Breakpoints 11 added in 11
|
genus is Bacillus NOR I fluoroquinolones I Bacillus Breakpoints 11 added in 11
|
||||||
genus is Bacillus NOR R fluoroquinolones R Bacillus Breakpoints 11 added in 11
|
genus is Bacillus NOR R fluoroquinolones R Bacillus Breakpoints 11 added in 11
|
||||||
order is Enterobacterales PEN, glycopeptides, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
order is Enterobacterales PEN, glycopeptides_except_lipo, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Enterobacter cloacae aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Enterobacter cloacae aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
@@ -232,17 +232,17 @@ genus_species is Klebsiella aerogenes aminopenicillins, AMC, CZO, FOX R Table
|
|||||||
genus_species is Escherichia hermannii aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Escherichia hermannii aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Hafnia alvei aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Hafnia alvei aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus is Klebsiella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus is Klebsiella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Morganella morganii aminopenicillins, AMC, CZO, tetracyclines, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Morganella morganii aminopenicillins, AMC, CZO, DOX, MNO, TCY, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Proteus mirabilis tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Proteus mirabilis DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Proteus penneri aminopenicillins, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Proteus penneri aminopenicillins, CZO, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Proteus vulgaris aminopenicillins, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Proteus vulgaris aminopenicillins, CZO, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Providencia rettgeri aminopenicillins, AMC, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Providencia rettgeri aminopenicillins, AMC, CZO, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Providencia stuartii aminopenicillins, AMC, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Providencia stuartii aminopenicillins, AMC, CZO, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus is Raoultella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus is Raoultella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Serratia marcescens aminopenicillins, AMC, CZO, FOX, CXM, DOX, TCY, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Serratia marcescens aminopenicillins, AMC, CZO, FOX, CXM, DOX, TCY, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Yersinia enterocolitica aminopenicillins, AMC, TIC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Yersinia enterocolitica aminopenicillins, AMC, TIC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus_species is Yersinia pseudotuberculosis PLB, COL R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
genus_species is Yersinia pseudotuberculosis PLB, COL R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||||
genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordetella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, FOX, CXM, glycopeptides, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordetella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, FOX, CXM, glycopeptides_except_lipo, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Acinetobacter baumannii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus_species is Acinetobacter baumannii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Acinetobacter pittii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus_species is Acinetobacter pittii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Acinetobacter nosocomialis aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus_species is Acinetobacter nosocomialis aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
@@ -250,10 +250,10 @@ genus_species is Acinetobacter calcoaceticus aminopenicillins, AMC, CZO, CTX,
|
|||||||
genus_species is Achromobacter xylosoxidans aminopenicillins, CZO, CTX, CRO, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus_species is Achromobacter xylosoxidans aminopenicillins, CZO, CTX, CRO, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
fullname like ^Burkholderia (ambifaria|anthina|arboris|cepacia|cenocepacia|contaminans|diffusa|dolosa|lata|latens|metallica|multivorans|paludis|pseudomultivorans|pyrrocinia|pseudomultivorans|seminalis|stabilis|stagnalis|territorii|ubonensis|vietnamiensis) aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, ATM, ETP, CIP, CHL, aminoglycosides, TMP, FOS, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
fullname like ^Burkholderia (ambifaria|anthina|arboris|cepacia|cenocepacia|contaminans|diffusa|dolosa|lata|latens|metallica|multivorans|paludis|pseudomultivorans|pyrrocinia|pseudomultivorans|seminalis|stabilis|stagnalis|territorii|ubonensis|vietnamiensis) aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, ATM, ETP, CIP, CHL, aminoglycosides, TMP, FOS, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Elizabethkingia meningoseptica aminopenicillins, AMC, TIC, CZO, CTX, CRO, CAZ, FEP, ATM, ETP, IPM, MEM, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus_species is Elizabethkingia meningoseptica aminopenicillins, AMC, TIC, CZO, CTX, CRO, CAZ, FEP, ATM, ETP, IPM, MEM, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Ochrobactrum anthropi aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus_species is Brucella anthropi aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, CZO, CTX, CRO, ETP, CHL, KAN, NEO, TMP, SXT, tetracyclines, TGC R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, CZO, CTX, CRO, ETP, CHL, KAN, NEO, TMP, SXT, DOX, MNO, TCY, TGC R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Stenotrophomonas maltophilia aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, ATM, ETP, IPM, MEM, aminoglycosides, TMP, FOS, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
genus_species is Stenotrophomonas maltophilia aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, ATM, ETP, IPM, MEM, aminoglycosides, TMP, FOS, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||||
genus one_of Haemophilus, Moraxella, Neisseria, Campylobacter glycopeptides, LIN, DAP, LNZ R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
genus one_of Haemophilus, Moraxella, Neisseria, Campylobacter glycopeptides_except_lipo, LIN, DAP, LNZ R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Haemophilus influenzae FUS, streptogramins R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
genus_species is Haemophilus influenzae FUS, streptogramins R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||||
genus_species is Moraxella catarrhalis TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
genus_species is Moraxella catarrhalis TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||||
genus is Neisseria TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
genus is Neisseria TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||||
@@ -279,8 +279,8 @@ genus_species is Enterococcus casseliflavus FUS, CAZ, cephalosporins_except_CA
|
|||||||
genus_species is Enterococcus faecium FUS, CAZ, cephalosporins_except_CAZ, aminoglycosides, macrolides, TMP, SXT R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
genus_species is Enterococcus faecium FUS, CAZ, cephalosporins_except_CAZ, aminoglycosides, macrolides, TMP, SXT R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||||
genus is Corynebacterium FOS R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
genus is Corynebacterium FOS R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||||
genus_species is Listeria monocytogenes cephalosporins R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
genus_species is Listeria monocytogenes cephalosporins R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||||
genus one_of Leuconostoc, Pediococcus glycopeptides R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
genus one_of Leuconostoc, Pediococcus glycopeptides_except_lipo R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||||
genus is Lactobacillus glycopeptides R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
genus is Lactobacillus glycopeptides_except_lipo R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||||
genus_species is Clostridium ramosum VAN R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
genus_species is Clostridium ramosum VAN R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||||
genus_species is Clostridium innocuum VAN R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
genus_species is Clostridium innocuum VAN R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||||
genus_species one_of Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G PEN S aminopenicillins, cephalosporins_except_CAZ, carbapenems S Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules 3.1
|
genus_species one_of Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G PEN S aminopenicillins, cephalosporins_except_CAZ, carbapenems S Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules 3.1
|
||||||
@@ -298,7 +298,7 @@ genus is Staphylococcus MFX R fluoroquinolones R Table 13: Interpretive rules fo
|
|||||||
genus_species is Streptococcus pneumoniae MFX R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
genus_species is Streptococcus pneumoniae MFX R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
||||||
order is Enterobacterales CIP R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
order is Enterobacterales CIP R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
||||||
genus_species is Neisseria gonorrhoeae CIP R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
genus_species is Neisseria gonorrhoeae CIP R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
||||||
order is Enterobacterales PEN, glycopeptides, lipoglycopeptides, FUS, macrolides, lincosamides, streptogramins, RIF, oxazolidinones R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
order is Enterobacterales PEN, glycopeptides_except_lipo, lipoglycopeptides, FUS, macrolides, lincosamides, streptogramins, RIF, oxazolidinones R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Enterobacter cloacae aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Enterobacter cloacae aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
@@ -308,13 +308,13 @@ genus_species is Klebsiella aerogenes aminopenicillins, AMC, SAM, CZO, CEP, LE
|
|||||||
genus_species is Klebsiella oxytoca aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Klebsiella oxytoca aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
fullname like ^Klebsiella( pneumoniae| quasipneumoniae| variicola)? aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
fullname like ^Klebsiella( pneumoniae| quasipneumoniae| variicola)? aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Leclercia adecarboxylata FOS R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Leclercia adecarboxylata FOS R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Morganella morganii aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, tetracyclines, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Morganella morganii aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, DOX, MNO, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Plesiomonas shigelloides aminopenicillins, AMC, SAM R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Plesiomonas shigelloides aminopenicillins, AMC, SAM R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Proteus mirabilis tetracyclines, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Proteus mirabilis DOX, MNO, TCY, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Proteus penneri aminopenicillins, CZO, CEP, LEX, CFR, CXM, tetracyclines, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Proteus penneri aminopenicillins, CZO, CEP, LEX, CFR, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Proteus vulgaris aminopenicillins, CZO, CEP, LEX, CFR, CXM, tetracyclines, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Proteus vulgaris aminopenicillins, CZO, CEP, LEX, CFR, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Providencia rettgeri aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, tetracyclines, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Providencia rettgeri aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, DOX, MNO, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Providencia stuartii aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, tetracyclines, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Providencia stuartii aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, DOX, MNO, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus is Raoultella aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus is Raoultella aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Serratia marcescens aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX, CXM, DOX, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Serratia marcescens aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX, CXM, DOX, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Yersinia enterocolitica aminopenicillins, AMC, SAM, TIC, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Yersinia enterocolitica aminopenicillins, AMC, SAM, TIC, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
@@ -324,20 +324,20 @@ genus_species is Aeromonas veronii aminopenicillins, AMC, SAM, FOX R Table 1:
|
|||||||
genus_species is Aeromonas dhakensis aminopenicillins, AMC, SAM, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Aeromonas dhakensis aminopenicillins, AMC, SAM, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Aeromonas caviae aminopenicillins, AMC, SAM, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Aeromonas caviae aminopenicillins, AMC, SAM, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus_species is Aeromonas jandaei aminopenicillins, AMC, SAM, TIC, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
genus_species is Aeromonas jandaei aminopenicillins, AMC, SAM, TIC, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||||
genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordetella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, cephalosporins_1st, cephalosporins_2nd, glycopeptides, lipoglycopeptides, FUS, macrolides, lincosamides, streptogramins, RIF, oxazolidinones R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2
|
genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordetella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, cephalosporins_1st, cephalosporins_2nd, glycopeptides_except_lipo, lipoglycopeptides, FUS, macrolides, lincosamides, streptogramins, RIF, oxazolidinones R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2
|
||||||
fullname like ^Acinetobacter (baumannii|pittii|nosocomialis) aminopenicillins, AMC, CRO, CTX, ATM, ETP, TMP, FOS, DOX, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
fullname like ^Acinetobacter (baumannii|pittii|nosocomialis) aminopenicillins, AMC, CRO, CTX, ATM, ETP, TMP, FOS, DOX, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||||
genus is Acinetobacter DOX, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
genus is Acinetobacter DOX, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||||
genus_species is Achromobacter xylosoxidans aminopenicillins, CRO, CTX, ETP R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
genus_species is Achromobacter xylosoxidans aminopenicillins, CRO, CTX, ETP R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||||
fullname like ^Burkholderia (ambifaria|anthina|arboris|cepacia|cenocepacia|contaminans|diffusa|dolosa|lata|latens|metallica|multivorans|paludis|pseudomultivorans|pyrrocinia|pseudomultivorans|seminalis|stabilis|stagnalis|territorii|ubonensis|vietnamiensis) aminopenicillins, AMC, SAM, TIC, TCC, PIP, TZP, CRO, CTX, ATM, ETP, CIP, CHL, aminoglycosides, TMP, FOS, polymyxins R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
fullname like ^Burkholderia (ambifaria|anthina|arboris|cepacia|cenocepacia|contaminans|diffusa|dolosa|lata|latens|metallica|multivorans|paludis|pseudomultivorans|pyrrocinia|pseudomultivorans|seminalis|stabilis|stagnalis|territorii|ubonensis|vietnamiensis) aminopenicillins, AMC, SAM, TIC, TCC, PIP, TZP, CRO, CTX, ATM, ETP, CIP, CHL, aminoglycosides, TMP, FOS, polymyxins R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||||
genus_species is Elizabethkingia meningoseptica aminopenicillins, AMC, SAM, TIC, TCC, PIP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP, IPM, MEM, polymyxins R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
genus_species is Elizabethkingia meningoseptica aminopenicillins, AMC, SAM, TIC, TCC, PIP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP, IPM, MEM, polymyxins R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||||
genus_species is Ochrobactrum anthropi aminopenicillins, AMC, SAM, TIC, TCC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
genus_species is Brucella anthropi aminopenicillins, AMC, SAM, TIC, TCC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||||
genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, SAM, CTX, CRO, ETP, CHL, KAN, NEO, TMP, tetracyclines, TGC R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, SAM, CTX, CRO, ETP, CHL, KAN, NEO, TMP, DOX, MNO, TCY, TGC R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||||
genus_species is Stenotrophomonas maltophilia aminopenicillins, AMC, SAM, TIC, PIP, TZP, CRO, CTX, ATM, ETP, IPM, MEM, aminoglycosides, TMP, FOS, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
genus_species is Stenotrophomonas maltophilia aminopenicillins, AMC, SAM, TIC, PIP, TZP, CRO, CTX, ATM, ETP, IPM, MEM, aminoglycosides, TMP, FOS, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||||
genus_species is Haemophilus influenzae FUS, streptogramins, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
genus_species is Haemophilus influenzae FUS, streptogramins, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||||
genus_species is Moraxella catarrhalis TMP, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
genus_species is Moraxella catarrhalis TMP, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||||
genus is Neisseria TMP, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
genus is Neisseria TMP, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||||
genus_species is Campylobacter fetus FUS, streptogramins, TMP, NAL, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
genus_species is Campylobacter fetus FUS, streptogramins, TMP, NAL, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||||
fullname like ^Campylobacter (jejuni|coli) FUS, streptogramins, TMP, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
fullname like ^Campylobacter (jejuni|coli) FUS, streptogramins, TMP, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||||
gramstain is Gram-positive ATM, TEM, polymyxins, NAL R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
gramstain is Gram-positive ATM, TEM, polymyxins, NAL R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
||||||
genus_species is Staphylococcus saprophyticus FUS, CAZ, FOS, NOV R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
genus_species is Staphylococcus saprophyticus FUS, CAZ, FOS, NOV R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
||||||
genus_species is Staphylococcus cohnii CAZ, NOV R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
genus_species is Staphylococcus cohnii CAZ, NOV R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
||||||
@@ -372,8 +372,8 @@ fullname like ^(Serratia|Providencia|Morganella morganii) TGC R Expert Rules o
|
|||||||
genus is Salmonella cephalosporins_2nd R Expert Rules on Salmonella Expert Rules 3.2
|
genus is Salmonella cephalosporins_2nd R Expert Rules on Salmonella Expert Rules 3.2
|
||||||
genus is Salmonella aminoglycosides R Expert Rules on Salmonella Expert Rules 3.2
|
genus is Salmonella aminoglycosides R Expert Rules on Salmonella Expert Rules 3.2
|
||||||
genus is Salmonella PEF R CIP R Expert Rules on Salmonella Expert Rules 3.2
|
genus is Salmonella PEF R CIP R Expert Rules on Salmonella Expert Rules 3.2
|
||||||
genus_species is Staphylococcus aureus FOX1 R all_betalactams R Expert Rules on Staphylococcus Expert Rules 3.2
|
genus_species is Staphylococcus aureus FOX1 R betalactams R Expert Rules on Staphylococcus Expert Rules 3.2
|
||||||
genus_species is Staphylococcus aureus FOX1 S all_betalactams S Expert Rules on Staphylococcus Expert Rules 3.2
|
genus_species is Staphylococcus aureus FOX1 S betalactams S Expert Rules on Staphylococcus Expert Rules 3.2
|
||||||
genus_species one_of Staphylococcus aureus, Staphylococcus lugdunensis PEN R AMP, AMX, AZL, BAM, CRB, CRN, EPC, HET, MEC, MEZ, MTM, PIP, PME, PVM, SBC, TAL, TEM, TIC R Expert Rules on Staphylococcus Expert Rules 3.2 all penicillins without beta-lactamse inhibitor
|
genus_species one_of Staphylococcus aureus, Staphylococcus lugdunensis PEN R AMP, AMX, AZL, BAM, CRB, CRN, EPC, HET, MEC, MEZ, MTM, PIP, PME, PVM, SBC, TAL, TEM, TIC R Expert Rules on Staphylococcus Expert Rules 3.2 all penicillins without beta-lactamse inhibitor
|
||||||
genus is Staphylococcus ERY, CLI S macrolides, lincosamides S Expert Rules on Staphylococcus Expert Rules 3.2
|
genus is Staphylococcus ERY, CLI S macrolides, lincosamides S Expert Rules on Staphylococcus Expert Rules 3.2
|
||||||
genus is Staphylococcus NOR S CIP, LVX, MFX, OFX S Expert Rules on Staphylococcus Expert Rules 3.2
|
genus is Staphylococcus NOR S CIP, LVX, MFX, OFX S Expert Rules on Staphylococcus Expert Rules 3.2
|
||||||
@@ -400,7 +400,7 @@ genus_species is Streptococcus pneumoniae TCY S DOX, MNO S Expert Rules on Strep
|
|||||||
genus_species is Streptococcus pneumoniae TCY R DOX, MNO R Expert Rules on Streptococcus pneumoniae Expert Rules 3.2
|
genus_species is Streptococcus pneumoniae TCY R DOX, MNO R Expert Rules on Streptococcus pneumoniae Expert Rules 3.2
|
||||||
genus_species is Streptococcus pneumoniae VAN S lipoglycopeptides S Expert Rules on Streptococcus pneumoniae Expert Rules 3.2
|
genus_species is Streptococcus pneumoniae VAN S lipoglycopeptides S Expert Rules on Streptococcus pneumoniae Expert Rules 3.2
|
||||||
fullname like ^Streptococcus (anginosus|australis|bovis|constellatus|cristatus|equinus|gallolyticus|gordonii|infantarius|infantis|intermedius|mitis|mutans|oligofermentans|oralis|parasanguinis|peroris|pseudopneumoniae|salivarius|sanguinis|sinensis|sobrinus|thermophilus|vestibularis|viridans)$ PEN S aminopenicillins, CTX, CRO S Expert Rules on Viridans Group Streptococci Expert Rules 3.2
|
fullname like ^Streptococcus (anginosus|australis|bovis|constellatus|cristatus|equinus|gallolyticus|gordonii|infantarius|infantis|intermedius|mitis|mutans|oligofermentans|oralis|parasanguinis|peroris|pseudopneumoniae|salivarius|sanguinis|sinensis|sobrinus|thermophilus|vestibularis|viridans)$ PEN S aminopenicillins, CTX, CRO S Expert Rules on Viridans Group Streptococci Expert Rules 3.2
|
||||||
genus_species is Haemophilus influenzae PEN S all_betalactams S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
genus_species is Haemophilus influenzae PEN S betalactams S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||||
genus_species is Haemophilus influenzae NAL S fluoroquinolones S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
genus_species is Haemophilus influenzae NAL S fluoroquinolones S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||||
genus_species is Haemophilus influenzae NAL R CIP, LVX, MFX R Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
genus_species is Haemophilus influenzae NAL R CIP, LVX, MFX R Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||||
genus_species is Haemophilus influenzae TCY S DOX, MNO S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
genus_species is Haemophilus influenzae TCY S DOX, MNO S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||||
|
|||||||
|
Can't render this file because it contains an unexpected character in line 6 and column 96.
|
@@ -136,8 +136,8 @@ read_EUCAST <- function(sheet, file, guideline_name) {
|
|||||||
disk_R = ifelse(has_zone_diameters, G, NA_character_)) %>%
|
disk_R = ifelse(has_zone_diameters, G, NA_character_)) %>%
|
||||||
filter(!is.na(drug),
|
filter(!is.na(drug),
|
||||||
!(is.na(MIC_S) & is.na(MIC_R) & is.na(disk_S) & is.na(disk_R)),
|
!(is.na(MIC_S) & is.na(MIC_R) & is.na(disk_S) & is.na(disk_R)),
|
||||||
!MIC_S %like% "(MIC|S ≤|note)",
|
MIC_S %unlike% "(MIC|S ≤|note)",
|
||||||
!MIC_S %like% "^[-]",
|
MIC_S %unlike% "^[-]",
|
||||||
drug != MIC_S,) %>%
|
drug != MIC_S,) %>%
|
||||||
mutate(administration = case_when(drug %like% "[( ]oral" ~ "oral",
|
mutate(administration = case_when(drug %like% "[( ]oral" ~ "oral",
|
||||||
drug %like% "[( ]iv" ~ "iv",
|
drug %like% "[( ]iv" ~ "iv",
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ abx_atc2 <- ab_old %>%
|
|||||||
filter(!atc %in% abx_atc1$atc,
|
filter(!atc %in% abx_atc1$atc,
|
||||||
is.na(ears_net),
|
is.na(ears_net),
|
||||||
!is.na(atc_group1),
|
!is.na(atc_group1),
|
||||||
!atc_group1 %like% ("virus|vaccin|viral|immun"),
|
atc_group1 %unlike% ("virus|vaccin|viral|immun"),
|
||||||
!official %like% "(combinations| with )") %>%
|
official %unlike% "(combinations| with )") %>%
|
||||||
mutate(ab = NA_character_) %>%
|
mutate(ab = NA_character_) %>%
|
||||||
as.data.frame(stringsAsFactors = FALSE) %>%
|
as.data.frame(stringsAsFactors = FALSE) %>%
|
||||||
select(ab, atc, name = official)
|
select(ab, atc, name = official)
|
||||||
@@ -337,18 +337,36 @@ antibiotics <- rbind(antibiotics,data.frame(ab = "FOX1", atc = NA, cid = NA,
|
|||||||
loinc = NA,
|
loinc = NA,
|
||||||
stringsAsFactors = FALSE))
|
stringsAsFactors = FALSE))
|
||||||
# More GLIMS codes
|
# More GLIMS codes
|
||||||
|
antibiotics[which(antibiotics$ab == "AMB"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "AMB"), "abbreviations"][[1]], "amf"))
|
||||||
antibiotics[which(antibiotics$ab == "CAZ"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CAZ"), "abbreviations"][[1]], "cftz"))
|
antibiotics[which(antibiotics$ab == "CAZ"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CAZ"), "abbreviations"][[1]], "cftz"))
|
||||||
|
antibiotics[which(antibiotics$ab == "COL"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "COL"), "abbreviations"][[1]], "cst"))
|
||||||
antibiotics[which(antibiotics$ab == "CRO"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CRO"), "abbreviations"][[1]], "cftr"))
|
antibiotics[which(antibiotics$ab == "CRO"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CRO"), "abbreviations"][[1]], "cftr"))
|
||||||
antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]], "cftx"))
|
antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]], "cftx"))
|
||||||
antibiotics[which(antibiotics$ab == "CXM"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CXM"), "abbreviations"][[1]], "cfrx"))
|
antibiotics[which(antibiotics$ab == "CXM"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CXM"), "abbreviations"][[1]], "cfrx"))
|
||||||
antibiotics[which(antibiotics$ab == "CZO"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CZO"), "abbreviations"][[1]], "cfzl"))
|
antibiotics[which(antibiotics$ab == "CZO"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CZO"), "abbreviations"][[1]], "cfzl"))
|
||||||
|
antibiotics[which(antibiotics$ab == "FCT"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FCT"), "abbreviations"][[1]], "fcu"))
|
||||||
|
antibiotics[which(antibiotics$ab == "FCT"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FCT"), "abbreviations"][[1]], "fluy"))
|
||||||
|
antibiotics[which(antibiotics$ab == "FLU"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FLU"), "abbreviations"][[1]], "flz"))
|
||||||
|
antibiotics[which(antibiotics$ab == "FOS"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FOS"), "abbreviations"][[1]], "fof"))
|
||||||
antibiotics[which(antibiotics$ab == "FOX"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FOX"), "abbreviations"][[1]], "cfxt"))
|
antibiotics[which(antibiotics$ab == "FOX"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FOX"), "abbreviations"][[1]], "cfxt"))
|
||||||
|
antibiotics[which(antibiotics$ab == "FUS"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FUS"), "abbreviations"][[1]], "fa"))
|
||||||
|
antibiotics[which(antibiotics$ab == "GEH"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "GEH"), "abbreviations"][[1]], "g_h"))
|
||||||
|
antibiotics[which(antibiotics$ab == "KAH"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "KAH"), "abbreviations"][[1]], "k_h"))
|
||||||
|
antibiotics[which(antibiotics$ab == "KET"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "KET"), "abbreviations"][[1]], "ktc"))
|
||||||
antibiotics[which(antibiotics$ab == "PIP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "PIP"), "abbreviations"][[1]], "pipc"))
|
antibiotics[which(antibiotics$ab == "PIP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "PIP"), "abbreviations"][[1]], "pipc"))
|
||||||
antibiotics[which(antibiotics$ab == "PIP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "PIP"), "abbreviations"][[1]], "PIPC"))
|
antibiotics[which(antibiotics$ab == "PIP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "PIP"), "abbreviations"][[1]], "PIPC"))
|
||||||
|
antibiotics[which(antibiotics$ab == "SPX"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "SPX"), "abbreviations"][[1]], "spa"))
|
||||||
|
antibiotics[which(antibiotics$ab == "STH"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "STH"), "abbreviations"][[1]], "s_h"))
|
||||||
|
antibiotics[which(antibiotics$ab == "STR1"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "STR1"), "abbreviations"][[1]], "stm"))
|
||||||
antibiotics[which(antibiotics$ab == "SXT"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "SXT"), "abbreviations"][[1]], "COTRIM"))
|
antibiotics[which(antibiotics$ab == "SXT"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "SXT"), "abbreviations"][[1]], "COTRIM"))
|
||||||
antibiotics[which(antibiotics$ab == "SXT"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "SXT"), "abbreviations"][[1]], "trsx"))
|
antibiotics[which(antibiotics$ab == "SXT"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "SXT"), "abbreviations"][[1]], "trsx"))
|
||||||
|
antibiotics[which(antibiotics$ab == "TGC"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "TGC"), "abbreviations"][[1]], "tig"))
|
||||||
|
antibiotics[which(antibiotics$ab == "TMP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "TMP"), "abbreviations"][[1]], "tri"))
|
||||||
antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]], "PIPTAZ"))
|
antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]], "PIPTAZ"))
|
||||||
|
antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]], "pit"))
|
||||||
antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]], "pita"))
|
antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "TZP"), "abbreviations"][[1]], "pita"))
|
||||||
|
antibiotics[which(antibiotics$ab == "VOR"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "VOR"), "abbreviations"][[1]], "vrc"))
|
||||||
|
|
||||||
# official RIVM codes (Dutch National Health Institute)
|
# official RIVM codes (Dutch National Health Institute)
|
||||||
# https://www.rivm.nl/sites/default/files/2019-09/Bijlage_4_Lijst_antibiotica%202020%201.0.pdf
|
# https://www.rivm.nl/sites/default/files/2019-09/Bijlage_4_Lijst_antibiotica%202020%201.0.pdf
|
||||||
antibiotics[which(antibiotics$ab == "FCT"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FCT"), "abbreviations"][[1]], "5flc"))
|
antibiotics[which(antibiotics$ab == "FCT"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FCT"), "abbreviations"][[1]], "5flc"))
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ MOs <- MOs %>%
|
|||||||
|
|
||||||
# what characters are in the fullnames?
|
# what characters are in the fullnames?
|
||||||
table(sort(unlist(strsplit(x = paste(MOs$fullname, collapse = ""), split = ""))))
|
table(sort(unlist(strsplit(x = paste(MOs$fullname, collapse = ""), split = ""))))
|
||||||
MOs %>% filter(!fullname %like% "^[a-z ]+$") %>% arrange(fullname) %>% View()
|
MOs %>% filter(fullname %unlike% "^[a-z ]+$") %>% arrange(fullname) %>% View()
|
||||||
|
|
||||||
table(MOs$kingdom, MOs$rank)
|
table(MOs$kingdom, MOs$rank)
|
||||||
table(AMR::microorganisms$kingdom, AMR::microorganisms$rank)
|
table(AMR::microorganisms$kingdom, AMR::microorganisms$rank)
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ updated_microorganisms <- taxonomy %>%
|
|||||||
TRUE ~ "subsp."),
|
TRUE ~ "subsp."),
|
||||||
ref = get_author_year(authors),
|
ref = get_author_year(authors),
|
||||||
species_id = as.character(record_no),
|
species_id = as.character(record_no),
|
||||||
source = "LSPN",
|
source = "LPSN",
|
||||||
prevalence = 0,
|
prevalence = 0,
|
||||||
snomed = NA)
|
snomed = NA)
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ files <- xml2::read_html(paste0("https://github.com/nathaneastwood/poorman/tree/
|
|||||||
# get full URLs of all raw R files
|
# get full URLs of all raw R files
|
||||||
files <- sort(paste0("https://raw.githubusercontent.com", gsub("blob/", "", files[files %like% "/R/.*.R$"])))
|
files <- sort(paste0("https://raw.githubusercontent.com", gsub("blob/", "", files[files %like% "/R/.*.R$"])))
|
||||||
# remove files with only pkg specific code
|
# remove files with only pkg specific code
|
||||||
files <- files[!files %like% "(zzz|init)[.]R$"]
|
files <- files[files %unlike% "(zzz|init)[.]R$"]
|
||||||
# also, there's a lot of functions we don't use
|
# also, there's a lot of functions we don't use
|
||||||
files <- files[!files %like% "(slice|glimpse|recode|replace_na|coalesce)[.]R$"]
|
files <- files[files %unlike% "(slice|glimpse|recode|replace_na|coalesce)[.]R$"]
|
||||||
|
|
||||||
# add our prepend file, containing info about the source of the data
|
# add our prepend file, containing info about the source of the data
|
||||||
intro <- readLines("data-raw/poorman_prepend.R")
|
intro <- readLines("data-raw/poorman_prepend.R")
|
||||||
|
|||||||
BIN
data-raw/tinytest_1.2.4.10.tar.gz
Normal file
@@ -1,262 +1,266 @@
|
|||||||
pattern regular_expr case_sensitive affect_mo_name de nl es it fr pt
|
pattern regular_expr case_sensitive affect_ab_name 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-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 TRUE Koagulase-positive Staphylococcus Coagulase-positieve Staphylococcus Staphylococcus coagulasa positivo Staphylococcus positivo coagulasi Staphylococcus à coagulase positif Staphylococcus coagulase positivo
|
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 TRUE Beta-hämolytischer Streptococcus Beta-hemolytische Streptococcus Streptococcus Beta-hemolítico Streptococcus Beta-emolitico Streptococcus Bêta-hémolytique Streptococcus Beta-hemolítico
|
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 TRUE unbekannte Gramnegativen onbekende Gram-negatieven Gram negativos desconocidos Gram negativi sconosciuti Gram négatifs inconnus Gram negativos desconhecidos
|
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 TRUE unbekannte Grampositiven onbekende Gram-positieven Gram positivos desconocidos Gram positivi sconosciuti Gram positifs inconnus Gram positivos 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 TRUE unbekannter Pilze onbekende schimmel hongo desconocido fungo sconosciuto champignon inconnu fungo desconhecido
|
unknown fungus TRUE TRUE FALSE 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 yeast TRUE TRUE FALSE 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 name TRUE TRUE FALSE 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 kingdom TRUE TRUE FALSE 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 phylum TRUE TRUE FALSE 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 class TRUE TRUE FALSE 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 order TRUE TRUE FALSE 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 family TRUE TRUE FALSE 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 genus TRUE TRUE FALSE 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 species TRUE TRUE FALSE 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 subspecies TRUE TRUE FALSE 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
|
unknown rank TRUE TRUE FALSE TRUE unbekannter Rang onbekende rang rango desconocido grado sconosciuto rang inconnu classificação desconhecido
|
||||||
CoNS FALSE TRUE TRUE KNS CNS SCN
|
CoNS FALSE TRUE FALSE TRUE KNS CNS SCN
|
||||||
CoPS FALSE TRUE TRUE KPS CPS SCP
|
CoPS FALSE TRUE FALSE TRUE KPS CPS SCP
|
||||||
Gram-negative TRUE TRUE FALSE Gramnegativ Gram-negatief Gram negativo Gram negativo Gram négatif Gram negativo
|
Gram-negative TRUE TRUE FALSE 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
|
Gram-positive TRUE TRUE FALSE 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
|
^Bacteria$ TRUE TRUE FALSE FALSE Bakterien Bacteriën Bacterias Batteri Bactéries Bactérias
|
||||||
^Fungi$ TRUE TRUE FALSE Pilze Schimmels Hongos Funghi Champignons Fungos
|
^Fungi$ TRUE TRUE FALSE FALSE Pilze Schimmels Hongos Funghi Champignons Fungos
|
||||||
^Yeasts$ TRUE TRUE FALSE Hefen Gisten Levaduras Lieviti Levures Leveduras
|
^Yeasts$ TRUE TRUE FALSE FALSE Hefen Gisten Levaduras Lieviti Levures Leveduras
|
||||||
^Protozoa$ TRUE TRUE FALSE Protozoen Protozoën Protozoarios Protozoi Protozoaires Protozoários
|
^Protozoa$ TRUE TRUE FALSE FALSE Protozoen Protozoën Protozoarios Protozoi Protozoaires Protozoários
|
||||||
biogroup TRUE TRUE FALSE Biogruppe biogroep biogrupo biogruppo biogroupe biogrupo
|
biogroup TRUE TRUE FALSE FALSE Biogruppe biogroep biogrupo biogruppo biogroupe biogrupo
|
||||||
biotype TRUE TRUE FALSE Biotyp biotipo biotipo biótipo
|
biotype TRUE TRUE FALSE FALSE Biotyp biotipo biotipo biótipo
|
||||||
vegetative TRUE TRUE FALSE vegetativ vegetatief vegetativo vegetativo végétatif vegetativo
|
vegetative TRUE TRUE FALSE FALSE vegetativ vegetatief vegetativo vegetativo végétatif vegetativo
|
||||||
([([ ]*?)group TRUE TRUE FALSE \\1Gruppe \\1groep \\1grupo \\1gruppo \\1groupe \\1grupo
|
([([ ]*?)group TRUE TRUE FALSE FALSE \\1Gruppe \\1groep \\1grupo \\1gruppo \\1groupe \\1grupo
|
||||||
([([ ]*?)Group TRUE TRUE FALSE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo
|
([([ ]*?)Group TRUE TRUE FALSE 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 .*growth TRUE FALSE 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
|
no|not TRUE FALSE FALSE FALSE keine? geen|niet no|sin sem non sem
|
||||||
Susceptible TRUE FALSE FALSE Empfindlich Gevoelig Susceptible
|
Susceptible TRUE FALSE FALSE FALSE Empfindlich Gevoelig Susceptible
|
||||||
Intermediate TRUE FALSE FALSE Mittlere Intermediair Intermedio
|
Intermediate TRUE FALSE FALSE FALSE Mittlere Intermediair Intermedio
|
||||||
Incr. exposure TRUE FALSE FALSE Empfindlich, erh Belastung 'Incr. exposure' 'Incr. exposure'
|
Incr. exposure TRUE FALSE FALSE FALSE Empfindlich, erh Belastung 'Incr. exposure' 'Incr. exposure'
|
||||||
Resistant TRUE FALSE FALSE Resistent Resistent Resistente
|
Resistant TRUE FALSE FALSE FALSE Resistent Resistent Resistente
|
||||||
antibiotic TRUE TRUE FALSE Antibiotikum antibioticum antibiótico
|
antibiotic TRUE TRUE FALSE FALSE Antibiotikum antibioticum antibiótico
|
||||||
Antibiotic TRUE TRUE FALSE Antibiotikum Antibioticum Antibiótico
|
Antibiotic TRUE TRUE FALSE FALSE Antibiotikum Antibioticum Antibiótico
|
||||||
Drug TRUE TRUE FALSE Medikament Middel Fármaco
|
Drug TRUE TRUE FALSE FALSE Medikament Middel Fármaco
|
||||||
drug TRUE TRUE FALSE Medikament middel fármaco
|
drug TRUE TRUE FALSE FALSE Medikament middel fármaco
|
||||||
4-aminosalicylic acid FALSE TRUE FALSE 4-Aminosalicylsäure 4-aminosalicylzuur Ácido 4-aminosalicílico
|
Frequency FALSE TRUE FALSE FALSE Zahl Aantal
|
||||||
Adefovir dipivoxil FALSE TRUE FALSE Adefovir Dipivoxil Adefovir Adefovir dipivoxil
|
Minimum Inhibitory Concentration (mg/L) FALSE FALSE FALSE FALSE Minimale Hemm-Konzentration (mg/L) Minimale inhiberende concentratie (mg/L)
|
||||||
Aldesulfone sodium FALSE TRUE FALSE Aldesulfon-Natrium Aldesulfon Aldesulfona sódica
|
Disk diffusion diameter (mm) FALSE FALSE FALSE FALSE Durchmesser der Scheibenzone (mm) Diameter diskzone (mm)
|
||||||
Amikacin FALSE TRUE FALSE Amikacin Amikacine Amikacina
|
Antimicrobial Interpretation FALSE FALSE FALSE FALSE Antimikrobielle Auswertung Antimicrobiële interpretatie
|
||||||
Amoxicillin FALSE TRUE FALSE Amoxicillin Amoxicilline Amoxicilina
|
4-aminosalicylic acid FALSE TRUE TRUE FALSE 4-Aminosalicylsäure 4-aminosalicylzuur Ácido 4-aminosalicílico
|
||||||
Amoxicillin/beta-lactamase inhibitor FALSE TRUE FALSE Amoxicillin/Beta-Lactamase-Hemmer Amoxicilline/enzymremmer amoxicilina/inhib. de la beta-lactamasa
|
Adefovir dipivoxil FALSE TRUE TRUE FALSE Adefovir Dipivoxil Adefovir Adefovir dipivoxil
|
||||||
Amphotericin B FALSE TRUE FALSE Amphotericin B Amfotericine B Anfotericina B
|
Aldesulfone sodium FALSE TRUE TRUE FALSE Aldesulfon-Natrium Aldesulfon Aldesulfona sódica
|
||||||
Ampicillin FALSE TRUE FALSE Ampicillin Ampicilline Ampicilina
|
Amikacin FALSE TRUE TRUE FALSE Amikacin Amikacine Amikacina
|
||||||
Ampicillin/beta-lactamase inhibitor FALSE TRUE FALSE Ampicillin/Beta-Laktamase-Hemmer Ampicilline/enzymremmer Ampicilina/inhib. de la betalactamasa
|
Amoxicillin FALSE TRUE TRUE FALSE Amoxicillin Amoxicilline Amoxicilina
|
||||||
Anidulafungin FALSE TRUE FALSE Anidulafungin Anidulafungine Anidulafungina
|
Amoxicillin/beta-lactamase inhibitor FALSE TRUE TRUE FALSE Amoxicillin/Beta-Lactamase-Hemmer Amoxicilline/enzymremmer amoxicilina/inhib. de la beta-lactamasa
|
||||||
Azidocillin FALSE TRUE FALSE Azidocillin Azidocilline Azidocilina
|
Amphotericin B FALSE TRUE TRUE FALSE Amphotericin B Amfotericine B Anfotericina B
|
||||||
Azithromycin FALSE TRUE FALSE Azithromycin Azitromycine Azitromicina
|
Ampicillin FALSE TRUE TRUE FALSE Ampicillin Ampicilline Ampicilina
|
||||||
Azlocillin FALSE TRUE FALSE Azlocillin Azlocilline Azlocilina
|
Ampicillin/beta-lactamase inhibitor FALSE TRUE TRUE FALSE Ampicillin/Beta-Laktamase-Hemmer Ampicilline/enzymremmer Ampicilina/inhib. de la betalactamasa
|
||||||
Bacampicillin FALSE TRUE FALSE Bacampicillin Bacampicilline Bacampicilina
|
Anidulafungin FALSE TRUE TRUE FALSE Anidulafungin Anidulafungine Anidulafungina
|
||||||
Bacitracin FALSE TRUE FALSE Bacitracin Bacitracine Bacitracina
|
Azidocillin FALSE TRUE TRUE FALSE Azidocillin Azidocilline Azidocilina
|
||||||
Benzathine benzylpenicillin FALSE TRUE FALSE Benzathin-Benzylpenicillin Benzylpenicillinebenzathine Bencilpenicilina benzatínica
|
Azithromycin FALSE TRUE TRUE FALSE Azithromycin Azitromycine Azitromicina
|
||||||
Benzathine phenoxymethylpenicillin FALSE TRUE FALSE Benzathin-Phenoxymethylpenicillin Fenoxymethylpenicillinebenzathine Fenoximetilpenicilina benzatínica
|
Azlocillin FALSE TRUE TRUE FALSE Azlocillin Azlocilline Azlocilina
|
||||||
Benzylpenicillin FALSE TRUE FALSE Benzylpenicillin Benzylpenicilline Bencilpenicilina
|
Bacampicillin FALSE TRUE TRUE FALSE Bacampicillin Bacampicilline Bacampicilina
|
||||||
Calcium aminosalicylate FALSE TRUE FALSE Kalzium-Aminosalicylat Aminosalicylzuur Aminosalicilato de calcio
|
Bacitracin FALSE TRUE TRUE FALSE Bacitracin Bacitracine Bacitracina
|
||||||
Capreomycin FALSE TRUE FALSE Capreomycin Capreomycine Capreomicina
|
Benzathine benzylpenicillin FALSE TRUE TRUE FALSE Benzathin-Benzylpenicillin Benzylpenicillinebenzathine Bencilpenicilina benzatínica
|
||||||
Carbenicillin FALSE TRUE FALSE Carbenicillin Carbenicilline Carbenicilina
|
Benzathine phenoxymethylpenicillin FALSE TRUE TRUE FALSE Benzathin-Phenoxymethylpenicillin Fenoxymethylpenicillinebenzathine Fenoximetilpenicilina benzatínica
|
||||||
Carindacillin FALSE TRUE FALSE Carindacillin Carindacilline Carindacilina
|
Benzylpenicillin FALSE TRUE TRUE FALSE Benzylpenicillin Benzylpenicilline Bencilpenicilina
|
||||||
Caspofungin FALSE TRUE FALSE Caspofungin Caspofungine Caspofungina
|
Calcium aminosalicylate FALSE TRUE TRUE FALSE Kalzium-Aminosalicylat Aminosalicylzuur Aminosalicilato de calcio
|
||||||
Ce(f|ph)acetrile TRUE TRUE FALSE Cefacetril Cefacetril Cefacetrilo
|
Capreomycin FALSE TRUE TRUE FALSE Capreomycin Capreomycine Capreomicina
|
||||||
Ce(f|ph)alotin TRUE TRUE FALSE Cefalotin Cefalotine Cefalotina
|
Carbenicillin FALSE TRUE TRUE FALSE Carbenicillin Carbenicilline Carbenicilina
|
||||||
Ce(f|ph)amandole TRUE TRUE FALSE Cefamandol Cefamandol Cefamandole
|
Carindacillin FALSE TRUE TRUE FALSE Carindacillin Carindacilline Carindacilina
|
||||||
Ce(f|ph)apirin TRUE TRUE FALSE Cefapirin Cefapirine Cefapirina
|
Caspofungin FALSE TRUE TRUE FALSE Caspofungin Caspofungine Caspofungina
|
||||||
Ce(f|ph)azedone TRUE TRUE FALSE Cefazedon Cefazedon Cefazedona
|
Ce(f|ph)acetrile TRUE TRUE TRUE FALSE Cefacetril Cefacetril Cefacetrilo
|
||||||
Ce(f|ph)azolin TRUE TRUE FALSE Cefazolin Cefazoline Cefazolina
|
Ce(f|ph)alotin TRUE TRUE TRUE FALSE Cefalotin Cefalotine Cefalotina
|
||||||
Ce(f|ph)alothin TRUE TRUE FALSE Cefalothin Cefalotine Cefalotina
|
Ce(f|ph)amandole TRUE TRUE TRUE FALSE Cefamandol Cefamandol Cefamandole
|
||||||
Ce(f|ph)alexin TRUE TRUE FALSE Cefalexin Cefalexine Cefalexina
|
Ce(f|ph)apirin TRUE TRUE TRUE FALSE Cefapirin Cefapirine Cefapirina
|
||||||
Ce(f|ph)epime TRUE TRUE FALSE Cefepim Cefepim Cefepime
|
Ce(f|ph)azedone TRUE TRUE TRUE FALSE Cefazedon Cefazedon Cefazedona
|
||||||
Ce(f|ph)ixime TRUE TRUE FALSE Cefixim Cefixim Cefixima
|
Ce(f|ph)azolin TRUE TRUE TRUE FALSE Cefazolin Cefazoline Cefazolina
|
||||||
Ce(f|ph)menoxime TRUE TRUE FALSE Cefmenoxim Cefmenoxim Cefmenoxima
|
Ce(f|ph)alothin TRUE TRUE TRUE FALSE Cefalothin Cefalotine Cefalotina
|
||||||
Ce(f|ph)metazole TRUE TRUE FALSE Cefmetazol Cefmetazol Cefmetazol
|
Ce(f|ph)alexin TRUE TRUE TRUE FALSE Cefalexin Cefalexine Cefalexina
|
||||||
Ce(f|ph)odizime TRUE TRUE FALSE Cefodizim Cefodizim Cefodizima
|
Ce(f|ph)epime TRUE TRUE TRUE FALSE Cefepim Cefepim Cefepime
|
||||||
Ce(f|ph)onicid TRUE TRUE FALSE Cefonicid Cefonicide Cefonicid
|
Ce(f|ph)ixime TRUE TRUE TRUE FALSE Cefixim Cefixim Cefixima
|
||||||
Ce(f|ph)operazone TRUE TRUE FALSE Cefoperazon Cefoperazon Cefoperazona
|
Ce(f|ph)menoxime TRUE TRUE TRUE FALSE Cefmenoxim Cefmenoxim Cefmenoxima
|
||||||
Ce(f|ph)operazone/beta-lactamase inhibitor TRUE TRUE FALSE Cefoperazon/Beta-Lactamase-Hemmer Cefoperazon/enzymremmer Cefoperazona/inhib. de la betalactamasa
|
Ce(f|ph)metazole TRUE TRUE TRUE FALSE Cefmetazol Cefmetazol Cefmetazol
|
||||||
Ce(f|ph)otaxime TRUE TRUE FALSE Cefotaxim Cefotaxim Cefotaxima
|
Ce(f|ph)odizime TRUE TRUE TRUE FALSE Cefodizim Cefodizim Cefodizima
|
||||||
Ce(f|ph)oxitin TRUE TRUE FALSE Cefoxitin Cefoxitine Cefoxitina
|
Ce(f|ph)onicid TRUE TRUE TRUE FALSE Cefonicid Cefonicide Cefonicid
|
||||||
Ce(f|ph)pirome TRUE TRUE FALSE Cefpirom Cefpirom Cefpirome
|
Ce(f|ph)operazone TRUE TRUE TRUE FALSE Cefoperazon Cefoperazon Cefoperazona
|
||||||
Ce(f|ph)podoxime TRUE TRUE FALSE Cefpodoxim Cefpodoxim Cefpodoxima
|
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)radine TRUE TRUE FALSE Cefradin Cefradine Cefradina
|
Ce(f|ph)otaxime TRUE TRUE TRUE FALSE Cefotaxim Cefotaxim Cefotaxima
|
||||||
Ce(f|ph)sulodin TRUE TRUE FALSE Cefsulodin Cefsulodine Cefsulodina
|
Ce(f|ph)oxitin TRUE TRUE TRUE FALSE Cefoxitin Cefoxitine Cefoxitina
|
||||||
Ce(f|ph)tazidime TRUE TRUE FALSE Ceftazidim Ceftazidim Ceftazidima
|
Ce(f|ph)pirome TRUE TRUE TRUE FALSE Cefpirom Cefpirom Cefpirome
|
||||||
Ce(f|ph)tezole TRUE TRUE FALSE Ceftezol Ceftezol Ceftezol
|
Ce(f|ph)podoxime TRUE TRUE TRUE FALSE Cefpodoxim Cefpodoxim Cefpodoxima
|
||||||
Ce(f|ph)tizoxime TRUE TRUE FALSE Ceftizoxim Ceftizoxim Ceftizoxima
|
Ce(f|ph)radine TRUE TRUE TRUE FALSE Cefradin Cefradine Cefradina
|
||||||
Ce(f|ph)triaxone TRUE TRUE FALSE Ceftriaxon Ceftriaxon Ceftriaxona
|
Ce(f|ph)sulodin TRUE TRUE TRUE FALSE Cefsulodin Cefsulodine Cefsulodina
|
||||||
Ce(f|ph)uroxime TRUE TRUE FALSE Cefuroxim Cefuroxim Cefuroxima
|
Ce(f|ph)tazidime TRUE TRUE TRUE FALSE Ceftazidim Ceftazidim Ceftazidima
|
||||||
Ce(f|ph)uroxime/metronidazole TRUE TRUE FALSE Cefuroxim/Metronidazol Cefuroxim/andere antibacteriele middelen Cefuroxima/metronidazol
|
Ce(f|ph)tezole TRUE TRUE TRUE FALSE Ceftezol Ceftezol Ceftezol
|
||||||
Chloramphenicol FALSE TRUE FALSE Chloramphenicol Chlooramfenicol Cloranfenicol
|
Ce(f|ph)tizoxime TRUE TRUE TRUE FALSE Ceftizoxim Ceftizoxim Ceftizoxima
|
||||||
Chlortetracycline FALSE TRUE FALSE Chlortetracyclin Chloortetracycline Clortetraciclina
|
Ce(f|ph)triaxone TRUE TRUE TRUE FALSE Ceftriaxon Ceftriaxon Ceftriaxona
|
||||||
Cinoxacin FALSE TRUE FALSE Cinoxacin Cinoxacine Cinoxacina
|
Ce(f|ph)uroxime TRUE TRUE TRUE FALSE Cefuroxim Cefuroxim Cefuroxima
|
||||||
Ciprofloxacin FALSE TRUE FALSE Ciprofloxacin Ciprofloxacine Ciprofloxacina
|
Ce(f|ph)uroxime/metronidazole TRUE TRUE TRUE FALSE Cefuroxim/Metronidazol Cefuroxim/andere antibacteriele middelen Cefuroxima/metronidazol
|
||||||
Clarithromycin FALSE TRUE FALSE Clarithromycin Claritromycine Claritromicina
|
Chloramphenicol FALSE TRUE TRUE FALSE Chloramphenicol Chlooramfenicol Cloranfenicol
|
||||||
Clavulanic acid FALSE TRUE FALSE Clavulansäure Clavulaanzuur Ácido clavulánico
|
Chlortetracycline FALSE TRUE TRUE FALSE Chlortetracyclin Chloortetracycline Clortetraciclina
|
||||||
clavulanic acid FALSE TRUE FALSE Clavulansäure clavulaanzuur ácido clavulánico
|
Cinoxacin FALSE TRUE TRUE FALSE Cinoxacin Cinoxacine Cinoxacina
|
||||||
Clindamycin FALSE TRUE FALSE Clindamycin Clindamycine Clindamicina
|
Ciprofloxacin FALSE TRUE TRUE FALSE Ciprofloxacin Ciprofloxacine Ciprofloxacina
|
||||||
Clometocillin FALSE TRUE FALSE Clometocillin Clometocilline Clometocilina
|
Clarithromycin FALSE TRUE TRUE FALSE Clarithromycin Claritromycine Claritromicina
|
||||||
Clotrimazole FALSE TRUE FALSE Clotrimazol Clotrimazol Clotrimazol
|
Clavulanic acid FALSE TRUE TRUE FALSE Clavulansäure Clavulaanzuur Ácido clavulánico
|
||||||
Cloxacillin FALSE TRUE FALSE Cloxacillin Cloxacilline Cloxacilina
|
clavulanic acid FALSE TRUE TRUE FALSE Clavulansäure clavulaanzuur ácido clavulánico
|
||||||
Colistin FALSE TRUE FALSE Colistin Colistine Colistina
|
Clindamycin FALSE TRUE TRUE FALSE Clindamycin Clindamycine Clindamicina
|
||||||
Dapsone FALSE TRUE FALSE Dapson Dapson Dapsona
|
Clometocillin FALSE TRUE TRUE FALSE Clometocillin Clometocilline Clometocilina
|
||||||
Daptomycin FALSE TRUE FALSE Daptomycin Daptomycine Daptomicina
|
Clotrimazole FALSE TRUE TRUE FALSE Clotrimazol Clotrimazol Clotrimazol
|
||||||
Dibekacin FALSE TRUE FALSE Dibekacin Dibekacine Dibekacina
|
Cloxacillin FALSE TRUE TRUE FALSE Cloxacillin Cloxacilline Cloxacilina
|
||||||
Dicloxacillin FALSE TRUE FALSE Dicloxacillin Dicloxacilline Dicloxacilina
|
Colistin FALSE TRUE TRUE FALSE Colistin Colistine Colistina
|
||||||
Dirithromycin FALSE TRUE FALSE Dirithromycin Diritromycine Diritromicina
|
Dapsone FALSE TRUE TRUE FALSE Dapson Dapson Dapsona
|
||||||
Econazole FALSE TRUE FALSE Econazol Econazol Econazol
|
Daptomycin FALSE TRUE TRUE FALSE Daptomycin Daptomycine Daptomicina
|
||||||
Enoxacin FALSE TRUE FALSE Enoxacin Enoxacine Enoxacina
|
Dibekacin FALSE TRUE TRUE FALSE Dibekacin Dibekacine Dibekacina
|
||||||
Epicillin FALSE TRUE FALSE Epicillin Epicilline Epicilina
|
Dicloxacillin FALSE TRUE TRUE FALSE Dicloxacillin Dicloxacilline Dicloxacilina
|
||||||
Erythromycin FALSE TRUE FALSE Erythromycin Erytromycine Eritromicina
|
Dirithromycin FALSE TRUE TRUE FALSE Dirithromycin Diritromycine Diritromicina
|
||||||
Ethambutol/isoniazid FALSE TRUE FALSE Ethambutol/Isoniazid Ethambutol/isoniazide Etambutol/isoniazida
|
Econazole FALSE TRUE TRUE FALSE Econazol Econazol Econazol
|
||||||
Fleroxacin FALSE TRUE FALSE Fleroxacin Fleroxacine Fleroxacina
|
Enoxacin FALSE TRUE TRUE FALSE Enoxacin Enoxacine Enoxacina
|
||||||
Flucloxacillin FALSE TRUE FALSE Flucloxacillin Flucloxacilline Flucloxacilina
|
Epicillin FALSE TRUE TRUE FALSE Epicillin Epicilline Epicilina
|
||||||
Fluconazole FALSE TRUE FALSE Fluconazol Fluconazol Fluconazol
|
Erythromycin FALSE TRUE TRUE FALSE Erythromycin Erytromycine Eritromicina
|
||||||
Flucytosine FALSE TRUE FALSE Flucytosin Fluorocytosine Flucitosina
|
Ethambutol/isoniazid FALSE TRUE TRUE FALSE Ethambutol/Isoniazid Ethambutol/isoniazide Etambutol/isoniazida
|
||||||
Flurithromycin FALSE TRUE FALSE Flurithromycin Fluritromycine Fluritromicina
|
Fleroxacin FALSE TRUE TRUE FALSE Fleroxacin Fleroxacine Fleroxacina
|
||||||
Fosfomycin FALSE TRUE FALSE Fosfomycin Fosfomycine Fosfomicina
|
Flucloxacillin FALSE TRUE TRUE FALSE Flucloxacillin Flucloxacilline Flucloxacilina
|
||||||
Fusidic acid FALSE TRUE FALSE Fusidinsäure Fusidinezuur Ácido fusídico
|
Fluconazole FALSE TRUE TRUE FALSE Fluconazol Fluconazol Fluconazol
|
||||||
Gatifloxacin FALSE TRUE FALSE Gatifloxacin Gatifloxacine Gatifloxacina
|
Flucytosine FALSE TRUE TRUE FALSE Flucytosin Fluorocytosine Flucitosina
|
||||||
Gemifloxacin FALSE TRUE FALSE Gemifloxacin Gemifloxacine Gemifloxacina
|
Flurithromycin FALSE TRUE TRUE FALSE Flurithromycin Fluritromycine Fluritromicina
|
||||||
Gentamicin FALSE TRUE FALSE Gentamicin Gentamicine Gentamicina
|
Fosfomycin FALSE TRUE TRUE FALSE Fosfomycin Fosfomycine Fosfomicina
|
||||||
Grepafloxacin FALSE TRUE FALSE Grepafloxacin Grepafloxacine Grepafloxacina
|
Fusidic acid FALSE TRUE TRUE FALSE Fusidinsäure Fusidinezuur Ácido fusídico
|
||||||
Hachimycin FALSE TRUE FALSE Hachimycin Hachimycine Hachimycin
|
Gatifloxacin FALSE TRUE TRUE FALSE Gatifloxacin Gatifloxacine Gatifloxacina
|
||||||
Hetacillin FALSE TRUE FALSE Hetacillin Hetacilline Hetacilina
|
Gemifloxacin FALSE TRUE TRUE FALSE Gemifloxacin Gemifloxacine Gemifloxacina
|
||||||
Imipenem/cilastatin FALSE TRUE FALSE Imipenem/Cilastatin Imipenem/enzymremmer Imipenem/cilastatina
|
Gentamicin FALSE TRUE TRUE FALSE Gentamicin Gentamicine Gentamicina
|
||||||
Inosine pranobex FALSE TRUE FALSE Inosin-Pranobex Inosiplex Inosina pranobex
|
Grepafloxacin FALSE TRUE TRUE FALSE Grepafloxacin Grepafloxacine Grepafloxacina
|
||||||
Isepamicin FALSE TRUE FALSE Isepamicin Isepamicine Isepamicina
|
Hachimycin FALSE TRUE TRUE FALSE Hachimycin Hachimycine Hachimycin
|
||||||
Isoconazole FALSE TRUE FALSE Isoconazol Isoconazol Isoconazol
|
Hetacillin FALSE TRUE TRUE FALSE Hetacillin Hetacilline Hetacilina
|
||||||
Isoniazid FALSE TRUE FALSE Isoniazid Isoniazide Isoniazida
|
Imipenem/cilastatin FALSE TRUE TRUE FALSE Imipenem/Cilastatin Imipenem/enzymremmer Imipenem/cilastatina
|
||||||
Itraconazole FALSE TRUE FALSE Itraconazol Itraconazol Itraconazol
|
Inosine pranobex FALSE TRUE TRUE FALSE Inosin-Pranobex Inosiplex Inosina pranobex
|
||||||
Josamycin FALSE TRUE FALSE Josamycin Josamycine Josamicina
|
Isepamicin FALSE TRUE TRUE FALSE Isepamicin Isepamicine Isepamicina
|
||||||
Kanamycin FALSE TRUE FALSE Kanamycin Kanamycine Kanamicina
|
Isoconazole FALSE TRUE TRUE FALSE Isoconazol Isoconazol Isoconazol
|
||||||
Ketoconazole FALSE TRUE FALSE Ketoconazol Ketoconazol Ketoconazol
|
Isoniazid FALSE TRUE TRUE FALSE Isoniazid Isoniazide Isoniazida
|
||||||
Levofloxacin FALSE TRUE FALSE Levofloxacin Levofloxacine Levofloxacina
|
Itraconazole FALSE TRUE TRUE FALSE Itraconazol Itraconazol Itraconazol
|
||||||
Lincomycin FALSE TRUE FALSE Lincomycin Lincomycine Lincomicina
|
Josamycin FALSE TRUE TRUE FALSE Josamycin Josamycine Josamicina
|
||||||
Lomefloxacin FALSE TRUE FALSE Lomefloxacin Lomefloxacine Lomefloxacina
|
Kanamycin FALSE TRUE TRUE FALSE Kanamycin Kanamycine Kanamicina
|
||||||
Lysozyme FALSE TRUE FALSE Lysozym Lysozym Lisozima
|
Ketoconazole FALSE TRUE TRUE FALSE Ketoconazol Ketoconazol Ketoconazol
|
||||||
Mandelic acid FALSE TRUE FALSE Mandelsäure Amandelzuur Ácido mandélico
|
Levofloxacin FALSE TRUE TRUE FALSE Levofloxacin Levofloxacine Levofloxacina
|
||||||
Metampicillin FALSE TRUE FALSE Metampicillin Metampicilline Metampicilina
|
Lincomycin FALSE TRUE TRUE FALSE Lincomycin Lincomycine Lincomicina
|
||||||
Meticillin FALSE TRUE FALSE Meticillin Meticilline Meticilina
|
Lomefloxacin FALSE TRUE TRUE FALSE Lomefloxacin Lomefloxacine Lomefloxacina
|
||||||
Metisazone FALSE TRUE FALSE Metisazon Metisazon Metisazona
|
Lysozyme FALSE TRUE TRUE FALSE Lysozym Lysozym Lisozima
|
||||||
Metronidazole FALSE TRUE FALSE Metronidazol Metronidazol Metronidazol
|
Mandelic acid FALSE TRUE TRUE FALSE Mandelsäure Amandelzuur Ácido mandélico
|
||||||
Mezlocillin FALSE TRUE FALSE Mezlocillin Mezlocilline Mezlocilina
|
Metampicillin FALSE TRUE TRUE FALSE Metampicillin Metampicilline Metampicilina
|
||||||
Micafungin FALSE TRUE FALSE Micafungin Micafungine Micafungina
|
Meticillin FALSE TRUE TRUE FALSE Meticillin Meticilline Meticilina
|
||||||
Miconazole FALSE TRUE FALSE Miconazol Miconazol Miconazol
|
Metisazone FALSE TRUE TRUE FALSE Metisazon Metisazon Metisazona
|
||||||
Midecamycin FALSE TRUE FALSE Midecamycin Midecamycine Midecamicina
|
Metronidazole FALSE TRUE TRUE FALSE Metronidazol Metronidazol Metronidazol
|
||||||
Miocamycin FALSE TRUE FALSE Miocamycin Miocamycine Miocamycin
|
Mezlocillin FALSE TRUE TRUE FALSE Mezlocillin Mezlocilline Mezlocilina
|
||||||
Moxifloxacin FALSE TRUE FALSE Moxifloxacin Moxifloxacine Moxifloxacina
|
Micafungin FALSE TRUE TRUE FALSE Micafungin Micafungine Micafungina
|
||||||
Mupirocin FALSE TRUE FALSE Mupirocin Mupirocine Mupirocina
|
Miconazole FALSE TRUE TRUE FALSE Miconazol Miconazol Miconazol
|
||||||
Nalidixic acid FALSE TRUE FALSE Nalidixinsäure Nalidixinezuur Ácido nalidíxico
|
Midecamycin FALSE TRUE TRUE FALSE Midecamycin Midecamycine Midecamicina
|
||||||
Neomycin FALSE TRUE FALSE Neomycin Neomycine Neomicina
|
Miocamycin FALSE TRUE TRUE FALSE Miocamycin Miocamycine Miocamycin
|
||||||
Netilmicin FALSE TRUE FALSE Netilmicin Netilmicine Netilmicina
|
Moxifloxacin FALSE TRUE TRUE FALSE Moxifloxacin Moxifloxacine Moxifloxacina
|
||||||
Nitrofurantoin FALSE TRUE FALSE Nitrofurantoin Nitrofurantoine Nitrofurantoína
|
Mupirocin FALSE TRUE TRUE FALSE Mupirocin Mupirocine Mupirocina
|
||||||
Norfloxacin FALSE TRUE FALSE Norfloxacin Norfloxacine Norfloxacina
|
Nalidixic acid FALSE TRUE TRUE FALSE Nalidixinsäure Nalidixinezuur Ácido nalidíxico
|
||||||
Novobiocin FALSE TRUE FALSE Novobiocin Novobiocine Novobiocina
|
Neomycin FALSE TRUE TRUE FALSE Neomycin Neomycine Neomicina
|
||||||
Nystatin FALSE TRUE FALSE Nystatin Nystatine Nistatina
|
Netilmicin FALSE TRUE TRUE FALSE Netilmicin Netilmicine Netilmicina
|
||||||
Ofloxacin FALSE TRUE FALSE Ofloxacin Ofloxacine Ofloxacina
|
Nitrofurantoin FALSE TRUE TRUE FALSE Nitrofurantoin Nitrofurantoine Nitrofurantoína
|
||||||
Oleandomycin FALSE TRUE FALSE Oleandomycin Oleandomycine Oleandomicina
|
Norfloxacin FALSE TRUE TRUE FALSE Norfloxacin Norfloxacine Norfloxacina
|
||||||
Ornidazole FALSE TRUE FALSE Ornidazol Ornidazol Ornidazol
|
Novobiocin FALSE TRUE TRUE FALSE Novobiocin Novobiocine Novobiocina
|
||||||
Oxacillin FALSE TRUE FALSE Oxacillin Oxacilline Oxacilina
|
Nystatin FALSE TRUE TRUE FALSE Nystatin Nystatine Nistatina
|
||||||
Oxolinic acid FALSE TRUE FALSE Oxolinsäure Oxolinezuur Ácido oxolínico
|
Ofloxacin FALSE TRUE TRUE FALSE Ofloxacin Ofloxacine Ofloxacina
|
||||||
Oxytetracycline FALSE TRUE FALSE Oxytetracyclin Oxytetracycline Oxitetraciclina
|
Oleandomycin FALSE TRUE TRUE FALSE Oleandomycin Oleandomycine Oleandomicina
|
||||||
Pazufloxacin FALSE TRUE FALSE Pazufloxacin Pazufloxacine Pazufloxacina
|
Ornidazole FALSE TRUE TRUE FALSE Ornidazol Ornidazol Ornidazol
|
||||||
Pefloxacin FALSE TRUE FALSE Pefloxacin Pefloxacine Pefloxacina
|
Oxacillin FALSE TRUE TRUE FALSE Oxacillin Oxacilline Oxacilina
|
||||||
Penamecillin FALSE TRUE FALSE Penamecillin Penamecilline Penamecilina
|
Oxolinic acid FALSE TRUE TRUE FALSE Oxolinsäure Oxolinezuur Ácido oxolínico
|
||||||
Penicillin FALSE TRUE FALSE Penicillin Penicilline Penicilina
|
Oxytetracycline FALSE TRUE TRUE FALSE Oxytetracyclin Oxytetracycline Oxitetraciclina
|
||||||
Pheneticillin FALSE TRUE FALSE Pheneticillin Feneticilline Feneticilina
|
Pazufloxacin FALSE TRUE TRUE FALSE Pazufloxacin Pazufloxacine Pazufloxacina
|
||||||
Phenoxymethylpenicillin FALSE TRUE FALSE Phenoxymethylpenicillin Fenoxymethylpenicilline Fenoximetilpenicilina
|
Pefloxacin FALSE TRUE TRUE FALSE Pefloxacin Pefloxacine Pefloxacina
|
||||||
Pipemidic acid FALSE TRUE FALSE Pipemidinsäure Pipemidinezuur Ácido pipemídico
|
Penamecillin FALSE TRUE TRUE FALSE Penamecillin Penamecilline Penamecilina
|
||||||
Piperacillin FALSE TRUE FALSE Piperacillin Piperacilline Piperacilina
|
Penicillin FALSE TRUE TRUE FALSE Penicillin Penicilline Penicilina
|
||||||
Piperacillin/beta-lactamase inhibitor FALSE TRUE FALSE Piperacillin/Beta-Lactamase-Hemmer Piperacilline/enzymremmer Piperacilina/inhib. de la betalactamasa
|
Pheneticillin FALSE TRUE TRUE FALSE Pheneticillin Feneticilline Feneticilina
|
||||||
Piromidic acid FALSE TRUE FALSE Piromidinsäure Piromidinezuur Ácido piromídico
|
Phenoxymethylpenicillin FALSE TRUE TRUE FALSE Phenoxymethylpenicillin Fenoxymethylpenicilline Fenoximetilpenicilina
|
||||||
Pivampicillin FALSE TRUE FALSE Pivampicillin Pivampicilline Pivampicilina
|
Pipemidic acid FALSE TRUE TRUE FALSE Pipemidinsäure Pipemidinezuur Ácido pipemídico
|
||||||
Polymyxin B FALSE TRUE FALSE Polymyxin B Polymyxine B Polimixina B
|
Piperacillin FALSE TRUE TRUE FALSE Piperacillin Piperacilline Piperacilina
|
||||||
Posaconazole FALSE TRUE FALSE Posaconazol Posaconazol Posaconazol
|
Piperacillin/beta-lactamase inhibitor FALSE TRUE TRUE FALSE Piperacillin/Beta-Lactamase-Hemmer Piperacilline/enzymremmer Piperacilina/inhib. de la betalactamasa
|
||||||
Pristinamycin FALSE TRUE FALSE Pristinamycin Pristinamycine Pristinamicina
|
Piromidic acid FALSE TRUE TRUE FALSE Piromidinsäure Piromidinezuur Ácido piromídico
|
||||||
Procaine benzylpenicillin FALSE TRUE FALSE Procain-Benzylpenicillin Benzylpenicillineprocaine Bencilpenicilina procaína
|
Pivampicillin FALSE TRUE TRUE FALSE Pivampicillin Pivampicilline Pivampicilina
|
||||||
Propicillin FALSE TRUE FALSE Propicillin Propicilline Propicilina
|
Polymyxin B FALSE TRUE TRUE FALSE Polymyxin B Polymyxine B Polimixina B
|
||||||
Prulifloxacin FALSE TRUE FALSE Prulifloxacin Prulifloxacine Prulifloxacina
|
Posaconazole FALSE TRUE TRUE FALSE Posaconazol Posaconazol Posaconazol
|
||||||
Quinupristin/dalfopristin FALSE TRUE FALSE Quinupristin/Dalfopristin Quinupristine/dalfopristine Quinupristina/dalfopristina
|
Pristinamycin FALSE TRUE TRUE FALSE Pristinamycin Pristinamycine Pristinamicina
|
||||||
Ribostamycin FALSE TRUE FALSE Ribostamycin Ribostamycine Ribostamicina
|
Procaine benzylpenicillin FALSE TRUE TRUE FALSE Procain-Benzylpenicillin Benzylpenicillineprocaine Bencilpenicilina procaína
|
||||||
Rifabutin FALSE TRUE FALSE Rifabutin Rifabutine Rifabutina
|
Propicillin FALSE TRUE TRUE FALSE Propicillin Propicilline Propicilina
|
||||||
Rifampicin FALSE TRUE FALSE Rifampicin Rifampicine Rifampicina
|
Prulifloxacin FALSE TRUE TRUE FALSE Prulifloxacin Prulifloxacine Prulifloxacina
|
||||||
Rifampicin/pyrazinamide/ethambutol/isoniazid FALSE TRUE FALSE Rifampicin/Pyrazinamid/Ethambutol/Isoniazid Rifampicine/pyrazinamide/ethambutol/isoniazide Rifampicina/pirazinamida/etambutol/isoniazida
|
Quinupristin/dalfopristin FALSE TRUE TRUE FALSE Quinupristin/Dalfopristin Quinupristine/dalfopristine Quinupristina/dalfopristina
|
||||||
Rifampicin/pyrazinamide/isoniazid FALSE TRUE FALSE Rifampicin/Pyrazinamid/Isoniazid Rifampicine/pyrazinamide/isoniazide Rifampicina/pirazinamida/isoniazida
|
Ribostamycin FALSE TRUE TRUE FALSE Ribostamycin Ribostamycine Ribostamicina
|
||||||
Rifampicin/isoniazid FALSE TRUE FALSE Rifampicin/Isoniazid Rifampicine/isoniazide Rifampicina/isoniazida
|
Rifabutin FALSE TRUE TRUE FALSE Rifabutin Rifabutine Rifabutina
|
||||||
Rifamycin FALSE TRUE FALSE Rifamycin Rifamycine Rifamicina
|
Rifampicin FALSE TRUE TRUE FALSE Rifampicin Rifampicine Rifampicina
|
||||||
Rifaximin FALSE TRUE FALSE Rifaximin Rifaximine Rifaximina
|
Rifampicin/pyrazinamide/ethambutol/isoniazid FALSE TRUE TRUE FALSE Rifampicin/Pyrazinamid/Ethambutol/Isoniazid Rifampicine/pyrazinamide/ethambutol/isoniazide Rifampicina/pirazinamida/etambutol/isoniazida
|
||||||
Rokitamycin FALSE TRUE FALSE Rokitamycin Rokitamycine Rokitamicina
|
Rifampicin/pyrazinamide/isoniazid FALSE TRUE TRUE FALSE Rifampicin/Pyrazinamid/Isoniazid Rifampicine/pyrazinamide/isoniazide Rifampicina/pirazinamida/isoniazida
|
||||||
Rosoxacin FALSE TRUE FALSE Rosoxacin Rosoxacine Rosoxacina
|
Rifampicin/isoniazid FALSE TRUE TRUE FALSE Rifampicin/Isoniazid Rifampicine/isoniazide Rifampicina/isoniazida
|
||||||
Roxithromycin FALSE TRUE FALSE Roxithromycin Roxitromycine Roxitromicina
|
Rifamycin FALSE TRUE TRUE FALSE Rifamycin Rifamycine Rifamicina
|
||||||
Rufloxacin FALSE TRUE FALSE Rufloxacin Rufloxacine Rufloxacina
|
Rifaximin FALSE TRUE TRUE FALSE Rifaximin Rifaximine Rifaximina
|
||||||
Sisomicin FALSE TRUE FALSE Sisomicin Sisomicine Sisomicina
|
Rokitamycin FALSE TRUE TRUE FALSE Rokitamycin Rokitamycine Rokitamicina
|
||||||
Sodium aminosalicylate FALSE TRUE FALSE Natrium-Aminosalicylat Aminosalicylzuur Aminosalicilato de sodio
|
Rosoxacin FALSE TRUE TRUE FALSE Rosoxacin Rosoxacine Rosoxacina
|
||||||
Sparfloxacin FALSE TRUE FALSE Sparfloxacin Sparfloxacine Esparfloxacina
|
Roxithromycin FALSE TRUE TRUE FALSE Roxithromycin Roxitromycine Roxitromicina
|
||||||
Spectinomycin FALSE TRUE FALSE Spectinomycin Spectinomycine Espectinomicina
|
Rufloxacin FALSE TRUE TRUE FALSE Rufloxacin Rufloxacine Rufloxacina
|
||||||
Spiramycin FALSE TRUE FALSE Spiramycin Spiramycine Espiramicina
|
Sisomicin FALSE TRUE TRUE FALSE Sisomicin Sisomicine Sisomicina
|
||||||
Spiramycin/metronidazole FALSE TRUE FALSE Spiramycin/Metronidazol Spiramycine/metronidazol Espiramicina/metronidazol
|
Sodium aminosalicylate FALSE TRUE TRUE FALSE Natrium-Aminosalicylat Aminosalicylzuur Aminosalicilato de sodio
|
||||||
Staphylococcus immunoglobulin FALSE TRUE FALSE Staphylococcus-Immunoglobulin Stafylokokkenimmunoglobuline Inmunoglobulina estafilocócica
|
Sparfloxacin FALSE TRUE TRUE FALSE Sparfloxacin Sparfloxacine Esparfloxacina
|
||||||
Streptoduocin FALSE TRUE FALSE Streptoduocin Streptoduocine Estreptoduocina
|
Spectinomycin FALSE TRUE TRUE FALSE Spectinomycin Spectinomycine Espectinomicina
|
||||||
Streptomycin FALSE TRUE FALSE Streptomycin Streptomycine Estreptomicina
|
Spiramycin FALSE TRUE TRUE FALSE Spiramycin Spiramycine Espiramicina
|
||||||
Streptomycin/isoniazid FALSE TRUE FALSE Streptomycin/Isoniazid Streptomycine/isoniazide Estreptomicina/isoniazida
|
Spiramycin/metronidazole FALSE TRUE TRUE FALSE Spiramycin/Metronidazol Spiramycine/metronidazol Espiramicina/metronidazol
|
||||||
Sulbenicillin FALSE TRUE FALSE Sulbenicillin Sulbenicilline Sulbenicilina
|
Staphylococcus immunoglobulin FALSE TRUE TRUE FALSE Staphylococcus-Immunoglobulin Stafylokokkenimmunoglobuline Inmunoglobulina estafilocócica
|
||||||
Sulfadiazine/tetroxoprim FALSE TRUE FALSE Sulfadiazin/Tetroxoprim Sulfadiazine/tetroxoprim Sulfadiazina/tetroxoprima
|
Streptoduocin FALSE TRUE TRUE FALSE Streptoduocin Streptoduocine Estreptoduocina
|
||||||
Sulfadiazine/trimethoprim FALSE TRUE FALSE Sulfadiazin/Trimethoprim Sulfadiazine/trimethoprim Sulfadiazina/trimetoprima
|
Streptomycin FALSE TRUE TRUE FALSE Streptomycin Streptomycine Estreptomicina
|
||||||
Sulfadimidine/trimethoprim FALSE TRUE FALSE Sulfadimidin/Trimethoprim Sulfadimidine/trimethoprim Sulfadimidina/trimetoprima
|
Streptomycin/isoniazid FALSE TRUE TRUE FALSE Streptomycin/Isoniazid Streptomycine/isoniazide Estreptomicina/isoniazida
|
||||||
Sulfafurazole FALSE TRUE FALSE Sulfafurazol Sulfafurazol Sulfafurazol
|
Sulbenicillin FALSE TRUE TRUE FALSE Sulbenicillin Sulbenicilline Sulbenicilina
|
||||||
Sulfaisodimidine FALSE TRUE FALSE Sulfaisodimidin Sulfisomidine Sulfaisodimidina
|
Sulfadiazine/tetroxoprim FALSE TRUE TRUE FALSE Sulfadiazin/Tetroxoprim Sulfadiazine/tetroxoprim Sulfadiazina/tetroxoprima
|
||||||
Sulfalene FALSE TRUE FALSE Sulfalene Sulfaleen Sulfaleno
|
Sulfadiazine/trimethoprim FALSE TRUE TRUE FALSE Sulfadiazin/Trimethoprim Sulfadiazine/trimethoprim Sulfadiazina/trimetoprima
|
||||||
Sulfamazone FALSE TRUE FALSE Sulfamazon Sulfamazon Sulfamazona
|
Sulfadimidine/trimethoprim FALSE TRUE TRUE FALSE Sulfadimidin/Trimethoprim Sulfadimidine/trimethoprim Sulfadimidina/trimetoprima
|
||||||
Sulfamerazine/trimethoprim FALSE TRUE FALSE Sulfamerazin/Trimethoprim Sulfamerazine/trimethoprim Sulfamerazina/trimetoprima
|
Sulfafurazole FALSE TRUE TRUE FALSE Sulfafurazol Sulfafurazol Sulfafurazol
|
||||||
Sulfamethizole FALSE TRUE FALSE Sulfamethizol Sulfamethizol Sulfametozol
|
Sulfaisodimidine FALSE TRUE TRUE FALSE Sulfaisodimidin Sulfisomidine Sulfaisodimidina
|
||||||
Sulfamethoxazole FALSE TRUE FALSE Sulfamethoxazol Sulfamethoxazol Sulfametoxazol
|
Sulfalene FALSE TRUE TRUE FALSE Sulfalene Sulfaleen Sulfaleno
|
||||||
Sulfamethoxazole/trimethoprim FALSE TRUE FALSE Sulfamethoxazol/Trimethoprim Sulfamethoxazol/trimethoprim Sulfametoxazol/trimetoprima
|
Sulfamazone FALSE TRUE TRUE FALSE Sulfamazon Sulfamazon Sulfamazona
|
||||||
Sulfametoxydiazine FALSE TRUE FALSE Sulfametoxydiazin Sulfamethoxydiazine Sulfametoxidiazina
|
Sulfamerazine/trimethoprim FALSE TRUE TRUE FALSE Sulfamerazin/Trimethoprim Sulfamerazine/trimethoprim Sulfamerazina/trimetoprima
|
||||||
Sulfametrole/trimethoprim FALSE TRUE FALSE Sulfametrole/Trimethoprim Sulfametrol/trimethoprim Sulfametrole/trimethoprim
|
Sulfamethizole FALSE TRUE TRUE FALSE Sulfamethizol Sulfamethizol Sulfametozol
|
||||||
Sulfamoxole FALSE TRUE FALSE Sulfamoxol Sulfamoxol Sulfamoxole
|
Sulfamethoxazole FALSE TRUE TRUE FALSE Sulfamethoxazol Sulfamethoxazol Sulfametoxazol
|
||||||
Sulfamoxole/trimethoprim FALSE TRUE FALSE Sulfamoxol/Trimethoprim Sulfamoxol/trimethoprim Sulfamoxol/trimetoprima
|
Sulfamethoxazole/trimethoprim FALSE TRUE TRUE FALSE Sulfamethoxazol/Trimethoprim Sulfamethoxazol/trimethoprim Sulfametoxazol/trimetoprima
|
||||||
Sulfaperin FALSE TRUE FALSE Sulfaperin Sulfaperine Sulfaproxeno
|
Sulfametoxydiazine FALSE TRUE TRUE FALSE Sulfametoxydiazin Sulfamethoxydiazine Sulfametoxidiazina
|
||||||
Sulfaphenazole FALSE TRUE FALSE Sulfaphenazol Sulfafenazol Sulfafenazol
|
Sulfametrole/trimethoprim FALSE TRUE TRUE FALSE Sulfametrole/Trimethoprim Sulfametrol/trimethoprim Sulfametrole/trimethoprim
|
||||||
Sulfathiazole FALSE TRUE FALSE Sulfathiazol Sulfathiazol Sulfatiazol
|
Sulfamoxole FALSE TRUE TRUE FALSE Sulfamoxol Sulfamoxol Sulfamoxole
|
||||||
Sulfathiourea FALSE TRUE FALSE Sulfathioharnstoff Sulfathioureum Sulfathiourea
|
Sulfamoxole/trimethoprim FALSE TRUE TRUE FALSE Sulfamoxol/Trimethoprim Sulfamoxol/trimethoprim Sulfamoxol/trimetoprima
|
||||||
Sultamicillin FALSE TRUE FALSE Sultamicillin Sultamicilline Sultamicilina
|
Sulfaperin FALSE TRUE TRUE FALSE Sulfaperin Sulfaperine Sulfaproxeno
|
||||||
Talampicillin FALSE TRUE FALSE Talampicillin Talampicilline Talampicilina
|
Sulfaphenazole FALSE TRUE TRUE FALSE Sulfaphenazol Sulfafenazol Sulfafenazol
|
||||||
Teicoplanin FALSE TRUE FALSE Teicoplanin Teicoplanine Teicoplanina
|
Sulfathiazole FALSE TRUE TRUE FALSE Sulfathiazol Sulfathiazol Sulfatiazol
|
||||||
Telithromycin FALSE TRUE FALSE Telithromycin Telitromycine Telitromicina
|
Sulfathiourea FALSE TRUE TRUE FALSE Sulfathioharnstoff Sulfathioureum Sulfathiourea
|
||||||
Temafloxacin FALSE TRUE FALSE Temafloxacin Temafloxacine Temafloxacina
|
Sultamicillin FALSE TRUE TRUE FALSE Sultamicillin Sultamicilline Sultamicilina
|
||||||
Temocillin FALSE TRUE FALSE Temocillin Temocilline Temocilina
|
Talampicillin FALSE TRUE TRUE FALSE Talampicillin Talampicilline Talampicilina
|
||||||
Tenofovir disoproxil FALSE TRUE FALSE Tenofovir Disoproxil Tenofovir Tenofovir disoproxil
|
Teicoplanin FALSE TRUE TRUE FALSE Teicoplanin Teicoplanine Teicoplanina
|
||||||
Terizidone FALSE TRUE FALSE Terizidon Terizidon Terizidona
|
Telithromycin FALSE TRUE TRUE FALSE Telithromycin Telitromycine Telitromicina
|
||||||
Thiamphenicol FALSE TRUE FALSE Thiamphenicol Thiamfenicol Tiamfenicol
|
Temafloxacin FALSE TRUE TRUE FALSE Temafloxacin Temafloxacine Temafloxacina
|
||||||
Thioacetazone/isoniazid FALSE TRUE FALSE Thioacetazon/Isoniazid Thioacetazon/isoniazide Tioacetazona/isoniazida
|
Temocillin FALSE TRUE TRUE FALSE Temocillin Temocilline Temocilina
|
||||||
Ticarcillin FALSE TRUE FALSE Ticarcillin Ticarcilline Ticarcilina
|
Tenofovir disoproxil FALSE TRUE TRUE FALSE Tenofovir Disoproxil Tenofovir Tenofovir disoproxil
|
||||||
Ticarcillin/beta-lactamase inhibitor FALSE TRUE FALSE Ticarcillin/Beta-Lactamase-Hemmer Ticarcilline/enzymremmer Ticarcilina/inhib. de la betalactamasa
|
Terizidone FALSE TRUE TRUE FALSE Terizidon Terizidon Terizidona
|
||||||
Ticarcillin/clavulanic acid FALSE TRUE FALSE Ticarcillin/Clavulansäure Ticarcilline/clavulaanzuur Ticarcilina/ácido clavulánico
|
Thiamphenicol FALSE TRUE TRUE FALSE Thiamphenicol Thiamfenicol Tiamfenicol
|
||||||
Tinidazole FALSE TRUE FALSE Tinidazol Tinidazol Tinidazol
|
Thioacetazone/isoniazid FALSE TRUE TRUE FALSE Thioacetazon/Isoniazid Thioacetazon/isoniazide Tioacetazona/isoniazida
|
||||||
Tobramycin FALSE TRUE FALSE Tobramycin Tobramycine Tobramicina
|
Ticarcillin FALSE TRUE TRUE FALSE Ticarcillin Ticarcilline Ticarcilina
|
||||||
Trimethoprim/sulfamethoxazole FALSE TRUE FALSE Trimethoprim/Sulfamethoxazol Cotrimoxazol Trimetoprima/sulfametoxazol
|
Ticarcillin/beta-lactamase inhibitor FALSE TRUE TRUE FALSE Ticarcillin/Beta-Lactamase-Hemmer Ticarcilline/enzymremmer Ticarcilina/inhib. de la betalactamasa
|
||||||
Troleandomycin FALSE TRUE FALSE Troleandomycin Troleandomycine Troleandomicina
|
Ticarcillin/clavulanic acid FALSE TRUE TRUE FALSE Ticarcillin/Clavulansäure Ticarcilline/clavulaanzuur Ticarcilina/ácido clavulánico
|
||||||
Trovafloxacin FALSE TRUE FALSE Trovafloxacin Trovafloxacine Trovafloxacina
|
Tinidazole FALSE TRUE TRUE FALSE Tinidazol Tinidazol Tinidazol
|
||||||
Vancomycin FALSE TRUE FALSE Vancomycin Vancomycine Vancomicina
|
Tobramycin FALSE TRUE TRUE FALSE Tobramycin Tobramycine Tobramicina
|
||||||
Voriconazole FALSE TRUE FALSE Voriconazol Voriconazol Voriconazol
|
Trimethoprim/sulfamethoxazole FALSE TRUE TRUE FALSE Trimethoprim/Sulfamethoxazol Cotrimoxazol Trimetoprima/sulfametoxazol
|
||||||
Aminoglycosides FALSE TRUE FALSE Aminoglykoside Aminoglycosiden Aminoglucósidos
|
Troleandomycin FALSE TRUE TRUE FALSE Troleandomycin Troleandomycine Troleandomicina
|
||||||
Amphenicols FALSE TRUE FALSE Amphenicole Amfenicolen Anfenicoles
|
Trovafloxacin FALSE TRUE TRUE FALSE Trovafloxacin Trovafloxacine Trovafloxacina
|
||||||
Antifungals/antimycotics FALSE TRUE FALSE Antimykotika/Antimykotika Antifungica/antimycotica Antifúngicos/antimicóticos
|
Vancomycin FALSE TRUE TRUE FALSE Vancomycin Vancomycine Vancomicina
|
||||||
Antimycobacterials FALSE TRUE FALSE Antimykobakterielle Mittel Antimycobacteriele middelen Antimicrobianos
|
Voriconazole FALSE TRUE TRUE FALSE Voriconazol Voriconazol Voriconazol
|
||||||
Beta-lactams/penicillins FALSE TRUE FALSE Beta-Lactame/Penicilline Beta-lactams/penicillines Beta-lactámicos/penicilinas
|
Aminoglycosides FALSE TRUE TRUE FALSE Aminoglykoside Aminoglycosiden Aminoglucósidos
|
||||||
Cephalosporins (1st gen.) FALSE TRUE FALSE Cephalosporine (1. Gen.) Cefalosporines (1e gen.) Cefalosporinas (1er gen.)
|
Amphenicols FALSE TRUE TRUE FALSE Amphenicole Amfenicolen Anfenicoles
|
||||||
Cephalosporins (2nd gen.) FALSE TRUE FALSE Cephalosporine (2. Gen.) Cefalosporines (2e gen.) Cefalosporinas (2do gen.)
|
Antifungals/antimycotics FALSE TRUE TRUE FALSE Antimykotika/Antimykotika Antifungica/antimycotica Antifúngicos/antimicóticos
|
||||||
Cephalosporins (3rd gen.) FALSE TRUE FALSE Cephalosporine (3. Gen.) Cefalosporines (3e gen.) Cefalosporinas (3er gen.)
|
Antimycobacterials FALSE TRUE TRUE FALSE Antimykobakterielle Mittel Antimycobacteriele middelen Antimicrobianos
|
||||||
Cephalosporins (4th gen.) FALSE TRUE FALSE Cephalosporine (4. Gen.) Cefalosporines (4e gen.) Cefalosporinas (4º gen.)
|
Beta-lactams/penicillins FALSE TRUE TRUE FALSE Beta-Lactame/Penicilline Beta-lactams/penicillines Beta-lactámicos/penicilinas
|
||||||
Cephalosporins (5th gen.) FALSE TRUE FALSE Cephalosporine (5. Gen.) Cefalosporines (5e gen.) Cefalosporinas (5º gen.)
|
Cephalosporins (1st gen.) FALSE TRUE TRUE FALSE Cephalosporine (1. Gen.) Cefalosporines (1e gen.) Cefalosporinas (1er gen.)
|
||||||
Cephalosporins (unclassified gen.) FALSE TRUE FALSE Cephalosporine (unklassifiziert) Cefalosporines (ongeclassificeerd) Cefalosporinas (no clasificado)
|
Cephalosporins (2nd gen.) FALSE TRUE TRUE FALSE Cephalosporine (2. Gen.) Cefalosporines (2e gen.) Cefalosporinas (2do gen.)
|
||||||
Cephalosporins FALSE TRUE FALSE Cephalosporine Cefalosporines Cefalosporinas
|
Cephalosporins (3rd gen.) FALSE TRUE TRUE FALSE Cephalosporine (3. Gen.) Cefalosporines (3e gen.) Cefalosporinas (3er gen.)
|
||||||
Glycopeptides FALSE TRUE FALSE Glykopeptide Glycopeptiden Glicopéptidos
|
Cephalosporins (4th gen.) FALSE TRUE TRUE FALSE Cephalosporine (4. Gen.) Cefalosporines (4e gen.) Cefalosporinas (4º gen.)
|
||||||
Macrolides/lincosamides FALSE TRUE FALSE Makrolide/Linkosamide Macroliden/lincosamiden Macrólidos/lincosamidas
|
Cephalosporins (5th gen.) FALSE TRUE TRUE FALSE Cephalosporine (5. Gen.) Cefalosporines (5e gen.) Cefalosporinas (5º gen.)
|
||||||
Other antibacterials FALSE TRUE FALSE Andere Antibiotika Overige antibiotica Otros antibacterianos
|
Cephalosporins (unclassified gen.) FALSE TRUE TRUE FALSE Cephalosporine (unklassifiziert) Cefalosporines (ongeclassificeerd) Cefalosporinas (no clasificado)
|
||||||
Polymyxins FALSE TRUE FALSE Polymyxine Polymyxines Polimixinas
|
Cephalosporins FALSE TRUE TRUE FALSE Cephalosporine Cefalosporines Cefalosporinas
|
||||||
Quinolones FALSE TRUE FALSE Quinolone Quinolonen Quinolonas
|
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>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
<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</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<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</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/* Styles for section anchors */
|
||||||
|
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
|
||||||
|
a.anchor-section::before {content: '#';}
|
||||||
|
.hasAnchor:hover a.anchor-section {visibility: visible;}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Do nothing if AnchorJS is used
|
||||||
|
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||||
|
|
||||||
|
// Do nothing if sections are already anchored
|
||||||
|
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use section id when pandoc runs with --section-divs
|
||||||
|
const section_id = function(x) {
|
||||||
|
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
|
||||||
|
? x.id : '');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add anchors
|
||||||
|
h.forEach(function(x) {
|
||||||
|
const id = x.id || section_id(x.parentElement);
|
||||||
|
if (id === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let anchor = document.createElement('a');
|
||||||
|
anchor.href = '#' + id;
|
||||||
|
anchor.classList = ['anchor-section'];
|
||||||
|
x.classList.add('hasAnchor');
|
||||||
|
x.appendChild(anchor);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 51 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: 68 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 46 KiB |
12
docs/articles/AMR_files/header-attrs-2.8/header-attrs.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||||
|
// be compatible with the behavior of Pandoc < 2.8).
|
||||||
|
document.addEventListener('DOMContentLoaded', function(e) {
|
||||||
|
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||||
|
var i, h, a;
|
||||||
|
for (i = 0; i < hs.length; i++) {
|
||||||
|
h = hs[i];
|
||||||
|
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||||
|
a = h.attributes;
|
||||||
|
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="EUCAST_files/header-attrs-2.6/header-attrs.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="col-md-9 contents">
|
||||||
<div class="page-header toc-ignore">
|
<div class="page-header toc-ignore">
|
||||||
<h1 data-toc-skip>How to apply EUCAST rules</h1>
|
<h1 data-toc-skip>How to apply EUCAST rules</h1>
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/* Styles for section anchors */
|
||||||
|
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
|
||||||
|
a.anchor-section::before {content: '#';}
|
||||||
|
.hasAnchor:hover a.anchor-section {visibility: visible;}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Do nothing if AnchorJS is used
|
||||||
|
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||||
|
|
||||||
|
// Do nothing if sections are already anchored
|
||||||
|
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use section id when pandoc runs with --section-divs
|
||||||
|
const section_id = function(x) {
|
||||||
|
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
|
||||||
|
? x.id : '');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add anchors
|
||||||
|
h.forEach(function(x) {
|
||||||
|
const id = x.id || section_id(x.parentElement);
|
||||||
|
if (id === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let anchor = document.createElement('a');
|
||||||
|
anchor.href = '#' + id;
|
||||||
|
anchor.classList = ['anchor-section'];
|
||||||
|
x.classList.add('hasAnchor');
|
||||||
|
x.appendChild(anchor);
|
||||||
|
});
|
||||||
|
});
|
||||||
12
docs/articles/EUCAST_files/header-attrs-2.8/header-attrs.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||||
|
// be compatible with the behavior of Pandoc < 2.8).
|
||||||
|
document.addEventListener('DOMContentLoaded', function(e) {
|
||||||
|
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||||
|
var i, h, a;
|
||||||
|
for (i = 0; i < hs.length; i++) {
|
||||||
|
h = hs[i];
|
||||||
|
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||||
|
a = h.attributes;
|
||||||
|
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9018</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="MDR_files/header-attrs-2.6/header-attrs.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="col-md-9 contents">
|
||||||
<div class="page-header toc-ignore">
|
<div class="page-header toc-ignore">
|
||||||
<h1 data-toc-skip>How to determine multi-drug resistance (MDR)</h1>
|
<h1 data-toc-skip>How to determine multi-drug resistance (MDR)</h1>
|
||||||
@@ -251,9 +251,9 @@
|
|||||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R"><span class="va">custom</span>
|
<code class="sourceCode R"><span class="va">custom</span>
|
||||||
<span class="co"># A set of custom MDRO rules:</span>
|
<span class="co"># A set of custom MDRO rules:</span>
|
||||||
<span class="co"># 1. CIP is "R" and age is higher than 60 -> Elderly Type A</span>
|
<span class="co"># 1. If CIP is "R" and age is higher than 60 then: Elderly Type A</span>
|
||||||
<span class="co"># 2. ERY is "R" and age is higher than 60 -> Elderly Type B</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"># 3. Otherwise: Negative</span>
|
||||||
<span class="co"># </span>
|
<span class="co"># </span>
|
||||||
<span class="co"># Unmatched rows will return NA.</span>
|
<span class="co"># Unmatched rows will return NA.</span>
|
||||||
<span class="co"># Results will be of class <factor>, with ordered levels: Negative < Elderly Type A < Elderly Type B</span></code></pre></div>
|
<span class="co"># Results will be of class <factor>, with ordered levels: Negative < Elderly Type A < Elderly Type B</span></code></pre></div>
|
||||||
@@ -263,7 +263,7 @@
|
|||||||
<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="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"># x</span>
|
||||||
<span class="co"># Negative Elderly Type A Elderly Type B </span>
|
<span class="co"># Negative Elderly Type A Elderly Type B </span>
|
||||||
<span class="co"># 1066 43 891</span></code></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>
|
<p>The rules set (the <code>custom</code> object in this case) could be exported to a shared file location using <code><a href="https://rdrr.io/r/base/readRDS.html">saveRDS()</a></code> if you collaborate with multiple users. The custom rules set could then be imported using <code><a href="https://rdrr.io/r/base/readRDS.html">readRDS()</a></code>.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -339,27 +339,27 @@ Unique: 2</p>
|
|||||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
<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"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span>
|
||||||
<span class="co"># 1 S R S S S I</span>
|
<span class="co"># 1 I I I I S S</span>
|
||||||
<span class="co"># 2 S I R R R R</span>
|
<span class="co"># 2 R I S I I I</span>
|
||||||
<span class="co"># 3 R S S I S I</span>
|
<span class="co"># 3 S R R R R I</span>
|
||||||
<span class="co"># 4 I S S S I S</span>
|
<span class="co"># 4 S R S S R S</span>
|
||||||
<span class="co"># 5 I I I S I R</span>
|
<span class="co"># 5 R S I R S R</span>
|
||||||
<span class="co"># 6 S I S R S S</span>
|
<span class="co"># 6 R R R R I I</span>
|
||||||
<span class="co"># kanamycin</span>
|
<span class="co"># kanamycin</span>
|
||||||
<span class="co"># 1 R</span>
|
<span class="co"># 1 I</span>
|
||||||
<span class="co"># 2 I</span>
|
<span class="co"># 2 I</span>
|
||||||
<span class="co"># 3 R</span>
|
<span class="co"># 3 S</span>
|
||||||
<span class="co"># 4 S</span>
|
<span class="co"># 4 R</span>
|
||||||
<span class="co"># 5 S</span>
|
<span class="co"># 5 I</span>
|
||||||
<span class="co"># 6 R</span></code></pre></div>
|
<span class="co"># 6 I</span></code></pre></div>
|
||||||
<p>We can now add the interpretation of MDR-TB to our data set. You can use:</p>
|
<p>We can now add the interpretation of MDR-TB to our data set. You can use:</p>
|
||||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
<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>
|
<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>
|
<p>or its shortcut <code><a href="../reference/mdro.html">mdr_tb()</a></code>:</p>
|
||||||
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R"><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdr_tb</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
<code class="sourceCode R"><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdr_tb</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
||||||
<span class="co"># NOTE: No column found as input for `col_mo`, assuming all records</span>
|
<span class="co"># ℹ No column found as input for `col_mo`, assuming all rows contain</span>
|
||||||
<span class="co"># containMycobacterium tuberculosis.</span></code></pre></div>
|
<span class="co"># Mycobacterium tuberculosis.</span></code></pre></div>
|
||||||
<p>Create a frequency table of the results:</p>
|
<p>Create a frequency table of the results:</p>
|
||||||
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span><span class="op">)</span></code></pre></div>
|
<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>
|
||||||
@@ -367,7 +367,7 @@ Unique: 2</p>
|
|||||||
<p>Class: factor > ordered (numeric)<br>
|
<p>Class: factor > ordered (numeric)<br>
|
||||||
Length: 5,000<br>
|
Length: 5,000<br>
|
||||||
Levels: 5: Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant <…<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>
|
Unique: 5</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead><tr class="header">
|
<thead><tr class="header">
|
||||||
@@ -382,40 +382,40 @@ Unique: 5</p>
|
|||||||
<tr class="odd">
|
<tr class="odd">
|
||||||
<td align="left">1</td>
|
<td align="left">1</td>
|
||||||
<td align="left">Mono-resistant</td>
|
<td align="left">Mono-resistant</td>
|
||||||
<td align="right">3246</td>
|
<td align="right">3271</td>
|
||||||
<td align="right">64.92%</td>
|
<td align="right">65.42%</td>
|
||||||
<td align="right">3246</td>
|
<td align="right">3271</td>
|
||||||
<td align="right">64.92%</td>
|
<td align="right">65.42%</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="even">
|
<tr class="even">
|
||||||
<td align="left">2</td>
|
<td align="left">2</td>
|
||||||
<td align="left">Negative</td>
|
<td align="left">Negative</td>
|
||||||
<td align="right">976</td>
|
<td align="right">949</td>
|
||||||
<td align="right">19.52%</td>
|
<td align="right">18.98%</td>
|
||||||
<td align="right">4222</td>
|
<td align="right">4220</td>
|
||||||
<td align="right">84.44%</td>
|
<td align="right">84.40%</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="odd">
|
<tr class="odd">
|
||||||
<td align="left">3</td>
|
<td align="left">3</td>
|
||||||
<td align="left">Multi-drug-resistant</td>
|
<td align="left">Multi-drug-resistant</td>
|
||||||
<td align="right">467</td>
|
<td align="right">449</td>
|
||||||
<td align="right">9.34%</td>
|
<td align="right">8.98%</td>
|
||||||
<td align="right">4689</td>
|
<td align="right">4669</td>
|
||||||
<td align="right">93.78%</td>
|
<td align="right">93.38%</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="even">
|
<tr class="even">
|
||||||
<td align="left">4</td>
|
<td align="left">4</td>
|
||||||
<td align="left">Poly-resistant</td>
|
<td align="left">Poly-resistant</td>
|
||||||
<td align="right">230</td>
|
<td align="right">240</td>
|
||||||
<td align="right">4.60%</td>
|
<td align="right">4.80%</td>
|
||||||
<td align="right">4919</td>
|
<td align="right">4909</td>
|
||||||
<td align="right">98.38%</td>
|
<td align="right">98.18%</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="odd">
|
<tr class="odd">
|
||||||
<td align="left">5</td>
|
<td align="left">5</td>
|
||||||
<td align="left">Extensively drug-resistant</td>
|
<td align="left">Extensively drug-resistant</td>
|
||||||
<td align="right">81</td>
|
<td align="right">91</td>
|
||||||
<td align="right">1.62%</td>
|
<td align="right">1.82%</td>
|
||||||
<td align="right">5000</td>
|
<td align="right">5000</td>
|
||||||
<td align="right">100.00%</td>
|
<td align="right">100.00%</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/* Styles for section anchors */
|
||||||
|
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
|
||||||
|
a.anchor-section::before {content: '#';}
|
||||||
|
.hasAnchor:hover a.anchor-section {visibility: visible;}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Do nothing if AnchorJS is used
|
||||||
|
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||||
|
|
||||||
|
// Do nothing if sections are already anchored
|
||||||
|
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use section id when pandoc runs with --section-divs
|
||||||
|
const section_id = function(x) {
|
||||||
|
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
|
||||||
|
? x.id : '');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add anchors
|
||||||
|
h.forEach(function(x) {
|
||||||
|
const id = x.id || section_id(x.parentElement);
|
||||||
|
if (id === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let anchor = document.createElement('a');
|
||||||
|
anchor.href = '#' + id;
|
||||||
|
anchor.classList = ['anchor-section'];
|
||||||
|
x.classList.add('hasAnchor');
|
||||||
|
x.appendChild(anchor);
|
||||||
|
});
|
||||||
|
});
|
||||||
12
docs/articles/MDR_files/header-attrs-2.8/header-attrs.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||||
|
// be compatible with the behavior of Pandoc < 2.8).
|
||||||
|
document.addEventListener('DOMContentLoaded', function(e) {
|
||||||
|
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||||
|
var i, h, a;
|
||||||
|
for (i = 0; i < hs.length; i++) {
|
||||||
|
h = hs[i];
|
||||||
|
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||||
|
a = h.attributes;
|
||||||
|
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.0</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="PCA_files/header-attrs-2.6/header-attrs.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="col-md-9 contents">
|
||||||
<div class="page-header toc-ignore">
|
<div class="page-header toc-ignore">
|
||||||
<h1 data-toc-skip>How to conduct principal component analysis (PCA) for AMR</h1>
|
<h1 data-toc-skip>How to conduct principal component analysis (PCA) for AMR</h1>
|
||||||
@@ -212,58 +212,58 @@
|
|||||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
<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>
|
<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="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"># Rows: 2,000</span>
|
||||||
<span class="co"># Columns: 49</span>
|
<span class="co"># Columns: 49</span>
|
||||||
<span class="co"># $ date <date> 2002-01-02, 2002-01-03, 2002-01-07, 2002-01-07, 2002…</span>
|
<span class="co"># $ date <date> 2002-01-02, 2002-01-03, 2002-01-07, 2002-01-07, 2002-…</span>
|
||||||
<span class="co"># $ hospital_id <fct> D, D, B, B, B, B, D, D, B, B, D, D, D, D, D, B, B, B, …</span>
|
<span class="co"># $ 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_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, F…</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, FALS…</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, 7…</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"># $ 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"># $ 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_STP…</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"># $ PEN <rsi> R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, …</span>
|
||||||
<span class="co"># $ OXA <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
<span class="co"># $ OXA <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…</span>
|
||||||
<span class="co"># $ FLC <rsi> NA, NA, R, R, R, R, S, S, R, S, S, S, NA, NA, NA, NA, …</span>
|
<span class="co"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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, N…</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, N…</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"># $ 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"># $ 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"># $ CTX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S, …</span>
|
||||||
<span class="co"># $ CAZ <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, …</span>
|
<span class="co"># $ CAZ <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, S…</span>
|
||||||
<span class="co"># $ CRO <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S, …</span>
|
<span class="co"># $ 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"># $ 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, N…</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, N…</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, N…</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, …</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"># $ 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"># $ 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, N…</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"># $ 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"># $ 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"># $ 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, …</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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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"># $ 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, N…</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, N…</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, …</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, N…</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>
|
<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>
|
<p>Now to transform this to a data set with only resistance percentages per taxonomic order and genus:</p>
|
||||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
<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>
|
<code class="sourceCode R"><span class="va">resistance_data</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||||
@@ -275,15 +275,15 @@
|
|||||||
|
|
||||||
<span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span>
|
||||||
<span class="co"># # A tibble: 6 x 10</span>
|
<span class="co"># # A tibble: 6 x 10</span>
|
||||||
<span class="co"># # Groups: order [2]</span>
|
<span class="co"># # Groups: order [5]</span>
|
||||||
<span class="co"># order genus AMC CXM CTX CAZ GEN TOB TMP SXT</span>
|
<span class="co"># order genus AMC CXM CTX CAZ GEN TOB TMP SXT</span>
|
||||||
<span class="co"># <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl></span>
|
<span class="co"># <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl></span>
|
||||||
<span class="co"># 1 (unknown order) (unknown genu… NA NA NA NA NA NA NA NA</span>
|
<span class="co"># 1 (unknown order) (unknown gen… NA NA NA NA NA NA NA NA</span>
|
||||||
<span class="co"># 2 Actinomycetales Corynebacteri… NA NA NA NA NA NA NA NA</span>
|
<span class="co"># 2 Actinomycetales Schaalia NA NA NA NA NA NA NA NA</span>
|
||||||
<span class="co"># 3 Actinomycetales Cutibacterium NA NA NA NA NA NA NA NA</span>
|
<span class="co"># 3 Bacteroidales Bacteroides NA NA NA NA NA NA NA NA</span>
|
||||||
<span class="co"># 4 Actinomycetales Dermabacter 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 Actinomycetales Micrococcus 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 Actinomycetales Rothia NA NA NA NA NA NA NA NA</span></code></pre></div>
|
<span class="co"># 6 Caryophanales Listeria NA NA NA NA NA NA NA NA</span></code></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="perform-principal-component-analysis" class="section level1">
|
<div id="perform-principal-component-analysis" class="section level1">
|
||||||
<h1 class="hasAnchor">
|
<h1 class="hasAnchor">
|
||||||
@@ -291,30 +291,34 @@
|
|||||||
<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>
|
<p>The new <code><a href="../reference/pca.html">pca()</a></code> function will automatically filter on rows that contain numeric values in all selected variables, so we now only need to do:</p>
|
||||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
<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>
|
<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"># NOTE: Columns selected for PCA: AMC CXM CTX CAZ GEN TOB TMP SXT. Total</span>
|
<span class="co"># ℹ Columns selected for PCA: "AMC", "CAZ", "CTX", "CXM", "GEN", "SXT", "TMP"</span>
|
||||||
<span class="co"># observations available: 7.</span></code></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>
|
<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 sourceCode r">
|
<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>
|
<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"># Importance of components:</span>
|
||||||
<span class="co"># PC1 PC2 PC3 PC4 PC5 PC6 PC7</span>
|
<span class="co"># PC1 PC2 PC3 PC4 PC5 PC6 PC7</span>
|
||||||
<span class="co"># Standard deviation 2.154 1.6807 0.61365 0.33902 0.20757 0.03136 1.733e-16</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.580 0.3531 0.04707 0.01437 0.00539 0.00012 0.000e+00</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.580 0.9331 0.98012 0.99449 0.99988 1.00000 1.000e+00</span></code></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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<div id="plotting-the-results" class="section level1">
|
<div id="plotting-the-results" class="section level1">
|
||||||
<h1 class="hasAnchor">
|
<h1 class="hasAnchor">
|
||||||
<a href="#plotting-the-results" class="anchor"></a>Plotting the results</h1>
|
<a href="#plotting-the-results" class="anchor"></a>Plotting the results</h1>
|
||||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R"><span class="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>
|
<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><img src="PCA_files/figure-html/unnamed-chunk-5-1.png" width="750"></p>
|
||||||
<p>But we can’t see the explanation of the points. Perhaps this works better with our new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function, that automatically adds the right labels and even groups:</p>
|
<p>But we can’t see the explanation of the points. Perhaps this works better with our new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function, that automatically adds the right labels and even groups:</p>
|
||||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
<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>
|
<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><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>
|
<p>You can also print an ellipse per group, and edit the appearance:</p>
|
||||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R"><span class="fu"><a href="../reference/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>
|
<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>
|
<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>
|
<p><img src="PCA_files/figure-html/unnamed-chunk-7-1.png" width="750"></p>
|
||||||
|
|||||||