mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 05:26:13 +01:00
(v0.7.1.9057) get_column_abx() improvement
This commit is contained in:
parent
920212e815
commit
04d49a62af
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 0.7.1.9056
|
||||
Date: 2019-08-14
|
||||
Version: 0.7.1.9057
|
||||
Date: 2019-08-15
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
|
3
NEWS.md
3
NEWS.md
@ -1,4 +1,4 @@
|
||||
# AMR 0.7.1.9056
|
||||
# AMR 0.7.1.9057
|
||||
|
||||
### Breaking
|
||||
* Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. Therefore, a new package was created for data cleaning and checking and it perfectly fits the `freq()` function. The [`clean`](https://github.com/msberends/clean) package is available on CRAN and will be installed automatically when updating the `AMR` package, that now imports it. In a later stage, the `skewness()` and `kurtosis()` functions will be moved to the `clean` package too.
|
||||
@ -46,6 +46,7 @@
|
||||
* Printed info now distinguishes between added and changes values
|
||||
* Using Verbose mode (i.e. `eucast_rules(..., verbose = TRUE)`) returns more informative and readable output
|
||||
* Using factors as input now adds missing factors levels when the function changes antibiotic results
|
||||
* Improved the internal auto-guessing function for determining antibiotics in your data set (`AMR:::get_column_abx()`)
|
||||
* Added tibble printing support for classes `rsi`, `mic`, `disk`, `ab` `mo`. When using tibbles containing antibiotic columns, values `S` will print in green, values `I` will print in yellow and values `R` will print in red. Microbial IDs (class `mo`) will emphasise on the genus and species, not on the kingdom.
|
||||
```r
|
||||
# (run this on your own console, as this page does not support colour printing)
|
||||
|
@ -148,29 +148,23 @@ get_column_abx <- function(x,
|
||||
}
|
||||
|
||||
# sort on name
|
||||
x <- x[sort(names(x))]
|
||||
dupes <- x[base::duplicated(x)]
|
||||
x <- x[order(names(x), x)]
|
||||
duplicates <- x[base::duplicated(x)]
|
||||
x <- x[!names(x) %in% names(duplicates)]
|
||||
|
||||
if (verbose == TRUE) {
|
||||
for (i in 1:length(x)) {
|
||||
if (x[i] %in% dupes) {
|
||||
message(red(paste0("NOTE: Using column `", bold(x[i]), "` as input for `", names(x)[i],
|
||||
"` (", ab_name(names(x)[i], language = "en", tolower = TRUE), ") [DUPLICATED USE].")))
|
||||
} else {
|
||||
message(blue(paste0("NOTE: Using column `", bold(x[i]), "` as input for `", names(x)[i],
|
||||
"` (", ab_name(names(x)[i], language = "en", tolower = TRUE), ").")))
|
||||
"` (", ab_name(names(x)[i], tolower = TRUE), ").")))
|
||||
}
|
||||
} else if (length(duplicates) > 0) {
|
||||
for (i in 1:length(duplicates)) {
|
||||
warning(red(paste0("Using column `", bold(duplicates[i]), "` as input for `", names(x[which(x == duplicates[i])]),
|
||||
"` (", ab_name(names(x[names(which(x == duplicates))[i]]), tolower = TRUE),
|
||||
"), although it was matched for multiple antibiotics or columns.")), call. = FALSE)
|
||||
}
|
||||
}
|
||||
|
||||
if (n_distinct(x) != length(x)) {
|
||||
msg_txt <- paste("Column(s)", paste0("`", dupes, "`", collapse = " and "), "used for more than one antibiotic.")
|
||||
if (verbose == FALSE) {
|
||||
msg_txt <- paste(msg_txt, "Use verbose = TRUE to see which antibiotics are used by which columns.")
|
||||
}
|
||||
stop(msg_txt, call. = FALSE)
|
||||
}
|
||||
|
||||
if (!is.null(hard_dependencies)) {
|
||||
if (!all(hard_dependencies %in% names(x))) {
|
||||
# missing a hard dependency will return NA and consequently the data will not be analysed
|
||||
|
@ -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">0.7.1.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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">0.7.1.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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">0.7.1.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</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">0.7.1.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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">0.7.1.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -225,9 +225,9 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="amr-0-7-1-9056" class="section level1">
|
||||
<div id="amr-0-7-1-9057" class="section level1">
|
||||
<h1 class="page-header">
|
||||
<a href="#amr-0-7-1-9056" class="anchor"></a>AMR 0.7.1.9056<small> Unreleased </small>
|
||||
<a href="#amr-0-7-1-9057" class="anchor"></a>AMR 0.7.1.9057<small> Unreleased </small>
|
||||
</h1>
|
||||
<div id="breaking" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -288,6 +288,7 @@
|
||||
<li>Using factors as input now adds missing factors levels when the function changes antibiotic results</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Improved the internal auto-guessing function for determining antibiotics in your data set (<code>AMR:::get_column_abx()</code>)</li>
|
||||
<li>
|
||||
<p>Added tibble printing support for classes <code>rsi</code>, <code>mic</code>, <code>disk</code>, <code>ab</code> <code>mo</code>. When using tibbles containing antibiotic columns, values <code>S</code> will print in green, values <code>I</code> will print in yellow and values <code>R</code> will print in red. Microbial IDs (class <code>mo</code>) will emphasise on the genus and species, not on the kingdom.</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="co"># (run this on your own console, as this page does not support colour printing)</span></a>
|
||||
@ -1237,7 +1238,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
|
||||
<div id="tocnav">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#amr-0-7-1-9056">0.7.1.9056</a></li>
|
||||
<li><a href="#amr-0-7-1-9057">0.7.1.9057</a></li>
|
||||
<li><a href="#amr-0-7-1">0.7.1</a></li>
|
||||
<li><a href="#amr-0-7-0">0.7.0</a></li>
|
||||
<li><a href="#amr-0-6-1">0.6.1</a></li>
|
||||
|
@ -80,7 +80,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">0.7.1.9055</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -476,7 +476,7 @@ To conduct an analysis of antimicrobial resistance, you should only include the
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
|
||||
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
|
@ -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">0.7.1.9056</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -80,7 +80,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">0.7.1.9055</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -388,7 +388,7 @@
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
|
||||
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
|
@ -44,6 +44,6 @@ test_that("looking up ab columns works", {
|
||||
expect_warning(generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
|
||||
expect_warning(get_column_abx(septic_patients, hard_dependencies = "FUS"))
|
||||
expect_message(get_column_abx(septic_patients, soft_dependencies = "FUS"))
|
||||
expect_error(get_column_abx(dplyr::rename(septic_patients, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
|
||||
expect_error(get_column_abx(dplyr::rename(septic_patients, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
|
||||
expect_message(get_column_abx(dplyr::rename(septic_patients, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
|
||||
expect_warning(get_column_abx(dplyr::rename(septic_patients, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user