mirror of
https://github.com/msberends/AMR.git
synced 2025-03-13 07:23:00 +01:00
Compare commits
2 Commits
6c3ab19e3a
...
916df6e90c
Author | SHA1 | Date | |
---|---|---|---|
916df6e90c | |||
00496e45b7 |
38
.github/workflows/check.yaml
vendored
38
.github/workflows/check.yaml
vendored
@ -52,7 +52,7 @@ jobs:
|
||||
config:
|
||||
- {os: macOS-latest, r: 'devel', allowfail: true}
|
||||
- {os: macOS-latest, r: 'release', allowfail: false}
|
||||
- {os: macOS-latest, r: 'oldrel', allowfail: false}
|
||||
- {os: macOS-latest, r: 'oldrel', allowfail: true}
|
||||
|
||||
- {os: windows-latest, r: 'devel', allowfail: false}
|
||||
- {os: windows-latest, r: 'release', allowfail: false}
|
||||
@ -89,18 +89,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r@master
|
||||
- uses: r-lib/actions/setup-r@v1
|
||||
with:
|
||||
r-version: ${{ matrix.config.r }}
|
||||
|
||||
# - uses: r-lib/actions/setup-pandoc@master
|
||||
|
||||
# - name: Query dependencies
|
||||
# if: matrix.config.r != '3.0'
|
||||
# run: |
|
||||
# saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
|
||||
# shell: Rscript {0}
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: runner.os == 'Linux'
|
||||
# update the below with sysreqs::sysreqs("DESCRIPTION") and check the "DEB" entries (for Ubuntu).
|
||||
@ -108,13 +100,13 @@ jobs:
|
||||
run: |
|
||||
sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev
|
||||
|
||||
- name: Cache R packages
|
||||
- name: Restore cached R packages
|
||||
# this step will add the step 'Post Restore cached R packages' on a succesful run
|
||||
if: runner.os != 'Windows'
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ env.R_LIBS_USER }}
|
||||
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3
|
||||
restore-keys: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3
|
||||
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4
|
||||
|
||||
- name: Update AMR package dependencies
|
||||
run: |
|
||||
@ -122,7 +114,7 @@ jobs:
|
||||
source("data-raw/_install_deps.R")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Session info
|
||||
- name: Show session info
|
||||
run: |
|
||||
options(width = 100)
|
||||
utils::sessionInfo()
|
||||
@ -137,8 +129,9 @@ jobs:
|
||||
_R_CHECK_DEPENDS_ONLY_: true
|
||||
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
||||
R_LIBS_USER: ${{ env.R_LIBS_USER }}
|
||||
R_TINYTEST: true
|
||||
# during 'R CMD check', R_LIBS_USER will be overwritten, so:
|
||||
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
|
||||
R_RUN_TINYTEST: true
|
||||
run: |
|
||||
tar -xf data-raw/AMR_latest.tar.gz
|
||||
rm -rf AMR/vignettes
|
||||
@ -153,8 +146,9 @@ jobs:
|
||||
_R_CHECK_DEPENDS_ONLY_: true
|
||||
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
||||
R_LIBS_USER: ${{ env.R_LIBS_USER }}
|
||||
R_TINYTEST: true
|
||||
# during 'R CMD check', R_LIBS_USER will be overwritten, so:
|
||||
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
|
||||
R_RUN_TINYTEST: true
|
||||
run: |
|
||||
tar -xf data-raw/AMR_latest.tar.gz
|
||||
rm -rf AMR/vignettes
|
||||
@ -167,9 +161,9 @@ jobs:
|
||||
find . -name 'tinytest.Rout*' -exec cat '{}' \; || true
|
||||
shell: bash
|
||||
|
||||
- name: Upload check results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@master
|
||||
- name: Upload artifacts
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
|
||||
name: artifacts-${{ matrix.config.os }}-r${{ matrix.config.r }}
|
||||
path: AMR.Rcheck
|
||||
|
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 1.6.0.9038
|
||||
Date: 2021-05-15
|
||||
Version: 1.6.0.9041
|
||||
Date: 2021-05-16
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
@ -57,7 +57,7 @@ Suggests:
|
||||
skimr,
|
||||
tidyr,
|
||||
tinytest,
|
||||
xml2,
|
||||
xml2
|
||||
VignetteBuilder: knitr,rmarkdown
|
||||
URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR
|
||||
BugReports: https://github.com/msberends/AMR/issues
|
||||
|
7
NEWS.md
7
NEWS.md
@ -1,12 +1,12 @@
|
||||
# `AMR` 1.6.0.9035
|
||||
## <small>Last updated: 15 May 2021</small>
|
||||
# `AMR` 1.6.0.9041
|
||||
## <small>Last updated: 16 May 2021</small>
|
||||
|
||||
### New
|
||||
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
||||
* Function `italicise_taxonomy()` to make taxonomic names within a string italic, with support for markdown and ANSI
|
||||
* Support for all four methods to determine first isolates as summarised by Hindler *et al.* (doi: [10.1086/511864](https://doi.org/10.1086/511864)): isolate-based, patient-based, episode-based and phenotype-based. The last method is now the default.
|
||||
* The `first_isolate()` function gained the argument `method` that has to be "phenotype-based", "episode-based", "patient-based", or "isolate-based". The old behaviour is equal to "episode-based". The new default is "phenotype-based" if antimicrobial test results are available, and "episode-based" otherwise. This new default will yield slightly more isolates for selection (which is a good thing).
|
||||
* Since fungal isolates can also be selected, the functions `key_antibiotics()` and `key_antibiotics_equal()` are now deprecated in favour of the `key_antimicrobials()` and `antimicrobial_equal()` functions. Also, the new `all_antimicrobials()` function works like the old `key_antibiotics()` function, but includes any column with antimicrobial test results. Using `key_antimicrobials()` still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new `antifungal` argument to set antifungal agents (antimycotics).
|
||||
* Since fungal isolates can also be selected, the functions `key_antibiotics()` and `key_antibiotics_equal()` are now deprecated in favour of the `key_antimicrobials()` and `antimicrobials_equal()` functions. Also, the new `all_antimicrobials()` function works like the old `key_antibiotics()` function, but includes any column with antimicrobial test results. Using `key_antimicrobials()` still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new `antifungal` argument to set antifungal agents (antimycotics).
|
||||
* Using `type == "points"` in the `first_isolate()` function for phenotype-based selection will now consider all antimicrobial drugs in the data set, using the new `all_antimicrobials()`
|
||||
* The `first_isolate()` function can now take a vector of values for `col_keyantibiotics` and can have an episode length of `Inf`
|
||||
* Since the phenotype-based method is the new default, `filter_first_isolate()` renders the `filter_first_weighted_isolate()` function redundant. For this reason, `filter_first_weighted_isolate()` is now deprecated.
|
||||
@ -41,6 +41,7 @@
|
||||
* Updated `skimr::skim()` usage for MIC values to also include 25th and 75th percentiles
|
||||
* Fix for plotting missing MIC/disk diffusion values
|
||||
* Updated join functions to always use `dplyr` join functions if the `dplyr` package is installed - now also preserving grouped variables
|
||||
* Fix for filtering on antibiotic classes (such as `filter_cephalosporins()`)
|
||||
|
||||
### Other
|
||||
* All unit tests are now processed by the `tinytest` package, instead of the `testthat` package. The `testthat` package unfortunately requires tons of dependencies that are also heavy and only usable for recent R versions, defeating the purpose to test our package under less recent R versions. On the contrary, the `tinytest` package is very lightweight and dependency-free.
|
||||
|
@ -125,11 +125,11 @@ filter_ab_class <- function(x,
|
||||
group %like% ab_class |
|
||||
atc_group1 %like% ab_class |
|
||||
atc_group2 %like% ab_class)
|
||||
ab_group <- find_ab_group(ab_class)
|
||||
if (ab_group == "") {
|
||||
if (nrow(ab_reference) == 0) {
|
||||
message_("Unknown antimicrobial class '", ab_class.bak, "', data left unchanged.")
|
||||
return(x.bak)
|
||||
}
|
||||
ab_group <- find_ab_group(ab_class.bak)
|
||||
# get the columns with a group names in the chosen ab class
|
||||
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
||||
if (length(agents) == 0) {
|
||||
|
@ -435,7 +435,7 @@ first_isolate <- function(x = NULL,
|
||||
if (length(c(row.start:row.end)) == pm_n_distinct(x[c(row.start:row.end), col_mo, drop = TRUE])) {
|
||||
if (info == TRUE) {
|
||||
message_("=> Found ", font_bold(paste(length(c(row.start:row.end)), "first isolates")),
|
||||
", as all isolates were different microorganisms",
|
||||
", as all isolates were different microbial species",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
}
|
||||
|
2
R/mdro.R
2
R/mdro.R
@ -306,7 +306,7 @@ mdro <- function(x = NULL,
|
||||
}
|
||||
if (is.null(col_mo) & guideline$code == "tb") {
|
||||
message_("No column found as input for `col_mo`, ",
|
||||
font_bold(paste0("assuming all records contain", font_italic("Mycobacterium tuberculosis"), ".")))
|
||||
font_bold(paste0("assuming all rows contain ", font_italic("Mycobacterium tuberculosis"), ".")))
|
||||
x$mo <- as.mo("Mycobacterium tuberculosis") # consider overkill at all times: MO_lookup[which(MO_lookup$fullname == "Mycobacterium tuberculosis"), "mo", drop = TRUE]
|
||||
col_mo <- "mo"
|
||||
}
|
||||
|
Binary file not shown.
@ -26,7 +26,7 @@
|
||||
pkg_suggests <- AMR:::trimws(unlist(strsplit(packageDescription("AMR")$Suggests, ",(\n)?")))
|
||||
|
||||
to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())]
|
||||
to_update <- as.data.frame(old.packages(), stringsAsFactors = FALSE)
|
||||
to_update <- as.data.frame(utils::old.packages(repos = "https://cran.rstudio.com/"), stringsAsFactors = FALSE)
|
||||
|
||||
for (i in seq_len(length(to_install))) {
|
||||
cat("Installing package", to_install[i], "\n")
|
||||
@ -37,11 +37,9 @@ for (i in seq_len(length(to_install))) {
|
||||
}
|
||||
|
||||
for (i in seq_len(length(to_update))) {
|
||||
cat("Updating package", to_install[i], "\n")
|
||||
cat("Updating package", to_update[i], "\n")
|
||||
tryCatch(update.packages(to_update[i], repos = "https://cran.rstudio.com/", ask = FALSE),
|
||||
# message = function(m) invisible(),
|
||||
warning = function(w) message(w$message),
|
||||
error = function(e) message(e$message))
|
||||
}
|
||||
|
||||
# saveRDS(to_update, ".github/depends.Rds", version = 2)
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9031</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9031</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="fas fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
<span class="fas fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
<span class="fas fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
<span class="fas fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fa fa-database"></span>
|
||||
<span class="fas fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fa fa-compress"></span>
|
||||
<span class="fas fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
<span class="fas fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
<span class="fas fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
<span class="fas fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fa fa-book-open"></span>
|
||||
<span class="fas fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
<span class="fas fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
<span class="far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
<span class="fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@ -187,13 +187,12 @@
|
||||
|
||||
|
||||
|
||||
</header><link href="datasets_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="datasets_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
</header><script src="datasets_files/header-attrs-2.7/header-attrs.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>Data sets for download / own use</h1>
|
||||
|
||||
<h4 class="date">27 April 2021</h4>
|
||||
<h4 class="date">16 May 2021</h4>
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>datasets.Rmd</code></div>
|
||||
@ -212,7 +211,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#microorganisms-currently-accepted-names" class="anchor"></a>Microorganisms (currently accepted names)</h2>
|
||||
<p>A data set with 70,026 rows and 16 columns, containing the following column names:<br><em>mo</em>, <em>fullname</em>, <em>kingdom</em>, <em>phylum</em>, <em>class</em>, <em>order</em>, <em>family</em>, <em>genus</em>, <em>species</em>, <em>subspecies</em>, <em>rank</em>, <em>ref</em>, <em>species_id</em>, <em>source</em>, <em>prevalence</em> and <em>snomed</em>.</p>
|
||||
<p>This data set is in R available as <code>microorganisms</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.html">here</a>.</p>
|
||||
<p>It was last updated on 11 March 2021 20:59:32 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/microorganisms.rds">R file</a> (2.2 MB)<br>
|
||||
@ -433,7 +432,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<p>A data set with 14,100 rows and 4 columns, containing the following column names:<br><em>fullname</em>, <em>fullname_new</em>, <em>ref</em> and <em>prevalence</em>.</p>
|
||||
<p><strong>Note:</strong> remember that the ‘ref’ columns contains the scientific reference to the old taxonomic entries, i.e. of column <em>‘fullname’</em>. For the scientific reference of the new names, i.e. of column <em>‘fullname_new’</em>, see the <code>microorganisms</code> data set.</p>
|
||||
<p>This data set is in R available as <code>microorganisms.old</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.old.html">here</a>.</p>
|
||||
<p>It was last updated on 5 March 2021 09:46:55 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.old.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/microorganisms.old.rds">R file</a> (0.2 MB)<br>
|
||||
@ -498,7 +497,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#antibiotic-agents" class="anchor"></a>Antibiotic agents</h2>
|
||||
<p>A data set with 456 rows and 14 columns, containing the following column names:<br><em>ab</em>, <em>atc</em>, <em>cid</em>, <em>name</em>, <em>group</em>, <em>atc_group1</em>, <em>atc_group2</em>, <em>abbreviations</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em>, <em>iv_units</em> and <em>loinc</em>.</p>
|
||||
<p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p>It was last updated on 4 May 2021 13:38:27 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (32 kB)<br>
|
||||
@ -666,7 +665,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#antiviral-agents" class="anchor"></a>Antiviral agents</h2>
|
||||
<p>A data set with 102 rows and 9 columns, containing the following column names:<br><em>atc</em>, <em>cid</em>, <em>name</em>, <em>atc_group</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em> and <em>iv_units</em>.</p>
|
||||
<p>This data set is in R available as <code>antivirals</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p>It was last updated on 29 August 2020 19:53:07 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antivirals.rds">R file</a> (5 kB)<br>
|
||||
@ -793,7 +792,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#intrinsic-bacterial-resistance" class="anchor"></a>Intrinsic bacterial resistance</h2>
|
||||
<p>A data set with 93,892 rows and 2 columns, containing the following column names:<br><em>microorganism</em> and <em>antibiotic</em>.</p>
|
||||
<p>This data set is in R available as <code>intrinsic_resistant</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</p>
|
||||
<p>It was last updated on 5 March 2021 09:46:55 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/intrinsic_resistant.rds">R file</a> (69 kB)<br>
|
||||
@ -1008,7 +1007,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#interpretation-from-mic-values-disk-diameters-to-rsi" class="anchor"></a>Interpretation from MIC values / disk diameters to R/SI</h2>
|
||||
<p>A data set with 20,486 rows and 10 columns, containing the following column names:<br><em>guideline</em>, <em>method</em>, <em>site</em>, <em>mo</em>, <em>ab</em>, <em>ref_tbl</em>, <em>disk_dose</em>, <em>breakpoint_S</em>, <em>breakpoint_R</em> and <em>uti</em>.</p>
|
||||
<p>This data set is in R available as <code>rsi_translation</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/rsi_translation.html">here</a>.</p>
|
||||
<p>It was last updated on 5 March 2021 09:46:55 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/rsi_translation.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.rds">R file</a> (34 kB)<br>
|
||||
@ -1138,7 +1137,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#dosage-guidelines-from-eucast" class="anchor"></a>Dosage guidelines from EUCAST</h2>
|
||||
<p>A data set with 169 rows and 9 columns, containing the following column names:<br><em>ab</em>, <em>name</em>, <em>type</em>, <em>dose</em>, <em>dose_times</em>, <em>administration</em>, <em>notes</em>, <em>original_txt</em> and <em>eucast_version</em>.</p>
|
||||
<p>This data set is in R available as <code>dosage</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/dosage.html">here</a>.</p>
|
||||
<p>It was last updated on 25 January 2021 20:58:20 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/dosage.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.rds">R file</a> (3 kB)<br>
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9031</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9031</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9031</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9031</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,12 +236,12 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1609031" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0.9031">
|
||||
<a href="#amr-1609031" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9031</h1>
|
||||
<div id="last-updated-15-may-2021" class="section level2">
|
||||
<div id="amr-1609041" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0.9041">
|
||||
<a href="#amr-1609041" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9041</h1>
|
||||
<div id="last-updated-16-may-2021" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-15-may-2021" class="anchor"></a><small>Last updated: 15 May 2021</small>
|
||||
<a href="#last-updated-16-may-2021" class="anchor"></a><small>Last updated: 16 May 2021</small>
|
||||
</h2>
|
||||
<div id="new" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -253,7 +253,7 @@
|
||||
<li>Support for all four methods to determine first isolates as summarised by Hindler <em>et al.</em> (doi: <a href="https://doi.org/10.1086/511864">10.1086/511864</a>): isolate-based, patient-based, episode-based and phenotype-based. The last method is now the default.
|
||||
<ul>
|
||||
<li>The <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function gained the argument <code>method</code> that has to be “phenotype-based”, “episode-based”, “patient-based”, or “isolate-based”. The old behaviour is equal to “episode-based”. The new default is “phenotype-based” if antimicrobial test results are available, and “episode-based” otherwise. This new default will yield slightly more isolates for selection (which is a good thing).</li>
|
||||
<li>Since fungal isolates can also be selected, the functions <code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code> and <code><a href="../reference/AMR-deprecated.html">key_antibiotics_equal()</a></code> are now deprecated in favour of the <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> and <code>antimicrobial_equal()</code> functions. Also, the new <code><a href="../reference/key_antimicrobials.html">all_antimicrobials()</a></code> function works like the old <code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code> function, but includes any column with antimicrobial test results. Using <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new <code>antifungal</code> argument to set antifungal agents (antimycotics).</li>
|
||||
<li>Since fungal isolates can also be selected, the functions <code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code> and <code><a href="../reference/AMR-deprecated.html">key_antibiotics_equal()</a></code> are now deprecated in favour of the <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> and <code><a href="../reference/key_antimicrobials.html">antimicrobials_equal()</a></code> functions. Also, the new <code><a href="../reference/key_antimicrobials.html">all_antimicrobials()</a></code> function works like the old <code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code> function, but includes any column with antimicrobial test results. Using <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new <code>antifungal</code> argument to set antifungal agents (antimycotics).</li>
|
||||
<li>Using <code>type == "points"</code> in the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function for phenotype-based selection will now consider all antimicrobial drugs in the data set, using the new <code><a href="../reference/key_antimicrobials.html">all_antimicrobials()</a></code>
|
||||
</li>
|
||||
<li>The <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function can now take a vector of values for <code>col_keyantibiotics</code> and can have an episode length of <code>Inf</code>
|
||||
@ -306,6 +306,7 @@
|
||||
<li>Updated <code><a href="https://docs.ropensci.org/skimr/reference/skim.html">skimr::skim()</a></code> usage for MIC values to also include 25th and 75th percentiles</li>
|
||||
<li>Fix for plotting missing MIC/disk diffusion values</li>
|
||||
<li>Updated join functions to always use <code>dplyr</code> join functions if the <code>dplyr</code> package is installed - now also preserving grouped variables</li>
|
||||
<li>Fix for filtering on antibiotic classes (such as <code><a href="../reference/filter_ab_class.html">filter_cephalosporins()</a></code>)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="other" class="section level3">
|
||||
|
@ -12,7 +12,7 @@ articles:
|
||||
datasets: datasets.html
|
||||
resistance_predict: resistance_predict.html
|
||||
welcome_to_AMR: welcome_to_AMR.html
|
||||
last_built: 2021-05-15T19:35Z
|
||||
last_built: 2021-05-16T08:48Z
|
||||
urls:
|
||||
reference: https://msberends.github.io/AMR//reference
|
||||
article: https://msberends.github.io/AMR//articles
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9031</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9031</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9041</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -133,7 +133,9 @@ echo
|
||||
echo "•••••••••••••••••"
|
||||
echo "• Building site •"
|
||||
echo "•••••••••••••••••"
|
||||
Rscript -e "suppressMessages(pkgdown::build_site(lazy = $lazy, examples = FALSE))"
|
||||
Rscript -e "suppressMessages(pkgdown::build_site(lazy = $lazy, examples = FALSE, install = FALSE))"
|
||||
# always rebuild datasets vignette
|
||||
Rscript -e "pkgdown::build_article('datasets', lazy = FALSE, quiet = TRUE)"
|
||||
# add the survey page
|
||||
Rscript -e "source('data-raw/create_survey_page.R')"
|
||||
echo
|
||||
|
@ -23,33 +23,33 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
expect_equal(percentage(0.25), "25%")
|
||||
expect_equal(percentage(0.5), "50%")
|
||||
expect_equal(percentage(0.500, digits = 1), "50.0%")
|
||||
expect_equal(percentage(0.1234), "12.3%")
|
||||
expect_equal(AMR:::percentage(0.25), "25%")
|
||||
expect_equal(AMR:::percentage(0.5), "50%")
|
||||
expect_equal(AMR:::percentage(0.500, digits = 1), "50.0%")
|
||||
expect_equal(AMR:::percentage(0.1234), "12.3%")
|
||||
# round up 0.5
|
||||
expect_equal(percentage(0.0054), "0.5%")
|
||||
expect_equal(percentage(0.0055), "0.6%")
|
||||
expect_equal(AMR:::percentage(0.0054), "0.5%")
|
||||
expect_equal(AMR:::percentage(0.0055), "0.6%")
|
||||
|
||||
expect_equal(strrep("A", 5), "AAAAA")
|
||||
expect_equal(strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))
|
||||
expect_equal(trimws(" test "), "test")
|
||||
expect_equal(trimws(" test ", "l"), "test ")
|
||||
expect_equal(trimws(" test ", "r"), " test")
|
||||
expect_equal(AMR:::strrep("A", 5), "AAAAA")
|
||||
expect_equal(AMR:::strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))
|
||||
expect_equal(AMR:::trimws(" test "), "test")
|
||||
expect_equal(AMR:::trimws(" test ", "l"), "test ")
|
||||
expect_equal(AMR:::trimws(" test ", "r"), " test")
|
||||
|
||||
expect_warning(generate_warning_abs_missing(c("AMP", "AMX")))
|
||||
expect_warning(generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
|
||||
expect_warning(get_column_abx(example_isolates, hard_dependencies = "FUS"))
|
||||
expect_message(get_column_abx(example_isolates, soft_dependencies = "FUS"))
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
expect_warning(get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
|
||||
expect_warning(get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
|
||||
expect_warning(AMR:::generate_warning_abs_missing(c("AMP", "AMX")))
|
||||
expect_warning(AMR:::generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
|
||||
expect_warning(AMR:::get_column_abx(example_isolates, hard_dependencies = "FUS"))
|
||||
expect_message(AMR:::get_column_abx(example_isolates, soft_dependencies = "FUS"))
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
|
||||
expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
|
||||
}
|
||||
|
||||
|
||||
# we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this:
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
expect_true(is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id)))
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id)))
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,20 +23,20 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
expect_true(example_isolates %>% select(aminoglycosides()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(carbapenems()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_1st()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_2nd()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_3rd()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_4th()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_5th()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(fluoroquinolones()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(glycopeptides()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(macrolides()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(oxazolidinones()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(penicillins()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(tetracyclines()) %>% ncol() < ncol(example_isolates))
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_true(example_isolates %>% select(aminoglycosides()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(carbapenems()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_1st()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_2nd()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_3rd()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_4th()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(cephalosporins_5th()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(fluoroquinolones()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(glycopeptides()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(macrolides()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(oxazolidinones()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(penicillins()) %>% ncol() < ncol(example_isolates))
|
||||
expect_true(example_isolates %>% select(tetracyclines()) %>% ncol() < ncol(example_isolates))
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,6 @@
|
||||
|
||||
b <- suppressWarnings(bug_drug_combinations(example_isolates))
|
||||
expect_inherits(b, "bug_drug_combinations")
|
||||
expect_stdout(print(b))
|
||||
expect_stdout(suppressMessages(print(b)))
|
||||
expect_true(is.data.frame(format(b)))
|
||||
expect_true(is.data.frame(format(b, combine_IR = TRUE, add_ab_group = FALSE)))
|
||||
|
@ -38,9 +38,9 @@ expect_equal(suppressWarnings(count_S(example_isolates$AMX)) + count_I(example_i
|
||||
|
||||
|
||||
# warning for speed loss
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(count_resistant(as.character(example_isolates$AMC)))
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(count_resistant(example_isolates$AMC,
|
||||
as.character(example_isolates$GEN)))
|
||||
|
||||
@ -53,7 +53,7 @@ expect_error(count_susceptible("test", as_percent = "test"))
|
||||
expect_error(count_df(c("A", "B", "C")))
|
||||
expect_error(count_df(example_isolates[, "date"]))
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_equal(example_isolates %>% count_susceptible(AMC), 1433)
|
||||
expect_equal(example_isolates %>% count_susceptible(AMC, GEN, only_all_tested = TRUE), 1687)
|
||||
expect_equal(example_isolates %>% count_susceptible(AMC, GEN, only_all_tested = FALSE), 1764)
|
||||
|
@ -23,7 +23,7 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
expect_true(check_dataset_integrity()) # in misc.R
|
||||
expect_true(AMR:::check_dataset_integrity()) # in misc.R
|
||||
|
||||
# IDs should always be unique
|
||||
expect_identical(nrow(microorganisms), length(unique(microorganisms$mo)))
|
||||
@ -34,14 +34,14 @@ expect_identical(class(antibiotics$ab), c("ab", "character"))
|
||||
# check cross table reference
|
||||
expect_true(all(microorganisms.codes$mo %in% microorganisms$mo))
|
||||
expect_true(all(example_isolates$mo %in% microorganisms$mo))
|
||||
expect_true(all(microorganisms.translation$mo_new %in% microorganisms$mo))
|
||||
expect_true(all(AMR:::microorganisms.translation$mo_new %in% microorganisms$mo))
|
||||
expect_false(any(AMR:::microorganisms.translation$mo_old %in% microorganisms$mo))
|
||||
expect_true(all(rsi_translation$mo %in% microorganisms$mo))
|
||||
expect_true(all(rsi_translation$ab %in% antibiotics$ab))
|
||||
expect_true(all(intrinsic_resistant$microorganism %in% microorganisms$fullname)) # also important for mo_is_intrinsic_resistant()
|
||||
expect_true(all(intrinsic_resistant$antibiotic %in% antibiotics$name))
|
||||
expect_false(any(is.na(microorganisms.codes$code)))
|
||||
expect_false(any(is.na(microorganisms.codes$mo)))
|
||||
expect_false(any(microorganisms.translation$mo_old %in% microorganisms$mo))
|
||||
expect_true(all(dosage$ab %in% antibiotics$ab))
|
||||
expect_true(all(dosage$name %in% antibiotics$name))
|
||||
|
||||
@ -52,7 +52,7 @@ expect_identical(as.ab(antibiotics$name), antibiotics$ab)
|
||||
datasets <- data(package = "AMR", envir = asNamespace("AMR"))$results[, "Item"]
|
||||
for (i in seq_len(length(datasets))) {
|
||||
dataset <- get(datasets[i], envir = asNamespace("AMR"))
|
||||
expect_identical(dataset_UTF8_to_ASCII(dataset), dataset, info = datasets[i])
|
||||
expect_identical(AMR:::dataset_UTF8_to_ASCII(dataset), dataset, info = datasets[i])
|
||||
}
|
||||
|
||||
df <- AMR:::MO_lookup
|
||||
@ -76,7 +76,7 @@ expect_stdout(print(catalogue_of_life_version()))
|
||||
uncategorised <- subset(microorganisms,
|
||||
genus == "Staphylococcus" &
|
||||
!species %in% c("", "aureus") &
|
||||
!mo %in% c(MO_CONS, MO_COPS))
|
||||
!mo %in% c(AMR:::MO_CONS, AMR:::MO_COPS))
|
||||
expect_true(NROW(uncategorised) == 0,
|
||||
info = ifelse(NROW(uncategorised) == 0,
|
||||
"All staphylococcal species categorised as CoNS/CoPS.",
|
||||
|
@ -43,13 +43,13 @@ expect_silent(barplot(as.disk(c(10, 20, 40))))
|
||||
expect_silent(plot(as.disk(c(10, 20, 40))))
|
||||
expect_silent(plot(as.disk(c(10, 20, 40)), expand = FALSE))
|
||||
expect_silent(plot(as.disk(c(10, 20, 40)), mo = "esco", ab = "cipr"))
|
||||
if (suppressWarnings(require("ggplot2"))) {
|
||||
if (pkg_is_available("ggplot2")) {
|
||||
expect_inherits(ggplot(as.disk(c(10, 20, 40))), "gg")
|
||||
expect_inherits(ggplot(as.disk(c(10, 20, 40)), expand = FALSE), "gg")
|
||||
expect_inherits(ggplot(as.disk(c(10, 20, 40)), mo = "esco", ab = "cipr"), "gg")
|
||||
}
|
||||
expect_stdout(print(as.disk(12)))
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_stdout(print(tibble(d = as.disk(12))))
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ test_df <- rbind(
|
||||
expect_equal(get_episode(test_df$date, 365),
|
||||
c(1, 1, 2, 2, 2, 3, 3, 4, 1, 2, 2, 2, 3))
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_identical(test_df %>% group_by(patient_id) %>% mutate(f = is_new_episode(date, 365)) %>% pull(f),
|
||||
c(TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE))
|
||||
|
||||
|
@ -24,15 +24,15 @@
|
||||
# ==================================================================== #
|
||||
|
||||
# thoroughly check input table
|
||||
expect_equal(colnames(eucast_rules_file),
|
||||
expect_equal(colnames(AMR:::eucast_rules_file),
|
||||
c("if_mo_property", "like.is.one_of", "this_value",
|
||||
"and_these_antibiotics", "have_these_values",
|
||||
"then_change_these_antibiotics", "to_value",
|
||||
"reference.rule", "reference.rule_group",
|
||||
"reference.version",
|
||||
"note"))
|
||||
MOs_mentioned <- unique(eucast_rules_file$this_value)
|
||||
MOs_mentioned <- sort(trimws(unlist(strsplit(MOs_mentioned[!is_valid_regex(MOs_mentioned)], ",", fixed = TRUE))))
|
||||
MOs_mentioned <- unique(AMR:::eucast_rules_file$this_value)
|
||||
MOs_mentioned <- sort(trimws(unlist(strsplit(MOs_mentioned[!AMR:::is_valid_regex(MOs_mentioned)], ",", fixed = TRUE))))
|
||||
MOs_test <- suppressWarnings(suppressMessages(mo_name(MOs_mentioned)))
|
||||
expect_true(length(MOs_mentioned[MOs_test != MOs_mentioned]) == 0)
|
||||
|
||||
@ -71,7 +71,7 @@ b <- data.frame(mo = c("Staphylococcus aureus",
|
||||
expect_equal(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)
|
||||
|
||||
# piperacillin must be R in Enterobacteriaceae when tica is R
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_equal(suppressWarnings(
|
||||
example_isolates %>%
|
||||
filter(mo_family(mo) == "Enterobacteriaceae") %>%
|
||||
@ -109,7 +109,7 @@ expect_equal(
|
||||
"S")
|
||||
|
||||
# also test norf
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_stdout(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"), info = TRUE)))
|
||||
}
|
||||
|
||||
|
@ -23,22 +23,22 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
expect_true(example_isolates %>% filter_ab_class("carbapenem") %>% nrow() > 0)
|
||||
expect_true(example_isolates %>% filter_aminoglycosides() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_carbapenems() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_cephalosporins() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_1st_cephalosporins() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_2nd_cephalosporins() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_3rd_cephalosporins() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_4th_cephalosporins() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_5th_cephalosporins() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_fluoroquinolones() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_glycopeptides() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_macrolides() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_oxazolidinones() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_penicillins() %>% ncol() > 0)
|
||||
expect_true(example_isolates %>% filter_tetracyclines() %>% ncol() > 0)
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_true(example_isolates %>% filter_ab_class("carbapenem") %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_aminoglycosides() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_carbapenems() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_cephalosporins() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_1st_cephalosporins() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_2nd_cephalosporins() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_3rd_cephalosporins() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_4th_cephalosporins() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_5th_cephalosporins() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_fluoroquinolones() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_glycopeptides() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_macrolides() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_oxazolidinones() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_penicillins() %>% nrow() < nrow(example_isolates))
|
||||
expect_true(example_isolates %>% filter_tetracyclines() %>% nrow() < nrow(example_isolates))
|
||||
|
||||
expect_true(example_isolates %>% filter_carbapenems("R", "all") %>% nrow() > 0)
|
||||
|
||||
|
@ -110,7 +110,7 @@ expect_error(first_isolate(example_isolates,
|
||||
col_date = "non-existing col",
|
||||
col_mo = "mo"))
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
# if mo is not an mo class, result should be the same
|
||||
expect_identical(example_isolates %>%
|
||||
mutate(mo = as.character(mo)) %>%
|
||||
@ -174,9 +174,7 @@ expect_identical(filter_first_isolate(example_isolates),
|
||||
|
||||
|
||||
# notice that all mo's are distinct, so all are TRUE
|
||||
expect_true(all(example_isolates %pm>%
|
||||
pm_distinct(mo, .keep_all = TRUE) %pm>%
|
||||
first_isolate(info = TRUE) == TRUE))
|
||||
expect_true(all(first_isolate(AMR:::pm_distinct(example_isolates, mo, .keep_all = TRUE), info = TRUE) == TRUE))
|
||||
|
||||
# only one isolate, so return fast
|
||||
expect_true(first_isolate(data.frame(mo = "Escherichia coli", date = Sys.Date(), patient = "patient"), info = TRUE))
|
||||
|
@ -23,7 +23,7 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
if (suppressWarnings(require("dplyr")) & suppressWarnings(require("ggplot2"))) {
|
||||
if (pkg_is_available("dplyr") & pkg_is_available("ggplot2")) {
|
||||
|
||||
pdf(NULL) # prevent Rplots.pdf being created
|
||||
|
||||
|
@ -27,7 +27,7 @@ expect_identical(italicise_taxonomy("test for E. coli"),
|
||||
"test for *E. coli*")
|
||||
expect_identical(italicise_taxonomy("test for E. coli"),
|
||||
italicize_taxonomy("test for E. coli"))
|
||||
if (has_colour()) {
|
||||
if (AMR:::has_colour()) {
|
||||
expect_identical(italicise_taxonomy("test for E. coli", type = "ansi"),
|
||||
"test for \033[3mE. coli\033[23m")
|
||||
}
|
||||
|
@ -24,12 +24,12 @@
|
||||
# ==================================================================== #
|
||||
|
||||
unjoined <- example_isolates
|
||||
inner <- example_isolates %>% inner_join_microorganisms()
|
||||
left <- example_isolates %>% left_join_microorganisms()
|
||||
semi <- example_isolates %>% semi_join_microorganisms()
|
||||
anti <- example_isolates %>% anti_join_microorganisms()
|
||||
suppressWarnings(right <- example_isolates %>% right_join_microorganisms())
|
||||
suppressWarnings(full <- example_isolates %>% full_join_microorganisms())
|
||||
inner <- inner_join_microorganisms(example_isolates)
|
||||
left <- left_join_microorganisms(example_isolates)
|
||||
semi <- semi_join_microorganisms(example_isolates)
|
||||
anti <- anti_join_microorganisms(example_isolates)
|
||||
suppressWarnings(right <- right_join_microorganisms(example_isolates))
|
||||
suppressWarnings(full <- full_join_microorganisms(example_isolates))
|
||||
|
||||
expect_true(ncol(unjoined) < ncol(inner))
|
||||
expect_true(nrow(unjoined) == nrow(inner))
|
||||
|
@ -232,7 +232,7 @@ expect_warning(mdro(example_isolates,
|
||||
info = FALSE))
|
||||
|
||||
# print groups
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_stdout(x <- mdro(example_isolates %>% group_by(hospital_id), info = TRUE))
|
||||
expect_stdout(x <- mdro(example_isolates %>% group_by(hospital_id), guideline = custom, info = TRUE))
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ expect_silent(barplot(as.mic(c(1, 2, 4, 8))))
|
||||
expect_silent(plot(as.mic(c(1, 2, 4, 8))))
|
||||
expect_silent(plot(as.mic(c(1, 2, 4, 8)), expand = FALSE))
|
||||
expect_silent(plot(as.mic(c(1, 2, 4, 8)), mo = "esco", ab = "cipr"))
|
||||
if (suppressWarnings(require("ggplot2"))) {
|
||||
if (pkg_is_available("ggplot2")) {
|
||||
expect_inherits(ggplot(as.mic(c(1, 2, 4, 8))), "gg")
|
||||
expect_inherits(ggplot(as.mic(c(1, 2, 4, 8)), expand = FALSE), "gg")
|
||||
expect_inherits(ggplot(as.mic(c(1, 2, 4, 8, 32)), mo = "esco", ab = "cipr"), "gg")
|
||||
@ -58,7 +58,7 @@ expect_stdout(print(as.mic(c(1, 2, 4, 8))))
|
||||
|
||||
expect_inherits(summary(as.mic(c(2, 8))), c("summaryDefault", "table"))
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_stdout(print(tibble(m = as.mic(2:4))))
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ expect_identical(as.character(as.mo("S. sanguinis", Lancefield = TRUE)), "B_S
|
||||
expect_identical(as.character(as.mo("S. salivarius", Lancefield = FALSE)), "B_STRPT_SLVR")
|
||||
expect_identical(as.character(as.mo("S. salivarius", Lancefield = TRUE)), "B_STRPT_GRPK") # group K
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
# select with one column
|
||||
expect_identical(
|
||||
example_isolates[1:10, ] %>%
|
||||
@ -273,7 +273,7 @@ expect_equal(as.character(as.mo(c("meningococ", "gonococ", "pneumococ"))),
|
||||
expect_equal(suppressWarnings(as.character(as.mo(c("yeasts", "fungi")))),
|
||||
c("F_YEAST", "F_FUNGUS"))
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
# print tibble
|
||||
expect_stdout(print(tibble(mo = as.mo("B_ESCHR_COLI"))))
|
||||
}
|
||||
@ -292,6 +292,6 @@ expect_equal(as.character(as.mo(c("E. coli", "E. coli ignorethis"), ignore_patte
|
||||
c("B_ESCHR_COLI", NA))
|
||||
|
||||
# frequency tables
|
||||
if (suppressWarnings(require("cleaner"))) {
|
||||
if (pkg_is_available("cleaner")) {
|
||||
expect_inherits(cleaner::freq(example_isolates$mo), "freq")
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ expect_equal(mo_is_intrinsic_resistant(c("Escherichia coli", "Staphylococcus aur
|
||||
# with reference data
|
||||
expect_equal(mo_name("test", reference_df = data.frame(col1 = "test", mo = "B_ESCHR_COLI")),
|
||||
"Escherichia coli")
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_equal(example_isolates %>% filter(mo_is_gram_negative()) %>% nrow(),
|
||||
730)
|
||||
expect_equal(example_isolates %>% filter(mo_is_gram_positive()) %>% nrow(),
|
||||
|
@ -42,12 +42,12 @@ expect_inherits(pca_model, "pca")
|
||||
|
||||
pdf(NULL) # prevent Rplots.pdf being created
|
||||
|
||||
if (suppressWarnings(require("ggplot2"))) {
|
||||
if (pkg_is_available("ggplot2")) {
|
||||
ggplot_pca(pca_model, ellipse = TRUE)
|
||||
ggplot_pca(pca_model, arrows_textangled = FALSE)
|
||||
}
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
resistance_data <- example_isolates %>%
|
||||
group_by(order = mo_order(mo),
|
||||
genus = mo_genus(mo)) %>%
|
||||
@ -56,7 +56,7 @@ if (suppressWarnings(require("dplyr"))) {
|
||||
pca(AMC, CXM, CTX, CAZ, GEN, TOB, TMP, "SXT")
|
||||
expect_inherits(pca_result, "prcomp")
|
||||
|
||||
if (suppressWarnings(require("ggplot2"))) {
|
||||
if (pkg_is_available("ggplot2")) {
|
||||
ggplot_pca(pca_result, ellipse = TRUE)
|
||||
ggplot_pca(pca_result, ellipse = FALSE, arrows_textangled = FALSE, scale = FALSE)
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ expect_equal(example_isolates %>% proportion_SI(AMC, GEN, only_all_tested = TRUE
|
||||
0.9382647,
|
||||
tolerance = 0.0001)
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
# percentages
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
@ -88,14 +88,14 @@ if (suppressWarnings(require("dplyr"))) {
|
||||
example_isolates$AMX %>% proportion_R())
|
||||
)
|
||||
}
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_R(as.character(example_isolates$AMC)))
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_S(as.character(example_isolates$AMC)))
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_S(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(n_rsi(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_equal(suppressWarnings(n_rsi(as.character(example_isolates$AMC,
|
||||
@ -120,11 +120,11 @@ expect_identical(suppressWarnings(proportion_S(example_isolates$AMX, minimum = n
|
||||
NA_real_)
|
||||
|
||||
# warning for speed loss
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_R(as.character(example_isolates$GEN)))
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_I(as.character(example_isolates$GEN)))
|
||||
reset_all_thrown_messages()
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_S(example_isolates$AMC, as.character(example_isolates$GEN)))
|
||||
expect_error(proportion_df(c("A", "B", "C")))
|
||||
expect_error(proportion_df(example_isolates[, "date"]))
|
||||
|
@ -23,7 +23,7 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_stdout(AMX_R <- example_isolates %>%
|
||||
filter(mo == "B_ESCHR_COLI") %>%
|
||||
rsi_predict(col_ab = "AMX",
|
||||
@ -43,7 +43,7 @@ expect_stdout(x <- suppressMessages(resistance_predict(example_isolates,
|
||||
info = TRUE)))
|
||||
pdf(NULL) # prevent Rplots.pdf being created
|
||||
expect_silent(plot(x))
|
||||
if (suppressWarnings(require("ggplot2"))) {
|
||||
if (pkg_is_available("ggplot2")) {
|
||||
expect_silent(ggplot_rsi_predict(x))
|
||||
expect_silent(ggplot(x))
|
||||
expect_error(ggplot_rsi_predict(example_isolates))
|
||||
|
@ -34,7 +34,7 @@ expect_inherits(unique(x[1], x[9]), "rsi")
|
||||
pdf(NULL) # prevent Rplots.pdf being created
|
||||
expect_silent(barplot(as.rsi(c("S", "I", "R"))))
|
||||
expect_silent(plot(as.rsi(c("S", "I", "R"))))
|
||||
if (suppressWarnings(require("ggplot2"))) expect_inherits(ggplot(as.rsi(c("S", "I", "R"))), "gg")
|
||||
if (pkg_is_available("ggplot2")) expect_inherits(ggplot(as.rsi(c("S", "I", "R"))), "gg")
|
||||
expect_stdout(print(as.rsi(c("S", "I", "R"))))
|
||||
expect_equal(as.character(as.rsi(c(1:3))), c("S", "I", "R"))
|
||||
expect_equal(suppressWarnings(as.logical(as.rsi("INVALID VALUE"))), NA)
|
||||
@ -49,7 +49,7 @@ expect_identical(as.logical(lapply(example_isolates, is.rsi.eligible)),
|
||||
expect_error(as.rsi.mic(as.mic(16)))
|
||||
expect_error(as.rsi.disk(as.disk(16)))
|
||||
expect_error(get_guideline("this one does not exist"))
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
# 40 rsi columns
|
||||
expect_equal(example_isolates %>%
|
||||
mutate_at(vars(PEN:RIF), as.character) %>%
|
||||
@ -61,10 +61,10 @@ if (suppressWarnings(require("dplyr"))) {
|
||||
|
||||
expect_stdout(print(tibble(ab = as.rsi("S"))))
|
||||
}
|
||||
if (suppressWarnings(require("skimr"))) {
|
||||
if (pkg_is_available("skimr")) {
|
||||
expect_inherits(skim(example_isolates),
|
||||
"data.frame")
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_inherits(example_isolates %>%
|
||||
mutate(m = as.mic(2),
|
||||
d = as.disk(20)) %>%
|
||||
@ -94,7 +94,7 @@ expect_equal(as.rsi(as.mic(2), "E. coli", "ampicillin", guideline = "EUCAST 2020
|
||||
as.rsi("S"))
|
||||
expect_equal(as.rsi(as.mic(32), "E. coli", "ampicillin", guideline = "EUCAST 2020"),
|
||||
as.rsi("R"))
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_true(suppressWarnings(example_isolates %>%
|
||||
mutate(amox_mic = as.mic(2)) %>%
|
||||
select(mo, amox_mic) %>%
|
||||
@ -121,7 +121,7 @@ expect_equal(as.character(
|
||||
ab = "ERY",
|
||||
guideline = "CLSI")),
|
||||
"R")
|
||||
if (suppressWarnings(require("dplyr"))) {
|
||||
if (pkg_is_available("dplyr")) {
|
||||
expect_true(example_isolates %>%
|
||||
mutate(amox_disk = as.disk(15)) %>%
|
||||
select(mo, amox_disk) %>%
|
||||
@ -130,7 +130,7 @@ if (suppressWarnings(require("dplyr"))) {
|
||||
is.rsi())
|
||||
}
|
||||
# frequency tables
|
||||
if (suppressWarnings(require("cleaner"))) {
|
||||
if (pkg_is_available("cleaner")) {
|
||||
expect_inherits(cleaner::freq(example_isolates$AMX), "freq")
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ for (i in seq_len(length(import_functions))) {
|
||||
pkg <- unname(import_functions[i])
|
||||
# function should exist in foreign pkg namespace
|
||||
if (pkg %in% rownames(installed.packages())) {
|
||||
tst <- !is.null(import_fn(name = fn, pkg = pkg, error_on_fail = FALSE))
|
||||
tst <- !is.null(AMR:::import_fn(name = fn, pkg = pkg, error_on_fail = FALSE))
|
||||
expect_true(tst,
|
||||
info = ifelse(tst,
|
||||
"All external function references exist.",
|
||||
|
@ -24,12 +24,21 @@
|
||||
# ==================================================================== #
|
||||
|
||||
# test only on GitHub Actions and at home - not on CRAN as tests are lengthy
|
||||
if (identical(Sys.getenv("R_TINYTEST"), "true")) {
|
||||
print(Sys.getenv("R_LIBS_USER"))
|
||||
.libPaths(c("/Users/runner/work/_temp/Library", .libPaths()))
|
||||
print(.libPaths())
|
||||
print(as.data.frame(utils::installed.packages())[, "Version", drop = FALSE])
|
||||
library(tinytest)
|
||||
library(AMR)
|
||||
test_package("AMR")
|
||||
if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) {
|
||||
# env var 'R_LIBS_USER' got overwritten during 'R CMD check' in GitHub Actions, so:
|
||||
.libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths()))
|
||||
# helper function
|
||||
pkg_is_available <- function(pkg, also_load = TRUE) {
|
||||
if (also_load == TRUE) {
|
||||
out <- suppressWarnings(require(pkg, character.only = TRUE, warn.conflicts = FALSE, quietly = TRUE))
|
||||
} else {
|
||||
out <- requireNamespace(pkg, quietly = TRUE)
|
||||
}
|
||||
isTRUE(out)
|
||||
}
|
||||
|
||||
if (pkg_is_available("tinytest")) {
|
||||
library(AMR)
|
||||
out <- test_package("AMR")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user