1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-24 18:46:14 +01:00

(v1.0.0.9003) prepare for short update

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-02-21 13:13:34 +01:00
parent 6408911922
commit bb3728f023
13 changed files with 45 additions and 36 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 1.0.0.9002
Date: 2020-02-20
Version: 1.0.0.9003
Date: 2020-02-21
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),

View File

@ -1,8 +1,7 @@
# AMR 1.0.0.9002
## <small>Last updated: 20-Feb-2020</small>
# AMR 1.0.0.9003
## <small>Last updated: 21-Feb-2020</small>
### Changed
* Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole
* Fixed floating point error for some MIC compa in EUCAST 2020 guideline
* Interpretation from MIC values to R/SI can now be used with `mutate_at()` of the dplyr package:
```r
@ -12,6 +11,7 @@
yourdata %>%
mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = .$mybacteria)
```
* Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole
* Added `uti` (as abbreviation of urinary tract infections) as parameter to `as.rsi()`, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs
# AMR 1.0.0

25
R/rsi.R
View File

@ -67,6 +67,8 @@
#' NIT = as.mic(32))
#' as.rsi(df)
#'
#' \donttest{
#'
#' # the dplyr way
#' library(dplyr)
#' df %>%
@ -88,7 +90,8 @@
#'
#' df %>%
#' mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE)
#'
#' }
#'
#' # for single values
#' as.rsi(x = as.mic(2),
#' mo = as.mo("S. pneumoniae"),
@ -199,20 +202,6 @@ as.rsi.default <- function(x, ...) {
}
}
#' @importFrom dplyr %>%
input_resembles_mic <- function(x) {
mic <- x %>%
gsub("[^0-9.,]+", "", .) %>%
unique()
mic_valid <- suppressWarnings(as.mic(mic))
result <- sum(!is.na(mic_valid)) / length(mic)
if (is.na(result)) {
0
} else {
result
}
}
#' @rdname as.rsi
#' @export
as.rsi.mic <- function(x, mo, ab = deparse(substitute(x)), guideline = "EUCAST", uti = FALSE, ...) {
@ -402,10 +391,14 @@ get_guideline <- function(guideline) {
rev() %>%
.[1]
}
if (!guideline_param %like% " ") {
# like 'EUCAST2020', should be 'EUCAST 2020'
guideline_param <- gsub("([a-z]+)([0-9]+)", "\\1 \\2", guideline_param, ignore.case = TRUE)
}
if (!guideline_param %in% rsi_translation$guideline) {
stop(paste0("invalid guideline: '", guideline,
"'.\nValid guidelines are: ", paste0("'", rev(sort(unique(rsi_translation$guideline))), "'", collapse = ", ")),
"'.\nValid guidelines are: ", paste0("'", unique(rsi_translation$guideline), "'", collapse = ", "), "."),
call. = FALSE)
}

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="https://msberends.gitlab.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.0.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.0.9003</span>
</span>
</div>

View File

@ -78,7 +78,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.0.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.0.9003</span>
</span>
</div>

View File

@ -78,7 +78,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.0.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.0.9003</span>
</span>
</div>

View File

@ -78,7 +78,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.0.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.0.9003</span>
</span>
</div>

View File

@ -43,7 +43,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.0.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.0.9003</span>
</span>
</div>

View File

@ -78,7 +78,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.0.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.0.9003</span>
</span>
</div>
@ -219,19 +219,18 @@
</div>
<div id="amr-1009002" class="section level1">
<div id="amr-1009003" class="section level1">
<h1 class="page-header">
<a href="#amr-1009002" class="anchor"></a>AMR 1.0.0.9002<small> Unreleased </small>
<a href="#amr-1009003" class="anchor"></a>AMR 1.0.0.9003<small> Unreleased </small>
</h1>
<div id="last-updated-20-feb-2020" class="section level2">
<div id="last-updated-21-feb-2020" class="section level2">
<h2 class="hasAnchor">
<a href="#last-updated-20-feb-2020" class="anchor"></a><small>Last updated: 20-Feb-2020</small>
<a href="#last-updated-21-feb-2020" class="anchor"></a><small>Last updated: 21-Feb-2020</small>
</h2>
<div id="changed" class="section level3">
<h3 class="hasAnchor">
<a href="#changed" class="anchor"></a>Changed</h3>
<ul>
<li><p>Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole</p></li>
<li><p>Fixed floating point error for some MIC compa in EUCAST 2020 guideline</p></li>
<li>
<p>Interpretation from MIC values to R/SI can now be used with <code><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at()</a></code> of the dplyr package:</p>
@ -241,6 +240,7 @@
<span id="cb1-4"><a href="#cb1-4"></a>yourdata <span class="op">%&gt;%</span><span class="st"> </span></span>
<span id="cb1-5"><a href="#cb1-5"></a><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span>(<span class="kw"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span>(antibiotic1<span class="op">:</span>antibiotic25), as.rsi, <span class="dt">mo =</span> .<span class="op">$</span>mybacteria)</span></code></pre></div>
</li>
<li><p>Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole</p></li>
<li><p>Added <code>uti</code> (as abbreviation of urinary tract infections) as parameter to <code><a href="../reference/as.rsi.html">as.rsi()</a></code>, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs</p></li>
</ul>
</div>
@ -1473,7 +1473,7 @@
<div id="tocnav">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#amr-1009002">1.0.0.9002</a></li>
<li><a href="#amr-1009003">1.0.0.9003</a></li>
<li><a href="#amr-100">1.0.0</a></li>
<li><a href="#amr-090">0.9.0</a></li>
<li><a href="#amr-080">0.8.0</a></li>

View File

@ -79,7 +79,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.0.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.0.9003</span>
</span>
</div>
@ -342,6 +342,8 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='kw'>NIT</span> <span class='kw'>=</span> <span class='fu'><a href='as.mic.html'>as.mic</a></span>(<span class='fl'>32</span>))
<span class='fu'>as.rsi</span>(<span class='no'>df</span>)
<span class='co'># \donttest{</span>
<span class='co'># the dplyr way</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>df</span> <span class='kw'>%&gt;%</span>
@ -363,6 +365,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='no'>df</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='no'>AMP</span>:<span class='no'>NIT</span>), <span class='no'>as.rsi</span>, <span class='kw'>mo</span> <span class='kw'>=</span> <span class='st'>"E. coli"</span>, <span class='kw'>uti</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
<span class='co'># }</span>
<span class='co'># for single values</span>
<span class='fu'>as.rsi</span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='fu'><a href='as.mic.html'>as.mic</a></span>(<span class='fl'>2</span>),

View File

@ -78,7 +78,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.0.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.0.9003</span>
</span>
</div>

View File

@ -108,6 +108,8 @@ df <- data.frame(microorganism = "E. coli",
NIT = as.mic(32))
as.rsi(df)
\donttest{
# the dplyr way
library(dplyr)
df \%>\%
@ -129,7 +131,8 @@ data.frame(mo = "E. coli",
df \%>\%
mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE)
}
# for single values
as.rsi(x = as.mic(2),
mo = as.mo("S. pneumoniae"),

View File

@ -34,6 +34,8 @@ test_that("rsi works", {
barplot(as.rsi(c("S", "I", "R")))
plot(as.rsi(c("S", "I", "R")))
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)
@ -55,9 +57,17 @@ test_that("rsi works", {
as.logical() %>%
sum(),
40)
expect_output(tibble(ab = as.rsi("S")))
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"))
})
test_that("mic2rsi works", {
skip_on_cran()