Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e975a3043c | ||
|
|
2ed5f13880 | ||
|
|
1e4eaf23f2 | ||
|
|
21b4552f5a | ||
|
|
c44ddf272f | ||
|
|
71db246d5c | ||
|
|
0d67db4f32 | ||
|
|
95f9563f58 | ||
|
|
1a9bac8c64 | ||
|
|
40d9658e06 | ||
|
|
f781998904 | ||
|
|
4d050aef7c | ||
|
|
4cb1db4554 | ||
|
|
303d61b473 |
@@ -24,8 +24,9 @@
|
||||
^\.lintr$
|
||||
^tests/testthat/_snaps$
|
||||
^vignettes/AMR\.Rmd$
|
||||
^vignettes/AMR_intro\.png$
|
||||
^vignettes/benchmarks\.Rmd$
|
||||
^vignettes/*\.not$
|
||||
^vignettes/benchmarks\.Rmd\.not$
|
||||
^vignettes/datasets\.Rmd$
|
||||
^vignettes/EUCAST\.Rmd$
|
||||
^vignettes/MDR\.Rmd$
|
||||
|
||||
@@ -3,26 +3,28 @@
|
||||
echo "Running pre-commit hook..."
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo ">> Updating R documentation..."
|
||||
if command -v Rscript > /dev/null; then
|
||||
if [ "$(Rscript -e 'cat(all(c('"'pkgload'"', '"'devtools'"', '"'dplyr'"') %in% rownames(installed.packages())))')" = "TRUE" ]; then
|
||||
Rscript -e "source('data-raw/pre-commit-hook.R')"
|
||||
if [ "$(Rscript -e 'cat(all(c('"'pkgload'"', '"'devtools'"', '"'dplyr'"', '"'styler'"') %in% rownames(installed.packages())))')" = "TRUE" ]; then
|
||||
Rscript -e "source('data-raw/_pre_commit_hook.R')"
|
||||
currentpkg=`Rscript -e "cat(pkgload::pkg_name())"`
|
||||
echo "-> Adding all files in folders 'data-raw', 'inst', 'man', and 'R' to this git commit"
|
||||
git add data-raw/*
|
||||
git add inst/*
|
||||
git add man/*
|
||||
git add R/sysdata.rda
|
||||
git add R/*
|
||||
else
|
||||
echo ">> R package 'pkgload', 'devtools', or 'dplyr' not installed!"
|
||||
echo "- R package 'pkgload', 'devtools', 'dplyr', or 'styler' not installed!"
|
||||
currentpkg="your"
|
||||
fi
|
||||
else
|
||||
echo ">> R is not available on your system!"
|
||||
echo "- R is not available on your system!"
|
||||
currentpkg="your"
|
||||
fi
|
||||
echo ">> "
|
||||
echo ""
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo ">> Updating semantic versioning and date..."
|
||||
echo ">> Updating semantic versioning and date..."
|
||||
|
||||
# get tags from remote, and remove tags not on remote:
|
||||
git fetch origin --prune --prune-tags --quiet
|
||||
|
||||
@@ -32,6 +32,9 @@ name: R-code-check-PR
|
||||
|
||||
jobs:
|
||||
R-code-check-PR:
|
||||
# do not run if we are the authors - the other checks will already run
|
||||
if: ${{ github.event.comment.author_association != 'MEMBER' && github.event.comment.author_association != 'OWNER' }}
|
||||
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
|
||||
continue-on-error: ${{ matrix.config.allowfail }}
|
||||
|
||||
@@ -97,10 +97,9 @@ jobs:
|
||||
path: ${{ env.R_LIBS_USER }}
|
||||
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4
|
||||
|
||||
- name: Unpack AMR and install R dependencies
|
||||
- name: Install R dependencies
|
||||
if: always()
|
||||
run: |
|
||||
tar -xf data-raw/AMR_latest.tar.gz
|
||||
Rscript -e "source('data-raw/_install_deps.R')"
|
||||
shell: bash
|
||||
|
||||
@@ -113,33 +112,42 @@ jobs:
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Remove vignettes on R without knitr support
|
||||
if: matrix.config.r == '3.0' || matrix.config.r == '3.1' || matrix.config.r == '3.2'
|
||||
# writing to DESCRIPTION2 and then moving to DESCRIPTION is required for R < 3.3 as writeLines() cannot overwrite
|
||||
if: matrix.config.r == '3.0' || matrix.config.r == '3.1' || matrix.config.r == '3.2' || matrix.config.r == '3.3'
|
||||
# writing to DESCRIPTION2 and then moving to DESCRIPTION is required for R <= 3.3 as writeLines() cannot overwrite
|
||||
run: |
|
||||
rm -rf AMR/vignettes
|
||||
Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[!grepl('VignetteBuilder', readLines('AMR/DESCRIPTION'))], 'AMR/DESCRIPTION2')"
|
||||
rm AMR/DESCRIPTION
|
||||
mv AMR/DESCRIPTION2 AMR/DESCRIPTION
|
||||
rm -rf vignettes
|
||||
Rscript -e "writeLines(readLines('DESCRIPTION')[!grepl('VignetteBuilder', readLines('DESCRIPTION'))], 'DESCRIPTION2')"
|
||||
rm DESCRIPTION
|
||||
mv DESCRIPTION2 DESCRIPTION
|
||||
shell: bash
|
||||
|
||||
- name: Run R CMD check
|
||||
if: always()
|
||||
env:
|
||||
# see https://rstudio.github.io/r-manuals/r-ints/Tools.html for an overview
|
||||
_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
|
||||
# no check for old R versions - these packages require higher R versions
|
||||
_R_CHECK_RD_XREFS_: ${{ matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2' && matrix.config.r != '3.3' && matrix.config.r != '3.4' }}
|
||||
_R_CHECK_FORCE_SUGGESTS_: false
|
||||
R_CHECK_CONSTANTS: 5
|
||||
R_JIT_STRATEGY: 3
|
||||
# during 'R CMD check', R_LIBS_USER will be overwritten, so:
|
||||
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
|
||||
# this is a required value to run the unit tests:
|
||||
R_RUN_TINYTEST: true
|
||||
run: |
|
||||
R CMD check --no-manual --run-donttest --run-dontrun AMR
|
||||
cd ..
|
||||
R CMD build AMR
|
||||
R CMD check --as-cran --no-manual --run-donttest --run-dontrun AMR_*.tar.gz
|
||||
shell: bash
|
||||
|
||||
- name: Show unit tests output
|
||||
if: always()
|
||||
run: |
|
||||
cd ../AMR.Rcheck
|
||||
find . -name 'tinytest.Rout*' -exec cat '{}' \; || true
|
||||
shell: bash
|
||||
|
||||
@@ -148,4 +156,4 @@ jobs:
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: artifacts-${{ matrix.config.os }}-r${{ matrix.config.r }}
|
||||
path: AMR.Rcheck
|
||||
path: ~/AMR.Rcheck
|
||||
|
||||
@@ -33,54 +33,30 @@ name: code-coverage
|
||||
|
||||
jobs:
|
||||
code-coverage:
|
||||
runs-on: macOS-latest
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r@v2
|
||||
with:
|
||||
r-version: release
|
||||
# use RStudio Package Manager to quickly install packages
|
||||
use-public-rspm: true
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@v2
|
||||
# with:
|
||||
# pandoc-version: '2.7.3' # The pandoc version to download (if necessary) and use.
|
||||
|
||||
- name: Query dependencies
|
||||
# this will change once a week, so it will cache dependency updates
|
||||
run: |
|
||||
writeLines(paste(format(Sys.Date(), "week %V %Y"), sprintf("R-%i.%i", getRversion()$major, getRversion()$minor)), ".github/week-R-version")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Restore cached R packages
|
||||
# this step will add the step 'Post Restore cached R packages' on a succesful run
|
||||
uses: actions/cache@v2
|
||||
- uses: r-lib/actions/setup-r-dependencies@v2
|
||||
with:
|
||||
path: ${{ env.R_LIBS_USER }}
|
||||
key: ${{ matrix.config.os }}-${{ hashFiles('.github/week-R-version') }}-v4
|
||||
|
||||
- name: Unpack AMR and install R dependencies
|
||||
run: |
|
||||
tar -xf data-raw/AMR_latest.tar.gz
|
||||
Rscript -e "source('data-raw/_install_deps.R')"
|
||||
shell: bash
|
||||
|
||||
- name: Show session info
|
||||
run: |
|
||||
options(width = 100)
|
||||
utils::sessionInfo()
|
||||
as.data.frame(utils::installed.packages())[, "Version", drop = FALSE]
|
||||
shell: Rscript {0}
|
||||
extra-packages: any::covr
|
||||
|
||||
- name: Test coverage
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
|
||||
R_RUN_TINYTEST: true
|
||||
run: |
|
||||
install.packages("covr", repos = "https://cran.rstudio.com/")
|
||||
library(AMR)
|
||||
library(tinytest)
|
||||
x <- covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R"))
|
||||
print(x)
|
||||
shell: Rscript {0}
|
||||
|
||||
@@ -33,34 +33,23 @@ name: lintr
|
||||
|
||||
jobs:
|
||||
lintr:
|
||||
runs-on: macOS-latest
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r@v2
|
||||
|
||||
- name: Query dependencies
|
||||
run: |
|
||||
install.packages('remotes')
|
||||
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
|
||||
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Cache R packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ env.R_LIBS_USER }}
|
||||
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
|
||||
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
|
||||
r-version: release
|
||||
# use RStudio Package Manager to quickly install packages
|
||||
use-public-rspm: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
install.packages(c("remotes"))
|
||||
remotes::install_deps(dependencies = TRUE)
|
||||
remotes::install_cran("lintr")
|
||||
shell: Rscript {0}
|
||||
- uses: r-lib/actions/setup-r-dependencies@v2
|
||||
with:
|
||||
extra-packages: any::lintr
|
||||
|
||||
- name: Lint
|
||||
run: lintr::lint_package(linters = lintr::with_defaults(line_length_linter = NULL, trailing_whitespace_linter = NULL, object_name_linter = NULL, cyclocomp_linter = NULL, object_length_linter = lintr::object_length_linter(length = 50L)), exclusions = list("R/aa_helper_pm_functions.R"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: No
|
||||
SaveWorkspace: Ask
|
||||
SaveWorkspace: No
|
||||
AlwaysSaveHistory: Yes
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
@@ -13,6 +13,7 @@ RnwWeave: Sweave
|
||||
LaTeX: pdfLaTeX
|
||||
|
||||
AutoAppendNewline: Yes
|
||||
LineEndingConversion: Posix
|
||||
|
||||
BuildType: Package
|
||||
PackageUseDevtools: Yes
|
||||
@@ -20,3 +21,5 @@ PackageInstallArgs: --no-multiarch --with-keep.source
|
||||
PackageBuildArgs: --no-build-vignettes
|
||||
PackageCheckArgs: --no-build-vignettes --as-cran
|
||||
PackageRoxygenize: rd,collate,namespace
|
||||
|
||||
UseNativePipeOperator: No
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
Package: AMR
|
||||
Version: 1.8.1.9030
|
||||
Date: 2022-08-26
|
||||
Version: 1.8.1.9043
|
||||
Date: 2022-08-28
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
data analysis and to work with microbial and antimicrobial properties by
|
||||
using evidence-based methods and reliable reference data such as LPSN
|
||||
<doi:10.1099/ijsem.0.004332>.
|
||||
Authors@R: c(
|
||||
person(c("Matthijs", "S."), "Berends", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7620-1800"), email = "m.berends@certe.nl"),
|
||||
person(c("Christian", "F."), "Luz", role = c("aut", "ctb"), comment = c(ORCID = "0000-0001-5809-5995")),
|
||||
person("Dennis", "Souverein", role = c("aut", "ctb"), comment = c(ORCID = "0000-0003-0455-0336")),
|
||||
person(c("Erwin", "E.", "A."), "Hassing", role = c("aut", "ctb")),
|
||||
person("Casper", "Albers", role = "ths", comment = c(ORCID = "0000-0002-9213-6743")),
|
||||
person("Peter", "Dutey-Magni", role = "ctb", comment = c(ORCID = "0000-0002-8942-9836")),
|
||||
person("Judith", "Fonville", role = "ctb"),
|
||||
person("Alex", "Friedrich", role = "ths", comment = c(ORCID = "0000-0003-4881-038X")),
|
||||
person("Corinna", "Glasner", role = "ths", comment = c(ORCID = "0000-0003-1241-1328")),
|
||||
person("Eric", "Hazenberg", role = "ctb"),
|
||||
person("Gwen", "Knight", role = "ctb", comment = c(ORCID = "0000-0002-7263-9896")),
|
||||
person("Annick", "Lenglet", role = "ctb", comment = c(ORCID = "0000-0003-2013-8405")),
|
||||
person("Bart", "Meijer", role = "ctb"),
|
||||
person("Anton", "Mymrikov", role = "ctb"),
|
||||
person("Sofia", "Ny", role = "ctb", comment = c(ORCID = "0000-0002-2017-1363")),
|
||||
person("Rogier", "Schade", role = "ctb"),
|
||||
person("Bhanu", "Sinha", role = "ths", comment = c(ORCID = "0000-0003-1634-0010")),
|
||||
person("Anthony", "Underwood", role = "ctb", comment = c(ORCID = "0000-0002-8547-4277")))
|
||||
person(family = "Berends", c("Matthijs", "S."), role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7620-1800"), email = "m.berends@certe.nl"),
|
||||
person(family = "Luz", c("Christian", "F."), role = c("aut", "ctb"), comment = c(ORCID = "0000-0001-5809-5995")),
|
||||
person(family = "Souverein", c("Dennis"), role = c("aut", "ctb"), comment = c(ORCID = "0000-0003-0455-0336")),
|
||||
person(family = "Hassing", c("Erwin", "E.", "A."), role = c("aut", "ctb")),
|
||||
person(family = "Albers", c("Casper", "J."), role = "ths", comment = c(ORCID = "0000-0002-9213-6743")),
|
||||
person(family = "Dutey-Magni", c("Peter"), role = "ctb", comment = c(ORCID = "0000-0002-8942-9836")),
|
||||
person(family = "Fonville", c("Judith", "M"), role = "ctb"),
|
||||
person(family = "Friedrich", c("Alex", "W."), role = "ths", comment = c(ORCID = "0000-0003-4881-038X")),
|
||||
person(family = "Glasner", c("Corinna"), role = "ths", comment = c(ORCID = "0000-0003-1241-1328")),
|
||||
person(family = "Hazenberg", c("Eric", "H.", "L.", "C.", "M."), role = "ctb"),
|
||||
person(family = "Knight", c("Gwen"), role = "ctb", comment = c(ORCID = "0000-0002-7263-9896")),
|
||||
person(family = "Lenglet", c("Annick"), role = "ctb", comment = c(ORCID = "0000-0003-2013-8405")),
|
||||
person(family = "Meijer", c("Bart", "C."), role = "ctb"),
|
||||
person(family = "Mymrikov", c("Anton"), role = "ctb"),
|
||||
person(family = "Ny", c("Sofia"), role = "ctb", comment = c(ORCID = "0000-0002-2017-1363")),
|
||||
person(family = "Schade", c("Rogier", "P."), role = "ctb"),
|
||||
person(family = "Sinha", c("Bhanu", "N.", "M."), role = "ths", comment = c(ORCID = "0000-0003-1634-0010")),
|
||||
person(family = "Underwood", c("Anthony"), role = "ctb", comment = c(ORCID = "0000-0002-8547-4277")))
|
||||
Depends: R (>= 3.0.0)
|
||||
Enhances:
|
||||
cleaner,
|
||||
skimr,
|
||||
ggplot2,
|
||||
tibble,
|
||||
tidyselect
|
||||
Suggests:
|
||||
curl,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# AMR 1.8.1.9030
|
||||
# AMR 1.8.1.9043
|
||||
|
||||
### New
|
||||
* EUCAST 2022 and CLSI 2022 guidelines have been added for `as.rsi()`. EUCAST 2022 is now the new default guideline for all MIC and disks diffusion interpretations.
|
||||
* Support for the following languages: Chinese, Greek, Japanese, Polish, Turkish and Ukrainian. The `AMR` package is now available in 16 languages.
|
||||
* Support for `data.frame`-enhancing R packages, more specifically: `data.table`, `tibble`, and `tsibble`. AMR package functions that have a data set as output (such as `rsi_df()` and `bug_drug_combinations()`), will now return the same data type as the input. Furthermore, all our data sets are now in `tibble` format.
|
||||
* Our data sets are now also continually exported to Apache Feather and Apache Parquet formats. You can find more info [in this article on our website](https://msberends.github.io/AMR/articles/datasets.html).
|
||||
* Support for the following languages: Chinese, Greek, Japanese, Polish, Turkish and Ukrainian. We are very grateful for the valuable input by our colleagues from other countries. The `AMR` package is now available in 16 languages.
|
||||
|
||||
### Changed
|
||||
* Fix for using `as.rsi()` on certain EUCAST breakpoints for MIC values
|
||||
@@ -16,12 +18,16 @@
|
||||
* Changed value in column `prevalence` of the `microorganisms` data set from 3 to 2 for these genera: *Acholeplasma*, *Alistipes*, *Alloprevotella*, *Bergeyella*, *Borrelia*, *Brachyspira*, *Butyricimonas*, *Cetobacterium*, *Chlamydia*, *Chlamydophila*, *Deinococcus*, *Dysgonomonas*, *Elizabethkingia*, *Empedobacter*, *Haloarcula*, *Halobacterium*, *Halococcus*, *Myroides*, *Odoribacter*, *Ornithobacterium*, *Parabacteroides*, *Pedobacter*, *Phocaeicola*, *Porphyromonas*, *Riemerella*, *Sphingobacterium*, *Streptobacillus*, *Tenacibaculum*, *Terrimonas*, *Victivallis*, *Wautersiella*, *Weeksella*
|
||||
* Fix for using the form `df[carbapenems() == "R", ]` using the latest `vctrs` package
|
||||
* Fix for using `info = FALSE` in `mdro()`
|
||||
* All data sets in this package are now exported as `tibble`, instead of base R `data.frame`s. Older R versions are still supported.
|
||||
* Automatic language determination will give a note once a session
|
||||
* For all interpretation guidelines using `as.rsi()` on amoxicillin, the rules for ampicillin will be used if amoxicillin rules are not available
|
||||
* Fix for using `ab_atc()` on non-existing ATC codes
|
||||
|
||||
### Other
|
||||
* New website to make use of the new Bootstrap 5 and pkgdown v2.0. The website now contains results for all examples and will be automatically regenerated with every change to our repository, using GitHub Actions
|
||||
* Added Peter Dutey-Magni and Anton Mymrikov as contributors, to thank them for their valuable input
|
||||
* Our data sets are now also continually exported to Apache Feather and Apache Parquet formats
|
||||
* Set up Git Large File Storage (Git LFS) for the large SAS and SPSS file formats
|
||||
* All R and Rmd files in this project are now styled using the `styler` package
|
||||
|
||||
|
||||
# `AMR` 1.8.1
|
||||
@@ -210,7 +216,7 @@
|
||||
* Functions `oxazolidinones()` (an antibiotic selector function) and `filter_oxazolidinones()` (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid
|
||||
```r
|
||||
library(dplyr)
|
||||
x <- example_isolates %>% select(date, hospital_id, oxazolidinones())
|
||||
x <- example_isolates %>% select(date, ward, oxazolidinones())
|
||||
#> Selecting oxazolidinones: column 'LNZ' (linezolid)
|
||||
|
||||
x <- example_isolates %>% filter_oxazolidinones()
|
||||
@@ -295,7 +301,7 @@
|
||||
```r
|
||||
library(dplyr)
|
||||
example_isolates %>%
|
||||
group_by(patient_id, hospital_id) %>%
|
||||
group_by(patient_id, ward) %>%
|
||||
filter(is_new_episode(date, episode_days = 60))
|
||||
```
|
||||
* Functions `mo_is_gram_negative()` and `mo_is_gram_positive()` as wrappers around `mo_gramstain()`. They always return `TRUE` or `FALSE` (except when the input is `NA` or the MO code is `UNKNOWN`), thus always return `FALSE` for species outside the taxonomic kingdom of Bacteria.
|
||||
@@ -909,7 +915,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
||||
boxplot()
|
||||
# grouped boxplots:
|
||||
septic_patients %>%
|
||||
group_by(hospital_id) %>%
|
||||
group_by(ward) %>%
|
||||
freq(age) %>%
|
||||
boxplot()
|
||||
```
|
||||
@@ -1162,13 +1168,13 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
* Support for grouping variables, test with:
|
||||
```r
|
||||
septic_patients %>%
|
||||
group_by(hospital_id) %>%
|
||||
group_by(ward) %>%
|
||||
freq(gender)
|
||||
```
|
||||
* Support for (un)selecting columns:
|
||||
```r
|
||||
septic_patients %>%
|
||||
freq(hospital_id) %>%
|
||||
freq(ward) %>%
|
||||
select(-count, -cum_count) # only get item, percent, cum_percent
|
||||
```
|
||||
* Check for `hms::is.hms`
|
||||
|
||||
@@ -24,34 +24,50 @@
|
||||
# ==================================================================== #
|
||||
|
||||
# add new version numbers here, and add the rules themselves to "data-raw/eucast_rules.tsv" and rsi_translation
|
||||
# (sourcing "data-raw/pre-commit-hook.R" will process the TSV file)
|
||||
EUCAST_VERSION_BREAKPOINTS <- list("11.0" = list(version_txt = "v11.0",
|
||||
year = 2021,
|
||||
title = "'EUCAST Clinical Breakpoint Tables'",
|
||||
url = "https://www.eucast.org/clinical_breakpoints/"),
|
||||
"10.0" = list(version_txt = "v10.0",
|
||||
year = 2020,
|
||||
title = "'EUCAST Clinical Breakpoint Tables'",
|
||||
url = "https://www.eucast.org/ast_of_bacteria/previous_versions_of_documents/"))
|
||||
EUCAST_VERSION_EXPERT_RULES <- list("3.1" = list(version_txt = "v3.1",
|
||||
year = 2016,
|
||||
title = "'EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"),
|
||||
"3.2" = list(version_txt = "v3.2",
|
||||
year = 2020,
|
||||
title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"),
|
||||
"3.3" = list(version_txt = "v3.3",
|
||||
year = 2021,
|
||||
title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"))
|
||||
# (sourcing "data-raw/_pre_commit_hook.R" will process the TSV file)
|
||||
EUCAST_VERSION_BREAKPOINTS <- list(
|
||||
"11.0" = list(
|
||||
version_txt = "v11.0",
|
||||
year = 2021,
|
||||
title = "'EUCAST Clinical Breakpoint Tables'",
|
||||
url = "https://www.eucast.org/clinical_breakpoints/"
|
||||
),
|
||||
"10.0" = list(
|
||||
version_txt = "v10.0",
|
||||
year = 2020,
|
||||
title = "'EUCAST Clinical Breakpoint Tables'",
|
||||
url = "https://www.eucast.org/ast_of_bacteria/previous_versions_of_documents/"
|
||||
)
|
||||
)
|
||||
EUCAST_VERSION_EXPERT_RULES <- list(
|
||||
"3.1" = list(
|
||||
version_txt = "v3.1",
|
||||
year = 2016,
|
||||
title = "'EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"
|
||||
),
|
||||
"3.2" = list(
|
||||
version_txt = "v3.2",
|
||||
year = 2020,
|
||||
title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"
|
||||
),
|
||||
"3.3" = list(
|
||||
version_txt = "v3.3",
|
||||
year = 2021,
|
||||
title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'",
|
||||
url = "https://www.eucast.org/expert_rules_and_expected_phenotypes/"
|
||||
)
|
||||
)
|
||||
|
||||
SNOMED_VERSION <- list(title = "Public Health Information Network Vocabulary Access and Distribution System (PHIN VADS)",
|
||||
current_source = "US Edition of SNOMED CT from 1 September 2020",
|
||||
current_version = 12,
|
||||
current_oid = "2.16.840.1.114222.4.11.1009",
|
||||
value_set_name = "Microorganism",
|
||||
url = "https://phinvads.cdc.gov/vads/ViewValueSet.action?oid=2.16.840.1.114222.4.11.1009")
|
||||
SNOMED_VERSION <- list(
|
||||
title = "Public Health Information Network Vocabulary Access and Distribution System (PHIN VADS)",
|
||||
current_source = "US Edition of SNOMED CT from 1 September 2020",
|
||||
current_version = 12,
|
||||
current_oid = "2.16.840.1.114222.4.11.1009",
|
||||
value_set_name = "Microorganism",
|
||||
url = "https://phinvads.cdc.gov/vads/ViewValueSet.action?oid=2.16.840.1.114222.4.11.1009"
|
||||
)
|
||||
|
||||
CATALOGUE_OF_LIFE <- list(
|
||||
year = 2019,
|
||||
@@ -61,73 +77,75 @@ CATALOGUE_OF_LIFE <- list(
|
||||
yearmonth_LPSN = "5 October 2021"
|
||||
)
|
||||
|
||||
globalVariables(c(".rowid",
|
||||
"ab",
|
||||
"ab_txt",
|
||||
"affect_ab_name",
|
||||
"affect_mo_name",
|
||||
"angle",
|
||||
"antibiotic",
|
||||
"antibiotics",
|
||||
"atc_group1",
|
||||
"atc_group2",
|
||||
"base_ab",
|
||||
"code",
|
||||
"cols",
|
||||
"count",
|
||||
"data",
|
||||
"disk",
|
||||
"dosage",
|
||||
"dose",
|
||||
"dose_times",
|
||||
"fullname",
|
||||
"fullname_lower",
|
||||
"g_species",
|
||||
"genus",
|
||||
"gr",
|
||||
"group",
|
||||
"guideline",
|
||||
"hjust",
|
||||
"input",
|
||||
"intrinsic_resistant",
|
||||
"isolates",
|
||||
"lang",
|
||||
"language",
|
||||
"lookup",
|
||||
"method",
|
||||
"mic",
|
||||
"mic ",
|
||||
"microorganism",
|
||||
"microorganisms",
|
||||
"microorganisms.codes",
|
||||
"microorganisms.old",
|
||||
"mo",
|
||||
"name",
|
||||
"new",
|
||||
"observations",
|
||||
"old",
|
||||
"old_name",
|
||||
"pattern",
|
||||
"R",
|
||||
"rank_index",
|
||||
"reference.rule",
|
||||
"reference.rule_group",
|
||||
"reference.version",
|
||||
"rowid",
|
||||
"rsi",
|
||||
"rsi_translation",
|
||||
"rule_group",
|
||||
"rule_name",
|
||||
"se_max",
|
||||
"se_min",
|
||||
"species",
|
||||
"species_id",
|
||||
"total",
|
||||
"txt",
|
||||
"type",
|
||||
"value",
|
||||
"varname",
|
||||
"xvar",
|
||||
"y",
|
||||
"year",
|
||||
"yvar"))
|
||||
globalVariables(c(
|
||||
".rowid",
|
||||
"ab",
|
||||
"ab_txt",
|
||||
"affect_ab_name",
|
||||
"affect_mo_name",
|
||||
"angle",
|
||||
"antibiotic",
|
||||
"antibiotics",
|
||||
"atc_group1",
|
||||
"atc_group2",
|
||||
"base_ab",
|
||||
"code",
|
||||
"cols",
|
||||
"count",
|
||||
"data",
|
||||
"disk",
|
||||
"dosage",
|
||||
"dose",
|
||||
"dose_times",
|
||||
"fullname",
|
||||
"fullname_lower",
|
||||
"g_species",
|
||||
"genus",
|
||||
"gr",
|
||||
"group",
|
||||
"guideline",
|
||||
"hjust",
|
||||
"input",
|
||||
"intrinsic_resistant",
|
||||
"isolates",
|
||||
"lang",
|
||||
"language",
|
||||
"lookup",
|
||||
"method",
|
||||
"mic",
|
||||
"mic ",
|
||||
"microorganism",
|
||||
"microorganisms",
|
||||
"microorganisms.codes",
|
||||
"microorganisms.old",
|
||||
"mo",
|
||||
"name",
|
||||
"new",
|
||||
"observations",
|
||||
"old",
|
||||
"old_name",
|
||||
"pattern",
|
||||
"R",
|
||||
"rank_index",
|
||||
"reference.rule",
|
||||
"reference.rule_group",
|
||||
"reference.version",
|
||||
"rowid",
|
||||
"rsi",
|
||||
"rsi_translation",
|
||||
"rule_group",
|
||||
"rule_name",
|
||||
"se_max",
|
||||
"se_min",
|
||||
"species",
|
||||
"species_id",
|
||||
"total",
|
||||
"txt",
|
||||
"type",
|
||||
"value",
|
||||
"varname",
|
||||
"xvar",
|
||||
"y",
|
||||
"year",
|
||||
"yvar"
|
||||
))
|
||||
|
||||
@@ -43,11 +43,16 @@ pm_left_join <- function(x, y, by = NULL, suffix = c(".x", ".y")) {
|
||||
colnames(x)[int_x] <- paste0(colnames(x)[int_x], suffix[1L])
|
||||
colnames(y)[int_y] <- paste0(colnames(y)[int_y], suffix[2L])
|
||||
|
||||
merged <- cbind(x,
|
||||
y[match(x[, by[1], drop = TRUE],
|
||||
y[, by[2], drop = TRUE]),
|
||||
colnames(y)[!colnames(y) %in% colnames(x) & !colnames(y) == by[2]],
|
||||
drop = FALSE])
|
||||
merged <- cbind(
|
||||
x,
|
||||
y[match(
|
||||
x[, by[1], drop = TRUE],
|
||||
y[, by[2], drop = TRUE]
|
||||
),
|
||||
colnames(y)[!colnames(y) %in% colnames(x) & !colnames(y) == by[2]],
|
||||
drop = FALSE
|
||||
]
|
||||
)
|
||||
|
||||
rownames(merged) <- NULL
|
||||
merged
|
||||
@@ -73,44 +78,51 @@ where <- function(fn) {
|
||||
}
|
||||
|
||||
# copied and slightly rewritten from poorman under same license (2021-10-15)
|
||||
quick_case_when <- function (...) {
|
||||
quick_case_when <- function(...) {
|
||||
fs <- list(...)
|
||||
lapply(fs, function(x) if (class(x) != "formula")
|
||||
stop("`case_when()` requires formula inputs."))
|
||||
lapply(fs, function(x) {
|
||||
if (class(x) != "formula") {
|
||||
stop("`case_when()` requires formula inputs.")
|
||||
}
|
||||
})
|
||||
n <- length(fs)
|
||||
if (n == 0L)
|
||||
if (n == 0L) {
|
||||
stop("No cases provided.")
|
||||
}
|
||||
|
||||
validate_case_when_length <- function (query, value, fs) {
|
||||
validate_case_when_length <- function(query, value, fs) {
|
||||
lhs_lengths <- lengths(query)
|
||||
rhs_lengths <- lengths(value)
|
||||
all_lengths <- unique(c(lhs_lengths, rhs_lengths))
|
||||
if (length(all_lengths) <= 1L)
|
||||
if (length(all_lengths) <= 1L) {
|
||||
return(all_lengths[[1L]])
|
||||
}
|
||||
non_atomic_lengths <- all_lengths[all_lengths != 1L]
|
||||
len <- non_atomic_lengths[[1L]]
|
||||
if (length(non_atomic_lengths) == 1L)
|
||||
if (length(non_atomic_lengths) == 1L) {
|
||||
return(len)
|
||||
}
|
||||
inconsistent_lengths <- non_atomic_lengths[-1L]
|
||||
lhs_problems <- lhs_lengths %in% inconsistent_lengths
|
||||
rhs_problems <- rhs_lengths %in% inconsistent_lengths
|
||||
problems <- lhs_problems | rhs_problems
|
||||
if (any(problems)) {
|
||||
stop("The following formulas must be length ", len, " or 1, not ",
|
||||
paste(inconsistent_lengths, collapse = ", "), ".\n ",
|
||||
paste(fs[problems], collapse = "\n "),
|
||||
call. = FALSE)
|
||||
paste(inconsistent_lengths, collapse = ", "), ".\n ",
|
||||
paste(fs[problems], collapse = "\n "),
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
replace_with <- function (x, i, val, arg_name) {
|
||||
if (is.null(val))
|
||||
replace_with <- function(x, i, val, arg_name) {
|
||||
if (is.null(val)) {
|
||||
return(x)
|
||||
}
|
||||
i[is.na(i)] <- FALSE
|
||||
if (length(val) == 1L) {
|
||||
x[i] <- val
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
x[i] <- val[i]
|
||||
}
|
||||
x
|
||||
@@ -122,15 +134,18 @@ quick_case_when <- function (...) {
|
||||
for (i in seq_len(n)) {
|
||||
query[[i]] <- eval(fs[[i]][[2]], envir = default_env)
|
||||
value[[i]] <- eval(fs[[i]][[3]], envir = default_env)
|
||||
if (!is.logical(query[[i]]))
|
||||
if (!is.logical(query[[i]])) {
|
||||
stop(fs[[i]][[2]], " does not return a `logical` vector.")
|
||||
}
|
||||
}
|
||||
m <- validate_case_when_length(query, value, fs)
|
||||
out <- value[[1]][rep(NA_integer_, m)]
|
||||
replaced <- rep(FALSE, m)
|
||||
for (i in seq_len(n)) {
|
||||
out <- replace_with(out, query[[i]] & !replaced, value[[i]],
|
||||
NULL)
|
||||
out <- replace_with(
|
||||
out, query[[i]] & !replaced, value[[i]],
|
||||
NULL
|
||||
)
|
||||
replaced <- replaced | (query[[i]] & !is.na(query[[i]]))
|
||||
}
|
||||
out
|
||||
@@ -162,17 +177,22 @@ addin_insert_like <- function() {
|
||||
|
||||
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)) {
|
||||
error = function(e) FALSE
|
||||
)) {
|
||||
return(TRUE)
|
||||
}
|
||||
tryCatch(substr(current_row_txt, current_col - nchar(txt), current_col) %like% paste0("^", txt),
|
||||
error = function(e) FALSE)
|
||||
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)
|
||||
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% ")) {
|
||||
@@ -202,33 +222,46 @@ check_dataset_integrity <- function() {
|
||||
plural <- c(" is", "s", "")
|
||||
}
|
||||
if (message_not_thrown_before("check_dataset_integrity", overwritten)) {
|
||||
warning_("The following data set", plural[1],
|
||||
" overwritten by your global environment and prevent", plural[2],
|
||||
" the AMR package from working correctly: ",
|
||||
vector_and(overwritten, quotes = "'"),
|
||||
".\nPlease rename your object", plural[3], ".")
|
||||
warning_(
|
||||
"The following data set", plural[1],
|
||||
" overwritten by your global environment and prevent", plural[2],
|
||||
" the AMR package from working correctly: ",
|
||||
vector_and(overwritten, quotes = "'"),
|
||||
".\nPlease rename your object", plural[3], "."
|
||||
)
|
||||
}
|
||||
}
|
||||
# check if other packages did not overwrite our data sets
|
||||
valid_microorganisms <- TRUE
|
||||
valid_antibiotics <- TRUE
|
||||
tryCatch({
|
||||
valid_microorganisms <- all(c("mo", "fullname", "kingdom", "phylum",
|
||||
"class", "order", "family", "genus",
|
||||
"species", "subspecies", "rank",
|
||||
"species_id", "source", "ref", "prevalence") %in% colnames(microorganisms),
|
||||
na.rm = TRUE)
|
||||
valid_antibiotics <- all(c("ab", "atc", "cid", "name", "group",
|
||||
"atc_group1", "atc_group2", "abbreviations",
|
||||
"synonyms", "oral_ddd", "oral_units",
|
||||
"iv_ddd", "iv_units", "loinc") %in% colnames(antibiotics),
|
||||
na.rm = TRUE)
|
||||
}, error = function(e) {
|
||||
# package not yet loaded
|
||||
require("AMR")
|
||||
})
|
||||
stop_if(!valid_microorganisms | !valid_antibiotics,
|
||||
"the data set `microorganisms` or `antibiotics` was overwritten in your environment because another package with the same object name(s) was loaded _after_ the AMR package, preventing the AMR package from working correctly. Please load the AMR package last.")
|
||||
tryCatch(
|
||||
{
|
||||
valid_microorganisms <- all(c(
|
||||
"mo", "fullname", "kingdom", "phylum",
|
||||
"class", "order", "family", "genus",
|
||||
"species", "subspecies", "rank",
|
||||
"species_id", "source", "ref", "prevalence"
|
||||
) %in% colnames(microorganisms),
|
||||
na.rm = TRUE
|
||||
)
|
||||
valid_antibiotics <- all(c(
|
||||
"ab", "atc", "cid", "name", "group",
|
||||
"atc_group1", "atc_group2", "abbreviations",
|
||||
"synonyms", "oral_ddd", "oral_units",
|
||||
"iv_ddd", "iv_units", "loinc"
|
||||
) %in% colnames(antibiotics),
|
||||
na.rm = TRUE
|
||||
)
|
||||
},
|
||||
error = function(e) {
|
||||
# package not yet loaded
|
||||
require("AMR")
|
||||
}
|
||||
)
|
||||
stop_if(
|
||||
!valid_microorganisms | !valid_antibiotics,
|
||||
"the data set `microorganisms` or `antibiotics` was overwritten in your environment because another package with the same object name(s) was loaded _after_ the AMR package, preventing the AMR package from working correctly. Please load the AMR package last."
|
||||
)
|
||||
invisible(TRUE)
|
||||
}
|
||||
|
||||
@@ -249,7 +282,7 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
# take first <mo> column
|
||||
found <- colnames(x)[vapply(FUN.VALUE = logical(1), x, is.mo)]
|
||||
} else if ("mo" %in% colnames_formatted &
|
||||
suppressWarnings(all(x$mo %in% c(NA, microorganisms$mo)))) {
|
||||
suppressWarnings(all(x$mo %in% c(NA, microorganisms$mo)))) {
|
||||
found <- "mo"
|
||||
} else if (any(colnames_formatted %like_case% "^(mo|microorganism|organism|bacteria|ba[ck]terie)s?$")) {
|
||||
found <- sort(colnames(x)[colnames_formatted %like_case% "^(mo|microorganism|organism|bacteria|ba[ck]terie)s?$"])
|
||||
@@ -258,7 +291,6 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
} else if (any(colnames_formatted %like_case% "species")) {
|
||||
found <- sort(colnames(x)[colnames_formatted %like_case% "species"])
|
||||
}
|
||||
|
||||
}
|
||||
# -- key antibiotics
|
||||
if (type %in% c("keyantibiotics", "keyantimicrobials")) {
|
||||
@@ -272,11 +304,13 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
# WHONET support
|
||||
found <- sort(colnames(x)[colnames_formatted %like_case% "^(specimen date|specimen_date|spec_date)"])
|
||||
if (!any(class(pm_pull(x, found)) %in% c("Date", "POSIXct"))) {
|
||||
stop(font_red(paste0("Found column '", font_bold(found), "' to be used as input for `col_", type,
|
||||
"`, but this column contains no valid dates. Transform its values to valid dates first.")),
|
||||
call. = FALSE)
|
||||
stop(font_red(paste0(
|
||||
"Found column '", font_bold(found), "' to be used as input for `col_", type,
|
||||
"`, but this column contains no valid dates. Transform its values to valid dates first."
|
||||
)),
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
} else if (any(vapply(FUN.VALUE = logical(1), x, function(x) inherits(x, c("Date", "POSIXct"))))) {
|
||||
# take first <Date> column
|
||||
found <- colnames(x)[vapply(FUN.VALUE = logical(1), x, function(x) inherits(x, c("Date", "POSIXct")))]
|
||||
@@ -313,8 +347,9 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
# this column should contain logicals
|
||||
if (!is.logical(x[, found, drop = TRUE])) {
|
||||
message_("Column '", font_bold(found), "' found as input for `col_", type,
|
||||
"`, but this column does not contain 'logical' values (TRUE/FALSE) and was ignored.",
|
||||
add_fn = font_red)
|
||||
"`, but this column does not contain 'logical' values (TRUE/FALSE) and was ignored.",
|
||||
add_fn = font_red
|
||||
)
|
||||
found <- NULL
|
||||
}
|
||||
}
|
||||
@@ -335,36 +370,52 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
}
|
||||
|
||||
is_valid_regex <- function(x) {
|
||||
regex_at_all <- tryCatch(vapply(FUN.VALUE = logical(1),
|
||||
X = strsplit(x, ""),
|
||||
FUN = function(y) any(y %in% c("$", "(", ")", "*", "+", "-",
|
||||
".", "?", "[", "]", "^", "{",
|
||||
"|", "}", "\\"),
|
||||
na.rm = TRUE),
|
||||
USE.NAMES = FALSE),
|
||||
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 <- tryCatch(vapply(
|
||||
FUN.VALUE = logical(1),
|
||||
X = strsplit(x, ""),
|
||||
FUN = function(y) {
|
||||
any(y %in% c(
|
||||
"$", "(", ")", "*", "+", "-",
|
||||
".", "?", "[", "]", "^", "{",
|
||||
"|", "}", "\\"
|
||||
),
|
||||
na.rm = TRUE
|
||||
)
|
||||
},
|
||||
USE.NAMES = FALSE
|
||||
),
|
||||
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) {
|
||||
# no "utils::installed.packages()" since it requires non-staged install since R 3.6.0
|
||||
# https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html
|
||||
vapply(FUN.VALUE = character(1), package, function(pkg)
|
||||
vapply(FUN.VALUE = character(1), package, function(pkg) {
|
||||
tryCatch(get(".packageName", envir = asNamespace(pkg)),
|
||||
error = function(e) {
|
||||
if (pkg == "rstudioapi") {
|
||||
stop("This function only works in RStudio when using R >= 3.2.", call. = FALSE)
|
||||
} else if (pkg != "base") {
|
||||
stop("This requires the '", pkg, "' package.",
|
||||
"\nTry to install it with: install.packages(\"", pkg, "\")",
|
||||
call. = FALSE)
|
||||
}
|
||||
}))
|
||||
error = function(e) {
|
||||
if (pkg == "rstudioapi") {
|
||||
stop("This function only works in RStudio when using R >= 3.2.", call. = FALSE)
|
||||
} else if (pkg != "base") {
|
||||
stop("This requires the '", pkg, "' package.",
|
||||
"\nTry to install it with: install.packages(\"", pkg, "\")",
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
return(invisible())
|
||||
}
|
||||
|
||||
@@ -390,12 +441,14 @@ import_fn <- function(name, pkg, error_on_fail = TRUE) {
|
||||
error = function(e) {
|
||||
if (isTRUE(error_on_fail)) {
|
||||
stop_("function ", name, "() is not an exported object from package '", pkg,
|
||||
"'. Please create an issue at https://github.com/msberends/AMR/issues. Many thanks!",
|
||||
call = FALSE)
|
||||
"'. Please create an issue at https://github.com/msberends/AMR/issues. Many thanks!",
|
||||
call = FALSE
|
||||
)
|
||||
} else {
|
||||
return(NULL)
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
# this alternative wrapper to the message(), warning() and stop() functions:
|
||||
@@ -416,14 +469,17 @@ word_wrap <- function(...,
|
||||
|
||||
if (msg %like% "\n") {
|
||||
# run word_wraps() over every line here, bind them and return again
|
||||
return(paste0(vapply(FUN.VALUE = character(1),
|
||||
trimws(unlist(strsplit(msg, "\n")), which = "right"),
|
||||
word_wrap,
|
||||
add_fn = add_fn,
|
||||
as_note = FALSE,
|
||||
width = width,
|
||||
extra_indent = extra_indent),
|
||||
collapse = "\n"))
|
||||
return(paste0(vapply(
|
||||
FUN.VALUE = character(1),
|
||||
trimws(unlist(strsplit(msg, "\n")), which = "right"),
|
||||
word_wrap,
|
||||
add_fn = add_fn,
|
||||
as_note = FALSE,
|
||||
width = width,
|
||||
extra_indent = extra_indent
|
||||
),
|
||||
collapse = "\n"
|
||||
))
|
||||
}
|
||||
|
||||
# correct for operators (will add the space later on)
|
||||
@@ -433,11 +489,14 @@ word_wrap <- function(...,
|
||||
msg_stripped <- font_stripstyle(msg)
|
||||
# where are the spaces now?
|
||||
msg_stripped_wrapped <- paste0(strwrap(msg_stripped,
|
||||
simplify = TRUE,
|
||||
width = width),
|
||||
collapse = "\n")
|
||||
simplify = TRUE,
|
||||
width = width
|
||||
),
|
||||
collapse = "\n"
|
||||
)
|
||||
msg_stripped_wrapped <- paste0(unlist(strsplit(msg_stripped_wrapped, "(\n|\\*\\|\\*)")),
|
||||
collapse = "\n")
|
||||
collapse = "\n"
|
||||
)
|
||||
msg_stripped_spaces <- which(unlist(strsplit(msg_stripped, "")) == " ")
|
||||
msg_stripped_wrapped_spaces <- which(unlist(strsplit(msg_stripped_wrapped, "")) != "\n")
|
||||
# so these are the indices of spaces that need to be replaced
|
||||
@@ -484,9 +543,11 @@ message_ <- function(...,
|
||||
add_fn = list(font_blue),
|
||||
as_note = TRUE) {
|
||||
message(word_wrap(...,
|
||||
add_fn = add_fn,
|
||||
as_note = as_note),
|
||||
appendLF = appendLF)
|
||||
add_fn = add_fn,
|
||||
as_note = as_note
|
||||
),
|
||||
appendLF = appendLF
|
||||
)
|
||||
}
|
||||
|
||||
warning_ <- function(...,
|
||||
@@ -494,10 +555,12 @@ warning_ <- function(...,
|
||||
immediate = FALSE,
|
||||
call = FALSE) {
|
||||
warning(word_wrap(...,
|
||||
add_fn = add_fn,
|
||||
as_note = FALSE),
|
||||
immediate. = immediate,
|
||||
call. = call)
|
||||
add_fn = add_fn,
|
||||
as_note = FALSE
|
||||
),
|
||||
immediate. = immediate,
|
||||
call. = call
|
||||
)
|
||||
}
|
||||
|
||||
# this alternative to the stop() function:
|
||||
@@ -553,8 +616,9 @@ stop_ifnot <- function(expr, ..., call = TRUE) {
|
||||
}
|
||||
}
|
||||
ifelse(!is.na(x),
|
||||
x,
|
||||
ifelse(!is.na(y), y, NA))
|
||||
x,
|
||||
ifelse(!is.na(y), y, NA)
|
||||
)
|
||||
}
|
||||
|
||||
return_after_integrity_check <- function(value, type, check_vector) {
|
||||
@@ -565,7 +629,7 @@ return_after_integrity_check <- function(value, type, check_vector) {
|
||||
value
|
||||
}
|
||||
|
||||
# transforms data set to data.frame with only ASCII values, to comply with CRAN policies
|
||||
# transforms data set to a tibble with only ASCII values, to comply with CRAN policies
|
||||
dataset_UTF8_to_ASCII <- function(df) {
|
||||
trans <- function(vect) {
|
||||
iconv(vect, from = "UTF-8", to = "ASCII//TRANSLIT")
|
||||
@@ -587,7 +651,7 @@ dataset_UTF8_to_ASCII <- function(df) {
|
||||
df[, i] <- col
|
||||
}
|
||||
}
|
||||
df
|
||||
import_fn("as_tibble", "tibble")(df)
|
||||
}
|
||||
|
||||
# for eucast_rules() and mdro(), creates markdown output with URLs and names
|
||||
@@ -596,7 +660,7 @@ create_eucast_ab_documentation <- function() {
|
||||
ab <- character()
|
||||
for (val in x) {
|
||||
if (paste0("AB_", val) %in% ls(envir = asNamespace("AMR"))) {
|
||||
# antibiotic group names, as defined in data-raw/pre-commit-hook.R, such as `CARBAPENEMS`
|
||||
# antibiotic group names, as defined in data-raw/_pre_commit_hook.R, such as `CARBAPENEMS`
|
||||
val <- eval(parse(text = paste0("AB_", val)), envir = asNamespace("AMR"))
|
||||
} else if (val %in% AB_lookup$ab) {
|
||||
# separate drugs, such as `AMX`
|
||||
@@ -646,13 +710,17 @@ vector_or <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_ca
|
||||
v <- c("R", "S", "I")
|
||||
}
|
||||
# all commas except for last item, so will become '"val1", "val2", "val3" or "val4"'
|
||||
paste0(paste0(quotes, v[seq_len(length(v) - 1)], quotes, collapse = ", "),
|
||||
last_sep, paste0(quotes, v[length(v)], quotes))
|
||||
paste0(
|
||||
paste0(quotes, v[seq_len(length(v) - 1)], quotes, collapse = ", "),
|
||||
last_sep, paste0(quotes, v[length(v)], quotes)
|
||||
)
|
||||
}
|
||||
|
||||
vector_and <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_captital = FALSE) {
|
||||
vector_or(v = v, quotes = quotes, reverse = reverse, sort = sort,
|
||||
initial_captital = initial_captital, last_sep = " and ")
|
||||
vector_or(
|
||||
v = v, quotes = quotes, reverse = reverse, sort = sort,
|
||||
initial_captital = initial_captital, last_sep = " and "
|
||||
)
|
||||
}
|
||||
|
||||
format_class <- function(class, plural = FALSE) {
|
||||
@@ -664,9 +732,11 @@ format_class <- function(class, plural = FALSE) {
|
||||
}
|
||||
class[class == "character"] <- "text string"
|
||||
class[class %in% c("Date", "POSIXt")] <- "date"
|
||||
class[class != class.bak] <- paste0(ifelse(plural, "", "a "),
|
||||
class[class != class.bak],
|
||||
ifelse(plural, "s", ""))
|
||||
class[class != class.bak] <- paste0(
|
||||
ifelse(plural, "", "a "),
|
||||
class[class != class.bak],
|
||||
ifelse(plural, "s", "")
|
||||
)
|
||||
# exceptions
|
||||
class[class == "logical"] <- ifelse(plural, "a vector of `TRUE`/`FALSE`", "`TRUE` or `FALSE`")
|
||||
class[class == "data.frame"] <- "a data set"
|
||||
@@ -707,11 +777,12 @@ meet_criteria <- function(object,
|
||||
|
||||
# if object is missing, or another error:
|
||||
tryCatch(invisible(object),
|
||||
error = function(e) pkg_env$meet_criteria_error_txt <- e$message)
|
||||
error = function(e) pkg_env$meet_criteria_error_txt <- e$message
|
||||
)
|
||||
if (!is.null(pkg_env$meet_criteria_error_txt)) {
|
||||
error_txt <- pkg_env$meet_criteria_error_txt
|
||||
pkg_env$meet_criteria_error_txt <- NULL
|
||||
stop(error_txt, call. = FALSE) # don't use stop_() here, pkg may not be loaded yet
|
||||
stop(error_txt, call. = FALSE) # don't use stop_() here, our pkg may not be loaded yet
|
||||
}
|
||||
pkg_env$meet_criteria_error_txt <- NULL
|
||||
|
||||
@@ -726,30 +797,34 @@ meet_criteria <- function(object,
|
||||
|
||||
if (!is.null(allow_class)) {
|
||||
stop_ifnot(inherits(object, allow_class), "argument `", obj_name,
|
||||
"` must be ", format_class(allow_class, plural = isTRUE(has_length > 1)),
|
||||
", i.e. not be ", format_class(class(object), plural = isTRUE(has_length > 1)),
|
||||
call = call_depth)
|
||||
"` must be ", format_class(allow_class, plural = isTRUE(has_length > 1)),
|
||||
", i.e. not be ", format_class(class(object), plural = isTRUE(has_length > 1)),
|
||||
call = call_depth
|
||||
)
|
||||
# check data.frames for data
|
||||
if (inherits(object, "data.frame")) {
|
||||
stop_if(any(dim(object) == 0),
|
||||
"the data provided in argument `", obj_name,
|
||||
"` must contain rows and columns (current dimensions: ",
|
||||
paste(dim(object), collapse = "x"), ")",
|
||||
call = call_depth)
|
||||
"the data provided in argument `", obj_name,
|
||||
"` must contain rows and columns (current dimensions: ",
|
||||
paste(dim(object), collapse = "x"), ")",
|
||||
call = call_depth
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!is.null(has_length)) {
|
||||
stop_ifnot(length(object) %in% has_length, "argument `", obj_name,
|
||||
"` must ", # ifelse(allow_NULL, "be NULL or must ", ""),
|
||||
"be of length ", vector_or(has_length, quotes = FALSE),
|
||||
", not ", length(object),
|
||||
call = call_depth)
|
||||
"` must ", # ifelse(allow_NULL, "be NULL or must ", ""),
|
||||
"be of length ", vector_or(has_length, quotes = FALSE),
|
||||
", not ", length(object),
|
||||
call = call_depth
|
||||
)
|
||||
}
|
||||
if (!is.null(looks_like)) {
|
||||
stop_ifnot(object %like% looks_like, "argument `", obj_name,
|
||||
"` must ", # ifelse(allow_NULL, "be NULL or must ", ""),
|
||||
"resemble the regular expression \"", looks_like, "\"",
|
||||
call = call_depth)
|
||||
"` must ", # ifelse(allow_NULL, "be NULL or must ", ""),
|
||||
"resemble the regular expression \"", looks_like, "\"",
|
||||
call = call_depth
|
||||
)
|
||||
}
|
||||
if (!is.null(is_in)) {
|
||||
if (ignore.case == TRUE) {
|
||||
@@ -757,48 +832,59 @@ meet_criteria <- function(object,
|
||||
is_in <- tolower(is_in)
|
||||
}
|
||||
stop_ifnot(all(object %in% is_in, na.rm = TRUE), "argument `", obj_name, "` ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"must be either ",
|
||||
"must only contain values "),
|
||||
vector_or(is_in, quotes = !isTRUE(any(c("double", "numeric", "integer") %in% allow_class))),
|
||||
ifelse(allow_NA == TRUE, ", or NA", ""),
|
||||
call = call_depth)
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"must be either ",
|
||||
"must only contain values "
|
||||
),
|
||||
vector_or(is_in, quotes = !isTRUE(any(c("double", "numeric", "integer") %in% allow_class))),
|
||||
ifelse(allow_NA == TRUE, ", or NA", ""),
|
||||
call = call_depth
|
||||
)
|
||||
}
|
||||
if (isTRUE(is_positive)) {
|
||||
stop_if(is.numeric(object) && !all(object > 0, na.rm = TRUE), "argument `", obj_name,
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"be a number higher than zero",
|
||||
"all be numbers higher than zero"),
|
||||
call = call_depth)
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"be a number higher than zero",
|
||||
"all be numbers higher than zero"
|
||||
),
|
||||
call = call_depth
|
||||
)
|
||||
}
|
||||
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)
|
||||
"` 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,
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"be a finite number",
|
||||
"all be finite numbers"),
|
||||
" (i.e. not be infinite)",
|
||||
call = call_depth)
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"be a finite number",
|
||||
"all be finite numbers"
|
||||
),
|
||||
" (i.e. not be infinite)",
|
||||
call = call_depth
|
||||
)
|
||||
}
|
||||
if (!is.null(contains_column_class)) {
|
||||
stop_ifnot(any(vapply(FUN.VALUE = logical(1),
|
||||
object,
|
||||
function(col, columns_class = contains_column_class) {
|
||||
inherits(col, columns_class)
|
||||
}), na.rm = TRUE),
|
||||
"the data provided in argument `", obj_name,
|
||||
"` must contain at least one column of class <", contains_column_class, ">. ",
|
||||
"See ?as.", contains_column_class, ".",
|
||||
call = call_depth)
|
||||
stop_ifnot(any(vapply(
|
||||
FUN.VALUE = logical(1),
|
||||
object,
|
||||
function(col, columns_class = contains_column_class) {
|
||||
inherits(col, columns_class)
|
||||
}
|
||||
), na.rm = TRUE),
|
||||
"the data provided in argument `", obj_name,
|
||||
"` must contain at least one column of class <", contains_column_class, ">. ",
|
||||
"See ?as.", contains_column_class, ".",
|
||||
call = call_depth
|
||||
)
|
||||
}
|
||||
return(invisible())
|
||||
}
|
||||
@@ -827,11 +913,9 @@ get_current_data <- function(arg_name, call) {
|
||||
# an element `.data` will be in the environment when using `dplyr::select()`
|
||||
# (but not when using `dplyr::filter()`, `dplyr::mutate()` or `dplyr::summarise()`)
|
||||
return(env$`.data`)
|
||||
|
||||
} else if (valid_df(env$xx)) {
|
||||
# an element `xx` will be in the environment for rows + cols, e.g. `example_isolates[c(1:3), carbapenems()]`
|
||||
return(env$xx)
|
||||
|
||||
} else if (valid_df(env$x)) {
|
||||
# an element `x` will be in the environment for only cols, e.g. `example_isolates[, carbapenems()]`
|
||||
return(env$x)
|
||||
@@ -843,17 +927,20 @@ get_current_data <- function(arg_name, call) {
|
||||
if (is.na(arg_name)) {
|
||||
if (isTRUE(is.numeric(call))) {
|
||||
fn <- as.character(sys.call(call + 1)[1])
|
||||
examples <- paste0(", e.g.:\n",
|
||||
" your_data %>% select(", fn, "())\n",
|
||||
" your_data %>% select(column_a, column_b, ", fn, "())\n",
|
||||
" your_data[, ", fn, "()]\n",
|
||||
' your_data[, c("column_a", "column_b", ', fn, "())]")
|
||||
examples <- paste0(
|
||||
", e.g.:\n",
|
||||
" your_data %>% select(", fn, "())\n",
|
||||
" your_data %>% select(column_a, column_b, ", fn, "())\n",
|
||||
" your_data[, ", fn, "()]\n",
|
||||
' your_data[, c("column_a", "column_b", ', fn, "())]"
|
||||
)
|
||||
} else {
|
||||
examples <- ""
|
||||
}
|
||||
stop_("this function must be used inside a `dplyr` verb or `data.frame` call",
|
||||
examples,
|
||||
call = call)
|
||||
examples,
|
||||
call = call
|
||||
)
|
||||
} else {
|
||||
# mimic a base R error that the argument is missing
|
||||
stop_("argument `", arg_name, "` is missing with no default", call = call)
|
||||
@@ -913,17 +1000,21 @@ unique_call_id <- function(entire_session = FALSE, match_fn = NULL) {
|
||||
# and relevant system call (where 'match_fn' is being called in)
|
||||
calls <- sys.calls()
|
||||
if (!identical(Sys.getenv("R_RUN_TINYTEST"), "true") &&
|
||||
!any(as.character(calls[[1]]) %like_case% "run_test_dir|run_test_file|test_all|tinytest|test_package|testthat")) {
|
||||
!any(as.character(calls[[1]]) %like_case% "run_test_dir|run_test_file|test_all|tinytest|test_package|testthat")) {
|
||||
for (i in seq_len(length(calls))) {
|
||||
call_clean <- gsub("[^a-zA-Z0-9_().-]", "", as.character(calls[[i]]), perl = TRUE)
|
||||
if (any(call_clean %like% paste0(match_fn, "\\("), na.rm = TRUE)) {
|
||||
return(c(envir = gsub("<environment: (.*)>", "\\1", utils::capture.output(sys.frames()[[1]]), perl = TRUE),
|
||||
call = paste0(deparse(calls[[i]]), collapse = "")))
|
||||
return(c(
|
||||
envir = gsub("<environment: (.*)>", "\\1", utils::capture.output(sys.frames()[[1]]), perl = TRUE),
|
||||
call = paste0(deparse(calls[[i]]), collapse = "")
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
c(envir = paste0(sample(c(c(0:9), letters[1:6]), size = 32, replace = TRUE), collapse = ""),
|
||||
call = paste0(sample(c(c(0:9), letters[1:6]), size = 32, replace = TRUE), collapse = ""))
|
||||
c(
|
||||
envir = paste0(sample(c(c(0:9), letters[1:6]), size = 32, replace = TRUE), collapse = ""),
|
||||
call = paste0(sample(c(c(0:9), letters[1:6]), size = 32, replace = TRUE), collapse = "")
|
||||
)
|
||||
}
|
||||
|
||||
#' @noRd
|
||||
@@ -932,17 +1023,23 @@ unique_call_id <- function(entire_session = FALSE, match_fn = NULL) {
|
||||
#' @param entire_session show message once per session
|
||||
message_not_thrown_before <- function(fn, ..., entire_session = FALSE) {
|
||||
# this is to prevent that messages/notes will be printed for every dplyr group or more than once per session
|
||||
# e.g. this would show a msg 4 times: example_isolates %>% group_by(hospital_id) %>% filter(mo_is_gram_negative())
|
||||
# e.g. this would show a msg 4 times: example_isolates %>% group_by(ward) %>% filter(mo_is_gram_negative())
|
||||
salt <- gsub("[^a-zA-Z0-9|_-]", "?", paste(c(...), sep = "|", collapse = "|"), perl = TRUE)
|
||||
not_thrown_before <- is.null(pkg_env[[paste0("thrown_msg.", fn, ".", salt)]]) ||
|
||||
!identical(pkg_env[[paste0("thrown_msg.", fn, ".", salt)]],
|
||||
unique_call_id(entire_session = entire_session,
|
||||
match_fn = fn))
|
||||
!identical(
|
||||
pkg_env[[paste0("thrown_msg.", fn, ".", salt)]],
|
||||
unique_call_id(
|
||||
entire_session = entire_session,
|
||||
match_fn = fn
|
||||
)
|
||||
)
|
||||
if (isTRUE(not_thrown_before)) {
|
||||
# message was not thrown before - remember this so on the next run it will return FALSE:
|
||||
assign(x = paste0("thrown_msg.", fn, ".", salt),
|
||||
value = unique_call_id(entire_session = entire_session, match_fn = fn),
|
||||
envir = pkg_env)
|
||||
assign(
|
||||
x = paste0("thrown_msg.", fn, ".", salt),
|
||||
value = unique_call_id(entire_session = entire_session, match_fn = fn),
|
||||
envir = pkg_env
|
||||
)
|
||||
}
|
||||
not_thrown_before
|
||||
}
|
||||
@@ -965,8 +1062,12 @@ has_colour <- function() {
|
||||
if ((cols <- Sys.getenv("RSTUDIO_CONSOLE_COLOR", "")) != "" && !is.na(as.double(cols))) {
|
||||
return(TRUE)
|
||||
}
|
||||
tryCatch(get("isAvailable", envir = asNamespace("rstudioapi"))(), error = function(e) return(FALSE)) &&
|
||||
tryCatch(get("hasFun", envir = asNamespace("rstudioapi"))("getConsoleHasColor"), error = function(e) return(FALSE))
|
||||
tryCatch(get("isAvailable", envir = asNamespace("rstudioapi"))(), error = function(e) {
|
||||
return(FALSE)
|
||||
}) &&
|
||||
tryCatch(get("hasFun", envir = asNamespace("rstudioapi"))("getConsoleHasColor"), error = function(e) {
|
||||
return(FALSE)
|
||||
})
|
||||
}
|
||||
if (rstudio_with_ansi_support() && sink.number() == 0) {
|
||||
return(TRUE)
|
||||
@@ -989,10 +1090,12 @@ has_colour <- function() {
|
||||
if (Sys.getenv("TERM") == "dumb") {
|
||||
return(FALSE)
|
||||
}
|
||||
grepl(pattern = "^screen|^xterm|^vt100|color|ansi|cygwin|linux",
|
||||
x = Sys.getenv("TERM"),
|
||||
ignore.case = TRUE,
|
||||
perl = TRUE)
|
||||
grepl(
|
||||
pattern = "^screen|^xterm|^vt100|color|ansi|cygwin|linux",
|
||||
x = Sys.getenv("TERM"),
|
||||
ignore.case = TRUE,
|
||||
perl = TRUE
|
||||
)
|
||||
}
|
||||
|
||||
# set colours if console has_colour()
|
||||
@@ -1051,15 +1154,15 @@ font_green_bg <- function(..., collapse = " ") {
|
||||
try_colour(..., before = "\033[42m", after = "\033[49m", collapse = collapse)
|
||||
}
|
||||
font_rsi_R_bg <- function(..., collapse = " ") {
|
||||
#ED553B
|
||||
# ED553B
|
||||
try_colour(..., before = "\033[48;5;203m", after = "\033[49m", collapse = collapse)
|
||||
}
|
||||
font_rsi_S_bg <- function(..., collapse = " ") {
|
||||
#3CAEA3
|
||||
# 3CAEA3
|
||||
try_colour(..., before = "\033[48;5;79m", after = "\033[49m", collapse = collapse)
|
||||
}
|
||||
font_rsi_I_bg <- function(..., collapse = " ") {
|
||||
#F6D55C
|
||||
# F6D55C
|
||||
try_colour(..., before = "\033[48;5;222m", after = "\033[49m", collapse = collapse)
|
||||
}
|
||||
font_red_bg <- function(..., collapse = " ") {
|
||||
@@ -1101,8 +1204,10 @@ progress_ticker <- function(n = 1, n_min = 0, print = TRUE, ...) {
|
||||
if (!is.null(progress_bar)) {
|
||||
# so we use progress::progress_bar
|
||||
# a close() method was also added, see below this function
|
||||
pb <- progress_bar$new(format = "[:bar] :percent (:current/:total)",
|
||||
total = n)
|
||||
pb <- progress_bar$new(
|
||||
format = "[:bar] :percent (:current/:total)",
|
||||
total = n
|
||||
)
|
||||
} else {
|
||||
pb <- utils::txtProgressBar(max = n, style = 3)
|
||||
pb$tick <- function() {
|
||||
@@ -1153,6 +1258,19 @@ create_pillar_column <- function(x, ...) {
|
||||
new_pillar_shaft_simple(x, ...)
|
||||
}
|
||||
|
||||
as_original_data_class <- function(df, old_class = NULL) {
|
||||
if ("tbl_df" %in% old_class && pkg_is_available("tibble", also_load = FALSE)) {
|
||||
fn <- import_fn("as_tibble", "tibble")
|
||||
} else if ("tbl_ts" %in% old_class && pkg_is_available("tsibble", also_load = FALSE)) {
|
||||
fn <- import_fn("as_tsibble", "tsibble")
|
||||
} else if ("data.table" %in% old_class && pkg_is_available("data.table", also_load = FALSE)) {
|
||||
fn <- import_fn("as.data.table", "data.table")
|
||||
} else {
|
||||
fn <- base::as.data.frame
|
||||
}
|
||||
fn(df)
|
||||
}
|
||||
|
||||
# copied from vctrs::s3_register by their permission:
|
||||
# https://github.com/r-lib/vctrs/blob/05968ce8e669f73213e3e894b5f4424af4f46316/R/register-s3.R
|
||||
s3_register <- function(generic, class, method = NULL) {
|
||||
@@ -1167,16 +1285,14 @@ s3_register <- function(generic, class, method = NULL) {
|
||||
top <- topenv(caller)
|
||||
if (isNamespace(top)) {
|
||||
asNamespace(environmentName(top))
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
caller
|
||||
}
|
||||
}
|
||||
get_method <- function(method, env) {
|
||||
if (is.null(method)) {
|
||||
get(paste0(generic, ".", class), envir = get_method_env())
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
method
|
||||
}
|
||||
}
|
||||
@@ -1202,19 +1318,30 @@ s3_register <- function(generic, class, method = NULL) {
|
||||
round2 <- function(x, digits = 1, force_zero = TRUE) {
|
||||
x <- as.double(x)
|
||||
# https://stackoverflow.com/a/12688836/4575331
|
||||
val <- (trunc((abs(x) * 10 ^ digits) + 0.5) / 10 ^ digits) * sign(x)
|
||||
val <- (trunc((abs(x) * 10^digits) + 0.5) / 10^digits) * sign(x)
|
||||
if (digits > 0 & force_zero == TRUE) {
|
||||
values_trans <- val[val != as.integer(val) & !is.na(val)]
|
||||
val[val != as.integer(val) & !is.na(val)] <- paste0(values_trans,
|
||||
strrep("0",
|
||||
max(0,
|
||||
digits - nchar(
|
||||
format(
|
||||
as.double(
|
||||
gsub(".*[.](.*)$",
|
||||
"\\1",
|
||||
values_trans)),
|
||||
scientific = FALSE)))))
|
||||
val[val != as.integer(val) & !is.na(val)] <- paste0(
|
||||
values_trans,
|
||||
strrep(
|
||||
"0",
|
||||
max(
|
||||
0,
|
||||
digits - nchar(
|
||||
format(
|
||||
as.double(
|
||||
gsub(
|
||||
".*[.](.*)$",
|
||||
"\\1",
|
||||
values_trans
|
||||
)
|
||||
),
|
||||
scientific = FALSE
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
as.double(val)
|
||||
}
|
||||
@@ -1231,12 +1358,20 @@ percentage <- function(x, digits = NULL, ...) {
|
||||
if (minimum > maximum) {
|
||||
minimum <- maximum
|
||||
}
|
||||
max_places <- max(unlist(lapply(strsplit(sub("0+$", "",
|
||||
as.character(x * 100)), ".", fixed = TRUE),
|
||||
function(y) ifelse(length(y) == 2, nchar(y[2]), 0))), na.rm = TRUE)
|
||||
max_places <- max(unlist(lapply(
|
||||
strsplit(sub(
|
||||
"0+$", "",
|
||||
as.character(x * 100)
|
||||
), ".", fixed = TRUE),
|
||||
function(y) ifelse(length(y) == 2, nchar(y[2]), 0)
|
||||
)), na.rm = TRUE)
|
||||
max(min(max_places,
|
||||
maximum, na.rm = TRUE),
|
||||
minimum, na.rm = TRUE)
|
||||
maximum,
|
||||
na.rm = TRUE
|
||||
),
|
||||
minimum,
|
||||
na.rm = TRUE
|
||||
)
|
||||
}
|
||||
|
||||
# format_percentage() function
|
||||
@@ -1250,10 +1385,11 @@ percentage <- function(x, digits = NULL, ...) {
|
||||
|
||||
# round right: percentage(0.4455) and format(as.percentage(0.4455), 1) should return "44.6%", not "44.5%"
|
||||
x_formatted <- format(round2(as.double(x), digits = digits + 2) * 100,
|
||||
scientific = FALSE,
|
||||
digits = max(1, digits),
|
||||
nsmall = digits,
|
||||
...)
|
||||
scientific = FALSE,
|
||||
digits = max(1, digits),
|
||||
nsmall = digits,
|
||||
...
|
||||
)
|
||||
x_formatted <- paste0(x_formatted, "%")
|
||||
x_formatted[!grepl(pattern = "^[0-9.,e-]+$", x = x)] <- NA_character_
|
||||
x_formatted
|
||||
@@ -1265,9 +1401,12 @@ percentage <- function(x, digits = NULL, ...) {
|
||||
# max one digit if undefined
|
||||
digits <- getdecimalplaces(x, minimum = 0, maximum = 1)
|
||||
}
|
||||
format_percentage(structure(.Data = as.double(x),
|
||||
class = c("percentage", "numeric")),
|
||||
digits = digits, ...)
|
||||
format_percentage(structure(
|
||||
.Data = as.double(x),
|
||||
class = c("percentage", "numeric")
|
||||
),
|
||||
digits = digits, ...
|
||||
)
|
||||
}
|
||||
|
||||
time_start_tracking <- function() {
|
||||
@@ -1283,13 +1422,16 @@ time_track <- function(name = NULL) {
|
||||
# see here for the full list: https://github.com/r-lib/backports
|
||||
strrep <- function(x, times) {
|
||||
x <- as.character(x)
|
||||
if (length(x) == 0L)
|
||||
if (length(x) == 0L) {
|
||||
return(x)
|
||||
}
|
||||
unlist(.mapply(function(x, times) {
|
||||
if (is.na(x) || is.na(times))
|
||||
if (is.na(x) || is.na(times)) {
|
||||
return(NA_character_)
|
||||
if (times <= 0L)
|
||||
}
|
||||
if (times <= 0L) {
|
||||
return("")
|
||||
}
|
||||
paste0(replicate(times, x), collapse = "")
|
||||
}, list(x = x, times = times), MoreArgs = list()), use.names = FALSE)
|
||||
}
|
||||
@@ -1297,9 +1439,10 @@ trimws <- function(x, which = c("both", "left", "right"), whitespace = "[ \t\r\n
|
||||
which <- match.arg(which)
|
||||
mysub <- function(re, x) sub(re, "", x, perl = TRUE)
|
||||
switch(which,
|
||||
left = mysub(paste0("^", whitespace, "+"), x),
|
||||
right = mysub(paste0(whitespace, "+$"), x),
|
||||
both = mysub(paste0(whitespace, "+$"), mysub(paste0("^", whitespace, "+"), x)))
|
||||
left = mysub(paste0("^", whitespace, "+"), x),
|
||||
right = mysub(paste0(whitespace, "+$"), x),
|
||||
both = mysub(paste0(whitespace, "+$"), mysub(paste0("^", whitespace, "+"), x))
|
||||
)
|
||||
}
|
||||
isFALSE <- function(x) {
|
||||
is.logical(x) && length(x) == 1L && !is.na(x) && !x
|
||||
@@ -1333,7 +1476,7 @@ if (getRversion() < "3.1") {
|
||||
sinpi <- function(...) 1
|
||||
tanpi <- function(...) 1
|
||||
}
|
||||
dir.exists <- function (paths) {
|
||||
x = base::file.info(paths)$isdir
|
||||
dir.exists <- function(paths) {
|
||||
x <- base::file.info(paths)$isdir
|
||||
!is.na(x) & x
|
||||
}
|
||||
|
||||
@@ -206,7 +206,9 @@ pm_distinct <- function(.data, ...) {
|
||||
}
|
||||
|
||||
pm_distinct.default <- function(.data, ..., .keep_all = FALSE) {
|
||||
if (ncol(.data) == 0L) return(.data[1, ])
|
||||
if (ncol(.data) == 0L) {
|
||||
return(.data[1, ])
|
||||
}
|
||||
cols <- pm_deparse_dots(...)
|
||||
col_names <- names(cols)
|
||||
col_len <- length(cols)
|
||||
@@ -336,7 +338,9 @@ pm_print.grouped_data <- function(x, ..., digits = NULL, quote = FALSE, right =
|
||||
}
|
||||
|
||||
pm_group_data <- function(.data) {
|
||||
if (!pm_has_groups(.data)) return(data.frame(.rows = I(list(seq_len(nrow(.data))))))
|
||||
if (!pm_has_groups(.data)) {
|
||||
return(data.frame(.rows = I(list(seq_len(nrow(.data))))))
|
||||
}
|
||||
pm_groups <- pm_get_groups(.data)
|
||||
pm_group_data_worker(.data, pm_groups)
|
||||
}
|
||||
@@ -360,7 +364,9 @@ pm_group_rows <- function(.data) {
|
||||
}
|
||||
|
||||
pm_group_indices <- function(.data) {
|
||||
if (!pm_has_groups(.data)) return(rep(1L, nrow(.data)))
|
||||
if (!pm_has_groups(.data)) {
|
||||
return(rep(1L, nrow(.data)))
|
||||
}
|
||||
pm_groups <- pm_get_groups(.data)
|
||||
res <- unique(.data[, pm_groups, drop = FALSE])
|
||||
res <- res[do.call(order, lapply(pm_groups, function(x) res[, x])), , drop = FALSE]
|
||||
@@ -417,7 +423,9 @@ pm_group_keys <- function(.data) {
|
||||
pm_context$setup(.data)
|
||||
res <- pm_context$.data[, pm_context$get_colnames() %in% pm_groups, drop = FALSE]
|
||||
res <- res[!duplicated(res), , drop = FALSE]
|
||||
if (nrow(res) == 0L) return(res)
|
||||
if (nrow(res) == 0L) {
|
||||
return(res)
|
||||
}
|
||||
class(res) <- "data.frame"
|
||||
res <- res[do.call(order, lapply(pm_groups, function(x) res[, x])), , drop = FALSE]
|
||||
rownames(res) <- NULL
|
||||
@@ -509,7 +517,9 @@ pm_join_message <- function(by) {
|
||||
pm_lag <- function(x, pm_n = 1L, default = NA) {
|
||||
if (inherits(x, "ts")) stop("`x` must be a vector, not a `ts` object, do you want `stats::pm_lag()`?")
|
||||
if (length(pm_n) != 1L || !is.numeric(pm_n) || pm_n < 0L) stop("`pm_n` must be a nonnegative integer scalar")
|
||||
if (pm_n == 0L) return(x)
|
||||
if (pm_n == 0L) {
|
||||
return(x)
|
||||
}
|
||||
tryCatch(
|
||||
storage.mode(default) <- typeof(x),
|
||||
warning = function(w) {
|
||||
@@ -525,7 +535,9 @@ pm_lag <- function(x, pm_n = 1L, default = NA) {
|
||||
|
||||
pm_lead <- function(x, pm_n = 1L, default = NA) {
|
||||
if (length(pm_n) != 1L || !is.numeric(pm_n) || pm_n < 0L) stop("pm_n must be a nonnegative integer scalar")
|
||||
if (pm_n == 0L) return(x)
|
||||
if (pm_n == 0L) {
|
||||
return(x)
|
||||
}
|
||||
tryCatch(
|
||||
storage.mode(default) <- typeof(x),
|
||||
warning = function(w) {
|
||||
@@ -565,7 +577,9 @@ pm_mutate.grouped_data <- function(.data, ...) {
|
||||
}
|
||||
pm_n_distinct <- function(..., na.rm = FALSE) {
|
||||
res <- c(...)
|
||||
if (is.list(res)) return(nrow(unique(as.data.frame(res, stringsAsFactors = FALSE))))
|
||||
if (is.list(res)) {
|
||||
return(nrow(unique(as.data.frame(res, stringsAsFactors = FALSE))))
|
||||
}
|
||||
if (isTRUE(na.rm)) res <- res[!is.na(res)]
|
||||
length(unique(res))
|
||||
}
|
||||
@@ -593,7 +607,7 @@ pm_pull <- function(.data, var = -1) {
|
||||
} else if (var_deparse %in% col_names) {
|
||||
var <- var_deparse
|
||||
}
|
||||
.data[, var]
|
||||
.data[, var, drop = TRUE]
|
||||
}
|
||||
pm_set_names <- function(object = nm, nm) {
|
||||
names(object) <- nm
|
||||
@@ -669,15 +683,16 @@ pm_rename_with <- function(.data, .fn, .cols = pm_everything(), ...) {
|
||||
.data
|
||||
}
|
||||
pm_replace_with <- function(x, i, val, arg_name) {
|
||||
if (is.null(val)) return(x)
|
||||
if (is.null(val)) {
|
||||
return(x)
|
||||
}
|
||||
pm_check_length(val, x, arg_name)
|
||||
pm_check_type(val, x, arg_name)
|
||||
pm_check_class(val, x, arg_name)
|
||||
i[is.na(i)] <- FALSE
|
||||
if (length(val) == 1L) {
|
||||
x[i] <- val
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
x[i] <- val[i]
|
||||
}
|
||||
x
|
||||
@@ -686,7 +701,9 @@ pm_replace_with <- function(x, i, val, arg_name) {
|
||||
pm_check_length <- function(x, y, arg_name) {
|
||||
length_x <- length(x)
|
||||
length_y <- length(y)
|
||||
if (all(length_x %in% c(1L, length_y))) return()
|
||||
if (all(length_x %in% c(1L, length_y))) {
|
||||
return()
|
||||
}
|
||||
if (length_y == 1) {
|
||||
stop(arg_name, " must be length 1, not ", paste(length_x, sep = ", "))
|
||||
} else {
|
||||
@@ -697,15 +714,21 @@ pm_check_length <- function(x, y, arg_name) {
|
||||
pm_check_type <- function(x, y, arg_name) {
|
||||
x_type <- typeof(x)
|
||||
y_type <- typeof(y)
|
||||
if (identical(x_type, y_type)) return()
|
||||
if (identical(x_type, y_type)) {
|
||||
return()
|
||||
}
|
||||
stop(arg_name, " must be `", y_type, "`, not `", x_type, "`")
|
||||
}
|
||||
|
||||
pm_check_class <- function(x, y, arg_name) {
|
||||
if (!is.object(x)) return()
|
||||
if (!is.object(x)) {
|
||||
return()
|
||||
}
|
||||
exp_classes <- class(y)
|
||||
out_classes <- class(x)
|
||||
if (identical(out_classes, exp_classes)) return()
|
||||
if (identical(out_classes, exp_classes)) {
|
||||
return()
|
||||
}
|
||||
stop(arg_name, " must have class `", exp_classes, "`, not class `", out_classes, "`")
|
||||
}
|
||||
pm_rownames_to_column <- function(.data, var = "rowname") {
|
||||
@@ -827,8 +850,7 @@ pm_select_positions <- function(.data, ..., .group_pos = FALSE) {
|
||||
|
||||
pm_eval_expr <- function(x) {
|
||||
type <- typeof(x)
|
||||
switch(
|
||||
type,
|
||||
switch(type,
|
||||
"integer" = x,
|
||||
"double" = as.integer(x),
|
||||
"character" = pm_select_char(x),
|
||||
@@ -864,8 +886,7 @@ pm_select_symbol <- function(expr) {
|
||||
|
||||
pm_eval_call <- function(x) {
|
||||
type <- as.character(x[[1]])
|
||||
switch(
|
||||
type,
|
||||
switch(type,
|
||||
`:` = pm_select_seq(x),
|
||||
`!` = pm_select_negate(x),
|
||||
`-` = pm_select_minus(x),
|
||||
@@ -1029,7 +1050,7 @@ pm_is_wholenumber <- function(x) {
|
||||
x %% 1L == 0L
|
||||
}
|
||||
|
||||
pm_seq2 <- function (from, to) {
|
||||
pm_seq2 <- function(from, to) {
|
||||
if (length(from) != 1) stop("`from` must be length one")
|
||||
if (length(to) != 1) stop("`to` must be length one")
|
||||
if (from > to) integer() else seq.int(from, to)
|
||||
@@ -1041,19 +1062,25 @@ pm_is_function <- function(x, frame) {
|
||||
warning = function(w) FALSE,
|
||||
error = function(e) FALSE
|
||||
)
|
||||
if (isTRUE(res)) return(res)
|
||||
if (isTRUE(res)) {
|
||||
return(res)
|
||||
}
|
||||
res <- tryCatch(
|
||||
is.function(eval(x)),
|
||||
warning = function(w) FALSE,
|
||||
error = function(e) FALSE
|
||||
)
|
||||
if (isTRUE(res)) return(res)
|
||||
if (isTRUE(res)) {
|
||||
return(res)
|
||||
}
|
||||
res <- tryCatch(
|
||||
is.function(eval(as.symbol(deparse(substitute(x))))),
|
||||
warning = function(w) FALSE,
|
||||
error = function(e) FALSE
|
||||
)
|
||||
if (isTRUE(res)) return(res)
|
||||
if (isTRUE(res)) {
|
||||
return(res)
|
||||
}
|
||||
FALSE
|
||||
}
|
||||
|
||||
|
||||
@@ -65,26 +65,25 @@
|
||||
#' as.ab("ERYT")
|
||||
#' as.ab("ERY")
|
||||
#' as.ab("eritromicine") # spelled wrong, yet works
|
||||
#' as.ab("Erythrocin") # trade name
|
||||
#' as.ab("Romycin") # trade name
|
||||
#' as.ab("Erythrocin") # trade name
|
||||
#' as.ab("Romycin") # trade name
|
||||
#'
|
||||
#' # spelling from different languages and dyslexia are no problem
|
||||
#' ab_atc("ceftriaxon")
|
||||
#' ab_atc("cephtriaxone") # small spelling error
|
||||
#' ab_atc("cephthriaxone") # or a bit more severe
|
||||
#' ab_atc("cephtriaxone") # small spelling error
|
||||
#' ab_atc("cephthriaxone") # or a bit more severe
|
||||
#' ab_atc("seephthriaaksone") # and even this works
|
||||
#'
|
||||
#' # use ab_* functions to get a specific properties (see ?ab_property);
|
||||
#' # they use as.ab() internally:
|
||||
#' ab_name("J01FA01") # "Erythromycin"
|
||||
#' ab_name("eryt") # "Erythromycin"
|
||||
#' ab_name("J01FA01") # "Erythromycin"
|
||||
#' ab_name("eryt") # "Erythromycin"
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # you can quickly rename <rsi> columns using dplyr >= 1.0.0:
|
||||
#' example_isolates %>%
|
||||
#' rename_with(as.ab, where(is.rsi))
|
||||
#'
|
||||
#' }
|
||||
#' }
|
||||
as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
@@ -100,7 +99,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
if (all(x %in% c(AB_lookup$ab, NA))) {
|
||||
# all valid AB codes, but not yet right class
|
||||
return(set_clean_class(x,
|
||||
new_class = c("ab", "character")))
|
||||
new_class = c("ab", "character")
|
||||
))
|
||||
}
|
||||
|
||||
initial_search <- is.null(list(...)$initial_search)
|
||||
@@ -125,6 +125,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
x <- unique(x_bak_clean) # this means that every x is in fact generalise_antibiotic_name(x)
|
||||
x_new <- rep(NA_character_, length(x))
|
||||
x_unknown <- character(0)
|
||||
x_unknown_ATCs <- character(0)
|
||||
|
||||
note_if_more_than_one_found <- function(found, index, from_text) {
|
||||
if (initial_search == TRUE & isTRUE(length(from_text) > 1)) {
|
||||
@@ -133,8 +134,10 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
abnames <- abnames[!abnames %in% c("clavulanic acid", "avibactam")]
|
||||
}
|
||||
if (length(abnames) > 1) {
|
||||
message_("More than one result was found for item ", index, ": ",
|
||||
vector_and(abnames, quotes = FALSE))
|
||||
message_(
|
||||
"More than one result was found for item ", index, ": ",
|
||||
vector_and(abnames, quotes = FALSE)
|
||||
)
|
||||
}
|
||||
}
|
||||
found[1L]
|
||||
@@ -147,12 +150,18 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
known_codes_atc <- vapply(FUN.VALUE = logical(1), x, function(x_) x_ %in% unlist(AB_lookup$atc), USE.NAMES = FALSE)
|
||||
known_codes_cid <- x %in% AB_lookup$cid
|
||||
x_new[known_codes_ab] <- AB_lookup$ab[match(x[known_codes_ab], AB_lookup$ab)]
|
||||
x_new[known_codes_atc] <- AB_lookup$ab[vapply(FUN.VALUE = integer(1),
|
||||
x[known_codes_atc],
|
||||
function(x_) which(vapply(FUN.VALUE = logical(1),
|
||||
AB_lookup$atc,
|
||||
function(atc) x_ %in% atc))[1L],
|
||||
USE.NAMES = FALSE)]
|
||||
x_new[known_codes_atc] <- AB_lookup$ab[vapply(
|
||||
FUN.VALUE = integer(1),
|
||||
x[known_codes_atc],
|
||||
function(x_) {
|
||||
which(vapply(
|
||||
FUN.VALUE = logical(1),
|
||||
AB_lookup$atc,
|
||||
function(atc) x_ %in% atc
|
||||
))[1L]
|
||||
},
|
||||
USE.NAMES = FALSE
|
||||
)]
|
||||
x_new[known_codes_cid] <- AB_lookup$ab[match(x[known_codes_cid], AB_lookup$cid)]
|
||||
already_known <- known_names | known_codes_ab | known_codes_atc | known_codes_cid
|
||||
|
||||
@@ -162,7 +171,6 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
for (i in which(!already_known)) {
|
||||
|
||||
if (initial_search == TRUE) {
|
||||
progress$tick()
|
||||
}
|
||||
@@ -171,15 +179,23 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
next
|
||||
}
|
||||
if (identical(x[i], "") |
|
||||
# prevent "bacteria" from coercing to TMP, since Bacterial is a brand name of it:
|
||||
identical(tolower(x[i]), "bacteria")) {
|
||||
# prevent "bacteria" from coercing to TMP, since Bacterial is a brand name of it:
|
||||
identical(tolower(x[i]), "bacteria")) {
|
||||
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
|
||||
next
|
||||
}
|
||||
if (x[i] %like_case% "[A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9]") {
|
||||
# seems an ATC code, but the available ones are in `already_known`, so:
|
||||
x_unknown <- c(x_unknown, x[i])
|
||||
x_unknown_ATCs <- c(x_unknown_ATCs, x[i])
|
||||
x_new[i] <- NA_character_
|
||||
next
|
||||
}
|
||||
|
||||
if (fast_mode == FALSE && flag_multiple_results == TRUE && x[i] %like% "[ ]") {
|
||||
from_text <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]]),
|
||||
error = function(e) character(0))
|
||||
error = function(e) character(0)
|
||||
)
|
||||
} else {
|
||||
from_text <- character(0)
|
||||
}
|
||||
@@ -191,8 +207,10 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
# exact LOINC code
|
||||
loinc_found <- unlist(lapply(AB_lookup$generalised_loinc,
|
||||
function(s) x[i] %in% s))
|
||||
loinc_found <- unlist(lapply(
|
||||
AB_lookup$generalised_loinc,
|
||||
function(s) x[i] %in% s
|
||||
))
|
||||
found <- antibiotics$ab[loinc_found == TRUE]
|
||||
if (length(found) > 0) {
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
@@ -200,8 +218,10 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
# exact synonym
|
||||
synonym_found <- unlist(lapply(AB_lookup$generalised_synonyms,
|
||||
function(s) x[i] %in% s))
|
||||
synonym_found <- unlist(lapply(
|
||||
AB_lookup$generalised_synonyms,
|
||||
function(s) x[i] %in% s
|
||||
))
|
||||
found <- antibiotics$ab[synonym_found == TRUE]
|
||||
if (length(found) > 0) {
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
@@ -209,9 +229,11 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
# exact abbreviation
|
||||
abbr_found <- unlist(lapply(AB_lookup$generalised_abbreviations,
|
||||
# require at least 2 characters for abbreviations
|
||||
function(s) x[i] %in% s & nchar(x[i]) >= 2))
|
||||
abbr_found <- unlist(lapply(
|
||||
AB_lookup$generalised_abbreviations,
|
||||
# require at least 2 characters for abbreviations
|
||||
function(s) x[i] %in% s & nchar(x[i]) >= 2
|
||||
))
|
||||
found <- antibiotics$ab[abbr_found == TRUE]
|
||||
if (length(found) > 0) {
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
@@ -235,7 +257,6 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
x_spelling <- x[i]
|
||||
if (already_regex == FALSE) {
|
||||
|
||||
x_spelling <- gsub("[IY]+", "[IY]+", x_spelling, perl = TRUE)
|
||||
x_spelling <- gsub("(C|K|Q|QU|S|Z|X|KS)+", "(C|K|Q|QU|S|Z|X|KS)+", x_spelling, perl = TRUE)
|
||||
x_spelling <- gsub("(PH|F|V)+", "(PH|F|V)+", x_spelling, perl = TRUE)
|
||||
@@ -260,21 +281,23 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
# try if name starts with it
|
||||
found <- antibiotics[which(AB_lookup$generalised_name %like% paste0("^", x_spelling)), ]$ab
|
||||
found <- antibiotics[which(AB_lookup$generalised_name %like% paste0("^", x_spelling)), "ab", drop = TRUE]
|
||||
if (length(found) > 0) {
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
next
|
||||
}
|
||||
# try if name ends with it
|
||||
found <- antibiotics[which(AB_lookup$generalised_name %like% paste0(x_spelling, "$")), ]$ab
|
||||
found <- antibiotics[which(AB_lookup$generalised_name %like% paste0(x_spelling, "$")), "ab", drop = TRUE]
|
||||
if (nchar(x[i]) >= 4 & length(found) > 0) {
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
next
|
||||
}
|
||||
|
||||
# and try if any synonym starts with it
|
||||
synonym_found <- unlist(lapply(AB_lookup$generalised_synonyms,
|
||||
function(s) any(s %like% paste0("^", x_spelling))))
|
||||
synonym_found <- unlist(lapply(
|
||||
AB_lookup$generalised_synonyms,
|
||||
function(s) any(s %like% paste0("^", x_spelling))
|
||||
))
|
||||
found <- antibiotics$ab[synonym_found == TRUE]
|
||||
if (length(found) > 0) {
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
@@ -305,19 +328,23 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
# transform back from other languages and try again
|
||||
x_translated <- paste(lapply(strsplit(x[i], "[^A-Z0-9]"),
|
||||
function(y) {
|
||||
for (i in seq_len(length(y))) {
|
||||
for (lang in LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED != "en"]) {
|
||||
y[i] <- ifelse(tolower(y[i]) %in% tolower(TRANSLATIONS[, lang, drop = TRUE]),
|
||||
TRANSLATIONS[which(tolower(TRANSLATIONS[, lang, drop = TRUE]) == tolower(y[i]) &
|
||||
!isFALSE(TRANSLATIONS$fixed)), "pattern"],
|
||||
y[i])
|
||||
}
|
||||
}
|
||||
generalise_antibiotic_name(y)
|
||||
})[[1]],
|
||||
collapse = "/")
|
||||
x_translated <- paste(lapply(
|
||||
strsplit(x[i], "[^A-Z0-9]"),
|
||||
function(y) {
|
||||
for (i in seq_len(length(y))) {
|
||||
for (lang in LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED != "en"]) {
|
||||
y[i] <- ifelse(tolower(y[i]) %in% tolower(TRANSLATIONS[, lang, drop = TRUE]),
|
||||
TRANSLATIONS[which(tolower(TRANSLATIONS[, lang, drop = TRUE]) == tolower(y[i]) &
|
||||
!isFALSE(TRANSLATIONS$fixed)), "pattern"],
|
||||
y[i]
|
||||
)
|
||||
}
|
||||
}
|
||||
generalise_antibiotic_name(y)
|
||||
}
|
||||
)[[1]],
|
||||
collapse = "/"
|
||||
)
|
||||
x_translated_guess <- suppressWarnings(as.ab(x_translated, initial_search = FALSE))
|
||||
if (!is.na(x_translated_guess)) {
|
||||
x_new[i] <- x_translated_guess
|
||||
@@ -325,17 +352,21 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
# now also try to coerce brandname combinations like "Amoxy/clavulanic acid"
|
||||
x_translated <- paste(lapply(strsplit(x_translated, "[^A-Z0-9 ]"),
|
||||
function(y) {
|
||||
for (i in seq_len(length(y))) {
|
||||
y_name <- suppressWarnings(ab_name(y[i], language = NULL, initial_search = FALSE))
|
||||
y[i] <- ifelse(!is.na(y_name),
|
||||
y_name,
|
||||
y[i])
|
||||
}
|
||||
generalise_antibiotic_name(y)
|
||||
})[[1]],
|
||||
collapse = "/")
|
||||
x_translated <- paste(lapply(
|
||||
strsplit(x_translated, "[^A-Z0-9 ]"),
|
||||
function(y) {
|
||||
for (i in seq_len(length(y))) {
|
||||
y_name <- suppressWarnings(ab_name(y[i], language = NULL, initial_search = FALSE))
|
||||
y[i] <- ifelse(!is.na(y_name),
|
||||
y_name,
|
||||
y[i]
|
||||
)
|
||||
}
|
||||
generalise_antibiotic_name(y)
|
||||
}
|
||||
)[[1]],
|
||||
collapse = "/"
|
||||
)
|
||||
x_translated_guess <- suppressWarnings(as.ab(x_translated, initial_search = FALSE))
|
||||
if (!is.na(x_translated_guess)) {
|
||||
x_new[i] <- x_translated_guess
|
||||
@@ -364,7 +395,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
found <- from_text[1L]
|
||||
} else {
|
||||
found <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]][1L]),
|
||||
error = function(e) NA_character_)
|
||||
error = function(e) NA_character_
|
||||
)
|
||||
}
|
||||
if (!is.na(found)) {
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
@@ -428,7 +460,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
substr(x[i], j + 1, j + 1),
|
||||
substr(x[i], j, j),
|
||||
# ending part:
|
||||
substr(x[i], j + 2, nchar(x[i])))
|
||||
substr(x[i], j + 2, nchar(x[i]))
|
||||
)
|
||||
found <- suppressWarnings(as.ab(x_switched, initial_search = FALSE))
|
||||
if (!is.na(found)) {
|
||||
break
|
||||
@@ -438,7 +471,6 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
x_new[i] <- found[1L]
|
||||
next
|
||||
}
|
||||
|
||||
} # end of initial_search = TRUE
|
||||
|
||||
# not found
|
||||
@@ -450,16 +482,19 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
# take failed ATC codes apart from rest
|
||||
x_unknown_ATCs <- x_unknown[x_unknown %like% "[A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9]"]
|
||||
x_unknown <- x_unknown[!x_unknown %in% x_unknown_ATCs]
|
||||
if (length(x_unknown_ATCs) > 0 & fast_mode == FALSE) {
|
||||
warning_("in `as.ab()`: these ATC codes are not (yet) in the antibiotics data set: ",
|
||||
vector_and(x_unknown_ATCs), ".")
|
||||
if (length(x_unknown_ATCs) > 0 && fast_mode == FALSE) {
|
||||
warning_(
|
||||
"in `as.ab()`: these ATC codes are not (yet) in the antibiotics data set: ",
|
||||
vector_and(x_unknown_ATCs), "."
|
||||
)
|
||||
}
|
||||
x_unknown <- x_unknown[!x_unknown %in% x_unknown_ATCs]
|
||||
|
||||
if (length(x_unknown) > 0 & fast_mode == FALSE) {
|
||||
warning_("in `as.ab()`: these values could not be coerced to a valid antimicrobial ID: ",
|
||||
vector_and(x_unknown), ".")
|
||||
if (length(x_unknown) > 0 && fast_mode == FALSE) {
|
||||
warning_(
|
||||
"in `as.ab()`: these values could not be coerced to a valid antimicrobial ID: ",
|
||||
vector_and(x_unknown), "."
|
||||
)
|
||||
}
|
||||
|
||||
x_result <- x_new[match(x_bak_clean, x)]
|
||||
@@ -468,7 +503,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
}
|
||||
|
||||
set_clean_class(x_result,
|
||||
new_class = c("ab", "character"))
|
||||
new_class = c("ab", "character")
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname as.ab
|
||||
|
||||
@@ -68,22 +68,28 @@
|
||||
#' ab_group(abx[[1]])
|
||||
#'
|
||||
#' if (require("dplyr")) {
|
||||
#' tibble(clinical_text = c("given 400mg cipro and 500 mg amox",
|
||||
#' "started on doxy iv today")) %>%
|
||||
#' mutate(abx_codes = ab_from_text(clinical_text),
|
||||
#' abx_doses = ab_from_text(clinical_text, type = "doses"),
|
||||
#' abx_admin = ab_from_text(clinical_text, type = "admin"),
|
||||
#' abx_coll = ab_from_text(clinical_text, collapse = "|"),
|
||||
#' abx_coll_names = ab_from_text(clinical_text,
|
||||
#' collapse = "|",
|
||||
#' translate_ab = "name"),
|
||||
#' abx_coll_doses = ab_from_text(clinical_text,
|
||||
#' type = "doses",
|
||||
#' collapse = "|"),
|
||||
#' abx_coll_admin = ab_from_text(clinical_text,
|
||||
#' type = "admin",
|
||||
#' collapse = "|"))
|
||||
#'
|
||||
#' tibble(clinical_text = c(
|
||||
#' "given 400mg cipro and 500 mg amox",
|
||||
#' "started on doxy iv today"
|
||||
#' )) %>%
|
||||
#' mutate(
|
||||
#' abx_codes = ab_from_text(clinical_text),
|
||||
#' abx_doses = ab_from_text(clinical_text, type = "doses"),
|
||||
#' abx_admin = ab_from_text(clinical_text, type = "admin"),
|
||||
#' abx_coll = ab_from_text(clinical_text, collapse = "|"),
|
||||
#' abx_coll_names = ab_from_text(clinical_text,
|
||||
#' collapse = "|",
|
||||
#' translate_ab = "name"
|
||||
#' ),
|
||||
#' abx_coll_doses = ab_from_text(clinical_text,
|
||||
#' type = "doses",
|
||||
#' collapse = "|"
|
||||
#' ),
|
||||
#' abx_coll_admin = ab_from_text(clinical_text,
|
||||
#' type = "admin",
|
||||
#' collapse = "|"
|
||||
#' )
|
||||
#' )
|
||||
#' }
|
||||
#' }
|
||||
ab_from_text <- function(text,
|
||||
@@ -112,11 +118,10 @@ ab_from_text <- function(text,
|
||||
on.exit(close(progress))
|
||||
|
||||
if (type %like% "(drug|ab|anti)") {
|
||||
|
||||
translate_ab <- get_translate_ab(translate_ab)
|
||||
|
||||
if (isTRUE(thorough_search) |
|
||||
(isTRUE(is.null(thorough_search)) & max(vapply(FUN.VALUE = double(1), text_split_all, length), na.rm = TRUE) <= 3)) {
|
||||
(isTRUE(is.null(thorough_search)) & max(vapply(FUN.VALUE = double(1), text_split_all, length), na.rm = TRUE) <= 3)) {
|
||||
text_split_all <- text_split_all[nchar(text_split_all) >= 4 & grepl("[a-z]+", text_split_all)]
|
||||
result <- lapply(text_split_all, function(text_split) {
|
||||
progress$tick()
|
||||
@@ -124,7 +129,6 @@ ab_from_text <- function(text,
|
||||
out <- as.ab(text_split, ...)
|
||||
)
|
||||
})
|
||||
|
||||
} else {
|
||||
# no thorough search
|
||||
abbr <- unlist(antibiotics$abbreviations)
|
||||
@@ -136,19 +140,24 @@ ab_from_text <- function(text,
|
||||
synonyms_part1 <- synonyms[seq_len(0.5 * length(synonyms))]
|
||||
synonyms_part2 <- synonyms[!synonyms %in% synonyms_part1]
|
||||
to_regex <- function(x) {
|
||||
paste0("^(",
|
||||
paste0(unique(gsub("[^a-z0-9]+", "", sort(tolower(x)))), collapse = "|"),
|
||||
").*")
|
||||
paste0(
|
||||
"^(",
|
||||
paste0(unique(gsub("[^a-z0-9]+", "", sort(tolower(x)))), collapse = "|"),
|
||||
").*"
|
||||
)
|
||||
}
|
||||
result <- lapply(text_split_all, function(text_split) {
|
||||
progress$tick()
|
||||
suppressWarnings(
|
||||
out <- as.ab(unique(c(text_split[text_split %like_case% to_regex(abbr)],
|
||||
text_split[text_split %like_case% to_regex(names_atc)],
|
||||
text_split[text_split %like_case% to_regex(synonyms_part1)],
|
||||
text_split[text_split %like_case% to_regex(synonyms_part2)])
|
||||
),
|
||||
...)
|
||||
out <- as.ab(
|
||||
unique(c(
|
||||
text_split[text_split %like_case% to_regex(abbr)],
|
||||
text_split[text_split %like_case% to_regex(names_atc)],
|
||||
text_split[text_split %like_case% to_regex(synonyms_part1)],
|
||||
text_split[text_split %like_case% to_regex(synonyms_part2)]
|
||||
)),
|
||||
...
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -165,15 +174,13 @@ ab_from_text <- function(text,
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
} else if (type %like% "dos") {
|
||||
text_split_all <- strsplit(text, " ")
|
||||
result <- lapply(text_split_all, function(text_split) {
|
||||
text_split <- text_split[text_split %like% "^[0-9]{2,}(/[0-9]+)?[a-z]*$"]
|
||||
# only left part of "/", like 500 in "500/125"
|
||||
text_split <- gsub("/.*", "", text_split)
|
||||
text_split <- gsub("/.*", "", text_split)
|
||||
text_split <- gsub(",", ".", text_split, fixed = TRUE) # foreign system using comma as decimal sep
|
||||
text_split <- as.double(gsub("[^0-9.]", "", text_split))
|
||||
# minimal 100 units/mg and no years that unlikely doses
|
||||
@@ -185,7 +192,6 @@ ab_from_text <- function(text,
|
||||
NA_real_
|
||||
}
|
||||
})
|
||||
|
||||
} else if (type %like% "adm") {
|
||||
result <- lapply(text_split_all, function(text_split) {
|
||||
text_split <- text_split[text_split %like% "(^iv$|intraven|^po$|per os|oral|implant|inhal|instill|nasal|paren|rectal|sublingual|buccal|trans.*dermal|vaginal)"]
|
||||
@@ -197,7 +203,6 @@ ab_from_text <- function(text,
|
||||
NA_character_
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
stop_("`type` must be either 'drug', 'dose' or 'administration'")
|
||||
}
|
||||
@@ -214,5 +219,4 @@ ab_from_text <- function(text,
|
||||
}
|
||||
|
||||
result
|
||||
|
||||
}
|
||||
|
||||
@@ -55,36 +55,38 @@
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @examples
|
||||
#' # all properties:
|
||||
#' ab_name("AMX") # "Amoxicillin"
|
||||
#' ab_atc("AMX") # "J01CA04" (ATC code from the WHO)
|
||||
#' ab_cid("AMX") # 33613 (Compound ID from PubChem)
|
||||
#' ab_synonyms("AMX") # a list with brand names of amoxicillin
|
||||
#' ab_name("AMX") # "Amoxicillin"
|
||||
#' ab_atc("AMX") # "J01CA04" (ATC code from the WHO)
|
||||
#' ab_cid("AMX") # 33613 (Compound ID from PubChem)
|
||||
#' ab_synonyms("AMX") # a list with brand names of amoxicillin
|
||||
#' ab_tradenames("AMX") # same
|
||||
#' ab_group("AMX") # "Beta-lactams/penicillins"
|
||||
#' ab_group("AMX") # "Beta-lactams/penicillins"
|
||||
#' ab_atc_group1("AMX") # "Beta-lactam antibacterials, penicillins"
|
||||
#' ab_atc_group2("AMX") # "Penicillins with extended spectrum"
|
||||
#' ab_url("AMX") # link to the official WHO page
|
||||
#' ab_url("AMX") # link to the official WHO page
|
||||
#'
|
||||
#' # smart lowercase tranformation
|
||||
#' ab_name(x = c("AMC", "PLB")) # "Amoxicillin/clavulanic acid" "Polymyxin B"
|
||||
#' ab_name(x = c("AMC", "PLB"),
|
||||
#' tolower = TRUE) # "amoxicillin/clavulanic acid" "polymyxin B"
|
||||
#' ab_name(x = c("AMC", "PLB")) # "Amoxicillin/clavulanic acid" "Polymyxin B"
|
||||
#' ab_name(
|
||||
#' x = c("AMC", "PLB"),
|
||||
#' tolower = TRUE
|
||||
#' ) # "amoxicillin/clavulanic acid" "polymyxin B"
|
||||
#'
|
||||
#' # defined daily doses (DDD)
|
||||
#' ab_ddd("AMX", "oral") # 1.5
|
||||
#' ab_ddd("AMX", "oral") # 1.5
|
||||
#' ab_ddd_units("AMX", "oral") # "g"
|
||||
#' ab_ddd("AMX", "iv") # 3
|
||||
#' ab_ddd_units("AMX", "iv") # "g"
|
||||
#' ab_ddd("AMX", "iv") # 3
|
||||
#' ab_ddd_units("AMX", "iv") # "g"
|
||||
#'
|
||||
#' ab_info("AMX") # all properties as a list
|
||||
#' ab_info("AMX") # all properties as a list
|
||||
#'
|
||||
#' # all ab_* functions use as.ab() internally, so you can go from 'any' to 'any':
|
||||
#' ab_atc("AMP") # ATC code of AMP (ampicillin)
|
||||
#' ab_group("J01CA01") # Drug group of ampicillins ATC code
|
||||
#' ab_loinc("ampicillin") # LOINC codes of ampicillin
|
||||
#' ab_name("21066-6") # "Ampicillin" (using LOINC)
|
||||
#' ab_name(6249) # "Ampicillin" (using CID)
|
||||
#' ab_name("J01CA01") # "Ampicillin" (using ATC)
|
||||
#' ab_atc("AMP") # ATC code of AMP (ampicillin)
|
||||
#' ab_group("J01CA01") # Drug group of ampicillins ATC code
|
||||
#' ab_loinc("ampicillin") # LOINC codes of ampicillin
|
||||
#' ab_name("21066-6") # "Ampicillin" (using LOINC)
|
||||
#' ab_name(6249) # "Ampicillin" (using CID)
|
||||
#' ab_name("J01CA01") # "Ampicillin" (using ATC)
|
||||
#'
|
||||
#' # spelling from different languages and dyslexia are no problem
|
||||
#' ab_atc("ceftriaxon")
|
||||
@@ -104,21 +106,21 @@
|
||||
#'
|
||||
#' # this does the same:
|
||||
#' example_isolates %>%
|
||||
#' rename_with(set_ab_names)%>%
|
||||
#' rename_with(set_ab_names) %>%
|
||||
#' head()
|
||||
#'
|
||||
#' # set_ab_names() works with any AB property:
|
||||
#' example_isolates %>%
|
||||
#' set_ab_names(property = "atc")%>%
|
||||
#' set_ab_names(property = "atc") %>%
|
||||
#' head()
|
||||
#'
|
||||
#' example_isolates %>%
|
||||
#' set_ab_names(where(is.rsi)) %>%
|
||||
#' colnames()
|
||||
#' example_isolates %>%
|
||||
#' set_ab_names(where(is.rsi)) %>%
|
||||
#' colnames()
|
||||
#'
|
||||
#' example_isolates %>%
|
||||
#' set_ab_names(NIT:VAN) %>%
|
||||
#' colnames()
|
||||
#' example_isolates %>%
|
||||
#' set_ab_names(NIT:VAN) %>%
|
||||
#' colnames()
|
||||
#' }
|
||||
#' }
|
||||
ab_name <- function(x, language = get_AMR_locale(), tolower = FALSE, ...) {
|
||||
@@ -180,17 +182,19 @@ ab_atc <- function(x, only_first = FALSE, ...) {
|
||||
atcs <- ab_validate(x = x, property = "atc", ...)
|
||||
|
||||
if (only_first == TRUE) {
|
||||
atcs <- vapply(FUN.VALUE = character(1),
|
||||
# get only the first ATC code
|
||||
atcs,
|
||||
function(x) {
|
||||
# try to get the J-group
|
||||
if (any(x %like% "^J")) {
|
||||
x[x %like% "^J"][1L]
|
||||
} else {
|
||||
as.character(x[1L])
|
||||
}
|
||||
})
|
||||
atcs <- vapply(
|
||||
FUN.VALUE = character(1),
|
||||
# get only the first ATC code
|
||||
atcs,
|
||||
function(x) {
|
||||
# try to get the J-group
|
||||
if (any(x %like% "^J")) {
|
||||
x[x %like% "^J"][1L]
|
||||
} else {
|
||||
as.character(x[1L])
|
||||
}
|
||||
}
|
||||
)
|
||||
} else if (length(atcs) == 1) {
|
||||
atcs <- unname(unlist(atcs))
|
||||
} else {
|
||||
@@ -241,8 +245,10 @@ ab_ddd <- function(x, administration = "oral", ...) {
|
||||
units <- list(...)$units
|
||||
if (!is.null(units) && isTRUE(units)) {
|
||||
if (message_not_thrown_before("ab_ddd", entire_session = TRUE)) {
|
||||
warning_("in `ab_ddd()`: using `ab_ddd(..., units = TRUE)` is deprecated, use `ab_ddd_units()` to retrieve units instead.",
|
||||
"This warning will be shown once per session.")
|
||||
warning_(
|
||||
"in `ab_ddd()`: using `ab_ddd(..., units = TRUE)` is deprecated, use `ab_ddd_units()` to retrieve units instead.",
|
||||
"This warning will be shown once per session."
|
||||
)
|
||||
}
|
||||
ddd_prop <- paste0(ddd_prop, "_units")
|
||||
} else {
|
||||
@@ -251,9 +257,11 @@ ab_ddd <- function(x, administration = "oral", ...) {
|
||||
out <- ab_validate(x = x, property = ddd_prop)
|
||||
|
||||
if (any(ab_name(x, language = NULL) %like% "/" & is.na(out))) {
|
||||
warning_("in `ab_ddd()`: DDDs of some combined products are available for different dose combinations and not (yet) part of the AMR package.",
|
||||
"Please refer to the WHOCC website:\n",
|
||||
"www.whocc.no/ddd/list_of_ddds_combined_products/")
|
||||
warning_(
|
||||
"in `ab_ddd()`: DDDs of some combined products are available for different dose combinations and not (yet) part of the AMR package.",
|
||||
"Please refer to the WHOCC website:\n",
|
||||
"www.whocc.no/ddd/list_of_ddds_combined_products/"
|
||||
)
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -266,9 +274,11 @@ ab_ddd_units <- function(x, administration = "oral", ...) {
|
||||
|
||||
x <- as.ab(x, ...)
|
||||
if (any(ab_name(x, language = NULL) %like% "/")) {
|
||||
warning_("in `ab_ddd_units()`: DDDs of combined products are available for different dose combinations and not (yet) part of the AMR package.",
|
||||
"Please refer to the WHOCC website:\n",
|
||||
"www.whocc.no/ddd/list_of_ddds_combined_products/")
|
||||
warning_(
|
||||
"in `ab_ddd_units()`: DDDs of combined products are available for different dose combinations and not (yet) part of the AMR package.",
|
||||
"Please refer to the WHOCC website:\n",
|
||||
"www.whocc.no/ddd/list_of_ddds_combined_products/"
|
||||
)
|
||||
}
|
||||
|
||||
ddd_prop <- paste0(administration, "_units")
|
||||
@@ -282,19 +292,27 @@ ab_info <- function(x, language = get_AMR_locale(), ...) {
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
|
||||
x <- as.ab(x, ...)
|
||||
list(ab = as.character(x),
|
||||
cid = ab_cid(x),
|
||||
name = ab_name(x, language = language),
|
||||
group = ab_group(x, language = language),
|
||||
atc = ab_atc(x),
|
||||
atc_group1 = ab_atc_group1(x, language = language),
|
||||
atc_group2 = ab_atc_group2(x, language = language),
|
||||
tradenames = ab_tradenames(x),
|
||||
loinc = ab_loinc(x),
|
||||
ddd = list(oral = list(amount = ab_ddd(x, administration = "oral"),
|
||||
units = ab_ddd_units(x, administration = "oral")),
|
||||
iv = list(amount = ab_ddd(x, administration = "iv"),
|
||||
units = ab_ddd_units(x, administration = "iv"))))
|
||||
list(
|
||||
ab = as.character(x),
|
||||
cid = ab_cid(x),
|
||||
name = ab_name(x, language = language),
|
||||
group = ab_group(x, language = language),
|
||||
atc = ab_atc(x),
|
||||
atc_group1 = ab_atc_group1(x, language = language),
|
||||
atc_group2 = ab_atc_group2(x, language = language),
|
||||
tradenames = ab_tradenames(x),
|
||||
loinc = ab_loinc(x),
|
||||
ddd = list(
|
||||
oral = list(
|
||||
amount = ab_ddd(x, administration = "oral"),
|
||||
units = ab_ddd_units(x, administration = "oral")
|
||||
),
|
||||
iv = list(
|
||||
amount = ab_ddd(x, administration = "iv"),
|
||||
units = ab_ddd_units(x, administration = "iv")
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -370,24 +388,28 @@ set_ab_names <- function(data, ..., property = "name", language = get_AMR_locale
|
||||
vars_ab <- as.ab(data, fast_mode = TRUE)
|
||||
vars <- data[!is.na(vars_ab)]
|
||||
}
|
||||
x <- vapply(FUN.VALUE = character(1),
|
||||
ab_property(vars, property = property, language = language),
|
||||
function(x) {
|
||||
if (property == "atc") {
|
||||
# try to get the J-group
|
||||
if (any(x %like% "^J")) {
|
||||
x[x %like% "^J"][1L]
|
||||
} else {
|
||||
as.character(x[1L])
|
||||
}
|
||||
} else {
|
||||
as.character(x[1L])
|
||||
}
|
||||
},
|
||||
USE.NAMES = FALSE)
|
||||
x <- vapply(
|
||||
FUN.VALUE = character(1),
|
||||
ab_property(vars, property = property, language = language),
|
||||
function(x) {
|
||||
if (property == "atc") {
|
||||
# try to get the J-group
|
||||
if (any(x %like% "^J")) {
|
||||
x[x %like% "^J"][1L]
|
||||
} else {
|
||||
as.character(x[1L])
|
||||
}
|
||||
} else {
|
||||
as.character(x[1L])
|
||||
}
|
||||
},
|
||||
USE.NAMES = FALSE
|
||||
)
|
||||
if (any(x %in% c("", NA))) {
|
||||
warning_("in `set_ab_names()`: no ", property, " found for column(s): ",
|
||||
vector_and(vars[x %in% c("", NA)], sort = FALSE))
|
||||
warning_(
|
||||
"in `set_ab_names()`: no ", property, " found for column(s): ",
|
||||
vector_and(vars[x %in% c("", NA)], sort = FALSE)
|
||||
)
|
||||
x[x %in% c("", NA)] <- vars[x %in% c("", NA)]
|
||||
}
|
||||
|
||||
@@ -399,15 +421,17 @@ set_ab_names <- function(data, ..., property = "name", language = get_AMR_locale
|
||||
# very hacky way of adding the index to each duplicate
|
||||
# so "Amoxicillin", "Amoxicillin", "Amoxicillin"
|
||||
# will be "Amoxicillin", "Amoxicillin_2", "Amoxicillin_3"
|
||||
invisible(lapply(unique(x),
|
||||
function(u) {
|
||||
dups <- which(x == u)
|
||||
if (length(dups) > 1) {
|
||||
# there are duplicates
|
||||
dup_add_int <- dups[2:length(dups)]
|
||||
x[dup_add_int] <<- paste0(x[dup_add_int], "_", c(2:length(dups)))
|
||||
}
|
||||
}))
|
||||
invisible(lapply(
|
||||
unique(x),
|
||||
function(u) {
|
||||
dups <- which(x == u)
|
||||
if (length(dups) > 1) {
|
||||
# there are duplicates
|
||||
dup_add_int <- dups[2:length(dups)]
|
||||
x[dup_add_int] <<- paste0(x[dup_add_int], "_", c(2:length(dups)))
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
if (is.data.frame(data)) {
|
||||
colnames(data)[colnames(data) %in% vars] <- x
|
||||
@@ -419,22 +443,25 @@ set_ab_names <- function(data, ..., property = "name", language = get_AMR_locale
|
||||
}
|
||||
|
||||
ab_validate <- function(x, property, ...) {
|
||||
|
||||
check_dataset_integrity()
|
||||
|
||||
if (tryCatch(all(x[!is.na(x)] %in% AB_lookup$ab), error = function(e) FALSE)) {
|
||||
# special case for ab_* functions where class is already <ab>
|
||||
x <- AB_lookup[match(x, AB_lookup$ab), property, drop = TRUE]
|
||||
|
||||
} else {
|
||||
# try to catch an error when inputting an invalid argument
|
||||
# so the 'call.' can be set to FALSE
|
||||
tryCatch(x[1L] %in% antibiotics[1, property],
|
||||
error = function(e) stop(e$message, call. = FALSE))
|
||||
tryCatch(x[1L] %in% antibiotics[1, property, drop = TRUE],
|
||||
error = function(e) stop(e$message, call. = FALSE)
|
||||
)
|
||||
|
||||
if (!all(x %in% AB_lookup[, property])) {
|
||||
if (!all(x %in% AB_lookup[, property, drop = TRUE])) {
|
||||
x <- as.ab(x, ...)
|
||||
x <- AB_lookup[match(x, AB_lookup$ab), property, drop = TRUE]
|
||||
if (all(is.na(x)) && is.list(AB_lookup[, property, drop = TRUE])) {
|
||||
x <- rep(NA_character_, length(x))
|
||||
} else {
|
||||
x <- AB_lookup[match(x, AB_lookup$ab), property, drop = TRUE]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,115 +49,138 @@
|
||||
#' @examples
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#' df <- example_isolates[ , c("hospital_id", "mo",
|
||||
#' "AMP", "AMC", "TZP", "CXM", "CRO", "GEN",
|
||||
#' "TOB", "COL", "IPM", "MEM", "TEC", "VAN")]
|
||||
#' example_isolates
|
||||
#'
|
||||
#' # base R ------------------------------------------------------------------
|
||||
#'
|
||||
#' # select columns 'IPM' (imipenem) and 'MEM' (meropenem)
|
||||
#' df[, carbapenems()]
|
||||
#' example_isolates[, carbapenems()]
|
||||
#'
|
||||
#' # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
|
||||
#' df[, c("mo", aminoglycosides())]
|
||||
#' example_isolates[, c("mo", aminoglycosides())]
|
||||
#'
|
||||
#' # select only antibiotic columns with DDDs for oral treatment
|
||||
#' df[, administrable_per_os()]
|
||||
#' example_isolates[, administrable_per_os()]
|
||||
#'
|
||||
#' # filter using any() or all()
|
||||
#' df[any(carbapenems() == "R"), ]
|
||||
#' subset(df, any(carbapenems() == "R"))
|
||||
#' example_isolates[any(carbapenems() == "R"), ]
|
||||
#' subset(example_isolates, any(carbapenems() == "R"))
|
||||
#'
|
||||
#' # filter on any or all results in the carbapenem columns (i.e., IPM, MEM):
|
||||
#' df[any(carbapenems()), ]
|
||||
#' df[all(carbapenems()), ]
|
||||
#' example_isolates[any(carbapenems()), ]
|
||||
#' example_isolates[all(carbapenems()), ]
|
||||
#'
|
||||
#' # filter with multiple antibiotic selectors using c()
|
||||
#' df[all(c(carbapenems(), aminoglycosides()) == "R"), ]
|
||||
#' example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]
|
||||
#'
|
||||
#' # filter + select in one go: get penicillins in carbapenems-resistant strains
|
||||
#' df[any(carbapenems() == "R"), penicillins()]
|
||||
#' example_isolates[any(carbapenems() == "R"), penicillins()]
|
||||
#'
|
||||
#' # You can combine selectors with '&' to be more specific. For example,
|
||||
#' # penicillins() would select benzylpenicillin ('peni G') and
|
||||
#' # administrable_per_os() would select erythromycin. Yet, when combined these
|
||||
#' # drugs are both omitted since benzylpenicillin is not administrable per os
|
||||
#' # and erythromycin is not a penicillin:
|
||||
#' df[, penicillins() & administrable_per_os()]
|
||||
#' example_isolates[, penicillins() & administrable_per_os()]
|
||||
#'
|
||||
#' # ab_selector() applies a filter in the `antibiotics` data set and is thus very
|
||||
#' # flexible. For instance, to select antibiotic columns with an oral DDD of at
|
||||
#' # least 1 gram:
|
||||
#' df[, ab_selector(oral_ddd > 1 & oral_units == "g")]
|
||||
#' example_isolates[, ab_selector(oral_ddd > 1 & oral_units == "g")]
|
||||
#'
|
||||
#' # dplyr -------------------------------------------------------------------
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # get AMR for all aminoglycosides e.g., per hospital:
|
||||
#' df %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' # get AMR for all aminoglycosides e.g., per ward:
|
||||
#' example_isolates %>%
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(across(aminoglycosides(), resistance))
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # You can combine selectors with '&' to be more specific:
|
||||
#' df %>%
|
||||
#' example_isolates %>%
|
||||
#' select(penicillins() & administrable_per_os())
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # get AMR for only drugs that matter - no intrinsic resistance:
|
||||
#' df %>%
|
||||
#' example_isolates %>%
|
||||
#' filter(mo_genus() %in% c("Escherichia", "Klebsiella")) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(across(not_intrinsic_resistant(), resistance))
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # get susceptibility for antibiotics whose name contains "trim":
|
||||
#' df %>%
|
||||
#' example_isolates %>%
|
||||
#' filter(first_isolate()) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(across(ab_selector(name %like% "trim"), susceptibility))
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||
#' df %>%
|
||||
#' example_isolates %>%
|
||||
#' select(carbapenems())
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
|
||||
#' df %>%
|
||||
#' example_isolates %>%
|
||||
#' select(mo, aminoglycosides())
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # any() and all() work in dplyr's filter() too:
|
||||
#' df %>%
|
||||
#' filter(any(aminoglycosides() == "R"),
|
||||
#' all(cephalosporins_2nd() == "R"))
|
||||
#' # any() and all() work in dplyr's filter() too:
|
||||
#' example_isolates %>%
|
||||
#' filter(
|
||||
#' any(aminoglycosides() == "R"),
|
||||
#' all(cephalosporins_2nd() == "R")
|
||||
#' )
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # also works with c():
|
||||
#' df %>%
|
||||
#' # also works with c():
|
||||
#' example_isolates %>%
|
||||
#' filter(any(c(carbapenems(), aminoglycosides()) == "R"))
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # not setting any/all will automatically apply all():
|
||||
#' df %>%
|
||||
#' # not setting any/all will automatically apply all():
|
||||
#' example_isolates %>%
|
||||
#' filter(aminoglycosides() == "R")
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
|
||||
#' df %>%
|
||||
#' example_isolates %>%
|
||||
#' select(mo, ab_class("mycobact"))
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # get bug/drug combinations for only glycopeptides in Gram-positives:
|
||||
#' df %>%
|
||||
#' example_isolates %>%
|
||||
#' filter(mo_is_gram_positive()) %>%
|
||||
#' select(mo, glycopeptides()) %>%
|
||||
#' bug_drug_combinations() %>%
|
||||
#' format()
|
||||
#'
|
||||
#' data.frame(some_column = "some_value",
|
||||
#' J01CA01 = "S") %>% # ATC code of ampicillin
|
||||
#' select(penicillins()) # only the 'J01CA01' column will be selected
|
||||
#'
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#' data.frame(
|
||||
#' some_column = "some_value",
|
||||
#' J01CA01 = "S"
|
||||
#' ) %>% # ATC code of ampicillin
|
||||
#' select(penicillins()) # only the 'J01CA01' column will be selected
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # with recent versions of dplyr this is all equal:
|
||||
#' x <- df[carbapenems() == "R", ]
|
||||
#' y <- df %>% filter(carbapenems() == "R")
|
||||
#' z <- df %>% filter(if_all(carbapenems(), ~.x == "R"))
|
||||
#' identical(x, y)
|
||||
#' identical(y, z)
|
||||
#' x <- example_isolates[carbapenems() == "R", ]
|
||||
#' y <- example_isolates %>% filter(carbapenems() == "R")
|
||||
#' z <- example_isolates %>% filter(if_all(carbapenems(), ~ .x == "R"))
|
||||
#' identical(x, y) && identical(y, z)
|
||||
#' }
|
||||
#' }
|
||||
ab_class <- function(ab_class,
|
||||
@@ -184,19 +207,25 @@ ab_selector <- function(filter,
|
||||
# but it only takes a couple of milliseconds
|
||||
vars_df <- get_current_data(arg_name = NA, call = -2)
|
||||
# to improve speed, get_column_abx() will only run once when e.g. in a select or group call
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = "ab_selector")
|
||||
ab_in_data <- get_column_abx(vars_df,
|
||||
info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = "ab_selector"
|
||||
)
|
||||
call <- substitute(filter)
|
||||
agents <- tryCatch(AMR::antibiotics[which(eval(call, envir = AMR::antibiotics)), "ab", drop = TRUE],
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
agents <- ab_in_data[ab_in_data %in% agents]
|
||||
message_agent_names(function_name = "ab_selector",
|
||||
agents = agents,
|
||||
ab_group = NULL,
|
||||
examples = "",
|
||||
call = call)
|
||||
message_agent_names(
|
||||
function_name = "ab_selector",
|
||||
agents = agents,
|
||||
ab_group = NULL,
|
||||
examples = "",
|
||||
call = call
|
||||
)
|
||||
structure(unname(agents),
|
||||
class = c("ab_selector", "character"))
|
||||
class = c("ab_selector", "character")
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
@@ -387,24 +416,34 @@ administrable_per_os <- function(only_rsi_columns = FALSE, ...) {
|
||||
# but it only takes a couple of milliseconds
|
||||
vars_df <- get_current_data(arg_name = NA, call = -2)
|
||||
# to improve speed, get_column_abx() will only run once when e.g. in a select or group call
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = "administrable_per_os")
|
||||
ab_in_data <- get_column_abx(vars_df,
|
||||
info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = "administrable_per_os"
|
||||
)
|
||||
agents_all <- antibiotics[which(!is.na(antibiotics$oral_ddd)), "ab", drop = TRUE]
|
||||
agents <- antibiotics[which(antibiotics$ab %in% ab_in_data & !is.na(antibiotics$oral_ddd)), "ab", drop = TRUE]
|
||||
agents <- ab_in_data[ab_in_data %in% agents]
|
||||
message_agent_names(function_name = "administrable_per_os",
|
||||
agents = agents,
|
||||
ab_group = "administrable_per_os",
|
||||
examples = paste0(" (such as ",
|
||||
vector_or(ab_name(sample(agents_all,
|
||||
size = min(5, length(agents_all)),
|
||||
replace = FALSE),
|
||||
tolower = TRUE,
|
||||
language = NULL),
|
||||
quotes = FALSE),
|
||||
")"))
|
||||
message_agent_names(
|
||||
function_name = "administrable_per_os",
|
||||
agents = agents,
|
||||
ab_group = "administrable_per_os",
|
||||
examples = paste0(
|
||||
" (such as ",
|
||||
vector_or(ab_name(sample(agents_all,
|
||||
size = min(5, length(agents_all)),
|
||||
replace = FALSE
|
||||
),
|
||||
tolower = TRUE,
|
||||
language = NULL
|
||||
),
|
||||
quotes = FALSE
|
||||
),
|
||||
")"
|
||||
)
|
||||
)
|
||||
structure(unname(agents),
|
||||
class = c("ab_selector", "character"))
|
||||
class = c("ab_selector", "character")
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
@@ -415,17 +454,22 @@ administrable_iv <- function(only_rsi_columns = FALSE, ...) {
|
||||
# but it only takes a couple of milliseconds
|
||||
vars_df <- get_current_data(arg_name = NA, call = -2)
|
||||
# to improve speed, get_column_abx() will only run once when e.g. in a select or group call
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = "administrable_iv")
|
||||
ab_in_data <- get_column_abx(vars_df,
|
||||
info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = "administrable_iv"
|
||||
)
|
||||
agents_all <- antibiotics[which(!is.na(antibiotics$iv_ddd)), "ab", drop = TRUE]
|
||||
agents <- antibiotics[which(antibiotics$ab %in% ab_in_data & !is.na(antibiotics$iv_ddd)), "ab", drop = TRUE]
|
||||
agents <- ab_in_data[ab_in_data %in% agents]
|
||||
message_agent_names(function_name = "administrable_iv",
|
||||
agents = agents,
|
||||
ab_group = "administrable_iv",
|
||||
examples = "")
|
||||
message_agent_names(
|
||||
function_name = "administrable_iv",
|
||||
agents = agents,
|
||||
ab_group = "administrable_iv",
|
||||
examples = ""
|
||||
)
|
||||
structure(unname(agents),
|
||||
class = c("ab_selector", "character"))
|
||||
class = c("ab_selector", "character")
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
@@ -438,35 +482,47 @@ not_intrinsic_resistant <- function(only_rsi_columns = FALSE, col_mo = NULL, ver
|
||||
# but it only takes a couple of milliseconds
|
||||
vars_df <- get_current_data(arg_name = NA, call = -2)
|
||||
# to improve speed, get_column_abx() will only run once when e.g. in a select or group call
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = "not_intrinsic_resistant")
|
||||
ab_in_data <- get_column_abx(vars_df,
|
||||
info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = "not_intrinsic_resistant"
|
||||
)
|
||||
# intrinsic vars
|
||||
vars_df_R <- tryCatch(sapply(eucast_rules(vars_df,
|
||||
col_mo = col_mo,
|
||||
version_expertrules = version_expertrules,
|
||||
rules = "expert",
|
||||
info = FALSE),
|
||||
function(col) tryCatch(!any(is.na(col)) && all(col == "R"),
|
||||
error = function(e) FALSE)),
|
||||
error = function(e) stop_("in not_intrinsic_resistant(): ", e$message, call = FALSE))
|
||||
vars_df_R <- tryCatch(sapply(
|
||||
eucast_rules(vars_df,
|
||||
col_mo = col_mo,
|
||||
version_expertrules = version_expertrules,
|
||||
rules = "expert",
|
||||
info = FALSE
|
||||
),
|
||||
function(col) {
|
||||
tryCatch(!any(is.na(col)) && all(col == "R"),
|
||||
error = function(e) FALSE
|
||||
)
|
||||
}
|
||||
),
|
||||
error = function(e) stop_("in not_intrinsic_resistant(): ", e$message, call = FALSE)
|
||||
)
|
||||
|
||||
agents <- ab_in_data[ab_in_data %in% names(vars_df_R[which(vars_df_R)])]
|
||||
if (length(agents) > 0 &&
|
||||
message_not_thrown_before("not_intrinsic_resistant", sort(agents))) {
|
||||
message_not_thrown_before("not_intrinsic_resistant", sort(agents))) {
|
||||
agents_formatted <- paste0("'", font_bold(agents, collapse = NULL), "'")
|
||||
agents_names <- ab_name(names(agents), tolower = TRUE, language = NULL)
|
||||
need_name <- generalise_antibiotic_name(agents) != generalise_antibiotic_name(agents_names)
|
||||
agents_formatted[need_name] <- paste0(agents_formatted[need_name], " (", agents_names[need_name], ")")
|
||||
message_("For `not_intrinsic_resistant()` removing ",
|
||||
ifelse(length(agents) == 1, "column ", "columns "),
|
||||
vector_and(agents_formatted, quotes = FALSE, sort = FALSE))
|
||||
message_(
|
||||
"For `not_intrinsic_resistant()` removing ",
|
||||
ifelse(length(agents) == 1, "column ", "columns "),
|
||||
vector_and(agents_formatted, quotes = FALSE, sort = FALSE)
|
||||
)
|
||||
}
|
||||
|
||||
vars_df_R <- names(vars_df_R)[which(!vars_df_R)]
|
||||
# find columns that are abx, but also intrinsic R
|
||||
out <- unname(intersect(ab_in_data, vars_df_R))
|
||||
structure(out,
|
||||
class = c("ab_selector", "character"))
|
||||
class = c("ab_selector", "character")
|
||||
)
|
||||
}
|
||||
|
||||
ab_select_exec <- function(function_name,
|
||||
@@ -477,20 +533,26 @@ ab_select_exec <- function(function_name,
|
||||
# but it only takes a couple of milliseconds
|
||||
vars_df <- get_current_data(arg_name = NA, call = -3)
|
||||
# to improve speed, get_column_abx() will only run once when e.g. in a select or group call
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = function_name)
|
||||
ab_in_data <- get_column_abx(vars_df,
|
||||
info = FALSE, only_rsi_columns = only_rsi_columns,
|
||||
sort = FALSE, fn = function_name
|
||||
)
|
||||
# untreatable drugs
|
||||
if (only_treatable == TRUE) {
|
||||
untreatable <- antibiotics[which(antibiotics$name %like% "-high|EDTA|polysorbate|macromethod|screening|/nacubactam"), "ab", drop = TRUE]
|
||||
if (any(untreatable %in% names(ab_in_data))) {
|
||||
if (message_not_thrown_before(function_name, "ab_class", "untreatable", entire_session = TRUE)) {
|
||||
warning_("in `", function_name, "()`: some agents were ignored since they cannot be used for treating patients: ",
|
||||
vector_and(ab_name(names(ab_in_data)[names(ab_in_data) %in% untreatable],
|
||||
language = NULL,
|
||||
tolower = TRUE),
|
||||
quotes = FALSE,
|
||||
sort = TRUE), ". They can be included using `", function_name, "(only_treatable = FALSE)`. ",
|
||||
"This warning will be shown once per session.")
|
||||
warning_(
|
||||
"in `", function_name, "()`: some agents were ignored since they cannot be used for treating patients: ",
|
||||
vector_and(ab_name(names(ab_in_data)[names(ab_in_data) %in% untreatable],
|
||||
language = NULL,
|
||||
tolower = TRUE
|
||||
),
|
||||
quotes = FALSE,
|
||||
sort = TRUE
|
||||
), ". They can be included using `", function_name, "(only_treatable = FALSE)`. ",
|
||||
"This warning will be shown once per session."
|
||||
)
|
||||
}
|
||||
ab_in_data <- ab_in_data[!names(ab_in_data) %in% untreatable]
|
||||
}
|
||||
@@ -502,20 +564,24 @@ ab_select_exec <- function(function_name,
|
||||
}
|
||||
|
||||
if (is.null(ab_class_args)) {
|
||||
# their upper case equivalent are vectors with class <ab>, created in data-raw/pre-commit-hook.R
|
||||
# their upper case equivalent are vectors with class <ab>, created in data-raw/_pre_commit_hook.R
|
||||
# carbapenems() gets its codes from AMR:::AB_CARBAPENEMS
|
||||
abx <- get(paste0("AB_", toupper(function_name)), envir = asNamespace("AMR"))
|
||||
ab_group <- function_name
|
||||
examples <- paste0(" (such as ", vector_or(ab_name(sample(abx, size = min(2, length(abx)), replace = FALSE),
|
||||
tolower = TRUE,
|
||||
language = NULL),
|
||||
quotes = FALSE), ")")
|
||||
tolower = TRUE,
|
||||
language = NULL
|
||||
),
|
||||
quotes = FALSE
|
||||
), ")")
|
||||
} else {
|
||||
# this for the 'manual' ab_class() function
|
||||
abx <- subset(AB_lookup,
|
||||
group %like% ab_class_args |
|
||||
atc_group1 %like% ab_class_args |
|
||||
atc_group2 %like% ab_class_args)$ab
|
||||
abx <- subset(
|
||||
AB_lookup,
|
||||
group %like% ab_class_args |
|
||||
atc_group1 %like% ab_class_args |
|
||||
atc_group2 %like% ab_class_args
|
||||
)$ab
|
||||
ab_group <- find_ab_group(ab_class_args)
|
||||
function_name <- "ab_class"
|
||||
examples <- paste0(" (such as ", find_ab_names(ab_class_args, 2), ")")
|
||||
@@ -524,14 +590,17 @@ ab_select_exec <- function(function_name,
|
||||
# get the columns with a group names in the chosen ab class
|
||||
agents <- ab_in_data[names(ab_in_data) %in% abx]
|
||||
|
||||
message_agent_names(function_name = function_name,
|
||||
agents = agents,
|
||||
ab_group = ab_group,
|
||||
examples = examples,
|
||||
ab_class_args = ab_class_args)
|
||||
message_agent_names(
|
||||
function_name = function_name,
|
||||
agents = agents,
|
||||
ab_group = ab_group,
|
||||
examples = examples,
|
||||
ab_class_args = ab_class_args
|
||||
)
|
||||
|
||||
structure(unname(agents),
|
||||
class = c("ab_selector", "character"))
|
||||
class = c("ab_selector", "character")
|
||||
)
|
||||
}
|
||||
|
||||
#' @method c ab_selector
|
||||
@@ -539,7 +608,8 @@ ab_select_exec <- function(function_name,
|
||||
#' @noRd
|
||||
c.ab_selector <- function(...) {
|
||||
structure(unlist(lapply(list(...), as.character)),
|
||||
class = c("ab_selector", "character"))
|
||||
class = c("ab_selector", "character")
|
||||
)
|
||||
}
|
||||
|
||||
all_any_ab_selector <- function(type, ..., na.rm = TRUE) {
|
||||
@@ -559,10 +629,12 @@ all_any_ab_selector <- function(type, ..., na.rm = TRUE) {
|
||||
}
|
||||
|
||||
x_transposed <- as.list(as.data.frame(t(df[, cols_ab, drop = FALSE]), stringsAsFactors = FALSE))
|
||||
vapply(FUN.VALUE = logical(1),
|
||||
X = x_transposed,
|
||||
FUN = function(y) scope_fn(y %in% result, na.rm = na.rm),
|
||||
USE.NAMES = FALSE)
|
||||
vapply(
|
||||
FUN.VALUE = logical(1),
|
||||
X = x_transposed,
|
||||
FUN = function(y) scope_fn(y %in% result, na.rm = na.rm),
|
||||
USE.NAMES = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
#' @method all ab_selector
|
||||
@@ -622,12 +694,15 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) {
|
||||
} else {
|
||||
type <- "all"
|
||||
if (length(e1) > 1) {
|
||||
message_("Assuming a filter on ", type, " ", length(e1), " ", gsub("[\\(\\)]", "", fn_name),
|
||||
". Wrap around `all()` or `any()` to prevent this note.")
|
||||
message_(
|
||||
"Assuming a filter on ", type, " ", length(e1), " ", gsub("[\\(\\)]", "", fn_name),
|
||||
". Wrap around `all()` or `any()` to prevent this note."
|
||||
)
|
||||
}
|
||||
}
|
||||
structure(all_any_ab_selector(type = type, e1, e2),
|
||||
class = c("ab_selector_any_all", "logical"))
|
||||
class = c("ab_selector_any_all", "logical")
|
||||
)
|
||||
}
|
||||
|
||||
#' @method != ab_selector
|
||||
@@ -644,15 +719,18 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) {
|
||||
} else {
|
||||
type <- "all"
|
||||
if (length(e1) > 1) {
|
||||
message_("Assuming a filter on ", type, " ", length(e1), " ", gsub("[\\(\\)]", "", fn_name),
|
||||
". Wrap around `all()` or `any()` to prevent this note.")
|
||||
message_(
|
||||
"Assuming a filter on ", type, " ", length(e1), " ", gsub("[\\(\\)]", "", fn_name),
|
||||
". Wrap around `all()` or `any()` to prevent this note."
|
||||
)
|
||||
}
|
||||
}
|
||||
# this is `!=`, so turn around the values
|
||||
rsi <- c("R", "S", "I")
|
||||
e2 <- rsi[rsi != e2]
|
||||
structure(all_any_ab_selector(type = type, e1, e2),
|
||||
class = c("ab_selector_any_all", "logical"))
|
||||
class = c("ab_selector_any_all", "logical")
|
||||
)
|
||||
}
|
||||
|
||||
#' @method & ab_selector
|
||||
@@ -662,7 +740,8 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) {
|
||||
# this is only required for base R, since tidyselect has already implemented this
|
||||
# e.g., for: example_isolates[, penicillins() & administrable_per_os()]
|
||||
structure(intersect(unclass(e1), unclass(e2)),
|
||||
class = c("ab_selector", "character"))
|
||||
class = c("ab_selector", "character")
|
||||
)
|
||||
}
|
||||
#' @method | ab_selector
|
||||
#' @export
|
||||
@@ -671,7 +750,8 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) {
|
||||
# this is only required for base R, since tidyselect has already implemented this
|
||||
# e.g., for: example_isolates[, penicillins() | administrable_per_os()]
|
||||
structure(union(unclass(e1), unclass(e2)),
|
||||
class = c("ab_selector", "character"))
|
||||
class = c("ab_selector", "character")
|
||||
)
|
||||
}
|
||||
|
||||
is_any <- function(el1) {
|
||||
@@ -689,8 +769,8 @@ find_ab_group <- function(ab_class_args) {
|
||||
ab_class_args <- gsub("[^a-zA-Z0-9]", ".*", ab_class_args)
|
||||
AB_lookup %pm>%
|
||||
subset(group %like% ab_class_args |
|
||||
atc_group1 %like% ab_class_args |
|
||||
atc_group2 %like% ab_class_args) %pm>%
|
||||
atc_group1 %like% ab_class_args |
|
||||
atc_group2 %like% ab_class_args) %pm>%
|
||||
pm_pull(group) %pm>%
|
||||
unique() %pm>%
|
||||
tolower() %pm>%
|
||||
@@ -703,23 +783,25 @@ find_ab_names <- function(ab_group, n = 3) {
|
||||
|
||||
# try popular first, they have DDDs
|
||||
drugs <- antibiotics[which((!is.na(antibiotics$iv_ddd) | !is.na(antibiotics$oral_ddd)) &
|
||||
antibiotics$name %unlike% " " &
|
||||
antibiotics$group %like% ab_group &
|
||||
antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||
antibiotics$name %unlike% " " &
|
||||
antibiotics$group %like% ab_group &
|
||||
antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||
if (length(drugs) < n) {
|
||||
# now try it all
|
||||
drugs <- antibiotics[which((antibiotics$group %like% ab_group |
|
||||
antibiotics$atc_group1 %like% ab_group |
|
||||
antibiotics$atc_group2 %like% ab_group) &
|
||||
antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||
antibiotics$atc_group1 %like% ab_group |
|
||||
antibiotics$atc_group2 %like% ab_group) &
|
||||
antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||
}
|
||||
if (length(drugs) == 0) {
|
||||
return("??")
|
||||
}
|
||||
vector_or(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE),
|
||||
tolower = TRUE,
|
||||
language = NULL),
|
||||
quotes = FALSE)
|
||||
tolower = TRUE,
|
||||
language = NULL
|
||||
),
|
||||
quotes = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
message_agent_names <- function(function_name, agents, ab_group = NULL, examples = "", ab_class_args = NULL, call = NULL) {
|
||||
@@ -739,15 +821,19 @@ message_agent_names <- function(function_name, agents, ab_group = NULL, examples
|
||||
agents_names <- ab_name(names(agents), tolower = TRUE, language = NULL)
|
||||
need_name <- generalise_antibiotic_name(agents) != generalise_antibiotic_name(agents_names)
|
||||
agents_formatted[need_name] <- paste0(agents_formatted[need_name], " (", agents_names[need_name], ")")
|
||||
message_("For `", function_name, "(",
|
||||
ifelse(function_name == "ab_class",
|
||||
paste0("\"", ab_class_args, "\""),
|
||||
ifelse(!is.null(call),
|
||||
paste0(deparse(call), collapse = " "),
|
||||
"")),
|
||||
")` using ",
|
||||
ifelse(length(agents) == 1, "column ", "columns "),
|
||||
vector_and(agents_formatted, quotes = FALSE, sort = FALSE))
|
||||
message_(
|
||||
"For `", function_name, "(",
|
||||
ifelse(function_name == "ab_class",
|
||||
paste0("\"", ab_class_args, "\""),
|
||||
ifelse(!is.null(call),
|
||||
paste0(deparse(call), collapse = " "),
|
||||
""
|
||||
)
|
||||
),
|
||||
")` using ",
|
||||
ifelse(length(agents) == 1, "column ", "columns "),
|
||||
vector_and(agents_formatted, quotes = FALSE, sort = FALSE)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,22 +72,28 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
# from https://stackoverflow.com/a/25450756/4575331
|
||||
years_gap <- reference$year - x$year
|
||||
ages <- ifelse(reference$mon < x$mon | (reference$mon == x$mon & reference$mday < x$mday),
|
||||
as.integer(years_gap - 1),
|
||||
as.integer(years_gap))
|
||||
as.integer(years_gap - 1),
|
||||
as.integer(years_gap)
|
||||
)
|
||||
|
||||
# add decimals
|
||||
if (exact == TRUE) {
|
||||
# get dates of `x` when `x` would have the year of `reference`
|
||||
x_in_reference_year <- as.POSIXlt(paste0(format(as.Date(reference), "%Y"),
|
||||
format(as.Date(x), "-%m-%d")),
|
||||
format = "%Y-%m-%d")
|
||||
x_in_reference_year <- as.POSIXlt(paste0(
|
||||
format(as.Date(reference), "%Y"),
|
||||
format(as.Date(x), "-%m-%d")
|
||||
),
|
||||
format = "%Y-%m-%d"
|
||||
)
|
||||
# get differences in days
|
||||
n_days_x_rest <- as.double(difftime(as.Date(reference),
|
||||
as.Date(x_in_reference_year),
|
||||
units = "days"))
|
||||
as.Date(x_in_reference_year),
|
||||
units = "days"
|
||||
))
|
||||
# get numbers of days the years of `reference` has for a reliable denominator
|
||||
n_days_reference_year <- as.POSIXlt(paste0(format(as.Date(reference), "%Y"), "-12-31"),
|
||||
format = "%Y-%m-%d")$yday + 1
|
||||
format = "%Y-%m-%d"
|
||||
)$yday + 1
|
||||
# add decimal parts of year
|
||||
mod <- n_days_x_rest / n_days_reference_year
|
||||
# negative mods are cases where `x_in_reference_year` > `reference` - so 'add' a year
|
||||
@@ -160,13 +166,15 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' filter_first_isolate() %>%
|
||||
#' filter(mo == as.mo("E. coli")) %>%
|
||||
#' filter(mo == as.mo("Escherichia coli")) %>%
|
||||
#' group_by(age_group = age_groups(age)) %>%
|
||||
#' select(age_group, CIP) %>%
|
||||
#' ggplot_rsi(x = "age_group",
|
||||
#' minimum = 0,
|
||||
#' x.title = "Age Group",
|
||||
#' title = "Ciprofloxacin resistance per age group")
|
||||
#' ggplot_rsi(
|
||||
#' x = "age_group",
|
||||
#' minimum = 0,
|
||||
#' x.title = "Age Group",
|
||||
#' title = "Ciprofloxacin resistance per age group"
|
||||
#' )
|
||||
#' }
|
||||
#' }
|
||||
age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
|
||||
@@ -183,7 +191,7 @@ age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
|
||||
if (split_at %like% "^(child|kid|junior)") {
|
||||
split_at <- c(0, 1, 2, 4, 6, 13, 18)
|
||||
} else if (split_at %like% "^(elder|senior)") {
|
||||
split_at <- c(65, 75, 85)
|
||||
split_at <- c(65, 75, 85)
|
||||
} else if (split_at %like% "^five") {
|
||||
split_at <- 1:20 * 5
|
||||
} else if (split_at %like% "^ten") {
|
||||
|
||||
@@ -52,13 +52,11 @@
|
||||
#' - Principal component analysis for AMR
|
||||
#'
|
||||
#' @section Reference Data Publicly Available:
|
||||
#' All reference data sets (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) in this `AMR` package are publicly and freely available. We continually export our data sets to formats for use in R, SPSS, SAS, Stata and Excel. We also supply flat files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please find [all download links on our website](https://msberends.github.io/AMR/articles/datasets.html), which is automatically updated with every code change.
|
||||
#' @section Read more on Our Website!:
|
||||
#' On our website <https://msberends.github.io/AMR/> you can find [a comprehensive tutorial](https://msberends.github.io/AMR/articles/AMR.html) about how to conduct AMR data analysis, the [complete documentation of all functions](https://msberends.github.io/AMR/reference/) and [an example analysis using WHONET data](https://msberends.github.io/AMR/articles/WHONET.html).
|
||||
#' All data sets in this `AMR` package (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) are publicly and freely available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. We also provide tab-separated plain text files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @section Contact Us:
|
||||
#' For suggestions, comments or questions, please contact us at:
|
||||
#' For suggestions, comments or questions, please contact us via:
|
||||
#'
|
||||
#' Matthijs S. Berends \cr
|
||||
#' Dr. Matthijs S. Berends \cr
|
||||
#' m.s.berends \[at\] umcg \[dot\] nl \cr
|
||||
#' University of Groningen
|
||||
#' Department of Medical Microbiology and Infection Prevention \cr
|
||||
|
||||
@@ -102,8 +102,9 @@ atc_online_property <- function(atc_code,
|
||||
|
||||
if (!has_internet()) {
|
||||
message_("There appears to be no internet connection, returning NA.",
|
||||
add_fn = font_red,
|
||||
as_note = FALSE)
|
||||
add_fn = font_red,
|
||||
as_note = FALSE
|
||||
)
|
||||
return(rep(NA, length(atc_code)))
|
||||
}
|
||||
|
||||
@@ -124,7 +125,6 @@ atc_online_property <- function(atc_code,
|
||||
on.exit(close(progress))
|
||||
|
||||
for (i in seq_len(length(atc_code))) {
|
||||
|
||||
progress$tick()
|
||||
|
||||
if (atc_code[i] %like% "^Q") {
|
||||
@@ -141,7 +141,8 @@ atc_online_property <- function(atc_code,
|
||||
html_node("#content") %pm>%
|
||||
html_children() %pm>%
|
||||
html_node("a"),
|
||||
error = function(e) NULL)
|
||||
error = function(e) NULL
|
||||
)
|
||||
if (is.null(out)) {
|
||||
message_("Connection to ", atc_url, " failed.")
|
||||
return(rep(NA, length(atc_code)))
|
||||
@@ -156,14 +157,14 @@ atc_online_property <- function(atc_code,
|
||||
# last one is antibiotics, skip it
|
||||
texts <- texts[seq_len(length(texts)) - 1]
|
||||
returnvalue <- c(list(texts), returnvalue)
|
||||
|
||||
} else {
|
||||
out <- tryCatch(
|
||||
read_html(atc_url) %pm>%
|
||||
html_nodes("table") %pm>%
|
||||
html_table(header = TRUE) %pm>%
|
||||
as.data.frame(stringsAsFactors = FALSE),
|
||||
error = function(e) NULL)
|
||||
error = function(e) NULL
|
||||
)
|
||||
if (is.null(out)) {
|
||||
message_("Connection to ", atc_url, " failed.")
|
||||
return(rep(NA, length(atc_code)))
|
||||
@@ -180,15 +181,15 @@ atc_online_property <- function(atc_code,
|
||||
|
||||
if (property %in% c("atc", "name")) {
|
||||
# ATC and name are only in first row
|
||||
returnvalue[i] <- out[1, property]
|
||||
returnvalue[i] <- out[1, property, drop = TRUE]
|
||||
} else {
|
||||
if (!"adm.r" %in% colnames(out) | is.na(out[1, "adm.r"])) {
|
||||
if (!"adm.r" %in% colnames(out) | is.na(out[1, "adm.r", drop = TRUE])) {
|
||||
returnvalue[i] <- NA
|
||||
next
|
||||
} else {
|
||||
for (j in seq_len(nrow(out))) {
|
||||
if (out[j, "adm.r"] == administration) {
|
||||
returnvalue[i] <- out[j, property]
|
||||
returnvalue[i] <- out[j, property, drop = TRUE]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' filter(mo == as.mo("E. coli")) %>%
|
||||
#' filter(mo == as.mo("Escherichia coli")) %>%
|
||||
#' select_if(is.rsi) %>%
|
||||
#' availability()
|
||||
#' }
|
||||
@@ -45,6 +45,8 @@ availability <- function(tbl, width = NULL) {
|
||||
meet_criteria(tbl, allow_class = "data.frame")
|
||||
meet_criteria(width, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)
|
||||
|
||||
tbl <- as.data.frame(tbl, stringsAsFactors = FALSE)
|
||||
|
||||
x <- vapply(FUN.VALUE = double(1), tbl, function(x) {
|
||||
1 - sum(is.na(x)) / length(x)
|
||||
})
|
||||
@@ -57,14 +59,14 @@ availability <- function(tbl, width = NULL) {
|
||||
if (is.null(width)) {
|
||||
width <- options()$width -
|
||||
(max(nchar(colnames(tbl))) +
|
||||
# count col
|
||||
8 +
|
||||
# available % column
|
||||
10 +
|
||||
# resistant % column
|
||||
10 +
|
||||
# extra margin
|
||||
5)
|
||||
# count col
|
||||
8 +
|
||||
# available % column
|
||||
10 +
|
||||
# resistant % column
|
||||
10 +
|
||||
# extra margin
|
||||
5)
|
||||
width <- width / 2
|
||||
}
|
||||
|
||||
@@ -80,14 +82,16 @@ availability <- function(tbl, width = NULL) {
|
||||
x_chars <- strrep("#", round(x, digits = 2) / (1 / width))
|
||||
x_chars_empty <- strrep("-", width - nchar(x_chars))
|
||||
|
||||
df <- data.frame(count = n,
|
||||
available = percentage(x),
|
||||
visual_availabilty = paste0("|", x_chars, x_chars_empty, "|"),
|
||||
resistant = R_print,
|
||||
visual_resistance = vis_resistance,
|
||||
stringsAsFactors = FALSE)
|
||||
df <- data.frame(
|
||||
count = n,
|
||||
available = percentage(x),
|
||||
visual_availabilty = paste0("|", x_chars, x_chars_empty, "|"),
|
||||
resistant = R_print,
|
||||
visual_resistance = vis_resistance,
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
if (length(R[is.na(R)]) == ncol(tbl)) {
|
||||
df[, 1:3]
|
||||
df[, 1:3, drop = FALSE]
|
||||
} else {
|
||||
df
|
||||
}
|
||||
|
||||
@@ -48,12 +48,17 @@
|
||||
#'
|
||||
#' # Use FUN to change to transformation of microorganism codes
|
||||
#' bug_drug_combinations(example_isolates,
|
||||
#' FUN = mo_gramstain)
|
||||
#' FUN = mo_gramstain
|
||||
#' )
|
||||
#'
|
||||
#' bug_drug_combinations(example_isolates,
|
||||
#' FUN = function(x) ifelse(x == as.mo("E. coli"),
|
||||
#' "E. coli",
|
||||
#' "Others"))
|
||||
#' FUN = function(x) {
|
||||
#' ifelse(x == as.mo("Escherichia coli"),
|
||||
#' "E. coli",
|
||||
#' "Others"
|
||||
#' )
|
||||
#' }
|
||||
#' )
|
||||
#' }
|
||||
bug_drug_combinations <- function(x,
|
||||
col_mo = NULL,
|
||||
@@ -89,13 +94,15 @@ bug_drug_combinations <- function(x,
|
||||
}
|
||||
|
||||
run_it <- function(x) {
|
||||
out <- data.frame(mo = character(0),
|
||||
ab = character(0),
|
||||
S = integer(0),
|
||||
I = integer(0),
|
||||
R = integer(0),
|
||||
total = integer(0),
|
||||
stringsAsFactors = FALSE)
|
||||
out <- data.frame(
|
||||
mo = character(0),
|
||||
ab = character(0),
|
||||
S = integer(0),
|
||||
I = integer(0),
|
||||
R = integer(0),
|
||||
total = integer(0),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
if (data_has_groups) {
|
||||
group_values <- unique(x[, which(colnames(x) %in% groups), drop = FALSE])
|
||||
rownames(group_values) <- NULL
|
||||
@@ -111,18 +118,21 @@ bug_drug_combinations <- function(x,
|
||||
data.frame(S = m["S", ], I = m["I", ], R = m["R", ], stringsAsFactors = FALSE)
|
||||
})
|
||||
merged <- do.call(rbind, pivot)
|
||||
out_group <- data.frame(mo = rep(unique_mo[i], NROW(merged)),
|
||||
ab = rownames(merged),
|
||||
S = merged$S,
|
||||
I = merged$I,
|
||||
R = merged$R,
|
||||
total = merged$S + merged$I + merged$R,
|
||||
stringsAsFactors = FALSE)
|
||||
out_group <- data.frame(
|
||||
mo = rep(unique_mo[i], NROW(merged)),
|
||||
ab = rownames(merged),
|
||||
S = merged$S,
|
||||
I = merged$I,
|
||||
R = merged$R,
|
||||
total = merged$S + merged$I + merged$R,
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
if (data_has_groups) {
|
||||
if (nrow(group_values) < nrow(out_group)) {
|
||||
# repeat group_values for the number of rows in out_group
|
||||
repeated <- rep(seq_len(nrow(group_values)),
|
||||
each = nrow(out_group) / nrow(group_values))
|
||||
each = nrow(out_group) / nrow(group_values)
|
||||
)
|
||||
group_values <- group_values[repeated, , drop = FALSE]
|
||||
}
|
||||
out_group <- cbind(group_values, out_group)
|
||||
@@ -144,15 +154,12 @@ bug_drug_combinations <- function(x,
|
||||
|
||||
if (data_has_groups) {
|
||||
out <- apply_group(x, "run_it", groups)
|
||||
rownames(out) <- NULL
|
||||
set_clean_class(out,
|
||||
new_class = c("grouped", "bug_drug_combinations", "data.frame"))
|
||||
} else {
|
||||
out <- run_it(x)
|
||||
rownames(out) <- NULL
|
||||
set_clean_class(out,
|
||||
new_class = c("bug_drug_combinations", "data.frame"))
|
||||
}
|
||||
rownames(out) <- NULL
|
||||
out <- as_original_data_class(out, class(x.bak))
|
||||
structure(out, class = c("bug_drug_combinations", ifelse(data_has_groups, "grouped", character(0)), class(out)))
|
||||
}
|
||||
|
||||
#' @method format bug_drug_combinations
|
||||
@@ -180,19 +187,25 @@ format.bug_drug_combinations <- function(x,
|
||||
meet_criteria(decimal.mark, allow_class = "character", has_length = 1)
|
||||
meet_criteria(big.mark, allow_class = "character", has_length = 1)
|
||||
|
||||
x.bak <- x
|
||||
if (inherits(x, "grouped")) {
|
||||
# bug_drug_combinations() has been run on groups, so de-group here
|
||||
warning_("in `format()`: formatting the output of `bug_drug_combinations()` does not support grouped variables, they were ignored")
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
idx <- split(seq_len(nrow(x)), paste0(x$mo, "%%", x$ab))
|
||||
x <- data.frame(mo = gsub("(.*)%%(.*)", "\\1", names(idx)),
|
||||
ab = gsub("(.*)%%(.*)", "\\2", names(idx)),
|
||||
S = sapply(idx, function(i) sum(y$S[i], na.rm = TRUE)),
|
||||
I = sapply(idx, function(i) sum(y$I[i], na.rm = TRUE)),
|
||||
R = sapply(idx, function(i) sum(y$R[i], na.rm = TRUE)),
|
||||
total = sapply(idx, function(i) sum(y$S[i], na.rm = TRUE) +
|
||||
sum(y$I[i], na.rm = TRUE) +
|
||||
sum(y$R[i], na.rm = TRUE)),
|
||||
stringsAsFactors = FALSE)
|
||||
x <- data.frame(
|
||||
mo = gsub("(.*)%%(.*)", "\\1", names(idx)),
|
||||
ab = gsub("(.*)%%(.*)", "\\2", names(idx)),
|
||||
S = sapply(idx, function(i) sum(x$S[i], na.rm = TRUE)),
|
||||
I = sapply(idx, function(i) sum(x$I[i], na.rm = TRUE)),
|
||||
R = sapply(idx, function(i) sum(x$R[i], na.rm = TRUE)),
|
||||
total = sapply(idx, function(i) {
|
||||
sum(x$S[i], na.rm = TRUE) +
|
||||
sum(x$I[i], na.rm = TRUE) +
|
||||
sum(x$R[i], na.rm = TRUE)
|
||||
}),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
@@ -226,7 +239,8 @@ format.bug_drug_combinations <- function(x,
|
||||
remove_NAs <- function(.data) {
|
||||
cols <- colnames(.data)
|
||||
.data <- as.data.frame(lapply(.data, function(x) ifelse(is.na(x), "", x)),
|
||||
stringsAsFactors = FALSE)
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
colnames(.data) <- cols
|
||||
.data
|
||||
}
|
||||
@@ -240,23 +254,29 @@ format.bug_drug_combinations <- function(x,
|
||||
}
|
||||
|
||||
y <- x %pm>%
|
||||
create_var(ab = as.ab(x$ab),
|
||||
ab_txt = give_ab_name(ab = x$ab, format = translate_ab, language = language)) %pm>%
|
||||
create_var(
|
||||
ab = as.ab(x$ab),
|
||||
ab_txt = give_ab_name(ab = x$ab, format = translate_ab, language = language)
|
||||
) %pm>%
|
||||
pm_group_by(ab, ab_txt, mo) %pm>%
|
||||
pm_summarise(isolates = sum(isolates, na.rm = TRUE),
|
||||
total = sum(total, na.rm = TRUE)) %pm>%
|
||||
pm_summarise(
|
||||
isolates = sum(isolates, na.rm = TRUE),
|
||||
total = sum(total, na.rm = TRUE)
|
||||
) %pm>%
|
||||
pm_ungroup()
|
||||
|
||||
y <- y %pm>%
|
||||
create_var(txt = paste0(percentage(y$isolates / y$total, decimal.mark = decimal.mark, big.mark = big.mark),
|
||||
" (", trimws(format(y$isolates, big.mark = big.mark)), "/",
|
||||
trimws(format(y$total, big.mark = big.mark)), ")")) %pm>%
|
||||
create_var(txt = paste0(
|
||||
percentage(y$isolates / y$total, decimal.mark = decimal.mark, big.mark = big.mark),
|
||||
" (", trimws(format(y$isolates, big.mark = big.mark)), "/",
|
||||
trimws(format(y$total, big.mark = big.mark)), ")"
|
||||
)) %pm>%
|
||||
pm_select(ab, ab_txt, mo, txt) %pm>%
|
||||
pm_arrange(mo)
|
||||
|
||||
# replace tidyr::pivot_wider() from here
|
||||
for (i in unique(y$mo)) {
|
||||
mo_group <- y[which(y$mo == i), c("ab", "txt")]
|
||||
mo_group <- y[which(y$mo == i), c("ab", "txt"), drop = FALSE]
|
||||
colnames(mo_group) <- c("ab", i)
|
||||
rownames(mo_group) <- NULL
|
||||
y <- y %pm>%
|
||||
@@ -269,7 +289,7 @@ format.bug_drug_combinations <- function(x,
|
||||
remove_NAs()
|
||||
|
||||
select_ab_vars <- function(.data) {
|
||||
.data[, c("ab_group", "ab_txt", colnames(.data)[!colnames(.data) %in% c("ab_group", "ab_txt", "ab")])]
|
||||
.data[, c("ab_group", "ab_txt", colnames(.data)[!colnames(.data) %in% c("ab_group", "ab_txt", "ab")]), drop = FALSE]
|
||||
}
|
||||
|
||||
y <- y %pm>%
|
||||
@@ -286,8 +306,10 @@ format.bug_drug_combinations <- function(x,
|
||||
colnames(y)[1] <- translate_into_language(colnames(y)[1], language, only_unknown = FALSE)
|
||||
} else {
|
||||
y <- y %pm>%
|
||||
pm_rename("Group" = ab_group,
|
||||
"Drug" = ab_txt)
|
||||
pm_rename(
|
||||
"Group" = ab_group,
|
||||
"Drug" = ab_txt
|
||||
)
|
||||
}
|
||||
|
||||
if (!is.null(language)) {
|
||||
@@ -299,17 +321,21 @@ format.bug_drug_combinations <- function(x,
|
||||
}
|
||||
|
||||
rownames(y) <- NULL
|
||||
y
|
||||
as_original_data_class(y, class(x.bak))
|
||||
}
|
||||
|
||||
#' @method print bug_drug_combinations
|
||||
#' @export
|
||||
print.bug_drug_combinations <- function(x, ...) {
|
||||
x_class <- class(x)
|
||||
print(set_clean_class(x,
|
||||
new_class = x_class[!x_class %in% c("bug_drug_combinations", "grouped")]),
|
||||
...)
|
||||
print(
|
||||
set_clean_class(x,
|
||||
new_class = x_class[!x_class %in% c("bug_drug_combinations", "grouped")]
|
||||
),
|
||||
...
|
||||
)
|
||||
message_("Use 'format()' on this result to get a publishable/printable format.",
|
||||
ifelse(inherits(x, "grouped"), " Note: The grouping variable(s) will be ignored.", ""),
|
||||
as_note = FALSE)
|
||||
ifelse(inherits(x, "grouped"), " Note: The grouping variable(s) will be ignored.", ""),
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ format_included_data_number <- function(data) {
|
||||
#' [Click here][catalogue_of_life] for more information about the included taxa. Check which versions of the CoL and LPSN were included in this package with [catalogue_of_life_version()].
|
||||
#' @section Included Taxa:
|
||||
#' Included are:
|
||||
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom %in% c("Archeae", "Bacteria", "Chromista", "Protozoa")), ])` (sub)species from the kingdoms of Archaea, Bacteria, Chromista and Protozoa
|
||||
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Fungi" & microorganisms$order %in% c("Eurotiales", "Microascales", "Mucorales", "Onygenales", "Pneumocystales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales")), ])` (sub)species from these orders of the kingdom of Fungi: Eurotiales, Microascales, Mucorales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales, as well as `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Fungi" & !microorganisms$order %in% c("Eurotiales", "Microascales", "Mucorales", "Onygenales", "Pneumocystales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales")), ])` other fungal (sub)species. The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant fungi are covered (such as all species of *Aspergillus*, *Candida*, *Cryptococcus*, *Histplasma*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*).
|
||||
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Animalia"), ])` (sub)species from `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Animalia"), "genus"])` other relevant genera from the kingdom of Animalia (such as *Strongyloides* and *Taenia*)
|
||||
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom %in% c("Archeae", "Bacteria", "Chromista", "Protozoa")), , drop = FALSE])` (sub)species from the kingdoms of Archaea, Bacteria, Chromista and Protozoa
|
||||
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Fungi" & microorganisms$order %in% c("Eurotiales", "Microascales", "Mucorales", "Onygenales", "Pneumocystales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales")), , drop = FALSE])` (sub)species from these orders of the kingdom of Fungi: Eurotiales, Microascales, Mucorales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales, as well as `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Fungi" & !microorganisms$order %in% c("Eurotiales", "Microascales", "Mucorales", "Onygenales", "Pneumocystales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales")), ])` other fungal (sub)species. The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant fungi are covered (such as all species of *Aspergillus*, *Candida*, *Cryptococcus*, *Histplasma*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*).
|
||||
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Animalia"), , drop = FALSE])` (sub)species from `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Animalia"), "genus", drop = TRUE])` other relevant genera from the kingdom of Animalia (such as *Strongyloides* and *Taenia*)
|
||||
#' - All `r format_included_data_number(microorganisms.old)` previously accepted names of all included (sub)species (these were taxonomically renamed)
|
||||
#' - The complete taxonomic tree of all included (sub)species: from kingdom to subspecies
|
||||
#' - The responsible author(s) and year of scientific publication
|
||||
@@ -72,13 +72,13 @@ format_included_data_number <- function(data) {
|
||||
#' mo_shortname("Chlamydophila psittaci")
|
||||
#'
|
||||
#' # Get any property from the entire taxonomic tree for all included species
|
||||
#' mo_class("E. coli")
|
||||
#' mo_class("Escherichia coli")
|
||||
#'
|
||||
#' mo_family("E. coli")
|
||||
#' mo_family("Escherichia coli")
|
||||
#'
|
||||
#' mo_gramstain("E. coli") # based on kingdom and phylum, see ?mo_gramstain
|
||||
#' mo_gramstain("Escherichia coli") # based on kingdom and phylum, see ?mo_gramstain
|
||||
#'
|
||||
#' mo_ref("E. coli")
|
||||
#' mo_ref("Escherichia coli")
|
||||
#'
|
||||
#' # Do not get mistaken - this package is about microorganisms
|
||||
#' mo_kingdom("C. elegans")
|
||||
@@ -94,41 +94,52 @@ NULL
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @export
|
||||
catalogue_of_life_version <- function() {
|
||||
|
||||
check_dataset_integrity()
|
||||
|
||||
# see the `CATALOGUE_OF_LIFE` list in R/globals.R
|
||||
lst <- list(CoL =
|
||||
list(version = gsub("{year}", CATALOGUE_OF_LIFE$year, CATALOGUE_OF_LIFE$version, fixed = TRUE),
|
||||
url = gsub("{year}", CATALOGUE_OF_LIFE$year, CATALOGUE_OF_LIFE$url_CoL, fixed = TRUE),
|
||||
n = nrow(pm_filter(microorganisms, source == "CoL"))),
|
||||
LPSN =
|
||||
list(version = "List of Prokaryotic names with Standing in Nomenclature",
|
||||
url = CATALOGUE_OF_LIFE$url_LPSN,
|
||||
yearmonth = CATALOGUE_OF_LIFE$yearmonth_LPSN,
|
||||
n = nrow(pm_filter(microorganisms, source == "LPSN"))),
|
||||
total_included =
|
||||
list(
|
||||
n_total_species = nrow(microorganisms),
|
||||
n_total_synonyms = nrow(microorganisms.old)))
|
||||
lst <- list(
|
||||
CoL =
|
||||
list(
|
||||
version = gsub("{year}", CATALOGUE_OF_LIFE$year, CATALOGUE_OF_LIFE$version, fixed = TRUE),
|
||||
url = gsub("{year}", CATALOGUE_OF_LIFE$year, CATALOGUE_OF_LIFE$url_CoL, fixed = TRUE),
|
||||
n = nrow(pm_filter(microorganisms, source == "CoL"))
|
||||
),
|
||||
LPSN =
|
||||
list(
|
||||
version = "List of Prokaryotic names with Standing in Nomenclature",
|
||||
url = CATALOGUE_OF_LIFE$url_LPSN,
|
||||
yearmonth = CATALOGUE_OF_LIFE$yearmonth_LPSN,
|
||||
n = nrow(pm_filter(microorganisms, source == "LPSN"))
|
||||
),
|
||||
total_included =
|
||||
list(
|
||||
n_total_species = nrow(microorganisms),
|
||||
n_total_synonyms = nrow(microorganisms.old)
|
||||
)
|
||||
)
|
||||
|
||||
set_clean_class(lst,
|
||||
new_class = c("catalogue_of_life_version", "list"))
|
||||
new_class = c("catalogue_of_life_version", "list")
|
||||
)
|
||||
}
|
||||
|
||||
#' @method print catalogue_of_life_version
|
||||
#' @export
|
||||
#' @noRd
|
||||
print.catalogue_of_life_version <- function(x, ...) {
|
||||
cat(paste0(font_bold("Included in this AMR package (v", utils::packageDescription("AMR")$Version, ") are:\n\n", collapse = ""),
|
||||
font_underline(x$CoL$version), "\n",
|
||||
" Available at: ", font_blue(x$CoL$url), "\n",
|
||||
" Number of included microbial species: ", format(x$CoL$n, big.mark = ","), "\n",
|
||||
font_underline(paste0(x$LPSN$version, " (",
|
||||
x$LPSN$yearmonth, ")")), "\n",
|
||||
" Available at: ", font_blue(x$LPSN$url), "\n",
|
||||
" Number of included bacterial species: ", format(x$LPSN$n, big.mark = ","), "\n\n",
|
||||
"=> Total number of species included: ", format(x$total_included$n_total_species, big.mark = ","), "\n",
|
||||
"=> Total number of synonyms included: ", format(x$total_included$n_total_synonyms, big.mark = ","), "\n\n",
|
||||
"See for more info ", font_grey_bg("`?microorganisms`"), " and ", font_grey_bg("`?catalogue_of_life`"), ".\n"))
|
||||
cat(paste0(
|
||||
font_bold("Included in this AMR package (v", utils::packageDescription("AMR")$Version, ") are:\n\n", collapse = ""),
|
||||
font_underline(x$CoL$version), "\n",
|
||||
" Available at: ", font_blue(x$CoL$url), "\n",
|
||||
" Number of included microbial species: ", format(x$CoL$n, big.mark = ","), "\n",
|
||||
font_underline(paste0(
|
||||
x$LPSN$version, " (",
|
||||
x$LPSN$yearmonth, ")"
|
||||
)), "\n",
|
||||
" Available at: ", font_blue(x$LPSN$url), "\n",
|
||||
" Number of included bacterial species: ", format(x$LPSN$n, big.mark = ","), "\n\n",
|
||||
"=> Total number of species included: ", format(x$total_included$n_total_species, big.mark = ","), "\n",
|
||||
"=> Total number of synonyms included: ", format(x$total_included$n_total_synonyms, big.mark = ","), "\n\n",
|
||||
"See for more info ", font_grey_bg("`?microorganisms`"), " and ", font_grey_bg("`?catalogue_of_life`"), ".\n"
|
||||
))
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
#' # run ?example_isolates for more info.
|
||||
#'
|
||||
#' # base R ------------------------------------------------------------
|
||||
#' count_resistant(example_isolates$AMX) # counts "R"
|
||||
#' count_resistant(example_isolates$AMX) # counts "R"
|
||||
#' count_susceptible(example_isolates$AMX) # counts "S" and "I"
|
||||
#' count_all(example_isolates$AMX) # counts "S", "I" and "R"
|
||||
#' count_all(example_isolates$AMX) # counts "S", "I" and "R"
|
||||
#'
|
||||
#' # be more specific
|
||||
#' count_S(example_isolates$AMX)
|
||||
@@ -75,31 +75,33 @@
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(R = count_R(CIP),
|
||||
#' I = count_I(CIP),
|
||||
#' S = count_S(CIP),
|
||||
#' n1 = count_all(CIP), # the actual total; sum of all three
|
||||
#' n2 = n_rsi(CIP), # same - analogous to n_distinct
|
||||
#' total = n()) # NOT the number of tested isolates!
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(
|
||||
#' R = count_R(CIP),
|
||||
#' I = count_I(CIP),
|
||||
#' S = count_S(CIP),
|
||||
#' n1 = count_all(CIP), # the actual total; sum of all three
|
||||
#' n2 = n_rsi(CIP), # same - analogous to n_distinct
|
||||
#' total = n()
|
||||
#' ) # NOT the number of tested isolates!
|
||||
#'
|
||||
#' # Number of available isolates for a whole antibiotic class
|
||||
#' # (i.e., in this data set columns GEN, TOB, AMK, KAN)
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(across(aminoglycosides(), n_rsi))
|
||||
#'
|
||||
#' # Count co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
#' # so we can see that combination therapy does a lot more than mono therapy.
|
||||
#' # Please mind that `susceptibility()` calculates percentages right away instead.
|
||||
#' example_isolates %>% count_susceptible(AMC) # 1433
|
||||
#' example_isolates %>% count_all(AMC) # 1879
|
||||
#' example_isolates %>% count_all(AMC) # 1879
|
||||
#'
|
||||
#' example_isolates %>% count_susceptible(GEN) # 1399
|
||||
#' example_isolates %>% count_all(GEN) # 1855
|
||||
#' example_isolates %>% count_all(GEN) # 1855
|
||||
#'
|
||||
#' example_isolates %>% count_susceptible(AMC, GEN) # 1764
|
||||
#' example_isolates %>% count_all(AMC, GEN) # 1936
|
||||
#' example_isolates %>% count_all(AMC, GEN) # 1936
|
||||
#'
|
||||
#' # Get number of S+I vs. R immediately of selected columns
|
||||
#' example_isolates %>%
|
||||
@@ -108,18 +110,20 @@
|
||||
#'
|
||||
#' # It also supports grouping variables
|
||||
#' example_isolates %>%
|
||||
#' select(hospital_id, AMX, CIP) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' select(ward, AMX, CIP) %>%
|
||||
#' group_by(ward) %>%
|
||||
#' count_df(translate = FALSE)
|
||||
#' }
|
||||
#' }
|
||||
count_resistant <- function(..., only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = "R",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = "R",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
@@ -127,10 +131,12 @@ count_resistant <- function(..., only_all_tested = FALSE) {
|
||||
count_susceptible <- function(..., only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = c("S", "I"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = c("S", "I"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
@@ -138,10 +144,12 @@ count_susceptible <- function(..., only_all_tested = FALSE) {
|
||||
count_R <- function(..., only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = "R",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = "R",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
@@ -152,10 +160,12 @@ count_IR <- function(..., only_all_tested = FALSE) {
|
||||
}
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = c("I", "R"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = c("I", "R"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
@@ -163,10 +173,12 @@ count_IR <- function(..., only_all_tested = FALSE) {
|
||||
count_I <- function(..., only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = "I",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = "I",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
@@ -174,10 +186,12 @@ count_I <- function(..., only_all_tested = FALSE) {
|
||||
count_SI <- function(..., only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = c("S", "I"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = c("S", "I"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
@@ -188,10 +202,12 @@ count_S <- function(..., only_all_tested = FALSE) {
|
||||
}
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = "S",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = "S",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
@@ -199,10 +215,12 @@ count_S <- function(..., only_all_tested = FALSE) {
|
||||
count_all <- function(..., only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = c("S", "I", "R"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = c("S", "I", "R"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
@@ -217,12 +235,15 @@ count_df <- function(data,
|
||||
combine_SI = TRUE,
|
||||
combine_IR = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc_df(type = "count",
|
||||
data = data,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
combine_SI_missing = missing(combine_SI)),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
rsi_calc_df(
|
||||
type = "count",
|
||||
data = data,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
combine_SI_missing = missing(combine_SI)
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#' Define Custom EUCAST Rules
|
||||
#'
|
||||
#' Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in [eucast_rules()].
|
||||
#' @param ... rules in [formula][`~`()] notation, see *Examples*
|
||||
#' @param ... rules in [formula][base::tilde] 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:
|
||||
@@ -77,33 +77,42 @@
|
||||
#' @returns A [list] containing the custom rules
|
||||
#' @export
|
||||
#' @examples
|
||||
#' x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||
#' AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
|
||||
#' x <- custom_eucast_rules(
|
||||
#' AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||
#' AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I"
|
||||
#' )
|
||||
#' x
|
||||
#'
|
||||
#' # run the custom rule set (verbose = TRUE will return a logbook instead of the data set):
|
||||
#' eucast_rules(example_isolates,
|
||||
#' rules = "custom",
|
||||
#' custom_rules = x,
|
||||
#' info = FALSE,
|
||||
#' verbose = TRUE)
|
||||
#' rules = "custom",
|
||||
#' custom_rules = x,
|
||||
#' info = FALSE,
|
||||
#' verbose = TRUE
|
||||
#' )
|
||||
#'
|
||||
#' # combine rule sets
|
||||
#' x2 <- c(x,
|
||||
#' custom_eucast_rules(TZP == "R" ~ carbapenems == "R"))
|
||||
#' 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`")
|
||||
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`")
|
||||
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]]
|
||||
@@ -122,8 +131,10 @@ custom_eucast_rules <- function(...) {
|
||||
|
||||
# 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`")
|
||||
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("AB_", toupper(result_group), "S") %in% DEFINED_AB_GROUPS) {
|
||||
# support for e.g. 'aminopenicillin' if user meant 'aminopenicillins'
|
||||
@@ -134,19 +145,25 @@ custom_eucast_rules <- function(...) {
|
||||
} else {
|
||||
result_group <- tryCatch(
|
||||
suppressWarnings(as.ab(result_group,
|
||||
fast_mode = TRUE,
|
||||
flag_multiple_results = FALSE)),
|
||||
error = function(e) NA_character_)
|
||||
fast_mode = TRUE,
|
||||
flag_multiple_results = FALSE
|
||||
)),
|
||||
error = function(e) NA_character_
|
||||
)
|
||||
}
|
||||
|
||||
stop_if(any(is.na(result_group)),
|
||||
"this result of rule ", i, " could not be translated to a single antimicrobial agent/group: \"",
|
||||
as.character(result)[[2]], "\".\n\nThe input can be a name or code of an antimicrobial agent, or be one of: ",
|
||||
vector_or(tolower(gsub("AB_", "", DEFINED_AB_GROUPS)), quotes = FALSE), ".")
|
||||
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(gsub("AB_", "", 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")
|
||||
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
|
||||
@@ -196,13 +213,19 @@ print.custom_eucast_rules <- function(x, ...) {
|
||||
} 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 <- 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 <- 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 = "")
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#'
|
||||
#' Two data sets containing all antibiotics/antimycotics and antivirals. Use [as.ab()] or one of the [`ab_*`][ab_property()] functions to retrieve values from the [antibiotics] data set. Three identifiers are included in this data set: an antibiotic ID (`ab`, primarily used in this package) as defined by WHONET/EARS-Net, an ATC code (`atc`) as defined by the WHO, and a Compound ID (`cid`) as found in PubChem. Other properties in this data set are derived from one or more of these codes. Note that some drugs have multiple ATC codes.
|
||||
#' @format
|
||||
#' ## For the [antibiotics] data set: a [data.frame] with `r nrow(antibiotics)` observations and `r ncol(antibiotics)` variables:
|
||||
#' ## For the [antibiotics] data set: a [tibble[tibble::tibble] with `r nrow(antibiotics)` observations and `r ncol(antibiotics)` variables:
|
||||
#' - `ab`\cr Antibiotic ID as used in this package (such as `AMC`), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available
|
||||
#' - `cid`\cr Compound ID as found in PubChem
|
||||
#' - `name`\cr Official name as used by WHONET/EARS-Net or the WHO
|
||||
@@ -43,7 +43,7 @@
|
||||
#' - `iv_units`\cr Units of `iv_ddd`
|
||||
#' - `loinc`\cr All LOINC codes (Logical Observation Identifiers Names and Codes) associated with the name of the antimicrobial agent. Use [ab_loinc()] to retrieve them quickly, see [ab_property()].
|
||||
#'
|
||||
#' ## For the [antivirals] data set: a [data.frame] with `r nrow(antivirals)` observations and `r ncol(antivirals)` variables:
|
||||
#' ## For the [antivirals] data set: a [tibble[tibble::tibble] with `r nrow(antivirals)` observations and `r ncol(antivirals)` variables:
|
||||
#' - `atc`\cr ATC codes (Anatomical Therapeutic Chemical) as defined by the WHOCC
|
||||
#' - `cid`\cr Compound ID as found in PubChem
|
||||
#' - `name`\cr Official name as used by WHONET/EARS-Net or the WHO
|
||||
@@ -58,24 +58,15 @@
|
||||
#' Synonyms (i.e. trade names) were derived from the Compound ID (`cid`) and consequently only available where a CID is available.
|
||||
#'
|
||||
#' ## Direct download
|
||||
#' These data sets are available as 'flat files' for use even without \R - you can find the files here:
|
||||
#'
|
||||
#' * <https://github.com/msberends/AMR/raw/main/data-raw/antibiotics.txt>
|
||||
#' * <https://github.com/msberends/AMR/raw/main/data-raw/antivirals.txt>
|
||||
#'
|
||||
#' Files in \R format (with preserved data structure) can be found here:
|
||||
#'
|
||||
#' * <https://github.com/msberends/AMR/raw/main/data/antibiotics.rda>
|
||||
#' * <https://github.com/msberends/AMR/raw/main/data/antivirals.rda>
|
||||
#' Like all data sets in this package, these data sets are publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @source World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): <https://www.whocc.no/atc_ddd_index/>
|
||||
#'
|
||||
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: <https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm>
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @inheritSection WHOCC WHOCC
|
||||
#' @seealso [microorganisms], [intrinsic_resistant]
|
||||
#' @examples
|
||||
#' head(antibiotics)
|
||||
#' head(antivirals)
|
||||
#' antibiotics
|
||||
#' antivirals
|
||||
"antibiotics"
|
||||
|
||||
#' @rdname antibiotics
|
||||
@@ -85,7 +76,7 @@
|
||||
#'
|
||||
#' A data set containing the full microbial taxonomy (**last updated: `r CATALOGUE_OF_LIFE$yearmonth_LPSN`**) of `r nr2char(length(unique(microorganisms$kingdom[!microorganisms$kingdom %like% "unknown"])))` kingdoms from the Catalogue of Life (CoL) and the List of Prokaryotic names with Standing in Nomenclature (LPSN). MO codes can be looked up using [as.mo()].
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @format A [data.frame] with `r format(nrow(microorganisms), big.mark = ",")` observations and `r ncol(microorganisms)` variables:
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(microorganisms), big.mark = ",")` observations and `r ncol(microorganisms)` variables:
|
||||
#' - `mo`\cr ID of microorganism as used by this package
|
||||
#' - `fullname`\cr Full name, like `"Escherichia coli"`
|
||||
#' - `kingdom`, `phylum`, `class`, `order`, `family`, `genus`, `species`, `subspecies`\cr Taxonomic rank of the microorganism
|
||||
@@ -114,10 +105,7 @@
|
||||
#' - 6 families under the Enterobacterales order, according to Adeolu *et al.* (2016, PMID 27620848), that are not (yet) in the Catalogue of Life
|
||||
#'
|
||||
#' ## Direct download
|
||||
#' This data set is available as 'flat file' for use even without \R - you can find the file here: <https://github.com/msberends/AMR/raw/main/data-raw/microorganisms.txt>.
|
||||
#'
|
||||
#' The file in \R format (with preserved data structure) can be found here: <https://github.com/msberends/AMR/raw/main/data/microorganisms.rda>.
|
||||
#'
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @section About the Records from LPSN (see *Source*):
|
||||
#' The List of Prokaryotic names with Standing in Nomenclature (LPSN) provides comprehensive information on the nomenclature of prokaryotes. LPSN is a free to use service founded by Jean P. Euzeby in 1997 and later on maintained by Aidan C. Parte.
|
||||
#'
|
||||
@@ -137,80 +125,80 @@
|
||||
#' `r SNOMED_VERSION$current_source` as currently implemented in this `AMR` package:
|
||||
#'
|
||||
#' * Retrieved from the `r SNOMED_VERSION$title`, OID `r SNOMED_VERSION$current_oid`, version `r SNOMED_VERSION$current_version`; url: <`r SNOMED_VERSION$url`>
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @seealso [as.mo()], [mo_property()], [microorganisms.codes], [intrinsic_resistant]
|
||||
#' @examples
|
||||
#' head(microorganisms)
|
||||
#' microorganisms
|
||||
"microorganisms"
|
||||
|
||||
#' Data Set with Previously Accepted Taxonomic Names
|
||||
#'
|
||||
#' A data set containing old (previously valid or accepted) taxonomic names according to the Catalogue of Life. This data set is used internally by [as.mo()].
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @format A [data.frame] with `r format(nrow(microorganisms.old), big.mark = ",")` observations and `r ncol(microorganisms.old)` variables:
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(microorganisms.old), big.mark = ",")` observations and `r ncol(microorganisms.old)` variables:
|
||||
#' - `fullname`\cr Old full taxonomic name of the microorganism
|
||||
#' - `fullname_new`\cr New full taxonomic name of the microorganism
|
||||
#' - `ref`\cr Author(s) and year of concerning scientific publication
|
||||
#' - `prevalence`\cr Prevalence of the microorganism, see [as.mo()]
|
||||
#' @details
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @source Catalogue of Life: Annual Checklist (public online taxonomic database), <http://www.catalogueoflife.org> (check included annual version with [catalogue_of_life_version()]).
|
||||
#'
|
||||
#' Parte, A.C. (2018). LPSN - List of Prokaryotic names with Standing in Nomenclature (bacterio.net), 20 years on. International Journal of Systematic and Evolutionary Microbiology, 68, 1825-1829; \doi{10.1099/ijsem.0.002786}
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @seealso [as.mo()] [mo_property()] [microorganisms]
|
||||
#' @examples
|
||||
#' head(microorganisms.old)
|
||||
#' microorganisms.old
|
||||
"microorganisms.old"
|
||||
|
||||
#' Data Set with `r format(nrow(microorganisms.codes), big.mark = ",")` Common Microorganism Codes
|
||||
#'
|
||||
#' A data set containing commonly used codes for microorganisms, from laboratory systems and WHONET. Define your own with [set_mo_source()]. They will all be searched when using [as.mo()] and consequently all the [`mo_*`][mo_property()] functions.
|
||||
#' @format A [data.frame] with `r format(nrow(microorganisms.codes), big.mark = ",")` observations and `r ncol(microorganisms.codes)` variables:
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(microorganisms.codes), big.mark = ",")` observations and `r ncol(microorganisms.codes)` variables:
|
||||
#' - `code`\cr Commonly used code of a microorganism
|
||||
#' - `mo`\cr ID of the microorganism in the [microorganisms] data set
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @details
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @inheritSection catalogue_of_life Catalogue of Life
|
||||
#' @seealso [as.mo()] [microorganisms]
|
||||
#' @examples
|
||||
#' head(microorganisms.codes)
|
||||
#' microorganisms.codes
|
||||
"microorganisms.codes"
|
||||
|
||||
#' Data Set with `r format(nrow(example_isolates), big.mark = ",")` Example Isolates
|
||||
#'
|
||||
#' A data set containing `r format(nrow(example_isolates), big.mark = ",")` microbial isolates with their full antibiograms. The data set reflects reality and can be used to practice AMR data analysis. For examples, please read [the tutorial on our website](https://msberends.github.io/AMR/articles/AMR.html).
|
||||
#' @format A [data.frame] with `r format(nrow(example_isolates), big.mark = ",")` observations and `r ncol(example_isolates)` variables:
|
||||
#' - `date`\cr date of receipt at the laboratory
|
||||
#' - `hospital_id`\cr ID of the hospital, from A to D
|
||||
#' - `ward_icu`\cr [logical] to determine if ward is an intensive care unit
|
||||
#' - `ward_clinical`\cr [logical] to determine if ward is a regular clinical ward
|
||||
#' - `ward_outpatient`\cr [logical] to determine if ward is an outpatient clinic
|
||||
#' - `age`\cr age of the patient
|
||||
#' - `gender`\cr gender of the patient
|
||||
#' - `patient_id`\cr ID of the patient
|
||||
#' - `mo`\cr ID of microorganism created with [as.mo()], see also [microorganisms]
|
||||
#' - `PEN:RIF`\cr `r sum(vapply(FUN.VALUE = logical(1), example_isolates, is.rsi))` different antibiotics with class [`rsi`] (see [as.rsi()]); these column names occur in the [antibiotics] data set and can be translated with [ab_name()]
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' A data set containing `r format(nrow(example_isolates), big.mark = ",")` microbial isolates with their full antibiograms. This data set contains randomised fictitious data, but reflects reality and can be used to practise AMR data analysis. For examples, please read [the tutorial on our website](https://msberends.github.io/AMR/articles/AMR.html).
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(example_isolates), big.mark = ",")` observations and `r ncol(example_isolates)` variables:
|
||||
#' - `date`\cr Date of receipt at the laboratory
|
||||
#' - `patient`\cr ID of the patient
|
||||
#' - `age`\cr Age of the patient
|
||||
#' - `gender`\cr Gender of the patient, either `r vector_or(example_isolates$gender)`
|
||||
#' - `ward`\cr Ward type where the patient was admitted, either `r vector_or(example_isolates$ward)`
|
||||
#' - `mo`\cr ID of microorganism created with [as.mo()], see also the [microorganisms] data set
|
||||
#' - `PEN:RIF`\cr `r sum(vapply(FUN.VALUE = logical(1), example_isolates, is.rsi))` different antibiotics with class [`rsi`] (see [as.rsi()]); these column names occur in the [antibiotics] data set and can be translated with [set_ab_names()] or [ab_name()]
|
||||
#' @details
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @examples
|
||||
#' head(example_isolates)
|
||||
#' example_isolates
|
||||
"example_isolates"
|
||||
|
||||
#' Data Set with Unclean Data
|
||||
#'
|
||||
#' A data set containing `r format(nrow(example_isolates_unclean), big.mark = ",")` microbial isolates that are not cleaned up and consequently not ready for AMR data analysis. This data set can be used for practice.
|
||||
#' @format A [data.frame] with `r format(nrow(example_isolates_unclean), big.mark = ",")` observations and `r ncol(example_isolates_unclean)` variables:
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(example_isolates_unclean), big.mark = ",")` observations and `r ncol(example_isolates_unclean)` variables:
|
||||
#' - `patient_id`\cr ID of the patient
|
||||
#' - `date`\cr date of receipt at the laboratory
|
||||
#' - `hospital`\cr ID of the hospital, from A to C
|
||||
#' - `bacteria`\cr info about microorganism that can be transformed with [as.mo()], see also [microorganisms]
|
||||
#' - `AMX:GEN`\cr 4 different antibiotics that have to be transformed with [as.rsi()]
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @details
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @examples
|
||||
#' head(example_isolates_unclean)
|
||||
#' example_isolates_unclean
|
||||
"example_isolates_unclean"
|
||||
|
||||
#' Data Set with `r format(nrow(WHONET), big.mark = ",")` Isolates - WHONET Example
|
||||
#'
|
||||
#' This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The antibiotic results are from our [example_isolates] data set. All patient names are created using online surname generators and are only in place for practice purposes.
|
||||
#' @format A [data.frame] with `r format(nrow(WHONET), big.mark = ",")` observations and `r ncol(WHONET)` variables:
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(WHONET), big.mark = ",")` observations and `r ncol(WHONET)` variables:
|
||||
#' - `Identification number`\cr ID of the sample
|
||||
#' - `Specimen number`\cr ID of the specimen
|
||||
#' - `Organism`\cr Name of the microorganism. Before analysis, you should transform this to a valid microbial class, using [as.mo()].
|
||||
@@ -237,15 +225,16 @@
|
||||
#' - `Comment`\cr Other comments
|
||||
#' - `Date of data entry`\cr [Date] this data was entered in WHONET
|
||||
#' - `AMP_ND10:CIP_EE`\cr `r sum(vapply(FUN.VALUE = logical(1), WHONET, is.rsi))` different antibiotics. You can lookup the abbreviations in the [antibiotics] data set, or use e.g. [`ab_name("AMP")`][ab_name()] to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using [as.rsi()].
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @details
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @examples
|
||||
#' head(WHONET)
|
||||
#' WHONET
|
||||
"WHONET"
|
||||
|
||||
#' Data Set for R/SI Interpretation
|
||||
#'
|
||||
#' Data set containing reference data to interpret MIC and disk diffusion to R/SI values, according to international guidelines. Currently implemented guidelines are EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`). Use [as.rsi()] to transform MICs or disks measurements to R/SI values.
|
||||
#' @format A [data.frame] with `r format(nrow(rsi_translation), big.mark = ",")` observations and `r ncol(rsi_translation)` variables:
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(rsi_translation), big.mark = ",")` observations and `r ncol(rsi_translation)` variables:
|
||||
#' - `guideline`\cr Name of the guideline
|
||||
#' - `method`\cr Either `r vector_or(rsi_translation$method)`
|
||||
#' - `site`\cr Body site, e.g. "Oral" or "Respiratory"
|
||||
@@ -258,31 +247,35 @@
|
||||
#' - `breakpoint_R`\cr Highest MIC value or lowest number of millimetres that leads to "R"
|
||||
#' - `uti`\cr A [logical] value (`TRUE`/`FALSE`) to indicate whether the rule applies to a urinary tract infection (UTI)
|
||||
#' @details
|
||||
#' The repository of this `AMR` package contains a file comprising this exact data set: <https://github.com/msberends/AMR/blob/main/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 and the `mo` and `ab` columns have been transformed to contain the full official names instead of codes.
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#'
|
||||
#' They **allow for machine reading EUCAST and CLSI guidelines**, which is almost impossible with the MS Excel and PDF files distributed by EUCAST and CLSI.
|
||||
#' @seealso [intrinsic_resistant]
|
||||
#' @examples
|
||||
#' head(rsi_translation)
|
||||
#' rsi_translation
|
||||
"rsi_translation"
|
||||
|
||||
#' Data Set with Bacterial Intrinsic Resistance
|
||||
#'
|
||||
#' Data set containing defined intrinsic resistance by EUCAST of all bug-drug combinations.
|
||||
#' @format A [data.frame] with `r format(nrow(intrinsic_resistant), big.mark = ",")` observations and `r ncol(intrinsic_resistant)` variables:
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(intrinsic_resistant), big.mark = ",")` observations and `r ncol(intrinsic_resistant)` variables:
|
||||
#' - `mo`\cr Microorganism ID
|
||||
#' - `ab`\cr Antibiotic ID
|
||||
#' @details The repository of this `AMR` package contains a file comprising this data set with full taxonomic and antibiotic names: <https://github.com/msberends/AMR/blob/main/data-raw/intrinsic_resistant.txt>. This file **allows for machine reading EUCAST guidelines about intrinsic resistance**, which is almost impossible with the Excel and PDF files distributed by EUCAST. The file is updated automatically.
|
||||
#'
|
||||
#' @details
|
||||
#' This data set is based on `r format_eucast_version_nr(3.3)`.
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#'
|
||||
#' ## Direct download
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#'
|
||||
#' They **allow for machine reading EUCAST and CLSI guidelines**, which is almost impossible with the MS Excel and PDF files distributed by EUCAST and CLSI.
|
||||
#' @examples
|
||||
#' head(intrinsic_resistant)
|
||||
#' intrinsic_resistant
|
||||
"intrinsic_resistant"
|
||||
|
||||
#' Data Set with Treatment Dosages as Defined by EUCAST
|
||||
#'
|
||||
#' EUCAST breakpoints used in this package are based on the dosages in this data set. They can be retrieved with [eucast_dosage()].
|
||||
#' @format A [data.frame] with `r format(nrow(dosage), big.mark = ",")` observations and `r ncol(dosage)` variables:
|
||||
#' @format A [tibble[tibble::tibble] with `r format(nrow(dosage), big.mark = ",")` observations and `r ncol(dosage)` variables:
|
||||
#' - `ab`\cr Antibiotic ID as used in this package (such as `AMC`), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available
|
||||
#' - `name`\cr Official name of the antimicrobial agent as used by WHONET/EARS-Net or the WHO
|
||||
#' - `type`\cr Type of the dosage, either `r vector_or(dosage$type)`
|
||||
@@ -292,8 +285,11 @@
|
||||
#' - `notes`\cr Additional dosage notes
|
||||
#' - `original_txt`\cr Original text in the PDF file of EUCAST
|
||||
#' - `eucast_version`\cr Version number of the EUCAST Clinical Breakpoints guideline to which these dosages apply
|
||||
#' @details `r format_eucast_version_nr(11.0)` are based on the dosages in this data set.
|
||||
#' @inheritSection AMR Reference Data Publicly Available
|
||||
#' @details
|
||||
#' This data set is based on `r format_eucast_version_nr(11.0)`.
|
||||
#'
|
||||
#' ## Direct download
|
||||
#' Like all data sets in this package, this data set is publicly available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. Please visit [our website for the download links](https://msberends.github.io/AMR/articles/datasets.html). The actual files are of course available on [our GitHub repository](https://github.com/msberends/AMR/tree/main/data-raw).
|
||||
#' @examples
|
||||
#' head(dosage)
|
||||
#' dosage
|
||||
"dosage"
|
||||
|
||||
@@ -36,11 +36,13 @@
|
||||
#' @seealso [as.rsi()]
|
||||
#' @examples
|
||||
#' # transform existing disk zones to the `disk` class (using base R)
|
||||
#' df <- data.frame(microorganism = "Escherichia coli",
|
||||
#' AMP = 20,
|
||||
#' CIP = 14,
|
||||
#' GEN = 18,
|
||||
#' TOB = 16)
|
||||
#' df <- data.frame(
|
||||
#' microorganism = "Escherichia coli",
|
||||
#' AMP = 20,
|
||||
#' CIP = 14,
|
||||
#' GEN = 18,
|
||||
#' TOB = 16
|
||||
#' )
|
||||
#' df[, 2:5] <- lapply(df[, 2:5], as.disk)
|
||||
#' str(df)
|
||||
#'
|
||||
@@ -52,10 +54,12 @@
|
||||
#' }
|
||||
#'
|
||||
#' # interpret disk values, see ?as.rsi
|
||||
#' as.rsi(x = as.disk(18),
|
||||
#' mo = "Strep pneu", # `mo` will be coerced with as.mo()
|
||||
#' ab = "ampicillin", # and `ab` with as.ab()
|
||||
#' guideline = "EUCAST")
|
||||
#' as.rsi(
|
||||
#' x = as.disk(18),
|
||||
#' mo = "Strep pneu", # `mo` will be coerced with as.mo()
|
||||
#' ab = "ampicillin", # and `ab` with as.ab()
|
||||
#' guideline = "EUCAST"
|
||||
#' )
|
||||
#'
|
||||
#' # interpret whole data set, pretend to be all from urinary tract infections:
|
||||
#' as.rsi(df, uti = TRUE)
|
||||
@@ -81,12 +85,15 @@ as.disk <- function(x, na.rm = FALSE) {
|
||||
# only keep last dot/comma
|
||||
reverse <- function(x) vapply(FUN.VALUE = character(1), lapply(strsplit(x, NULL), rev), paste, collapse = "")
|
||||
x <- sub("{{dot}}", ".",
|
||||
gsub(".", "",
|
||||
reverse(sub(".", "}}tod{{",
|
||||
reverse(x),
|
||||
fixed = TRUE)),
|
||||
fixed = TRUE),
|
||||
fixed = TRUE)
|
||||
gsub(".", "",
|
||||
reverse(sub(".", "}}tod{{",
|
||||
reverse(x),
|
||||
fixed = TRUE
|
||||
)),
|
||||
fixed = TRUE
|
||||
),
|
||||
fixed = TRUE
|
||||
)
|
||||
x_clean <- gsub(remove, "", x, ignore.case = TRUE, fixed = fixed)
|
||||
# remove everything that is not a number or dot
|
||||
as.double(gsub("[^0-9.]+", "", x_clean))
|
||||
@@ -104,14 +111,17 @@ as.disk <- function(x, na.rm = FALSE) {
|
||||
unique() %pm>%
|
||||
sort() %pm>%
|
||||
vector_and(quotes = TRUE)
|
||||
warning_("in `as.disk()`: ", na_after - na_before, " results truncated (",
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid disk zones: ",
|
||||
list_missing)
|
||||
warning_(
|
||||
"in `as.disk()`: ", na_after - na_before, " results truncated (",
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid disk zones: ",
|
||||
list_missing
|
||||
)
|
||||
}
|
||||
}
|
||||
set_clean_class(as.integer(x),
|
||||
new_class = c("disk", "integer"))
|
||||
new_class = c("disk", "integer")
|
||||
)
|
||||
}
|
||||
|
||||
all_valid_disks <- function(x) {
|
||||
@@ -119,7 +129,8 @@ all_valid_disks <- function(x) {
|
||||
return(FALSE)
|
||||
}
|
||||
x_disk <- tryCatch(suppressWarnings(as.disk(x[!is.na(x)])),
|
||||
error = function(e) NA)
|
||||
error = function(e) NA
|
||||
)
|
||||
!any(is.na(x_disk)) && !all(is.na(x))
|
||||
}
|
||||
|
||||
@@ -127,7 +138,8 @@ all_valid_disks <- function(x) {
|
||||
#' @details `NA_disk_` is a missing value of the new `<disk>` class.
|
||||
#' @export
|
||||
NA_disk_ <- set_clean_class(as.integer(NA_real_),
|
||||
new_class = c("disk", "integer"))
|
||||
new_class = c("disk", "integer")
|
||||
)
|
||||
|
||||
#' @rdname as.disk
|
||||
#' @export
|
||||
@@ -218,10 +230,10 @@ rep.disk <- function(x, ...) {
|
||||
get_skimmers.disk <- function(column) {
|
||||
skimr::sfl(
|
||||
skim_type = "disk",
|
||||
min = ~min(as.double(.), na.rm = TRUE),
|
||||
max = ~max(as.double(.), na.rm = TRUE),
|
||||
median = ~stats::median(as.double(.), na.rm = TRUE),
|
||||
n_unique = ~length(unique(stats::na.omit(.))),
|
||||
hist = ~skimr::inline_hist(stats::na.omit(as.double(.)))
|
||||
min = ~ min(as.double(.), na.rm = TRUE),
|
||||
max = ~ max(as.double(.), na.rm = TRUE),
|
||||
median = ~ stats::median(as.double(.), na.rm = TRUE),
|
||||
n_unique = ~ length(unique(stats::na.omit(.))),
|
||||
hist = ~ skimr::inline_hist(stats::na.omit(as.double(.)))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -46,61 +46,76 @@
|
||||
#' # See ?example_isolates
|
||||
#' df <- example_isolates[sample(seq_len(2000), size = 200), ]
|
||||
#'
|
||||
#' get_episode(df$date, episode_days = 60) # indices
|
||||
#' get_episode(df$date, episode_days = 60) # indices
|
||||
#' is_new_episode(df$date, episode_days = 60) # TRUE/FALSE
|
||||
#'
|
||||
#' # filter on results from the third 60-day episode only, using base R
|
||||
#' df[which(get_episode(df$date, 60) == 3), ]
|
||||
#'
|
||||
#' # the functions also work for less than a day, e.g. to include one per hour:
|
||||
#' get_episode(c(Sys.time(),
|
||||
#' Sys.time() + 60 * 60),
|
||||
#' episode_days = 1/24)
|
||||
#' get_episode(c(
|
||||
#' Sys.time(),
|
||||
#' Sys.time() + 60 * 60
|
||||
#' ),
|
||||
#' episode_days = 1 / 24
|
||||
#' )
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' # is_new_episode() can also be used in dplyr verbs to determine patient
|
||||
#' # episodes based on any (combination of) grouping variables:
|
||||
#' df %>%
|
||||
#' mutate(condition = sample(x = c("A", "B", "C"),
|
||||
#' size = 2000,
|
||||
#' replace = TRUE)) %>%
|
||||
#' mutate(condition = sample(
|
||||
#' x = c("A", "B", "C"),
|
||||
#' size = 200,
|
||||
#' replace = TRUE
|
||||
#' )) %>%
|
||||
#' group_by(condition) %>%
|
||||
#' mutate(new_episode = is_new_episode(date, 365)) %>%
|
||||
#' select(patient_id, date, condition, new_episode)
|
||||
#'
|
||||
#' select(patient, date, condition, new_episode)
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#' df %>%
|
||||
#' group_by(hospital_id, patient_id) %>%
|
||||
#' group_by(ward, patient) %>%
|
||||
#' transmute(date,
|
||||
#' patient_id,
|
||||
#' new_index = get_episode(date, 60),
|
||||
#' new_logical = is_new_episode(date, 60))
|
||||
#'
|
||||
#' patient,
|
||||
#' new_index = get_episode(date, 60),
|
||||
#' new_logical = is_new_episode(date, 60)
|
||||
#' )
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#' df %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(n_patients = n_distinct(patient_id),
|
||||
#' n_episodes_365 = sum(is_new_episode(date, episode_days = 365)),
|
||||
#' n_episodes_60 = sum(is_new_episode(date, episode_days = 60)),
|
||||
#' n_episodes_30 = sum(is_new_episode(date, episode_days = 30)))
|
||||
#'
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(
|
||||
#' n_patients = n_distinct(patient),
|
||||
#' n_episodes_365 = sum(is_new_episode(date, episode_days = 365)),
|
||||
#' n_episodes_60 = sum(is_new_episode(date, episode_days = 60)),
|
||||
#' n_episodes_30 = sum(is_new_episode(date, episode_days = 30))
|
||||
#' )
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # grouping on patients and microorganisms leads to the same
|
||||
#' # results as first_isolate() when using 'episode-based':
|
||||
#' x <- df %>%
|
||||
#' filter_first_isolate(include_unknown = TRUE,
|
||||
#' method = "episode-based")
|
||||
#' filter_first_isolate(
|
||||
#' include_unknown = TRUE,
|
||||
#' method = "episode-based"
|
||||
#' )
|
||||
#'
|
||||
#' y <- df %>%
|
||||
#' group_by(patient_id, mo) %>%
|
||||
#' group_by(patient, mo) %>%
|
||||
#' filter(is_new_episode(date, 365)) %>%
|
||||
#' ungroup()
|
||||
#'
|
||||
#' identical(x, y)
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # but is_new_episode() has a lot more flexibility than first_isolate(),
|
||||
#' # since you can now group on anything that seems relevant:
|
||||
#' df %>%
|
||||
#' group_by(patient_id, mo, hospital_id, ward_icu) %>%
|
||||
#' group_by(patient, mo, ward) %>%
|
||||
#' mutate(flag_episode = is_new_episode(date, 365)) %>%
|
||||
#' select(group_vars(.), flag_episode)
|
||||
#' }
|
||||
@@ -109,10 +124,12 @@ get_episode <- function(x, episode_days, ...) {
|
||||
meet_criteria(x, allow_class = c("Date", "POSIXt"), allow_NA = TRUE)
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||
|
||||
exec_episode(x = x,
|
||||
type = "sequential",
|
||||
episode_days = episode_days,
|
||||
... = ...)
|
||||
exec_episode(
|
||||
x = x,
|
||||
type = "sequential",
|
||||
episode_days = episode_days,
|
||||
... = ...
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname get_episode
|
||||
@@ -121,10 +138,12 @@ is_new_episode <- function(x, episode_days, ...) {
|
||||
meet_criteria(x, allow_class = c("Date", "POSIXt"), allow_NA = TRUE)
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||
|
||||
exec_episode(x = x,
|
||||
type = "logical",
|
||||
episode_days = episode_days,
|
||||
... = ...)
|
||||
exec_episode(
|
||||
x = x,
|
||||
type = "logical",
|
||||
episode_days = episode_days,
|
||||
... = ...
|
||||
)
|
||||
}
|
||||
|
||||
exec_episode <- function(x, type, episode_days, ...) {
|
||||
|
||||
@@ -35,11 +35,15 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
for (i in seq_len(length(version))) {
|
||||
v <- version[i]
|
||||
if (markdown == TRUE) {
|
||||
txt <- c(txt, paste0("[", lst[[v]]$title, " ", lst[[v]]$version_txt, "](", lst[[v]]$url, ")",
|
||||
" (", lst[[v]]$year, ")"))
|
||||
txt <- c(txt, paste0(
|
||||
"[", lst[[v]]$title, " ", lst[[v]]$version_txt, "](", lst[[v]]$url, ")",
|
||||
" (", lst[[v]]$year, ")"
|
||||
))
|
||||
} else {
|
||||
txt <- c(txt, paste0(lst[[version]]$title, " ", lst[[v]]$version_txt,
|
||||
" (", lst[[v]]$year, ")"))
|
||||
txt <- c(txt, paste0(
|
||||
lst[[version]]$title, " ", lst[[v]]$version_txt,
|
||||
" (", lst[[v]]$year, ")"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +56,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
#' Apply rules for clinical breakpoints and intrinsic resistance as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, <https://eucast.org>), see *Source*. Use [eucast_dosage()] to get a [data.frame] with advised dosages of a certain bug-drug combination, which is based on the [dosage] data set.
|
||||
#'
|
||||
#' To improve the interpretation of the antibiogram before EUCAST rules are applied, some non-EUCAST rules can applied at default, see *Details*.
|
||||
#' @param x data with antibiotic columns, such as `amox`, `AMX` and `AMC`
|
||||
#' @param x a data set with antibiotic columns, such as `amox`, `AMX` and `AMC`
|
||||
#' @param info a [logical] to indicate whether progress should be printed to the console, defaults to only print while in interactive sessions
|
||||
#' @param rules a [character] vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"custom"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`. If using `"custom"`, be sure to fill in argument `custom_rules` too. Custom rules can be created with [custom_eucast_rules()].
|
||||
#' @param 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.
|
||||
@@ -117,19 +121,23 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' a <- data.frame(mo = c("Staphylococcus aureus",
|
||||
#' "Enterococcus faecalis",
|
||||
#' "Escherichia coli",
|
||||
#' "Klebsiella pneumoniae",
|
||||
#' "Pseudomonas aeruginosa"),
|
||||
#' VAN = "-", # Vancomycin
|
||||
#' AMX = "-", # Amoxicillin
|
||||
#' COL = "-", # Colistin
|
||||
#' CAZ = "-", # Ceftazidime
|
||||
#' CXM = "-", # Cefuroxime
|
||||
#' PEN = "S", # Benzylpenicillin
|
||||
#' FOX = "S", # Cefoxitin
|
||||
#' stringsAsFactors = FALSE)
|
||||
#' a <- data.frame(
|
||||
#' mo = c(
|
||||
#' "Staphylococcus aureus",
|
||||
#' "Enterococcus faecalis",
|
||||
#' "Escherichia coli",
|
||||
#' "Klebsiella pneumoniae",
|
||||
#' "Pseudomonas aeruginosa"
|
||||
#' ),
|
||||
#' VAN = "-", # Vancomycin
|
||||
#' AMX = "-", # Amoxicillin
|
||||
#' COL = "-", # Colistin
|
||||
#' CAZ = "-", # Ceftazidime
|
||||
#' CXM = "-", # Cefuroxime
|
||||
#' PEN = "S", # Benzylpenicillin
|
||||
#' FOX = "S", # Cefoxitin
|
||||
#' stringsAsFactors = FALSE
|
||||
#' )
|
||||
#'
|
||||
#' head(a)
|
||||
#'
|
||||
@@ -175,7 +183,8 @@ eucast_rules <- function(x,
|
||||
|
||||
if ("custom" %in% rules & is.null(custom_rules)) {
|
||||
warning_("in `eucast_rules()`: no custom rules were set with the `custom_rules` argument",
|
||||
immediate = TRUE)
|
||||
immediate = TRUE
|
||||
)
|
||||
rules <- rules[rules != "custom"]
|
||||
if (length(rules) == 0) {
|
||||
if (info == TRUE) {
|
||||
@@ -201,9 +210,11 @@ eucast_rules <- function(x,
|
||||
}
|
||||
|
||||
if (interactive() & verbose == TRUE & info == TRUE) {
|
||||
txt <- paste0("WARNING: In Verbose mode, the eucast_rules() 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.",
|
||||
"\n\nThis may overwrite your existing data if you use e.g.:",
|
||||
"\ndata <- eucast_rules(data, verbose = TRUE)\n\nDo you want to continue?")
|
||||
txt <- paste0(
|
||||
"WARNING: In Verbose mode, the eucast_rules() 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.",
|
||||
"\n\nThis may overwrite your existing data if you use e.g.:",
|
||||
"\ndata <- eucast_rules(data, verbose = TRUE)\n\nDo you want to continue?"
|
||||
)
|
||||
showQuestion <- import_fn("showQuestion", "rstudioapi", error_on_fail = FALSE)
|
||||
if (!is.null(showQuestion)) {
|
||||
q_continue <- showQuestion("Using verbose = TRUE with eucast_rules()", txt)
|
||||
@@ -277,28 +288,32 @@ eucast_rules <- function(x,
|
||||
}
|
||||
}
|
||||
|
||||
cols_ab <- get_column_abx(x = x,
|
||||
soft_dependencies = c("AMC",
|
||||
"AMP",
|
||||
"AMX",
|
||||
"CIP",
|
||||
"ERY",
|
||||
"FOX1",
|
||||
"GEN",
|
||||
"MFX",
|
||||
"NAL",
|
||||
"NOR",
|
||||
"PEN",
|
||||
"PIP",
|
||||
"TCY",
|
||||
"TIC",
|
||||
"TOB"),
|
||||
hard_dependencies = NULL,
|
||||
verbose = verbose,
|
||||
info = info,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
fn = "eucast_rules",
|
||||
...)
|
||||
cols_ab <- get_column_abx(
|
||||
x = x,
|
||||
soft_dependencies = c(
|
||||
"AMC",
|
||||
"AMP",
|
||||
"AMX",
|
||||
"CIP",
|
||||
"ERY",
|
||||
"FOX1",
|
||||
"GEN",
|
||||
"MFX",
|
||||
"NAL",
|
||||
"NOR",
|
||||
"PEN",
|
||||
"PIP",
|
||||
"TCY",
|
||||
"TIC",
|
||||
"TOB"
|
||||
),
|
||||
hard_dependencies = NULL,
|
||||
verbose = verbose,
|
||||
info = info,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
fn = "eucast_rules",
|
||||
...
|
||||
)
|
||||
|
||||
if (!"AMP" %in% names(cols_ab) & "AMX" %in% names(cols_ab)) {
|
||||
# ampicillin column is missing, but amoxicillin is available
|
||||
@@ -348,13 +363,17 @@ eucast_rules <- function(x,
|
||||
} else {
|
||||
if (length(ab_names) == 2) {
|
||||
# like PEN,FOX S,R
|
||||
paste0(ab_names[1], " is '", ab_results[1], "' and ",
|
||||
ab_names[2], " is '", ab_results[2], "'")
|
||||
paste0(
|
||||
ab_names[1], " is '", ab_results[1], "' and ",
|
||||
ab_names[2], " is '", ab_results[2], "'"
|
||||
)
|
||||
} else {
|
||||
# like PEN,FOX,GEN S,R,R (although dependency on > 2 ABx does not exist at the moment)
|
||||
paste0(ab_names[1], " is '", ab_results[1], "' and ",
|
||||
ab_names[2], " is '", ab_results[2], "' and ",
|
||||
ab_names[3], " is '", ab_results[3], "'")
|
||||
paste0(
|
||||
ab_names[1], " is '", ab_results[1], "' and ",
|
||||
ab_names[2], " is '", ab_results[2], "' and ",
|
||||
ab_names[3], " is '", ab_results[3], "'"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,29 +386,34 @@ eucast_rules <- function(x,
|
||||
|
||||
# Preparing the data ------------------------------------------------------
|
||||
|
||||
verbose_info <- data.frame(rowid = character(0),
|
||||
col = character(0),
|
||||
mo_fullname = character(0),
|
||||
old = as.rsi(character(0)),
|
||||
new = as.rsi(character(0)),
|
||||
rule = character(0),
|
||||
rule_group = character(0),
|
||||
rule_name = character(0),
|
||||
rule_source = character(0),
|
||||
stringsAsFactors = FALSE)
|
||||
verbose_info <- data.frame(
|
||||
rowid = character(0),
|
||||
col = character(0),
|
||||
mo_fullname = character(0),
|
||||
old = as.rsi(character(0)),
|
||||
new = as.rsi(character(0)),
|
||||
rule = character(0),
|
||||
rule_group = character(0),
|
||||
rule_name = character(0),
|
||||
rule_source = character(0),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
|
||||
old_cols <- colnames(x)
|
||||
old_attributes <- attributes(x)
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE) # no tibbles, data.tables, etc.
|
||||
rownames(x) <- NULL # will later be restored with old_attributes
|
||||
# create unique row IDs - combination of the MO and all ABx columns (so they will only run once per unique combination)
|
||||
x$`.rowid` <- vapply(FUN.VALUE = character(1),
|
||||
as.list(as.data.frame(t(x[, c(col_mo, cols_ab), drop = FALSE]),
|
||||
stringsAsFactors = FALSE)),
|
||||
function(x) {
|
||||
x[is.na(x)] <- "."
|
||||
paste0(x, collapse = "")
|
||||
})
|
||||
x$`.rowid` <- vapply(
|
||||
FUN.VALUE = character(1),
|
||||
as.list(as.data.frame(t(x[, c(col_mo, cols_ab), drop = FALSE]),
|
||||
stringsAsFactors = FALSE
|
||||
)),
|
||||
function(x) {
|
||||
x[is.na(x)] <- "."
|
||||
paste0(x, collapse = "")
|
||||
}
|
||||
)
|
||||
|
||||
# save original table, with the new .rowid column
|
||||
x.bak <- x
|
||||
@@ -412,11 +436,11 @@ eucast_rules <- function(x,
|
||||
}
|
||||
|
||||
if (any(x$genus == "Staphylococcus", na.rm = TRUE)) {
|
||||
all_staph <- MO_lookup[which(MO_lookup$genus == "Staphylococcus"), ]
|
||||
all_staph <- MO_lookup[which(MO_lookup$genus == "Staphylococcus"), , drop = FALSE]
|
||||
all_staph$CNS_CPS <- suppressWarnings(mo_name(all_staph$mo, Becker = "all", language = NULL))
|
||||
}
|
||||
if (any(x$genus == "Streptococcus", na.rm = TRUE)) {
|
||||
all_strep <- MO_lookup[which(MO_lookup$genus == "Streptococcus"), ]
|
||||
all_strep <- MO_lookup[which(MO_lookup$genus == "Streptococcus"), , drop = FALSE]
|
||||
all_strep$Lancefield <- suppressWarnings(mo_name(all_strep$mo, Lancefield = TRUE, language = NULL))
|
||||
}
|
||||
|
||||
@@ -428,11 +452,16 @@ eucast_rules <- function(x,
|
||||
if (info == TRUE) {
|
||||
cat("\n")
|
||||
cat(word_wrap(
|
||||
font_bold(paste0("Rules by this AMR package (",
|
||||
font_red(paste0("v", utils::packageDescription("AMR")$Version, ", ",
|
||||
format(as.Date(utils::packageDescription("AMR")$Date), format = "%Y"))), "), see ?eucast_rules\n"))))
|
||||
font_bold(paste0(
|
||||
"Rules by this AMR package (",
|
||||
font_red(paste0(
|
||||
"v", utils::packageDescription("AMR")$Version, ", ",
|
||||
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"), drop = FALSE]
|
||||
colnames(ab_enzyme) <- c("enzyme_ab", "enzyme_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]
|
||||
@@ -446,7 +475,7 @@ eucast_rules <- function(x,
|
||||
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), ]
|
||||
ab_enzyme <- ab_enzyme[order(ab_enzyme$enzyme_name), , drop = FALSE]
|
||||
|
||||
for (i in seq_len(nrow(ab_enzyme))) {
|
||||
# check if both base and base + enzyme inhibitor are part of the data set
|
||||
@@ -455,24 +484,31 @@ eucast_rules <- function(x,
|
||||
col_enzyme <- unname(cols_ab[ab_enzyme$enzyme_ab[i]])
|
||||
|
||||
# Set base to R where base + enzyme inhibitor is R ----
|
||||
rule_current <- paste0(ab_enzyme$base_name[i], " ('", font_bold(col_base), "') = R if ",
|
||||
tolower(ab_enzyme$enzyme_name[i]), " ('", font_bold(col_enzyme), "') = R")
|
||||
rule_current <- paste0(
|
||||
ab_enzyme$base_name[i], " ('", font_bold(col_base), "') = R if ",
|
||||
tolower(ab_enzyme$enzyme_name[i]), " ('", font_bold(col_enzyme), "') = R"
|
||||
)
|
||||
if (info == TRUE) {
|
||||
cat(word_wrap(rule_current,
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6))
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6
|
||||
))
|
||||
}
|
||||
run_changes <- edit_rsi(x = x,
|
||||
to = "R",
|
||||
rule = c(rule_current, "Other rules", "",
|
||||
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)),
|
||||
rows = which(as.rsi_no_warning(x[, col_enzyme, drop = TRUE]) == "R"),
|
||||
cols = col_base,
|
||||
last_verbose_info = verbose_info,
|
||||
original_data = x.bak,
|
||||
warned = warned,
|
||||
info = info,
|
||||
verbose = verbose)
|
||||
run_changes <- edit_rsi(
|
||||
x = x,
|
||||
to = "R",
|
||||
rule = c(
|
||||
rule_current, "Other rules", "",
|
||||
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)
|
||||
),
|
||||
rows = which(as.rsi_no_warning(x[, col_enzyme, drop = TRUE]) == "R"),
|
||||
cols = col_base,
|
||||
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
|
||||
@@ -488,25 +524,32 @@ eucast_rules <- function(x,
|
||||
}
|
||||
|
||||
# Set base + enzyme inhibitor to S where base is S ----
|
||||
rule_current <- paste0(ab_enzyme$enzyme_name[i], " ('", font_bold(col_enzyme), "') = S if ",
|
||||
tolower(ab_enzyme$base_name[i]), " ('", font_bold(col_base), "') = S")
|
||||
rule_current <- paste0(
|
||||
ab_enzyme$enzyme_name[i], " ('", font_bold(col_enzyme), "') = S if ",
|
||||
tolower(ab_enzyme$base_name[i]), " ('", font_bold(col_base), "') = S"
|
||||
)
|
||||
|
||||
if (info == TRUE) {
|
||||
cat(word_wrap(rule_current,
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6))
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6
|
||||
))
|
||||
}
|
||||
run_changes <- edit_rsi(x = x,
|
||||
to = "S",
|
||||
rule = c(rule_current, "Other rules", "",
|
||||
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)),
|
||||
rows = which(as.rsi_no_warning(x[, col_base, drop = TRUE]) == "S"),
|
||||
cols = col_enzyme,
|
||||
last_verbose_info = verbose_info,
|
||||
original_data = x.bak,
|
||||
warned = warned,
|
||||
info = info,
|
||||
verbose = verbose)
|
||||
run_changes <- edit_rsi(
|
||||
x = x,
|
||||
to = "S",
|
||||
rule = c(
|
||||
rule_current, "Other rules", "",
|
||||
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)
|
||||
),
|
||||
rows = which(as.rsi_no_warning(x[, col_base, drop = TRUE]) == "S"),
|
||||
cols = col_enzyme,
|
||||
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
|
||||
@@ -522,7 +565,6 @@ eucast_rules <- function(x,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (info == TRUE) {
|
||||
cat("\n")
|
||||
@@ -543,27 +585,33 @@ eucast_rules <- function(x,
|
||||
# this allows: eucast_rules(x, eucast_rules_df = AMR:::EUCAST_RULES_DF %>% filter(is.na(have_these_values)))
|
||||
eucast_rules_df <- list(...)$eucast_rules_df
|
||||
} else {
|
||||
# otherwise internal data file, created in data-raw/pre-commit-hook.R
|
||||
# otherwise internal data file, created in data-raw/_pre_commit_hook.R
|
||||
eucast_rules_df <- EUCAST_RULES_DF
|
||||
}
|
||||
|
||||
# filter on user-set guideline versions ----
|
||||
if (any(c("all", "breakpoints") %in% rules)) {
|
||||
eucast_rules_df <- subset(eucast_rules_df,
|
||||
reference.rule_group %unlike% "breakpoint" |
|
||||
(reference.rule_group %like% "breakpoint" & reference.version == version_breakpoints))
|
||||
eucast_rules_df <- subset(
|
||||
eucast_rules_df,
|
||||
reference.rule_group %unlike% "breakpoint" |
|
||||
(reference.rule_group %like% "breakpoint" & reference.version == version_breakpoints)
|
||||
)
|
||||
}
|
||||
if (any(c("all", "expert") %in% rules)) {
|
||||
eucast_rules_df <- subset(eucast_rules_df,
|
||||
reference.rule_group %unlike% "expert" |
|
||||
(reference.rule_group %like% "expert" & reference.version == version_expertrules))
|
||||
eucast_rules_df <- subset(
|
||||
eucast_rules_df,
|
||||
reference.rule_group %unlike% "expert" |
|
||||
(reference.rule_group %like% "expert" & reference.version == version_expertrules)
|
||||
)
|
||||
}
|
||||
# filter out AmpC de-repressed cephalosporin-resistant mutants ----
|
||||
# no need to filter on version number here - the rules contain these version number, so are inherently filtered
|
||||
# cefotaxime, ceftriaxone, ceftazidime
|
||||
if (is.null(ampc_cephalosporin_resistance) || isFALSE(ampc_cephalosporin_resistance)) {
|
||||
eucast_rules_df <- subset(eucast_rules_df,
|
||||
reference.rule %unlike% "ampc")
|
||||
eucast_rules_df <- subset(
|
||||
eucast_rules_df,
|
||||
reference.rule %unlike% "ampc"
|
||||
)
|
||||
} else {
|
||||
if (isTRUE(ampc_cephalosporin_resistance)) {
|
||||
ampc_cephalosporin_resistance <- "R"
|
||||
@@ -573,7 +621,6 @@ eucast_rules <- function(x,
|
||||
|
||||
# Go over all rules and apply them ----
|
||||
for (i in seq_len(nrow(eucast_rules_df))) {
|
||||
|
||||
rule_previous <- eucast_rules_df[max(1, i - 1), "reference.rule", drop = TRUE]
|
||||
rule_current <- eucast_rules_df[i, "reference.rule", drop = TRUE]
|
||||
rule_next <- eucast_rules_df[min(nrow(eucast_rules_df), i + 1), "reference.rule", drop = TRUE]
|
||||
@@ -593,10 +640,14 @@ eucast_rules <- function(x,
|
||||
if (is.na(eucast_rules_df[i, "and_these_antibiotics", drop = TRUE])) {
|
||||
rule_text <- paste0("always report as '", eucast_rules_df[i, "to_value", drop = TRUE], "': ", get_antibiotic_names(eucast_rules_df[i, "then_change_these_antibiotics", drop = TRUE]))
|
||||
} else {
|
||||
rule_text <- paste0("report as '", eucast_rules_df[i, "to_value", drop = TRUE], "' when ",
|
||||
format_antibiotic_names(ab_names = get_antibiotic_names(eucast_rules_df[i, "and_these_antibiotics", drop = TRUE]),
|
||||
ab_results = eucast_rules_df[i, "have_these_values", drop = TRUE]), ": ",
|
||||
get_antibiotic_names(eucast_rules_df[i, "then_change_these_antibiotics", drop = TRUE]))
|
||||
rule_text <- paste0(
|
||||
"report as '", eucast_rules_df[i, "to_value", drop = TRUE], "' when ",
|
||||
format_antibiotic_names(
|
||||
ab_names = get_antibiotic_names(eucast_rules_df[i, "and_these_antibiotics", drop = TRUE]),
|
||||
ab_results = eucast_rules_df[i, "have_these_values", drop = TRUE]
|
||||
), ": ",
|
||||
get_antibiotic_names(eucast_rules_df[i, "then_change_these_antibiotics", drop = TRUE])
|
||||
)
|
||||
}
|
||||
}
|
||||
if (i == 1) {
|
||||
@@ -611,9 +662,12 @@ eucast_rules <- function(x,
|
||||
# Print EUCAST intro ------------------------------------------------------
|
||||
if (rule_group_current %unlike% "other" & eucast_notification_shown == FALSE) {
|
||||
cat(
|
||||
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",
|
||||
font_blue("https://eucast.org/"), "\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",
|
||||
font_blue("https://eucast.org/"), "\n"
|
||||
)
|
||||
)
|
||||
eucast_notification_shown <- TRUE
|
||||
}
|
||||
|
||||
@@ -623,25 +677,36 @@ eucast_rules <- function(x,
|
||||
cat(font_bold(
|
||||
ifelse(
|
||||
rule_group_current %like% "breakpoint",
|
||||
paste0("\n",
|
||||
word_wrap(
|
||||
breakpoints_info$title, " (",
|
||||
font_red(paste0(breakpoints_info$version_txt, ", ", breakpoints_info$year)), ")\n")),
|
||||
paste0(
|
||||
"\n",
|
||||
word_wrap(
|
||||
breakpoints_info$title, " (",
|
||||
font_red(paste0(breakpoints_info$version_txt, ", ", breakpoints_info$year)), ")\n"
|
||||
)
|
||||
),
|
||||
ifelse(
|
||||
rule_group_current %like% "expert",
|
||||
paste0("\n",
|
||||
word_wrap(
|
||||
expertrules_info$title, " (",
|
||||
font_red(paste0(expertrules_info$version_txt, ", ", expertrules_info$year)), ")\n")),
|
||||
""))), "\n")
|
||||
paste0(
|
||||
"\n",
|
||||
word_wrap(
|
||||
expertrules_info$title, " (",
|
||||
font_red(paste0(expertrules_info$version_txt, ", ", expertrules_info$year)), ")\n"
|
||||
)
|
||||
),
|
||||
""
|
||||
)
|
||||
)
|
||||
), "\n")
|
||||
}
|
||||
# Print rule -------------------------------------------------------------
|
||||
if (rule_current != rule_previous) {
|
||||
# is new rule within group, print its name
|
||||
cat(italicise_taxonomy(word_wrap(rule_current,
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6),
|
||||
type = "ansi"))
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6
|
||||
),
|
||||
type = "ansi"
|
||||
))
|
||||
warned <- FALSE
|
||||
}
|
||||
}
|
||||
@@ -654,27 +719,39 @@ eucast_rules <- function(x,
|
||||
# be sure to comprise all coagulase-negative/-positive staphylococci when they are mentioned
|
||||
if (mo_value %like% "coagulase" && any(x$genus == "Staphylococcus", na.rm = TRUE)) {
|
||||
if (mo_value %like% "negative") {
|
||||
eucast_rules_df[i, "this_value"] <- paste0("^(", paste0(all_staph[which(all_staph$CNS_CPS %like% "negative"),
|
||||
"fullname",
|
||||
drop = TRUE],
|
||||
collapse = "|"),
|
||||
")$")
|
||||
eucast_rules_df[i, "this_value"] <- paste0(
|
||||
"^(", paste0(all_staph[which(all_staph$CNS_CPS %like% "negative"),
|
||||
"fullname",
|
||||
drop = TRUE
|
||||
],
|
||||
collapse = "|"
|
||||
),
|
||||
")$"
|
||||
)
|
||||
} else {
|
||||
eucast_rules_df[i, "this_value"] <- paste0("^(", paste0(all_staph[which(all_staph$CNS_CPS %like% "positive"),
|
||||
"fullname",
|
||||
drop = TRUE],
|
||||
collapse = "|"),
|
||||
")$")
|
||||
eucast_rules_df[i, "this_value"] <- paste0(
|
||||
"^(", paste0(all_staph[which(all_staph$CNS_CPS %like% "positive"),
|
||||
"fullname",
|
||||
drop = TRUE
|
||||
],
|
||||
collapse = "|"
|
||||
),
|
||||
")$"
|
||||
)
|
||||
}
|
||||
like_is_one_of <- "like"
|
||||
}
|
||||
# be sure to comprise all beta-haemolytic Streptococci (Lancefield groups A, B, C and G) when they are mentioned
|
||||
if (mo_value %like% "group [ABCG]" && any(x$genus == "Streptococcus", na.rm = TRUE)) {
|
||||
eucast_rules_df[i, "this_value"] <- paste0("^(", paste0(all_strep[which(all_strep$Lancefield %like% "group [ABCG]"),
|
||||
"fullname",
|
||||
drop = TRUE],
|
||||
collapse = "|"),
|
||||
")$")
|
||||
eucast_rules_df[i, "this_value"] <- paste0(
|
||||
"^(", paste0(all_strep[which(all_strep$Lancefield %like% "group [ABCG]"),
|
||||
"fullname",
|
||||
drop = TRUE
|
||||
],
|
||||
collapse = "|"
|
||||
),
|
||||
")$"
|
||||
)
|
||||
like_is_one_of <- "like"
|
||||
}
|
||||
|
||||
@@ -683,10 +760,13 @@ eucast_rules <- function(x,
|
||||
mo_value <- paste0("^", mo_value, "$")
|
||||
} else if (like_is_one_of == "one_of") {
|
||||
# so 'Clostridium, Actinomyces, ...' will turn into '^(Clostridium|Actinomyces|...)$'
|
||||
mo_value <- paste0("^(",
|
||||
paste(trimws(unlist(strsplit(mo_value, ",", fixed = TRUE))),
|
||||
collapse = "|"),
|
||||
")$")
|
||||
mo_value <- paste0(
|
||||
"^(",
|
||||
paste(trimws(unlist(strsplit(mo_value, ",", fixed = TRUE))),
|
||||
collapse = "|"
|
||||
),
|
||||
")$"
|
||||
)
|
||||
} else if (like_is_one_of != "like") {
|
||||
stop("invalid value for column 'like.is.one_of'", call. = FALSE)
|
||||
}
|
||||
@@ -698,7 +778,8 @@ eucast_rules <- function(x,
|
||||
|
||||
if (is.na(source_antibiotics)) {
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value),
|
||||
error = function(e) integer(0))
|
||||
error = function(e) integer(0)
|
||||
)
|
||||
} else {
|
||||
source_antibiotics <- get_ab_from_namespace(source_antibiotics, cols_ab)
|
||||
if (length(source_value) == 1 & length(source_antibiotics) > 1) {
|
||||
@@ -707,21 +788,23 @@ eucast_rules <- function(x,
|
||||
if (length(source_antibiotics) == 0) {
|
||||
rows <- integer(0)
|
||||
} else if (length(source_antibiotics) == 1) {
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
& as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]),
|
||||
error = function(e) integer(0))
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value &
|
||||
as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]),
|
||||
error = function(e) integer(0)
|
||||
)
|
||||
} else if (length(source_antibiotics) == 2) {
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
& as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]
|
||||
& as.rsi_no_warning(x[, source_antibiotics[2L]]) == source_value[2L]),
|
||||
error = function(e) integer(0))
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value &
|
||||
as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L] &
|
||||
as.rsi_no_warning(x[, source_antibiotics[2L]]) == source_value[2L]),
|
||||
error = function(e) integer(0)
|
||||
)
|
||||
# nolint start
|
||||
# } else if (length(source_antibiotics) == 3) {
|
||||
# rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
# & as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]
|
||||
# & as.rsi_no_warning(x[, source_antibiotics[2L]]) == source_value[2L]
|
||||
# & as.rsi_no_warning(x[, source_antibiotics[3L]]) == source_value[3L]),
|
||||
# error = function(e) integer(0))
|
||||
# } else if (length(source_antibiotics) == 3) {
|
||||
# rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
# & as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]
|
||||
# & as.rsi_no_warning(x[, source_antibiotics[2L]]) == source_value[2L]
|
||||
# & as.rsi_no_warning(x[, source_antibiotics[3L]]) == source_value[3L]),
|
||||
# error = function(e) integer(0))
|
||||
# nolint end
|
||||
} else {
|
||||
stop_("only 2 antibiotics supported for source_antibiotics")
|
||||
@@ -732,19 +815,24 @@ eucast_rules <- function(x,
|
||||
|
||||
# Apply rule on data ------------------------------------------------------
|
||||
# this will return the unique number of changes
|
||||
run_changes <- edit_rsi(x = x,
|
||||
to = target_value,
|
||||
rule = c(rule_text, rule_group_current, rule_current,
|
||||
ifelse(rule_group_current %like% "breakpoint",
|
||||
paste0(breakpoints_info$title, " ", breakpoints_info$version_txt, ", ", breakpoints_info$year),
|
||||
paste0(expertrules_info$title, " ", expertrules_info$version_txt, ", ", expertrules_info$year))),
|
||||
rows = rows,
|
||||
cols = cols,
|
||||
last_verbose_info = verbose_info,
|
||||
original_data = x.bak,
|
||||
warned = warned,
|
||||
info = info,
|
||||
verbose = verbose)
|
||||
run_changes <- edit_rsi(
|
||||
x = x,
|
||||
to = target_value,
|
||||
rule = c(
|
||||
rule_text, rule_group_current, rule_current,
|
||||
ifelse(rule_group_current %like% "breakpoint",
|
||||
paste0(breakpoints_info$title, " ", breakpoints_info$version_txt, ", ", breakpoints_info$year),
|
||||
paste0(expertrules_info$title, " ", expertrules_info$version_txt, ", ", expertrules_info$year)
|
||||
)
|
||||
),
|
||||
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
|
||||
@@ -770,35 +858,47 @@ eucast_rules <- function(x,
|
||||
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 <- 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))
|
||||
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"))
|
||||
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)
|
||||
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
|
||||
@@ -821,7 +921,8 @@ eucast_rules <- function(x,
|
||||
pm_mutate(row = pm_row_number()) %pm>%
|
||||
pm_select(`.rowid`, row) %pm>%
|
||||
pm_right_join(verbose_info,
|
||||
by = c(".rowid" = "rowid")) %pm>%
|
||||
by = c(".rowid" = "rowid")
|
||||
) %pm>%
|
||||
pm_select(-`.rowid`) %pm>%
|
||||
pm_select(row, pm_everything()) %pm>%
|
||||
pm_filter(!is.na(new) | is.na(new) & !is.na(old)) %pm>%
|
||||
@@ -830,7 +931,6 @@ eucast_rules <- function(x,
|
||||
}
|
||||
|
||||
if (info == TRUE) {
|
||||
|
||||
if (verbose == TRUE) {
|
||||
wouldve <- "would have "
|
||||
} else {
|
||||
@@ -838,12 +938,16 @@ eucast_rules <- function(x,
|
||||
}
|
||||
|
||||
cat(paste0("\n", font_grey(strrep("-", 0.95 * options()$width)), "\n"))
|
||||
cat(word_wrap(paste0("The rules ", paste0(wouldve, "affected "),
|
||||
font_bold(formatnr(pm_n_distinct(verbose_info$row)),
|
||||
"out of", formatnr(nrow(x.bak)),
|
||||
"rows"),
|
||||
", making a total of ",
|
||||
font_bold(formatnr(nrow(verbose_info)), "edits\n"))))
|
||||
cat(word_wrap(paste0(
|
||||
"The rules ", paste0(wouldve, "affected "),
|
||||
font_bold(
|
||||
formatnr(pm_n_distinct(verbose_info$row)),
|
||||
"out of", formatnr(nrow(x.bak)),
|
||||
"rows"
|
||||
),
|
||||
", making a total of ",
|
||||
font_bold(formatnr(nrow(verbose_info)), "edits\n")
|
||||
)))
|
||||
|
||||
total_n_added <- verbose_info %pm>% pm_filter(is.na(old)) %pm>% nrow()
|
||||
total_n_changed <- verbose_info %pm>% pm_filter(!is.na(old)) %pm>% nrow()
|
||||
@@ -854,18 +958,24 @@ eucast_rules <- function(x,
|
||||
} else {
|
||||
colour <- font_green # is function
|
||||
}
|
||||
cat(colour(paste0("=> ", wouldve, "added ",
|
||||
font_bold(formatnr(verbose_info %pm>%
|
||||
pm_filter(is.na(old)) %pm>%
|
||||
nrow()), "test results"),
|
||||
"\n")))
|
||||
cat(colour(paste0(
|
||||
"=> ", wouldve, "added ",
|
||||
font_bold(formatnr(verbose_info %pm>%
|
||||
pm_filter(is.na(old)) %pm>%
|
||||
nrow()), "test results"),
|
||||
"\n"
|
||||
)))
|
||||
if (total_n_added > 0) {
|
||||
added_summary <- verbose_info %pm>%
|
||||
pm_filter(is.na(old)) %pm>%
|
||||
pm_count(new, name = "n")
|
||||
cat(paste(" -",
|
||||
paste0(formatnr(added_summary$n), " test result", ifelse(added_summary$n > 1, "s", ""),
|
||||
" added as ", paste0('"', added_summary$new, '"')), collapse = "\n"))
|
||||
paste0(
|
||||
formatnr(added_summary$n), " test result", ifelse(added_summary$n > 1, "s", ""),
|
||||
" added as ", paste0('"', added_summary$new, '"')
|
||||
),
|
||||
collapse = "\n"
|
||||
))
|
||||
}
|
||||
|
||||
# print changed values
|
||||
@@ -877,19 +987,25 @@ eucast_rules <- function(x,
|
||||
if (total_n_added + total_n_changed > 0) {
|
||||
cat("\n")
|
||||
}
|
||||
cat(colour(paste0("=> ", wouldve, "changed ",
|
||||
font_bold(formatnr(verbose_info %pm>%
|
||||
pm_filter(!is.na(old)) %pm>%
|
||||
nrow()), "test results"),
|
||||
"\n")))
|
||||
cat(colour(paste0(
|
||||
"=> ", wouldve, "changed ",
|
||||
font_bold(formatnr(verbose_info %pm>%
|
||||
pm_filter(!is.na(old)) %pm>%
|
||||
nrow()), "test results"),
|
||||
"\n"
|
||||
)))
|
||||
if (total_n_changed > 0) {
|
||||
changed_summary <- verbose_info %pm>%
|
||||
pm_filter(!is.na(old)) %pm>%
|
||||
pm_mutate(new = ifelse(is.na(new), "NA", new)) %pm>%
|
||||
pm_count(old, new, name = "n")
|
||||
cat(paste(" -",
|
||||
paste0(formatnr(changed_summary$n), " test result", ifelse(changed_summary$n > 1, "s", ""), " changed from ",
|
||||
paste0('"', changed_summary$old, '"'), " to ", paste0('"', changed_summary$new, '"')), collapse = "\n"))
|
||||
paste0(
|
||||
formatnr(changed_summary$n), " test result", ifelse(changed_summary$n > 1, "s", ""), " changed from ",
|
||||
paste0('"', changed_summary$old, '"'), " to ", paste0('"', changed_summary$new, '"')
|
||||
),
|
||||
collapse = "\n"
|
||||
))
|
||||
cat("\n")
|
||||
}
|
||||
|
||||
@@ -907,17 +1023,20 @@ eucast_rules <- function(x,
|
||||
# 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_("in `eucast_rules()`: not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
|
||||
" - ", x_deparsed, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
||||
warn_lacking_rsi_class,
|
||||
paste0(warn_lacking_rsi_class[1], ":", warn_lacking_rsi_class[length(warn_lacking_rsi_class)])), ")\n",
|
||||
" - ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" - ", x_deparsed, " %>% mutate(across(where(is.rsi.eligible), as.rsi))")
|
||||
warning_(
|
||||
"in `eucast_rules()`: not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
|
||||
" - ", x_deparsed, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
||||
warn_lacking_rsi_class,
|
||||
paste0(warn_lacking_rsi_class[1], ":", warn_lacking_rsi_class[length(warn_lacking_rsi_class)])
|
||||
), ")\n",
|
||||
" - ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" - ", x_deparsed, " %>% mutate(across(where(is.rsi.eligible), as.rsi))"
|
||||
)
|
||||
}
|
||||
|
||||
# Return data set ---------------------------------------------------------
|
||||
if (verbose == TRUE) {
|
||||
verbose_info
|
||||
as_original_data_class(verbose_info, old_attributes$class)
|
||||
} else {
|
||||
# x was analysed with only unique rows, so join everything together again
|
||||
x <- x[, c(cols_ab, ".rowid"), drop = FALSE]
|
||||
@@ -925,7 +1044,7 @@ eucast_rules <- function(x,
|
||||
x.bak <- x.bak %pm>%
|
||||
pm_left_join(x, by = ".rowid")
|
||||
x.bak <- x.bak[, old_cols, drop = FALSE]
|
||||
# reset original attributes
|
||||
# reset original attributes, no need for as_original_data_class() here
|
||||
attributes(x.bak) <- old_attributes
|
||||
x.bak
|
||||
}
|
||||
@@ -945,11 +1064,13 @@ edit_rsi <- function(x,
|
||||
cols <- unique(cols[!is.na(cols) & !is.null(cols)])
|
||||
|
||||
# for Verbose Mode, keep track of all changes and return them
|
||||
track_changes <- list(added = 0,
|
||||
changed = 0,
|
||||
output = x,
|
||||
verbose_info = last_verbose_info,
|
||||
rsi_warn = character(0))
|
||||
track_changes <- list(
|
||||
added = 0,
|
||||
changed = 0,
|
||||
output = x,
|
||||
verbose_info = last_verbose_info,
|
||||
rsi_warn = character(0)
|
||||
)
|
||||
|
||||
txt_error <- function() {
|
||||
if (info == TRUE) cat("", font_red_bg(font_white(" ERROR ")), "\n\n")
|
||||
@@ -972,15 +1093,19 @@ edit_rsi <- function(x,
|
||||
warning = function(w) {
|
||||
if (w$message %like% "invalid factor level") {
|
||||
xyz <- vapply(FUN.VALUE = logical(1), cols, function(col) {
|
||||
new_edits[, col] <<- factor(x = as.character(pm_pull(new_edits, col)),
|
||||
levels = unique(c(to, levels(pm_pull(new_edits, col)))))
|
||||
new_edits[, col] <<- factor(
|
||||
x = as.character(pm_pull(new_edits, col)),
|
||||
levels = unique(c(to, levels(pm_pull(new_edits, col))))
|
||||
)
|
||||
TRUE
|
||||
})
|
||||
suppressWarnings(new_edits[rows, cols] <<- to)
|
||||
warning_("in `eucast_rules()`: 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.")
|
||||
warning_(
|
||||
"in `eucast_rules()`: 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."
|
||||
)
|
||||
txt_warning()
|
||||
warned <- FALSE
|
||||
} else {
|
||||
@@ -990,12 +1115,15 @@ edit_rsi <- function(x,
|
||||
},
|
||||
error = function(e) {
|
||||
txt_error()
|
||||
stop(paste0("In row(s) ", paste(rows[1:min(length(rows), 10)], collapse = ","),
|
||||
ifelse(length(rows) > 10, "...", ""),
|
||||
" while writing value '", to,
|
||||
"' to column(s) `", paste(cols, collapse = "`, `"),
|
||||
"`:\n", e$message),
|
||||
call. = FALSE)
|
||||
stop(paste0(
|
||||
"In row(s) ", paste(rows[1:min(length(rows), 10)], collapse = ","),
|
||||
ifelse(length(rows) > 10, "...", ""),
|
||||
" while writing value '", to,
|
||||
"' to column(s) `", paste(cols, collapse = "`, `"),
|
||||
"`:\n", e$message
|
||||
),
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1005,23 +1133,28 @@ edit_rsi <- function(x,
|
||||
as.integer(rownames(original_data[which(original_data$.rowid %in% rowids), , drop = FALSE]))
|
||||
}
|
||||
for (i in seq_len(length(cols))) {
|
||||
verbose_new <- data.frame(rowid = new_edits[rows, ".rowid", drop = TRUE],
|
||||
col = cols[i],
|
||||
mo_fullname = new_edits[rows, "fullname", drop = TRUE],
|
||||
old = x[rows, cols[i], drop = TRUE],
|
||||
new = to,
|
||||
rule = font_stripstyle(rule[1]),
|
||||
rule_group = font_stripstyle(rule[2]),
|
||||
rule_name = font_stripstyle(rule[3]),
|
||||
rule_source = font_stripstyle(rule[4]),
|
||||
stringsAsFactors = FALSE)
|
||||
colnames(verbose_new) <- c("rowid", "col", "mo_fullname", "old", "new",
|
||||
"rule", "rule_group", "rule_name", "rule_source")
|
||||
verbose_new <- data.frame(
|
||||
rowid = new_edits[rows, ".rowid", drop = TRUE],
|
||||
col = cols[i],
|
||||
mo_fullname = new_edits[rows, "fullname", drop = TRUE],
|
||||
old = x[rows, cols[i], drop = TRUE],
|
||||
new = to,
|
||||
rule = font_stripstyle(rule[1]),
|
||||
rule_group = font_stripstyle(rule[2]),
|
||||
rule_name = font_stripstyle(rule[3]),
|
||||
rule_source = font_stripstyle(rule[4]),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
colnames(verbose_new) <- c(
|
||||
"rowid", "col", "mo_fullname", "old", "new",
|
||||
"rule", "rule_group", "rule_name", "rule_source"
|
||||
)
|
||||
verbose_new <- verbose_new %pm>% pm_filter(old != new | is.na(old) | is.na(new) & !is.na(old))
|
||||
# save changes to data set 'verbose_info'
|
||||
track_changes$verbose_info <- rbind(track_changes$verbose_info,
|
||||
verbose_new,
|
||||
stringsAsFactors = FALSE)
|
||||
verbose_new,
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
# count adds and changes
|
||||
track_changes$added <- track_changes$added + verbose_new %pm>%
|
||||
pm_filter(is.na(old)) %pm>%
|
||||
@@ -1047,28 +1180,38 @@ eucast_dosage <- function(ab, administration = "iv", version_breakpoints = 11.0)
|
||||
meet_criteria(version_breakpoints, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_BREAKPOINTS)))
|
||||
|
||||
# show used version_breakpoints number once per session (pkg_env will reload every session)
|
||||
if (message_not_thrown_before("eucast_dosage", "v", gsub("[^0-9]", "", version_breakpoints), entire_session = TRUE)) {
|
||||
message_("Dosages for antimicrobial drugs, as meant for ",
|
||||
format_eucast_version_nr(version_breakpoints, markdown = FALSE), ". ",
|
||||
font_red("This note will be shown once per session."))
|
||||
if (message_not_thrown_before("eucast_dosage", "v", gsub("[^0-9]", "", version_breakpoints), entire_session = TRUE)) {
|
||||
message_(
|
||||
"Dosages for antimicrobial drugs, as meant for ",
|
||||
format_eucast_version_nr(version_breakpoints, markdown = FALSE), ". ",
|
||||
font_red("This note will be shown once per session.")
|
||||
)
|
||||
}
|
||||
|
||||
ab <- as.ab(ab)
|
||||
lst <- vector("list", length = length(ab))
|
||||
for (i in seq_len(length(ab))) {
|
||||
df <- AMR::dosage[which(AMR::dosage$ab == ab[i] & AMR::dosage$administration == administration), , drop = FALSE]
|
||||
lst[[i]] <- list(ab = "",
|
||||
name = "",
|
||||
standard_dosage = ifelse("standard_dosage" %in% df$type,
|
||||
df[which(df$type == "standard_dosage"), ]$original_txt,
|
||||
NA_character_),
|
||||
high_dosage = ifelse("high_dosage" %in% df$type,
|
||||
df[which(df$type == "high_dosage"), ]$original_txt,
|
||||
NA_character_))
|
||||
lst[[i]] <- list(
|
||||
ab = "",
|
||||
name = "",
|
||||
standard_dosage = ifelse("standard_dosage" %in% df$type,
|
||||
df[which(df$type == "standard_dosage"), "original_txt", drop = TRUE],
|
||||
NA_character_
|
||||
),
|
||||
high_dosage = ifelse("high_dosage" %in% df$type,
|
||||
df[which(df$type == "high_dosage"), "original_txt", drop = TRUE],
|
||||
NA_character_
|
||||
)
|
||||
)
|
||||
}
|
||||
out <- do.call("rbind", lapply(lst, as.data.frame, stringsAsFactors = FALSE))
|
||||
rownames(out) <- NULL
|
||||
out$ab <- ab
|
||||
out$name <- ab_name(ab, language = NULL)
|
||||
out
|
||||
if (pkg_is_available("tibble", also_load = FALSE)) {
|
||||
import_fn("as_tibble", "tibble")(out)
|
||||
} else {
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#' @param col_mo column name of the IDs of the microorganisms (see [as.mo()]), defaults to the first column of class [`mo`]. Values will be coerced using [as.mo()].
|
||||
#' @param col_testcode column name of the test codes. Use `col_testcode = NULL` to **not** exclude certain test codes (such as test codes for screening). In that case `testcodes_exclude` will be ignored.
|
||||
#' @param col_specimen column name of the specimen type or group
|
||||
#' @param col_icu column name of the logicals (`TRUE`/`FALSE`) whether a ward or department is an Intensive Care Unit (ICU)
|
||||
#' @param col_icu column name of the logicals (`TRUE`/`FALSE`) whether a ward or department is an Intensive Care Unit (ICU). This can also be a [logical] vector with the same length as rows in `x`.
|
||||
#' @param col_keyantimicrobials (only useful when `method = "phenotype-based"`) column name of the key antimicrobials to determine first isolates, see [key_antimicrobials()]. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' or 'antimicrobials' (case insensitive). Use `col_keyantimicrobials = FALSE` to prevent this. Can also be the output of [key_antimicrobials()].
|
||||
#' @param episode_days episode in days after which a genus/species combination will be determined as 'first isolate' again. The default of 365 days is based on the guideline by CLSI, see *Source*.
|
||||
#' @param testcodes_exclude a [character] vector with test codes that should be excluded (case-insensitive)
|
||||
@@ -119,7 +119,7 @@
|
||||
#' @rdname first_isolate
|
||||
#' @seealso [key_antimicrobials()]
|
||||
#' @export
|
||||
#' @return A [`logical`] vector
|
||||
#' @return A [logical] vector
|
||||
#' @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/>.
|
||||
@@ -138,36 +138,20 @@
|
||||
#' # filter on first isolates using dplyr:
|
||||
#' example_isolates %>%
|
||||
#' filter(first_isolate())
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # short-hand version:
|
||||
#' example_isolates %>%
|
||||
#' filter_first_isolate(info = FALSE)
|
||||
#' }
|
||||
#' if (require("dplyr")) {
|
||||
#'
|
||||
#' # flag the first isolates per group:
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' mutate(first = first_isolate()) %>%
|
||||
#' select(hospital_id, date, patient_id, mo, first)
|
||||
#'
|
||||
#' # now let's see if first isolates matter:
|
||||
#' A <- example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(count = n_rsi(GEN), # gentamicin availability
|
||||
#' resistance = resistance(GEN)) # gentamicin resistance
|
||||
#'
|
||||
#' B <- example_isolates %>%
|
||||
#' filter_first_isolate() %>% # the 1st isolate filter
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(count = n_rsi(GEN), # gentamicin availability
|
||||
#' resistance = resistance(GEN)) # gentamicin resistance
|
||||
#'
|
||||
#' # Have a look at A and B.
|
||||
#' A
|
||||
#' B
|
||||
#'
|
||||
#' # B is more reliable because every isolate is counted only once.
|
||||
#' # Gentamicin resistance in hospital D appears to be 4.2% higher than
|
||||
#' # when you (erroneously) would have used all isolates for analysis.
|
||||
#' # flag the first isolates per group:
|
||||
#' example_isolates %>%
|
||||
#' group_by(ward) %>%
|
||||
#' mutate(first = first_isolate()) %>%
|
||||
#' select(ward, date, patient, mo, first)
|
||||
#' }
|
||||
#' }
|
||||
first_isolate <- function(x = NULL,
|
||||
@@ -190,7 +174,6 @@ first_isolate <- function(x = NULL,
|
||||
include_unknown = FALSE,
|
||||
include_untested_rsi = TRUE,
|
||||
...) {
|
||||
|
||||
dots <- unlist(list(...))
|
||||
if (length(dots) != 0) {
|
||||
# backwards compatibility with old arguments
|
||||
@@ -217,7 +200,15 @@ first_isolate <- function(x = NULL,
|
||||
col_specimen <- NULL
|
||||
}
|
||||
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))
|
||||
if (is.logical(col_icu)) {
|
||||
meet_criteria(col_icu, allow_class = "logical", has_length = c(1, nrow(x)), allow_NULL = TRUE)
|
||||
if (length(col_icu) == 1) {
|
||||
col_icu <- rep(col_icu, nrow(x))
|
||||
}
|
||||
} else {
|
||||
meet_criteria(col_icu, allow_class = c("character", "logical"), has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
col_icu <- x[, col_icu, drop = TRUE]
|
||||
}
|
||||
# method
|
||||
method <- coerce_method(method)
|
||||
meet_criteria(method, allow_class = "character", has_length = 1, is_in = c("phenotype-based", "episode-based", "patient-based", "isolate-based"))
|
||||
@@ -250,23 +241,30 @@ first_isolate <- function(x = NULL,
|
||||
# remove data.table, grouping from tibbles, etc.
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
|
||||
any_col_contains_rsi <- any(vapply(FUN.VALUE = logical(1),
|
||||
X = x,
|
||||
# check only first 10,000 rows
|
||||
FUN = function(x) any(as.character(x[1:10000]) %in% c("R", "S", "I"), na.rm = TRUE),
|
||||
USE.NAMES = FALSE))
|
||||
any_col_contains_rsi <- any(vapply(
|
||||
FUN.VALUE = logical(1),
|
||||
X = x,
|
||||
# check only first 10,000 rows
|
||||
FUN = function(x) any(as.character(x[1:10000]) %in% c("R", "S", "I"), na.rm = TRUE),
|
||||
USE.NAMES = FALSE
|
||||
))
|
||||
if (method == "phenotype-based" & !any_col_contains_rsi) {
|
||||
method <- "episode-based"
|
||||
}
|
||||
if (info == TRUE & message_not_thrown_before("first_isolate", "method")) {
|
||||
message_(paste0("Determining first isolates ",
|
||||
ifelse(method %in% c("episode-based", "phenotype-based"),
|
||||
ifelse(is.infinite(episode_days),
|
||||
"without a specified episode length",
|
||||
paste("using an episode length of", episode_days, "days")),
|
||||
"")),
|
||||
as_note = FALSE,
|
||||
add_fn = font_black)
|
||||
message_(paste0(
|
||||
"Determining first isolates ",
|
||||
ifelse(method %in% c("episode-based", "phenotype-based"),
|
||||
ifelse(is.infinite(episode_days),
|
||||
"without a specified episode length",
|
||||
paste("using an episode length of", episode_days, "days")
|
||||
),
|
||||
""
|
||||
)
|
||||
),
|
||||
as_note = FALSE,
|
||||
add_fn = font_black
|
||||
)
|
||||
}
|
||||
|
||||
# try to find columns based on type
|
||||
@@ -335,7 +333,9 @@ first_isolate <- function(x = NULL,
|
||||
check_columns_existance <- function(column, tblname = x) {
|
||||
if (!is.null(column)) {
|
||||
stop_ifnot(column %in% colnames(tblname),
|
||||
"Column '", column, "' not found.", call = FALSE)
|
||||
"Column '", column, "' not found.",
|
||||
call = FALSE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +343,6 @@ first_isolate <- function(x = NULL,
|
||||
check_columns_existance(col_patient_id)
|
||||
check_columns_existance(col_mo)
|
||||
check_columns_existance(col_testcode)
|
||||
check_columns_existance(col_icu)
|
||||
check_columns_existance(col_keyantimicrobials)
|
||||
|
||||
# convert dates to Date
|
||||
@@ -364,8 +363,9 @@ first_isolate <- function(x = NULL,
|
||||
# remove testcodes
|
||||
if (!is.null(testcodes_exclude) & info == TRUE & message_not_thrown_before("first_isolate", "excludingtestcodes")) {
|
||||
message_("Excluding test codes: ", vector_and(testcodes_exclude, quotes = TRUE),
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
if (is.null(col_specimen)) {
|
||||
@@ -377,8 +377,9 @@ first_isolate <- function(x = NULL,
|
||||
check_columns_existance(col_specimen, x)
|
||||
if (info == TRUE & message_not_thrown_before("first_isolate", "excludingspecimen")) {
|
||||
message_("Excluding other than specimen group '", specimen_group, "'",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!is.null(col_keyantimicrobials)) {
|
||||
@@ -391,18 +392,22 @@ first_isolate <- function(x = NULL,
|
||||
|
||||
# arrange data to the right sorting
|
||||
if (is.null(specimen_group)) {
|
||||
x <- x[order(x$newvar_patient_id,
|
||||
x$newvar_genus_species,
|
||||
x$newvar_date), ]
|
||||
x <- x[order(
|
||||
x$newvar_patient_id,
|
||||
x$newvar_genus_species,
|
||||
x$newvar_date
|
||||
), ]
|
||||
rownames(x) <- NULL
|
||||
row.start <- 1
|
||||
row.end <- nrow(x)
|
||||
} else {
|
||||
# filtering on specimen and only analyse these rows to save time
|
||||
x <- x[order(pm_pull(x, col_specimen),
|
||||
x$newvar_patient_id,
|
||||
x$newvar_genus_species,
|
||||
x$newvar_date), ]
|
||||
x <- x[order(
|
||||
pm_pull(x, col_specimen),
|
||||
x$newvar_patient_id,
|
||||
x$newvar_genus_species,
|
||||
x$newvar_date
|
||||
), ]
|
||||
rownames(x) <- NULL
|
||||
suppressWarnings(
|
||||
row.start <- which(x %pm>% pm_pull(col_specimen) == specimen_group) %pm>% min(na.rm = TRUE)
|
||||
@@ -416,25 +421,28 @@ first_isolate <- function(x = NULL,
|
||||
if (abs(row.start) == Inf | abs(row.end) == Inf) {
|
||||
if (info == TRUE) {
|
||||
message_("=> Found ", font_bold("no isolates"),
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
return(rep(FALSE, nrow(x)))
|
||||
}
|
||||
if (row.start == row.end) {
|
||||
if (info == TRUE) {
|
||||
message_("=> Found ", font_bold("1 first isolate"), ", as the data only contained 1 row",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
return(TRUE)
|
||||
}
|
||||
if (length(c(row.start:row.end)) == pm_n_distinct(x[c(row.start:row.end), col_mo, drop = TRUE])) {
|
||||
if (info == TRUE) {
|
||||
message_("=> Found ", font_bold(paste(length(c(row.start:row.end)), "first isolates")),
|
||||
", as all isolates were different microbial species",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
", as all isolates were different microbial species",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
return(rep(TRUE, length(c(row.start:row.end))))
|
||||
}
|
||||
@@ -443,61 +451,74 @@ first_isolate <- function(x = NULL,
|
||||
x$newvar_row_index_sorted <- seq_len(nrow(x))
|
||||
|
||||
scope.size <- nrow(x[which(x$newvar_row_index_sorted %in% c(row.start + 1:row.end) &
|
||||
!is.na(x$newvar_mo)), , drop = FALSE])
|
||||
!is.na(x$newvar_mo)), , drop = FALSE])
|
||||
|
||||
# Analysis of first isolate ----
|
||||
if (!is.null(col_keyantimicrobials)) {
|
||||
if (info == TRUE & message_not_thrown_before("first_isolate", "type")) {
|
||||
if (type == "keyantimicrobials") {
|
||||
message_("Basing inclusion on key antimicrobials, ",
|
||||
ifelse(ignore_I == FALSE, "not ", ""),
|
||||
"ignoring I",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
ifelse(ignore_I == FALSE, "not ", ""),
|
||||
"ignoring I",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
if (type == "points") {
|
||||
message_("Basing inclusion on all antimicrobial results, using a points threshold of ",
|
||||
points_threshold,
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
points_threshold,
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x$other_pat_or_mo <- ifelse(x$newvar_patient_id == pm_lag(x$newvar_patient_id) &
|
||||
x$newvar_genus_species == pm_lag(x$newvar_genus_species),
|
||||
FALSE,
|
||||
TRUE)
|
||||
x$newvar_genus_species == pm_lag(x$newvar_genus_species),
|
||||
FALSE,
|
||||
TRUE
|
||||
)
|
||||
|
||||
x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species)
|
||||
x$more_than_episode_ago <- unlist(lapply(split(x$newvar_date,
|
||||
x$episode_group),
|
||||
exec_episode, # this will skip meet_criteria() in is_new_episode(), saving time
|
||||
type = "logical",
|
||||
episode_days = episode_days),
|
||||
use.names = FALSE)
|
||||
x$more_than_episode_ago <- unlist(lapply(split(
|
||||
x$newvar_date,
|
||||
x$episode_group
|
||||
),
|
||||
exec_episode, # this will skip meet_criteria() in is_new_episode(), saving time
|
||||
type = "logical",
|
||||
episode_days = episode_days
|
||||
),
|
||||
use.names = FALSE
|
||||
)
|
||||
|
||||
if (!is.null(col_keyantimicrobials)) {
|
||||
# with key antibiotics
|
||||
x$other_key_ab <- !antimicrobials_equal(y = x$newvar_key_ab,
|
||||
z = pm_lag(x$newvar_key_ab),
|
||||
type = type,
|
||||
ignore_I = ignore_I,
|
||||
points_threshold = points_threshold)
|
||||
x$newvar_first_isolate <- pm_if_else(x$newvar_row_index_sorted >= row.start &
|
||||
x$newvar_row_index_sorted <= row.end &
|
||||
x$newvar_genus_species != "" &
|
||||
(x$other_pat_or_mo | x$more_than_episode_ago | x$other_key_ab),
|
||||
TRUE,
|
||||
FALSE)
|
||||
x$other_key_ab <- !antimicrobials_equal(
|
||||
y = x$newvar_key_ab,
|
||||
z = pm_lag(x$newvar_key_ab),
|
||||
type = type,
|
||||
ignore_I = ignore_I,
|
||||
points_threshold = points_threshold
|
||||
)
|
||||
x$newvar_first_isolate <- pm_if_else(
|
||||
x$newvar_row_index_sorted >= row.start &
|
||||
x$newvar_row_index_sorted <= row.end &
|
||||
x$newvar_genus_species != "" &
|
||||
(x$other_pat_or_mo | x$more_than_episode_ago | x$other_key_ab),
|
||||
TRUE,
|
||||
FALSE
|
||||
)
|
||||
} else {
|
||||
# no key antibiotics
|
||||
x$newvar_first_isolate <- pm_if_else(x$newvar_row_index_sorted >= row.start &
|
||||
x$newvar_row_index_sorted <= row.end &
|
||||
x$newvar_genus_species != "" &
|
||||
(x$other_pat_or_mo | x$more_than_episode_ago),
|
||||
TRUE,
|
||||
FALSE)
|
||||
x$newvar_first_isolate <- pm_if_else(
|
||||
x$newvar_row_index_sorted >= row.start &
|
||||
x$newvar_row_index_sorted <= row.end &
|
||||
x$newvar_genus_species != "" &
|
||||
(x$other_pat_or_mo | x$more_than_episode_ago),
|
||||
TRUE,
|
||||
FALSE
|
||||
)
|
||||
}
|
||||
|
||||
# first one as TRUE
|
||||
@@ -508,14 +529,16 @@ first_isolate <- function(x = NULL,
|
||||
}
|
||||
if (!is.null(col_icu)) {
|
||||
if (icu_exclude == TRUE) {
|
||||
message_("Excluding isolates from ICU.",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
x[which(as.logical(x[, col_icu, drop = TRUE])), "newvar_first_isolate"] <- FALSE
|
||||
message_("Excluding ", format(sum(col_icu, na.rm = TRUE), big.mark = ","), " isolates from ICU.",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
x[which(col_icu), "newvar_first_isolate"] <- FALSE
|
||||
} else {
|
||||
message_("Including isolates from ICU.",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,34 +562,43 @@ first_isolate <- function(x = NULL,
|
||||
}
|
||||
})
|
||||
message_("\nGroup: ", paste0(names(group), " = ", group, collapse = ", "), "\n",
|
||||
as_note = FALSE,
|
||||
add_fn = font_red)
|
||||
as_note = FALSE,
|
||||
add_fn = font_red
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# handle empty microorganisms
|
||||
if (any(x$newvar_mo == "UNKNOWN", na.rm = TRUE) & info == TRUE) {
|
||||
message_(ifelse(include_unknown == TRUE, "Included ", "Excluded "),
|
||||
format(sum(x$newvar_mo == "UNKNOWN", na.rm = TRUE),
|
||||
decimal.mark = decimal.mark, big.mark = big.mark),
|
||||
" isolates with a microbial ID 'UNKNOWN' (in column '", font_bold(col_mo), "')")
|
||||
message_(
|
||||
ifelse(include_unknown == TRUE, "Included ", "Excluded "),
|
||||
format(sum(x$newvar_mo == "UNKNOWN", na.rm = TRUE),
|
||||
decimal.mark = decimal.mark, big.mark = big.mark
|
||||
),
|
||||
" isolates with a microbial ID 'UNKNOWN' (in column '", font_bold(col_mo), "')"
|
||||
)
|
||||
}
|
||||
x[which(x$newvar_mo == "UNKNOWN"), "newvar_first_isolate"] <- include_unknown
|
||||
|
||||
# exclude all NAs
|
||||
if (any(is.na(x$newvar_mo)) & info == TRUE) {
|
||||
message_("Excluded ", format(sum(is.na(x$newvar_mo), na.rm = TRUE),
|
||||
decimal.mark = decimal.mark, big.mark = big.mark),
|
||||
" isolates with a microbial ID 'NA' (in column '", font_bold(col_mo), "')")
|
||||
message_(
|
||||
"Excluded ", format(sum(is.na(x$newvar_mo), na.rm = TRUE),
|
||||
decimal.mark = decimal.mark, big.mark = big.mark
|
||||
),
|
||||
" isolates with a microbial ID 'NA' (in column '", font_bold(col_mo), "')"
|
||||
)
|
||||
}
|
||||
x[which(is.na(x$newvar_mo)), "newvar_first_isolate"] <- FALSE
|
||||
|
||||
# handle isolates without antibiogram
|
||||
if (include_untested_rsi == FALSE && any(is.rsi(x))) {
|
||||
rsi_all_NA <- which(unname(vapply(FUN.VALUE = logical(1),
|
||||
as.data.frame(t(x[, is.rsi(x), drop = FALSE])),
|
||||
function(rsi_values) all(is.na(rsi_values)))))
|
||||
rsi_all_NA <- which(unname(vapply(
|
||||
FUN.VALUE = logical(1),
|
||||
as.data.frame(t(x[, is.rsi(x), drop = FALSE])),
|
||||
function(rsi_values) all(is.na(rsi_values))
|
||||
)))
|
||||
x[rsi_all_NA, "newvar_first_isolate"] <- FALSE
|
||||
}
|
||||
|
||||
@@ -586,20 +618,25 @@ first_isolate <- function(x = NULL,
|
||||
}
|
||||
# mark up number of found
|
||||
n_found <- format(n_found, big.mark = big.mark, decimal.mark = decimal.mark)
|
||||
message_(paste0("=> Found ",
|
||||
font_bold(paste0(n_found,
|
||||
ifelse(method == "isolate-based", "", paste0(" '", method, "'")),
|
||||
" first isolates")),
|
||||
" (",
|
||||
ifelse(p_found_total != p_found_scope,
|
||||
paste0(p_found_scope, " within scope and "),
|
||||
""),
|
||||
p_found_total, " of total where a microbial ID was available)"),
|
||||
add_fn = font_black, as_note = FALSE)
|
||||
message_(paste0(
|
||||
"=> Found ",
|
||||
font_bold(paste0(
|
||||
n_found,
|
||||
ifelse(method == "isolate-based", "", paste0(" '", method, "'")),
|
||||
" first isolates"
|
||||
)),
|
||||
" (",
|
||||
ifelse(p_found_total != p_found_scope,
|
||||
paste0(p_found_scope, " within scope and "),
|
||||
""
|
||||
),
|
||||
p_found_total, " of total where a microbial ID was available)"
|
||||
),
|
||||
add_fn = font_black, as_note = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
x$newvar_first_isolate
|
||||
|
||||
}
|
||||
|
||||
#' @rdname first_isolate
|
||||
@@ -624,13 +661,15 @@ filter_first_isolate <- function(x = 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"))
|
||||
|
||||
subset(x, first_isolate(x = x,
|
||||
col_date = col_date,
|
||||
col_patient_id = col_patient_id,
|
||||
col_mo = col_mo,
|
||||
episode_days = episode_days,
|
||||
method = method,
|
||||
...))
|
||||
subset(x, first_isolate(
|
||||
x = x,
|
||||
col_date = col_date,
|
||||
col_patient_id = col_patient_id,
|
||||
col_mo = col_mo,
|
||||
episode_days = episode_days,
|
||||
method = method,
|
||||
...
|
||||
))
|
||||
}
|
||||
|
||||
coerce_method <- function(method) {
|
||||
|
||||
@@ -111,74 +111,92 @@ g.test <- function(x,
|
||||
p = rep(1 / length(x), length(x)),
|
||||
rescale.p = FALSE) {
|
||||
DNAME <- deparse(substitute(x))
|
||||
if (is.data.frame(x))
|
||||
if (is.data.frame(x)) {
|
||||
x <- as.matrix(x)
|
||||
}
|
||||
if (is.matrix(x)) {
|
||||
if (min(dim(x)) == 1L)
|
||||
if (min(dim(x)) == 1L) {
|
||||
x <- as.vector(x)
|
||||
}
|
||||
}
|
||||
if (!is.matrix(x) && !is.null(y)) {
|
||||
if (length(x) != length(y))
|
||||
if (length(x) != length(y)) {
|
||||
stop("'x' and 'y' must have the same length")
|
||||
}
|
||||
DNAME2 <- deparse(substitute(y))
|
||||
xname <- if (length(DNAME) > 1L || nchar(DNAME, "w") >
|
||||
30)
|
||||
30) {
|
||||
""
|
||||
else DNAME
|
||||
} else {
|
||||
DNAME
|
||||
}
|
||||
yname <- if (length(DNAME2) > 1L || nchar(DNAME2, "w") >
|
||||
30)
|
||||
30) {
|
||||
""
|
||||
else DNAME2
|
||||
} else {
|
||||
DNAME2
|
||||
}
|
||||
OK <- complete.cases(x, y)
|
||||
x <- factor(x[OK])
|
||||
y <- factor(y[OK])
|
||||
if ((nlevels(x) < 2L) || (nlevels(y) < 2L))
|
||||
if ((nlevels(x) < 2L) || (nlevels(y) < 2L)) {
|
||||
stop("'x' and 'y' must have at least 2 levels")
|
||||
}
|
||||
x <- table(x, y)
|
||||
names(dimnames(x)) <- c(xname, yname)
|
||||
DNAME <- paste(paste(DNAME, collapse = "\n"), "and",
|
||||
paste(DNAME2, collapse = "\n"))
|
||||
DNAME <- paste(
|
||||
paste(DNAME, collapse = "\n"), "and",
|
||||
paste(DNAME2, collapse = "\n")
|
||||
)
|
||||
}
|
||||
if (any(x < 0) || any(is.na((x)))) # this last one was anyNA, but only introduced in R 3.1.0
|
||||
if (any(x < 0) || any(is.na((x)))) { # this last one was anyNA, but only introduced in R 3.1.0
|
||||
stop("all entries of 'x' must be nonnegative and finite")
|
||||
if ((n <- sum(x)) == 0)
|
||||
}
|
||||
if ((n <- sum(x)) == 0) {
|
||||
stop("at least one entry of 'x' must be positive")
|
||||
}
|
||||
|
||||
|
||||
if (is.matrix(x)) {
|
||||
METHOD <- "G-test of independence"
|
||||
nr <- as.integer(nrow(x))
|
||||
nc <- as.integer(ncol(x))
|
||||
if (is.na(nr) || is.na(nc) || is.na(nr * nc))
|
||||
if (is.na(nr) || is.na(nc) || is.na(nr * nc)) {
|
||||
stop("invalid nrow(x) or ncol(x)", domain = NA)
|
||||
}
|
||||
# add fisher.test suggestion
|
||||
if (nr == 2 && nc == 2)
|
||||
if (nr == 2 && nc == 2) {
|
||||
warning("`fisher.test()` is always more reliable for 2x2 tables and although much slower, often only takes seconds.")
|
||||
}
|
||||
sr <- rowSums(x)
|
||||
sc <- colSums(x)
|
||||
E <- outer(sr, sc, "*") / n
|
||||
v <- function(r, c, n) c * r * (n - r) * (n - c) / n ^ 3
|
||||
v <- function(r, c, n) c * r * (n - r) * (n - c) / n^3
|
||||
V <- outer(sr, sc, v, n)
|
||||
dimnames(E) <- dimnames(x)
|
||||
|
||||
STATISTIC <- 2 * sum(x * log(x / E)) # sum((abs(x - E) - YATES)^2/E) for chisq.test
|
||||
PARAMETER <- (nr - 1L) * (nc - 1L)
|
||||
PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE)
|
||||
|
||||
}
|
||||
else {
|
||||
if (length(dim(x)) > 2L)
|
||||
} else {
|
||||
if (length(dim(x)) > 2L) {
|
||||
stop("invalid 'x'")
|
||||
if (length(x) == 1L)
|
||||
}
|
||||
if (length(x) == 1L) {
|
||||
stop("'x' must at least have 2 elements")
|
||||
if (length(x) != length(p))
|
||||
}
|
||||
if (length(x) != length(p)) {
|
||||
stop("'x' and 'p' must have the same number of elements")
|
||||
if (any(p < 0))
|
||||
}
|
||||
if (any(p < 0)) {
|
||||
stop("probabilities must be non-negative.")
|
||||
}
|
||||
if (abs(sum(p) - 1) > sqrt(.Machine$double.eps)) {
|
||||
if (rescale.p)
|
||||
if (rescale.p) {
|
||||
p <- p / sum(p)
|
||||
else stop("probabilities must sum to 1.")
|
||||
} else {
|
||||
stop("probabilities must sum to 1.")
|
||||
}
|
||||
}
|
||||
METHOD <- "G-test of goodness-of-fit (likelihood ratio test)"
|
||||
E <- n * p
|
||||
@@ -188,15 +206,17 @@ g.test <- function(x,
|
||||
|
||||
PARAMETER <- length(x) - 1
|
||||
PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE)
|
||||
|
||||
}
|
||||
names(STATISTIC) <- "X-squared"
|
||||
names(PARAMETER) <- "df"
|
||||
if (any(E < 5) && is.finite(PARAMETER))
|
||||
if (any(E < 5) && is.finite(PARAMETER)) {
|
||||
warning("G-statistic approximation may be incorrect due to E < 5")
|
||||
}
|
||||
|
||||
structure(list(statistic = STATISTIC, argument = PARAMETER,
|
||||
p.value = PVAL, method = METHOD, data.name = DNAME,
|
||||
observed = x, expected = E, residuals = (x - E) / sqrt(E),
|
||||
stdres = (x - E) / sqrt(V)), class = "htest")
|
||||
structure(list(
|
||||
statistic = STATISTIC, argument = PARAMETER,
|
||||
p.value = PVAL, method = METHOD, data.name = DNAME,
|
||||
observed = x, expected = E, residuals = (x - E) / sqrt(E),
|
||||
stdres = (x - E) / sqrt(V)
|
||||
), class = "htest")
|
||||
}
|
||||
|
||||
@@ -67,10 +67,12 @@
|
||||
#' if (require("dplyr")) {
|
||||
#' # calculate the resistance per group first
|
||||
#' resistance_data <- example_isolates %>%
|
||||
#' group_by(order = mo_order(mo), # group on anything, like order
|
||||
#' genus = mo_genus(mo)) %>% # and genus as we do here;
|
||||
#' filter(n() >= 30) %>% # filter on only 30 results per group
|
||||
#' summarise_if(is.rsi, resistance) # then get resistance of all drugs
|
||||
#' group_by(
|
||||
#' order = mo_order(mo), # group on anything, like order
|
||||
#' genus = mo_genus(mo)
|
||||
#' ) %>% # and genus as we do here;
|
||||
#' filter(n() >= 30) %>% # filter on only 30 results per group
|
||||
#' summarise_if(is.rsi, resistance) # then get resistance of all drugs
|
||||
#'
|
||||
#' # now conduct PCA for certain antimicrobial agents
|
||||
#' pca_result <- resistance_data %>%
|
||||
@@ -112,7 +114,6 @@ ggplot_pca <- function(x,
|
||||
arrows_alpha = 0.75,
|
||||
base_textsize = 10,
|
||||
...) {
|
||||
|
||||
stop_ifnot_installed("ggplot2")
|
||||
meet_criteria(x, allow_class = c("prcomp", "princomp", "PCA", "lda"))
|
||||
meet_criteria(choices, allow_class = c("numeric", "integer"), has_length = 2, is_positive = TRUE, is_finite = TRUE)
|
||||
@@ -136,16 +137,18 @@ ggplot_pca <- function(x,
|
||||
meet_criteria(arrows_alpha, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(base_textsize, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
|
||||
calculations <- pca_calculations(pca_model = x,
|
||||
groups = groups,
|
||||
groups_missing = missing(groups),
|
||||
labels = labels,
|
||||
labels_missing = missing(labels),
|
||||
choices = choices,
|
||||
scale = scale,
|
||||
pc.biplot = pc.biplot,
|
||||
ellipse_prob = ellipse_prob,
|
||||
labels_text_placement = labels_text_placement)
|
||||
calculations <- pca_calculations(
|
||||
pca_model = x,
|
||||
groups = groups,
|
||||
groups_missing = missing(groups),
|
||||
labels = labels,
|
||||
labels_missing = missing(labels),
|
||||
choices = choices,
|
||||
scale = scale,
|
||||
pc.biplot = pc.biplot,
|
||||
ellipse_prob = ellipse_prob,
|
||||
labels_text_placement = labels_text_placement
|
||||
)
|
||||
choices <- calculations$choices
|
||||
df.u <- calculations$df.u
|
||||
df.v <- calculations$df.v
|
||||
@@ -160,10 +163,14 @@ ggplot_pca <- function(x,
|
||||
} else {
|
||||
u.axis.labs <- paste0("PC", choices)
|
||||
}
|
||||
u.axis.labs <- paste0(u.axis.labs,
|
||||
paste0("\n(explained var: ",
|
||||
percentage(x$sdev[choices] ^ 2 / sum(x$sdev ^ 2)),
|
||||
")"))
|
||||
u.axis.labs <- paste0(
|
||||
u.axis.labs,
|
||||
paste0(
|
||||
"\n(explained var: ",
|
||||
percentage(x$sdev[choices]^2 / sum(x$sdev^2)),
|
||||
")"
|
||||
)
|
||||
)
|
||||
|
||||
# Score Labels
|
||||
if (!is.null(labels)) {
|
||||
@@ -176,87 +183,113 @@ ggplot_pca <- function(x,
|
||||
}
|
||||
|
||||
# Base plot
|
||||
g <- ggplot2::ggplot(data = df.u,
|
||||
ggplot2::aes(x = xvar, y = yvar)) +
|
||||
g <- ggplot2::ggplot(
|
||||
data = df.u,
|
||||
ggplot2::aes(x = xvar, y = yvar)
|
||||
) +
|
||||
ggplot2::xlab(u.axis.labs[1]) +
|
||||
ggplot2::ylab(u.axis.labs[2]) +
|
||||
ggplot2::expand_limits(x = c(-1.15, 1.15),
|
||||
y = c(-1.15, 1.15))
|
||||
ggplot2::expand_limits(
|
||||
x = c(-1.15, 1.15),
|
||||
y = c(-1.15, 1.15)
|
||||
)
|
||||
|
||||
# Draw either labels or points
|
||||
if (!is.null(df.u$labels)) {
|
||||
if (!is.null(df.u$groups)) {
|
||||
g <- g + ggplot2::geom_point(ggplot2::aes(colour = groups),
|
||||
alpha = points_alpha,
|
||||
size = points_size) +
|
||||
alpha = points_alpha,
|
||||
size = points_size
|
||||
) +
|
||||
ggplot2::geom_text(ggplot2::aes(label = labels, colour = groups),
|
||||
nudge_y = -0.05,
|
||||
size = labels_textsize) +
|
||||
nudge_y = -0.05,
|
||||
size = labels_textsize
|
||||
) +
|
||||
ggplot2::labs(colour = group_name)
|
||||
} else {
|
||||
g <- g + ggplot2::geom_point(alpha = points_alpha,
|
||||
size = points_size) +
|
||||
g <- g + ggplot2::geom_point(
|
||||
alpha = points_alpha,
|
||||
size = points_size
|
||||
) +
|
||||
ggplot2::geom_text(ggplot2::aes(label = labels),
|
||||
nudge_y = -0.05,
|
||||
size = labels_textsize)
|
||||
nudge_y = -0.05,
|
||||
size = labels_textsize
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (!is.null(df.u$groups)) {
|
||||
g <- g + ggplot2::geom_point(ggplot2::aes(colour = groups),
|
||||
alpha = points_alpha,
|
||||
size = points_size) +
|
||||
alpha = points_alpha,
|
||||
size = points_size
|
||||
) +
|
||||
ggplot2::labs(colour = group_name)
|
||||
} else {
|
||||
g <- g + ggplot2::geom_point(alpha = points_alpha,
|
||||
size = points_size)
|
||||
g <- g + ggplot2::geom_point(
|
||||
alpha = points_alpha,
|
||||
size = points_size
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
# Overlay a concentration ellipse if there are groups
|
||||
if (!is.null(df.u$groups) & !is.null(ell) & isTRUE(ellipse)) {
|
||||
g <- g + ggplot2::geom_path(data = ell,
|
||||
ggplot2::aes(colour = groups, group = groups),
|
||||
size = ellipse_size,
|
||||
alpha = points_alpha)
|
||||
g <- g + ggplot2::geom_path(
|
||||
data = ell,
|
||||
ggplot2::aes(colour = groups, group = groups),
|
||||
size = ellipse_size,
|
||||
alpha = points_alpha
|
||||
)
|
||||
}
|
||||
|
||||
# Label the variable axes
|
||||
if (arrows == TRUE) {
|
||||
g <- g + ggplot2::geom_segment(data = df.v,
|
||||
ggplot2::aes(x = 0, y = 0, xend = xvar, yend = yvar),
|
||||
arrow = ggplot2::arrow(length = ggplot2::unit(0.5, "picas"),
|
||||
angle = 20,
|
||||
ends = "last",
|
||||
type = "open"),
|
||||
colour = arrows_colour,
|
||||
size = arrows_size,
|
||||
alpha = arrows_alpha)
|
||||
g <- g + ggplot2::geom_segment(
|
||||
data = df.v,
|
||||
ggplot2::aes(x = 0, y = 0, xend = xvar, yend = yvar),
|
||||
arrow = ggplot2::arrow(
|
||||
length = ggplot2::unit(0.5, "picas"),
|
||||
angle = 20,
|
||||
ends = "last",
|
||||
type = "open"
|
||||
),
|
||||
colour = arrows_colour,
|
||||
size = arrows_size,
|
||||
alpha = arrows_alpha
|
||||
)
|
||||
if (arrows_textangled == TRUE) {
|
||||
g <- g + ggplot2::geom_text(data = df.v,
|
||||
ggplot2::aes(label = varname, x = xvar, y = yvar, angle = angle, hjust = hjust),
|
||||
colour = arrows_colour,
|
||||
size = arrows_textsize,
|
||||
alpha = arrows_alpha)
|
||||
g <- g + ggplot2::geom_text(
|
||||
data = df.v,
|
||||
ggplot2::aes(label = varname, x = xvar, y = yvar, angle = angle, hjust = hjust),
|
||||
colour = arrows_colour,
|
||||
size = arrows_textsize,
|
||||
alpha = arrows_alpha
|
||||
)
|
||||
} else {
|
||||
g <- g + ggplot2::geom_text(data = df.v,
|
||||
ggplot2::aes(label = varname, x = xvar, y = yvar, hjust = hjust),
|
||||
colour = arrows_colour,
|
||||
size = arrows_textsize,
|
||||
alpha = arrows_alpha)
|
||||
g <- g + ggplot2::geom_text(
|
||||
data = df.v,
|
||||
ggplot2::aes(label = varname, x = xvar, y = yvar, hjust = hjust),
|
||||
colour = arrows_colour,
|
||||
size = arrows_textsize,
|
||||
alpha = arrows_alpha
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
# Add caption label about total explained variance
|
||||
g <- g + ggplot2::labs(caption = paste0("Total explained variance: ",
|
||||
percentage(sum(x$sdev[choices] ^ 2 / sum(x$sdev ^ 2)))))
|
||||
g <- g + ggplot2::labs(caption = paste0(
|
||||
"Total explained variance: ",
|
||||
percentage(sum(x$sdev[choices]^2 / sum(x$sdev^2)))
|
||||
))
|
||||
|
||||
# mark-up nicely
|
||||
g <- g + ggplot2::theme_minimal(base_size = base_textsize) +
|
||||
ggplot2::theme(panel.grid.major = ggplot2::element_line(colour = "grey85"),
|
||||
panel.grid.minor = ggplot2::element_blank(),
|
||||
# centre title and subtitle
|
||||
plot.title = ggplot2::element_text(hjust = 0.5),
|
||||
plot.subtitle = ggplot2::element_text(hjust = 0.5))
|
||||
ggplot2::theme(
|
||||
panel.grid.major = ggplot2::element_line(colour = "grey85"),
|
||||
panel.grid.minor = ggplot2::element_blank(),
|
||||
# centre title and subtitle
|
||||
plot.title = ggplot2::element_text(hjust = 0.5),
|
||||
plot.subtitle = ggplot2::element_text(hjust = 0.5)
|
||||
)
|
||||
|
||||
g
|
||||
}
|
||||
@@ -272,17 +305,19 @@ pca_calculations <- function(pca_model,
|
||||
pc.biplot = TRUE,
|
||||
ellipse_prob = 0.68,
|
||||
labels_text_placement = 1.5) {
|
||||
|
||||
non_numeric_cols <- attributes(pca_model)$non_numeric_cols
|
||||
if (groups_missing) {
|
||||
groups <- tryCatch(non_numeric_cols[[1]],
|
||||
error = function(e) NULL)
|
||||
error = function(e) NULL
|
||||
)
|
||||
group_name <- tryCatch(colnames(non_numeric_cols[1]),
|
||||
error = function(e) NULL)
|
||||
error = function(e) NULL
|
||||
)
|
||||
}
|
||||
if (labels_missing) {
|
||||
labels <- tryCatch(non_numeric_cols[[2]],
|
||||
error = function(e) NULL)
|
||||
error = function(e) NULL
|
||||
)
|
||||
}
|
||||
if (!is.null(groups) & is.null(labels)) {
|
||||
# turn them around
|
||||
@@ -319,13 +354,15 @@ pca_calculations <- function(pca_model,
|
||||
# Scores
|
||||
choices <- pmin(choices, ncol(u))
|
||||
obs.scale <- 1 - as.integer(scale)
|
||||
df.u <- as.data.frame(sweep(u[, choices], 2, d[choices] ^ obs.scale, FUN = "*"),
|
||||
stringsAsFactors = FALSE)
|
||||
df.u <- as.data.frame(sweep(u[, choices], 2, d[choices]^obs.scale, FUN = "*"),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
|
||||
# Directions
|
||||
v <- sweep(v, 2, d ^ as.integer(scale), FUN = "*")
|
||||
v <- sweep(v, 2, d^as.integer(scale), FUN = "*")
|
||||
df.v <- as.data.frame(v[, choices],
|
||||
stringsAsFactors = FALSE)
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
|
||||
names(df.u) <- c("xvar", "yvar")
|
||||
names(df.v) <- names(df.u)
|
||||
@@ -337,10 +374,10 @@ pca_calculations <- function(pca_model,
|
||||
# Scale the radius of the correlation circle so that it corresponds to
|
||||
# a data ellipse for the standardized PC scores
|
||||
circle_prob <- 0.69
|
||||
r <- sqrt(qchisq(circle_prob, df = 2)) * prod(colMeans(df.u ^ 2)) ^ (0.25)
|
||||
r <- sqrt(qchisq(circle_prob, df = 2)) * prod(colMeans(df.u^2))^(0.25)
|
||||
|
||||
# Scale directions
|
||||
v.scale <- rowSums(v ^ 2)
|
||||
v.scale <- rowSums(v^2)
|
||||
df.v <- r * df.v / sqrt(max(v.scale))
|
||||
|
||||
# Grouping variable
|
||||
@@ -361,20 +398,24 @@ pca_calculations <- function(pca_model,
|
||||
df.groups <- lapply(unique(df.u$groups), function(g, df = df.u) {
|
||||
x <- df[which(df$groups == g), , drop = FALSE]
|
||||
if (nrow(x) <= 2) {
|
||||
return(data.frame(X1 = numeric(0),
|
||||
X2 = numeric(0),
|
||||
groups = character(0),
|
||||
stringsAsFactors = FALSE))
|
||||
return(data.frame(
|
||||
X1 = numeric(0),
|
||||
X2 = numeric(0),
|
||||
groups = character(0),
|
||||
stringsAsFactors = FALSE
|
||||
))
|
||||
}
|
||||
sigma <- var(cbind(x$xvar, x$yvar))
|
||||
mu <- c(mean(x$xvar), mean(x$yvar))
|
||||
ed <- sqrt(qchisq(ellipse_prob, df = 2))
|
||||
data.frame(sweep(circle %*% chol(sigma) * ed,
|
||||
MARGIN = 2,
|
||||
STATS = mu,
|
||||
FUN = "+"),
|
||||
groups = x$groups[1],
|
||||
stringsAsFactors = FALSE)
|
||||
MARGIN = 2,
|
||||
STATS = mu,
|
||||
FUN = "+"
|
||||
),
|
||||
groups = x$groups[1],
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
})
|
||||
ell <- do.call(rbind, df.groups)
|
||||
if (NROW(ell) == 0) {
|
||||
@@ -386,12 +427,13 @@ pca_calculations <- function(pca_model,
|
||||
ell <- NULL
|
||||
}
|
||||
|
||||
list(choices = choices,
|
||||
df.u = df.u,
|
||||
df.v = df.v,
|
||||
ell = ell,
|
||||
groups = groups,
|
||||
group_name = group_name,
|
||||
labels = labels
|
||||
list(
|
||||
choices = choices,
|
||||
df.u = df.u,
|
||||
df.v = df.v,
|
||||
ell = ell,
|
||||
groups = groups,
|
||||
group_name = group_name,
|
||||
labels = labels
|
||||
)
|
||||
}
|
||||
|
||||
@@ -66,11 +66,13 @@
|
||||
#' @export
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' if (require("ggplot2") & require("dplyr")) {
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # get antimicrobial results for drugs against a UTI:
|
||||
#' ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) +
|
||||
#' geom_rsi()
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # prettify the plot using some additional functions:
|
||||
#' df <- example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)
|
||||
@@ -80,68 +82,91 @@
|
||||
#' scale_rsi_colours() +
|
||||
#' labels_rsi_count() +
|
||||
#' theme_rsi()
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # or better yet, simplify this using the wrapper function - a single command:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi()
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # get only proportions and no counts:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi(datalabels = FALSE)
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # add other ggplot2 arguments as you like:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi(width = 0.5,
|
||||
#' colour = "black",
|
||||
#' size = 1,
|
||||
#' linetype = 2,
|
||||
#' alpha = 0.25)
|
||||
#' ggplot_rsi(
|
||||
#' width = 0.5,
|
||||
#' colour = "black",
|
||||
#' size = 1,
|
||||
#' linetype = 2,
|
||||
#' alpha = 0.25
|
||||
#' )
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # you can alter the colours with colour names:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX) %>%
|
||||
#' ggplot_rsi(colours = c(SI = "yellow"))
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # but you can also use the built-in colour-blind friendly colours for
|
||||
#' # your plots, where "S" is green, "I" is yellow and "R" is red:
|
||||
#' data.frame(x = c("Value1", "Value2", "Value3"),
|
||||
#' y = c(1, 2, 3),
|
||||
#' z = c("Value4", "Value5", "Value6")) %>%
|
||||
#' data.frame(
|
||||
#' x = c("Value1", "Value2", "Value3"),
|
||||
#' y = c(1, 2, 3),
|
||||
#' z = c("Value4", "Value5", "Value6")
|
||||
#' ) %>%
|
||||
#' ggplot() +
|
||||
#' geom_col(aes(x = x, y = y, fill = z)) +
|
||||
#' scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R")
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # resistance of ciprofloxacine per age group
|
||||
#' example_isolates %>%
|
||||
#' mutate(first_isolate = first_isolate()) %>%
|
||||
#' filter(first_isolate == TRUE,
|
||||
#' mo == as.mo("E. coli")) %>%
|
||||
#' filter(
|
||||
#' first_isolate == TRUE,
|
||||
#' mo == as.mo("Escherichia coli")
|
||||
#' ) %>%
|
||||
#' # age_groups() is also a function in this AMR package:
|
||||
#' group_by(age_group = age_groups(age)) %>%
|
||||
#' select(age_group, CIP) %>%
|
||||
#' ggplot_rsi(x = "age_group")
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # a shorter version which also adjusts data label colours:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi(colours = FALSE)
|
||||
#'
|
||||
#' }
|
||||
#' if (require("ggplot2") && require("dplyr")) {
|
||||
#'
|
||||
#' # it also supports groups (don't forget to use the group var on `x` or `facet`):
|
||||
#' example_isolates %>%
|
||||
#' filter(mo_is_gram_negative()) %>%
|
||||
#' filter(mo_is_gram_negative(), ward != "Outpatient") %>%
|
||||
#' # select only UTI-specific drugs
|
||||
#' select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' ggplot_rsi(x = "hospital_id",
|
||||
#' facet = "antibiotic",
|
||||
#' nrow = 1,
|
||||
#' title = "AMR of Anti-UTI Drugs Per Hospital",
|
||||
#' x.title = "Hospital",
|
||||
#' datalabels = FALSE)
|
||||
#' select(ward, AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' group_by(ward) %>%
|
||||
#' ggplot_rsi(
|
||||
#' x = "ward",
|
||||
#' facet = "antibiotic",
|
||||
#' nrow = 1,
|
||||
#' title = "AMR of Anti-UTI Drugs Per Ward",
|
||||
#' x.title = "Ward",
|
||||
#' datalabels = FALSE
|
||||
#' )
|
||||
#' }
|
||||
#' }
|
||||
ggplot_rsi <- function(data,
|
||||
@@ -158,11 +183,13 @@ ggplot_rsi <- function(data,
|
||||
minimum = 30,
|
||||
language = get_AMR_locale(),
|
||||
nrow = NULL,
|
||||
colours = c(S = "#3CAEA3",
|
||||
SI = "#3CAEA3",
|
||||
I = "#F6D55C",
|
||||
IR = "#ED553B",
|
||||
R = "#ED553B"),
|
||||
colours = c(
|
||||
S = "#3CAEA3",
|
||||
SI = "#3CAEA3",
|
||||
I = "#F6D55C",
|
||||
IR = "#ED553B",
|
||||
R = "#ED553B"
|
||||
),
|
||||
datalabels = TRUE,
|
||||
datalabels.size = 2.5,
|
||||
datalabels.colour = "grey15",
|
||||
@@ -172,7 +199,6 @@ ggplot_rsi <- function(data,
|
||||
x.title = "Antimicrobial",
|
||||
y.title = "Proportion",
|
||||
...) {
|
||||
|
||||
stop_ifnot_installed("ggplot2")
|
||||
meet_criteria(data, allow_class = "data.frame", contains_column_class = "rsi")
|
||||
meet_criteria(position, allow_class = "character", has_length = 1, is_in = c("fill", "stack", "dodge"), allow_NULL = TRUE)
|
||||
@@ -221,9 +247,11 @@ ggplot_rsi <- function(data,
|
||||
}
|
||||
|
||||
p <- ggplot2::ggplot(data = data) +
|
||||
geom_rsi(position = position, x = x, fill = fill, translate_ab = translate_ab,
|
||||
minimum = minimum, language = language,
|
||||
combine_SI = combine_SI, combine_IR = combine_IR, ...) +
|
||||
geom_rsi(
|
||||
position = position, x = x, fill = fill, translate_ab = translate_ab,
|
||||
minimum = minimum, language = language,
|
||||
combine_SI = combine_SI, combine_IR = combine_IR, ...
|
||||
) +
|
||||
theme_rsi()
|
||||
|
||||
if (fill == "interpretation") {
|
||||
@@ -236,26 +264,30 @@ ggplot_rsi <- function(data,
|
||||
}
|
||||
|
||||
if (datalabels == TRUE) {
|
||||
p <- p + labels_rsi_count(position = position,
|
||||
x = x,
|
||||
translate_ab = translate_ab,
|
||||
minimum = minimum,
|
||||
language = language,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
datalabels.size = datalabels.size,
|
||||
datalabels.colour = datalabels.colour)
|
||||
p <- p + labels_rsi_count(
|
||||
position = position,
|
||||
x = x,
|
||||
translate_ab = translate_ab,
|
||||
minimum = minimum,
|
||||
language = language,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
datalabels.size = datalabels.size,
|
||||
datalabels.colour = datalabels.colour
|
||||
)
|
||||
}
|
||||
|
||||
if (!is.null(facet)) {
|
||||
p <- p + facet_rsi(facet = facet, nrow = nrow)
|
||||
}
|
||||
|
||||
p <- p + ggplot2::labs(title = title,
|
||||
subtitle = subtitle,
|
||||
caption = caption,
|
||||
x = x.title,
|
||||
y = y.title)
|
||||
p <- p + ggplot2::labs(
|
||||
title = title,
|
||||
subtitle = subtitle,
|
||||
caption = caption,
|
||||
x = x.title,
|
||||
y = y.title
|
||||
)
|
||||
|
||||
p
|
||||
}
|
||||
@@ -270,7 +302,7 @@ geom_rsi <- function(position = NULL,
|
||||
language = get_AMR_locale(),
|
||||
combine_SI = TRUE,
|
||||
combine_IR = FALSE,
|
||||
...) {
|
||||
...) {
|
||||
x <- x[1]
|
||||
stop_ifnot_installed("ggplot2")
|
||||
stop_if(is.data.frame(position), "`position` is invalid. Did you accidentally use '%>%' instead of '+'?")
|
||||
@@ -309,12 +341,14 @@ geom_rsi <- function(position = NULL,
|
||||
|
||||
ggplot2::geom_col(
|
||||
data = function(x) {
|
||||
rsi_df(data = x,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
minimum = minimum,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR)
|
||||
rsi_df(
|
||||
data = x,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
minimum = minimum,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR
|
||||
)
|
||||
},
|
||||
mapping = ggplot2::aes_string(x = x, y = y, fill = fill),
|
||||
position = position,
|
||||
@@ -358,9 +392,11 @@ scale_y_percent <- function(breaks = seq(0, 1, 0.1), limits = NULL) {
|
||||
if (all(breaks[breaks != 0] > 1)) {
|
||||
breaks <- breaks / 100
|
||||
}
|
||||
ggplot2::scale_y_continuous(breaks = breaks,
|
||||
labels = percentage(breaks),
|
||||
limits = limits)
|
||||
ggplot2::scale_y_continuous(
|
||||
breaks = breaks,
|
||||
labels = percentage(breaks),
|
||||
limits = limits
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname ggplot_rsi
|
||||
@@ -371,11 +407,13 @@ scale_rsi_colours <- function(...,
|
||||
meet_criteria(aesthetics, allow_class = "character", is_in = c("alpha", "colour", "color", "fill", "linetype", "shape", "size"))
|
||||
# behaviour until AMR pkg v1.5.0 and also when coming from ggplot_rsi()
|
||||
if ("colours" %in% names(list(...))) {
|
||||
original_cols <- c(S = "#3CAEA3",
|
||||
SI = "#3CAEA3",
|
||||
I = "#F6D55C",
|
||||
IR = "#ED553B",
|
||||
R = "#ED553B")
|
||||
original_cols <- c(
|
||||
S = "#3CAEA3",
|
||||
SI = "#3CAEA3",
|
||||
I = "#F6D55C",
|
||||
IR = "#ED553B",
|
||||
R = "#ED553B"
|
||||
)
|
||||
colours <- replace(original_cols, names(list(...)$colours), list(...)$colours)
|
||||
# limits = force is needed in ggplot2 3.3.4 and 3.3.5, see here;
|
||||
# https://github.com/tidyverse/ggplot2/issues/4511#issuecomment-866185530
|
||||
@@ -385,18 +423,32 @@ scale_rsi_colours <- function(...,
|
||||
return(invisible())
|
||||
}
|
||||
|
||||
names_susceptible <- c("S", "SI", "IS", "S+I", "I+S", "susceptible", "Susceptible",
|
||||
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Susceptible"),
|
||||
"replacement", drop = TRUE]))
|
||||
names_incr_exposure <- c("I", "intermediate", "increased exposure", "incr. exposure",
|
||||
"Increased exposure", "Incr. exposure", "Susceptible, incr. exp.",
|
||||
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Intermediate"),
|
||||
"replacement", drop = TRUE]),
|
||||
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Susceptible, incr. exp."),
|
||||
"replacement", drop = TRUE]))
|
||||
names_resistant <- c("R", "IR", "RI", "R+I", "I+R", "resistant", "Resistant",
|
||||
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Resistant"),
|
||||
"replacement", drop = TRUE]))
|
||||
names_susceptible <- c(
|
||||
"S", "SI", "IS", "S+I", "I+S", "susceptible", "Susceptible",
|
||||
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Susceptible"),
|
||||
"replacement",
|
||||
drop = TRUE
|
||||
])
|
||||
)
|
||||
names_incr_exposure <- c(
|
||||
"I", "intermediate", "increased exposure", "incr. exposure",
|
||||
"Increased exposure", "Incr. exposure", "Susceptible, incr. exp.",
|
||||
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Intermediate"),
|
||||
"replacement",
|
||||
drop = TRUE
|
||||
]),
|
||||
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Susceptible, incr. exp."),
|
||||
"replacement",
|
||||
drop = TRUE
|
||||
])
|
||||
)
|
||||
names_resistant <- c(
|
||||
"R", "IR", "RI", "R+I", "I+R", "resistant", "Resistant",
|
||||
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Resistant"),
|
||||
"replacement",
|
||||
drop = TRUE
|
||||
])
|
||||
)
|
||||
|
||||
susceptible <- rep("#3CAEA3", length(names_susceptible))
|
||||
names(susceptible) <- names_susceptible
|
||||
@@ -405,7 +457,7 @@ scale_rsi_colours <- function(...,
|
||||
resistant <- rep("#ED553B", length(names_resistant))
|
||||
names(resistant) <- names_resistant
|
||||
|
||||
original_cols = c(susceptible, incr_exposure, resistant)
|
||||
original_cols <- c(susceptible, incr_exposure, resistant)
|
||||
dots <- c(...)
|
||||
# replace S, I, R as colours: scale_rsi_colours(mydatavalue = "S")
|
||||
dots[dots == "S"] <- "#3CAEA3"
|
||||
@@ -422,12 +474,14 @@ scale_rsi_colours <- function(...,
|
||||
theme_rsi <- function() {
|
||||
stop_ifnot_installed("ggplot2")
|
||||
ggplot2::theme_minimal(base_size = 10) +
|
||||
ggplot2::theme(panel.grid.major.x = ggplot2::element_blank(),
|
||||
panel.grid.minor = ggplot2::element_blank(),
|
||||
panel.grid.major.y = ggplot2::element_line(colour = "grey75"),
|
||||
# center title and subtitle
|
||||
plot.title = ggplot2::element_text(hjust = 0.5),
|
||||
plot.subtitle = ggplot2::element_text(hjust = 0.5))
|
||||
ggplot2::theme(
|
||||
panel.grid.major.x = ggplot2::element_blank(),
|
||||
panel.grid.minor = ggplot2::element_blank(),
|
||||
panel.grid.major.y = ggplot2::element_line(colour = "grey75"),
|
||||
# center title and subtitle
|
||||
plot.title = ggplot2::element_text(hjust = 0.5),
|
||||
plot.subtitle = ggplot2::element_text(hjust = 0.5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname ggplot_rsi
|
||||
@@ -459,26 +513,32 @@ labels_rsi_count <- function(position = NULL,
|
||||
position <- ggplot2::position_fill(vjust = 0.5, reverse = TRUE)
|
||||
}
|
||||
x_name <- x
|
||||
ggplot2::geom_text(mapping = ggplot2::aes_string(label = "lbl",
|
||||
x = x,
|
||||
y = "value"),
|
||||
position = position,
|
||||
inherit.aes = FALSE,
|
||||
size = datalabels.size,
|
||||
colour = datalabels.colour,
|
||||
lineheight = 0.75,
|
||||
data = function(x) {
|
||||
transformed <- rsi_df(data = x,
|
||||
translate_ab = translate_ab,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
minimum = minimum,
|
||||
language = language)
|
||||
transformed$gr <- transformed[, x_name, drop = TRUE]
|
||||
transformed %pm>%
|
||||
pm_group_by(gr) %pm>%
|
||||
pm_mutate(lbl = paste0("n=", isolates)) %pm>%
|
||||
pm_ungroup() %pm>%
|
||||
pm_select(-gr)
|
||||
})
|
||||
ggplot2::geom_text(
|
||||
mapping = ggplot2::aes_string(
|
||||
label = "lbl",
|
||||
x = x,
|
||||
y = "value"
|
||||
),
|
||||
position = position,
|
||||
inherit.aes = FALSE,
|
||||
size = datalabels.size,
|
||||
colour = datalabels.colour,
|
||||
lineheight = 0.75,
|
||||
data = function(x) {
|
||||
transformed <- rsi_df(
|
||||
data = x,
|
||||
translate_ab = translate_ab,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
minimum = minimum,
|
||||
language = language
|
||||
)
|
||||
transformed$gr <- transformed[, x_name, drop = TRUE]
|
||||
transformed %pm>%
|
||||
pm_group_by(gr) %pm>%
|
||||
pm_mutate(lbl = paste0("n=", isolates)) %pm>%
|
||||
pm_ungroup() %pm>%
|
||||
pm_select(-gr)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -34,8 +34,10 @@
|
||||
#' @return A column name of `x`, or `NULL` when no result is found.
|
||||
#' @export
|
||||
#' @examples
|
||||
#' df <- data.frame(amox = "S",
|
||||
#' tetr = "R")
|
||||
#' df <- data.frame(
|
||||
#' amox = "S",
|
||||
#' tetr = "R"
|
||||
#' )
|
||||
#'
|
||||
#' guess_ab_col(df, "amoxicillin")
|
||||
#' # [1] "amox"
|
||||
@@ -47,8 +49,10 @@
|
||||
#' # [1] "tetr"
|
||||
#'
|
||||
#' # WHONET codes
|
||||
#' df <- data.frame(AMP_ND10 = "R",
|
||||
#' AMC_ED20 = "S")
|
||||
#' df <- data.frame(
|
||||
#' AMP_ND10 = "R",
|
||||
#' AMC_ED20 = "S"
|
||||
#' )
|
||||
#' guess_ab_col(df, "ampicillin")
|
||||
#' # [1] "AMP_ND10"
|
||||
#' guess_ab_col(df, "J01CR02")
|
||||
@@ -57,8 +61,10 @@
|
||||
#' # [1] "AMC_ED20"
|
||||
#'
|
||||
#' # Longer names take precendence:
|
||||
#' df <- data.frame(AMP_ED2 = "S",
|
||||
#' AMP_ED20 = "S")
|
||||
#' df <- data.frame(
|
||||
#' AMP_ED2 = "S",
|
||||
#' AMP_ED20 = "S"
|
||||
#' )
|
||||
#' guess_ab_col(df, "ampicillin")
|
||||
#' # [1] "AMP_ED20"
|
||||
guess_ab_col <- function(x = NULL, search_string = NULL, verbose = FALSE, only_rsi_columns = FALSE) {
|
||||
@@ -73,23 +79,28 @@ guess_ab_col <- function(x = NULL, search_string = NULL, verbose = FALSE, only_r
|
||||
meet_criteria(search_string, allow_class = "character", has_length = 1, allow_NULL = FALSE)
|
||||
}
|
||||
|
||||
all_found <- get_column_abx(x, info = verbose, only_rsi_columns = only_rsi_columns,
|
||||
verbose = verbose, fn = "guess_ab_col")
|
||||
all_found <- get_column_abx(x,
|
||||
info = verbose, only_rsi_columns = only_rsi_columns,
|
||||
verbose = verbose, fn = "guess_ab_col"
|
||||
)
|
||||
search_string.ab <- suppressWarnings(as.ab(search_string))
|
||||
ab_result <- unname(all_found[names(all_found) == search_string.ab])
|
||||
|
||||
if (length(ab_result) == 0) {
|
||||
if (verbose == TRUE) {
|
||||
message_("No column found as input for ", search_string,
|
||||
" (", ab_name(search_string, language = NULL, tolower = TRUE), ").",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
" (", ab_name(search_string, language = NULL, tolower = TRUE), ").",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
return(NULL)
|
||||
} else {
|
||||
if (verbose == TRUE) {
|
||||
message_("Using column '", font_bold(ab_result), "' as input for ", search_string,
|
||||
" (", ab_name(search_string, language = NULL, tolower = TRUE), ").")
|
||||
message_(
|
||||
"Using column '", font_bold(ab_result), "' as input for ", search_string,
|
||||
" (", ab_name(search_string, language = NULL, tolower = TRUE), ")."
|
||||
)
|
||||
}
|
||||
return(ab_result)
|
||||
}
|
||||
@@ -106,9 +117,13 @@ get_column_abx <- function(x,
|
||||
reuse_previous_result = TRUE,
|
||||
fn = NULL) {
|
||||
# check if retrieved before, then get it from package environment
|
||||
if (isTRUE(reuse_previous_result) && identical(unique_call_id(entire_session = FALSE,
|
||||
match_fn = fn),
|
||||
pkg_env$get_column_abx.call)) {
|
||||
if (isTRUE(reuse_previous_result) && identical(
|
||||
unique_call_id(
|
||||
entire_session = FALSE,
|
||||
match_fn = fn
|
||||
),
|
||||
pkg_env$get_column_abx.call
|
||||
)) {
|
||||
# so within the same call, within the same environment, we got here again.
|
||||
# but we could've come from another function within the same call, so now only check the columns that changed
|
||||
|
||||
@@ -156,8 +171,9 @@ get_column_abx <- function(x,
|
||||
# only test maximum of 10,000 values per column
|
||||
if (info == TRUE) {
|
||||
message_(" (using only ", font_bold("the first 10,000 rows"), ")...",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE)
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
x <- x[1:10000, , drop = FALSE]
|
||||
} else if (info == TRUE) {
|
||||
@@ -169,24 +185,28 @@ get_column_abx <- function(x,
|
||||
# and that they have no more than 50% invalid values
|
||||
vectr_antibiotics <- unlist(AB_lookup$generalised_all)
|
||||
vectr_antibiotics <- vectr_antibiotics[!is.na(vectr_antibiotics) & nchar(vectr_antibiotics) >= 3]
|
||||
x_columns <- vapply(FUN.VALUE = character(1),
|
||||
colnames(x),
|
||||
function(col, df = x) {
|
||||
if (generalise_antibiotic_name(col) %in% vectr_antibiotics ||
|
||||
is.rsi(x[, col, drop = TRUE]) ||
|
||||
is.rsi.eligible(x[, col, drop = TRUE], threshold = 0.5)
|
||||
) {
|
||||
return(col)
|
||||
} else {
|
||||
return(NA_character_)
|
||||
}
|
||||
}, USE.NAMES = FALSE)
|
||||
x_columns <- vapply(
|
||||
FUN.VALUE = character(1),
|
||||
colnames(x),
|
||||
function(col, df = x) {
|
||||
if (generalise_antibiotic_name(col) %in% vectr_antibiotics ||
|
||||
is.rsi(x[, col, drop = TRUE]) ||
|
||||
is.rsi.eligible(x[, col, drop = TRUE], threshold = 0.5)
|
||||
) {
|
||||
return(col)
|
||||
} else {
|
||||
return(NA_character_)
|
||||
}
|
||||
}, USE.NAMES = FALSE
|
||||
)
|
||||
|
||||
x_columns <- x_columns[!is.na(x_columns)]
|
||||
x <- x[, x_columns, drop = FALSE] # without drop = FALSE, x will become a vector when x_columns is length 1
|
||||
df_trans <- data.frame(colnames = colnames(x),
|
||||
abcode = suppressWarnings(as.ab(colnames(x), info = FALSE)),
|
||||
stringsAsFactors = FALSE)
|
||||
df_trans <- data.frame(
|
||||
colnames = colnames(x),
|
||||
abcode = suppressWarnings(as.ab(colnames(x), info = FALSE)),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
df_trans <- df_trans[!is.na(df_trans$abcode), , drop = FALSE]
|
||||
out <- as.character(df_trans$colnames)
|
||||
names(out) <- df_trans$abcode
|
||||
@@ -204,8 +224,9 @@ get_column_abx <- function(x,
|
||||
message_(" WARNING", add_fn = list(font_yellow, font_bold), as_note = FALSE)
|
||||
}
|
||||
warning_("Invalid antibiotic reference(s): ", vector_and(names(dots)[is.na(newnames)], quotes = FALSE),
|
||||
call = FALSE,
|
||||
immediate = TRUE)
|
||||
call = FALSE,
|
||||
immediate = TRUE
|
||||
)
|
||||
all_okay <- FALSE
|
||||
}
|
||||
unexisting_cols <- which(!vapply(FUN.VALUE = logical(1), dots, function(col) all(col %in% x_columns)))
|
||||
@@ -214,7 +235,8 @@ get_column_abx <- function(x,
|
||||
message_(" ERROR", add_fn = list(font_red, font_bold), as_note = FALSE)
|
||||
}
|
||||
stop_("Column(s) not found: ", vector_and(unlist(dots[[unexisting_cols]]), quotes = FALSE),
|
||||
call = FALSE)
|
||||
call = FALSE
|
||||
)
|
||||
all_okay <- FALSE
|
||||
}
|
||||
# turn all NULLs to NAs
|
||||
@@ -255,17 +277,22 @@ get_column_abx <- function(x,
|
||||
}
|
||||
for (i in seq_len(length(out))) {
|
||||
if (verbose == TRUE & !names(out[i]) %in% names(duplicates)) {
|
||||
message_("Using column '", font_bold(out[i]), "' as input for ", names(out)[i],
|
||||
" (", ab_name(names(out)[i], tolower = TRUE, language = NULL), ").")
|
||||
message_(
|
||||
"Using column '", font_bold(out[i]), "' as input for ", names(out)[i],
|
||||
" (", ab_name(names(out)[i], tolower = TRUE, language = NULL), ")."
|
||||
)
|
||||
}
|
||||
if (names(out[i]) %in% names(duplicates)) {
|
||||
already_set_as <- out[unname(out) == unname(out[i])][1L]
|
||||
warning_(paste0("Column '", font_bold(out[i]), "' will not be used for ",
|
||||
names(out)[i], " (", ab_name(names(out)[i], tolower = TRUE, language = NULL), ")",
|
||||
", as it is already set for ",
|
||||
names(already_set_as), " (", ab_name(names(already_set_as), tolower = TRUE, language = NULL), ")"),
|
||||
add_fn = font_red,
|
||||
immediate = verbose)
|
||||
warning_(paste0(
|
||||
"Column '", font_bold(out[i]), "' will not be used for ",
|
||||
names(out)[i], " (", ab_name(names(out)[i], tolower = TRUE, language = NULL), ")",
|
||||
", as it is already set for ",
|
||||
names(already_set_as), " (", ab_name(names(already_set_as), tolower = TRUE, language = NULL), ")"
|
||||
),
|
||||
add_fn = font_red,
|
||||
immediate = verbose
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,11 +317,16 @@ get_column_abx <- function(x,
|
||||
if (info == TRUE & !all(soft_dependencies %in% names(out))) {
|
||||
# missing a soft dependency may lower the reliability
|
||||
missing <- soft_dependencies[!soft_dependencies %in% names(out)]
|
||||
missing_msg <- vector_and(paste0(ab_name(missing, tolower = TRUE, language = NULL),
|
||||
" (", font_bold(missing, collapse = NULL), ")"),
|
||||
quotes = FALSE)
|
||||
message_("Reliability would be improved if these antimicrobial results would be available too: ",
|
||||
missing_msg)
|
||||
missing_msg <- vector_and(paste0(
|
||||
ab_name(missing, tolower = TRUE, language = NULL),
|
||||
" (", font_bold(missing, collapse = NULL), ")"
|
||||
),
|
||||
quotes = FALSE
|
||||
)
|
||||
message_(
|
||||
"Reliability would be improved if these antimicrobial results would be available too: ",
|
||||
missing_msg
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +343,7 @@ get_ab_from_namespace <- function(x, cols_ab) {
|
||||
x_new <- character()
|
||||
for (val in x) {
|
||||
if (paste0("AB_", val) %in% ls(envir = asNamespace("AMR"))) {
|
||||
# antibiotic group names, as defined in data-raw/pre-commit-hook.R, such as `AB_CARBAPENEMS`
|
||||
# antibiotic group names, as defined in data-raw/_pre_commit_hook.R, such as `AB_CARBAPENEMS`
|
||||
val <- eval(parse(text = paste0("AB_", val)), envir = asNamespace("AMR"))
|
||||
} else if (val %in% AB_lookup$ab) {
|
||||
# separate drugs, such as `AMX`
|
||||
@@ -333,7 +365,10 @@ generate_warning_abs_missing <- function(missing, any = FALSE) {
|
||||
} else {
|
||||
any_txt <- c("", "are")
|
||||
}
|
||||
warning_(paste0("Introducing NAs since", any_txt[1], " these antimicrobials ", any_txt[2], " required: ",
|
||||
vector_and(missing, quotes = FALSE)),
|
||||
immediate = TRUE)
|
||||
warning_(paste0(
|
||||
"Introducing NAs since", any_txt[1], " these antimicrobials ", any_txt[2], " required: ",
|
||||
vector_and(missing, quotes = FALSE)
|
||||
),
|
||||
immediate = TRUE
|
||||
)
|
||||
}
|
||||
|
||||
@@ -58,56 +58,69 @@ italicise_taxonomy <- function(string, type = c("markdown", "ansi")) {
|
||||
after <- "\033[23m"
|
||||
}
|
||||
|
||||
vapply(FUN.VALUE = character(1),
|
||||
string,
|
||||
function(s) {
|
||||
s_split <- unlist(strsplit(s, " "))
|
||||
vapply(
|
||||
FUN.VALUE = character(1),
|
||||
string,
|
||||
function(s) {
|
||||
s_split <- unlist(strsplit(s, " "))
|
||||
|
||||
search_strings <- gsub("[^a-zA-Z-]", "", s_split)
|
||||
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_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])
|
||||
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)
|
||||
# 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))
|
||||
ind <- c(ind_species, which(ind_fullname))
|
||||
|
||||
s_split[ind] <- paste0(before, s_split[ind], after)
|
||||
s_paste <- paste(s_split, collapse = " ")
|
||||
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)
|
||||
# clean up a bit
|
||||
s_paste <- gsub(paste0(after, " ", before), " ", s_paste, fixed = TRUE)
|
||||
|
||||
s_paste
|
||||
},
|
||||
USE.NAMES = FALSE)
|
||||
s_paste
|
||||
},
|
||||
USE.NAMES = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname italicise_taxonomy
|
||||
|
||||
@@ -42,21 +42,28 @@
|
||||
#' left_join_microorganisms(as.mo("K. pneumoniae"))
|
||||
#' left_join_microorganisms("B_KLBSL_PNMN")
|
||||
#'
|
||||
#' df <- data.frame(
|
||||
#' date = seq(
|
||||
#' from = as.Date("2018-01-01"),
|
||||
#' to = as.Date("2018-01-07"),
|
||||
#' by = 1
|
||||
#' ),
|
||||
#' bacteria = as.mo(c(
|
||||
#' "S. aureus", "MRSA", "MSSA", "STAAUR",
|
||||
#' "E. coli", "E. coli", "E. coli"
|
||||
#' )),
|
||||
#' stringsAsFactors = FALSE
|
||||
#' )
|
||||
#' colnames(df)
|
||||
#'
|
||||
#' df_joined <- left_join_microorganisms(df, "bacteria")
|
||||
#' colnames(df_joined)
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' left_join_microorganisms() %>%
|
||||
#' colnames()
|
||||
#'
|
||||
#' df <- data.frame(date = seq(from = as.Date("2018-01-01"),
|
||||
#' to = as.Date("2018-01-07"),
|
||||
#' by = 1),
|
||||
#' bacteria = as.mo(c("S. aureus", "MRSA", "MSSA", "STAAUR",
|
||||
#' "E. coli", "E. coli", "E. coli")),
|
||||
#' stringsAsFactors = FALSE)
|
||||
#' colnames(df)
|
||||
#' df_joined <- left_join_microorganisms(df, "bacteria")
|
||||
#' colnames(df_joined)
|
||||
#' }
|
||||
#' }
|
||||
inner_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
|
||||
@@ -119,9 +126,14 @@ join_microorganisms <- function(type, x, by, suffix, ...) {
|
||||
check_dataset_integrity()
|
||||
|
||||
if (!is.data.frame(x)) {
|
||||
x <- data.frame(mo = x, stringsAsFactors = FALSE)
|
||||
if (pkg_is_available("tibble", also_load = FALSE)) {
|
||||
x <- import_fn("tibble", "tibble")(mo = x)
|
||||
} else {
|
||||
x <- data.frame(mo = x, stringsAsFactors = FALSE)
|
||||
}
|
||||
by <- "mo"
|
||||
}
|
||||
x.bak <- x
|
||||
if (is.null(by)) {
|
||||
by <- search_type_in_df(x, "mo", info = FALSE)
|
||||
if (is.null(by) && NCOL(x) == 1) {
|
||||
@@ -171,5 +183,5 @@ join_microorganisms <- function(type, x, by, suffix, ...) {
|
||||
warning_("in `", type, "_join()`: the newly joined data set contains ", nrow(joined) - nrow(x), " rows more than the number of rows of `x`.")
|
||||
}
|
||||
|
||||
joined
|
||||
as_original_data_class(joined, class(x.bak))
|
||||
}
|
||||
|
||||
@@ -115,14 +115,22 @@
|
||||
#' }
|
||||
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"),
|
||||
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)) {
|
||||
@@ -168,13 +176,16 @@ key_antimicrobials <- function(x = NULL,
|
||||
values_new_length <- length(values)
|
||||
|
||||
if (values_new_length < values_old_length &
|
||||
any(filter, na.rm = TRUE) &
|
||||
message_not_thrown_before("key_antimicrobials", name)) {
|
||||
warning_("in `key_antimicrobials()`: ",
|
||||
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.")
|
||||
any(filter, na.rm = TRUE) &
|
||||
message_not_thrown_before("key_antimicrobials", name)) {
|
||||
warning_(
|
||||
"in `key_antimicrobials()`: ",
|
||||
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."
|
||||
)
|
||||
}
|
||||
|
||||
generate_antimcrobials_string(x[which(filter), c(universal, values), drop = FALSE])
|
||||
@@ -189,30 +200,38 @@ key_antimicrobials <- function(x = NULL,
|
||||
|
||||
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-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(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)
|
||||
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)
|
||||
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_("in `key_antimicrobials()`: no distinct key antibiotics determined.")
|
||||
@@ -236,10 +255,12 @@ all_antimicrobials <- function(x = NULL,
|
||||
|
||||
# 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, fn = "all_antimicrobials")
|
||||
cols <- get_column_abx(x,
|
||||
only_rsi_columns = only_rsi_columns, info = FALSE,
|
||||
sort = FALSE, fn = "all_antimicrobials"
|
||||
)
|
||||
|
||||
generate_antimcrobials_string(x[ , cols, drop = FALSE])
|
||||
generate_antimcrobials_string(x[, cols, drop = FALSE])
|
||||
}
|
||||
|
||||
generate_antimcrobials_string <- function(df) {
|
||||
@@ -249,26 +270,32 @@ generate_antimcrobials_string <- function(df) {
|
||||
if (NROW(df) == 0) {
|
||||
return(character(0))
|
||||
}
|
||||
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)))
|
||||
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))
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname key_antimicrobials
|
||||
#' @export
|
||||
antimicrobials_equal <- function(y,
|
||||
z,
|
||||
type = c("points", "keyantimicrobials"),
|
||||
ignore_I = TRUE,
|
||||
points_threshold = 2,
|
||||
...) {
|
||||
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")
|
||||
@@ -320,14 +347,18 @@ antimicrobials_equal <- function(y,
|
||||
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 <- 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
|
||||
}
|
||||
|
||||
@@ -52,18 +52,16 @@
|
||||
#'
|
||||
#' # also supports multiple patterns
|
||||
#' a <- c("Test case", "Something different", "Yet another thing")
|
||||
#' b <- c( "case", "diff", "yet")
|
||||
#' b <- c("case", "diff", "yet")
|
||||
#' a %like% b
|
||||
#' a %unlike% b
|
||||
#'
|
||||
#' a[1] %like% b
|
||||
#' a %like% b[1]
|
||||
#'
|
||||
#' # get isolates whose name start with 'Ent' or 'ent'
|
||||
#' example_isolates[which(mo_name(example_isolates$mo) %like% "^ent"), ]
|
||||
#' \donttest{
|
||||
#' # faster way, since mo_name() is context-aware:
|
||||
#' example_isolates[which(mo_name() %like% "^ent"), ]
|
||||
#' # get isolates whose name start with 'Entero' (case-insensitive)
|
||||
#' example_isolates[which(mo_name() %like% "^entero"), ]
|
||||
#'
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
@@ -98,18 +96,22 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
||||
if (length(x) == 1) {
|
||||
x <- rep(x, length(pattern))
|
||||
} else if (length(pattern) != length(x)) {
|
||||
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), ")")
|
||||
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(
|
||||
mapply(FUN = grepl,
|
||||
x = x,
|
||||
pattern = pattern,
|
||||
fixed = fixed,
|
||||
perl = !fixed,
|
||||
MoreArgs = list(ignore.case = FALSE),
|
||||
SIMPLIFY = FALSE,
|
||||
USE.NAMES = FALSE)
|
||||
mapply(
|
||||
FUN = grepl,
|
||||
x = x,
|
||||
pattern = pattern,
|
||||
fixed = fixed,
|
||||
perl = !fixed,
|
||||
MoreArgs = list(ignore.case = FALSE),
|
||||
SIMPLIFY = FALSE,
|
||||
USE.NAMES = FALSE
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,20 +25,42 @@
|
||||
|
||||
# these are allowed MIC values and will become [factor] levels
|
||||
ops <- c("<", "<=", "", ">=", ">")
|
||||
valid_mic_levels <- 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",
|
||||
sort(c(1:99, 125, 128, 256, 512, 625)))))))))),
|
||||
unique(c(t(vapply(FUN.VALUE = character(103), ops,
|
||||
function(x) paste0(x, sort(as.double(paste0("0.",
|
||||
c(1:99, 125, 128, 256, 512))))))))),
|
||||
c(t(vapply(FUN.VALUE = character(10), ops,
|
||||
function(x) paste0(x, sort(c(1:9, 1.5)))))),
|
||||
c(t(vapply(FUN.VALUE = character(45), ops,
|
||||
function(x) paste0(x, c(10:98)[9:98 %% 2 == TRUE])))),
|
||||
c(t(vapply(FUN.VALUE = character(17), ops,
|
||||
function(x) paste0(x, sort(c(2 ^ c(7:11), 192, 80 * c(2:12))))))))
|
||||
valid_mic_levels <- 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",
|
||||
sort(c(1:99, 125, 128, 256, 512, 625))
|
||||
))))
|
||||
}
|
||||
)))),
|
||||
unique(c(t(vapply(
|
||||
FUN.VALUE = character(103), ops,
|
||||
function(x) {
|
||||
paste0(x, sort(as.double(paste0(
|
||||
"0.",
|
||||
c(1:99, 125, 128, 256, 512)
|
||||
))))
|
||||
}
|
||||
)))),
|
||||
c(t(vapply(
|
||||
FUN.VALUE = character(10), ops,
|
||||
function(x) paste0(x, sort(c(1:9, 1.5)))
|
||||
))),
|
||||
c(t(vapply(
|
||||
FUN.VALUE = character(45), ops,
|
||||
function(x) paste0(x, c(10:98)[9:98 %% 2 == TRUE])
|
||||
))),
|
||||
c(t(vapply(
|
||||
FUN.VALUE = character(17), ops,
|
||||
function(x) paste0(x, sort(c(2^c(7:11), 192, 80 * c(2:12))))
|
||||
)))
|
||||
)
|
||||
|
||||
#' Transform Input to Minimum Inhibitory Concentrations (MIC)
|
||||
#'
|
||||
@@ -108,21 +130,32 @@ valid_mic_levels <- c(c(t(vapply(FUN.VALUE = character(9), ops,
|
||||
#' all(mic_data < 512)
|
||||
#'
|
||||
#' # interpret MIC values
|
||||
#' as.rsi(x = as.mic(2),
|
||||
#' mo = as.mo("Streptococcus pneumoniae"),
|
||||
#' ab = "AMX",
|
||||
#' guideline = "EUCAST")
|
||||
#' as.rsi(x = as.mic(c(0.01, 2, 4, 8)),
|
||||
#' mo = as.mo("Streptococcus pneumoniae"),
|
||||
#' ab = "AMX",
|
||||
#' guideline = "EUCAST")
|
||||
#' as.rsi(
|
||||
#' x = as.mic(2),
|
||||
#' mo = as.mo("Streptococcus pneumoniae"),
|
||||
#' ab = "AMX",
|
||||
#' guideline = "EUCAST"
|
||||
#' )
|
||||
#' as.rsi(
|
||||
#' x = as.mic(c(0.01, 2, 4, 8)),
|
||||
#' mo = as.mo("Streptococcus pneumoniae"),
|
||||
#' ab = "AMX",
|
||||
#' guideline = "EUCAST"
|
||||
#' )
|
||||
#'
|
||||
#' # plot MIC values, see ?plot
|
||||
#' plot(mic_data)
|
||||
#' plot(mic_data, mo = "E. coli", ab = "cipro")
|
||||
#' autoplot(mic_data, mo = "E. coli", ab = "cipro")
|
||||
#' autoplot(mic_data, mo = "E. coli", ab = "cipro", language = "nl") # Dutch
|
||||
#' autoplot(mic_data, mo = "E. coli", ab = "cipro", language = "uk") # Ukrainian
|
||||
#'
|
||||
#' if (require("ggplot2")) {
|
||||
#' autoplot(mic_data, mo = "E. coli", ab = "cipro")
|
||||
#' }
|
||||
#' if (require("ggplot2")) {
|
||||
#' autoplot(mic_data, mo = "E. coli", ab = "cipro", language = "nl") # Dutch
|
||||
#' }
|
||||
#' if (require("ggplot2")) {
|
||||
#' autoplot(mic_data, mo = "E. coli", ab = "cipro", language = "uk") # Ukrainian
|
||||
#' }
|
||||
as.mic <- function(x, na.rm = FALSE) {
|
||||
meet_criteria(x, allow_class = c("mic", "character", "numeric", "integer", "factor"), allow_NA = TRUE)
|
||||
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||
@@ -184,13 +217,16 @@ as.mic <- function(x, na.rm = FALSE) {
|
||||
sort() %pm>%
|
||||
vector_and(quotes = TRUE)
|
||||
warning_("in `as.mic()`: ", na_after - na_before, " results truncated (",
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid MICs: ",
|
||||
list_missing, call = FALSE)
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid MICs: ",
|
||||
list_missing,
|
||||
call = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
set_clean_class(factor(x, levels = valid_mic_levels, ordered = TRUE),
|
||||
new_class = c("mic", "ordered", "factor"))
|
||||
new_class = c("mic", "ordered", "factor")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +235,8 @@ all_valid_mics <- function(x) {
|
||||
return(FALSE)
|
||||
}
|
||||
x_mic <- tryCatch(suppressWarnings(as.mic(x[!is.na(x)])),
|
||||
error = function(e) NA)
|
||||
error = function(e) NA
|
||||
)
|
||||
!any(is.na(x_mic)) && !all(is.na(x))
|
||||
}
|
||||
|
||||
@@ -208,7 +245,8 @@ all_valid_mics <- function(x) {
|
||||
#' @format NULL
|
||||
#' @export
|
||||
NA_mic_ <- set_clean_class(factor(NA, levels = valid_mic_levels, ordered = TRUE),
|
||||
new_class = c("mic", "ordered", "factor"))
|
||||
new_class = c("mic", "ordered", "factor")
|
||||
)
|
||||
|
||||
#' @rdname as.mic
|
||||
#' @export
|
||||
@@ -264,8 +302,10 @@ type_sum.mic <- function(x, ...) {
|
||||
#' @noRd
|
||||
print.mic <- function(x, ...) {
|
||||
cat("Class <mic>",
|
||||
ifelse(length(levels(x)) < length(valid_mic_levels), font_red(" with dropped levels"), ""),
|
||||
"\n", sep = "")
|
||||
ifelse(length(levels(x)) < length(valid_mic_levels), font_red(" with dropped levels"), ""),
|
||||
"\n",
|
||||
sep = ""
|
||||
)
|
||||
print(as.character(x), quote = FALSE)
|
||||
att <- attributes(x)
|
||||
if ("na.action" %in% names(att)) {
|
||||
@@ -371,12 +411,12 @@ hist.mic <- function(x, ...) {
|
||||
get_skimmers.mic <- function(column) {
|
||||
skimr::sfl(
|
||||
skim_type = "mic",
|
||||
p0 = ~stats::quantile(., probs = 0, na.rm = TRUE, names = FALSE),
|
||||
p25 = ~stats::quantile(., probs = 0.25, na.rm = TRUE, names = FALSE),
|
||||
p50 = ~stats::quantile(., probs = 0.5, na.rm = TRUE, names = FALSE),
|
||||
p75 = ~stats::quantile(., probs = 0.75, na.rm = TRUE, names = FALSE),
|
||||
p100 = ~stats::quantile(., probs = 1, na.rm = TRUE, names = FALSE),
|
||||
hist = ~skimr::inline_hist(log2(stats::na.omit(.)), 5)
|
||||
p0 = ~ stats::quantile(., probs = 0, na.rm = TRUE, names = FALSE),
|
||||
p25 = ~ stats::quantile(., probs = 0.25, na.rm = TRUE, names = FALSE),
|
||||
p50 = ~ stats::quantile(., probs = 0.5, na.rm = TRUE, names = FALSE),
|
||||
p75 = ~ stats::quantile(., probs = 0.75, na.rm = TRUE, names = FALSE),
|
||||
p100 = ~ stats::quantile(., probs = 1, na.rm = TRUE, names = FALSE),
|
||||
hist = ~ skimr::inline_hist(log2(stats::na.omit(.)), 5)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -672,7 +712,7 @@ is_lower <- function(el) {
|
||||
#' @export
|
||||
#' @noRd
|
||||
`^.mic` <- function(e1, e2) {
|
||||
as.double(e1) ^ as.double(e2)
|
||||
as.double(e1)^as.double(e2)
|
||||
}
|
||||
|
||||
#' @method %% mic
|
||||
|
||||
@@ -56,8 +56,10 @@
|
||||
#' as.mo("E. coli")
|
||||
#' mo_uncertainties()
|
||||
#'
|
||||
#' mo_matching_score(x = "E. coli",
|
||||
#' n = c("Escherichia coli", "Entamoeba coli"))
|
||||
#' mo_matching_score(
|
||||
#' x = "E. coli",
|
||||
#' n = c("Escherichia coli", "Entamoeba coli")
|
||||
#' )
|
||||
mo_matching_score <- function(x, n) {
|
||||
meet_criteria(x, allow_class = c("character", "data.frame", "list"))
|
||||
meet_criteria(n, allow_class = "character")
|
||||
@@ -67,10 +69,14 @@ mo_matching_score <- function(x, n) {
|
||||
x <- gsub("[^a-zA-Z0-9 \\(\\)]+", "", x)
|
||||
|
||||
# remove abbreviations known to the field
|
||||
x <- gsub(paste0("(^|[^a-z0-9]+)(",
|
||||
paste0(pkg_env$mo_field_abbreviations, collapse = "|"),
|
||||
")([^a-z0-9]+|$)"),
|
||||
"", x, perl = TRUE, ignore.case = TRUE)
|
||||
x <- gsub(paste0(
|
||||
"(^|[^a-z0-9]+)(",
|
||||
paste0(pkg_env$mo_field_abbreviations, collapse = "|"),
|
||||
")([^a-z0-9]+|$)"
|
||||
),
|
||||
"", x,
|
||||
perl = TRUE, ignore.case = TRUE
|
||||
)
|
||||
|
||||
# only keep one space
|
||||
x <- gsub(" +", " ", x)
|
||||
|
||||
@@ -139,11 +139,13 @@
|
||||
#' mo_type("Klebsiella pneumoniae")
|
||||
#'
|
||||
#' mo_fullname("S. pyogenes",
|
||||
#' Lancefield = TRUE,
|
||||
#' language = "de")
|
||||
#' Lancefield = TRUE,
|
||||
#' language = "de"
|
||||
#' )
|
||||
#' mo_fullname("S. pyogenes",
|
||||
#' Lancefield = TRUE,
|
||||
#' language = "nl")
|
||||
#' Lancefield = TRUE,
|
||||
#' language = "nl"
|
||||
#' )
|
||||
#'
|
||||
#'
|
||||
#' # other --------------------------------------------------------------------
|
||||
@@ -176,9 +178,10 @@ mo_name <- function(x, language = get_AMR_locale(), ...) {
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
|
||||
translate_into_language(mo_validate(x = x, property = "fullname", language = language, ...),
|
||||
language = language,
|
||||
only_unknown = FALSE,
|
||||
only_affect_mo_names = TRUE)
|
||||
language = language,
|
||||
only_unknown = FALSE,
|
||||
only_affect_mo_names = TRUE
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname mo_property
|
||||
@@ -367,14 +370,16 @@ mo_gramstain <- function(x, language = get_AMR_locale(), ...) {
|
||||
x[mo_kingdom(x.mo) == "Bacteria"] <- "Gram-negative"
|
||||
# overwrite these 4 phyla with Gram-positives
|
||||
# Source: https://itis.gov/servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value=956097 (Cavalier-Smith, 2002)
|
||||
x[(mo_phylum(x.mo) %in% c("Actinobacteria",
|
||||
"Chloroflexi",
|
||||
"Firmicutes",
|
||||
"Tenericutes") &
|
||||
# but class Negativicutes (of phylum Firmicutes) are Gram-negative!
|
||||
mo_class(x.mo) != "Negativicutes")
|
||||
# and of course our own ID for Gram-positives
|
||||
| x.mo == "B_GRAMP"] <- "Gram-positive"
|
||||
x[(mo_phylum(x.mo) %in% c(
|
||||
"Actinobacteria",
|
||||
"Chloroflexi",
|
||||
"Firmicutes",
|
||||
"Tenericutes"
|
||||
) &
|
||||
# but class Negativicutes (of phylum Firmicutes) are Gram-negative!
|
||||
mo_class(x.mo) != "Negativicutes")
|
||||
# and of course our own ID for Gram-positives
|
||||
| x.mo == "B_GRAMP"] <- "Gram-positive"
|
||||
|
||||
load_mo_failures_uncertainties_renamed(metadata)
|
||||
translate_into_language(x, language = language, only_unknown = FALSE)
|
||||
@@ -467,9 +472,11 @@ mo_is_intrinsic_resistant <- function(x, ab, language = get_AMR_locale(), ...) {
|
||||
|
||||
# show used version number once per session (pkg_env will reload every session)
|
||||
if (message_not_thrown_before("mo_is_intrinsic_resistant", "version.mo", entire_session = TRUE)) {
|
||||
message_("Determining intrinsic resistance based on ",
|
||||
format_eucast_version_nr(3.3, markdown = FALSE), ". ",
|
||||
font_red("This note will be shown once per session."))
|
||||
message_(
|
||||
"Determining intrinsic resistance based on ",
|
||||
format_eucast_version_nr(3.3, markdown = FALSE), ". ",
|
||||
font_red("This note will be shown once per session.")
|
||||
)
|
||||
}
|
||||
|
||||
# runs against internal vector: INTRINSIC_R (see zzz.R)
|
||||
@@ -562,7 +569,7 @@ mo_rank <- function(x, language = get_AMR_locale(), ...) {
|
||||
|
||||
#' @rdname mo_property
|
||||
#' @export
|
||||
mo_taxonomy <- function(x, language = get_AMR_locale(), ...) {
|
||||
mo_taxonomy <- function(x, language = get_AMR_locale(), ...) {
|
||||
if (missing(x)) {
|
||||
# this tries to find the data and an <mo> column
|
||||
x <- find_mo_col(fn = "mo_taxonomy")
|
||||
@@ -573,14 +580,16 @@ mo_taxonomy <- function(x, language = get_AMR_locale(), ...) {
|
||||
x <- as.mo(x, language = language, ...)
|
||||
metadata <- get_mo_failures_uncertainties_renamed()
|
||||
|
||||
out <- list(kingdom = mo_kingdom(x, language = language),
|
||||
phylum = mo_phylum(x, language = language),
|
||||
class = mo_class(x, language = language),
|
||||
order = mo_order(x, language = language),
|
||||
family = mo_family(x, language = language),
|
||||
genus = mo_genus(x, language = language),
|
||||
species = mo_species(x, language = language),
|
||||
subspecies = mo_subspecies(x, language = language))
|
||||
out <- list(
|
||||
kingdom = mo_kingdom(x, language = language),
|
||||
phylum = mo_phylum(x, language = language),
|
||||
class = mo_class(x, language = language),
|
||||
order = mo_order(x, language = language),
|
||||
family = mo_family(x, language = language),
|
||||
genus = mo_genus(x, language = language),
|
||||
species = mo_species(x, language = language),
|
||||
subspecies = mo_subspecies(x, language = language)
|
||||
)
|
||||
|
||||
load_mo_failures_uncertainties_renamed(metadata)
|
||||
out
|
||||
@@ -601,7 +610,7 @@ mo_synonyms <- function(x, language = get_AMR_locale(), ...) {
|
||||
|
||||
IDs <- mo_name(x = x, language = NULL)
|
||||
syns <- lapply(IDs, function(newname) {
|
||||
res <- sort(microorganisms.old[which(microorganisms.old$fullname_new == newname), "fullname"])
|
||||
res <- sort(microorganisms.old[which(microorganisms.old$fullname_new == newname), "fullname", drop = TRUE])
|
||||
if (length(res) == 0) {
|
||||
NULL
|
||||
} else {
|
||||
@@ -621,7 +630,7 @@ mo_synonyms <- function(x, language = get_AMR_locale(), ...) {
|
||||
|
||||
#' @rdname mo_property
|
||||
#' @export
|
||||
mo_info <- function(x, language = get_AMR_locale(), ...) {
|
||||
mo_info <- function(x, language = get_AMR_locale(), ...) {
|
||||
if (missing(x)) {
|
||||
# this tries to find the data and an <mo> column
|
||||
x <- find_mo_col(fn = "mo_info")
|
||||
@@ -632,13 +641,18 @@ mo_info <- function(x, language = get_AMR_locale(), ...) {
|
||||
x <- as.mo(x, language = language, ...)
|
||||
metadata <- get_mo_failures_uncertainties_renamed()
|
||||
|
||||
info <- lapply(x, function(y)
|
||||
c(mo_taxonomy(y, language = language),
|
||||
list(synonyms = mo_synonyms(y),
|
||||
gramstain = mo_gramstain(y, language = language),
|
||||
url = unname(mo_url(y, open = FALSE)),
|
||||
ref = mo_ref(y),
|
||||
snomed = unlist(mo_snomed(y)))))
|
||||
info <- lapply(x, function(y) {
|
||||
c(
|
||||
mo_taxonomy(y, language = language),
|
||||
list(
|
||||
synonyms = mo_synonyms(y),
|
||||
gramstain = mo_gramstain(y, language = language),
|
||||
url = unname(mo_url(y, open = FALSE)),
|
||||
ref = mo_ref(y),
|
||||
snomed = unlist(mo_snomed(y))
|
||||
)
|
||||
)
|
||||
})
|
||||
if (length(info) > 1) {
|
||||
names(info) <- mo_name(x)
|
||||
result <- info
|
||||
@@ -664,10 +678,11 @@ mo_url <- function(x, open = FALSE, language = get_AMR_locale(), ...) {
|
||||
x.mo <- as.mo(x = x, language = language, ... = ...)
|
||||
metadata <- get_mo_failures_uncertainties_renamed()
|
||||
|
||||
df <- microorganisms[match(x.mo, microorganisms$mo), c("mo", "fullname", "source", "kingdom", "rank")]
|
||||
df <- microorganisms[match(x.mo, microorganisms$mo), c("mo", "fullname", "source", "kingdom", "rank"), drop = FALSE]
|
||||
df$url <- ifelse(df$source == "LPSN",
|
||||
paste0(CATALOGUE_OF_LIFE$url_LPSN, "/species/", gsub(" ", "-", tolower(df$fullname), fixed = TRUE)),
|
||||
paste0(CATALOGUE_OF_LIFE$url_CoL, "/data/search?type=EXACT&q=", gsub(" ", "%20", df$fullname, fixed = TRUE)))
|
||||
paste0(CATALOGUE_OF_LIFE$url_LPSN, "/species/", gsub(" ", "-", tolower(df$fullname), fixed = TRUE)),
|
||||
paste0(CATALOGUE_OF_LIFE$url_CoL, "/data/search?type=EXACT&q=", gsub(" ", "%20", df$fullname, fixed = TRUE))
|
||||
)
|
||||
|
||||
genera <- which(df$kingdom == "Bacteria" & df$rank == "genus")
|
||||
df$url[genera] <- gsub("/species/", "/genus/", df$url[genera], fixed = TRUE)
|
||||
@@ -719,12 +734,12 @@ mo_validate <- function(x, property, language, ...) {
|
||||
if (tryCatch(all(x[!is.na(x)] %in% MO_lookup$mo) & !has_Becker_or_Lancefield, error = function(e) FALSE)) {
|
||||
# special case for mo_* functions where class is already <mo>
|
||||
x <- MO_lookup[match(x, MO_lookup$mo), property, drop = TRUE]
|
||||
|
||||
} else {
|
||||
# try to catch an error when inputting an invalid argument
|
||||
# so the 'call.' can be set to FALSE
|
||||
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 (!all(x[!is.na(x)] %in% MO_lookup[, property, drop = TRUE]) | has_Becker_or_Lancefield) {
|
||||
x <- exec_as.mo(x, property = property, language = language, ...)
|
||||
@@ -747,9 +762,12 @@ find_mo_col <- function(fn) {
|
||||
# which is useful when functions are used within dplyr verbs
|
||||
df <- get_current_data(arg_name = "x", call = -3) # will return an error if not found
|
||||
mo <- NULL
|
||||
try({
|
||||
mo <- suppressMessages(search_type_in_df(df, "mo"))
|
||||
}, silent = TRUE)
|
||||
try(
|
||||
{
|
||||
mo <- suppressMessages(search_type_in_df(df, "mo"))
|
||||
},
|
||||
silent = TRUE
|
||||
)
|
||||
if (!is.null(df) && !is.null(mo) && is.data.frame(df)) {
|
||||
if (message_not_thrown_before(fn = fn)) {
|
||||
message_("Using column '", font_bold(mo), "' as input for `", fn, "()`")
|
||||
|
||||
@@ -134,8 +134,9 @@ set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_s
|
||||
if (file.exists(mo_source_destination)) {
|
||||
unlink(mo_source_destination)
|
||||
message_("Removed mo_source file '", font_bold(mo_source_destination), "'",
|
||||
add_fn = font_red,
|
||||
as_note = FALSE)
|
||||
add_fn = font_red,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
return(invisible())
|
||||
}
|
||||
@@ -145,34 +146,33 @@ set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_s
|
||||
df <- NULL
|
||||
if (path %like% "[.]rds$") {
|
||||
df <- readRDS(path)
|
||||
|
||||
} else if (path %like% "[.]xlsx?$") {
|
||||
# is Excel file (old or new)
|
||||
stop_ifnot_installed("readxl")
|
||||
df <- readxl::read_excel(path)
|
||||
|
||||
} else if (path %like% "[.]tsv$") {
|
||||
df <- utils::read.table(file = path, header = TRUE, sep = "\t", stringsAsFactors = FALSE)
|
||||
|
||||
} else if (path %like% "[.]csv$") {
|
||||
df <- utils::read.table(file = path, header = TRUE, sep = ",", stringsAsFactors = FALSE)
|
||||
|
||||
} else {
|
||||
# try comma first
|
||||
try(
|
||||
df <- utils::read.table(file = path, header = TRUE, sep = ",", stringsAsFactors = FALSE),
|
||||
silent = TRUE)
|
||||
silent = TRUE
|
||||
)
|
||||
if (!check_validity_mo_source(df, stop_on_error = FALSE)) {
|
||||
# try tab
|
||||
try(
|
||||
df <- utils::read.table(file = path, header = TRUE, sep = "\t", stringsAsFactors = FALSE),
|
||||
silent = TRUE)
|
||||
silent = TRUE
|
||||
)
|
||||
}
|
||||
if (!check_validity_mo_source(df, stop_on_error = FALSE)) {
|
||||
# try pipe
|
||||
try(
|
||||
df <- utils::read.table(file = path, header = TRUE, sep = "|", stringsAsFactors = FALSE),
|
||||
silent = TRUE)
|
||||
silent = TRUE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,11 +200,15 @@ set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_s
|
||||
} else {
|
||||
action <- "Created"
|
||||
# only ask when file is created, not when it is updated
|
||||
txt <- paste0(word_wrap(paste0("This will write create the new file '",
|
||||
mo_source_destination,
|
||||
"', for which your permission is needed.")),
|
||||
"\n\n",
|
||||
word_wrap("Do you agree that this file will be created?"))
|
||||
txt <- paste0(
|
||||
word_wrap(paste0(
|
||||
"This will write create the new file '",
|
||||
mo_source_destination,
|
||||
"', for which your permission is needed."
|
||||
)),
|
||||
"\n\n",
|
||||
word_wrap("Do you agree that this file will be created?")
|
||||
)
|
||||
showQuestion <- import_fn("showQuestion", "rstudioapi", error_on_fail = FALSE)
|
||||
if (!is.null(showQuestion)) {
|
||||
q_continue <- showQuestion("Create new file in home directory", txt)
|
||||
@@ -220,11 +224,13 @@ set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_s
|
||||
attr(df, "mo_source_timestamp") <- file.mtime(path)
|
||||
saveRDS(df, mo_source_destination)
|
||||
pkg_env$mo_source <- df
|
||||
message_(action, " mo_source file '", font_bold(mo_source_destination),
|
||||
"' (", formatted_filesize(mo_source_destination),
|
||||
") from '", font_bold(path),
|
||||
"' (", formatted_filesize(path),
|
||||
'), columns "', colnames(df)[1], '" and "', colnames(df)[2], '"')
|
||||
message_(
|
||||
action, " mo_source file '", font_bold(mo_source_destination),
|
||||
"' (", formatted_filesize(mo_source_destination),
|
||||
") from '", font_bold(path),
|
||||
"' (", formatted_filesize(path),
|
||||
'), columns "', colnames(df)[1], '" and "', colnames(df)[2], '"'
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname mo_source
|
||||
@@ -289,9 +295,10 @@ check_validity_mo_source <- function(x, refer_to_name = "`reference_df`", stop_o
|
||||
plural <- ""
|
||||
}
|
||||
stop_("Value", plural, " ", vector_and(invalid[, 1, drop = TRUE], quotes = TRUE),
|
||||
" found in ", tolower(refer_to_name),
|
||||
", but with invalid microorganism code", plural, " ", vector_and(invalid$mo, quotes = TRUE),
|
||||
call = FALSE)
|
||||
" found in ", tolower(refer_to_name),
|
||||
", but with invalid microorganism code", plural, " ", vector_and(invalid$mo, quotes = TRUE),
|
||||
call = FALSE
|
||||
)
|
||||
} else {
|
||||
return(FALSE)
|
||||
}
|
||||
|
||||
@@ -43,10 +43,12 @@
|
||||
#' if (require("dplyr")) {
|
||||
#' # calculate the resistance per group first
|
||||
#' resistance_data <- example_isolates %>%
|
||||
#' group_by(order = mo_order(mo), # group on anything, like order
|
||||
#' genus = mo_genus(mo)) %>% # and genus as we do here;
|
||||
#' filter(n() >= 30) %>% # filter on only 30 results per group
|
||||
#' summarise_if(is.rsi, resistance) # then get resistance of all drugs
|
||||
#' group_by(
|
||||
#' order = mo_order(mo), # group on anything, like order
|
||||
#' genus = mo_genus(mo)
|
||||
#' ) %>% # and genus as we do here;
|
||||
#' filter(n() >= 30) %>% # filter on only 30 results per group
|
||||
#' summarise_if(is.rsi, resistance) # then get resistance of all drugs
|
||||
#'
|
||||
#' # now conduct PCA for certain antimicrobial agents
|
||||
#' pca_result <- resistance_data %>%
|
||||
@@ -92,7 +94,8 @@ pca <- function(x,
|
||||
new_list <- list(0)
|
||||
for (i in seq_len(length(dots) - 1)) {
|
||||
new_list[[i]] <- tryCatch(eval(dots[[i + 1]], envir = x),
|
||||
error = function(e) stop(e$message, call. = FALSE))
|
||||
error = function(e) stop(e$message, call. = FALSE)
|
||||
)
|
||||
if (length(new_list[[i]]) == 1) {
|
||||
if (is.character(new_list[[i]]) & new_list[[i]] %in% colnames(x)) {
|
||||
# this is to support quoted variables: df %pm>% pca("mycol1", "mycol2")
|
||||
@@ -111,21 +114,24 @@ pca <- function(x,
|
||||
|
||||
# set column names
|
||||
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
|
||||
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)), drop = FALSE]
|
||||
# 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 <- pm_ungroup(x) # would otherwise select the grouping vars
|
||||
x <- pm_ungroup(x) # would otherwise select the grouping vars
|
||||
x <- x[rowSums(is.na(x)) == 0, ] # remove columns containing NAs
|
||||
|
||||
pca_data <- x[, which(vapply(FUN.VALUE = logical(1), x, function(x) is.numeric(x)))]
|
||||
pca_data <- x[, which(vapply(FUN.VALUE = logical(1), x, function(x) is.numeric(x))), drop = FALSE]
|
||||
|
||||
message_("Columns selected for PCA: ", vector_and(font_bold(colnames(pca_data), collapse = NULL), quotes = TRUE),
|
||||
". Total observations available: ", nrow(pca_data), ".")
|
||||
message_(
|
||||
"Columns selected for PCA: ", vector_and(font_bold(colnames(pca_data), collapse = NULL), quotes = TRUE),
|
||||
". Total observations available: ", nrow(pca_data), "."
|
||||
)
|
||||
|
||||
if (getRversion() < "3.4.0") {
|
||||
# stats::prcomp prior to 3.4.0 does not have the 'rank.' argument
|
||||
|
||||
@@ -111,21 +111,24 @@ plot.mic <- function(x,
|
||||
|
||||
x <- plot_prepare_table(x, expand = expand)
|
||||
|
||||
cols_sub <- plot_colours_subtitle_guideline(x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
fn = as.mic,
|
||||
language = language,
|
||||
...)
|
||||
cols_sub <- plot_colours_subtitle_guideline(
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
fn = as.mic,
|
||||
language = language,
|
||||
...
|
||||
)
|
||||
barplot(x,
|
||||
col = cols_sub$cols,
|
||||
main = main,
|
||||
ylim = c(0, max(x) * ifelse(any(colours_RSI %in% cols_sub$cols), 1.1, 1)),
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
axes = FALSE)
|
||||
col = cols_sub$cols,
|
||||
main = main,
|
||||
ylim = c(0, max(x) * ifelse(any(colours_RSI %in% cols_sub$cols), 1.1, 1)),
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
axes = FALSE
|
||||
)
|
||||
axis(2, seq(0, max(x)))
|
||||
if (!is.null(cols_sub$sub)) {
|
||||
mtext(side = 3, line = 0.5, adj = 0.5, cex = 0.75, cols_sub$sub)
|
||||
@@ -148,14 +151,15 @@ plot.mic <- function(x,
|
||||
}
|
||||
|
||||
legend("top",
|
||||
x.intersp = 0.5,
|
||||
legend = translate_into_language(legend_txt, language = language),
|
||||
fill = legend_col,
|
||||
horiz = TRUE,
|
||||
cex = 0.75,
|
||||
box.lwd = 0,
|
||||
box.col = "#FFFFFF55",
|
||||
bg = "#FFFFFF55")
|
||||
x.intersp = 0.5,
|
||||
legend = translate_into_language(legend_txt, language = language),
|
||||
fill = legend_col,
|
||||
horiz = TRUE,
|
||||
cex = 0.75,
|
||||
box.lwd = 0,
|
||||
box.col = "#FFFFFF55",
|
||||
bg = "#FFFFFF55"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,15 +197,17 @@ barplot.mic <- function(height,
|
||||
|
||||
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
||||
|
||||
plot(x = height,
|
||||
main = main,
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
...)
|
||||
plot(
|
||||
x = height,
|
||||
main = main,
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
#' @method autoplot mic
|
||||
@@ -245,14 +251,16 @@ autoplot.mic <- function(object,
|
||||
}
|
||||
|
||||
x <- plot_prepare_table(object, expand = expand)
|
||||
cols_sub <- plot_colours_subtitle_guideline(x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
fn = as.mic,
|
||||
language = language,
|
||||
...)
|
||||
cols_sub <- plot_colours_subtitle_guideline(
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
fn = as.mic,
|
||||
language = language,
|
||||
...
|
||||
)
|
||||
df <- as.data.frame(x, stringsAsFactors = TRUE)
|
||||
colnames(df) <- c("mic", "count")
|
||||
df$cols <- cols_sub$cols
|
||||
@@ -260,23 +268,29 @@ autoplot.mic <- function(object,
|
||||
df$cols[df$cols == colours_RSI[2]] <- "Susceptible"
|
||||
df$cols[df$cols == colours_RSI[3]] <- plot_name_of_I(cols_sub$guideline)
|
||||
df$cols <- factor(translate_into_language(df$cols, language = language),
|
||||
levels = translate_into_language(c("Susceptible", plot_name_of_I(cols_sub$guideline), "Resistant"),
|
||||
language = language),
|
||||
ordered = TRUE)
|
||||
levels = translate_into_language(c("Susceptible", plot_name_of_I(cols_sub$guideline), "Resistant"),
|
||||
language = language
|
||||
),
|
||||
ordered = TRUE
|
||||
)
|
||||
p <- ggplot2::ggplot(df)
|
||||
|
||||
if (any(colours_RSI %in% cols_sub$cols)) {
|
||||
vals <- c("Resistant" = colours_RSI[1],
|
||||
"Susceptible" = colours_RSI[2],
|
||||
"Susceptible, incr. exp." = colours_RSI[3],
|
||||
"Intermediate" = colours_RSI[3])
|
||||
vals <- c(
|
||||
"Resistant" = colours_RSI[1],
|
||||
"Susceptible" = colours_RSI[2],
|
||||
"Susceptible, incr. exp." = colours_RSI[3],
|
||||
"Intermediate" = colours_RSI[3]
|
||||
)
|
||||
names(vals) <- translate_into_language(names(vals), language = language)
|
||||
p <- p +
|
||||
ggplot2::geom_col(ggplot2::aes(x = mic, y = count, fill = cols)) +
|
||||
# limits = force is needed because of a ggplot2 >= 3.3.4 bug (#4511)
|
||||
ggplot2::scale_fill_manual(values = vals,
|
||||
name = NULL,
|
||||
limits = force)
|
||||
ggplot2::scale_fill_manual(
|
||||
values = vals,
|
||||
name = NULL,
|
||||
limits = force
|
||||
)
|
||||
} else {
|
||||
p <- p +
|
||||
ggplot2::geom_col(ggplot2::aes(x = mic, y = count))
|
||||
@@ -290,8 +304,10 @@ autoplot.mic <- function(object,
|
||||
#' @rdname plot
|
||||
# will be exported using s3_register() in R/zzz.R
|
||||
fortify.mic <- function(object, ...) {
|
||||
stats::setNames(as.data.frame(plot_prepare_table(object, expand = FALSE)),
|
||||
c("x", "y"))
|
||||
stats::setNames(
|
||||
as.data.frame(plot_prepare_table(object, expand = FALSE)),
|
||||
c("x", "y")
|
||||
)
|
||||
}
|
||||
|
||||
#' @method plot disk
|
||||
@@ -334,22 +350,25 @@ plot.disk <- function(x,
|
||||
|
||||
x <- plot_prepare_table(x, expand = expand)
|
||||
|
||||
cols_sub <- plot_colours_subtitle_guideline(x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
fn = as.disk,
|
||||
language = language,
|
||||
...)
|
||||
cols_sub <- plot_colours_subtitle_guideline(
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
fn = as.disk,
|
||||
language = language,
|
||||
...
|
||||
)
|
||||
|
||||
barplot(x,
|
||||
col = cols_sub$cols,
|
||||
main = main,
|
||||
ylim = c(0, max(x) * ifelse(any(colours_RSI %in% cols_sub$cols), 1.1, 1)),
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
axes = FALSE)
|
||||
col = cols_sub$cols,
|
||||
main = main,
|
||||
ylim = c(0, max(x) * ifelse(any(colours_RSI %in% cols_sub$cols), 1.1, 1)),
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
axes = FALSE
|
||||
)
|
||||
axis(2, seq(0, max(x)))
|
||||
if (!is.null(cols_sub$sub)) {
|
||||
mtext(side = 3, line = 0.5, adj = 0.5, cex = 0.75, cols_sub$sub)
|
||||
@@ -371,14 +390,15 @@ plot.disk <- function(x,
|
||||
legend_col <- c(legend_col, colours_RSI[2])
|
||||
}
|
||||
legend("top",
|
||||
x.intersp = 0.5,
|
||||
legend = translate_into_language(legend_txt, language = language),
|
||||
fill = legend_col,
|
||||
horiz = TRUE,
|
||||
cex = 0.75,
|
||||
box.lwd = 0,
|
||||
box.col = "#FFFFFF55",
|
||||
bg = "#FFFFFF55")
|
||||
x.intersp = 0.5,
|
||||
legend = translate_into_language(legend_txt, language = language),
|
||||
fill = legend_col,
|
||||
horiz = TRUE,
|
||||
cex = 0.75,
|
||||
box.lwd = 0,
|
||||
box.col = "#FFFFFF55",
|
||||
bg = "#FFFFFF55"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,15 +436,17 @@ barplot.disk <- function(height,
|
||||
|
||||
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
||||
|
||||
plot(x = height,
|
||||
main = main,
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
...)
|
||||
plot(
|
||||
x = height,
|
||||
main = main,
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
#' @method autoplot disk
|
||||
@@ -468,14 +490,16 @@ autoplot.disk <- function(object,
|
||||
}
|
||||
|
||||
x <- plot_prepare_table(object, expand = expand)
|
||||
cols_sub <- plot_colours_subtitle_guideline(x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
fn = as.disk,
|
||||
language = language,
|
||||
...)
|
||||
cols_sub <- plot_colours_subtitle_guideline(
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
colours_RSI = colours_RSI,
|
||||
fn = as.disk,
|
||||
language = language,
|
||||
...
|
||||
)
|
||||
df <- as.data.frame(x, stringsAsFactors = TRUE)
|
||||
colnames(df) <- c("disk", "count")
|
||||
df$cols <- cols_sub$cols
|
||||
@@ -484,23 +508,29 @@ autoplot.disk <- function(object,
|
||||
df$cols[df$cols == colours_RSI[2]] <- "Susceptible"
|
||||
df$cols[df$cols == colours_RSI[3]] <- plot_name_of_I(cols_sub$guideline)
|
||||
df$cols <- factor(translate_into_language(df$cols, language = language),
|
||||
levels = translate_into_language(c("Susceptible", plot_name_of_I(cols_sub$guideline), "Resistant"),
|
||||
language = language),
|
||||
ordered = TRUE)
|
||||
levels = translate_into_language(c("Susceptible", plot_name_of_I(cols_sub$guideline), "Resistant"),
|
||||
language = language
|
||||
),
|
||||
ordered = TRUE
|
||||
)
|
||||
p <- ggplot2::ggplot(df)
|
||||
|
||||
if (any(colours_RSI %in% cols_sub$cols)) {
|
||||
vals <- c("Resistant" = colours_RSI[1],
|
||||
"Susceptible" = colours_RSI[2],
|
||||
"Susceptible, incr. exp." = colours_RSI[3],
|
||||
"Intermediate" = colours_RSI[3])
|
||||
vals <- c(
|
||||
"Resistant" = colours_RSI[1],
|
||||
"Susceptible" = colours_RSI[2],
|
||||
"Susceptible, incr. exp." = colours_RSI[3],
|
||||
"Intermediate" = colours_RSI[3]
|
||||
)
|
||||
names(vals) <- translate_into_language(names(vals), language = language)
|
||||
p <- p +
|
||||
ggplot2::geom_col(ggplot2::aes(x = disk, y = count, fill = cols)) +
|
||||
# limits = force is needed because of a ggplot2 >= 3.3.4 bug (#4511)
|
||||
ggplot2::scale_fill_manual(values = vals,
|
||||
name = NULL,
|
||||
limits = force)
|
||||
ggplot2::scale_fill_manual(
|
||||
values = vals,
|
||||
name = NULL,
|
||||
limits = force
|
||||
)
|
||||
} else {
|
||||
p <- p +
|
||||
ggplot2::geom_col(ggplot2::aes(x = disk, y = count))
|
||||
@@ -514,8 +544,10 @@ autoplot.disk <- function(object,
|
||||
#' @rdname plot
|
||||
# will be exported using s3_register() in R/zzz.R
|
||||
fortify.disk <- function(object, ...) {
|
||||
stats::setNames(as.data.frame(plot_prepare_table(object, expand = FALSE)),
|
||||
c("x", "y"))
|
||||
stats::setNames(
|
||||
as.data.frame(plot_prepare_table(object, expand = FALSE)),
|
||||
c("x", "y")
|
||||
)
|
||||
}
|
||||
|
||||
#' @method plot rsi
|
||||
@@ -546,37 +578,44 @@ plot.rsi <- function(x,
|
||||
|
||||
if (!"S" %in% data$x) {
|
||||
data <- rbind(data, data.frame(x = "S", n = 0, s = 0, stringsAsFactors = FALSE),
|
||||
stringsAsFactors = FALSE)
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
}
|
||||
if (!"I" %in% data$x) {
|
||||
data <- rbind(data, data.frame(x = "I", n = 0, s = 0, stringsAsFactors = FALSE),
|
||||
stringsAsFactors = FALSE)
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
}
|
||||
if (!"R" %in% data$x) {
|
||||
data <- rbind(data, data.frame(x = "R", n = 0, s = 0, stringsAsFactors = FALSE),
|
||||
stringsAsFactors = FALSE)
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
data$x <- factor(data$x, levels = c("S", "I", "R"), ordered = TRUE)
|
||||
|
||||
ymax <- pm_if_else(max(data$s) > 95, 105, 100)
|
||||
|
||||
plot(x = data$x,
|
||||
y = data$s,
|
||||
lwd = 2,
|
||||
ylim = c(0, ymax),
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
main = main,
|
||||
axes = FALSE)
|
||||
plot(
|
||||
x = data$x,
|
||||
y = data$s,
|
||||
lwd = 2,
|
||||
ylim = c(0, ymax),
|
||||
ylab = ylab,
|
||||
xlab = xlab,
|
||||
main = main,
|
||||
axes = FALSE
|
||||
)
|
||||
# x axis
|
||||
axis(side = 1, at = 1:pm_n_distinct(data$x), labels = levels(data$x), lwd = 0)
|
||||
# y axis, 0-100%
|
||||
axis(side = 2, at = seq(0, 100, 5))
|
||||
|
||||
text(x = data$x,
|
||||
y = data$s + 4,
|
||||
labels = paste0(data$s, "% (n = ", data$n, ")"))
|
||||
text(
|
||||
x = data$x,
|
||||
y = data$s + 4,
|
||||
labels = paste0(data$s, "% (n = ", data$n, ")")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -617,11 +656,12 @@ barplot.rsi <- function(height,
|
||||
x <- table(height)
|
||||
x <- x[c(1, 2, 3)]
|
||||
barplot(x,
|
||||
col = colours_RSI,
|
||||
xlab = xlab,
|
||||
main = main,
|
||||
ylab = ylab,
|
||||
axes = FALSE)
|
||||
col = colours_RSI,
|
||||
xlab = xlab,
|
||||
main = main,
|
||||
ylab = ylab,
|
||||
axes = FALSE
|
||||
)
|
||||
axis(2, seq(0, max(x)))
|
||||
}
|
||||
|
||||
@@ -665,10 +705,14 @@ autoplot.rsi <- function(object,
|
||||
ggplot2::ggplot(df) +
|
||||
ggplot2::geom_col(ggplot2::aes(x = rsi, y = count, fill = rsi)) +
|
||||
# limits = force is needed because of a ggplot2 >= 3.3.4 bug (#4511)
|
||||
ggplot2::scale_fill_manual(values = c("R" = colours_RSI[1],
|
||||
"S" = colours_RSI[2],
|
||||
"I" = colours_RSI[3]),
|
||||
limits = force) +
|
||||
ggplot2::scale_fill_manual(
|
||||
values = c(
|
||||
"R" = colours_RSI[1],
|
||||
"S" = colours_RSI[2],
|
||||
"I" = colours_RSI[3]
|
||||
),
|
||||
limits = force
|
||||
) +
|
||||
ggplot2::labs(title = title, x = xlab, y = ylab) +
|
||||
ggplot2::theme(legend.position = "none")
|
||||
}
|
||||
@@ -677,8 +721,10 @@ autoplot.rsi <- function(object,
|
||||
#' @rdname plot
|
||||
# will be exported using s3_register() in R/zzz.R
|
||||
fortify.rsi <- function(object, ...) {
|
||||
stats::setNames(as.data.frame(table(object)),
|
||||
c("x", "y"))
|
||||
stats::setNames(
|
||||
as.data.frame(table(object)),
|
||||
c("x", "y")
|
||||
)
|
||||
}
|
||||
|
||||
plot_prepare_table <- function(x, expand) {
|
||||
@@ -743,8 +789,10 @@ plot_colours_subtitle_guideline <- function(x, mo, ab, guideline, colours_RSI, f
|
||||
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)
|
||||
message_(
|
||||
"No ", guideline, " interpretations found for ",
|
||||
ab_name(ab, language = NULL, tolower = TRUE), " in ", moname
|
||||
)
|
||||
guideline_txt <- ""
|
||||
} else {
|
||||
guideline_txt <- guideline
|
||||
@@ -753,7 +801,7 @@ plot_colours_subtitle_guideline <- function(x, mo, ab, guideline, colours_RSI, f
|
||||
}
|
||||
guideline_txt <- paste0("(", guideline_txt, ")")
|
||||
}
|
||||
sub <- bquote(.(abname)~"-"~italic(.(moname))~.(guideline_txt))
|
||||
sub <- bquote(.(abname) ~ "-" ~ italic(.(moname)) ~ .(guideline_txt))
|
||||
} else {
|
||||
cols <- "#BEBEBE"
|
||||
sub <- NULL
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
#' # run ?example_isolates for more info.
|
||||
#'
|
||||
#' # base R ------------------------------------------------------------
|
||||
#' resistance(example_isolates$AMX) # determines %R
|
||||
#' resistance(example_isolates$AMX) # determines %R
|
||||
#' susceptibility(example_isolates$AMX) # determines %S+I
|
||||
#'
|
||||
#' # be more specific
|
||||
@@ -106,50 +106,60 @@
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(r = resistance(CIP),
|
||||
#' n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr, see ?n_rsi
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(
|
||||
#' r = resistance(CIP),
|
||||
#' n = n_rsi(CIP)
|
||||
#' ) # n_rsi works like n_distinct in dplyr, see ?n_rsi
|
||||
#'
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(R = resistance(CIP, as_percent = TRUE),
|
||||
#' SI = susceptibility(CIP, as_percent = TRUE),
|
||||
#' n1 = count_all(CIP), # the actual total; sum of all three
|
||||
#' n2 = n_rsi(CIP), # same - analogous to n_distinct
|
||||
#' total = n()) # NOT the number of tested isolates!
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(
|
||||
#' R = resistance(CIP, as_percent = TRUE),
|
||||
#' SI = susceptibility(CIP, as_percent = TRUE),
|
||||
#' n1 = count_all(CIP), # the actual total; sum of all three
|
||||
#' n2 = n_rsi(CIP), # same - analogous to n_distinct
|
||||
#' total = n()
|
||||
#' ) # NOT the number of tested isolates!
|
||||
#'
|
||||
#' # Calculate co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
#' # so we can see that combination therapy does a lot more than mono therapy:
|
||||
#' example_isolates %>% susceptibility(AMC) # %SI = 76.3%
|
||||
#' example_isolates %>% count_all(AMC) # n = 1879
|
||||
#' example_isolates %>% susceptibility(AMC) # %SI = 76.3%
|
||||
#' example_isolates %>% count_all(AMC) # n = 1879
|
||||
#'
|
||||
#' example_isolates %>% susceptibility(GEN) # %SI = 75.4%
|
||||
#' example_isolates %>% count_all(GEN) # n = 1855
|
||||
#' example_isolates %>% susceptibility(GEN) # %SI = 75.4%
|
||||
#' example_isolates %>% count_all(GEN) # n = 1855
|
||||
#'
|
||||
#' example_isolates %>% susceptibility(AMC, GEN) # %SI = 94.1%
|
||||
#' example_isolates %>% count_all(AMC, GEN) # n = 1939
|
||||
#' example_isolates %>% count_all(AMC, GEN) # n = 1939
|
||||
#'
|
||||
#'
|
||||
#' # See Details on how `only_all_tested` works. Example:
|
||||
#' example_isolates %>%
|
||||
#' summarise(numerator = count_susceptible(AMC, GEN),
|
||||
#' denominator = count_all(AMC, GEN),
|
||||
#' proportion = susceptibility(AMC, GEN))
|
||||
#' summarise(
|
||||
#' numerator = count_susceptible(AMC, GEN),
|
||||
#' denominator = count_all(AMC, GEN),
|
||||
#' proportion = susceptibility(AMC, GEN)
|
||||
#' )
|
||||
#'
|
||||
#' example_isolates %>%
|
||||
#' summarise(numerator = count_susceptible(AMC, GEN, only_all_tested = TRUE),
|
||||
#' denominator = count_all(AMC, GEN, only_all_tested = TRUE),
|
||||
#' proportion = susceptibility(AMC, GEN, only_all_tested = TRUE))
|
||||
#' summarise(
|
||||
#' numerator = count_susceptible(AMC, GEN, only_all_tested = TRUE),
|
||||
#' denominator = count_all(AMC, GEN, only_all_tested = TRUE),
|
||||
#' proportion = susceptibility(AMC, GEN, only_all_tested = TRUE)
|
||||
#' )
|
||||
#'
|
||||
#'
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(cipro_p = susceptibility(CIP, as_percent = TRUE),
|
||||
#' cipro_n = count_all(CIP),
|
||||
#' genta_p = susceptibility(GEN, as_percent = TRUE),
|
||||
#' genta_n = count_all(GEN),
|
||||
#' combination_p = susceptibility(CIP, GEN, as_percent = TRUE),
|
||||
#' combination_n = count_all(CIP, GEN))
|
||||
#' group_by(ward) %>%
|
||||
#' summarise(
|
||||
#' cipro_p = susceptibility(CIP, as_percent = TRUE),
|
||||
#' cipro_n = count_all(CIP),
|
||||
#' genta_p = susceptibility(GEN, as_percent = TRUE),
|
||||
#' genta_n = count_all(GEN),
|
||||
#' combination_p = susceptibility(CIP, GEN, as_percent = TRUE),
|
||||
#' combination_n = count_all(CIP, GEN)
|
||||
#' )
|
||||
#'
|
||||
#' # Get proportions S/I/R immediately of all rsi columns
|
||||
#' example_isolates %>%
|
||||
@@ -159,8 +169,8 @@
|
||||
#' # It also supports grouping variables
|
||||
#' # (use rsi_df to also include the count)
|
||||
#' example_isolates %>%
|
||||
#' select(hospital_id, AMX, CIP) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' select(ward, AMX, CIP) %>%
|
||||
#' group_by(ward) %>%
|
||||
#' rsi_df(translate = FALSE)
|
||||
#' }
|
||||
#' }
|
||||
@@ -170,12 +180,14 @@ resistance <- function(...,
|
||||
only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = "R",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = "R",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
@@ -186,12 +198,14 @@ susceptibility <- function(...,
|
||||
only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = c("S", "I"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = c("S", "I"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
@@ -202,12 +216,14 @@ proportion_R <- function(...,
|
||||
only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = "R",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = "R",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
@@ -218,12 +234,14 @@ proportion_IR <- function(...,
|
||||
only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = c("I", "R"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = c("I", "R"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
@@ -234,12 +252,14 @@ proportion_I <- function(...,
|
||||
only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = "I",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = "I",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
@@ -250,12 +270,14 @@ proportion_SI <- function(...,
|
||||
only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = c("S", "I"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = c("S", "I"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
@@ -266,12 +288,14 @@ proportion_S <- function(...,
|
||||
only_all_tested = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc(...,
|
||||
ab_result = "S",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
ab_result = "S",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
@@ -284,14 +308,17 @@ proportion_df <- function(data,
|
||||
combine_SI = TRUE,
|
||||
combine_IR = FALSE) {
|
||||
tryCatch(
|
||||
rsi_calc_df(type = "proportion",
|
||||
data = data,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
combine_SI_missing = missing(combine_SI)),
|
||||
error = function(e) stop_(e$message, call = -5))
|
||||
rsi_calc_df(
|
||||
type = "proportion",
|
||||
data = data,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
combine_SI_missing = missing(combine_SI)
|
||||
),
|
||||
error = function(e) stop_(e$message, call = -5)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
#'
|
||||
#' \donttest{
|
||||
#' # make the random generation more realistic by setting a bug and/or drug:
|
||||
#' random_mic(25, "Klebsiella pneumoniae") # range 0.0625-64
|
||||
#' random_mic(25, "Klebsiella pneumoniae", "meropenem") # range 0.0625-16
|
||||
#' random_mic(25, "Klebsiella pneumoniae") # range 0.0625-64
|
||||
#' random_mic(25, "Klebsiella pneumoniae", "meropenem") # range 0.0625-16
|
||||
#' random_mic(25, "Streptococcus pneumoniae", "meropenem") # range 0.0625-4
|
||||
#'
|
||||
#' random_disk(25, "Klebsiella pneumoniae") # range 8-50
|
||||
#' random_disk(25, "Klebsiella pneumoniae", "ampicillin") # range 11-17
|
||||
#' random_disk(25, "Klebsiella pneumoniae") # range 8-50
|
||||
#' random_disk(25, "Klebsiella pneumoniae", "ampicillin") # range 11-17
|
||||
#' random_disk(25, "Streptococcus pneumoniae", "ampicillin") # range 12-27
|
||||
#' }
|
||||
random_mic <- function(size = NULL, mo = NULL, ab = NULL, ...) {
|
||||
@@ -92,14 +92,16 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) {
|
||||
pm_filter(guideline %like% "EUCAST") %pm>%
|
||||
pm_arrange(pm_desc(guideline)) %pm>%
|
||||
subset(guideline == max(guideline) &
|
||||
method == type)
|
||||
method == type)
|
||||
|
||||
if (!is.null(mo)) {
|
||||
mo_coerced <- as.mo(mo)
|
||||
mo_include <- c(mo_coerced,
|
||||
as.mo(mo_genus(mo_coerced)),
|
||||
as.mo(mo_family(mo_coerced)),
|
||||
as.mo(mo_order(mo_coerced)))
|
||||
mo_include <- c(
|
||||
mo_coerced,
|
||||
as.mo(mo_genus(mo_coerced)),
|
||||
as.mo(mo_family(mo_coerced)),
|
||||
as.mo(mo_order(mo_coerced))
|
||||
)
|
||||
df_new <- df %pm>%
|
||||
subset(mo %in% mo_include)
|
||||
if (nrow(df_new) > 0) {
|
||||
@@ -125,10 +127,14 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) {
|
||||
mic_range <- c(0.001, 0.002, 0.005, 0.010, 0.025, 0.0625, 0.125, 0.250, 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 256)
|
||||
|
||||
# get highest/lowest +/- random 1 to 3 higher factors of two
|
||||
max_range <- mic_range[min(length(mic_range),
|
||||
which(mic_range == max(df$breakpoint_R)) + sample(c(1:3), 1))]
|
||||
min_range <- mic_range[max(1,
|
||||
which(mic_range == min(df$breakpoint_S)) - sample(c(1:3), 1))]
|
||||
max_range <- mic_range[min(
|
||||
length(mic_range),
|
||||
which(mic_range == max(df$breakpoint_R)) + sample(c(1:3), 1)
|
||||
)]
|
||||
min_range <- mic_range[max(
|
||||
1,
|
||||
which(mic_range == min(df$breakpoint_S)) - sample(c(1:3), 1)
|
||||
)]
|
||||
|
||||
mic_range_new <- mic_range[mic_range <= max_range & mic_range >= min_range]
|
||||
if (length(mic_range_new) == 0) {
|
||||
@@ -144,9 +150,11 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) {
|
||||
}
|
||||
return(out)
|
||||
} else if (type == "DISK") {
|
||||
set_range <- seq(from = as.integer(min(df$breakpoint_R) / 1.25),
|
||||
to = as.integer(max(df$breakpoint_S) * 1.25),
|
||||
by = 1)
|
||||
set_range <- seq(
|
||||
from = as.integer(min(df$breakpoint_R) / 1.25),
|
||||
to = as.integer(max(df$breakpoint_S) * 1.25),
|
||||
by = 1
|
||||
)
|
||||
out <- sample(set_range, size = size, replace = TRUE)
|
||||
out[out < 6] <- sample(c(6:10), length(out[out < 6]), replace = TRUE)
|
||||
out[out > 50] <- sample(c(40:50), length(out[out > 50]), replace = TRUE)
|
||||
|
||||
@@ -65,9 +65,10 @@
|
||||
#' @importFrom stats predict glm lm
|
||||
#' @examples
|
||||
#' x <- resistance_predict(example_isolates,
|
||||
#' col_ab = "AMX",
|
||||
#' year_min = 2010,
|
||||
#' model = "binomial")
|
||||
#' col_ab = "AMX",
|
||||
#' year_min = 2010,
|
||||
#' model = "binomial"
|
||||
#' )
|
||||
#' plot(x)
|
||||
#' \donttest{
|
||||
#' if (require("ggplot2")) {
|
||||
@@ -80,7 +81,7 @@
|
||||
#' filter_first_isolate() %>%
|
||||
#' filter(mo_genus(mo) == "Staphylococcus") %>%
|
||||
#' resistance_predict("PEN", model = "binomial")
|
||||
#' plot(x)
|
||||
#' print(plot(x))
|
||||
#'
|
||||
#' # get the model from the object
|
||||
#' mymodel <- attributes(x)$model
|
||||
@@ -88,15 +89,16 @@
|
||||
#' }
|
||||
#'
|
||||
#' # create nice plots with ggplot2 yourself
|
||||
#' if (require("dplyr") & require("ggplot2")) {
|
||||
#'
|
||||
#' if (require("dplyr") && require("ggplot2")) {
|
||||
#' data <- example_isolates %>%
|
||||
#' filter(mo == as.mo("E. coli")) %>%
|
||||
#' resistance_predict(col_ab = "AMX",
|
||||
#' col_date = "date",
|
||||
#' model = "binomial",
|
||||
#' info = FALSE,
|
||||
#' minimum = 15)
|
||||
#' resistance_predict(
|
||||
#' col_ab = "AMX",
|
||||
#' col_date = "date",
|
||||
#' model = "binomial",
|
||||
#' info = FALSE,
|
||||
#' minimum = 15
|
||||
#' )
|
||||
#' head(data)
|
||||
#' autoplot(data)
|
||||
#' }
|
||||
@@ -127,6 +129,9 @@ resistance_predict <- function(x,
|
||||
|
||||
stop_if(is.null(model), 'choose a regression model with the `model` argument, e.g. resistance_predict(..., model = "binomial")')
|
||||
|
||||
x.bak <- x
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
|
||||
dots <- unlist(list(...))
|
||||
if (length(dots) != 0) {
|
||||
# backwards compatibility with old arguments
|
||||
@@ -144,11 +149,10 @@ resistance_predict <- function(x,
|
||||
col_date <- search_type_in_df(x = x, type = "date")
|
||||
stop_if(is.null(col_date), "`col_date` must be set")
|
||||
}
|
||||
stop_ifnot(col_date %in% colnames(x),
|
||||
"column '", col_date, "' not found")
|
||||
|
||||
# no grouped tibbles
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
stop_ifnot(
|
||||
col_date %in% colnames(x),
|
||||
"column '", col_date, "' not found"
|
||||
)
|
||||
|
||||
year <- function(x) {
|
||||
# don't depend on lubridate or so, would be overkill for only this function
|
||||
@@ -173,8 +177,9 @@ resistance_predict <- function(x,
|
||||
# remove rows with NAs
|
||||
df <- subset(df, !is.na(df[, col_ab, drop = TRUE]))
|
||||
df$year <- year(df[, col_date, drop = TRUE])
|
||||
df <- as.data.frame(rbind(table(df[, c("year", col_ab)])),
|
||||
stringsAsFactors = FALSE)
|
||||
df <- as.data.frame(rbind(table(df[, c("year", col_ab), drop = FALSE])),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
df$year <- as.integer(rownames(df))
|
||||
rownames(df) <- NULL
|
||||
|
||||
@@ -209,7 +214,6 @@ resistance_predict <- function(x,
|
||||
predictmodel <- predict(model_lm, newdata = years, type = "response", se.fit = TRUE)
|
||||
prediction <- predictmodel$fit
|
||||
se <- predictmodel$se.fit
|
||||
|
||||
} else if (model %in% c("loglin", "poisson")) {
|
||||
model <- "poisson"
|
||||
model_lm <- with(df, glm(R ~ year, family = poisson))
|
||||
@@ -222,7 +226,6 @@ resistance_predict <- function(x,
|
||||
predictmodel <- predict(model_lm, newdata = years, type = "response", se.fit = TRUE)
|
||||
prediction <- predictmodel$fit
|
||||
se <- predictmodel$se.fit
|
||||
|
||||
} else if (model %in% c("lin", "linear")) {
|
||||
model <- "linear"
|
||||
model_lm <- with(df, lm((R / (R + S)) ~ year))
|
||||
@@ -235,23 +238,23 @@ resistance_predict <- function(x,
|
||||
predictmodel <- predict(model_lm, newdata = years, se.fit = TRUE)
|
||||
prediction <- predictmodel$fit
|
||||
se <- predictmodel$se.fit
|
||||
|
||||
} else {
|
||||
stop("no valid model selected. See ?resistance_predict.")
|
||||
}
|
||||
|
||||
# prepare the output dataframe
|
||||
df_prediction <- data.frame(year = unlist(years),
|
||||
value = prediction,
|
||||
se_min = prediction - se,
|
||||
se_max = prediction + se,
|
||||
stringsAsFactors = FALSE)
|
||||
df_prediction <- data.frame(
|
||||
year = unlist(years),
|
||||
value = prediction,
|
||||
se_min = prediction - se,
|
||||
se_max = prediction + se,
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
|
||||
if (model == "poisson") {
|
||||
df_prediction$value <- as.integer(format(df_prediction$value, scientific = FALSE))
|
||||
df_prediction$se_min <- as.integer(df_prediction$se_min)
|
||||
df_prediction$se_max <- as.integer(df_prediction$se_max)
|
||||
|
||||
} else {
|
||||
# se_max not above 1
|
||||
df_prediction$se_max <- ifelse(df_prediction$se_max > 1, 1, df_prediction$se_max)
|
||||
@@ -259,10 +262,12 @@ resistance_predict <- function(x,
|
||||
# se_min not below 0
|
||||
df_prediction$se_min <- ifelse(df_prediction$se_min < 0, 0, df_prediction$se_min)
|
||||
|
||||
df_observations <- data.frame(year = df$year,
|
||||
observations = df$R + df$S,
|
||||
observed = df$R / (df$R + df$S),
|
||||
stringsAsFactors = FALSE)
|
||||
df_observations <- data.frame(
|
||||
year = df$year,
|
||||
observations = df$R + df$S,
|
||||
observed = df$R / (df$R + df$S),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
df_prediction <- df_prediction %pm>%
|
||||
pm_left_join(df_observations, by = "year")
|
||||
df_prediction$estimated <- df_prediction$value
|
||||
@@ -275,11 +280,11 @@ resistance_predict <- function(x,
|
||||
}
|
||||
|
||||
df_prediction$value <- ifelse(df_prediction$value > 1, 1, ifelse(df_prediction$value < 0, 0, df_prediction$value))
|
||||
df_prediction <- df_prediction[order(df_prediction$year), ]
|
||||
df_prediction <- df_prediction[order(df_prediction$year), , drop = FALSE]
|
||||
|
||||
structure(
|
||||
.Data = df_prediction,
|
||||
class = c("resistance_predict", "data.frame"),
|
||||
out <- as_original_data_class(df_prediction, class(x.bak))
|
||||
structure(out,
|
||||
class = c("resistance_predict", class(out)),
|
||||
I_as_S = I_as_S,
|
||||
model_title = model,
|
||||
model = model_lm,
|
||||
@@ -305,33 +310,41 @@ plot.resistance_predict <- function(x, main = paste("Resistance Prediction of",
|
||||
ylab <- "%IR"
|
||||
}
|
||||
|
||||
plot(x = x$year,
|
||||
y = x$value,
|
||||
ylim = c(0, 1),
|
||||
yaxt = "n", # no y labels
|
||||
pch = 19, # closed dots
|
||||
ylab = paste0("Percentage (", ylab, ")"),
|
||||
xlab = "Year",
|
||||
main = main,
|
||||
sub = paste0("(n = ", sum(x$observations, na.rm = TRUE),
|
||||
", model: ", attributes(x)$model_title, ")"),
|
||||
cex.sub = 0.75)
|
||||
plot(
|
||||
x = x$year,
|
||||
y = x$value,
|
||||
ylim = c(0, 1),
|
||||
yaxt = "n", # no y labels
|
||||
pch = 19, # closed dots
|
||||
ylab = paste0("Percentage (", ylab, ")"),
|
||||
xlab = "Year",
|
||||
main = main,
|
||||
sub = paste0(
|
||||
"(n = ", sum(x$observations, na.rm = TRUE),
|
||||
", model: ", attributes(x)$model_title, ")"
|
||||
),
|
||||
cex.sub = 0.75
|
||||
)
|
||||
|
||||
|
||||
axis(side = 2, at = seq(0, 1, 0.1), labels = paste0(0:10 * 10, "%"))
|
||||
|
||||
# hack for error bars: https://stackoverflow.com/a/22037078/4575331
|
||||
arrows(x0 = x$year,
|
||||
y0 = x$se_min,
|
||||
x1 = x$year,
|
||||
y1 = x$se_max,
|
||||
length = 0.05, angle = 90, code = 3, lwd = 1.5)
|
||||
arrows(
|
||||
x0 = x$year,
|
||||
y0 = x$se_min,
|
||||
x1 = x$year,
|
||||
y1 = x$se_max,
|
||||
length = 0.05, angle = 90, code = 3, lwd = 1.5
|
||||
)
|
||||
|
||||
# overlay grey points for prediction
|
||||
points(x = subset(x, is.na(observations))$year,
|
||||
y = subset(x, is.na(observations))$value,
|
||||
pch = 19,
|
||||
col = "grey40")
|
||||
points(
|
||||
x = subset(x, is.na(observations))$year,
|
||||
y = subset(x, is.na(observations))$value,
|
||||
pch = 19,
|
||||
col = "grey40"
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname resistance_predict
|
||||
@@ -353,16 +366,24 @@ ggplot_rsi_predict <- function(x,
|
||||
ylab <- "%IR"
|
||||
}
|
||||
|
||||
p <- ggplot2::ggplot(as.data.frame(x, stringsAsFactors = FALSE),
|
||||
ggplot2::aes(x = year, y = value)) +
|
||||
ggplot2::geom_point(data = subset(x, !is.na(observations)),
|
||||
size = 2) +
|
||||
p <- ggplot2::ggplot(
|
||||
as.data.frame(x, stringsAsFactors = FALSE),
|
||||
ggplot2::aes(x = year, y = value)
|
||||
) +
|
||||
ggplot2::geom_point(
|
||||
data = subset(x, !is.na(observations)),
|
||||
size = 2
|
||||
) +
|
||||
scale_y_percent(limits = c(0, 1)) +
|
||||
ggplot2::labs(title = main,
|
||||
y = paste0("Percentage (", ylab, ")"),
|
||||
x = "Year",
|
||||
caption = paste0("(n = ", sum(x$observations, na.rm = TRUE),
|
||||
", model: ", attributes(x)$model_title, ")"))
|
||||
ggplot2::labs(
|
||||
title = main,
|
||||
y = paste0("Percentage (", ylab, ")"),
|
||||
x = "Year",
|
||||
caption = paste0(
|
||||
"(n = ", sum(x$observations, na.rm = TRUE),
|
||||
", model: ", attributes(x)$model_title, ")"
|
||||
)
|
||||
)
|
||||
|
||||
if (ribbon == TRUE) {
|
||||
p <- p + ggplot2::geom_ribbon(ggplot2::aes(ymin = se_min, ymax = se_max), alpha = 0.25)
|
||||
@@ -371,9 +392,11 @@ ggplot_rsi_predict <- function(x,
|
||||
}
|
||||
p <- p +
|
||||
# overlay grey points for prediction
|
||||
ggplot2::geom_point(data = subset(x, is.na(observations)),
|
||||
size = 2,
|
||||
colour = "grey40")
|
||||
ggplot2::geom_point(
|
||||
data = subset(x, is.na(observations)),
|
||||
size = 2,
|
||||
colour = "grey40"
|
||||
)
|
||||
p
|
||||
}
|
||||
|
||||
|
||||
@@ -104,25 +104,31 @@
|
||||
#' # For INTERPRETING disk diffusion and MIC values -----------------------
|
||||
#'
|
||||
#' # a whole data set, even with combined MIC values and disk zones
|
||||
#' df <- data.frame(microorganism = "Escherichia coli",
|
||||
#' AMP = as.mic(8),
|
||||
#' CIP = as.mic(0.256),
|
||||
#' GEN = as.disk(18),
|
||||
#' TOB = as.disk(16),
|
||||
#' NIT = as.mic(32),
|
||||
#' ERY = "R")
|
||||
#' df <- data.frame(
|
||||
#' microorganism = "Escherichia coli",
|
||||
#' AMP = as.mic(8),
|
||||
#' CIP = as.mic(0.256),
|
||||
#' GEN = as.disk(18),
|
||||
#' TOB = as.disk(16),
|
||||
#' NIT = as.mic(32),
|
||||
#' ERY = "R"
|
||||
#' )
|
||||
#' as.rsi(df)
|
||||
#'
|
||||
#' # for single values
|
||||
#' as.rsi(x = as.mic(2),
|
||||
#' mo = as.mo("S. pneumoniae"),
|
||||
#' ab = "AMP",
|
||||
#' guideline = "EUCAST")
|
||||
#' as.rsi(
|
||||
#' x = as.mic(2),
|
||||
#' mo = as.mo("S. pneumoniae"),
|
||||
#' ab = "AMP",
|
||||
#' guideline = "EUCAST"
|
||||
#' )
|
||||
#'
|
||||
#' as.rsi(x = as.disk(18),
|
||||
#' mo = "Strep pneu", # `mo` will be coerced with as.mo()
|
||||
#' ab = "ampicillin", # and `ab` with as.ab()
|
||||
#' guideline = "EUCAST")
|
||||
#' as.rsi(
|
||||
#' x = as.disk(18),
|
||||
#' mo = "Strep pneu", # `mo` will be coerced with as.mo()
|
||||
#' ab = "ampicillin", # and `ab` with as.ab()
|
||||
#' guideline = "EUCAST"
|
||||
#' )
|
||||
#'
|
||||
#' \donttest{
|
||||
#' # the dplyr way
|
||||
@@ -137,14 +143,18 @@
|
||||
#' mutate_at(vars(AMP:TOB), as.rsi, mo = .$microorganism)
|
||||
#'
|
||||
#' # to include information about urinary tract infections (UTI)
|
||||
#' data.frame(mo = "E. coli",
|
||||
#' NIT = c("<= 2", 32),
|
||||
#' from_the_bladder = c(TRUE, FALSE)) %>%
|
||||
#' data.frame(
|
||||
#' mo = "E. coli",
|
||||
#' NIT = c("<= 2", 32),
|
||||
#' from_the_bladder = c(TRUE, FALSE)
|
||||
#' ) %>%
|
||||
#' as.rsi(uti = "from_the_bladder")
|
||||
#'
|
||||
#' data.frame(mo = "E. coli",
|
||||
#' NIT = c("<= 2", 32),
|
||||
#' specimen = c("urine", "blood")) %>%
|
||||
#' data.frame(
|
||||
#' mo = "E. coli",
|
||||
#' NIT = c("<= 2", 32),
|
||||
#' specimen = c("urine", "blood")
|
||||
#' ) %>%
|
||||
#' as.rsi() # automatically determines urine isolates
|
||||
#'
|
||||
#' df %>%
|
||||
@@ -155,10 +165,9 @@
|
||||
#'
|
||||
#' as.rsi(c("S", "I", "R", "A", "B", "C"))
|
||||
#' as.rsi("<= 0.002; S") # will return "S"
|
||||
|
||||
#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
|
||||
#' is.rsi(rsi_data)
|
||||
#' plot(rsi_data) # for percentages
|
||||
#' plot(rsi_data) # for percentages
|
||||
#' barplot(rsi_data) # for frequencies
|
||||
#'
|
||||
#' # the dplyr way
|
||||
@@ -186,7 +195,8 @@ as.rsi <- function(x, ...) {
|
||||
#' @details `NA_rsi_` is a missing value of the new `<rsi>` class, analogous to e.g. base \R's [`NA_character_`][base::NA].
|
||||
#' @export
|
||||
NA_rsi_ <- set_clean_class(factor(NA, levels = c("S", "I", "R"), ordered = TRUE),
|
||||
new_class = c("rsi", "ordered", "factor"))
|
||||
new_class = c("rsi", "ordered", "factor")
|
||||
)
|
||||
|
||||
#' @rdname as.rsi
|
||||
#' @export
|
||||
@@ -209,17 +219,19 @@ is.rsi.eligible <- function(x, threshold = 0.05) {
|
||||
}
|
||||
|
||||
stop_if(NCOL(x) > 1, "`x` must be a one-dimensional vector.")
|
||||
if (any(c("numeric",
|
||||
"integer",
|
||||
"mo",
|
||||
"ab",
|
||||
"Date",
|
||||
"POSIXt",
|
||||
"raw",
|
||||
"hms",
|
||||
"mic",
|
||||
"disk")
|
||||
%in% class(x))) {
|
||||
if (any(c(
|
||||
"numeric",
|
||||
"integer",
|
||||
"mo",
|
||||
"ab",
|
||||
"Date",
|
||||
"POSIXt",
|
||||
"raw",
|
||||
"hms",
|
||||
"mic",
|
||||
"disk"
|
||||
)
|
||||
%in% class(x))) {
|
||||
# no transformation needed
|
||||
return(FALSE)
|
||||
} else if (all(x %in% c("R", "S", "I", NA)) & !all(is.na(x))) {
|
||||
@@ -235,8 +247,10 @@ is.rsi.eligible <- function(x, threshold = 0.05) {
|
||||
ab <- suppressWarnings(as.ab(cur_col, fast_mode = TRUE, info = FALSE))
|
||||
if (!is.na(ab)) {
|
||||
# this is a valid antibiotic code
|
||||
message_("Column '", font_bold(cur_col), "' is as.rsi()-eligible (despite only having empty values), since it seems to be ",
|
||||
ab_name(ab, language = NULL, tolower = TRUE), " (", ab, ")")
|
||||
message_(
|
||||
"Column '", font_bold(cur_col), "' is as.rsi()-eligible (despite only having empty values), since it seems to be ",
|
||||
ab_name(ab, language = NULL, tolower = TRUE), " (", ab, ")"
|
||||
)
|
||||
return(TRUE)
|
||||
}
|
||||
}
|
||||
@@ -272,9 +286,7 @@ as.rsi.default <- function(x, ...) {
|
||||
x[x.bak == 2] <- "I"
|
||||
x[x.bak == 3] <- "R"
|
||||
}
|
||||
|
||||
} 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
|
||||
if (all_valid_mics(x)) {
|
||||
@@ -291,12 +303,18 @@ as.rsi.default <- function(x, ...) {
|
||||
na_before <- length(x[is.na(x)])
|
||||
|
||||
# correct for translations
|
||||
trans_R <- unlist(TRANSLATIONS[which(TRANSLATIONS$pattern == "Resistant"),
|
||||
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]])
|
||||
trans_S <- unlist(TRANSLATIONS[which(TRANSLATIONS$pattern == "Susceptible"),
|
||||
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]])
|
||||
trans_I <- unlist(TRANSLATIONS[which(TRANSLATIONS$pattern %in% c("Incr. exposure", "Susceptible, incr. exp.", "Intermediate")),
|
||||
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]])
|
||||
trans_R <- unlist(TRANSLATIONS[
|
||||
which(TRANSLATIONS$pattern == "Resistant"),
|
||||
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]
|
||||
])
|
||||
trans_S <- unlist(TRANSLATIONS[
|
||||
which(TRANSLATIONS$pattern == "Susceptible"),
|
||||
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]
|
||||
])
|
||||
trans_I <- unlist(TRANSLATIONS[
|
||||
which(TRANSLATIONS$pattern %in% c("Incr. exposure", "Susceptible, incr. exp.", "Intermediate")),
|
||||
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]
|
||||
])
|
||||
x <- gsub(paste0(unique(trans_R[!is.na(trans_R)]), collapse = "|"), "R", x, ignore.case = TRUE)
|
||||
x <- gsub(paste0(unique(trans_S[!is.na(trans_S)]), collapse = "|"), "S", x, ignore.case = TRUE)
|
||||
x <- gsub(paste0(unique(trans_I[!is.na(trans_I)]), collapse = "|"), "I", x, ignore.case = TRUE)
|
||||
@@ -328,9 +346,11 @@ as.rsi.default <- function(x, ...) {
|
||||
sort() %pm>%
|
||||
vector_and(quotes = TRUE)
|
||||
warning_("in `as.rsi()`: ", na_after - na_before, " results truncated (",
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid antimicrobial interpretations: ",
|
||||
list_missing, call = FALSE)
|
||||
round(((na_after - na_before) / length(x)) * 100),
|
||||
"%) that were invalid antimicrobial interpretations: ",
|
||||
list_missing,
|
||||
call = FALSE
|
||||
)
|
||||
}
|
||||
if (any(toupper(x.bak[!is.na(x.bak)]) == "U") && message_not_thrown_before("as.rsi", "U")) {
|
||||
warning_("in `as.rsi()`: 'U' was interpreted as 'S', following some laboratory systems")
|
||||
@@ -345,7 +365,8 @@ as.rsi.default <- function(x, ...) {
|
||||
}
|
||||
|
||||
set_clean_class(factor(x, levels = c("S", "I", "R"), ordered = TRUE),
|
||||
new_class = c("rsi", "ordered", "factor"))
|
||||
new_class = c("rsi", "ordered", "factor")
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname as.rsi
|
||||
@@ -359,17 +380,19 @@ as.rsi.mic <- function(x,
|
||||
add_intrinsic_resistance = FALSE,
|
||||
reference_data = AMR::rsi_translation,
|
||||
...) {
|
||||
as_rsi_method(method_short = "mic",
|
||||
method_long = "MIC values",
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
...)
|
||||
as_rsi_method(
|
||||
method_short = "mic",
|
||||
method_long = "MIC values",
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname as.rsi
|
||||
@@ -382,17 +405,19 @@ as.rsi.disk <- function(x,
|
||||
add_intrinsic_resistance = FALSE,
|
||||
reference_data = AMR::rsi_translation,
|
||||
...) {
|
||||
as_rsi_method(method_short = "disk",
|
||||
method_long = "disk diffusion zones",
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
conserve_capped_values = FALSE,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
...)
|
||||
as_rsi_method(
|
||||
method_short = "disk",
|
||||
method_long = "disk diffusion zones",
|
||||
x = x,
|
||||
mo = mo,
|
||||
ab = ab,
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
conserve_capped_values = FALSE,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
#' @rdname as.rsi
|
||||
@@ -442,8 +467,10 @@ as.rsi.data.frame <- function(x,
|
||||
}
|
||||
} else {
|
||||
# column found, transform to logical
|
||||
stop_if(length(col_uti) != 1 | !col_uti %in% colnames(x),
|
||||
"argument `uti` must be a [logical] vector, of must be a single column name of `x`")
|
||||
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`"
|
||||
)
|
||||
uti <- as.logical(x[, col_uti, drop = TRUE])
|
||||
}
|
||||
} else {
|
||||
@@ -457,11 +484,13 @@ as.rsi.data.frame <- function(x,
|
||||
} else {
|
||||
plural <- c("", "s", "a ")
|
||||
}
|
||||
message_("Assuming value", plural[1], " ",
|
||||
vector_and(values, quotes = TRUE),
|
||||
" in column '", font_bold(col_specimen),
|
||||
"' reflect", plural[2], " ", plural[3], "urinary tract infection", plural[1],
|
||||
".\n Use `as.rsi(uti = FALSE)` to prevent this.")
|
||||
message_(
|
||||
"Assuming value", plural[1], " ",
|
||||
vector_and(values, quotes = TRUE),
|
||||
" in column '", font_bold(col_specimen),
|
||||
"' reflect", plural[2], " ", plural[3], "urinary tract infection", plural[1],
|
||||
".\n Use `as.rsi(uti = FALSE)` to prevent this."
|
||||
)
|
||||
} else {
|
||||
# no data about UTI's found
|
||||
uti <- FALSE
|
||||
@@ -501,8 +530,10 @@ as.rsi.data.frame <- function(x,
|
||||
}
|
||||
})]
|
||||
|
||||
stop_if(length(ab_cols) == 0,
|
||||
"no columns with MIC values, disk zones or antibiotic column names found in this data set. Use as.mic() or as.disk() to transform antimicrobial columns.")
|
||||
stop_if(
|
||||
length(ab_cols) == 0,
|
||||
"no columns with MIC values, disk zones or antibiotic column names found in this data set. Use as.mic() or as.disk() to transform antimicrobial columns."
|
||||
)
|
||||
# set type per column
|
||||
types <- character(length(ab_cols))
|
||||
types[vapply(FUN.VALUE = logical(1), x.bak[, ab_cols, drop = FALSE], is.disk)] <- "disk"
|
||||
@@ -522,30 +553,34 @@ as.rsi.data.frame <- function(x,
|
||||
|
||||
for (i in seq_len(length(ab_cols))) {
|
||||
if (types[i] == "mic") {
|
||||
x[, ab_cols[i]] <- as.rsi(x = x %pm>%
|
||||
pm_pull(ab_cols[i]) %pm>%
|
||||
as.character() %pm>%
|
||||
as.mic(),
|
||||
mo = x_mo,
|
||||
ab = ab_cols[i],
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
is_data.frame = TRUE)
|
||||
x[, ab_cols[i]] <- as.rsi(
|
||||
x = x %pm>%
|
||||
pm_pull(ab_cols[i]) %pm>%
|
||||
as.character() %pm>%
|
||||
as.mic(),
|
||||
mo = x_mo,
|
||||
ab = ab_cols[i],
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
is_data.frame = TRUE
|
||||
)
|
||||
} else if (types[i] == "disk") {
|
||||
x[, ab_cols[i]] <- as.rsi(x = x %pm>%
|
||||
pm_pull(ab_cols[i]) %pm>%
|
||||
as.character() %pm>%
|
||||
as.disk(),
|
||||
mo = x_mo,
|
||||
ab = ab_cols[i],
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
is_data.frame = TRUE)
|
||||
x[, ab_cols[i]] <- as.rsi(
|
||||
x = x %pm>%
|
||||
pm_pull(ab_cols[i]) %pm>%
|
||||
as.character() %pm>%
|
||||
as.disk(),
|
||||
mo = x_mo,
|
||||
ab = ab_cols[i],
|
||||
guideline = guideline,
|
||||
uti = uti,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data,
|
||||
is_data.frame = TRUE
|
||||
)
|
||||
} else if (types[i] == "rsi") {
|
||||
show_message <- FALSE
|
||||
ab <- ab_cols[i]
|
||||
@@ -554,18 +589,20 @@ as.rsi.data.frame <- function(x,
|
||||
show_message <- TRUE
|
||||
# only print message if values are not already clean
|
||||
message_("=> Cleaning values in column '", font_bold(ab), "' (",
|
||||
ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""),
|
||||
ab_name(ab_coerced, tolower = TRUE), ")... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE)
|
||||
ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""),
|
||||
ab_name(ab_coerced, tolower = TRUE), ")... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE
|
||||
)
|
||||
} else if (!is.rsi(x.bak[, ab_cols[i], drop = TRUE])) {
|
||||
show_message <- TRUE
|
||||
# only print message if class not already set
|
||||
message_("=> Assigning class <rsi> to already clean column '", font_bold(ab), "' (",
|
||||
ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""),
|
||||
ab_name(ab_coerced, tolower = TRUE), ")... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE)
|
||||
ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""),
|
||||
ab_name(ab_coerced, tolower = TRUE), ")... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE
|
||||
)
|
||||
}
|
||||
x[, ab_cols[i]] <- as.rsi.default(x = as.character(x[, ab_cols[i], drop = TRUE]))
|
||||
if (show_message == TRUE) {
|
||||
@@ -591,8 +628,10 @@ get_guideline <- function(guideline, reference_data) {
|
||||
}
|
||||
|
||||
stop_ifnot(guideline_param %in% reference_data$guideline,
|
||||
"invalid guideline: '", guideline,
|
||||
"'.\nValid guidelines are: ", vector_and(reference_data$guideline, quotes = TRUE, reverse = TRUE), call = FALSE)
|
||||
"invalid guideline: '", guideline,
|
||||
"'.\nValid guidelines are: ", vector_and(reference_data$guideline, quotes = TRUE, reverse = TRUE),
|
||||
call = FALSE
|
||||
)
|
||||
|
||||
guideline_param
|
||||
}
|
||||
@@ -623,34 +662,43 @@ as_rsi_method <- function(method_short,
|
||||
if (!is.null(cur_column_dplyr) && tryCatch(is.data.frame(get_current_data("ab", call = 0)), error = function(e) FALSE)) {
|
||||
# try to get current column, which will only be available when in across()
|
||||
ab <- tryCatch(cur_column_dplyr(),
|
||||
error = function(e) ab)
|
||||
error = function(e) ab
|
||||
)
|
||||
}
|
||||
|
||||
# for auto-determining mo
|
||||
mo_var_found <- ""
|
||||
if (is.null(mo)) {
|
||||
tryCatch({
|
||||
df <- get_current_data(arg_name = "mo", call = -3) # will return an error if not found
|
||||
mo <- NULL
|
||||
try({
|
||||
mo <- suppressMessages(search_type_in_df(df, "mo"))
|
||||
}, silent = TRUE)
|
||||
if (!is.null(df) && !is.null(mo) && is.data.frame(df)) {
|
||||
mo_var_found <- paste0(" based on column '", font_bold(mo), "'")
|
||||
mo <- df[, mo, drop = TRUE]
|
||||
tryCatch(
|
||||
{
|
||||
df <- get_current_data(arg_name = "mo", call = -3) # will return an error if not found
|
||||
mo <- NULL
|
||||
try(
|
||||
{
|
||||
mo <- suppressMessages(search_type_in_df(df, "mo"))
|
||||
},
|
||||
silent = TRUE
|
||||
)
|
||||
if (!is.null(df) && !is.null(mo) && is.data.frame(df)) {
|
||||
mo_var_found <- paste0(" based on column '", font_bold(mo), "'")
|
||||
mo <- df[, mo, drop = TRUE]
|
||||
}
|
||||
},
|
||||
error = function(e) {
|
||||
mo <- NULL
|
||||
}
|
||||
}, error = function(e) {
|
||||
mo <- NULL
|
||||
})
|
||||
)
|
||||
}
|
||||
if (is.null(mo)) {
|
||||
stop_("No information was supplied about the microorganisms (missing argument `mo` and no column of class <mo> found). See ?as.rsi.\n\n",
|
||||
"To transform certain columns with e.g. mutate(), use `data %>% mutate(across(..., as.rsi, mo = x))`, where x is your column with microorganisms.\n",
|
||||
"To tranform all ", method_long, " in a data set, use `data %>% as.rsi()` or `data %>% mutate(across(where(is.", method_short, "), as.rsi))`.", call = FALSE)
|
||||
"To transform certain columns with e.g. mutate(), use `data %>% mutate(across(..., as.rsi, mo = x))`, where x is your column with microorganisms.\n",
|
||||
"To tranform all ", method_long, " in a data set, use `data %>% as.rsi()` or `data %>% mutate(across(where(is.", method_short, "), as.rsi))`.",
|
||||
call = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
if (length(ab) == 1 && ab %like% paste0("as.", method_short)) {
|
||||
stop_('No unambiguous name was supplied about the antibiotic (argument `ab`). See ?as.rsi.', call = FALSE)
|
||||
stop_("No unambiguous name was supplied about the antibiotic (argument `ab`). See ?as.rsi.", call = FALSE)
|
||||
}
|
||||
|
||||
ab_coerced <- suppressWarnings(as.ab(ab))
|
||||
@@ -658,9 +706,10 @@ as_rsi_method <- function(method_short,
|
||||
guideline_coerced <- get_guideline(guideline, reference_data)
|
||||
if (is.na(ab_coerced)) {
|
||||
message_("Returning NAs for unknown drug: '", font_bold(ab),
|
||||
"'. Rename this column to a drug name or code, and check the output with `as.ab()`.",
|
||||
add_fn = font_red,
|
||||
as_note = FALSE)
|
||||
"'. Rename this column to a drug name or code, and check the output with `as.ab()`.",
|
||||
add_fn = font_red,
|
||||
as_note = FALSE
|
||||
)
|
||||
return(as.rsi(rep(NA, length(x))))
|
||||
}
|
||||
if (length(mo_coerced) == 1) {
|
||||
@@ -673,26 +722,35 @@ as_rsi_method <- function(method_short,
|
||||
agent_formatted <- paste0("'", font_bold(ab), "'")
|
||||
agent_name <- ab_name(ab_coerced, tolower = TRUE, language = NULL)
|
||||
if (generalise_antibiotic_name(ab) != generalise_antibiotic_name(agent_name)) {
|
||||
agent_formatted <- paste0(agent_formatted, " (", ab_coerced, ", ", agent_name, ")")
|
||||
agent_formatted <- paste0(
|
||||
agent_formatted,
|
||||
" (", ifelse(ab == ab_coerced, "",
|
||||
paste0(ab_coerced, ", ")
|
||||
), agent_name, ")"
|
||||
)
|
||||
}
|
||||
message_("=> Interpreting ", method_long, " of ", ifelse(isTRUE(list(...)$is_data.frame), "column ", ""),
|
||||
agent_formatted,
|
||||
mo_var_found,
|
||||
" according to ", ifelse(identical(reference_data, AMR::rsi_translation),
|
||||
font_bold(guideline_coerced),
|
||||
"manually defined 'reference_data'"),
|
||||
"... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE)
|
||||
result <- exec_as.rsi(method = method_short,
|
||||
x = x,
|
||||
mo = mo_coerced,
|
||||
ab = ab_coerced,
|
||||
guideline = guideline_coerced,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data) # exec_as.rsi will return message 'OK'
|
||||
agent_formatted,
|
||||
mo_var_found,
|
||||
" according to ", ifelse(identical(reference_data, AMR::rsi_translation),
|
||||
font_bold(guideline_coerced),
|
||||
"manually defined 'reference_data'"
|
||||
),
|
||||
"... ",
|
||||
appendLF = FALSE,
|
||||
as_note = FALSE
|
||||
)
|
||||
result <- exec_as.rsi(
|
||||
method = method_short,
|
||||
x = x,
|
||||
mo = mo_coerced,
|
||||
ab = ab_coerced,
|
||||
guideline = guideline_coerced,
|
||||
uti = uti,
|
||||
conserve_capped_values = conserve_capped_values,
|
||||
add_intrinsic_resistance = add_intrinsic_resistance,
|
||||
reference_data = reference_data
|
||||
) # exec_as.rsi will return message 'OK'
|
||||
result
|
||||
}
|
||||
|
||||
@@ -739,39 +797,57 @@ exec_as.rsi <- function(method,
|
||||
|
||||
guideline_coerced <- get_guideline(guideline, reference_data)
|
||||
if (guideline_coerced != guideline) {
|
||||
if (message_not_thrown_before("as.rsi", "msg1")) {
|
||||
if (message_not_thrown_before("as.rsi", "guideline")) {
|
||||
message_("Using guideline ", font_bold(guideline_coerced), " as input for `guideline`.")
|
||||
}
|
||||
}
|
||||
|
||||
new_rsi <- rep(NA_character_, length(x))
|
||||
ab_param <- ab
|
||||
|
||||
if (identical(reference_data, AMR::rsi_translation)) {
|
||||
trans <- reference_data %pm>%
|
||||
subset(guideline == guideline_coerced & method == method_param & ab == ab_param)
|
||||
if (ab_param == "AMX" && nrow(trans) == 0) {
|
||||
ab_param <- "AMP"
|
||||
if (message_not_thrown_before("as.rsi", "AMP_for_AMX")) {
|
||||
message_("(using ampicillin rules)", appendLF = FALSE, as_note = FALSE)
|
||||
}
|
||||
trans <- reference_data %pm>%
|
||||
subset(guideline == guideline_coerced & method == method_param & ab == ab_param)
|
||||
}
|
||||
} else {
|
||||
trans <- reference_data %pm>%
|
||||
subset(method == method_param & ab == ab_param)
|
||||
}
|
||||
|
||||
if (nrow(trans) == 0) {
|
||||
message_(" OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||
load_mo_failures_uncertainties_renamed(metadata_mo)
|
||||
return(set_clean_class(factor(new_rsi, levels = c("S", "I", "R"), ordered = TRUE),
|
||||
new_class = c("rsi", "ordered", "factor")
|
||||
))
|
||||
}
|
||||
|
||||
trans$lookup <- paste(trans$mo, trans$ab)
|
||||
|
||||
lookup_mo <- paste(mo, ab)
|
||||
lookup_genus <- paste(mo_genus, ab)
|
||||
lookup_family <- paste(mo_family, ab)
|
||||
lookup_order <- paste(mo_order, ab)
|
||||
lookup_becker <- paste(mo_becker, ab)
|
||||
lookup_lancefield <- paste(mo_lancefield, ab)
|
||||
lookup_other <- paste(mo_other, ab)
|
||||
lookup_mo <- paste(mo, ab_param)
|
||||
lookup_genus <- paste(mo_genus, ab_param)
|
||||
lookup_family <- paste(mo_family, ab_param)
|
||||
lookup_order <- paste(mo_order, ab_param)
|
||||
lookup_becker <- paste(mo_becker, ab_param)
|
||||
lookup_lancefield <- paste(mo_lancefield, ab_param)
|
||||
lookup_other <- paste(mo_other, ab_param)
|
||||
|
||||
any_is_intrinsic_resistant <- FALSE
|
||||
|
||||
for (i in seq_len(length(x))) {
|
||||
is_intrinsic_r <- paste(mo[i], ab) %in% INTRINSIC_R
|
||||
is_intrinsic_r <- paste(mo[i], ab_param) %in% INTRINSIC_R
|
||||
any_is_intrinsic_resistant <- any_is_intrinsic_resistant | is_intrinsic_r
|
||||
|
||||
if (isTRUE(add_intrinsic_resistance) & is_intrinsic_r) {
|
||||
if (guideline_coerced %unlike% "EUCAST") {
|
||||
if (message_not_thrown_before("as.rsi", "msg2")) {
|
||||
if (message_not_thrown_before("as.rsi", "intrinsic")) {
|
||||
warning_("in `as.rsi()`: using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.")
|
||||
}
|
||||
} else {
|
||||
@@ -782,16 +858,18 @@ exec_as.rsi <- function(method,
|
||||
|
||||
get_record <- trans %pm>%
|
||||
# no subsetting to UTI here
|
||||
subset(lookup %in% c(lookup_mo[i],
|
||||
lookup_genus[i],
|
||||
lookup_family[i],
|
||||
lookup_order[i],
|
||||
lookup_becker[i],
|
||||
lookup_lancefield[i],
|
||||
lookup_other[i]))
|
||||
subset(lookup %in% c(
|
||||
lookup_mo[i],
|
||||
lookup_genus[i],
|
||||
lookup_family[i],
|
||||
lookup_order[i],
|
||||
lookup_becker[i],
|
||||
lookup_lancefield[i],
|
||||
lookup_other[i]
|
||||
))
|
||||
|
||||
if (any(get_record$uti == TRUE, na.rm = TRUE) && !any(uti == TRUE, na.rm = TRUE) && message_not_thrown_before("as.rsi", "msg3", ab)) {
|
||||
warning_("in `as.rsi()`: interpretation of ", font_bold(ab_name(ab, tolower = TRUE)), " is only available for (uncomplicated) urinary tract infections (UTI) for some microorganisms. Use argument `uti` to set which isolates are from urine. See ?as.rsi.")
|
||||
if (any(get_record$uti == TRUE, na.rm = TRUE) && !any(uti == TRUE, na.rm = TRUE) && message_not_thrown_before("as.rsi", "uti", ab_param)) {
|
||||
warning_("in `as.rsi()`: interpretation of ", font_bold(ab_name(ab_param, tolower = TRUE)), " is only available for (uncomplicated) urinary tract infections (UTI) for some microorganisms. Use argument `uti` to set which isolates are from urine. See ?as.rsi.")
|
||||
rise_warning <- TRUE
|
||||
}
|
||||
|
||||
@@ -812,40 +890,47 @@ exec_as.rsi <- function(method,
|
||||
if (is.na(x[i]) | (is.na(get_record$breakpoint_S) & is.na(get_record$breakpoint_R))) {
|
||||
new_rsi[i] <- NA_character_
|
||||
} else if (method == "mic") {
|
||||
new_rsi[i] <- quick_case_when(isTRUE(conserve_capped_values) & isTRUE(x[i] %like% "^<[0-9]") ~ "S",
|
||||
isTRUE(conserve_capped_values) & isTRUE(x[i] %like% "^>[0-9]") ~ "R",
|
||||
# these basically call `<=.mic()` and `>=.mic()`:
|
||||
isTRUE(x[i] <= get_record$breakpoint_S) ~ "S",
|
||||
guideline_coerced %like% "EUCAST" & isTRUE(x[i] > get_record$breakpoint_R) ~ "R",
|
||||
guideline_coerced %like% "CLSI" & isTRUE(x[i] >= get_record$breakpoint_R) ~ "R",
|
||||
# return "I" when not match the bottom or top
|
||||
!is.na(get_record$breakpoint_S) & !is.na(get_record$breakpoint_R) ~ "I",
|
||||
# and NA otherwise
|
||||
TRUE ~ NA_character_)
|
||||
new_rsi[i] <- quick_case_when(
|
||||
isTRUE(conserve_capped_values) & isTRUE(x[i] %like% "^<[0-9]") ~ "S",
|
||||
isTRUE(conserve_capped_values) & isTRUE(x[i] %like% "^>[0-9]") ~ "R",
|
||||
# these basically call `<=.mic()` and `>=.mic()`:
|
||||
isTRUE(x[i] <= get_record$breakpoint_S) ~ "S",
|
||||
guideline_coerced %like% "EUCAST" & isTRUE(x[i] > get_record$breakpoint_R) ~ "R",
|
||||
guideline_coerced %like% "CLSI" & isTRUE(x[i] >= get_record$breakpoint_R) ~ "R",
|
||||
# return "I" when not match the bottom or top
|
||||
!is.na(get_record$breakpoint_S) & !is.na(get_record$breakpoint_R) ~ "I",
|
||||
# and NA otherwise
|
||||
TRUE ~ NA_character_
|
||||
)
|
||||
} else if (method == "disk") {
|
||||
new_rsi[i] <- quick_case_when(isTRUE(as.double(x[i]) >= as.double(get_record$breakpoint_S)) ~ "S",
|
||||
guideline_coerced %like% "EUCAST" & isTRUE(as.double(x[i]) < as.double(get_record$breakpoint_R)) ~ "R",
|
||||
guideline_coerced %like% "CLSI" & isTRUE(as.double(x[i]) <= as.double(get_record$breakpoint_R)) ~ "R",
|
||||
# return "I" when not match the bottom or top
|
||||
!is.na(get_record$breakpoint_S) & !is.na(get_record$breakpoint_R) ~ "I",
|
||||
# and NA otherwise
|
||||
TRUE ~ NA_character_)
|
||||
new_rsi[i] <- quick_case_when(
|
||||
isTRUE(as.double(x[i]) >= as.double(get_record$breakpoint_S)) ~ "S",
|
||||
guideline_coerced %like% "EUCAST" & isTRUE(as.double(x[i]) < as.double(get_record$breakpoint_R)) ~ "R",
|
||||
guideline_coerced %like% "CLSI" & isTRUE(as.double(x[i]) <= as.double(get_record$breakpoint_R)) ~ "R",
|
||||
# return "I" when not match the bottom or top
|
||||
!is.na(get_record$breakpoint_S) & !is.na(get_record$breakpoint_R) ~ "I",
|
||||
# and NA otherwise
|
||||
TRUE ~ NA_character_
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (any_is_intrinsic_resistant & guideline_coerced %like% "EUCAST" & !isTRUE(add_intrinsic_resistance)) {
|
||||
# found some intrinsic resistance, but was not applied
|
||||
if (message_not_thrown_before("as.rsi", "msg4")) {
|
||||
if (message_not_thrown_before("as.rsi", "unapplied_instrinsic")) {
|
||||
warning_("in `as.rsi()`: found intrinsic resistance in some bug/drug combinations, although it was not applied.\nUse `as.rsi(..., add_intrinsic_resistance = TRUE)` to apply it.")
|
||||
}
|
||||
rise_warning <- TRUE
|
||||
}
|
||||
|
||||
new_rsi <- x_bak %pm>%
|
||||
pm_left_join(data.frame(x_mo = paste0(x, mo), new_rsi,
|
||||
stringsAsFactors = FALSE),
|
||||
by = "x_mo") %pm>%
|
||||
pm_left_join(data.frame(
|
||||
x_mo = paste0(x, mo), new_rsi,
|
||||
stringsAsFactors = FALSE
|
||||
),
|
||||
by = "x_mo"
|
||||
) %pm>%
|
||||
pm_pull(new_rsi)
|
||||
|
||||
if (isTRUE(rise_warning)) {
|
||||
@@ -857,7 +942,8 @@ exec_as.rsi <- function(method,
|
||||
load_mo_failures_uncertainties_renamed(metadata_mo)
|
||||
|
||||
set_clean_class(factor(new_rsi, levels = c("S", "I", "R"), ordered = TRUE),
|
||||
new_class = c("rsi", "ordered", "factor"))
|
||||
new_class = c("rsi", "ordered", "factor")
|
||||
)
|
||||
}
|
||||
|
||||
# will be exported using s3_register() in R/zzz.R
|
||||
@@ -885,12 +971,14 @@ freq.rsi <- function(x, ...) {
|
||||
x_name <- gsub(".*[$]", "", x_name)
|
||||
if (x_name %in% c("x", ".")) {
|
||||
# try again going through system calls
|
||||
x_name <- stats::na.omit(vapply(FUN.VALUE = character(1),
|
||||
sys.calls(),
|
||||
function(call) {
|
||||
call_txt <- as.character(call)
|
||||
ifelse(call_txt[1] %like% "freq$", call_txt[length(call_txt)], character(0))
|
||||
}))[1L]
|
||||
x_name <- stats::na.omit(vapply(
|
||||
FUN.VALUE = character(1),
|
||||
sys.calls(),
|
||||
function(call) {
|
||||
call_txt <- as.character(call)
|
||||
ifelse(call_txt[1] %like% "freq$", call_txt[length(call_txt)], character(0))
|
||||
}
|
||||
))[1L]
|
||||
}
|
||||
ab <- suppressMessages(suppressWarnings(as.ab(x_name)))
|
||||
digits <- list(...)$digits
|
||||
@@ -898,17 +986,25 @@ freq.rsi <- function(x, ...) {
|
||||
digits <- 2
|
||||
}
|
||||
if (!is.na(ab)) {
|
||||
cleaner::freq.default(x = x, ...,
|
||||
.add_header = list(
|
||||
Drug = paste0(ab_name(ab, language = NULL), " (", ab, ", ", paste(ab_atc(ab), collapse = "/"), ")"),
|
||||
`Drug group` = ab_group(ab, language = NULL),
|
||||
`%SI` = trimws(percentage(susceptibility(x, minimum = 0, as_percent = FALSE),
|
||||
digits = digits))))
|
||||
cleaner::freq.default(
|
||||
x = x, ...,
|
||||
.add_header = list(
|
||||
Drug = paste0(ab_name(ab, language = NULL), " (", ab, ", ", paste(ab_atc(ab), collapse = "/"), ")"),
|
||||
`Drug group` = ab_group(ab, language = NULL),
|
||||
`%SI` = trimws(percentage(susceptibility(x, minimum = 0, as_percent = FALSE),
|
||||
digits = digits
|
||||
))
|
||||
)
|
||||
)
|
||||
} else {
|
||||
cleaner::freq.default(x = x, ...,
|
||||
.add_header = list(
|
||||
`%SI` = trimws(percentage(susceptibility(x, minimum = 0, as_percent = FALSE),
|
||||
digits = digits))))
|
||||
cleaner::freq.default(
|
||||
x = x, ...,
|
||||
.add_header = list(
|
||||
`%SI` = trimws(percentage(susceptibility(x, minimum = 0, as_percent = FALSE),
|
||||
digits = digits
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -923,9 +1019,11 @@ get_skimmers.rsi <- function(column) {
|
||||
if (any(calls_txt %like% "skim_variable", na.rm = TRUE)) {
|
||||
ind <- which(calls_txt %like% "skim_variable")[1L]
|
||||
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_)
|
||||
error = function(e) NA_character_
|
||||
)
|
||||
} else {
|
||||
NA_character_
|
||||
}
|
||||
@@ -937,9 +1035,9 @@ get_skimmers.rsi <- function(column) {
|
||||
count_R = count_R,
|
||||
count_S = count_susceptible,
|
||||
count_I = count_I,
|
||||
prop_R = ~proportion_R(., minimum = 0),
|
||||
prop_S = ~susceptibility(., minimum = 0),
|
||||
prop_I = ~proportion_I(., minimum = 0)
|
||||
prop_R = ~ proportion_R(., minimum = 0),
|
||||
prop_S = ~ susceptibility(., minimum = 0),
|
||||
prop_I = ~ proportion_I(., minimum = 0)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,9 @@ rsi_calc <- function(...,
|
||||
|
||||
data_vars <- dots2vars(...)
|
||||
|
||||
dots_df <- switch(1, ...)
|
||||
dots_df <- switch(1,
|
||||
...
|
||||
)
|
||||
if (is.data.frame(dots_df)) {
|
||||
# make sure to remove all other classes like tibbles, data.tables, etc
|
||||
dots_df <- as.data.frame(dots_df, stringsAsFactors = FALSE)
|
||||
@@ -54,8 +56,10 @@ rsi_calc <- function(...,
|
||||
stop_if(length(dots) == 0, "no variables selected", call = -2)
|
||||
|
||||
stop_if("also_single_tested" %in% names(dots),
|
||||
"`also_single_tested` was replaced by `only_all_tested`.\n",
|
||||
"Please read Details in the help page (`?proportion`) as this may have a considerable impact on your analysis.", call = -2)
|
||||
"`also_single_tested` was replaced by `only_all_tested`.\n",
|
||||
"Please read Details in the help page (`?proportion`) as this may have a considerable impact on your analysis.",
|
||||
call = -2
|
||||
)
|
||||
ndots <- length(dots)
|
||||
|
||||
if (is.data.frame(dots_df)) {
|
||||
@@ -69,14 +73,16 @@ rsi_calc <- function(...,
|
||||
dots <- dots[2:length(dots)]
|
||||
}
|
||||
if (length(dots) == 0 | all(dots == "df")) {
|
||||
# for complete data.frames, like example_isolates %pm>% select(AMC, GEN) %pm>% proportion_S()
|
||||
# for complete data.frames, like example_isolates %pm>% select(AMC, GEN) %pm>% proportion_S()
|
||||
# and the old rsi function, which has "df" as name of the first argument
|
||||
x <- dots_df
|
||||
} else {
|
||||
# get dots that are in column names already, and the ones that will be once evaluated using dots_df or global env
|
||||
# this is to support susceptibility(example_isolates, AMC, any_of(some_vector_with_AB_names))
|
||||
dots <- c(dots[dots %in% colnames(dots_df)],
|
||||
eval(parse(text = dots[!dots %in% colnames(dots_df)]), envir = dots_df, enclos = globalenv()))
|
||||
dots <- c(
|
||||
dots[dots %in% colnames(dots_df)],
|
||||
eval(parse(text = dots[!dots %in% colnames(dots_df)]), envir = dots_df, enclos = globalenv())
|
||||
)
|
||||
dots_not_exist <- dots[!dots %in% colnames(dots_df)]
|
||||
stop_if(length(dots_not_exist) > 0, "column(s) not found: ", vector_and(dots_not_exist, quotes = TRUE), call = -2)
|
||||
x <- dots_df[, dots, drop = FALSE]
|
||||
@@ -89,7 +95,7 @@ rsi_calc <- function(...,
|
||||
x <- NULL
|
||||
try(x <- as.data.frame(dots, stringsAsFactors = FALSE), silent = TRUE)
|
||||
if (is.null(x)) {
|
||||
# support for example_isolates %pm>% group_by(hospital_id) %pm>% summarise(amox = susceptibility(GEN, AMX))
|
||||
# support for example_isolates %pm>% group_by(ward) %pm>% summarise(amox = susceptibility(GEN, AMX))
|
||||
x <- as.data.frame(list(...), stringsAsFactors = FALSE)
|
||||
}
|
||||
}
|
||||
@@ -125,9 +131,11 @@ rsi_calc <- function(...,
|
||||
x_transposed <- as.list(as.data.frame(t(x), stringsAsFactors = FALSE))
|
||||
if (only_all_tested == TRUE) {
|
||||
# no NAs in any column
|
||||
y <- apply(X = as.data.frame(lapply(x, as.integer), stringsAsFactors = FALSE),
|
||||
MARGIN = 1,
|
||||
FUN = min)
|
||||
y <- apply(
|
||||
X = as.data.frame(lapply(x, as.integer), stringsAsFactors = FALSE),
|
||||
MARGIN = 1,
|
||||
FUN = min
|
||||
)
|
||||
numerator <- sum(as.integer(y) %in% as.integer(ab_result), na.rm = TRUE)
|
||||
denominator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) !(any(is.na(y)))))
|
||||
} else {
|
||||
@@ -149,9 +157,10 @@ rsi_calc <- function(...,
|
||||
if (print_warning == TRUE) {
|
||||
if (message_not_thrown_before("rsi_calc")) {
|
||||
warning_("Increase speed by transforming to class <rsi> on beforehand:\n",
|
||||
" your_data %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" your_data %>% mutate(across(where(is.rsi.eligible), as.rsi))",
|
||||
call = FALSE)
|
||||
" your_data %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||
" your_data %>% mutate(across(where(is.rsi.eligible), as.rsi))",
|
||||
call = FALSE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,10 +191,12 @@ rsi_calc <- function(...,
|
||||
}
|
||||
}
|
||||
warning_("Introducing NA: ",
|
||||
ifelse(denominator == 0, "no", paste("only", denominator)),
|
||||
" results available",
|
||||
data_vars,
|
||||
" (`minimum` = ", minimum, ").", call = FALSE)
|
||||
ifelse(denominator == 0, "no", paste("only", denominator)),
|
||||
" results available",
|
||||
data_vars,
|
||||
" (`minimum` = ", minimum, ").",
|
||||
call = FALSE
|
||||
)
|
||||
fraction <- NA_real_
|
||||
} else {
|
||||
fraction <- numerator / denominator
|
||||
@@ -226,6 +237,7 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
|
||||
|
||||
translate_ab <- get_translate_ab(translate_ab)
|
||||
|
||||
data.bak <- data
|
||||
# select only groups and antibiotics
|
||||
if (is_null_or_grouped_tbl(data)) {
|
||||
data_has_groups <- TRUE
|
||||
@@ -251,11 +263,13 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
|
||||
}
|
||||
|
||||
sum_it <- function(.data) {
|
||||
out <- data.frame(antibiotic = character(0),
|
||||
interpretation = character(0),
|
||||
value = double(0),
|
||||
isolates = integer(0),
|
||||
stringsAsFactors = FALSE)
|
||||
out <- data.frame(
|
||||
antibiotic = character(0),
|
||||
interpretation = character(0),
|
||||
value = double(0),
|
||||
isolates = integer(0),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
if (data_has_groups) {
|
||||
group_values <- unique(.data[, which(colnames(.data) %in% groups), drop = FALSE])
|
||||
rownames(group_values) <- NULL
|
||||
@@ -279,18 +293,22 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
|
||||
} else {
|
||||
col_results$value <- rep(NA_real_, NROW(col_results))
|
||||
}
|
||||
out_new <- data.frame(antibiotic = ifelse(isFALSE(translate_ab),
|
||||
colnames(.data)[i],
|
||||
ab_property(colnames(.data)[i], property = translate_ab, language = language)),
|
||||
interpretation = col_results$interpretation,
|
||||
value = col_results$value,
|
||||
isolates = col_results$isolates,
|
||||
stringsAsFactors = FALSE)
|
||||
out_new <- data.frame(
|
||||
antibiotic = ifelse(isFALSE(translate_ab),
|
||||
colnames(.data)[i],
|
||||
ab_property(colnames(.data)[i], property = translate_ab, language = language)
|
||||
),
|
||||
interpretation = col_results$interpretation,
|
||||
value = col_results$value,
|
||||
isolates = col_results$isolates,
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
if (data_has_groups) {
|
||||
if (nrow(group_values) < nrow(out_new)) {
|
||||
# repeat group_values for the number of rows in out_new
|
||||
repeated <- rep(seq_len(nrow(group_values)),
|
||||
each = nrow(out_new) / nrow(group_values))
|
||||
each = nrow(out_new) / nrow(group_values)
|
||||
)
|
||||
group_values <- group_values[repeated, , drop = FALSE]
|
||||
}
|
||||
out_new <- cbind(group_values, out_new)
|
||||
@@ -331,9 +349,9 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
|
||||
|
||||
if (data_has_groups) {
|
||||
# ordering by the groups and two more: "antibiotic" and "interpretation"
|
||||
out <- pm_ungroup(out[do.call("order", out[, seq_len(length(groups) + 2)]), ])
|
||||
out <- pm_ungroup(out[do.call("order", out[, seq_len(length(groups) + 2), drop = FALSE]), , drop = FALSE])
|
||||
} else {
|
||||
out <- out[order(out$antibiotic, out$interpretation), ]
|
||||
out <- out[order(out$antibiotic, out$interpretation), , drop = FALSE]
|
||||
}
|
||||
|
||||
if (type == "proportion") {
|
||||
@@ -344,8 +362,8 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
|
||||
}
|
||||
|
||||
rownames(out) <- NULL
|
||||
class(out) <- c("rsi_df", class(out))
|
||||
out
|
||||
out <- as_original_data_class(out, class(data.bak))
|
||||
structure(out, class = c("rsi_df", class(out)))
|
||||
}
|
||||
|
||||
get_translate_ab <- function(translate_ab) {
|
||||
@@ -357,9 +375,10 @@ get_translate_ab <- function(translate_ab) {
|
||||
} else {
|
||||
translate_ab <- tolower(translate_ab)
|
||||
stop_ifnot(translate_ab %in% colnames(AMR::antibiotics),
|
||||
"invalid value for 'translate_ab', this must be a column name of the antibiotics data set\n",
|
||||
"or TRUE (equals 'name') or FALSE to not translate at all.",
|
||||
call = FALSE)
|
||||
"invalid value for 'translate_ab', this must be a column name of the antibiotics data set\n",
|
||||
"or TRUE (equals 'name') or FALSE to not translate at all.",
|
||||
call = FALSE
|
||||
)
|
||||
translate_ab
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,14 +32,15 @@ rsi_df <- function(data,
|
||||
as_percent = FALSE,
|
||||
combine_SI = TRUE,
|
||||
combine_IR = FALSE) {
|
||||
rsi_calc_df(type = "both",
|
||||
data = data,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
combine_SI_missing = missing(combine_SI))
|
||||
|
||||
rsi_calc_df(
|
||||
type = "both",
|
||||
data = data,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
combine_SI = combine_SI,
|
||||
combine_IR = combine_IR,
|
||||
combine_SI_missing = missing(combine_SI)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ skewness.default <- function(x, na.rm = FALSE) {
|
||||
x <- x[!is.na(x)]
|
||||
}
|
||||
n <- length(x)
|
||||
(sum((x - mean(x))^3) / n) / (sum((x - mean(x)) ^ 2) / n) ^ (3 / 2)
|
||||
(sum((x - mean(x))^3) / n) / (sum((x - mean(x))^2) / n)^(3 / 2)
|
||||
}
|
||||
|
||||
#' @method skewness matrix
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
#'
|
||||
#' For language-dependent output of AMR functions, like [mo_name()], [mo_gramstain()], [mo_type()] and [ab_name()].
|
||||
#' @param x text to translate
|
||||
#' @param lang language to choose. Use one of these supported language names or ISO-639-1 codes: `r paste0('"', sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), '" ("' , LANGUAGES_SUPPORTED, '")', collapse = ", ")`.
|
||||
#' @param language language to choose. Use one of these supported language names or ISO-639-1 codes: `r paste0('"', sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), '" ("' , LANGUAGES_SUPPORTED, '")', collapse = ", ")`.
|
||||
#' @details The currently `r length(LANGUAGES_SUPPORTED)` supported languages are `r vector_and(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), quotes = FALSE, sort = FALSE)`. All these languages have translations available for all antimicrobial agents and colloquial microorganism names.
|
||||
#'
|
||||
#' Please read about adding or updating a language in [our Wiki](https://github.com/msberends/AMR/wiki/).
|
||||
#'
|
||||
#' ## Changing the Default Language
|
||||
#' The system language will be used at default (as returned by `Sys.getenv("LANG")` or, if `LANG` is not set, [Sys.getlocale("LC_COLLATE")]), if that language is supported. But the language to be used can be overwritten in two ways and will be checked in this order:
|
||||
#' The system language will be used at default (as returned by `Sys.getenv("LANG")` or, if `LANG` is not set, [`Sys.getlocale("LC_COLLATE")`][Sys.getlocale()]), if that language is supported. But the language to be used can be overwritten in two ways and will be checked in this order:
|
||||
#'
|
||||
#' 1. Setting the R option `AMR_locale`, either by using `set_AMR_locale()` or by running e.g. `options(AMR_locale = "de")`.
|
||||
#'
|
||||
@@ -84,19 +84,21 @@ get_AMR_locale <- function() {
|
||||
|
||||
lang <- find_language(lang)
|
||||
if (lang != "en" && interactive() && message_not_thrown_before("get_AMR_locale", entire_session = TRUE)) {
|
||||
message_("Assuming the ", LANGUAGES_SUPPORTED_NAMES[[lang]]$exonym, " language (",
|
||||
LANGUAGES_SUPPORTED_NAMES[[lang]]$endonym, ") for the AMR package. Change this with `set_AMR_locale()`. ",
|
||||
"This note will be shown once per session.")
|
||||
message_(
|
||||
"Assuming the ", LANGUAGES_SUPPORTED_NAMES[[lang]]$exonym, " language (",
|
||||
LANGUAGES_SUPPORTED_NAMES[[lang]]$endonym, ") for the AMR package. Change this with `set_AMR_locale()`. ",
|
||||
"This note will be shown once per session."
|
||||
)
|
||||
}
|
||||
lang
|
||||
}
|
||||
|
||||
#' @rdname translate
|
||||
#' @export
|
||||
set_AMR_locale <- function(lang) {
|
||||
lang <- validate_language(lang)
|
||||
options(AMR_locale = lang)
|
||||
message_("Using the ", LANGUAGES_SUPPORTED_NAMES[[lang]]$exonym, " language (", LANGUAGES_SUPPORTED_NAMES[[lang]]$endonym, ") for the AMR package for this session.")
|
||||
set_AMR_locale <- function(language) {
|
||||
language <- validate_language(language)
|
||||
options(AMR_locale = language)
|
||||
message_("Using the ", LANGUAGES_SUPPORTED_NAMES[[language]]$exonym, " language (", LANGUAGES_SUPPORTED_NAMES[[language]]$endonym, ") for the AMR package for this session.")
|
||||
}
|
||||
|
||||
#' @rdname translate
|
||||
@@ -111,37 +113,45 @@ translate_AMR <- function(x, language = get_AMR_locale()) {
|
||||
translate_into_language(x, language = language)
|
||||
}
|
||||
|
||||
|
||||
validate_language <- function(language, extra_txt = character(0)) {
|
||||
if (trimws(tolower(language)) %in% c("en", "english", "", "false", NA)) {
|
||||
return("en")
|
||||
}
|
||||
lang <- find_language(language, fallback = FALSE)
|
||||
stop_ifnot(length(lang) > 0 && lang %in% LANGUAGES_SUPPORTED,
|
||||
"unsupported language for AMR package", extra_txt, ": \"", language, "\". Use one of these language names or ISO-639-1 codes: ",
|
||||
paste0('"', vapply(FUN.VALUE = character(1), LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]),
|
||||
'" ("' , LANGUAGES_SUPPORTED, '")', collapse = ", "),
|
||||
call = FALSE)
|
||||
"unsupported language for AMR package", extra_txt, ": \"", language, "\". Use one of these language names or ISO-639-1 codes: ",
|
||||
paste0('"', vapply(FUN.VALUE = character(1), LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]),
|
||||
'" ("', LANGUAGES_SUPPORTED, '")',
|
||||
collapse = ", "
|
||||
),
|
||||
call = FALSE
|
||||
)
|
||||
lang
|
||||
}
|
||||
|
||||
find_language <- function(lang, fallback = TRUE) {
|
||||
lang <- Map(function(l, n, check = lang) {
|
||||
grepl(paste0("^(", l[1], "|", l[2], "|",
|
||||
n, "(_|$)|", toupper(n), "(_|$))"),
|
||||
check,
|
||||
ignore.case = FALSE,
|
||||
perl = TRUE,
|
||||
useBytes = FALSE)
|
||||
find_language <- function(language, fallback = TRUE) {
|
||||
language <- Map(function(l, n, check = language) {
|
||||
grepl(paste0(
|
||||
"^(", l[1], "|", l[2], "|",
|
||||
n, "(_|$)|", toupper(n), "(_|$))"
|
||||
),
|
||||
check,
|
||||
ignore.case = FALSE,
|
||||
perl = TRUE,
|
||||
useBytes = FALSE
|
||||
)
|
||||
},
|
||||
LANGUAGES_SUPPORTED_NAMES,
|
||||
LANGUAGES_SUPPORTED,
|
||||
USE.NAMES = TRUE)
|
||||
lang <- names(which(lang == TRUE))
|
||||
if (isTRUE(fallback) && length(lang) == 0) {
|
||||
USE.NAMES = TRUE
|
||||
)
|
||||
language <- names(which(language == TRUE))
|
||||
if (isTRUE(fallback) && length(language) == 0) {
|
||||
# other language -> set to English
|
||||
lang <- "en"
|
||||
language <- "en"
|
||||
}
|
||||
lang
|
||||
language
|
||||
}
|
||||
|
||||
# translate strings based on inst/translations.tsv
|
||||
@@ -150,7 +160,6 @@ translate_into_language <- function(from,
|
||||
only_unknown = FALSE,
|
||||
only_affect_ab_names = FALSE,
|
||||
only_affect_mo_names = FALSE) {
|
||||
|
||||
if (is.null(language)) {
|
||||
return(from)
|
||||
}
|
||||
@@ -193,19 +202,26 @@ translate_into_language <- function(from,
|
||||
error = function(e) {
|
||||
warning_("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).")
|
||||
return(FALSE)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
if (NROW(df_trans) == 0 | !any_form_in_patterns) {
|
||||
return(from)
|
||||
}
|
||||
|
||||
lapply(seq_len(nrow(df_trans)),
|
||||
function(i) from_unique_translated <<- gsub(pattern = df_trans$pattern[i],
|
||||
replacement = df_trans[i, lang, drop = TRUE],
|
||||
x = from_unique_translated,
|
||||
ignore.case = !df_trans$case_sensitive[i] & df_trans$regular_expr[i],
|
||||
fixed = !df_trans$regular_expr[i],
|
||||
perl = df_trans$regular_expr[i]))
|
||||
lapply(
|
||||
seq_len(nrow(df_trans)),
|
||||
function(i) {
|
||||
from_unique_translated <<- gsub(
|
||||
pattern = df_trans$pattern[i],
|
||||
replacement = df_trans[i, lang, drop = TRUE],
|
||||
x = from_unique_translated,
|
||||
ignore.case = !df_trans$case_sensitive[i] & df_trans$regular_expr[i],
|
||||
fixed = !df_trans$regular_expr[i],
|
||||
perl = df_trans$regular_expr[i]
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
# force UTF-8 for diacritics
|
||||
from_unique_translated <- enc2utf8(from_unique_translated)
|
||||
|
||||
@@ -26,16 +26,19 @@
|
||||
# set up package environment, used by numerous AMR functions
|
||||
pkg_env <- new.env(hash = FALSE)
|
||||
pkg_env$mo_failed <- character(0)
|
||||
pkg_env$mo_field_abbreviations <- c("AIEC", "ATEC", "BORSA", "CRSM", "DAEC", "EAEC",
|
||||
"EHEC", "EIEC", "EPEC", "ETEC", "GISA", "MRPA",
|
||||
"MRSA", "MRSE", "MSSA", "MSSE", "NMEC", "PISP",
|
||||
"PRSP", "STEC", "UPEC", "VISA", "VISP", "VRE",
|
||||
"VRSA", "VRSP")
|
||||
pkg_env$mo_field_abbreviations <- c(
|
||||
"AIEC", "ATEC", "BORSA", "CRSM", "DAEC", "EAEC",
|
||||
"EHEC", "EIEC", "EPEC", "ETEC", "GISA", "MRPA",
|
||||
"MRSA", "MRSE", "MSSA", "MSSE", "NMEC", "PISP",
|
||||
"PRSP", "STEC", "UPEC", "VISA", "VISP", "VRE",
|
||||
"VRSA", "VRSP"
|
||||
)
|
||||
|
||||
# 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)
|
||||
error = function(e) FALSE
|
||||
)
|
||||
if (utf8_supported && !is_latex) {
|
||||
# \u2139 is a symbol officially named 'information source'
|
||||
pkg_env$info_icon <- "\u2139"
|
||||
@@ -95,15 +98,22 @@ if (utf8_supported && !is_latex) {
|
||||
s3_register("vctrs::vec_cast", "integer.disk")
|
||||
|
||||
# if mo source exists, fire it up (see mo_source())
|
||||
try({
|
||||
if (file.exists(getOption("AMR_mo_source", "~/mo_source.rds"))) {
|
||||
invisible(get_mo_source())
|
||||
}
|
||||
}, silent = TRUE)
|
||||
try(
|
||||
{
|
||||
if (file.exists(getOption("AMR_mo_source", "~/mo_source.rds"))) {
|
||||
invisible(get_mo_source())
|
||||
}
|
||||
},
|
||||
silent = TRUE
|
||||
)
|
||||
|
||||
# be sure to print tibbles as tibbles
|
||||
if (pkg_is_available("tibble", also_load = FALSE)) {
|
||||
loadNamespace("tibble")
|
||||
}
|
||||
|
||||
# reference data - they have additional columns compared to `antibiotics` and `microorganisms` to improve speed
|
||||
# they cannott be part of R/sysdata.rda since CRAN thinks it would make the package too large (+3 MB)
|
||||
# they cannot be part of R/sysdata.rda since CRAN thinks it would make the package too large (+3 MB)
|
||||
assign(x = "AB_lookup", value = create_AB_lookup(), envir = asNamespace("AMR"))
|
||||
assign(x = "MO_lookup", value = create_MO_lookup(), envir = asNamespace("AMR"))
|
||||
assign(x = "MO.old_lookup", value = create_MO.old_lookup(), envir = asNamespace("AMR"))
|
||||
@@ -133,14 +143,14 @@ create_MO_lookup <- function() {
|
||||
MO_lookup$fullname_lower <- MO_FULLNAME_LOWER
|
||||
} else {
|
||||
MO_lookup$fullname_lower <- ""
|
||||
warning("MO table updated - Run: source(\"data-raw/pre-commit-hook.R\")", call. = FALSE)
|
||||
warning("MO table updated - Run: source(\"data-raw/_pre_commit_hook.R\")", call. = FALSE)
|
||||
}
|
||||
|
||||
# add a column with only "e coli" like combinations
|
||||
MO_lookup$g_species <- gsub("^([a-z])[a-z]+ ([a-z]+) ?.*", "\\1 \\2", MO_lookup$fullname_lower, perl = TRUE)
|
||||
|
||||
# so arrange data on prevalence first, then kingdom, then full name
|
||||
MO_lookup[order(MO_lookup$prevalence, MO_lookup$kingdom_index, MO_lookup$fullname_lower), ]
|
||||
MO_lookup[order(MO_lookup$prevalence, MO_lookup$kingdom_index, MO_lookup$fullname_lower), , drop = FALSE]
|
||||
}
|
||||
|
||||
create_MO.old_lookup <- function() {
|
||||
@@ -151,7 +161,7 @@ create_MO.old_lookup <- function() {
|
||||
MO.old_lookup$g_species <- trimws(gsub("^([a-z])[a-z]+ ([a-z]+) ?.*", "\\1 \\2", MO.old_lookup$fullname_lower))
|
||||
|
||||
# so arrange data on prevalence first, then full name
|
||||
MO.old_lookup[order(MO.old_lookup$prevalence, MO.old_lookup$fullname_lower), ]
|
||||
MO.old_lookup[order(MO.old_lookup$prevalence, MO.old_lookup$fullname_lower), , drop = FALSE]
|
||||
}
|
||||
|
||||
create_intr_resistance <- function() {
|
||||
|
||||
@@ -71673,7 +71673,7 @@
|
||||
"7553-1","Origanum vulgare Ab.IgG","ACnc","Pt","Ser","Qn","","ALLERGY","2.27","MIN","","ACTIVE","","1","","","","","","Y","","ABS; Aby; Allergen; Allergens; ALLERGY TESTING; Antby; Anti; Antibodies; Antibody; Arbitrary concentration; Autoantibodies; Autoantibody; f283; Immune globulin G; Immunoglobulin G; Oregano; Oreganum; Point in time; QNT; Quan; Quant; Quantitative; Random; Rf283; Serum; SR","Oregano IgG Qn","Both","","","","","Oregano IgG Ab [Units/volume] in Serum","","","","","","","0","0","0","","","","","","1.0h(2)","","Oregano IgG Qn (S)"
|
||||
"75531-4","Enrollment basis","Type","Pt","^Patient","Nom","","SURVEY.PCORNET","2.50","MIN","","ACTIVE","","4","","","","","","","","Nominal; Point in time; Random; Survey; SURVEY.PCORNET; Typ","Enrollment basis","Observation","","","","","Enrollment basis","","","","","","","0","0","0","","","","","","2.50","",""
|
||||
"75532-2","Applicable accrediting agency for unit","Type","Pt","{Nursing unit}","Nom","NMMDS","SURVEY.NMMDS","2.50","MIN","Types of accreditation that are appropriate or applicable to a unit or service. The unit may or may not have received the accreditation.","ACTIVE","","4","","","","","","","","Nominal; Nursing Management Minimum Data Set; Point in time; Random; Survey; SURVEY.NMMDS; Typ","","Observation","","","Copyright © 2006 Diane Huber and Connie Delaney. Used with permission.","","Applicable accrediting agency for unit [NMMDS]","","","","","","","0","0","0","","NMMDS","","","","2.50","",""
|
||||
"75533-0","Accreditation, certification, & licensure panel","-","Pt","{Nursing unit}","-","NMMDS","PANEL.SURVEY.NMMDS","2.52","MIN","The set of terms in this panel are used to indicate quality assurance organizations of the nursing delivery unit/service by 3 different quality measure categories: accreditation, certification and licensure. Accreditation is a seal of approval given by private, nationally recognized groups that check on the quality of care at health care facilities and organizations. Health care organizations must meet certain quality standards in order to be accredited. Certification is the formal recognition of the knowledge, skills, and experience demonstrated by the achievement of standards that are identified by the profession² (ANA, 2009). Licensure is the granting of authority to practice² (ANA, 2009). State agencies determine the requirements for licensure and examine the competency necessary to meet quality standards.","ACTIVE","","4","","","","","","","","Nursing Management Minimum Data Set; Pan; PANEL.SURVEY.NMMDS; Panl; Pnl; Point in time; Random; Survey; SURVEY.NMMDS","","","","","Copyright © 2006 Diane Huber and Connie Delaney. Used with permission.","","NMMDS accreditation, certification, and licensure panel [NMMDS]","","","","","","","0","0","0","","NMMDS","Panel","","","2.50","",""
|
||||
"75533-0","Accreditation, certification, & licensure panel","-","Pt","{Nursing unit}","-","NMMDS","PANEL.SURVEY.NMMDS","2.52","MIN","The set of terms in this panel are used to indicate quality assurance organizations of the nursing delivery unit/service by 3 different quality measure categories: accreditation, certification and licensure. Accreditation is a seal of approval given by private, nationally recognized groups that check on the quality of care at health care facilities and organizations. Health care organizations must meet certain quality standards in order to be accredited. Certification is the formal recognition of the knowledge, skills, and experience demonstrated by the achievement of standards that are identified by the profession² (ANA, 2009). Licensure is the granting of authority to practise² (ANA, 2009). State agencies determine the requirements for licensure and examine the competency necessary to meet quality standards.","ACTIVE","","4","","","","","","","","Nursing Management Minimum Data Set; Pan; PANEL.SURVEY.NMMDS; Panl; Pnl; Point in time; Random; Survey; SURVEY.NMMDS","","","","","Copyright © 2006 Diane Huber and Connie Delaney. Used with permission.","","NMMDS accreditation, certification, and licensure panel [NMMDS]","","","","","","","0","0","0","","NMMDS","Panel","","","2.50","",""
|
||||
"75534-8","Accreditation received","Type","Pt","{Nursing unit}","Nom","NMMDS","SURVEY.NMMDS","2.50","MIN","Types of accreditation obtained by a unit to demonstrate quality of care. Accreditation is a seal of approval given by private, nationally recognized groups that check on the quality of care at health care facilities and organizations. Health care organizations must meet certain quality standards in order to be accredited.","ACTIVE","","4","","","","","","","","Nominal; Nursing Management Minimum Data Set; Point in time; Random; Survey; SURVEY.NMMDS; Typ","","Observation","","","Copyright © 2006 Diane Huber and Connie Delaney. Used with permission.","","Accreditation received [NMMDS]","","","","","","","0","0","0","","NMMDS","","","","2.50","",""
|
||||
"75535-5","Certification received","Type","Pt","{Nursing unit}","Nom","NMMDS","SURVEY.NMMDS","2.50","MIN","Types of certification obtained by a unit to demonstrate quality care.","ACTIVE","","4","","","","","","","","Nominal; Nursing Management Minimum Data Set; Point in time; Random; Survey; SURVEY.NMMDS; Typ","","Observation","","","Copyright © 2006 Diane Huber and Connie Delaney. Used with permission.","","Certification received [NMMDS]","","","","","","","0","0","0","","NMMDS","","","","2.50","",""
|
||||
"75536-3","Applicable certification agency for unit","Type","Pt","{Nursing unit}","Nom","NMMDS","SURVEY.NMMDS","2.50","MIN","Types of certification that are appropriate or applicable to a unit or service. The unit may or may not have received the certification.","ACTIVE","","4","","","","","","","","Nominal; Nursing Management Minimum Data Set; Point in time; Random; Survey; SURVEY.NMMDS; Typ","","Observation","","","Copyright © 2006 Diane Huber and Connie Delaney. Used with permission.","","Applicable certification agency for unit [NMMDS]","","","","","","","0","0","0","","NMMDS","","","","2.50","",""
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -26,12 +26,15 @@
|
||||
# some old R instances have trouble installing tinytest, so we ship it too
|
||||
install.packages("data-raw/tinytest_1.3.1.tar.gz", dependencies = c("Depends", "Imports", "LinkingTo"))
|
||||
install.packages(getwd(), repos = NULL, type = "source")
|
||||
# install.packages("data-raw/AMR_latest.tar.gz", dependencies = FALSE)
|
||||
|
||||
pkg_suggests <- gsub("[^a-zA-Z0-9]+", "",
|
||||
unlist(strsplit(unlist(packageDescription("AMR",
|
||||
fields = c("Suggests", "Enhances", "LinkingTo"))),
|
||||
split = ", ?")))
|
||||
pkg_suggests <- gsub(
|
||||
"[^a-zA-Z0-9]+", "",
|
||||
unlist(strsplit(unlist(packageDescription("AMR",
|
||||
fields = c("Suggests", "Enhances", "LinkingTo")
|
||||
)),
|
||||
split = ", ?"
|
||||
))
|
||||
)
|
||||
pkg_suggests <- unname(pkg_suggests[!is.na(pkg_suggests)])
|
||||
cat("################################################\n")
|
||||
cat("Packages listed in Suggests/Enhances:", paste(pkg_suggests, collapse = ", "), "\n")
|
||||
@@ -49,22 +52,26 @@ if (length(to_install) == 0) {
|
||||
for (i in seq_len(length(to_install))) {
|
||||
cat("Installing package", to_install[i], "\n")
|
||||
tryCatch(install.packages(to_install[i],
|
||||
type = "source",
|
||||
repos = "https://cran.rstudio.com/",
|
||||
dependencies = c("Depends", "Imports", "LinkingTo"),
|
||||
quiet = FALSE),
|
||||
# message = function(m) invisible(),
|
||||
warning = function(w) message(w$message),
|
||||
error = function(e) message(e$message))
|
||||
type = "source",
|
||||
repos = "https://cran.rstudio.com/",
|
||||
dependencies = c("Depends", "Imports", "LinkingTo"),
|
||||
quiet = FALSE
|
||||
),
|
||||
# message = function(m) invisible(),
|
||||
warning = function(w) message(w$message),
|
||||
error = function(e) message(e$message)
|
||||
)
|
||||
if (.Platform$OS.type != "unix" && !to_install[i] %in% rownames(utils::installed.packages())) {
|
||||
tryCatch(install.packages(to_install[i],
|
||||
type = "binary",
|
||||
repos = "https://cran.rstudio.com/",
|
||||
dependencies = c("Depends", "Imports", "LinkingTo"),
|
||||
quiet = FALSE),
|
||||
# message = function(m) invisible(),
|
||||
warning = function(w) message(w$message),
|
||||
error = function(e) message(e$message))
|
||||
type = "binary",
|
||||
repos = "https://cran.rstudio.com/",
|
||||
dependencies = c("Depends", "Imports", "LinkingTo"),
|
||||
quiet = FALSE
|
||||
),
|
||||
# message = function(m) invisible(),
|
||||
warning = function(w) message(w$message),
|
||||
error = function(e) message(e$message)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +83,9 @@ if (length(to_update) == 0) {
|
||||
for (i in seq_len(length(to_update))) {
|
||||
cat("Updating package '", to_update[i], "' v", as.character(packageVersion(to_update[i])), "\n", sep = "")
|
||||
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))
|
||||
# message = function(m) invisible(),
|
||||
warning = function(w) message(w$message),
|
||||
error = function(e) message(e$message)
|
||||
)
|
||||
cat("Updated to '", to_update[i], "' v", as.character(packageVersion(to_update[i])), "\n", sep = "")
|
||||
}
|
||||
|
||||
@@ -28,9 +28,10 @@
|
||||
|
||||
if (!file.exists("DESCRIPTION") || !"Package: AMR" %in% readLines("DESCRIPTION")) {
|
||||
stop("Be sure to run this script in the root location of the AMR package folder.\n",
|
||||
"Working directory expected to contain the DESCRIPTION file of the AMR package.\n",
|
||||
"Current working directory: ", getwd(),
|
||||
call. = FALSE)
|
||||
"Working directory expected to contain the DESCRIPTION file of the AMR package.\n",
|
||||
"Current working directory: ", getwd(),
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
# save old global env to restore later
|
||||
@@ -41,34 +42,42 @@ load("R/sysdata.rda", envir = lang_env)
|
||||
|
||||
# replace language objects with updates
|
||||
message("Reading translation file...")
|
||||
lang_env$TRANSLATIONS <- utils::read.delim(file = "data-raw/translations.tsv",
|
||||
sep = "\t",
|
||||
stringsAsFactors = FALSE,
|
||||
header = TRUE,
|
||||
blank.lines.skip = TRUE,
|
||||
fill = TRUE,
|
||||
strip.white = TRUE,
|
||||
encoding = "UTF-8",
|
||||
fileEncoding = "UTF-8",
|
||||
na.strings = c(NA, "", NULL),
|
||||
allowEscapes = TRUE, # else "\\1" will be imported as "\\\\1"
|
||||
quote = "")
|
||||
lang_env$TRANSLATIONS <- utils::read.delim(
|
||||
file = "data-raw/translations.tsv",
|
||||
sep = "\t",
|
||||
stringsAsFactors = FALSE,
|
||||
header = TRUE,
|
||||
blank.lines.skip = TRUE,
|
||||
fill = TRUE,
|
||||
strip.white = TRUE,
|
||||
encoding = "UTF-8",
|
||||
fileEncoding = "UTF-8",
|
||||
na.strings = c(NA, "", NULL),
|
||||
allowEscapes = TRUE, # else "\\1" will be imported as "\\\\1"
|
||||
quote = ""
|
||||
)
|
||||
|
||||
lang_env$LANGUAGES_SUPPORTED_NAMES <- c(list(en = list(exonym = "English", endonym = "English")),
|
||||
lapply(lang_env$TRANSLATIONS[, which(nchar(colnames(lang_env$TRANSLATIONS)) == 2)],
|
||||
function(x) list(exonym = x[1], endonym = x[2])))
|
||||
lang_env$LANGUAGES_SUPPORTED_NAMES <- c(
|
||||
list(en = list(exonym = "English", endonym = "English")),
|
||||
lapply(
|
||||
lang_env$TRANSLATIONS[, which(nchar(colnames(lang_env$TRANSLATIONS)) == 2), drop = FALSE],
|
||||
function(x) list(exonym = x[1], endonym = x[2])
|
||||
)
|
||||
)
|
||||
|
||||
lang_env$LANGUAGES_SUPPORTED <- names(lang_env$LANGUAGES_SUPPORTED_NAMES)
|
||||
|
||||
# save env to internal package data
|
||||
# usethis::use_data() does not allow to save a list :(
|
||||
message("Saving to internal data...")
|
||||
save(list = names(lang_env),
|
||||
file = "R/sysdata.rda",
|
||||
ascii = FALSE,
|
||||
version = 2,
|
||||
compress = "xz",
|
||||
envir = lang_env)
|
||||
save(
|
||||
list = names(lang_env),
|
||||
file = "R/sysdata.rda",
|
||||
ascii = FALSE,
|
||||
version = 2,
|
||||
compress = "xz",
|
||||
envir = lang_env
|
||||
)
|
||||
|
||||
rm(lang_env)
|
||||
|
||||
|
||||
@@ -0,0 +1,502 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Data Analysis for R #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2022 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/ #
|
||||
# ==================================================================== #
|
||||
|
||||
# Run this file to update the package using:
|
||||
# source("data-raw/_pre_commit_hook.R")
|
||||
|
||||
library(dplyr, warn.conflicts = FALSE)
|
||||
devtools::load_all(quiet = TRUE)
|
||||
|
||||
suppressMessages(set_AMR_locale("en"))
|
||||
|
||||
old_globalenv <- ls(envir = globalenv())
|
||||
|
||||
# Save internal data to R/sysdata.rda -------------------------------------
|
||||
|
||||
# See 'data-raw/eucast_rules.tsv' for the EUCAST reference file
|
||||
EUCAST_RULES_DF <- utils::read.delim(
|
||||
file = "data-raw/eucast_rules.tsv",
|
||||
skip = 10,
|
||||
sep = "\t",
|
||||
stringsAsFactors = FALSE,
|
||||
header = TRUE,
|
||||
strip.white = TRUE,
|
||||
na = c(NA, "", NULL)
|
||||
) %>%
|
||||
# take the order of the reference.rule_group column in the original data file
|
||||
mutate(
|
||||
reference.rule_group = factor(reference.rule_group,
|
||||
levels = unique(reference.rule_group),
|
||||
ordered = TRUE
|
||||
),
|
||||
sorting_rule = ifelse(grepl("^Table", reference.rule, ignore.case = TRUE), 1, 2)
|
||||
) %>%
|
||||
arrange(
|
||||
reference.rule_group,
|
||||
reference.version,
|
||||
sorting_rule,
|
||||
reference.rule
|
||||
) %>%
|
||||
mutate(reference.rule_group = as.character(reference.rule_group)) %>%
|
||||
select(-sorting_rule)
|
||||
|
||||
TRANSLATIONS <- utils::read.delim(
|
||||
file = "data-raw/translations.tsv",
|
||||
sep = "\t",
|
||||
stringsAsFactors = FALSE,
|
||||
header = TRUE,
|
||||
blank.lines.skip = TRUE,
|
||||
fill = TRUE,
|
||||
strip.white = TRUE,
|
||||
encoding = "UTF-8",
|
||||
fileEncoding = "UTF-8",
|
||||
na.strings = c(NA, "", NULL),
|
||||
allowEscapes = TRUE, # else "\\1" will be imported as "\\\\1"
|
||||
quote = ""
|
||||
)
|
||||
|
||||
LANGUAGES_SUPPORTED_NAMES <- c(
|
||||
list(en = list(exonym = "English", endonym = "English")),
|
||||
lapply(
|
||||
TRANSLATIONS[, which(nchar(colnames(TRANSLATIONS)) == 2), drop = FALSE],
|
||||
function(x) list(exonym = x[1], endonym = x[2])
|
||||
)
|
||||
)
|
||||
|
||||
LANGUAGES_SUPPORTED <- names(LANGUAGES_SUPPORTED_NAMES)
|
||||
|
||||
# vectors of CoNS and CoPS, improves speed in as.mo()
|
||||
create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
|
||||
# Determination of which staphylococcal species are CoNS/CoPS according to:
|
||||
# - Becker et al. 2014, PMID 25278577
|
||||
# - Becker et al. 2019, PMID 30872103
|
||||
# - Becker et al. 2020, PMID 32056452
|
||||
# this function returns class <mo>
|
||||
MO_staph <- AMR::microorganisms
|
||||
MO_staph <- MO_staph[which(MO_staph$genus == "Staphylococcus"), , drop = FALSE]
|
||||
if (type == "CoNS") {
|
||||
MO_staph[which(MO_staph$species %in% c(
|
||||
"coagulase-negative", "argensis", "arlettae",
|
||||
"auricularis", "borealis", "caeli", "capitis", "caprae",
|
||||
"carnosus", "casei", "chromogenes", "cohnii", "condimenti",
|
||||
"croceilyticus",
|
||||
"debuckii", "devriesei", "edaphicus", "epidermidis",
|
||||
"equorum", "felis", "fleurettii", "gallinarum",
|
||||
"haemolyticus", "hominis", "jettensis", "kloosii",
|
||||
"lentus", "lugdunensis", "massiliensis", "microti",
|
||||
"muscae", "nepalensis", "pasteuri", "petrasii",
|
||||
"pettenkoferi", "piscifermentans", "pragensis", "pseudoxylosus",
|
||||
"pulvereri", "rostri", "saccharolyticus", "saprophyticus",
|
||||
"sciuri", "simulans", "stepanovicii", "succinus",
|
||||
"ureilyticus",
|
||||
"vitulinus", "vitulus", "warneri", "xylosus",
|
||||
"caledonicus", "canis",
|
||||
"durrellii", "lloydii"
|
||||
) |
|
||||
(MO_staph$species == "schleiferi" & MO_staph$subspecies %in% c("schleiferi", ""))),
|
||||
"mo",
|
||||
drop = TRUE
|
||||
]
|
||||
} else if (type == "CoPS") {
|
||||
MO_staph[which(MO_staph$species %in% c(
|
||||
"coagulase-positive", "coagulans",
|
||||
"agnetis", "argenteus",
|
||||
"cornubiensis",
|
||||
"delphini", "lutrae",
|
||||
"hyicus", "intermedius",
|
||||
"pseudintermedius", "pseudointermedius",
|
||||
"schweitzeri", "simiae",
|
||||
"roterodami"
|
||||
) |
|
||||
(MO_staph$species == "schleiferi" & MO_staph$subspecies == "coagulans")),
|
||||
"mo",
|
||||
drop = TRUE
|
||||
]
|
||||
}
|
||||
}
|
||||
create_MO_fullname_lower <- function() {
|
||||
MO_lookup <- AMR::microorganisms
|
||||
# use this paste instead of `fullname` to work with Viridans Group Streptococci, etc.
|
||||
MO_lookup$fullname_lower <- tolower(trimws(paste(
|
||||
MO_lookup$genus,
|
||||
MO_lookup$species,
|
||||
MO_lookup$subspecies
|
||||
)))
|
||||
ind <- MO_lookup$genus == "" | grepl("^[(]unknown ", MO_lookup$fullname, perl = TRUE)
|
||||
MO_lookup[ind, "fullname_lower"] <- tolower(MO_lookup[ind, "fullname", drop = TRUE])
|
||||
MO_lookup$fullname_lower <- trimws(gsub("[^.a-z0-9/ \\-]+", "", MO_lookup$fullname_lower, perl = TRUE))
|
||||
MO_lookup$fullname_lower
|
||||
}
|
||||
MO_CONS <- create_species_cons_cops("CoNS")
|
||||
MO_COPS <- create_species_cons_cops("CoPS")
|
||||
MO_STREP_ABCG <- as.mo(MO_lookup[which(MO_lookup$genus == "Streptococcus"), "mo", drop = TRUE], Lancefield = TRUE) %in% c("B_STRPT_GRPA", "B_STRPT_GRPB", "B_STRPT_GRPC", "B_STRPT_GRPG")
|
||||
MO_FULLNAME_LOWER <- create_MO_fullname_lower()
|
||||
MO_PREVALENT_GENERA <- c(
|
||||
"Absidia", "Acholeplasma", "Acremonium", "Actinotignum", "Aedes", "Alistipes", "Alloprevotella",
|
||||
"Alternaria", "Anaerosalibacter", "Ancylostoma", "Angiostrongylus", "Anisakis", "Anopheles",
|
||||
"Apophysomyces", "Arachnia", "Aspergillus", "Aureobasidium", "Bacteroides", "Basidiobolus",
|
||||
"Beauveria", "Bergeyella", "Blastocystis", "Blastomyces", "Borrelia", "Brachyspira", "Branhamella",
|
||||
"Butyricimonas", "Candida", "Capillaria", "Capnocytophaga", "Catabacter", "Cetobacterium", "Chaetomium",
|
||||
"Chlamydia", "Chlamydophila", "Chryseobacterium", "Chrysonilia", "Cladophialophora", "Cladosporium",
|
||||
"Conidiobolus", "Contracaecum", "Cordylobia", "Cryptococcus", "Curvularia", "Deinococcus", "Demodex",
|
||||
"Dermatobia", "Diphyllobothrium", "Dirofilaria", "Dysgonomonas", "Echinostoma", "Elizabethkingia",
|
||||
"Empedobacter", "Enterobius", "Exophiala", "Exserohilum", "Fasciola", "Flavobacterium", "Fonsecaea",
|
||||
"Fusarium", "Fusobacterium", "Giardia", "Haloarcula", "Halobacterium", "Halococcus", "Hendersonula",
|
||||
"Heterophyes", "Histoplasma", "Hymenolepis", "Hypomyces", "Hysterothylacium", "Lelliottia",
|
||||
"Leptosphaeria", "Leptotrichia", "Lucilia", "Lumbricus", "Malassezia", "Malbranchea", "Metagonimus",
|
||||
"Microsporum", "Mortierella", "Mucor", "Mycocentrospora", "Mycoplasma", "Myroides", "Necator",
|
||||
"Nectria", "Ochroconis", "Odoribacter", "Oesophagostomum", "Oidiodendron", "Opisthorchis",
|
||||
"Ornithobacterium", "Parabacteroides", "Pediculus", "Pedobacter", "Phlebotomus", "Phocaeicola",
|
||||
"Phocanema", "Phoma", "Piedraia", "Pithomyces", "Pityrosporum", "Porphyromonas", "Prevotella",
|
||||
"Pseudallescheria", "Pseudoterranova", "Pulex", "Rhizomucor", "Rhizopus", "Rhodotorula", "Riemerella",
|
||||
"Saccharomyces", "Sarcoptes", "Scolecobasidium", "Scopulariopsis", "Scytalidium", "Sphingobacterium",
|
||||
"Spirometra", "Spiroplasma", "Sporobolomyces", "Stachybotrys", "Streptobacillus", "Strongyloides",
|
||||
"Syngamus", "Taenia", "Tannerella", "Tenacibaculum", "Terrimonas", "Toxocara", "Treponema", "Trichinella",
|
||||
"Trichobilharzia", "Trichoderma", "Trichomonas", "Trichophyton", "Trichosporon", "Trichostrongylus",
|
||||
"Trichuris", "Tritirachium", "Trombicula", "Tunga", "Ureaplasma", "Victivallis", "Wautersiella",
|
||||
"Weeksella", "Wuchereria"
|
||||
)
|
||||
|
||||
# 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")
|
||||
AB_AMINOGLYCOSIDES <- antibiotics %>%
|
||||
filter(group %like% "aminoglycoside") %>%
|
||||
pull(ab)
|
||||
AB_AMINOPENICILLINS <- as.ab(c("AMP", "AMX"))
|
||||
AB_ANTIFUNGALS <- AB_lookup %>%
|
||||
filter(group %like% "antifungal") %>%
|
||||
pull(ab)
|
||||
AB_ANTIMYCOBACTERIALS <- AB_lookup %>%
|
||||
filter(group %like% "antimycobacterial") %>%
|
||||
pull(ab)
|
||||
AB_CARBAPENEMS <- antibiotics %>%
|
||||
filter(group %like% "carbapenem") %>%
|
||||
pull(ab)
|
||||
AB_CEPHALOSPORINS <- antibiotics %>%
|
||||
filter(group %like% "cephalosporin") %>%
|
||||
pull(ab)
|
||||
AB_CEPHALOSPORINS_1ST <- antibiotics %>%
|
||||
filter(group %like% "cephalosporin.*1") %>%
|
||||
pull(ab)
|
||||
AB_CEPHALOSPORINS_2ND <- antibiotics %>%
|
||||
filter(group %like% "cephalosporin.*2") %>%
|
||||
pull(ab)
|
||||
AB_CEPHALOSPORINS_3RD <- antibiotics %>%
|
||||
filter(group %like% "cephalosporin.*3") %>%
|
||||
pull(ab)
|
||||
AB_CEPHALOSPORINS_4TH <- antibiotics %>%
|
||||
filter(group %like% "cephalosporin.*4") %>%
|
||||
pull(ab)
|
||||
AB_CEPHALOSPORINS_5TH <- antibiotics %>%
|
||||
filter(group %like% "cephalosporin.*5") %>%
|
||||
pull(ab)
|
||||
AB_CEPHALOSPORINS_EXCEPT_CAZ <- AB_CEPHALOSPORINS[AB_CEPHALOSPORINS != "CAZ"]
|
||||
AB_FLUOROQUINOLONES <- antibiotics %>%
|
||||
filter(atc_group2 %like% "fluoroquinolone" | (group %like% "quinolone" & is.na(atc_group2))) %>%
|
||||
pull(ab)
|
||||
AB_GLYCOPEPTIDES <- antibiotics %>%
|
||||
filter(group %like% "glycopeptide") %>%
|
||||
pull(ab)
|
||||
AB_LIPOGLYCOPEPTIDES <- as.ab(c("DAL", "ORI", "TLV")) # dalba/orita/tela
|
||||
AB_GLYCOPEPTIDES_EXCEPT_LIPO <- AB_GLYCOPEPTIDES[!AB_GLYCOPEPTIDES %in% AB_LIPOGLYCOPEPTIDES]
|
||||
AB_LINCOSAMIDES <- antibiotics %>%
|
||||
filter(atc_group2 %like% "lincosamide" | (group %like% "lincosamide" & is.na(atc_group2))) %>%
|
||||
pull(ab)
|
||||
AB_MACROLIDES <- antibiotics %>%
|
||||
filter(atc_group2 %like% "macrolide" | (group %like% "macrolide" & is.na(atc_group2))) %>%
|
||||
pull(ab)
|
||||
AB_OXAZOLIDINONES <- antibiotics %>%
|
||||
filter(group %like% "oxazolidinone") %>%
|
||||
pull(ab)
|
||||
AB_PENICILLINS <- antibiotics %>%
|
||||
filter(group %like% "penicillin") %>%
|
||||
pull(ab)
|
||||
AB_POLYMYXINS <- antibiotics %>%
|
||||
filter(group %like% "polymyxin") %>%
|
||||
pull(ab)
|
||||
AB_QUINOLONES <- antibiotics %>%
|
||||
filter(group %like% "quinolone") %>%
|
||||
pull(ab)
|
||||
AB_STREPTOGRAMINS <- antibiotics %>%
|
||||
filter(atc_group2 %like% "streptogramin") %>%
|
||||
pull(ab)
|
||||
AB_TETRACYCLINES <- antibiotics %>%
|
||||
filter(group %like% "tetracycline") %>%
|
||||
pull(ab)
|
||||
AB_TETRACYCLINES_EXCEPT_TGC <- AB_TETRACYCLINES[AB_TETRACYCLINES != "TGC"]
|
||||
AB_TRIMETHOPRIMS <- antibiotics %>%
|
||||
filter(group %like% "trimethoprim") %>%
|
||||
pull(ab)
|
||||
AB_UREIDOPENICILLINS <- as.ab(c("PIP", "TZP", "AZL", "MEZ"))
|
||||
AB_BETALACTAMS <- c(AB_PENICILLINS, AB_CEPHALOSPORINS, AB_CARBAPENEMS)
|
||||
# this will be used for documentation:
|
||||
DEFINED_AB_GROUPS <- ls(envir = globalenv())
|
||||
DEFINED_AB_GROUPS <- DEFINED_AB_GROUPS[!DEFINED_AB_GROUPS %in% globalenv_before_ab]
|
||||
create_AB_lookup <- function() {
|
||||
AB_lookup <- AMR::antibiotics
|
||||
AB_lookup$generalised_name <- generalise_antibiotic_name(AB_lookup$name)
|
||||
AB_lookup$generalised_synonyms <- lapply(AB_lookup$synonyms, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_abbreviations <- lapply(AB_lookup$abbreviations, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_loinc <- lapply(AB_lookup$loinc, generalise_antibiotic_name)
|
||||
AB_lookup$generalised_all <- unname(lapply(
|
||||
as.list(as.data.frame(t(AB_lookup[,
|
||||
c(
|
||||
"ab", "atc", "cid", "name",
|
||||
colnames(AB_lookup)[colnames(AB_lookup) %like% "generalised"]
|
||||
),
|
||||
drop = FALSE
|
||||
]),
|
||||
stringsAsFactors = FALSE
|
||||
)),
|
||||
function(x) {
|
||||
x <- generalise_antibiotic_name(unname(unlist(x)))
|
||||
x[x != ""]
|
||||
}
|
||||
))
|
||||
AB_lookup[, colnames(AB_lookup)[colnames(AB_lookup) %like% "^generalised"]]
|
||||
}
|
||||
AB_LOOKUP <- create_AB_lookup()
|
||||
|
||||
# Export to package as internal data ----
|
||||
usethis::ui_info(paste0("Saving {usethis::ui_value('sysdata.rda')} to {usethis::ui_value('R/')}"))
|
||||
suppressMessages(usethis::use_data(EUCAST_RULES_DF,
|
||||
TRANSLATIONS,
|
||||
LANGUAGES_SUPPORTED_NAMES,
|
||||
LANGUAGES_SUPPORTED,
|
||||
MO_CONS,
|
||||
MO_COPS,
|
||||
MO_STREP_ABCG,
|
||||
MO_FULLNAME_LOWER,
|
||||
MO_PREVALENT_GENERA,
|
||||
AB_LOOKUP,
|
||||
AB_AMINOGLYCOSIDES,
|
||||
AB_AMINOPENICILLINS,
|
||||
AB_ANTIFUNGALS,
|
||||
AB_ANTIMYCOBACTERIALS,
|
||||
AB_CARBAPENEMS,
|
||||
AB_CEPHALOSPORINS,
|
||||
AB_CEPHALOSPORINS_1ST,
|
||||
AB_CEPHALOSPORINS_2ND,
|
||||
AB_CEPHALOSPORINS_3RD,
|
||||
AB_CEPHALOSPORINS_4TH,
|
||||
AB_CEPHALOSPORINS_5TH,
|
||||
AB_CEPHALOSPORINS_EXCEPT_CAZ,
|
||||
AB_FLUOROQUINOLONES,
|
||||
AB_LIPOGLYCOPEPTIDES,
|
||||
AB_GLYCOPEPTIDES,
|
||||
AB_GLYCOPEPTIDES_EXCEPT_LIPO,
|
||||
AB_LINCOSAMIDES,
|
||||
AB_MACROLIDES,
|
||||
AB_OXAZOLIDINONES,
|
||||
AB_PENICILLINS,
|
||||
AB_POLYMYXINS,
|
||||
AB_QUINOLONES,
|
||||
AB_STREPTOGRAMINS,
|
||||
AB_TETRACYCLINES,
|
||||
AB_TETRACYCLINES_EXCEPT_TGC,
|
||||
AB_TRIMETHOPRIMS,
|
||||
AB_UREIDOPENICILLINS,
|
||||
AB_BETALACTAMS,
|
||||
DEFINED_AB_GROUPS,
|
||||
internal = TRUE,
|
||||
overwrite = TRUE,
|
||||
version = 2,
|
||||
compress = "xz"
|
||||
))
|
||||
|
||||
# Export data sets to the repository in different formats -----------------
|
||||
|
||||
for (pkg in c("haven", "openxlsx", "arrow")) {
|
||||
if (!pkg %in% rownames(utils::installed.packages())) {
|
||||
message("NOTE: package '", pkg, "' not installed! Ignoring export where this package is required.")
|
||||
}
|
||||
}
|
||||
if ("digest" %in% rownames(utils::installed.packages())) {
|
||||
md5 <- function(object) digest::digest(object, "md5")
|
||||
} else {
|
||||
# will write all files anyway, since MD5 hash cannot be determined
|
||||
md5 <- function(object) "unknown-md5-hash"
|
||||
}
|
||||
|
||||
write_md5 <- function(object) {
|
||||
conn <- file(paste0("data-raw/", deparse(substitute(object)), ".md5"))
|
||||
writeLines(md5(object), conn)
|
||||
close(conn)
|
||||
}
|
||||
changed_md5 <- function(object) {
|
||||
tryCatch(
|
||||
{
|
||||
conn <- file(paste0("data-raw/", deparse(substitute(object)), ".md5"))
|
||||
compared <- md5(object) != readLines(con = conn)
|
||||
close(conn)
|
||||
compared
|
||||
},
|
||||
error = function(e) TRUE
|
||||
)
|
||||
}
|
||||
|
||||
# give official names to ABs and MOs
|
||||
rsi <- rsi_translation %>%
|
||||
mutate(mo_name = mo_name(mo, language = NULL), .after = mo) %>%
|
||||
mutate(ab_name = ab_name(ab, language = NULL), .after = ab)
|
||||
if (changed_md5(rsi)) {
|
||||
usethis::ui_info(paste0("Saving {usethis::ui_value('rsi_translation')} to {usethis::ui_value('data-raw/')}"))
|
||||
write_md5(rsi)
|
||||
try(saveRDS(rsi, "data-raw/rsi_translation.rds", version = 2, compress = "xz"), silent = TRUE)
|
||||
try(write.table(rsi, "data-raw/rsi_translation.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
|
||||
try(haven::write_sas(rsi, "data-raw/rsi_translation.sas"), silent = TRUE)
|
||||
try(haven::write_sav(rsi, "data-raw/rsi_translation.sav"), silent = TRUE)
|
||||
try(haven::write_dta(rsi, "data-raw/rsi_translation.dta"), silent = TRUE)
|
||||
try(openxlsx::write.xlsx(rsi, "data-raw/rsi_translation.xlsx"), silent = TRUE)
|
||||
try(arrow::write_feather(rsi, "data-raw/rsi_translation.feather"), silent = TRUE)
|
||||
try(arrow::write_parquet(rsi, "data-raw/rsi_translation.parquet"), silent = TRUE)
|
||||
}
|
||||
|
||||
if (changed_md5(microorganisms)) {
|
||||
usethis::ui_info(paste0("Saving {usethis::ui_value('microorganisms')} to {usethis::ui_value('data-raw/')}"))
|
||||
write_md5(microorganisms)
|
||||
try(saveRDS(microorganisms, "data-raw/microorganisms.rds", version = 2, compress = "xz"), silent = TRUE)
|
||||
try(write.table(mo, "data-raw/microorganisms.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
|
||||
max_50_snomed <- sapply(microorganisms$snomed, function(x) paste(x[seq_len(min(50, length(x), na.rm = TRUE))], collapse = " "))
|
||||
mo <- microorganisms
|
||||
mo$snomed <- max_50_snomed
|
||||
mo <- dplyr::mutate_if(mo, ~ !is.numeric(.), as.character)
|
||||
try(haven::write_sas(mo, "data-raw/microorganisms.sas"), silent = TRUE)
|
||||
try(haven::write_sav(mo, "data-raw/microorganisms.sav"), silent = TRUE)
|
||||
try(haven::write_dta(mo, "data-raw/microorganisms.dta"), silent = TRUE)
|
||||
try(openxlsx::write.xlsx(mo, "data-raw/microorganisms.xlsx"), silent = TRUE)
|
||||
try(arrow::write_feather(microorganisms, "data-raw/microorganisms.feather"), silent = TRUE)
|
||||
try(arrow::write_parquet(microorganisms, "data-raw/microorganisms.parquet"), silent = TRUE)
|
||||
}
|
||||
|
||||
if (changed_md5(microorganisms.old)) {
|
||||
usethis::ui_info(paste0("Saving {usethis::ui_value('microorganisms.old')} to {usethis::ui_value('data-raw/')}"))
|
||||
write_md5(microorganisms.old)
|
||||
try(saveRDS(microorganisms.old, "data-raw/microorganisms.old.rds", version = 2, compress = "xz"), silent = TRUE)
|
||||
try(write.table(microorganisms.old, "data-raw/microorganisms.old.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
|
||||
try(haven::write_sas(microorganisms.old, "data-raw/microorganisms.old.sas"), silent = TRUE)
|
||||
try(haven::write_sav(microorganisms.old, "data-raw/microorganisms.old.sav"), silent = TRUE)
|
||||
try(haven::write_dta(microorganisms.old, "data-raw/microorganisms.old.dta"), silent = TRUE)
|
||||
try(openxlsx::write.xlsx(microorganisms.old, "data-raw/microorganisms.old.xlsx"), silent = TRUE)
|
||||
try(arrow::write_feather(microorganisms.old, "data-raw/microorganisms.old.feather"), silent = TRUE)
|
||||
try(arrow::write_parquet(microorganisms.old, "data-raw/microorganisms.old.parquet"), silent = TRUE)
|
||||
}
|
||||
|
||||
ab <- dplyr::mutate_if(antibiotics, ~ !is.numeric(.), as.character)
|
||||
if (changed_md5(ab)) {
|
||||
usethis::ui_info(paste0("Saving {usethis::ui_value('antibiotics')} to {usethis::ui_value('data-raw/')}"))
|
||||
write_md5(ab)
|
||||
try(saveRDS(antibiotics, "data-raw/antibiotics.rds", version = 2, compress = "xz"), silent = TRUE)
|
||||
try(write.table(antibiotics, "data-raw/antibiotics.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
|
||||
try(haven::write_sas(ab, "data-raw/antibiotics.sas"), silent = TRUE)
|
||||
try(haven::write_sav(ab, "data-raw/antibiotics.sav"), silent = TRUE)
|
||||
try(haven::write_dta(ab, "data-raw/antibiotics.dta"), silent = TRUE)
|
||||
try(openxlsx::write.xlsx(ab, "data-raw/antibiotics.xlsx"), silent = TRUE)
|
||||
try(arrow::write_feather(antibiotics, "data-raw/antibiotics.feather"), silent = TRUE)
|
||||
try(arrow::write_parquet(antibiotics, "data-raw/antibiotics.parquet"), silent = TRUE)
|
||||
}
|
||||
|
||||
av <- dplyr::mutate_if(antivirals, ~ !is.numeric(.), as.character)
|
||||
if (changed_md5(av)) {
|
||||
usethis::ui_info(paste0("Saving {usethis::ui_value('antivirals')} to {usethis::ui_value('data-raw/')}"))
|
||||
write_md5(av)
|
||||
try(saveRDS(antivirals, "data-raw/antivirals.rds", version = 2, compress = "xz"), silent = TRUE)
|
||||
try(write.table(av, "data-raw/antivirals.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
|
||||
try(haven::write_sas(av, "data-raw/antivirals.sas"), silent = TRUE)
|
||||
try(haven::write_sav(av, "data-raw/antivirals.sav"), silent = TRUE)
|
||||
try(haven::write_dta(av, "data-raw/antivirals.dta"), silent = TRUE)
|
||||
try(openxlsx::write.xlsx(av, "data-raw/antivirals.xlsx"), silent = TRUE)
|
||||
try(arrow::write_feather(antivirals, "data-raw/antivirals.feather"), silent = TRUE)
|
||||
try(arrow::write_parquet(antivirals, "data-raw/antivirals.parquet"), silent = TRUE)
|
||||
}
|
||||
|
||||
# give official names to ABs and MOs
|
||||
intrinsicR <- data.frame(
|
||||
microorganism = mo_name(intrinsic_resistant$mo, language = NULL),
|
||||
antibiotic = ab_name(intrinsic_resistant$ab, language = NULL),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
if (changed_md5(intrinsicR)) {
|
||||
usethis::ui_info(paste0("Saving {usethis::ui_value('intrinsic_resistant')} to {usethis::ui_value('data-raw/')}"))
|
||||
write_md5(intrinsicR)
|
||||
try(saveRDS(intrinsicR, "data-raw/intrinsic_resistant.rds", version = 2, compress = "xz"), silent = TRUE)
|
||||
try(write.table(intrinsicR, "data-raw/intrinsic_resistant.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
|
||||
try(haven::write_sas(intrinsicR, "data-raw/intrinsic_resistant.sas"), silent = TRUE)
|
||||
try(haven::write_sav(intrinsicR, "data-raw/intrinsic_resistant.sav"), silent = TRUE)
|
||||
try(haven::write_dta(intrinsicR, "data-raw/intrinsic_resistant.dta"), silent = TRUE)
|
||||
try(openxlsx::write.xlsx(intrinsicR, "data-raw/intrinsic_resistant.xlsx"), silent = TRUE)
|
||||
try(arrow::write_feather(intrinsicR, "data-raw/intrinsic_resistant.feather"), silent = TRUE)
|
||||
try(arrow::write_parquet(intrinsicR, "data-raw/intrinsic_resistant.parquet"), silent = TRUE)
|
||||
}
|
||||
|
||||
if (changed_md5(dosage)) {
|
||||
usethis::ui_info(paste0("Saving {usethis::ui_value('dosage')} to {usethis::ui_value('data-raw/')}"))
|
||||
write_md5(dosage)
|
||||
try(saveRDS(dosage, "data-raw/dosage.rds", version = 2, compress = "xz"), silent = TRUE)
|
||||
try(write.table(dosage, "data-raw/dosage.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
|
||||
try(haven::write_sas(dosage, "data-raw/dosage.sas"), silent = TRUE)
|
||||
try(haven::write_sav(dosage, "data-raw/dosage.sav"), silent = TRUE)
|
||||
try(haven::write_dta(dosage, "data-raw/dosage.dta"), silent = TRUE)
|
||||
try(openxlsx::write.xlsx(dosage, "data-raw/dosage.xlsx"), silent = TRUE)
|
||||
try(arrow::write_feather(dosage, "data-raw/dosage.feather"), silent = TRUE)
|
||||
try(arrow::write_parquet(dosage, "data-raw/dosage.parquet"), silent = TRUE)
|
||||
}
|
||||
|
||||
suppressMessages(reset_AMR_locale())
|
||||
|
||||
# remove leftovers from global env
|
||||
current_globalenv <- ls(envir = globalenv())
|
||||
rm(list = current_globalenv[!current_globalenv %in% old_globalenv])
|
||||
rm(current_globalenv)
|
||||
|
||||
devtools::load_all(quiet = TRUE)
|
||||
|
||||
|
||||
# Update URLs -------------------------------------------------------------
|
||||
usethis::ui_info("Checking URLs for redirects")
|
||||
invisible(capture.output(urlchecker::url_update()))
|
||||
|
||||
|
||||
# Document pkg ------------------------------------------------------------
|
||||
usethis::ui_info("Documenting package")
|
||||
suppressMessages(devtools::document(quiet = TRUE))
|
||||
|
||||
|
||||
# Style pkg ---------------------------------------------------------------
|
||||
usethis::ui_info("Styling package")
|
||||
invisible(capture.output(styler::style_pkg(
|
||||
style = styler::tidyverse_style,
|
||||
filetype = c("R", "Rmd")
|
||||
)))
|
||||
invisible(capture.output(styler::style_dir(
|
||||
path = "inst", # unit tests
|
||||
style = styler::tidyverse_style,
|
||||
filetype = c("R", "Rmd")
|
||||
)))
|
||||
|
||||
|
||||
# Finished ----------------------------------------------------------------
|
||||
usethis::ui_done("All done")
|
||||
@@ -1 +1 @@
|
||||
4f082a7952a37133305f64d6f711e81e
|
||||
79ed9c5d9ddd2c270a5bbb579a920992
|
||||
|
||||
@@ -1,519 +1,2 @@
|
||||
"ab" "cid" "name" "group" "atc" "atc_group1" "atc_group2" "abbreviations" "synonyms" "oral_ddd" "oral_units" "iv_ddd" "iv_units" "loinc"
|
||||
"AMA" 4649 "4-aminosalicylic acid" "Antimycobacterials" "J04AA01" "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" 3366 "5-fluorocytosine" "Antifungals/antimycotics" "D01AE21" "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" "" "" ""
|
||||
"ASP" 49787020 "Acetylspiramycin" "Macrolides/lincosamides" "" "c(\"acetylspiramycin\", \"foromacidin b\", \"spiramycin ii\")" "character(0)"
|
||||
"ALS" 8954 "Aldesulfone sodium" "Other antibacterials" "J04BA03" "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)"
|
||||
"AMK" 37768 "Amikacin" "Aminoglycosides" "c(\"D06AX12\", \"J01GB06\", \"S01AA21\")" "Aminoglycoside antibacterials" "Other aminoglycosides" "c(\"ak\", \"ami\", \"amik\", \"amk\", \"an\")" "c(\"amicacin\", \"amikacillin\", \"amikacin\", \"amikacin base\", \"amikacin dihydrate\", \"amikacin sulfate\", \"amikacina\", \"amikacine\", \"amikacinum\", \"amikavet\", \"amikin\", \"amiklin\", \"amikozit\", \"amukin\", \"arikace\", \"briclin\", \"lukadin\", \"mikavir\", \"pierami\", \"potentox\")" 1 "g" "c(\"13546-7\", \"15098-7\", \"17798-0\", \"31097-9\", \"31098-7\", \"31099-5\", \"3319-1\", \"3320-9\", \"3321-7\", \"35669-1\", \"50802-8\", \"50803-6\", \"56628-1\", \"59378-0\", \"80972-3\")"
|
||||
"AKF" "Amikacin/fosfomycin" "Aminoglycosides" "" "" ""
|
||||
"AMX" 33613 "Amoxicillin" "Beta-lactams/penicillins" "J01CA04" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"ac\", \"amox\", \"amx\")" "c(\"actimoxi\", \"amoclen\", \"amolin\", \"amopen\", \"amopenixin\", \"amoxibiotic\", \"amoxicaps\", \"amoxicilina\", \"amoxicillin\", \"amoxicilline\", \"amoxicillinum\", \"amoxiden\", \"amoxil\", \"amoxivet\", \"amoxy\", \"amoxycillin\", \"anemolin\", \"aspenil\", \"biomox\", \"bristamox\", \"cemoxin\", \"clamoxyl\", \"delacillin\", \"dispermox\", \"efpenix\", \"flemoxin\", \"hiconcil\", \"histocillin\", \"hydroxyampicillin\", \"ibiamox\", \"imacillin\", \"lamoxy\", \"metafarma capsules\", \"metifarma capsules\", \"moxacin\", \"moxatag\", \"ospamox\", \"pamoxicillin\",
|
||||
\"piramox\", \"robamox\", \"sawamox pm\", \"tolodina\", \"unicillin\", \"utimox\", \"vetramox\")" 1.5 "g" 3 "g" "c(\"16365-9\", \"25274-2\", \"3344-9\", \"80133-2\")"
|
||||
"AMC" 23665637 "Amoxicillin/clavulanic acid" "Beta-lactams/penicillins" "J01CR02" "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" "" "" ""
|
||||
"AMB" 5280965 "Amphotericin B" "Antifungals/antimycotics" "c(\"A01AB04\", \"A07AA07\", \"G01AA03\", \"J02AA01\")" "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\")" 40 "mg" 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\")" "" ""
|
||||
"AMP" 6249 "Ampicillin" "Beta-lactams/penicillins" "c(\"J01CA01\", \"S01AA19\")" "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\",
|
||||
\"ponecil\", \"princillin\", \"principen\", \"qidamp\", \"racenacillin\", \"rosampline\", \"roscillin\", \"semicillin\", \"semicillin r\", \"servicillin\", \"sumipanto\", \"synpenin\", \"texcillin\", \"tokiocillin\", \"tolomol\", \"totacillin\", \"totalciclina\", \"totapen\", \"trifacilina\", \"ukapen\", \"ultrabion\", \"ultrabron\", \"vampen\", \"viccillin\", \"viccillin s\", \"vidocillin\", \"wypicil\")" 2 "g" 6 "g" "c(\"21066-6\", \"3355-5\", \"33562-0\", \"33919-2\", \"43883-8\", \"43884-6\", \"87604-5\")"
|
||||
"SAM" 119561 "Ampicillin/sulbactam" "Beta-lactams/penicillins" "J01CR01" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "c(\"a/s\", \"ab\", \"ams\", \"amsu\", \"apsu\", \"sam\")" "" 6 "g" ""
|
||||
"AMR" 73341 "Amprolium" "Other antibacterials" "" "c(\"amprocidum\", \"amprolio\", \"amprolium\", \"amprovine\")" "character(0)"
|
||||
"ANI" 166548 "Anidulafungin" "Antifungals/antimycotics" "J02AX06" "Antimycotics for systemic use" "Other antimycotics for systemic use" "anid" "c(\"anidulafungin\", \"anidulafungina\", \"anidulafungine\", \"anidulafunginum\", \"ecalta\", \"eraxis\")" 0.1 "g" "58420-1"
|
||||
"APL" 6602341 "Apalcillin" "Beta-lactams/penicillins" "" "c(\"apalcilina\", \"apalcillin\", \"apalcilline\", \"apalcillinum\")" "character(0)"
|
||||
"APR" 3081545 "Apramycin" "Aminoglycosides" "" "c(\"ambylan\", \"apralan\", \"apramicina\", \"apramycin\", \"apramycine\", \"apramycinum\", \"nebramycin ii\")" "character(0)"
|
||||
"ARB" 68682 "Arbekacin" "Aminoglycosides" "J01GB12" "" "c(\"arbekacin\", \"arbekacina\", \"arbekacine\", \"arbekacini sulfas\", \"arbekacinum\", \"habekacin\", \"haberacin\")" 0.2 "g" "character(0)"
|
||||
"APX" 71961 "Aspoxicillin" "Beta-lactams/penicillins" "J01CA19" "" "c(\"aspoxicilina\", \"aspoxicillan\", \"aspoxicillin\", \"aspoxicilline\", \"aspoxicillinum\")" 4 "g" "character(0)"
|
||||
"AST" 5284517 "Astromicin" "Aminoglycosides" "" "c(\"astromicin\", \"astromicin a\", \"astromicina\", \"astromicine\", \"astromicinum\", \"fortimicin a\")" "character(0)"
|
||||
"AVB" 9835049 "Avibactam" "Beta-lactams/penicillins" "" "c(\"avibactam\", \"avibactam free acid\")" "character(0)"
|
||||
"AVI" 71674 "Avilamycin" "Other antibacterials" "" "c(\"avilamycin\", \"avilamycina\", \"avilamycine\", \"avilamycinum\", \"surmax\")" "character(0)"
|
||||
"AVO" 16131159 "Avoparcin" "Glycopeptides" "" "" ""
|
||||
"AZD" 15574941 "Azidocillin" "Beta-lactams/penicillins" "J01CE04" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"azidocilina\", \"azidocillin\", \"azidocillina\", \"azidocilline\", \"azidocillinum\")" 1.5 "g" "character(0)"
|
||||
"AZM" 447043 "Azithromycin" "Macrolides/lincosamides" "c(\"J01FA10\", \"S01AA26\")" "Macrolides, lincosamides and streptogramins" "Macrolides" "c(\"az\", \"azi\", \"azit\", \"azm\")" "c(\"aritromicina\", \"azasite\", \"azenil\", \"azifast\", \"azigram\", \"azimakrol\", \"azithramycine\", \"azithromycin\", \"azithromycine\", \"azithromycinum\", \"azitrocin\", \"azitromax\", \"azitromicina\", \"azitromicine\", \"azitromin\", \"aziwok\", \"aztrin\", \"azyter\", \"azythromycin\", \"hemomycin\", \"misultina\", \"mixoterin\", \"setron\", \"sumamed\", \"tromix\", \"trulimax\", \"zentavion\", \"zithrax\", \"zithromac\", \"zithromax\", \"zithromax iv\", \"zithromycin\", \"zitrim\", \"zitromax\", \"zitrotek\", \"zmax sr\")" 0.3 "g" 0.5 "g" "c(\"16420-2\", \"25233-8\")"
|
||||
"AZL" 6479523 "Azlocillin" "Beta-lactams/penicillins" "J01CA09" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"az\", \"azl\", \"azlo\")" "" 12 "g" ""
|
||||
"ATM" 5742832 "Aztreonam" "Beta-lactams/penicillins" "J01DF01" "Other beta-lactam antibacterials" "Monobactams" "c(\"at\", \"atm\", \"azm\", \"azt\", \"aztr\")" "c(\"azactam\", \"azetreonam\", \"azthreonam\", \"aztreonam\", \"primbactam\")" 4 "g" "c(\"16423-6\", \"25234-6\", \"3369-6\")"
|
||||
"AZA" "Aztreonam/avibactam" "Beta-lactams/penicillins" "" "" ""
|
||||
"ANC" "Aztreonam/nacubactam" "Beta-lactams/penicillins" "" "" ""
|
||||
"BAM" 441397 "Bacampicillin" "Beta-lactams/penicillins" "J01CA06" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"bacampicilina\", \"bacampicillin\", \"bacampicilline\", \"bacampicillinum\", \"penglobe\")" 1.2 "g" "character(0)"
|
||||
"BAC" 78358334 "Bacitracin zinc" "Other antibacterials" "R02AB04" "baci" "" ""
|
||||
"BDQ" 5388906 "Bedaquiline" "Other antibacterials" "J04AK05" "" "c(\"bedaquiline\", \"sirturo\")" 86 "mg" "80637-2"
|
||||
"BEK" 439318 "Bekanamycin" "Aminoglycosides" "J01GB13" "" "c(\"aminodeoxykanamycin\", \"becanamicina\", \"bekanamycin\", \"bekanamycine\", \"bekanamycinum\", \"nebramycin v\")" 0.6 "g" "character(0)"
|
||||
"BNB" "Benzathine benzylpenicillin" "Beta-lactams/penicillins" "J01CE08" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "" 3.6 "g" ""
|
||||
"BNP" 64725 "Benzathine phenoxymethylpenicillin" "Beta-lactams/penicillins" "J01CE10" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"bicillin v\", \"biphecillin\")" 2 "g" "character(0)"
|
||||
"PEN" 5904 "Benzylpenicillin" "Beta-lactams/penicillins" "c(\"J01CE01\", \"S01AA14\")" "Combinations of antibacterials" "Combinations of antibacterials" "c(\"bepe\", \"pen\", \"peni\", \"peni g\", \"penicillin\", \"penicillin g\", \"pg\")" "c(\"abbocillin\", \"ayercillin\", \"bencilpenicilina\", \"benzopenicillin\", \"benzyl penicillin\", \"benzylpenicillin\", \"benzylpenicillin g\", \"benzylpenicilline\", \"benzylpenicillinum\", \"bicillin\", \"cillora\", \"cilloral\", \"cilopen\", \"compocillin g\", \"cosmopen\", \"dropcillin\", \"free penicillin g\", \"free penicillin ii\", \"galofak\", \"gelacillin\", \"liquacillin\", \"megacillin\", \"pencillin g\", \"penicillin\", \"penicilling\", \"pentids\", \"permapen\", \"pfizerpen\", \"pfizerpen g\", \"pharmacillin\", \"pradupen\", \"specilline g\", \"ursopen\"
|
||||
)" 3.6 "g" "3913-1"
|
||||
"BES" 10178705 "Besifloxacin" "Quinolones" "S01AE08" "" "besifloxacin" "character(0)"
|
||||
"BIA" 71339 "Biapenem" "Carbapenems" "J01DH05" "" "c(\"biapenem\", \"biapenern\", \"bipenem\", \"omegacin\")" 1.2 "g" "character(0)"
|
||||
"BCZ" 65807 "Bicyclomycin" "Other antibacterials" "c(\"\", \"bicozamycin\")" "c(\"aizumycin\", \"bacfeed\", \"bacteron\", \"bicozamicina\", \"bicozamycin\", \"bicozamycine\", \"bicozamycinum\")" "character(0)"
|
||||
"BDP" 68760 "Brodimoprim" "Trimethoprims" "J01EA02" "Sulfonamides and trimethoprim" "Trimethoprim and derivatives" "" "c(\"brodimoprim\", \"brodimoprima\", \"brodimoprime\", \"brodimoprimum\", \"bromdimoprim\", \"hyprim\", \"unitrim\")" 0.2 "g" "character(0)"
|
||||
"BUT" 47472 "Butoconazole" "Antifungals/antimycotics" "G01AF15" "" "c(\"butaconazole\", \"butoconazol\", \"butoconazole\", \"butoconazolum\", \"compositenstarke\", \"dahlin\", \"femstat\", \"gynofort\", \"polyfructosanum\")" "character(0)"
|
||||
"CDZ" 44242317 "Cadazolid" "Oxazolidinones" "" "cadazolid" "character(0)"
|
||||
"CLA" "Calcium aminosalicylate" "Antimycobacterials" "J04AA03" "Drugs for treatment of tuberculosis" "Aminosalicylic acid and derivatives" "" "" 15 "g" ""
|
||||
"CAP" 135565060 "Capreomycin" "Antimycobacterials" "J04AB30" "Drugs for treatment of tuberculosis" "Antibiotics" "c(\"\", \"capr\")" "" 1 "g" ""
|
||||
"CRB" 20824 "Carbenicillin" "Beta-lactams/penicillins" "J01CA03" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"bar\", \"carb\", \"cb\")" "c(\"anabactyl\", \"carbenicilina\", \"carbenicillin\", \"carbenicillina\", \"carbenicilline\", \"carbenicillinum\", \"geopen\", \"pyopen\")" 12 "g" "3434-8"
|
||||
"CRN" 93184 "Carindacillin" "Beta-lactams/penicillins" "J01CA05" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"carindacilina\", \"carindacillin\", \"carindacilline\", \"carindacillinum\")" 4 "g" "character(0)"
|
||||
"CAR" 6540466 "Carumonam" "Other antibacterials" "J01DF02" "" "c(\"carumonam\", \"carumonamum\")" 2 "g" "character(0)"
|
||||
"CAS" 2826718 "Caspofungin" "Antifungals/antimycotics" "J02AX04" "Antimycotics for systemic use" "Other antimycotics for systemic use" "casp" "c(\"cancidas\", \"capsofungin\", \"caspofungin\")" 50 "mg" "58419-3"
|
||||
"CAC" 91562 "Cefacetrile" "Cephalosporins (1st gen.)" "J01DB10" "Other beta-lactam antibacterials" "First-generation cephalosporins" "" "c(\"cefacetril\", \"cefacetrile\", \"cefacetrilo\", \"cefacetrilum\", \"celospor\", \"celtol\", \"cephacetrile\", \"cristacef\", \"vetrimast\")" "character(0)"
|
||||
"CEC" 51039 "Cefaclor" "Cephalosporins (2nd gen.)" "J01DC04" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "c(\"ccl\", \"cec\", \"cf\", \"cfac\", \"cfc\", \"cfcl\", \"cfr\", \"fac\")" "c(\"alenfral\", \"alfacet\", \"ceclor\", \"ceclor cd\", \"cefaclor\", \"cefaclor anhydrous\", \"cefaclor monohydrate\", \"cefacloro\", \"cefaclorum\", \"cefeaclor\", \"cephaclor\", \"dystaclor mr\", \"keflor\", \"kefral\", \"raniclor\")" 1 "g" "c(\"16564-7\", \"21149-0\")"
|
||||
"CFR" 47965 "Cefadroxil" "Cephalosporins (1st gen.)" "J01DB05" "Other beta-lactam antibacterials" "First-generation cephalosporins" "c(\"cfdx\", \"cfr\", \"fad\")" "c(\"cefadrops\", \"cefadroxil\", \"cefadroxil anhydrous\", \"cefadroxilo\", \"cefadroxilum\", \"cefradroxil\", \"cephadroxil\", \"duricef\", \"sumacef\", \"ultracef\")" 2 "g" "16565-4"
|
||||
"RID" 5773 "Cefaloridine" "Cephalosporins (1st gen.)" "J01DB02" "Other beta-lactam antibacterials" "First-generation cephalosporins" "cefa" "c(\"aliporina\", \"ampligram\", \"cefaloridin\", \"cefaloridina\", \"cefaloridine\", \"cefaloridinum\", \"cefalorizin\", \"ceflorin\", \"cepaloridin\", \"cepalorin\", \"cephalomycine\", \"cephaloridin\", \"cephaloridine\", \"cephaloridinum\", \"ceporan\", \"ceporin\", \"ceporine\", \"cilifor\", \"deflorin\", \"faredina\", \"floridin\", \"glaxoridin\", \"intrasporin\", \"keflodin\", \"keflordin\", \"kefloridin\", \"kefspor\", \"lloncefal\", \"loridine\", \"sasperin\", \"sefacin\", \"verolgin\", \"vioviantine\")" 3 "g" "character(0)"
|
||||
"MAN" 456255 "Cefamandole" "Cephalosporins (2nd gen.)" "J01DC03" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "c(\"cfam\", \"cfmn\")" "c(\"cefadole\", \"cefamandol\", \"cefamandole\", \"cefamandolum\", \"cephadole\", \"cephamandole\", \"kefamandol\", \"kefdole\", \"mancef\")" 6 "g" "3441-3"
|
||||
"CTZ" 6410758 "Cefatrizine" "Cephalosporins (1st gen.)" "J01DB07" "Other beta-lactam antibacterials" "First-generation cephalosporins" "" "c(\"bricef\", \"cefatrix\", \"cefatrizine\", \"cefatrizino\", \"cefatrizinum\", \"cepticol\", \"cetrazil\", \"latocef\", \"orosporina\", \"trizina\")" 1 "g" "character(0)"
|
||||
"CZD" 71736 "Cefazedone" "Cephalosporins (1st gen.)" "J01DB06" "Other beta-lactam antibacterials" "First-generation cephalosporins" "" "c(\"cefazedon\", \"cefazedona\", \"cefazedone\", \"cefazedone acid\", \"cefazedonum\", \"refosporen\", \"refosporene\", \"refosporin\")" 3 "g" "character(0)"
|
||||
"CZO" 33255 "Cefazolin" "Cephalosporins (1st gen.)" "J01DB04" "Other beta-lactam antibacterials" "First-generation cephalosporins" "c(\"cfz\", \"cfzl\", \"cz\", \"czol\", \"faz\", \"kz\")" "c(\"atirin\", \"cefamezin\", \"cefamezine\", \"cefazina\", \"cefazolin\", \"cefazolin acid\", \"cefazolina\", \"cefazoline\", \"cefazolinum\", \"cephamezine\", \"cephazolidin\", \"cephazolin\", \"cephazoline\", \"elzogram\", \"firmacef\", \"kefzol\", \"liviclina\", \"totacef\")" 3 "g" "c(\"16566-2\", \"25235-3\", \"3442-1\", \"3443-9\", \"80962-4\")"
|
||||
"CFB" 127527 "Cefbuperazone" "Other antibacterials" "J01DC13" "" "c(\"cefbuperazona\", \"cefbuperazone\", \"cefbuperazonum\", \"cefbuperzaone\", \"cerbuperazone\", \"tomiporan\")" 2 "g" "character(0)"
|
||||
"CCP" 6436055 "Cefcapene" "Cephalosporins (3rd gen.)" "J01DD17" "" "c(\"cefcamate\", \"cefcapene\")" 0.45 "g" "character(0)"
|
||||
"CCX" 5282438 "Cefcapene pivoxil" "Cephalosporins (3rd gen.)" "" "c(\"cefcamate pivoxil\", \"cefcapene piroxil\")" "character(0)"
|
||||
"CDR" 6915944 "Cefdinir" "Cephalosporins (3rd gen.)" "J01DD15" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"cd\", \"cdn\", \"cdr\", \"cfd\", \"din\")" "c(\"cefdinir\", \"cefdinirum\", \"cefdinyl\", \"cefdirnir\", \"ceftinex\", \"cefzon\", \"omnicef\")" 0.6 "g" "character(0)"
|
||||
"DIT" 9870843 "Cefditoren" "Cephalosporins (3rd gen.)" "J01DD16" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "cdn" "cefditoren" 0.4 "g" "character(0)"
|
||||
"DIX" 6437877 "Cefditoren pivoxil" "Cephalosporins (3rd gen.)" "" "c(\"cefditoren\", \"cefditoren pi voxil\", \"cefditoren pivoxil\", \"cefditorin\", \"cefditorin pivoxil\", \"meiact\", \"spectracef\")" "character(0)"
|
||||
"FEP" 5479537 "Cefepime" "Cephalosporins (4th gen.)" "J01DE01" "Other beta-lactam antibacterials" "Fourth-generation cephalosporins" "c(\"cfep\", \"cfpi\", \"cpe\", \"cpm\", \"fep\", \"pm\", \"xpm\")" "c(\"axepim\", \"cefepima\", \"cefepime\", \"cefepimum\", \"cepimax\", \"cepimex\", \"maxcef\", \"maxipime\")" 4 "g" "38363-8"
|
||||
"CPC" 9567559 "Cefepime/clavulanic acid" "Cephalosporins (4th gen.)" "c(\"cicl\", \"xpml\")" "" ""
|
||||
"FNC" "Cefepime/nacubactam" "Beta-lactams/penicillins" "" "" ""
|
||||
"FPT" 9567558 "Cefepime/tazobactam" "Cephalosporins (4th gen.)" "" "" ""
|
||||
"FPZ" "Cefepime/zidebactam" "Other antibacterials" "" "" ""
|
||||
"CAT" 5487888 "Cefetamet" "Cephalosporins (3rd gen.)" "J01DD10" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "c(\"cefetamet\", \"cefetametum\", \"cepime o\", \"deacetoxycefotaxime\")" 1 "g" "character(0)"
|
||||
"CPI" 5486182 "Cefetamet pivoxil" "Cephalosporins (3rd gen.)" "" "c(\"cefetamet pivoxyl\", \"globocef\")" "character(0)"
|
||||
"CCL" 71719688 "Cefetecol" "Cephalosporins (4th gen.)" "c(\"\", \"cefcatacol\")" "" ""
|
||||
"CZL" 193956 "Cefetrizole" "Cephalosporins (unclassified gen.)" "" "c(\"cefetrizole\", \"cefetrizolum\")" "character(0)"
|
||||
"FDC" 77843966 "Cefiderocol" "Other antibacterials" "J01DI04" "" "cefiderocol" "character(0)"
|
||||
"CFM" 5362065 "Cefixime" "Cephalosporins (3rd gen.)" "J01DD08" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"cfe\", \"cfix\", \"cfxm\", \"dcfm\", \"fix\", \"ix\")" "c(\"cefixim\", \"cefixima\", \"cefixime\", \"cefixime anhydrous\", \"cefiximum\", \"cefixoral\", \"cefspan\", \"cephoral\", \"denvar\", \"necopen\", \"suprax\", \"tricef\", \"unixime\")" 0.4 "g" "c(\"16567-0\", \"25236-1\")"
|
||||
"CMX" 9570757 "Cefmenoxime" "Cephalosporins (3rd gen.)" "J01DD05" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "c(\"bestron\", \"cefmax\", \"cefmenoxima\", \"cefmenoxime\", \"cefmenoximum\")" 2 "g" "character(0)"
|
||||
"CMZ" 42008 "Cefmetazole" "Cephalosporins (2nd gen.)" "J01DC09" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "" "c(\"cefmetazole\", \"cefmetazolo\", \"cefmetazolum\")" 4 "g" "character(0)"
|
||||
"CNX" 71141 "Cefminox" "Other antibacterials" "J01DC12" "" "c(\"cefminox\", \"cefminoxum\")" 4 "g" "character(0)"
|
||||
"DIZ" 5361871 "Cefodizime" "Cephalosporins (3rd gen.)" "J01DD09" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "c(\"cefodizima\", \"cefodizime\", \"cefodizime acid\", \"cefodizimum\", \"cefodizme\", \"diezime\", \"modivid\", \"neucef\", \"timecef\")" 2 "g" "character(0)"
|
||||
"CID" 43594 "Cefonicid" "Cephalosporins (2nd gen.)" "J01DC06" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "" "c(\"cefonicid\", \"cefonicido\", \"cefonicidum\", \"monocef\")" 1 "g" "c(\"25237-9\", \"3444-7\")"
|
||||
"CFP" 44187 "Cefoperazone" "Cephalosporins (3rd gen.)" "J01DD12" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"cfp\", \"cfpz\", \"cp\", \"cpz\", \"fop\", \"per\")" "c(\"bioperazone\", \"cefobid\", \"cefoperazine\", \"cefoperazon\", \"cefoperazone\", \"cefoperazone acid\", \"cefoperazono\", \"cefoperazonum\", \"cefozon\", \"medocef\", \"myticef\", \"pathozone\", \"peracef\")" 4 "g" "3445-4"
|
||||
"CSL" "Cefoperazone/sulbactam" "Cephalosporins (3rd gen.)" "J01DD62" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "" 4 "g" ""
|
||||
"CND" 43507 "Ceforanide" "Cephalosporins (2nd gen.)" "J01DC11" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "" "c(\"ceforanide\", \"ceforanido\", \"ceforanidum\", \"precef\", \"radacef\")" 4 "g" "character(0)"
|
||||
"CSE" 9830519 "Cefoselis" "Cephalosporins (4th gen.)" "" "c(\"cefoselis\", \"cefoselis sulfate\", \"winsef\")" "character(0)"
|
||||
"CTX" 5742673 "Cefotaxime" "Cephalosporins (3rd gen.)" "J01DD01" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"cfot\", \"cft\", \"cftx\", \"ct\", \"ctx\", \"fot\", \"tax\", \"xct\")" "c(\"cefotaxim\", \"cefotaxim hikma\", \"cefotaxima\", \"cefotaxime\", \"cefotaxime acid\", \"cefotaximum\", \"cephotaxime\", \"claforan\", \"omnatax\")" 4 "g" "c(\"25238-7\", \"3446-2\", \"80961-6\")"
|
||||
"CTC" 9575353 "Cefotaxime/clavulanic acid" "Cephalosporins (3rd gen.)" "c(\"cxcl\", \"xctl\")" "" ""
|
||||
"CTS" 9574753 "Cefotaxime/sulbactam" "Cephalosporins (3rd gen.)" "" "" ""
|
||||
"CTT" 53025 "Cefotetan" "Cephalosporins (2nd gen.)" "J01DC05" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "c(\"cftt\", \"cn\", \"cte\", \"ctn\", \"ctt\", \"tans\")" "c(\"apacef\", \"cefotetan\", \"cefotetan free acid\", \"cefotetanum\")" 4 "g" "c(\"25239-5\", \"3447-0\")"
|
||||
"CTF" 43708 "Cefotiam" "Cephalosporins (2nd gen.)" "J01DC07" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "" "c(\"cefotiam\", \"cefotiam?\", \"cefotiamum\", \"ceradolan\", \"ceradon\", \"haloapor\")" 1.2 "g" 4 "g" "character(0)"
|
||||
"CHE" 125846 "Cefotiam hexetil" "Cephalosporins (3rd gen.)" "" "c(\"cefotiam cilexetil\", \"pansporin t\")" "character(0)"
|
||||
"FOV" 9578573 "Cefovecin" "Cephalosporins (3rd gen.)" "" "" ""
|
||||
"FOX" 441199 "Cefoxitin" "Cephalosporins (2nd gen.)" "J01DC01" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "c(\"cfox\", \"cfx\", \"cfxt\", \"cx\", \"fox\", \"fx\")" "c(\"cefoxitin\", \"cefoxitina\", \"cefoxitine\", \"cefoxitinum\", \"cefoxotin\", \"cephoxitin\", \"mefoxin\", \"mefoxitin\", \"rephoxitin\")" 6 "g" "c(\"25240-3\", \"3448-8\")"
|
||||
"FOX1" "Cefoxitin screening" "Cephalosporins (2nd gen.)" "cfsc" "" ""
|
||||
"ZOP" 9571080 "Cefozopran" "Cephalosporins (4th gen.)" "J01DE03" "" "cefozopran" 4 "g" "character(0)"
|
||||
"CFZ" 68597 "Cefpimizole" "Cephalosporins (3rd gen.)" "" "c(\"cefpimizol\", \"cefpimizole\", \"cefpimizole sodium\", \"cefpimizolum\")" "character(0)"
|
||||
"CPM" 636405 "Cefpiramide" "Cephalosporins (3rd gen.)" "J01DD11" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "c(\"cefpiramide\", \"cefpiramide acid\", \"cefpiramido\", \"cefpiramidum\")" 2 "g" "character(0)"
|
||||
"CPO" 5479539 "Cefpirome" "Cephalosporins (4th gen.)" "J01DE02" "Other beta-lactam antibacterials" "Fourth-generation cephalosporins" "c(\"\", \"cfpr\")" "c(\"broact\", \"cefpiroma\", \"cefpirome\", \"cefpiromum\", \"cefrom\", \"cerfpirome\", \"keiten\")" 4 "g" "character(0)"
|
||||
"CPD" 6335986 "Cefpodoxime" "Cephalosporins (3rd gen.)" "J01DD13" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"cfpd\", \"cfpo\", \"cpd\", \"pod\", \"px\")" "c(\"cefpodoxim acid\", \"cefpodoxima\", \"cefpodoxime\", \"cefpodoxime acid\", \"cefpodoximum\", \"epoxim\")" 0.4 "g" "25241-1"
|
||||
"CPX" 6526396 "Cefpodoxime proxetil" "Cephalosporins (3rd gen.)" "" "c(\"cefodox\", \"cefoprox\", \"cefpodoxime proxetil\", \"cepodem\", \"orelox\", \"otreon\", \"podomexef\", \"simplicef\", \"vantin\")" "character(0)"
|
||||
"CDC" "Cefpodoxime/clavulanic acid" "Cephalosporins (3rd gen.)" "c(\"\", \"cecl\")" "" ""
|
||||
"CPR" 5281006 "Cefprozil" "Cephalosporins (2nd gen.)" "J01DC10" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "c(\"cpr\", \"cpz\", \"fp\")" "c(\"arzimol\", \"brisoral\", \"cefprozil\", \"cefprozil anhydrous\", \"cefprozil hydrate\", \"cefprozilo\", \"cefprozilum\", \"cefzil\", \"cronocef\", \"procef\", \"serozil\")" 1 "g" "character(0)"
|
||||
"CEQ" 5464355 "Cefquinome" "Cephalosporins (4th gen.)" "" "c(\"cefquinoma\", \"cefquinome\", \"cefquinomum\", \"cobactan\")" "character(0)"
|
||||
"CRD" 5284529 "Cefroxadine" "Cephalosporins (1st gen.)" "J01DB11" "Other beta-lactam antibacterials" "First-generation cephalosporins" "" "c(\"cefroxadine\", \"cefroxadino\", \"cefroxadinum\")" 2.1 "g" "character(0)"
|
||||
"CFS" 656575 "Cefsulodin" "Cephalosporins (3rd gen.)" "J01DD03" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"cfsl\", \"cfsu\")" "c(\"cefsulodin\", \"cefsulodine\", \"cefsulodino\", \"cefsulodinum\")" 4 "g" "c(\"131-3\", \"25242-9\")"
|
||||
"CSU" 68718 "Cefsumide" "Cephalosporins (unclassified gen.)" "" "c(\"cefsumide\", \"cefsumido\", \"cefsumidum\")" "character(0)"
|
||||
"CPT" 56841980 "Ceftaroline" "Cephalosporins (5th gen.)" "J01DI02" "c(\"\", \"cfro\")" "c(\"teflaro\", \"zinforo\")" 1.2 "g" "character(0)"
|
||||
"CPA" "Ceftaroline/avibactam" "Cephalosporins (5th gen.)" "" "" ""
|
||||
"CAZ" 5481173 "Ceftazidime" "Cephalosporins (3rd gen.)" "J01DD02" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"caz\", \"cefta\", \"cfta\", \"cftz\", \"taz\", \"tz\", \"xtz\")" "c(\"ceftazidim\", \"ceftazidima\", \"ceftazidime\", \"ceftazidimum\", \"ceptaz\", \"fortaz\", \"fortum\", \"pentacef\", \"tazicef\", \"tazidime\")" 4 "g" "c(\"21151-6\", \"3449-6\", \"80960-8\")"
|
||||
"CZA" 90643431 "Ceftazidime/avibactam" "Cephalosporins (3rd gen.)" "c(\"\", \"cfav\")" "c(\"avycaz\", \"zavicefta\")" ""
|
||||
"CCV" 9575352 "Ceftazidime/clavulanic acid" "Cephalosporins (3rd gen.)" "J01DD52" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"czcl\", \"xtzl\")" "" 6 "g" ""
|
||||
"CEM" 6537431 "Cefteram" "Cephalosporins (3rd gen.)" "J01DD18" "" "c(\"cefteram\", \"cefterame\", \"cefteramum\", \"ceftetrame\")" 0.4 "g" "character(0)"
|
||||
"CPL" 5362114 "Cefteram pivoxil" "Cephalosporins (3rd gen.)" "" "c(\"cefteram pivoxil\", \"tomiron\")" "character(0)"
|
||||
"CTL" 65755 "Ceftezole" "Cephalosporins (1st gen.)" "J01DB12" "Other beta-lactam antibacterials" "First-generation cephalosporins" "" "c(\"ceftezol\", \"ceftezole\", \"ceftezolo\", \"ceftezolum\", \"demethylcefazolin\")" 3 "g" "character(0)"
|
||||
"CTB" 5282242 "Ceftibuten" "Cephalosporins (3rd gen.)" "J01DD14" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"cb\", \"cfbu\", \"ctb\", \"tib\")" "c(\"ceftem\", \"ceftibuten\", \"ceftibuten hydrate\", \"ceftibutene\", \"ceftibuteno\", \"ceftibutenum\", \"cephem\", \"ceprifran\", \"isocef\", \"keimax\")" 0.4 "g" "character(0)"
|
||||
"TIO" 6328657 "Ceftiofur" "Cephalosporins (3rd gen.)" "" "c(\"ceftiofur\", \"ceftiofurum\", \"excede\", \"excenel\", \"naxcel\")" "character(0)"
|
||||
"CZX" 6533629 "Ceftizoxime" "Cephalosporins (3rd gen.)" "J01DD07" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"cfzx\", \"ctz\", \"cz\", \"czx\", \"tiz\", \"zox\")" "c(\"cefizox\", \"ceftisomin\", \"ceftix\", \"ceftizoxima\", \"ceftizoxime\", \"ceftizoximum\", \"epocelin\", \"eposerin\")" 4 "g" "c(\"25243-7\", \"3450-4\")"
|
||||
"CZP" 9578661 "Ceftizoxime alapivoxil" "Cephalosporins (3rd gen.)" "" "" ""
|
||||
"BPR" 135413542 "Ceftobiprole" "Cephalosporins (5th gen.)" "" "ceftobiprole" "character(0)"
|
||||
"CFM1" 135413544 "Ceftobiprole medocaril" "Cephalosporins (5th gen.)" "J01DI01" "Other beta-lactam antibacterials" "Other cephalosporins and penems" "" "" 1.5 "g" ""
|
||||
"CEI" "Ceftolozane/enzyme inhibitor" "Cephalosporins (5th gen.)" "J01DI54" "Other beta-lactam antibacterials" "Other cephalosporins and penems" "" "" 3 "g" ""
|
||||
"CZT" "Ceftolozane/tazobactam" "Cephalosporins (5th gen.)" "" "" ""
|
||||
"CRO" 5479530 "Ceftriaxone" "Cephalosporins (3rd gen.)" "J01DD04" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"axo\", \"cax\", \"cftr\", \"cro\", \"ctr\", \"frx\", \"tx\")" "c(\"biotrakson\", \"cefatriaxone\", \"cefatriaxone hydrate\", \"ceftriaxon\", \"ceftriaxona\", \"ceftriaxone\", \"ceftriaxone sodium\", \"ceftriaxonum\", \"ceftriazone\", \"cephtriaxone\", \"longacef\", \"rocefin\", \"rocephalin\", \"rocephin\", \"rocephine\", \"rophex\")" 2 "g" "c(\"25244-5\", \"3451-2\", \"80957-4\")"
|
||||
"CXM" 5479529 "Cefuroxime" "Cephalosporins (2nd gen.)" "c(\"J01DC02\", \"S01AA27\")" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "c(\"cfrx\", \"cfur\", \"cfx\", \"crm\", \"cxm\", \"fur\", \"rox\", \"xm\")" "c(\"biofuroksym\", \"cefuril\", \"cefuroxim\", \"cefuroxime\", \"cefuroximine\", \"cefuroximo\", \"cefuroximum\", \"cephuroxime\", \"kefurox\", \"sharox\", \"zinacef\", \"zinacef danmark\")" 0.5 "g" 3 "g" "c(\"25245-2\", \"3452-0\", \"80608-3\", \"80617-4\")"
|
||||
"CXA" 6321416 "Cefuroxime axetil" "Cephalosporins (2nd gen.)" "c(\"\", \"cfax\")" "c(\"altacef\", \"bioracef\", \"cefaks\", \"cefazine\", \"ceftin\", \"cefuroximaxetil\", \"cefuroxime axetil\", \"celocid\", \"cepazine\", \"cethixim\", \"cetoxil\", \"coliofossim\", \"elobact\", \"forcef\", \"furoxime\", \"kalcef\", \"maxitil\", \"medoxm\", \"nivador\", \"zinnat\")" "character(0)"
|
||||
"CFM2" "Cefuroxime/metronidazole" "Other antibacterials" "J01RA03" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
|
||||
"ZON" 6336505 "Cefuzonam" "Other antibacterials" "" "c(\"cefuzonam\", \"cefuzonam sodium\", \"cefuzoname\", \"cefuzonamum\")" "character(0)"
|
||||
"LEX" 27447 "Cephalexin" "Cephalosporins (1st gen.)" "J01DB01" "Other beta-lactam antibacterials" "First-generation cephalosporins" "c(\"\", \"cflx\")" "c(\"alcephin\", \"alexin\", \"alsporin\", \"anhydrous cefalexin\", \"anhydrous cephalexin\", \"biocef\", \"carnosporin\", \"cefablan\", \"cefadal\", \"cefadin\", \"cefadina\", \"cefaleksin\", \"cefalessina\", \"cefalexin\", \"cefalexin anhydrous\", \"cefalexina\", \"cefalexine\", \"cefalexinum\", \"cefalin\", \"cefaloto\", \"cefaseptin\", \"ceflax\", \"ceforal\", \"cefovit\", \"celexin\", \"cepastar\", \"cepexin\", \"cephacillin\", \"cephalexin\", \"cephalexin anhydrous\", \"cephalexine\", \"cephalexinum\", \"cephanasten\", \"cephaxin\", \"cephin\", \"ceporex\", \"ceporex forte\",
|
||||
\"ceporexin\", \"ceporexine\", \"cerexin\", \"cerexins\", \"cophalexin\", \"durantel\", \"durantel ds\", \"erocetin\", \"factagard\", \"felexin\", \"ibilex\", \"ibrexin\", \"inphalex\", \"kefalospes\", \"keflet\", \"keflex\", \"kefolan\", \"keforal\", \"keftab\", \"kekrinal\", \"kidolex\", \"lafarine\", \"larixin\", \"lenocef\", \"lexibiotico\", \"lonflex\", \"lopilexin\", \"madlexin\", \"mamalexin\", \"mamlexin\", \"medoxine\", \"neokef\", \"neolexina\", \"novolexin\", \"optocef\", \"oracef\", \"oriphex\", \"oroxin\", \"ortisporina\", \"ospexin\", \"palitrex\", \"panixine disperdose\",
|
||||
\"pectril\", \"pyassan\", \"roceph\", \"roceph distab\", \"sanaxin\", \"sartosona\", \"sencephalin\", \"sepexin\", \"servispor\", \"sialexin\", \"sinthecillin\", \"sporicef\", \"sporidex\", \"syncle\", \"synecl\", \"tepaxin\", \"tokiolexin\", \"uphalexin\", \"voxxim\", \"winlex\", \"zozarine\")" 2 "g" "c(\"21175-5\", \"3453-8\")"
|
||||
"CEP" 6024 "Cephalothin" "Cephalosporins (1st gen.)" "J01DB03" "Other beta-lactam antibacterials" "First-generation cephalosporins" "c(\"cfal\", \"cflt\")" "c(\"cefalothin\", \"cefalotin\", \"cefalotina\", \"cefalotina fabra\", \"cefalotine\", \"cefalotinum\", \"cemastin\", \"cephalothinum\", \"cephalotin\", \"coaxin\", \"keflin\", \"seffin\")" 4 "g" "c(\"25246-0\", \"3454-6\")"
|
||||
"HAP" 30699 "Cephapirin" "Cephalosporins (1st gen.)" "J01DB08" "Other beta-lactam antibacterials" "First-generation cephalosporins" "" "c(\"ambrocef\", \"cefadyl\", \"cefapilin\", \"cefapirin\", \"cefapirina\", \"cefapirine\", \"cefapirinum\", \"cefaprin\", \"cefaprin sodium\", \"cefatrex\", \"cefatrexyl\", \"cephapirine\", \"metricure\")" 4 "g" "10980-1"
|
||||
"CED" 38103 "Cephradine" "Cephalosporins (1st gen.)" "J01DB09" "Other beta-lactam antibacterials" "First-generation cephalosporins" "c(\"cfra\", \"cfrd\")" "c(\"anspor\", \"cefradin\", \"cefradina\", \"cefradine\", \"cefradinum\", \"cekodin\", \"cephradin\", \"cephradine\", \"eskacef\", \"infexin\", \"megace f\", \"megacef\", \"sefril\", \"velocef\", \"velosef\")" 2 "g" 2 "g" "character(0)"
|
||||
"CTO" 71402 "Cetocycline" "Tetracyclines" "" "c(\"cetocycline\", \"cetocyline\", \"cetotetrine\")" "character(0)"
|
||||
"CHL" 5959 "Chloramphenicol" "Amphenicols" "c(\"D06AX02\", \"D10AF03\", \"G01AA05\", \"J01BA01\", \"S01AA01\", \"S02AA01\", \"S03AA08\")" "Amphenicols" "Amphenicols" "c(\"c\", \"chl\", \"chlo\", \"cl\")" "c(\"alficetyn\", \"ambofen\", \"amphenicol\", \"amphicol\", \"amseclor\", \"anacetin\", \"aquamycetin\", \"austracil\", \"austracol\", \"biocetin\", \"biophenicol\", \"catilan\", \"ch loramex\", \"chemiceticol\", \"chemicetin\", \"chemicetina\", \"chlomin\", \"chlomycol\", \"chloramex\", \"chloramfenikol\", \"chloramficin\", \"chloramfilin\", \"chloramphenicol\", \"chloramphenicole\", \"chloramphenicolum\", \"chloramsaar\", \"chlorasol\", \"chlorbiotic\", \"chloricol\", \"chlormycetin r\", \"chlornitromycin\", \"chloroamphenicol\", \"chlorocaps\", \"chlorocid\",
|
||||
\"chlorocid s\", \"chlorocide\", \"chlorocidin c\", \"chlorocidin c tetran\", \"chlorocin\", \"chlorocol\", \"chlorofair\", \"chloroject l\", \"chloromax\", \"chloromycetin\", \"chloromycetny\", \"chloromyxin\", \"chloronitrin\", \"chloroptic\", \"chloroptic s.o.p\", \"chloroptic s.o.p.\", \"chlorovules\", \"chlorsig\", \"cidocetine\", \"ciplamycetin\", \"cloramfen\", \"cloramfenicol\", \"cloramfenicolo\", \"cloramficin\", \"cloramical\", \"cloramicol\", \"cloramidina\", \"cloranfenicol\", \"cloroamfenicolo\", \"clorocyn\", \"cloromisan\", \"cloromissan\", \"clorosintex\",
|
||||
\"comycetin\", \"cylphenicol\", \"desphen\", \"detreomycin\", \"detreomycine\", \"dextromycetin\", \"doctamicina\", \"duphenicol\", \"econochlor\", \"embacetin\", \"emetren\", \"enicol\", \"enteromycetin\", \"erbaplast\", \"ertilen\", \"f armicetina\", \"farmicetina\", \"fenicol\", \"globenicol\", \"glorous\", \"halomycetin\", \"hortfenicol\", \"interomycetine\", \"intramycetin\", \"intramyctin\", \"isicetin\", \"ismicetina\", \"isophenicol\", \"isopto fenicol\", \"juvamycetin\", \"kamaver\", \"kemicetina\", \"kemicetine\", \"kloramfenikol\", \"klorita\", \"klorocid s\",
|
||||
\"laevomycetinum\", \"leukamycin\", \"leukomyan\", \"leukomycin\", \"levocin\", \"levomicetina\", \"levomitsetin\", \"levomycetin\", \"levoplast\", \"levosin\", \"levovetin\", \"loromicetina\", \"loromisan\", \"loromisin\", \"mastiphen\", \"mediamycetine\", \"medichol\", \"micloretin\", \"micochlorine\", \"micoclorina\", \"microcetina\", \"mychel\", \"mycinol\", \"myclocin\", \"mycochlorin\", \"myscel\", \"normimycin v\", \"novochlorocap\", \"novomycetin\", \"novophenicol\", \"ocuphenicol\", \"oftalent\", \"oleomycetin\", \"opclor\", \"opelor\", \"ophthochlor\", \"ophthocort\",
|
||||
\"ophtochlor\", \"optomycin\", \"otachron\", \"otophen\", \"pantovernil\", \"paraxin\", \"pentamycetin\", \"quemicetina\", \"rivomycin\", \"romphenil\", \"ronfenil\", \"ronphenil\", \"septicol\", \"sificetina\", \"sintomicetina\", \"sintomicetine r\", \"sno phenicol\", \"soluthor\", \"stanomycetin\", \"synthomycetin\", \"synthomycetine\", \"synthomycine\", \"syntomycin\", \"tevcocin\", \"tevcosin\", \"tifomycin\", \"tifomycine\", \"tiromycetin\", \"treomicetina\", \"unimycetin\", \"veticol\", \"vice ton\", \"viceton\")" 3 "g" 3 "g" "c(\"15101-9\", \"16603-3\", \"16604-1\", \"25247-8\", \"29214-4\", \"29346-4\", \"29347-2\", \"3455-3\")"
|
||||
"CTE" 54675777 "Chlortetracycline" "Tetracyclines" "c(\"A01AB21\", \"D06AA02\", \"J01AA03\", \"S01AA02\")" "Tetracyclines" "Tetracyclines" "" "c(\"acronize\", \"aueromycin\", \"aureocina\", \"aureomycin\", \"aureomykoin\", \"biomitsin\", \"biomycin\", \"biomycin a\", \"chlormax\", \"chlorotetracycline\", \"chlortetracycline\", \"chlortetracyclinum\", \"chrysomykine\", \"clortetraciclina\", \"duomycin\", \"flamycin\", \"uromycin\")" 1 "g" "87600-3"
|
||||
"CIC" 19003 "Ciclacillin" "Beta-lactams/penicillins" "" "c(\"bastcillin\", \"calthor\", \"ciclacilina\", \"ciclacillin\", \"ciclacilline\", \"ciclacillinum\", \"ciclacillum\", \"citosarin\", \"cyclacillin\", \"cyclapen\", \"noblicil\", \"orfilina\", \"peamezin\", \"syngacillin\", \"ultracillin\", \"vastcillin\", \"vipicil\", \"wyvital\")" "character(0)"
|
||||
"CIX" 47472 "Ciclopirox" "Antifungals/antimycotics" "c(\"D01AE14\", \"G01AX12\")" "Antifungals for topical use" "Other antifungals for topical use" "cipx" "c(\"butaconazole\", \"butoconazol\", \"butoconazole\", \"butoconazolum\", \"compositenstarke\", \"dahlin\", \"femstat\", \"gynofort\", \"polyfructosanum\")" "character(0)"
|
||||
"CIN" 2762 "Cinoxacin" "Quinolones" "J01MB06" "Quinolone antibacterials" "Other quinolones" "c(\"cino\", \"cnox\")" "c(\"azolinic acid\", \"cinobac\", \"cinobactin\", \"cinoxacin\", \"cinoxacine\", \"cinoxacino\", \"cinoxacinum\", \"clinoxacin\", \"noxigram\", \"uronorm\")" 1 "g" "character(0)"
|
||||
"CIP" 2764 "Ciprofloxacin" "Quinolones" "c(\"J01MA02\", \"S01AE03\", \"S02AA15\", \"S03AA07\")" "Quinolone antibacterials" "Fluoroquinolones" "c(\"ci\", \"cip\", \"cipr\", \"cp\")" "c(\"alcon cilox\", \"auripro\", \"bacquinor\", \"baflox\", \"baycip\", \"bernoflox\", \"cetraxal\", \"ciflox\", \"cifloxin\", \"ciloxan\", \"ciplus\", \"ciprecu\", \"ciprine\", \"ciprinol\", \"cipro i.v.\", \"cipro iv\", \"cipro xl\", \"cipro xr\", \"ciprobay\", \"ciprobay uro\", \"ciprocinol\", \"ciprodar\", \"ciproflox\", \"ciprofloxacin\", \"ciprofloxacina\", \"ciprofloxacine\", \"ciprofloxacino\", \"ciprofloxacinum\", \"ciprogis\", \"ciprolin\", \"ciprolon\", \"cipromycin\", \"ciproquinol\", \"ciprowin\", \"ciproxan\", \"ciproxin\", \"ciproxina\", \"ciproxine\", \"ciriax\",
|
||||
\"citopcin\", \"corsacin\", \"cyprobay\", \"fimoflox\", \"flociprin\", \"ipiflox\", \"italnik\", \"linhaliq\", \"otiprio\", \"probiox\", \"proflaxin\", \"quinolid\", \"quintor\", \"rancif\", \"roxytal\", \"septicide\", \"sophixin ofteno\", \"spitacin\", \"superocin\", \"velmonit\", \"velomonit\", \"zumaflox\")" 1 "g" 0.8 "g" "c(\"14031-9\", \"14032-7\", \"14058-2\", \"14059-0\", \"25248-6\", \"34636-1\", \"3484-3\")"
|
||||
"CLR" 84029 "Clarithromycin" "Macrolides/lincosamides" "J01FA09" "Macrolides, lincosamides and streptogramins" "Macrolides" "c(\"ch\", \"cla\", \"clar\", \"clm\", \"clr\")" "c(\"abbotic\", \"astromen\", \"biaxin\", \"biaxin filmtab\", \"biaxin hp\", \"biaxin xl\", \"biaxin xl filmtab\", \"bicrolid\", \"clacee\", \"clacid\", \"clacine\", \"clambiotic\", \"clarem\", \"claribid\", \"claricide\", \"claridar\", \"claripen\", \"clarith\", \"clarithromycin\", \"clarithromycine\", \"clarithromycinum\", \"claritromicina\", \"clathromycin\", \"crixan\", \"cyllid\", \"cyllind\", \"fromilid\", \"heliclar\", \"klabax\", \"klacid\", \"klaciped\", \"klaricid\", \"klaricid h.p\", \"klaricid h.p.\", \"klaricid pediatric\", \"klaricid xl\", \"klarid\", \"klarin\",
|
||||
\"kofron\", \"mabicrol\", \"macladin\", \"maclar\", \"veclam\", \"vikrol\", \"zeclar\")" 0.5 "g" 1 "g" "c(\"16619-9\", \"25253-6\", \"34638-7\", \"80559-8\")"
|
||||
"CLA1" 5280980 "Clavulanic acid" "Other antibacterials" "" "c(\"acide clavulanique\", \"acido clavulanico\", \"acidum clavulanicum\", \"clavulanate\", \"clavulanate acid\", \"clavulanate lithium\", \"clavulanic acid\", \"clavulansaeure\", \"clavulansaure\", \"clavulinic acid\", \"clavulox\", \"sodium clavulanate\")" "character(0)"
|
||||
"CLX" 60063 "Clinafloxacin" "Quinolones" "" "clinafloxacin" "character(0)"
|
||||
"CLI" 446598 "Clindamycin" "Macrolides/lincosamides" "c(\"D10AF01\", \"G01AA10\", \"J01FF01\")" "Macrolides, lincosamides and streptogramins" "Lincosamides" "c(\"cc\", \"cd\", \"cli\", \"clin\", \"cm\", \"da\")" "c(\"antirobe\", \"chlolincocin\", \"clindaderm\", \"clindamicina\", \"clindamycin\", \"clindamycine\", \"clindamycinum\", \"clinimycin\", \"dalacin c\", \"dalacine\", \"klimicin\", \"sobelin\")" 1.2 "g" 1.8 "g" "c(\"16621-5\", \"16622-3\", \"25249-4\", \"3486-8\")"
|
||||
"CLF" 2794 "Clofazimine" "Antimycobacterials" "J04BA01" "Drugs for treatment of lepra" "Drugs for treatment of lepra" "clof" "c(\"chlofazimine\", \"clofazimin\", \"clofazimina\", \"clofazimine\", \"clofaziminum\", \"lampren\", \"lamprene\", \"riminophenazine\")" 0.1 "g" "character(0)"
|
||||
"CLF1" 2799 "Clofoctol" "Other antibacterials" "J01XX03" "Other antibacterials" "Other antibacterials" "" "c(\"clofoctol\", \"clofoctolo\", \"clofoctolum\", \"gramplus\", \"octofene\")" "character(0)"
|
||||
"CLM" 71807 "Clometocillin" "Beta-lactams/penicillins" "J01CE07" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"chlomethocillin\", \"clometacillin\", \"clometocilina\", \"clometocillin\", \"clometocilline\", \"clometocillinum\", \"rixapen\")" 1 "g" "character(0)"
|
||||
"CLM1" 54680675 "Clomocycline" "Tetracyclines" "J01AA11" "Tetracyclines" "Tetracyclines" "" "c(\"chlormethylencycline\", \"clomociclina\", \"clomocyclin\", \"clomocycline\", \"clomocyclinum\", \"megaclor\")" 1 "g" "character(0)"
|
||||
"CTR" 2812 "Clotrimazole" "Antifungals/antimycotics" "c(\"A01AB18\", \"D01AC01\", \"G01AF02\")" "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)"
|
||||
"CLO" 6098 "Cloxacillin" "Beta-lactams/penicillins" "J01CF02" "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" 5311054 "Colistin" "Polymyxins" "c(\"A07AA10\", \"J01XB01\")" "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" 9 "MU" "c(\"16645-4\", \"29493-4\")"
|
||||
"COP" "Colistin/polysorbate" "Other antibacterials" "" "" ""
|
||||
"CYC" 6234 "Cycloserine" "Oxazolidinones" "J04AB01" "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" 23724878 "Dalbavancin" "Glycopeptides" "J01XA04" "Other antibacterials" "Glycopeptide antibacterials" "dalb" "c(\"dalbavancin\", \"dalvance\")" 1.5 "g" "character(0)"
|
||||
"DAN" 71335 "Danofloxacin" "Quinolones" "" "c(\"advocin\", \"danofloxacin\", \"danofloxacine\", \"danofloxacino\", \"danofloxacinum\")" "character(0)"
|
||||
"DPS" 2955 "Dapsone" "Other antibacterials" "c(\"D10AX05\", \"J04BA02\")" "Drugs for treatment of lepra" "Drugs for treatment of lepra" "" "c(\"aczone\", \"araldite ht\", \"atrisone\", \"avlosulfon\", \"avlosulfone\", \"avlosulphone\", \"avsulfor\", \"bis sulfone\", \"bissulfone\", \"bissulphone\", \"croysulfone\", \"croysulphone\", \"dapson\", \"dapsona\", \"dapsone\", \"dapsonum\", \"di sulfone\", \"diaphenyl sulfone\", \"diaphenylsulfon\", \"diaphenylsulfone\", \"diaphenylsulphon\", \"diaphenylsulphone\", \"dimitone\", \"diphenasone\", \"diphone\", \"disulfone\", \"disulone\", \"disulphone\", \"dubronax\", \"dubronaz\", \"dumitone\", \"eporal\", \"metabolite c\", \"novophone\", \"protogen\", \"servidapson\",
|
||||
\"slphadione\", \"sulfadione\", \"sulfona\", \"sulfone ucb\", \"sulfonyldianiline\", \"sulphadione\", \"sulphonyldianiline\", \"sumicure s\", \"tarimyl\", \"udolac\", \"wln: zr dswr dz\")" 50 "mg" "9747-7"
|
||||
"DAP" 16134395 "Daptomycin" "Other antibacterials" "J01XX09" "Other antibacterials" "Other antibacterials" "c(\"dap\", \"dapt\")" "c(\"cidecin\", \"cubicin\", \"dapcin\", \"daptomicina\", \"daptomycine\", \"daptomycinum\")" 0.28 "g" "character(0)"
|
||||
"DFX" 487101 "Delafloxacin" "Quinolones" "J01MA23" "" "c(\"baxdela\", \"delafloxacin\", \"delafloxacinum\")" 0.9 "g" 0.6 "g" "character(0)"
|
||||
"DLM" 6480466 "Delamanid" "Antimycobacterials" "J04AK06" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "dela" "c(\"delamanid\", \"deltyba\")" 0.2 "g" "character(0)"
|
||||
"DEM" 54680690 "Demeclocycline" "Tetracyclines" "c(\"D06AA01\", \"J01AA01\")" "Tetracyclines" "Tetracyclines" "" "c(\"bioterciclin\", \"clortetrin\", \"deganol\", \"demeclociclina\", \"demeclocycline\", \"demeclocyclinum\", \"demeclor\", \"demetraclin\", \"diuciclin\", \"elkamicina\", \"ledermycin\", \"mexocine\", \"novotriclina\", \"perciclina\", \"sumaclina\")" 0.6 "g" "c(\"10982-7\", \"29494-2\")"
|
||||
"DKB" 470999 "Dibekacin" "Aminoglycosides" "J01GB09" "Aminoglycoside antibacterials" "Other aminoglycosides" "" "c(\"debecacin\", \"dibekacin\", \"dibekacin sulfate\", \"dibekacina\", \"dibekacine\", \"dibekacinum\", \"dideoxykanamycin b\", \"kappati\", \"orbicin\", \"panamicin\")" 0.14 "g" "character(0)"
|
||||
"DIC" 18381 "Dicloxacillin" "Beta-lactams/penicillins" "J01CF01" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "c(\"\", \"dicl\")" "c(\"dichloroxacillin\", \"diclossacillina\", \"dicloxaciclin\", \"dicloxacilin\", \"dicloxacilina\", \"dicloxacillin\", \"dicloxacillin sodium\", \"dicloxacillina\", \"dicloxacilline\", \"dicloxacillinum\", \"dicloxacycline\", \"dycill\", \"dynapen\", \"maclicine\", \"nm|| dicloxacillin\", \"pathocil\")" 2 "g" 2 "g" "c(\"10984-3\", \"16769-2\", \"25252-8\")"
|
||||
"DIF" 56206 "Difloxacin" "Quinolones" "" "difloxacin" "character(0)"
|
||||
"DIR" 6473883 "Dirithromycin" "Macrolides/lincosamides" "J01FA13" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"dirithromycin\", \"dirithromycine\", \"dirithromycinum\", \"diritromicina\", \"divitross\", \"dynabac\", \"noriclan\", \"valodin\")" 0.5 "g" "character(0)"
|
||||
"DOR" 73303 "Doripenem" "Carbapenems" "J01DH04" "Other beta-lactam antibacterials" "Carbapenems" "dori" "c(\"doribax\", \"doripenem\", \"doripenem hydrate\", \"finibax\")" 1.5 "g" "character(0)"
|
||||
"DOX" 54671203 "Doxycycline" "Tetracyclines" "c(\"A01AB22\", \"J01AA02\")" "Tetracyclines" "Tetracyclines" "c(\"dox\", \"doxy\")" "c(\"atridox\", \"azudoxat\", \"deoxymykoin\", \"dossiciclina\", \"doxcycline anhydrous\", \"doxiciclina\", \"doxitard\", \"doxivetin\", \"doxycen\", \"doxychel\", \"doxycin\", \"doxycyclin\", \"doxycycline\", \"doxycycline calcium\", \"doxycycline hyclate\", \"doxycyclinum\", \"doxylin\", \"doxysol\", \"doxytec\", \"doxytetracycline\", \"hydramycin\", \"investin\", \"jenacyclin\", \"liviatin\", \"monodox\", \"oracea\", \"periostat\", \"ronaxan\", \"spanor\", \"supracyclin\", \"vibramycin\", \"vibramycin novum\", \"vibramycine\", \"vibravenos\", \"zenavod\")" 0.1 "g" 0.1 "g" "c(\"10986-8\", \"21250-6\", \"26902-7\")"
|
||||
"ECO" 3198 "Econazole" "Antifungals/antimycotics" "c(\"D01AC03\", \"G01AF05\")" "Antifungals for topical use" "Imidazole and triazole derivatives" "econ" "c(\"econazol\", \"econazole\", \"econazolum\", \"ecostatin\", \"ecostatin cream\", \"palavale\", \"pevaryl\", \"spectazole\", \"spectazole cream\")" "character(0)"
|
||||
"ENX" 3229 "Enoxacin" "Quinolones" "J01MA04" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"enox\")" "c(\"almitil\", \"bactidan\", \"bactidron\", \"comprecin\", \"enofloxacine\", \"enoksetin\", \"enoram\", \"enoxacin\", \"enoxacina\", \"enoxacine\", \"enoxacino\", \"enoxacinum\", \"enoxen\", \"enoxin\", \"enoxor\", \"flumark\", \"penetrex\")" 0.8 "g" "c(\"16816-1\", \"3590-7\")"
|
||||
"ENR" 71188 "Enrofloxacin" "Quinolones" "" "c(\"baytril\", \"enrofloxacin\", \"enrofloxacine\", \"enrofloxacino\", \"enrofloxacinum\")" "character(0)"
|
||||
"ENV" 135565326 "Enviomycin" "Antimycobacterials" "c(\"\", \"tuberactinomycin\")" "c(\"enviomicina\", \"enviomycin\", \"enviomycina\", \"enviomycinum\")" "character(0)"
|
||||
"EPE" "Eperozolid" "Other antibacterials" "" "" ""
|
||||
"EPC" 71392 "Epicillin" "Beta-lactams/penicillins" "J01CA07" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"dexacillin\", \"dihydroampicillin\", \"epicilina\", \"epicillin\", \"epicilline\", \"epicillinum\")" 2 "g" 2 "g" "character(0)"
|
||||
"EPP" 68916 "Epiroprim" "Other antibacterials" "" "c(\"epiroprim\", \"epiroprima\", \"epiroprime\", \"epiroprimum\")" "character(0)"
|
||||
"ERV" 54726192 "Eravacycline" "Tetracyclines" "J01AA13" "Tetracyclines" "Tetracyclines" "erav" "eravacycline" "character(0)"
|
||||
"ETP" 150610 "Ertapenem" "Carbapenems" "J01DH03" "Other beta-lactam antibacterials" "Carbapenems" "c(\"erta\", \"etp\")" "c(\"ertapenem\", \"invanz\")" 1 "g" "character(0)"
|
||||
"ERY" 12560 "Erythromycin" "Macrolides/lincosamides" "c(\"D10AF02\", \"J01FA01\", \"S01AA17\")" "Macrolides, lincosamides and streptogramins" "Macrolides" "c(\"e\", \"em\", \"ery\", \"eryt\")" "c(\"abboticin\", \"abomacetin\", \"acneryne\", \"acnesol\", \"akne cordes losung\", \"aknederm ery gel\", \"aknemycin\", \"austrias\", \"benzamycin\", \"derimer\", \"deripil\", \"dotycin\", \"dumotrycin\", \"emuvin\", \"emycin\", \"endoeritrin\", \"erecin\", \"erisone\", \"eritomicina\", \"eritrocina\", \"eritromicina\", \"ermycin\", \"eryacne\", \"eryacnen\", \"eryc sprinkles\", \"erycen\", \"erycette\", \"erycin\", \"erycinum\", \"eryderm\", \"erydermer\", \"erygel\", \"eryhexal\", \"erymax\", \"erymed\", \"erysafe\", \"erytab\", \"erythrocin\", \"erythrocin stearate\",
|
||||
\"erythroderm\", \"erythrogran\", \"erythroguent\", \"erythromid\", \"erythromycin\", \"erythromycin a\", \"erythromycin base\", \"erythromycin lactate\", \"erythromycine\", \"erythromycines\", \"erythromycinum\", \"erytop\", \"erytrociclin\", \"ilocaps\", \"ilosone\", \"iloticina\", \"ilotycin\", \"ilotycin gluceptate\", \"ilotycin t.s.\", \"inderm\", \"inderm gel\", \"indermretcin\", \"latotryd\", \"lederpax\", \"mephamycin\", \"mercina\", \"oftamolets\", \"paediathrocin\", \"pantoderm\", \"pantodrin\", \"pantomicina\", \"pce dispertab\", \"pharyngocin\", \"primacine\",
|
||||
\"propiocine\", \"proterytrin\", \"retcin\", \"robimycin\", \"romycin\", \"sansac\", \"skid gel e\", \"staticin\", \"stiemicyn\", \"stiemycin\", \"theramycin z\", \"tiloryth\", \"tiprocin\", \"torlamicina\", \"udima ery gel\", \"wyamycin s\")" 2 "g" 1 "g" "c(\"12298-6\", \"16829-4\", \"25275-9\", \"3597-2\")"
|
||||
"ETH" 14052 "Ethambutol" "Antimycobacterials" "J04AK02" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "etha" "c(\"aethambutolum\", \"ebutol\", \"etambutol\", \"etambutolo\", \"etapiam\", \"ethambutol\", \"ethambutolum\", \"myambutol\", \"mycobutol\", \"purderal\", \"servambutol\")" 1.2 "g" 1.2 "g" "c(\"25404-5\", \"3607-9\")"
|
||||
"ETI" 456476 "Ethambutol/isoniazid" "Antimycobacterials" "J04AM03" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" ""
|
||||
"ETI1" 2761171 "Ethionamide" "Antimycobacterials" "J04AD03" "Drugs for treatment of tuberculosis" "Thiocarbamide derivatives" "ethi" "c(\"aethionamidum\", \"aetina\", \"aetiva\", \"amidazin\", \"amidazine\", \"ethatyl\", \"ethimide\", \"ethina\", \"ethinamide\", \"ethionamide\", \"ethionamidum\", \"ethioniamide\", \"ethylisothiamide\", \"ethyonomide\", \"etimid\", \"etiocidan\", \"etionamid\", \"etionamida\", \"etionamide\", \"etioniamid\", \"etionid\", \"etionizin\", \"etionizina\", \"etionizine\", \"fatoliamid\", \"iridocin\", \"iridocin bayer\", \"iridozin\", \"isothin\", \"isotiamida\", \"itiocide\", \"nicotion\", \"nisotin\", \"nizotin\", \"rigenicid\", \"sertinon\", \"teberus\", \"thianid\", \"thianide\",
|
||||
\"thioamide\", \"thiodine\", \"thiomid\", \"thioniden\", \"tianid\", \"tiomid\", \"trecator\", \"trecator sc\", \"trekator\", \"trescatyl\", \"trescazide\", \"tubenamide\", \"tubermin\", \"tuberoid\", \"tuberoson\")" 0.75 "g" "16845-0"
|
||||
"ETO" 6034 "Ethopabate" "Other antibacterials" "" "c(\"amprol plus\", \"ethopabat\", \"ethopabate\", \"ethyl pabate\")" "character(0)"
|
||||
"EXE" "Exebacase" "" "" ""
|
||||
"FAR" 65894 "Faropenem" "Other antibacterials" "J01DI03" "Other beta-lactam antibacterials" "Other cephalosporins and penems" "" "c(\"faropenem\", \"faropenem sodium\", \"fropenem\", \"fropenum sodium\")" 0.75 "g" "character(0)"
|
||||
"FDX" 10034073 "Fidaxomicin" "Other antibacterials" "A07AA12" "" "c(\"dificid\", \"dificlir\", \"difimicin\", \"fidaxomicin\", \"lipiarmycin\", \"tiacumicin b\")" 0.4 "g" "character(0)"
|
||||
"FIN" 11567473 "Finafloxacin" "Quinolones" "" "finafloxacin" "character(0)"
|
||||
"FLA" 46783781 "Flavomycin" "Other antibacterials" "" "moenomycin complex" "character(0)"
|
||||
"FLE" 3357 "Fleroxacin" "Quinolones" "J01MA08" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"fler\")" "c(\"fleroxacin\", \"fleroxacine\", \"fleroxacino\", \"fleroxacinum\", \"fleroxicin\", \"megalocin\", \"megalone\", \"megalosin\", \"quinodis\")" 0.4 "g" 0.4 "g" "character(0)"
|
||||
"FLO" 65864 "Flomoxef" "Other antibacterials" "J01DC14" "" "c(\"flomoxef\", \"flomoxefo\", \"flomoxefum\")" 2 "g" "character(0)"
|
||||
"FLR" 114811 "Florfenicol" "Other antibacterials" "" "c(\"aquafen\", \"florfenicol\", \"nuflor\", \"nuflor gold\")" "87599-7"
|
||||
"FLC" 21319 "Flucloxacillin" "Beta-lactams/penicillins" "J01CF05" "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" 3365 "Fluconazole" "Antifungals/antimycotics" "c(\"D01AC15\", \"J02AC01\")" "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" 3374 "Flumequine" "Quinolones" "J01MB07" "Quinolone antibacterials" "Other quinolones" "" "c(\"apurone\", \"fantacin\", \"flumequine\", \"flumequino\", \"flumequinum\", \"flumigal\", \"flumiquil\", \"flumisol\", \"flumix\", \"imequyl\")" 1.2 "g" "character(0)"
|
||||
"FLR1" 71260 "Flurithromycin" "Macrolides/lincosamides" "J01FA14" "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)"
|
||||
"FOS" 446987 "Fosfomycin" "Other antibacterials" "J01XX01" "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)"
|
||||
"FRM" 8378 "Framycetin" "Aminoglycosides" "c(\"D09AA01\", \"R01AX08\", \"S01AA07\")" "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)"
|
||||
"FRZ" 5323714 "Furazolidone" "Other antibacterials" "G01AX06" "" "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)"
|
||||
"FUS" 3000226 "Fusidic acid" "Other antibacterials" "c(\"D06AX01\", \"D09AA02\", \"J01XC01\", \"S01AA13\")" "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)"
|
||||
"GRN" 124093 "Garenoxacin" "Quinolones" "J01MA19" "" "c(\"ganefloxacin\", \"garenfloxacin\", \"garenoxacin\")" 0.4 "g" "character(0)"
|
||||
"GAT" 5379 "Gatifloxacin" "Quinolones" "c(\"J01MA16\", \"S01AE06\")" "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" 9571107 "Gemifloxacin" "Quinolones" "J01MA15" "Quinolone antibacterials" "Fluoroquinolones" "" "c(\"factiv\", \"factive\", \"gemifioxacin\", \"gemifloxacin\", \"gemifloxacine\", \"gemifloxacino\", \"gemifloxacinum\")" 0.32 "g" "character(0)"
|
||||
"GEN" 3467 "Gentamicin" "Aminoglycosides" "c(\"D06AX07\", \"J01GB03\", \"S01AA11\", \"S02AA14\", \"S03AA06\")" "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(\"gehi\", \"gehl\", \"genta high\", \"gentamicin high\")" "" ""
|
||||
"GEP" 25101874 "Gepotidacin" "Other antibacterials" "" "gepotidacin" "character(0)"
|
||||
"GRX" 72474 "Grepafloxacin" "Quinolones" "J01MA11" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"grep\")" "grepafloxacin" 0.4 "g" "character(0)"
|
||||
"GRI" 441140 "Griseofulvin" "Antifungals/antimycotics" "c(\"D01AA08\", \"D01BA01\")" "" "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\",
|
||||
\"grisovin\", \"grisovin fp\", \"grizeofulvin\", \"grysio\", \"guservin\", \"lamoryl\", \"likuden\", \"likunden\", \"murfulvin\", \"poncyl\", \"spirofulvin\", \"sporostatin xan\", \"xuanjing\")" 0.5 "g" "12402-4"
|
||||
"HAB" 175989 "Habekacin" "Aminoglycosides" "" "c(\"arbekacin sulfate\", \"habekacin\", \"habekacin sulfate\", \"habekacin xsulfate\")" "character(0)"
|
||||
"HCH" 11979956 "Hachimycin" "Antifungals/antimycotics" "c(\"D01AA03\", \"G01AA06\", \"J02AA02\")" "Antimycotics for systemic use" "Antibiotics" "" "c(\"cabimicina\", \"hachimicina\", \"hachimycin\", \"hachimycine\", \"hachimycinum\", \"trichomycinum\", \"trichonat\")" "character(0)"
|
||||
"HET" 443387 "Hetacillin" "Beta-lactams/penicillins" "J01CA18" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"etacillina\", \"hetacilina\", \"hetacillin\", \"hetacilline\", \"hetacillinum\", \"phenazacillin\", \"versapen\")" 2 "g" "character(0)"
|
||||
"HYG" 56928061 "Hygromycin" "Aminoglycosides" "" "c(\"antihelmycin\", \"hydromycin b\", \"hygrovetine\")" "character(0)"
|
||||
"IBX" "Ibrexafungerp" "Antifungals" "" "" ""
|
||||
"ICL" 213043 "Iclaprim" "Other antibacterials" "J01EA03" "" "c(\"iclaprim\", \"mersarex\")" "character(0)"
|
||||
"IPM" 104838 "Imipenem" "Carbapenems" "J01DH51" "Other beta-lactam antibacterials" "Carbapenems" "c(\"imci\", \"imi\", \"imip\", \"imp\")" "c(\"imipemide\", \"imipenem\", \"imipenem anhydrous\", \"imipenem/cilastatin\", \"imipenemum\", \"imipenen\", \"primaxin\", \"tienamycin\")" 2 "g" "c(\"17010-0\", \"25257-7\", \"27331-8\", \"3688-9\")"
|
||||
"IPE" "Imipenem/EDTA" "Carbapenems" "" "" ""
|
||||
"IMR" "Imipenem/relebactam" "Carbapenems" "" "" ""
|
||||
"ISV" 6918485 "Isavuconazole" "Antifungals/antimycotics" "J02AC05" "c(\"\", \"isav\")" "isavuconazole" 0.2 "g" 0.2 "g" "character(0)"
|
||||
"ISE" 3037209 "Isepamicin" "Aminoglycosides" "J01GB11" "Aminoglycoside antibacterials" "Other aminoglycosides" "" "c(\"isepacin\", \"isepalline\", \"isepamicin\", \"isepamicina\", \"isepamicine\", \"isepamicinum\")" 0.4 "g" "character(0)"
|
||||
"ISO" 3760 "Isoconazole" "Antifungals/antimycotics" "c(\"D01AC05\", \"G01AF07\")" "Antimycotics for topic use" "Triazole derivatives" "" "c(\"isoconazol\", \"isoconazole\", \"isoconazolum\", \"travogen\")" "character(0)"
|
||||
"INH" 3767 "Isoniazid" "Antimycobacterials" "J04AC01" "Drugs for treatment of tuberculosis" "Hydrazides" "inh" "c(\"abdizide\", \"andrazide\", \"anidrasona\", \"antimicina\", \"antituberkulosum\", \"armacide\", \"armazid\", \"armazide\", \"atcotibine\", \"azt + isoniazid\", \"azuren\", \"bacillin\", \"cemidon\", \"chemiazid\", \"chemidon\", \"continazine\", \"cortinazine\", \"cotinazin\", \"cotinizin\", \"defonin\", \"dibutin\", \"diforin\", \"dinacrin\", \"ditubin\", \"ebidene\", \"eralon\", \"ertuban\", \"eutizon\", \"evalon\", \"fetefu\", \"fimalene\", \"hid rasonil\", \"hidranizil\", \"hidrasonil\", \"hidrulta\", \"hidrun\", \"hycozid\", \"hydrazid\", \"hydrazide\", \"hyozid\", \"i.a.i.\",
|
||||
\"idrazil\", \"inizid\", \"iscotin\", \"isidrina\", \"ismazide\", \"isobicina\", \"isocid\", \"isocidene\", \"isocotin\", \"isohydrazide\", \"isokin\", \"isolyn\", \"isonerit\", \"isonex\", \"isoniacid\", \"isoniazid\", \"isoniazid sa\", \"isoniazida\", \"isoniazide\", \"isoniazidum\", \"isonicazide\", \"isonicid\", \"isonico\", \"isonicotan\", \"isonicotil\", \"isonicotinhydrazid\", \"isonicotinohydrazide\", \"isonide\", \"isonidrin\", \"isonikazid\", \"isonilex\", \"isonin\", \"isonindon\", \"isonirit\", \"isoniton\", \"isonizida\", \"isonizide\", \"isotamine\", \"isotebe\",
|
||||
\"isotebezid\", \"isotinyl\", \"isozid\", \"isozide\", \"isozyd\", \"laniazid\", \"laniozid\", \"lanizid\", \"mayambutol\", \"mybasan\", \"neoteben\", \"neoxin\", \"neumandin\", \"niadrin\", \"nicazide\", \"nicetal\", \"nicizina\", \"niconyl\", \"nicotibina\", \"nicotibine\", \"nicotisan\", \"nicozide\", \"nidaton\", \"nidrazid\", \"nikozid\", \"niplen\", \"nitadon\", \"niteban\", \"nydrazid\", \"nyscozid\", \"pelazid\", \"percin\", \"phthisen\", \"pycazide\", \"pyreazid\", \"pyricidin\", \"pyridicin\", \"pyrizidin\", \"raumanon\", \"razide\", \"retozide\", \"rifater\", \"rimicid\",
|
||||
\"rimifon\", \"rimiphone\", \"rimitsid\", \"robiselin\", \"robisellin\", \"roxifen\", \"sanohidrazina\", \"sauterazid\", \"sauterzid\", \"stanozide\", \"tebecid\", \"tebenic\", \"tebexin\", \"tebilon\", \"teebaconin\", \"tekazin\", \"tibazide\", \"tibemid\", \"tibiazide\", \"tibinide\", \"tibison\", \"tibivis\", \"tibizide\", \"tibusan\", \"tisiodrazida\", \"tizide\", \"tubazid\", \"tubazide\", \"tubeco\", \"tubecotubercid\", \"tuberian\", \"tubicon\", \"tubilysin\", \"tubizid\", \"tubomel\", \"unicocyde\", \"unicozyde\", \"vazadrine\", \"vederon\", \"zidafimia\", \"zinadon\",
|
||||
\"zonazide\")" 0.3 "g" 0.3 "g" "c(\"25451-6\", \"26756-7\", \"3697-0\", \"40371-7\")"
|
||||
"ITR" 3793 "Itraconazole" "Antifungals/antimycotics" "J02AC02" "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" 5282165 "Josamycin" "Macrolides/lincosamides" "J01FA07" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"josacine\", \"josamicina\", \"josamycin\", \"josamycine\", \"josamycinum\")" 2 "g" "character(0)"
|
||||
"KAN" 6032 "Kanamycin" "Aminoglycosides" "c(\"A07AA08\", \"J01GB04\", \"S01AA24\")" "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\")" 3 "g" 1 "g" "c(\"23889-9\", \"3698-8\", \"3699-6\", \"3700-2\", \"47395-9\")"
|
||||
"KAH" "Kanamycin-high" "Aminoglycosides" "c(\"\", \"k_h\", \"kahl\")" "" ""
|
||||
"KAC" "Kanamycin/cephalexin" "Aminoglycosides" "" "" ""
|
||||
"KET" 456201 "Ketoconazole" "Antifungals/antimycotics" "c(\"D01AC08\", \"G01AF11\", \"H02CA03\", \"J02AB02\")" "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" "Macrolides/lincosamides" "c(\"\", \"leucomycin\")" "" ""
|
||||
"LAS" 5360807 "Lasalocid" "Other antibacterials" "" "c(\"avatec\", \"lasalocid\", \"lasalocid a\", \"lasalocide\", \"lasalocide a\", \"lasalocido\", \"lasalocidum\")" "87598-9"
|
||||
"LTM" 47499 "Latamoxef" "Cephalosporins (3rd gen.)" "J01DD06" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "c(\"mox\", \"moxa\", \"moxalactam\")" "c(\"disodium moxalactam\", \"festamoxin\", \"lamoxactam\", \"latamoxef\", \"latamoxefum\", \"shiomarin\")" 4 "g" "character(0)"
|
||||
"LMU" 25185057 "Lefamulin" "Other antibacterials" "J01XX12" "" "lefamulin" "character(0)"
|
||||
"LEN" 65646 "Lenampicillin" "Beta-lactams/penicillins" "" "c(\"lenampicilina\", \"lenampicillin\", \"lenampicillin hcl\", \"lenampicilline\", \"lenampicillinum\")" "character(0)"
|
||||
"LVX" 149096 "Levofloxacin" "Quinolones" "c(\"J01MA12\", \"S01AE05\")" "Quinolone antibacterials" "Fluoroquinolones" "c(\"le\", \"lev\", \"levo\", \"lvx\")" "c(\"aeroquin\", \"cravit\", \"cravit hydrate\", \"cravit iv\", \"cravit ophthalmic\", \"elequine\", \"floxacin\", \"floxel\", \"iquix hydrate\", \"leroxacin\", \"lesacin\", \"levaquin\", \"levaquin hydrate\", \"levo floxacin\", \"levofiexacin\", \"levofloxacin\", \"levofloxacin hydrate\", \"levofloxacine\", \"levofloxacino\", \"levofloxacinum\", \"levokacin\", \"levoxacin\", \"mosardal\", \"nofaxin\", \"oftaquix\", \"quixin\", \"reskuin\", \"tavanic\", \"unibiotic\", \"venaxan\", \"volequin\")" 0.5 "g" 0.5 "g" "c(\"21368-6\", \"30532-6\", \"30533-4\")"
|
||||
"LND" 9850038 "Levonadifloxacin" "Quinolones" "J01MA24" "" "levonadifloxacin" "character(0)"
|
||||
"LSP" "Linco-spectin" "Other antibacterials" "c(\"\", \"lincomycin/spectinomycin\")" "" ""
|
||||
"LIN" 3000540 "Lincomycin" "Macrolides/lincosamides" "J01FF02" "Macrolides, lincosamides and streptogramins" "Lincosamides" "linc" "c(\"cillimycin\", \"jiemycin\", \"lincolcina\", \"lincolnensin\", \"lincomicina\", \"lincomycin\", \"lincomycin a\", \"lincomycine\", \"lincomycinum\")" 1.8 "g" 1.8 "g" "87597-1"
|
||||
"LNZ" 441401 "Linezolid" "Oxazolidinones" "J01XX08" "Other antibacterials" "Other antibacterials" "c(\"line\", \"lnz\", \"lz\", \"lzd\")" "c(\"linezlid\", \"linezoid\", \"linezolid\", \"linezolide\", \"linezolidum\", \"zivoxid\", \"zyvoxa\", \"zyvoxam\", \"zyvoxid\")" 1.2 "g" 1.2 "g" "c(\"34202-2\", \"80609-1\")"
|
||||
"LFE" "Linoprist-flopristin" "Other antibacterials" "" "" ""
|
||||
"LOM" 3948 "Lomefloxacin" "Quinolones" "c(\"J01MA07\", \"S01AE04\")" "Quinolone antibacterials" "Fluoroquinolones" "c(\"lmf\", \"lom\", \"lome\")" "c(\"lomefloxacin\", \"lomefloxacine\", \"lomefloxacino\", \"lomefloxacinum\", \"maxaquin\")" 0.4 "g" "character(0)"
|
||||
"LOR" 5284585 "Loracarbef" "Cephalosporins (2nd gen.)" "J01DC08" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "c(\"\", \"lora\")" "c(\"anhydrous loracarbef\", \"lorabid\", \"loracarbef\", \"loracarbefum\", \"lorbef\", \"loribid\")" 0.6 "g" "character(0)"
|
||||
"LYM" 54707177 "Lymecycline" "Tetracyclines" "J01AA04" "Tetracyclines" "Tetracyclines" "" "c(\"biovetin\", \"chlortetracyclin\", \"ciclisin\", \"ciclolysal\", \"infaciclina\", \"limeciclina\", \"lisinbiotic\", \"lymecyclin\", \"lymecycline\", \"lymecyclinum\", \"mucomycin\", \"ntetracycline\", \"tetralisal\", \"tetralysal\", \"vebicyclysal\")" 0.6 "g" 0.6 "g" "character(0)"
|
||||
"MNA" 1292 "Mandelic acid" "Other antibacterials" "c(\"B05CA06\", \"J01XX06\")" "Other antibacterials" "Other antibacterials" "" "c(\"acido mandelico\", \"almond acid\", \"amygdalic acid\", \"benzoglycolic acid\", \"hydroxyacetic acid\", \"kyselina mandlova\", \"mandelic acid\", \"paramandelic acid\", \"phenylglycolic acid\", \"uromaline\")" 12 "g" "character(0)"
|
||||
"MGX" "Manogepix" "Antifungals" "" "" ""
|
||||
"MAR" 60651 "Marbofloxacin" "Quinolones" "" "c(\"marbocyl\", \"marbofloxacin\", \"marbofloxacine\", \"marbofloxacino\", \"marbofloxacinum\", \"zeniquin\")" "character(0)"
|
||||
"MEC" 36273 "Mecillinam" "Beta-lactams/penicillins" "J01CA11" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"\", \"amdinocillin\")" "c(\"amdinocillin\", \"coactin\", \"hexacillin\", \"mecilinamo\", \"mecillinam\", \"mecillinamum\", \"micillinam\", \"penicillin hx\", \"selexidin\")" 1.2 "g" "character(0)"
|
||||
"MEL" 71306732 "Meleumycin" "Macrolides/lincosamides" "" "" ""
|
||||
"MEM" 441130 "Meropenem" "Carbapenems" "J01DH02" "Other beta-lactam antibacterials" "Carbapenems" "c(\"mem\", \"mer\", \"mero\", \"mp\", \"mrp\")" "c(\"meronem\", \"meropen\", \"meropenem\", \"meropenem anhydrous\", \"meropenem hydrate\", \"meropenem trihydrate\", \"meropenemum\", \"merrem\", \"merrem i.v.\", \"merrem iv\")" 3 "g" "41406-0"
|
||||
"MNC" "Meropenem/nacubactam" "Carbapenems" "" "" ""
|
||||
"MEV" "Meropenem/vaborbactam" "Carbapenems" "J01DH52" "Other beta-lactam antibacterials" "Carbapenems" "" "" 3 "g" ""
|
||||
"MES" 176886 "Mesulfamide" "Other antibacterials" "" "c(\"mesulfamide\", \"mesulfamido\", \"mesulfamidum\")" "character(0)"
|
||||
"MTC" 54675785 "Metacycline" "Tetracyclines" "J01AA05" "Tetracyclines" "Tetracyclines" "" "c(\"bialatan\", \"metaciclina\", \"metacycline\", \"metacyclinum\", \"methacycline\", \"methacycline base\", \"methacyclinum\", \"methylenecycline\", \"physiomycine\", \"rondomycin\")" 0.6 "g" "character(0)"
|
||||
"MTM" 6713928 "Metampicillin" "Beta-lactams/penicillins" "J01CA14" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"blomopen\", \"bonopen\", \"celinmicina\", \"elatocilline\", \"fedacilina kapseln\", \"filorex\", \"italcina kapseln\", \"magnipen\", \"metabacter ampullen\", \"metambac\", \"metampicilina\", \"metampicillin\", \"metampicillin sodium\", \"metampicillina\", \"metampicilline\", \"metampicillinum\", \"methampicillin\", \"metiskia ampullen\", \"micinovo\", \"micinovo ampullen\", \"pangocilin\", \"probiotic\", \"rastomycin k\", \"relyothenate\", \"ruticina\", \"rutizina\", \"rutizina ampullen\", \"sedomycin\", \"suvipen\", \"suvipen ampullen\", \"tampilen ampullen\",
|
||||
\"teonicon trofen\", \"viderpen\", \"viderpin\", \"vioplex\")" 1.5 "g" 1.5 "g" "character(0)"
|
||||
"MTH" 4101 "Methenamine" "Other antibacterials" "J01XX05" "Other antibacterials" "Other antibacterials" "" "c(\"aceto hmt\", \"aminoform\", \"aminoformaldehyde\", \"ammoform\", \"ammonioformaldehyde\", \"antihydral\", \"cystamin\", \"cystex\", \"cystogen\", \"duirexol\", \"ekagom h\", \"esametilentetramina\", \"formamine\", \"formin\", \"h.m.t.\", \"heksa k\", \"herax uts\", \"heterin\", \"hexa b\", \"hexaform\", \"hexaloids\", \"hexamethylamine\", \"hexamethylenamine\", \"hexamethyleneamine\", \"hexamethylentetramin\", \"hexamine\", \"hexamine silver\", \"hexamine superfine\", \"hexaminum\", \"hexasan\", \"hexilmethylenamine\", \"metenamina\", \"metenamine\", \"methamin\",
|
||||
\"methenamin\", \"methenamine\", \"methenamine silver\", \"methenaminum\", \"metramine\", \"naphthamine\", \"nocceler h\", \"preparation af\", \"resotropin\", \"sanceler h\", \"sanceler ht\", \"silver methenamine\", \"uramin\", \"uratrine\", \"urisol\", \"uritone\", \"urodeine\", \"urotropin\", \"urotropine\", \"vesaloin\", \"vesalvine\", \"xametrin\")" 3 "g" "character(0)"
|
||||
"MET" 6087 "Methicillin" "Beta-lactams/penicillins" "J01CF03" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "meti" "c(\"dimocillin\", \"metacillin\", \"methcilline\", \"methicillin\", \"methicillinum\", \"methycillin\", \"meticilina\", \"meticillin\", \"meticillina\", \"meticilline\", \"meticillinum\", \"staphcillin\")" 4 "g" "c(\"29492-6\", \"3788-7\")"
|
||||
"MTP" 68590 "Metioprim" "Other antibacterials" "" "c(\"methioprim\", \"metioprim\", \"metioprima\", \"metioprime\", \"metioprimum\")" "character(0)"
|
||||
"MXT" 3047729 "Metioxate" "Quinolones" "" "c(\"metioxate\", \"metioxato\", \"metioxatum\")" "character(0)"
|
||||
"MTR" 4173 "Metronidazole" "Other antibacterials" "c(\"A01AB17\", \"D06BX01\", \"G01AF01\", \"J01XD01\", \"P01AB01\")" "Other antibacterials" "Imidazole derivatives" "c(\"metr\", \"mnz\")" "c(\"acromona\", \"anagiardil\", \"arilin\", \"atrivyl\", \"danizol\", \"deflamon\", \"efloran\", \"elyzol\", \"entizol\", \"flagemona\", \"flagesol\", \"flagil\", \"flagyl\", \"flagyl er\", \"flagyl i.v.\", \"flagyl i.v. rtu\", \"flazol\", \"flegyl\", \"florazole\", \"fossyol\", \"giatricol\", \"ginefla vir\", \"gineflavir\", \"helidac\", \"mepagyl\", \"meronidal\", \"methronidazole\", \"metric\", \"metro cream\", \"metro gel\", \"metro i.v\", \"metro i.v.\", \"metro iv\", \"metrocream\", \"metrodzhil\", \"metrogel\", \"metrogyl\", \"metrolag\", \"metrolotion\", \"metrolyl\",
|
||||
\"metromidol\", \"metronidaz\", \"metronidazol\", \"metronidazole\", \"metronidazole usp\", \"metronidazolo\", \"metronidazolum\", \"metrotop\", \"metrozine\", \"metryl\", \"mexibol\", \"mexibol 'silanes'\", \"monagyl\", \"monasin\", \"nidagel\", \"nidagyl\", \"noritate\", \"novonidazol\", \"orvagil\", \"polibiotic\", \"protostat\", \"rathimed\", \"rosased\", \"sanatrichom\", \"satric\", \"takimetol\", \"trichazol\", \"trichex\", \"tricho cordes\", \"trichobrol\", \"trichocide\", \"trichomol\", \"trichopal\", \"trichopol\", \"tricocet\", \"tricom\", \"tricowas b\", \"trikacide\",
|
||||
\"trikamon\", \"trikhopol\", \"trikojol\", \"trikozol\", \"trimeks\", \"trivazol\", \"vagilen\", \"vagimid\", \"vandazole\", \"vertisal\", \"wagitran\", \"zadstat\", \"zidoval\")" 2 "g" 1.5 "g" "10991-8"
|
||||
"MEZ" 656511 "Mezlocillin" "Beta-lactams/penicillins" "J01CA10" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"mez\", \"mezl\", \"mz\")" "c(\"mezlin\", \"mezlocilina\", \"mezlocillin\", \"mezlocillin acid\", \"mezlocillin sodium\", \"mezlocilline\", \"mezlocillinum\", \"multocillin\")" 6 "g" "3820-8"
|
||||
"MSU" "Mezlocillin/sulbactam" "Beta-lactams/penicillins" "" "" ""
|
||||
"MIF" 477468 "Micafungin" "Antifungals/antimycotics" "J02AX05" "Antimycotics for systemic use" "Other antimycotics for systemic use" "c(\"\", \"mica\")" "c(\"micafungin\", \"mycamine\")" 0.1 "g" "58418-5"
|
||||
"MCZ" 4189 "Miconazole" "Antifungals/antimycotics" "c(\"A01AB09\", \"A07AC01\", \"D01AC02\", \"G01AF04\", \"J02AB01\", \"S02AA13\")" "Antimycotics for systemic use" "Imidazole derivatives" "mico" "c(\"aflorix\", \"albistat\", \"andergin\", \"brentan\", \"conofite\", \"dactarin\", \"daktarin\", \"daktarin iv\", \"florid\", \"lotrimin af\", \"micantin\", \"miconasil nitrate\", \"miconazol\", \"miconazole\", \"miconazole base\", \"miconazolo\", \"miconazolum\", \"micozole\", \"minostate\", \"monista\", \"monistat\", \"monistat iv\", \"oravig\", \"vusion\", \"zimybase\", \"zimycan\")" 0.2 "g" 1 "g" "17278-3"
|
||||
"MCR" 3037206 "Micronomicin" "Aminoglycosides" "S01AA22" "" "c(\"gentamicin c\", \"micromycin\", \"micronomicin\", \"micronomicina\", \"micronomicine\", \"micronomicinum\", \"sagamicin\", \"santemycin\")" "character(0)"
|
||||
"MID" 5282169 "Midecamycin" "Macrolides/lincosamides" "J01FA03" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"aboren\", \"espinomycin a\", \"macropen\", \"madecacine\", \"medemycin\", \"midecamicina\", \"midecamycin\", \"midecamycin a\", \"midecamycine\", \"midecamycinum\", \"midecin\", \"momicine\", \"mydecamycin\", \"myoxam\", \"normicina\", \"rubimycin\", \"turimycin p\")" 1.2 "g" 1 "g" "character(0)"
|
||||
"MIL" 37614 "Miloxacin" "Quinolones" "" "c(\"miloxacin\", \"miloxacine\", \"miloxacino\", \"miloxacinum\")" "character(0)"
|
||||
"MNO" 54675783 "Minocycline" "Tetracyclines" "c(\"A01AB23\", \"D10AF07\", \"J01AA08\")" "Tetracyclines" "Tetracyclines" "c(\"mc\", \"mh\", \"mi\", \"min\", \"mino\", \"mn\", \"mno\")" "c(\"akamin\", \"aknemin\", \"borymycin\", \"dynacin\", \"klinomycin\", \"minociclina\", \"minocin\", \"minocline\", \"minocyclin\", \"minocycline\", \"minocyclinum\", \"minocyn\", \"minoderm\", \"minomycin\", \"sebomin\", \"solodyn\", \"vectrin\")" 1 "mg" 0.2 "g" "c(\"34606-4\", \"3822-4\", \"49757-8\")"
|
||||
"MCM" 5282188 "Miocamycin" "Macrolides/lincosamides" "J01FA11" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"acecamycin\", \"macroral\", \"midecamycin acetate\", \"miocamen\", \"miocamycine\", \"miokamycin\", \"myocamicin\", \"ponsinomycin\")" 1.2 "g" "character(0)"
|
||||
"MON" 23667299 "Monensin sodium" "Other antibacterials" "" "c(\"monensin sodium\", \"sodium monensin\")" "character(0)"
|
||||
"MRN" 70374 "Morinamide" "Antimycobacterials" "J04AK04" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "" "c(\"morfazinamide\", \"morfazinammide\", \"morfgazinamide\", \"morinamida\", \"morinamide\", \"morinamidum\", \"morphazinamid\", \"morphazinamide\", \"piazofolina\", \"piazolin\", \"piazolina\")" "character(0)"
|
||||
"MFX" 152946 "Moxifloxacin" "Quinolones" "c(\"J01MA14\", \"S01AE07\")" "Quinolone antibacterials" "Fluoroquinolones" "c(\"mox\", \"moxi\", \"mxf\")" "c(\"actira\", \"avelox\", \"avelox i.v.\", \"avelox iv\", \"avolex\", \"izilox\", \"moxeza\", \"moxifloxacin\", \"moxifloxacine\", \"vigamox\")" 0.4 "g" 0.4 "g" "c(\"43751-7\", \"45223-5\", \"80540-8\")"
|
||||
"MUP" 446596 "Mupirocin" "Other antibacterials" "c(\"D06AX09\", \"R01AX06\")" "c(\"mup\", \"mupi\")" "c(\"bactoderm\", \"bactroban\", \"bactroban nasal\", \"bactroban ointment\", \"centany\", \"mupirocin\", \"mupirocina\", \"mupirocine\", \"mupirocinum\", \"plasimine\", \"pseudomonic acid\", \"pseudomonic acid a\", \"turixin\")" "character(0)"
|
||||
"NAC" 73386748 "Nacubactam" "Beta-lactams/penicillins" "" "nacubactam" "character(0)"
|
||||
"NAD" 4410 "Nadifloxacin" "Quinolones" "D10AF05" "" "c(\"acuatim\", \"nadifloxacin\", \"nadifloxacine\", \"nadifloxacino\", \"nadifloxacinum\", \"nadixa\", \"nadoxin\")" "character(0)"
|
||||
"NAF" 8982 "Nafcillin" "Beta-lactams/penicillins" "J01CF06" "" "c(\"nafcilina\", \"nafcillin\", \"nafcillin sodium\", \"nafcilline\", \"nafcillinum\", \"nallpen\", \"naphcillin\", \"unipen\")" 3 "g" "c(\"10993-4\", \"25232-0\")"
|
||||
"ZWK" 117587595 "Nafithromycin" "Macrolides/lincosamides" "" "nafithromycin" "character(0)"
|
||||
"NAL" 4421 "Nalidixic acid" "Quinolones" "J01MB02" "Quinolone antibacterials" "Other quinolones" "c(\"na\", \"nal\", \"nali\")" "c(\"acide nalidixico\", \"acide nalidixique\", \"acido nalidissico\", \"acido nalidixico\", \"acidum nalidixicum\", \"betaxina\", \"dixiben\", \"dixinal\", \"eucisten\", \"eucistin\", \"innoxalomn\", \"innoxalon\", \"jicsron\", \"kusnarin\", \"naldixic acid\", \"nalidic acid\", \"nalidicron\", \"nalidixan\", \"nalidixane\", \"nalidixate\", \"nalidixate sodium\", \"nalidixic\", \"nalidixic acid\", \"nalidixin\", \"nalidixinic acid\", \"nalidixinsaure\", \"nalitucsan\", \"nalurin\", \"narigix\", \"naxuril\", \"neggram\", \"negram\", \"nevigramon\", \"nicelate\", \"nogram\",
|
||||
\"poleon\", \"sicmylon\", \"specifen\", \"specifin\", \"unaserus\", \"uralgin\", \"uriben\", \"uriclar\", \"urisal\", \"urodixin\", \"uroman\", \"uroneg\", \"uronidix\", \"uropan\", \"wintomylon\", \"wintron\")" 4 "g" "character(0)"
|
||||
"NAR" 65452 "Narasin" "Other antibacterials" "" "c(\"monteban\", \"narasin\", \"narasin a\", \"narasine\", \"narasino\", \"narasinum\", \"narasul\")" "87570-8"
|
||||
"NEO" 8378 "Neomycin" "Aminoglycosides" "c(\"A01AB08\", \"A07AA01\", \"B05CA09\", \"D06AX04\", \"J01GB05\", \"R02AB01\", \"S01AA03\", \"S02AA07\", \"S03AA01\")" "Aminoglycoside antibacterials" "Other aminoglycosides" "neom" "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\")" 5 "g" "c(\"10995-9\", \"25262-7\")"
|
||||
"NET" 441306 "Netilmicin" "Aminoglycosides" "c(\"J01GB07\", \"S01AA23\")" "Aminoglycoside antibacterials" "Other aminoglycosides" "neti" "c(\"netillin\", \"netilmicin\", \"netilmicin sulfate\", \"netilmicina\", \"netilmicine\", \"netilmicinum\", \"netilyn\", \"netira\", \"vectacin\")" 0.35 "g" 0.35 "g" "c(\"25263-5\", \"3848-9\", \"3849-7\", \"3850-5\", \"47385-0\", \"59565-2\", \"59566-0\", \"59567-8\")"
|
||||
"NIC" 9507 "Nicarbazin" "Other antibacterials" "" "c(\"nicarb\", \"nicarbasin\", \"nicarbazin\", \"nicarbazine\", \"nicoxin\", \"nicrazin\", \"nicrazine\", \"nirazin\")" "character(0)"
|
||||
"NIF" 71946 "Nifuroquine" "Quinolones" "" "c(\"nifuroquina\", \"nifuroquine\", \"nifuroquinum\", \"quinaldofur\")" "character(0)"
|
||||
"NFR" 9571062 "Nifurtoinol" "Other antibacterials" "J01XE02" "Other antibacterials" "Nitrofuran derivatives" "" "c(\"levantin\", \"nifurtoinol\", \"nifurtoinolo\", \"nifurtoinolum\", \"urfadin\", \"urfadine\", \"urfadyn\")" 0.16 "g" "character(0)"
|
||||
"NTZ" 41684 "Nitazoxanide" "Other antibacterials" "P01AX11" "" "c(\"adrovet\", \"alinia\", \"azt + nitazoxanide\", \"colufase\", \"cryptaz\", \"dexidex\", \"heliton\", \"kidonax\", \"nitaxozanid\", \"nitaxozanide\", \"nitazox\", \"nitazoxamide\", \"nitazoxanid\", \"nitazoxanida\", \"nitazoxanide\", \"nitazoxanidum\", \"omniparax\", \"pacovanton\", \"paramix\", \"taenitaz\")" 1 "g" "character(0)"
|
||||
"NIT" 6604200 "Nitrofurantoin" "Other antibacterials" "J01XE01" "Other antibacterials" "Nitrofuran derivatives" "c(\"f\", \"f/m\", \"fd\", \"ft\", \"ni\", \"nit\", \"nitr\")" "c(\"alfuran\", \"benkfuran\", \"berkfuran\", \"berkfurin\", \"ceduran\", \"chemiofuran\", \"cistofuran\", \"cyantin\", \"cystit\", \"dantafur\", \"fua med\", \"fuamed\", \"furabid\", \"furachel\", \"furadantin\", \"furadantin retard\", \"furadantina mc\", \"furadantine\", \"furadantine mc\", \"furadantoin\", \"furadoin\", \"furadoine\", \"furadonin\", \"furadonine\", \"furadoninum\", \"furadontin\", \"furadoxyl\", \"furalan\", \"furaloid\", \"furantoin\", \"furantoina\", \"furatoin\", \"furedan\", \"furina\", \"furobactina\", \"furodantin\", \"furophen t\", \"gerofuran\",
|
||||
\"io>>uss>>a<<ixoo\", \"ituran\", \"ivadantin\", \"macpac\", \"macrobid\", \"macrodantin\", \"macrodantina\", \"macrofuran\", \"macrofurin\", \"nierofu\", \"nifurantin\", \"nifuretten\", \"nitoin\", \"nitrex\", \"nitrofuradantin\", \"nitrofurantion\", \"nitrofurantoin\", \"nitrofurantoin macro\", \"nitrofurantoina\", \"nitrofurantoine\", \"nitrofurantoinum\", \"novofuran\", \"orafuran\", \"parfuran\", \"phenurin\", \"piyeloseptyl\", \"siraliden\", \"trantoin\", \"uerineks\", \"urantoin\", \"urizept\", \"urodin\", \"urofuran\", \"urofurin\", \"urolisa\", \"urolong\",
|
||||
\"uvamin\", \"welfurin\", \"zoofurin\")" 0.2 "g" "3860-4"
|
||||
"NIZ" 5447130 "Nitrofurazone" "Other antibacterials" "" "c(\"acutol\", \"aldomycin\", \"alfucin\", \"amifur\", \"babrocid\", \"becafurazone\", \"biofuracina\", \"biofurea\", \"chemofuran\", \"chixin\", \"cocafurin\", \"coxistat\", \"dermofural\", \"dymazone\", \"dynazone\", \"eldezol\", \"fedacin\", \"flavazone\", \"fracine\", \"furacilin\", \"furacilinum\", \"furacillin\", \"furacin\", \"furacine\", \"furacinetten\", \"furacoccid\", \"furacort\", \"furacycline\", \"furaderm\", \"furagent\", \"furalcyn\", \"furaldon\", \"furalone\", \"furametral\", \"furaplast\", \"furaseptyl\", \"furaskin\", \"furatsilin\", \"furaziline\", \"furazin\",
|
||||
\"furazina\", \"furazol w\", \"furazone\", \"furazyme\", \"furesol\", \"furfurin\", \"furosem\", \"fuvacillin\", \"hemofuran\", \"ibiofural\", \"mammex\", \"mastofuran\", \"monafuracin\", \"monafuracis\", \"monofuracin\", \"nfz mix\", \"nifucin\", \"nifurid\", \"nifuzon\", \"nitrofural\", \"nitrofuralum\", \"nitrofuran\", \"nitrofurane\", \"nitrofurazan\", \"nitrofurazone\", \"nitrofurazonum\", \"nitrofurol\", \"nitrozone\", \"otofural\", \"otofuran\", \"rivafurazon\", \"sanfuran\", \"vabrocid\", \"vadrocid\", \"yatrocin\")" "character(0)"
|
||||
"NTR" 19910 "Nitroxoline" "Quinolones" "J01XX07" "Other antibacterials" "Other antibacterials" "" "c(\"galinok\", \"isinok\", \"nibiol\", \"nicene forte\", \"nitroxolin\", \"nitroxolina\", \"nitroxoline\", \"nitroxolinum\", \"notroxoline\", \"noxibiol\")" 1 "g" "character(0)"
|
||||
"NOR" 4539 "Norfloxacin" "Quinolones" "c(\"J01MA06\", \"S01AE02\")" "Quinolone antibacterials" "Fluoroquinolones" "c(\"nor\", \"norf\", \"nx\", \"nxn\")" "c(\"baccidal\", \"barazan\", \"chibroxin\", \"chibroxine\", \"chibroxol\", \"fulgram\", \"gonorcin\", \"lexinor\", \"nolicin\", \"noracin\", \"noraxin\", \"norflo\", \"norfloxacin\", \"norfloxacine\", \"norfloxacino\", \"norfloxacinum\", \"norocin\", \"noroxin\", \"noroxine\", \"norxacin\", \"sebercim\", \"uroxacin\", \"utinor\", \"zoroxin\")" 0.8 "g" "3867-9"
|
||||
"NVA" 10419027 "Norvancomycin" "Glycopeptides" "" "norvancomycin" "character(0)"
|
||||
"NOV" 54675769 "Novobiocin" "Other antibacterials" "novo" "c(\"albamix\", \"albamycin\", \"cardelmycin\", \"cathocin\", \"cathomycin\", \"crystallinic acid\", \"inamycin\", \"novobiocin\", \"novobiocina\", \"novobiocine\", \"novobiocinum\", \"robiocina\", \"sirbiocina\", \"spheromycin\", \"stilbiocina\", \"streptonivicin\")" "17378-1"
|
||||
"NYS" 6433272 "Nystatin" "Antifungals/antimycotics" "c(\"A07AA02\", \"D01AA01\", \"G01AA01\")" "nyst" "c(\"biofanal\", \"candex lotion\", \"comycin\", \"diastatin\", \"herniocid\", \"moronal\", \"myconystatin\", \"mycostatin\", \"mycostatin pastilles\", \"mykinac\", \"mykostatyna\", \"nilstat\", \"nistatin\", \"nistatina\", \"nyamyc\", \"nyotran\", \"nyotrantrade mark\", \"nystaform\", \"nystan\", \"nystatin\", \"nystatin a\", \"nystatin g\", \"nystatin lf\", \"nystatine\", \"nystatinum\", \"nystatyna\", \"nystavescent\", \"nystex\", \"nystop\", \"stamycin\", \"terrastatin\", \"zydin e\")" 1.5 "MU" "character(0)"
|
||||
"OFX" 4583 "Ofloxacin" "Quinolones" "c(\"J01MA01\", \"S01AE01\", \"S02AA16\")" "Quinolone antibacterials" "Fluoroquinolones" "c(\"of\", \"ofl\", \"oflo\", \"ofx\")" "c(\"bactocin\", \"danoflox\", \"effexin\", \"exocin\", \"exocine\", \"flobacin\", \"flodemex\", \"flotavid\", \"flovid\", \"floxal\", \"floxil\", \"floxin\", \"floxin otic\", \"floxstat\", \"fugacin\", \"inoflox\", \"kinflocin\", \"kinoxacin\", \"levofloxacin hcl\", \"liflox\", \"loxinter\", \"marfloxacin\", \"medofloxine\", \"mergexin\", \"monoflocet\", \"novecin\", \"nufafloqo\", \"occidal\", \"ocuflox\", \"oflocee\", \"oflocet\", \"oflocin\", \"oflodal\", \"oflodex\", \"oflodura\", \"ofloxacin\", \"ofloxacin otic\", \"ofloxacina\", \"ofloxacine\", \"ofloxacino\", \"ofloxacinum\",
|
||||
\"ofloxin\", \"onexacin\", \"operan\", \"orocin\", \"otonil\", \"oxaldin\", \"pharflox\", \"praxin\", \"puiritol\", \"qinolon\", \"quinolon\", \"quotavil\", \"sinflo\", \"tabrin\", \"taravid\", \"tariflox\", \"tarivid\", \"telbit\", \"tructum\", \"uro tarivid\", \"viotisone\", \"visiren\", \"zanocin\")" 0.4 "g" 0.4 "g" "c(\"25264-3\", \"3877-8\")"
|
||||
"OLE" 72493 "Oleandomycin" "Macrolides/lincosamides" "J01FA05" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"amimycin\", \"landomycin\", \"matromycin\", \"oleandomycin a\", \"romicil\")" 1 "g" "character(0)"
|
||||
"OMC" 54697325 "Omadacycline" "Tetracyclines" "J01AA15" "" "c(\"amadacycline\", \"omadacycline\")" 0.3 "g" 0.1 "g" "character(0)"
|
||||
"OPT" 87880 "Optochin" "Other antibacterials" "" "c(\"numoquin\", \"optochin\", \"optoquine\")" "character(0)"
|
||||
"ORB" 60605 "Orbifloxacin" "Quinolones" "" "orbifloxacin" "character(0)"
|
||||
"ORI" 16136912 "Oritavancin" "Glycopeptides" "J01XA05" "Other antibacterials" "Glycopeptide antibacterials" "orit" "oritavancin" "character(0)"
|
||||
"ORS" "Ormetroprim/sulfamethoxazole" "Other antibacterials" "" "" ""
|
||||
"ORN" 28061 "Ornidazole" "Other antibacterials" "c(\"G01AF06\", \"J01XD03\", \"P01AB03\")" "Other antibacterials" "Imidazole derivatives" "" "c(\"madelen\", \"ornidal\", \"ornidazol\", \"ornidazole\", \"ornidazolum\", \"tiberal\")" 1.5 "g" 1 "g" "character(0)"
|
||||
"OXA" 6196 "Oxacillin" "Beta-lactams/penicillins" "J01CF04" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "c(\"ox\", \"oxa\", \"oxac\", \"oxal\", \"oxs\")" "c(\"bactocill\", \"ossacillina\", \"oxacilina\", \"oxacillin\", \"oxacillin sodium\", \"oxacilline\", \"oxacillinum\", \"oxazocillin\", \"oxazocilline\", \"prostaphlin\", \"prostaphlyn\", \"sodium oxacillin\")" 2 "g" 2 "g" "c(\"25265-0\", \"3882-8\")"
|
||||
"OXO" 4628 "Oxolinic acid" "Quinolones" "J01MB05" "Quinolone antibacterials" "Other quinolones" "" "c(\"acide oxolinique\", \"acido ossolico\", \"acido oxolinico\", \"acidum oxolinicum\", \"aqualinic\", \"cistopax\", \"dioxacin\", \"emyrenil\", \"gramurin\", \"inoxyl\", \"nidantin\", \"oksaren\", \"orthurine\", \"ossian\", \"oxoboi\", \"oxolinic\", \"oxolinic acid\", \"pietil\", \"prodoxal\", \"prodoxol\", \"starner\", \"tiurasin\", \"ultibid\", \"urinox\", \"uritrate\", \"urotrate\", \"uroxol\", \"utibid\")" 1 "g" "character(0)"
|
||||
"OXY" 54675779 "Oxytetracycline" "Tetracyclines" "c(\"D06AA03\", \"G01AA07\", \"J01AA06\", \"S01AA04\")" "Tetracyclines" "Tetracyclines" "" "c(\"adamycin\", \"berkmycen\", \"biostat\", \"biostat pa\", \"dabicycline\", \"dalimycin\", \"embryostat\", \"fanterrin\", \"galsenomycin\", \"geomycin\", \"geotilin\", \"hydroxytetracyclinum\", \"imperacin\", \"lenocycline\", \"macocyn\", \"medamycin\", \"mepatar\", \"oksisyklin\", \"ossitetraciclina\", \"oxacycline\", \"oxitetraciclina\", \"oxitetracyclin\", \"oxitetracycline\", \"oxitetracyclinum\", \"oxydon\", \"oxymycin\", \"oxymykoin\", \"oxypam\", \"oxysteclin\", \"oxyterracin\", \"oxyterracine\", \"oxyterracyne\", \"oxytetracid\", \"oxytetracyclin\", \"oxytetracycline\",
|
||||
\"oxytetracycline base\", \"oxytetracyclinum\", \"proteroxyna\", \"riomitsin\", \"ryomycin\", \"solkaciclina\", \"stecsolin\", \"stevacin\", \"tarocyn\", \"tarosin\", \"teravit\", \"terrafungine\", \"terramitsin\", \"terramycin\", \"terramycin im\", \"tetran\", \"unimycin\", \"ursocyclin\", \"ursocycline\", \"vendarcin\")" 1 "g" 1 "g" "c(\"17396-3\", \"25266-8\", \"87595-5\")"
|
||||
"OZN" "Ozenoxacin" "" "" ""
|
||||
"PAS" 4649 "P-aminosalicylic acid" "Antimycobacterials" "" "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\")" "character(0)"
|
||||
"PAN" 72015 "Panipenem" "Carbapenems" "" "c(\"panipenem\", \"panipenemum\", \"penipanem\")" "character(0)"
|
||||
"PAR" 165580 "Paromomycin" "Other antibacterials" "A07AA06" "" "c(\"aminosidin\", \"aminosidine\", \"aminosidine i\", \"aminosidine sulfate\", \"amminosidin\", \"crestomycin\", \"estomycin\", \"gabbromicina\", \"gabbromycin\", \"gabromycin\", \"humatin\", \"humycin\", \"hydroxymycin\", \"hydroxymycin sulfate\", \"monomycin\", \"monomycin a\", \"neomycin e\", \"paramomycin\", \"paramomycin sulfate\", \"paromomicina\", \"paromomycin\", \"paromomycin i\", \"paromomycine\", \"paromomycinum\", \"paucimycin\", \"paucimycinum\", \"quintomycin c\")" 3 "g" "character(0)"
|
||||
"PAZ" 65957 "Pazufloxacin" "Quinolones" "J01MA18" "Quinolone antibacterials" "Fluoroquinolones" "" "c(\"pazufloxacin\", \"pazufloxacine\", \"pazufloxacino\", \"pazufloxacinum\")" 1 "g" "character(0)"
|
||||
"PEF" 51081 "Pefloxacin" "Quinolones" "J01MA03" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"pefl\")" "c(\"abactal\", \"labocton\", \"pefloxacin\", \"pefloxacine\", \"pefloxacino\", \"pefloxacinum\", \"perfloxacin\", \"silver pefloxacin\")" 0.8 "g" 0.8 "g" "3906-5"
|
||||
"PNM" 10250769 "Penamecillin" "Beta-lactams/penicillins" "J01CE06" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"hydroxymethyl\", \"penamecilina\", \"penamecillin\", \"penamecillina\", \"penamecilline\", \"penamecillinum\")" 1.05 "g" "character(0)"
|
||||
"PNO" "Penicillin/novobiocin" "Beta-lactams/penicillins" "" "" ""
|
||||
"PSU" "Penicillin/sulbactam" "Beta-lactams/penicillins" "" "" ""
|
||||
"PNM1" 54686187 "Penimepicycline" "Tetracyclines" "J01AA10" "Tetracyclines" "Tetracyclines" "" "c(\"duamine\", \"hydrocycline\", \"penetracyne\", \"penimepiciclina\", \"penimepicycline\", \"penimepicyclinum\")" "character(0)"
|
||||
"PIM" 65453 "Pentisomicin" "Aminoglycosides" "" "c(\"pentisomicin\", \"pentisomicina\", \"pentisomicine\", \"pentisomicinum\")" "character(0)"
|
||||
"PTZ" 55250256 "Pentizidone" "Other antibacterials" "" "" ""
|
||||
"PEX" 16132253 "Pexiganan" "Other antibacterials" "" "pexiganan" "character(0)"
|
||||
"PHE" 272833 "Phenethicillin" "Beta-lactams/penicillins" "J01CE05" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "c(\"\", \"fene\")" "c(\"feneticilina\", \"feneticillina\", \"feneticilline\", \"k phenethicillin\", \"phenethicilin\", \"phenethicillinum\", \"pheneticillin\", \"pheneticilline\", \"pheneticillinum\", \"phenoxy pc\", \"potassium penicillin\")" 1 "g" "41471-4"
|
||||
"PHN" 6869 "Phenoxymethylpenicillin" "Beta-lactams/penicillins" "J01CE02" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "c(\"fepe\", \"peni v\", \"penicillin v\", \"pnv\", \"pv\")" "c(\"acipen v\", \"apocillin\", \"apopen\", \"beromycin\", \"calcipen\", \"compocillin v\", \"crystapen v\", \"distaquaine v\", \"eskacillian v\", \"eskacillin v\", \"fenacilin\", \"fenospen\", \"meropenin\", \"oracillin\", \"oratren\", \"penicillin v\", \"phenocillin\", \"phenomycilline\", \"phenopenicillin\", \"robicillin\", \"rocilin\", \"stabicillin\", \"vebecillin\", \"veetids\", \"vegacillin\")" 2 "g" "character(0)"
|
||||
"PMR" 5284447 "Pimaricin" "Antifungals/antimycotics" "c(\"\", \"natamycin\")" "c(\"delvocid\", \"mycophyt\", \"myprozine\", \"natacyn\", \"natamicina\", \"natamycin\", \"natamycine\", \"natamycinum\", \"pimafucin\", \"pimaracin\", \"pimarizin\", \"synogil\", \"tennecetin\")" "character(0)"
|
||||
"PPA" 4831 "Pipemidic acid" "Quinolones" "J01MB04" "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" 43672 "Piperacillin" "Beta-lactams/penicillins" "J01CA12" "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" "" "" ""
|
||||
"TZP" 461573 "Piperacillin/tazobactam" "Beta-lactams/penicillins" "J01CR05" "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)"
|
||||
"PRL" 157385 "Pirlimycin" "Macrolides/lincosamides" "" "c(\"pirlimycin\", \"pirlimycina\", \"pirlimycine\", \"pirlimycinum\", \"pirsue\")" "character(0)"
|
||||
"PIR" 4855 "Piromidic acid" "Quinolones" "J01MB03" "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)"
|
||||
"PVM" 33478 "Pivampicillin" "Beta-lactams/penicillins" "J01CA02" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"berocillin\", \"pivaloylampicillin\", \"pivampicilina\", \"pivampicillin\", \"pivampicilline\", \"pivampicillinum\", \"pondocillin\")" 1.05 "g" "character(0)"
|
||||
"PME" 115163 "Pivmecillinam" "Beta-lactams/penicillins" "J01CA08" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"amdinocillin pivoxil\", \"coactabs\", \"hydroxymethyl\", \"pivmecilinamo\", \"pivmecillinam\", \"pivmecillinam hcl\", \"pivmecillinamum\")" 0.6 "g" "character(0)"
|
||||
"PLZ" 42613186 "Plazomicin" "Aminoglycosides" "J01GB14" "" "plazomicin" "92024-9"
|
||||
"PLB" 49800004 "Polymyxin B" "Polymyxins" "c(\"A07AA05\", \"J01XB02\", \"S01AA18\", \"S02AA11\", \"S03AA03\")" "Other antibacterials" "Polymyxins" "c(\"pb\", \"pol\", \"polb\", \"poly\", \"poly b\", \"polymixin\", \"polymixin b\")" "c(\"polimixina b\", \"polumyxin b\", \"polymixin b\", \"polymyxine b\")" 3 "MU" 0.15 "g" "c(\"17473-0\", \"25269-2\")"
|
||||
"POP" "Polymyxin B/polysorbate 80" "Polymyxins" "" "" ""
|
||||
"POS" 468595 "Posaconazole" "Antifungals/antimycotics" "J02AC04" "Antimycotics for systemic use" "Triazole derivatives" "posa" "c(\"noxafil\", \"posaconazole\", \"posaconazole sp\", \"posconazole\")" 0.3 "g" 0.3 "g" "c(\"53731-6\", \"80545-7\")"
|
||||
"PRA" 9802884 "Pradofloxacin" "Quinolones" "" "pradofloxacin" "character(0)"
|
||||
"PRX" 71455 "Premafloxacin" "Quinolones" "" "premafloxacin" "character(0)"
|
||||
"PMD" 456199 "Pretomanid" "Antimycobacterials" "J04AK08" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "" "" ""
|
||||
"PRM" 6446787 "Primycin" "Macrolides/lincosamides" "" "" ""
|
||||
"PRI" 11979535 "Pristinamycin" "Macrolides/lincosamides" "J01FG01" "Macrolides, lincosamides and streptogramins" "Streptogramins" "c(\"\", \"pris\")" "c(\"eskalin v\", \"mikamycin\", \"mikamycine\", \"mikamycinum\", \"ostreogrycinum\", \"pristinamycine\", \"pristinamycinum\", \"stafac\", \"stafytracine\", \"staphylomycin\", \"starfac\", \"streptogramin\", \"vernamycin\", \"virgimycin\", \"virgimycine\", \"virginiamycina\", \"virginiamycine\", \"virginiamycinum\")" 2 "g" "character(0)"
|
||||
"PRB" 5903 "Procaine benzylpenicillin" "Beta-lactams/penicillins" "J01CE09" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"depocillin\", \"duphapen\", \"hostacillin\", \"hydracillin\", \"jenacillin o\", \"nopcaine\", \"penicillin procaine\", \"retardillin\", \"vetspen\", \"vitablend\")" 0.6 "g" "character(0)"
|
||||
"PRP" 92879 "Propicillin" "Beta-lactams/penicillins" "J01CE03" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "c(\"propicilina\", \"propicillin\", \"propicilline\", \"propicillinum\")" 0.9 "g" "character(0)"
|
||||
"PKA" 9872451 "Propikacin" "Aminoglycosides" "" "c(\"propikacin\", \"propikacina\", \"propikacine\", \"propikacinum\")" "character(0)"
|
||||
"PTH" 666418 "Prothionamide" "Antimycobacterials" "J04AD01" "Drugs for treatment of tuberculosis" "Thiocarbamide derivatives" "prot" "c(\"ektebin\", \"peteha\", \"prothionamide\", \"prothionamidum\", \"protion\", \"protionamid\", \"protionamida\", \"protionamide\", \"protionamidum\", \"protionizina\", \"tebeform\", \"trevintix\", \"tuberex\")" 0.75 "g" "character(0)"
|
||||
"PRU" 65947 "Prulifloxacin" "Quinolones" "J01MA17" "Quinolone antibacterials" "Fluoroquinolones" "" "c(\"prulifloxacin\", \"pruvel\", \"pufloxacin dioxolil\", \"quisnon\")" 0.6 "g" "character(0)"
|
||||
"PZA" 1046 "Pyrazinamide" "Antimycobacterials" "J04AK01" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "pyra" "c(\"aldinamid\", \"aldinamide\", \"braccopiral\", \"corsazinmid\", \"dipimide\", \"eprazin\", \"farmizina\", \"isopas\", \"lynamide\", \"novamid\", \"p ezetamid\", \"pezetamid\", \"pharozinamide\", \"piraldina\", \"pirazimida\", \"pirazinamid\", \"pirazinamida\", \"pirazinamide\", \"prazina\", \"pyrafat\", \"pyramide\", \"pyrazide\", \"pyrazinamdie\", \"pyrazinamid\", \"pyrazinamide\", \"pyrazinamidum\", \"pyrazine carboxamide\", \"pyrazineamide\", \"pyrizinamide\", \"rifafour\", \"rozide\", \"tebrazid\", \"tebrazio\", \"tisamid\", \"unipyranamide\", \"zinamide\", \"zinastat\"
|
||||
)" 1.5 "g" "c(\"11001-5\", \"25270-0\")"
|
||||
"QDA" 11979418 "Quinupristin/dalfopristin" "Macrolides/lincosamides" "J01FG02" "Macrolides, lincosamides and streptogramins" "Streptogramins" "c(\"q/d\", \"qda\", \"qida\", \"quda\", \"rp\", \"syn\")" "" 1.5 "g" ""
|
||||
"RAC" 56052 "Ractopamine" "Other antibacterials" "" "c(\"ractopamina\", \"ractopamine\", \"ractopaminum\")" "character(0)"
|
||||
"RAM" 16132338 "Ramoplanin" "Glycopeptides" "" "ramoplanin" "character(0)"
|
||||
"RZM" 10993211 "Razupenem" "Carbapenems" "" "razupenem" "character(0)"
|
||||
"RTP" 6918462 "Retapamulin" "Other antibacterials" "D06AX13" "Antibiotics for topical use" "Other antibiotics for topical use" "c(\"\", \"ret\")" "c(\"altabax\", \"altargo\", \"retapamulin\")" "character(0)"
|
||||
"RZF" "Rezafungin" "Antifungals" "" "" ""
|
||||
"RBC" 44631912 "Ribociclib" "Antifungals/antimycotics" "L01EF02" "Antimycotics for systemic use" "Triazole derivatives" "ribo" "c(\"kisqali\", \"ribociclib\")" "character(0)"
|
||||
"RST" 33042 "Ribostamycin" "Aminoglycosides" "J01GB10" "Aminoglycoside antibacterials" "Other aminoglycosides" "" "c(\"dekamycin iv\", \"hetangmycin\", \"ribastamin\", \"ribostamicina\", \"ribostamycin\", \"ribostamycine\", \"ribostamycinum\", \"vistamycin\", \"xylostatin\")" 1 "g" "character(0)"
|
||||
"RID1" 16659285 "Ridinilazole" "Other antibacterials" "" "ridinilazole" "character(0)"
|
||||
"RIB" 135398743 "Rifabutin" "Antimycobacterials" "J04AB04" "Drugs for treatment of tuberculosis" "Antibiotics" "rifb" "c(\"alfacid\", \"ansamicin\", \"ansamycin\", \"ansatipin\", \"ansatipine\", \"mycobutin\", \"rifabutin\", \"rifabutina\", \"rifabutine\", \"rifabutinum\")" 0.15 "g" "24032-5"
|
||||
"RIF" 135398735 "Rifampicin" "Antimycobacterials" "J04AB02" "Drugs for treatment of tuberculosis" "Antibiotics" "rifa" "c(\"abrifam\", \"archidyn\", \"arficin\", \"arzide\", \"azt + rifampin\", \"benemicin\", \"benemycin\", \"dipicin\", \"doloresum\", \"eremfat\", \"famcin\", \"fenampicin\", \"rifadin\", \"rifadin i.v\", \"rifadin i.v.\", \"rifadine\", \"rifagen\", \"rifaldazin\", \"rifaldazine\", \"rifaldin\", \"rifamate\", \"rifamicin amp\", \"rifamor\", \"rifampicin\", \"rifampicin sv\", \"rifampicina\", \"rifampicine\", \"rifampicinum\", \"rifampin\", \"rifamsolin\", \"rifamycin amp\", \"rifaprodin\", \"rifcin\", \"rifobac\", \"rifoldin\", \"rifoldine\", \"riforal\", \"rimactan\", \"rimactane\",
|
||||
\"rimactizid\", \"rimazid\", \"rimycin\", \"sinerdol\", \"tubocin\")" 0.6 "g" 0.6 "g" "character(0)"
|
||||
"RFI" "Rifampicin/isoniazid" "Antimycobacterials" "J04AM02" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "c(\"rifinah\", \"rimactazid\")" "character(0)"
|
||||
"RPEI" "Rifampicin/pyrazinamide/ethambutol/isoniazid" "Antimycobacterials" "J04AM06" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" ""
|
||||
"RPI" "Rifampicin/pyrazinamide/isoniazid" "Antimycobacterials" "J04AM05" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" ""
|
||||
"RFM" 6324616 "Rifamycin" "Antimycobacterials" "c(\"A07AA13\", \"D06AX15\", \"J04AB03\", \"S01AA16\", \"S02AA12\")" "Drugs for treatment of tuberculosis" "Antibiotics" "" "c(\"aemcolo\", \"rifacin\", \"rifamicina\", \"rifamicine sv\", \"rifamycin\", \"rifamycine\", \"rifamycinum\", \"rifocin\", \"rifocyn\", \"rifomycin\", \"rifomycin sv\", \"tuborin\")" 0.6 "g" "character(0)"
|
||||
"RFP" 135403821 "Rifapentine" "Antimycobacterials" "J04AB05" "Drugs for treatment of tuberculosis" "Antibiotics" "c(\"rifp\", \"rpt\")" "c(\"cyclopentyl rifampin\", \"priftin\", \"rifapentin\", \"rifapentina\", \"rifapentine\", \"rifapentinum\")" 0.11 "g" "character(0)"
|
||||
"RFX" 6436173 "Rifaximin" "Other antibacterials" "c(\"A07AA11\", \"D06AX11\")" "Intestinal antiinfectives" "Antibiotics" "" "c(\"fatroximin\", \"flonorm\", \"lormyx\", \"lumenax\", \"normix\", \"redactiv\", \"rifacol\", \"rifamixin\", \"rifaxidin\", \"rifaximin\", \"rifaximina\", \"rifaximine\", \"rifaximinum\", \"rifaxin\", \"ritacol\", \"spiraxin\", \"xifaxan\", \"xifaxsan\")" 0.6 "g" "character(0)"
|
||||
"RIT" 65633 "Ritipenem" "Carbapenems" "" "ritipenem" "character(0)"
|
||||
"RIA" 163692 "Ritipenem acoxil" "Carbapenems" "" "ritipenem acoxil" "character(0)"
|
||||
"ROK" 5282211 "Rokitamycin" "Macrolides/lincosamides" "J01FA12" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"propionylleucomycin\", \"ricamycin\", \"rokicid\", \"rokital\", \"rokitamicina\", \"rokitamycin\", \"rokitamycine\", \"rokitamycinum\")" 0.8 "g" "character(0)"
|
||||
"RLT" 54682938 "Rolitetracycline" "Tetracyclines" "J01AA09" "Tetracyclines" "Tetracyclines" "" "c(\"bristacin\", \"kinteto\", \"reverin\", \"rolitetraciclina\", \"rolitetracycline\", \"rolitetracyclinum\", \"solvocillin\", \"superciclin\", \"synotodecin\", \"synterin\", \"syntetrex\", \"syntetrin\", \"velacicline\", \"velacycline\")" 0.35 "g" "character(0)"
|
||||
"ROS" 287180 "Rosoxacin" "Quinolones" "J01MB01" "Quinolone antibacterials" "Other quinolones" "" "c(\"acrosoxacin\", \"eracine\", \"eradacil\", \"eradacin\", \"rosoxacin\", \"rosoxacine\", \"rosoxacino\", \"rosoxacinum\", \"roxadyl\", \"winuron\")" 0.3 "g" "character(0)"
|
||||
"RXT" "Roxithromycin" "Macrolides/lincosamides" "J01FA06" "Macrolides, lincosamides and streptogramins" "Macrolides" "roxi" "" 0.3 "g" ""
|
||||
"RFL" 58258 "Rufloxacin" "Quinolones" "J01MA10" "Quinolone antibacterials" "Fluoroquinolones" "" "c(\"rufloxacin\", \"rufloxacin hcl\", \"rufloxacine\", \"rufloxacino\", \"rufloxacinum\")" 0.2 "g" "character(0)"
|
||||
"SAL" 3085092 "Salinomycin" "Other antibacterials" "" "c(\"coxistac\", \"procoxacin\", \"salinomicina\", \"salinomycin\", \"salinomycine\", \"salinomycinum\")" "87593-0"
|
||||
"SAR" 56208 "Sarafloxacin" "Quinolones" "" "c(\"difloxacine\", \"difloxacino\", \"difloxacinum\", \"saraflox\", \"sarafloxacin\", \"sarafloxacine\", \"sarafloxacino\", \"sarafloxacinum\")" "character(0)"
|
||||
"SRX" 9933415 "Sarmoxicillin" "Beta-lactams/penicillins" "" "sarmoxicillin" "character(0)"
|
||||
"SEC" 71815 "Secnidazole" "Other antibacterials" "P01AB07" "" "c(\"flagentyl\", \"secnidal\", \"secnidazol\", \"secnidazole\", \"secnidazolum\", \"secnil\", \"sindose\", \"solosec\")" 2 "g" "character(0)"
|
||||
"SMF" "Simvastatin/fenofibrate" "Antimycobacterials" "C10BA04" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "simv" "" ""
|
||||
"SIS" 36119 "Sisomicin" "Aminoglycosides" "J01GB08" "Aminoglycoside antibacterials" "Other aminoglycosides" "siso" "c(\"rickamicin\", \"salvamina\", \"siseptin sulfate\", \"sisomicin\", \"sisomicin sulfate\", \"sisomicina\", \"sisomicine\", \"sisomicinum\", \"sisomin\", \"sisomycin\", \"sissomicin\", \"sizomycin\")" 0.24 "g" "character(0)"
|
||||
"SIT" 461399 "Sitafloxacin" "Quinolones" "J01MA21" "" "c(\"gracevit\", \"sitafloxacinisomer\")" 0.1 "g" "character(0)"
|
||||
"SDA" 2724368 "Sodium aminosalicylate" "Antimycobacterials" "J04AA02" "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" "J01FA16" "" "" ""
|
||||
"SPX" 60464 "Sparfloxacin" "Quinolones" "J01MA09" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"spa\", \"spar\")" "c(\"esparfloxacino\", \"sparfloxacin\", \"sparfloxacine\", \"sparfloxacinum\")" 0.2 "g" "character(0)"
|
||||
"SPT" 15541 "Spectinomycin" "Other antibacterials" "J01XX04" "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" 6419898 "Spiramycin" "Macrolides/lincosamides" "J01FA02" "Macrolides, lincosamides and streptogramins" "Macrolides" "c(\"\", \"spir\")" "c(\"espiramicin\", \"provamycin\", \"rovamycin\", \"rovamycine\", \"sequamycin\", \"spiramycine\", \"spiramycinum\")" 3 "g" "character(0)"
|
||||
"SPM" "Spiramycin/metronidazole" "Other antibacterials" "J01RA04" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
|
||||
"STR" "Streptoduocin" "Aminoglycosides" "J01GA02" "Aminoglycoside antibacterials" "Streptomycins" "" "" 1 "g" ""
|
||||
"STR1" 19649 "Streptomycin" "Aminoglycosides" "c(\"A07AA04\", \"J01GA01\")" "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(\"sthi\", \"sthl\", \"strepto high\", \"streptomycin high\")" "" ""
|
||||
"STI" "Streptomycin/isoniazid" "Antimycobacterials" "J04AM01" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" ""
|
||||
"SUL" 130313 "Sulbactam" "Beta-lactams/penicillins" "J01CG01" "Beta-lactam antibacterials, penicillins" "Beta-lactamase inhibitors" "" "c(\"betamaze\", \"sulbactam\", \"sulbactam acid\", \"sulbactam free acid\", \"sulbactamum\")" 1 "g" "character(0)"
|
||||
"SBC" 20055036 "Sulbenicillin" "Beta-lactams/penicillins" "J01CA16" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"kedacillina\", \"sulbenicilina\", \"sulbenicilline\", \"sulbenicillinum\")" 15 "g" "character(0)"
|
||||
"SUC" 5318 "Sulconazole" "Antifungals/antimycotics" "D01AC09" "" "c(\"sulconazol\", \"sulconazole\", \"sulconazolum\")" "character(0)"
|
||||
"SUP" 6634 "Sulfachlorpyridazine" "Other antibacterials" "" "c(\"cluricol\", \"cosulid\", \"cosumix\", \"durasulf\", \"nefrosul\", \"nsulfanilamide\", \"prinzone vet\", \"prinzone vet.\", \"solfaclorpiridazina\", \"sonilyn\", \"sulfachlorpyridazine\", \"sulfacloropiridazina\", \"vetisulid\")" "character(0)"
|
||||
"SDI" 5215 "Sulfadiazine" "Trimethoprims" "J01EC02" "Sulfonamides and trimethoprim" "Intermediate-acting sulfonamides" "" "c(\"adiazin\", \"adiazine\", \"cocodiazine\", \"codiazine\", \"cremodiazine\", \"cremotres\", \"debenal\", \"deltazina\", \"diazin\", \"diazolone\", \"diazovit\", \"diazyl\", \"eskadiazine\", \"honey diazine\", \"liquadiazine\", \"microsulfon\", \"neazine\", \"neotrizine\", \"nsulfanilamide\", \"palatrize\", \"piridisir\", \"pirimal\", \"pyrimal\", \"quadetts\", \"quadramoid\", \"sanodiazine\", \"sildaflo\", \"silvadene\", \"solfadiazina\", \"spofadrizine\", \"sterazine\", \"sulfacombin\", \"sulfadiazene\", \"sulfadiazin\", \"sulfadiazina\", \"sulfadiazine\", \"sulfadiazinum\",
|
||||
\"sulfapirimidin\", \"sulfapyrimidin\", \"sulfapyrimidine\", \"sulfatryl\", \"sulfazine\", \"sulfolex\", \"sulfonamides duplex\", \"sulfonsol\", \"sulfose\", \"sulphadiazine\", \"sulphadiazine e\", \"terfonyl\", \"theradiazine\", \"thermazene\", \"trifonamide\", \"triple sulfa\", \"triple sulfas\", \"trisem\", \"truozine\", \"zinc sulfadiazine\")" 0.6 "g" "c(\"27216-1\", \"59742-7\", \"6907-0\")"
|
||||
"SLT" 122284 "Sulfadiazine/tetroxoprim" "Trimethoprims" "J01EE06" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "" "" ""
|
||||
"SLT1" 64932 "Sulfadiazine/trimethoprim" "Trimethoprims" "J01EE02" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "" "c(\"antastmon\", \"cotrimazine\", \"diaziprim forte\", \"ditrim\", \"ditrivet\", \"sultrisan\", \"triglobe\", \"trimin\", \"tucoprim\", \"uniprim\")" "character(0)"
|
||||
"SUD" 5323 "Sulfadimethoxine" "Trimethoprims" "J01ED01" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"agribon\", \"arnosulfan\", \"bactrovet\", \"deposul\", \"diasulfa\", \"diasulfyl\", \"dimetazina\", \"dinosol\", \"dorisul\", \"lasibon\", \"madribon\", \"madrigid\", \"madriqid\", \"madroxin\", \"madroxine\", \"maxulvet\", \"mecozine\", \"memcozine\", \"metoxidon\", \"neostrepal\", \"neostreptal\", \"nsulfanilamide\", \"omnibon\", \"persulfen\", \"primor\", \"radonin\", \"redifal\", \"rofenaid\", \"roscosulf\", \"scandisil\", \"solfadimetossina\", \"sudine\", \"suldixine\", \"sulfabon\", \"sulfadimethoxin\", \"sulfadimethoxine\", \"sulfadimethoxinum\", \"sulfadimetossina\",
|
||||
\"sulfadimetoxin\", \"sulfadimetoxina\", \"sulfadimetoxine\", \"sulfastop\", \"sulfdimethoxine\", \"sulfoplan\", \"sulphadimethoxine\", \"sulxin\", \"sumbio\", \"symbio\", \"theracanzan\", \"ultrasulfon\")" 0.5 "g" "character(0)"
|
||||
"SDM" 5327 "Sulfadimidine" "Trimethoprims" "J01EB03" "Sulfonamides and trimethoprim" "Short-acting sulfonamides" "" "c(\"azolmetazin\", \"benzene sulfonamide\", \"calfspan\", \"calfspan tablets\", \"cremomethazine\", \"diazil\", \"diazilsulfadine\", \"dimezathine\", \"intradine\", \"kelametazine\", \"mermeth\", \"metazin\", \"neasina\", \"neazina\", \"nsulfanilamide\", \"panazin\", \"pirmazin\", \"primazin\", \"sa iii\", \"solfadimidina\", \"spanbolet\", \"sulfadimerazine\", \"sulfadimesin\", \"sulfadimesine\", \"sulfadimethyldiazine\", \"sulfadimezin\", \"sulfadimezine\", \"sulfadimezinum\", \"sulfadimidin\", \"sulfadimidina\", \"sulfadimidine\", \"sulfadimidinum\", \"sulfadine\",
|
||||
\"sulfametazina\", \"sulfametazyny\", \"sulfamethazine\", \"sulfamethiazine\", \"sulfamezathine\", \"sulfamidine\", \"sulfasure sr bolus\", \"sulfodimesin\", \"sulfodimezine\", \"sulka k boluses\", \"sulka s boluses\", \"sulmet\", \"sulphadimidine\", \"sulphamethasine\", \"sulphamethazine\", \"sulphamezathine\", \"sulphamidine\", \"sulphodimezine\", \"superseptil\", \"superseptyl\", \"vertolan\")" 4 "g" "character(0)"
|
||||
"SLT2" "Sulfadimidine/trimethoprim" "Trimethoprims" "J01EE05" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "" "" ""
|
||||
"SLF" 5344 "Sulfafurazole" "Trimethoprims" "c(\"J01EB05\", \"S01AB02\")" "Sulfonamides and trimethoprim" "Short-acting sulfonamides" "c(\"\", \"sfsz\")" "c(\"accuzole\", \"alphazole\", \"amidoxal\", \"astrazolo\", \"azo gantrisin\", \"azosulfizin\", \"bactesulf\", \"barazae\", \"chemouag\", \"cosoxazole\", \"dorsulfan\", \"dorsulfan warthausen\", \"entusil\", \"entusul\", \"eryzole\", \"gantrisin\", \"gantrisine\", \"gantrisona\", \"gantrizin\", \"gantrosan\", \"isoxamin\", \"neazolin\", \"neoxazoi\", \"neoxazol\", \"novazolo\", \"novosaxazole\", \"nsulfanilamide\", \"nsulphanilamide\", \"pancid\", \"pediazole\", \"renosulfan\", \"resoxol\", \"roxosul\", \"roxosul tablets\", \"roxoxol\", \"saxosozine\", \"sodizole\", \"solfafurazolo\",
|
||||
\"soxamide\", \"soxazole\", \"soxisol\", \"soxitabs\", \"soxomide\", \"stansin\", \"sulbio\", \"sulfafuraz ole\", \"sulfafurazol\", \"sulfafurazole\", \"sulfafurazolum\", \"sulfagan\", \"sulfagen\", \"sulfaisoxazole\", \"sulfalar\", \"sulfapolar\", \"sulfasol\", \"sulfasoxazole\", \"sulfasoxizole\", \"sulfazin\", \"sulfisin\", \"sulfisonazole\", \"sulfisoxasole\", \"sulfisoxazol\", \"sulfisoxazole\", \"sulfisoxazolum\", \"sulfizin\", \"sulfizol\", \"sulfizole\", \"sulfofurazole\", \"sulfoxol\", \"suloxsol\", \"sulphafuraz\", \"sulphafurazol\", \"sulphafurazole\", \"sulphafurazolum\",
|
||||
\"sulphaisoxazole\", \"sulphisoxazol\", \"sulphisoxazole\", \"sulphofurazole\", \"sulsoxin\", \"thiasin\", \"unisulf\", \"urisoxin\", \"uritrisin\", \"urogan\", \"vagilia\")" 4 "g" 4 "g" "character(0)"
|
||||
"SLF1" 5343 "Sulfaisodimidine" "Trimethoprims" "J01EB01" "Sulfonamides and trimethoprim" "Short-acting sulfonamides" "" "c(\"aristamid\", \"aristamide\", \"aristogyn\", \"domain\", \"domian\", \"elcosin\", \"elcosine\", \"elkosil\", \"elkosin\", \"elkosine\", \"erycon\", \"isosulf\", \"mefenal\", \"nsulfanilamide\", \"solfisomidina\", \"sulfadimetine\", \"sulfaisodimerazine\", \"sulfaisodimidine\", \"sulfaisodimidinum\", \"sulfaisomidine\", \"sulfamethin\", \"sulfasomidine\", \"sulfisomidina\", \"sulfisomidine\", \"sulfisomidine sodium\", \"sulfisomidinum\", \"sulphasomidine\")" 4 "g" 4 "g" "character(0)"
|
||||
"SLF2" 9047 "Sulfalene" "Trimethoprims" "J01ED02" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"dalysep\", \"kelfizin\", \"kelfizina\", \"kelfizine\", \"kelfizine w\", \"longum\", \"nsulfanilamide\", \"policydal\", \"polycidal\", \"solfametopirazina\", \"sulfalen\", \"sulfalene\", \"sulfaleno\", \"sulfalenum\", \"sulfamethopyrazine\", \"sulfamethoxypyrazine\", \"sulfametopyrazine\", \"sulfametoxypyridazin\", \"sulphalene\", \"sulphametopyrazine\", \"vetkelfizina\")" 0.1 "g" "character(0)"
|
||||
"SZO" 187764 "Sulfamazone" "Trimethoprims" "J01ED09" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"sulfamazon\", \"sulfamazona\", \"sulfamazone\", \"sulfamazonum\")" 1.5 "g" "character(0)"
|
||||
"SLF3" 5325 "Sulfamerazine" "Trimethoprims" "c(\"D06BA06\", \"J01ED07\")" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"cremomerazine\", \"kelamerazine\", \"mebacid\", \"mesulfa\", \"methylpyrimal\", \"methylsulfazin\", \"methylsulfazine\", \"metilsulfadiazin\", \"metilsulfazin\", \"nsulfanilamide\", \"percoccide\", \"pyralcid\", \"pyrimal m\", \"romezin\", \"septacil\", \"septosyl\", \"solfamerazina\", \"solumedin\", \"sulfameradine\", \"sulfamerazin\", \"sulfamerazina\", \"sulfamerazine\", \"sulfamerazinum\", \"sulfamethyldiazine\", \"sulphamerazine\", \"sumedine\", \"susfamerazine\")" 3 "g" "character(0)"
|
||||
"SLT3" "Sulfamerazine/trimethoprim" "Trimethoprims" "J01EE07" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "" "" ""
|
||||
"SUM" 5327 "Sulfamethazine" "Other antibacterials" "" "c(\"azolmetazin\", \"benzene sulfonamide\", \"calfspan\", \"calfspan tablets\", \"cremomethazine\", \"diazil\", \"diazilsulfadine\", \"dimezathine\", \"intradine\", \"kelametazine\", \"mermeth\", \"metazin\", \"neasina\", \"neazina\", \"nsulfanilamide\", \"panazin\", \"pirmazin\", \"primazin\", \"sa iii\", \"solfadimidina\", \"spanbolet\", \"sulfadimerazine\", \"sulfadimesin\", \"sulfadimesine\", \"sulfadimethyldiazine\", \"sulfadimezin\", \"sulfadimezine\", \"sulfadimezinum\", \"sulfadimidin\", \"sulfadimidina\", \"sulfadimidine\", \"sulfadimidinum\", \"sulfadine\",
|
||||
\"sulfametazina\", \"sulfametazyny\", \"sulfamethazine\", \"sulfamethiazine\", \"sulfamezathine\", \"sulfamidine\", \"sulfasure sr bolus\", \"sulfodimesin\", \"sulfodimezine\", \"sulka k boluses\", \"sulka s boluses\", \"sulmet\", \"sulphadimidine\", \"sulphamethasine\", \"sulphamethazine\", \"sulphamezathine\", \"sulphamidine\", \"sulphodimezine\", \"superseptil\", \"superseptyl\", \"vertolan\")" "87592-2"
|
||||
"SLF4" 5328 "Sulfamethizole" "Trimethoprims" "c(\"B05CA04\", \"D06BA04\", \"J01EB02\", \"S01AB01\")" "Sulfonamides and trimethoprim" "Short-acting sulfonamides" "c(\"\", \"sfmz\")" "c(\"ayerlucil\", \"lucosil\", \"methazol\", \"microsul\", \"nsulfanilamide\", \"proklar\", \"renasul\", \"salimol\", \"solfametizolo\", \"sulamethizole\", \"sulfa gram\", \"sulfamethizol\", \"sulfamethizole\", \"sulfamethizolum\", \"sulfametizol\", \"sulfapyelon\", \"sulfstat\", \"sulfurine\", \"sulphamethizole\", \"tetracid\", \"thidicur\", \"thiosulfil\", \"thiosulfil forte\", \"ultrasul\", \"urocydal\", \"urodiaton\", \"urolucosil\", \"urosulfin\")" 4 "g" "c(\"60175-7\", \"60176-5\", \"60177-3\")"
|
||||
"SMX" 5329 "Sulfamethoxazole" "Trimethoprims" "J01EC01" "Sulfonamides and trimethoprim" "Intermediate-acting sulfonamides" "c(\"sfmx\", \"sulf\")" "c(\"azo gantanol\", \"eusaprim\", \"gamazole\", \"gantanol\", \"gantanol ds\", \"metoxal\", \"nsulfanilamide\", \"nsulphanilamide\", \"radonil\", \"septran\", \"septrin\", \"simsinomin\", \"sinomin\", \"solfametossazolo\", \"sulfamethalazole\", \"sulfamethoxazol\", \"sulfamethoxazole\", \"sulfamethoxazolum\", \"sulfamethoxizole\", \"sulfamethylisoxazole\", \"sulfametoxazol\", \"sulfisomezole\", \"sulphamethalazole\", \"sulphamethoxazol\", \"sulphamethoxazole\", \"sulphisomezole\", \"urobak\")" 2 "g" "c(\"10342-4\", \"25271-8\", \"39772-9\", \"59971-2\", \"59972-0\", \"60333-2\", \"72674-5\", \"80549-9\", \"80974-9\")"
|
||||
"SLF5" 5330 "Sulfamethoxypyridazine" "Trimethoprims" "J01ED05" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"altezol\", \"davosin\", \"depovernil\", \"kineks\", \"lederkyn\", \"lentac\", \"lisulfen\", \"longin\", \"medicel\", \"midicel\", \"midikel\", \"myasul\", \"nsulfanilamide\", \"opinsul\", \"paramid\", \"paramid supra\", \"petrisul\", \"piridolo\", \"quinoseptyl\", \"retamid\", \"retasulfin\", \"retasulphine\", \"slosul\", \"spofadazine\", \"sulfalex\", \"sulfapyridazine\", \"sulfdurazin\", \"sulfozona\", \"sultirene\", \"vinces\")" 0.5 "g" "character(0)"
|
||||
"SLF6" 19596 "Sulfametomidine" "Trimethoprims" "J01ED03" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"duroprocin\", \"methofadin\", \"methofazine\", \"nsulfanilamide\", \"solfametomidina\", \"sulfamethomidine\", \"sulfametomidin\", \"sulfametomidina\", \"sulfametomidine\", \"sulfametomidinum\")" "character(0)"
|
||||
"SLF7" 5326 "Sulfametoxydiazine" "Trimethoprims" "J01ED04" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"bayrena\", \"berlicid\", \"dairena\", \"durenat\", \"juvoxin\", \"kinecid\", \"kirocid\", \"longasulf\", \"methoxypyrimal\", \"nsulfanilamide\", \"solfametossidiazina\", \"sulfameter\", \"sulfamethorine\", \"sulfamethoxine\", \"sulfamethoxydiazin\", \"sulfamethoxydiazine\", \"sulfamethoxydin\", \"sulfamethoxydine\", \"sulfametin\", \"sulfametinum\", \"sulfametorin\", \"sulfametorine\", \"sulfametorinum\", \"sulfametoxidiazina\", \"sulfametoxidine\", \"sulfametoxydiazine\", \"sulfametoxydiazinum\", \"sulphameter\", \"sulphamethoxydiazine\", \"supramid\",
|
||||
\"ultrax\")" 0.5 "g" "character(0)"
|
||||
"SLT4" "Sulfametrole/trimethoprim" "Trimethoprims" "J01EE03" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "c(\"\", \"trsm\")" "" ""
|
||||
"SLF8" 12894 "Sulfamoxole" "Trimethoprims" "J01EC03" "Sulfonamides and trimethoprim" "Intermediate-acting sulfonamides" "" "c(\"justamil\", \"nsulfanilamide\", \"oxasulfa\", \"solfamossolo\", \"sulfadimethyloxazole\", \"sulfamoxol\", \"sulfamoxole\", \"sulfamoxolum\", \"sulfano\", \"sulfavigor\", \"sulfmidil\", \"sulfono\", \"sulfune\", \"sulfuno\", \"sulphamoxole\", \"tardamid\", \"tardamide\")" 1 "g" 1 "g" "character(0)"
|
||||
"SLT5" "Sulfamoxole/trimethoprim" "Trimethoprims" "J01EE04" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "" "" ""
|
||||
"SLF9" 5333 "Sulfanilamide" "Trimethoprims" "c(\"D06BA05\", \"J01EB06\")" "Sulfonamides and trimethoprim" "Short-acting sulfonamides" "" "c(\"albexan\", \"albosal\", \"ambeside\", \"antistrept\", \"astreptine\", \"astrocid\", \"bacteramid\", \"bactesid\", \"collomide\", \"colsulanyde\", \"copticide\", \"deseptyl\", \"desseptyl\", \"dipron\", \"ergaseptine\", \"erysipan\", \"estreptocida\", \"exoseptoplix\", \"gerison\", \"gombardol\", \"infepan\", \"lysococcine\", \"neococcyl\", \"orgaseptine\", \"prontalbin\", \"prontosil album\", \"prontosil i\", \"prontosil white\", \"prontylin\", \"pronzin album\", \"proseptal\", \"proseptine\", \"proseptol\", \"pysococcine\", \"rubiazol a\", \"sanamid\", \"septamide album\",
|
||||
\"septanilam\", \"septinal\", \"septolix\", \"septoplex\", \"septoplix\", \"solfanilamide\", \"stopton album\", \"stramid\", \"strepamide\", \"strepsan\", \"streptagol\", \"streptamid\", \"streptamin\", \"streptasol\", \"streptocid\", \"streptocid album\", \"streptocide\", \"streptocide white\", \"streptocidum\", \"streptoclase\", \"streptocom\", \"streptol\", \"strepton\", \"streptopan\", \"streptosil\", \"streptozol\", \"streptozone\", \"streptrocide\", \"sulfamidyl\", \"sulfamine\", \"sulfana\", \"sulfanalone\", \"sulfanidyl\", \"sulfanil\", \"sulfanilamida\", \"sulfanilamide\",
|
||||
\"sulfanilamidum\", \"sulfanilimidic acid\", \"sulfanimide\", \"sulfocidin\", \"sulfocidine\", \"sulfonamide\", \"sulfonamide p\", \"sulfonylamide\", \"sulphanilamide\", \"sulphanilamide gr\", \"sulphonamide\", \"therapol\", \"tolder\", \"white streptocide\", \"wln: zswr dz\")" "character(0)"
|
||||
"SLF10" 68933 "Sulfaperin" "Trimethoprims" "J01ED06" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"anastaf\", \"archisulfa\", \"avissul\", \"chemiopen\", \"demosulfan\", \"durisan saft\", \"ipersulfidin sirup\", \"isosulfamerazine\", \"methylsulfadiazin\", \"novosul\", \"nsulfanilamide\", \"orosulfan\", \"pallidin\", \"retardon\", \"risulfasens\", \"sulfaperin\", \"sulfaperina\", \"sulfaperine\", \"sulfaperinum\", \"sulfatreis\", \"sulfopirimidine\", \"sulpenta\", \"ultrasulfon sirup\")" 0.5 "g" "character(0)"
|
||||
"SLF11" 5335 "Sulfaphenazole" "Trimethoprims" "J01ED08" "Sulfonamides and trimethoprim" "Long-acting sulfonamides" "" "c(\"depocid\", \"depotsulfonamide\", \"eftolon\", \"firmazolo\", \"inamil\", \"isarol\", \"isarol v\", \"merian\", \"microtan pirazolo\", \"nsulfanilamide\", \"orisul\", \"orisulf\", \"paidazolo\", \"phenylsulfapyrazole\", \"plisulfan\", \"raziosulfa\", \"solfafenazolo\", \"sulfabid\", \"sulfafenazol\", \"sulfafenazolo\", \"sulfaphenazol\", \"sulfaphenazole\", \"sulfaphenazolum\", \"sulfaphenazon\", \"sulfaphenylpipazol\", \"sulfaphenylpyrazol\", \"sulfaphenylpyrazole\", \"sulfonylpyrazol\", \"sulphaphenazole\", \"sulphenazole\")" 1 "g" "character(0)"
|
||||
"SLF12" 5336 "Sulfapyridine" "Trimethoprims" "J01EB04" "Sulfonamides and trimethoprim" "Short-acting sulfonamides" "" "c(\"adiplon\", \"coccoclase\", \"dagenan\", \"eubasin\", \"eubasinum\", \"haptocil\", \"piridazol\", \"plurazol\", \"pyriamid\", \"pyridazol\", \"relbapiridina\", \"septipulmon\", \"solfapiridina\", \"streptosilpyridine\", \"sulfapiridina\", \"sulfapyridin\", \"sulfapyridine\", \"sulfapyridinum\", \"sulfidin\", \"sulfidine\", \"sulphapyridin\", \"sulphapyridine\", \"thioseptal\", \"trianon\")" 1 "g" "c(\"14075-6\", \"55580-5\")"
|
||||
"SNA" 60582 "Sulfasuccinamide" "Other antibacterials" "" "c(\"ambesid\", \"derganil\", \"sulfasuccinamid\", \"sulfasuccinamida\", \"sulfasuccinamide\", \"sulfasuccinamidum\")" "character(0)"
|
||||
"SUT" 5340 "Sulfathiazole" "Trimethoprims" "c(\"D06BA02\", \"J01EB07\")" "Sulfonamides and trimethoprim" "Short-acting sulfonamides" "" "c(\"azoquimiol\", \"azoseptale\", \"cerazol\", \"cerazole\", \"chemosept\", \"cibazol\", \"duatok\", \"dulana\", \"eleudron\", \"enterobiocine\", \"estafilol\", \"formosulfathiazole\", \"neostrepsan\", \"norsulfasol\", \"norsulfazol\", \"norsulfazole\", \"norsulfazolum\", \"nsulfanilamide\", \"planomide\", \"poliseptil\", \"sanotiazol\", \"septozol\", \"solfatiazolo\", \"streptosilthiazole\", \"sulfamul\", \"sulfathiazol\", \"sulfathiazole\", \"sulfathiazolum\", \"sulfatiazol\", \"sulfavitina\", \"sulfocerol\", \"sulphathiazole\", \"sulzol\", \"thiacoccine\", \"thiasulfol\",
|
||||
\"thiazamide\", \"thiozamide\", \"wintrazole\")" "87591-4"
|
||||
"SLF13" 3000579 "Sulfathiourea" "Trimethoprims" "J01EB08" "Sulfonamides and trimethoprim" "Short-acting sulfonamides" "" "c(\"badional\", \"baldinol\", \"fontamide\", \"salvoseptyl\", \"solfatiourea\", \"solufontamide\", \"sulfanilthiourea\", \"sulfathiocarbamid\", \"sulfathiocarbamide\", \"sulfathiocarbamidum\", \"sulfathiourea\", \"sulfathiouree\", \"sulfatiourea\", \"sulphathiourea\")" 6 "g" "character(0)"
|
||||
"SOX" 5344 "Sulfisoxazole" "Other antibacterials" "" "c(\"accuzole\", \"alphazole\", \"amidoxal\", \"astrazolo\", \"azo gantrisin\", \"azosulfizin\", \"bactesulf\", \"barazae\", \"chemouag\", \"cosoxazole\", \"dorsulfan\", \"dorsulfan warthausen\", \"entusil\", \"entusul\", \"eryzole\", \"gantrisin\", \"gantrisine\", \"gantrisona\", \"gantrizin\", \"gantrosan\", \"isoxamin\", \"neazolin\", \"neoxazoi\", \"neoxazol\", \"novazolo\", \"novosaxazole\", \"nsulfanilamide\", \"nsulphanilamide\", \"pancid\", \"pediazole\", \"renosulfan\", \"resoxol\", \"roxosul\", \"roxosul tablets\", \"roxoxol\", \"saxosozine\", \"sodizole\", \"solfafurazolo\",
|
||||
\"soxamide\", \"soxazole\", \"soxisol\", \"soxitabs\", \"soxomide\", \"stansin\", \"sulbio\", \"sulfafuraz ole\", \"sulfafurazol\", \"sulfafurazole\", \"sulfafurazolum\", \"sulfagan\", \"sulfagen\", \"sulfaisoxazole\", \"sulfalar\", \"sulfapolar\", \"sulfasol\", \"sulfasoxazole\", \"sulfasoxizole\", \"sulfazin\", \"sulfisin\", \"sulfisonazole\", \"sulfisoxasole\", \"sulfisoxazol\", \"sulfisoxazole\", \"sulfisoxazolum\", \"sulfizin\", \"sulfizol\", \"sulfizole\", \"sulfofurazole\", \"sulfoxol\", \"suloxsol\", \"sulphafuraz\", \"sulphafurazol\", \"sulphafurazole\", \"sulphafurazolum\",
|
||||
\"sulphaisoxazole\", \"sulphisoxazol\", \"sulphisoxazole\", \"sulphofurazole\", \"sulsoxin\", \"thiasin\", \"unisulf\", \"urisoxin\", \"uritrisin\", \"urogan\", \"vagilia\")" "9701-4"
|
||||
"SSS" 86225 "Sulfonamide" "Other antibacterials" "c(\"\", \"sfna\")" "" ""
|
||||
"SLP" 9950244 "Sulopenem" "Other antibacterials" "" "sulopenem" "character(0)"
|
||||
"SLT6" 444022 "Sultamicillin" "Beta-lactams/penicillins" "J01CR04" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "" "c(\"sultamicilina\", \"sultamicillin\", \"sultamicillinum\")" 1.5 "g" "character(0)"
|
||||
"SUR" 46700778 "Surotomycin" "Other antibacterials" "" "surotomycin" "character(0)"
|
||||
"TAL" 71447 "Talampicillin" "Beta-lactams/penicillins" "J01CA15" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "c(\"talampicilina\", \"talampicillin\", \"talampicilline\", \"talampicillinum\")" 2 "g" "character(0)"
|
||||
"TLP" 163307 "Talmetoprim" "Other antibacterials" "" "talmetoprim" "character(0)"
|
||||
"TAZ" 123630 "Tazobactam" "Beta-lactams/penicillins" "J01CG02" "Beta-lactam antibacterials, penicillins" "Beta-lactamase inhibitors" "tazo" "c(\"tazobactam\", \"tazobactam acid\", \"tazobactamum\", \"tazobactum\")" "character(0)"
|
||||
"TBP" 9800194 "Tebipenem" "Carbapenems" "" "" ""
|
||||
"TZD" 11234049 "Tedizolid" "Oxazolidinones" "J01XX11" "Other antibacterials" "Other antibacterials" "tedi" "c(\"tedizolid\", \"torezolid\")" 0.2 "g" 0.2 "g" "character(0)"
|
||||
"TEC" 16131923 "Teicoplanin" "Glycopeptides" "J01XA02" "Other antibacterials" "Glycopeptide antibacterials" "c(\"tec\", \"tei\", \"teic\", \"tp\", \"tpl\", \"tpn\")" "c(\"targocid\", \"tecoplanina\", \"tecoplanine\", \"tecoplaninum\", \"teichomycin\", \"teicoplanina\", \"teicoplanine\", \"teicoplaninum\")" 0.4 "g" "c(\"25534-9\", \"25535-6\", \"34378-0\", \"34379-8\", \"4043-6\", \"80968-1\")"
|
||||
"TCM" "Teicoplanin-macromethod" "Glycopeptides" "" "" ""
|
||||
"TLV" 3081362 "Telavancin" "Glycopeptides" "J01XA03" "Other antibacterials" "Glycopeptide antibacterials" "tela" "c(\"telavancin\", \"vibativ\")" "character(0)"
|
||||
"TLT" 3002190 "Telithromycin" "Macrolides/lincosamides" "J01FA15" "Macrolides, lincosamides and streptogramins" "Macrolides" "c(\"\", \"teli\")" "levviax" 0.8 "g" "character(0)"
|
||||
"TMX" 60021 "Temafloxacin" "Quinolones" "J01MA05" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"tema\")" "c(\"omniflox\", \"temafloxacin\", \"temafloxacina\", \"temafloxacine\", \"temafloxacinum\")" 0.8 "g" "character(0)"
|
||||
"TEM" 171758 "Temocillin" "Beta-lactams/penicillins" "J01CA17" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "c(\"\", \"temo\")" "c(\"temocilina\", \"temocillin\", \"temocillina\", \"temocilline\", \"temocillinum\")" 4 "g" "character(0)"
|
||||
"TRB" 1549008 "Terbinafine" "Antifungals/antimycotics" "c(\"D01AE15\", \"D01BA02\")" "Antifungals for systemic use" "Antifungals for systemic use" "c(\"\", \"terb\")" "c(\"corbinal\", \"lamasil\", \"lamisil\", \"lamisil at\", \"lamisil tablet\", \"terbinafina\", \"terbinafine\", \"terbinafinum\", \"terbinex\")" 0.25 "g" "character(0)"
|
||||
"TRC" 441383 "Terconazole" "Antifungals/antimycotics" "G01AG02" "" "c(\"fungistat\", \"panlomyc\", \"terazol\", \"terconazol\", \"terconazole\", \"terconazolum\", \"tercospor\", \"triaconazole\", \"zazole\")" "character(0)"
|
||||
"TRZ" 65720 "Terizidone" "Antimycobacterials" "J04AK03" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "" "c(\"terivalidin\", \"terizidon\", \"terizidona\", \"terizidone\", \"terizidonum\")" "character(0)"
|
||||
"TCY" 54675776 "Tetracycline" "Tetracyclines" "c(\"A01AB13\", \"D06AA04\", \"J01AA07\", \"S01AA09\", \"S02AA08\", \"S03AA02\")" "Tetracyclines" "Tetracyclines" "c(\"tc\", \"te\", \"tet\", \"tetr\")" "c(\"abramycin\", \"abricycline\", \"achromycin\", \"achromycin v\", \"actisite\", \"agromicina\", \"ambramicina\", \"ambramycin\", \"amycin\", \"biocycline\", \"bristaciclin\", \"bristaciclina\", \"bristacycline\", \"cefracycline\", \"centet\", \"ciclibion\", \"copharlan\", \"criseociclina\", \"cyclomycin\", \"cyclopar\", \"cytome\", \"democracin\", \"deschlorobiomycin\", \"dumocyclin\", \"enterocycline\", \"hostacyclin\", \"lexacycline\", \"limecycline\", \"liquamycin\", \"medocycline\", \"mericycline\", \"micycline\", \"neocycline\", \"oletetrin\", \"omegamycin\",
|
||||
\"orlycycline\", \"panmycin\", \"piracaps\", \"polycycline\", \"polyotic\", \"purocyclina\", \"resteclin\", \"robitet\", \"roviciclina\", \"sigmamycin\", \"solvocin\", \"sumycin\", \"sumycin syrup\", \"tetrabon\", \"tetrachel\", \"tetraciclina\", \"tetracycl\", \"tetracyclin\", \"tetracycline\", \"tetracycline base\", \"tetracycline i\", \"tetracycline ii\", \"tetracyclinum\", \"tetracyn\", \"tetradecin\", \"tetrafil\", \"tetramed\", \"tetrasure\", \"tetraverine\", \"tetrazyklin\", \"tetrex\", \"topicycline\", \"tsiklomistsin\", \"tsiklomitsin\", \"veracin\", \"vetacyclinum\"
|
||||
)" 1 "g" 1 "g" "c(\"25272-6\", \"4045-1\", \"87590-6\")"
|
||||
"TET" 65450 "Tetroxoprim" "Other antibacterials" "" "c(\"tetroxoprim\", \"tetroxoprima\", \"tetroxoprime\", \"tetroxoprimum\")" "character(0)"
|
||||
"THA" 9568512 "Thiacetazone" "Oxazolidinones" "" "c(\"aktivan\", \"ambathizon\", \"amithiozone\", \"amithizone\", \"amitiozon\", \"benthiozone\", \"benzothiozane\", \"benzothiozon\", \"berculon a\", \"berkazon\", \"citazone\", \"conteben\", \"diasan\", \"diazan\", \"domakol\", \"ilbion\", \"livazone\", \"mirizone neustab\", \"mivizon\", \"myvizone\", \"neotibil\", \"neustab\", \"novakol\", \"nuclon argentinian\", \"panrone\", \"parazone\", \"seroden\", \"siocarbazone\", \"tebalon\", \"tebecure\", \"tebemar\", \"tebesone i\", \"tebethion\", \"tebethione\", \"tebezon\", \"thiacetazone\", \"thiacetone\", \"thiacetozone\",
|
||||
\"thibon\", \"thibone\", \"thioacetazon\", \"thioacetazone\", \"thioacetazonum\", \"thioazetazone\", \"thiocarbazil\", \"thiomicid\", \"thionicid\", \"thioparamizon\", \"thioparamizone\", \"thiosemicarbarzone\", \"thiosemicarbazone\", \"thiotebesin\", \"thiotebezin\", \"thiotebicina\", \"thizone\", \"tiacetazon\", \"tibicur\", \"tibion\", \"tibione\", \"tibizan\", \"tibone\", \"tioacetazon\", \"tioacetazona\", \"tioatsetazon\", \"tiobicina\", \"tiocarone\", \"tiosecolo\", \"tubercazon\", \"tubigal\")" "character(0)"
|
||||
"THI" 27200 "Thiamphenicol" "Amphenicols" "J01BA02" "Amphenicols" "Amphenicols" "" "c(\"descocin\", \"dexawin\", \"dextrosulfenidol\", \"dextrosulphenidol\", \"efnicol\", \"hyrazin\", \"igralin\", \"macphenicol\", \"masatirin\", \"neomyson\", \"racefenicol\", \"racefenicolo\", \"racefenicolum\", \"raceophenidol\", \"racephenicol\", \"rincrol\", \"thiamcol\", \"thiamphenicol\", \"thiamphenicolum\", \"thiocymetin\", \"thiomycetin\", \"thiophenicol\", \"tiamfenicol\", \"tiamfenicolo\", \"urfamicina\", \"urfamycine\", \"vicemycetin\")" 1.5 "g" 1.5 "g" "character(0)"
|
||||
"THI1" "Thioacetazone/isoniazid" "Antimycobacterials" "J04AM04" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" ""
|
||||
"TIA" 656958 "Tiamulin" "Other antibacterials" "" "c(\"denagard\", \"tiamulin\", \"tiamulin pamoate\", \"tiamulina\", \"tiamuline\", \"tiamulinum\")" "87589-8"
|
||||
"TIC" 36921 "Ticarcillin" "Beta-lactams/penicillins" "J01CA13" "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" 6437075 "Ticarcillin/clavulanic acid" "Beta-lactams/penicillins" "J01CR03" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "c(\"t/c\", \"tcc\", \"ticl\", \"tim\", \"tlc\")" "timentin" 15 "g" "character(0)"
|
||||
"TGC" 54686904 "Tigecycline" "Tetracyclines" "J01AA12" "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" "P01AA05" "" "c(\"tilbroquinol\", \"tilbroquinolum\")" "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"
|
||||
"TIN" 5479 "Tinidazole" "Other antibacterials" "c(\"J01XD02\", \"P01AB02\")" "Other antibacterials" "Imidazole derivatives" "c(\"\", \"tini\")" "c(\"amtiba\", \"bioshik\", \"ethyl sulfone\", \"fasigin\", \"fasigyn\", \"fasigyntrade mark\", \"fasygin\", \"glongyn\", \"haisigyn\", \"pletil\", \"simplotan\", \"simplotantrade mark\", \"sorquetan\", \"tindamax\", \"tindamaxtrade mark\", \"tinidazol\", \"tinidazole\", \"tinidazolum\", \"tricolam\", \"trimonase\")" 2 "g" 1.5 "g" "character(0)"
|
||||
"TCR" 3001386 "Tiocarlide" "Antimycobacterials" "J04AD02" "Drugs for treatment of tuberculosis" "Thiocarbamide derivatives" "" "c(\"amixyl\", \"datanil\", \"disocarban\", \"disoxyl\", \"thiocarlide\", \"tiocarlid\", \"tiocarlida\", \"tiocarlide\", \"tiocarlidum\")" 7 "g" "character(0)"
|
||||
"TDC" 10247721 "Tiodonium chloride" "Other antibacterials" "" "c(\"cloruro de tiodonio\", \"tiodonii chloridum\", \"tiodonium chloride\")" "character(0)"
|
||||
"TXC" 65788 "Tioxacin" "Quinolones" "" "c(\"tioxacin\", \"tioxacine\", \"tioxacino\", \"tioxacinum\", \"tioxic acid\")" "character(0)"
|
||||
"TIZ" 394397 "Tizoxanide" "Other antibacterials" "" "ntzdes" "character(0)"
|
||||
"TOB" 36294 "Tobramycin" "Aminoglycosides" "c(\"J01GB01\", \"S01AA12\")" "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\")" "" ""
|
||||
"TFX" 5517 "Tosufloxacin" "Quinolones" "J01MA22" "" "tosufloxacin" 0.45 "g" "character(0)"
|
||||
"TMP" 5578 "Trimethoprim" "Trimethoprims" "J01EA01" "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\",
|
||||
\"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" 358641 "Trimethoprim/sulfamethoxazole" "Trimethoprims" "J01EE01" "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)"
|
||||
"TRL" 202225 "Troleandomycin" "Macrolides/lincosamides" "J01FA08" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "c(\"acetyloleandomycin\", \"aovine\", \"cyclamycin\", \"evramicina\", \"matromicina\", \"matromycin t\", \"oleandocetine\", \"t.a.o.\", \"treolmicina\", \"tribiocillina\", \"triocetin\", \"triolan\", \"troleandomicina\", \"troleandomycin\", \"troleandomycine\", \"troleandomycinum\", \"viamicina\", \"wytrion\")" 1 "g" "character(0)"
|
||||
"TRO" 55886 "Trospectomycin" "Other antibacterials" "" "c(\"trospectinomycin\", \"trospectomicina\", \"trospectomycin\", \"trospectomycine\", \"trospectomycinum\")" "character(0)"
|
||||
"TVA" 62959 "Trovafloxacin" "Quinolones" "J01MA13" "Quinolone antibacterials" "Fluoroquinolones" "c(\"\", \"trov\")" "c(\"trovafloxacin\", \"trovan\")" 0.2 "g" 0.2 "g" "character(0)"
|
||||
"TUL" 9832301 "Tulathromycin" "Macrolides/lincosamides" "" "c(\"draxxin\", \"tulathrmycin a\", \"tulathromycin\", \"tulathromycin a\")" "character(0)"
|
||||
"TYL" 5280440 "Tylosin" "Macrolides/lincosamides" "" "c(\"fradizine\", \"tilosina\", \"tylocine\", \"tylosin\", \"tylosin a\", \"tylosine\", \"tylosinum\")" "87587-2"
|
||||
"TYL1" 6441094 "Tylvalosin" "Macrolides/lincosamides" "c(\"\", \"tvn\")" "" ""
|
||||
"PRU1" 124225 "Ulifloxacin (Prulifloxacin)" "Other antibacterials" "" "ulifloxacin" "character(0)"
|
||||
"VAN" 14969 "Vancomycin" "Glycopeptides" "c(\"A07AA09\", \"J01XA01\", \"S01AA28\")" "Other antibacterials" "Glycopeptide antibacterials" "c(\"va\", \"van\", \"vanc\")" "c(\"vancocin\", \"vancocin hcl\", \"vancoled\", \"vancomicina\", \"vancomycin\", \"vancomycin hcl\", \"vancomycine\", \"vancomycinum\", \"vancor\", \"viomycin derivative\")" 2 "g" 2 "g" "c(\"13586-3\", \"13587-1\", \"20578-1\", \"31012-8\", \"39092-2\", \"39796-8\", \"39797-6\", \"4089-9\", \"4090-7\", \"4091-5\", \"4092-3\", \"50938-0\", \"59381-4\")"
|
||||
"VAM" "Vancomycin-macromethod" "Glycopeptides" "" "" ""
|
||||
"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)"
|
||||
"VOR" 71616 "Voriconazole" "Antifungals/antimycotics" "J02AC03" "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" 72144 "Xibornol" "Other antibacterials" "J01XX02" "Other antibacterials" "Other antibacterials" "" "c(\"bactacine\", \"bracen\", \"nanbacine\", \"xibornol\", \"xibornolo\", \"xibornolum\")" "character(0)"
|
||||
"ZID" 77846445 "Zidebactam" "Other antibacterials" "" "zidebactam" "character(0)"
|
||||
"ZFD" "Zoliflodacin" "" "" ""
|
||||
"AMA" 4649 "4-aminosalicylic acid" "Antimycobacterials"
|
||||
@@ -1 +1 @@
|
||||
7b6649442069d3d121f61ca3ff01843a
|
||||
246da79545e045edac7c3ec445b3a04e
|
||||
|
||||
@@ -1 +1 @@
|
||||
58d6a0589aea598420e37045fb04a5ae
|
||||
21f4808065fcad26bdf869a693b074d2
|
||||
|
||||
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 40 KiB |
@@ -1,13 +0,0 @@
|
||||
ex2 <- example_isolates
|
||||
for (extra_id in seq_len(50)) {
|
||||
ex2 <- ex2 %>%
|
||||
bind_rows(example_isolates %>% mutate(patient_id = paste0(patient_id, extra_id)))
|
||||
}
|
||||
# randomly clear antibibiograms of 2%
|
||||
clr <- sort(sample(x = seq_len(nrow(ex2)),
|
||||
size = nrow(ex2) * 0.02))
|
||||
for (row in which(is.rsi(ex2))) {
|
||||
ex2[clr, row] <- NA_rsi_
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
library(dplyr)
|
||||
example_isolates %>%
|
||||
select(mo, where(is.rsi)) %>%
|
||||
tidyr::pivot_longer(cols = where(is.rsi)) %>%
|
||||
# remove intrisic R
|
||||
filter(!paste(mo, name) %in% AMR:::INTRINSIC_R) %>%
|
||||
mutate(name = as.ab(name),
|
||||
value = ifelse(value == "R", 1, 0),
|
||||
class = ab_group(name)) %>%
|
||||
group_by(mo, class) %>%
|
||||
summarise(n = n(),
|
||||
res = mean(value, na.rm = TRUE)) %>%
|
||||
filter(n > 30, !is.na(res))
|
||||
|
||||
|
||||
|
||||
df <- example_isolates
|
||||
search_mo <- "B_ESCHR_COLI"
|
||||
intrinsic_res <- INTRINSIC_R[INTRINSIC_R %like% search_mo]
|
||||
intrinsic_res <- gsub(".* (.*)", "\\1", intrinsic_res)
|
||||
|
||||
x <- df %>%
|
||||
select(mo, where(is.rsi)) %>%
|
||||
filter(mo == search_mo) %>%
|
||||
# at least 30 results available
|
||||
select(function(x) sum(!is.na(x)) >= 30) %>%
|
||||
# remove intrisic R
|
||||
select(!matches(paste(intrinsic_res, collapse = "|")))
|
||||
|
Before Width: | Height: | Size: 87 KiB |
@@ -30,8 +30,9 @@
|
||||
# 2. Download the CSV from https://loinc.org/download/loinc-table-file-csv/ (Loinc_2.67_Text_2.67.zip)
|
||||
# 3. Read Loinc.csv that's in this zip file
|
||||
loinc_df <- read.csv("data-raw/Loinc.csv",
|
||||
row.names = NULL,
|
||||
stringsAsFactors = FALSE)
|
||||
row.names = NULL,
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
|
||||
# 4. Clean and add
|
||||
library(dplyr)
|
||||
@@ -39,7 +40,10 @@ library(cleaner)
|
||||
library(AMR)
|
||||
loinc_df %>% freq(CLASS) # to find the drugs
|
||||
loinc_df <- loinc_df %>% filter(CLASS == "DRUG/TOX")
|
||||
ab_names <- antibiotics %>% pull(name) %>% paste0(collapse = "|") %>% paste0("(", ., ")")
|
||||
ab_names <- antibiotics %>%
|
||||
pull(name) %>%
|
||||
paste0(collapse = "|") %>%
|
||||
paste0("(", ., ")")
|
||||
|
||||
antibiotics$loinc <- as.list(rep(NA_character_, nrow(antibiotics)))
|
||||
for (i in seq_len(nrow(antibiotics))) {
|
||||
|
||||