99 Commits
Author SHA1 Message Date
dr. M.S. (Matthijs) Berends cfd31f0f0c (v2.1.1.9099) fix generating GPT training test 2024-10-17 11:55:23 +02:00
dr. M.S. (Matthijs) Berends a9e753b1dc (v2.1.1.9098) update Py vigettes 2024-10-17 11:52:01 +02:00
dr. M.S. (Matthijs) Berends 40edc16fdf fix PyPI 2024-10-15 17:31:47 +02:00
dr. M.S. (Matthijs) Berends 448b6abb06 fix Python PI publish 2024-10-15 17:27:00 +02:00
dr. M.S. (Matthijs) Berends 5c4d8fcd2a (v2.1.1.9095) Python support 2024-10-15 17:12:55 +02:00
dr. M.S. (Matthijs) Berends 94501371cd (v2.1.1.9094) fix antibiotics 2024-10-10 16:38:20 +02:00
dr. M.S. (Matthijs) Berends ef79d22daf (v2.1.1.9093) New brand names 2024-10-06 22:30:52 +02:00
dr. M.S. (Matthijs) Berends c588902f4c (v2.1.1.9092) Fix website 2024-10-06 16:25:31 +02:00
Matthijs Berends 3dd3b6292a Update _pkgdown.yml 2024-10-04 16:49:55 +02:00
dr. M.S. (Matthijs) Berends 325664f5aa (v2.1.1.9090) website error 2024-10-04 16:08:41 +02:00
dr. M.S. (Matthijs) Berends 0736ac7a7e (v2.1.1.9089) website update 2024-10-04 15:44:05 +02:00
dr. M.S. (Matthijs) Berends 9fb891eee2 (v2.1.1.9087) update unit tests 2024-10-04 15:28:44 +02:00
dr. M.S. (Matthijs) Berends 738689beea website (no-verify) 2024-10-02 10:31:43 +02:00
dr. M.S. (Matthijs) Berends 50a9f8f0e0 (v2.1.1.9086) website update 2024-10-02 10:20:05 +02:00
Matthijs Berends 88740b6f11 Update extra.js 2024-09-30 23:15:28 +02:00
dr. M.S. (Matthijs) Berends 91415462c0 (v2.1.1.9084) add vignette about Python 2024-09-30 22:04:44 +02:00
dr. M.S. (Matthijs) Berends 8907e8e4af (v2.1.1.9083) update for first_isolate() 2024-09-30 19:13:53 +02:00
dr. M.S. (Matthijs) Berends 681fe011fe (v2.1.1.9082) algorithm updates 2024-09-30 18:46:55 +02:00
dr. M.S. (Matthijs) Berends ac1c40d8bb (v2.1.1.9081) HUGE microorganisms update for fungi! 2024-09-29 22:17:56 +02:00
dr. M.S. (Matthijs) Berends a558f4c121 (v2.1.1.9080) fix rescale_mic() for an outside MIC range 2024-09-24 22:39:40 +02:00
dr. M.S. (Matthijs) Berends 1ca40e8d67 (v2.1.1.9079) fix for uti in as.sir() 2024-09-24 15:34:12 +02:00
dr. M.S. (Matthijs) Berends 127892430d (v2.1.1.9078) 12 new formatting formats for antibiogram(), prepare for Bayesian WISCA 2024-09-22 11:45:51 +02:00
dr. M.S. (Matthijs) Berends 28bf91cbf5 (v2.1.1.9077) fix logos 2024-09-19 14:40:19 +02:00
dr. M.S. (Matthijs) Berends 82239503ee (v2.1.1.9076) 2024-09-19 14:22:09 +02:00
dr. M.S. (Matthijs) Berends a88472a263 test new git hook 2024-09-19 14:20:03 +02:00
dr. M.S. (Matthijs) Berends 29756977cf no-verify 2024-09-19 13:58:41 +02:00
dr. M.S. (Matthijs) Berends 4e96a56b6a (v2.1.1.9073) unit tests 2024-09-19 13:57:36 +02:00
dr. M.S. (Matthijs) Berends ef8ef28650 (v2.1.1.9072) 2024-09-19 11:46:17 +02:00
dr. M.S. (Matthijs) Berends ddb23b6e73 (v2.1.1.9071) update veterinary SIR interpretation, add only_fungi 2024-09-19 11:44:56 +02:00
dr. M.S. (Matthijs) Berends 573c0346ed (v2.1.1.9070) fix for mo_current mo (no-verify) 2024-07-19 18:05:49 +02:00
dr. M.S. (Matthijs) Berends 83907c9c65 add files (no-verify) 2024-07-17 14:31:09 +02:00
dr. M.S. (Matthijs) Berends 7258a491b9 (v2.1.1.9068) fix for mo_url() and as.mo() for synonyms 2024-07-17 14:29:55 +02:00
dr. M.S. (Matthijs) Berends 63f6790c58 add (no-verify) 2024-07-16 16:10:38 +02:00
dr. M.S. (Matthijs) Berends b94dac770c (v2.1.1.9066) git hook fix? 2024-07-16 16:09:33 +02:00
dr. M.S. (Matthijs) Berends ff03bb6471 (v2.1.1.9065) unit tests 2 2024-07-16 15:58:18 +02:00
dr. M.S. (Matthijs) Berends 7f344836ea (v2.1.1.9064) unit tests 2024-07-16 15:55:58 +02:00
dr. M.S. (Matthijs) Berends 640888f408 (v2.1.1.9064) update all microbial taxonomy, add mycobank, big documentation update 2024-07-16 14:53:17 +02:00
dr. M.S. (Matthijs) Berends 4f9db23684 check for windows unit test (no-check) 2024-06-23 16:18:42 +02:00
dr. M.S. (Matthijs) Berends 82585901a7 (v2.1.1.9061) animal host fix 2024-06-19 15:41:45 +02:00
dr. M.S. (Matthijs) Berends c67d003e9e (v2.1.1.9060) SDD results now in as.sir() 2024-06-19 15:08:23 +02:00
dr. M.S. (Matthijs) Berends 0c3d81f32e (v2.1.1.9059) documentation fix 2024-06-17 22:26:05 +02:00
dr. M.S. (Matthijs) Berends 1bc2e04e1c (v2.1.1.9058) fix hosts, add translations 2024-06-17 22:19:38 +02:00
dr. M.S. (Matthijs) Berends a4dc37a4e4 (v2.1.1.9057) fix for missing breakpoints 2024-06-17 16:52:12 +02:00
dr. M.S. (Matthijs) Berends d9e66fb118 (v2.1.1.9056) example fix 2024-06-17 14:52:18 +02:00
dr. M.S. (Matthijs) Berends 1e65b5a289 (v2.1.1.9055) example fix 2024-06-17 14:36:40 +02:00
dr. M.S. (Matthijs) Berends 13baf8d7be (v2.1.1.9054) fix examples 2024-06-17 13:52:02 +02:00
dr. M.S. (Matthijs) Berends 2dee1d71dc (v2.1.1.9053) add verbose to as.sir(), unit test fix 2024-06-17 10:38:45 +02:00
dr. M.S. (Matthijs) Berends 68f7795481 (v2.1.1.9052) unit test fix 2024-06-16 20:53:50 +02:00
dr. M.S. (Matthijs) Berends 4ffac7e22d (v2.1.1.9051) fix VGS mo code 2024-06-16 11:28:56 +02:00
dr. M.S. (Matthijs) Berends bdbf5198a2 (v2.1.1.9050) vctrs fix for sir, small documentation fixes 2024-06-15 15:33:49 +02:00
dr. M.S. (Matthijs) Berends 9bf7584d58 (v2.1.1.9049) new 2024 breakpoints, add AMO, set NI instead of N 2024-06-14 22:39:01 +02:00
dr. M.S. (Matthijs) Berends de17de1be9 (v2.1.1.9048) vctrs update for sir 2024-06-13 20:55:17 +02:00
dr. M.S. (Matthijs) Berends 3179216c81 (v2.1.1.9047) unit test and index 2024-06-13 07:37:53 +02:00
dr. M.S. (Matthijs) Berends cd1b37ff69 (v2.1.1.9046) unit test fix 2024-06-12 14:37:44 +02:00
dr. M.S. (Matthijs) Berends c753afcd76 (v2.1.1.9045) fix host in animal guidelines 2024-06-12 10:32:43 +02:00
dr. M.S. (Matthijs) Berends 3a54711dfe (v2.1.1.9044) update website 2024-06-10 15:10:54 +02:00
dr. M.S. (Matthijs) Berends 31207952d3 (v2.1.1.9043) fix sir translation with as.double 2024-06-10 10:34:45 +02:00
dr. M.S. (Matthijs) Berends a3071cf58b (v2.1.1.9042) update translations and example isolates 2024-06-09 11:31:04 +02:00
dr. M.S. (Matthijs) Berends af74e1d4f2 (v2.1.1.9041) antibiotics update 2024-06-08 17:35:25 +02:00
dr. M.S. (Matthijs) Berends e2acc513a5 (v2.1.1.9040) try to put version number in commit msg 2024-06-07 12:07:07 +02:00
dr. M.S. (Matthijs) Berends 0bda9e9997 try to add version to commit msg 2024-06-04 20:21:12 +02:00
dr. M.S. (Matthijs) Berends c5981cdeb3 fix unit test 2024-06-04 20:17:54 +02:00
dr. M.S. (Matthijs) Berends 7c1b564648 fix SIR interpretation for uti 2024-05-31 21:24:35 +02:00
dr. M.S. (Matthijs) Berends 60c6c21e45 fix SIR interpretation 2024-05-31 09:50:54 +02:00
dr. M.S. (Matthijs) Berends ba4dc20cf3 autoplot fix 2024-05-30 16:39:59 +02:00
dr. M.S. (Matthijs) Berends d4490c7f25 fix sorting of MICs, MIC autoplot titles 2024-05-30 15:50:17 +02:00
dr. M.S. (Matthijs) Berends c3ce1b551d rename limit_mic_range() to rescale_mic() 2024-05-24 15:07:41 +02:00
dr. M.S. (Matthijs) Berends d214f74e25 allow column name for ab in as.sir() 2024-05-20 21:29:13 +02:00
dr. M.S. (Matthijs) Berends fc269e667d unit test fix 2024-05-20 18:58:35 +02:00
dr. M.S. (Matthijs) Berends 08a27922a8 new SDD and N for as.sir() 2024-05-20 15:27:04 +02:00
dr. M.S. (Matthijs) Berends b68f47d985 improved algorithm of as.ab() 2024-05-12 16:24:44 +02:00
dr. M.S. (Matthijs) Berends 1bce7ed3d3 fix git hooks 2024-04-24 11:58:16 +02:00
dr. M.S. (Matthijs) Berends 7f18e66c4e unit test fix 2024-04-24 11:42:43 +02:00
dr. M.S. (Matthijs) Berends 3e5c7d45c6 update intro logo 2024-04-24 09:58:24 +02:00
dr. M.S. (Matthijs) Berends 25089e811e correct for high-level abx 2024-04-24 09:50:32 +02:00
dr. M.S. (Matthijs) Berends 0d8a91db49 rename pre-commit hook to pre-commit checks (no-check) 2024-04-23 10:55:48 +02:00
dr. M.S. (Matthijs) Berends 04df6dfcf5 fix website nav header (no-check) 2024-04-23 10:33:26 +02:00
dr. M.S. (Matthijs) Berends 35f095cceb fixes #148 2024-04-23 09:34:05 +02:00
dr. M.S. (Matthijs) Berends 2899b3c840 new mo_group_members() 2024-04-19 10:18:21 +02:00
dr. M.S. (Matthijs) Berends 7e7bc9d56e Merge branch 'main' of https://github.com/msberends/AMR 2024-04-08 09:58:54 +02:00
dr. M.S. (Matthijs) Berends d2c5e4b749 update website colours 2024-04-08 09:55:21 +02:00
Matthijs Berends 42a23e89a8 Update DESCRIPTION 2024-04-08 00:52:25 +02:00
dr. M.S. (Matthijs) Berends 94e9a4d99b update MIC implementation 2024-04-07 20:22:59 +02:00
dr. M.S. (Matthijs) Berends 0039cb05d6 update MIC comparisons 2024-04-05 16:44:43 +02:00
dr. M.S. (Matthijs) Berends 4170def0ec unit test 2024-03-09 16:46:59 +01:00
dr. M.S. (Matthijs) Berends bc4f8515e2 new Norwegian link 2024-03-03 23:24:57 +01:00
dr. M.S. (Matthijs) Berends f2d245b0cb update navbar colours 2024-03-03 19:07:09 +01:00
dr. M.S. (Matthijs) Berends 46634bfcaa navbar colour 2024-02-25 16:48:04 +01:00
Matthijs Berends 8b43fed94d Update _pkgdown.yml 2024-02-25 14:40:19 +01:00
dr. M.S. (Matthijs) Berends 8d077149fa new logo 2024-02-25 14:20:43 +01:00
dr. M.S. (Matthijs) Berends b303662ec6 fix veterinary for R<4 2024-02-24 19:26:35 +01:00
dr. M.S. (Matthijs) Berends 35963ca3dc vctrs fix 2024-02-24 18:51:37 +01:00
dr. M.S. (Matthijs) Berends 4aa5413641 fix unit test 2024-02-24 18:14:50 +01:00
dr. M.S. (Matthijs) Berends 7be4dabbc0 support veterinary MIC/disk translation 2024-02-24 15:16:52 +01:00
Emil Rossing 74ea6c8c60 Added support for 'html' in italicize_taxonomy() (#134) 2024-02-13 13:47:07 +01:00
dr. M.S. (Matthijs) Berends 83e92fd88c docu fix 2023-12-04 08:19:02 +01:00
dr. M.S. (Matthijs) Berends 7059568581 fix scale functions 2023-12-03 16:51:54 +01:00
dr. M.S. (Matthijs) Berends c7461766ce Remove RSI from package, add extra MIC scale functions 2023-12-03 11:34:48 +01:00
dr. M.S. (Matthijs) Berends 6f417d0ef2 add scale_x_mic() 2023-12-03 01:06:00 +01:00
333 changed files with 399499 additions and 159159 deletions
-1
View File
@@ -30,7 +30,6 @@
^vignettes/datasets\.Rmd$
^vignettes/EUCAST\.Rmd$
^vignettes/MDR\.Rmd$
^vignettes/other_pkg.*\.Rmd$
^vignettes/PCA\.Rmd$
^vignettes/resistance_predict\.Rmd$
^vignettes/WHONET\.Rmd$
+62
View File
@@ -0,0 +1,62 @@
#!/bin/bash
# ==================================================================== #
# TITLE: #
# AMR: An R Package for Working with Antimicrobial Resistance Data #
# #
# SOURCE CODE: #
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
# Center Groningen in The Netherlands, in collaboration with many #
# colleagues from around the world, see our website. #
# #
# 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/ #
# ==================================================================== #
# Path to the commit message file
COMMIT_MSG_FILE="$1"
# Read the original commit message
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
# Check if commit should skip checks
if [[ "$COMMIT_MSG" =~ no-?checks?|no-?verify ]]; then
echo "Not modifying commit message with 'pre-commit':"
echo "Commit message contains 'no-check' or 'no-verify'."
echo ""
exit 0
fi
# Read the version number from the temporary file
if [ -f ".git/commit_version.tmp" ]; then
currentversion=$(cat .git/commit_version.tmp)
rm -f .git/commit_version.tmp
else
echo "Version number file not found."
currentversion=""
fi
# Prepend the version number to the commit message if available
if [ -n "$currentversion" ]; then
echo "(v${currentversion}) ${COMMIT_MSG}" > "$COMMIT_MSG_FILE"
else
echo "No version number to prepend to commit message."
fi
exit 0
+39 -25
View File
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# ==================================================================== #
# TITLE: #
@@ -8,9 +8,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -29,20 +29,34 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
echo "Running pre-commit hook..."
# Check if commit should skip checks
COMMIT_MSG_FILE=".git/COMMIT_EDITMSG"
if [ -f "$COMMIT_MSG_FILE" ]; then
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
if [[ "$COMMIT_MSG" =~ no-?checks?|no-?verify ]]; then
echo "Not running prehook 'pre-commit':"
echo "Commit message contains 'no-check' or 'no-verify'."
echo ""
exit 0
fi
fi
echo "Running prehook..."
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Run the R script and stage the modified files
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')"
Rscript -e "source('data-raw/_pre_commit_checks.R')"
currentpkg=$(Rscript -e "cat(pkgload::pkg_name())")
bash data-raw/AMRforRGPT.sh
echo "- Adding changed files in ./data-raw and ./man to this commit"
git add data-raw/*
git add man/*
git add R/sysdata.rda
git add NAMESPACE
else
echo "- R package 'pkgload', 'devtools', 'dplyr', or 'styler' not installed!"
echo "- R package 'pkgload', 'devtools', or 'dplyr' not installed!"
currentpkg="your"
fi
else
@@ -51,51 +65,51 @@ else
fi
echo ""
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "Updating semantic versioning and date..."
# get tags from remote, and remove tags not on remote:
# Get tags from remote and remove tags not on remote
git fetch origin --prune --prune-tags --quiet
currenttagfull=$(git describe --tags --abbrev=0)
currenttag=$(git describe --tags --abbrev=0 | sed 's/v//')
# assume main branch to be 'main' or 'master', pick the right name:
# Assume main branch to be 'main' or 'master'
defaultbranch=$(git branch | cut -c 3- | grep -E '^master$|^main$')
if [ "$currenttag" = "" ]; then
# there is no tag, so set tag to 0.0.1 and commit index to current count
currenttag="0.0.1"
currentcommit=$(git rev-list --count ${defaultbranch})
echo "- no git tags found, create one in format 'v(x).(y).(z)' - curently ${currentcommit} previous commits in '${defaultbranch}'"
echo "- No git tags found, creating one in format 'v(x).(y).(z)' - currently ${currentcommit} previous commits in '${defaultbranch}'"
else
# there is a tag, so base version number on that
currentcommit=$(git rev-list --count ${currenttagfull}..${defaultbranch})
echo "- latest tag is '${currenttagfull}', with ${currentcommit} previous commits in '${defaultbranch}'"
echo "- Latest tag is '${currenttagfull}', with ${currentcommit} previous commits in '${defaultbranch}'"
fi
# combine tag (e.g. 1.2.3) and commit number (like 5) increased by 9000 to indicate beta version
currentversion="$currenttag.$((currentcommit + 9001))" # results in e.g. 1.2.3.9005
# Combine tag and commit number
currentversion="$currenttag.$((currentcommit + 9001))"
echo "- ${currentpkg} pkg version set to ${currentversion}"
# set version number and date to DESCRIPTION file
# Update version number and date in DESCRIPTION
sed -i -- "s/^Version: .*/Version: ${currentversion}/" DESCRIPTION
sed -i -- "s/^Date: .*/Date: $(date '+%Y-%m-%d')/" DESCRIPTION
echo "- updated version number and date in ./DESCRIPTION"
# remove leftover on macOS
echo "- Updated version number and date in ./DESCRIPTION"
rm -f DESCRIPTION--
# add to commit
git add DESCRIPTION
# set version number to NEWS file
# Update version number in NEWS.md
if [ -e "NEWS.md" ]; then
if [ "$currentpkg" = "your" ]; then
currentpkg=""
fi
sed -i -- "1s/.*/# ${currentpkg} ${currentversion}/" NEWS.md
echo "- updated version number in ./NEWS.md"
# remove leftover on macOS
echo "- Updated version number in ./NEWS.md"
rm -f NEWS.md--
# add to commit
git add NEWS.md
else
echo "- no NEWS.md found!"
echo "- No NEWS.md found!"
fi
echo ""
# Save the version number for use in the commit-msg hook
echo "${currentversion}" > .git/commit_version.tmp
exit 0
+4 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -49,6 +49,7 @@ jobs:
# Test all old versions of R >= 3.0, we support them all!
# For these old versions, dependencies and vignettes will not be checked.
# For recent R versions, see check-recent.yaml (r-lib and tidyverse support the latest 5 major R releases).
- {os: ubuntu-latest, r: '3.6', allowfail: false}
# - {os: windows-latest, r: '3.5', allowfail: true} # always fails, horrible with UTF-8
- {os: ubuntu-latest, r: '3.4', allowfail: false}
- {os: ubuntu-latest, r: '3.3', allowfail: false}
+8 -8
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -58,15 +58,15 @@ jobs:
- {os: ubuntu-latest, r: 'devel', allowfail: false}
# current 'release' version, check all major OSes:
- {os: macOS-latest, r: '4.3', allowfail: false}
- {os: windows-latest, r: '4.3', allowfail: false}
- {os: ubuntu-latest, r: '4.3', allowfail: false}
- {os: macOS-latest, r: 'release', allowfail: false}
- {os: windows-latest, r: 'release', allowfail: false}
- {os: ubuntu-latest, r: 'release', allowfail: false}
# older versions (see also check-old.yaml for even older versions):
- {os: ubuntu-latest, r: '4.3', allowfail: false}
- {os: ubuntu-latest, r: '4.2', allowfail: false}
- {os: ubuntu-latest, r: '4.1', allowfail: false}
- {os: ubuntu-latest, r: '4.0', allowfail: false}
- {os: ubuntu-latest, r: '3.6', allowfail: false} # when a new R releases, this one has to move to check-old.yaml
- {os: ubuntu-latest, r: '4.0', allowfail: false} # when a new R releases, this one has to move to check-old.yaml
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+69
View File
@@ -0,0 +1,69 @@
# ==================================================================== #
# TITLE: #
# AMR: An R Package for Working with Antimicrobial Resistance Data #
# #
# SOURCE CODE: #
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
# Center Groningen in The Netherlands, in collaboration with many #
# colleagues from around the world, see our website. #
# #
# 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/ #
# ==================================================================== #
on:
push:
# only on main
branches: "main"
name: Publish Python Package to PyPI
jobs:
update-pypi:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine wheel
- name: Build the Python package
run: |
cd data-raw/
bash _generate_python_wrapper.sh
- name: Publish to PyPI
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
cd data-raw/python_wrapper/AMR
python -m twine upload dist/*
# for test server:
# python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+1
View File
@@ -26,3 +26,4 @@ data-raw/country_analysis_url_token.R
data-raw/country_analysis2.R
data-raw/taxonomy.csv
data-raw/WHONET/*
data-raw/python_wrapper/*
+14 -12
View File
@@ -1,16 +1,16 @@
Package: AMR
Version: 2.1.1
Date: 2023-10-20
Version: 2.1.1.9099
Date: 2024-10-17
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, as described in <doi:10.18637/jss.v104.i03>.
Authors@R: c(
person(family = "Berends", c("Matthijs", "S."), role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7620-1800"), email = "m.s.berends@umcg.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 = "Bolton", c("Larisse"), role = "ctb", comment = c(ORCID = "0000-0001-7879-2173")),
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")),
@@ -18,36 +18,38 @@ Authors@R: c(
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 = "Luz", c("Christian", "F."), role = c("ctb"), comment = c(ORCID = "0000-0001-5809-5995")),
person(family = "Meijer", c("Bart", "C."), role = "ctb"),
person(family = "Mykhailenko", c("Dmytro"), role = "ctb"),
person(family = "Mymrikov", c("Anton"), role = "ctb"),
person(family = "Norgan", c("Andrew", "P."), role = "ctb", comment = c(ORCID = "0000-0002-2955-2066")),
person(family = "Ny", c("Sofia"), role = "ctb", comment = c(ORCID = "0000-0002-2017-1363")),
person(family = "Saab", c("Matthew"), role = "ctb"),
person(family = "Salm", c("Jonas"), role = "ctb"),
person(family = "Sanchez", c("Javier"), role = "ctb", comment = c(ORCID = "0000-0003-2605-8094")),
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 = "Stull", c("Jason"), role = "ctb", comment = c(ORCID = "0000-0002-9028-8153")),
person(family = "Underwood", c("Anthony"), role = "ctb", comment = c(ORCID = "0000-0002-8547-4277")),
person(family = "Williams", c("Anita"), role = "ctb", comment = c(ORCID = "0000-0002-5295-8451")))
Depends: R (>= 3.0.0)
Enhances:
cleaner,
ggplot2,
janitor,
skimr,
tibble,
tidyselect,
tsibble
Suggests:
cleaner,
cli,
curl,
data.table,
dplyr,
ggplot2,
knitr,
progress,
readxl,
rmarkdown,
rvest,
skimr,
tibble,
tidyselect,
tinytest,
vctrs,
xml2
VignetteBuilder: knitr,rmarkdown
URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR
@@ -55,5 +57,5 @@ BugReports: https://github.com/msberends/AMR/issues
License: GPL-2 | file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
+15 -29
View File
@@ -13,7 +13,6 @@ S3method("[<-",av)
S3method("[<-",disk)
S3method("[<-",mic)
S3method("[<-",mo)
S3method("[<-",rsi)
S3method("[<-",sir)
S3method("[[",ab)
S3method("[[",av)
@@ -25,7 +24,6 @@ S3method("[[<-",av)
S3method("[[<-",disk)
S3method("[[<-",mic)
S3method("[[<-",mo)
S3method("[[<-",rsi)
S3method("[[<-",sir)
S3method("|",ab_selector)
S3method(Complex,mic)
@@ -38,24 +36,23 @@ S3method(any,ab_selector)
S3method(any,ab_selector_any_all)
S3method(as.data.frame,ab)
S3method(as.data.frame,av)
S3method(as.data.frame,mic)
S3method(as.data.frame,mo)
S3method(as.double,mic)
S3method(as.double,sir)
S3method(as.list,custom_eucast_rules)
S3method(as.list,custom_mdro_guideline)
S3method(as.list,mic)
S3method(as.matrix,mic)
S3method(as.numeric,mic)
S3method(as.rsi,data.frame)
S3method(as.rsi,default)
S3method(as.rsi,disk)
S3method(as.rsi,mic)
S3method(as.sir,data.frame)
S3method(as.sir,default)
S3method(as.sir,disk)
S3method(as.sir,mic)
S3method(as.vector,mic)
S3method(barplot,antibiogram)
S3method(barplot,disk)
S3method(barplot,mic)
S3method(barplot,rsi)
S3method(barplot,sir)
S3method(c,ab)
S3method(c,ab_selector)
@@ -65,11 +62,9 @@ S3method(c,custom_mdro_guideline)
S3method(c,disk)
S3method(c,mic)
S3method(c,mo)
S3method(c,rsi)
S3method(c,sir)
S3method(close,progress_bar)
S3method(droplevels,mic)
S3method(droplevels,rsi)
S3method(droplevels,sir)
S3method(format,bug_drug_combinations)
S3method(hist,mic)
@@ -87,9 +82,9 @@ S3method(plot,antibiogram)
S3method(plot,disk)
S3method(plot,mic)
S3method(plot,resistance_predict)
S3method(plot,rsi)
S3method(plot,sir)
S3method(print,ab)
S3method(print,ab_selector)
S3method(print,av)
S3method(print,bug_drug_combinations)
S3method(print,custom_eucast_rules)
@@ -100,15 +95,14 @@ S3method(print,mo)
S3method(print,mo_renamed)
S3method(print,mo_uncertainties)
S3method(print,pca)
S3method(print,rsi)
S3method(print,sir)
S3method(print,sir_log)
S3method(quantile,mic)
S3method(rep,ab)
S3method(rep,av)
S3method(rep,disk)
S3method(rep,mic)
S3method(rep,mo)
S3method(rep,rsi)
S3method(rep,sir)
S3method(skewness,data.frame)
S3method(skewness,default)
@@ -117,14 +111,12 @@ S3method(sort,mic)
S3method(summary,mic)
S3method(summary,mo)
S3method(summary,pca)
S3method(summary,rsi)
S3method(summary,sir)
S3method(unique,ab)
S3method(unique,av)
S3method(unique,disk)
S3method(unique,mic)
S3method(unique,mo)
S3method(unique,rsi)
S3method(unique,sir)
export("%like%")
export("%like_case%")
@@ -132,7 +124,6 @@ export("%unlike%")
export("%unlike_case%")
export(NA_disk_)
export(NA_mic_)
export(NA_rsi_)
export(NA_sir_)
export(ab_atc)
export(ab_atc_group1)
@@ -171,7 +162,6 @@ export(as.av)
export(as.disk)
export(as.mic)
export(as.mo)
export(as.rsi)
export(as.sir)
export(atc_online_ddd)
export(atc_online_ddd_units)
@@ -217,21 +207,17 @@ export(custom_mdro_guideline)
export(eucast_dosage)
export(eucast_exceptional_phenotypes)
export(eucast_rules)
export(facet_rsi)
export(facet_sir)
export(filter_first_isolate)
export(first_isolate)
export(fluoroquinolones)
export(full_join_microorganisms)
export(g.test)
export(geom_rsi)
export(geom_sir)
export(get_AMR_locale)
export(get_episode)
export(get_mo_source)
export(ggplot_pca)
export(ggplot_rsi)
export(ggplot_rsi_predict)
export(ggplot_sir)
export(ggplot_sir_predict)
export(glycopeptides)
@@ -242,8 +228,6 @@ export(is.av)
export(is.disk)
export(is.mic)
export(is.mo)
export(is.rsi)
export(is.rsi.eligible)
export(is.sir)
export(is_new_episode)
export(is_sir_eligible)
@@ -251,7 +235,6 @@ export(italicise_taxonomy)
export(italicize_taxonomy)
export(key_antimicrobials)
export(kurtosis)
export(labels_rsi_count)
export(labels_sir_count)
export(left_join_microorganisms)
export(like)
@@ -273,6 +256,7 @@ export(mo_fullname)
export(mo_gbif)
export(mo_genus)
export(mo_gramstain)
export(mo_group_members)
export(mo_info)
export(mo_is_anaerobic)
export(mo_is_gram_negative)
@@ -282,6 +266,7 @@ export(mo_is_yeast)
export(mo_kingdom)
export(mo_lpsn)
export(mo_matching_score)
export(mo_mycobank)
export(mo_name)
export(mo_order)
export(mo_oxygen_tolerance)
@@ -304,8 +289,8 @@ export(mo_uncertainties)
export(mo_url)
export(mo_year)
export(mrgn)
export(n_rsi)
export(n_sir)
export(nitrofurans)
export(not_intrinsic_resistant)
export(oxazolidinones)
export(pca)
@@ -320,16 +305,18 @@ export(proportion_df)
export(quinolones)
export(random_disk)
export(random_mic)
export(random_rsi)
export(random_sir)
export(rescale_mic)
export(reset_AMR_locale)
export(resistance)
export(resistance_predict)
export(rifamycins)
export(right_join_microorganisms)
export(rsi_df)
export(rsi_predict)
export(scale_rsi_colours)
export(scale_colour_mic)
export(scale_fill_mic)
export(scale_sir_colours)
export(scale_x_mic)
export(scale_y_mic)
export(scale_y_percent)
export(semi_join_microorganisms)
export(set_AMR_locale)
@@ -343,7 +330,6 @@ export(skewness)
export(streptogramins)
export(susceptibility)
export(tetracyclines)
export(theme_rsi)
export(theme_sir)
export(translate_AMR)
export(trimethoprims)
+74 -194
View File
@@ -1,206 +1,86 @@
# AMR 2.1.1
# AMR 2.1.1.9099
* Fix for selecting first isolates using the phenotype-based method
* This included too many isolates when patients had altering antibiograms within the same bacterial species
* See for more info [our issue #122](https://github.com/msberends/AMR/issues/122)
* Added 1,366 LOINC codes to the `antibiotics` data set and updated to the latest version (LOINC v2.76)
* MICs can now be used in complex number calculations and allow scientific number format as input (e.g., `as.mic("1.28e-2")`)
* Fix rounding MICs on latest R beta ('R-devel')
* Removed unneeded note about the used language when option `AMR_locale` is set
* Fixed non-ASCII characters in documentation, according to CRAN maintainers
*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)*
#### A New Milestone: AMR v3.0 with One Health Support (= Human + Veterinary + Environmental)
This package now supports not only tools for AMR data analysis in clinical settings, but also for veterinary and environmental microbiology. This was made possible through a collaboration with the [University of Prince Edward Island's Atlantic Veterinary College](https://www.upei.ca/avc), Canada. To celebrate this great improvement of the package, we also updated the package logo to reflect this change.
# AMR 2.1.0
## Breaking
* Removed all functions and references that used the deprecated `rsi` class, which were all replaced with their `sir` equivalents over a year ago
## New
* Regarding clinical breakpoints:
* Clinical breakpoints and intrinsic resistance of EUCAST 2023 and CLSI 2023 have been added to the `clinical_breakpoints` data set for usage in `as.sir()`. EUCAST 2023 (v13.0) is now the new default guideline for all MIC and disks diffusion interpretations
* The EUCAST dosage guideline of v13.0 has been added to the `dosage` data set
* The `clinical_breakpoints` data set now also contains epidemiological cut-off (ECOFF) values and CLSI animal breakpoints. These two new breakpoint types can be used for MIC/disk interpretation using `as.sir(..., breakpoint_type = "ECOFF")` or`as.sir(..., breakpoint_type = "animal")`, which is an important new addition for veterinary microbiology.
* Added support for 30 species groups / complexes. They are gathered in a new data set `microorganisms.groups` and are used in clinical breakpoint interpretation. For example, CLSI 2023 contains breakpoints for the RGM group (Rapidly Growing Mycobacterium, containing over 80 species) which is now supported by our package.
* Added oxygen tolerance from BacDive to over 25,000 bacteria in the `microorganisms` data set
* Added `mo_oxygen_tolerance()` to retrieve the values
* Added `mo_is_anaerobic()` to determine which genera/species are obligate anaerobic bacteria
* Added LPSN and GBIF identifiers, and oxygen tolerance to `mo_info()`
* Added SAS Transport files (file extension `.xpt`) to [our download page](https://msberends.github.io/AMR/articles/datasets.html) to use in SAS software
* Added microbial codes for Gram-negative/positive anaerobic bacteria
* **One Health implementation**
* Function `as.sir()` now has extensive support for veterinary breakpoints from CLSI. Use `breakpoint_type = "animal"` and set the `host` argument to a variable that contains animal species names.
* The CLSI VET09 guideline has been implemented to address cases where veterinary breakpoints are missing (only applies when `guideline` is set to CLSI)
* The `clinical_breakpoints` data set contains all these breakpoints, and can be downloaded on our [download page](https://msberends.github.io/AMR/articles/datasets.html).
* The `antibiotics` data set contains all veterinary antibiotics, such as pradofloxacin and enrofloxacin. All WHOCC codes for veterinary use have been added as well.
* `ab_atc()` now supports ATC codes of veterinary antibiotics (that all start with "Q")
* `ab_url()` now supports retrieving the WHOCC url of their ATCvet pages
* **Major update to fungal taxonomy and tools for mycologists**
* MycoBank has now been integrated as the primary taxonomic source for fungi. The `microorganisms` data set has been enriched with new columns (`mycobank`, `mycobank_parent`, and `mycobank_renamed_to`) that provide detailed information for fungal species.
* A remarkable addition of over 20,000 new fungal records
* New function `mo_mycobank()` to retrieve the MycoBank record number, analogous to existing functions such as `mo_lpsn()` and `mo_gbif()`.
* The `as.mo()` function and all `mo_*()` functions now include an `only_fungi` argument, allowing users to restrict results solely to fungal species. This ensures fungi are prioritised over bacteria during microorganism identification. This can also be set globally with the new `AMR_only_fungi` option.
* Also updated other kingdoms, welcoming a total of 2,149 new records from 2023 and 927 from 2024.
* **Updated clinical breakpoints**
* EUCAST 2024 and CLSI 2024 are now supported, by adding all of their over 4,000 new clinical breakpoints to the `clinical_breakpoints` data set for usage in `as.sir()`. EUCAST 2024 is now the new default guideline for all MIC and disk diffusion interpretations.
* `as.sir()` now brings additional factor levels: "NI" for non-interpretable and "SDD" for susceptible dose-dependent. Currently, the `clinical_breakpoints` data set contains 24 breakpoints that can return the value "SDD" instead of "I".
* **New forms for MIC plotting and transforming**
* New function group `scale_*_mic()`, namely: `scale_x_mic()`, `scale_y_mic()`, `scale_colour_mic()` and `scale_fill_mic()`. They are advanced ggplot2 extensions to allow easy plotting of MIC values. They allow for manual range definition and plotting missing intermediate log2 levels.
* New function `rescale_mic()`, which allows users to rescale MIC values to a manually set range. This is the powerhouse behind the `scale_*_mic()` functions, but it can be used independently to, for instance, compare equality in MIC distributions by rescaling them to the same range first.
* **Support for Python**
* While using R for the heavy lifting, [our 'AMR' Python Package](https://pypi.org/project/AMR/) was developed to run the AMR R package natively in Python. The Python package will always have the same version number as the R package, as it is built automatically with every code change.
* **Other**
* New function `mo_group_members()` to retrieve the member microorganisms of a microorganism group. For example, `mo_group_members("Strep group C")` returns a vector of all microorganisms that belong to that group.
## Changed
* Updated algorithm of `as.mo()` by giving more weight to fungi
* Fixed clinical breakpoints errors introduced by the source we import the rules from
* `mo_rank()` now returns `NA` for 'unknown' microorganisms (`B_ANAER`, `B_ANAER-NEG`, `B_ANAER-POS`, `B_GRAMN`, `B_GRAMP`, `F_FUNGUS`, `F_YEAST`, and `UNKNOWN`)
* When printing microorganism or antibiotic codes in a tibble, a mouse-hover now shows the full name of the code
* Plots for MIC and disk diffusion values:
* Now have settable arguments for breakpoint type and PK/PD, like `as.sir()`
* Will now contain the name of the guideline table in the subtitle of the plot
* Fixed formatting for `sir_interpretation_history()`
* Fixed some WHONET codes for microorganisms and consequently a couple of entries in `clinical_breakpoints`
* Fixed a bug for `as.mo()` that led to coercion of `NA` values when using custom microorganism codes
* Fixed usage of `icu_exclude` in `first_isolates()`
* Improved `as.mo()` algorithm:
* Now allows searching on only species names
* Fix for using the `keep_synonyms` argument when using MO codes as input
* Fix for using the `minimum_matching_score` argument
* Updated the code table in `microorganisms.codes`
* Fixed an endless loop if using `reference_df` in `as.mo()`
* Fixed bug for indicating UTIs in `as.sir()`
* Greatly improved speed of `as.sir()`
# AMR 2.0.0
This is a new major release of the AMR package, with great new additions but also some breaking changes for current users. These are all listed below.
**[TL;DR](https://en.wikipedia.org/wiki/TL;DR)**
* All functions and arguments with 'rsi' were replaced with 'sir', such as the interpretation of MIC values (now `as.sir()` instead of `as.rsi()`) - all old functions still work for now
* Many new interesting functions, such as `antibiogram()` (for generating traditional/combined/syndromic/WISCA antibiograms), `sir_confidence_interval()` and `mean_amr_distance()`, and `add_custom_microorganisms()` to add custom microorganisms to this package
* Clinical breakpoints added for EUCAST 2022 and CLSI 2022
* Microbiological taxonomy (`microorganisms` data set) updated to 2022 and now based on LPSN and GBIF
* Much increased algorithms to translate user input to valid taxonomy, e.g. by using [recent scientific work](https://doi.org/10.1099/mic.0.001269) about per-species human pathogenicity
* 20 new antibiotics added and updated all DDDs and ATC codes
* Extended support for antiviral agents (`antivirals` data set), with many new functions
* Now available in 20 languages
* Many small bug fixes
## New
### SIR vs. RSI
For this milestone version, we replaced all mentions of RSI with SIR, to comply with what is actually being commonly used in the field of clinical microbiology when it comes to this tri-form regarding AMR.
While existing functions such as `as.rsi()`, `rsi_df()` and `ggplot_rsi()` still work, their replacements `as.sir()`, `sir_df()`, `ggplot_sir()` are now the current functions for AMR data analysis. A warning will be thrown once a session to remind users about this. The data set `rsi_translation` is now called `clinical_breakpoints` to better reflect its content.
The 'RSI functions' will be removed in a future version, but not before late 2023 / early 2024.
### New antibiogram function
With the new `antibiogram()` function, users can now generate traditional, combined, syndromic, and even weighted-incidence syndromic combination antibiograms (WISCA). With this, we follow the logic in the previously described work of Klinker *et al.* (2021, DOI [10.1177/20499361211011373](https://doi.org/10.1177/20499361211011373)) and Barbieri *et al.* (2021, DOI [10.1186/s13756-021-00939-2](https://doi.org/10.1186/s13756-021-00939-2)).
The help page for `antibiogram()` extensively elaborates on use cases, and `antibiogram()` also supports printing in R Markdown and Quarto, with support for 20 languages.
Furthermore, different plotting methods were implemented to allow for graphical visualisations as well.
### Interpretation of MIC and disk diffusion values
The clinical breakpoints and intrinsic resistance of EUCAST 2022 and CLSI 2022 have been added for `as.sir()`. EUCAST 2022 (v12.0) is now the new default guideline for all MIC and disks diffusion interpretations, and for `eucast_rules()` to apply EUCAST Expert Rules. The default guideline (EUCAST) can now be changed with the new `AMR_guideline` option, such as: `options(AMR_guideline = "CLSI 2020")`.
With the new arguments `include_PKPD` (default: `TRUE`) and `include_screening` (default: `FALSE`), users can now specify whether breakpoints for screening and from the PK/PD table should be included when interpreting MICs and disks diffusion values. These options can be set globally, which can be read in [our new manual](https://msberends.github.io/AMR/reference/AMR-options.html).
Interpretation guidelines older than 10 years were removed, the oldest now included guidelines of EUCAST and CLSI are from 2013.
### Supported languages
We added support for the following ten languages: Chinese (simplified), Czech, Finnish, Greek, Japanese, Norwegian (bokmål), Polish, Romanian, Turkish and Ukrainian. All antibiotic names are now available in these languages, and the AMR package will automatically determine a supported language based on the user's system language.
We are very grateful for the valuable input by our colleagues from other countries. The `AMR` package is now available in 20 languages in total, and according to download stats used in almost all countries in the world!
### Outbreak management
For analysis in outbreak management, we updated the `get_episode()` and `is_new_episode()` functions: they now contain an argument `case_free_days`. This argument can be used to quantify the duration of case-free days (the inter-epidemic interval), after which a new episode will start.
This is common requirement in outbreak management, e.g. when determining the number of norovirus outbreaks in a hospital. The case-free period could then be 14 or 28 days, so that new norovirus cases after that time will be considered a different (or new) episode.
### Microbiological taxonomy
The `microorganisms` data set no longer relies on the Catalogue of Life, but on the List of Prokaryotic names with Standing in Nomenclature (LPSN) and is supplemented with the 'backbone taxonomy' from the Global Biodiversity Information Facility (GBIF). The structure of this data set has changed to include separate LPSN and GBIF identifiers. Almost all previous MO codes were retained. It contains over 1,400 taxonomic names from 2022.
We previously relied on our own experience to categorise species into pathogenic groups, but we were very happy to encounter the very recent work of Bartlett *et al.* (2022, DOI [10.1099/mic.0.001269](https://doi.org/10.1099/mic.0.001269)) who extensively studied medical-scientific literature to categorise all bacterial species into groups. See `mo_matching_score()` on how their work was incorporated into the `prevalence` column of the `microorganisms` data set. Using their results, the `as.mo()` and all `mo_*()` functions are now much better capable of converting user input to valid taxonomic records.
The new function `add_custom_microorganisms()` allows users to add custom microorganisms to the `AMR` package.
We also made the following changes regarding the included taxonomy or microorganisms functions:
* Updated full microbiological taxonomy according to the latest daily LPSN data set (December 2022) and latest yearly GBIF taxonomy backbone (November 2022)
* Added function `mo_current()` to get the currently valid taxonomic name of a microorganism
* Support for all 1,516 city-like serovars of *Salmonella*, such as *Salmonella* Goldcoast. Formally, these are serovars belonging to the *S. enterica* species, but they are reported with only the name of the genus and the city. For this reason, the serovars are in the `subspecies` column of the `microorganisms` data set and "enterica" is in the `species` column, but the full name does not contain the species name (*enterica*).
* All new algorithm for `as.mo()` (and thus all `mo_*()` functions) while still following our original set-up as described in our recently published JSS paper (DOI [10.18637/jss.v104.i03](https://doi.org/10.18637/jss.v104.i03)).
* A new argument `keep_synonyms` allows to *not* correct for updated taxonomy, in favour of the now deleted argument `allow_uncertain`
* It has increased tremendously in speed and returns generally more consequent results
* Sequential coercion is now extremely fast as results are stored to the package environment, although coercion of unknown values must be run once per session. Previous results can be reset/removed with the new `mo_reset_session()` function.
* Support for microorganism codes of the ASIan Antimicrobial Resistance Surveillance Network (ASIARS-Net)
* The MO matching score algorithm (`mo_matching_score()`) now counts deletions and substitutions as 2 instead of 1, which impacts the outcome of `as.mo()` and any `mo_*()` function
* **Removed all species of the taxonomic kingdom Chromista** from the package. This was done for multiple reasons:
* CRAN allows packages to be around 5 MB maximum, some packages are exempted but this package is not one of them
* Chromista are not relevant when it comes to antimicrobial resistance, thus lacking the primary scope of this package
* Chromista are almost never clinically relevant, thus lacking the secondary scope of this package
* The `microorganisms.old` data set was removed, and all previously accepted names are now included in the `microorganisms` data set. A new column `status` contains `"accepted"` for currently accepted names and `"synonym"` for taxonomic synonyms; currently invalid names. All previously accepted names now have a microorganisms ID and - if available - an LPSN, GBIF and SNOMED CT identifier.
### Antibiotic agents and selectors
The new function `add_custom_antimicrobials()` allows users to add custom antimicrobial codes and names to the `AMR` package.
The `antibiotics` data set was greatly updated:
* The following 20 antibiotics have been added (also includes the [new J01RA ATC group](https://www.whocc.no/atc_ddd_index/?code=J01RA&showdescription=no)): azithromycin/fluconazole/secnidazole (AFC), cefepime/amikacin (CFA), cefixime/ornidazole (CEO), ceftriaxone/beta-lactamase inhibitor (CEB), ciprofloxacin/metronidazole (CIM), ciprofloxacin/ornidazole (CIO), ciprofloxacin/tinidazole (CIT), furazidin (FUR), isoniazid/sulfamethoxazole/trimethoprim/pyridoxine (IST), lascufloxacin (LSC), levofloxacin/ornidazole (LEO), nemonoxacin (NEM), norfloxacin/metronidazole (NME), norfloxacin/tinidazole (NTI), ofloxacin/ornidazole (OOR), oteseconazole (OTE), rifampicin/ethambutol/isoniazid (REI), sarecycline (SRC), tetracycline/oleandomycin (TOL), and thioacetazone (TAT)
* Added some missing ATC codes
* Updated DDDs and PubChem Compound IDs
* Updated some antibiotic name spelling, now used by WHOCC (such as cephalexin -> cefalexin, and phenethicillin -> pheneticillin)
* Antibiotic code "CEI" for ceftolozane/tazobactam has been replaced with "CZT" to comply with EARS-Net and WHONET 2022. The old code will still work in all cases when using `as.ab()` or any of the `ab_*()` functions.
* Support for antimicrobial interpretation of anaerobic bacteria, by adding a 'placeholder' code `B_ANAER` to the `microorganisms` data set and adding the breakpoints of anaerobics to the `clinical_breakpoints` data set, which is used by `as.sir()` for interpretion of MIC and disk diffusion values
Also, we added support for using antibiotic selectors in scoped `dplyr` verbs (with or without using `vars()`), such as in: `... %>% summarise_at(aminoglycosides(), resistance)`, please see `resistance()` for examples.
### Antiviral agents
We now added extensive support for antiviral agents! For the first time, the `AMR` package has extensive support for antiviral drugs and to work with their names, codes and other data in any way.
* The `antivirals` data set has been extended with 18 new drugs (also from the [new J05AJ ATC group](https://www.whocc.no/atc_ddd_index/?code=J05AJ&showdescription=no)) and now also contains antiviral identifiers and LOINC codes
* A new data type `av` (*antivirals*) has been added, which is functionally similar to `ab` for antibiotics
* Functions `as.av()`, `av_name()`, `av_atc()`, `av_synonyms()`, `av_from_text()` have all been added as siblings to their `ab_*()` equivalents
### Other new functions
* Function `sir_confidence_interval()` to add confidence intervals in AMR calculation. This is now also included in `sir_df()` and `proportion_df()`.
* Function `mean_amr_distance()` to calculate the mean AMR distance. The mean AMR distance is a normalised numeric value to compare AMR test results and can help to identify similar isolates, without comparing antibiograms by hand.
* Function `sir_interpretation_history()` to view the history of previous runs of `as.sir()` (previously `as.rsi()`). This returns a 'logbook' with the selected guideline, reference table and specific interpretation of each row in a data set on which `as.sir()` was run.
## Changes
* `get_episode()` (and its wrapper `is_new_episode()`):
* Fix for working with `NA` values
* Fix for unsorted dates of length 2
* Now returns class `integer` instead of `numeric` since they are always whole numbers
* Argument `combine_IR` has been removed from this package (affecting functions `count_df()`, `proportion_df()`, and `sir_df()` and some plotting functions), since it was replaced with `combine_SI` three years ago
* Using `units` in `ab_ddd(..., units = "...")` had been deprecated for some time and is now not supported anymore. Use `ab_ddd_units()` instead.
* Support for `data.frame`-enhancing R packages, more specifically: `data.table::data.table`, `janitor::tabyl`, `tibble::tibble`, and `tsibble::tsibble`. AMR package functions that have a data set as output (such as `sir_df()` and `bug_drug_combinations()`), will now return the same data type as the input.
* All data sets in this package are now a `tibble`, instead of base R `data.frame`s. Older R versions are still supported, even if they do not support `tibble`s.
* 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).
* For `as.sir()`:
* Fixed certain EUCAST breakpoints for MIC values
* Allow `NA` values (e.g. `as.sir(as.disk(NA), ...)`)
* Fix for bug-drug combinations with multiple breakpoints for different body sites
* Interpretation from MIC and disk zones is now more informative about availability of breakpoints and more robust
* Removed the `as.integer()` method for MIC values, since MIC are not integer values and running `table()` on MIC values consequently failed for not being able to retrieve the level position (as that's how normally `as.integer()` on `factor`s work)
* Fixed determination of Gram stains (`mo_gramstain()`), since the taxonomic phyla Actinobacteria, Chloroflexi, Firmicutes, and Tenericutes have been renamed to respectively Actinomycetota, Chloroflexota, Bacillota, and Mycoplasmatota in 2021
* `droplevels()` on MIC will now return a common `factor` at default and will lose the `mic` class. Use `droplevels(..., as.mic = TRUE)` to keep the `mic` class.
* Small fix for using `ab_from_text()`
* Fixes for reading in text files using `set_mo_source()`, which now also allows the source file to contain valid taxonomic names instead of only valid microorganism ID of this package
* Fixed a bug for `mdro()` when using similar column names with the Magiorakos guideline
* Using any `random_*()` function (such as `random_mic()`) is now possible by directly calling the package without loading it first: `AMR::random_mic(10)`
* Extended support for the `vctrs` package, used internally by the tidyverse. This allows to change values of class `mic`, `disk`, `sir`, `mo` and `ab` in tibbles, and to use antibiotic selectors for selecting/filtering, e.g. `df[carbapenems() == "R", ]`
* Fix for using `info = FALSE` in `mdro()`
* For all interpretation guidelines using `as.sir()` 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
* Black and white message texts are now reversed in colour if using an RStudio dark theme
* `mo_snomed()` now returns class `character`, not `numeric` anymore (to make long SNOMED codes readable)
* Fix for using `as.ab()` on `NA` values
* Updated support for all WHONET 2022 microorganism codes
* Antimicrobial interpretation 'SDD' (susceptible dose-dependent, coined by CLSI) will be interpreted as 'I' to comply with EUCAST's 'I' in `as.sir()`
* Fix for `mo_shortname()` in case of higher taxonomic ranks (order, class, phylum)
* Cleaning columns with `as.sir()`, `as.mic()`, or `as.disk()` will now show the column name in the warning for invalid results
* Fix for using `g.test()` with zeroes in a 2x2 table
* `mo_synonyns()` now contains the scientific reference as names
* SIR interpretation
* It is now possible to use column names for argument `ab`, `mo`, and `uti`: `as.sir(..., ab = "column1", mo = "column2", uti = "column3")`. This greatly improves the flexibility for users.
* Users can now set their own criteria (using regular expressions) as to what should be considered S, I, R, SDD, and NI.
* To get quantitative values, `as.double()` on a `sir` object will return 1 for S, 2 for SDD/I, and 3 for R (NI will become `NA`). Other functions using `sir` classes (e.g., `summary()`) are updated to reflect the change to contain NI and SDD.
* `antibiogram()` function
* New argument `formatting_type` to set any of the 12 options for the formatting of all 'cells'. This defaults to `10`, changing the output of antibiograms to cells with `5% (15/300)` instead of the previous standard of just `5`.
* For this reason, `add_total_n` is now `FALSE` at default since the denominators are added to the cells
* The `ab_transform` argument now defaults to `"name"`, displaying antibiotic column names instead of codes
* `antibiotics` data set
* Added "clindamycin inducible screening" as `CLI1`. Since clindamycin is a lincosamide, the antibiotic selector `lincosamides()` now contains the argument `only_treatable = TRUE` (similar to other antibiotic selectors that contain non-treatable drugs)
* Added Amorolfine (`AMO`, D01AE16), which is now also part of the `antifungals()` selector
* Antibiotic selectors
* Added selectors `nitrofurans()` and `rifamycins()`
* When using antibiotic selectors such as `aminoglycosides()` that exclude non-treatable drugs like gentamicin-high, the function now always returns a warning that these can be included using `only_treatable = FALSE`
* MICs
* Added as valid levels: 4096, 6 powers of 0.0625, and 5 powers of 192 (192, 384, 576, 768, 960)
* Added new argument `keep_operators` to `as.mic()`. This can be `"all"` (default), `"none"`, or `"edges"`. This argument is also available in the new `rescale_mic()` and `scale_*_mic()` functions.
* Comparisons of MIC values are now more strict. For example, `>32` is higher than (and never equal to) `32`. Thus, `as.mic(">32") == as.mic(32)` now returns `FALSE`, and `as.mic(">32") > as.mic(32)` now returns `TRUE`.
* Sorting of MIC values (using `sort()`) was fixed in the same manner; `<0.001` now gets sorted before `0.001`, and `>0.001` gets sorted after `0.001`.
* Intermediate log2 levels used for MIC plotting are now more common values instead of following a strict dilution range
* Disks of 0 to 5 mm are now allowed, the newly allowed range for disk diffusion (`as.disk()`) is now between 0 and 50 mm
* Updated `italicise_taxonomy()` to support HTML output
* `custom_eucast_rules()` now supports multiple antibiotics and antibiotic groups to be affected by a single rule
* `mo_info()` now contains an extra element `rank` and `group_members` (with the contents of the new `mo_group_members()` function)
* Updated all ATC codes from WHOCC
* Updated all antibiotic DDDs from WHOCC
* Added over 1,500 trade names for antibiotics
* Fix for using a manual value for `mo_transform` in `antibiogram()`
* Fix for mapping 'high level' antibiotics in `as.ab()` (amphotericin B-high, gentamicin-high, kanamycin-high, streptomycin-high, tobramycin-high)
* Improved overall algorithm of `as.ab()` for better performance and accuracy
* Improved overall algorithm of `as.mo()` for better performance and accuracy. Specifically:
* More weight is given to genus and species combinations in cases where the subspecies is miswritten, so that the result will be the correct genus and species
* Genera from the World Health Organization's (WHO) Priority Pathogen List now have the highest prevalence
* Fixed a bug for when `antibiogram()` returns an empty data set
* Fixed a bug for `sir_confidence_interval()` when there are no isolates available
* Updated the prevalence calculation to include genera from the World Health Organization's (WHO) Priority Pathogen List
* Improved algorithm of `first_isolate()` when using the phenotype-based method, to prioritise records with the highest availability of SIR values
## Other
* Greatly improved `vctrs` integration, a Tidyverse package working in the background for many Tidyverse functions. For users, this means that functions such as `dplyr`'s `bind_rows()`, `rowwise()` and `c_across()` are now supported for e.g. columns of class `mic`. Despite this, this `AMR` package is still zero-dependent on any other package, including `dplyr` and `vctrs`.
* Greatly updated and expanded documentation
* Added Larisse Bolton, Jordan Stull, Matthew Saab, and Javier Sanchez as contributors, to thank them for their valuable input
* Stopped support for SAS (`.xpt`) files, since their file structure and extremely inefficient and requires more disk space than GitHub allows in a single commit.
* Added Peter Dutey-Magni, Dmytro Mykhailenko, Anton Mymrikov, Andrew Norgan, Jonas Salm, and Anita Williams as contributors, to thank them for their valuable input
* New website to make use of the new Bootstrap 5 and pkgdown 2.0. The website now contains results for all examples and will be automatically regenerated with every change to our repository, using GitHub Actions
* All R and Rmd files in this project are now styled using the `styler` package
* Set scalar conditional expressions (`&&` and `||`) where possible to comply with the upcoming R 4.3
* An enormous lot of code cleaning, fixing some small bugs along the way
## Older Versions
----
This changelog only contains changes from AMR v3.0 (October 2024) and later.
This changelog only contains changes from AMR v2.0 (January 2023) and later. For prior versions, please see [our archive](https://github.com/msberends/AMR/blob/v1.8.2/NEWS.md).
* For prior v2 versions, please see [our v2 archive](https://github.com/msberends/AMR/blob/v2.1.1/NEWS.md).
* For prior v1 versions, please see [our v1 archive](https://github.com/msberends/AMR/blob/v1.8.2/NEWS.md).
+4 -4
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -40,7 +40,7 @@
#'
#' The `AMR` package is available in `r vector_and(vapply(FUN.VALUE = character(1), LANGUAGES_SUPPORTED_NAMES, function(x) x$exonym), quotes = FALSE, sort = FALSE)`. Antimicrobial drug (group) names and colloquial microorganism names are provided in these languages.
#' @section Reference Data Publicly Available:
#' All data sets in this `AMR` package (about microorganisms, antibiotics, SIR 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).
#' All data sets in this `AMR` package (about microorganisms, antibiotics, SIR interpretation, EUCAST rules, etc.) are publicly and freely available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, 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).
#' @source
#' To cite AMR in publications use:
#'
+25 -9
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -28,7 +28,7 @@
# ==================================================================== #
# add new version numbers here, and add the rules themselves to "data-raw/eucast_rules.tsv" and clinical_breakpoints
# (sourcing "data-raw/_pre_commit_hook.R" will process the TSV file)
# (sourcing "data-raw/_pre_commit_checks.R" will process the TSV file)
EUCAST_VERSION_BREAKPOINTS <- list(
# "13.0" = list(
# version_txt = "v13.0",
@@ -86,26 +86,37 @@ EUCAST_VERSION_EXPERT_RULES <- list(
TAXONOMY_VERSION <- list(
GBIF = list(
accessed_date = as.Date("2022-12-11"),
citation = "GBIF Secretariat (2022). GBIF Backbone Taxonomy. Checklist dataset \\doi{10.15468/39omei}.",
name = "Global Biodiversity Information Facility (GBIF)",
accessed_date = as.Date("2024-06-24"),
citation = "GBIF Secretariat (2023). GBIF Backbone Taxonomy. Checklist dataset \\doi{10.15468/39omei}.",
url = "https://www.gbif.org"
),
LPSN = list(
accessed_date = as.Date("2022-12-11"),
name = "List of Prokaryotic names with Standing in Nomenclature (LPSN)",
accessed_date = as.Date("2024-06-24"),
citation = "Parte, AC *et al.* (2020). **List of Prokaryotic names with Standing in Nomenclature (LPSN) moves to the DSMZ.** International Journal of Systematic and Evolutionary Microbiology, 70, 5607-5612; \\doi{10.1099/ijsem.0.004332}.",
url = "https://lpsn.dsmz.de"
),
MycoBank = list(
name = "MycoBank",
accessed_date = as.Date("2024-06-24"),
citation = "Vincent, R *et al* (2013). **MycoBank gearing up for new horizons.** IMA Fungus, 4(2), 371-9; \\doi{10.5598/imafungus.2013.04.02.16}.",
url = "https://www.mycobank.org"
),
BacDive = list(
accessed_date = as.Date("2023-05-12"),
name = "BacDive",
accessed_date = as.Date("2024-07-16"),
citation = "Reimer, LC *et al.* (2022). ***BacDive* in 2022: the knowledge base for standardized bacterial and archaeal data.** Nucleic Acids Res., 50(D1):D741-D74; \\doi{10.1093/nar/gkab961}.",
url = "https://bacdive.dsmz.de"
),
SNOMED = list(
accessed_date = as.Date("2021-07-01"),
name = "Systematized Nomenclature of Medicine - Clinical Terms (SNOMED-CT)",
accessed_date = as.Date("2024-07-16"),
citation = "Public Health Information Network Vocabulary Access and Distribution System (PHIN VADS). US Edition of SNOMED CT from 1 September 2020. Value Set Name 'Microorganism', OID 2.16.840.1.114222.4.11.1009 (v12).",
url = "https://phinvads.cdc.gov"
),
LOINC = list(
name = "Logical Observation Identifiers Names and Codes (LOINC)",
accessed_date = as.Date("2023-10-19"),
citation = "Logical Observation Identifiers Names and Codes (LOINC), Version 2.76 (18 September, 2023).",
url = "https://loinc.org"
@@ -146,6 +157,8 @@ globalVariables(c(
"group",
"guideline",
"hjust",
"host_index",
"host_match",
"input",
"intrinsic_resistant",
"isolates",
@@ -159,6 +172,7 @@ globalVariables(c(
"microorganisms",
"microorganisms.codes",
"mo",
"n",
"name",
"new",
"numerator",
@@ -184,8 +198,10 @@ globalVariables(c(
"total",
"txt",
"type",
"uti_index",
"value",
"varname",
"x",
"xvar",
"y",
"year",
+92 -46
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -237,7 +237,7 @@ addin_insert_like <- function() {
}
}
search_type_in_df <- function(x, type, info = TRUE) {
search_type_in_df <- function(x, type, info = TRUE, add_col_prefix = TRUE) {
meet_criteria(x, allow_class = "data.frame")
meet_criteria(type, allow_class = "character", has_length = 1)
@@ -280,7 +280,7 @@ search_type_in_df <- function(x, type, info = TRUE) {
if (!inherits(pm_pull(x, found), c("Date", "POSIXct"))) {
stop(
font_red(paste0(
"Found column '", font_bold(found), "' to be used as input for `col_", type,
"Found column '", font_bold(found), "' to be used as input for `", ifelse(add_col_prefix, "col_", ""), type,
"`, but this column contains no valid dates. Transform its values to valid dates first."
)),
call. = FALSE
@@ -311,6 +311,14 @@ search_type_in_df <- function(x, type, info = TRUE) {
found <- sort(colnames(x)[colnames_formatted %like_case% "^(specimen)"])
}
}
# -- host (animals)
if (type == "host") {
if (any(colnames_formatted %like_case% "^(host|animal)")) {
found <- sort(colnames(x)[colnames_formatted %like_case% "^(host|animal)"])
} else if (any(colnames_formatted %like_case% "((^|[^A-Za-z])host($|[^A-Za-z])|animal)")) {
found <- sort(colnames(x)[colnames_formatted %like_case% "((^|[^A-Za-z])host($|[^A-Za-z])|animal)"])
}
}
# -- UTI (urinary tract infection)
if (type == "uti") {
if (any(colnames_formatted == "uti")) {
@@ -321,7 +329,7 @@ search_type_in_df <- function(x, type, info = TRUE) {
if (!is.null(found)) {
# this column should contain logicals
if (!is.logical(x[, found, drop = TRUE])) {
message_("Column '", font_bold(found), "' found as input for `col_", type,
message_("Column '", font_bold(found), "' found as input for `", ifelse(add_col_prefix, "col_", ""), type,
"`, but this column does not contain 'logical' values (TRUE/FALSE) and was ignored.",
add_fn = font_red
)
@@ -334,9 +342,9 @@ search_type_in_df <- function(x, type, info = TRUE) {
if (!is.null(found) && isTRUE(info)) {
if (message_not_thrown_before("search_in_type", type)) {
msg <- paste0("Using column '", font_bold(found), "' as input for `col_", type, "`.")
msg <- paste0("Using column '", font_bold(found), "' as input for `", ifelse(add_col_prefix, "col_", ""), type, "`.")
if (type %in% c("keyantibiotics", "keyantimicrobials", "specimen")) {
msg <- paste(msg, "Use", font_bold(paste0("col_", type), "= FALSE"), "to prevent this.")
msg <- paste(msg, "Use", font_bold(paste0(ifelse(add_col_prefix, "col_", ""), type), "= FALSE"), "to prevent this.")
}
message_(msg)
}
@@ -456,7 +464,8 @@ word_wrap <- function(...,
ops <- "([,./><\\]\\[])"
msg <- gsub(paste0(ops, " ", ops), "\\1\\2", msg, perl = TRUE)
# we need to correct for already applied style, that adds text like "\033[31m\"
msg_stripped <- font_stripstyle(msg)
msg_stripped <- gsub("(.*)?\\033\\]8;;.*\\a(.*?)\\033\\]8;;\\a(.*)", "\\1\\2\\3", msg, perl = TRUE) # for font_url()
msg_stripped <- font_stripstyle(msg_stripped)
# where are the spaces now?
msg_stripped_wrapped <- paste0(
strwrap(msg_stripped,
@@ -515,6 +524,9 @@ word_wrap <- function(...,
# otherwise, give a 'click to run' popup
parts[cmds & parts %unlike% "[.]"] <- font_url(url = paste0("ide:run:AMR::", parts[cmds & parts %unlike% "[.]"]),
txt = parts[cmds & parts %unlike% "[.]"])
# text starting with `?` must also lead to the help page
parts[parts %like% "^[?]"] <- font_url(url = paste0("ide:help:AMR::", gsub("()", "", gsub("^[?]", "", parts[parts %like% "^[?]"]), fixed = TRUE)),
txt = parts[parts %like% "^[?]"])
msg <- paste0(parts, collapse = "`")
}
msg <- gsub("`(.+?)`", font_grey_bg("\\1"), msg)
@@ -561,6 +573,7 @@ warning_ <- function(...,
# - wraps text to never break lines within words
stop_ <- function(..., call = TRUE) {
msg <- paste0(c(...), collapse = "")
msg_call <- ""
if (!isFALSE(call)) {
if (isTRUE(call)) {
call <- as.character(sys.call(-1)[1])
@@ -568,10 +581,19 @@ stop_ <- function(..., call = TRUE) {
# so you can go back more than 1 call, as used in sir_calc(), that now throws a reference to e.g. n_sir()
call <- as.character(sys.call(call)[1])
}
msg <- paste0("in ", call, "(): ", msg)
msg_call <- paste0("in ", call, "():")
}
msg <- trimws2(word_wrap(msg, add_fn = list(), as_note = FALSE))
stop(msg, call. = FALSE)
if (!is.null(AMR_env$cli_abort) && length(unlist(strsplit(msg, "\n", fixed = TRUE))) <= 1) {
if (is.character(call)) {
call <- as.call(str2lang(paste0(call, "()")))
} else {
call <- NULL
}
AMR_env$cli_abort(msg, call = call)
} else {
stop(paste(msg_call, msg), call. = FALSE)
}
}
stop_if <- function(expr, ..., call = TRUE) {
@@ -680,7 +702,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_checks.R, such as `CARBAPENEMS`
val <- eval(parse(text = paste0("AB_", val)), envir = asNamespace("AMR"))
} else if (val %in% AMR_env$AB_lookup$ab) {
# separate drugs, such as `AMX`
@@ -734,6 +756,10 @@ vector_or <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_ca
# class 'sir' should be sorted like this
v <- c("S", "I", "R")
}
if (identical(v, c("I", "NI", "R", "S", "SDD"))) {
# class 'sir' should be sorted like this
v <- c("S", "SDD", "I", "R", "NI")
}
# oxford comma
if (last_sep %in% c(" or ", " and ") && length(v) > 2) {
last_sep <- paste0(",", last_sep)
@@ -796,7 +822,6 @@ meet_criteria <- function(object, # can be literally `list(...)` for `allow_argu
is_positive = NULL,
is_positive_or_zero = NULL,
is_finite = NULL,
contains_column_class = NULL,
allow_NULL = FALSE,
allow_NA = FALSE,
ignore.case = FALSE,
@@ -825,8 +850,13 @@ meet_criteria <- function(object, # can be literally `list(...)` for `allow_argu
stop_if(allow_NA == FALSE, "argument `", obj_name, "` must not be NA", call = call_depth)
return(invisible())
}
if (identical(class(object), "list") && !"list" %in% allow_class) {
# coming from Python, possibly - turn lists (not data.frame) to the underlying data type
object <- unlist(object)
}
if (!is.null(allow_class)) {
if (!is.null(allow_class) && !(suppressWarnings(all(is.na(object))) && allow_NA == TRUE)) {
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)),
@@ -862,12 +892,20 @@ meet_criteria <- function(object, # can be literally `list(...)` for `allow_argu
object <- tolower(object)
is_in <- tolower(is_in)
}
stop_ifnot(all(object %in% is_in, na.rm = TRUE), "argument `", obj_name, "` ",
is_in.bak <- is_in
if ("logical" %in% allow_class) {
is_in <- is_in[!is_in %in% c("TRUE", "FALSE")]
}
or_values <- vector_or(is_in, quotes = !isTRUE(any(c("numeric", "integer") %in% allow_class)))
if ("logical" %in% allow_class) {
or_values <- paste0(or_values, ", or TRUE or FALSE")
}
stop_ifnot(all(object %in% is_in.bak, 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))),
or_values,
ifelse(allow_NA == TRUE, ", or NA", ""),
call = call_depth
)
@@ -903,21 +941,6 @@ meet_criteria <- function(object, # can be literally `list(...)` for `allow_argu
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[1L], "'. ",
"See `?as.", contains_column_class[1L], "`.",
call = call_depth
)
}
if (!is.null(allow_arguments_from) && !is.null(names(object))) {
args_given <- names(object)
if (is.function(allow_arguments_from)) {
@@ -939,6 +962,20 @@ meet_criteria <- function(object, # can be literally `list(...)` for `allow_argu
return(invisible())
}
ascertain_sir_classes <- function(x, obj_name) {
sirs <- vapply(FUN.VALUE = logical(1), x, is.sir)
if (!any(sirs, na.rm = TRUE)) {
warning_("the data provided in argument `", obj_name,
"` should contain at least one column of class 'sir'. Eligible SIR column were now guessed. ",
"See `?as.sir`.")
sirs_eligible <- is_sir_eligible(x)
for (col in colnames(x)[sirs_eligible]) {
x[[col]] <- as.sir(x[[col]])
}
}
x
}
get_current_data <- function(arg_name, call) {
valid_df <- function(x) {
!is.null(x) && is.data.frame(x)
@@ -997,10 +1034,10 @@ get_current_data <- function(arg_name, 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, "())]"
" ", AMR_env$bullet_icon, " your_data %>% select(", fn, "())\n",
" ", AMR_env$bullet_icon, " your_data %>% select(column_a, column_b, ", fn, "())\n",
" ", AMR_env$bullet_icon, " your_data[, ", fn, "()]\n",
" ", AMR_env$bullet_icon, " your_data[, c(\"column_a\", \"column_b\", ", fn, "())]"
)
} else {
examples <- ""
@@ -1028,10 +1065,15 @@ get_current_column <- function() {
if (tryCatch(!is.null(env$i), error = function(e) FALSE)) {
if (!is.null(env$tibble_vars)) {
# for mutate_if()
# TODO remove later, was part of older dplyr versions (at least not in dplyr 1.1.4)
env$tibble_vars[env$i]
} else {
# for mutate(across())
df <- tryCatch(get_current_data(NA, 0), error = function(e) NULL)
if (!is.null(env$data) && is.data.frame(env$data)) {
df <- env$data
} else {
df <- tryCatch(get_current_data(NA, 0), error = function(e) NULL)
}
if (is.data.frame(df)) {
colnames(df)[env$i]
} else {
@@ -1311,19 +1353,24 @@ progress_ticker <- function(n = 1, n_min = 0, print = TRUE, clear = TRUE, title
}
set_clean_class(pb, new_class = "txtProgressBar")
} else if (n >= n_min) {
# use `progress`, which also has a timer
title <- trimws2(title)
if (title != "") {
title <- paste0(title, " ")
}
progress_bar <- import_fn("progress_bar", "progress", error_on_fail = FALSE)
if (!is.null(progress_bar)) {
# so we use progress::progress_bar
# a close()-method was also added, see below for that
pb <- progress_bar$new(
show_after = 0,
format = paste0(title,
ifelse(only_bar_percent == TRUE, "[:bar] :percent", "[:bar] :percent (:current/:total,:eta)")),
clear = clear,
total = n
)
} else {
# use base R
# use base R's txtProgressBar
cat(title, "\n", sep = "")
pb <- utils::txtProgressBar(max = n, style = 3)
pb$tick <- function() {
pb$up(pb$getVal() + 1)
@@ -1378,12 +1425,8 @@ as_original_data_class <- function(df, old_class = NULL, extra_class = NULL) {
if ("tbl_df" %in% old_class && pkg_is_available("tibble")) {
# this will then also remove groups
fn <- import_fn("as_tibble", "tibble")
} else if ("tbl_ts" %in% old_class && pkg_is_available("tsibble")) {
fn <- import_fn("as_tsibble", "tsibble")
} else if ("data.table" %in% old_class && pkg_is_available("data.table")) {
fn <- import_fn("as.data.table", "data.table")
} else if ("tabyl" %in% old_class && pkg_is_available("janitor")) {
fn <- import_fn("as_tabyl", "janitor")
} else {
fn <- function(x) base::as.data.frame(df, stringsAsFactors = FALSE)
}
@@ -1507,22 +1550,25 @@ add_MO_lookup_to_AMR_env <- function() {
MO_lookup[which(MO_lookup$kingdom == "Bacteria" | MO_lookup$mo == "UNKNOWN"), "kingdom_index"] <- 1
MO_lookup[which(MO_lookup$kingdom == "Fungi"), "kingdom_index"] <- 1.25
MO_lookup[which(MO_lookup$kingdom == "Protozoa"), "kingdom_index"] <- 1.5
MO_lookup[which(MO_lookup$kingdom == "Chromista"), "kingdom_index"] <- 1.75
MO_lookup[which(MO_lookup$kingdom == "Archaea"), "kingdom_index"] <- 2
# all the rest
MO_lookup[which(is.na(MO_lookup$kingdom_index)), "kingdom_index"] <- 3
# the fullname lowercase, important for the internal algorithms in as.mo()
MO_lookup$fullname_lower <- tolower(trimws(paste(
MO_lookup$fullname_lower <- tolower(trimws2(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 <- trimws2(gsub("[^.a-z0-9/ \\-]+", "", MO_lookup$fullname_lower, perl = TRUE))
# special for Salmonella - they have cities as subspecies but not the species (enterica) in the fullname:
MO_lookup$fullname_lower[which(MO_lookup$subspecies %like_case% "^[A-Z]")] <- gsub(" enterica ", " ", MO_lookup$fullname_lower[which(MO_lookup$subspecies %like_case% "^[A-Z]")], fixed = TRUE)
MO_lookup$genus_lower <- tolower(MO_lookup$genus)
MO_lookup$full_first <- substr(MO_lookup$fullname_lower, 1, 1)
MO_lookup$species_first <- tolower(substr(MO_lookup$species, 1, 1)) # tolower for groups (Streptococcus, Salmonella)
MO_lookup$subspecies_first <- tolower(substr(MO_lookup$subspecies, 1, 1)) # tolower for Salmonella serovars
@@ -1551,7 +1597,7 @@ readRDS_AMR <- function(file, refhook = NULL) {
match <- function(x, table, ...) {
if (!is.null(AMR_env$chmatch) && inherits(x, "character") && inherits(table, "character")) {
# data.table::chmatch() is much faster than base::match() for character
AMR_env$chmatch(x, table, ...)
tryCatch(AMR_env$chmatch(x, table, ...), error = function(e) base::match(x, table, ...))
} else {
base::match(x, table, ...)
}
@@ -1559,7 +1605,7 @@ match <- function(x, table, ...) {
`%in%` <- function(x, table) {
if (!is.null(AMR_env$chin) && inherits(x, "character") && inherits(table, "character")) {
# data.table::`%chin%`() is much faster than base::`%in%`() for character
AMR_env$chin(x, table)
tryCatch(AMR_env$chin(x, table), error = function(e) base::`%in%`(x, table))
} else {
base::`%in%`(x, table)
}
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+15 -14
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -31,19 +31,20 @@
#'
#' This is an overview of all the package-specific [options()] you can set in the `AMR` package.
#' @section Options:
#' * `AMR_custom_ab` \cr Allows to use custom antimicrobial drugs with this package. This is explained in [add_custom_antimicrobials()].
#' * `AMR_custom_mo` \cr Allows to use custom microorganisms with this package. This is explained in [add_custom_microorganisms()].
#' * `AMR_eucastrules` \cr Used for setting the default types of rules for [eucast_rules()] function, must be one or more of: `"breakpoints"`, `"expert"`, `"other"`, `"custom"`, `"all"`, and defaults to `c("breakpoints", "expert")`.
#' * `AMR_guideline` \cr Used for setting the default guideline for interpreting MIC values and disk diffusion diameters with [as.sir()]. Can be only the guideline name (e.g., `"CLSI"`) or the name with a year (e.g. `"CLSI 2019"`). The default to the latest implemented EUCAST guideline, currently \code{"`r clinical_breakpoints$guideline[1]`"}. Supported guideline are currently EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`).
#' * `AMR_antibiogram_formatting_type` \cr A [numeric] (1-12) to use in [antibiogram()], to indicate which formatting type to use.
#' * `AMR_breakpoint_type` \cr A [character] to use in [as.sir()], to indicate which breakpoint type to use. This must be either `r vector_or(clinical_breakpoints$type)`.
#' * `AMR_cleaning_regex` \cr A [regular expression][base::regex] (case-insensitive) to use in [as.mo()] and all [`mo_*`][mo_property()] functions, to clean the user input. The default is the outcome of [mo_cleaning_regex()], which removes texts between brackets and texts such as "species" and "serovar".
#' * `AMR_custom_ab` \cr A file location to an RDS file, to use custom antimicrobial drugs with this package. This is explained in [add_custom_antimicrobials()].
#' * `AMR_custom_mo` \cr A file location to an RDS file, to use custom microorganisms with this package. This is explained in [add_custom_microorganisms()].
#' * `AMR_eucastrules` \cr A [character] to set the default types of rules for [eucast_rules()] function, must be one or more of: `"breakpoints"`, `"expert"`, `"other"`, `"custom"`, `"all"`, and defaults to `c("breakpoints", "expert")`.
#' * `AMR_guideline` \cr A [character] to set the default guideline for interpreting MIC values and disk diffusion diameters with [as.sir()]. Can be only the guideline name (e.g., `"CLSI"`) or the name with a year (e.g. `"CLSI 2019"`). The default to the latest implemented EUCAST guideline, currently \code{"`r clinical_breakpoints$guideline[1]`"}. Supported guideline are currently EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`).
#' * `AMR_ignore_pattern` \cr A [regular expression][base::regex] to ignore (i.e., make `NA`) any match given in [as.mo()] and all [`mo_*`][mo_property()] functions.
#' * `AMR_include_PKPD` \cr A [logical] to use in [as.sir()], to indicate that PK/PD clinical breakpoints must be applied as a last resort - the default is `TRUE`.
#' * `AMR_ecoff` \cr A [logical] use in [as.sir()], to indicate that ECOFF (Epidemiological Cut-Off) values must be used - the default is `FALSE`.
#' * `AMR_include_screening` \cr A [logical] to use in [as.sir()], to indicate that clinical breakpoints for screening are allowed - the default is `FALSE`.
#' * `AMR_keep_synonyms` \cr A [logical] to use in [as.mo()] and all [`mo_*`][mo_property()] functions, to indicate if old, previously valid taxonomic names must be preserved and not be corrected to currently accepted names. The default is `FALSE`.
#' * `AMR_cleaning_regex` \cr A [regular expression][base::regex] (case-insensitive) to use in [as.mo()] and all [`mo_*`][mo_property()] functions, to clean the user input. The default is the outcome of [mo_cleaning_regex()], which removes texts between brackets and texts such as "species" and "serovar".
#' * `AMR_locale` \cr A language to use for the `AMR` package, can be one of these supported language names or ISO-639-1 codes: `r vector_or(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`. The default is the current system language (if supported).
#' * `AMR_locale` \cr A [character] to set the language for the `AMR` package, can be one of these supported language names or ISO-639-1 codes: `r vector_or(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`. The default is the current system language (if supported, English otherwise).
#' * `AMR_mo_source` \cr A file location for a manual code list to be used in [as.mo()] and all [`mo_*`][mo_property()] functions. This is explained in [set_mo_source()].
#'
#'
#' @section Saving Settings Between Sessions:
#' Settings in \R are not saved globally and are thus lost when \R is exited. You can save your options to your own `.Rprofile` file, which is a user-specific file. You can edit it using:
#'
@@ -51,18 +52,18 @@
#' utils::file.edit("~/.Rprofile")
#' ```
#'
#' In this file, you can set options such as:
#' In this file, you can set options such as...
#'
#' ```r
#' options(AMR_locale = "pt")
#' options(AMR_include_PKPD = TRUE)
#' ```
#'
#' to add Portuguese language support of antibiotics, and allow PK/PD rules when interpreting MIC values with [as.sir()].
#' ...to add Portuguese language support of antibiotics, and allow PK/PD rules when interpreting MIC values with [as.sir()].
#'
#' ### Share Options Within Team
#'
#' For a more global approach, e.g. within a data team, save an options file to a remote file location, such as a shared network drive. This would work in this way:
#' For a more global approach, e.g. within a (data) team, save an options file to a remote file location, such as a shared network drive, and have each user read in this file automatically at start-up. This would work in this way:
#'
#' 1. Save a plain text file to e.g. "X:/team_folder/R_options.R" and fill it with preferred settings.
#'
+50 -40
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -51,7 +51,7 @@
#'
#' You can add your own manual codes to be considered by [as.ab()] and all [`ab_*`][ab_property()] functions, see [add_custom_antimicrobials()].
#' @section Source:
#' World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/}
#' World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://atcddd.fhi.no/atc_ddd_index/}
#'
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm}
#' @aliases ab
@@ -107,7 +107,10 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
))
}
initial_search <- is.null(list(...)$initial_search)
loop_time <- list(...)$loop_time
if (is.null(loop_time)) {
loop_time <- 1
}
already_regex <- isTRUE(list(...)$already_regex)
fast_mode <- isTRUE(list(...)$fast_mode)
@@ -117,8 +120,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
# remove diacritics
x <- iconv(x, from = "UTF-8", to = "ASCII//TRANSLIT")
x <- gsub('"', "", x, fixed = TRUE)
x <- gsub("(specimen|specimen date|specimen_date|spec_date|gender|^dates?$)", "", x, ignore.case = TRUE, perl = TRUE)
# penicillin is a special case: we call it so, but then mean benzylpenicillin
x <- gsub("(specimen|specimen date|specimen_date|spec_date|gender|^dates?$|animal|host($|[a-z]))", "", x, ignore.case = TRUE, perl = TRUE)
# penicillin is a special case: we call it so, but then most often mean benzylpenicillin
x[x %like_case% "^PENICILLIN" & x %unlike_case% "[ /+-]"] <- "benzylpenicillin"
x_bak_clean <- x
if (already_regex == FALSE) {
@@ -131,16 +134,21 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_unknown_ATCs <- character(0)
note_if_more_than_one_found <- function(found, index, from_text) {
if (isTRUE(initial_search) && isTRUE(length(from_text) > 1)) {
abnames <- ab_name(from_text, tolower = TRUE, initial_search = FALSE)
if (loop_time == 1 && isTRUE(length(from_text) > 1)) {
abnames <- ab_name(from_text, tolower = TRUE, loop_time = loop_time + 1)
if (ab_name(found[1L], language = NULL) %like% "(clavulanic acid|(avi|tazo|mono|vabor)bactam)") {
abnames <- abnames[!abnames %in% c("clavulanic acid", "avibactam", "tazobactam", "vaborbactam", "monobactam")]
}
if (length(abnames) > 1) {
message_(
"More than one result was found for item ", index, ": ",
vector_and(abnames, quotes = FALSE)
)
if (toupper(paste(abnames, collapse = " ")) %in% AMR_env$AB_lookup$generalised_name) {
# if the found values combined is a valid AB, return that
found <- AMR_env$AB_lookup$ab[match(toupper(paste(abnames, collapse = " ")), AMR_env$AB_lookup$generalised_name)][1]
} else {
message_(
"More than one result was found for item ", index, ": ",
vector_and(abnames, quotes = FALSE)
)
}
}
}
found[1L]
@@ -174,13 +182,13 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_new[is.na(x)] <- NA
already_known[is.na(x)] <- FALSE
if (isTRUE(initial_search) && sum(already_known) < length(x)) {
if (loop_time == 1 && sum(already_known) < length(x)) {
progress <- progress_ticker(n = sum(!already_known), n_min = 25, print = info) # start if n >= 25
on.exit(close(progress))
}
for (i in which(!already_known)) {
if (isTRUE(initial_search)) {
if (loop_time == 1) {
progress$tick()
}
@@ -202,7 +210,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
}
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]]),
from_text <- tryCatch(suppressWarnings(ab_from_text(x[i], loop_time = loop_time + 1, translate_ab = FALSE)[[1]]),
error = function(e) character(0)
)
} else {
@@ -314,13 +322,12 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
}
# INITIAL SEARCH - More uncertain results ----
if (isTRUE(initial_search) && fast_mode == FALSE) {
# only run on first try
if (loop_time <= 2 && fast_mode == FALSE) {
# only run on first and second try
# try by removing all spaces
if (x[i] %like% " ") {
found <- suppressWarnings(as.ab(gsub(" +", "", x[i], perl = TRUE), initial_search = FALSE))
found <- suppressWarnings(as.ab(gsub(" +", "", x[i], perl = TRUE), loop_time = loop_time + 2))
if (length(found) > 0 && !is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
next
@@ -329,7 +336,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
# try by removing all spaces and numbers
if (x[i] %like% " " || x[i] %like% "[0-9]") {
found <- suppressWarnings(as.ab(gsub("[ 0-9]", "", x[i], perl = TRUE), initial_search = FALSE))
found <- suppressWarnings(as.ab(gsub("[ 0-9]", "", x[i], perl = TRUE), loop_time = loop_time + 2))
if (length(found) > 0 && !is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
next
@@ -355,7 +362,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
)[[1]],
collapse = "/"
)
x_translated_guess <- suppressWarnings(as.ab(x_translated, initial_search = FALSE))
x_translated_guess <- suppressWarnings(as.ab(x_translated, loop_time = loop_time + 2))
if (!is.na(x_translated_guess)) {
x_new[i] <- x_translated_guess
next
@@ -367,7 +374,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
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_name <- suppressWarnings(ab_name(y[i], language = NULL, loop_time = loop_time + 2))
y[i] <- ifelse(!is.na(y_name),
y_name,
y[i]
@@ -378,7 +385,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
)[[1]],
collapse = "/"
)
x_translated_guess <- suppressWarnings(as.ab(x_translated, initial_search = FALSE))
x_translated_guess <- suppressWarnings(as.ab(x_translated, loop_time = loop_time + 2))
if (!is.na(x_translated_guess)) {
x_new[i] <- x_translated_guess
next
@@ -386,7 +393,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
# try by removing all trailing capitals
if (x[i] %like_case% "[a-z]+[A-Z]+$") {
found <- suppressWarnings(as.ab(gsub("[A-Z]+$", "", x[i], perl = TRUE), initial_search = FALSE))
found <- suppressWarnings(as.ab(gsub("[A-Z]+$", "", x[i], perl = TRUE), loop_time = loop_time + 2))
if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
next
@@ -394,7 +401,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
}
# keep only letters
found <- suppressWarnings(as.ab(gsub("[^A-Z]", "", x[i], perl = TRUE), initial_search = FALSE))
found <- suppressWarnings(as.ab(gsub("[^A-Z]", "", x[i], perl = TRUE), loop_time = loop_time + 2))
if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
next
@@ -405,7 +412,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
if (flag_multiple_results == TRUE) {
found <- from_text[1L]
} else {
found <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]][1L]),
found <- tryCatch(suppressWarnings(ab_from_text(x[i], loop_time = loop_time + 2, translate_ab = FALSE)[[1]][1L]),
error = function(e) NA_character_
)
}
@@ -415,12 +422,12 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
}
# first 5 except for cephalosporins, then first 7 (those cephalosporins all start quite the same!)
found <- suppressWarnings(as.ab(substr(x[i], 1, 5), initial_search = FALSE))
if (!is.na(found) && ab_group(found, initial_search = FALSE) %unlike% "cephalosporins") {
found <- suppressWarnings(as.ab(substr(x[i], 1, 5), loop_time = loop_time + 2))
if (!is.na(found) && ab_group(found, loop_time = loop_time + 1) %unlike% "cephalosporins") {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
next
}
found <- suppressWarnings(as.ab(substr(x[i], 1, 7), initial_search = FALSE))
found <- suppressWarnings(as.ab(substr(x[i], 1, 7), loop_time = loop_time + 2))
if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
next
@@ -428,7 +435,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
# make all consonants facultative
search_str <- gsub("([BCDFGHJKLMNPQRSTVWXZ])", "\\1*", x[i], perl = TRUE)
found <- suppressWarnings(as.ab(search_str, initial_search = FALSE, already_regex = TRUE))
found <- suppressWarnings(as.ab(search_str, loop_time = loop_time + 2, already_regex = TRUE))
# keep at least 4 normal characters
if (nchar(gsub(".\\*", "", search_str, perl = TRUE)) < 4) {
found <- NA
@@ -440,7 +447,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
# make all vowels facultative
search_str <- gsub("([AEIOUY])", "\\1*", x[i], perl = TRUE)
found <- suppressWarnings(as.ab(search_str, initial_search = FALSE, already_regex = TRUE))
found <- suppressWarnings(as.ab(search_str, loop_time = loop_time + 2, already_regex = TRUE))
# keep at least 5 normal characters
if (nchar(gsub(".\\*", "", search_str, perl = TRUE)) < 5) {
found <- NA
@@ -456,7 +463,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_spelling <- gsub("I+", "[AEIOU]+", x_spelling, fixed = TRUE)
x_spelling <- gsub("O+", "[AEIOU]+", x_spelling, fixed = TRUE)
x_spelling <- gsub("U+", "[AEIOU]+", x_spelling, fixed = TRUE)
found <- suppressWarnings(as.ab(x_spelling, initial_search = FALSE, already_regex = TRUE))
found <- suppressWarnings(as.ab(x_spelling, loop_time = loop_time + 2, already_regex = TRUE))
if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
next
@@ -473,7 +480,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
# ending part:
substr(x[i], j + 2, nchar(x[i]))
)
found <- suppressWarnings(as.ab(x_switched, initial_search = FALSE))
found <- suppressWarnings(as.ab(x_switched, loop_time = loop_time + 1))
if (!is.na(found)) {
break
}
@@ -482,18 +489,18 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_new[i] <- found[1L]
next
}
} # end of initial_search = TRUE
} # end of loop_time <= 2
# not found
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
}
if (isTRUE(initial_search) && sum(already_known) < length(x)) {
if (loop_time == 1 && sum(already_known) < length(x)) {
close(progress)
}
# save to package env to save time for next time
if (isTRUE(initial_search)) {
if (loop_time == 1) {
AMR_env$ab_previously_coerced <- AMR_env$ab_previously_coerced[which(!AMR_env$ab_previously_coerced$x %in% x), , drop = FALSE]
AMR_env$ab_previously_coerced <- unique(rbind_AMR(
AMR_env$ab_previously_coerced,
@@ -518,6 +525,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_unknown,
AMR_env$ab_previously_coerced$x_bak[which(AMR_env$ab_previously_coerced$x %in% x & is.na(AMR_env$ab_previously_coerced$ab))]
)
x_unknown <- x_unknown[!x_unknown %in% c("", NA)]
if (length(x_unknown) > 0 && fast_mode == FALSE) {
warning_(
"in `as.ab()`: these values could not be coerced to a valid antimicrobial ID: ",
@@ -645,12 +653,14 @@ generalise_antibiotic_name <- function(x) {
x <- gsub("_(MIC|RSI|SIR|DIS[CK])$", "", x, perl = TRUE)
# remove disk concentrations, like LVX_NM -> LVX
x <- gsub("_[A-Z]{2}[0-9_.]{0,3}$", "", x, perl = TRUE)
# remove part between brackets if that's followed by another string
x <- gsub("(.*)+ [(].*[)]", "\\1", x)
# keep only max 1 space
x <- trimws2(gsub(" +", " ", x, perl = TRUE))
# non-character, space or number should be a slash
x <- gsub("[^A-Z0-9 -]", "/", x, perl = TRUE)
x <- gsub("[^A-Z0-9 -)(]", "/", x, perl = TRUE)
# correct for 'high level' antibiotics
x <- gsub("([^A-Z0-9/ -]+)?(HIGH(.?LE?VE?L)?|[^A-Z0-9/]H[^A-Z0-9]?L)([^A-Z0-9 -]+)?", "-HIGH", x, perl = TRUE)
# remove part between brackets if that's followed by another string
x <- gsub("(.*)+ [(].*[)]", "\\1", x)
# spaces around non-characters must be removed: amox + clav -> amox/clav
x <- gsub("(.*[A-Z0-9]) ([^A-Z0-9].*)", "\\1\\2", x, perl = TRUE)
x <- gsub("(.*[^A-Z0-9]) ([A-Z0-9].*)", "\\1\\2", x, perl = TRUE)
+7 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -129,6 +129,10 @@ ab_from_text <- function(text,
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()
text_split <- text_split[text_split %like% "[A-Z]" & text_split %unlike% "[0-9]"]
if (length(text_split) == 0) {
return(as.ab(NA_character_))
}
suppressWarnings(
as.ab(text_split, ...)
)
+10 -7
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -33,7 +33,7 @@
#' @param x any (vector of) text that can be coerced to a valid antibiotic drug code with [as.ab()]
#' @param tolower a [logical] to indicate whether the first [character] of every output should be transformed to a lower case [character]. This will lead to e.g. "polymyxin B" and not "polymyxin b".
#' @param property one of the column names of one of the [antibiotics] data set: `vector_or(colnames(antibiotics), sort = FALSE)`.
#' @param language language of the returned text - the default is the current system language (see [get_AMR_locale()]) and can also be set with the [package option][AMR-options] [`AMR_locale`][AMR-options]. Use `language = NULL` or `language = ""` to prevent translation.
#' @param language language of the returned text - the default is the current system language (see [get_AMR_locale()]) and can also be set with the package option [`AMR_locale`][AMR-options]. Use `language = NULL` or `language = ""` to prevent translation.
#' @param administration way of administration, either `"oral"` or `"iv"`
#' @param open browse the URL using [utils::browseURL()]
#' @param ... in case of [set_ab_names()] and `data` is a [data.frame]: columns to select (supports tidy selection such as `column1:column4`), otherwise other arguments passed on to [as.ab()]
@@ -245,7 +245,7 @@ ab_ddd <- function(x, administration = "oral", ...) {
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/"
"atcddd.fhi.no/ddd/list_of_ddds_combined_products/"
)
}
out
@@ -265,7 +265,7 @@ ab_ddd_units <- function(x, administration = "oral", ...) {
warning_(
"in `ab_ddd_units()`: 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/"
"atcddd.fhi.no/ddd/list_of_ddds_combined_products/"
)
}
out
@@ -310,7 +310,10 @@ ab_url <- function(x, open = FALSE, ...) {
ab <- as.ab(x = x, ...)
atcs <- ab_atc(ab, only_first = TRUE)
u <- paste0("https://www.whocc.no/atc_ddd_index/?code=", atcs, "&showdescription=no")
u <- character(length(atcs))
# veterinary codes
u[atcs %like% "^Q"] <- paste0("https://atcddd.fhi.no/atcvet/atcvet_index/?code=", atcs[atcs %like% "^Q"], "&showdescription=no")
u[atcs %unlike% "^Q"] <- paste0("https://atcddd.fhi.no/atc_ddd_index//?code=", atcs[atcs %unlike% "^Q"], "&showdescription=no")
u[is.na(atcs)] <- NA_character_
names(u) <- ab_name(ab)
+102 -175
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -57,59 +57,31 @@
#' example_isolates
#'
#'
#' # Examples sections below are split into 'base R', 'dplyr', and 'data.table':
#'
#'
#' # base R ------------------------------------------------------------------
#'
#' # select columns 'IPM' (imipenem) and 'MEM' (meropenem)
#' example_isolates[, carbapenems()]
#'
#' # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
#' example_isolates[, c("mo", aminoglycosides())]
#'
#' # select only antibiotic columns with DDDs for oral treatment
#' example_isolates[, administrable_per_os()]
#'
#' # filter using any() or all()
#' example_isolates[any(carbapenems() == "R"), ]
#' subset(example_isolates, any(carbapenems() == "R"))
#'
#' # filter on any or all results in the carbapenem columns (i.e., IPM, MEM):
#' example_isolates[any(carbapenems()), ]
#' example_isolates[all(carbapenems()), ]
#'
#' # filter with multiple antibiotic selectors using c()
#' example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]
#'
#' # filter + select in one go: get penicillins in carbapenem-resistant strains
#' 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:
#' 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:
#' example_isolates[, ab_selector(oral_ddd > 1 & oral_units == "g")]
#'
#' # Examples sections below are split into 'dplyr', 'base R', and 'data.table':
#'
#' \donttest{
#' # dplyr -------------------------------------------------------------------
#'
#' if (require("dplyr")) {
#' example_isolates %>% select(carbapenems())
#' }
#'
#' if (require("dplyr")) {
#' tibble(kefzol = random_sir(5)) %>%
#' select(cephalosporins())
#' # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
#' example_isolates %>% select(mo, aminoglycosides())
#' }
#'
#' if (require("dplyr")) {
#' # select only antibiotic columns with DDDs for oral treatment
#' example_isolates %>% select(administrable_per_os())
#' }
#'
#' if (require("dplyr")) {
#' # get AMR for all aminoglycosides e.g., per ward:
#' example_isolates %>%
#' group_by(ward) %>%
#' summarise(across(aminoglycosides(), resistance))
#' summarise(across(aminoglycosides(),
#' resistance))
#' }
#' if (require("dplyr")) {
#' # You can combine selectors with '&' to be more specific:
@@ -121,7 +93,8 @@
#' example_isolates %>%
#' filter(mo_genus() %in% c("Escherichia", "Klebsiella")) %>%
#' group_by(ward) %>%
#' summarise(across(not_intrinsic_resistant(), resistance))
#' summarise_at(not_intrinsic_resistant(),
#' resistance)
#' }
#' if (require("dplyr")) {
#' # get susceptibility for antibiotics whose name contains "trim":
@@ -187,6 +160,44 @@
#' }
#'
#'
#' # base R ------------------------------------------------------------------
#'
#' # select columns 'IPM' (imipenem) and 'MEM' (meropenem)
#' example_isolates[, carbapenems()]
#'
#' # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
#' example_isolates[, c("mo", aminoglycosides())]
#'
#' # select only antibiotic columns with DDDs for oral treatment
#' example_isolates[, administrable_per_os()]
#'
#' # filter using any() or all()
#' example_isolates[any(carbapenems() == "R"), ]
#' subset(example_isolates, any(carbapenems() == "R"))
#'
#' # filter on any or all results in the carbapenem columns (i.e., IPM, MEM):
#' example_isolates[any(carbapenems()), ]
#' example_isolates[all(carbapenems()), ]
#'
#' # filter with multiple antibiotic selectors using c()
#' example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]
#'
#' # filter + select in one go: get penicillins in carbapenem-resistant strains
#' 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:
#' 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:
#' example_isolates[, ab_selector(oral_ddd > 1 & oral_units == "g")]
#'
#'
#' # data.table --------------------------------------------------------------
#'
#' # data.table is supported as well, just use it in the same way as with
@@ -226,10 +237,6 @@ ab_class <- function(ab_class,
meet_criteria(ab_class, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec(NULL, only_sir_columns = only_sir_columns, ab_class_args = ab_class, only_treatable = only_treatable)
}
@@ -242,10 +249,6 @@ ab_selector <- function(filter,
...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
# get_current_data() has to run each time, for cases where e.g., filter() and select() are used in same call
# but it only takes a couple of milliseconds
@@ -277,10 +280,6 @@ ab_selector <- function(filter,
aminoglycosides <- function(only_sir_columns = FALSE, only_treatable = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("aminoglycosides", only_sir_columns = only_sir_columns, only_treatable = only_treatable)
}
@@ -288,10 +287,6 @@ aminoglycosides <- function(only_sir_columns = FALSE, only_treatable = TRUE, ...
#' @export
aminopenicillins <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("aminopenicillins", only_sir_columns = only_sir_columns)
}
@@ -299,10 +294,6 @@ aminopenicillins <- function(only_sir_columns = FALSE, ...) {
#' @export
antifungals <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("antifungals", only_sir_columns = only_sir_columns)
}
@@ -310,10 +301,6 @@ antifungals <- function(only_sir_columns = FALSE, ...) {
#' @export
antimycobacterials <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("antimycobacterials", only_sir_columns = only_sir_columns)
}
@@ -322,10 +309,6 @@ antimycobacterials <- function(only_sir_columns = FALSE, ...) {
betalactams <- function(only_sir_columns = FALSE, only_treatable = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("betalactams", only_sir_columns = only_sir_columns, only_treatable = only_treatable)
}
@@ -334,10 +317,6 @@ betalactams <- function(only_sir_columns = FALSE, only_treatable = TRUE, ...) {
carbapenems <- function(only_sir_columns = FALSE, only_treatable = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("carbapenems", only_sir_columns = only_sir_columns, only_treatable = only_treatable)
}
@@ -345,10 +324,6 @@ carbapenems <- function(only_sir_columns = FALSE, only_treatable = TRUE, ...) {
#' @export
cephalosporins <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("cephalosporins", only_sir_columns = only_sir_columns)
}
@@ -356,10 +331,6 @@ cephalosporins <- function(only_sir_columns = FALSE, ...) {
#' @export
cephalosporins_1st <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("cephalosporins_1st", only_sir_columns = only_sir_columns)
}
@@ -367,10 +338,6 @@ cephalosporins_1st <- function(only_sir_columns = FALSE, ...) {
#' @export
cephalosporins_2nd <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("cephalosporins_2nd", only_sir_columns = only_sir_columns)
}
@@ -378,10 +345,6 @@ cephalosporins_2nd <- function(only_sir_columns = FALSE, ...) {
#' @export
cephalosporins_3rd <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("cephalosporins_3rd", only_sir_columns = only_sir_columns)
}
@@ -389,10 +352,6 @@ cephalosporins_3rd <- function(only_sir_columns = FALSE, ...) {
#' @export
cephalosporins_4th <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("cephalosporins_4th", only_sir_columns = only_sir_columns)
}
@@ -400,10 +359,6 @@ cephalosporins_4th <- function(only_sir_columns = FALSE, ...) {
#' @export
cephalosporins_5th <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("cephalosporins_5th", only_sir_columns = only_sir_columns)
}
@@ -411,10 +366,6 @@ cephalosporins_5th <- function(only_sir_columns = FALSE, ...) {
#' @export
fluoroquinolones <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("fluoroquinolones", only_sir_columns = only_sir_columns)
}
@@ -422,32 +373,21 @@ fluoroquinolones <- function(only_sir_columns = FALSE, ...) {
#' @export
glycopeptides <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("glycopeptides", only_sir_columns = only_sir_columns)
}
#' @rdname antibiotic_class_selectors
#' @export
lincosamides <- function(only_sir_columns = FALSE, ...) {
lincosamides <- function(only_sir_columns = FALSE, only_treatable = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("lincosamides", only_sir_columns = only_sir_columns)
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
ab_select_exec("lincosamides", only_sir_columns = only_sir_columns, only_treatable = only_treatable)
}
#' @rdname antibiotic_class_selectors
#' @export
lipoglycopeptides <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("lipoglycopeptides", only_sir_columns = only_sir_columns)
}
@@ -455,21 +395,20 @@ lipoglycopeptides <- function(only_sir_columns = FALSE, ...) {
#' @export
macrolides <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("macrolides", only_sir_columns = only_sir_columns)
}
#' @rdname antibiotic_class_selectors
#' @export
nitrofurans <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
ab_select_exec("nitrofurans", only_sir_columns = only_sir_columns)
}
#' @rdname antibiotic_class_selectors
#' @export
oxazolidinones <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("oxazolidinones", only_sir_columns = only_sir_columns)
}
@@ -477,10 +416,6 @@ oxazolidinones <- function(only_sir_columns = FALSE, ...) {
#' @export
penicillins <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("penicillins", only_sir_columns = only_sir_columns)
}
@@ -489,43 +424,34 @@ penicillins <- function(only_sir_columns = FALSE, ...) {
polymyxins <- function(only_sir_columns = FALSE, only_treatable = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("polymyxins", only_sir_columns = only_sir_columns, only_treatable = only_treatable)
}
#' @rdname antibiotic_class_selectors
#' @export
streptogramins <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("streptogramins", only_sir_columns = only_sir_columns)
}
#' @rdname antibiotic_class_selectors
#' @export
quinolones <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("quinolones", only_sir_columns = only_sir_columns)
}
#' @rdname antibiotic_class_selectors
#' @export
rifamycins <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
ab_select_exec("rifamycins", only_sir_columns = only_sir_columns)
}
#' @rdname antibiotic_class_selectors
#' @export
streptogramins <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
ab_select_exec("streptogramins", only_sir_columns = only_sir_columns)
}
#' @rdname antibiotic_class_selectors
#' @export
tetracyclines <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("tetracyclines", only_sir_columns = only_sir_columns)
}
@@ -533,10 +459,6 @@ tetracyclines <- function(only_sir_columns = FALSE, ...) {
#' @export
trimethoprims <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("trimethoprims", only_sir_columns = only_sir_columns)
}
@@ -544,10 +466,6 @@ trimethoprims <- function(only_sir_columns = FALSE, ...) {
#' @export
ureidopenicillins <- function(only_sir_columns = FALSE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
ab_select_exec("ureidopenicillins", only_sir_columns = only_sir_columns)
}
@@ -649,10 +567,10 @@ not_intrinsic_resistant <- function(only_sir_columns = FALSE, col_mo = NULL, ver
),
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)
@@ -663,7 +581,7 @@ not_intrinsic_resistant <- function(only_sir_columns = FALSE, col_mo = NULL, ver
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))
@@ -687,9 +605,9 @@ ab_select_exec <- function(function_name,
# untreatable drugs
if (only_treatable == TRUE) {
untreatable <- AMR_env$AB_lookup[which(AMR_env$AB_lookup$name %like% "-high|EDTA|polysorbate|macromethod|screening|/nacubactam"), "ab", drop = TRUE]
untreatable <- AMR_env$AB_lookup[which(AMR_env$AB_lookup$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)) {
if (message_not_thrown_before(function_name, "ab_class", "untreatable")) {
warning_(
"in `", function_name, "()`: some drugs were ignored since they cannot be used for treating patients: ",
vector_and(
@@ -699,8 +617,7 @@ ab_select_exec <- function(function_name,
),
quotes = FALSE,
sort = TRUE
), ". They can be included using `", function_name, "(only_treatable = FALSE)`. ",
"This warning will be shown once per session."
), ". They can be included using `", function_name, "(only_treatable = FALSE)`."
)
}
ab_in_data <- ab_in_data[!names(ab_in_data) %in% untreatable]
@@ -719,7 +636,7 @@ ab_select_exec <- function(function_name,
} else if (isTRUE(function_name == "antimycobacterials")) {
abx <- AMR_env$AB_lookup$ab[which(AMR_env$AB_lookup$group == "Antimycobacterials")]
} else {
# 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_checks.R
# carbapenems() gets its codes from AMR:::AB_CARBAPENEMS
abx <- get(paste0("AB_", toupper(function_name)), envir = asNamespace("AMR"))
# manually added codes from add_custom_antimicrobials() must also be supported
@@ -773,6 +690,16 @@ ab_select_exec <- function(function_name,
)
}
#' @method print ab_selector
#' @export
#' @noRd
print.ab_selector <- function(x, ...) {
warning_("It should never be needed to print an antibiotic selector class. Are you using data.table? Then add the argument `with = FALSE`, see our examples at `?ab_selector`.",
immediate = TRUE)
cat("Class 'ab_selector'\n")
print(as.character(x), quote = FALSE)
}
#' @method c ab_selector
#' @export
#' @noRd
@@ -784,10 +711,10 @@ c.ab_selector <- function(...) {
all_any_ab_selector <- function(type, ..., na.rm = TRUE) {
cols_ab <- c(...)
result <- cols_ab[toupper(cols_ab) %in% c("S", "I", "R")]
result <- cols_ab[toupper(cols_ab) %in% c("S", "SDD", "I", "R", "NI")]
if (length(result) == 0) {
message_("Filtering ", type, " of columns ", vector_and(font_bold(cols_ab, collapse = NULL), quotes = "'"), ' to contain value "S", "I" or "R"')
result <- c("S", "I", "R")
result <- c("S", "SDD", "I", "R", "NI")
}
cols_ab <- cols_ab[!cols_ab %in% result]
df <- get_current_data(arg_name = NA, call = -3)
@@ -896,7 +823,7 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) {
}
}
# this is `!=`, so turn around the values
sir <- c("S", "I", "R")
sir <- c("S", "SDD", "I", "R", "NI")
e2 <- sir[sir != e2]
structure(all_any_ab_selector(type = type, e1, e2),
class = c("ab_selector_any_all", "logical")
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+140 -40
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -27,34 +27,56 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
#' Generate Antibiogram: Traditional, Combined, Syndromic, or Weighted-Incidence Syndromic Combination (WISCA)
#' Generate Traditional, Combination, Syndromic, or WISCA Antibiograms
#'
#' Generate an antibiogram, and communicate the results in plots or tables. These functions follow the logic of Klinker *et al.* and Barbieri *et al.* (see *Source*), and allow reporting in e.g. R Markdown and Quarto as well.
#' Create detailed antibiograms with options for traditional, combination, syndromic, and Bayesian WISCA methods. Based on the approaches of Klinker *et al.*, Barbieri *et al.*, and the Bayesian WISCA model (Weighted-Incidence Syndromic Combination Antibiogram) by Bielicki *et al.*, this function provides flexible output formats including plots and tables, ideal for integration with R Markdown and Quarto reports.
#' @param x a [data.frame] containing at least a column with microorganisms and columns with antibiotic results (class 'sir', see [as.sir()])
#' @param antibiotics vector of any antibiotic name or code (will be evaluated with [as.ab()], column name of `x`, or (any combinations of) [antibiotic selectors][antibiotic_class_selectors] such as [aminoglycosides()] or [carbapenems()]. For combination antibiograms, this can also be set to values separated with `"+"`, such as "TZP+TOB" or "cipro + genta", given that columns resembling such antibiotics exist in `x`. See *Examples*.
#' @param mo_transform a character to transform microorganism input - must be "name", "shortname", "gramstain", or one of the column names of the [microorganisms] data set: `r vector_or(colnames(microorganisms), sort = FALSE, quotes = TRUE)`. Can also be `NULL` to not transform the input.
#' @param ab_transform a character to transform antibiotic input - must be one of the column names of the [antibiotics] data set: `r vector_or(colnames(antibiotics), sort = FALSE, quotes = TRUE)`. Can also be `NULL` to not transform the input.
#' @param mo_transform a character to transform microorganism input - must be `"name"`, `"shortname"` (default), `"gramstain"`, or one of the column names of the [microorganisms] data set: `r vector_or(colnames(microorganisms), sort = FALSE, quotes = TRUE)`. Can also be `NULL` to not transform the input.
#' @param ab_transform a character to transform antibiotic input - must be one of the column names of the [antibiotics] data set (defaults to `"name"`): `r vector_or(colnames(antibiotics), sort = FALSE, quotes = TRUE)`. Can also be `NULL` to not transform the input.
#' @param syndromic_group a column name of `x`, or values calculated to split rows of `x`, e.g. by using [ifelse()] or [`case_when()`][dplyr::case_when()]. See *Examples*.
#' @param add_total_n a [logical] to indicate whether total available numbers per pathogen should be added to the table (default is `TRUE`). This will add the lowest and highest number of available isolate per antibiotic (e.g, if for *E. coli* 200 isolates are available for ciprofloxacin and 150 for amoxicillin, the returned number will be "150-200").
#' @param only_all_tested (for combination antibiograms): a [logical] to indicate that isolates must be tested for all antibiotics, see *Details*
#' @param digits number of digits to use for rounding
#' @param digits number of digits to use for rounding the susceptibility percentage
#' @param formatting_type numeric value (112) indicating how the 'cells' of the antibiogram table should be formatted. See *Details* > *Formatting Type* for a list of options.
#' @param col_mo column name of the names or codes of the microorganisms (see [as.mo()]) - the default is the first column of class [`mo`]. Values will be coerced using [as.mo()].
#' @param language language to translate text, which defaults to the system language (see [get_AMR_locale()])
#' @param minimum the minimum allowed number of available (tested) isolates. Any isolate count lower than `minimum` will return `NA` with a warning. The default number of `30` isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see *Source*.
#' @param combine_SI a [logical] to indicate whether all susceptibility should be determined by results of either S or I, instead of only S (default is `TRUE`)
#' @param combine_SI a [logical] to indicate whether all susceptibility should be determined by results of either S, SDD, or I, instead of only S (default is `TRUE`)
#' @param sep a separating character for antibiotic columns in combination antibiograms
#' @param info a [logical] to indicate info should be printed - the default is `TRUE` only in interactive mode
#' @param object an [antibiogram()] object
#' @param ... when used in [R Markdown or Quarto][knitr::kable()]: arguments passed on to [knitr::kable()] (otherwise, has no use)
#' @details This function returns a table with values between 0 and 100 for *susceptibility*, not resistance.
#'
#'
#' **Remember that you should filter your data to let it contain only first isolates!** This is needed to exclude duplicates and to reduce selection bias. Use [first_isolate()] to determine them in your data set with one of the four available algorithms.
#'
#' All types of antibiograms as listed below can be plotted (using [ggplot2::autoplot()] or base \R [plot()]/[barplot()]). The `antibiogram` object can also be used directly in R Markdown / Quarto (i.e., `knitr`) for reports. In this case, [knitr::kable()] will be applied automatically and microorganism names will even be printed in italics at default (see argument `italicise`). You can also use functions from specific 'table reporting' packages to transform the output of [antibiogram()] to your needs, e.g. with `flextable::as_flextable()` or `gt::gt()`.
#'
#' ### Formatting Type
#'
#' The formatting of the 'cells' of the table can be set with the argument `formatting_type`. In these examples, `5` is the susceptibility percentage, `15` the numerator, and `300` the denominator:
#'
#' 1. 5
#' 2. 15
#' 3. 300
#' 4. 15/300
#' 5. 5 (300)
#' 6. 5% (300)
#' 7. 5 (N=300)
#' 8. 5% (N=300)
#' 9. 5 (15/300)
#' 10. 5% (15/300)
#' 11. 5 (N=15/300)
#' 12. 5% (N=15/300)
#'
#' The default is `10`, which can be set globally with the package option [`AMR_antibiogram_formatting_type`][AMR-options], e.g. `options(AMR_antibiogram_formatting_type = 5)`.
#'
#' Set `digits` (defaults to `0`) to alter the rounding of the susceptibility percentage.
#'
#' ### Antibiogram Types
#'
#' There are four antibiogram types, as proposed by Klinker *et al.* (2021, \doi{10.1177/20499361211011373}), and they are all supported by [antibiogram()]:
#' There are four antibiogram types, as summarised by Klinker *et al.* (2021, \doi{10.1177/20499361211011373}), and they are all supported by [antibiogram()]. Use WISCA whenever possible, since it provides precise coverage estimates by accounting for pathogen incidence and antimicrobial susceptibility. See the section *Why Use WISCA?* on this page.
#'
#' The four antibiogram types:
#'
#' 1. **Traditional Antibiogram**
#'
@@ -91,6 +113,8 @@
#' ```
#'
#' 4. **Weighted-Incidence Syndromic Combination Antibiogram (WISCA)**
#'
#' WISCA enhances empirical antibiotic selection by weighting the incidence of pathogens in specific clinical syndromes and combining them with their susceptibility data. It provides an estimation of regimen coverage by aggregating pathogen incidences and susceptibilities across potential causative organisms. See also the section *Why Use WISCA?* on this page.
#'
#' Case example: Susceptibility of *Pseudomonas aeruginosa* to TZP among respiratory specimens (obtained among ICU patients only) for male patients age >=65 years with heart failure
#'
@@ -106,8 +130,12 @@
#' .$condition == "Heart Disease",
#' "Study Group", "Control Group"))
#' ```
#'
#' WISCA uses a sophisticated Bayesian decision model to combine both local and pooled antimicrobial resistance data. This approach not only evaluates local patterns but can also draw on multi-centre datasets to improve regimen accuracy, even in low-incidence infections like paediatric bloodstream infections (BSIs).
#'
#' Note that for combination antibiograms, it is important to realise that susceptibility can be calculated in two ways, which can be set with the `only_all_tested` argument (default is `FALSE`). See this example for two antibiotics, Drug A and Drug B, about how [antibiogram()] works to calculate the %SI:
#' ### Inclusion in Combination Antibiogram and Syndromic Antibiogram
#'
#' Note that for types 2 and 3 (Combination Antibiogram and Syndromic Antibiogram), it is important to realise that susceptibility can be calculated in two ways, which can be set with the `only_all_tested` argument (default is `FALSE`). See this example for two antibiotics, Drug A and Drug B, about how [antibiogram()] works to calculate the %SI:
#'
#' ```
#' --------------------------------------------------------------------
@@ -127,8 +155,28 @@
#' <NA> <NA> - - - -
#' --------------------------------------------------------------------
#' ```
#'
#' ### Plotting
#'
#' All types of antibiograms as listed above can be plotted (using [ggplot2::autoplot()] or base \R's [plot()] and [barplot()]).
#'
#' THe outcome of [antibiogram()] can also be used directly in R Markdown / Quarto (i.e., `knitr`) for reports. In this case, [knitr::kable()] will be applied automatically and microorganism names will even be printed in italics at default (see argument `italicise`).
#'
#' You can also use functions from specific 'table reporting' packages to transform the output of [antibiogram()] to your needs, e.g. with `flextable::as_flextable()` or `gt::gt()`.
#'
#' @section Why Use WISCA?:
#' WISCA is a powerful tool for guiding empirical antibiotic therapy because it provides precise coverage estimates by accounting for pathogen incidence and antimicrobial susceptibility. This is particularly important in empirical treatment, where the causative pathogen is often unknown at the outset. Traditional antibiograms do not reflect the weighted likelihood of specific pathogens based on clinical syndromes, which can lead to suboptimal treatment choices.
#'
#' The Bayesian WISCA, as described by Bielicki *et al.* (2016), improves on earlier methods by handling uncertainties common in smaller datasets, such as low-incidence infections. This method offers a significant advantage by:
#'
#' 1. Pooling Data from Multiple Sources:\cr WISCA uses pooled data from multiple hospitals or surveillance sources to overcome limitations of small sample sizes at individual institutions, allowing for more confident selection of narrow-spectrum antibiotics or combinations.
#' 2. Bayesian Framework:\cr The Bayesian decision tree model accounts for both local data and prior knowledge (such as inherent resistance patterns) to estimate regimen coverage. It allows for a more precise estimation of coverage, even in cases where susceptibility data is missing or incomplete.
#' 3. Incorporating Pathogen and Regimen Uncertainty:\cr WISCA allows clinicians to see the likelihood that an empirical regimen will be effective against all relevant pathogens, taking into account uncertainties related to both pathogen prevalence and antimicrobial resistance. This leads to better-informed, data-driven clinical decisions.
#' 4. Scenarios for Optimising Treatment:\cr For hospitals or settings with low-incidence infections, WISCA helps determine whether local data is sufficient or if pooling with external data is necessary. It also identifies statistically significant differences or similarities between antibiotic regimens, enabling clinicians to choose optimal therapies with greater confidence.
#'
#' WISCA is essential in optimising empirical treatment by shifting away from broad-spectrum antibiotics, which are often overused in empirical settings. By offering precise estimates based on syndromic patterns and pooled data, WISCA supports antimicrobial stewardship by guiding more targeted therapy, reducing unnecessary broad-spectrum use, and combating the rise of antimicrobial resistance.
#' @source
#' * Bielicki JA *et al.* (2016). **Selecting appropriate empirical antibiotic regimens for paediatric bloodstream infections: application of a Bayesian decision model to local and pooled antimicrobial resistance surveillance data** *Journal of Antimicrobial Chemotherapy* 71(3); \doi{10.1093/jac/dkv397}
#' * Klinker KP *et al.* (2021). **Antimicrobial stewardship and antibiograms: importance of moving beyond traditional antibiograms**. *Therapeutic Advances in Infectious Disease*, May 5;8:20499361211011373; \doi{10.1177/20499361211011373}
#' * Barbieri E *et al.* (2021). **Development of a Weighted-Incidence Syndromic Combination Antibiogram (WISCA) to guide the choice of the empiric antibiotic treatment for urinary tract infection in paediatric patients: a Bayesian approach** *Antimicrobial Resistance & Infection Control* May 1;10(1):74; \doi{10.1186/s13756-021-00939-2}
#' * **M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 5th Edition**, 2022, *Clinical and Laboratory Standards Institute (CLSI)*. <https://clsi.org/standards/products/microbiology/documents/m39/>.
@@ -253,24 +301,27 @@
antibiogram <- function(x,
antibiotics = where(is.sir),
mo_transform = "shortname",
ab_transform = NULL,
ab_transform = "name",
syndromic_group = NULL,
add_total_n = TRUE,
add_total_n = FALSE,
only_all_tested = FALSE,
digits = 0,
formatting_type = getOption("AMR_antibiogram_formatting_type", 10),
col_mo = NULL,
language = get_AMR_locale(),
minimum = 30,
combine_SI = TRUE,
sep = " + ",
info = interactive()) {
meet_criteria(x, allow_class = "data.frame", contains_column_class = c("sir", "rsi"))
meet_criteria(x, allow_class = "data.frame")
x <- ascertain_sir_classes(x, "x")
meet_criteria(mo_transform, allow_class = "character", has_length = 1, is_in = c("name", "shortname", "gramstain", colnames(AMR::microorganisms)), allow_NULL = TRUE)
meet_criteria(ab_transform, allow_class = "character", has_length = 1, is_in = colnames(AMR::antibiotics), allow_NULL = TRUE)
meet_criteria(syndromic_group, allow_class = "character", allow_NULL = TRUE, allow_NA = TRUE)
meet_criteria(add_total_n, allow_class = "logical", has_length = 1)
meet_criteria(only_all_tested, allow_class = "logical", has_length = 1)
meet_criteria(digits, allow_class = c("numeric", "integer"), has_length = 1, is_finite = TRUE)
meet_criteria(formatting_type, allow_class = c("numeric", "integer"), has_length = 1, is_in = c(1:12))
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
language <- validate_language(language)
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_positive_or_zero = TRUE, is_finite = TRUE)
@@ -294,7 +345,7 @@ antibiogram <- function(x,
} else if (mo_transform == "name") {
x$`.mo` <- mo_name(x$`.mo`, language = language)
} else {
x$`.mo` <- mo_property(x$`.mo`, language = language)
x$`.mo` <- mo_property(x$`.mo`, property = mo_transform, language = language)
}
x$`.mo`[is.na(x$`.mo`)] <- "(??)"
@@ -348,11 +399,11 @@ antibiogram <- function(x,
} else {
# determine whether this new column should contain S, I, R, or NA
if (isTRUE(combine_SI)) {
S_values <- c("S", "I")
S_values <- c("S", "SDD", "I")
} else {
S_values <- "S"
}
other_values <- setdiff(c("S", "I", "R"), S_values)
other_values <- setdiff(c("S", "SDD", "I", "R", "NI"), S_values)
x_transposed <- as.list(as.data.frame(t(x[, abx, drop = FALSE]), stringsAsFactors = FALSE))
if (isTRUE(only_all_tested)) {
x[new_colname] <- as.sir(vapply(FUN.VALUE = character(1), x_transposed, function(x) ifelse(anyNA(x), NA_character_, ifelse(any(x %in% S_values), "S", "R")), USE.NAMES = FALSE))
@@ -388,18 +439,21 @@ antibiogram <- function(x,
counts <- out
if (isTRUE(combine_SI)) {
out$numerator <- out$S + out$I
out$numerator <- out$S + out$I + out$SDD
} else {
out$numerator <- out$S
}
if (any(out$total < minimum, na.rm = TRUE)) {
if (all(out$total < minimum, na.rm = TRUE)) {
warning_("All combinations had less than `minimum = ", minimum, "` results, returning an empty antibiogram")
return(as_original_data_class(data.frame(), class(out), extra_class = "antibiogram"))
} else if (any(out$total < minimum, na.rm = TRUE)) {
if (isTRUE(info)) {
message_("NOTE: ", sum(out$total < minimum, na.rm = TRUE), " combinations had less than `minimum = ", minimum, "` results and were ignored", add_fn = font_red)
}
out <- out %pm>%
subset(total >= minimum)
}
# regroup for summarising
if (isTRUE(has_syndromic_group)) {
colnames(out)[1] <- "syndromic_group"
@@ -409,9 +463,38 @@ antibiogram <- function(x,
out <- out %pm>%
pm_group_by(mo, ab)
}
out <- out %pm>%
pm_summarise(SI = numerator / total)
# formatting type:
# 1. 5
# 2. 15
# 3. 300
# 4. 15/300
# 5. 5 (300)
# 6. 5% (300)
# 7. 5 (N=300)
# 8. 5% (N=300)
# 9. 5 (15/300)
# 10. 5% (15/300)
# 11. 5 (N=15/300)
# 12. 5% (N=15/300)
out_numeric <- out %pm>%
pm_summarise(percentage = numerator / total,
numerator = numerator,
total = total)
out$digits <- digits # since pm_sumarise() cannot work with an object outside the current frame
if (formatting_type == 1) out <- out %pm>% pm_summarise(out_value = round((numerator / total) * 100, digits = digits))
if (formatting_type == 2) out <- out %pm>% pm_summarise(out_value = numerator)
if (formatting_type == 3) out <- out %pm>% pm_summarise(out_value = total)
if (formatting_type == 4) out <- out %pm>% pm_summarise(out_value = paste0(numerator, "/", total))
if (formatting_type == 5) out <- out %pm>% pm_summarise(out_value = paste0(round((numerator / total) * 100, digits = digits), " (", total, ")"))
if (formatting_type == 6) out <- out %pm>% pm_summarise(out_value = paste0(round((numerator / total) * 100, digits = digits), "% (", total, ")"))
if (formatting_type == 7) out <- out %pm>% pm_summarise(out_value = paste0(round((numerator / total) * 100, digits = digits), " (N=", total, ")"))
if (formatting_type == 8) out <- out %pm>% pm_summarise(out_value = paste0(round((numerator / total) * 100, digits = digits), "% (N=", total, ")"))
if (formatting_type == 9) out <- out %pm>% pm_summarise(out_value = paste0(round((numerator / total) * 100, digits = digits), " (", numerator, "/", total, ")"))
if (formatting_type == 10) out <- out %pm>% pm_summarise(out_value = paste0(round((numerator / total) * 100, digits = digits), "% (", numerator, "/", total, ")"))
if (formatting_type == 11) out <- out %pm>% pm_summarise(out_value = paste0(round((numerator / total) * 100, digits = digits), " (N=", numerator, "/", total, ")"))
if (formatting_type == 12) out <- out %pm>% pm_summarise(out_value = paste0(round((numerator / total) * 100, digits = digits), "% (N=", numerator, "/", total, ")"))
# transform names of antibiotics
ab_naming_function <- function(x, t, l, s) {
x <- strsplit(x, s, fixed = TRUE)
@@ -433,15 +516,15 @@ antibiogram <- function(x,
out
}
out$ab <- ab_naming_function(out$ab, t = ab_transform, l = language, s = sep)
out_numeric$ab <- ab_naming_function(out_numeric$ab, t = ab_transform, l = language, s = sep)
# transform long to wide
long_to_wide <- function(object, digs) {
object$SI <- round(object$SI * 100, digits = digs)
long_to_wide <- function(object) {
object <- object %pm>%
# an unclassed data.frame is required for stats::reshape()
as.data.frame(stringsAsFactors = FALSE) %pm>%
stats::reshape(direction = "wide", idvar = "mo", timevar = "ab", v.names = "SI")
colnames(object) <- gsub("^SI?[.]", "", colnames(object))
stats::reshape(direction = "wide", idvar = "mo", timevar = "ab", v.names = "out_value")
colnames(object) <- gsub("^out_value?[.]", "", colnames(object))
return(object)
}
@@ -449,18 +532,17 @@ antibiogram <- function(x,
attr(out, "pm_groups") <- NULL
attr(out, "groups") <- NULL
class(out) <- class(out)[!class(out) %in% c("grouped_df", "grouped_data")]
long <- out
if (isTRUE(has_syndromic_group)) {
grps <- unique(out$syndromic_group)
for (i in seq_len(length(grps))) {
grp <- grps[i]
if (i == 1) {
new_df <- long_to_wide(out[which(out$syndromic_group == grp), , drop = FALSE], digs = digits)
new_df <- long_to_wide(out[which(out$syndromic_group == grp), , drop = FALSE])
} else {
new_df <- rbind_AMR(
new_df,
long_to_wide(out[which(out$syndromic_group == grp), , drop = FALSE], digs = digits)
long_to_wide(out[which(out$syndromic_group == grp), , drop = FALSE])
)
}
}
@@ -470,7 +552,7 @@ antibiogram <- function(x,
new_df <- new_df[, c("syndromic_group", "mo", sort(colnames(new_df)[!colnames(new_df) %in% c("syndromic_group", "mo")])), drop = FALSE]
colnames(new_df)[1:2] <- translate_AMR(c("Syndromic Group", "Pathogen"), language = language)
} else {
new_df <- long_to_wide(out, digs = digits)
new_df <- long_to_wide(out)
# sort rows
new_df <- new_df %pm>% pm_arrange(mo)
# sort columns
@@ -510,15 +592,33 @@ antibiogram <- function(x,
rownames(out) <- NULL
structure(out,
has_syndromic_group = has_syndromic_group,
long = long,
out_numeric = out_numeric,
combine_SI = combine_SI
)
}
# will be exported in R/zzz.R
tbl_sum.antibiogram <- function(x, ...) {
dims <- paste(format(NROW(x), big.mark = ","), AMR_env$cross_icon, format(NCOL(x), big.mark = ","))
names(dims) <- "An Antibiogram"
dims
}
# will be exported in R/zzz.R
tbl_format_footer.antibiogram <- function(x, ...) {
footer <- NextMethod()
if (NROW(x) == 0) {
return(footer)
}
c(footer, font_subtle(paste0("# Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,\n",
"# or use it directly in R Markdown or ",
font_url("https://quarto.org", "Quarto"), ", see ", word_wrap("?antibiogram"))))
}
#' @export
#' @rdname antibiogram
plot.antibiogram <- function(x, ...) {
df <- attributes(x)$long
df <- attributes(x)$out_numeric
if ("syndromic_group" %in% colnames(df)) {
# barplot in base R does not support facets - paste columns together
df$mo <- paste(df$mo, "-", df$syndromic_group)
@@ -534,7 +634,7 @@ plot.antibiogram <- function(x, ...) {
df_sub <- df[df$mo == mo, , drop = FALSE]
barplot(
height = df_sub$SI * 100,
height = df_sub$percentage * 100,
xlab = NULL,
ylab = ifelse(isTRUE(attributes(x)$combine_SI), "%SI", "%S"),
names.arg = df_sub$ab,
@@ -557,12 +657,12 @@ barplot.antibiogram <- function(height, ...) {
#' @rdname antibiogram
# will be exported using s3_register() in R/zzz.R
autoplot.antibiogram <- function(object, ...) {
df <- attributes(object)$long
df <- attributes(object)$out_numeric
ggplot2::ggplot(df) +
ggplot2::geom_col(
ggplot2::aes(
x = ab,
y = SI * 100,
y = percentage * 100,
fill = if ("syndromic_group" %in% colnames(df)) {
syndromic_group
} else {
+15 -11
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -64,7 +64,7 @@
#' **N.B. This function requires an internet connection and only works if the following packages are installed: `curl`, `rvest`, `xml2`.**
#' @export
#' @rdname atc_online
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
#' @source <https://atcddd.fhi.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
#' @examples
#' \donttest{
#' if (requireNamespace("curl") && requireNamespace("rvest") && requireNamespace("xml2")) {
@@ -81,9 +81,9 @@
atc_online_property <- function(atc_code,
property,
administration = "O",
url = "https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no",
url_vet = "https://www.whocc.no/atcvet/atcvet_index/?code=%s&showdescription=no") {
meet_criteria(atc_code, allow_class = "character")
url = "https://atcddd.fhi.no/atc_ddd_index/?code=%s&showdescription=no",
url_vet = "https://atcddd.fhi.no/atcvet/atcvet_index/?code=%s&showdescription=no") {
meet_criteria(atc_code, allow_class = "character", allow_NA = TRUE)
meet_criteria(property, allow_class = "character", has_length = 1, is_in = c("ATC", "Name", "DDD", "U", "unit", "Adm.R", "Note", "groups"), ignore.case = TRUE)
meet_criteria(administration, allow_class = "character", has_length = 1)
meet_criteria(url, allow_class = "character", has_length = 1, looks_like = "https?://")
@@ -128,6 +128,10 @@ atc_online_property <- function(atc_code,
for (i in seq_len(length(atc_code))) {
progress$tick()
if (is.na(atc_code[i])) {
next
}
if (atc_code[i] %like% "^Q") {
# veterinary drugs, ATC_vet codes start with a "Q"
@@ -176,7 +180,7 @@ atc_online_property <- function(atc_code,
colnames(out) <- gsub("^atc.*", "atc", tolower(colnames(out)))
if (length(out) == 0) {
warning_("in `atc_online_property()`: ATC not found: ", atc_code[i], ". Please check ", atc_url, ".")
message_("in `atc_online_property()`: no properties found for ATC ", atc_code[i], ". Please check ", font_url(atc_url, "this WHOCC webpage"), ".")
returnvalue[i] <- NA
next
}
@@ -209,20 +213,20 @@ atc_online_property <- function(atc_code,
#' @rdname atc_online
#' @export
atc_online_groups <- function(atc_code, ...) {
meet_criteria(atc_code, allow_class = "character")
meet_criteria(atc_code, allow_class = "character", allow_NA = TRUE)
atc_online_property(atc_code = atc_code, property = "groups", ...)
}
#' @rdname atc_online
#' @export
atc_online_ddd <- function(atc_code, ...) {
meet_criteria(atc_code, allow_class = "character")
meet_criteria(atc_code, allow_class = "character", allow_NA = TRUE)
atc_online_property(atc_code = atc_code, property = "ddd", ...)
}
#' @rdname atc_online
#' @export
atc_online_ddd_units <- function(atc_code, ...) {
meet_criteria(atc_code, allow_class = "character")
meet_criteria(atc_code, allow_class = "character", allow_NA = TRUE)
atc_online_property(atc_code = atc_code, property = "unit", ...)
}
+4 -4
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -49,7 +49,7 @@
#'
#' Note: the [as.av()] and [`av_*`][av_property()] functions may use very long regular expression to match brand names of antimicrobial drugs. This may fail on some systems.
#' @section Source:
#' World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/}
#' World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://atcddd.fhi.no/atc_ddd_index/}
#'
#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm}
#' @aliases av
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+7 -7
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -33,7 +33,7 @@
#' @param x any (vector of) text that can be coerced to a valid antiviral drug code with [as.av()]
#' @param tolower a [logical] to indicate whether the first [character] of every output should be transformed to a lower case [character].
#' @param property one of the column names of one of the [antivirals] data set: `vector_or(colnames(antivirals), sort = FALSE)`.
#' @param language language of the returned text - the default is system language (see [get_AMR_locale()]) and can also be set with the [package option][AMR-options] [`AMR_locale`][AMR-options]. Use `language = NULL` or `language = ""` to prevent translation.
#' @param language language of the returned text - the default is system language (see [get_AMR_locale()]) and can also be set with the package option [`AMR_locale`][AMR-options]. Use `language = NULL` or `language = ""` to prevent translation.
#' @param administration way of administration, either `"oral"` or `"iv"`
#' @param open browse the URL using [utils::browseURL()]
#' @param ... other arguments passed on to [as.av()]
@@ -164,7 +164,7 @@ av_ddd <- function(x, administration = "oral", ...) {
warning_(
"in `av_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/"
"atcddd.fhi.no/ddd/list_of_ddds_combined_products/"
)
}
out
@@ -184,7 +184,7 @@ av_ddd_units <- function(x, administration = "oral", ...) {
warning_(
"in `av_ddd_units()`: 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/"
"atcddd.fhi.no/ddd/list_of_ddds_combined_products/"
)
}
out
@@ -227,7 +227,7 @@ av_url <- function(x, open = FALSE, ...) {
av <- as.av(x = x, ...)
atcs <- av_atc(av, only_first = TRUE)
u <- paste0("https://www.whocc.no/atc_ddd_index/?code=", atcs, "&showdescription=no")
u <- paste0("https://atcddd.fhi.no/atc_ddd_index/?code=", atcs, "&showdescription=no")
u[is.na(atcs)] <- NA_character_
names(u) <- av_name(av)
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+19 -11
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -31,7 +31,7 @@
#'
#' Determine antimicrobial resistance (AMR) of all bug-drug combinations in your data set where at least 30 (default) isolates are available per species. Use [format()] on the result to prettify it to a publishable/printable format, see *Examples*.
#' @inheritParams eucast_rules
#' @param combine_SI a [logical] to indicate whether values S and I should be summed, so resistance will be based on only R - the default is `TRUE`
#' @param combine_SI a [logical] to indicate whether values S, SDD, and I should be summed, so resistance will be based on only R - the default is `TRUE`
#' @param add_ab_group a [logical] to indicate where the group of the antimicrobials must be included as a first column
#' @param remove_intrinsic_resistant [logical] to indicate that rows and columns with 100% resistance for all tested antimicrobials must be removed from the table
#' @param FUN the function to call on the `mo` column to transform the microorganism codes - the default is [mo_shortname()]
@@ -42,7 +42,7 @@
#' @details The function [format()] calculates the resistance per bug-drug combination and returns a table ready for reporting/publishing. Use `combine_SI = TRUE` (default) to test R vs. S+I and `combine_SI = FALSE` to test R+I vs. S. This table can also directly be used in R Markdown / Quarto without the need for e.g. [knitr::kable()].
#' @export
#' @rdname bug_drug_combinations
#' @return The function [bug_drug_combinations()] returns a [data.frame] with columns "mo", "ab", "S", "I", "R" and "total".
#' @return The function [bug_drug_combinations()] returns a [data.frame] with columns "mo", "ab", "S", "SDD", "I", "R", and "total".
#' @examples
#' # example_isolates is a data set available in the AMR package.
#' # run ?example_isolates for more info.
@@ -71,7 +71,8 @@ bug_drug_combinations <- function(x,
col_mo = NULL,
FUN = mo_shortname,
...) {
meet_criteria(x, allow_class = "data.frame", contains_column_class = c("sir", "rsi"))
meet_criteria(x, allow_class = "data.frame")
x <- ascertain_sir_classes(x, "x")
meet_criteria(col_mo, allow_class = "character", is_in = colnames(x), has_length = 1, allow_NULL = TRUE)
meet_criteria(FUN, allow_class = "function", has_length = 1)
@@ -105,6 +106,7 @@ bug_drug_combinations <- function(x,
mo = character(0),
ab = character(0),
S = integer(0),
SDD = integer(0),
I = integer(0),
R = integer(0),
total = integer(0),
@@ -121,17 +123,19 @@ bug_drug_combinations <- function(x,
x_mo_filter <- x[which(x[, col_mo, drop = TRUE] == unique_mo[i]), names(which(vapply(FUN.VALUE = logical(1), x, is.sir))), drop = FALSE]
# turn and merge everything
pivot <- lapply(x_mo_filter, function(x) {
m <- as.matrix(table(x))
data.frame(S = m["S", ], I = m["I", ], R = m["R", ], stringsAsFactors = FALSE)
m <- as.matrix(table(as.sir(x)))
data.frame(S = m["S", ], SDD = m["SDD", ], I = m["I", ], R = m["R", ], NI = m["NI", ], stringsAsFactors = FALSE)
})
merged <- do.call(rbind_AMR, pivot)
out_group <- data.frame(
mo = rep(unique_mo[i], NROW(merged)),
ab = rownames(merged),
S = merged$S,
SDD = merged$SDD,
I = merged$I,
R = merged$R,
total = merged$S + merged$I + merged$R,
NI = merged$NI,
total = merged$S + merged$SDD + merged$I + merged$R + merged$NI,
stringsAsFactors = FALSE
)
if (data_has_groups) {
@@ -203,12 +207,16 @@ format.bug_drug_combinations <- function(x,
mo = gsub("(.*)%%(.*)", "\\1", names(idx)),
ab = gsub("(.*)%%(.*)", "\\2", names(idx)),
S = vapply(FUN.VALUE = double(1), idx, function(i) sum(x$S[i], na.rm = TRUE)),
SDD = vapply(FUN.VALUE = double(1), idx, function(i) sum(x$SDD[i], na.rm = TRUE)),
I = vapply(FUN.VALUE = double(1), idx, function(i) sum(x$I[i], na.rm = TRUE)),
R = vapply(FUN.VALUE = double(1), idx, function(i) sum(x$R[i], na.rm = TRUE)),
NI = vapply(FUN.VALUE = double(1), idx, function(i) sum(x$NI[i], na.rm = TRUE)),
total = vapply(FUN.VALUE = double(1), idx, function(i) {
sum(x$S[i], na.rm = TRUE) +
sum(x$SDD[i], na.rm = TRUE) +
sum(x$I[i], na.rm = TRUE) +
sum(x$R[i], na.rm = TRUE)
sum(x$R[i], na.rm = TRUE) +
sum(x$NI[i], na.rm = TRUE)
}),
stringsAsFactors = FALSE
)
@@ -223,7 +231,7 @@ format.bug_drug_combinations <- function(x,
if (combine_SI == TRUE) {
x$isolates <- x$R
} else {
x$isolates <- x$R + x$I
x$isolates <- x$R + x$I + x$SDD
}
give_ab_name <- function(ab, format, language) {
+67 -61
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -135,62 +135,7 @@ count_resistant <- function(..., only_all_tested = FALSE) {
count_susceptible <- function(..., only_all_tested = FALSE) {
tryCatch(
sir_calc(...,
ab_result = c("S", "I"),
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
}
#' @rdname count
#' @export
count_R <- function(..., only_all_tested = FALSE) {
tryCatch(
sir_calc(...,
ab_result = "R",
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
}
#' @rdname count
#' @export
count_IR <- function(..., only_all_tested = FALSE) {
if (message_not_thrown_before("count_IR", entire_session = TRUE)) {
message_("Using `count_IR()` is discouraged; use `count_resistant()` instead to not consider \"I\" being resistant. This note will be shown once for this session.", as_note = FALSE)
}
tryCatch(
sir_calc(...,
ab_result = c("I", "R"),
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
}
#' @rdname count
#' @export
count_I <- function(..., only_all_tested = FALSE) {
tryCatch(
sir_calc(...,
ab_result = "I",
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
}
#' @rdname count
#' @export
count_SI <- function(..., only_all_tested = FALSE) {
tryCatch(
sir_calc(...,
ab_result = c("S", "I"),
ab_result = c("S", "SDD", "I"),
only_all_tested = only_all_tested,
only_count = TRUE
),
@@ -202,7 +147,7 @@ count_SI <- function(..., only_all_tested = FALSE) {
#' @export
count_S <- function(..., only_all_tested = FALSE) {
if (message_not_thrown_before("count_S", entire_session = TRUE)) {
message_("Using `count_S()` is discouraged; use `count_susceptible()` instead to also consider \"I\" being susceptible. This note will be shown once for this session.", as_note = FALSE)
message_("Using `count_S()` is discouraged; use `count_susceptible()` instead to also consider \"I\" and \"SDD\" being susceptible. This note will be shown once for this session.", as_note = FALSE)
}
tryCatch(
sir_calc(...,
@@ -214,12 +159,73 @@ count_S <- function(..., only_all_tested = FALSE) {
)
}
#' @rdname count
#' @export
count_SI <- function(..., only_all_tested = FALSE) {
if (message_not_thrown_before("count_SI", entire_session = TRUE)) {
message_("Note that `count_SI()` will also count dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE)
}
tryCatch(
sir_calc(...,
ab_result = c("S", "SDD", "I"),
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
}
#' @rdname count
#' @export
count_I <- function(..., only_all_tested = FALSE) {
if (message_not_thrown_before("count_I", entire_session = TRUE)) {
message_("Note that `count_I()` will also count dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE)
}
tryCatch(
sir_calc(...,
ab_result = c("I", "SDD"),
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
}
#' @rdname count
#' @export
count_IR <- function(..., only_all_tested = FALSE) {
if (message_not_thrown_before("count_IR", entire_session = TRUE)) {
message_("Using `count_IR()` is discouraged; use `count_resistant()` instead to not consider \"I\" and \"SDD\" being resistant. This note will be shown once for this session.", as_note = FALSE)
}
tryCatch(
sir_calc(...,
ab_result = c("I", "SDD", "R"),
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
}
#' @rdname count
#' @export
count_R <- function(..., only_all_tested = FALSE) {
tryCatch(
sir_calc(...,
ab_result = "R",
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
}
#' @rdname count
#' @export
count_all <- function(..., only_all_tested = FALSE) {
tryCatch(
sir_calc(...,
ab_result = c("S", "I", "R"),
ab_result = c("S", "SDD", "I", "R", "NI"),
only_all_tested = only_all_tested,
only_count = TRUE
),
+6 -6
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -35,11 +35,11 @@
#'
#' There are two ways to circumvent this and automate the process of adding antimicrobials:
#'
#' **Method 1:** Using the [package option][AMR-options] [`AMR_custom_ab`][AMR-options], which is the preferred method. To use this method:
#' **Method 1:** Using the package option [`AMR_custom_ab`][AMR-options], which is the preferred method. To use this method:
#'
#' 1. Create a data set in the structure of the [antibiotics] data set (containing at the very least columns "ab" and "name") and save it with [saveRDS()] to a location of choice, e.g. `"~/my_custom_ab.rds"`, or any remote location.
#'
#' 2. Set the file location to the [package option][AMR-options] [`AMR_custom_ab`][AMR-options]: `options(AMR_custom_ab = "~/my_custom_ab.rds")`. This can even be a remote file location, such as an https URL. Since options are not saved between \R sessions, it is best to save this option to the `.Rprofile` file so that it will be loaded on start-up of \R. To do this, open the `.Rprofile` file using e.g. `utils::file.edit("~/.Rprofile")`, add this text and save the file:
#' 2. Set the file location to the package option [`AMR_custom_ab`][AMR-options]: `options(AMR_custom_ab = "~/my_custom_ab.rds")`. This can even be a remote file location, such as an https URL. Since options are not saved between \R sessions, it is best to save this option to the `.Rprofile` file so that it will be loaded on start-up of \R. To do this, open the `.Rprofile` file using e.g. `utils::file.edit("~/.Rprofile")`, add this text and save the file:
#'
#' ```r
#' # Add custom antimicrobial codes:
@@ -96,7 +96,7 @@
#'
#'
#' # Add Co-fluampicil, which is one of the many J01CR50 codes, see
#' # https://www.whocc.no/ddd/list_of_ddds_combined_products/
#' # https://atcddd.fhi.no/ddd/list_of_ddds_combined_products/
#' add_custom_antimicrobials(
#' data.frame(
#' ab = "COFLU",
+49 -26
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -30,7 +30,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][base::tilde] notation, see *Examples*
#' @param ... rules in [formula][base::tilde] notation, see below for instructions, and in *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:
@@ -89,11 +89,24 @@
#' #> 2 Klebsiella pneumoniae R R S
#' ```
#'
#' ### Usage of antibiotic group names
#' ### Usage of multiple antibiotics and antibiotic group names
#'
#' You can define antibiotic groups instead of single antibiotics for the rule consequence, which is the part *after* the tilde (~). In the examples above, the antibiotic group `aminopenicillins` includes both ampicillin and amoxicillin.
#'
#' Rules can also be applied to multiple antibiotics and antibiotic groups simultaneously. Use the `c()` function to combine multiple antibiotics. For instance, the following example sets all aminopenicillins and ureidopenicillins to "R" if column TZP (piperacillin/tazobactam) is "R":
#'
#' ```r
#' x <- custom_eucast_rules(TZP == "R" ~ c(aminopenicillins, ureidopenicillins) == "R")
#' x
#' #> A set of custom EUCAST rules:
#' #>
#' #> 1. If TZP is "R" then set to "R":
#' #> amoxicillin (AMX), ampicillin (AMP), azlocillin (AZL), mezlocillin (MEZ), piperacillin (PIP), piperacillin/tazobactam (TZP)
#' ```
#'
#' It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part *after* the tilde. In above examples, the antibiotic group `aminopenicillins` is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the drugs that will be matched when running the rule.
#' These `r length(DEFINED_AB_GROUPS)` antibiotic groups are allowed in the rules (case-insensitive) and can be used in any combination:
#'
#' `r paste0(" * ", sapply(DEFINED_AB_GROUPS, function(x) paste0("\"", tolower(gsub("^AB_", "", x)), "\"\\cr(", vector_and(ab_name(eval(parse(text = x), envir = asNamespace("AMR")), language = NULL, tolower = TRUE), quotes = FALSE), ")"), USE.NAMES = FALSE), "\n", collapse = "")`
#' `r paste0(" * ", sapply(DEFINED_AB_GROUPS, function(x) paste0(tolower(gsub("^AB_", "", x)), "\\cr(", vector_and(ab_name(eval(parse(text = x), envir = asNamespace("AMR")), language = NULL, tolower = TRUE), quotes = FALSE), ")"), USE.NAMES = FALSE), "\n", collapse = "")`
#' @returns A [list] containing the custom rules
#' @export
#' @examples
@@ -156,24 +169,34 @@ custom_eucast_rules <- function(...) {
"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'
result_group <- paste0(result_group, "s")
result_group<- as.character(str2lang(result_group))
result_group <- result_group[result_group != "c"]
result_group_agents <- character(0)
for (j in seq_len(length(result_group))) {
if (paste0("AB_", toupper(result_group[j]), "S") %in% DEFINED_AB_GROUPS) {
# support for e.g. 'aminopenicillin' if user meant 'aminopenicillins'
result_group[j] <- paste0(result_group[j], "s")
}
if (paste0("AB_", toupper(result_group[j])) %in% DEFINED_AB_GROUPS) {
result_group_agents <- c(result_group_agents,
eval(parse(text = paste0("AB_", toupper(result_group[j]))), envir = asNamespace("AMR")))
} else {
out_group <- tryCatch(
suppressWarnings(as.ab(result_group[j],
fast_mode = TRUE,
flag_multiple_results = FALSE
)),
error = function(e) NA_character_
)
if (!all(is.na(out_group))) {
result_group_agents <- c(result_group_agents, out_group)
}
}
}
if (paste0("AB_", toupper(result_group)) %in% DEFINED_AB_GROUPS) {
result_group <- eval(parse(text = paste0("AB_", toupper(result_group))), envir = asNamespace("AMR"))
} else {
result_group <- tryCatch(
suppressWarnings(as.ab(result_group,
fast_mode = TRUE,
flag_multiple_results = FALSE
)),
error = function(e) NA_character_
)
}
result_group_agents <- result_group_agents[!is.na(result_group_agents)]
stop_if(
any(is.na(result_group)),
length(result_group_agents) == 0,
"this result of rule ", i, " could not be translated to a single antimicrobial drug/group: \"",
as.character(result)[[2]], "\".\n\nThe input can be a name or code of an antimicrobial drug, or be one of: ",
vector_or(tolower(gsub("AB_", "", DEFINED_AB_GROUPS)), quotes = FALSE), "."
@@ -181,12 +204,12 @@ custom_eucast_rules <- function(...) {
result_value <- as.character(result)[[3]]
result_value[result_value == "NA"] <- NA
stop_ifnot(
result_value %in% c("S", "I", "R", NA),
"the resulting value of rule ", i, " must be either \"S\", \"I\", \"R\" or NA"
result_value %in% c("S", "SDD", "I", "R", "NI", NA),
"the resulting value of rule ", i, " must be either \"S\", \"SDD\", \"I\", \"R\", \"NI\" or NA"
)
result_value <- as.sir(result_value)
out[[i]]$result_group <- result_group
out[[i]]$result_group <- result_group_agents
out[[i]]$result_value <- result_value
}
+5 -5
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -37,11 +37,11 @@
#'
#' There are two ways to circumvent this and automate the process of adding microorganisms:
#'
#' **Method 1:** Using the [package option][AMR-options] [`AMR_custom_mo`][AMR-options], which is the preferred method. To use this method:
#' **Method 1:** Using the package option [`AMR_custom_mo`][AMR-options], which is the preferred method. To use this method:
#'
#' 1. Create a data set in the structure of the [microorganisms] data set (containing at the very least column "genus") and save it with [saveRDS()] to a location of choice, e.g. `"~/my_custom_mo.rds"`, or any remote location.
#'
#' 2. Set the file location to the [package option][AMR-options] [`AMR_custom_mo`][AMR-options]: `options(AMR_custom_mo = "~/my_custom_mo.rds")`. This can even be a remote file location, such as an https URL. Since options are not saved between \R sessions, it is best to save this option to the `.Rprofile` file so that it will be loaded on start-up of \R. To do this, open the `.Rprofile` file using e.g. `utils::file.edit("~/.Rprofile")`, add this text and save the file:
#' 2. Set the file location to the package option [`AMR_custom_mo`][AMR-options]: `options(AMR_custom_mo = "~/my_custom_mo.rds")`. This can even be a remote file location, such as an https URL. Since options are not saved between \R sessions, it is best to save this option to the `.Rprofile` file so that it will be loaded on start-up of \R. To do this, open the `.Rprofile` file using e.g. `utils::file.edit("~/.Rprofile")`, add this text and save the file:
#'
#' ```r
#' # Add custom microorganism codes:
+71 -50
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -32,9 +32,9 @@
#' 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 [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. *This is a unique identifier.*
#' - `cid`\cr Compound ID as found in PubChem. *This is a unique identifier.*
#' - `name`\cr Official name as used by WHONET/EARS-Net or the WHO. *This is a unique identifier.*
#' - `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. ***This is a unique identifier.***
#' - `cid`\cr Compound ID as found in PubChem. ***This is a unique identifier.***
#' - `name`\cr Official name as used by WHONET/EARS-Net or the WHO. ***This is a unique identifier.***
#' - `group`\cr A short and concise group name, based on WHONET and WHOCC definitions
#' - `atc`\cr ATC codes (Anatomical Therapeutic Chemical) as defined by the WHOCC, like `J01CR02`
#' - `atc_group1`\cr Official pharmacological subgroup (3rd level ATC code) as defined by the WHOCC, like `"Macrolides, lincosamides and streptogramins"`
@@ -48,10 +48,10 @@
#' - `loinc`\cr All codes associated with the name of the antimicrobial drug from `r TAXONOMY_VERSION$LOINC$citation` Use [ab_loinc()] to retrieve them quickly, see [ab_property()].
#'
#' ### For the [antivirals] data set: a [tibble][tibble::tibble] with `r nrow(antivirals)` observations and `r ncol(antivirals)` variables:
#' - `av`\cr Antiviral ID as used in this package (such as `ACI`), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available. *This is a unique identifier.* Combinations are codes that contain a `+` to indicate this, such as `ATA+COBI` for atazanavir/cobicistat.
#' - `name`\cr Official name as used by WHONET/EARS-Net or the WHO. *This is a unique identifier.*
#' - `av`\cr Antiviral ID as used in this package (such as `ACI`), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available. ***This is a unique identifier.*** Combinations are codes that contain a `+` to indicate this, such as `ATA+COBI` for atazanavir/cobicistat.
#' - `name`\cr Official name as used by WHONET/EARS-Net or the WHO. ***This is a unique identifier.***
#' - `atc`\cr ATC codes (Anatomical Therapeutic Chemical) as defined by the WHOCC
#' - `cid`\cr Compound ID as found in PubChem. *This is a unique identifier.*
#' - `cid`\cr Compound ID as found in PubChem. ***This is a unique identifier.***
#' - `atc_group`\cr Official pharmacological subgroup (3rd level ATC code) as defined by the WHOCC
#' - `synonyms`\cr Synonyms (often trade names) of a drug, as found in PubChem based on their compound ID
#' - `oral_ddd`\cr Defined Daily Dose (DDD), oral treatment
@@ -64,10 +64,10 @@
#' Synonyms (i.e. trade names) were derived from the PubChem Compound ID (column `cid`) and consequently only available where a CID is available.
#'
#' ### Direct download
#' 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).
#' 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, 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/>
#' * World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): <https://atcddd.fhi.no/atc_ddd_index/>
#'
#' * `r TAXONOMY_VERSION$LOINC$citation` Accessed from <`r TAXONOMY_VERSION$LOINC$url`> on `r documentation_date(TAXONOMY_VERSION$LOINC$accessed_date)`.
#'
@@ -82,35 +82,41 @@
#' @rdname antibiotics
"antivirals"
#' Data Set with `r format(nrow(microorganisms), big.mark = " ")` Microorganisms
#' Data Set with `r format(nrow(microorganisms), big.mark = " ")` Taxonomic Records of Microorganisms
#'
#' A data set containing the full microbial taxonomy (**last updated: `r documentation_date(max(TAXONOMY_VERSION$GBIF$accessed_date, TAXONOMY_VERSION$LPSN$accessed_date))`**) of `r nr2char(length(unique(microorganisms$kingdom[!microorganisms$kingdom %like% "unknown"])))` kingdoms from the List of Prokaryotic names with Standing in Nomenclature (LPSN) and the Global Biodiversity Information Facility (GBIF). This data set is the backbone of this `AMR` package. MO codes can be looked up using [as.mo()].
#' @description
#' A data set containing the full microbial taxonomy (**last updated: `r documentation_date(max(TAXONOMY_VERSION$GBIF$accessed_date, TAXONOMY_VERSION$LPSN$accessed_date, TAXONOMY_VERSION$MycoBank$accessed_date))`**) of `r nr2char(length(unique(microorganisms$kingdom[!microorganisms$kingdom %like% "unknown"])))` kingdoms. This data set is the backbone of this `AMR` package. MO codes can be looked up using [as.mo()] and microorganism properties can be looked up using any of the [`mo_*`][mo_property()] functions.
#'
#' This data set is carefully crafted, yet made 100% reproducible from public and authoritative taxonomic sources (using [this script](https://github.com/msberends/AMR/blob/main/data-raw/reproduction_of_microorganisms.R)), namely: *`r TAXONOMY_VERSION$LPSN$name`* for bacteria, *`r TAXONOMY_VERSION$MycoBank$name`* for fungi, and *`r TAXONOMY_VERSION$GBIF$name`* for all others taxons.
#' @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. *This is a unique identifier.*
#' - `fullname`\cr Full name, like `"Escherichia coli"`. For the taxonomic ranks genus, species and subspecies, this is the 'pasted' text of genus, species, and subspecies. For all taxonomic ranks higher than genus, this is the name of the taxon. *This is a unique identifier.*
#' - `mo`\cr ID of microorganism as used by this package. ***This is a unique identifier.***
#' - `fullname`\cr Full name, like `"Escherichia coli"`. For the taxonomic ranks genus, species and subspecies, this is the 'pasted' text of genus, species, and subspecies. For all taxonomic ranks higher than genus, this is the name of the taxon. ***This is a unique identifier.***
#' - `status` \cr Status of the taxon, either `r vector_or(microorganisms$status)`
#' - `kingdom`, `phylum`, `class`, `order`, `family`, `genus`, `species`, `subspecies`\cr Taxonomic rank of the microorganism
#' - `kingdom`, `phylum`, `class`, `order`, `family`, `genus`, `species`, `subspecies`\cr Taxonomic rank of the microorganism. Note that for fungi, *phylum* is equal to their taxonomic *division*. Also, for fungi, *subkingdom* and *subdivision* were left out since they do not occur in the bacterial taxonomy.
#' - `rank`\cr Text of the taxonomic rank of the microorganism, such as `"species"` or `"genus"`
#' - `ref`\cr Author(s) and year of related scientific publication. This contains only the *first surname* and year of the *latest* authors, e.g. "Wallis *et al.* 2006 *emend.* Smith and Jones 2018" becomes "Smith *et al.*, 2018". This field is directly retrieved from the source specified in the column `source`. Moreover, accents were removed to comply with CRAN that only allows ASCII characters.
#' - `lpsn`\cr Identifier ('Record number') of the List of Prokaryotic names with Standing in Nomenclature (LPSN). This will be the first/highest LPSN identifier to keep one identifier per row. For example, *Acetobacter ascendens* has LPSN Record number 7864 and 11011. Only the first is available in the `microorganisms` data set.
#' - `oxygen_tolerance` \cr Oxygen tolerance, either `r vector_or(microorganisms$oxygen_tolerance)`. These data were retrieved from BacDive (see *Source*). Items that contain "likely" are missing from BacDive and were extrapolated from other species within the same genus to guess the oxygen tolerance. Currently `r round(length(microorganisms$oxygen_tolerance[which(!is.na(microorganisms$oxygen_tolerance))]) / nrow(microorganisms[which(microorganisms$kingdom == "Bacteria"), ]) * 100, 1)`% of all `r format_included_data_number(nrow(microorganisms[which(microorganisms$kingdom == "Bacteria"), ]))` bacteria in the data set contain an oxygen tolerance.
#' - `source`\cr Either `r vector_or(microorganisms$source)` (see *Source*)
#' - `lpsn`\cr Identifier ('Record number') of `r TAXONOMY_VERSION$LPSN$name`. This will be the first/highest LPSN identifier to keep one identifier per row. For example, *Acetobacter ascendens* has LPSN Record number 7864 and 11011. Only the first is available in the `microorganisms` data set. ***This is a unique identifier***, though available for only `r format_included_data_number(sum(!is.na(microorganisms$lpsn)))` records.
#' - `lpsn_parent`\cr LPSN identifier of the parent taxon
#' - `lpsn_renamed_to`\cr LPSN identifier of the currently valid taxon
#' - `gbif`\cr Identifier ('taxonID') of the Global Biodiversity Information Facility (GBIF)
#' - `mycobank`\cr Identifier ('MycoBank #') of `r TAXONOMY_VERSION$MycoBank$name`. ***This is a unique identifier***, though available for only `r format_included_data_number(sum(!is.na(microorganisms$mycobank)))` records.
#' - `mycobank_parent`\cr MycoBank identifier of the parent taxon
#' - `mycobank_renamed_to`\cr MycoBank identifier of the currently valid taxon
#' - `gbif`\cr Identifier ('taxonID') of `r TAXONOMY_VERSION$GBIF$name`. ***This is a unique identifier***, though available for only `r format_included_data_number(sum(!is.na(microorganisms$gbif)))` records.
#' - `gbif_parent`\cr GBIF identifier of the parent taxon
#' - `gbif_renamed_to`\cr GBIF identifier of the currently valid taxon
#' - `source`\cr Either `r vector_or(microorganisms$source)` (see *Source*)
#' - `prevalence`\cr Prevalence of the microorganism according to Bartlett *et al.* (2022, \doi{10.1099/mic.0.001269}), see [mo_matching_score()] for the full explanation
#' - `prevalence`\cr Prevalence of the microorganism based on Bartlett *et al.* (2022, \doi{10.1099/mic.0.001269}), see [mo_matching_score()] for the full explanation
#' - `snomed`\cr Systematized Nomenclature of Medicine (SNOMED) code of the microorganism, version of `r documentation_date(TAXONOMY_VERSION$SNOMED$accessed_date)` (see *Source*). Use [mo_snomed()] to retrieve it quickly, see [mo_property()].
#' @details
#' Please note that entries are only based on the List of Prokaryotic names with Standing in Nomenclature (LPSN) and the Global Biodiversity Information Facility (GBIF) (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect.
#' Please note that entries are only based on LPSN, MycoBank, and GBIF (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect.
#'
#' For example, *Staphylococcus pettenkoferi* was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the `AMR` package returns 2007 for `mo_year("S. pettenkoferi")`.
#' For example, *Staphylococcus pettenkoferi* was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not until 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the `AMR` package returns 2007 for `mo_year("S. pettenkoferi")`.
#'
#' @section Included Taxa:
#' Included taxonomic data are:
#' Included taxonomic data from [LPSN](`r TAXONOMY_VERSION$LPSN$url`), [MycoBank](`r TAXONOMY_VERSION$MycoBank$url`), and [GBIF](`r TAXONOMY_VERSION$GBIF$url`) are:
#' - All `r format_included_data_number(microorganisms[which(microorganisms$kingdom %in% c("Archeae", "Bacteria")), , drop = FALSE])` (sub)species from the kingdoms of Archaea and Bacteria
#' - `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Fungi"), , drop = FALSE])` (sub)species from the kingdom of Fungi. 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. Only relevant fungi are covered (such as all species of *Aspergillus*, *Candida*, *Cryptococcus*, *Histoplasma*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*).
#' - `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Fungi"), , drop = FALSE])` species from the kingdom of Fungi. 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. Only relevant fungi are covered (such as all species of *Aspergillus*, *Candida*, *Cryptococcus*, *Histoplasma*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*).
#' - `r format_included_data_number(microorganisms[which(microorganisms$kingdom == "Protozoa"), , drop = FALSE])` (sub)species from the kingdom of Protozoa
#' - `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[which(microorganisms$status != "accepted"), , drop = FALSE])` previously accepted names of all included (sub)species (these were taxonomically renamed)
@@ -127,22 +133,28 @@
#' - 1 entry of *Moraxella* (*M. catarrhalis*), which was formally named *Branhamella catarrhalis* (Catlin, 1970) though this change was never accepted within the field of clinical microbiology
#' - 8 other 'undefined' entries (unknown, unknown Gram-negatives, unknown Gram-positives, unknown yeast, unknown fungus, and unknown anaerobic Gram-pos/Gram-neg bacteria)
#'
#' The syntax used to transform the original data to a cleansed \R format, can be found here: <https://github.com/msberends/AMR/blob/main/data-raw/reproduction_of_microorganisms.R>.
#' The syntax used to transform the original data to a cleansed \R format, can be [found here](https://github.com/msberends/AMR/blob/main/data-raw/reproduction_of_microorganisms.R).
#'
#' ### 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).
#' @section About the Records from LPSN (see *Source*):
#' LPSN is the main source for bacteriological taxonomy of this `AMR` package.
#'
#' 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.
#' 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, 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
#' * `r TAXONOMY_VERSION$LPSN$citation` Accessed from <`r TAXONOMY_VERSION$LPSN$url`> on `r documentation_date(TAXONOMY_VERSION$LPSN$accessed_date)`.
#'
#' * `r TAXONOMY_VERSION$GBIF$citation` Accessed from <`r TAXONOMY_VERSION$GBIF$url`> on `r documentation_date(TAXONOMY_VERSION$GBIF$accessed_date)`.
#'
#' * `r TAXONOMY_VERSION$BacDive$citation` Accessed from <`r TAXONOMY_VERSION$BacDive$url`> on `r documentation_date(TAXONOMY_VERSION$BacDive$accessed_date)`.
#' Taxonomic entries were imported in this order of importance:
#' 1. `r TAXONOMY_VERSION$LPSN$name`:\cr\cr
#' `r TAXONOMY_VERSION$LPSN$citation` Accessed from <`r TAXONOMY_VERSION$LPSN$url`> on `r documentation_date(TAXONOMY_VERSION$LPSN$accessed_date)`.
#'
#' * `r TAXONOMY_VERSION$SNOMED$citation` URL: <`r TAXONOMY_VERSION$SNOMED$url`>
#' 2. `r TAXONOMY_VERSION$MycoBank$name`:\cr\cr
#' `r TAXONOMY_VERSION$MycoBank$citation` Accessed from <`r TAXONOMY_VERSION$MycoBank$url`> on `r documentation_date(TAXONOMY_VERSION$MycoBank$accessed_date)`.
#'
#' 3. `r TAXONOMY_VERSION$GBIF$name`:\cr\cr
#' `r TAXONOMY_VERSION$GBIF$citation` Accessed from <`r TAXONOMY_VERSION$GBIF$url`> on `r documentation_date(TAXONOMY_VERSION$GBIF$accessed_date)`.
#'
#' Furthermore, these sources were used for additional details:
#'
#' * `r TAXONOMY_VERSION$BacDive$name`:\cr\cr
#' `r TAXONOMY_VERSION$BacDive$citation` Accessed from <`r TAXONOMY_VERSION$BacDive$url`> on `r documentation_date(TAXONOMY_VERSION$BacDive$accessed_date)`.
#'
#' * `r TAXONOMY_VERSION$SNOMED$name`:\cr\cr
#' `r TAXONOMY_VERSION$SNOMED$citation` Accessed from <`r TAXONOMY_VERSION$SNOMED$url`> on `r documentation_date(TAXONOMY_VERSION$SNOMED$accessed_date)`.
#'
#' * Grimont *et al.* (2007). Antigenic Formulae of the Salmonella Serovars, 9th Edition. WHO Collaborating Centre for Reference and Research on *Salmonella* (WHOCC-SALM).
#'
@@ -156,10 +168,10 @@
#'
#' A data set containing commonly used codes for microorganisms, from laboratory systems and [WHONET](https://whonet.org). 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 [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. *This is a unique identifier.*
#' - `code`\cr Commonly used code of a microorganism. ***This is a unique identifier.***
#' - `mo`\cr ID of the microorganism in the [microorganisms] data set
#' @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).
#' 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, 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).
#' @seealso [as.mo()] [microorganisms]
#' @examples
#' microorganisms.codes
@@ -183,7 +195,7 @@
#' - `mo_group_name`\cr Name of the species group / microbiological complex, as retrieved with [mo_name()]
#' - `mo_name`\cr Name of the microorganism belonging in the species group / microbiological complex, as retrieved with [mo_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).
#' 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, 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).
#' @seealso [as.mo()] [microorganisms]
#' @examples
#' microorganisms.groups
@@ -204,7 +216,7 @@
#' - `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.sir))` different antibiotics with class [`sir`] (see [as.sir()]); 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).
#' 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, 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
#' example_isolates
"example_isolates"
@@ -219,7 +231,7 @@
#' - `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.sir()]
#' @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).
#' 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, 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
#' example_isolates_unclean
"example_isolates_unclean"
@@ -255,17 +267,25 @@
#' - `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.sir))` 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.sir()].
#' @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).
#' 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, 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
#' WHONET
"WHONET"
#' Data Set with Clinical Breakpoints for SIR Interpretation
#'
#' Data set containing clinical breakpoints to interpret MIC and disk diffusion to SIR values, according to international guidelines. Currently implemented guidelines are EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`). Use [as.sir()] to transform MICs or disks measurements to SIR values.
#' @description Data set containing clinical breakpoints to interpret MIC and disk diffusion to SIR values, according to international guidelines. This dataset contain breakpoints for humans, `r length(unique(clinical_breakpoints$host[!clinical_breakpoints$host %in% clinical_breakpoints$type]))` different animal groups, and ECOFFs.
#'
#' These breakpoints are currently implemented:
#' - For **clinical microbiology**: EUCAST `r min(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "EUCAST" & type == "human")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "EUCAST" & type == "human")$guideline)))` and CLSI `r min(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "CLSI" & type == "human")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "CLSI" & type == "human")$guideline)))`;
#' - For **veterinary microbiology**: EUCAST `r min(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "EUCAST" & type == "animal")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "EUCAST" & type == "animal")$guideline)))` and CLSI `r min(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "CLSI" & type == "animal")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "CLSI" & type == "animal")$guideline)))`;
#' - For **ECOFFs** (Epidemiological Cut-off Values): EUCAST `r min(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "EUCAST" & type == "ECOFF")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "EUCAST" & type == "ECOFF")$guideline)))` and CLSI `r min(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "CLSI" & type == "ECOFF")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "CLSI" & type == "ECOFF")$guideline)))`.
#'
#' Use [as.sir()] to transform MICs or disks measurements to SIR values.
#' @format A [tibble][tibble::tibble] with `r format(nrow(clinical_breakpoints), big.mark = " ")` observations and `r ncol(clinical_breakpoints)` variables:
#' - `guideline`\cr Name of the guideline
#' - `type`\cr Breakpoint type, either `r vector_or(clinical_breakpoints$type)`
#' - `host`\cr Host of infectious agent. This is mostly useful for veterinary breakpoints and is either `r vector_or(clinical_breakpoints$host)`
#' - `method`\cr Testing method, either `r vector_or(clinical_breakpoints$method)`
#' - `site`\cr Body site for which the breakpoint must be applied, e.g. "Oral" or "Respiratory"
#' - `mo`\cr Microbial ID, see [as.mo()]
@@ -276,22 +296,23 @@
#' - `breakpoint_S`\cr Lowest MIC value or highest number of millimetres that leads to "S"
#' - `breakpoint_R`\cr Highest MIC value or lowest number of millimetres that leads to "R"
#' - `uti`\cr A [logical] value (`TRUE`/`FALSE`) to indicate whether the rule applies to a urinary tract infection (UTI)
#' - `is_SDD`\cr A [logical] value (`TRUE`/`FALSE`) to indicate whether the intermediate range between "S" and "R" should be interpreted as "SDD", instead of "I". This currently applies to `r sum(clinical_breakpoints$is_SDD)` breakpoints.
#' @details
#' ### Different types of breakpoints
#' Supported types of breakpoints are `r vector_and(clinical_breakpoints$type, quote = FALSE)`. ECOFF (Epidemiological cut-off) values are used in antimicrobial susceptibility testing to differentiate between wild-type and non-wild-type strains of bacteria or fungi.
#'
#' The default is `"human"`, which can also be set with the [package option][AMR-options] [`AMR_breakpoint_type`][AMR-options]. Use [`as.sir(..., breakpoint_type = ...)`][as.sir()] to interpret raw data using a specific breakpoint type, e.g. `as.sir(..., breakpoint_type = "ECOFF")` to use ECOFFs.
#' The default is `"human"`, which can also be set with the package option [`AMR_breakpoint_type`][AMR-options]. Use [`as.sir(..., breakpoint_type = ...)`][as.sir()] to interpret raw data using a specific breakpoint type, e.g. `as.sir(..., breakpoint_type = "ECOFF")` to use ECOFFs.
#'
#' ### Imported from WHONET
#' Clinical breakpoints in this package were validated through and imported from [WHONET](https://whonet.org), a free desktop Windows application developed and supported by the WHO Collaborating Centre for Surveillance of Antimicrobial Resistance. More can be read on [their website](https://whonet.org). The developers of WHONET and this `AMR` package have been in contact about sharing their work. We highly appreciate their development on the WHONET software.
#' Clinical breakpoints in this package were validated through and imported from [WHONET](https://whonet.org), a free desktop Windows application developed and supported by the WHO Collaborating Centre for Surveillance of Antimicrobial Resistance. More can be read on [their website](https://whonet.org). The developers of WHONET and this `AMR` package have been in contact about sharing their work. We highly appreciate their great development on the WHONET software.
#'
#' ### Response from CLSI and EUCAST
#' The CEO of CLSI and the chairman of EUCAST have endorsed the work and public use of this `AMR` package (and consequently the use of their breakpoints) in June 2023, when future development of distributing clinical breakpoints was discussed in a meeting between CLSI, EUCAST, the WHO, and developers of WHONET and the `AMR` package.
#' The CEO of CLSI and the chairman of EUCAST have endorsed the work and public use of this `AMR` package (and consequently the use of their breakpoints) in June 2023, when future development of distributing clinical breakpoints was discussed in a meeting between CLSI, EUCAST, WHO, developers of WHONET software, and developers of this `AMR` package.
#'
#' ### 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, though initiatives have started to overcome these burdens.
#' 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, 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, though initiatives have started to overcome these burdens.
#'
#' **NOTE:** this `AMR` package (and the WHONET software as well) contains internal methods to apply the guidelines, which is rather complex. For example, some breakpoints must be applied on certain species groups (which are in case of this package available through the [microorganisms.groups] data set). It is important that this is considered when using the breakpoints for own use.
#' **NOTE:** this `AMR` package (and the WHONET software as well) contains rather complex internal methods to apply the guidelines. For example, some breakpoints must be applied on certain species groups (which are in case of this package available through the [microorganisms.groups] data set). It is important that this is considered when using the breakpoints for own use.
#' @seealso [intrinsic_resistant]
#' @examples
#' clinical_breakpoints
@@ -307,7 +328,7 @@
#' This data set is based on `r format_eucast_version_nr(3.3)`.
#'
#' ### 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).
#' 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, 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
@@ -328,7 +349,7 @@
#' - `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, either `r vector_or(dosage$eucast_version, quotes = FALSE, sort = TRUE, reverse = TRUE)`
#' @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).
#' 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, 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
#' dosage
"dosage"
+7 -12
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -29,13 +29,13 @@
#' Transform Input to Disk Diffusion Diameters
#'
#' This transforms a vector to a new class [`disk`], which is a disk diffusion growth zone size (around an antibiotic disk) in millimetres between 6 and 50.
#' This transforms a vector to a new class [`disk`], which is a disk diffusion growth zone size (around an antibiotic disk) in millimetres between 0 and 50.
#' @rdname as.disk
#' @param x vector
#' @param na.rm a [logical] indicating whether missing values should be removed
#' @details Interpret disk values as SIR values with [as.sir()]. It supports guidelines from EUCAST and CLSI.
#'
#' Disk diffusion growth zone sizes must be between 6 and 50 millimetres. Values higher than 50 but lower than 100 will be maximised to 50. All others input values outside the 6-50 range will return `NA`.
#' Disk diffusion growth zone sizes must be between 0 and 50 millimetres. Values higher than 50 but lower than 100 will be maximised to 50. All others input values outside the 0-50 range will return `NA`.
#' @return An [integer] with additional class [`disk`]
#' @aliases disk
#' @export
@@ -108,8 +108,8 @@ as.disk <- function(x, na.rm = FALSE) {
# round up and make it an integer
x <- as.integer(ceiling(clean_double2(x)))
# disks can never be less than 6 mm (size of smallest disk) or more than 50 mm
x[x < 6 | x > 99] <- NA_integer_
# disks can never be less than 0 mm or more than 50 mm
x[x < 0 | x > 99] <- NA_integer_
x[x > 50] <- 50L
na_after <- length(x[is.na(x)])
@@ -165,11 +165,6 @@ pillar_shaft.disk <- function(x, ...) {
create_pillar_column(out, align = "right", width = 2)
}
# will be exported using s3_register() in R/zzz.R
type_sum.disk <- function(x, ...) {
"disk"
}
#' @method print disk
#' @export
#' @noRd
+9 -9
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -61,7 +61,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
#' To improve the interpretation of the antibiogram before EUCAST rules are applied, some non-EUCAST rules can applied at default, see *Details*.
#' @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 - the default is 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 using the [package option][AMR-options] [`AMR_eucastrules`][AMR-options]: `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 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 using the package option [`AMR_eucastrules`][AMR-options]: `options(AMR_eucastrules = "all")`. If using `"custom"`, be sure to fill in argument `custom_rules` too. Custom rules can be created with [custom_eucast_rules()].
#' @param verbose a [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way. Using Verbose mode takes a lot more time.
#' @param version_breakpoints the version number to use for the EUCAST Clinical Breakpoints guideline. Can be `r vector_or(names(EUCAST_VERSION_BREAKPOINTS), reverse = TRUE)`.
#' @param version_expertrules the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be `r vector_or(names(EUCAST_VERSION_EXPERT_RULES), reverse = TRUE)`.
@@ -99,11 +99,11 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
#'
#' Important examples include amoxicillin and amoxicillin/clavulanic acid, and trimethoprim and trimethoprim/sulfamethoxazole. Needless to say, for these rules to work, both drugs must be available in the data set.
#'
#' Since these rules are not officially approved by EUCAST, they are not applied at default. To use these rules, include `"other"` to the `rules` argument, or use `eucast_rules(..., rules = "all")`. You can also set the [package option][AMR-options] [`AMR_eucastrules`][AMR-options], i.e. run `options(AMR_eucastrules = "all")`.
#' Since these rules are not officially approved by EUCAST, they are not applied at default. To use these rules, include `"other"` to the `rules` argument, or use `eucast_rules(..., rules = "all")`. You can also set the package option [`AMR_eucastrules`][AMR-options], i.e. run `options(AMR_eucastrules = "all")`.
#' @section Antibiotics:
#' To define antibiotics column names, leave as it is to determine it automatically with [guess_ab_col()] or input a text (case-insensitive), or use `NULL` to skip a column (e.g. `TIC = NULL` to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning.
#'
#' The following antibiotics are eligible for the functions [eucast_rules()] and [mdro()]. These are shown below in the format 'name (`antimicrobial ID`, [ATC code](https://www.whocc.no/atc/structure_and_principles/))', sorted alphabetically:
#' The following antibiotics are eligible for the functions [eucast_rules()] and [mdro()]. These are shown below in the format 'name (`antimicrobial ID`, [ATC code](https://atcddd.fhi.no/atc/structure_and_principles/))', sorted alphabetically:
#'
#' `r create_eucast_ab_documentation()`
#' @aliases EUCAST
@@ -184,7 +184,6 @@ eucast_rules <- function(x,
meet_criteria(ampc_cephalosporin_resistance, allow_class = c("logical", "character", "sir"), has_length = 1, allow_NA = TRUE, allow_NULL = TRUE)
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
meet_criteria(custom_rules, allow_class = "custom_eucast_rules", allow_NULL = TRUE)
if ("only_rsi_columns" %in% names(list(...))) only_sir_columns <- list(...)$only_rsi_columns
add_MO_lookup_to_AMR_env()
@@ -463,7 +462,7 @@ eucast_rules <- function(x,
font_red(paste0(
"v", utils::packageDescription("AMR")$Version, ", ",
format(as.Date(utils::packageDescription("AMR")$Date), format = "%Y")
)), "), see ?eucast_rules\n"
)), "), see `?eucast_rules`\n"
))
))
}
@@ -591,7 +590,7 @@ 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_checks.R
eucast_rules_df <- EUCAST_RULES_DF
}
@@ -890,6 +889,7 @@ eucast_rules <- function(x,
),
type = "ansi"
))
cat("\n")
warned <- FALSE
}
run_changes <- edit_sir(
+57
View File
@@ -0,0 +1,57 @@
# ==================================================================== #
# TITLE: #
# AMR: An R Package for Working with Antimicrobial Resistance Data #
# #
# SOURCE CODE: #
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
# Center Groningen in The Netherlands, in collaboration with many #
# colleagues from around the world, see our website. #
# #
# 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/ #
# ==================================================================== #
#' Export Data Set as NCBI BioSample Antibiogram
#'
#'
#' @param x a data set
#' @param filename a character string specifying the file name
#' @param type a character string specifying the type of data set, either "pathogen MIC" or "beta-lactamase MIC", see <https://www.ncbi.nlm.nih.gov/biosample/docs/>
#' @keywords internal
export_ncbi_biosample <- function(x,
filename = paste0("biosample_", format(Sys.time(), "%Y-%m-%d-%H%M%S"), ".xlsx"),
type = "pathogen MIC",
columns = where(is.mic),
save_as_xlsx = TRUE) {
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
meet_criteria(filename, allow_class = "character", has_length = 1)
meet_criteria(type, allow_class = "character", has_length = 1, is_in = c("pathogen MIC", "beta-lactamase MIC"))
meet_criteria(save_as_xlsx, allow_class = "logical", has_length = 1)
out <- x %pm>%
pm_select(columns)
stop_if(NROW(out) == 0, "No columns found.")
if (isTRUE(save_as_xlsx)) {
export <- import_fn("write.xlsx", pkg = "openxlsx", error_on_fail = TRUE)
export(out, file = filename, overwrite = TRUE, asTable = FALSE)
} else {
out
}
}
+14 -14
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -227,10 +227,6 @@ first_isolate <- function(x = NULL,
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
meet_criteria(info, allow_class = "logical", has_length = 1)
meet_criteria(include_unknown, allow_class = "logical", has_length = 1)
if ("include_untested_rsi" %in% names(list(...))) {
deprecation_warning("include_untested_rsi", "include_untested_sir", is_function = FALSE)
include_untested_sir <- list(...)$include_untested_rsi
}
meet_criteria(include_untested_sir, allow_class = "logical", has_length = 1)
# remove data.table, grouping from tibbles, etc.
@@ -240,7 +236,7 @@ first_isolate <- function(x = NULL,
FUN.VALUE = logical(1),
X = x,
# check only first 10,000 rows
FUN = function(x) any(as.character(x[1:10000]) %in% c("S", "I", "R"), na.rm = TRUE),
FUN = function(x) any(as.character(x[1:10000]) %in% c("S", "SDD", "I", "R", "NI"), na.rm = TRUE),
USE.NAMES = FALSE
))
if (method == "phenotype-based" && !any_col_contains_sir) {
@@ -674,6 +670,15 @@ duplicated_antibiogram <- function(antibiogram, points_threshold, ignore_I, type
# fast return, only 1 isolate
return(FALSE)
}
# first sort on data availability - count the dots and order that ascending so that highest availability of SIR is on top
number_dots <- vapply(FUN.VALUE = integer(1),
antibiogram,
function(x) sum(strsplit(x, "", fixed = TRUE)[[1]] == "."),
USE.NAMES = FALSE)
new_order <- order(number_dots, antibiogram)
antibiogram.bak <- antibiogram
antibiogram <- antibiogram[new_order]
out <- rep(NA, length(antibiogram))
out[1] <- FALSE
out[2] <- antimicrobials_equal(antibiogram[1], antibiogram[2],
@@ -684,11 +689,6 @@ duplicated_antibiogram <- function(antibiogram, points_threshold, ignore_I, type
return(out)
}
# sort after the second one (since we already determined AB equality of the first two)
original_sort <- c(1, 2, rank(antibiogram[3:length(antibiogram)]) + 2)
antibiogram.bak <- antibiogram
antibiogram <- c(antibiogram[1:2], sort(antibiogram[3:length(antibiogram)]))
# we can skip the duplicates - they are never unique antibiograms of course
duplicates <- duplicated(antibiogram)
out[3:length(out)][duplicates[3:length(out)] == TRUE] <- TRUE
@@ -707,7 +707,7 @@ duplicated_antibiogram <- function(antibiogram, points_threshold, ignore_I, type
type = type)))
}
out <- out[original_sort]
out <- out[order(new_order)]
# rerun duplicated again
duplicates <- duplicated(antibiogram.bak)
out[duplicates == TRUE] <- TRUE
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+9 -7
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -85,16 +85,18 @@
#' summary(pca_result)
#'
#' # old base R plotting method:
#' biplot(pca_result)
#' biplot(pca_result, main = "Base R biplot")
#'
#' # new ggplot2 plotting method using this package:
#' if (require("ggplot2")) {
#' ggplot_pca(pca_result)
#'
#' ggplot_pca(pca_result) +
#' labs(title = "ggplot2 biplot")
#' }
#' if (require("ggplot2")) {
#' # still extendible with any ggplot2 function
#' ggplot_pca(pca_result) +
#' scale_colour_viridis_d() +
#' labs(title = "Title here")
#' labs(title = "ggplot2 biplot")
#' }
#' }
#' }
+5 -4
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -193,7 +193,8 @@ ggplot_sir <- function(data,
y.title = "Proportion",
...) {
stop_ifnot_installed("ggplot2")
meet_criteria(data, allow_class = "data.frame", contains_column_class = c("sir", "rsi"))
meet_criteria(data, allow_class = "data.frame")
data <- ascertain_sir_classes(data, "data")
meet_criteria(position, allow_class = "character", has_length = 1, is_in = c("fill", "stack", "dodge"), allow_NULL = TRUE)
meet_criteria(x, allow_class = "character", has_length = 1)
meet_criteria(fill, allow_class = "character", has_length = 1)
+16 -14
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -274,16 +274,18 @@ get_column_abx <- function(x,
}
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
)
if (names(out)[i] != names(already_set_as)) {
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
)
}
}
}
}
@@ -335,7 +337,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_checks.R, such as `AB_CARBAPENEMS`
val <- eval(parse(text = paste0("AB_", val)), envir = asNamespace("AMR"))
} else if (val %in% AMR_env$AB_lookup$ab) {
# separate drugs, such as `AMX`
+11 -8
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -31,11 +31,11 @@
#'
#' According to the binomial nomenclature, the lowest four taxonomic levels (family, genus, species, subspecies) should be printed in italics. This function finds taxonomic names within strings and makes them italic.
#' @param string a [character] (vector)
#' @param type type of conversion of the taxonomic names, either "markdown" or "ansi", see *Details*
#' @param type type of conversion of the taxonomic names, either "markdown", "html" or "ansi", see *Details*
#' @details
#' This function finds the taxonomic names and makes them italic based on the [microorganisms] data set.
#'
#' The taxonomic names can be italicised using markdown (the default) by adding `*` before and after the taxonomic names, or using ANSI colours by adding `\033[3m` before and `\033[23m` after the taxonomic names. If multiple ANSI colours are not available, no conversion will occur.
#' The taxonomic names can be italicised using markdown (the default) by adding `*` before and after the taxonomic names, or `<i>` and `</i>` when using html. When using 'ansi', ANSI colours will be added using `\033[3m` before and `\033[23m` after the taxonomic names. If multiple ANSI colours are not available, no conversion will occur.
#'
#' This function also supports abbreviation of the genus if it is followed by a species, such as "E. coli" and "K. pneumoniae ozaenae".
#' @export
@@ -44,18 +44,21 @@
#' italicise_taxonomy("An overview of S. aureus isolates")
#'
#' cat(italicise_taxonomy("An overview of S. aureus isolates", type = "ansi"))
italicise_taxonomy <- function(string, type = c("markdown", "ansi")) {
italicise_taxonomy <- function(string, type = c("markdown", "ansi", "html")) {
if (missing(type)) {
type <- "markdown"
}
meet_criteria(string, allow_class = "character")
meet_criteria(type, allow_class = "character", has_length = 1, is_in = c("markdown", "ansi"))
meet_criteria(type, allow_class = "character", has_length = 1, is_in = c("markdown", "ansi", "html"))
add_MO_lookup_to_AMR_env()
if (type == "markdown") {
before <- "*"
after <- "*"
} else if (type == "html") {
before <- "<i>"
after <- "</i>"
} else if (type == "ansi") {
if (!has_colour() && !identical(Sys.getenv("IN_PKGDOWN"), "true")) {
return(string)
@@ -134,7 +137,7 @@ italicise_taxonomy <- function(string, type = c("markdown", "ansi")) {
#' @rdname italicise_taxonomy
#' @export
italicize_taxonomy <- function(string, type = c("markdown", "ansi")) {
italicize_taxonomy <- function(string, type = c("markdown", "ansi", "html")) {
if (missing(type)) {
type <- "markdown"
}
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+7 -9
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -149,10 +149,6 @@ key_antimicrobials <- function(x = NULL,
meet_criteria(gram_positive, allow_class = "character", allow_NULL = TRUE)
meet_criteria(antifungal, allow_class = "character", allow_NULL = TRUE)
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
# force regular data.frame, not a tibble or data.table
x <- as.data.frame(x, stringsAsFactors = FALSE)
@@ -192,7 +188,7 @@ key_antimicrobials <- function(x = NULL,
"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."
"as key antimicrobials for ", name, "s. See `?key_antimicrobials`."
)
}
@@ -286,6 +282,8 @@ generate_antimcrobials_string <- function(df) {
as.list(df),
function(x) {
x <- toupper(as.character(x))
x[x == "SDD"] <- "I"
# ignore "NI" here, no use for determining first isolates
x[!x %in% c("S", "I", "R")] <- "."
paste(x)
}
@@ -316,7 +314,7 @@ antimicrobials_equal <- function(y,
val <- strsplit(val, "", fixed = TRUE)[[1L]]
val.int <- rep(NA_real_, length(val))
val.int[val == "S"] <- 1
val.int[val == "I"] <- 2
val.int[val %in% c("I", "SDD")] <- 2
val.int[val == "R"] <- 3
val.int
}
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+4 -8
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -192,10 +192,6 @@ mdro <- function(x = NULL,
meet_criteria(pct_required_classes, allow_class = "numeric", has_length = 1)
meet_criteria(combine_SI, allow_class = "logical", has_length = 1)
meet_criteria(verbose, allow_class = "logical", has_length = 1)
if ("only_rsi_columns" %in% names(list(...))) {
deprecation_warning("only_rsi_columns", "only_sir_columns", is_function = FALSE)
only_sir_columns <- list(...)$only_rsi_columns
}
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
if (!any(is_sir_eligible(x))) {
@@ -736,7 +732,7 @@ mdro <- function(x = NULL,
sum(vapply(
FUN.VALUE = logical(1),
group_tbl,
function(group) any(unlist(x[row, group[!is.na(group)], drop = TRUE]) %in% c("S", "I", "R"))
function(group) any(unlist(x[row, group[!is.na(group)], drop = TRUE]) %in% c("S", "SDD", "I", "R"))
))
}
)
+7 -7
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -32,7 +32,7 @@
#' Calculates a normalised mean for antimicrobial resistance between multiple observations, to help to identify similar isolates without comparing antibiograms by hand.
#' @param x a vector of class [sir][as.sir()], [mic][as.mic()] or [disk][as.disk()], or a [data.frame] containing columns of any of these classes
#' @param ... variables to select (supports [tidyselect language][tidyselect::language] such as `column1:column4` and `where(is.mic)`, and can thus also be [antibiotic selectors][ab_selector()]
#' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so the input only consists of S+I vs. R (susceptible vs. resistant) - the default is `TRUE`
#' @param combine_SI a [logical] to indicate whether all values of S, SDD, and I must be merged into one, so the input only consists of S+I vs. R (susceptible vs. resistant) - the default is `TRUE`
#' @details The mean AMR distance is effectively [the Z-score](https://en.wikipedia.org/wiki/Standard_score); a normalised numeric value to compare AMR test results which can help to identify similar isolates, without comparing antibiograms by hand.
#'
#' MIC values (see [as.mic()]) are transformed with [log2()] first; their distance is thus calculated as `(log2(x) - mean(log2(x))) / sd(log2(x))`.
@@ -118,7 +118,7 @@ mean_amr_distance.disk <- function(x, ...) {
mean_amr_distance.sir <- function(x, ..., combine_SI = TRUE) {
meet_criteria(combine_SI, allow_class = "logical", has_length = 1, .call_depth = -1)
if (isTRUE(combine_SI)) {
x[x == "I"] <- "S"
x[x %in% c("I", "SDD")] <- "S"
}
mean_amr_distance(as.double(x))
}
@@ -175,8 +175,8 @@ mean_amr_distance.data.frame <- function(x, ..., combine_SI = TRUE) {
#' @param row an index, such as a row number
#' @export
amr_distance_from_row <- function(amr_distance, row) {
meet_criteria(amr_distance, allow_class = c("double", "numeric"), is_finite = TRUE)
meet_criteria(row, allow_class = c("logical", "double", "numeric"))
meet_criteria(amr_distance, allow_class = "numeric", is_finite = TRUE)
meet_criteria(row, allow_class = c("logical", "numeric", "integer"))
if (is.logical(row)) {
row <- which(row)
}
+268 -158
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -27,48 +27,25 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
# these are allowed MIC values and will become [factor] levels
operators <- c("<", "<=", "", ">=", ">")
valid_mic_levels <- c(
c(t(vapply(
FUN.VALUE = character(6), operators,
function(x) paste0(x, "0.000", c(1:4, 6, 8))
))),
c(t(vapply(
FUN.VALUE = character(90), operators,
function(x) paste0(x, "0.00", c(1:9, 11:19, 21:29, 31:39, 41:49, 51:59, 61:69, 71:79, 81:89, 91:99))
))),
unique(c(t(vapply(
FUN.VALUE = character(106), operators,
function(x) {
paste0(x, sort(as.double(paste0(
"0.0",
sort(c(1:99, 125, 128, 156, 165, 256, 512, 625))
))))
}
)))),
unique(c(t(vapply(
FUN.VALUE = character(103), operators,
function(x) {
paste0(x, sort(as.double(paste0(
"0.",
c(1:99, 125, 128, 256, 512)
))))
}
)))),
c(t(vapply(
FUN.VALUE = character(10), operators,
function(x) paste0(x, sort(c(1:9, 1.5)))
))),
c(t(vapply(
FUN.VALUE = character(45), operators,
function(x) paste0(x, c(10:98)[9:98 %% 2 == TRUE])
))),
c(t(vapply(
FUN.VALUE = character(17), operators,
function(x) paste0(x, sort(c(2^c(7:11), 192, 80 * c(2:12))))
)))
# these are allowed MIC values and will become factor levels
VALID_MIC_LEVELS <- c(
as.double(paste0("0.000", c(1:9))),
as.double(paste0("0.00", c(1:99, 1953125, 390625, 78125))),
as.double(paste0("0.0", c(1:99, 125, 128, 156, 165, 256, 512, 625, 3125, 15625))),
as.double(paste0("0.", c(1:99, 125, 128, 256, 512))),
1:9, 1.5,
c(10:98)[9:98 %% 2 == TRUE],
2^c(7:12), 192 * c(1:5), 80 * c(2:12)
)
VALID_MIC_LEVELS <- trimws(gsub("[.]?0+$", "", format(unique(sort(VALID_MIC_LEVELS)), scientific = FALSE), perl = TRUE))
operators <- c("<", "<=", "", ">=", ">")
VALID_MIC_LEVELS <- c(t(vapply(FUN.VALUE = character(length(VALID_MIC_LEVELS)),
c("<", "<=", "", ">=", ">"),
paste0,
VALID_MIC_LEVELS)))
COMMON_MIC_VALUES <- c(0.001, 0.002, 0.004, 0.008, 0.016, 0.032, 0.064,
0.125, 0.25, 0.5, 1, 2, 4, 8, 16, 32,
64, 128, 256, 512, 1024)
#' Transform Input to Minimum Inhibitory Concentrations (MIC)
#'
@@ -76,6 +53,7 @@ valid_mic_levels <- c(
#' @rdname as.mic
#' @param x a [character] or [numeric] vector
#' @param na.rm a [logical] indicating whether missing values should be removed
#' @param keep_operators a [character] specifying how to handle operators (such as `>` and `<=`) in the input. Accepts one of three values: `"all"` (or `TRUE`) to keep all operators, `"none"` (or `FALSE`) to remove all operators, or `"edges"` to keep operators only at both ends of the range.
#' @param ... arguments passed on to methods
#' @details To interpret MIC values as SIR values, use [as.sir()] on MIC values. It supports guidelines from EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`).
#'
@@ -115,12 +93,16 @@ valid_mic_levels <- c(
#' #> 10 16 A
#' ```
#'
#' The following [generic functions][groupGeneric()] are implemented for the MIC class: `!`, `!=`, `%%`, `%/%`, `&`, `*`, `+`, `-`, `/`, `<`, `<=`, `==`, `>`, `>=`, `^`, `|`, [abs()], [acos()], [acosh()], [all()], [any()], [asin()], [asinh()], [atan()], [atanh()], [ceiling()], [cos()], [cosh()], [cospi()], [cummax()], [cummin()], [cumprod()], [cumsum()], [digamma()], [exp()], [expm1()], [floor()], [gamma()], [lgamma()], [log()], [log1p()], [log2()], [log10()], [max()], [mean()], [min()], [prod()], [range()], [round()], [sign()], [signif()], [sin()], [sinh()], [sinpi()], [sqrt()], [sum()], [tan()], [tanh()], [tanpi()], [trigamma()] and [trunc()]. Some functions of the `stats` package are also implemented: [median()], [quantile()], [mad()], [IQR()], [fivenum()]. Also, [boxplot.stats()] is supported. Since [sd()] and [var()] are non-generic functions, these could not be extended. Use [mad()] as an alternative, or use e.g. `sd(as.numeric(x))` where `x` is your vector of MIC values.
#' All so-called [group generic functions][groupGeneric()] are implemented for the MIC class (such as `!`, `!=`, `<`, `>=`, [exp()], [log2()]). Some functions of the `stats` package are also implemented (such as [quantile()], [median()], [fivenum()]). Since [sd()] and [var()] are non-generic functions, these could not be extended. Use [mad()] as an alternative, or use e.g. `sd(as.numeric(x))` where `x` is your vector of MIC values.
#'
#' Using [as.double()] or [as.numeric()] on MIC values will remove the operators and return a numeric vector. Do **not** use [as.integer()] on MIC values as by the \R convention on [factor]s, it will return the index of the factor levels (which is often useless for regular users).
#'
#' Use [droplevels()] to drop unused levels. At default, it will return a plain factor. Use `droplevels(..., as.mic = TRUE)` to maintain the `mic` class.
#' @return Ordered [factor] with additional class [`mic`], that in mathematical operations acts as decimal numbers. Bare in mind that the outcome of any mathematical operation on MICs will return a [numeric] value.
#'
#' With [rescale_mic()], existing MIC ranges can be limited to a defined range of MIC values. This can be useful to better compare MIC distributions.
#'
#' For `ggplot2`, use one of the [`scale_*_mic()`][scale_x_mic()] functions to plot MIC values. They allows custom MIC ranges and to plot intermediate log2 levels for missing MIC values.
#' @return Ordered [factor] with additional class [`mic`], that in mathematical operations acts as a [numeric] vector. Bear in mind that the outcome of any mathematical operation on MICs will return a [numeric] value.
#' @aliases mic
#' @export
#' @seealso [as.sir()]
@@ -136,6 +118,9 @@ valid_mic_levels <- c(
#' fivenum(mic_data)
#' quantile(mic_data)
#' all(mic_data < 512)
#'
#' # rescale MICs using rescale_mic()
#' rescale_mic(mic_data, mic_range = c(4, 16))
#'
#' # interpret MIC values
#' as.sir(
@@ -161,112 +146,182 @@ valid_mic_levels <- c(
#' if (require("ggplot2")) {
#' autoplot(mic_data, mo = "E. coli", ab = "cipro", language = "nl") # Dutch
#' }
as.mic <- function(x, na.rm = FALSE) {
as.mic <- function(x, na.rm = FALSE, keep_operators = "all") {
meet_criteria(x, allow_NA = TRUE)
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
if (is.mic(x)) {
x
meet_criteria(keep_operators, allow_class = c("character", "logical"), is_in = c("all", "none", "edges", FALSE, TRUE), has_length = 1)
if (isTRUE(keep_operators)) {
keep_operators <- "all"
} else if (isFALSE(keep_operators)) {
keep_operators <- "none"
}
if (is.mic(x) && (keep_operators == "all" || !any(x %like% "[>=<]", na.rm = TRUE))) {
if (!identical(levels(x), VALID_MIC_LEVELS)) {
# from an older AMR version - just update MIC factor levels
x <- set_clean_class(factor(as.character(x), levels = VALID_MIC_LEVELS, ordered = TRUE),
new_class = c("mic", "ordered", "factor"))
}
return(x)
}
x.bak <- NULL
if (is.numeric(x)) {
x.bak <- format(x, scientific = FALSE)
# MICs never have more than 9 decimals, so:
x <- format(round(x, 9), scientific = FALSE)
} else {
if (is.numeric(x)) {
x <- format(x, scientific = FALSE)
} else {
x <- as.character(unlist(x))
}
if (isTRUE(na.rm)) {
x <- x[!is.na(x)]
}
x[trimws2(x) == ""] <- NA
x <- as.character(unlist(x))
}
if (isTRUE(na.rm)) {
x <- x[!is.na(x)]
}
x <- trimws2(x)
x[x == ""] <- NA
if (is.null(x.bak)) {
x.bak <- x
# comma to period
x <- gsub(",", ".", x, fixed = TRUE)
# transform scientific notation
x[x %like% "[-]?[0-9]+([.][0-9]+)?e[-]?[0-9]+"] <- as.double(x[x %like% "[-]?[0-9]+([.][0-9]+)?e[-]?[0-9]+"])
# transform Unicode for >= and <=
x <- gsub("\u2264", "<=", x, fixed = TRUE)
x <- gsub("\u2265", ">=", x, fixed = TRUE)
# remove other invalid characters
x <- gsub("[^a-zA-Z0-9.><= ]+", "", x, perl = TRUE)
# remove space between operator and number ("<= 0.002" -> "<=0.002")
x <- gsub("(<|=|>) +", "\\1", x, perl = TRUE)
# transform => to >= and =< to <=
x <- gsub("=<", "<=", x, fixed = TRUE)
x <- gsub("=>", ">=", x, fixed = TRUE)
# dots without a leading zero must start with 0
x <- gsub("([^0-9]|^)[.]", "\\10.", x, perl = TRUE)
# values like "<=0.2560.512" should be 0.512
x <- gsub(".*[.].*[.]", "0.", x, perl = TRUE)
# remove ending .0
x <- gsub("[.]+0$", "", x, perl = TRUE)
# remove all after last digit
x <- gsub("[^0-9]+$", "", x, perl = TRUE)
# keep only one zero before dot
x <- gsub("0+[.]", "0.", x, perl = TRUE)
# starting 00 is probably 0.0 if there's no dot yet
x[x %unlike% "[.]"] <- gsub("^00", "0.0", x[!x %like% "[.]"])
# remove last zeroes
x <- gsub("([.].?)0+$", "\\1", x, perl = TRUE)
x <- gsub("(.*[.])0+$", "\\10", x, perl = TRUE)
# remove ending .0 again
x[x %like% "[.]"] <- gsub("0+$", "", x[x %like% "[.]"])
# never end with dot
x <- gsub("[.]$", "", x, perl = TRUE)
# trim it
x <- trimws2(x)
## previously unempty values now empty - should return a warning later on
x[x.bak != "" & x == ""] <- "invalid"
na_before <- x[is.na(x) | x == ""] %pm>% length()
x[!x %in% valid_mic_levels] <- NA
na_after <- x[is.na(x) | x == ""] %pm>% length()
if (na_before != na_after) {
list_missing <- x.bak[is.na(x) & !is.na(x.bak) & x.bak != ""] %pm>%
unique() %pm>%
sort() %pm>%
vector_and(quotes = TRUE)
cur_col <- get_current_column()
warning_("in `as.mic()`: ", na_after - na_before, " result",
ifelse(na_after - na_before > 1, "s", ""),
ifelse(is.null(cur_col), "", paste0(" in column '", cur_col, "'")),
" truncated (",
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")
}
# comma to period
x <- gsub(",", ".", x, fixed = TRUE)
# transform scientific notation
x[x %like% "[-]?[0-9]+([.][0-9]+)?e[-]?[0-9]+"] <- as.double(x[x %like% "[-]?[0-9]+([.][0-9]+)?e[-]?[0-9]+"])
# transform Unicode for >= and <=
x <- gsub("\u2264", "<=", x, fixed = TRUE)
x <- gsub("\u2265", ">=", x, fixed = TRUE)
# remove other invalid characters
x <- gsub("[^a-zA-Z0-9.><= ]+", "", x, perl = TRUE)
# remove space between operator and number ("<= 0.002" -> "<=0.002")
x <- gsub("(<|=|>) +", "\\1", x, perl = TRUE)
# transform => to >= and =< to <=
x <- gsub("=<", "<=", x, fixed = TRUE)
x <- gsub("=>", ">=", x, fixed = TRUE)
# dots without a leading zero must start with 0
x <- gsub("([^0-9]|^)[.]", "\\10.", x, perl = TRUE)
# values like "<=0.2560.512" should be 0.512
x <- gsub(".*[.].*[.]", "0.", x, perl = TRUE)
# remove ending .0
x <- gsub("[.]+0$", "", x, perl = TRUE)
# remove all after last digit
x <- gsub("[^0-9]+$", "", x, perl = TRUE)
# keep only one zero before dot
x <- gsub("0+[.]", "0.", x, perl = TRUE)
# starting 00 is probably 0.0 if there's no dot yet
x[x %unlike% "[.]"] <- gsub("^00", "0.0", x[!x %like% "[.]"])
# remove last zeroes
x <- gsub("([.].?)0+$", "\\1", x, perl = TRUE)
x <- gsub("(.*[.])0+$", "\\10", x, perl = TRUE)
# remove ending .0 again
x[x %like% "[.]"] <- gsub("0+$", "", x[x %like% "[.]"])
# never end with dot
x <- gsub("[.]$", "", x, perl = TRUE)
# trim it
x <- trimws2(x)
## previously unempty values now empty - should return a warning later on
x[x.bak != "" & x == ""] <- "invalid"
na_before <- x[is.na(x) | x == ""] %pm>% length()
x[!x %in% VALID_MIC_LEVELS] <- NA
na_after <- x[is.na(x) | x == ""] %pm>% length()
if (na_before != na_after) {
list_missing <- x.bak[is.na(x) & !is.na(x.bak) & x.bak != ""] %pm>%
unique() %pm>%
sort() %pm>%
vector_and(quotes = TRUE)
cur_col <- get_current_column()
warning_("in `as.mic()`: ", na_after - na_before, " result",
ifelse(na_after - na_before > 1, "s", ""),
ifelse(is.null(cur_col), "", paste0(" in column '", cur_col, "'")),
" truncated (",
round(((na_after - na_before) / length(x)) * 100),
"%) that were invalid MICs: ",
list_missing,
call = FALSE
)
}
if (keep_operators == "none" && !all(is.na(x))) {
x <- gsub("[>=<]", "", x)
} else if (keep_operators == "edges" && !all(is.na(x))) {
dbls <- as.double(gsub("[>=<]", "", x))
x[dbls == min(dbls, na.rm = TRUE)] <- paste0("<=", min(dbls, na.rm = TRUE))
x[dbls == max(dbls, na.rm = TRUE)] <- paste0(">=", max(dbls, na.rm = TRUE))
keep <- x[dbls == max(dbls, na.rm = TRUE) | dbls == min(dbls, na.rm = TRUE)]
x[!x %in% keep] <- gsub("[>=<]", "", x[!x %in% keep])
}
set_clean_class(factor(x, levels = VALID_MIC_LEVELS, ordered = TRUE),
new_class = c("mic", "ordered", "factor"))
}
all_valid_mics <- function(x) {
if (!inherits(x, c("mic", "character", "factor", "numeric", "integer"))) {
return(FALSE)
}
x_mic <- tryCatch(suppressWarnings(as.mic(x[!is.na(x)])),
error = function(e) NA
)
!any(is.na(x_mic)) && !all(is.na(x))
#' @rdname as.mic
#' @export
is.mic <- function(x) {
inherits(x, "mic")
}
#' @rdname as.mic
#' @details `NA_mic_` is a missing value of the new `mic` class, analogous to e.g. base \R's [`NA_character_`][base::NA].
#' @format NULL
#' @export
NA_mic_ <- set_clean_class(factor(NA, levels = valid_mic_levels, ordered = TRUE),
NA_mic_ <- set_clean_class(factor(NA, levels = VALID_MIC_LEVELS, ordered = TRUE),
new_class = c("mic", "ordered", "factor")
)
#' @rdname as.mic
#' @param mic_range a manual range to limit the MIC values, e.g., `mic_range = c(0.001, 32)`. Use `NA` to set no limit on one side, e.g., `mic_range = c(NA, 32)`.
#' @export
is.mic <- function(x) {
inherits(x, "mic")
rescale_mic <- function(x, mic_range, keep_operators = "edges", as.mic = TRUE) {
meet_criteria(mic_range, allow_class = c("numeric", "integer", "logical"), has_length = 2, allow_NA = TRUE, allow_NULL = TRUE)
stop_ifnot(all(mic_range %in% c(VALID_MIC_LEVELS, NA)),
"Values in `mic_range` must be valid MIC values. Unvalid: ", vector_and(mic_range[mic_range %in% c(VALID_MIC_LEVELS, NA)]))
x <- as.mic(x)
if (is.null(mic_range)) {
mic_range <- c(NA, NA)
}
mic_range <- as.mic(mic_range)
min_mic <- mic_range[1]
max_mic <- mic_range[2]
if (!is.na(min_mic)) {
x[x < min_mic] <- min_mic
}
if (!is.na(max_mic)) {
x[x > max_mic] <- max_mic
}
x <- as.mic(x, keep_operators = ifelse(keep_operators == "edges", "none", keep_operators))
if (isTRUE(as.mic)) {
if (keep_operators == "edges") {
x[x == min(x, na.rm = TRUE)] <- paste0("<=", x[x == min(x, na.rm = TRUE)])
x[x == max(x, na.rm = TRUE)] <- paste0(">=", x[x == max(x, na.rm = TRUE)])
}
return(x)
}
# create a manual factor with levels only within desired range
expanded <- plotrange_as_table(x,
expand = TRUE,
keep_operators = ifelse(keep_operators == "edges", "none", keep_operators),
mic_range = mic_range)
if (keep_operators == "edges") {
names(expanded)[1] <- paste0("<=", names(expanded)[1])
names(expanded)[length(expanded)] <- paste0(">=", names(expanded)[length(expanded)])
}
# MICs contain all MIC levels, so strip this to only existing levels and their intermediate values
out <- factor(names(expanded),
levels = names(expanded),
ordered = TRUE)
# and only keep the ones in the data
if (keep_operators == "edges") {
out <- out[match(x, as.double(as.mic(out, keep_operators = "all")))]
} else {
out <- out[match(x, out)]
}
out
}
#' @method as.double mic
@@ -288,6 +343,7 @@ as.numeric.mic <- function(x, ...) {
#' @param as.mic a [logical] to indicate whether the `mic` class should be kept - the default is `FALSE`
#' @export
droplevels.mic <- function(x, as.mic = FALSE, ...) {
x <- as.mic(x) # make sure that currently implemented MIC levels are used
x <- droplevels.factor(x, ...)
if (as.mic == TRUE) {
class(x) <- c("mic", "ordered", "factor")
@@ -295,32 +351,50 @@ droplevels.mic <- function(x, as.mic = FALSE, ...) {
x
}
all_valid_mics <- function(x) {
if (!inherits(x, c("mic", "character", "factor", "numeric", "integer"))) {
return(FALSE)
}
x_mic <- tryCatch(suppressWarnings(as.mic(x[!is.na(x)])),
error = function(e) NA
)
!any(is.na(x_mic)) && !all(is.na(x))
}
# will be exported using s3_register() in R/zzz.R
pillar_shaft.mic <- function(x, ...) {
if(!identical(levels(x), VALID_MIC_LEVELS) && message_not_thrown_before("pillar_shaft.mic")) {
warning_(AMR_env$sup_1_icon, " These columns contain an outdated or altered structure - convert with `as.mic()` to update",
call = FALSE)
}
crude_numbers <- as.double(x)
operators <- gsub("[^<=>]+", "", as.character(x))
operators[!is.na(operators) & operators != ""] <- font_silver(operators[!is.na(operators) & operators != ""], collapse = NULL)
out <- trimws(paste0(operators, trimws(format(crude_numbers))))
out[is.na(x)] <- font_na(NA)
# maketrailing zeroes almost invisible
out[out %like% "[.]"] <- gsub("([.]?0+)$", font_white("\\1"), out[out %like% "[.]"], perl = TRUE)
# make trailing zeroes less visible
out[out %like% "[.]"] <- gsub("([.]?0+)$", font_silver("\\1"), out[out %like% "[.]"], perl = TRUE)
create_pillar_column(out, align = "right", width = max(nchar(font_stripstyle(out))))
}
# will be exported using s3_register() in R/zzz.R
type_sum.mic <- function(x, ...) {
"mic"
if(!identical(levels(x), VALID_MIC_LEVELS)) {
paste0("mic", AMR_env$sup_1_icon)
} else {
"mic"
}
}
#' @method print mic
#' @export
#' @noRd
print.mic <- function(x, ...) {
cat("Class 'mic'",
ifelse(length(levels(x)) < length(valid_mic_levels), font_red(" with dropped levels"), ""),
"\n",
sep = ""
)
cat("Class 'mic'")
if(!identical(levels(x), VALID_MIC_LEVELS)) {
cat(font_red(" with an outdated or altered structure - convert with `as.mic()` to update"))
}
cat("\n")
print(as.character(x), quote = FALSE)
att <- attributes(x)
if ("na.action" %in% names(att)) {
@@ -341,22 +415,44 @@ summary.mic <- function(object, ...) {
as.matrix.mic <- function(x, ...) {
as.matrix(as.double(x), ...)
}
#' @method as.vector mic
#' @export
#' @noRd
as.vector.mic <- function(x, mode = "numneric", ...) {
y <- NextMethod()
y <- as.mic(y)
calls <- unlist(lapply(sys.calls(), as.character))
if (any(calls %in% c("rbind", "cbind")) && message_not_thrown_before("as.vector.mic")) {
warning_("Functions `rbind()` and `cbind()` cannot preserve the structure of MIC values. Use dplyr's `bind_rows()` or `bind_cols()` instead.", call = FALSE)
}
y
}
#' @method as.list mic
#' @export
#' @noRd
as.list.mic <- function(x, ...) {
lapply(as.list(as.character(x), ...), as.mic)
}
#' @method as.data.frame mic
#' @export
#' @noRd
as.data.frame.mic <- function(x, ...) {
as.data.frame.vector(as.mic(x), ...)
}
#' @method [ mic
#' @export
#' @noRd
"[.mic" <- function(x, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
as.mic(y)
}
#' @method [[ mic
#' @export
#' @noRd
"[[.mic" <- function(x, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
as.mic(y)
}
#' @method [<- mic
#' @export
@@ -364,8 +460,7 @@ as.matrix.mic <- function(x, ...) {
"[<-.mic" <- function(i, j, ..., value) {
value <- as.mic(value)
y <- NextMethod()
attributes(y) <- attributes(i)
y
as.mic(y)
}
#' @method [[<- mic
#' @export
@@ -373,8 +468,7 @@ as.matrix.mic <- function(x, ...) {
"[[<-.mic" <- function(i, j, ..., value) {
value <- as.mic(value)
y <- NextMethod()
attributes(y) <- attributes(i)
y
as.mic(y)
}
#' @method c mic
#' @export
@@ -388,8 +482,7 @@ c.mic <- function(...) {
#' @noRd
unique.mic <- function(x, incomparables = FALSE, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
as.mic(y)
}
#' @method rep mic
@@ -397,20 +490,25 @@ unique.mic <- function(x, incomparables = FALSE, ...) {
#' @noRd
rep.mic <- function(x, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
as.mic(y)
}
#' @method sort mic
#' @export
#' @noRd
sort.mic <- function(x, decreasing = FALSE, ...) {
x <- as.mic(x) # make sure that currently implemented MIC levels are used
dbl <- as.double(x)
# make sure that e.g. '<0.001' comes before '0.001', and '>0.001' comes after
dbl[as.character(x) %like% "<[0-9]"] <- dbl[as.character(x) %like% "<[0-9]"] - 0.000002
dbl[as.character(x) %like% "<="] <- dbl[as.character(x) %like% "<="] - 0.000001
dbl[as.character(x) %like% ">="] <- dbl[as.character(x) %like% ">="] + 0.000001
dbl[as.character(x) %like% ">[0-9]"] <- dbl[as.character(x) %like% ">[0-9]"] + 0.000002
if (decreasing == TRUE) {
ord <- order(-as.double(x))
x[order(-dbl)]
} else {
ord <- order(as.double(x))
x[order(dbl)]
}
x[ord]
}
#' @method hist mic
@@ -424,6 +522,7 @@ hist.mic <- function(x, ...) {
# will be exported using s3_register() in R/zzz.R
get_skimmers.mic <- function(column) {
column <- as.mic(column) # make sure that currently implemented MIC levels are used
skimr::sfl(
skim_type = "mic",
p0 = ~ stats::quantile(., probs = 0, na.rm = TRUE, names = FALSE),
@@ -475,12 +574,23 @@ Math.mic <- function(x, ...) {
#' @export
Ops.mic <- function(e1, e2) {
e1_chr <- as.character(e1)
e2_chr <- character(0)
e1 <- as.double(e1)
if (!missing(e2)) {
# when e1 is `!`, e2 is missing
# when .Generic is `!`, e2 is missing
e2_chr <- as.character(e2)
e2 <- as.double(e2)
}
# set class to numeric, because otherwise NextMethod will be factor (since mic is a factor)
if (as.character(.Generic) %in% c("<", "<=", "==", "!=", ">", ">=")) {
# make sure that <0.002 is lower than 0.002
# and that >32 is higher than 32, but equal to >=32
e1[e1_chr %like% "<" & e1_chr %unlike% "="] <- e1[e1_chr %like% "<" & e1_chr %unlike% "="] - 0.000001
e1[e1_chr %like% ">" & e1_chr %unlike% "="] <- e1[e1_chr %like% ">" & e1_chr %unlike% "="] + 0.000001
e2[e2_chr %like% "<" & e2_chr %unlike% "="] <- e2[e2_chr %like% "<" & e2_chr %unlike% "="] - 0.000001
e2[e2_chr %like% ">" & e2_chr %unlike% "="] <- e2[e2_chr %like% ">" & e2_chr %unlike% "="] + 0.000001
}
# set .Class to numeric, because otherwise NextMethod will be factor (since mic is a factor)
.Class <- class(e1)
NextMethod(.Generic)
}
+155 -94
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -38,17 +38,19 @@
#'
#' This excludes enterococci at default (who are in group D), use `Lancefield = "all"` to also categorise all enterococci as group D.
#' @param minimum_matching_score a numeric value to set as the lower limit for the [MO matching score][mo_matching_score()]. When left blank, this will be determined automatically based on the character length of `x`, its [taxonomic kingdom][microorganisms] and [human pathogenicity][mo_matching_score()].
#' @param keep_synonyms a [logical] to indicate if old, previously valid taxonomic names must be preserved and not be corrected to currently accepted names. The default is `FALSE`, which will return a note if old taxonomic names were processed. The default can be set with the [package option][AMR-options] [`AMR_keep_synonyms`][AMR-options], i.e. `options(AMR_keep_synonyms = TRUE)` or `options(AMR_keep_synonyms = FALSE)`.
#' @param keep_synonyms a [logical] to indicate if old, previously valid taxonomic names must be preserved and not be corrected to currently accepted names. The default is `FALSE`, which will return a note if old taxonomic names were processed. The default can be set with the package option [`AMR_keep_synonyms`][AMR-options], i.e. `options(AMR_keep_synonyms = TRUE)` or `options(AMR_keep_synonyms = FALSE)`.
#' @param reference_df a [data.frame] to be used for extra reference when translating `x` to a valid [`mo`]. See [set_mo_source()] and [get_mo_source()] to automate the usage of your own codes (e.g. used in your analysis or organisation).
#' @param ignore_pattern a Perl-compatible [regular expression][base::regex] (case-insensitive) of which all matches in `x` must return `NA`. This can be convenient to exclude known non-relevant input and can also be set with the [package option][AMR-options] [`AMR_ignore_pattern`][AMR-options], e.g. `options(AMR_ignore_pattern = "(not reported|contaminated flora)")`.
#' @param cleaning_regex a Perl-compatible [regular expression][base::regex] (case-insensitive) to clean the input of `x`. Every matched part in `x` will be removed. At default, this is the outcome of [mo_cleaning_regex()], which removes texts between brackets and texts such as "species" and "serovar". The default can be set with the [package option][AMR-options] [`AMR_cleaning_regex`][AMR-options].
#' @param ignore_pattern a Perl-compatible [regular expression][base::regex] (case-insensitive) of which all matches in `x` must return `NA`. This can be convenient to exclude known non-relevant input and can also be set with the package option [`AMR_ignore_pattern`][AMR-options], e.g. `options(AMR_ignore_pattern = "(not reported|contaminated flora)")`.
#' @param cleaning_regex a Perl-compatible [regular expression][base::regex] (case-insensitive) to clean the input of `x`. Every matched part in `x` will be removed. At default, this is the outcome of [mo_cleaning_regex()], which removes texts between brackets and texts such as "species" and "serovar". The default can be set with the package option [`AMR_cleaning_regex`][AMR-options].
#' @param only_fungi a [logical] to indicate if only fungi must be found, making sure that e.g. misspellings always return records from the kingdom of Fungi. This can be set globally for [all microorganism functions][mo_property()] with the package option [`AMR_only_fungi`][AMR-options], i.e. `options(AMR_only_fungi = TRUE)`.
#' @param language language to translate text like "no growth", which defaults to the system language (see [get_AMR_locale()])
#' @param info a [logical] to indicate if a progress bar should be printed if more than 25 items are to be coerced - the default is `TRUE` only in interactive mode
#' @param info a [logical] to indicate that info must be printed, e.g. a progress bar when more than 25 items are to be coerced, or a list with old taxonomic names. The default is `TRUE` only in interactive mode.
#' @param ... other arguments passed on to functions
#' @rdname as.mo
#' @aliases mo
#' @details
#' A microorganism (MO) code from this package (class: [`mo`]) is human readable and typically looks like these examples:
#' A microorganism (MO) code from this package (class: [`mo`]) is human-readable and typically looks like these examples:
#'
#' ```
#' Code Full name
#' --------------- --------------------------------------
@@ -60,49 +62,74 @@
#' | | | \---> subspecies, a 3-5 letter acronym
#' | | \----> species, a 3-6 letter acronym
#' | \----> genus, a 4-8 letter acronym
#' \----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
#' F (Fungi), PL (Plantae), P (Protozoa)
#' \----> kingdom: A (Archaea), AN (Animalia), B (Bacteria),
#' C (Chromista), F (Fungi), PL (Plantae),
#' P (Protozoa)
#' ```
#'
#' Values that cannot be coerced will be considered 'unknown' and will be returned as the MO code `UNKNOWN` with a warning.
#' Values that cannot be coerced will be considered 'unknown' and will return the MO code `UNKNOWN` with a warning.
#'
#' Use the [`mo_*`][mo_property()] functions to get properties based on the returned code, see *Examples*.
#'
#' The [as.mo()] function uses a novel [matching score algorithm][mo_matching_score()] (see *Matching Score for Microorganisms* below) to match input against the [available microbial taxonomy][microorganisms] in this package. This will lead to the effect that e.g. `"E. coli"` (a microorganism highly prevalent in humans) will return the microbial ID of *Escherichia coli* and not *Entamoeba coli* (a microorganism less prevalent in humans), although the latter would alphabetically come first.
#'
#' With `Becker = TRUE`, the following `r length(MO_CONS[MO_CONS != "B_STPHY_CONS"])` staphylococci will be converted to the **coagulase-negative group**: `r vector_and(gsub("Staphylococcus", "S.", mo_name(MO_CONS[MO_CONS != "B_STPHY_CONS"], keep_synonyms = TRUE)), quotes = "*")`.\cr The following `r length(MO_COPS[MO_COPS != "B_STPHY_COPS"])` staphylococci will be converted to the **coagulase-positive group**: `r vector_and(gsub("Staphylococcus", "S.", mo_name(MO_COPS[MO_COPS != "B_STPHY_COPS"], keep_synonyms = TRUE)), quotes = "*")`.
#'
#' With `Lancefield = TRUE`, the following streptococci will be converted to their corresponding Lancefield group: `r vector_and(gsub("Streptococcus", "S.", paste0("*", mo_name(MO_LANCEFIELD, keep_synonyms = TRUE), "* (", mo_species(MO_LANCEFIELD, keep_synonyms = TRUE, Lancefield = TRUE), ")")), quotes = FALSE)`.
#' The [as.mo()] function uses a novel and scientifically validated (\doi{10.18637/jss.v104.i03}) matching score algorithm (see *Matching Score for Microorganisms* below) to match input against the [available microbial taxonomy][microorganisms] in this package. This implicates that e.g. `"E. coli"` (a microorganism highly prevalent in humans) will return the microbial ID of *Escherichia coli* and not *Entamoeba coli* (a microorganism less prevalent in humans), although the latter would alphabetically come first.
#'
#' ### Coping with Uncertain Results
#'
#' Results of non-exact taxonomic input are based on their [matching score][mo_matching_score()]. The lowest allowed score can be set with the `minimum_matching_score` argument. At default this will be determined based on the character length of the input, and the [taxonomic kingdom][microorganisms] and [human pathogenicity][mo_matching_score()] of the taxonomic outcome. If values are matched with uncertainty, a message will be shown to suggest the user to evaluate the results with [mo_uncertainties()], which returns a [data.frame] with all specifications.
#' Results of non-exact taxonomic input are based on their [matching score][mo_matching_score()]. The lowest allowed score can be set with the `minimum_matching_score` argument. At default this will be determined based on the character length of the input, the [taxonomic kingdom][microorganisms], and the [human pathogenicity][mo_matching_score()] of the taxonomic outcome. If values are matched with uncertainty, a message will be shown to suggest the user to inspect the results with [mo_uncertainties()], which returns a [data.frame] with all specifications.
#'
#' To increase the quality of matching, the `cleaning_regex` argument can be used to clean the input (i.e., `x`). This must be a [regular expression][base::regex] that matches parts of the input that should be removed before the input is matched against the [available microbial taxonomy][microorganisms]. It will be matched Perl-compatible and case-insensitive. The default value of `cleaning_regex` is the outcome of the helper function [mo_cleaning_regex()].
#' To increase the quality of matching, the `cleaning_regex` argument is used to clean the input. This must be a [regular expression][base::regex] that matches parts of the input that should be removed before the input is matched against the [available microbial taxonomy][microorganisms]. It will be matched Perl-compatible and case-insensitive. The default value of `cleaning_regex` is the outcome of the helper function [mo_cleaning_regex()].
#'
#' There are three helper functions that can be run after using the [as.mo()] function:
#' - Use [mo_uncertainties()] to get a [data.frame] that prints in a pretty format with all taxonomic names that were guessed. The output contains the matching score for all matches (see *Matching Score for Microorganisms* below).
#' - Use [mo_failures()] to get a [character] [vector] with all values that could not be coerced to a valid value.
#' - Use [mo_renamed()] to get a [data.frame] with all values that could be coerced based on old, previously accepted taxonomic names.
#'
#' ### Microbial Prevalence of Pathogens in Humans
#' ### For Mycologists
#'
#' The [matching score algorithm][mo_matching_score()] gives precedence to bacteria over fungi. If you are only analysing fungi, be sure to use `only_fungi = TRUE`, or better yet, add this to your code and run it once every session:
#'
#' ```r
#' options(AMR_only_fungi = TRUE)
#' ```
#'
#' This will make sure that no bacteria or other 'non-fungi' will be returned by [as.mo()], or any of the [`mo_*`][mo_property()] functions.
#'
#' The coercion rules consider the prevalence of microorganisms in humans, which is available as the `prevalence` column in the [microorganisms] data set. The grouping into human pathogenic prevalence is explained in the section *Matching Score for Microorganisms* below.
#' ### Coagulase-negative and Coagulase-positive Staphylococci
#'
#' With `Becker = TRUE`, the following staphylococci will be converted to their corresponding coagulase group:
#'
#' * Coagulase-negative: `r vector_and(gsub("Staphylococcus", "S.", mo_name(MO_CONS[MO_CONS != "B_STPHY_CONS"], keep_synonyms = TRUE)), quotes = "*")`
#' * Coagulase-positive: `r vector_and(gsub("Staphylococcus", "S.", mo_name(MO_COPS[MO_COPS != "B_STPHY_COPS"], keep_synonyms = TRUE)), quotes = "*")`
#'
#' This is based on:
#'
#' * Becker K *et al.* (2014). **Coagulase-Negative Staphylococci.** *Clin Microbiol Rev.* 27(4): 870-926; \doi{10.1128/CMR.00109-13}
#' * Becker K *et al.* (2019). **Implications of identifying the recently defined members of the *S. aureus* complex, *S. argenteus* and *S. schweitzeri*: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).** *Clin Microbiol Infect*; \doi{10.1016/j.cmi.2019.02.028}
#' * Becker K *et al.* (2020). **Emergence of coagulase-negative staphylococci.** *Expert Rev Anti Infect Ther.* 18(4):349-366; \doi{10.1080/14787210.2020.1730813}
#'
#' For newly named staphylococcal species, such as *S. brunensis* (2024) and *S. shinii* (2023), we looked up the scientific reference to make sure the species are considered for the correct coagulase group.
#'
#' ### Lancefield Groups in Streptococci
#'
#' With `Lancefield = TRUE`, the following streptococci will be converted to their corresponding Lancefield group:
#'
#' * `r paste(apply(aggregate(mo_name ~ mo_group_name, data = microorganisms.groups[microorganisms.groups$mo_group_name %like_case% "Streptococcus Group [A-Z]$", ], FUN = function(x) vector_and(gsub("Streptococcus", "S.", x, fixed = TRUE), quotes = "*", sort = TRUE)), 1, function(row) paste(row["mo_group_name"], ": ", row["mo_name"], sep = "")), collapse = "\n* ")`
#'
#' This is based on:
#'
#' * Lancefield RC (1933). **A serological differentiation of human and other groups of hemolytic streptococci.** *J Exp Med.* 57(4): 571-95; \doi{10.1084/jem.57.4.571}
#'
#' @inheritSection mo_matching_score Matching Score for Microorganisms
#'
# (source as a section here, so it can be inherited by other man pages)
#' @section Source:
#' 1. Berends MS *et al.* (2022). **AMR: An R Package for Working with Antimicrobial Resistance Data**. *Journal of Statistical Software*, 104(3), 1-31; \doi{10.18637/jss.v104.i03}
#' 2. Becker K *et al.* (2014). **Coagulase-Negative Staphylococci.** *Clin Microbiol Rev.* 27(4): 870-926; \doi{10.1128/CMR.00109-13}
#' 3. Becker K *et al.* (2019). **Implications of identifying the recently defined members of the *S. aureus* complex, *S. argenteus* and *S. schweitzeri*: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).** *Clin Microbiol Infect*; \doi{10.1016/j.cmi.2019.02.028}
#' 4. Becker K *et al.* (2020). **Emergence of coagulase-negative staphylococci.** *Expert Rev Anti Infect Ther.* 18(4):349-366; \doi{10.1080/14787210.2020.1730813}
#' 5. Lancefield RC (1933). **A serological differentiation of human and other groups of hemolytic streptococci.** *J Exp Med.* 57(4): 571-95; \doi{10.1084/jem.57.4.571}
#' 6. Berends MS *et al.* (2022). **Trends in Occurrence and Phenotypic Resistance of Coagulase-Negative Staphylococci (CoNS) Found in Human Blood in the Northern Netherlands between 2013 and 2019/** *Micro.rganisms* 10(9), 1801; \doi{10.3390/microorganisms10091801}
#' 7. `r TAXONOMY_VERSION$LPSN$citation` Accessed from <`r TAXONOMY_VERSION$LPSN$url`> on `r documentation_date(TAXONOMY_VERSION$LPSN$accessed_date)`.
#' 8. `r TAXONOMY_VERSION$GBIF$citation` Accessed from <`r TAXONOMY_VERSION$GBIF$url`> on `r documentation_date(TAXONOMY_VERSION$GBIF$accessed_date)`.
#' 9. `r TAXONOMY_VERSION$BacDive$citation` Accessed from <`r TAXONOMY_VERSION$BacDive$url`> on `r documentation_date(TAXONOMY_VERSION$BacDive$accessed_date)`.
#' 10. `r TAXONOMY_VERSION$SNOMED$citation` URL: <`r TAXONOMY_VERSION$SNOMED$url`>
#' 11. Bartlett A *et al.* (2022). **A comprehensive list of bacterial pathogens infecting humans** *Microbiology* 168:001269; \doi{10.1099/mic.0.001269}
#' * Berends MS *et al.* (2022). **AMR: An R Package for Working with Antimicrobial Resistance Data**. *Journal of Statistical Software*, 104(3), 1-31; \doi{10.18637/jss.v104.i03}
#' * `r TAXONOMY_VERSION$LPSN$citation` Accessed from <`r TAXONOMY_VERSION$LPSN$url`> on `r documentation_date(TAXONOMY_VERSION$LPSN$accessed_date)`.
#' * `r TAXONOMY_VERSION$MycoBank$citation` Accessed from <`r TAXONOMY_VERSION$MycoBank$url`> on `r documentation_date(TAXONOMY_VERSION$MycoBank$accessed_date)`.
#' * `r TAXONOMY_VERSION$GBIF$citation` Accessed from <`r TAXONOMY_VERSION$GBIF$url`> on `r documentation_date(TAXONOMY_VERSION$GBIF$accessed_date)`.
#' * `r TAXONOMY_VERSION$BacDive$citation` Accessed from <`r TAXONOMY_VERSION$BacDive$url`> on `r documentation_date(TAXONOMY_VERSION$BacDive$accessed_date)`.
#' * `r TAXONOMY_VERSION$SNOMED$citation` URL: <`r TAXONOMY_VERSION$SNOMED$url`>
#' * Bartlett A *et al.* (2022). **A comprehensive list of bacterial pathogens infecting humans** *Microbiology* 168:001269; \doi{10.1099/mic.0.001269}
#' @export
#' @return A [character] [vector] with additional class [`mo`]
#' @seealso [microorganisms] for the [data.frame] that is being used to determine ID's.
@@ -160,6 +187,7 @@ as.mo <- function(x,
reference_df = get_mo_source(),
ignore_pattern = getOption("AMR_ignore_pattern", NULL),
cleaning_regex = getOption("AMR_cleaning_regex", mo_cleaning_regex()),
only_fungi = getOption("AMR_only_fungi", FALSE),
language = get_AMR_locale(),
info = interactive(),
...) {
@@ -171,6 +199,7 @@ as.mo <- function(x,
meet_criteria(reference_df, allow_class = "data.frame", allow_NULL = TRUE)
meet_criteria(ignore_pattern, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(cleaning_regex, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(only_fungi, allow_class = "logical", has_length = 1)
language <- validate_language(language)
meet_criteria(info, allow_class = "logical", has_length = 1)
@@ -224,7 +253,7 @@ as.mo <- function(x,
out[is.na(out)] <- convert_colloquial_input(x[is.na(out)])
# From previous hits in this session ----
old <- out
out[is.na(out) & paste(x, minimum_matching_score) %in% AMR_env$mo_previously_coerced$x] <- AMR_env$mo_previously_coerced$mo[match(paste(x, minimum_matching_score)[is.na(out) & paste(x, minimum_matching_score) %in% AMR_env$mo_previously_coerced$x], AMR_env$mo_previously_coerced$x)]
out[is.na(out) & paste(x, minimum_matching_score, only_fungi) %in% AMR_env$mo_previously_coerced$x] <- AMR_env$mo_previously_coerced$mo[match(paste(x, minimum_matching_score, only_fungi)[is.na(out) & paste(x, minimum_matching_score, only_fungi) %in% AMR_env$mo_previously_coerced$x], AMR_env$mo_previously_coerced$x)]
new <- out
if (isTRUE(info) && message_not_thrown_before("as.mo", old, new, entire_session = TRUE) && any(is.na(old) & !is.na(new), na.rm = TRUE)) {
message_(
@@ -250,11 +279,16 @@ as.mo <- function(x,
x_unique <- unique(x[is.na(out) & !is.na(x)])
# set up progress bar
progress <- progress_ticker(n = length(x_unique), n_min = 10, print = info)
progress <- progress_ticker(n = length(x_unique), n_min = 10, print = info, title = "Converting microorganism input")
on.exit(close(progress))
msg <- character(0)
MO_lookup_current <- AMR_env$MO_lookup
if (isTRUE(only_fungi)) {
MO_lookup_current <- MO_lookup_current[MO_lookup_current$kingdom == "Fungi", , drop = FALSE]
}
# run it
x_coerced <- vapply(FUN.VALUE = character(1), x_unique, function(x_search) {
progress$tick()
@@ -270,8 +304,8 @@ as.mo <- function(x,
x_search_cleaned[x_search_cleaned == toupper(x_search_cleaned)] <- x_out[x_search_cleaned == toupper(x_search_cleaned)]
# first check if cleaning led to an exact result, case-insensitive
if (x_out %in% AMR_env$MO_lookup$fullname_lower) {
return(as.character(AMR_env$MO_lookup$mo[match(x_out, AMR_env$MO_lookup$fullname_lower)]))
if (x_out %in% MO_lookup_current$fullname_lower) {
return(as.character(MO_lookup_current$mo[match(x_out, MO_lookup_current$fullname_lower)]))
}
# input must not be too short
@@ -281,48 +315,53 @@ as.mo <- function(x,
# take out the parts, split by space
x_parts <- strsplit(gsub("-", " ", x_out, fixed = TRUE), " ", fixed = TRUE)[[1]]
# do a pre-match on first character (and if it contains a space, first chars of first two terms)
if (length(x_parts) %in% c(2, 3)) {
# for genus + species + subspecies
if (nchar(gsub("[^a-z]", "", x_parts[1], perl = TRUE)) <= 3) {
filtr <- which(AMR_env$MO_lookup$full_first == substr(x_parts[1], 1, 1) &
(AMR_env$MO_lookup$species_first == substr(x_parts[2], 1, 1) |
AMR_env$MO_lookup$subspecies_first == substr(x_parts[2], 1, 1) |
AMR_env$MO_lookup$subspecies_first == substr(x_parts[3], 1, 1)))
if (paste(x_parts[1:2], collapse = " ") %in% MO_lookup_current$fullname_lower) {
filtr <- which(MO_lookup_current$fullname_lower %like% paste(x_parts[1:2], collapse = " "))
} else if (x_parts[1] %in% MO_lookup_current$genus_lower && !paste(x_parts[1:2], collapse = " ") %in% MO_lookup_current$fullname_lower) {
# for a known genus, but unknown (sub)species
filtr <- which(MO_lookup_current$genus_lower == x_parts[1])
minimum_matching_score <- 0.05
} else if (nchar(gsub("[^a-z]", "", x_parts[1], perl = TRUE)) <= 3) {
filtr <- which(MO_lookup_current$full_first == substr(x_parts[1], 1, 1) &
(MO_lookup_current$species_first == substr(x_parts[2], 1, 1) |
MO_lookup_current$subspecies_first == substr(x_parts[2], 1, 1) |
MO_lookup_current$subspecies_first == substr(x_parts[3], 1, 1)))
} else {
filtr <- which(AMR_env$MO_lookup$full_first == substr(x_parts[1], 1, 1) |
AMR_env$MO_lookup$species_first == substr(x_parts[2], 1, 1) |
AMR_env$MO_lookup$subspecies_first == substr(x_parts[2], 1, 1) |
AMR_env$MO_lookup$subspecies_first == substr(x_parts[3], 1, 1))
filtr <- which(MO_lookup_current$full_first == substr(x_parts[1], 1, 1) |
MO_lookup_current$species_first == substr(x_parts[2], 1, 1) |
MO_lookup_current$subspecies_first == substr(x_parts[2], 1, 1) |
MO_lookup_current$subspecies_first == substr(x_parts[3], 1, 1))
}
} else if (length(x_parts) > 3) {
first_chars <- paste0("(^| )[", paste(substr(x_parts, 1, 1), collapse = ""), "]")
filtr <- which(AMR_env$MO_lookup$full_first %like_case% first_chars)
filtr <- which(MO_lookup_current$full_first %like_case% first_chars)
} else if (nchar(x_out) == 3) {
# no space and 3 characters - probably a code such as SAU or ECO
msg <<- c(msg, paste0("Input \"", x_search, "\" was assumed to be a microorganism code - tried to match on \"", totitle(substr(x_out, 1, 1)), AMR_env$dots, " ", substr(x_out, 2, 3), AMR_env$dots, "\""))
filtr <- which(AMR_env$MO_lookup$fullname_lower %like_case% paste0("(^| )", substr(x_out, 1, 1), ".* ", substr(x_out, 2, 3)))
filtr <- which(MO_lookup_current$fullname_lower %like_case% paste0("(^| )", substr(x_out, 1, 1), ".* ", substr(x_out, 2, 3)))
} else if (nchar(x_out) == 4) {
# no space and 4 characters - probably a code such as STAU or ESCO
msg <<- c(msg, paste0("Input \"", x_search, "\" was assumed to be a microorganism code - tried to match on \"", totitle(substr(x_out, 1, 2)), AMR_env$dots, " ", substr(x_out, 3, 4), AMR_env$dots, "\""))
filtr <- which(AMR_env$MO_lookup$fullname_lower %like_case% paste0("(^| )", substr(x_out, 1, 2), ".* ", substr(x_out, 3, 4)))
filtr <- which(MO_lookup_current$fullname_lower %like_case% paste0("(^| )", substr(x_out, 1, 2), ".* ", substr(x_out, 3, 4)))
} else if (nchar(x_out) <= 6) {
# no space and 5-6 characters - probably a code such as STAAUR or ESCCOL
first_part <- paste0(substr(x_out, 1, 2), "[a-z]*", substr(x_out, 3, 3))
second_part <- substr(x_out, 4, nchar(x_out))
msg <<- c(msg, paste0("Input \"", x_search, "\" was assumed to be a microorganism code - tried to match on \"", gsub("[a-z]*", AMR_env$dots, totitle(first_part), fixed = TRUE), " ", second_part, AMR_env$dots, "\""))
filtr <- which(AMR_env$MO_lookup$fullname_lower %like_case% paste0("(^| )", first_part, ".* ", second_part))
filtr <- which(MO_lookup_current$fullname_lower %like_case% paste0("(^| )", first_part, ".* ", second_part))
} else {
# for genus or species or subspecies
filtr <- which(AMR_env$MO_lookup$full_first == substr(x_parts, 1, 1) |
AMR_env$MO_lookup$species_first == substr(x_parts, 1, 1) |
AMR_env$MO_lookup$subspecies_first == substr(x_parts, 1, 1))
filtr <- which(MO_lookup_current$full_first == substr(x_parts, 1, 1) |
MO_lookup_current$species_first == substr(x_parts, 1, 1) |
MO_lookup_current$subspecies_first == substr(x_parts, 1, 1))
}
if (length(filtr) == 0) {
mo_to_search <- AMR_env$MO_lookup$fullname
mo_to_search <- MO_lookup_current$fullname
} else {
mo_to_search <- AMR_env$MO_lookup$fullname[filtr]
mo_to_search <- MO_lookup_current$fullname[filtr]
}
AMR_env$mo_to_search <- mo_to_search
@@ -331,9 +370,9 @@ as.mo <- function(x,
if (is.null(minimum_matching_score)) {
minimum_matching_score_current <- min(0.6, min(10, nchar(x_search_cleaned)) * 0.08)
# correct back for prevalence
minimum_matching_score_current <- minimum_matching_score_current / AMR_env$MO_lookup$prevalence[match(mo_to_search, AMR_env$MO_lookup$fullname)]
minimum_matching_score_current <- minimum_matching_score_current / MO_lookup_current$prevalence[match(mo_to_search, MO_lookup_current$fullname)]
# correct back for kingdom
minimum_matching_score_current <- minimum_matching_score_current / AMR_env$MO_lookup$kingdom_index[match(mo_to_search, AMR_env$MO_lookup$fullname)]
minimum_matching_score_current <- minimum_matching_score_current / MO_lookup_current$kingdom_index[match(mo_to_search, MO_lookup_current$fullname)]
minimum_matching_score_current <- pmax(minimum_matching_score_current, m)
if (length(x_parts) > 1 && all(m <= 0.55, na.rm = TRUE)) {
# if the highest score is 0.5, we have nothing serious - 0.5 is the lowest for pathogenic group 1
@@ -352,7 +391,7 @@ as.mo <- function(x,
warning_("No hits found for \"", x_search, "\" with minimum_matching_score = ", ifelse(is.null(minimum_matching_score), paste0("NULL (=", round(min(minimum_matching_score_current, na.rm = TRUE), 3), ")"), minimum_matching_score), ". Try setting this value lower or even to 0.", call = FALSE)
result_mo <- NA_character_
} else {
result_mo <- AMR_env$MO_lookup$mo[match(top_hits[1], AMR_env$MO_lookup$fullname)]
result_mo <- MO_lookup_current$mo[match(top_hits[1], MO_lookup_current$fullname)]
AMR_env$mo_uncertainties <- rbind_AMR(
AMR_env$mo_uncertainties,
data.frame(
@@ -370,7 +409,7 @@ as.mo <- function(x,
AMR_env$mo_previously_coerced <- unique(rbind_AMR(
AMR_env$mo_previously_coerced,
data.frame(
x = paste(x_search, minimum_matching_score),
x = paste(x_search, minimum_matching_score, only_fungi),
mo = result_mo,
stringsAsFactors = FALSE
)
@@ -416,20 +455,10 @@ as.mo <- function(x,
} # end of loop over all yet unknowns
# Keep or replace synonyms ----
lpsn_matches <- AMR_env$MO_lookup$lpsn_renamed_to[match(out, AMR_env$MO_lookup$mo)]
lpsn_matches[!lpsn_matches %in% AMR_env$MO_lookup$lpsn] <- NA
# GBIF only for non-bacteria, since we use LPSN as primary source for bacteria
# (an example is Strep anginosus, renamed according to GBIF, not according to LPSN)
gbif_matches <- AMR_env$MO_lookup$gbif_renamed_to[AMR_env$MO_lookup$kingdom != "Bacteria"][match(out, AMR_env$MO_lookup$mo[AMR_env$MO_lookup$kingdom != "Bacteria"])]
gbif_matches[!gbif_matches %in% AMR_env$MO_lookup$gbif] <- NA
AMR_env$mo_renamed <- list(
old = out[!is.na(gbif_matches) | !is.na(lpsn_matches)],
gbif_matches = gbif_matches[!is.na(gbif_matches) | !is.na(lpsn_matches)],
lpsn_matches = lpsn_matches[!is.na(gbif_matches) | !is.na(lpsn_matches)]
)
out_current <- synonym_mo_to_accepted_mo(out, fill_in_accepted = FALSE)
AMR_env$mo_renamed <- list(old = out[!is.na(out_current)])
if (isFALSE(keep_synonyms)) {
out[which(!is.na(gbif_matches))] <- AMR_env$MO_lookup$mo[match(gbif_matches[which(!is.na(gbif_matches))], AMR_env$MO_lookup$gbif)]
out[which(!is.na(lpsn_matches))] <- AMR_env$MO_lookup$mo[match(lpsn_matches[which(!is.na(lpsn_matches))], AMR_env$MO_lookup$lpsn)]
out[!is.na(out_current)] <- out_current[!is.na(out_current)]
if (isTRUE(info) && length(AMR_env$mo_renamed$old) > 0) {
print(mo_renamed(), extra_txt = " (use `keep_synonyms = TRUE` to leave uncorrected)")
}
@@ -439,7 +468,7 @@ as.mo <- function(x,
}
# Apply Becker ----
if (isTRUE(Becker) || Becker == "all") {
if (!isTRUE(only_fungi) && (isTRUE(Becker) || Becker == "all")) {
# warn when species found that are not in:
# - Becker et al. 2014, PMID 25278577
# - Becker et al. 2019, PMID 30872103
@@ -460,7 +489,7 @@ as.mo <- function(x,
}
}
# 'MO_CONS' and 'MO_COPS' are 'mo' vectors created in R/_pre_commit_hook.R
# 'MO_CONS' and 'MO_COPS' are 'mo' vectors created in R/_pre_commit_checks.R
out[out %in% MO_CONS] <- "B_STPHY_CONS"
out[out %in% MO_COPS] <- "B_STPHY_COPS"
if (Becker == "all") {
@@ -469,7 +498,7 @@ as.mo <- function(x,
}
# Apply Lancefield ----
if (isTRUE(Lancefield) || Lancefield == "all") {
if (!isTRUE(only_fungi) && (isTRUE(Lancefield) || Lancefield == "all")) {
# (using `%like_case%` to also match subspecies)
# group A - S. pyogenes
@@ -567,7 +596,8 @@ mo_reset_session <- function() {
mo_cleaning_regex <- function() {
parts_to_remove <- c("e?spp([^a-z]+|$)", "e?ssp([^a-z]+|$)", "e?ss([^a-z]+|$)", "e?sp([^a-z]+|$)", "e?subsp", "sube?species", "e?species",
"biovar[a-z]*", "biotype", "serovar[a-z]*", "var([^a-z]+|$)", "serogr.?up[a-z]*",
"titer", "dummy", "Ig[ADEGM]")
"titer", "dummy", "Ig[ADEGM]", " ?[a-z-]+[-](resistant|susceptible) ?")
paste0(
"(",
"[^A-Za-z- \\(\\)\\[\\]{}]+",
@@ -926,11 +956,15 @@ print.mo_uncertainties <- function(x, n = 10, ...) {
),
collapse = "\n"
),
# Add note if result was coerced to accepted taxonomic name
ifelse(x[i, ]$keep_synonyms == FALSE & x[i, ]$mo %in% AMR_env$MO_lookup$mo[which(AMR_env$MO_lookup$status == "synonym")],
ifelse(x[i, ]$mo %in% AMR_env$MO_lookup$mo[which(AMR_env$MO_lookup$status == "synonym")],
paste0(
strrep(" ", nchar(x[i, ]$original_input) + 6),
font_red(paste0("This old taxonomic name was converted to ", font_italic(AMR_env$MO_lookup$fullname[match(synonym_mo_to_accepted_mo(x[i, ]$mo), AMR_env$MO_lookup$mo)], collapse = NULL), " (", synonym_mo_to_accepted_mo(x[i, ]$mo), ")."), collapse = NULL)
ifelse(x[i, ]$keep_synonyms == FALSE,
# Add note if result was coerced to accepted taxonomic name
font_red(paste0("This outdated taxonomic name was converted to ", font_italic(AMR_env$MO_lookup$fullname[match(synonym_mo_to_accepted_mo(x[i, ]$mo), AMR_env$MO_lookup$mo)], collapse = NULL), " (", synonym_mo_to_accepted_mo(x[i, ]$mo), ")."), collapse = NULL),
# Or add note if result is currently another taxonomic name
font_red(paste0(font_bold("Note: "), "The current name is ", font_italic(AMR_env$MO_lookup$fullname[match(synonym_mo_to_accepted_mo(x[i, ]$mo), AMR_env$MO_lookup$mo)], collapse = NULL), " (", AMR_env$MO_lookup$ref[match(synonym_mo_to_accepted_mo(x[i, ]$mo), AMR_env$MO_lookup$mo)], ")."), collapse = NULL)
)
),
""
),
@@ -1038,13 +1072,17 @@ convert_colloquial_input <- function(x) {
out[x %like_case% "anaerob[a-z]+ .*gram[ -]?neg.*"] <- "B_ANAER-NEG"
out[x %like_case% "anaerob[a-z]+ .*gram[ -]?pos.*"] <- "B_ANAER-POS"
out[is.na(out) & x %like_case% "anaerob[a-z]+ (micro)?.*organism"] <- "B_ANAER"
out[is.na(out) & x %like_case% "anaerob[a-z]+ bacter"] <- "B_ANAER"
# coryneform bacteria
out[x %like_case% "^coryneform"] <- "B_CORYNF"
# yeasts and fungi
out[x %like_case% "^yeast?"] <- "F_YEAST"
out[x %like_case% "^fung(us|i)"] <- "F_FUNGUS"
out[x %like_case% "(^| )yeast?"] <- "F_YEAST"
out[x %like_case% "(^| )fung(us|i)"] <- "F_FUNGUS"
# protozoa
out[x %like_case% "protozo"] <- "P_PROTOZOAN" # to hit it with most languages, and "protozo" does not occur in the microorganisms data set for anything else
# trivial names known to the field
out[x %like_case% "meningo[ck]o[ck]"] <- "B_NESSR_MNNG"
@@ -1239,29 +1277,52 @@ repair_reference_df <- function(reference_df) {
}
get_mo_uncertainties <- function() {
remember <- list(uncertainties = AMR_env$mo_uncertainties)
remember <- list(uncertainties = AMR_env$mo_uncertainties,
failures = AMR_env$mo_failures)
# empty them, otherwise e.g. mo_shortname("Chlamydophila psittaci") will give 3 notes
AMR_env$mo_uncertainties <- NULL
AMR_env$mo_failures <- NULL
remember
}
load_mo_uncertainties <- function(metadata) {
AMR_env$mo_uncertainties <- metadata$uncertainties
AMR_env$mo_failures <- metadata$failures
}
synonym_mo_to_accepted_mo <- function(x, fill_in_accepted = FALSE) {
x_gbif <- AMR_env$MO_lookup$gbif_renamed_to[match(x, AMR_env$MO_lookup$mo)]
x_lpsn <- AMR_env$MO_lookup$lpsn_renamed_to[match(x, AMR_env$MO_lookup$mo)]
x_gbif[!x_gbif %in% AMR_env$MO_lookup$gbif] <- NA
x_lpsn[!x_lpsn %in% AMR_env$MO_lookup$lpsn] <- NA
out <- ifelse(is.na(x_lpsn),
AMR_env$MO_lookup$mo[match(x_gbif, AMR_env$MO_lookup$gbif)],
AMR_env$MO_lookup$mo[match(x_lpsn, AMR_env$MO_lookup$lpsn)]
)
if (isTRUE(fill_in_accepted)) {
x_accepted <- which(AMR_env$MO_lookup$status[match(x, AMR_env$MO_lookup$mo)] == "accepted")
out[x_accepted] <- x[x_accepted]
synonym_mo_to_accepted_mo <- function(x, fill_in_accepted = FALSE, dataset = AMR_env$MO_lookup) {
# `dataset` is an argument so that it can be used in the regeneration of the microorganisms data set
if (identical(dataset, AMR_env$MO_lookup)) {
add_MO_lookup_to_AMR_env()
dataset <- AMR_env$MO_lookup
}
out <- x
is_still_synonym <- dataset$status[match(out, dataset$mo)] == "synonym"
limit <- 0
while(any(is_still_synonym, na.rm = TRUE) && limit < 5) {
limit <- limit + 1
# make sure to get the latest name, e.g. Fusarium pulicaris robiniae was first renamed to Fusarium roseum, then to Fusarium sambucinum
# we need the MO of Fusarium pulicaris robiniae to return the MO of Fusarium sambucinum
must_be_corrected <- !is.na(is_still_synonym) & is_still_synonym
x_gbif <- dataset$gbif_renamed_to[match(out, dataset$mo)]
x_mycobank <- dataset$mycobank_renamed_to[match(out, dataset$mo)]
x_lpsn <- dataset$lpsn_renamed_to[match(out, dataset$mo)]
out[must_be_corrected & !is.na(x_gbif)] <- dataset$mo[match(x_gbif[must_be_corrected & !is.na(x_gbif)], dataset$gbif)]
out[must_be_corrected & !is.na(x_mycobank)] <- dataset$mo[match(x_mycobank[must_be_corrected & !is.na(x_mycobank)], dataset$mycobank)]
out[must_be_corrected & !is.na(x_lpsn)] <- dataset$mo[match(x_lpsn[must_be_corrected & !is.na(x_lpsn)], dataset$lpsn)]
is_still_synonym <- dataset$status[match(out, dataset$mo)] == "synonym"
}
x_no_synonym <- dataset$status[match(x, dataset$mo)] != "synonym"
out[x_no_synonym] <- NA_character_
if (isTRUE(fill_in_accepted)) {
out[!is.na(x_no_synonym) & x_no_synonym] <- x[!is.na(x_no_synonym) & x_no_synonym]
}
out[is.na(match(x, dataset$mo))] <- NA_character_
out
}
+10 -10
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -30,12 +30,11 @@
#' Calculate the Matching Score for Microorganisms
#'
#' This algorithm is used by [as.mo()] and all the [`mo_*`][mo_property()] functions to determine the most probable match of taxonomic records based on user input.
#' @author Dr. Matthijs Berends, 2018
#' @param x Any user input value(s)
#' @param n A full taxonomic name, that exists in [`microorganisms$fullname`][microorganisms]
#' @note This algorithm was originally described in: Berends MS *et al.* (2022). **AMR: An R Package for Working with Antimicrobial Resistance Data**. *Journal of Statistical Software*, 104(3), 1-31; \doi{10.18637/jss.v104.i03}.
#' @note This algorithm was originally developed in 2018 and subsequently described in: Berends MS *et al.* (2022). **AMR: An R Package for Working with Antimicrobial Resistance Data**. *Journal of Statistical Software*, 104(3), 1-31; \doi{10.18637/jss.v104.i03}.
#'
#' Later, the work of Bartlett A *et al.* about bacterial pathogens infecting humans (2022, \doi{10.1099/mic.0.001269}) was incorporated.
#' Later, the work of Bartlett A *et al.* about bacterial pathogens infecting humans (2022, \doi{10.1099/mic.0.001269}) was incorporated, and optimalisations to the algorithm were made.
#' @section Matching Score for Microorganisms:
#' With ambiguous user input in [as.mo()] and all the [`mo_*`][mo_property()] functions, the returned results are chosen based on their matching score using [mo_matching_score()]. This matching score \eqn{m}, is calculated as:
#'
@@ -50,19 +49,20 @@
#' * \eqn{l_n} is the length of \eqn{n};
#' * \eqn{lev} is the [Levenshtein distance function](https://en.wikipedia.org/wiki/Levenshtein_distance) (counting any insertion as 1, and any deletion or substitution as 2) that is needed to change \eqn{x} into \eqn{n};
#' * \eqn{p_n} is the human pathogenic prevalence group of \eqn{n}, as described below;
#' * \eqn{k_n} is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 1.25, Protozoa = 1.5, Archaea = 2, others = 3.
#' * \eqn{k_n} is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 1.25, Protozoa = 1.5, Chromista = 1.75, Archaea = 2, others = 3.
#'
#' The grouping into human pathogenic prevalence \eqn{p} is based on recent work from Bartlett *et al.* (2022, \doi{10.1099/mic.0.001269}) who extensively studied medical-scientific literature to categorise all bacterial species into these groups:
#'
#' - **Established**, if a taxonomic species has infected at least three persons in three or more references. These records have `prevalence = 1.0` in the [microorganisms] data set;
#' - **Established**, if a taxonomic species has infected at least three persons in three or more references. These records have `prevalence = 1.15` in the [microorganisms] data set;
#' - **Putative**, if a taxonomic species has fewer than three known cases. These records have `prevalence = 1.25` in the [microorganisms] data set.
#'
#' Furthermore,
#'
#' - Any genus present in the **established** list also has `prevalence = 1.0` in the [microorganisms] data set;
#' - Genera from the World Health Organization's (WHO) Priority Pathogen List have `prevalence = 1.0` in the [microorganisms] data set;
#' - Any genus present in the **established** list also has `prevalence = 1.15` in the [microorganisms] data set;
#' - Any other genus present in the **putative** list has `prevalence = 1.25` in the [microorganisms] data set;
#' - Any other species or subspecies of which the genus is present in the two aforementioned groups, has `prevalence = 1.5` in the [microorganisms] data set;
#' - Any *non-bacterial* genus, species or subspecies of which the genus is present in the following list, has `prevalence = 1.25` in the [microorganisms] data set: `r vector_or(MO_PREVALENT_GENERA, quotes = "*")`;
#' - Any *non-bacterial* genus, species or subspecies of which the genus is present in the following list, has `prevalence = 1.25` in the [microorganisms] data set: `r vector_or(MO_RELEVANT_GENERA, quotes = "*")`;
#' - All other records have `prevalence = 2.0` in the [microorganisms] data set.
#'
#' When calculating the matching score, all characters in \eqn{x} and \eqn{n} are ignored that are other than A-Z, a-z, 0-9, spaces and parentheses.
+90 -23
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -39,8 +39,8 @@
#' @details All functions will, at default, **not** keep old taxonomic properties, as synonyms are automatically replaced with the current taxonomy. Take for example *Enterobacter aerogenes*, which was initially named in 1960 but renamed to *Klebsiella aerogenes* in 2017:
#' - `mo_genus("Enterobacter aerogenes")` will return `"Klebsiella"` (with a note about the renaming)
#' - `mo_genus("Enterobacter aerogenes", keep_synonyms = TRUE)` will return `"Enterobacter"` (with a once-per-session warning that the name is outdated)
#' - `mo_ref("Enterobacter aerogenes")` will return `"Tindall et al., 2017"` (with a note)
#' - `mo_ref("Enterobacter aerogenes", keep_synonyms = TRUE)` will return `"Hormaeche et al., 1960"` (with a warning)
#' - `mo_ref("Enterobacter aerogenes")` will return `"Tindall et al., 2017"` (with a note about the renaming)
#' - `mo_ref("Enterobacter aerogenes", keep_synonyms = TRUE)` will return `"Hormaeche et al., 1960"` (with a once-per-session warning that the name is outdated)
#'
#' The short name ([mo_shortname()]) returns the first character of the genus and the full species, such as `"E. coli"`, for species and subspecies. Exceptions are abbreviations of staphylococci (such as *"CoNS"*, Coagulase-Negative Staphylococci) and beta-haemolytic streptococci (such as *"GBS"*, Group B Streptococci). Please bear in mind that e.g. *E. coli* could mean *Escherichia coli* (kingdom of Bacteria) as well as *Entamoeba coli* (kingdom of Protozoa). Returning to the full name will be done using [as.mo()] internally, giving priority to bacteria and human pathogens, i.e. `"E. coli"` will be considered *Escherichia coli*. As a result, `mo_fullname(mo_shortname("Entamoeba coli"))` returns `"Escherichia coli"`.
#'
@@ -50,15 +50,15 @@
#'
#' Determination of the Gram stain ([mo_gramstain()]) will be based on the taxonomic kingdom and phylum. Originally, Cavalier-Smith defined the so-called subkingdoms Negibacteria and Posibacteria (2002, [PMID 11837318](https://pubmed.ncbi.nlm.nih.gov/11837318/)), and only considered these phyla as Posibacteria: Actinobacteria, Chloroflexi, Firmicutes, and Tenericutes. These phyla were later renamed to Actinomycetota, Chloroflexota, Bacillota, and Mycoplasmatota (2021, [PMID 34694987](https://pubmed.ncbi.nlm.nih.gov/34694987/)). Bacteria in these phyla are considered Gram-positive in this `AMR` package, except for members of the class Negativicutes (within phylum Bacillota) which are Gram-negative. All other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a value `NA`. Functions [mo_is_gram_negative()] and [mo_is_gram_positive()] always return `TRUE` or `FALSE` (or `NA` when the input is `NA` or the MO code is `UNKNOWN`), thus always return `FALSE` for species outside the taxonomic kingdom of Bacteria.
#'
#' Determination of yeasts ([mo_is_yeast()]) will be based on the taxonomic kingdom and class. *Budding yeasts* are fungi of the phylum Ascomycota, class Saccharomycetes (also called Hemiascomycetes). *True yeasts* are aggregated into the underlying order Saccharomycetales. Thus, for all microorganisms that are member of the taxonomic class Saccharomycetes, the function will return `TRUE`. It returns `FALSE` otherwise (or `NA` when the input is `NA` or the MO code is `UNKNOWN`).
#' Determination of yeasts ([mo_is_yeast()]) will be based on the taxonomic kingdom and class. *Budding yeasts* are yeasts that reproduce asexually through a process called budding, where a new cell develops from a small protrusion on the parent cell. Taxonomically, these are members of the phylum Ascomycota, class Saccharomycetes (also called Hemiascomycetes) or Pichiomycetes. *True yeasts* quite specifically refers to yeasts in the underlying order Saccharomycetales (such as *Saccharomyces cerevisiae*). Thus, for all microorganisms that are member of the taxonomic class Saccharomycetes or Pichiomycetes, the function will return `TRUE`. It returns `FALSE` otherwise (or `NA` when the input is `NA` or the MO code is `UNKNOWN`).
#'
#' Determination of intrinsic resistance ([mo_is_intrinsic_resistant()]) will be based on the [intrinsic_resistant] data set, which is based on `r format_eucast_version_nr(3.3)`. The [mo_is_intrinsic_resistant()] function can be vectorised over both argument `x` (input for microorganisms) and `ab` (input for antibiotics).
#'
#' Determination of bacterial oxygen tolerance ([mo_oxygen_tolerance()]) will be based on BacDive, see *Source*. The function [mo_is_anaerobic()] only returns `TRUE` if the oxygen tolerance is `"anaerobe"`, indicting an obligate anaerobic species or genus. It always returns `FALSE` for species outside the taxonomic kingdom of Bacteria.
#'
#' The function [mo_url()] will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species.
#' The function [mo_url()] will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species. [This MycoBank URL](`r TAXONOMY_VERSION$MycoBank$url`) will be used for fungi wherever available , [this LPSN URL](`r TAXONOMY_VERSION$MycoBank$url`) for bacteria wherever available, and [this GBIF link](`r TAXONOMY_VERSION$GBIF$url`) otherwise.
#'
#' SNOMED codes ([mo_snomed()]) are from the version of `r documentation_date(TAXONOMY_VERSION$SNOMED$accessed_date)`. See *Source* and the [microorganisms] data set for more info.
#' SNOMED codes ([mo_snomed()]) was last updated on `r documentation_date(TAXONOMY_VERSION$SNOMED$accessed_date)`. See *Source* and the [microorganisms] data set for more info.
#'
#' Old taxonomic names (so-called 'synonyms') can be retrieved with [mo_synonyms()] (which will have the scientific reference as [name][base::names()]), the current taxonomic name can be retrieved with [mo_current()]. Both functions return full names.
#'
@@ -71,8 +71,9 @@
#' @return
#' - An [integer] in case of [mo_year()]
#' - An [ordered factor][factor] in case of [mo_pathogenicity()]
#' - A [list] in case of [mo_taxonomy()], [mo_synonyms()], [mo_snomed()] and [mo_info()]
#' - A named [character] in case of [mo_url()]
#' - A [list] in case of [mo_taxonomy()], [mo_synonyms()], [mo_snomed()], and [mo_info()]
#' - A [logical] in case of [mo_is_anaerobic()], [mo_is_gram_negative()], [mo_is_gram_positive()], [mo_is_intrinsic_resistant()], and [mo_is_yeast()]
#' - A named [character] in case of [mo_synonyms()] and [mo_url()]
#' - A [character] in all other cases
#' @export
#' @seealso Data set [microorganisms]
@@ -106,17 +107,25 @@
#' mo_rank("Klebsiella pneumoniae")
#' mo_url("Klebsiella pneumoniae")
#' mo_is_yeast(c("Candida", "Trichophyton", "Klebsiella"))
#'
#'
#' mo_group_members(c("Streptococcus group A",
#' "Streptococcus group C",
#' "Streptococcus group G",
#' "Streptococcus group L"))
#'
#'
#' # scientific reference -----------------------------------------------------
#'
#' mo_ref("Klebsiella aerogenes")
#' mo_authors("Klebsiella aerogenes")
#' mo_year("Klebsiella aerogenes")
#' mo_synonyms("Klebsiella aerogenes")
#' mo_lpsn("Klebsiella aerogenes")
#' mo_gbif("Klebsiella aerogenes")
#' mo_synonyms("Klebsiella aerogenes")
#'
#' mo_mycobank("Candida albicans")
#' mo_mycobank("Candida krusei")
#' mo_mycobank("Candida krusei", keep_synonyms = TRUE)
#'
#'
#' # abbreviations known in the field -----------------------------------------
#'
@@ -209,7 +218,13 @@ mo_name <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("A
#' @rdname mo_property
#' @export
mo_fullname <- mo_name
mo_fullname <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("AMR_keep_synonyms", FALSE), ...) {
if (missing(x)) {
# this tries to find the data and an 'mo' column
x <- find_mo_col(fn = "mo_fullname")
}
mo_name(x = x, language = language, keep_synonyms = keep_synonyms, ...)
}
#' @rdname mo_property
#' @export
@@ -245,7 +260,7 @@ mo_shortname <- function(x, language = get_AMR_locale(), keep_synonyms = getOpti
# unknown species etc.
shortnames[shortnames %like% "unknown"] <- paste0("(", trimws2(gsub("[^a-zA-Z -]", "", shortnames[shortnames %like% "unknown"], perl = TRUE)), ")")
shortnames[mo_rank(x.mo) %in% c("kingdom", "phylum", "class", "order", "family")] <- mo_name(x.mo, language = NULL, keep_synonyms = keep_synonyms)
shortnames[mo_rank(x.mo) %in% c("kingdom", "phylum", "class", "order", "family")] <- mo_name(x.mo[mo_rank(x.mo) %in% c("kingdom", "phylum", "class", "order", "family")], language = NULL, keep_synonyms = keep_synonyms)
shortnames[is.na(x.mo)] <- NA_character_
load_mo_uncertainties(metadata)
@@ -427,8 +442,8 @@ mo_pathogenicity <- function(x, language = get_AMR_locale(), keep_synonyms = get
kngd <- AMR_env$MO_lookup$kingdom[match(x.mo, AMR_env$MO_lookup$mo)]
rank <- AMR_env$MO_lookup$rank[match(x.mo, AMR_env$MO_lookup$mo)]
out <- factor(case_when_AMR(prev == 1 & kngd == "Bacteria" & rank != "genus" ~ "Pathogenic",
(prev < 2 & kngd == "Fungi") ~ "Potentially pathogenic",
out <- factor(case_when_AMR(prev <= 1.15 & kngd == "Bacteria" & rank != "genus" ~ "Pathogenic",
prev < 2 & kngd == "Fungi" ~ "Potentially pathogenic",
prev == 2 & kngd == "Bacteria" ~ "Non-pathogenic",
kngd == "Bacteria" ~ "Potentially pathogenic",
TRUE ~ "Unknown"),
@@ -538,8 +553,7 @@ mo_is_yeast <- function(x, language = get_AMR_locale(), keep_synonyms = getOptio
load_mo_uncertainties(metadata)
out <- rep(FALSE, length(x))
out[x.kingdom == "Fungi" & x.class == "Saccharomycetes"] <- TRUE
out <- x.mo == "F_YEAST" | (x.kingdom == "Fungi" & x.class %in% c("Saccharomycetes", "Pichiomycetes"))
out[x.mo %in% c(NA_character_, "UNKNOWN")] <- NA
out
}
@@ -692,6 +706,21 @@ mo_lpsn <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("A
mo_validate(x = x, property = "lpsn", language = language, keep_synonyms = keep_synonyms, ...)
}
#' @rdname mo_property
#' @export
mo_mycobank <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("AMR_keep_synonyms", FALSE), ...) {
if (missing(x)) {
# this tries to find the data and an 'mo' column
x <- find_mo_col(fn = "mo_mycobank")
}
meet_criteria(x, allow_NA = TRUE)
language <- validate_language(language)
meet_criteria(keep_synonyms, allow_class = "logical", has_length = 1)
mo_validate(x = x, property = "mycobank", language = language, keep_synonyms = keep_synonyms, ...)
}
#' @rdname mo_property
#' @export
mo_gbif <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("AMR_keep_synonyms", FALSE), ...) {
@@ -791,11 +820,42 @@ mo_synonyms <- function(x, language = get_AMR_locale(), keep_synonyms = getOptio
mo_current <- function(x, language = get_AMR_locale(), ...) {
meet_criteria(x, allow_NA = TRUE)
language <- validate_language(language)
x.mo <- suppressWarnings(as.mo(x, keep_synonyms = TRUE, ...))
x.mo <- suppressWarnings(as.mo(x, keep_synonyms = TRUE, info = FALSE, ...))
out <- synonym_mo_to_accepted_mo(x.mo, fill_in_accepted = TRUE)
mo_name(out, language = language)
}
#' @rdname mo_property
#' @export
mo_group_members <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("AMR_keep_synonyms", FALSE), ...) {
if (missing(x)) {
# this tries to find the data and an 'mo' column
x <- find_mo_col(fn = "mo_synonyms")
}
meet_criteria(x, allow_NA = TRUE)
language <- validate_language(language)
meet_criteria(keep_synonyms, allow_class = "logical", has_length = 1)
add_MO_lookup_to_AMR_env()
x.mo <- as.mo(x, language = language, keep_synonyms = keep_synonyms, ...)
metadata <- get_mo_uncertainties()
members <- lapply(x.mo, function(y) {
AMR::microorganisms.groups$mo_name[which(AMR::microorganisms.groups$mo_group == y)]
})
names(members) <- mo_name(x, keep_synonyms = TRUE, language = language)
if (length(members) == 1) {
members <- unname(unlist(members))
}
load_mo_uncertainties(metadata)
members
}
#' @rdname mo_property
#' @export
mo_info <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("AMR_keep_synonyms", FALSE), ...) {
@@ -812,7 +872,8 @@ mo_info <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("A
info <- lapply(x, function(y) {
c(
list(mo = as.character(x)),
list(mo = as.character(y),
rank = mo_rank(y, language = language, keep_synonyms = keep_synonyms)),
mo_taxonomy(y, language = language, keep_synonyms = keep_synonyms),
list(
status = mo_status(y, language = language, keep_synonyms = keep_synonyms),
@@ -823,7 +884,9 @@ mo_info <- function(x, language = get_AMR_locale(), keep_synonyms = getOption("A
ref = mo_ref(y, keep_synonyms = keep_synonyms),
snomed = unlist(mo_snomed(y, keep_synonyms = keep_synonyms)),
lpsn = mo_lpsn(y, language = language, keep_synonyms = keep_synonyms),
gbif = mo_gbif(y, language = language, keep_synonyms = keep_synonyms)
mycobank = mo_mycobank(y, language = language, keep_synonyms = keep_synonyms),
gbif = mo_gbif(y, language = language, keep_synonyms = keep_synonyms),
group_members = mo_group_members(y, language = language, keep_synonyms = keep_synonyms)
)
)
})
@@ -857,19 +920,23 @@ mo_url <- function(x, open = FALSE, language = get_AMR_locale(), keep_synonyms =
x.rank <- AMR_env$MO_lookup$rank[match(x.mo, AMR_env$MO_lookup$mo)]
x.name <- AMR_env$MO_lookup$fullname[match(x.mo, AMR_env$MO_lookup$mo)]
x.lpsn <- AMR_env$MO_lookup$lpsn[match(x.mo, AMR_env$MO_lookup$mo)]
x.mycobank <- AMR_env$MO_lookup$mycobank[match(x.mo, AMR_env$MO_lookup$mo)]
x.gbif <- AMR_env$MO_lookup$gbif[match(x.mo, AMR_env$MO_lookup$mo)]
u <- character(length(x))
u[!is.na(x.gbif)] <- paste0(TAXONOMY_VERSION$GBIF$url, "/species/", x.gbif[!is.na(x.gbif)])
# overwrite with LPSN:
u[!is.na(x.lpsn)] <- paste0(TAXONOMY_VERSION$LPSN$url, "/", x.rank[!is.na(x.lpsn)], "/", gsub(" ", "-", tolower(x.name[!is.na(x.lpsn)]), fixed = TRUE))
# overwrite with MycoBank (bacteria from LPSN will not be overwritten since MycoBank has no bacteria)
u[!is.na(x.mycobank)] <- paste0(TAXONOMY_VERSION$MycoBank$url, "/mb/", gsub(" ", "%20", tolower(x.mycobank[!is.na(x.mycobank)]), fixed = TRUE))
names(u) <- x.name
if (isTRUE(open)) {
if (length(u) > 1) {
warning_("in `mo_url()`: only the first URL will be opened, as `browseURL()` only suports one string.")
warning_("in `mo_url()`: only the first URL will be opened, as R's built-in function `browseURL()` only suports one string.")
}
utils::browseURL(u[1L])
}
+12 -7
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -39,7 +39,7 @@
#' @aliases set_mo_source get_mo_source
#' @details The reference file can be a text file separated with commas (CSV) or tabs or pipes, an Excel file (either 'xls' or 'xlsx' format) or an \R object file (extension '.rds'). To use an Excel file, you will need to have the `readxl` package installed.
#'
#' [set_mo_source()] will check the file for validity: it must be a [data.frame], must have a column named `"mo"` which contains values from [`microorganisms$mo`][microorganisms] or [`microorganisms$fullname`][microorganisms] and must have a reference column with your own defined values. If all tests pass, [set_mo_source()] will read the file into \R and will ask to export it to `"~/mo_source.rds"`. The CRAN policy disallows packages to write to the file system, although '*exceptions may be allowed in interactive sessions if the package obtains confirmation from the user*'. For this reason, this function only works in interactive sessions so that the user can **specifically confirm and allow** that this file will be created. The destination of this file can be set with the `destination` argument and defaults to the user's home directory. It can also be set with the [package option][AMR-options] [`AMR_mo_source`][AMR-options], e.g. `options(AMR_mo_source = "my/location/file.rds")`.
#' [set_mo_source()] will check the file for validity: it must be a [data.frame], must have a column named `"mo"` which contains values from [`microorganisms$mo`][microorganisms] or [`microorganisms$fullname`][microorganisms] and must have a reference column with your own defined values. If all tests pass, [set_mo_source()] will read the file into \R and will ask to export it to `"~/mo_source.rds"`. The CRAN policy disallows packages to write to the file system, although '*exceptions may be allowed in interactive sessions if the package obtains confirmation from the user*'. For this reason, this function only works in interactive sessions so that the user can **specifically confirm and allow** that this file will be created. The destination of this file can be set with the `destination` argument and defaults to the user's home directory. It can also be set with the package option [`AMR_mo_source`][AMR-options], e.g. `options(AMR_mo_source = "my/location/file.rds")`.
#'
#' The created compressed data file `"mo_source.rds"` will be used at default for MO determination (function [as.mo()] and consequently all `mo_*` functions like [mo_genus()] and [mo_gramstain()]). The location and timestamp of the original file will be saved as an [attribute][base::attributes()] to the compressed data file.
#'
@@ -125,14 +125,13 @@
#' If the original file (in the previous case an Excel file) is moved or deleted, the `mo_source.rds` file will be removed upon the next use of [as.mo()] or any [`mo_*`][mo_property()] function.
#' @export
set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_source.rds")) {
stop_ifnot(interactive(), "this function can only be used in interactive mode, since it must ask for the user's permission to write a file to their file system.")
meet_criteria(path, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(destination, allow_class = "character", has_length = 1)
stop_ifnot(destination %like% "[.]rds$", "the `destination` must be a file location with file extension .rds.")
mo_source_destination <- path.expand(destination)
stop_ifnot(interactive(), "this function can only be used in interactive mode, since it must ask for the user's permission to write a file to their file system.")
if (is.null(path) || path %in% c(FALSE, "")) {
AMR_env$mo_source <- NULL
if (file.exists(mo_source_destination)) {
@@ -247,6 +246,12 @@ get_mo_source <- function(destination = getOption("AMR_mo_source", "~/mo_source.
}
return(NULL)
}
if (destination %unlike% "[.]rds$") {
current_ext <- regexpr("\\.([[:alnum:]]+)$", destination)
current_ext <- ifelse(current_ext > -1L, substring(destination, current_ext + 1L), "")
vowel <- ifelse(current_ext %like% "^[AEFHILMNORSX]", "n", "")
stop_("The AMR mo source must be an RDS file, not a", vowel, " ", toupper(current_ext), " file. If `\"", basename(destination), "\"` was meant as your input file, use `set_mo_source()` on this file. In any case, the option `AMR_mo_source` must be set to another path.")
}
if (is.null(AMR_env$mo_source)) {
AMR_env$mo_source <- readRDS_AMR(path.expand(destination))
}
+4 -4
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -113,7 +113,7 @@ pca <- function(x,
x <- as.data.frame(new_list, stringsAsFactors = FALSE)
if (any(vapply(FUN.VALUE = logical(1), x, function(y) !is.numeric(y)))) {
warning_("in `pca()`: be sure to first calculate the resistance (or susceptibility) of variables with antimicrobial test results, since PCA works with numeric variables only. See Examples in ?pca.", call = FALSE)
warning_("in `pca()`: be sure to first calculate the resistance (or susceptibility) of variables with antimicrobial test results, since PCA works with numeric variables only. See Examples in `?pca`.", call = FALSE)
}
# set column names
+154 -56
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -29,8 +29,10 @@
#' Plotting for Classes `sir`, `mic` and `disk`
#'
#' @description
#' Functions to plot classes `sir`, `mic` and `disk`, with support for base \R and `ggplot2`.
#'
#' Especially the `scale_*_mic()` functions are relevant wrappers to plot MIC values for `ggplot2`. They allows custom MIC ranges and to plot intermediate log2 levels for missing MIC values.
#' @param x,object values created with [as.mic()], [as.disk()] or [as.sir()] (or their `random_*` variants, such as [random_mic()])
#' @param mo any (vector of) text that can be coerced to a valid microorganism code with [as.mo()]
#' @param ab any (vector of) text that can be coerced to a valid antimicrobial drug code with [as.ab()]
@@ -38,7 +40,7 @@
#' @param main,title title of the plot
#' @param xlab,ylab axis title
#' @param colours_SIR colours to use for filling in the bars, must be a vector of three values (in the order S, I and R). The default colours are colour-blind friendly.
#' @param language language to be used to translate 'Susceptible', 'Increased exposure'/'Intermediate' and 'Resistant' - the default is system language (see [get_AMR_locale()]) and can be overwritten by setting the [package option][AMR-options] [`AMR_locale`][AMR-options], e.g. `options(AMR_locale = "de")`, see [translate]. Use `language = NULL` or `language = ""` to prevent translation.
#' @param language language to be used to translate 'Susceptible', 'Increased exposure'/'Intermediate' and 'Resistant' - the default is system language (see [get_AMR_locale()]) and can be overwritten by setting the package option [`AMR_locale`][AMR-options], e.g. `options(AMR_locale = "de")`, see [translate]. Use `language = NULL` or `language = ""` to prevent translation.
#' @param expand a [logical] to indicate whether the range on the x axis should be expanded between the lowest and highest value. For MIC values, intermediate values will be factors of 2 starting from the highest MIC value. For disk diameters, the whole diameter range will be filled.
#' @inheritParams as.sir
#' @details
@@ -66,9 +68,40 @@
#' plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl")
#'
#'
#'
#' # Plotting using scale_x_mic()
#' \donttest{
#' if (require("ggplot2")) {
#' mic_plot <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")),
#' counts = c(1, 1, 2, 2, 3, 3)),
#' aes(mics, counts)) +
#' geom_col()
#' mic_plot +
#' labs(title = "without scale_x_mic()")
#' }
#' if (require("ggplot2")) {
#' mic_plot +
#' scale_x_mic() +
#' labs(title = "with scale_x_mic()")
#' }
#' if (require("ggplot2")) {
#' mic_plot +
#' scale_x_mic(keep_operators = "all") +
#' labs(title = "with scale_x_mic() keeping all operators")
#' }
#' if (require("ggplot2")) {
#' mic_plot +
#' scale_x_mic(mic_range = c(1, 16)) +
#' labs(title = "with scale_x_mic() using a manual 'within' range")
#' }
#' if (require("ggplot2")) {
#' mic_plot +
#' scale_x_mic(mic_range = c(0.032, 256)) +
#' labs(title = "with scale_x_mic() using a manual 'outside' range")
#' }
#'
#' if (require("ggplot2")) {
#' autoplot(some_mic_values)
#' }
#' if (require("ggplot2")) {
@@ -80,6 +113,59 @@
#' }
NULL
#' @export
#' @inheritParams as.mic
#' @param drop a [logical] to remove intermediate MIC values, defaults to `FALSE`
#' @rdname plot
scale_x_mic <- function(keep_operators = "edges", mic_range = NULL, drop = FALSE, ...) {
stop_ifnot_installed("ggplot2")
meet_criteria(drop, allow_class = "logical", has_length = 1)
scale <- ggplot2::scale_x_discrete(drop = drop, ...)
scale$transform <- function(x, keep_ops = keep_operators, mic_rng = mic_range) {
rescale_mic(x = x, keep_operators = keep_ops, mic_range = mic_rng, as.mic = FALSE)
}
scale
}
#' @export
#' @inheritParams as.mic
#' @rdname plot
scale_y_mic <- function(keep_operators = "edges", mic_range = NULL, drop = FALSE, ...) {
stop_ifnot_installed("ggplot2")
meet_criteria(drop, allow_class = "logical", has_length = 1)
scale <- ggplot2::scale_y_discrete(drop = drop, ...)
scale$transform <- function(x, keep_ops = keep_operators, mic_rng = mic_range) {
rescale_mic(x = x, keep_operators = keep_ops, mic_range = mic_rng, as.mic = FALSE)
}
scale
}
#' @export
#' @inheritParams as.mic
#' @rdname plot
scale_colour_mic <- function(keep_operators = "edges", mic_range = NULL, drop = FALSE, ...) {
stop_ifnot_installed("ggplot2")
meet_criteria(drop, allow_class = "logical", has_length = 1)
scale <- ggplot2::scale_colour_discrete(drop = drop, ...)
scale$transform <- function(x, keep_ops = keep_operators, mic_rng = mic_range) {
rescale_mic(x = x, keep_operators = keep_ops, mic_range = mic_rng, as.mic = FALSE)
}
scale
}
#' @export
#' @inheritParams as.mic
#' @rdname plot
scale_fill_mic <- function(keep_operators = "edges", mic_range = NULL, drop = FALSE, ...) {
stop_ifnot_installed("ggplot2")
meet_criteria(drop, allow_class = "logical", has_length = 1)
scale <- ggplot2::scale_fill_discrete(drop = drop, ...)
scale$transform <- function(x, keep_ops = keep_operators, mic_rng = mic_range) {
rescale_mic(x = x, keep_operators = keep_ops, mic_range = mic_rng, as.mic = FALSE)
}
scale
}
#' @method plot mic
#' @importFrom graphics barplot axis mtext legend
#' @export
@@ -103,21 +189,18 @@ plot.mic <- function(x,
meet_criteria(main, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(ylab, allow_class = "character", has_length = 1)
meet_criteria(xlab, allow_class = "character", has_length = 1)
if ("colours_RSI" %in% names(list(...))) {
deprecation_warning(extra_msg = "The 'colours_RSI' argument has been replaced with 'colours_SIR'.")
colours_SIR <- list(...)$colours_RSI
}
meet_criteria(colours_SIR, allow_class = "character", has_length = c(1, 3))
language <- validate_language(language)
meet_criteria(expand, allow_class = "logical", has_length = 1)
x <- as.mic(x) # make sure that currently implemented MIC levels are used
if (length(colours_SIR) == 1) {
colours_SIR <- rep(colours_SIR, 3)
}
main <- gsub(" +", " ", paste0(main, collapse = " "))
x <- plot_prepare_table(x, expand = expand)
x <- plotrange_as_table(x, expand = expand)
cols_sub <- plot_colours_subtitle_guideline(
x = x,
mo = mo,
@@ -193,15 +276,13 @@ barplot.mic <- function(height,
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
meet_criteria(ab, allow_class = c("ab", "character"), allow_NULL = TRUE)
meet_criteria(guideline, allow_class = "character", has_length = 1)
if ("colours_RSI" %in% names(list(...))) {
deprecation_warning(extra_msg = "The 'colours_RSI' argument has been replaced with 'colours_SIR'.")
colours_SIR <- list(...)$colours_RSI
}
meet_criteria(colours_SIR, allow_class = "character", has_length = c(1, 3))
language <- validate_language(language)
meet_criteria(expand, allow_class = "logical", has_length = 1)
main <- gsub(" +", " ", paste0(main, collapse = " "))
height <- as.mic(height) # make sure that currently implemented MIC levels are used
plot(
x = height,
@@ -239,10 +320,6 @@ autoplot.mic <- function(object,
meet_criteria(title, allow_class = "character", allow_NULL = TRUE)
meet_criteria(ylab, allow_class = "character", has_length = 1)
meet_criteria(xlab, allow_class = "character", has_length = 1)
if ("colours_RSI" %in% names(list(...))) {
deprecation_warning(extra_msg = "The 'colours_RSI' argument has been replaced with 'colours_SIR'.")
colours_SIR <- list(...)$colours_RSI
}
meet_criteria(colours_SIR, allow_class = "character", has_length = c(1, 3))
language <- validate_language(language)
meet_criteria(expand, allow_class = "logical", has_length = 1)
@@ -254,7 +331,8 @@ autoplot.mic <- function(object,
title <- gsub(" +", " ", paste0(title, collapse = " "))
}
x <- plot_prepare_table(object, expand = expand)
object <- as.mic(object) # make sure that currently implemented MIC levels are used
x <- plotrange_as_table(object, expand = expand)
cols_sub <- plot_colours_subtitle_guideline(
x = x,
mo = mo,
@@ -290,6 +368,7 @@ autoplot.mic <- function(object,
if (any(colours_SIR %in% cols_sub$cols)) {
vals <- c(
"(S) Susceptible" = colours_SIR[1],
"(SDD) Susceptible dose-dependent" = colours_SIR[2],
"(I) Susceptible, incr. exp." = colours_SIR[2],
"(I) Intermediate" = colours_SIR[2],
"(R) Resistant" = colours_SIR[3]
@@ -316,12 +395,14 @@ autoplot.mic <- function(object,
#' @rdname plot
# will be exported using s3_register() in R/zzz.R
fortify.mic <- function(object, ...) {
object <- as.mic(object) # make sure that currently implemented MIC levels are used
stats::setNames(
as.data.frame(plot_prepare_table(object, expand = FALSE)),
as.data.frame(plotrange_as_table(object, expand = FALSE)),
c("x", "y")
)
}
#' @method plot disk
#' @export
#' @importFrom graphics barplot axis mtext legend
@@ -345,10 +426,6 @@ plot.disk <- function(x,
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
meet_criteria(ab, allow_class = c("ab", "character"), allow_NULL = TRUE)
meet_criteria(guideline, allow_class = "character", has_length = 1)
if ("colours_RSI" %in% names(list(...))) {
deprecation_warning(extra_msg = "The 'colours_RSI' argument has been replaced with 'colours_SIR'.")
colours_SIR <- list(...)$colours_RSI
}
meet_criteria(colours_SIR, allow_class = "character", has_length = c(1, 3))
language <- validate_language(language)
meet_criteria(expand, allow_class = "logical", has_length = 1)
@@ -358,8 +435,7 @@ plot.disk <- function(x,
}
main <- gsub(" +", " ", paste0(main, collapse = " "))
x <- plot_prepare_table(x, expand = expand)
x <- plotrange_as_table(x, expand = expand)
cols_sub <- plot_colours_subtitle_guideline(
x = x,
mo = mo,
@@ -435,10 +511,6 @@ barplot.disk <- function(height,
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
meet_criteria(ab, allow_class = c("ab", "character"), allow_NULL = TRUE)
meet_criteria(guideline, allow_class = "character", has_length = 1)
if ("colours_RSI" %in% names(list(...))) {
deprecation_warning(extra_msg = "The 'colours_RSI' argument has been replaced with 'colours_SIR'.")
colours_SIR <- list(...)$colours_RSI
}
meet_criteria(colours_SIR, allow_class = "character", has_length = c(1, 3))
language <- validate_language(language)
meet_criteria(expand, allow_class = "logical", has_length = 1)
@@ -481,10 +553,6 @@ autoplot.disk <- function(object,
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
meet_criteria(ab, allow_class = c("ab", "character"), allow_NULL = TRUE)
meet_criteria(guideline, allow_class = "character", has_length = 1)
if ("colours_RSI" %in% names(list(...))) {
deprecation_warning(extra_msg = "The 'colours_RSI' argument has been replaced with 'colours_SIR'.")
colours_SIR <- list(...)$colours_RSI
}
meet_criteria(colours_SIR, allow_class = "character", has_length = c(1, 3))
language <- validate_language(language)
meet_criteria(expand, allow_class = "logical", has_length = 1)
@@ -496,7 +564,7 @@ autoplot.disk <- function(object,
title <- gsub(" +", " ", paste0(title, collapse = " "))
}
x <- plot_prepare_table(object, expand = expand)
x <- plotrange_as_table(object, expand = expand)
cols_sub <- plot_colours_subtitle_guideline(
x = x,
mo = mo,
@@ -533,6 +601,7 @@ autoplot.disk <- function(object,
if (any(colours_SIR %in% cols_sub$cols)) {
vals <- c(
"(S) Susceptible" = colours_SIR[1],
"(SDD) Susceptible dose-dependent" = colours_SIR[2],
"(I) Susceptible, incr. exp." = colours_SIR[2],
"(I) Intermediate" = colours_SIR[2],
"(R) Resistant" = colours_SIR[3]
@@ -560,7 +629,7 @@ autoplot.disk <- function(object,
# 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)),
as.data.frame(plotrange_as_table(object, expand = FALSE)),
c("x", "y")
)
}
@@ -586,14 +655,21 @@ plot.sir <- function(x,
if (!"S" %in% data$x) {
data <- rbind_AMR(data, data.frame(x = "S", n = 0, s = 0, stringsAsFactors = FALSE))
}
if (!"SDD" %in% data$x) {
data <- rbind_AMR(data, data.frame(x = "SDD", n = 0, s = 0, stringsAsFactors = FALSE))
}
if (!"I" %in% data$x) {
data <- rbind_AMR(data, data.frame(x = "I", n = 0, s = 0, stringsAsFactors = FALSE))
}
if (!"R" %in% data$x) {
data <- rbind_AMR(data, data.frame(x = "R", n = 0, s = 0, stringsAsFactors = FALSE))
}
data$x <- factor(data$x, levels = c("S", "I", "R"), ordered = TRUE)
if (!"NI" %in% data$x) {
data <- rbind_AMR(data, data.frame(x = "NI", n = 0, s = 0, stringsAsFactors = FALSE))
}
data <- data[!(data$n == 0 & data$x %in% c("SDD", "I", "NI")), , drop = FALSE]
data$x <- factor(data$x, levels = intersect(unique(data$x), c("S", "SDD", "I", "R", "NI")), ordered = TRUE)
ymax <- pm_if_else(max(data$s) > 95, 105, 100)
@@ -635,10 +711,6 @@ barplot.sir <- function(height,
meet_criteria(xlab, allow_class = "character", has_length = 1)
meet_criteria(main, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(ylab, allow_class = "character", has_length = 1)
if ("colours_RSI" %in% names(list(...))) {
deprecation_warning(extra_msg = "The 'colours_RSI' argument has been replaced with 'colours_SIR'.")
colours_SIR <- list(...)$colours_RSI
}
meet_criteria(colours_SIR, allow_class = "character", has_length = c(1, 3))
language <- validate_language(language)
meet_criteria(expand, allow_class = "logical", has_length = 1)
@@ -646,10 +718,15 @@ barplot.sir <- function(height,
if (length(colours_SIR) == 1) {
colours_SIR <- rep(colours_SIR, 3)
}
# add SDD and N to colours
colours_SIR <- c(colours_SIR[1:2], colours_SIR[2], colours_SIR[3], "#888888")
main <- gsub(" +", " ", paste0(main, collapse = " "))
x <- table(height)
x <- x[c(1, 2, 3)]
# remove missing I, SDD, and N
colours_SIR <- colours_SIR[!(names(x) %in% c("SDD", "I", "NI") & x == 0)]
x <- x[!(names(x) %in% c("SDD", "I", "NI") & x == 0)]
# plot it
barplot(x,
col = colours_SIR,
xlab = xlab,
@@ -688,15 +765,18 @@ autoplot.sir <- function(object,
}
df <- as.data.frame(table(object), stringsAsFactors = TRUE)
colnames(df) <- c("sir", "count")
colnames(df) <- c("x", "n")
df <- df[!(df$n == 0 & df$x %in% c("SDD", "I", "NI")), , drop = FALSE]
ggplot2::ggplot(df) +
ggplot2::geom_col(ggplot2::aes(x = sir, y = count, fill = sir)) +
ggplot2::geom_col(ggplot2::aes(x = x, y = n, fill = x)) +
# limits = force is needed because of a ggplot2 >= 3.3.4 bug (#4511)
ggplot2::scale_fill_manual(
values = c(
"S" = colours_SIR[1],
"SDD" = colours_SIR[2],
"I" = colours_SIR[2],
"R" = colours_SIR[3]
"R" = colours_SIR[3],
"NI" = "#888888"
),
limits = force
) +
@@ -714,22 +794,27 @@ fortify.sir <- function(object, ...) {
)
}
plot_prepare_table <- function(x, expand) {
plotrange_as_table <- function(x, expand, keep_operators = "all", mic_range = NULL) {
x <- x[!is.na(x)]
stop_if(length(x) == 0, "no observations to plot", call = FALSE)
if (is.mic(x)) {
x <- as.mic(x, keep_operators = keep_operators)
if (expand == TRUE) {
# expand range for MIC by adding factors of 2 from lowest to highest so all MICs in between also print
valid_lvls <- levels(x)
extra_range <- max(x) / 2
while (min(extra_range) / 2 > min(x)) {
extra_range <- c(min(extra_range) / 2, extra_range)
# expand range for MIC by adding common intermediate factors levels
if (!is.null(mic_range) && !all(is.na(mic_range))) {
# base on mic_range
`%na_or%` <- function(x, y) if (is.na(x)) y else x
extra_range <- COMMON_MIC_VALUES[COMMON_MIC_VALUES >= (mic_range[1] %na_or% min(x, na.rm = TRUE)) & COMMON_MIC_VALUES <= (mic_range[2] %na_or% max(x, na.rm = TRUE))]
} else {
# base on x
extra_range <- COMMON_MIC_VALUES[COMMON_MIC_VALUES > min(x, na.rm = TRUE) & COMMON_MIC_VALUES < max(x, na.rm = TRUE)]
}
# remove the ones that are in 25% range of user values
extra_range <- extra_range[!vapply(FUN.VALUE = logical(1), extra_range, function(r) any(abs(r - x) / x < 0.25, na.rm = TRUE))]
nms <- extra_range
extra_range <- rep(0, length(extra_range))
names(extra_range) <- nms
x <- table(droplevels(x, as.mic = FALSE))
extra_range <- extra_range[!names(extra_range) %in% names(x) & names(extra_range) %in% valid_lvls]
extra_range <- extra_range[!names(extra_range) %in% names(x) & names(extra_range) %in% VALID_MIC_LEVELS]
x <- as.table(c(x, extra_range))
} else {
x <- table(droplevels(x, as.mic = FALSE))
@@ -751,6 +836,15 @@ plot_prepare_table <- function(x, expand) {
as.table(x)
}
ggplot2_get_from_dots <- function(arg, default, ...) {
dots <- list(...)
if (!arg %in% names(dots)) {
default
} else {
dots[[arg]]
}
}
plot_name_of_I <- function(guideline) {
if (guideline %unlike% "CLSI" && as.double(gsub("[^0-9]+", "", guideline)) >= 2019) {
# interpretation since 2019
@@ -762,6 +856,8 @@ plot_name_of_I <- function(guideline) {
}
plot_colours_subtitle_guideline <- function(x, mo, ab, guideline, colours_SIR, fn, language, method, breakpoint_type, include_PKPD, ...) {
stop_if(length(x) == 0, "no observations to plot", call = FALSE)
guideline <- get_guideline(guideline, AMR::clinical_breakpoints)
# store previous interpretations to backup
@@ -804,8 +900,10 @@ plot_colours_subtitle_guideline <- function(x, mo, ab, guideline, colours_SIR, f
cols <- character(length = length(sir))
cols[is.na(sir)] <- "#BEBEBE"
cols[sir == "S"] <- colours_SIR[1]
cols[sir == "SDD"] <- colours_SIR[2]
cols[sir == "I"] <- colours_SIR[2]
cols[sir == "R"] <- colours_SIR[3]
cols[sir == "NI"] <- "#888888"
sub <- bquote(.(abname) ~ "-" ~ italic(.(moname)) ~ .(guideline_txt))
} else {
cols <- "#BEBEBE"
+33 -20
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -39,8 +39,8 @@
#' @param data a [data.frame] containing columns with class [`sir`] (see [as.sir()])
#' @param translate_ab a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]
#' @inheritParams ab_property
#' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant) - the default is `TRUE`
#' @param ab_result antibiotic results to test against, must be one or more values of "S", "I", or "R"
#' @param combine_SI a [logical] to indicate whether all values of S, SDD, and I must be merged into one, so the output only consists of S+SDD+I vs. R (susceptible vs. resistant) - the default is `TRUE`
#' @param ab_result antibiotic results to test against, must be one or more values of "S", "SDD", "I", or "R"
#' @param confidence_level the confidence level for the returned confidence interval. For the calculation, the number of S or SI isolates, and R isolates are compared with the total number of available isolates with R, S, or I by using [binom.test()], i.e., the Clopper-Pearson method.
#' @param side the side of the confidence interval to return. The default is `"both"` for a length 2 vector, but can also be (abbreviated as) `"min"`/`"left"`/`"lower"`/`"less"` or `"max"`/`"right"`/`"higher"`/`"greater"`.
#' @param collapse a [logical] to indicate whether the output values should be 'collapsed', i.e. be merged together into one value, or a character value to use for collapsing
@@ -48,7 +48,7 @@
#' @details
#' **Remember that you should filter your data to let it contain only first isolates!** This is needed to exclude duplicates and to reduce selection bias. Use [first_isolate()] to determine them in your data set with one of the four available algorithms.
#'
#' The function [resistance()] is equal to the function [proportion_R()]. The function [susceptibility()] is equal to the function [proportion_SI()].
#' The function [resistance()] is equal to the function [proportion_R()]. The function [susceptibility()] is equal to the function [proportion_SI()]. Since AMR v3.0, [proportion_SI()] and [proportion_I()] include dose-dependent susceptibility ('SDD').
#'
#' Use [sir_confidence_interval()] to calculate the confidence interval, which relies on [binom.test()], i.e., the Clopper-Pearson method. This function returns a vector of length 2 at default for antimicrobial *resistance*. Change the `side` argument to "left"/"min" or "right"/"max" to return a single value, and change the `ab_result` argument to e.g. `c("S", "I")` to test for antimicrobial *susceptibility*, see Examples.
#'
@@ -247,7 +247,7 @@ susceptibility <- function(...,
only_all_tested = FALSE) {
tryCatch(
sir_calc(...,
ab_result = c("S", "I"),
ab_result = c("S", "SDD", "I"),
minimum = minimum,
as_percent = as_percent,
only_all_tested = only_all_tested,
@@ -267,7 +267,7 @@ sir_confidence_interval <- function(...,
confidence_level = 0.95,
side = "both",
collapse = FALSE) {
meet_criteria(ab_result, allow_class = c("character", "sir"), has_length = c(1, 2, 3), is_in = c("S", "I", "R"))
meet_criteria(ab_result, allow_class = c("character", "sir"), has_length = c(1:5), is_in = c("S", "SDD", "I", "R", "NI"))
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_positive_or_zero = TRUE, is_finite = TRUE)
meet_criteria(as_percent, allow_class = "logical", has_length = 1)
meet_criteria(only_all_tested, allow_class = "logical", has_length = 1)
@@ -285,32 +285,37 @@ sir_confidence_interval <- function(...,
)
n <- tryCatch(
sir_calc(...,
ab_result = c("S", "I", "R"),
ab_result = c("S", "SDD", "I", "R", "NI"),
only_all_tested = only_all_tested,
only_count = TRUE
),
error = function(e) stop_(gsub("in sir_calc(): ", "", e$message, fixed = TRUE), call = -5)
)
# this applies the Clopper-Pearson method
out <- stats::binom.test(x = x, n = n, conf.level = confidence_level)$conf.int
out <- set_clean_class(out, "double")
if (x == 0) {
out <- c(0, 0)
} else {
# this applies the Clopper-Pearson method
out <- stats::binom.test(x = x, n = n, conf.level = confidence_level)$conf.int
}
out <- set_clean_class(out, "numeric")
if (side %in% c("left", "l", "lower", "lowest", "less", "min")) {
out <- out[1]
} else if (side %in% c("right", "r", "higher", "highest", "greater", "g", "max")) {
out <- out[2]
}
if (isTRUE(as_percent)) {
out <- percentage(out, digits = 1)
out <- trimws(percentage(out, digits = 1))
}
if (!isFALSE(collapse) && length(out) > 1) {
if (is.numeric(out)) {
out <- round(out, digits = 3)
}
# out[is.na(out)] <- 0
out <- paste(out, collapse = ifelse(isTRUE(collapse), "-", collapse))
}
if (n < minimum) {
warning_("Introducing NA: ",
ifelse(n == 0, "no", paste("only", n)),
@@ -323,7 +328,6 @@ sir_confidence_interval <- function(...,
return(NA_real_)
}
}
out
}
@@ -351,9 +355,12 @@ proportion_IR <- function(...,
minimum = 30,
as_percent = FALSE,
only_all_tested = FALSE) {
if (message_not_thrown_before("proportion_IR", entire_session = TRUE)) {
message_("Note that `proportion_IR()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE)
}
tryCatch(
sir_calc(...,
ab_result = c("I", "R"),
ab_result = c("I", "SDD", "R"),
minimum = minimum,
as_percent = as_percent,
only_all_tested = only_all_tested,
@@ -369,9 +376,12 @@ proportion_I <- function(...,
minimum = 30,
as_percent = FALSE,
only_all_tested = FALSE) {
if (message_not_thrown_before("proportion_I", entire_session = TRUE)) {
message_("Note that `proportion_I()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE)
}
tryCatch(
sir_calc(...,
ab_result = "I",
ab_result = c("I", "SDD"),
minimum = minimum,
as_percent = as_percent,
only_all_tested = only_all_tested,
@@ -387,9 +397,12 @@ proportion_SI <- function(...,
minimum = 30,
as_percent = FALSE,
only_all_tested = FALSE) {
if (message_not_thrown_before("proportion_SI", entire_session = TRUE)) {
message_("Note that `proportion_SI()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE)
}
tryCatch(
sir_calc(...,
ab_result = c("S", "I"),
ab_result = c("S", "I", "SDD"),
minimum = minimum,
as_percent = as_percent,
only_all_tested = only_all_tested,
+3 -7
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -83,10 +83,6 @@ random_disk <- function(size = NULL, mo = NULL, ab = NULL, ...) {
#' @export
random_sir <- function(size = NULL, prob_SIR = c(0.33, 0.33, 0.33), ...) {
meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE, allow_NULL = TRUE)
if ("prob_RSI" %in% names(list(...))) {
deprecation_warning("prob_RSI", "prob_SIR", is_function = FALSE)
prob_SIR <- list(...)$prob_RSI
}
meet_criteria(prob_SIR, allow_class = c("numeric", "integer"), has_length = 3)
if (is.null(size)) {
size <- NROW(get_current_data(arg_name = "size", call = -3))
+4 -4
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -231,7 +231,7 @@ resistance_predict <- function(x,
prediction <- predictmodel$fit
se <- predictmodel$se.fit
} else {
stop("no valid model selected. See ?resistance_predict.")
stop("no valid model selected. See `?resistance_predict`.")
}
# prepare the output dataframe
+704 -297
View File
File diff suppressed because it is too large Load Diff
+25 -12
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -41,7 +41,7 @@ sir_calc <- function(...,
as_percent = FALSE,
only_all_tested = FALSE,
only_count = FALSE) {
meet_criteria(ab_result, allow_class = c("character", "numeric", "integer"), has_length = c(1, 2, 3))
meet_criteria(ab_result, allow_class = c("character", "numeric", "integer"), has_length = c(1:5))
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_positive_or_zero = TRUE, is_finite = TRUE)
meet_criteria(as_percent, allow_class = "logical", has_length = 1)
meet_criteria(only_all_tested, allow_class = "logical", has_length = 1)
@@ -137,11 +137,11 @@ sir_calc <- function(...,
if (isTRUE(only_all_tested)) {
# no NAs in any column
y <- apply(
X = as.data.frame(lapply(x, as.integer), stringsAsFactors = FALSE),
X = as.data.frame(lapply(x, as.double), stringsAsFactors = FALSE),
MARGIN = 1,
FUN = min
)
numerator <- sum(as.integer(y) %in% as.integer(ab_result), na.rm = TRUE)
numerator <- sum(!is.na(y) & y %in% as.double(ab_result), na.rm = TRUE)
denominator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) !(anyNA(y))))
} else {
# may contain NAs in any column
@@ -223,7 +223,8 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
combine_SI = TRUE,
confidence_level = 0.95) {
meet_criteria(type, is_in = c("proportion", "count", "both"), has_length = 1)
meet_criteria(data, allow_class = "data.frame", contains_column_class = c("sir", "rsi"))
meet_criteria(data, allow_class = "data.frame")
data <- ascertain_sir_classes(data, "data")
meet_criteria(translate_ab, allow_class = c("character", "logical"), has_length = 1, allow_NA = TRUE)
language <- validate_language(language)
meet_criteria(minimum, allow_class = c("numeric", "integer"), has_length = 1, is_positive_or_zero = TRUE, is_finite = TRUE)
@@ -249,7 +250,13 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
for (i in seq_len(ncol(data))) {
if (is.sir(data[, i, drop = TRUE])) {
data[, i] <- as.character(data[, i, drop = TRUE])
data[, i] <- gsub("(I|S)", "SI", data[, i, drop = TRUE])
if ("SDD" %in% data[, i, drop = TRUE]) {
if (message_not_thrown_before("sir_calc_df", combine_SI, entire_session = TRUE)) {
message_("Note that `sir_calc_df()` will also count dose-dependent susceptibility, 'SDD', as 'SI' when `combine_SI = TRUE`. This note will be shown once for this session.", as_note = FALSE)
}
}
data[, i] <- gsub("(I|S|SDD)", "SI", data[, i, drop = TRUE])
}
}
}
@@ -272,9 +279,9 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
for (i in seq_len(ncol(.data))) {
values <- .data[, i, drop = TRUE]
if (isTRUE(combine_SI)) {
values <- factor(values, levels = c("SI", "R"), ordered = TRUE)
values <- factor(values, levels = c("SI", "R", "NI"), ordered = TRUE)
} else {
values <- factor(values, levels = c("S", "I", "R"), ordered = TRUE)
values <- factor(values, levels = c("S", "SDD", "I", "R", "NI"), ordered = TRUE)
}
col_results <- as.data.frame(as.matrix(table(values)), stringsAsFactors = FALSE)
col_results$interpretation <- rownames(col_results)
@@ -351,8 +358,14 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
} else {
# don't use as.sir() here, as it would add the class 'sir' and we would like
# the same data structure as output, regardless of input
out$interpretation <- factor(out$interpretation, levels = c("S", "I", "R"), ordered = TRUE)
if (out$value[out$interpretation == "SDD"] > 0) {
out$interpretation <- factor(out$interpretation, levels = c("S", "SDD", "I", "R"), ordered = TRUE)
} else {
out$interpretation <- factor(out$interpretation, levels = c("S", "I", "R"), ordered = TRUE)
}
}
out <- out[!is.na(out$interpretation), , drop = FALSE]
if (data_has_groups) {
# ordering by the groups and two more: "antibiotic" and "interpretation"
@@ -373,5 +386,5 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
rownames(out) <- NULL
out <- as_original_data_class(out, class(data.bak)) # will remove tibble groups
structure(out, class = c("sir_df", "rsi_df", class(out)))
structure(out, class = c("sir_df", class(out)))
}
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
BIN
View File
Binary file not shown.
+6 -6
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -34,7 +34,7 @@
#' @param language language to choose. Use one of these supported language names or ISO-639-1 codes: `r vector_or(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`.
#' @details The currently `r length(LANGUAGES_SUPPORTED)` supported languages are `r vector_and(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`. All these languages have translations available for all antimicrobial drugs and colloquial microorganism names.
#'
#' To permanently silence the once-per-session language note on a non-English operating system, you can set the [package option][AMR-options] [`AMR_locale`][AMR-options] in your `.Rprofile` file like this:
#' To permanently silence the once-per-session language note on a non-English operating system, you can set the package option [`AMR_locale`][AMR-options] in your `.Rprofile` file like this:
#'
#' ```r
#' # Open .Rprofile file
@@ -51,12 +51,12 @@
#' ### 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")`][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 [package option][AMR-options] [`AMR_locale`][AMR-options], either by using e.g. `set_AMR_locale("German")` or by running e.g. `options(AMR_locale = "German")`.
#' 1. Setting the package option [`AMR_locale`][AMR-options], either by using e.g. `set_AMR_locale("German")` or by running e.g. `options(AMR_locale = "German")`.
#'
#' Note that setting an \R option only works in the same session. Save the command `options(AMR_locale = "(your language)")` to your `.Rprofile` file to apply it for every session. Run `utils::file.edit("~/.Rprofile")` to edit your `.Rprofile` file.
#' 2. Setting the system variable `LANGUAGE` or `LANG`, e.g. by adding `LANGUAGE="de_DE.utf8"` to your `.Renviron` file in your home directory.
#'
#' Thus, if the [package option][AMR-options] [`AMR_locale`][AMR-options] is set, the system variables `LANGUAGE` and `LANG` will be ignored.
#' Thus, if the package option [`AMR_locale`][AMR-options] is set, the system variables `LANGUAGE` and `LANG` will be ignored.
#' @rdname translate
#' @name translate
#' @export
+74 -29
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -34,7 +34,8 @@
# see https://github.com/tidyverse/dplyr/issues/5955 why this is required
# S3: ab_selector
# S3: ab_selector ----
# this does not need a .default method since it's used internally only
vec_ptype2.character.ab_selector <- function(x, y, ...) {
x
}
@@ -45,7 +46,8 @@ vec_cast.character.ab_selector <- function(x, to, ...) {
unclass(x)
}
# S3: ab_selector_any_all
# S3: ab_selector_any_all ----
# this does not need a .default method since it's used internally only
vec_ptype2.logical.ab_selector_any_all <- function(x, y, ...) {
x
}
@@ -56,12 +58,12 @@ vec_cast.logical.ab_selector_any_all <- function(x, to, ...) {
unclass(x)
}
# S3: ab
vec_ptype2.character.ab <- function(x, y, ...) {
# S3: ab ----
vec_ptype2.ab.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}
vec_ptype2.ab.character <- function(x, y, ...) {
y
vec_ptype2.ab.ab <- function(x, y, ...) {
x
}
vec_cast.character.ab <- function(x, to, ...) {
as.character(x)
@@ -70,12 +72,12 @@ vec_cast.ab.character <- function(x, to, ...) {
return_after_integrity_check(x, "antimicrobial drug code", as.character(AMR_env$AB_lookup$ab))
}
# S3: av
vec_ptype2.character.av <- function(x, y, ...) {
# S3: av ----
vec_ptype2.av.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}
vec_ptype2.av.character <- function(x, y, ...) {
y
vec_ptype2.av.av <- function(x, y, ...) {
x
}
vec_cast.character.av <- function(x, to, ...) {
as.character(x)
@@ -84,12 +86,12 @@ vec_cast.av.character <- function(x, to, ...) {
return_after_integrity_check(x, "antiviral drug code", as.character(AMR_env$AV_lookup$av))
}
# S3: mo
vec_ptype2.character.mo <- function(x, y, ...) {
# S3: mo ----
vec_ptype2.mo.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}
vec_ptype2.mo.character <- function(x, y, ...) {
y
vec_ptype2.mo.mo <- function(x, y, ...) {
x
}
vec_cast.character.mo <- function(x, to, ...) {
as.character(x)
@@ -99,12 +101,21 @@ vec_cast.mo.character <- function(x, to, ...) {
return_after_integrity_check(x, "microorganism code", as.character(AMR_env$MO_lookup$mo))
}
# S3: disk
vec_ptype2.integer.disk <- function(x, y, ...) {
x
# S3: disk ----
vec_ptype_full.disk <- function(x, ...) {
"disk"
}
vec_ptype2.disk.integer <- function(x, y, ...) {
y
vec_ptype_abbr.disk <- function(x, ...) {
"dsk"
}
vec_ptype2.disk.default <- function (x, y, ..., x_arg = "", y_arg = "") {
NA_disk_[0]
}
vec_ptype2.disk.disk <- function(x, y, ...) {
NA_disk_[0]
}
vec_cast.disk.disk <- function(x, to, ...) {
as.disk(x)
}
vec_cast.integer.disk <- function(x, to, ...) {
unclass(x)
@@ -125,29 +136,63 @@ vec_cast.disk.character <- function(x, to, ...) {
as.disk(x)
}
# S3: mic
# S3: mic ----
vec_ptype2.mic.default <- function (x, y, ..., x_arg = "", y_arg = "") {
# this will make sure that currently implemented MIC levels are returned
NA_mic_[0]
}
vec_ptype2.mic.mic <- function(x, y, ...) {
# this will make sure that currently implemented MIC levels are returned
NA_mic_[0]
}
vec_cast.mic.mic <- function(x, to, ...) {
# this will make sure that currently implemented MIC levels are returned
as.mic(x)
}
vec_cast.character.mic <- function(x, to, ...) {
as.character(x)
}
vec_cast.double.mic <- function(x, to, ...) {
as.double(x)
}
vec_cast.integer.mic <- function(x, to, ...) {
as.integer(x)
}
vec_cast.factor.mic <- function(x, to, ...) {
factor(as.character(x))
}
vec_cast.mic.double <- function(x, to, ...) {
as.mic(x)
}
vec_cast.mic.character <- function(x, to, ...) {
as.mic(x)
}
vec_cast.mic.integer <- function(x, to, ...) {
as.mic(x)
}
vec_cast.mic.factor <- function(x, to, ...) {
as.mic(x)
}
vec_math.mic <- function(.fn, x, ...) {
.fn(as.double(x), ...)
}
# S3: sir
vec_ptype2.character.sir <- function(x, y, ...) {
x
vec_arith.mic <- function(op, x, y, ...) {
vctrs::vec_arith(op, as.double(x), as.double(y))
}
vec_ptype2.sir.character <- function(x, y, ...) {
y
# S3: sir ----
vec_ptype2.sir.default <- function (x, y, ..., x_arg = "", y_arg = "") {
NA_sir_[0]
}
vec_ptype2.sir.sir <- function(x, y, ...) {
NA_sir_[0]
}
vec_ptype2.character.sir <- function(x, y, ...) {
NA_sir_[0]
}
vec_cast.sir.sir <- function(x, to, ...) {
# this makes sure that old SIR objects (with S/I/R) are converted to the current structure (S/SDD/I/R/NI)
as.sir(x)
}
vec_cast.character.sir <- function(x, to, ...) {
as.character(x)
+5 -5
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -31,13 +31,13 @@
#'
#' All antimicrobial drugs and their official names, ATC codes, ATC groups and defined daily dose (DDD) are included in this package, using the WHO Collaborating Centre for Drug Statistics Methodology.
#' @section WHOCC:
#' This package contains **all ~550 antibiotic, antimycotic and antiviral drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, <https://www.whocc.no>) and the Pharmaceuticals Community Register of the European Commission (<https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm>).
#' This package contains **all ~550 antibiotic, antimycotic and antiviral drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, <https://atcddd.fhi.no>) and the Pharmaceuticals Community Register of the European Commission (<https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm>).
#'
#' These have become the gold standard for international drug utilisation monitoring and research.
#'
#' The WHOCC is located in Oslo at the Norwegian Institute of Public Health and funded by the Norwegian government. The European Commission is the executive of the European Union and promotes its general interest.
#'
#' **NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package.** See <https://www.whocc.no/copyright_disclaimer/.>
#' **NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package.** See <https://atcddd.fhi.no/copyright_disclaimer/.>
#' @name WHOCC
#' @rdname WHOCC
+11 -168
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -27,171 +27,14 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
#' Deprecated Functions
#'
#' These functions are so-called '[Deprecated]'. **They will be removed in a future release.** Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
#' @keywords internal
#' @name AMR-deprecated
#' @rdname AMR-deprecated
#' @export
NA_rsi_ <- set_clean_class(factor(NA_character_, levels = c("S", "I", "R"), ordered = TRUE),
new_class = c("rsi", "ordered", "factor")
)
#' @rdname AMR-deprecated
#' @export
as.rsi <- function(x, ...) {
deprecation_warning("as.rsi", "as.sir")
UseMethod("as.rsi")
}
#' @noRd
#' @export
as.rsi.default <- function(...) {
as.sir.default(...)
}
#' @noRd
#' @export
as.rsi.mic <- function(...) {
as.sir.mic(...)
}
#' @noRd
#' @export
as.rsi.disk <- function(...) {
as.sir.disk(...)
}
#' @noRd
#' @export
as.rsi.data.frame <- function(...) {
as.sir.data.frame(...)
}
#' @rdname AMR-deprecated
#' @export
facet_rsi <- function(...) {
deprecation_warning("facet_rsi", "facet_sir")
facet_sir(...)
}
#' @rdname AMR-deprecated
#' @export
geom_rsi <- function(...) {
deprecation_warning("geom_rsi", "geom_sir")
geom_sir(...)
}
#' @rdname AMR-deprecated
#' @export
ggplot_rsi <- function(...) {
deprecation_warning("ggplot_rsi", "ggplot_sir")
ggplot_sir(...)
}
#' @rdname AMR-deprecated
#' @export
ggplot_rsi_predict <- function(...) {
deprecation_warning("ggplot_rsi_predict", "ggplot_sir_predict")
ggplot_sir_predict(...)
}
#' @rdname AMR-deprecated
#' @export
is.rsi <- function(...) {
# REMINDER: change as.sir() to remove the deprecation warning there
suppressWarnings(is.sir(...))
}
#' @rdname AMR-deprecated
#' @export
is.rsi.eligible <- function(...) {
deprecation_warning("is.rsi.eligible", "is_sir_eligible")
is_sir_eligible(...)
}
#' @rdname AMR-deprecated
#' @export
labels_rsi_count <- function(...) {
deprecation_warning("labels_rsi_count", "labels_sir_count")
labels_sir_count(...)
}
#' @rdname AMR-deprecated
#' @export
n_rsi <- function(...) {
deprecation_warning("n_rsi", "n_sir")
n_sir(...)
}
#' @rdname AMR-deprecated
#' @export
random_rsi <- function(...) {
deprecation_warning("random_rsi", "random_sir")
random_sir(...)
}
#' @rdname AMR-deprecated
#' @export
rsi_df <- function(...) {
deprecation_warning("rsi_df", "sir_df")
sir_df(...)
}
#' @rdname AMR-deprecated
#' @export
rsi_predict <- function(...) {
deprecation_warning("rsi_predict", "sir_predict")
sir_predict(...)
}
#' @rdname AMR-deprecated
#' @export
scale_rsi_colours <- function(...) {
deprecation_warning("scale_rsi_colours", "scale_sir_colours")
scale_sir_colours(...)
}
#' @rdname AMR-deprecated
#' @export
theme_rsi <- function(...) {
deprecation_warning("theme_rsi", "theme_sir")
theme_sir(...)
}
# will be exported using s3_register() in R/zzz.R
pillar_shaft.rsi <- pillar_shaft.sir
type_sum.rsi <- function(x, ...) {
if (message_not_thrown_before("type_sum.rsi")) {
deprecation_warning(extra_msg = "The 'rsi' class has been replaced with 'sir'. Transform your 'rsi' columns to 'sir' with `as.sir()`, e.g.:\n your_data %>% mutate_if(is.rsi, as.sir)")
}
"rsi"
}
#' @method print rsi
#' @export
#' @noRd
print.rsi <- function(x, ...) {
deprecation_warning(extra_msg = "The 'rsi' class has been replaced with 'sir' - transform your 'rsi' data with `as.sir()`")
cat("Class 'rsi'", font_bold(font_red("[!]\n")))
print(as.character(x), quote = FALSE)
}
#' @noRd
#' @export
`[<-.rsi` <- `[<-.sir`
#' @noRd
#' @export
`[[<-.rsi` <- `[[<-.sir`
#' @noRd
#' @export
barplot.rsi <- barplot.sir
#' @noRd
#' @export
c.rsi <- c.sir
#' @noRd
#' @export
droplevels.rsi <- droplevels.sir
#' @noRd
#' @export
plot.rsi <- plot.sir
#' @noRd
#' @export
rep.rsi <- rep.sir
#' @noRd
#' @export
summary.rsi <- summary.sir
#' @noRd
#' @export
unique.rsi <- unique.sir
# WHEN REMOVING RSI, DON'T FORGET TO REMOVE :
# - THE "rsi_df" CLASS FROM R/sir_calc.R
# - CODE CONTAINING only_rsi_columns, colours_RSI, include_untested_rsi, prob_RSI
# #' Deprecated Functions
# #'
# #' These functions are so-called '[Deprecated]'. **They will be removed in a future release.** Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
# #' @keywords internal
# #' @name AMR-deprecated
# #' @rdname AMR-deprecated
# #' @export
# NULL
deprecation_warning <- function(old = NULL, new = NULL, extra_msg = NULL, is_function = TRUE) {
if (is.null(old)) {
+72 -48
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -58,16 +58,20 @@ AMR_env$av_previously_coerced <- data.frame(
AMR_env$sir_interpretation_history <- data.frame(
datetime = Sys.time()[0],
index = integer(0),
ab_user = character(0),
mo_user = character(0),
ab_given = character(0),
mo_given = character(0),
host_given = character(0),
ab = set_clean_class(character(0), c("ab", "character")),
mo = set_clean_class(character(0), c("mo", "character")),
host = character(0),
method = character(0),
input = double(0),
outcome = NA_sir_[0],
method = character(0),
breakpoint_S_R = character(0),
notes = character(0),
guideline = character(0),
ref_table = character(0),
uti = logical(0),
breakpoint_S_R = character(0),
stringsAsFactors = FALSE
)
@@ -77,17 +81,15 @@ AMR_env$is_dark_theme <- NULL
AMR_env$chmatch <- import_fn("chmatch", "data.table", error_on_fail = FALSE)
AMR_env$chin <- import_fn("%chin%", "data.table", error_on_fail = FALSE)
# determine info icon for messages
if (pkg_is_available("cli")) {
# let cli do the determination of supported symbols
AMR_env$info_icon <- import_fn("symbol", "cli")$info
AMR_env$bullet_icon <- import_fn("symbol", "cli")$bullet
AMR_env$dots <- import_fn("symbol", "cli")$ellipsis
} else {
AMR_env$info_icon <- "i"
AMR_env$bullet_icon <- "*"
AMR_env$dots <- "..."
}
# take cli symbols and error function if available
AMR_env$info_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$info %or% "i"
AMR_env$bullet_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$bullet %or% "*"
AMR_env$cross_icon <- if (isTRUE(base::l10n_info()$`UTF-8`)) "\u00d7" else "x"
AMR_env$dots <- import_fn("symbol", "cli", error_on_fail = FALSE)$ellipsis %or% "..."
AMR_env$sup_1_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$sup_1 %or% "*"
AMR_env$cli_abort <- import_fn("cli_abort", "cli", error_on_fail = FALSE)
.onLoad <- function(lib, pkg) {
# Support for tibble headers (type_sum) and tibble columns content (pillar_shaft)
@@ -98,16 +100,16 @@ if (pkg_is_available("cli")) {
s3_register("pillar::pillar_shaft", "av")
s3_register("pillar::pillar_shaft", "mo")
s3_register("pillar::pillar_shaft", "sir")
s3_register("pillar::pillar_shaft", "rsi") # remove in a later version
s3_register("pillar::pillar_shaft", "mic")
s3_register("pillar::pillar_shaft", "disk")
# no type_sum of disk, that's now in vctrs::vec_ptype_full
s3_register("pillar::type_sum", "ab")
s3_register("pillar::type_sum", "av")
s3_register("pillar::type_sum", "mo")
s3_register("pillar::type_sum", "sir")
s3_register("pillar::type_sum", "rsi") # remove in a later version
s3_register("pillar::type_sum", "mic")
s3_register("pillar::type_sum", "disk")
s3_register("pillar::tbl_sum", "antibiogram")
s3_register("pillar::tbl_format_footer", "antibiogram")
# Support for frequency tables from the cleaner package
s3_register("cleaner::freq", "mo")
s3_register("cleaner::freq", "sir")
@@ -132,6 +134,7 @@ if (pkg_is_available("cli")) {
s3_register("knitr::knit_print", "antibiogram")
s3_register("knitr::knit_print", "formatted_bug_drug_combinations")
# Support vctrs package for use in e.g. dplyr verbs
# NOTE 2024-02-22 this is the right way - it should be 2 S3 classes in the second argument
# S3: ab_selector
s3_register("vctrs::vec_ptype2", "character.ab_selector")
s3_register("vctrs::vec_ptype2", "ab_selector.character")
@@ -141,23 +144,26 @@ if (pkg_is_available("cli")) {
s3_register("vctrs::vec_ptype2", "ab_selector_any_all.logical")
s3_register("vctrs::vec_cast", "logical.ab_selector_any_all")
# S3: ab
s3_register("vctrs::vec_ptype2", "character.ab")
s3_register("vctrs::vec_ptype2", "ab.character")
s3_register("vctrs::vec_ptype2", "ab.default")
s3_register("vctrs::vec_ptype2", "ab.ab")
s3_register("vctrs::vec_cast", "character.ab")
s3_register("vctrs::vec_cast", "ab.character")
# S3: av
s3_register("vctrs::vec_ptype2", "character.av")
s3_register("vctrs::vec_ptype2", "av.character")
s3_register("vctrs::vec_ptype2", "av.default")
s3_register("vctrs::vec_ptype2", "av.av")
s3_register("vctrs::vec_cast", "character.av")
s3_register("vctrs::vec_cast", "av.character")
# S3: mo
s3_register("vctrs::vec_ptype2", "character.mo")
s3_register("vctrs::vec_ptype2", "mo.character")
s3_register("vctrs::vec_ptype2", "mo.default")
s3_register("vctrs::vec_ptype2", "mo.mo")
s3_register("vctrs::vec_cast", "character.mo")
s3_register("vctrs::vec_cast", "mo.character")
# S3: disk
s3_register("vctrs::vec_ptype2", "integer.disk")
s3_register("vctrs::vec_ptype2", "disk.integer")
s3_register("vctrs::vec_ptype_full", "disk")
s3_register("vctrs::vec_ptype_abbr", "disk")
s3_register("vctrs::vec_ptype2", "disk.default")
s3_register("vctrs::vec_ptype2", "disk.disk")
s3_register("vctrs::vec_cast", "disk.disk")
s3_register("vctrs::vec_cast", "integer.disk")
s3_register("vctrs::vec_cast", "disk.integer")
s3_register("vctrs::vec_cast", "double.disk")
@@ -165,16 +171,26 @@ if (pkg_is_available("cli")) {
s3_register("vctrs::vec_cast", "character.disk")
s3_register("vctrs::vec_cast", "disk.character")
# S3: mic
s3_register("vctrs::vec_ptype2", "mic.default")
s3_register("vctrs::vec_ptype2", "mic.mic")
s3_register("vctrs::vec_cast", "character.mic")
s3_register("vctrs::vec_cast", "double.mic")
s3_register("vctrs::vec_cast", "integer.mic")
s3_register("vctrs::vec_cast", "factor.mic")
s3_register("vctrs::vec_cast", "mic.character")
s3_register("vctrs::vec_cast", "mic.double")
s3_register("vctrs::vec_cast", "mic.integer")
s3_register("vctrs::vec_cast", "mic.factor")
s3_register("vctrs::vec_cast", "mic.mic")
s3_register("vctrs::vec_math", "mic")
s3_register("vctrs::vec_arith", "mic")
# S3: sir
s3_register("vctrs::vec_ptype2", "sir.default")
s3_register("vctrs::vec_ptype2", "sir.sir")
s3_register("vctrs::vec_ptype2", "character.sir")
s3_register("vctrs::vec_ptype2", "sir.character")
s3_register("vctrs::vec_cast", "character.sir")
s3_register("vctrs::vec_cast", "sir.character")
s3_register("vctrs::vec_cast", "sir.sir")
# if mo source exists, fire it up (see mo_source())
if (tryCatch(file.exists(getOption("AMR_mo_source", "~/mo_source.rds")), error = function(e) FALSE)) {
@@ -194,26 +210,34 @@ if (pkg_is_available("cli")) {
.onAttach <- function(lib, pkg) {
# if custom ab option is available, load it
if (!is.null(getOption("AMR_custom_ab")) && file.exists(getOption("AMR_custom_ab", default = ""))) {
packageStartupMessage("Adding custom antimicrobials from '", getOption("AMR_custom_ab"), "'...", appendLF = FALSE)
x <- readRDS_AMR(getOption("AMR_custom_ab"))
tryCatch(
{
suppressWarnings(suppressMessages(add_custom_antimicrobials(x)))
packageStartupMessage("OK.")
},
error = function(e) packageStartupMessage("Failed: ", e$message)
)
if (getOption("AMR_custom_ab") %unlike% "[.]rds$") {
packageStartupMessage("The file with custom antimicrobials must be an RDS file. Set the option `AMR_custom_ab` to another path.")
} else {
packageStartupMessage("Adding custom antimicrobials from '", getOption("AMR_custom_ab"), "'...", appendLF = FALSE)
x <- readRDS_AMR(getOption("AMR_custom_ab"))
tryCatch(
{
suppressWarnings(suppressMessages(add_custom_antimicrobials(x)))
packageStartupMessage("OK.")
},
error = function(e) packageStartupMessage("Failed: ", e$message)
)
}
}
# if custom mo option is available, load it
if (!is.null(getOption("AMR_custom_mo")) && file.exists(getOption("AMR_custom_mo", default = ""))) {
packageStartupMessage("Adding custom microorganisms from '", getOption("AMR_custom_mo"), "'...", appendLF = FALSE)
x <- readRDS_AMR(getOption("AMR_custom_mo"))
tryCatch(
{
suppressWarnings(suppressMessages(add_custom_microorganisms(x)))
packageStartupMessage("OK.")
},
error = function(e) packageStartupMessage("Failed: ", e$message)
)
if (getOption("AMR_custom_mo") %unlike% "[.]rds$") {
packageStartupMessage("The file with custom microorganisms must be an RDS file. Set the option `AMR_custom_mo` to another path.")
} else {
packageStartupMessage("Adding custom microorganisms from '", getOption("AMR_custom_mo"), "'...", appendLF = FALSE)
x <- readRDS_AMR(getOption("AMR_custom_mo"))
tryCatch(
{
suppressWarnings(suppressMessages(add_custom_microorganisms(x)))
packageStartupMessage("OK.")
},
error = function(e) packageStartupMessage("Failed: ", e$message)
)
}
}
}
+2 -4
View File
@@ -1,12 +1,10 @@
# `AMR` (for R)
<a href="https://msberends.github.io/AMR/"><img src="https://msberends.github.io/AMR/AMR_intro.png" align="center"></a>
<a target="_blank" href="https://chatgpt.com/g/g-M4UNLwFi5-amr-for-r-assistant"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/AMRforRGPT.svg" style="width: 400px;"></a>
----
This work was published in the Journal of Statistical Software (Volume 104(3); [DOI 10.18637/jss.v104.i03](https://doi.org/10.18637/jss.v104.i03)) and formed the basis of two PhD theses ([DOI 10.33612/diss.177417131](https://doi.org/10.33612/diss.177417131) and [DOI 10.33612/diss.192486375](https://doi.org/10.33612/diss.192486375)).
`AMR` is a free, open-source and independent R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. Our aim is to provide a standard for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting. It is currently being used in over 175 countries.
`AMR` is a free, open-source and independent R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. Our aim is to provide a standard for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting. It is currently being used in over 175 countries. This work was published in the Journal of Statistical Software (2022, Volume 104(3); [DOI 10.18637/jss.v104.i03](https://doi.org/10.18637/jss.v104.i03)) and formed the basis of two PhD theses ([DOI 10.33612/diss.177417131](https://doi.org/10.33612/diss.177417131) and [DOI 10.33612/diss.192486375](https://doi.org/10.33612/diss.192486375)).
After installing this package, R knows ~52,000 distinct microbial species and all ~600 antibiotic, antimycotic, and antiviral drugs by name and code (including ATC, WHONET/EARS-Net, PubChem, LOINC and SNOMED CT), and knows all about valid SIR and MIC values. It supports any data format, including WHONET/EARS-Net data. Antimicrobial names and group names are available in English, Chinese, Danish, Dutch, French, German, Greek, Italian, Japanese, Polish, Portuguese, Russian, Spanish, Swedish, Turkish, and Ukrainian.
+37 -46
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -35,21 +35,13 @@ template:
bootswatch: "flatly"
assets: "pkgdown/logos" # use logos in this folder
bslib:
base_font: {google: "Lato"}
heading_font: {google: "Lato"}
code_font: {google: "Fira Code"}
# body-text-align: "justify"
line-height-base: 1.75
# the green "success" colour of this bootstrap theme should be the same as the green in our logo
success: "#128f76"
link-color: "#128f76"
light: "#128f76a6" # this is success with 60% alpha
# the template "info" is blue - this should be a green fitting our theme
info: "#60a799"
# make top bar a bit wider
navbar-padding-y: "0.5rem"
opengraph:
twitter:
creator: "@msberends"
card: summary_large_image
news:
one_page: true
@@ -61,7 +53,7 @@ footer:
right: [logo]
components:
devtext: '<code>AMR</code> (for R). Free and open-source, licenced under the <a target="_blank" href="https://github.com/msberends/AMR/blob/main/LICENSE">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <a target="_blank" href="https://www.rug.nl">University of Groningen</a> and <a target="_blank" href="https://www.umcg.nl">University Medical Center Groningen</a> in The Netherlands.'
logo: '<a target="_blank" href="https://www.rug.nl"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/logos/logo_rug.svg" style="max-width: 150px;"></a><a target="_blank" href="https://www.umcg.nl"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/logos/logo_umcg.svg" style="max-width: 150px;"></a>'
logo: '<a target="_blank" href="https://www.rug.nl"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/logo_rug.svg" style="max-width: 150px;"></a><a target="_blank" href="https://www.umcg.nl"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/logo_umcg.svg" style="max-width: 150px;"></a>'
home:
sidebar:
@@ -100,7 +92,7 @@ navbar:
- text: "Work with WHONET Data"
icon: "fa-globe-americas"
href: "articles/WHONET.html"
# - text: "Import Data From SPSS/SAS/Stata"
# - text: "Import Data From SPSS/Stata"
# icon: "fa-file-upload"
# href: "articles/SPSS.html"
- text: "Apply Eucast Rules"
@@ -115,21 +107,9 @@ navbar:
- text: "Get Properties of an Antiviral Drug"
icon: "fa-capsules"
href: "reference/av_property.html" # reference instead of an article
- text: "With other pkgs"
icon: "fa-layer-group"
menu:
- text: "AMR & dplyr/tidyverse"
icon: "fa-layer-group"
href: "articles/other_pkg.html"
- text: "AMR & data.table"
icon: "fa-layer-group"
href: "articles/other_pkg.html"
- text: "AMR & tidymodels"
icon: "fa-layer-group"
href: "articles/other_pkg.html"
- text: "AMR & base R"
icon: "fa-layer-group"
href: "articles/other_pkg.html"
- text: "AMR for Python"
icon: "fab fa-python"
href: "articles/AMR_for_Python.html"
- text: "Manual"
icon: "fa-book-open"
href: "reference/index.html"
@@ -174,7 +154,7 @@ reference:
- "`atc_online_property`"
- "`add_custom_antimicrobials`"
- title: "Preparing data: antimicrobial resistance"
- title: "Preparing data: antimicrobial results"
desc: >
With `as.mic()` and `as.disk()` you can transform your raw input to valid MIC or disk diffusion values.
Use `as.sir()` for cleaning raw data to let it only contain "R", "I" and "S", or to interpret MIC or disk diffusion values as SIR based on the lastest EUCAST and CLSI guidelines.
@@ -186,7 +166,7 @@ reference:
- "`eucast_rules`"
- "`custom_eucast_rules`"
- title: "Analysing data: antimicrobial resistance"
- title: "Analysing data"
desc: >
Use these function for the analysis part. You can use `susceptibility()` or `resistance()` on any antibiotic column.
With `antibiogram()`, you can generate a traditional, combined, syndromic, or weighted-incidence syndromic combination
@@ -202,15 +182,26 @@ reference:
- "`key_antimicrobials`"
- "`mdro`"
- "`count`"
- "`plot`"
- "`ggplot_sir`"
- "`bug_drug_combinations`"
- "`antibiotic_class_selectors`"
- "`mean_amr_distance`"
- "`resistance_predict`"
- "`guess_ab_col`"
- title: "Other: AMR-specific options"
- title: "Plotting data"
desc: >
Use these functions for the plotting part. The `scale_*_mic()` functions extend the ggplot2 package to allow plotting of
MIC values, even within a manually set range.
If using `plot()` (base R) or `autoplot()` (ggplot2) on MIC values or disk diffusion values, the user can
set the interpretation guideline to give the bars the right SIR colours.
The `ggplot_sir()` function is a short wrapper for users not much accustomed to ggplot2 yet.
The `ggplot_pca()` function is a specific function to plot so-called biplots for PCA (principal component analysis).
contents:
- "`plot`"
- "`ggplot_sir`"
- "`ggplot_pca`"
- title: "AMR-specific options"
desc: >
The AMR package is customisable, by providing settings that can be set per user or per team. For
example, the default interpretation guideline can be changed from EUCAST to CLSI, or a supported
@@ -235,16 +226,16 @@ reference:
Some pages about our package and its external sources. Be sure to read our [How To's](./../articles/index.html)
for more information about how to work with functions in this package.
contents:
- "`example_isolates`"
- "`microorganisms`"
- "`antibiotics`"
- "`clinical_breakpoints`"
- "`example_isolates`"
- "`microorganisms.codes`"
- "`microorganisms.groups`"
- "`antibiotics`"
- "`intrinsic_resistant`"
- "`dosage`"
- "`WHOCC`"
- "`example_isolates_unclean`"
- "`clinical_breakpoints`"
- "`WHONET`"
- title: "Other: miscellaneous functions"
@@ -255,9 +246,9 @@ reference:
contents:
- "`age_groups`"
- "`age`"
- "`export_ncbi_biosample`"
- "`availability`"
- "`get_AMR_locale`"
- "`ggplot_pca`"
- "`italicise_taxonomy`"
- "`join`"
- "`like`"
@@ -273,10 +264,10 @@ reference:
- "`kurtosis`"
- "`skewness`"
- title: "Other: deprecated functions"
desc: >
These functions are deprecated, meaning that they will still
work but show a warning with every use and will be removed
in a future version.
contents:
- "`AMR-deprecated`"
# - title: "Other: deprecated functions"
# desc: >
# These functions are deprecated, meaning that they will still
# work but show a warning with every use and will be removed
# in a future version.
# contents:
# - "`AMR-deprecated`"
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
+3
View File
@@ -0,0 +1,3 @@
green grass #a7dbc3
green bacteria #128F76
blue sky #a8d5ef
Binary file not shown.
File diff suppressed because one or more lines are too long
+69
View File
@@ -0,0 +1,69 @@
---
title: "AMR Goes Vet"
author: "Jason, Matthew, Javier, Matthijs"
date: "2024-02-20"
format:
html:
embed-resources: true
---
## Import WHONET data set
```{r, message=FALSE, warning=FALSE}
library(dplyr)
library(readr)
library(tidyr)
# WHONET version of 16th Feb 2024
whonet_breakpoints <- read_tsv("WHONET/Resources/Breakpoints.txt", na = c("", "NA", "-"),
show_col_types = FALSE, guess_max = Inf) %>%
filter(GUIDELINES %in% c("CLSI", "EUCAST"))
dim(whonet_breakpoints)
```
# EDA of Animal Breakpoints
```{r}
whonet_breakpoints |>
filter(BREAKPOINT_TYPE != "Human")
whonet_breakpoints |>
filter(BREAKPOINT_TYPE != "Human") |>
count(BREAKPOINT_TYPE)
whonet_breakpoints |>
filter(BREAKPOINT_TYPE == "Animal")
```
### Count of all animal breakpoints
```{r}
whonet_breakpoints |>
filter(BREAKPOINT_TYPE == "Animal") |>
count(YEAR, HOST, REFERENCE_TABLE = gsub("VET[0-9]+ ", "", REFERENCE_TABLE)) |>
pivot_wider(names_from = YEAR, values_from = n, values_fill = list(n = 0)) |>
arrange(HOST, REFERENCE_TABLE)
```
### Cats only
```{r}
whonet_breakpoints |>
filter(HOST == "Cats", YEAR >= 2021) |>
select(GUIDELINES, YEAR, TEST_METHOD, ORGANISM_CODE, R, S) |>
mutate(MO_NAME = AMR::mo_shortname(ORGANISM_CODE), .before = R) |>
as.data.frame()
```
### Site of infection in cats (2023)
```{r}
whonet_breakpoints |>
filter(HOST == "Cats", YEAR == 2023) |>
mutate(MO = AMR::mo_shortname(ORGANISM_CODE),
AB = AMR::ab_name(WHONET_ABX_CODE),
SITE_OF_INFECTION = substr(SITE_OF_INFECTION, 1, 25)) |>
arrange(MO, AB) |>
select(MO, AB, SITE_OF_INFECTION) |>
as.data.frame()
```
Binary file not shown.
Binary file not shown.
+61
View File
@@ -0,0 +1,61 @@
#!/bin/bash
# Check if the current directory is named 'AMR'
if [ "$(basename "$PWD")" != "AMR" ]; then
echo "Error: The script must be run from the 'AMR' directory."
exit 1
fi
# Define the output file, located in ./data-raw
output_file="data-raw/gpt_training_text.txt"
# Clear the output file if it exists
echo "This files contains all context you must know about the AMR package for R."> "$output_file"
echo -e "\n\n\n\n" >> "$output_file"
# Function to remove header block (delimited by # ======)
remove_header() {
sed '/# =\{6,\}/,/# =\{6,\}/d' "$1"
}
# Process all .R files in the 'R' folder
for file in R/*.R; do
echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
remove_header "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
done
# Process all .Rmd files in the 'vignettes' folder
for file in vignettes/*.Rmd; do
echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
remove_header "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
done
# Process important metadata files (DESCRIPTION, NAMESPACE, index.md)
for file in DESCRIPTION NAMESPACE index.md; do
if [[ -f $file ]]; then
echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
cat "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
fi
done
# Process test files (if available) in the 'tests' folder
for file in tests/*.R; do
echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
remove_header "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
done
# Process all .Rd files from the 'man' folder
for file in man/*.Rd; do
echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
remove_header "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
done
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 330 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.
+290
View File
@@ -0,0 +1,290 @@
#!/bin/bash
# ==================================================================== #
# TITLE: #
# AMR: An R Package for Working with Antimicrobial Resistance Data #
# #
# SOURCE CODE: #
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
# Center Groningen in The Netherlands, in collaboration with many #
# colleagues from around the world, see our website. #
# #
# 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/ #
# ==================================================================== #
# Clean up
rm -rf python_wrapper/AMR/*
mkdir -p python_wrapper/AMR/AMR
# Output Python file
functions_file="python_wrapper/AMR/AMR/functions.py"
datasets_file="python_wrapper/AMR/AMR/datasets.py"
init_file="python_wrapper/AMR/AMR/__init__.py"
# Write header to the datasets Python file, including the convert_to_python function
cat <<EOL > "$datasets_file"
BLUE = '\033[94m'
GREEN = '\033[32m'
RESET = '\033[0m'
print(f"{BLUE}AMR:{RESET} Setting up R environment and AMR datasets...", flush=True)
from rpy2 import robjects
from rpy2.robjects import pandas2ri
from rpy2.robjects.packages import importr, isinstalled
import pandas as pd
# import importlib.metadata as metadata
# Check if AMR package is installed in R
if not isinstalled('AMR'):
utils = importr('utils')
utils.install_packages('AMR', repos='https://msberends.r-universe.dev')
# Python package version of AMR
python_amr_version = metadata.version('AMR')
# R package version of AMR
# r_amr_version = robjects.r('packageVersion("AMR")')[0]
# Compare R and Python package versions
# if r_amr_version != python_amr_version:
# print(f"{BLUE}AMR:{RESET} Version mismatch detected. Updating AMR R package version to {python_amr_version}...", flush=True)
# try:
# # Re-install the specific version of AMR in R
# utils = importr('utils')
# utils.install_packages('AMR', repos='https://msberends.r-universe.dev')
# except Exception as e:
# print(f"{BLUE}AMR:{RESET} Could not update: {e}{RESET}", flush=True)
# Activate the automatic conversion between R and pandas DataFrames
pandas2ri.activate()
# example_isolates
example_isolates = pandas2ri.rpy2py(robjects.r('''
df <- AMR::example_isolates
df[] <- lapply(df, function(x) {
if (inherits(x, c("Date", "POSIXt", "factor"))) {
as.character(x)
} else {
x
}
})
df <- df[, !sapply(df, is.list)]
df
'''))
example_isolates['date'] = pd.to_datetime(example_isolates['date'])
# microorganisms
microorganisms = pandas2ri.rpy2py(robjects.r('AMR::microorganisms[, !sapply(AMR::microorganisms, is.list)]'))
antibiotics = pandas2ri.rpy2py(robjects.r('AMR::antibiotics[, !sapply(AMR::antibiotics, is.list)]'))
clinical_breakpoints = pandas2ri.rpy2py(robjects.r('AMR::clinical_breakpoints[, !sapply(AMR::clinical_breakpoints, is.list)]'))
print(f"{BLUE}AMR:{RESET} {GREEN}Done.{RESET}", flush=True)
EOL
echo "from .datasets import example_isolates" >> $init_file
echo "from .datasets import microorganisms" >> $init_file
echo "from .datasets import antibiotics" >> $init_file
echo "from .datasets import clinical_breakpoints" >> $init_file
# Write header to the functions Python file, including the convert_to_python function
cat <<EOL > "$functions_file"
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
from rpy2.robjects.vectors import StrVector, FactorVector, IntVector, FloatVector, DataFrame
from rpy2.robjects import pandas2ri
import pandas as pd
import numpy as np
# Activate automatic conversion between R data frames and pandas data frames
pandas2ri.activate()
# Import the AMR R package
amr_r = importr('AMR')
def convert_to_python(r_output):
# Check if it's a StrVector (R character vector)
if isinstance(r_output, StrVector):
return list(r_output) # Convert to a Python list of strings
# Check if it's a FactorVector (R factor)
elif isinstance(r_output, FactorVector):
return list(r_output) # Convert to a list of integers (factor levels)
# Check if it's an IntVector or FloatVector (numeric R vectors)
elif isinstance(r_output, (IntVector, FloatVector)):
return list(r_output) # Convert to a Python list of integers or floats
# Check if it's a pandas-compatible R data frame
elif isinstance(r_output, pd.DataFrame):
return r_output # Return as pandas DataFrame (already converted by pandas2ri)
elif isinstance(r_output, DataFrame):
return pandas2ri.rpy2py(r_output) # Return as pandas DataFrame
# Check if the input is a NumPy array and has a string data type
if isinstance(r_output, np.ndarray) and np.issubdtype(r_output.dtype, np.str_):
return r_output.tolist() # Convert to a regular Python list
# Fall-back
return r_output
EOL
# Directory where the .Rd files are stored (update path as needed)
rd_dir="../man"
# Iterate through each .Rd file in the man directory
for rd_file in "$rd_dir"/*.Rd; do
# Extract function names and their arguments from the .Rd files
awk '
BEGIN {
usage_started = 0
}
# Detect the start of the \usage block
/^\\usage\{/ {
usage_started = 1
}
# Detect the end of the \usage block
usage_started && /^\}/ {
usage_started = 0
}
# Process lines within the \usage block that look like function calls
usage_started && /^[a-zA-Z_]+/ {
func_line = $0
func_line_py = $0
# Extract the function name (up to the first parenthesis)
sub(/\(.*/, "", func_line)
func_name = func_line
func_name_py = func_name
# Replace dots with underscores in Python function names
gsub(/\./, "_", func_name_py)
# Extract the arguments (inside the parentheses)
sub(/^[^(]+\(/, "", $0)
sub(/\).*/, "", $0)
func_args = $0
# Count the number of arguments
arg_count = split(func_args, arg_array, ",")
# Handle "..." arguments (convert them to *args, **kwargs in Python)
gsub("\\.\\.\\.", "*args, **kwargs", func_args)
# Remove default values from arguments
gsub(/ = [^,]+/, "", func_args)
# If no arguments, skip the function (dont print it)
if (arg_count == 0) {
func_args = "*args, **kwargs"
}
# If more than 1 argument, replace the 2nd to nth arguments with *args, **kwargs
if (arg_count > 1) {
first_arg = arg_array[1]
func_args = first_arg ", *args, **kwargs"
}
if (arg_array[1] == "...") {
func_args = "*args, **kwargs"
}
# Skip functions where func_name_py is identical to func_args
if (func_name_py == func_args) {
next
}
# Skip functions matching the regex pattern
if (func_name_py ~ /^(x |facet|scale|set|get|NA_|microorganisms|antibiotics|clinical_breakpoints|example_isolates)/) {
next
}
# Replace TRUE/FALSE/NULL
gsub("TRUE", "True", func_args)
gsub("FALSE", "False", func_args)
gsub("NULL", "None", func_args)
# Write the Python function definition to the output file
print "def " func_name_py "(" func_args "):" >> "'"$functions_file"'"
print " \"\"\"See our website of the R package for the manual: https://msberends.github.io/AMR/index.html\"\"\"" >> "'"$functions_file"'"
print " return convert_to_python(amr_r." func_name_py "(" func_args "))" >> "'"$functions_file"'"
print "from .functions import " func_name_py >> "'"$init_file"'"
}
' "$rd_file"
done
# Output completion message
echo "Python wrapper functions generated in $functions_file."
echo "Python wrapper functions listed in $init_file."
cp ../vignettes/AMR_for_Python.Rmd python_wrapper/AMR/README.md
sed -i '1,/^# Introduction$/d' python_wrapper/AMR/README.md
echo "README copied"
# Path to your DESCRIPTION file
description_file="../DESCRIPTION"
# Output setup.py file
functions_file="python_wrapper/AMR/setup.py"
# Extract the relevant fields from DESCRIPTION
version=$(grep "^Version:" "$description_file" | awk '{print $2}')
# Write the setup.py file
cat <<EOL > "$functions_file"
from setuptools import setup, find_packages
setup(
name='AMR',
version='$version',
packages=find_packages(),
install_requires=[
'rpy2',
'numpy',
'pandas',
],
author='Dr. Matthijs Berends',
author_email='m.s.berends@umcg.nl',
description='A Python wrapper for the AMR R package',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
url='https://github.com/msberends/AMR',
project_urls={
'Bug Tracker': 'https://github.com/msberends/AMR/issues',
},
license='GPL 2',
classifiers=[
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
],
python_requires='>=3.6',
)
EOL
# Output completion message
echo "setup.py has been generated in $functions_file."
cd python_wrapper/AMR
python3 setup.py sdist bdist_wheel
+3 -3
View File
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -6,9 +6,9 @@
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
# Data. Journal of Statistical Software, 104(3), 1-31. #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
@@ -28,7 +28,7 @@
# ==================================================================== #
# Run this file to update the package using:
# source("data-raw/_pre_commit_hook.R")
# source("data-raw/_pre_commit_checks.R")
library(dplyr, warn.conflicts = FALSE)
try(detach("package:data.table", unload = TRUE), silent = TRUE) # to prevent like() to precede over AMR::like
@@ -36,12 +36,14 @@ devtools::load_all(quiet = TRUE)
suppressMessages(set_AMR_locale("English"))
old_globalenv <- ls(envir = globalenv())
pre_commit_lst <- list()
# Save internal data to R/sysdata.rda -------------------------------------
usethis::ui_info(paste0("Updating internal package data"))
# See 'data-raw/eucast_rules.tsv' for the EUCAST reference file
EUCAST_RULES_DF <- utils::read.delim(
pre_commit_lst$EUCAST_RULES_DF <- utils::read.delim(
file = "data-raw/eucast_rules.tsv",
skip = 9,
sep = "\t",
@@ -67,7 +69,7 @@ EUCAST_RULES_DF <- utils::read.delim(
mutate(reference.rule_group = as.character(reference.rule_group)) %>%
select(-sorting_rule)
TRANSLATIONS <- utils::read.delim(
pre_commit_lst$TRANSLATIONS <- utils::read.delim(
file = "data-raw/translations.tsv",
sep = "\t",
stringsAsFactors = FALSE,
@@ -82,15 +84,15 @@ TRANSLATIONS <- utils::read.delim(
quote = ""
)
LANGUAGES_SUPPORTED_NAMES <- c(
pre_commit_lst$LANGUAGES_SUPPORTED_NAMES <- c(
list(en = list(exonym = "English", endonym = "English")),
lapply(
TRANSLATIONS[, which(nchar(colnames(TRANSLATIONS)) == 2), drop = FALSE],
TRANSLATIONS[, which(nchar(colnames(pre_commit_lst$TRANSLATIONS)) == 2), drop = FALSE],
function(x) list(exonym = x[1], endonym = x[2])
)
)
LANGUAGES_SUPPORTED <- names(LANGUAGES_SUPPORTED_NAMES)
pre_commit_lst$LANGUAGES_SUPPORTED <- names(pre_commit_lst$LANGUAGES_SUPPORTED_NAMES)
# vectors of CoNS and CoPS, improves speed in as.mo()
create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
@@ -120,7 +122,8 @@ create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
"vitulinus", "vitulus", "warneri", "xylosus",
"caledonicus", "canis",
"durrellii", "lloydii",
"ratti", "taiwanensis", "veratri", "urealyticus"
"ratti", "taiwanensis", "veratri", "urealyticus",
"americanisciuri", "marylandisciuri", "shinii", "brunensis"
) |
# old, now renamed to S. schleiferi (but still as synonym in our data of course):
(MO_staph$species == "schleiferi" & MO_staph$subspecies %in% c("schleiferi", ""))),
@@ -147,108 +150,298 @@ create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
]
}
}
MO_CONS <- create_species_cons_cops("CoNS")
MO_COPS <- create_species_cons_cops("CoPS")
MO_STREP_ABCG <- AMR::microorganisms$mo[which(AMR::microorganisms$genus == "Streptococcus" &
pre_commit_lst$MO_CONS <- create_species_cons_cops("CoNS")
pre_commit_lst$MO_COPS <- create_species_cons_cops("CoPS")
pre_commit_lst$MO_STREP_ABCG <- AMR::microorganisms$mo[which(AMR::microorganisms$genus == "Streptococcus" &
tolower(AMR::microorganisms$species) %in% c(
"pyogenes", "agalactiae", "dysgalactiae", "equi", "canis",
"group a", "group b", "group c", "group g"
))]
MO_LANCEFIELD <- AMR::microorganisms$mo[which(AMR::microorganisms$mo %like% "^(B_STRPT_PYGN(_|$)|B_STRPT_AGLC(_|$)|B_STRPT_(DYSG|EQUI)(_|$)|B_STRPT_ANGN(_|$)|B_STRPT_(DYSG|CANS)(_|$)|B_STRPT_SNGN(_|$)|B_STRPT_SLVR(_|$))")]
MO_PREVALENT_GENERA <- c(
"Absidia", "Acanthamoeba", "Acremonium", "Aedes", "Alternaria", "Amoeba", "Ancylostoma", "Angiostrongylus",
"Anisakis", "Anopheles", "Apophysomyces", "Aspergillus", "Aureobasidium", "Basidiobolus", "Beauveria",
"Blastocystis", "Blastomyces", "Candida", "Capillaria", "Chaetomium", "Chrysonilia", "Cladophialophora",
"Cladosporium", "Conidiobolus", "Contracaecum", "Cordylobia", "Cryptococcus", "Curvularia", "Demodex",
"Dermatobia", "Dientamoeba", "Diphyllobothrium", "Dirofilaria", "Echinostoma", "Entamoeba", "Enterobius",
"Exophiala", "Exserohilum", "Fasciola", "Fonsecaea", "Fusarium", "Giardia", "Haloarcula", "Halobacterium",
"Halococcus", "Hendersonula", "Heterophyes", "Histomonas", "Histoplasma", "Hymenolepis", "Hypomyces",
"Hysterothylacium", "Leishmania", "Malassezia", "Malbranchea", "Metagonimus", "Meyerozyma", "Microsporidium",
"Microsporum", "Mortierella", "Mucor", "Mycocentrospora", "Necator", "Nectria", "Ochroconis", "Oesophagostomum",
"Oidiodendron", "Opisthorchis", "Pediculus", "Penicillium", "Phlebotomus", "Phoma", "Pichia", "Piedraia", "Pithomyces",
"Pityrosporum", "Pneumocystis", "Pseudallescheria", "Pseudoterranova", "Pulex", "Rhizomucor", "Rhizopus",
"Rhodotorula", "Saccharomyces", "Sarcoptes", "Scolecobasidium", "Scopulariopsis", "Scytalidium", "Spirometra",
"Sporobolomyces", "Stachybotrys", "Strongyloides", "Syngamus", "Taenia", "Talaromyces", "Toxocara", "Trichinella",
"Trichobilharzia", "Trichoderma", "Trichomonas", "Trichophyton", "Trichosporon", "Trichostrongylus", "Trichuris",
"Tritirachium", "Trombicula", "Trypanosoma", "Tunga", "Wuchereria"
pre_commit_lst$MO_LANCEFIELD <- AMR::microorganisms$mo[which(AMR::microorganisms$mo %like% "^(B_STRPT_PYGN(_|$)|B_STRPT_AGLC(_|$)|B_STRPT_(DYSG|EQUI)(_|$)|B_STRPT_ANGN(_|$)|B_STRPT_(DYSG|CANS)(_|$)|B_STRPT_SNGN(_|$)|B_STRPT_SLVR(_|$))")]
pre_commit_lst$MO_WHO_PRIORITY_GENERA <- c(
# World Health Organization's (WHO) Priority Pathogen List (some are from the group Enterobacteriaceae)
"Acinetobacter",
"Aspergillus",
"Blastomyces",
"Campylobacter",
"Candida",
"Citrobacter",
"Clostridioides",
"Coccidioides",
"Cryptococcus",
"Edwardsiella",
"Enterobacter",
"Enterococcus",
"Escherichia",
"Fusarium",
"Haemophilus",
"Helicobacter",
"Histoplasma",
"Klebsiella",
"Morganella",
"Mycobacterium",
"Neisseria",
"Paracoccidioides",
"Pneumocystis",
"Proteus",
"Providencia",
"Pseudomonas",
"Salmonella",
"Serratia",
"Shigella",
"Staphylococcus",
"Streptococcus",
"Yersinia"
)
pre_commit_lst$MO_RELEVANT_GENERA <- c(
"Absidia",
"Acanthamoeba",
"Acremonium",
"Actinomucor",
"Aedes",
"Alternaria",
"Amoeba",
"Ancylostoma",
"Angiostrongylus",
"Anisakis",
"Anopheles",
"Apophysomyces",
"Arthroderma",
"Aspergillus",
"Aureobasidium",
"Basidiobolus",
"Beauveria",
"Bipolaris",
"Blastobotrys",
"Blastocystis",
"Blastomyces",
"Candida",
"Capillaria",
"Chaetomium",
"Chilomastix",
"Chrysonilia",
"Chrysosporium",
"Cladophialophora",
"Cladosporium",
"Clavispora",
"Coccidioides",
"Cokeromyces",
"Conidiobolus",
"Coniochaeta",
"Contracaecum",
"Cordylobia",
"Cryptococcus",
"Cryptosporidium",
"Cunninghamella",
"Curvularia",
"Cyberlindnera",
"Debaryozyma",
"Demodex",
"Dermatobia",
"Dientamoeba",
"Diphyllobothrium",
"Dirofilaria",
"Echinostoma",
"Entamoeba",
"Enterobius",
"Epidermophyton",
"Exidia",
"Exophiala",
"Exserohilum",
"Fasciola",
"Fonsecaea",
"Fusarium",
"Geotrichum",
"Giardia",
"Graphium",
"Haloarcula",
"Halobacterium",
"Halococcus",
"Hansenula",
"Hendersonula",
"Heterophyes",
"Histomonas",
"Histoplasma",
"Hortaea",
"Hymenolepis",
"Hypomyces",
"Hysterothylacium",
"Kloeckera",
"Kluyveromyces",
"Kodamaea",
"Lacazia",
"Leishmania",
"Lichtheimia",
"Lodderomyces",
"Lomentospora",
"Madurella",
"Malassezia",
"Malbranchea",
"Metagonimus",
"Meyerozyma",
"Microsporidium",
"Microsporum",
"Millerozyma",
"Mortierella",
"Mucor",
"Mycocentrospora",
"Nannizzia",
"Necator",
"Nectria",
"Ochroconis",
"Oesophagostomum",
"Oidiodendron",
"Opisthorchis",
"Paecilomyces",
"Paracoccidioides",
"Pediculus",
"Penicillium",
"Phaeoacremonium",
"Phaeomoniella",
"Phialophora",
"Phlebotomus",
"Phoma",
"Pichia",
"Piedraia",
"Pithomyces",
"Pityrosporum",
"Pneumocystis",
"Pseudallescheria",
"Pseudoscopulariopsis",
"Pseudoterranova",
"Pulex",
"Purpureocillium",
"Quambalaria",
"Rhinocladiella",
"Rhizomucor",
"Rhizopus",
"Rhodotorula",
"Saccharomyces",
"Saksenaea",
"Saprochaete",
"Sarcoptes",
"Scedosporium",
"Schistosoma",
"Schizosaccharomyces",
"Scolecobasidium",
"Scopulariopsis",
"Scytalidium",
"Spirometra",
"Sporobolomyces",
"Sporopachydermia",
"Sporothrix",
"Sporotrichum",
"Stachybotrys",
"Strongyloides",
"Syncephalastrum",
"Syngamus",
"Taenia",
"Talaromyces",
"Teleomorph",
"Toxocara",
"Trichinella",
"Trichobilharzia",
"Trichoderma",
"Trichomonas",
"Trichophyton",
"Trichosporon",
"Trichostrongylus",
"Trichuris",
"Tritirachium",
"Trombicula",
"Trypanosoma",
"Tunga",
"Ulocladium",
"Ustilago",
"Verticillium",
"Wallemia",
"Wangiella",
"Wickerhamomyces",
"Wuchereria",
"Yarrowia",
"Zygosaccharomyces"
)
# 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 %>%
pre_commit_lst$AB_AMINOGLYCOSIDES <- antibiotics %>%
filter(group %like% "aminoglycoside") %>%
pull(ab)
AB_AMINOPENICILLINS <- as.ab(c("AMP", "AMX"))
AB_ANTIFUNGALS <- AMR_env$AB_lookup %>%
pre_commit_lst$AB_AMINOPENICILLINS <- as.ab(c("AMP", "AMX"))
pre_commit_lst$AB_ANTIFUNGALS <- antibiotics %>%
filter(group %like% "antifungal") %>%
pull(ab)
AB_ANTIMYCOBACTERIALS <- AMR_env$AB_lookup %>%
pre_commit_lst$AB_ANTIMYCOBACTERIALS <- antibiotics %>%
filter(group %like% "antimycobacterial") %>%
pull(ab)
AB_CARBAPENEMS <- antibiotics %>%
pre_commit_lst$AB_CARBAPENEMS <- antibiotics %>%
filter(group %like% "carbapenem") %>%
pull(ab)
AB_CEPHALOSPORINS <- antibiotics %>%
pre_commit_lst$AB_CEPHALOSPORINS <- antibiotics %>%
filter(group %like% "cephalosporin") %>%
pull(ab)
AB_CEPHALOSPORINS_1ST <- antibiotics %>%
pre_commit_lst$AB_CEPHALOSPORINS_1ST <- antibiotics %>%
filter(group %like% "cephalosporin.*1") %>%
pull(ab)
AB_CEPHALOSPORINS_2ND <- antibiotics %>%
pre_commit_lst$AB_CEPHALOSPORINS_2ND <- antibiotics %>%
filter(group %like% "cephalosporin.*2") %>%
pull(ab)
AB_CEPHALOSPORINS_3RD <- antibiotics %>%
pre_commit_lst$AB_CEPHALOSPORINS_3RD <- antibiotics %>%
filter(group %like% "cephalosporin.*3") %>%
pull(ab)
AB_CEPHALOSPORINS_4TH <- antibiotics %>%
pre_commit_lst$AB_CEPHALOSPORINS_4TH <- antibiotics %>%
filter(group %like% "cephalosporin.*4") %>%
pull(ab)
AB_CEPHALOSPORINS_5TH <- antibiotics %>%
pre_commit_lst$AB_CEPHALOSPORINS_5TH <- antibiotics %>%
filter(group %like% "cephalosporin.*5") %>%
pull(ab)
AB_CEPHALOSPORINS_EXCEPT_CAZ <- AB_CEPHALOSPORINS[AB_CEPHALOSPORINS != "CAZ"]
AB_FLUOROQUINOLONES <- antibiotics %>%
pre_commit_lst$AB_CEPHALOSPORINS_EXCEPT_CAZ <- pre_commit_lst$AB_CEPHALOSPORINS[pre_commit_lst$AB_CEPHALOSPORINS != "CAZ"]
pre_commit_lst$AB_FLUOROQUINOLONES <- antibiotics %>%
filter(atc_group2 %like% "fluoroquinolone" | (group %like% "quinolone" & is.na(atc_group2))) %>%
pull(ab)
AB_GLYCOPEPTIDES <- antibiotics %>%
pre_commit_lst$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 %>%
pre_commit_lst$AB_LIPOGLYCOPEPTIDES <- as.ab(c("DAL", "ORI", "TLV")) # dalba/orita/tela
pre_commit_lst$AB_GLYCOPEPTIDES_EXCEPT_LIPO <- pre_commit_lst$AB_GLYCOPEPTIDES[!pre_commit_lst$AB_GLYCOPEPTIDES %in% pre_commit_lst$AB_LIPOGLYCOPEPTIDES]
pre_commit_lst$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))) %>%
pre_commit_lst$AB_MACROLIDES <- antibiotics %>%
filter(atc_group2 %like% "macrolide" | (group %like% "macrolide" & is.na(atc_group2) & name %unlike% "screening|inducible")) %>%
pull(ab)
AB_OXAZOLIDINONES <- antibiotics %>%
pre_commit_lst$AB_NITROFURANS <- antibiotics %>%
filter(name %like% "^furaz|nitrofura" | atc_group2 %like% "nitrofuran") %>%
pull(ab)
pre_commit_lst$AB_OXAZOLIDINONES <- antibiotics %>%
filter(group %like% "oxazolidinone") %>%
pull(ab)
AB_PENICILLINS <- antibiotics %>%
pre_commit_lst$AB_PENICILLINS <- antibiotics %>%
filter(group %like% "penicillin") %>%
pull(ab)
AB_POLYMYXINS <- antibiotics %>%
pre_commit_lst$AB_POLYMYXINS <- antibiotics %>%
filter(group %like% "polymyxin") %>%
pull(ab)
AB_QUINOLONES <- antibiotics %>%
pre_commit_lst$AB_QUINOLONES <- antibiotics %>%
filter(group %like% "quinolone") %>%
pull(ab)
AB_STREPTOGRAMINS <- antibiotics %>%
pre_commit_lst$AB_RIFAMYCINS <- antibiotics %>%
filter(name %like% "Rifampi|Rifabutin|Rifapentine|rifamy") %>%
pull(ab)
pre_commit_lst$AB_STREPTOGRAMINS <- antibiotics %>%
filter(atc_group2 %like% "streptogramin") %>%
pull(ab)
AB_TETRACYCLINES <- antibiotics %>%
pre_commit_lst$AB_TETRACYCLINES <- antibiotics %>%
filter(group %like% "tetracycline") %>%
pull(ab)
AB_TETRACYCLINES_EXCEPT_TGC <- AB_TETRACYCLINES[AB_TETRACYCLINES != "TGC"]
AB_TRIMETHOPRIMS <- antibiotics %>%
pre_commit_lst$AB_TETRACYCLINES_EXCEPT_TGC <- pre_commit_lst$AB_TETRACYCLINES[pre_commit_lst$AB_TETRACYCLINES != "TGC"]
pre_commit_lst$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)
pre_commit_lst$AB_UREIDOPENICILLINS <- as.ab(c("PIP", "TZP", "AZL", "MEZ"))
pre_commit_lst$AB_BETALACTAMS <- c(pre_commit_lst$AB_PENICILLINS, pre_commit_lst$AB_CEPHALOSPORINS, pre_commit_lst$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]
pre_commit_lst$DEFINED_AB_GROUPS <- sort(names(pre_commit_lst)[names(pre_commit_lst) %like% "^AB_" & names(pre_commit_lst) != "AB_LOOKUP"])
create_AB_AV_lookup <- function(df) {
new_df <- df
new_df$generalised_name <- generalise_antibiotic_name(new_df$name)
@@ -275,60 +468,26 @@ create_AB_AV_lookup <- function(df) {
))
new_df[, colnames(new_df)[colnames(new_df) %like% "^generalised"]]
}
AB_LOOKUP <- create_AB_AV_lookup(AMR::antibiotics)
AV_LOOKUP <- create_AB_AV_lookup(AMR::antivirals)
pre_commit_lst$AB_LOOKUP <- create_AB_AV_lookup(AMR::antibiotics)
pre_commit_lst$AV_LOOKUP <- create_AB_AV_lookup(AMR::antivirals)
# Export to package as internal data ----
usethis::ui_info(paste0("Updating internal package data"))
suppressMessages(usethis::use_data(EUCAST_RULES_DF,
TRANSLATIONS,
LANGUAGES_SUPPORTED_NAMES,
LANGUAGES_SUPPORTED,
MO_CONS,
MO_COPS,
MO_STREP_ABCG,
MO_LANCEFIELD,
MO_PREVALENT_GENERA,
AB_LOOKUP,
AV_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"
))
# usethis::use_data() must receive unquoted object names, which is not flexible at all.
# we'll use good old base::save() instead
save(list = names(pre_commit_lst),
file = "R/sysdata.rda",
envir = as.environment(pre_commit_lst),
compress = "xz",
version = 2,
ascii = FALSE)
usethis::ui_done("Saved to {usethis::ui_value('R/sysdata.rda')}")
# Export data sets to the repository in different formats -----------------
for (pkg in c("haven", "openxlsx", "arrow")) {
for (pkg in c("haven", "openxlsx2", "arrow")) {
if (!pkg %in% rownames(utils::installed.packages())) {
message("NOTE: package '", pkg, "' not installed! Ignoring export where this package is required.")
}
@@ -366,10 +525,9 @@ if (changed_md5(clin_break)) {
write_md5(clin_break)
try(saveRDS(clin_break, "data-raw/clinical_breakpoints.rds", version = 2, compress = "xz"), silent = TRUE)
try(write.table(clinical_breakpoints, "data-raw/clinical_breakpoints.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(haven::write_xpt(clin_break, "data-raw/clinical_breakpoints.xpt"), silent = TRUE)
try(haven::write_sav(clin_break, "data-raw/clinical_breakpoints.sav"), silent = TRUE)
try(haven::write_dta(clin_break, "data-raw/clinical_breakpoints.dta"), silent = TRUE)
try(openxlsx::write.xlsx(clin_break, "data-raw/clinical_breakpoints.xlsx"), silent = TRUE)
try(openxlsx2::write_xlsx(clin_break, "data-raw/clinical_breakpoints.xlsx"), silent = TRUE)
try(arrow::write_feather(clin_break, "data-raw/clinical_breakpoints.feather"), silent = TRUE)
try(arrow::write_parquet(clin_break, "data-raw/clinical_breakpoints.parquet"), silent = TRUE)
}
@@ -382,12 +540,11 @@ if (changed_md5(microorganisms)) {
mo <- microorganisms
mo$snomed <- max_50_snomed
mo <- dplyr::mutate_if(mo, ~ !is.numeric(.), as.character)
try(haven::write_xpt(mo, "data-raw/microorganisms.xpt"), silent = TRUE)
try(haven::write_sav(mo, "data-raw/microorganisms.sav"), silent = TRUE)
try(haven::write_dta(mo, "data-raw/microorganisms.dta"), silent = TRUE)
mo_all_snomed <- microorganisms %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ","))
try(write.table(mo_all_snomed, "data-raw/microorganisms.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(openxlsx::write.xlsx(mo_all_snomed, "data-raw/microorganisms.xlsx"), silent = TRUE)
try(openxlsx2::write_xlsx(mo_all_snomed, "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)
}
@@ -397,10 +554,9 @@ if (changed_md5(microorganisms.codes)) {
write_md5(microorganisms.codes)
try(saveRDS(microorganisms.codes, "data-raw/microorganisms.codes.rds", version = 2, compress = "xz"), silent = TRUE)
try(write.table(microorganisms.codes, "data-raw/microorganisms.codes.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(haven::write_xpt(microorganisms.codes, "data-raw/microorganisms.codes.xpt"), silent = TRUE)
try(haven::write_sav(microorganisms.codes, "data-raw/microorganisms.codes.sav"), silent = TRUE)
try(haven::write_dta(microorganisms.codes, "data-raw/microorganisms.codes.dta"), silent = TRUE)
try(openxlsx::write.xlsx(microorganisms.codes, "data-raw/microorganisms.codes.xlsx"), silent = TRUE)
try(openxlsx2::write_xlsx(microorganisms.codes, "data-raw/microorganisms.codes.xlsx"), silent = TRUE)
try(arrow::write_feather(microorganisms.codes, "data-raw/microorganisms.codes.feather"), silent = TRUE)
try(arrow::write_parquet(microorganisms.codes, "data-raw/microorganisms.codes.parquet"), silent = TRUE)
}
@@ -410,10 +566,9 @@ if (changed_md5(microorganisms.groups)) {
write_md5(microorganisms.groups)
try(saveRDS(microorganisms.groups, "data-raw/microorganisms.groups.rds", version = 2, compress = "xz"), silent = TRUE)
try(write.table(microorganisms.groups, "data-raw/microorganisms.groups.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(haven::write_xpt(microorganisms.groups, "data-raw/microorganisms.groups.xpt"), silent = TRUE)
try(haven::write_sav(microorganisms.groups, "data-raw/microorganisms.groups.sav"), silent = TRUE)
try(haven::write_dta(microorganisms.groups, "data-raw/microorganisms.groups.dta"), silent = TRUE)
try(openxlsx::write.xlsx(microorganisms.groups, "data-raw/microorganisms.groups.xlsx"), silent = TRUE)
try(openxlsx2::write_xlsx(microorganisms.groups, "data-raw/microorganisms.groups.xlsx"), silent = TRUE)
try(arrow::write_feather(microorganisms.groups, "data-raw/microorganisms.groups.feather"), silent = TRUE)
try(arrow::write_parquet(microorganisms.groups, "data-raw/microorganisms.groups.parquet"), silent = TRUE)
}
@@ -423,12 +578,11 @@ 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(haven::write_xpt(ab, "data-raw/antibiotics.xpt"), silent = TRUE)
try(haven::write_sav(ab, "data-raw/antibiotics.sav"), silent = TRUE)
try(haven::write_dta(ab, "data-raw/antibiotics.dta"), silent = TRUE)
ab_lists <- antibiotics %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ","))
try(write.table(ab_lists, "data-raw/antibiotics.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(openxlsx::write.xlsx(ab_lists, "data-raw/antibiotics.xlsx"), silent = TRUE)
try(openxlsx2::write_xlsx(ab_lists, "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)
}
@@ -438,12 +592,11 @@ 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(haven::write_xpt(av, "data-raw/antivirals.xpt"), silent = TRUE)
try(haven::write_sav(av, "data-raw/antivirals.sav"), silent = TRUE)
try(haven::write_dta(av, "data-raw/antivirals.dta"), silent = TRUE)
av_lists <- antivirals %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ","))
try(write.table(av_lists, "data-raw/antivirals.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(openxlsx::write.xlsx(av_lists, "data-raw/antivirals.xlsx"), silent = TRUE)
try(openxlsx2::write_xlsx(av_lists, "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)
}
@@ -459,10 +612,9 @@ if (changed_md5(intrinsicR)) {
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_xpt(intrinsicR, "data-raw/intrinsic_resistant.xpt"), 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(openxlsx2::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)
}
@@ -472,21 +624,15 @@ if (changed_md5(dosage)) {
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_xpt(dosage, "data-raw/dosage.xpt"), 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(openxlsx2::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)
suppressMessages(set_AMR_locale("English"))
@@ -500,19 +646,6 @@ usethis::ui_info("Documenting package")
suppressMessages(devtools::document(quiet = TRUE))
# Style pkg ---------------------------------------------------------------
if (!"styler" %in% rownames(utils::installed.packages())) {
message("Package 'styler' not installed!")
} else if (interactive()) {
# only when sourcing this file ourselves
# usethis::ui_info("Styling package")
# styler::style_pkg(
# style = styler::tidyverse_style,
# filetype = c("R", "Rmd")
# )
}
# Finished ----------------------------------------------------------------
usethis::ui_done("All done")
suppressMessages(reset_AMR_locale())
+1 -1
View File
@@ -1 +1 @@
3d8c509ec95d61889cae83af43b0e6b7
6f6b49606c2c51f8344fbb9e186a3ad3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+60 -58
View File
@@ -5,22 +5,23 @@
"ALS" 8954 "Aldesulfone sodium" "Other antibacterials" "J04BA03" "Drugs for treatment of lepra" "Drugs for treatment of lepra" "" "adesulfone sodium,aldapsone,aldesulfona sodica,aldesulfone,aldesulfone sodique,aldesulfone sodium,aldesulphone sodium,diamidin,diasone,diasone sodium,diazon,novotrone,sodium aldesulphone,sodium sulfoxone,sulfoxone sodium" 0.33 "g" ""
"AMK" 37768 "Amikacin" "Aminoglycosides" "D06AX12,J01GB06,S01AA21" "Aminoglycoside antibacterials" "Other aminoglycosides" "ak,ami,amik,amk,an" "amicacin,amikacillin,amikacin,amikacin base,amikacin dihydrate,amikacin free base,amikacin sulfate,amikacina,amikacine,amikacinum,amikavet,amikin,amiklin,amikozit,amukin,arikace,arikayce liposomal,briclin,kaminax,lukadin,mikavir,pierami,potentox" 1 "g" "101493-5,11-7,12-5,13-3,13546-7,14-1,15098-7,17798-0,18860-7,20373-7,23624-0,25174-4,25175-1,25176-9,25177-7,25178-5,25179-3,31097-9,31098-7,31099-5,3319-1,3320-9,3321-7,35669-1,42642-9,48169-7,50802-8,50803-6,56628-1,59378-0,60564-2,60565-9,6975-7,80972-3,89484-0"
"AKF" "Amikacin/fosfomycin" "Aminoglycosides" "NA" "" "" ""
"AMO" 54260 "Amorolfine" "Antifungals/antimycotics" "D01AE16" "Antifungals for topical use" "Other antifungals for topical use" "amor" "amorolfina,amorolfine,amorolfinum,loceryl" ""
"AMX" 33613 "Amoxicillin" "Beta-lactams/penicillins" "J01CA04" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "ac,amox,amx" "actimoxi,amoclen,amolin,amopen,amopenixin,amoxibiotic,amoxicaps,amoxicilina,amoxicillin,amoxicillin hydrate,amoxicilline,amoxicillinum,amoxiden,amoxil,amoxivet,amoxy,amoxycillin,amoxyke,anemolin,aspenil,atoksilin,biomox,bristamox,cemoxin,clamoxyl,damoxy,delacillin,demoksil,dispermox,efpenix,flemoxin,hiconcil,histocillin,hydroxyampicillin,ibiamox,imacillin,lamoxy,largopen,metafarma capsules,metifarma capsules,moksilin,moxacin,moxatag,ospamox,pamoxicillin,piramox,promoxil,remoxil,robamox,sawamox pm,tolodina,topramoxin,unicillin,utimox,vetramox" 1.5 "g" 3 "g" "101498-4,15-8,16-6,16365-9,17-4,18-2,18861-5,18862-3,19-0,20-8,21-6,22-4,25274-2,25310-4,3344-9,55614-2,55615-9,55616-7,6976-5,6977-3,80133-2"
"AMC" 23665637 "Amoxicillin/clavulanic acid" "Beta-lactams/penicillins" "J01CR02" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "a/c,amcl,aml,aug,xl" "amocla,amoclan,amoclav,amoksiclav,amoxsiklav,amoxyclav,augmentan,augmentin,augmentin xr,augmentine,auspilic,clamentin,clamobit,clavamox,clavinex,clavoxilin plus,clavulin,clavumox,coamoxiclav,eumetinex,kmoxilin,spectramox,spektramox,synulox,viaclav,xiclav" 1.5 "g" 3 "g" ""
"AXS" 465441 "Amoxicillin/sulbactam" "Beta-lactams/penicillins" "NA" "" "" "55614-2,55615-9,55616-7"
"AMB" 5280965 "Amphotericin B" "Antifungals/antimycotics" "A01AB04,A07AA07,G01AA03,J02AA01" "Antimycotics for systemic use" "Antibiotics" "amf,amfb,amph" "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" "16370-9,18863-1,23-2,24-0,25-7,26-5,3353-0,3354-8,40707-2,40757-7,49859-2,6978-1"
"AMH" "Amphotericin B-high" "Aminoglycosides" "NA" "amfo b high,amhl,ampho b high,amphotericin high" "" ""
"AMB" 5280965 "Amphotericin B" "Antifungals/antimycotics" "A01AB04,A07AA07,G01AA03,J02AA01" "Antimycotics for systemic use" "Antibiotics" "amf,amfb,amph" "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" 210 "mg" "16370-9,18863-1,23-2,24-0,25-7,26-5,3353-0,3354-8,40707-2,40757-7,49859-2,6978-1"
"AMH" "Amphotericin B-high" "Antifungals/antimycotics" "NA" "amfo b high,amhl,ampho b high,amphotericin high" "" ""
"AMP" 6249 "Ampicillin" "Beta-lactams/penicillins" "J01CA01,S01AA19" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "am,amp,ampi" "acillin,adobacillin,amblosin,amcill,amfipen,amfipen v,amipenix s,ampichel,ampicil,ampicilina,ampicillin,ampicillin a,ampicillin acid,ampicillin anhydrate,ampicillin anhydrous,ampicillin base,ampicillin hydrate,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,redicilin,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" "101477-8,101478-6,18864-9,18865-6,20374-5,21066-6,23618-2,27-3,28-1,29-9,30-7,31-5,32-3,33-1,3355-5,33562-0,33919-2,34-9,43883-8,43884-6,6979-9,6980-7,87604-5"
"SAM" 119561 "Ampicillin/sulbactam" "Beta-lactams/penicillins" "J01CR01" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "a/s,ab,ams,amsu,apsu,sam" "sulacillin" 6 "g" "101478-6,18865-6,20374-5,23618-2,31-5,32-3,33-1,34-9,6980-7"
"AMR" 73341 "Amprolium" "Other antibacterials" "NA" "" "amprocidum,amprol,amprolio,amprolium,amprolium chloride,amprovine,thiacoccid" ""
"AMR" 73341 "Amprolium" "Other antibacterials" "QP51BX02" "" "amprocidum,amprol,amprolio,amprolium,amprolium chloride,amprovine,thiacoccid" ""
"ANI" 166548 "Anidulafungin" "Antifungals/antimycotics" "J02AX06" "Antimycotics for systemic use" "Other antimycotics for systemic use" "anid" "anidulafungin,anidulafungina,anidulafungine,anidulafunginum,ecalta,eraxis" 0.1 "g" "55343-8,57095-2,58420-1,77162-6"
"APL" 6602341 "Apalcillin" "Beta-lactams/penicillins" "NA" "" "apalcilina,apalcillin,apalcilline,apalcillinum" ""
"APR" 3081545 "Apramycin" "Aminoglycosides" "NA" "" "ambylan,apralan,apramicina,apramycin,apramycine,apramycinum,nebramycin ii" "23659-6,73652-0,73653-8"
"APR" 3081545 "Apramycin" "Aminoglycosides" "QA07AA92,QJ01GB90,QJ51GB90" "" "ambylan,apralan,apramicina,apramycin,apramycine,apramycinum,nebramycin ii" "23659-6,73652-0,73653-8"
"ARB" 68682 "Arbekacin" "Aminoglycosides" "J01GB12" "" "arbekacin,arbekacina,arbekacine,arbekacini sulfas,arbekacinum,habekacin,haberacin" 0.2 "g" "32373-3,53818-1,54173-0"
"APX" 71961 "Aspoxicillin" "Beta-lactams/penicillins" "J01CA19" "" "aspoxicilina,aspoxicillan,aspoxicillin,aspoxicilline,aspoxicillinum" 4 "g" ""
"AST" 5284517 "Astromicin" "Aminoglycosides" "NA" "" "astromicin,astromicin a,astromicina,astromicine,astromicinum,fortimicin,fortimicin a" ""
"AVB" 9835049 "Avibactam" "Beta-lactams/penicillins" "NA" "" "avibactam,avibactam free acid,avibactamfreeacid" ""
"AVI" 71674 "Avilamycin" "Other antibacterials" "NA" "" "avilamycin,avilamycina,avilamycine,avilamycinum,surmax" "35754-1,35755-8,35756-6,55619-1"
"AVI" 71674 "Avilamycin" "Other antibacterials" "QA07AA95" "" "avilamycin,avilamycina,avilamycine,avilamycinum,surmax" "35754-1,35755-8,35756-6,55619-1"
"AVO" 16131159 "Avoparcin" "Glycopeptides" "NA" "" "avoparcin,avoparcina,avoparcine,avoparcinum,avotan" ""
"AZD" 15574941 "Azidocillin" "Beta-lactams/penicillins" "J01CE04" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "azidocilina,azidocillin,azidocillina,azidocilline,azidocillinum" 1.5 "g" ""
"AZM" 447043 "Azithromycin" "Macrolides/lincosamides" "J01FA10,S01AA26" "Macrolides, lincosamides and streptogramins" "Macrolides" "az,azi,azit,azm" "aritromicina,aruzilina,azasite,azenil,azifast,azigram,azimakrol,azithramycine,azithrocin,azithromycin,azithromycine,azithromycinum,azitrocin,azitromax,azitromicina,azitromicine,azitromin,aziwin,aziwok,aztrin,azyter,azythromycin,durasite,hemomycin,macrozit,misultina,mixoterin,setron,sumamed,toraseptol,tromix,trozocina,trulimax,xithrone,zentavion,zithrax,zithromac,zithromax,zithromax iv,zithromycin,zitrim,zitromax,zitrotek,zmax sr,zythromax" 0.3 "g" 0.5 "g" "100043-9,16420-2,16421-0,18866-4,23612-5,25233-8,35-6,36-4,37-2,38-0,6981-5,89480-8"
@@ -30,7 +31,7 @@
"AZA" "Aztreonam/avibactam" "Beta-lactams/penicillins" "NA" "" "" ""
"ANC" "Aztreonam/nacubactam" "Beta-lactams/penicillins" "NA" "" "" ""
"BAM" 441397 "Bacampicillin" "Beta-lactams/penicillins" "J01CA06" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "bacampicilina,bacampicillin,bacampicilline,bacampicillinum,penglobe" 1.2 "g" "18869-8,47-1,48-9,49-7,50-5,55620-9"
"BAC" 78358334 "Bacitracin" "Other antibacterials" "R02AB04,J01XX10" "baci" "fortracin,md bacitracin" "10868-8,16428-5,18870-6,6827-0,6983-1,87603-7"
"BAC" 78358334 "Bacitracin" "Other antibacterials" "D06AX05,J01XX10,R02AB04,S01AA32" "baci" "fortracin,md bacitracin" "10868-8,16428-5,18870-6,6827-0,6983-1,87603-7"
"BDQ" 5388906 "Bedaquiline" "Other antibacterials" "J04AK05" "" "bedaquiline,sirturo" 86 "mg" "80637-2,88703-4,88704-2,94274-8,96107-8"
"BEK" 439318 "Bekanamycin" "Aminoglycosides" "J01GB13" "" "aminodeoxykanamycin,becanamicina,bekanamycin,bekanamycine,bekanamycinum,kanamycin b,klebcil,nebramycin v" 0.6 "g" ""
"BNB" "Benzathine benzylpenicillin" "Beta-lactams/penicillins" "J01CE08" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "beacillin,cepacilina,extencilline,lentopenil,penidural,tardocillin" 3.6 "g" ""
@@ -75,10 +76,10 @@
"CPI" 5486182 "Cefetamet pivoxil" "Cephalosporins (3rd gen.)" "NA" "" "cefetamet pivoxyl,globocef" ""
"CCL" 71719688 "Cefetecol" "Cephalosporins (4th gen.)" "NA" "cefcatacol" "cefetecol,cefetecol anhydrous" ""
"CZL" 193956 "Cefetrizole" "Cephalosporins (unclassified gen.)" "NA" "" "cefetrizole,cefetrizolum" ""
"FDC" 77843966 "Cefiderocol" "Other antibacterials" "J01DI04" "" "cefiderocol" "95767-0,99280-0,99503-5"
"FDC" 77843966 "Cefiderocol" "Cephalosporins (unclassified gen.)" "J01DI04" "" "cefiderocol" 6 "g" "95767-0,99280-0,99503-5"
"CFM" 5362065 "Cefixime" "Cephalosporins (3rd gen.)" "J01DD08" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "cfe,cfix,cfxm,dcfm,fix,ix" "anhydrous cefixime,cefixim,cefixima,cefixime,cefixime anhydrous,cefixime hydrate,cefiximum,cefixoral,cefspan,cephoral,citropen,denvar,necopen,oroken,suprax,tricef,unixime" 0.4 "g" "16567-0,18880-5,25236-1,35766-5,79-4,80-2,81-0,82-8"
"CEO" "Cefixime/ornidazole" "Other antibacterials" "J01RA15" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"CMX" 9570757 "Cefmenoxime" "Cephalosporins (3rd gen.)" "J01DD05" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "bestron,cefmax,cefmenoxima,cefmenoxime,cefmenoximum" 2 "g" "32375-8,54174-8,54203-5,55641-5"
"CMX" 9570757 "Cefmenoxime" "Cephalosporins (3rd gen.)" "J01DD05,S01AA31,S02AA18" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "bestron,cefmax,cefmenoxima,cefmenoxime,cefmenoximum" 2 "g" "32375-8,54174-8,54203-5,55641-5"
"CMZ" 42008 "Cefmetazole" "Cephalosporins (2nd gen.)" "J01DC09" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "" "cefmetazole,cefmetazolesodium,cefmetazolo,cefmetazolum" 4 "g" "11575-8,18881-3,25222-1,87-7,88-5,89-3,90-1"
"CNX" 71141 "Cefminox" "Other antibacterials" "J01DC12" "" "cefminox,cefminoxum" 4 "g" "54908-9"
"DIZ" 5361871 "Cefodizime" "Cephalosporins (3rd gen.)" "J01DD09" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "cefodizima,cefodizime,cefodizime acid,cefodizime disodium,cefodizimum,cefodizme,diezime,modivid,neucef,timecef" 2 "g" "18882-1,6988-0,91-9,92-7,93-5,94-3"
@@ -93,7 +94,7 @@
"CTT" 53025 "Cefotetan" "Cephalosporins (2nd gen.)" "J01DC05" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "cftt,cn,cte,ctn,ctt,tans" "apacef,cefotan,cefotetan,cefotetan acid,cefotetan free acid,cefotetanum" 4 "g" "111-5,112-3,113-1,114-9,18887-0,25239-5,3447-0,41672-7,41673-5,41674-3,41729-5,6990-6"
"CTF" 43708 "Cefotiam" "Cephalosporins (2nd gen.)" "J01DC07" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "" "cefotiam,cefotiam?,cefotiamum,ceradolan,ceradon,haloapor" 1.2 "g" 4 "g" "32374-1,35772-3,35773-1,55645-6,55737-1,55738-9,55739-7,55740-5"
"CHE" 125846 "Cefotiam hexetil" "Cephalosporins (3rd gen.)" "NA" "" "cefotiam cilexetil,pansporin t" "55737-1,55738-9,55739-7,55740-5"
"FOV" 9578573 "Cefovecin" "Cephalosporins (3rd gen.)" "NA" "" "cefovecin" "76147-8,87792-8"
"FOV" 9578573 "Cefovecin" "Cephalosporins (3rd gen.)" "QJ01DD91" "" "cefovecin" "76147-8,87792-8"
"FOX" 441199 "Cefoxitin" "Cephalosporins (2nd gen.)" "J01DC01" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "cfox,cfx,cfxt,cx,fox,fx" "cefoxitin,cefoxitina,cefoxitine,cefoxitinum,cefoxotin,cenomycin,cephoxitin,mefoxin,mefoxitin,rephoxitin" 6 "g" "101492-7,115-6,116-4,117-2,118-0,18888-8,25220-5,25240-3,25366-6,3448-8,41675-0,41676-8,41677-6,41730-3,6991-4"
"FOX1" "Cefoxitin screening" "Cephalosporins (2nd gen.)" "NA" "cfsc" "" ""
"ZOP" 9571080 "Cefozopran" "Cephalosporins (4th gen.)" "J01DE03" "" "cefozopran" 4 "g" "100045-4,53820-7"
@@ -104,7 +105,7 @@
"CPX" 6526396 "Cefpodoxime proxetil" "Cephalosporins (3rd gen.)" "NA" "" "cefodox,cefoprox,cefpodoxime proxetil,cepodem,orelox,orelox paed,otreon,podomexef,simplicef,vantin" ""
"CDC" "Cefpodoxime/clavulanic acid" "Cephalosporins (3rd gen.)" "NA" "cecl" "" ""
"CPR" 5281006 "Cefprozil" "Cephalosporins (2nd gen.)" "J01DC10" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "cpr,cpz,fp" "arzimol,brisoral,cefprozil,cefprozil anhydrous,cefprozil hydrate,cefprozilo,cefprozilum,cefzil,cronocef,procef,serozil" 1 "g" "123-0,124-8,125-5,126-3,18891-2,6994-8"
"CEQ" 5464355 "Cefquinome" "Cephalosporins (4th gen.)" "NA" "" "cefquinoma,cefquinome,cefquinomum,cobactan" "100046-2,76150-2"
"CEQ" 5464355 "Cefquinome" "Cephalosporins (4th gen.)" "QG51AA07,QJ01DE90,QJ51DE90" "" "cefquinoma,cefquinome,cefquinomum,cobactan" "100046-2,76150-2"
"CRD" 5284529 "Cefroxadine" "Cephalosporins (1st gen.)" "J01DB11" "Other beta-lactam antibacterials" "First-generation cephalosporins" "" "cefroxadin,cefroxadine,cefroxadino,cefroxadinum,oraspor" 2.1 "g" ""
"CFS" 656575 "Cefsulodin" "Cephalosporins (3rd gen.)" "J01DD03" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "cfsl,cfsu" "cefonomil,cefsulodin,cefsulodine,cefsulodino,cefsulodinum" 4 "g" "127-1,128-9,129-7,130-5,131-3,18892-0,25242-9,55647-2"
"CSU" 68718 "Cefsumide" "Cephalosporins (unclassified gen.)" "NA" "" "cefsulmid,cefsumide,cefsumido,cefsumidum" ""
@@ -117,12 +118,12 @@
"CPL" 5362114 "Cefteram pivoxil" "Cephalosporins (3rd gen.)" "NA" "" "cefteram pivoxil,cefterampivoxil,tomiron" ""
"CTL" 65755 "Ceftezole" "Cephalosporins (1st gen.)" "J01DB12" "Other beta-lactam antibacterials" "First-generation cephalosporins" "" "ceftezol,ceftezole,ceftezolo,ceftezolum,demethylcefazolin" 3 "g" ""
"CTB" 5282242 "Ceftibuten" "Cephalosporins (3rd gen.)" "J01DD14" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "cb,cfbu,ctb,tib" "ceftem,ceftibuten,ceftibuten dihydrate,ceftibuten hydrate,ceftibutene,ceftibuteno,ceftibutenum,ceftibutin,cephem,ceprifran,isocef,keimax" 0.4 "g" "35777-2,35778-0,35779-8,6996-3"
"TIO" 6328657 "Ceftiofur" "Cephalosporins (3rd gen.)" "NA" "" "ceftiofur,ceftiofurum,excede,excenel,naxcel" "23709-9,35780-6,35781-4,55652-2"
"TIO" 6328657 "Ceftiofur" "Cephalosporins (3rd gen.)" "QJ01DD90,QJ51DD90" "" "ceftiofur,ceftiofurum,excede,excenel,naxcel" "23709-9,35780-6,35781-4,55652-2"
"CZX" 6533629 "Ceftizoxime" "Cephalosporins (3rd gen.)" "J01DD07" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "cfzx,ctz,cz,czx,tiz,zox" "cefizox,ceftisomin,ceftix,ceftizoxima,ceftizoxime,ceftizoximum,epocelin,eposerin" 4 "g" "136-2,137-0,138-8,139-6,18894-6,20378-6,23622-4,25243-7,3450-4,6997-1"
"CZP" 9578661 "Ceftizoxime alapivoxil" "Cephalosporins (3rd gen.)" "NA" "" "" ""
"BPR" 135413542 "Ceftobiprole" "Cephalosporins (5th gen.)" "NA" "" "ceftobiprole" "43269-0,43270-8,43271-6,43272-4,85052-9"
"CFM1" 135413544 "Ceftobiprole medocaril" "Cephalosporins (5th gen.)" "J01DI01" "Other beta-lactam antibacterials" "Other cephalosporins and penems" "" "" 1.5 "g" ""
"CZT" 86291594 "Ceftolozane/tazobactam" "Cephalosporins (5th gen.)" "J01DI54" "Other beta-lactam antibacterials" "Other cephalosporins and penems" "CEI" "zerbaxa" 3 "g" "101484-4,73602-5,73624-9,73647-0,87735-7"
"CZT" 86291594 "Ceftolozane/tazobactam" "Cephalosporins (5th gen.)" "J01DI54" "Other beta-lactam antibacterials" "Other cephalosporins and penems" "cei" "zerbaxa" 3 "g" "101484-4,73602-5,73624-9,73647-0,87735-7"
"CRO" 5479530 "Ceftriaxone" "Cephalosporins (3rd gen.)" "J01DD04" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "axo,cax,cftr,cro,ctr,frx,tx" "biotrakson,cefatriaxone,cefatriaxone hydrate,ceftriaxon,ceftriaxona,ceftriaxone,ceftriaxone sodium,ceftriaxonum,ceftriazone,cephtriaxone,longacef,rocefin,rocephalin,rocephin,rocephine,rophex" 2 "g" "101485-1,140-4,141-2,142-0,143-8,18895-3,25244-5,25367-4,31140-7,31141-5,3451-2,41681-8,41682-6,41683-4,41732-9,50633-7,55190-3,6998-9,80957-4"
"CEB" "Ceftriaxone/beta-lactamase inhibitor" "Cephalosporins (3rd gen.)" "J01DD63" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "" "" 2 "g" ""
"CXM" 5479529 "Cefuroxime" "Cephalosporins (2nd gen.)" "J01DC02,S01AA27" "Other beta-lactam antibacterials" "Second-generation cephalosporins" "cfrx,cfur,cfx,crm,cxm,fur,rox,xm" "biofuroksym,cefuril,cefuroxim,cefuroxima,cefuroxime,cefuroxime acid,cefuroximine,cefuroximo,cefuroximum,cephuroxime,kefurox,sharox,zinacef,zinacef danmark" 0.5 "g" 3 "g" "101503-1,144-6,145-3,146-1,147-9,18896-1,20460-2,25245-2,3452-0,35782-2,35783-0,51724-3,51774-8,55653-0,55654-8,6999-7,74699-0,80608-3,80617-4"
@@ -137,13 +138,14 @@
"CIX" 47472 "Ciclopirox" "Antifungals/antimycotics" "D01AE14,G01AX12" "Antifungals for topical use" "Other antifungals for topical use" "cipx" "butaconazole,butoconazol,butoconazole,butoconazolum,ciclodan,ciclopirox,ciclopirox gel,ciclopirox olamin,ciclopiroxum,compositenstarke,dahlin,femstat,gynofort,loprox,loprox cream,loprox gel,penlac,polyfructosanum,stieprox" ""
"CIN" 2762 "Cinoxacin" "Quinolones" "J01MB06" "Quinolone antibacterials" "Other quinolones" "cino,cnox" "azolinic acid,cinobac,cinobactin,cinoxacin,cinoxacine,cinoxacino,cinoxacinum,clinoxacin,noxigram,uronorm" 1 "g" "180-0,181-8,182-6,183-4,18905-0,55656-3"
"CIP" 2764 "Ciprofloxacin" "Quinolones" "J01MA02,S01AE03,S02AA15,S03AA07" "Quinolone antibacterials" "Fluoroquinolones" "ci,cip,cipr,cp" "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" "101500-7,14031-9,14032-7,14058-2,14059-0,184-2,185-9,186-7,187-5,18906-8,20377-8,23621-6,25180-1,25181-9,25188-4,25189-2,25248-6,34636-1,3484-3,42644-5,55194-5,7002-9"
"CIM" "Ciprofloxacin/metronidazole" "Other antibacterials" "J01RA10" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"CIO" "Ciprofloxacin/ornidazole" "Other antibacterials" "J01RA12" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"CIT" "Ciprofloxacin/tinidazole" "Other antibacterials" "J01RA11" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"CIM" "Ciprofloxacin/metronidazole" "Quinolones" "J01RA10" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"CIO" "Ciprofloxacin/ornidazole" "Quinolones" "J01RA12" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"CIT" "Ciprofloxacin/tinidazole" "Quinolones" "J01RA11" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"CLR" 84029 "Clarithromycin" "Macrolides/lincosamides" "J01FA09" "Macrolides, lincosamides and streptogramins" "Macrolides" "ch,cla,clar,clm,clr" "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,prevpac,veclam,vikrol,zeclar" 0.5 "g" 1 "g" "100048-8,16619-9,16620-7,188-3,189-1,18907-6,190-9,191-7,20375-2,23619-0,25190-0,25191-8,25192-6,25253-6,34638-7,43987-7,43990-1,43991-9,7003-7,80559-8,89485-7"
"CLA1" 5280980 "Clavulanic acid" "Other antibacterials" "NA" "" "acide clavulanique,acido clavulanico,acidum clavulanicum,clavulanate,clavulanate acid,clavulanate lithium,clavulanateacid,clavulanic acid,clavulansaeure,clavulansaure,clavulinic acid,clavulox,serdaxin,sodium clavulanate" ""
"CLX" 60063 "Clinafloxacin" "Quinolones" "NA" "" "clinafloxacin" "32376-6,33284-1,35785-5,35786-3,7004-5"
"CLI" 446598 "Clindamycin" "Macrolides/lincosamides" "D10AF01,G01AA10,J01FF01" "Macrolides, lincosamides and streptogramins" "Lincosamides" "cc,cd,cli,clin,cm,da" "antirobe,chlolincocin,clindaderm,clindamicina,clindamycin,clindamycine,clindamycinum,clinimycin,dalacin c,dalacine,klimicin,sobelin" 1.2 "g" 1.8 "g" "16621-5,16622-3,18908-4,192-5,193-3,194-1,195-8,25249-4,3486-8,42720-3,55657-1,55658-9,55659-7,55660-5,61188-9,7005-2"
"CLI1" "Clindamycin inducible screening" "Macrolides/lincosamides" "NA" "clin inducible,clinda inducible,clindamycin inducible" "" ""
"CLF" 2794 "Clofazimine" "Antimycobacterials" "J04BA01" "Drugs for treatment of lepra" "Drugs for treatment of lepra" "clof" "chlofazimine,clofazimin,clofazimina,clofazimine,clofaziminum,colfazimine,lampren,lamprene,riminophenazine" 0.1 "g" "16623-1,20376-0,23620-8,23627-3,43986-9,43988-5,43989-3,55661-3,55662-1,96108-6"
"CLF1" 2799 "Clofoctol" "Other antibacterials" "J01XX03" "Other antibacterials" "Other antibacterials" "" "clofoctol,clofoctolo,clofoctolum,gramplus,octofene" ""
"CLM" 71807 "Clometocillin" "Beta-lactams/penicillins" "J01CE07" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "chlomethocillin,clometacillin,clometocilina,clometocillin,clometocilline,clometocillinum,rixapen" 1 "g" ""
@@ -154,32 +156,32 @@
"COP" "Colistin/polysorbate" "Other antibacterials" "NA" "" "" ""
"CYC" 6234 "Cycloserine" "Oxazolidinones" "J04AB01" "Drugs for treatment of tuberculosis" "Antibiotics" "cycl" "cicloserina,closerin,closina,cyclorin,cycloserin,cycloserine,cycloserinum,farmiserina,micoserina,miroserina,miroseryn,novoserin,oxamicina,oxamycin,seromycin,tebemicina,tisomycin,wasserina" 0.75 "g" "16702-3,18914-2,212-1,213-9,214-7,215-4,23608-3,25207-2,25208-0,25209-8,25251-0,3519-6,55667-0"
"DAL" 23724878 "Dalbavancin" "Glycopeptides" "J01XA04" "Other antibacterials" "Glycopeptide antibacterials" "dalb" "dalbavancin,dalvance" 1.5 "g" "41688-3,41689-1,41690-9,41734-5"
"DAN" 71335 "Danofloxacin" "Quinolones" "NA" "" "advocin,danofloxacin,danofloxacine,danofloxacino,danofloxacinum" "73601-7,73623-1,73646-2"
"DAN" 71335 "Danofloxacin" "Quinolones" "QJ01MA92" "" "advocin,danofloxacin,danofloxacine,danofloxacino,danofloxacinum" "73601-7,73623-1,73646-2"
"DPS" 2955 "Dapsone" "Other antibacterials" "D10AX05,J04BA02" "Drugs for treatment of lepra" "Drugs for treatment of lepra" "" "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" 50 "mg" "51698-9,9747-7"
"DAP" 16134395 "Daptomycin" "Other antibacterials" "J01XX09" "Other antibacterials" "Other antibacterials" "dap,dapt" "cidecin,cubicin,dapcin,daptomicina,daptomycine,daptomycinum" 0.28 "g" "35787-1,35788-9,35789-7,41691-7"
"DFX" 487101 "Delafloxacin" "Quinolones" "J01MA23" "" "baxdela,delafloxacin,delafloxacinum,quofenix" 0.9 "g" 0.6 "g" "88885-9,90447-4,93790-4"
"DLM" 6480466 "Delamanid" "Antimycobacterials" "J04AK06" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "dela" "delamanid,deltyba" 0.2 "g" "93851-4,96109-4"
"DEM" 54680690 "Demeclocycline" "Tetracyclines" "D06AA01,J01AA01" "Tetracyclines" "Tetracyclines" "" "bioterciclin,clortetrin,declomycin,deganol,demeclociclina,demeclocycline,demeclocyclinum,demeclor,demetraclin,diuciclin,elkamicina,ledermycin,mexocine,novotriclina,perciclina,sumaclina" 0.6 "g" "10982-7,18915-9,216-2,217-0,218-8,219-6,29494-2,7006-0"
"DKB" 470999 "Dibekacin" "Aminoglycosides" "J01GB09" "Aminoglycoside antibacterials" "Other aminoglycosides" "" "debecacin,dibekacin,dibekacin sulfate,dibekacina,dibekacine,dibekacinum,dideoxykanamycin b,kappati,orbicin,panamicin" 0.14 "g" "55669-6,55670-4,55671-2,55672-0"
"DKB" 470999 "Dibekacin" "Aminoglycosides" "J01GB09,S01AA29" "Aminoglycoside antibacterials" "Other aminoglycosides" "" "debecacin,dibekacin,dibekacin sulfate,dibekacina,dibekacine,dibekacinum,dideoxykanamycin b,kappati,orbicin,panamicin" 0.14 "g" "55669-6,55670-4,55671-2,55672-0"
"DIC" 18381 "Dicloxacillin" "Beta-lactams/penicillins" "J01CF01" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "dicl" "dichloroxacillin,diclossacillina,dicloxaciclin,dicloxacilin,dicloxacilina,dicloxacillin,dicloxacillin sodium,dicloxacillina,dicloxacilline,dicloxacillinum,dicloxacycline,dycill,dynapen,maclicine,nm|| dicloxacillin,pathocil" 2 "g" 2 "g" "10984-3,16769-2,18916-7,220-4,221-2,222-0,223-8,25252-8,32380-8,55668-8"
"DIF" 56206 "Difloxacin" "Quinolones" "NA" "" "dicural,difloxacin,pulsaflox" "35790-5,35791-3,35792-1"
"DIF" 56206 "Difloxacin" "Quinolones" "QJ01MA94" "" "dicural,difloxacin,pulsaflox" "35790-5,35791-3,35792-1"
"DIR" 6473883 "Dirithromycin" "Macrolides/lincosamides" "J01FA13" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "dirithromycin,dirithromycine,dirithromycinum,diritromicina,divitross,dynabac,noriclan,valodin" 0.5 "g" "35793-9,35794-7,35795-4,7007-8"
"DOR" 73303 "Doripenem" "Carbapenems" "J01DH04" "Other beta-lactam antibacterials" "Carbapenems" "dori" "doribax,doripenem,doripenem hydrate,finibax" 1.5 "g" "56031-8,58711-3,60535-2,72893-1"
"DOX" 54671203 "Doxycycline" "Tetracyclines" "A01AB22,J01AA02" "Tetracyclines" "Tetracyclines" "dox,doxy" "atridox,azudoxat,deoxymykoin,dossiciclina,doxcycline anhydrous,doxiciclina,doxirobe,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" "10986-8,18917-5,20379-4,21250-6,224-6,225-3,226-1,227-9,23623-2,25223-9,26902-7,7008-6"
"ECO" 3198 "Econazole" "Antifungals/antimycotics" "D01AC03,G01AF05" "Antifungals for topical use" "Imidazole and triazole derivatives" "econ" "econazol,econazole,econazolum,ecostatin,ecostatin cream,palavale,pevaryl,spectazole,spectazole cream" "25595-0,25637-0,54178-9,55673-8"
"ENX" 3229 "Enoxacin" "Quinolones" "J01MA04" "Quinolone antibacterials" "Fluoroquinolones" "enox" "almitil,bactidan,bactidron,comprecin,enofloxacine,enoksetin,enoram,enoxacin,enoxacina,enoxacine,enoxacino,enoxacinum,enoxen,enoxin,enoxor,flumark,penetrex" 0.8 "g" "16816-1,18918-3,228-7,229-5,230-3,231-1,3590-7,41692-5"
"ENR" 71188 "Enrofloxacin" "Quinolones" "NA" "" "baytril,enrofloxacin,enrofloxacine,enrofloxacino,enrofloxacinum,enroxil" "23712-3,35796-2,35797-0,35798-8"
"ENV" 135565326 "Enviomycin" "Antimycobacterials" "J04AB06" "tuberactinomycin" "enviomicina,enviomycin,enviomycina,enviomycinum,tuberactin" ""
"ENR" 71188 "Enrofloxacin" "Quinolones" "QJ01MA90" "" "baytril,enrofloxacin,enrofloxacine,enrofloxacino,enrofloxacinum,enroxil" "23712-3,35796-2,35797-0,35798-8"
"ENV" 135565326 "Enviomycin" "Antimycobacterials" "J04AB06" "tuberactinomycin" "enviomicina,enviomycin,enviomycina,enviomycinum,tuberactin" 1 "g" ""
"EPE" "Eperozolid" "Other antibacterials" "NA" "" "" ""
"EPC" 71392 "Epicillin" "Beta-lactams/penicillins" "J01CA07" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "dexacillin,dihydroampicillin,epicilina,epicillin,epicilline,epicillinum" 2 "g" 2 "g" ""
"EPP" 68916 "Epiroprim" "Other antibacterials" "NA" "" "epiroprim,epiroprima,epiroprime,epiroprimum" ""
"ERV" 54726192 "Eravacycline" "Tetracyclines" "J01AA13" "Tetracyclines" "Tetracyclines" "erav" "eravacycline,xerava" "100049-6,85423-2,93767-2"
"ERV" 54726192 "Eravacycline" "Tetracyclines" "J01AA13" "Tetracyclines" "Tetracyclines" "erav" "eravacycline,xerava" 0.14 "g" "100049-6,85423-2,93767-2"
"ETP" 150610 "Ertapenem" "Carbapenems" "J01DH03" "Other beta-lactam antibacterials" "Carbapenems" "erta,etp" "ertapenem,invanz" 1 "g" "101486-9,35799-6,35800-2,35801-0,35802-8"
"ERY" 12560 "Erythromycin" "Macrolides/lincosamides" "D10AF02,J01FA01,S01AA17" "Macrolides, lincosamides and streptogramins" "Macrolides" "e,em,ery,eryt" "abboticin,abomacetin,acneryne,acnesol,akne cordes losung,aknederm ery gel,aknemycin,austrias,benzamycin,bristamycin,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,erypar,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" "100050-4,11576-6,12298-6,16829-4,16830-2,18919-1,18920-9,20380-2,232-9,233-7,234-5,235-2,236-0,23633-1,237-8,238-6,239-4,25224-7,25275-9,3597-2,7009-4"
"ETH" 14052 "Ethambutol" "Antimycobacterials" "J04AK02" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "etha" "aethambutolum,diambutol,ebutol,etambutol,etambutolo,etapiam,ethambutol,ethambutolum,myambutol,mycobutol,purderal,servambutol,tibutol" 1.2 "g" 1.2 "g" "100051-2,16841-9,18921-7,20381-0,23625-7,240-2,241-0,242-8,243-6,25187-6,25194-2,25195-9,25230-4,25404-5,3607-9,42645-2,42646-0,55154-9,55674-6,56025-0,7010-2,89491-5"
"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" "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" "16099-4,16845-0,18922-5,20382-8,23617-4,25183-5,25196-7,25198-3,25231-2,41693-3,42647-8,42648-6,7011-0,96110-2"
"ETO" 6034 "Ethopabate" "Other antibacterials" "NA" "" "amprol plus,ethopabat,ethopabate,ethyl pabate" ""
"ETO" 6034 "Ethopabate" "Other antibacterials" "QP51AX17" "" "amprol plus,ethopabat,ethopabate,ethyl pabate" ""
"EXE" "Exebacase" "NA" "" "" ""
"FAR" 65894 "Faropenem" "Other antibacterials" "J01DI03" "Other beta-lactam antibacterials" "Other cephalosporins and penems" "" "faropenem,faropenem sodium,fropenem,fropenum sodium" 0.75 "g" "73600-9,73622-3,73645-4"
"FDX" 10034073 "Fidaxomicin" "Other antibacterials" "A07AA12" "" "dificid,dificlir,difimicin,fidaxomicin,lipiarmicin,lipiarmycin,lipiarrmycin,tiacumicin b" 0.4 "g" "73599-3,73621-5,73644-7"
@@ -187,23 +189,23 @@
"FLA" 46783781 "Flavomycin" "Other antibacterials" "NA" "" "flavophospholipol,moenomycin complex" ""
"FLE" 3357 "Fleroxacin" "Quinolones" "J01MA08" "Quinolone antibacterials" "Fluoroquinolones" "fler" "fleroxacin,fleroxacine,fleroxacino,fleroxacinum,fleroxicin,megalocin,megalone,megalosin,quinodis" 0.4 "g" 0.4 "g" "25411-0,32372-5,35806-9,7012-8"
"FLO" 65864 "Flomoxef" "Other antibacterials" "J01DC14" "" "flomoxef,flomoxefo,flomoxefum" 2 "g" "100052-0,53822-3"
"FLR" 114811 "Florfenicol" "Other antibacterials" "NA" "" "aquafen,florfenicol,nuflor,nuflor gold" "23740-4,35807-7,35808-5,87599-7"
"FLR" 114811 "Florfenicol" "Other antibacterials" "QJ01BA90,QJ51BA90" "" "aquafen,florfenicol,nuflor,nuflor gold" "23740-4,35807-7,35808-5,87599-7"
"FLC" 21319 "Flucloxacillin" "Beta-lactams/penicillins" "J01CF05" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "clox,flux" "culpen,floxacillin,floxacillin sodium,floxapen,floxapen sodium salt,fluclox,flucloxacilina,flucloxacillin,flucloxacilline,flucloxacillinum,fluorochloroxacillin,staphylex" 2 "g" 2 "g" ""
"FLU" 3365 "Fluconazole" "Antifungals/antimycotics" "D01AC15,J02AC01" "Antimycotics for systemic use" "Triazole derivatives" "fluc,fluz,flz" "alflucoz,alfumet,alkanazole,biocanol,biozole,biozolene,canzol,cryptal,diflazon,diflucan,dimycon,elazor,flucazol,fluconazol,fluconazole,fluconazole capsules,fluconazoli,fluconazolum,flucoral,flucostat,flukezol,flunazol,flunizol,flusol,fluzon,fluzone,forcan,fuconal,fungata,loitin,oxifugol,pritenzol,syscan,trican,triconal,triflucan,zoltec" 0.2 "g" 0.2 "g" "10987-6,16870-8,18924-1,248-5,249-3,250-1,251-9,25255-1,7013-6,80530-9"
"FCT" 3366 "Flucytosine" "Antifungals/antimycotics" "D01AE21,J02AX01" "Antifungals for topical use" "Other antifungals for topical use" "5flc,fcu,fluo,fluy" "alcobon,ancoban,ancobon,ancotil,ancotyl,flourocytosine,flucitosina,flucystine,flucytosin,flucytosine,flucytosinum,flucytosone,fluocytosine,fluorcytosine,fluorocytosine" ""
"FCT" 3366 "Flucytosine" "Antifungals/antimycotics" "D01AE21,J02AX01" "Antifungals for topical use" "Other antifungals for topical use" "5flc,fcu,fluo,fluy" "alcobon,ancoban,ancobon,ancotil,ancotyl,flourocytosine,flucitosina,flucystine,flucytosin,flucytosine,flucytosinum,flucytosone,fluocytosine,fluorcytosine,fluorocytosine" 10 "g" 10 "g" ""
"FLM" 3374 "Flumequine" "Quinolones" "J01MB07" "Quinolone antibacterials" "Other quinolones" "" "apurone,fantacin,flumequine,flumequino,flumequinum,flumigal,flumiquil,flumisol,flumix,imequyl" 1.2 "g" "55675-3,55676-1,55677-9,55678-7"
"FLR1" 71260 "Flurithromycin" "Macrolides/lincosamides" "J01FA14" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "flurithromicina,flurithromycime,flurithromycin,flurithromycine,flurithromycinum,fluritromicina,fluritromycinum,flurizic" 0.75 "g" ""
"FFL" 214356 "Fosfluconazole" "Antifungals/antimycotics" "NA" "" "fosfluconazole,phosfluconazole,procif,prodif" ""
"FOS" 446987 "Fosfomycin" "Other antibacterials" "J01XX01" "Other antibacterials" "Other antibacterials" "ff,fm,fo,fof,fos,fosf" "calcium fosfomycin,fosfocina,fosfomicin,fosfomicina,fosfomycin,fosfomycin sodium,fosfomycine,fosfomycinum,fosfonomycin,infectophos,monuril,monurol,phosphonemycin,phosphonomycin,veramina" 3 "g" 8 "g" "25596-8,25653-7,35809-3,35810-1"
"FOS" 446987 "Fosfomycin" "Other antibacterials" "J01XX01,S02AA17" "Other antibacterials" "Other antibacterials" "ff,fm,fo,fof,fos,fosf" "calcium fosfomycin,fosfocina,fosfomicin,fosfomicina,fosfomycin,fosfomycin sodium,fosfomycine,fosfomycinum,fosfonomycin,infectophos,monuril,monurol,phosphonemycin,phosphonomycin,veramina" 3 "g" 8 "g" "25596-8,25653-7,35809-3,35810-1"
"FMD" 572 "Fosmidomycin" "Other antibacterials" "NA" "" "fosmidomycin,fosmidomycina,fosmidomycine,fosmidomycinum" ""
"FRM" 8378 "Framycetin" "Aminoglycosides" "D09AA01,R01AX08,S01AA07" "fram" "actilin,actiline,antibiotique,bycomycin,dekamycin iii,endomixin,enterfram,fradiomycin,fradiomycin b,fradiomycinum,framicetina,framidal,framycetin,framycetin sulfate,framycetine,framycetinum,framycin,framygen,francetin,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" "18926-6,257-6,258-4,259-2,260-0,55679-5"
"FUR" 6870646 "Furazidin" "Other antibacterials" "J01XE03" "Other antibacterials" "Nitrofuran derivatives" "" "akritoin,furagin,furaginum,furamag,furazidin,furazidine" 0.3 "g" ""
"FRZ" 5323714 "Furazolidone" "Other antibacterials" "G01AX06" "" "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" "69574-2,87794-4"
"FUS" 3000226 "Fusidic acid" "Other antibacterials" "D06AX01,D09AA02,J01XC01,S01AA13" "Other antibacterials" "Steroid antibacterials" "fa,fusi" "acide fusidique,acido fusidico,acidum fusidicum,flucidin,fucidate,fucidate sodium,fucidic acid,fucidin,fucidin acid,fucithalmic,fusidate,fusidate acid,fusidic acid,fusidicacid,fusidine,fusidinic acid,ramycin,taksta" 1.5 "g" 1.5 "g" ""
"GAM" 59364992 "Gamithromycin" "Macrolides/lincosamides" "NA" "" "gamithromycin" "100054-6,88376-9,88378-5"
"GAM" 59364992 "Gamithromycin" "Macrolides/lincosamides" "QJ01FA95" "" "gamithromycin" "100054-6,88376-9,88378-5"
"GRN" 124093 "Garenoxacin" "Quinolones" "J01MA19" "" "ganefloxacin,garenfloxacin,garenoxacin" 0.4 "g" "35811-9,35812-7,35813-5"
"GAT" 5379 "Gatifloxacin" "Quinolones" "J01MA16,S01AE06" "Quinolone antibacterials" "Fluoroquinolones" "gati" "gatiflo,gatifloxacin,gatifloxacin hydrate,gatifloxacine,gatifloxcin,gatilox,gatiquin,gatispan,tequin,tequin and zymar,zymaxid" 0.4 "g" 0.4 "g" "31036-7,31038-3,31040-9,31042-5,41494-6"
"GEM" 9571107 "Gemifloxacin" "Quinolones" "J01MA15" "Quinolone antibacterials" "Fluoroquinolones" "" "factiv,factive,gemifioxacin,gemifloxacin,gemifloxacine,gemifloxacino,gemifloxacinum" 0.32 "g" "35814-3,35815-0,35816-8,41697-4"
"GEM" 9571107 "Gemifloxacin" "Quinolones" "J01MA15" "Quinolone antibacterials" "Fluoroquinolones" "" "factiv,factive,gemifioxacin,gemifloxacin,gemifloxacine,gemifloxacino,gemifloxacinum" 0.32 "g" 0.2 "g" "35814-3,35815-0,35816-8,41697-4"
"GEN" 3467 "Gentamicin" "Aminoglycosides" "D06AX07,J01GB03,S01AA11,S02AA14,S03AA06" "Aminoglycoside antibacterials" "Other aminoglycosides" "cn,gen,gent,gm" "apogen,centicin,cidomycin,garamycin,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" "101494-3,13561-6,13562-4,15106-8,18928-2,18929-0,22746-2,22747-0,266-7,267-5,268-3,269-1,31091-2,31092-0,31093-8,35668-3,35817-6,3663-2,3664-0,3665-7,39082-3,47109-4,50630-3,59379-8,7016-9,7017-7,7018-5,80971-5,88111-0,89481-6"
"GEH" "Gentamicin-high" "Aminoglycosides" "NA" "gehi,gehl,genta high,gentamicin high" "" "18929-0,35817-6,7017-7,7018-5"
"GEP" 25101874 "Gepotidacin" "Other antibacterials" "NA" "" "gepotidacin" ""
@@ -213,11 +215,11 @@
"HCH" 11979956 "Hachimycin" "Antifungals/antimycotics" "D01AA03,G01AA06,J02AA02" "Antimycotics for systemic use" "Antibiotics" "" "cabimicina,hachimicina,hachimycin,hachimycine,hachimycinum,trichomycinum,trichonat" ""
"HET" 443387 "Hetacillin" "Beta-lactams/penicillins" "J01CA18" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "etacillina,hetacilina,hetacillin,hetacillin acid,hetacilline,hetacillinum,phenazacillin,versapen" 2 "g" "18931-6,274-1,275-8,276-6,277-4"
"HYG" 56928061 "Hygromycin" "Aminoglycosides" "NA" "" "antihelmycin,hydromycin b,hygrovetine" ""
"IBX" "Ibrexafungerp" "Antifungals" "NA" "" "ibrexafungerp" ""
"IBX" "Ibrexafungerp" "Antifungals" "J02AX07" "" "ibrexafungerp" ""
"ICL" 213043 "Iclaprim" "Other antibacterials" "J01EA03" "" "iclaprim,mersarex" "73597-7,73619-9,73642-1"
"IPM" 104838 "Imipenem" "Carbapenems" "J01DH51" "Other beta-lactam antibacterials" "Carbapenems" "imci,imi,imip,imp" "imipemide,imipenem,imipenem anhydrous,imipenem hydrate,imipenem/cilastatin,imipenemum,imipenen,primaxin,recarbrio .,tienamycin" 2 "g" "101487-7,17010-0,18932-4,18933-2,23613-3,25221-3,25257-7,27331-8,278-2,279-0,280-8,281-6,282-4,283-2,284-0,285-7,35819-2,3688-9,54170-6,54171-4,54172-2,7019-3,85424-0,93232-7,96372-8"
"IPE" "Imipenem/EDTA" "Carbapenems" "NA" "" "" "35819-2,54170-6,54171-4,54172-2"
"IMR" "Imipenem/relebactam" "Carbapenems" "NA,J01DH56" "" "" "85424-0,93232-7,96372-8"
"IMR" "Imipenem/relebactam" "Carbapenems" "NA,J01DH56" "" "" 2 "g" "85424-0,93232-7,96372-8"
"ISV" 6918485 "Isavuconazole" "Antifungals/antimycotics" "J02AC05" "isav" "isavuconazole" 0.2 "g" 0.2 "g" "85381-2,88887-5"
"ISE" 3037209 "Isepamicin" "Aminoglycosides" "J01GB11" "Aminoglycoside antibacterials" "Other aminoglycosides" "" "isepacin,isepalline,isepamicin,isepamicina,isepamicine,isepamicinsulphate,isepamicinum" 0.4 "g" "32381-6,35820-0,35821-8,55680-3"
"ISO" 3760 "Isoconazole" "Antifungals/antimycotics" "D01AC05,G01AF07" "Antimycotics for topic use" "Triazole derivatives" "" "isoconazol,isoconazole,isoconazolum,travogen" "55681-1,55682-9,55683-7,55684-5"
@@ -229,8 +231,8 @@
"KAH" "Kanamycin-high" "Aminoglycosides" "NA" "k_h,kahl" "" "18936-5,7023-5,7024-3"
"KAC" "Kanamycin/cephalexin" "Aminoglycosides" "NA" "" "" ""
"KET" 456201 "Ketoconazole" "Antifungals/antimycotics" "D01AC08,G01AF11,H02CA03,J02AB02" "Antimycotics for systemic use" "Imidazole derivatives" "keto,ktc" "extina,fungarest,fungoral,ketocanazole,ketoconazol,ketoconazole,ketoconazolum,ketoderm,nizoral,xolegel" 0.6 "g" "10990-0,12393-5,18937-3,25259-3,294-9,295-6,296-4,297-2,60091-6,60092-4,7025-0"
"KIT" "Kitasamycin" "Macrolides/lincosamides" "NA" "leucomycin" "jomybel,josacine,josamicina,josamycin,josamycine,josamycinum" ""
"LAS" 5360807 "Lasalocid" "Other antibacterials" "NA" "" "avatec,lasalocid,lasalocid a,lasalocide,lasalocide a,lasalocido,lasalocidum" "87598-9"
"KIT" "Kitasamycin" "Macrolides/lincosamides" "QJ01FA93" "leucomycin" "jomybel,josacine,josamicina,josamycin,josamycine,josamycinum" ""
"LAS" 5360807 "Lasalocid" "Other antibacterials" "QP51BB02" "" "avatec,lasalocid,lasalocid a,lasalocide,lasalocide a,lasalocido,lasalocidum" "87598-9"
"LSC" 71528768 "Lascufloxacin" "Quinolones" "J01MA25" "Quinolone antibacterials" "Fluoroquinolones" "" "lascufloxacin" 75 "mg" ""
"LTM" 47499 "Latamoxef" "Cephalosporins (3rd gen.)" "J01DD06" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "mox,moxa,moxalactam" "disodium moxalactam,festamoxin,lamoxactam,latamoxef,latamoxefum,moxalactamsupplement,shiomarin" 4 "g" ""
"LMU" 25185057 "Lefamulin" "Other antibacterials" "J01XX12" "" "lefamulin,xenleta" "85425-7,99281-8"
@@ -247,7 +249,7 @@
"LYM" 54707177 "Lymecycline" "Tetracyclines" "J01AA04" "Tetracyclines" "Tetracyclines" "" "biovetin,chlortetracyclin,ciclisin,ciclolysal,ciclolysine,infaciclina,limeciclina,lisinbiotic,lymecyclin,lymecycline,lymecyclinum,mucomycin,ntetracycline,tetralisal,tetralysal,vebicyclysal" 0.6 "g" 0.6 "g" "18941-5,310-3,311-1,312-9,313-7"
"MNA" 1292 "Mandelic acid" "Other antibacterials" "B05CA06,J01XX06" "Other antibacterials" "Other antibacterials" "" "acido mandelico,almond acid,ammonium mandelate,amygdalic acid,benzoglycolic acid,hydroxyacetic acid,kyselina mandlova,mandelic acid,paramandelic acid,phenylglycolic acid,uromaline" 12 "g" ""
"MGX" "Manogepix" "Antifungals" "NA" "" "manogepix" ""
"MAR" 60651 "Marbofloxacin" "Quinolones" "NA" "" "marbocyl,marbofloxacin,marbofloxacine,marbofloxacino,marbofloxacinum,zeniquin" "73596-9,73618-1,73641-3"
"MAR" 60651 "Marbofloxacin" "Quinolones" "QJ01MA93" "" "marbocyl,marbofloxacin,marbofloxacine,marbofloxacino,marbofloxacinum,zeniquin" "73596-9,73618-1,73641-3"
"MEC" 36273 "Mecillinam" "Beta-lactams/penicillins" "J01CA11" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "amdinocillin" "amdinocillin,coactin,hexacillin,mecilinamo,mecillinam,mecillinamum,micillinam,penicillin hx,selexidin" 1.2 "g" ""
"MEL" 71306732 "Meleumycin" "Macrolides/lincosamides" "NA" "" "" ""
"MEM" 441130 "Meropenem" "Carbapenems" "J01DH02" "Other beta-lactam antibacterials" "Carbapenems" "mem,mer,mero,mp,mrp" "meronem,meropen,meropenem,meropenem anhydrous,meropenem hydrate,meropenem trihydrate,meropenemum,merrem,merrem i.v.,merrem iv" 3 "g" "101222-8,101488-5,101489-3,18943-1,41406-0,6651-4,6652-2,6653-0,6654-8,7029-2,85426-5,85427-3,88892-5,90980-4"
@@ -279,9 +281,9 @@
"NAF" 8982 "Nafcillin" "Beta-lactams/penicillins" "J01CF06" "" "nafcilina,nafcillin,nafcillin sodium,nafcilline,nafcillinum,nallpen,naphcillin,unipen" 3 "g" "10993-4,18951-4,25232-0,346-7,347-5,348-3,349-1,41704-8"
"ZWK" 117587595 "Nafithromycin" "Macrolides/lincosamides" "NA" "" "nafithromycin" ""
"NAL" 4421 "Nalidixic acid" "Quinolones" "J01MB02" "Quinolone antibacterials" "Other quinolones" "na,nal,nali" "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,nalidixicacid,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" ""
"NAR" 65452 "Narasin" "Other antibacterials" "NA" "" "monteban,narasin,narasin a,narasine,narasino,narasinum,narasul" "87570-8"
"NAR" 65452 "Narasin" "Other antibacterials" "QP51BB04" "" "monteban,narasin,narasin a,narasine,narasino,narasinum,narasul" "87570-8"
"NEM" 11993740 "Nemonoxacin" "Quinolones" "J01MB08" "Quinolone antibacterials" "Other quinolones" "" "nemonoxacin" ""
"NEO" 8378 "Neomycin" "Aminoglycosides" "A01AB08,A07AA01,B05CA09,D06AX04,J01GB05,R02AB01,S01AA03,S02AA07,S03AA01" "Aminoglycoside antibacterials" "Other aminoglycosides" "neom" "actilin,actiline,antibiotique,bycomycin,dekamycin iii,endomixin,enterfram,fradiomycin,fradiomycin b,fradiomycinum,framicetina,framidal,framycetin,framycetin sulfate,framycetine,framycetinum,framycin,framygen,francetin,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" "10995-9,18953-0,25262-7,354-1,355-8,356-6,357-4,41705-5"
"NEO" 8378 "Neomycin" "Aminoglycosides" "A01AB08,A07AA01,B05CA09,D06AX04,J01GB05,R02AB01,S01AA03,S02AA07,S03AA01" "Aminoglycoside antibacterials" "Other aminoglycosides" "neom" "actilin,actiline,antibiotique,bycomycin,dekamycin iii,endomixin,enterfram,fradiomycin,fradiomycin b,fradiomycinum,framicetina,framidal,framycetin,framycetin sulfate,framycetine,framycetinum,framycin,framygen,francetin,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" 1 "g" "10995-9,18953-0,25262-7,354-1,355-8,356-6,357-4,41705-5"
"NET" 441306 "Netilmicin" "Aminoglycosides" "J01GB07,S01AA23" "Aminoglycoside antibacterials" "Other aminoglycosides" "neti" "netillin,netilmicin,netilmicin sulfate,netilmicina,netilmicine,netilmicinum,netilyn,netira,nettacin,vectacin" 0.35 "g" 0.35 "g" "18954-8,25263-5,358-2,359-0,360-8,361-6,3848-9,3849-7,3850-5,47385-0,59565-2,59566-0,59567-8,7035-9"
"NIC" 9507 "Nicarbazin" "Other antibacterials" "NA" "" "nicarb,nicarbasin,nicarbazin,nicarbazine,nicoxin,nicrazin,nicrazine,nirazin" ""
"NIF" 71946 "Nifuroquine" "Quinolones" "NA" "" "abimasten,nifuroquina,nifuroquine,nifuroquinum,quinaldofur" ""
@@ -294,24 +296,24 @@
"NME" "Norfloxacin/metronidazole" "Other antibacterials" "J01RA14" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"NTI" "Norfloxacin/tinidazole" "Other antibacterials" "J01RA13" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"NVA" 10419027 "Norvancomycin" "Glycopeptides" "NA" "" "norvancomycin" ""
"NOV" 54675769 "Novobiocin" "Other antibacterials" "NA" "novo" "albamix,albamycin,cardelmycin,cathocin,cathomycin,crystallinic acid,inamycin,novobiocin,novobiocina,novobiocine,novobiocinum,robiocina,sirbiocina,spheromycin,stilbiocina,streptonivicin" "17378-1,18957-1,370-7,371-5,372-3,373-1,41706-3"
"NOV" 54675769 "Novobiocin" "Other antibacterials" "QJ01XX95" "novo" "albamix,albamycin,cardelmycin,cathocin,cathomycin,crystallinic acid,inamycin,novobiocin,novobiocina,novobiocine,novobiocinum,robiocina,sirbiocina,spheromycin,stilbiocina,streptonivicin" "17378-1,18957-1,370-7,371-5,372-3,373-1,41706-3"
"NYS" 6433272 "Nystatin" "Antifungals/antimycotics" "A07AA02,D01AA01,G01AA01" "nyst" "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 hydrate,nystatin lf,nystatine,nystatinum,nystatyna,nystavescent,nystex,nystop,stamycin,terrastatin,zydin e" 1.5 "MU" "10697-1,10698-9,18958-9,35824-2,55689-4"
"OFX" 4583 "Ofloxacin" "Quinolones" "J01MA01,S01AE01,S02AA16" "Quinolone antibacterials" "Fluoroquinolones" "of,ofl,oflo,ofx" "bactocin,danoflox,dextrofloxacin,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" "18959-7,20384-4,23948-3,25264-3,374-9,375-6,376-4,377-2,3877-8,41408-6,41409-4,41410-2,42653-6,7038-3,72168-8"
"OOR" "Ofloxacin/ornidazole" "Other antibacterials" "J01RA09" "Combinations of antibacterials" "Combinations of antibacterials" "" "" ""
"OLE" 72493 "Oleandomycin" "Macrolides/lincosamides" "J01FA05" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "amimycin,landomycin,matromycin,oleandomicina,oleandomycin,oleandomycin a,oleandomycine,oleandomycinum,romicil" 1 "g" "18960-5,378-0,379-8,380-6,381-4,55690-2"
"OMC" 54697325 "Omadacycline" "Tetracyclines" "J01AA15" "" "amadacycline,omadacycline" 0.3 "g" 0.1 "g" "73594-4,73616-5,73639-7"
"OPT" 87880 "Optochin" "Other antibacterials" "NA" "" "numoquin,optochin,optoquine" "100055-3,73665-2"
"ORB" 60605 "Orbifloxacin" "Quinolones" "NA" "" "orbifloxacin" "35825-9,35826-7,35827-5"
"ORB" 60605 "Orbifloxacin" "Quinolones" "QJ01MA95" "" "orbifloxacin" "35825-9,35826-7,35827-5"
"ORI" 16136912 "Oritavancin" "Glycopeptides" "J01XA05" "Other antibacterials" "Glycopeptide antibacterials" "orit" "kimyrsa,oritavancin" "41707-1,41708-9,41709-7,41736-0"
"ORS" "Ormetroprim/sulfamethoxazole" "Other antibacterials" "NA" "" "" "73593-6,73615-7,73638-9"
"ORN" 28061 "Ornidazole" "Other antibacterials" "G01AF06,J01XD03,P01AB03" "Other antibacterials" "Imidazole derivatives" "" "madelen,ornidal,ornidazol,ornidazole,ornidazolum,tiberal" 1.5 "g" 1 "g" "55691-0,55692-8,55693-6,55694-4"
"OTE" 77050711 "Oteseconazole" "Antifungals/antimycotics" "J02AC06" "Antimycotics for systemic use" "Triazole derivatives" "" "oteseconazole" ""
"OTE" 77050711 "Oteseconazole" "Antifungals/antimycotics" "J02AC06" "Antimycotics for systemic use" "Triazole derivatives" "" "oteseconazole" 21 "mg" ""
"OXA" 6196 "Oxacillin" "Beta-lactams/penicillins" "J01CF04" "Beta-lactam antibacterials, penicillins" "Beta-lactamase resistant penicillins" "ox,oxa,oxac,oxal,oxs" "bactocill,ossacillina,oxacilina,oxacillin,oxacillin sodium,oxacilline,oxacillinum,oxazocillin,oxazocilline,prostaphlin,prostaphlyn,sodium oxacillin" 2 "g" 2 "g" "18961-3,25265-0,382-2,383-0,384-8,385-5,3882-8,7039-1"
"OXO" 4628 "Oxolinic acid" "Quinolones" "J01MB05" "Quinolone antibacterials" "Other quinolones" "" "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" ""
"OXY" 54675779 "Oxytetracycline" "Tetracyclines" "D06AA03,G01AA07,J01AA06,S01AA04" "Tetracyclines" "Tetracyclines" "" "adamycin,berkmycen,biostat,biostat pa,bisolvomycin,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,terramycine,tetran,unimycin,ursocyclin,ursocycline,vendarcin" 1 "g" 1 "g" "17396-3,18962-1,25266-8,386-3,387-1,388-9,389-7,55699-3,87595-5"
"OXY" 54675779 "Oxytetracycline" "Tetracyclines" "A01AB25,D06AA03,G01AA07,J01AA06,S01AA04" "Tetracyclines" "Tetracyclines" "" "adamycin,berkmycen,biostat,biostat pa,bisolvomycin,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,terramycine,tetran,unimycin,ursocyclin,ursocycline,vendarcin" 1 "g" 1 "g" "17396-3,18962-1,25266-8,386-3,387-1,388-9,389-7,55699-3,87595-5"
"OZN" "Ozenoxacin" "D06AX14" "" "ozadub,ozenoxacin,ozenoxacin cream" ""
"PAS" 4649 "P-aminosalicylic acid" "Antimycobacterials" "NA" "" "aminopar,aminosalicylic,aminosalicylic acid,aminosalyl,aminox,apacil,deapasil,entepas,ferrosan,gabbropas,granupas,helipidyl,hellipidyl,neopasalate,osacyl,pamacyl,pamisyl,paramycin,parasal,parasalicil,parasalindon,pasalon,pasara,pascorbic,pasdium,paser granules,paskalium,pasmed,pasnodia,pasolac,propasa,rezipas,teebacin" ""
"PAN" 72015 "Panipenem" "Carbapenems" "NA,J01DH55" "" "panipenem,panipenem/betamipron,panipenemum,penipanem" "100056-1,53823-1"
"PAN" 72015 "Panipenem" "Carbapenems" "NA,J01DH55" "" "panipenem,panipenem/betamipron,panipenemum,penipanem" 2 "g" "100056-1,53823-1"
"PAR" 165580 "Paromomycin" "Other antibacterials" "A07AA06" "" "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" "51719-3,53824-9,55700-9,55701-7,55702-5"
"PAZ" 65957 "Pazufloxacin" "Quinolones" "J01MA18" "Quinolone antibacterials" "Fluoroquinolones" "" "pazufloxacin,pazufloxacine,pazufloxacino,pazufloxacinum" 1 "g" ""
"PEF" 51081 "Pefloxacin" "Quinolones" "J01MA03" "Quinolone antibacterials" "Fluoroquinolones" "pefl" "abactal,labocton,pefloxacin,pefloxacine,pefloxacinium,pefloxacino,pefloxacinum,perfloxacin,silver pefloxacin" 0.8 "g" 0.8 "g" "18963-9,35828-3,390-5,3906-5,7040-9"
@@ -330,7 +332,7 @@
"PIS" "Piperacillin/sulbactam" "Beta-lactams/penicillins" "NA" "" "" "54197-9,54198-7,54199-5,55704-1"
"TZP" 461573 "Piperacillin/tazobactam" "Beta-lactams/penicillins" "J01CR05" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "p/t,piptaz,piptazo,pit,pita,pt,ptc,ptz,tzp" "tazocel,tazocillin,tazocin,zosyn" 14 "g" "101491-9,18970-4,411-9,412-7,413-5,414-3,7044-1"
"PRC" 71978 "Piridicillin" "Beta-lactams/penicillins" "NA" "" "piridicillin" ""
"PRL" 157385 "Pirlimycin" "Macrolides/lincosamides" "NA" "" "pirlimycin,pirlimycina,pirlimycine,pirlimycinum,pirsue" "35829-1,35830-9,35831-7"
"PRL" 157385 "Pirlimycin" "Macrolides/lincosamides" "QJ51FF90" "" "pirlimycin,pirlimycina,pirlimycine,pirlimycinum,pirsue" "35829-1,35830-9,35831-7"
"PIR" 4855 "Piromidic acid" "Quinolones" "J01MB03" "Quinolone antibacterials" "Other quinolones" "" "acide piromidique,acido piromidico,acidum piromidicum,actrun c,bactramyl,enterol,gastrurol,panacid,pirodal,piromidate,piromidic acid,piromidicacid,pyrido,reelon,septural,urisept,uropir,zaomeal" 2 "g" ""
"PVM" 33478 "Pivampicillin" "Beta-lactams/penicillins" "J01CA02" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "berocillin,pivaloylampicillin,pivampicilina,pivampicillin,pivampicilline,pivampicillinum,pondocillin" 1.05 "g" "18971-2,415-0,416-8,417-6,418-4"
"PME" 115163 "Pivmecillinam" "Beta-lactams/penicillins" "J01CA08" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "amdinocillin pivoxil,coactabs,hydroxymethyl,pivmecilinamo,pivmecillinam,pivmecillinam hcl,pivmecillinamum" 0.6 "g" ""
@@ -338,9 +340,9 @@
"PLB" 49800004 "Polymyxin B" "Polymyxins" "A07AA05,J01XB02,S01AA18,S02AA11,S03AA03" "Other antibacterials" "Polymyxins" "pb,pol,polb,poly,poly b,polymixin,polymixin b" "polimixina b,polumyxin b,polymixin b,polymyxine b" 3 "MU" 0.15 "g" "17473-0,18972-0,25269-2,35832-5,419-2,420-0,421-8,422-6"
"POP" "Polymyxin B/polysorbate 80" "Polymyxins" "NA" "" "" ""
"POS" 468595 "Posaconazole" "Antifungals/antimycotics" "J02AC04" "Antimycotics for systemic use" "Triazole derivatives" "posa" "noxafil,posaconazole,posaconazole sp,posconazole" 0.3 "g" 0.3 "g" "53731-6,54186-2,54187-0,54188-8,54189-6,80545-7"
"PRA" 9802884 "Pradofloxacin" "Quinolones" "NA" "" "pradofloxacin,pudofloxacin,veraflox" "76148-6,87800-9"
"PRA" 9802884 "Pradofloxacin" "Quinolones" "QJ01MA97" "" "pradofloxacin,pudofloxacin,veraflox" "76148-6,87800-9"
"PRX" 71455 "Premafloxacin" "Quinolones" "NA" "" "premafloxacin,remafloxacin" "73591-0,73613-2,73636-3"
"PMD" 456199 "Pretomanid" "Antimycobacterials" "J04AK08" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "" "oxazine,pretomanid" "93850-6"
"PMD" 456199 "Pretomanid" "Antimycobacterials" "J04AK08" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "" "oxazine,pretomanid" 0.2 "g" "93850-6"
"PRM" 6446787 "Primycin" "Macrolides/lincosamides" "NA" "" "primycin" ""
"PRI" 11979535 "Pristinamycin" "Macrolides/lincosamides" "J01FG01" "Macrolides, lincosamides and streptogramins" "Streptogramins" "pris" "eskalin v,mikamycin,mikamycine,mikamycinum,ostreogrycinum,pristinamycine,pristinamycinum,stafac,stafytracine,staphylomycin,starfac,streptogramin,vernamycin,virgimycin,virgimycine,virginiamycin,virginiamycina,virginiamycine,virginiamycinum" 2 "g" "32383-2,35833-3,35834-1,55709-0"
"PRB" 5903 "Procaine benzylpenicillin" "Beta-lactams/penicillins" "J01CE09" "Beta-lactam antibacterials, penicillins" "Beta-lactamase sensitive penicillins" "" "depocillin,duphapen,hostacillin,hydracillin,jenacillin o,nopcaine,penicillin procaine,retardillin,vetspen,vitablend" 0.6 "g" ""
@@ -349,13 +351,13 @@
"PTH" 666418 "Protionamide" "Antimycobacterials" "J04AD01" "Drugs for treatment of tuberculosis" "Thiocarbamide derivatives" "prot" "ektebin,peteha,prothionamide,prothionamidum,protion,protionamid,protionamida,protionamide,protionamidum,protionizina,tebeform,trevintix,tuberex" 0.75 "g" ""
"PRU" 65947 "Prulifloxacin" "Quinolones" "J01MA17" "Quinolone antibacterials" "Fluoroquinolones" "" "prulifloxacin,pruvel,pufloxacin dioxolil,quisnon" 0.6 "g" "100058-7,76145-2"
"PZA" 1046 "Pyrazinamide" "Antimycobacterials" "J04AK01" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "pyra" "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" "11001-5,18973-8,20461-0,23632-3,25186-8,25229-6,25270-0,423-4,424-2,425-9,426-7,42935-7,55710-8,55711-6,56026-8,92242-7"
"QDA" 11979418 "Quinupristin/dalfopristin" "Macrolides/lincosamides" "J01FG02" "Macrolides, lincosamides and streptogramins" "Streptogramins" "q/d,qda,qida,quda,rp,syn" "" 1.5 "g" "23640-6,23641-4,33334-4,35835-8,58712-1"
"QDA" 11979418 "Quinupristin/dalfopristin" "Macrolides/lincosamides" "QJ01FG02" "Macrolides, lincosamides and streptogramins" "Streptogramins" "q/d,qda,qida,quda,rp,syn" "" "23640-6,23641-4,33334-4,35835-8,58712-1"
"RAC" 56052 "Ractopamine" "Other antibacterials" "NA" "" "optaflexx,paylean,ractopamina,ractopamine,ractopaminum" ""
"RAM" 16132338 "Ramoplanin" "Glycopeptides" "NA" "" "ramoplanin" "41710-5,41711-3,41712-1,41737-8"
"RZM" 10993211 "Razupenem" "Carbapenems" "NA" "" "razupenem" "73590-2,73612-4,73635-5"
"RTP" 6918462 "Retapamulin" "Other antibacterials" "D06AX13" "Antibiotics for topical use" "Other antibiotics for topical use" "ret" "altabax,altargo,retapamulin" ""
"RZF" "Rezafungin" "Antifungals" "NA" "" "biafungin,rezafungin cation,rezafungin ion" ""
"RBC" 44631912 "Ribociclib" "Antifungals/antimycotics" "L01EF02" "Antimycotics for systemic use" "Triazole derivatives" "ribo" "kisqali,ribociclib" 0.45 ""
"RBC" 44631912 "Ribociclib" "Antifungals/antimycotics" "L01EF02" "Antimycotics for systemic use" "Triazole derivatives" "ribo" "kisqali,ribociclib" 0.45 "g" ""
"RST" 33042 "Ribostamycin" "Aminoglycosides" "J01GB10" "Aminoglycoside antibacterials" "Other aminoglycosides" "" "dekamycin iv,hetangmycin,ribastamin,ribostamicina,ribostamycin,ribostamycine,ribostamycinum,vistamycin,xylostatin" 1 "g" ""
"RID1" 16659285 "Ridinilazole" "Other antibacterials" "NA" "" "ridinilazole" ""
"RIB" 135398743 "Rifabutin" "Antimycobacterials" "J04AB04" "Drugs for treatment of tuberculosis" "Antibiotics" "rifb" "alfacid,ansamicin,ansamycin,ansatipin,ansatipine,assatipin,mycobutin,rifabutin,rifabutina,rifabutine,rifabutinum" 0.15 "g" "100699-8,16100-0,16386-5,16387-3,19149-4,20386-9,23630-7,24032-5,25199-1,25200-7,25201-5,42655-1,42656-9,54183-9,96113-6"
@@ -364,7 +366,7 @@
"RFI" "Rifampicin/isoniazid" "Antimycobacterials" "J04AM02" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "rifinah,rimactazid" ""
"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" "A07AA13,D06AX15,J04AB03,S01AA16,S02AA12" "Drugs for treatment of tuberculosis" "Antibiotics" "" "aemcolo,rifacin,rifamicina,rifamicine sv,rifamycin,rifamycine,rifamycinum,rifocin,rifocyn,rifomycin,rifomycin sv,tuborin" 0.6 "g" ""
"RFM" 6324616 "Rifamycin" "Antimycobacterials" "A07AA13,D06AX15,J04AB03,S01AA16,S02AA12" "Drugs for treatment of tuberculosis" "Antibiotics" "" "aemcolo,rifacin,rifamicina,rifamicine sv,rifamycin,rifamycine,rifamycinum,rifocin,rifocyn,rifomycin,rifomycin sv,tuborin" 0.8 "g" 0.6 "g" ""
"RFP" 135403821 "Rifapentine" "Antimycobacterials" "J04AB05" "Drugs for treatment of tuberculosis" "Antibiotics" "rifp,rpt" "cyclopentyl rifampin,prifitin,priftin,rifapentin,rifapentina,rifapentine,rifapentinum" 0.11 "g" "100059-5,76627-9"
"RFX" 6436173 "Rifaximin" "Other antibacterials" "A07AA11,D06AX11" "Intestinal antiinfectives" "Antibiotics" "" "fatroximin,flonorm,lormyx,lumenax,normix,redactiv,rifacol,rifamixin,rifaxidin,rifaximin,rifaximina,rifaximine,rifaximinum,rifaxin,ritacol,spiraxin,xifaxan,xifaxsan" 0.6 "g" "73589-4,73611-6,73634-8"
"RIT" 65633 "Ritipenem" "Carbapenems" "NA" "" "ritipenem" ""
@@ -374,8 +376,8 @@
"ROS" 287180 "Rosoxacin" "Quinolones" "J01MB01" "Quinolone antibacterials" "Other quinolones" "" "acrosoxacin,eracine,eradacil,eradacin,eradicin,rosoxacin,rosoxacine,rosoxacino,rosoxacinum,roxadyl,winoxacin,winuron" 0.3 "g" "18977-9,439-0,440-8,441-6,442-4,55713-2"
"RXT" "Roxithromycin" "Macrolides/lincosamides" "J01FA06" "Macrolides, lincosamides and streptogramins" "Macrolides" "roxi" "roxithromycin,roxithromycine,roxithromycinum,roxitromicina,rulide" 0.3 "g" "18978-7,443-2,444-0,445-7,446-5,7046-6"
"RFL" 58258 "Rufloxacin" "Quinolones" "J01MA10" "Quinolone antibacterials" "Fluoroquinolones" "" "rufloxacin,rufloxacin hcl,rufloxacine,rufloxacino,rufloxacinum" 0.2 "g" ""
"SAL" 3085092 "Salinomycin" "Other antibacterials" "NA" "" "coxistac,procoxacin,salinomicina,salinomycin,salinomycine,salinomycinum" "35836-6,35837-4,35838-2,87593-0"
"SAR" 56208 "Sarafloxacin" "Quinolones" "NA" "" "difloxacine,difloxacino,difloxacinum,quinolone der.,saraflox,sarafloxacin,sarafloxacine,sarafloxacino,sarafloxacinum" "73588-6,73610-8,73633-0"
"SAL" 3085092 "Salinomycin" "Other antibacterials" "QP51BB01" "" "coxistac,procoxacin,salinomicina,salinomycin,salinomycine,salinomycinum" "35836-6,35837-4,35838-2,87593-0"
"SAR" 56208 "Sarafloxacin" "Quinolones" "QJ01MA98" "" "difloxacine,difloxacino,difloxacinum,quinolone der.,saraflox,sarafloxacin,sarafloxacine,sarafloxacino,sarafloxacinum" "73588-6,73610-8,73633-0"
"SRC" 54681908 "Sarecycline" "Tetracyclines" "J01AA14" "Tetracyclines" "Tetracyclines" "" "sarecycline,seysara" 0.1 "g" ""
"SRX" 9933415 "Sarmoxicillin" "Beta-lactams/penicillins" "NA" "" "sarmoxicillin" ""
"SEC" 71815 "Secnidazole" "Other antibacterials" "P01AB07" "" "flagentyl,secnidal,secnidazol,secnidazole,secnidazolum,secnil,sindose,solosec" 2 "g" ""
@@ -395,7 +397,7 @@
"SUL" 130313 "Sulbactam" "Beta-lactams/penicillins" "J01CG01" "Beta-lactam antibacterials, penicillins" "Beta-lactamase inhibitors" "" "betamaze,sulbactam,sulbactam acid,sulbactam free acid,sulbactamum" 1 "g" "41716-2,41717-0,41718-8,41739-4"
"SBC" 20055036 "Sulbenicillin" "Beta-lactams/penicillins" "J01CA16" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "kedacillina,sulbenicilina,sulbenicillin,sulbenicilline,sulbenicillinum" 15 "g" ""
"SUC" 5318 "Sulconazole" "Antifungals/antimycotics" "D01AC09" "" "sulconazol,sulconazole,sulconazolum" ""
"SUP" 6634 "Sulfachlorpyridazine" "Other antibacterials" "NA" "" "cluricol,cosulid,cosumix,durasulf,nefrosul,nsulfanilamide,prinzone vet,prinzone vet.,solfaclorpiridazina,sonilyn,sulfachlorpyridazine,sulfacloropiridazina,vetisulid" ""
"SUP" 6634 "Sulfachlorpyridazine" "Other antibacterials" "QJ01EQ12" "" "cluricol,cosulid,cosumix,durasulf,nefrosul,nsulfanilamide,prinzone vet,prinzone vet.,solfaclorpiridazina,sonilyn,sulfachlorpyridazine,sulfacloropiridazina,vetisulid" ""
"SDI" 5215 "Sulfadiazine" "Trimethoprims" "J01EC02" "Sulfonamides and trimethoprim" "Intermediate-acting sulfonamides" "" "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" "18984-5,27216-1,463-0,464-8,465-5,466-3,59742-7,6907-0,7050-8"
"SLT" 122284 "Sulfadiazine/tetroxoprim" "Trimethoprims" "J01EE06" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "" "cotetroxazine" ""
"SLT1" 64932 "Sulfadiazine/trimethoprim" "Trimethoprims" "J01EE02" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "" "antastmon,cotrimazine,diaziprim forte,ditrim,ditrivet,sultrisan,triglobe,trimin,tucoprim,uniprim" ""
@@ -432,7 +434,7 @@
"TAL" 71447 "Talampicillin" "Beta-lactams/penicillins" "J01CA15" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "" "talampicilina,talampicillin,talampicilline,talampicillinum" 2 "g" "18988-6,479-6,480-4,481-2,482-0"
"TLP" 163307 "Talmetoprim" "Other antibacterials" "NA" "" "talmetoprim" ""
"TAZ" 123630 "Tazobactam" "Beta-lactams/penicillins" "J01CG02" "Beta-lactam antibacterials, penicillins" "Beta-lactamase inhibitors" "tazo" "tazobactam,tazobactam acid,tazobactamum,tazobactum" "41719-6,41720-4,41721-2,41740-2"
"TBP" 9800194 "Tebipenem" "Carbapenems" "NA,J01DH06" "" "tebipenem pivoxil" ""
"TBP" 9800194 "Tebipenem" "Carbapenems" "NA,J01DH06" "" "tebipenem pivoxil" 0.56 "g" ""
"TZD" 11234049 "Tedizolid" "Oxazolidinones" "J01XX11" "Other antibacterials" "Other antibacterials" "tedi" "sivextro,tedizolid,torezolid" 0.2 "g" 0.2 "g" "73586-0,73608-2,73631-4"
"TEC" 16131923 "Teicoplanin" "Glycopeptides" "J01XA02" "Other antibacterials" "Glycopeptide antibacterials" "tec,tei,teic,tp,tpl,tpn" "targocid,tecoplanina,tecoplanine,tecoplaninum,teichomycin,teicoplanin,teicoplanina,teicoplanine,teicoplaninum" 0.4 "g" "18989-4,25534-9,25535-6,34378-0,34379-8,4043-6,483-8,484-6,485-3,486-1,7051-6,80968-1"
"TCM" "Teicoplanin-macromethod" "Glycopeptides" "NA" "" "" ""
@@ -450,29 +452,29 @@
"THI" 27200 "Thiamphenicol" "Amphenicols" "J01BA02" "Amphenicols" "Amphenicols" "" "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" "41723-8,41724-6,41725-3,54169-8"
"TAT" 9568512 "Thioacetazone" "Antimycobacterials" "J04AK07" "Drugs for treatment of tuberculosis" "Other drugs for treatment of tuberculosis" "" "aktivan,ambathizon,amithiozone,amitiozon,benthiozone,benzothiozane,benzothiozon,berculon a,berkazon,citazone,conteben,diasan,domakol,ilbion,livazone,mirizone neustab,mivizon,myvizone,neotibil,neustab,novakol,nuclon argentinian,panrone,parazone,seroden,siocarbazone,tebalon,tebecure,tebemar,tebesone i,tebethion,tebethione,tebezon,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" ""
"THI1" "Thioacetazone/isoniazid" "Antimycobacterials" "J04AM04" "Drugs for treatment of tuberculosis" "Combinations of drugs for treatment of tuberculosis" "" "" ""
"TIA" 656958 "Tiamulin" "Other antibacterials" "NA" "" "denagard,thiamutilin,tiamulin,tiamulin pamoate,tiamulina,tiamuline,tiamulinum,tiavet p" "35846-5,35847-3,35848-1,87589-8"
"TIA" 656958 "Tiamulin" "Other antibacterials" "QJ01XQ01" "" "denagard,thiamutilin,tiamulin,tiamulin pamoate,tiamulina,tiamuline,tiamulinum,tiavet p" "35846-5,35847-3,35848-1,87589-8"
"TIC" 36921 "Ticarcillin" "Beta-lactams/penicillins" "J01CA13" "Beta-lactam antibacterials, penicillins" "Penicillins with extended spectrum" "tc,ti,tic,tica" "ticarcilina,ticarcillin,ticarcilline,ticarcillinum,ticillin,timentin" 15 "g" "18994-4,18995-1,25254-4,4054-3,4055-0,499-4,500-9,501-7,502-5,503-3,504-1,505-8,506-6,55716-5,55717-3,55718-1,55719-9,7053-2,7054-0"
"TCC" 6437075 "Ticarcillin/clavulanic acid" "Beta-lactams/penicillins" "J01CR03" "Beta-lactam antibacterials, penicillins" "Combinations of penicillins, incl. beta-lactamase inhibitors" "t/c,tcc,ticl,tim,tlc" "timentin" 15 "g" ""
"TGC" 54686904 "Tigecycline" "Tetracyclines" "J01AA12" "Tetracyclines" "Tetracyclines" "tgc,tig,tige" "haizheng li xing,tigeciclina,tigecyclin,tigecycline,tigecycline hydrate,tigecyclinum,tigilcycline,tygacil" 0.1 "g" "101499-2,42354-1,42355-8,42356-6,42357-4,55158-0"
"TBQ" 65592 "Tilbroquinol" "Quinolones" "P01AA05" "" "tilbroquinol,tilbroquinolum" ""
"TIP" 24860548 "Tildipirosin" "Macrolides/lincosamides" "NA" "" "tildipirosin,zuprevo" "100060-3,88375-1,88377-7"
"TIL" 5282521 "Tilmicosin" "Macrolides/lincosamides" "NA" "" "micotil,pulmotil,tilmicosin,tilmicosina,tilmicosine,tilmicosinum" "35849-9,35850-7,35851-5,87588-0"
"TIN" 5479 "Tinidazole" "Other antibacterials" "J01XD02,P01AB02" "Other antibacterials" "Imidazole derivatives" "tini" "amtiba,bioshik,ethyl sulfone,fasigin,fasigyn,fasigyntrade mark,fasygin,glongyn,haisigyn,pletil,simplotan,simplotantrade mark,sorquetan,symplotan,tindamax,tindamaxtrade mark,tinidazol,tinidazole,tinidazolum,tricolam,trimonase" 2 "g" 1.5 "g" "54928-7,55720-7,55721-5,55722-3"
"TIP" 24860548 "Tildipirosin" "Macrolides/lincosamides" "QJ01FA96" "" "tildipirosin,zuprevo" "100060-3,88375-1,88377-7"
"TIL" 5282521 "Tilmicosin" "Macrolides/lincosamides" "QJ01FA91" "" "micotil,pulmotil,tilmicosin,tilmicosina,tilmicosine,tilmicosinum" "35849-9,35850-7,35851-5,87588-0"
"TIN" 5479 "Tinidazole" "Other antibacterials" "G01AF21,J01XD02,P01AB02" "Other antibacterials" "Imidazole derivatives" "tini" "amtiba,bioshik,ethyl sulfone,fasigin,fasigyn,fasigyntrade mark,fasygin,glongyn,haisigyn,pletil,simplotan,simplotantrade mark,sorquetan,symplotan,tindamax,tindamaxtrade mark,tinidazol,tinidazole,tinidazolum,tricolam,trimonase" 2 "g" 1.5 "g" "54928-7,55720-7,55721-5,55722-3"
"TCR" 3001386 "Tiocarlide" "Antimycobacterials" "J04AD02" "Drugs for treatment of tuberculosis" "Thiocarbamide derivatives" "" "amixyl,datanil,disocarban,disoxyl,isoxyl,thiocarlide,tiocarlid,tiocarlida,tiocarlide,tiocarlidum" 7 "g" ""
"TDC" 10247721 "Tiodonium chloride" "Other antibacterials" "NA" "" "cloruro de tiodonio,tiodonii chloridum,tiodonium chloride" ""
"TXC" 65788 "Tioxacin" "Quinolones" "NA" "" "tioxacin,tioxacine,tioxacino,tioxacinum,tioxic acid" ""
"TIZ" 394397 "Tizoxanide" "Other antibacterials" "NA" "" "ntzdes" "73585-2,73607-4,73629-8"
"TOB" 36294 "Tobramycin" "Aminoglycosides" "J01GB01,S01AA12" "Aminoglycoside antibacterials" "Other aminoglycosides" "nn,tm,to,tob,tobr" "bethkis,brulamycin,deoxykanamycin b,distobram,gernebcin,gotabiotic,kitabis,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" "101496-8,13584-8,17808-7,18996-9,22750-4,22751-2,22752-0,25227-0,25800-4,31094-6,31095-3,31096-1,35239-3,35670-9,4057-6,4058-4,4059-2,507-4,508-2,509-0,50927-3,510-8,52962-8,59380-6,7055-7,80966-5"
"TOH" "Tobramycin-high" "Aminoglycosides" "NA" "tobra high,tobramycin high,tohl" "" ""
"TFX" 5517 "Tosufloxacin" "Quinolones" "J01MA22" "" "tosufloxacin" 0.45 "g" "100061-1,76146-0"
"TFX" 5517 "Tosufloxacin" "Quinolones" "J01MA22,S01AE09" "" "tosufloxacin" 0.45 "g" "100061-1,76146-0"
"TMP" 5578 "Trimethoprim" "Trimethoprims" "J01EA01" "Sulfonamides and trimethoprim" "Trimethoprim and derivatives" "t,tmp,tr,tri,trim,w" "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,infectotrimet,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" "101495-0,11005-6,17747-7,18997-7,18998-5,20387-7,23614-1,23631-5,25273-4,32342-8,4079-0,4080-8,4081-6,511-6,512-4,513-2,514-0,515-7,516-5,517-3,518-1,55584-7,7056-5,7057-3,80552-3,80973-1"
"SXT" 358641 "Trimethoprim/sulfamethoxazole" "Trimethoprims" "J01EE01" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "cot,cotrim,sxt,t/s,trsu,trsx,ts" "abacin,abactrim,agoprim,alfatrim,aposulfatrim,bacteral,bacterial forte,bactilen,bactiver,bacton,bactoreduct,bactrim,bactrim ds,bactrim forte,bactrim pediatric,bactrimel,bactrizol,bactromin,bactropin,baktar,belcomycine,berlocid,bibacrim,biseptol,chemitrim,chemotrim,ciplin,colimycin,colimycin sulphate,colisticin,colistimethate,colistimethate sodium,colistin sulfate,colistin sulphate,colomycin,coly-mycin,cotribene,cotrim d.s.,cotrim eu rho,cotrim holsen,cotrim.l.u.t.,cotrimaxazol,cotrimazole,cotrimhexal,cotrimoxazol,cotrimoxazol al,cotrimoxazole,cotrimstada,cotriver,dibaprim,drylin,duratrimet,eltrianyl,escoprim,esteprim,eusaprim,fectrim,gantaprim,gantaprin,gantrim,groprim,helveprim,imexim,jenamoxazol,kemoprim,kepinol,kepinol forte,laratrim,linaris,maxtrim,microtrim,microtrim forte,mikrosid,momentol,oecotrim,oriprim,oxaprim,pantoprim,polymyxin e,polymyxin e. sulfate,primazole,promixin,septra,septra ds,septra grape,septrim,septrin,servitrim,sigaprim,sigaprin,sulfatrim pediatric,sulfotrim,sulfotrimin,sulmeprim pediatric,sulprim,sumetrolim,supracombin,suprim,tacumil,teleprim,teleprin,thiocuran,totazina,tribakin,trifen,trigonyl,trimesulf,trimetho comp,trimethoprimsulfa,trimetoger,trimexazol,trimforte,trimosulfa,uroplus,uroplus ds,uroplus ss" "101495-0,18998-5,20387-7,23631-5,25273-4,32342-8,4081-6,515-7,516-5,517-3,518-1,7057-3"
"SXT" 358641 "Trimethoprim/sulfamethoxazole" "Trimethoprims" "J01EE01" "Sulfonamides and trimethoprim" "Combinations of sulfonamides and trimethoprim, incl. derivatives" "cot,cotrim,sxt,t/s,tms,trsu,trsx,ts" "abacin,abactrim,agoprim,alfatrim,aposulfatrim,bacteral,bacterial forte,bactilen,bactiver,bacton,bactoreduct,bactrim,bactrim ds,bactrim forte,bactrim pediatric,bactrimel,bactrizol,bactromin,bactropin,baktar,belcomycine,berlocid,bibacrim,biseptol,chemitrim,chemotrim,ciplin,colimycin,colimycin sulphate,colisticin,colistimethate,colistimethate sodium,colistin sulfate,colistin sulphate,colomycin,coly-mycin,cotribene,cotrim d.s.,cotrim eu rho,cotrim holsen,cotrim.l.u.t.,cotrimaxazol,cotrimazole,cotrimhexal,cotrimoxazol,cotrimoxazol al,cotrimoxazole,cotrimstada,cotriver,dibaprim,drylin,duratrimet,eltrianyl,escoprim,esteprim,eusaprim,fectrim,gantaprim,gantaprin,gantrim,groprim,helveprim,imexim,jenamoxazol,kemoprim,kepinol,kepinol forte,laratrim,linaris,maxtrim,microtrim,microtrim forte,mikrosid,momentol,oecotrim,oriprim,oxaprim,pantoprim,polymyxin e,polymyxin e. sulfate,primazole,promixin,septra,septra ds,septra grape,septrim,septrin,servitrim,sigaprim,sigaprin,sulfatrim pediatric,sulfotrim,sulfotrimin,sulmeprim pediatric,sulprim,sumetrolim,supracombin,suprim,tacumil,teleprim,teleprin,thiocuran,totazina,tribakin,trifen,trigonyl,trimesulf,trimetho comp,trimethoprimsulfa,trimetoger,trimexazol,trimforte,trimosulfa,uroplus,uroplus ds,uroplus ss" "101495-0,18998-5,20387-7,23631-5,25273-4,32342-8,4081-6,515-7,516-5,517-3,518-1,7057-3"
"TRL" 202225 "Troleandomycin" "Macrolides/lincosamides" "J01FA08" "Macrolides, lincosamides and streptogramins" "Macrolides" "" "acetyloleandomycin,aovine,cyclamycin,evramicina,matromicina,matromycin t,micotil,oleandocetine,oleandomycin,t.a.o.,treolmicina,tribiocillina,triocetin,triolan,troleandomicina,troleandomycin,troleandomycine,troleandomycinum,viamicina,wytrion" 1 "g" "18999-3,519-9,520-7,521-5,522-3"
"TRO" 55886 "Trospectomycin" "Other antibacterials" "NA" "" "rubidiumnitrate,trospectinomycin,trospectomicina,trospectomycin,trospectomycine,trospectomycinum" ""
"TVA" 62959 "Trovafloxacin" "Quinolones" "J01MA13" "Quinolone antibacterials" "Fluoroquinolones" "trov" "trovafloxacin,trovan" 0.2 "g" 0.2 "g" "23642-2,23643-0,35855-6,7058-1"
"TUL" 9832301 "Tulathromycin" "Macrolides/lincosamides" "NA" "" "draxxin,tulathrmycin a,tulathromycin,tulathromycin a" "76149-4,87798-5"
"TYL" 5280440 "Tylosin" "Macrolides/lincosamides" "NA" "" "fradizine,tilosina,tylocine,tylosin,tylosin a,tylosine,tylosinum" "35856-4,35857-2,35858-0,87587-2"
"TYL1" 6441094 "Tylvalosin" "Macrolides/lincosamides" "NA" "tvn" "tylvalosin" "101526-2,87586-4"
"TUL" 9832301 "Tulathromycin" "Macrolides/lincosamides" "QJ01FA94" "" "draxxin,tulathrmycin a,tulathromycin,tulathromycin a" "76149-4,87798-5"
"TYL" 5280440 "Tylosin" "Macrolides/lincosamides" "QJ01FA90,QJ51FA90" "" "fradizine,tilosina,tylocine,tylosin,tylosin a,tylosine,tylosinum" "35856-4,35857-2,35858-0,87587-2"
"TYL1" 6441094 "Tylvalosin" "Macrolides/lincosamides" "QJ01FA92" "tvn" "tylvalosin" "101526-2,87586-4"
"PRU1" 124225 "Ulifloxacin (Prulifloxacin)" "Other antibacterials" "NA" "" "ulifloxacin" ""
"VAN" 14969 "Vancomycin" "Glycopeptides" "A07AA09,J01XA01,S01AA28" "Other antibacterials" "Glycopeptide antibacterials" "va,van,vanc" "vancocin,vancocin hcl,vancoled,vancomicina,vancomycin,vancomycin hcl,vancomycine,vancomycinum,vancor,viomycin derivative" 2 "g" 2 "g" "13586-3,13587-1,19000-9,20578-1,23615-8,25228-8,31012-8,39092-2,39796-8,39797-6,4089-9,4090-7,4091-5,4092-3,50938-0,523-1,524-9,525-6,526-4,59381-4,7059-9,92241-9,97657-1"
"VAM" "Vancomycin-macromethod" "Glycopeptides" "NA" "" "" ""
Binary file not shown.
Binary file not shown.
Binary file not shown.
+8937 -2341
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1 +1 @@
c4a5519e0ecc74220fc768e944a372f7
10fd88018ca098a76a8b1e9c86d2e40c

Some files were not shown because too many files have changed in this diff Show More