Compare commits
42 Commits
v1.6.0
...
916df6e90c
| Author | SHA1 | Date | |
|---|---|---|---|
| 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$
|
||||||
|
|||||||
128
.github/workflows/check.yaml
vendored
@@ -50,9 +50,9 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config:
|
||||||
- {os: macOS-latest, r: 'devel', allowfail: false}
|
- {os: macOS-latest, r: 'devel', allowfail: true}
|
||||||
- {os: macOS-latest, r: 'release', allowfail: false}
|
- {os: macOS-latest, r: 'release', allowfail: false}
|
||||||
- {os: macOS-latest, r: 'oldrel', allowfail: false}
|
- {os: macOS-latest, r: 'oldrel', allowfail: true}
|
||||||
|
|
||||||
- {os: windows-latest, r: 'devel', allowfail: false}
|
- {os: windows-latest, r: 'devel', allowfail: false}
|
||||||
- {os: windows-latest, r: 'release', allowfail: false}
|
- {os: windows-latest, r: 'release', allowfail: false}
|
||||||
@@ -65,10 +65,10 @@ jobs:
|
|||||||
- {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: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
# - {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
- {os: ubuntu-20.04, r: '3.0', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '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: '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: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
@@ -77,10 +77,10 @@ jobs:
|
|||||||
- {os: ubuntu-16.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.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.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.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.3', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
# - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.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.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"}
|
- {os: ubuntu-16.04, r: '3.0', allowfail: false, 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 +89,81 @@ 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: Query dependencies
|
|
||||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
|
||||||
run: |
|
|
||||||
install.packages('remotes')
|
|
||||||
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
|
|
||||||
shell: Rscript {0}
|
|
||||||
|
|
||||||
- name: Cache R packages
|
|
||||||
if: runner.os != 'Windows' && matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
|
||||||
uses: actions/cache@v1
|
|
||||||
with:
|
|
||||||
path: ${{ env.R_LIBS_USER }}
|
|
||||||
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3-${{ hashFiles('.github/depends.Rds') }}
|
|
||||||
restore-keys: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3-
|
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
- name: Install Linux dependencies
|
||||||
if: runner.os == 'Linux' && matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
if: runner.os == 'Linux'
|
||||||
env:
|
|
||||||
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
|
|
||||||
run: |
|
|
||||||
Rscript -e "remotes::install_github('r-hub/sysreqs')"
|
|
||||||
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
|
|
||||||
sudo -s eval "$sysreqs"
|
|
||||||
|
|
||||||
- name: Install Linux dependencies on old R versions
|
|
||||||
if: matrix.config.r == '3.0' || matrix.config.r == '3.1' || matrix.config.r == '3.2'
|
|
||||||
env:
|
|
||||||
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
|
|
||||||
# update the below with sysreqs::sysreqs("DESCRIPTION") and check the "DEB" entries (for Ubuntu).
|
# 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
|
# we don't want to depend on the sysreqs pkg here, as it requires a quite new R version
|
||||||
run: |
|
run: |
|
||||||
sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev
|
sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev
|
||||||
|
|
||||||
- name: Install macOS dependencies
|
- name: Restore cached R packages
|
||||||
if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'devel'
|
# this step will add the step 'Post Restore cached R packages' on a succesful run
|
||||||
run: |
|
if: runner.os != 'Windows'
|
||||||
brew install mariadb-connector-c
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ${{ env.R_LIBS_USER }}
|
||||||
|
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4
|
||||||
|
|
||||||
- name: Install package dependencies
|
- name: Update AMR package dependencies
|
||||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
|
||||||
run: |
|
run: |
|
||||||
remotes::install_deps(dependencies = TRUE)
|
install.packages("data-raw/AMR_latest.tar.gz")
|
||||||
remotes::install_cran("rcmdcheck")
|
source("data-raw/_install_deps.R")
|
||||||
shell: Rscript {0}
|
shell: Rscript {0}
|
||||||
|
|
||||||
- name: Session info
|
- name: Show 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: Run R CMD check on Windows
|
||||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
if: runner.os == 'Windows'
|
||||||
env:
|
|
||||||
_R_CHECK_CRAN_INCOMING_: false
|
|
||||||
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
|
|
||||||
shell: Rscript {0}
|
|
||||||
|
|
||||||
- name: Run R CMD check on older R versions
|
|
||||||
if: matrix.config.r == '3.0' || matrix.config.r == '3.1' || matrix.config.r == '3.2'
|
|
||||||
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
|
tar -xf data-raw/AMR_latest.tar.gz
|
||||||
|
rm -rf AMR/vignettes
|
||||||
- name: Show testthat output
|
R CMD check AMR
|
||||||
if: always()
|
|
||||||
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
|
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Upload check results
|
- name: Run R CMD check on Linux and macOS
|
||||||
if: failure()
|
if: runner.os != 'Windows'
|
||||||
uses: actions/upload-artifact@master
|
env:
|
||||||
|
_R_CHECK_CRAN_INCOMING_: false
|
||||||
|
_R_CHECK_FORCE_SUGGESTS_: false
|
||||||
|
_R_CHECK_DEPENDS_ONLY_: true
|
||||||
|
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||||
|
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
||||||
|
# during 'R CMD check', R_LIBS_USER will be overwritten, so:
|
||||||
|
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
|
||||||
|
R_RUN_TINYTEST: true
|
||||||
|
run: |
|
||||||
|
tar -xf data-raw/AMR_latest.tar.gz
|
||||||
|
rm -rf AMR/vignettes
|
||||||
|
R CMD check AMR --no-manual --no-vignettes
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Show unit tests output
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
find . -name 'tinytest.Rout*' -exec cat '{}' \; || true
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
|
name: artifacts-${{ matrix.config.os }}-r${{ matrix.config.r }}
|
||||||
path: check
|
path: AMR.Rcheck
|
||||||
|
|||||||
16
DESCRIPTION
@@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.6.0
|
Version: 1.6.0.9041
|
||||||
Date: 2021-03-14
|
Date: 2021-05-16
|
||||||
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,11 +35,10 @@ 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:
|
||||||
@@ -47,6 +46,7 @@ Suggests:
|
|||||||
curl,
|
curl,
|
||||||
dplyr,
|
dplyr,
|
||||||
ggplot2,
|
ggplot2,
|
||||||
|
ggtext,
|
||||||
knitr,
|
knitr,
|
||||||
microbenchmark,
|
microbenchmark,
|
||||||
pillar,
|
pillar,
|
||||||
@@ -55,8 +55,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
|
||||||
|
|||||||
13
NAMESPACE
@@ -43,6 +43,8 @@ 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 +59,8 @@ S3method(barplot,disk)
|
|||||||
S3method(barplot,mic)
|
S3method(barplot,mic)
|
||||||
S3method(barplot,rsi)
|
S3method(barplot,rsi)
|
||||||
S3method(c,ab)
|
S3method(c,ab)
|
||||||
|
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 +101,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 +142,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 +161,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)
|
||||||
@@ -184,6 +193,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)
|
||||||
@@ -227,8 +237,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)
|
||||||
|
|||||||
90
NEWS.md
@@ -1,5 +1,53 @@
|
|||||||
# AMR 1.6.0
|
# `AMR` 1.6.0.9041
|
||||||
|
## <small>Last updated: 16 May 2021</small>
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
* Added `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
|
||||||
|
* Fix for filtering on antibiotic classes (such as `filter_cephalosporins()`)
|
||||||
|
|
||||||
|
### 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, defeating the purpose to test our package under less recent R versions. 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.
|
||||||
@@ -59,7 +107,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 +141,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 +218,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 +290,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 +343,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 +381,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 +403,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 +419,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 +467,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 +533,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 +662,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 +723,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 +781,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!**
|
||||||
|
|
||||||
@@ -932,7 +980,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 +1063,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 +1174,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 +1244,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 +1279,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 +1287,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
|
||||||
@@ -148,8 +193,8 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
|||||||
}
|
}
|
||||||
# -- key antibiotics
|
# -- key antibiotics
|
||||||
if (type == "keyantibiotics") {
|
if (type == "keyantibiotics") {
|
||||||
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, "\")",
|
||||||
@@ -265,7 +321,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") {
|
||||||
@@ -299,8 +355,8 @@ word_wrap <- function(...,
|
|||||||
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 +459,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
|
||||||
@@ -481,7 +537,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 +551,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 +576,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,
|
||||||
@@ -590,16 +645,23 @@ meet_criteria <- function(object,
|
|||||||
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,
|
||||||
@@ -641,6 +703,7 @@ get_current_data <- function(arg_name, call) {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -650,12 +713,17 @@ get_current_data <- function(arg_name, call) {
|
|||||||
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
|
||||||
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,6 +743,7 @@ 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)
|
return(vars_df)
|
||||||
@@ -770,6 +839,7 @@ message_not_thrown_before <- function(fn, entire_session = FALSE) {
|
|||||||
|
|
||||||
reset_all_thrown_messages <- function() {
|
reset_all_thrown_messages <- function() {
|
||||||
# for unit tests, where the environment and highest system call do not change
|
# for unit tests, where the environment and highest system call do not change
|
||||||
|
# can be found in tests/testthat/*.R
|
||||||
pkg_env_contents <- ls(envir = pkg_env)
|
pkg_env_contents <- ls(envir = pkg_env)
|
||||||
rm(list = pkg_env_contents[pkg_env_contents %like% "^thrown_msg."],
|
rm(list = pkg_env_contents[pkg_env_contents %like% "^thrown_msg."],
|
||||||
envir = pkg_env)
|
envir = pkg_env)
|
||||||
@@ -913,8 +983,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()
|
||||||
@@ -1087,8 +1157,8 @@ 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.numeric(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.0.5)
|
||||||
# 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)
|
||||||
@@ -1135,3 +1205,11 @@ 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 (as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 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
|
||||||
|
}
|
||||||
|
|||||||
27
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
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
#' 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 +155,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 +169,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 +236,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 +388,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 +476,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 +550,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 +558,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
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#'
|
#'
|
||||||
#' 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 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, "."), "")}}
|
||||||
#' @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 only_rsi_columns a [logical] to indicate whether only columns of class `<rsi>` must be selected (defaults to `FALSE`), see [as.rsi()]
|
||||||
#' @inheritParams filter_ab_class
|
#' @inheritParams filter_ab_class
|
||||||
#' @details \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}}
|
#' @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, "."), "")}}
|
||||||
#'
|
#'
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
10
R/age.R
@@ -29,8 +29,8 @@
|
|||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x date(s), will be coerced with [as.POSIXlt()]
|
#' @param x date(s), will be coerced with [as.POSIXlt()]
|
||||||
#' @param reference reference date(s) (defaults to today), will be coerced with [as.POSIXlt()]
|
#' @param reference reference date(s) (defaults to today), will be coerced with [as.POSIXlt()]
|
||||||
#' @param exact a logical to indicate whether age calculation should be exact, i.e. with decimals. It divides the number of days of [year-to-date](https://en.wikipedia.org/wiki/Year-to-date) (YTD) of `x` by the number of days in the year of `reference` (either 365 or 366).
|
#' @param 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.
|
||||||
#' @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
|
||||||
@@ -105,7 +105,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 +149,8 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
|||||||
#' }
|
#' }
|
||||||
#' }
|
#' }
|
||||||
age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
|
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.
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
254
R/custom_eucast_rules.R
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
# ==================================================================== #
|
||||||
|
# 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,
|
||||||
|
info = FALSE,
|
||||||
|
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 (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
|
||||||
|
}
|
||||||
16
R/data.R
@@ -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!
|
||||||
|
|||||||
@@ -45,3 +45,96 @@ 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)
|
||||||
|
}
|
||||||
|
|||||||
11
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
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
545
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
|
||||||
#'
|
#'
|
||||||
@@ -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,35 @@ 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 <- strsplit(x, ", *")[[1]]
|
||||||
y <- character(0)
|
x_new <- character()
|
||||||
for (i in seq_len(length(x))) {
|
for (val in x) {
|
||||||
if (is.function(get(x[i]))) {
|
if (toupper(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 = toupper(val)), envir = asNamespace("AMR"))
|
||||||
|
} else if (toupper(val) %in% AB_lookup$ab) {
|
||||||
|
# separate drugs, such as `AMX`
|
||||||
|
val <- as.ab(val)
|
||||||
|
} else {
|
||||||
|
stop_("antimicrobial agent (group) not found in EUCAST rules file: ", val, call = FALSE)
|
||||||
}
|
}
|
||||||
y <- c(y, tryCatch(get(x[i]), error = function(e) ""))
|
x_new <- c(x_new, val)
|
||||||
}
|
}
|
||||||
y[y != "" & y %in% colnames(df)]
|
cols_ab[match(x_new, names(cols_ab))]
|
||||||
}
|
|
||||||
markup_italics_where_needed <- function(x) {
|
|
||||||
# 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 +419,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 +451,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 +507,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 +545,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 +569,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 +589,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 +597,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 +625,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 +656,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 +718,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 +746,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 +761,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 +776,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 +922,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 +952,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 +959,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 +975,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 +996,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 +1019,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]))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#' @param ab_class an antimicrobial class, like `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value.
|
#' @param ab_class an antimicrobial class, 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 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 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 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()]
|
#' @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.
|
#' @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
|
#' @rdname filter_ab_class
|
||||||
@@ -125,11 +125,11 @@ filter_ab_class <- function(x,
|
|||||||
group %like% ab_class |
|
group %like% ab_class |
|
||||||
atc_group1 %like% ab_class |
|
atc_group1 %like% ab_class |
|
||||||
atc_group2 %like% ab_class)
|
atc_group2 %like% ab_class)
|
||||||
ab_group <- find_ab_group(ab_class)
|
if (nrow(ab_reference) == 0) {
|
||||||
if (ab_group == "") {
|
|
||||||
message_("Unknown antimicrobial class '", ab_class.bak, "', data left unchanged.")
|
message_("Unknown antimicrobial class '", ab_class.bak, "', data left unchanged.")
|
||||||
return(x.bak)
|
return(x.bak)
|
||||||
}
|
}
|
||||||
|
ab_group <- find_ab_group(ab_class.bak)
|
||||||
# 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 (length(agents) == 0) {
|
if (length(agents) == 0) {
|
||||||
@@ -425,7 +425,7 @@ find_ab_group <- function(ab_class) {
|
|||||||
|
|
||||||
find_ab_names <- function(ab_group, n = 3) {
|
find_ab_names <- function(ab_group, n = 3) {
|
||||||
ab_group <- gsub("[^a-zA-Z0-9]", ".*", ab_group)
|
ab_group <- gsub("[^a-zA-Z0-9]", ".*", ab_group)
|
||||||
drugs <- antibiotics[which(antibiotics$group %like% ab_group & !antibiotics$ab %like% "[0-9]$"), ]$name
|
drugs <- antibiotics[which(antibiotics$group %like% ab_group & antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||||
paste0(sort(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE),
|
paste0(sort(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE),
|
||||||
tolower = TRUE, language = NULL)),
|
tolower = TRUE, language = NULL)),
|
||||||
collapse = ", ")
|
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
|
||||||
|
#' To conduct epidemiological analyses on antimicrobial resistance data, only so-called first isolates should be included to prevent overestimation and underestimation of antimicrobial resistance. Different methods can be used to do so, see below.
|
||||||
|
#'
|
||||||
#' These functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
#' These functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||||
#'
|
#'
|
||||||
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but more efficient for data sets containing microorganism codes or names.
|
#' 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,16 +251,23 @@ 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
|
||||||
@@ -214,6 +277,37 @@ first_isolate <- function(x = NULL,
|
|||||||
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 = "keyantibiotics")
|
||||||
|
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")
|
||||||
@@ -233,11 +327,6 @@ first_isolate <- function(x = NULL,
|
|||||||
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")
|
||||||
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ globalVariables(c(".rowid",
|
|||||||
"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,6 +102,7 @@ get_column_abx <- function(x,
|
|||||||
verbose = FALSE,
|
verbose = FALSE,
|
||||||
info = TRUE,
|
info = TRUE,
|
||||||
only_rsi_columns = FALSE,
|
only_rsi_columns = FALSE,
|
||||||
|
sort = TRUE,
|
||||||
...) {
|
...) {
|
||||||
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)
|
||||||
@@ -109,6 +110,7 @@ get_column_abx <- function(x,
|
|||||||
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)
|
||||||
@@ -186,11 +188,15 @@ get_column_abx <- function(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) {
|
||||||
|
|||||||
131
R/italicise_taxonomy.R
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
# ==================================================================== #
|
||||||
|
# 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:
|
||||||
|
#'
|
||||||
|
#' 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 then the `x` argument can be left blank, 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)
|
||||||
|
}
|
||||||
|
|||||||
151
R/mdro.R
@@ -34,7 +34,7 @@
|
|||||||
#' @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 then the `x` argument can be left blank, see *Examples*.
|
||||||
@@ -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'
|
||||||
@@ -729,14 +729,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, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
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
|
||||||
@@ -99,14 +99,14 @@ 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
|
||||||
tryCatch(colnames(x) <- as.character(dots)[2:length(dots)],
|
tryCatch(colnames(x) <- as.character(dots)[2:length(dots)],
|
||||||
error = function(e) warning("column names could not be set"))
|
error = function(e) warning("column names could not be set"))
|
||||||
|
|
||||||
# keep only numeric columns
|
# keep only [numeric] columns
|
||||||
x <- x[, vapply(FUN.VALUE = logical(1), x, function(y) is.numeric(y))]
|
x <- x[, vapply(FUN.VALUE = logical(1), x, function(y) is.numeric(y))]
|
||||||
# bind the data set with the non-numeric columns
|
# bind the data set with the non-numeric columns
|
||||||
x <- cbind(x.bak[, vapply(FUN.VALUE = logical(1), x.bak, function(y) !is.numeric(y) & !all(is.na(y))), drop = FALSE], x)
|
x <- cbind(x.bak[, vapply(FUN.VALUE = logical(1), x.bak, function(y) !is.numeric(y) & !all(is.na(y))), drop = FALSE], x)
|
||||||
|
|||||||
219
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.
|
||||||
#'
|
#'
|
||||||
@@ -93,6 +93,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 +150,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 +179,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 +226,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 +310,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 +368,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 +397,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 +444,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 +504,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 +576,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 +611,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 +619,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 +654,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).*
|
||||||
#'
|
#'
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -347,6 +347,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 +374,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)) +
|
||||||
|
|||||||
83
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()]
|
||||||
@@ -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, ...) {
|
||||||
@@ -259,13 +259,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 +546,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 +555,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 +694,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 +787,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 +934,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 +1026,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
@@ -157,11 +157,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 +172,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]))
|
||||||
|
|
||||||
|
|||||||
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)"), "]"))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ 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: >
|
||||||
@@ -154,7 +155,7 @@ reference:
|
|||||||
- "`count`"
|
- "`count`"
|
||||||
- "`is_new_episode`"
|
- "`is_new_episode`"
|
||||||
- "`first_isolate`"
|
- "`first_isolate`"
|
||||||
- "`key_antibiotics`"
|
- "`key_antimicrobials`"
|
||||||
- "`mdro`"
|
- "`mdro`"
|
||||||
- "`count`"
|
- "`count`"
|
||||||
- "`plot`"
|
- "`plot`"
|
||||||
@@ -176,6 +177,7 @@ reference:
|
|||||||
- "`availability`"
|
- "`availability`"
|
||||||
- "`get_locale`"
|
- "`get_locale`"
|
||||||
- "`ggplot_pca`"
|
- "`ggplot_pca`"
|
||||||
|
- "`italicise_taxonomy`"
|
||||||
- "`join`"
|
- "`join`"
|
||||||
- "`like`"
|
- "`like`"
|
||||||
- "`mo_matching_score`"
|
- "`mo_matching_score`"
|
||||||
|
|||||||
45
data-raw/_install_deps.R
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# ==================================================================== #
|
||||||
|
# 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/ #
|
||||||
|
# ==================================================================== #
|
||||||
|
|
||||||
|
pkg_suggests <- AMR:::trimws(unlist(strsplit(packageDescription("AMR")$Suggests, ",(\n)?")))
|
||||||
|
|
||||||
|
to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())]
|
||||||
|
to_update <- as.data.frame(utils::old.packages(repos = "https://cran.rstudio.com/"), stringsAsFactors = FALSE)
|
||||||
|
|
||||||
|
for (i in seq_len(length(to_install))) {
|
||||||
|
cat("Installing package", to_install[i], "\n")
|
||||||
|
tryCatch(install.packages(to_install[i], repos = "https://cran.rstudio.com/", dependencies = TRUE, quiet = TRUE),
|
||||||
|
# message = function(m) invisible(),
|
||||||
|
warning = function(w) message(w$message),
|
||||||
|
error = function(e) message(e$message))
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ antibiotic TRUE TRUE FALSE Antibiotikum antibioticum antibiótico
|
|||||||
Antibiotic TRUE TRUE FALSE Antibiotikum Antibioticum Antibiótico
|
Antibiotic TRUE TRUE FALSE Antibiotikum Antibioticum Antibiótico
|
||||||
Drug TRUE TRUE FALSE Medikament Middel Fármaco
|
Drug TRUE TRUE FALSE Medikament Middel Fármaco
|
||||||
drug TRUE TRUE FALSE Medikament middel fármaco
|
drug TRUE TRUE FALSE Medikament middel fármaco
|
||||||
|
Frequency FALSE TRUE FALSE Zahl Aantal
|
||||||
|
Minimum Inhibitory Concentration (mg/L) FALSE FALSE FALSE Minimale Hemm-Konzentration (mg/L) Minimale inhiberende concentratie (mg/L)
|
||||||
|
Disk diffusion diameter (mm) FALSE FALSE FALSE Durchmesser der Scheibenzone (mm) Diameter diskzone (mm)
|
||||||
|
Antimicrobial Interpretation FALSE FALSE FALSE Antimikrobielle Auswertung Antimicrobiële interpretatie
|
||||||
4-aminosalicylic acid FALSE TRUE FALSE 4-Aminosalicylsäure 4-aminosalicylzuur Ácido 4-aminosalicílico
|
4-aminosalicylic acid FALSE TRUE FALSE 4-Aminosalicylsäure 4-aminosalicylzuur Ácido 4-aminosalicílico
|
||||||
Adefovir dipivoxil FALSE TRUE FALSE Adefovir Dipivoxil Adefovir Adefovir dipivoxil
|
Adefovir dipivoxil FALSE TRUE FALSE Adefovir Dipivoxil Adefovir Adefovir dipivoxil
|
||||||
Aldesulfone sodium FALSE TRUE FALSE Aldesulfon-Natrium Aldesulfon Aldesulfona sódica
|
Aldesulfone sodium FALSE TRUE FALSE Aldesulfon-Natrium Aldesulfon Aldesulfona sódica
|
||||||
|
|||||||
|
@@ -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.6.0.9041</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.6.0.9041</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: 39 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 46 KiB |
@@ -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.6.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -47,14 +47,14 @@
|
|||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li>
|
<li>
|
||||||
<a href="../index.html">
|
<a href="../index.html">
|
||||||
<span class="fas fa-home"></span>
|
<span class="fa fa-home"></span>
|
||||||
|
|
||||||
Home
|
Home
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||||
<span class="fas fa-question-circle"></span>
|
<span class="fa fa-question-circle"></span>
|
||||||
|
|
||||||
How to
|
How to
|
||||||
|
|
||||||
@@ -63,77 +63,77 @@
|
|||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/AMR.html">
|
<a href="../articles/AMR.html">
|
||||||
<span class="fas fa-directions"></span>
|
<span class="fa fa-directions"></span>
|
||||||
|
|
||||||
Conduct AMR analysis
|
Conduct AMR analysis
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/resistance_predict.html">
|
<a href="../articles/resistance_predict.html">
|
||||||
<span class="fas fa-dice"></span>
|
<span class="fa fa-dice"></span>
|
||||||
|
|
||||||
Predict antimicrobial resistance
|
Predict antimicrobial resistance
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/datasets.html">
|
<a href="../articles/datasets.html">
|
||||||
<span class="fas fa-database"></span>
|
<span class="fa fa-database"></span>
|
||||||
|
|
||||||
Data sets for download / own use
|
Data sets for download / own use
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/PCA.html">
|
<a href="../articles/PCA.html">
|
||||||
<span class="fas fa-compress"></span>
|
<span class="fa fa-compress"></span>
|
||||||
|
|
||||||
Conduct principal component analysis for AMR
|
Conduct principal component analysis for AMR
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/MDR.html">
|
<a href="../articles/MDR.html">
|
||||||
<span class="fas fa-skull-crossbones"></span>
|
<span class="fa fa-skull-crossbones"></span>
|
||||||
|
|
||||||
Determine multi-drug resistance (MDR)
|
Determine multi-drug resistance (MDR)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/WHONET.html">
|
<a href="../articles/WHONET.html">
|
||||||
<span class="fas fa-globe-americas"></span>
|
<span class="fa fa-globe-americas"></span>
|
||||||
|
|
||||||
Work with WHONET data
|
Work with WHONET data
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/SPSS.html">
|
<a href="../articles/SPSS.html">
|
||||||
<span class="fas fa-file-upload"></span>
|
<span class="fa fa-file-upload"></span>
|
||||||
|
|
||||||
Import data from SPSS/SAS/Stata
|
Import data from SPSS/SAS/Stata
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/EUCAST.html">
|
<a href="../articles/EUCAST.html">
|
||||||
<span class="fas fa-exchange-alt"></span>
|
<span class="fa fa-exchange-alt"></span>
|
||||||
|
|
||||||
Apply EUCAST rules
|
Apply EUCAST rules
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/mo_property.html">
|
<a href="../reference/mo_property.html">
|
||||||
<span class="fas fa-bug"></span>
|
<span class="fa fa-bug"></span>
|
||||||
|
|
||||||
Get properties of a microorganism
|
Get properties of a microorganism
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/ab_property.html">
|
<a href="../reference/ab_property.html">
|
||||||
<span class="fas fa-capsules"></span>
|
<span class="fa fa-capsules"></span>
|
||||||
|
|
||||||
Get properties of an antibiotic
|
Get properties of an antibiotic
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/benchmarks.html">
|
<a href="../articles/benchmarks.html">
|
||||||
<span class="fas fa-shipping-fast"></span>
|
<span class="fa fa-shipping-fast"></span>
|
||||||
|
|
||||||
Other: benchmarks
|
Other: benchmarks
|
||||||
</a>
|
</a>
|
||||||
@@ -142,21 +142,21 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/index.html">
|
<a href="../reference/index.html">
|
||||||
<span class="fas fa-book-open"></span>
|
<span class="fa fa-book-open"></span>
|
||||||
|
|
||||||
Manual
|
Manual
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../authors.html">
|
<a href="../authors.html">
|
||||||
<span class="fas fa-users"></span>
|
<span class="fa fa-users"></span>
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../news/index.html">
|
<a href="../news/index.html">
|
||||||
<span class="far fa-newspaper"></span>
|
<span class="far fa far fa-newspaper"></span>
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
</a>
|
</a>
|
||||||
@@ -165,14 +165,14 @@
|
|||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/msberends/AMR">
|
<a href="https://github.com/msberends/AMR">
|
||||||
<span class="fab fa-github"></span>
|
<span class="fab fa fab fa-github"></span>
|
||||||
|
|
||||||
Source Code
|
Source Code
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../survey.html">
|
<a href="../survey.html">
|
||||||
<span class="fas fa-clipboard-list"></span>
|
<span class="fa fa-clipboard-list"></span>
|
||||||
|
|
||||||
Survey
|
Survey
|
||||||
</a>
|
</a>
|
||||||
@@ -187,7 +187,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="EUCAST_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
</header><link href="EUCAST_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||||
|
<script src="EUCAST_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||||
<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>
|
||||||
@@ -215,8 +216,8 @@
|
|||||||
<a href="#examples" class="anchor"></a>Examples</h2>
|
<a href="#examples" class="anchor"></a>Examples</h2>
|
||||||
<p>These rules can be used to discard impossible bug-drug combinations in your data. For example, <em>Klebsiella</em> produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of <em>Klebsiella</em> is resistant to ampicillin.</p>
|
<p>These rules can be used to discard impossible bug-drug combinations in your data. For example, <em>Klebsiella</em> produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of <em>Klebsiella</em> is resistant to ampicillin.</p>
|
||||||
<p>Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, <em>Klebsiella</em>). EUCAST expert rules solve this, that can be applied using <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:</p>
|
<p>Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, <em>Klebsiella</em>). EUCAST expert rules solve this, that can be applied using <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:</p>
|
||||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">oops</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
<span class="va">oops</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
||||||
<span class="st">"Escherichia"</span><span class="op">)</span>,
|
<span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||||
ampicillin <span class="op">=</span> <span class="st">"S"</span><span class="op">)</span>
|
ampicillin <span class="op">=</span> <span class="st">"S"</span><span class="op">)</span>
|
||||||
<span class="va">oops</span>
|
<span class="va">oops</span>
|
||||||
@@ -227,19 +228,19 @@
|
|||||||
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">oops</span>, info <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">oops</span>, info <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
|
||||||
<span class="co"># mo ampicillin</span>
|
<span class="co"># mo ampicillin</span>
|
||||||
<span class="co"># 1 Klebsiella R</span>
|
<span class="co"># 1 Klebsiella R</span>
|
||||||
<span class="co"># 2 Escherichia S</span></code></pre></div>
|
<span class="co"># 2 Escherichia S</span></pre></div>
|
||||||
<p>A more convenient function is <code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> that uses the same guideline, but allows to check for one or more specific microorganisms or antibiotics:</p>
|
<p>A more convenient function is <code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> that uses the same guideline, but allows to check for one or more specific microorganisms or antibiotics:</p>
|
||||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>, <span class="st">"Escherichia"</span><span class="op">)</span>,
|
<span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>, <span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||||
<span class="st">"ampicillin"</span><span class="op">)</span>
|
<span class="st">"ampicillin"</span><span class="op">)</span>
|
||||||
<span class="co"># [1] TRUE FALSE</span>
|
<span class="co"># [1] TRUE FALSE</span>
|
||||||
|
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
<span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
||||||
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"ampicillin"</span>, <span class="st">"kanamycin"</span><span class="op">)</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"ampicillin"</span>, <span class="st">"kanamycin"</span><span class="op">)</span><span class="op">)</span>
|
||||||
<span class="co"># [1] TRUE FALSE</span></code></pre></div>
|
<span class="co"># [1] TRUE FALSE</span></pre></div>
|
||||||
<p>EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called <em>interpretive reading</em>, is basically a form of imputation, and is part of the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function as well:</p>
|
<p>EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called <em>interpretive reading</em>, is basically a form of imputation, and is part of the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function as well:</p>
|
||||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Staphylococcus aureus"</span>,
|
<span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Staphylococcus aureus"</span>,
|
||||||
<span class="st">"Enterococcus faecalis"</span>,
|
<span class="st">"Enterococcus faecalis"</span>,
|
||||||
<span class="st">"Escherichia coli"</span>,
|
<span class="st">"Escherichia coli"</span>,
|
||||||
<span class="st">"Klebsiella pneumoniae"</span>,
|
<span class="st">"Klebsiella pneumoniae"</span>,
|
||||||
@@ -251,9 +252,9 @@
|
|||||||
CXM <span class="op">=</span> <span class="st">"-"</span>, <span class="co"># Cefuroxime</span>
|
CXM <span class="op">=</span> <span class="st">"-"</span>, <span class="co"># Cefuroxime</span>
|
||||||
PEN <span class="op">=</span> <span class="st">"S"</span>, <span class="co"># Benzylenicillin</span>
|
PEN <span class="op">=</span> <span class="st">"S"</span>, <span class="co"># Benzylenicillin</span>
|
||||||
FOX <span class="op">=</span> <span class="st">"S"</span>, <span class="co"># Cefoxitin</span>
|
FOX <span class="op">=</span> <span class="st">"S"</span>, <span class="co"># Cefoxitin</span>
|
||||||
stringsAsFactors <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
stringsAsFactors <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
|
||||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">data</span></code></pre></div>
|
<span class="va">data</span></pre></div>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead><tr class="header">
|
<thead><tr class="header">
|
||||||
<th align="left">mo</th>
|
<th align="left">mo</th>
|
||||||
@@ -318,8 +319,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span></pre></div>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead><tr class="header">
|
<thead><tr class="header">
|
||||||
<th align="left">mo</th>
|
<th align="left">mo</th>
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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.6.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -47,14 +47,14 @@
|
|||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li>
|
<li>
|
||||||
<a href="../index.html">
|
<a href="../index.html">
|
||||||
<span class="fas fa-home"></span>
|
<span class="fa fa-home"></span>
|
||||||
|
|
||||||
Home
|
Home
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||||
<span class="fas fa-question-circle"></span>
|
<span class="fa fa-question-circle"></span>
|
||||||
|
|
||||||
How to
|
How to
|
||||||
|
|
||||||
@@ -63,77 +63,77 @@
|
|||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/AMR.html">
|
<a href="../articles/AMR.html">
|
||||||
<span class="fas fa-directions"></span>
|
<span class="fa fa-directions"></span>
|
||||||
|
|
||||||
Conduct AMR analysis
|
Conduct AMR analysis
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/resistance_predict.html">
|
<a href="../articles/resistance_predict.html">
|
||||||
<span class="fas fa-dice"></span>
|
<span class="fa fa-dice"></span>
|
||||||
|
|
||||||
Predict antimicrobial resistance
|
Predict antimicrobial resistance
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/datasets.html">
|
<a href="../articles/datasets.html">
|
||||||
<span class="fas fa-database"></span>
|
<span class="fa fa-database"></span>
|
||||||
|
|
||||||
Data sets for download / own use
|
Data sets for download / own use
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/PCA.html">
|
<a href="../articles/PCA.html">
|
||||||
<span class="fas fa-compress"></span>
|
<span class="fa fa-compress"></span>
|
||||||
|
|
||||||
Conduct principal component analysis for AMR
|
Conduct principal component analysis for AMR
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/MDR.html">
|
<a href="../articles/MDR.html">
|
||||||
<span class="fas fa-skull-crossbones"></span>
|
<span class="fa fa-skull-crossbones"></span>
|
||||||
|
|
||||||
Determine multi-drug resistance (MDR)
|
Determine multi-drug resistance (MDR)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/WHONET.html">
|
<a href="../articles/WHONET.html">
|
||||||
<span class="fas fa-globe-americas"></span>
|
<span class="fa fa-globe-americas"></span>
|
||||||
|
|
||||||
Work with WHONET data
|
Work with WHONET data
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/SPSS.html">
|
<a href="../articles/SPSS.html">
|
||||||
<span class="fas fa-file-upload"></span>
|
<span class="fa fa-file-upload"></span>
|
||||||
|
|
||||||
Import data from SPSS/SAS/Stata
|
Import data from SPSS/SAS/Stata
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/EUCAST.html">
|
<a href="../articles/EUCAST.html">
|
||||||
<span class="fas fa-exchange-alt"></span>
|
<span class="fa fa-exchange-alt"></span>
|
||||||
|
|
||||||
Apply EUCAST rules
|
Apply EUCAST rules
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/mo_property.html">
|
<a href="../reference/mo_property.html">
|
||||||
<span class="fas fa-bug"></span>
|
<span class="fa fa-bug"></span>
|
||||||
|
|
||||||
Get properties of a microorganism
|
Get properties of a microorganism
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/ab_property.html">
|
<a href="../reference/ab_property.html">
|
||||||
<span class="fas fa-capsules"></span>
|
<span class="fa fa-capsules"></span>
|
||||||
|
|
||||||
Get properties of an antibiotic
|
Get properties of an antibiotic
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/benchmarks.html">
|
<a href="../articles/benchmarks.html">
|
||||||
<span class="fas fa-shipping-fast"></span>
|
<span class="fa fa-shipping-fast"></span>
|
||||||
|
|
||||||
Other: benchmarks
|
Other: benchmarks
|
||||||
</a>
|
</a>
|
||||||
@@ -142,21 +142,21 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/index.html">
|
<a href="../reference/index.html">
|
||||||
<span class="fas fa-book-open"></span>
|
<span class="fa fa-book-open"></span>
|
||||||
|
|
||||||
Manual
|
Manual
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../authors.html">
|
<a href="../authors.html">
|
||||||
<span class="fas fa-users"></span>
|
<span class="fa fa-users"></span>
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../news/index.html">
|
<a href="../news/index.html">
|
||||||
<span class="far fa-newspaper"></span>
|
<span class="far fa far fa-newspaper"></span>
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
</a>
|
</a>
|
||||||
@@ -165,14 +165,14 @@
|
|||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/msberends/AMR">
|
<a href="https://github.com/msberends/AMR">
|
||||||
<span class="fab fa-github"></span>
|
<span class="fab fa fab fa-github"></span>
|
||||||
|
|
||||||
Source Code
|
Source Code
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../survey.html">
|
<a href="../survey.html">
|
||||||
<span class="fas fa-clipboard-list"></span>
|
<span class="fa fa-clipboard-list"></span>
|
||||||
|
|
||||||
Survey
|
Survey
|
||||||
</a>
|
</a>
|
||||||
@@ -187,7 +187,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="MDR_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
</header><link href="MDR_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||||
|
<script src="MDR_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||||
<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>
|
||||||
@@ -243,27 +244,27 @@
|
|||||||
<a href="#custom-guidelines" class="anchor"></a>Custom Guidelines</h4>
|
<a href="#custom-guidelines" class="anchor"></a>Custom Guidelines</h4>
|
||||||
<p>You can also use your own custom guideline. Custom guidelines can be set with the <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data.</p>
|
<p>You can also use your own custom guideline. Custom guidelines can be set with the <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data.</p>
|
||||||
<p>If you are familiar with <code><a href="https://dplyr.tidyverse.org/reference/case_when.html">case_when()</a></code> of the <code>dplyr</code> package, you will recognise the input method to set your own rules. Rules must be set using what considers to be the ‘formula notation’:</p>
|
<p>If you are familiar with <code><a href="https://dplyr.tidyverse.org/reference/case_when.html">case_when()</a></code> of the <code>dplyr</code> package, you will recognise the input method to set your own rules. Rules must be set using what considers to be the ‘formula notation’:</p>
|
||||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">custom</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">custom_mdro_guideline</a></span><span class="op">(</span><span class="va">CIP</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type A"</span>,
|
<span class="va">custom</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">custom_mdro_guideline</a></span><span class="op">(</span><span class="va">CIP</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type A"</span>,
|
||||||
<span class="va">ERY</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type B"</span><span class="op">)</span></code></pre></div>
|
<span class="va">ERY</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type B"</span><span class="op">)</span></pre></div>
|
||||||
<p>If a row/an isolate matches the first rule, the value after the first <code><a href="https://rdrr.io/r/base/tilde.html">~</a></code> (in this case <em>‘Elderly Type A’</em>) will be set as MDRO value. Otherwise, the second rule will be tried and so on. The number of rules is unlimited.</p>
|
<p>If a row/an isolate matches the first rule, the value after the first <code><a href="https://rdrr.io/r/base/tilde.html">~</a></code> (in this case <em>‘Elderly Type A’</em>) will be set as MDRO value. Otherwise, the second rule will be tried and so on. The number of rules is unlimited.</p>
|
||||||
<p>You can print the rules set in the console for an overview. Colours will help reading it if your console supports colours.</p>
|
<p>You can print the rules set in the console for an overview. Colours will help reading it if your console supports colours.</p>
|
||||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">custom</span>
|
<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></pre></div>
|
||||||
<p>The outcome of the function can be used for the <code>guideline</code> argument in the [mdro()] function:</p>
|
<p>The outcome of the function can be used for the <code>guideline</code> argument in the [mdro()] function:</p>
|
||||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">example_isolates</span>, guideline <span class="op">=</span> <span class="va">custom</span><span class="op">)</span>
|
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">example_isolates</span>, guideline <span class="op">=</span> <span class="va">custom</span><span class="op">)</span>
|
||||||
<span class="fu"><a href="https://rdrr.io/r/base/table.html">table</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
<span class="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></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>
|
||||||
@@ -272,15 +273,15 @@
|
|||||||
<a href="#examples" class="anchor"></a>Examples</h3>
|
<a href="#examples" class="anchor"></a>Examples</h3>
|
||||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function always returns an ordered <code>factor</code>. For example, the output of the default guideline by Magiorakos <em>et al.</em> returns a <code>factor</code> with levels ‘Negative’, ‘MDR’, ‘XDR’ or ‘PDR’ in that order.</p>
|
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function always returns an ordered <code>factor</code>. For example, the output of the default guideline by Magiorakos <em>et al.</em> returns a <code>factor</code> with levels ‘Negative’, ‘MDR’, ‘XDR’ or ‘PDR’ in that order.</p>
|
||||||
<p>The next example uses the <code>example_isolates</code> data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR data analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:</p>
|
<p>The next example uses the <code>example_isolates</code> data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR data analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:</p>
|
||||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># to support pipes: %>%</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># to support pipes: %>%</span>
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></code></pre></div>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></pre></div>
|
||||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">example_isolates</span> <span class="op">%>%</span>
|
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="op">)</span> <span class="co"># show frequency table of the result</span>
|
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="op">)</span> <span class="co"># show frequency table of the result</span>
|
||||||
<span class="co"># Warning: NA introduced for isolates where the available percentage of antimicrobial</span>
|
<span class="co"># Warning: NA introduced for isolates where the available percentage of antimicrobial</span>
|
||||||
<span class="co"># classes was below 50% (set with `pct_required_classes`)</span></code></pre></div>
|
<span class="co"># classes was below 50% (set with `pct_required_classes`)</span></pre></div>
|
||||||
<p><strong>Frequency table</strong></p>
|
<p><strong>Frequency table</strong></p>
|
||||||
<p>Class: factor > ordered (numeric)<br>
|
<p>Class: factor > ordered (numeric)<br>
|
||||||
Length: 2,000<br>
|
Length: 2,000<br>
|
||||||
@@ -316,8 +317,8 @@ Unique: 2</p>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>For another example, I will create a data set to determine multi-drug resistant TB:</p>
|
<p>For another example, I will create a data set to determine multi-drug resistant TB:</p>
|
||||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># random_rsi() is a helper function to generate</span>
|
<span class="co"># random_rsi() is a helper function to generate</span>
|
||||||
<span class="co"># a random vector with values S, I and R</span>
|
<span class="co"># a random vector with values S, I and R</span>
|
||||||
<span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>rifampicin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
<span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>rifampicin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
isoniazid <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
isoniazid <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
@@ -325,44 +326,44 @@ Unique: 2</p>
|
|||||||
ethambutol <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
ethambutol <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
pyrazinamide <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
pyrazinamide <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
moxifloxacin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
moxifloxacin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
kanamycin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></code></pre></div>
|
kanamycin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></pre></div>
|
||||||
<p>Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same:</p>
|
<p>Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same:</p>
|
||||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>RIF <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
<span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>RIF <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
INH <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
INH <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
GAT <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
GAT <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
ETH <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
ETH <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
PZA <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
PZA <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
MFX <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
MFX <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||||
KAN <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></code></pre></div>
|
KAN <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></pre></div>
|
||||||
<p>The data set now looks like this:</p>
|
<p>The data set now looks like this:</p>
|
||||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||||
<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="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 S S S S R R</span>
|
||||||
<span class="co"># 2 S I R R R R</span>
|
<span class="co"># 2 R S S S I R</span>
|
||||||
<span class="co"># 3 R S S I S I</span>
|
<span class="co"># 3 R R I R I R</span>
|
||||||
<span class="co"># 4 I S S S I S</span>
|
<span class="co"># 4 R R S S R I</span>
|
||||||
<span class="co"># 5 I I I S I R</span>
|
<span class="co"># 5 R R R I I I</span>
|
||||||
<span class="co"># 6 S I S R S S</span>
|
<span class="co"># 6 R I 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 R</span>
|
||||||
<span class="co"># 3 R</span>
|
<span class="co"># 3 I</span>
|
||||||
<span class="co"># 4 S</span>
|
<span class="co"># 4 I</span>
|
||||||
<span class="co"># 5 S</span>
|
<span class="co"># 5 S</span>
|
||||||
<span class="co"># 6 R</span></code></pre></div>
|
<span class="co"># 6 I</span></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">
|
||||||
<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>
|
<span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">my_TB_data</span>, guideline <span class="op">=</span> <span class="st">"TB"</span><span class="op">)</span></pre></div>
|
||||||
<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">
|
||||||
<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="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 records</span>
|
||||||
<span class="co"># containMycobacterium tuberculosis.</span></code></pre></div>
|
<span class="co"># containMycobacterium tuberculosis.</span></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">
|
||||||
<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>
|
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span><span class="op">)</span></pre></div>
|
||||||
<p><strong>Frequency table</strong></p>
|
<p><strong>Frequency table</strong></p>
|
||||||
<p>Class: factor > ordered (numeric)<br>
|
<p>Class: factor > ordered (numeric)<br>
|
||||||
Length: 5,000<br>
|
Length: 5,000<br>
|
||||||
@@ -382,40 +383,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">3165</td>
|
||||||
<td align="right">64.92%</td>
|
<td align="right">63.30%</td>
|
||||||
<td align="right">3246</td>
|
<td align="right">3165</td>
|
||||||
<td align="right">64.92%</td>
|
<td align="right">63.30%</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">1000</td>
|
||||||
<td align="right">19.52%</td>
|
<td align="right">20.00%</td>
|
||||||
<td align="right">4222</td>
|
<td align="right">4165</td>
|
||||||
<td align="right">84.44%</td>
|
<td align="right">83.30%</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">463</td>
|
||||||
<td align="right">9.34%</td>
|
<td align="right">9.26%</td>
|
||||||
<td align="right">4689</td>
|
<td align="right">4628</td>
|
||||||
<td align="right">93.78%</td>
|
<td align="right">92.56%</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">255</td>
|
||||||
<td align="right">4.60%</td>
|
<td align="right">5.10%</td>
|
||||||
<td align="right">4919</td>
|
<td align="right">4883</td>
|
||||||
<td align="right">98.38%</td>
|
<td align="right">97.66%</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">117</td>
|
||||||
<td align="right">1.62%</td>
|
<td align="right">2.34%</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);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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.6.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -47,14 +47,14 @@
|
|||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li>
|
<li>
|
||||||
<a href="../index.html">
|
<a href="../index.html">
|
||||||
<span class="fas fa-home"></span>
|
<span class="fa fa-home"></span>
|
||||||
|
|
||||||
Home
|
Home
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||||
<span class="fas fa-question-circle"></span>
|
<span class="fa fa-question-circle"></span>
|
||||||
|
|
||||||
How to
|
How to
|
||||||
|
|
||||||
@@ -63,77 +63,77 @@
|
|||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/AMR.html">
|
<a href="../articles/AMR.html">
|
||||||
<span class="fas fa-directions"></span>
|
<span class="fa fa-directions"></span>
|
||||||
|
|
||||||
Conduct AMR analysis
|
Conduct AMR analysis
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/resistance_predict.html">
|
<a href="../articles/resistance_predict.html">
|
||||||
<span class="fas fa-dice"></span>
|
<span class="fa fa-dice"></span>
|
||||||
|
|
||||||
Predict antimicrobial resistance
|
Predict antimicrobial resistance
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/datasets.html">
|
<a href="../articles/datasets.html">
|
||||||
<span class="fas fa-database"></span>
|
<span class="fa fa-database"></span>
|
||||||
|
|
||||||
Data sets for download / own use
|
Data sets for download / own use
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/PCA.html">
|
<a href="../articles/PCA.html">
|
||||||
<span class="fas fa-compress"></span>
|
<span class="fa fa-compress"></span>
|
||||||
|
|
||||||
Conduct principal component analysis for AMR
|
Conduct principal component analysis for AMR
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/MDR.html">
|
<a href="../articles/MDR.html">
|
||||||
<span class="fas fa-skull-crossbones"></span>
|
<span class="fa fa-skull-crossbones"></span>
|
||||||
|
|
||||||
Determine multi-drug resistance (MDR)
|
Determine multi-drug resistance (MDR)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/WHONET.html">
|
<a href="../articles/WHONET.html">
|
||||||
<span class="fas fa-globe-americas"></span>
|
<span class="fa fa-globe-americas"></span>
|
||||||
|
|
||||||
Work with WHONET data
|
Work with WHONET data
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/SPSS.html">
|
<a href="../articles/SPSS.html">
|
||||||
<span class="fas fa-file-upload"></span>
|
<span class="fa fa-file-upload"></span>
|
||||||
|
|
||||||
Import data from SPSS/SAS/Stata
|
Import data from SPSS/SAS/Stata
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/EUCAST.html">
|
<a href="../articles/EUCAST.html">
|
||||||
<span class="fas fa-exchange-alt"></span>
|
<span class="fa fa-exchange-alt"></span>
|
||||||
|
|
||||||
Apply EUCAST rules
|
Apply EUCAST rules
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/mo_property.html">
|
<a href="../reference/mo_property.html">
|
||||||
<span class="fas fa-bug"></span>
|
<span class="fa fa-bug"></span>
|
||||||
|
|
||||||
Get properties of a microorganism
|
Get properties of a microorganism
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/ab_property.html">
|
<a href="../reference/ab_property.html">
|
||||||
<span class="fas fa-capsules"></span>
|
<span class="fa fa-capsules"></span>
|
||||||
|
|
||||||
Get properties of an antibiotic
|
Get properties of an antibiotic
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/benchmarks.html">
|
<a href="../articles/benchmarks.html">
|
||||||
<span class="fas fa-shipping-fast"></span>
|
<span class="fa fa-shipping-fast"></span>
|
||||||
|
|
||||||
Other: benchmarks
|
Other: benchmarks
|
||||||
</a>
|
</a>
|
||||||
@@ -142,21 +142,21 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/index.html">
|
<a href="../reference/index.html">
|
||||||
<span class="fas fa-book-open"></span>
|
<span class="fa fa-book-open"></span>
|
||||||
|
|
||||||
Manual
|
Manual
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../authors.html">
|
<a href="../authors.html">
|
||||||
<span class="fas fa-users"></span>
|
<span class="fa fa-users"></span>
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../news/index.html">
|
<a href="../news/index.html">
|
||||||
<span class="far fa-newspaper"></span>
|
<span class="far fa far fa-newspaper"></span>
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
</a>
|
</a>
|
||||||
@@ -165,14 +165,14 @@
|
|||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/msberends/AMR">
|
<a href="https://github.com/msberends/AMR">
|
||||||
<span class="fab fa-github"></span>
|
<span class="fab fa fab fa-github"></span>
|
||||||
|
|
||||||
Source Code
|
Source Code
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../survey.html">
|
<a href="../survey.html">
|
||||||
<span class="fas fa-clipboard-list"></span>
|
<span class="fa fa-clipboard-list"></span>
|
||||||
|
|
||||||
Survey
|
Survey
|
||||||
</a>
|
</a>
|
||||||
@@ -187,7 +187,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="PCA_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
</header><link href="PCA_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||||
|
<script src="PCA_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||||
<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>
|
||||||
@@ -209,8 +210,8 @@
|
|||||||
<h1 class="hasAnchor">
|
<h1 class="hasAnchor">
|
||||||
<a href="#transforming" class="anchor"></a>Transforming</h1>
|
<a href="#transforming" class="anchor"></a>Transforming</h1>
|
||||||
<p>For PCA, we need to transform our AMR data first. This is what the <code>example_isolates</code> data set in this package looks like:</p>
|
<p>For PCA, we need to transform our AMR data first. This is what the <code>example_isolates</code> data set in this package looks like:</p>
|
||||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||||
<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://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://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="co"># Rows: 2,000</span>
|
<span class="co"># Rows: 2,000</span>
|
||||||
@@ -263,10 +264,10 @@
|
|||||||
<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, N…</span>
|
||||||
<span class="co"># $ COL <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, …</span>
|
<span class="co"># $ COL <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, …</span>
|
||||||
<span class="co"># $ MUP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
<span class="co"># $ MUP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||||
<span class="co"># $ RIF <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span></code></pre></div>
|
<span class="co"># $ RIF <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span></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">
|
||||||
<code class="sourceCode R"><span class="va">resistance_data</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span>
|
<span class="va">resistance_data</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span>order <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, <span class="co"># group on anything, like order</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span>order <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, <span class="co"># group on anything, like order</span>
|
||||||
genus <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span> <span class="co"># and genus as we do here</span>
|
genus <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span> <span class="co"># and genus as we do here</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise_all.html">summarise_if</a></span><span class="op">(</span><span class="va">is.rsi</span>, <span class="va">resistance</span><span class="op">)</span> <span class="op">%>%</span> <span class="co"># then get resistance of all drugs</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise_all.html">summarise_if</a></span><span class="op">(</span><span class="va">is.rsi</span>, <span class="va">resistance</span><span class="op">)</span> <span class="op">%>%</span> <span class="co"># then get resistance of all drugs</span>
|
||||||
@@ -275,48 +276,52 @@
|
|||||||
|
|
||||||
<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></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">
|
||||||
<a href="#perform-principal-component-analysis" class="anchor"></a>Perform principal component analysis</h1>
|
<a href="#perform-principal-component-analysis" class="anchor"></a>Perform principal component analysis</h1>
|
||||||
<p>The new <code><a href="../reference/pca.html">pca()</a></code> function will automatically filter on rows that contain numeric values in all selected variables, so we now only need to do:</p>
|
<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">
|
||||||
<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="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></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">
|
||||||
<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="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></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">
|
||||||
<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>
|
<span class="fu"><a href="https://rdrr.io/r/stats/biplot.html">biplot</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></pre></div>
|
||||||
<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">
|
||||||
<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>
|
<span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></pre></div>
|
||||||
<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">
|
||||||
<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"><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></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>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 91 KiB |
@@ -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.9014</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -47,14 +47,14 @@
|
|||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li>
|
<li>
|
||||||
<a href="../index.html">
|
<a href="../index.html">
|
||||||
<span class="fas fa-home"></span>
|
<span class="fa fa-home"></span>
|
||||||
|
|
||||||
Home
|
Home
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||||
<span class="fas fa-question-circle"></span>
|
<span class="fa fa-question-circle"></span>
|
||||||
|
|
||||||
How to
|
How to
|
||||||
|
|
||||||
@@ -63,77 +63,77 @@
|
|||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/AMR.html">
|
<a href="../articles/AMR.html">
|
||||||
<span class="fas fa-directions"></span>
|
<span class="fa fa-directions"></span>
|
||||||
|
|
||||||
Conduct AMR analysis
|
Conduct AMR analysis
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/resistance_predict.html">
|
<a href="../articles/resistance_predict.html">
|
||||||
<span class="fas fa-dice"></span>
|
<span class="fa fa-dice"></span>
|
||||||
|
|
||||||
Predict antimicrobial resistance
|
Predict antimicrobial resistance
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/datasets.html">
|
<a href="../articles/datasets.html">
|
||||||
<span class="fas fa-database"></span>
|
<span class="fa fa-database"></span>
|
||||||
|
|
||||||
Data sets for download / own use
|
Data sets for download / own use
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/PCA.html">
|
<a href="../articles/PCA.html">
|
||||||
<span class="fas fa-compress"></span>
|
<span class="fa fa-compress"></span>
|
||||||
|
|
||||||
Conduct principal component analysis for AMR
|
Conduct principal component analysis for AMR
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/MDR.html">
|
<a href="../articles/MDR.html">
|
||||||
<span class="fas fa-skull-crossbones"></span>
|
<span class="fa fa-skull-crossbones"></span>
|
||||||
|
|
||||||
Determine multi-drug resistance (MDR)
|
Determine multi-drug resistance (MDR)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/WHONET.html">
|
<a href="../articles/WHONET.html">
|
||||||
<span class="fas fa-globe-americas"></span>
|
<span class="fa fa-globe-americas"></span>
|
||||||
|
|
||||||
Work with WHONET data
|
Work with WHONET data
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/SPSS.html">
|
<a href="../articles/SPSS.html">
|
||||||
<span class="fas fa-file-upload"></span>
|
<span class="fa fa-file-upload"></span>
|
||||||
|
|
||||||
Import data from SPSS/SAS/Stata
|
Import data from SPSS/SAS/Stata
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/EUCAST.html">
|
<a href="../articles/EUCAST.html">
|
||||||
<span class="fas fa-exchange-alt"></span>
|
<span class="fa fa-exchange-alt"></span>
|
||||||
|
|
||||||
Apply EUCAST rules
|
Apply EUCAST rules
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/mo_property.html">
|
<a href="../reference/mo_property.html">
|
||||||
<span class="fas fa-bug"></span>
|
<span class="fa fa-bug"></span>
|
||||||
|
|
||||||
Get properties of a microorganism
|
Get properties of a microorganism
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/ab_property.html">
|
<a href="../reference/ab_property.html">
|
||||||
<span class="fas fa-capsules"></span>
|
<span class="fa fa-capsules"></span>
|
||||||
|
|
||||||
Get properties of an antibiotic
|
Get properties of an antibiotic
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/benchmarks.html">
|
<a href="../articles/benchmarks.html">
|
||||||
<span class="fas fa-shipping-fast"></span>
|
<span class="fa fa-shipping-fast"></span>
|
||||||
|
|
||||||
Other: benchmarks
|
Other: benchmarks
|
||||||
</a>
|
</a>
|
||||||
@@ -142,21 +142,21 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/index.html">
|
<a href="../reference/index.html">
|
||||||
<span class="fas fa-book-open"></span>
|
<span class="fa fa-book-open"></span>
|
||||||
|
|
||||||
Manual
|
Manual
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../authors.html">
|
<a href="../authors.html">
|
||||||
<span class="fas fa-users"></span>
|
<span class="fa fa-users"></span>
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../news/index.html">
|
<a href="../news/index.html">
|
||||||
<span class="far fa-newspaper"></span>
|
<span class="far fa far fa-newspaper"></span>
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
</a>
|
</a>
|
||||||
@@ -165,14 +165,14 @@
|
|||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/msberends/AMR">
|
<a href="https://github.com/msberends/AMR">
|
||||||
<span class="fab fa-github"></span>
|
<span class="fab fa fab fa-github"></span>
|
||||||
|
|
||||||
Source Code
|
Source Code
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../survey.html">
|
<a href="../survey.html">
|
||||||
<span class="fas fa-clipboard-list"></span>
|
<span class="fa fa-clipboard-list"></span>
|
||||||
|
|
||||||
Survey
|
Survey
|
||||||
</a>
|
</a>
|
||||||
@@ -187,13 +187,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="SPSS_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
</header><link href="SPSS_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||||
|
<script src="SPSS_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||||
<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 import data from SPSS / SAS / Stata</h1>
|
<h1 data-toc-skip>How to import data from SPSS / SAS / Stata</h1>
|
||||||
<h4 class="author">Matthijs S. Berends</h4>
|
<h4 class="author">Matthijs S. Berends</h4>
|
||||||
|
|
||||||
<h4 class="date">02 February 2021</h4>
|
<h4 class="date">27 April 2021</h4>
|
||||||
|
|
||||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/SPSS.Rmd"><code>vignettes/SPSS.Rmd</code></a></small>
|
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/SPSS.Rmd"><code>vignettes/SPSS.Rmd</code></a></small>
|
||||||
<div class="hidden name"><code>SPSS.Rmd</code></div>
|
<div class="hidden name"><code>SPSS.Rmd</code></div>
|
||||||
@@ -228,7 +229,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p><strong>R has a huge community.</strong></p>
|
<p><strong>R has a huge community.</strong></p>
|
||||||
<p>Many R users just ask questions on websites like <a href="https://stackoverflow.com">StackOverflow.com</a>, the largest online community for programmers. At the time of writing, <a href="https://stackoverflow.com/questions/tagged/r?sort=votes">385,525 R-related questions</a> have already been asked on this platform (that covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.</p>
|
<p>Many R users just ask questions on websites like <a href="https://stackoverflow.com">StackOverflow.com</a>, the largest online community for programmers. At the time of writing, <a href="https://stackoverflow.com/questions/tagged/r?sort=votes">398,952 R-related questions</a> have already been asked on this platform (that covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p><strong>R understands any data type, including SPSS/SAS/Stata.</strong></p>
|
<p><strong>R understands any data type, including SPSS/SAS/Stata.</strong></p>
|
||||||
@@ -247,8 +248,8 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>To demonstrate the first point:</p>
|
<p>To demonstrate the first point:</p>
|
||||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># not all values are valid MIC values:</span>
|
<span class="co"># not all values are valid MIC values:</span>
|
||||||
<span class="fu"><a href="../reference/as.mic.html">as.mic</a></span><span class="op">(</span><span class="fl">0.125</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/as.mic.html">as.mic</a></span><span class="op">(</span><span class="fl">0.125</span><span class="op">)</span>
|
||||||
<span class="co"># Class <mic></span>
|
<span class="co"># Class <mic></span>
|
||||||
<span class="co"># [1] 0.125</span>
|
<span class="co"># [1] 0.125</span>
|
||||||
@@ -279,7 +280,7 @@
|
|||||||
<span class="co"># [4] "fluclox" "flucloxacilina" "flucloxacillin" </span>
|
<span class="co"># [4] "fluclox" "flucloxacilina" "flucloxacillin" </span>
|
||||||
<span class="co"># [7] "flucloxacilline" "flucloxacillinum" "fluorochloroxacillin"</span>
|
<span class="co"># [7] "flucloxacilline" "flucloxacillinum" "fluorochloroxacillin"</span>
|
||||||
<span class="fu"><a href="../reference/ab_property.html">ab_atc</a></span><span class="op">(</span><span class="st">"floxapen"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/ab_property.html">ab_atc</a></span><span class="op">(</span><span class="st">"floxapen"</span><span class="op">)</span>
|
||||||
<span class="co"># [1] "J01CF05"</span></code></pre></div>
|
<span class="co"># [1] "J01CF05"</span></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="import-data-from-spsssasstata" class="section level2">
|
<div id="import-data-from-spsssasstata" class="section level2">
|
||||||
<h2 class="hasAnchor">
|
<h2 class="hasAnchor">
|
||||||
@@ -295,8 +296,8 @@
|
|||||||
<p><img src="https://github.com/msberends/AMR/raw/master/docs/import2.png"></p>
|
<p><img src="https://github.com/msberends/AMR/raw/master/docs/import2.png"></p>
|
||||||
<p>If you want named variables to be imported as factors so it resembles SPSS more, use <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>.</p>
|
<p>If you want named variables to be imported as factors so it resembles SPSS more, use <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>.</p>
|
||||||
<p>The difference is this:</p>
|
<p>The difference is this:</p>
|
||||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">SPSS_data</span>
|
<span class="va">SPSS_data</span>
|
||||||
<span class="co"># # A tibble: 4,203 x 4</span>
|
<span class="co"># # A tibble: 4,203 x 4</span>
|
||||||
<span class="co"># v001 sex status statusage</span>
|
<span class="co"># v001 sex status statusage</span>
|
||||||
<span class="co"># <dbl> <dbl+lbl> <dbl+lbl> <dbl></span>
|
<span class="co"># <dbl> <dbl+lbl> <dbl+lbl> <dbl></span>
|
||||||
@@ -326,74 +327,74 @@
|
|||||||
<span class="co"># 8 10011 Male alive 73.1</span>
|
<span class="co"># 8 10011 Male alive 73.1</span>
|
||||||
<span class="co"># 9 10017 Male alive 56.7</span>
|
<span class="co"># 9 10017 Male alive 56.7</span>
|
||||||
<span class="co"># 10 10018 Female alive 66.6</span>
|
<span class="co"># 10 10018 Female alive 66.6</span>
|
||||||
<span class="co"># # … with 4,193 more rows</span></code></pre></div>
|
<span class="co"># # … with 4,193 more rows</span></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="base-r" class="section level3">
|
<div id="base-r" class="section level3">
|
||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
<a href="#base-r" class="anchor"></a>Base R</h3>
|
<a href="#base-r" class="anchor"></a>Base R</h3>
|
||||||
<p>To import data from SPSS, SAS or Stata, you can use the <a href="https://haven.tidyverse.org/">great <code>haven</code> package</a> yourself:</p>
|
<p>To import data from SPSS, SAS or Stata, you can use the <a href="https://haven.tidyverse.org/">great <code>haven</code> package</a> yourself:</p>
|
||||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># download and install the latest version:</span>
|
<span class="co"># download and install the latest version:</span>
|
||||||
<span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"haven"</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"haven"</span><span class="op">)</span>
|
||||||
<span class="co"># load the package you just installed:</span>
|
<span class="co"># load the package you just installed:</span>
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://haven.tidyverse.org">haven</a></span><span class="op">)</span> </code></pre></div>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://haven.tidyverse.org">haven</a></span><span class="op">)</span> </pre></div>
|
||||||
<p>You can now import files as follows:</p>
|
<p>You can now import files as follows:</p>
|
||||||
<div id="spss" class="section level4">
|
<div id="spss" class="section level4">
|
||||||
<h4 class="hasAnchor">
|
<h4 class="hasAnchor">
|
||||||
<a href="#spss" class="anchor"></a>SPSS</h4>
|
<a href="#spss" class="anchor"></a>SPSS</h4>
|
||||||
<p>To read files from SPSS into R:</p>
|
<p>To read files from SPSS into R:</p>
|
||||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># read any SPSS file based on file extension (best way):</span>
|
<span class="co"># read any SPSS file based on file extension (best way):</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_spss</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_spss</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||||
|
|
||||||
<span class="co"># read .sav or .zsav file:</span>
|
<span class="co"># read .sav or .zsav file:</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_sav</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_sav</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||||
|
|
||||||
<span class="co"># read .por file:</span>
|
<span class="co"># read .por file:</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_por</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_por</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></pre></div>
|
||||||
<p>Do not forget about <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>, as mentioned above.</p>
|
<p>Do not forget about <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>, as mentioned above.</p>
|
||||||
<p>To export your R objects to the SPSS file format:</p>
|
<p>To export your R objects to the SPSS file format:</p>
|
||||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># save as .sav file:</span>
|
<span class="co"># save as .sav file:</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||||
|
|
||||||
<span class="co"># save as compressed .zsav file:</span>
|
<span class="co"># save as compressed .zsav file:</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, compress <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, compress <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="sas" class="section level4">
|
<div id="sas" class="section level4">
|
||||||
<h4 class="hasAnchor">
|
<h4 class="hasAnchor">
|
||||||
<a href="#sas" class="anchor"></a>SAS</h4>
|
<a href="#sas" class="anchor"></a>SAS</h4>
|
||||||
<p>To read files from SAS into R:</p>
|
<p>To read files from SAS into R:</p>
|
||||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># read .sas7bdat + .sas7bcat files:</span>
|
<span class="co"># read .sas7bdat + .sas7bcat files:</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">read_sas</a></span><span class="op">(</span>data_file <span class="op">=</span> <span class="st">"path/to/file"</span>, catalog_file <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">read_sas</a></span><span class="op">(</span>data_file <span class="op">=</span> <span class="st">"path/to/file"</span>, catalog_file <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span>
|
||||||
|
|
||||||
<span class="co"># read SAS transport files (version 5 and version 8):</span>
|
<span class="co"># read SAS transport files (version 5 and version 8):</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">read_xpt</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">read_xpt</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></pre></div>
|
||||||
<p>To export your R objects to the SAS file format:</p>
|
<p>To export your R objects to the SAS file format:</p>
|
||||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># save as regular SAS file:</span>
|
<span class="co"># save as regular SAS file:</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">write_sas</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">write_sas</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||||
|
|
||||||
<span class="co"># the SAS transport format is an open format </span>
|
<span class="co"># the SAS transport format is an open format </span>
|
||||||
<span class="co"># (required for submission of the data to the FDA)</span>
|
<span class="co"># (required for submission of the data to the FDA)</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">write_xpt</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, version <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">write_xpt</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, version <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="stata" class="section level4">
|
<div id="stata" class="section level4">
|
||||||
<h4 class="hasAnchor">
|
<h4 class="hasAnchor">
|
||||||
<a href="#stata" class="anchor"></a>Stata</h4>
|
<a href="#stata" class="anchor"></a>Stata</h4>
|
||||||
<p>To read files from Stata into R:</p>
|
<p>To read files from Stata into R:</p>
|
||||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># read .dta file:</span>
|
<span class="co"># read .dta file:</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_stata</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_stata</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span>
|
||||||
|
|
||||||
<span class="co"># works exactly the same:</span>
|
<span class="co"># works exactly the same:</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_dta</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_dta</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span></pre></div>
|
||||||
<p>To export your R objects to the Stata file format:</p>
|
<p>To export your R objects to the Stata file format:</p>
|
||||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb9"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># save as .dta file, Stata version 14:</span>
|
<span class="co"># save as .dta file, Stata version 14:</span>
|
||||||
<span class="co"># (supports Stata v8 until v15 at the time of writing)</span>
|
<span class="co"># (supports Stata v8 until v15 at the time of writing)</span>
|
||||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">write_dta</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"/path/to/file"</span>, version <span class="op">=</span> <span class="fl">14</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">write_dta</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"/path/to/file"</span>, version <span class="op">=</span> <span class="fl">14</span><span class="op">)</span></pre></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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.6.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -47,14 +47,14 @@
|
|||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li>
|
<li>
|
||||||
<a href="../index.html">
|
<a href="../index.html">
|
||||||
<span class="fas fa-home"></span>
|
<span class="fa fa-home"></span>
|
||||||
|
|
||||||
Home
|
Home
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||||
<span class="fas fa-question-circle"></span>
|
<span class="fa fa-question-circle"></span>
|
||||||
|
|
||||||
How to
|
How to
|
||||||
|
|
||||||
@@ -63,77 +63,77 @@
|
|||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/AMR.html">
|
<a href="../articles/AMR.html">
|
||||||
<span class="fas fa-directions"></span>
|
<span class="fa fa-directions"></span>
|
||||||
|
|
||||||
Conduct AMR analysis
|
Conduct AMR analysis
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/resistance_predict.html">
|
<a href="../articles/resistance_predict.html">
|
||||||
<span class="fas fa-dice"></span>
|
<span class="fa fa-dice"></span>
|
||||||
|
|
||||||
Predict antimicrobial resistance
|
Predict antimicrobial resistance
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/datasets.html">
|
<a href="../articles/datasets.html">
|
||||||
<span class="fas fa-database"></span>
|
<span class="fa fa-database"></span>
|
||||||
|
|
||||||
Data sets for download / own use
|
Data sets for download / own use
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/PCA.html">
|
<a href="../articles/PCA.html">
|
||||||
<span class="fas fa-compress"></span>
|
<span class="fa fa-compress"></span>
|
||||||
|
|
||||||
Conduct principal component analysis for AMR
|
Conduct principal component analysis for AMR
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/MDR.html">
|
<a href="../articles/MDR.html">
|
||||||
<span class="fas fa-skull-crossbones"></span>
|
<span class="fa fa-skull-crossbones"></span>
|
||||||
|
|
||||||
Determine multi-drug resistance (MDR)
|
Determine multi-drug resistance (MDR)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/WHONET.html">
|
<a href="../articles/WHONET.html">
|
||||||
<span class="fas fa-globe-americas"></span>
|
<span class="fa fa-globe-americas"></span>
|
||||||
|
|
||||||
Work with WHONET data
|
Work with WHONET data
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/SPSS.html">
|
<a href="../articles/SPSS.html">
|
||||||
<span class="fas fa-file-upload"></span>
|
<span class="fa fa-file-upload"></span>
|
||||||
|
|
||||||
Import data from SPSS/SAS/Stata
|
Import data from SPSS/SAS/Stata
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/EUCAST.html">
|
<a href="../articles/EUCAST.html">
|
||||||
<span class="fas fa-exchange-alt"></span>
|
<span class="fa fa-exchange-alt"></span>
|
||||||
|
|
||||||
Apply EUCAST rules
|
Apply EUCAST rules
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/mo_property.html">
|
<a href="../reference/mo_property.html">
|
||||||
<span class="fas fa-bug"></span>
|
<span class="fa fa-bug"></span>
|
||||||
|
|
||||||
Get properties of a microorganism
|
Get properties of a microorganism
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/ab_property.html">
|
<a href="../reference/ab_property.html">
|
||||||
<span class="fas fa-capsules"></span>
|
<span class="fa fa-capsules"></span>
|
||||||
|
|
||||||
Get properties of an antibiotic
|
Get properties of an antibiotic
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../articles/benchmarks.html">
|
<a href="../articles/benchmarks.html">
|
||||||
<span class="fas fa-shipping-fast"></span>
|
<span class="fa fa-shipping-fast"></span>
|
||||||
|
|
||||||
Other: benchmarks
|
Other: benchmarks
|
||||||
</a>
|
</a>
|
||||||
@@ -142,21 +142,21 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../reference/index.html">
|
<a href="../reference/index.html">
|
||||||
<span class="fas fa-book-open"></span>
|
<span class="fa fa-book-open"></span>
|
||||||
|
|
||||||
Manual
|
Manual
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../authors.html">
|
<a href="../authors.html">
|
||||||
<span class="fas fa-users"></span>
|
<span class="fa fa-users"></span>
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../news/index.html">
|
<a href="../news/index.html">
|
||||||
<span class="far fa-newspaper"></span>
|
<span class="far fa far fa-newspaper"></span>
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
</a>
|
</a>
|
||||||
@@ -165,14 +165,14 @@
|
|||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/msberends/AMR">
|
<a href="https://github.com/msberends/AMR">
|
||||||
<span class="fab fa-github"></span>
|
<span class="fab fa fab fa-github"></span>
|
||||||
|
|
||||||
Source Code
|
Source Code
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../survey.html">
|
<a href="../survey.html">
|
||||||
<span class="fas fa-clipboard-list"></span>
|
<span class="fa fa-clipboard-list"></span>
|
||||||
|
|
||||||
Survey
|
Survey
|
||||||
</a>
|
</a>
|
||||||
@@ -187,7 +187,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="WHONET_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
</header><link href="WHONET_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||||
|
<script src="WHONET_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||||
<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 work with WHONET data</h1>
|
<h1 data-toc-skip>How to work with WHONET data</h1>
|
||||||
@@ -205,38 +206,38 @@
|
|||||||
<a href="#import-of-data" class="anchor"></a>Import of data</h3>
|
<a href="#import-of-data" class="anchor"></a>Import of data</h3>
|
||||||
<p>This tutorial assumes you already imported the WHONET data with e.g. the <a href="https://readxl.tidyverse.org/"><code>readxl</code> package</a>. In RStudio, this can be done using the menu button ‘Import Dataset’ in the tab ‘Environment’. Choose the option ‘From Excel’ and select your exported file. Make sure date fields are imported correctly.</p>
|
<p>This tutorial assumes you already imported the WHONET data with e.g. the <a href="https://readxl.tidyverse.org/"><code>readxl</code> package</a>. In RStudio, this can be done using the menu button ‘Import Dataset’ in the tab ‘Environment’. Choose the option ‘From Excel’ and select your exported file. Make sure date fields are imported correctly.</p>
|
||||||
<p>An example syntax could look like this:</p>
|
<p>An example syntax could look like this:</p>
|
||||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://readxl.tidyverse.org">readxl</a></span><span class="op">)</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://readxl.tidyverse.org">readxl</a></span><span class="op">)</span>
|
||||||
<span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://readxl.tidyverse.org/reference/read_excel.html">read_excel</a></span><span class="op">(</span>path <span class="op">=</span> <span class="st">"path/to/your/file.xlsx"</span><span class="op">)</span></code></pre></div>
|
<span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://readxl.tidyverse.org/reference/read_excel.html">read_excel</a></span><span class="op">(</span>path <span class="op">=</span> <span class="st">"path/to/your/file.xlsx"</span><span class="op">)</span></pre></div>
|
||||||
<p>This package comes with an <a href="https://msberends.github.io/AMR/reference/WHONET.html">example data set <code>WHONET</code></a>. We will use it for this analysis.</p>
|
<p>This package comes with an <a href="https://msberends.github.io/AMR/reference/WHONET.html">example data set <code>WHONET</code></a>. We will use it for this analysis.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="preparation" class="section level3">
|
<div id="preparation" class="section level3">
|
||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
<a href="#preparation" class="anchor"></a>Preparation</h3>
|
<a href="#preparation" class="anchor"></a>Preparation</h3>
|
||||||
<p>First, load the relevant packages if you did not yet did this. I use the tidyverse for all of my analyses. All of them. If you don’t know it yet, I suggest you read about it on their website: <a href="https://www.tidyverse.org/" class="uri">https://www.tidyverse.org/</a>.</p>
|
<p>First, load the relevant packages if you did not yet did this. I use the tidyverse for all of my analyses. All of them. If you don’t know it yet, I suggest you read about it on their website: <a href="https://www.tidyverse.org/" class="uri">https://www.tidyverse.org/</a>.</p>
|
||||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># part of tidyverse</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># part of tidyverse</span>
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://ggplot2.tidyverse.org">ggplot2</a></span><span class="op">)</span> <span class="co"># part of tidyverse</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://ggplot2.tidyverse.org">ggplot2</a></span><span class="op">)</span> <span class="co"># part of tidyverse</span>
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span> <span class="co"># this package</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span> <span class="co"># this package</span>
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></code></pre></div>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></pre></div>
|
||||||
<p>We will have to transform some variables to simplify and automate the analysis:</p>
|
<p>We will have to transform some variables to simplify and automate the analysis:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Microorganisms should be transformed to our own microorganism IDs (called an <code>mo</code>) using <a href="https://msberends.github.io/AMR/reference/catalogue_of_life">our Catalogue of Life reference data set</a>, which contains all ~70,000 microorganisms from the taxonomic kingdoms Bacteria, Fungi and Protozoa. We do the tranformation with <code><a href="../reference/as.mo.html">as.mo()</a></code>. This function also recognises almost all WHONET abbreviations of microorganisms.</li>
|
<li>Microorganisms should be transformed to our own microorganism IDs (called an <code>mo</code>) using <a href="https://msberends.github.io/AMR/reference/catalogue_of_life">our Catalogue of Life reference data set</a>, which contains all ~70,000 microorganisms from the taxonomic kingdoms Bacteria, Fungi and Protozoa. We do the tranformation with <code><a href="../reference/as.mo.html">as.mo()</a></code>. This function also recognises almost all WHONET abbreviations of microorganisms.</li>
|
||||||
<li>Antimicrobial results or interpretations have to be clean and valid. In other words, they should only contain values <code>"S"</code>, <code>"I"</code> or <code>"R"</code>. That is exactly where the <code><a href="../reference/as.rsi.html">as.rsi()</a></code> function is for.</li>
|
<li>Antimicrobial results or interpretations have to be clean and valid. In other words, they should only contain values <code>"S"</code>, <code>"I"</code> or <code>"R"</code>. That is exactly where the <code><a href="../reference/as.rsi.html">as.rsi()</a></code> function is for.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># transform variables</span>
|
<span class="co"># transform variables</span>
|
||||||
<span class="va">data</span> <span class="op"><-</span> <span class="va">WHONET</span> <span class="op">%>%</span>
|
<span class="va">data</span> <span class="op"><-</span> <span class="va">WHONET</span> <span class="op">%>%</span>
|
||||||
<span class="co"># get microbial ID based on given organism</span>
|
<span class="co"># get microbial ID based on given organism</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">Organism</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">Organism</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
<span class="co"># transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class</span>
|
<span class="co"># transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">AMP_ND10</span><span class="op">:</span><span class="va">CIP_EE</span><span class="op">)</span>, <span class="va">as.rsi</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">AMP_ND10</span><span class="op">:</span><span class="va">CIP_EE</span><span class="op">)</span>, <span class="va">as.rsi</span><span class="op">)</span></pre></div>
|
||||||
<p>No errors or warnings, so all values are transformed succesfully.</p>
|
<p>No errors or warnings, so all values are transformed succesfully.</p>
|
||||||
<p>We also created a package dedicated to data cleaning and checking, called the <code>cleaner</code> package. Its <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> function can be used to create frequency tables.</p>
|
<p>We also created a package dedicated to data cleaning and checking, called the <code>cleaner</code> package. Its <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> function can be used to create frequency tables.</p>
|
||||||
<p>So let’s check our data, with a couple of frequency tables:</p>
|
<p>So let’s check our data, with a couple of frequency tables:</p>
|
||||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># our newly created `mo` variable, put in the mo_name() function</span>
|
<span class="co"># our newly created `mo` variable, put in the mo_name() function</span>
|
||||||
<span class="va">data</span> <span class="op">%>%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, nmax <span class="op">=</span> <span class="fl">10</span><span class="op">)</span></code></pre></div>
|
<span class="va">data</span> <span class="op">%>%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, nmax <span class="op">=</span> <span class="fl">10</span><span class="op">)</span></pre></div>
|
||||||
<p><strong>Frequency table</strong></p>
|
<p><strong>Frequency table</strong></p>
|
||||||
<p>Class: character<br>
|
<p>Class: character<br>
|
||||||
Length: 500<br>
|
Length: 500<br>
|
||||||
@@ -337,10 +338,10 @@ Longest: 40</p>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>(omitted 27 entries, n = 56 [11.20%])</p>
|
<p>(omitted 27 entries, n = 56 [11.20%])</p>
|
||||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="co"># our transformed antibiotic columns</span>
|
<span class="co"># our transformed antibiotic columns</span>
|
||||||
<span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span>
|
<span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span>
|
||||||
<span class="va">data</span> <span class="op">%>%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">AMC_ND2</span><span class="op">)</span></code></pre></div>
|
<span class="va">data</span> <span class="op">%>%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">AMC_ND2</span><span class="op">)</span></pre></div>
|
||||||
<p><strong>Frequency table</strong></p>
|
<p><strong>Frequency table</strong></p>
|
||||||
<p>Class: factor > ordered > rsi (numeric)<br>
|
<p>Class: factor > ordered > rsi (numeric)<br>
|
||||||
Length: 500<br>
|
Length: 500<br>
|
||||||
@@ -391,11 +392,11 @@ Drug group: Beta-lactams/penicillins<br>
|
|||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
<a href="#a-first-glimpse-at-results" class="anchor"></a>A first glimpse at results</h3>
|
<a href="#a-first-glimpse-at-results" class="anchor"></a>A first glimpse at results</h3>
|
||||||
<p>An easy <code>ggplot</code> will already give a lot of information, using the included <code><a href="../reference/ggplot_rsi.html">ggplot_rsi()</a></code> function:</p>
|
<p>An easy <code>ggplot</code> will already give a lot of information, using the included <code><a href="../reference/ggplot_rsi.html">ggplot_rsi()</a></code> function:</p>
|
||||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||||
<code class="sourceCode R"><span class="va">data</span> <span class="op">%>%</span>
|
<span class="va">data</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">Country</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">Country</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">Country</span>, <span class="va">AMP_ND2</span>, <span class="va">AMC_ED20</span>, <span class="va">CAZ_ED10</span>, <span class="va">CIP_ED5</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">Country</span>, <span class="va">AMP_ND2</span>, <span class="va">AMC_ED20</span>, <span class="va">CAZ_ED10</span>, <span class="va">CIP_ED5</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="../reference/ggplot_rsi.html">ggplot_rsi</a></span><span class="op">(</span>translate_ab <span class="op">=</span> <span class="st">'ab'</span>, facet <span class="op">=</span> <span class="st">"Country"</span>, datalabels <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="../reference/ggplot_rsi.html">ggplot_rsi</a></span><span class="op">(</span>translate_ab <span class="op">=</span> <span class="st">'ab'</span>, facet <span class="op">=</span> <span class="st">"Country"</span>, datalabels <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
|
||||||
<p><img src="WHONET_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
|
<p><img src="WHONET_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 60 KiB |
@@ -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.9027</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9015</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header><script src="benchmarks_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
</header><script src="benchmarks_files/header-attrs-2.7/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>Benchmarks</h1>
|
<h1 data-toc-skip>Benchmarks</h1>
|
||||||
@@ -227,18 +227,18 @@
|
|||||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">S.aureus</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">2</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">S.aureus</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">2</span><span class="op">)</span>
|
||||||
<span class="co"># Unit: milliseconds</span>
|
<span class="co"># Unit: milliseconds</span>
|
||||||
<span class="co"># expr min lq mean median uq max neval</span>
|
<span class="co"># expr min lq mean median uq max neval</span>
|
||||||
<span class="co"># as.mo("sau") 9.9 11.0 13.0 11.0 12.0 43 25</span>
|
<span class="co"># as.mo("sau") 9.6 10.0 12.0 10 11.0 42 25</span>
|
||||||
<span class="co"># as.mo("stau") 52.0 55.0 68.0 58.0 86.0 95 25</span>
|
<span class="co"># as.mo("stau") 52.0 55.0 74.0 59 94.0 110 25</span>
|
||||||
<span class="co"># as.mo("STAU") 53.0 56.0 73.0 62.0 93.0 100 25</span>
|
<span class="co"># as.mo("STAU") 51.0 53.0 73.0 57 91.0 100 25</span>
|
||||||
<span class="co"># as.mo("staaur") 10.0 11.0 17.0 11.0 12.0 48 25</span>
|
<span class="co"># as.mo("staaur") 9.5 9.9 11.0 10 12.0 13 25</span>
|
||||||
<span class="co"># as.mo("STAAUR") 10.0 11.0 14.0 11.0 13.0 48 25</span>
|
<span class="co"># as.mo("STAAUR") 9.4 10.0 18.0 10 12.0 52 25</span>
|
||||||
<span class="co"># as.mo("S. aureus") 27.0 28.0 41.0 33.0 60.0 73 25</span>
|
<span class="co"># as.mo("S. aureus") 24.0 26.0 31.0 26 29.0 62 25</span>
|
||||||
<span class="co"># as.mo("S aureus") 27.0 28.0 49.0 34.0 64.0 160 25</span>
|
<span class="co"># as.mo("S aureus") 25.0 25.0 42.0 29 62.0 68 25</span>
|
||||||
<span class="co"># as.mo("Staphylococcus aureus") 2.9 3.2 4.8 3.4 3.7 36 25</span>
|
<span class="co"># as.mo("Staphylococcus aureus") 2.5 2.9 3.2 3 3.5 4 25</span>
|
||||||
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 250.0 260.0 270.0 270.0 280.0 320 25</span>
|
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 240.0 240.0 260.0 250 260.0 390 25</span>
|
||||||
<span class="co"># as.mo("Sthafilokkockus aaureuz") 170.0 200.0 210.0 210.0 210.0 310 25</span>
|
<span class="co"># as.mo("Sthafilokkockus aaureuz") 150.0 190.0 190.0 190 190.0 250 25</span>
|
||||||
<span class="co"># as.mo("MRSA") 10.0 11.0 16.0 12.0 12.0 50 25</span>
|
<span class="co"># as.mo("MRSA") 8.7 10.0 15.0 11 12.0 49 25</span>
|
||||||
<span class="co"># as.mo("VISA") 19.0 20.0 27.0 21.0 23.0 60 25</span></code></pre></div>
|
<span class="co"># as.mo("VISA") 17.0 19.0 25.0 21 22.0 57 25</span></code></pre></div>
|
||||||
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="750"></p>
|
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="750"></p>
|
||||||
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 200 milliseconds, this is only 5 input values per second. It is clear that accepted taxonomic names are extremely fast, but some variations are up to 200 times slower to determine.</p>
|
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 200 milliseconds, this is only 5 input values per second. It is clear that accepted taxonomic names are extremely fast, but some variations are up to 200 times slower to determine.</p>
|
||||||
<p>To improve performance, we implemented two important algorithms to save unnecessary calculations: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
|
<p>To improve performance, we implemented two important algorithms to save unnecessary calculations: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
|
||||||
@@ -260,8 +260,8 @@
|
|||||||
<span class="co"># what do these values look like? They are of class <mo>:</span>
|
<span class="co"># what do these values look like? They are of class <mo>:</span>
|
||||||
<span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||||
<span class="co"># Class <mo></span>
|
<span class="co"># Class <mo></span>
|
||||||
<span class="co"># [1] B_STRPT_PYGN B_STPHY_HMNS B_STPHY_CONS B_STRPT_SLVR B_ENTRBC_CLOC</span>
|
<span class="co"># [1] B_KLBSL_PNMN B_STPHY_EPDR B_STRPT_PNMN B_STRPT_EQNS B_ESCHR_COLI</span>
|
||||||
<span class="co"># [6] B_STPHY_CONS</span>
|
<span class="co"># [6] B_KLBSL_PNMN</span>
|
||||||
|
|
||||||
<span class="co"># as the example_isolates data set has 2,000 rows, we should have 2 million items</span>
|
<span class="co"># as the example_isolates data set has 2,000 rows, we should have 2 million items</span>
|
||||||
<span class="fu"><a href="https://rdrr.io/r/base/length.html">length</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/base/length.html">length</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||||
@@ -277,8 +277,8 @@
|
|||||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||||
<span class="co"># Unit: milliseconds</span>
|
<span class="co"># Unit: milliseconds</span>
|
||||||
<span class="co"># expr min lq mean median uq max neval</span>
|
<span class="co"># expr min lq mean median uq max neval</span>
|
||||||
<span class="co"># mo_name(x) 161 194 224 204 229 368 10</span></code></pre></div>
|
<span class="co"># mo_name(x) 155 182 233 228 242 350 10</span></code></pre></div>
|
||||||
<p>So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.204 seconds. That is 102 nanoseconds on average. You only lose time on your unique input values.</p>
|
<p>So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.228 seconds. That is 114 nanoseconds on average. You only lose time on your unique input values.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="precalculated-results" class="section level3">
|
<div id="precalculated-results" class="section level3">
|
||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
@@ -292,10 +292,10 @@
|
|||||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||||
<span class="co"># Unit: milliseconds</span>
|
<span class="co"># Unit: milliseconds</span>
|
||||||
<span class="co"># expr min lq mean median uq max neval</span>
|
<span class="co"># expr min lq mean median uq max neval</span>
|
||||||
<span class="co"># A 7.45 7.84 12.70 8.62 9.16 51.10 10</span>
|
<span class="co"># A 6.62 6.84 7.30 6.91 8.10 8.74 10</span>
|
||||||
<span class="co"># B 23.80 24.50 30.60 26.30 28.80 70.20 10</span>
|
<span class="co"># B 22.20 23.10 33.20 24.50 27.70 70.80 10</span>
|
||||||
<span class="co"># C 1.66 1.74 1.85 1.79 1.92 2.24 10</span></code></pre></div>
|
<span class="co"># C 1.37 1.50 1.66 1.71 1.81 1.84 10</span></code></pre></div>
|
||||||
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0018 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0017 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R"><span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>A <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span><span class="op">(</span><span class="st">"aureus"</span><span class="op">)</span>,
|
<code class="sourceCode R"><span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>A <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span><span class="op">(</span><span class="st">"aureus"</span><span class="op">)</span>,
|
||||||
B <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"Staphylococcus"</span><span class="op">)</span>,
|
B <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"Staphylococcus"</span><span class="op">)</span>,
|
||||||
@@ -309,14 +309,14 @@
|
|||||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||||
<span class="co"># Unit: milliseconds</span>
|
<span class="co"># Unit: milliseconds</span>
|
||||||
<span class="co"># expr min lq mean median uq max neval</span>
|
<span class="co"># expr min lq mean median uq max neval</span>
|
||||||
<span class="co"># A 1.59 1.60 1.91 1.97 2.15 2.28 10</span>
|
<span class="co"># A 1.19 1.21 1.43 1.28 1.65 2.03 10</span>
|
||||||
<span class="co"># B 1.58 1.61 1.87 1.86 1.96 2.39 10</span>
|
<span class="co"># B 1.19 1.24 1.38 1.26 1.53 1.83 10</span>
|
||||||
<span class="co"># C 1.55 1.57 1.64 1.63 1.69 1.79 10</span>
|
<span class="co"># C 1.24 1.28 1.45 1.36 1.41 2.24 10</span>
|
||||||
<span class="co"># D 1.57 1.60 1.83 1.72 1.92 2.73 10</span>
|
<span class="co"># D 1.20 1.22 1.33 1.23 1.41 1.77 10</span>
|
||||||
<span class="co"># E 1.50 1.74 1.86 1.86 2.03 2.24 10</span>
|
<span class="co"># E 1.21 1.22 1.35 1.27 1.38 1.69 10</span>
|
||||||
<span class="co"># F 1.49 1.55 1.75 1.67 1.90 2.24 10</span>
|
<span class="co"># F 1.20 1.21 1.34 1.26 1.37 1.71 10</span>
|
||||||
<span class="co"># G 1.54 1.59 1.69 1.65 1.77 1.95 10</span>
|
<span class="co"># G 1.17 1.22 1.31 1.27 1.31 1.71 10</span>
|
||||||
<span class="co"># H 1.57 1.58 1.75 1.72 1.78 2.21 10</span></code></pre></div>
|
<span class="co"># H 1.21 1.27 1.42 1.37 1.47 1.84 10</span></code></pre></div>
|
||||||
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> anyway, there is no point in calculating the result. And because this package contains all phyla of all known bacteria, it can just return the initial value immediately.</p>
|
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> anyway, there is no point in calculating the result. And because this package contains all phyla of all known bacteria, it can just return the initial value immediately.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="results-in-other-languages" class="section level3">
|
<div id="results-in-other-languages" class="section level3">
|
||||||
@@ -344,13 +344,13 @@
|
|||||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">4</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">4</span><span class="op">)</span>
|
||||||
<span class="co"># Unit: milliseconds</span>
|
<span class="co"># Unit: milliseconds</span>
|
||||||
<span class="co"># expr min lq mean median uq max neval</span>
|
<span class="co"># expr min lq mean median uq max neval</span>
|
||||||
<span class="co"># en 17.33 18.21 21.97 19.06 20.40 68.32 100</span>
|
<span class="co"># en 17.19 17.50 22.00 17.76 18.54 61.02 100</span>
|
||||||
<span class="co"># de 20.44 21.37 30.49 22.33 24.97 78.42 100</span>
|
<span class="co"># de 31.08 31.53 39.66 32.04 35.34 76.23 100</span>
|
||||||
<span class="co"># nl 25.13 26.10 31.91 27.11 28.50 86.00 100</span>
|
<span class="co"># nl 30.19 31.41 40.64 32.30 35.93 79.53 100</span>
|
||||||
<span class="co"># es 20.28 21.16 26.37 22.03 23.67 74.74 100</span>
|
<span class="co"># es 30.50 31.33 41.70 31.84 35.90 181.80 100</span>
|
||||||
<span class="co"># it 20.06 21.00 26.05 21.95 23.42 94.16 100</span>
|
<span class="co"># it 20.94 21.37 25.27 21.63 22.44 69.84 100</span>
|
||||||
<span class="co"># fr 19.90 20.63 24.40 21.85 22.82 69.07 100</span>
|
<span class="co"># fr 20.62 21.00 27.09 21.41 23.12 79.50 100</span>
|
||||||
<span class="co"># pt 20.22 21.03 25.63 21.89 23.24 76.63 100</span></code></pre></div>
|
<span class="co"># pt 20.41 21.23 25.33 21.56 22.22 70.65 100</span></code></pre></div>
|
||||||
<p>Currently supported non-English languages are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
<p>Currently supported non-English languages are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 82 KiB |
@@ -0,0 +1,12 @@
|
|||||||
|
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||||
|
// be compatible with the behavior of Pandoc < 2.8).
|
||||||
|
document.addEventListener('DOMContentLoaded', function(e) {
|
||||||
|
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
||||||
|
var i, h, a;
|
||||||
|
for (i = 0; i < hs.length; i++) {
|
||||||
|
h = hs[i];
|
||||||
|
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||||
|
a = h.attributes;
|
||||||
|
while (a.length > 0) h.removeAttribute(a[0].name);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</button>
|
</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.6.0.9041</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
<div class="page-header toc-ignore">
|
<div class="page-header toc-ignore">
|
||||||
<h1 data-toc-skip>Data sets for download / own use</h1>
|
<h1 data-toc-skip>Data sets for download / own use</h1>
|
||||||
|
|
||||||
<h4 class="date">11 March 2021</h4>
|
<h4 class="date">16 May 2021</h4>
|
||||||
|
|
||||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
|
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
|
||||||
<div class="hidden name"><code>datasets.Rmd</code></div>
|
<div class="hidden name"><code>datasets.Rmd</code></div>
|
||||||
@@ -497,7 +497,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
|||||||
<a href="#antibiotic-agents" class="anchor"></a>Antibiotic agents</h2>
|
<a href="#antibiotic-agents" class="anchor"></a>Antibiotic agents</h2>
|
||||||
<p>A data set with 456 rows and 14 columns, containing the following column names:<br><em>ab</em>, <em>atc</em>, <em>cid</em>, <em>name</em>, <em>group</em>, <em>atc_group1</em>, <em>atc_group2</em>, <em>abbreviations</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em>, <em>iv_units</em> and <em>loinc</em>.</p>
|
<p>A data set with 456 rows and 14 columns, containing the following column names:<br><em>ab</em>, <em>atc</em>, <em>cid</em>, <em>name</em>, <em>group</em>, <em>atc_group1</em>, <em>atc_group2</em>, <em>abbreviations</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em>, <em>iv_units</em> and <em>loinc</em>.</p>
|
||||||
<p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p>
|
<p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p>
|
||||||
<p>It was last updated on 11 March 2021 20:59:32 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
<p>It was last updated on 4 May 2021 13:38:27 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||||
<p><strong>Direct download links:</strong></p>
|
<p><strong>Direct download links:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (32 kB)<br>
|
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (32 kB)<br>
|
||||||
|
|||||||