Browse Source

(v1.4.0.9037) random_* functions

main
parent
commit
c8bcecf232
  1. 1
      .Rbuildignore
  2. 4
      DESCRIPTION
  3. 4
      NAMESPACE
  4. 7
      NEWS.md
  5. 2
      R/ab_property.R
  6. 24
      R/disk.R
  7. 4
      R/is_new_episode.R
  8. 10
      R/mic.R
  9. 133
      R/random.R
  10. 1
      _pkgdown.yml
  11. 2
      docs/404.html
  12. 2
      docs/LICENSE-text.html
  13. 2
      docs/articles/index.html
  14. 2
      docs/authors.html
  15. 85
      docs/index.html
  16. 15
      docs/news/index.html
  17. 4
      docs/pkgdown.yml
  18. 10
      docs/reference/index.html
  19. 10
      docs/reference/is_new_episode.html
  20. 16
      docs/reference/plot.html
  21. 338
      docs/reference/random.html
  22. 3
      docs/sitemap.xml
  23. 2
      docs/survey.html
  24. 10
      man/is_new_episode.Rd
  25. 12
      man/plot.Rd
  26. 64
      man/random.Rd
  27. 44
      tests/testthat/test-random.R

1
.Rbuildignore

@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
^public$
^data-raw$
^\.lintr$
^tests/testthat/_snaps$
^vignettes/AMR.Rmd$
^vignettes/benchmarks.Rmd$
^vignettes/EUCAST.Rmd$

4
DESCRIPTION

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Package: AMR
Version: 1.4.0.9036
Date: 2020-12-11
Version: 1.4.0.9037
Date: 2020-12-12
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),

4
NAMESPACE

@ -40,6 +40,7 @@ S3method(format,bug_drug_combinations) @@ -40,6 +40,7 @@ S3method(format,bug_drug_combinations)
S3method(kurtosis,data.frame)
S3method(kurtosis,default)
S3method(kurtosis,matrix)
S3method(plot,disk)
S3method(plot,mic)
S3method(plot,resistance_predict)
S3method(plot,rsi)
@ -203,6 +204,9 @@ export(proportion_R) @@ -203,6 +204,9 @@ export(proportion_R)
export(proportion_S)
export(proportion_SI)
export(proportion_df)
export(random_disk)
export(random_mic)
export(random_rsi)
export(resistance)
export(resistance_predict)
export(right_join_microorganisms)

7
NEWS.md

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
# AMR 1.4.0.9036
## <small>Last updated: 11 December 2020</small>
# AMR 1.4.0.9037
## <small>Last updated: 12 December 2020</small>
### New
* Function `is_new_episode()` to determine patient episodes which are not necessarily based on microorganisms. It also supports grouped variables with e.g. `mutate()`, `filter()` and `summarise()` of the `dplyr` package:
@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
```
* Functions `mo_is_gram_negative()` and `mo_is_gram_positive()` as wrappers around `mo_gramstain()`. They always return `TRUE` or `FALSE` (except when the input is `NA` or the MO code is `UNKNOWN`), thus always return `FALSE` for species outside the taxonomic kingdom of Bacteria.
* Function `mo_is_intrinsic_resistant()` to test for intrinsic resistance, based on [EUCAST Intrinsic Resistance and Unusual Phenotypes v3.2](https://www.eucast.org/expert_rules_and_intrinsic_resistance/) from 2020.
* Functions `random_mic()`, `random_disk()` and `random_rsi()` for random number generation. They take microorganism names and antibiotic names as input to make generation more realistic.
### Changed
* Reference data used for `as.rsi()` can now be set by the user, using the `reference_data` parameter. This allows for using own interpretation guidelines. The user-set data must have the same structure as `rsi_translation`.
@ -36,6 +37,8 @@ @@ -36,6 +37,8 @@
* Fixed a bug where `as.ab()` would sometimes fail
* If using `as.rsi()` on MICs or disk diffusion while there is intrinsic antimicrobial resistance, a warning will be thrown to remind about this
* Better tibble printing for MIC values
* Fix for plotting MIC values with `plot()`
* Added `plot()` generic to class `<disk>`
### Other
* All messages and warnings thrown by this package now break sentences on whole words

2
R/ab_property.R

@ -260,7 +260,7 @@ ab_validate <- function(x, property, ...) { @@ -260,7 +260,7 @@ ab_validate <- function(x, property, ...) {
if (!all(x %in% antibiotics[, property])) {
x <- data.frame(ab = as.ab(x, ...), stringsAsFactors = FALSE) %pm>%
pm_left_join(antibiotics, by = "ab") %pm>%
pm_pull(property)
pm_pull(property)
}
if (property == "ab") {
return(set_clean_class(x, new_class = c("ab", "character")))

24
R/disk.R

@ -144,6 +144,30 @@ print.disk <- function(x, ...) { @@ -144,6 +144,30 @@ print.disk <- function(x, ...) {
print(as.integer(x), quote = FALSE)
}
#' @method plot disk
#' @export
#' @importFrom graphics barplot axis
#' @rdname plot
plot.disk <- function(x,
main = paste("Disk zones values of", deparse(substitute(x))),
ylab = "Frequency",
xlab = "Disk diffusion (mm)",
axes = FALSE,
...) {
meet_criteria(main, allow_class = "character", has_length = 1)
meet_criteria(ylab, allow_class = "character", has_length = 1)
meet_criteria(xlab, allow_class = "character", has_length = 1)
meet_criteria(axes, allow_class = "logical", has_length = 1)
barplot(table(x),
ylab = ylab,
xlab = xlab,
axes = axes,
main = main,
...)
axis(2, seq(0, max(table(x))))
}
#' @method [ disk
#' @export
#' @noRd

4
R/is_new_episode.R

@ -26,13 +26,15 @@ @@ -26,13 +26,15 @@
#' Determine (new) episodes for patients
#'
#' This function determines which items in a vector can be considered (the start of) a new episode, based on the parameter `episode_days`. This can be used to determine clinical episodes for any epidemiological analysis.
#' @inheritSection lifecycle Experimental lifecycle
#' @inheritSection lifecycle Stable lifecycle
#' @param x vector of dates (class `Date` or `POSIXt`)
#' @param episode_days length of the required episode in days, defaults to 365. Every element in the input will return `TRUE` after this number of days has passed since the last included date, independent of calendar years. Please see *Details*.
#' @param ... arguments passed on to [as.Date()]
#' @details
#' Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least `episode_days` days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least `episode_days` days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.
#'
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but more efficient for data sets containing microorganism codes or names.
#'
#' The `dplyr` package is not required for this function to work, but this function works conveniently inside `dplyr` verbs such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()].
#' @return a [logical] vector
#' @export

10
R/mic.R

@ -223,7 +223,7 @@ summary.mic <- function(object, ...) { @@ -223,7 +223,7 @@ summary.mic <- function(object, ...) {
#' @method plot mic
#' @export
#' @importFrom graphics barplot axis par
#' @importFrom graphics barplot axis
#' @rdname plot
plot.mic <- function(x,
main = paste("MIC values of", deparse(substitute(x))),
@ -236,13 +236,13 @@ plot.mic <- function(x, @@ -236,13 +236,13 @@ plot.mic <- function(x,
meet_criteria(xlab, allow_class = "character", has_length = 1)
meet_criteria(axes, allow_class = "logical", has_length = 1)
barplot(table(droplevels.factor(x)),
barplot(table(as.double(x)),
ylab = ylab,
xlab = xlab,
axes = axes,
main = main,
...)
axis(2, seq(0, max(table(droplevels.factor(x)))))
axis(2, seq(0, max(table(as.double(x)))))
}
#' @method barplot mic
@ -260,13 +260,13 @@ barplot.mic <- function(height, @@ -260,13 +260,13 @@ barplot.mic <- function(height,
meet_criteria(xlab, allow_class = "character", has_length = 1)
meet_criteria(axes, allow_class = "logical", has_length = 1)
barplot(table(droplevels.factor(height)),
barplot(table(as.double(height)),
ylab = ylab,
xlab = xlab,
axes = axes,
main = main,
...)
axis(2, seq(0, max(table(droplevels.factor(height)))))
axis(2, seq(0, max(table(as.double(height)))))
}
#' @method [ mic

133
R/random.R

@ -0,0 +1,133 @@ @@ -0,0 +1,133 @@
# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Analysis for R #
# #
# SOURCE #
# https://github.com/msberends/AMR #
# #
# LICENCE #
# (c) 2018-2020 Berends MS, Luz CF et al. #
# Developed at the University of Groningen, the Netherlands, in #
# collaboration with non-profit organisations Certe Medical #
# Diagnostics & Advice, and University Medical Center Groningen. #
# #
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# We created this package for both routine data analysis and academic #
# research and it was publicly released in the hope that it will be #
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
# #
# Visit our website for the full manual and a complete tutorial about #
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
#' Random MIC values/disk zones/RSI generation
#'
#' These functions can be used for generating random MIC values and disk diffusion diameters, for AMR analysis practice.
#' @inheritSection lifecycle Maturing lifecycle
#' @param size desired size of the returned vector
#' @param mo any character that can be coerced to a valid microorganism code with [as.mo()]
#' @param ab any character that can be coerced to a valid antimicrobial agent code with [as.ab()]
#' @param prob_RSI a vector of length 3: the probabilities for R (1st value), S (2nd value) and I (3rd value)
#' @param ... extension for future versions, not used at the moment
#' @details The base R function [sample()] is used for generating values.
#'
#' Generated values are based on the latest EUCAST guideline implemented in the [rsi_translation] data set. To create specific generated values per bug or drug, set the `mo` and/or `ab` parameter.
#' @return class `<mic>` for [random_mic()] (see [as.mic()]) and class `<disk>` for [random_disk()] (see [as.disk()])
#' @name random
#' @rdname random
#' @export
#' @inheritSection AMR Read more on our website!
#' @examples
#' random_mic(100)
#' random_disk(100)
#' random_rsi(100)
#'
#' \donttest{
#' # make the random generation more realistic by setting a bug and/or drug:
#' random_mic(100, "Klebsiella pneumoniae") # range 0.0625-64
#' random_mic(100, "Klebsiella pneumoniae", "meropenem") # range 0.0625-16
#' random_mic(100, "Streptococcus pneumoniae", "meropenem") # range 0.0625-4
#'
#' random_disk(100, "Klebsiella pneumoniae") # range 11-50
#' random_disk(100, "Klebsiella pneumoniae", "ampicillin") # range 6-14
#' random_disk(100, "Streptococcus pneumoniae", "ampicillin") # range 16-22
#' }
random_mic <- function(size, mo = NULL, ab = NULL, ...) {
random_exec("MIC", size = size, mo = mo, ab = ab)
}
#' @rdname random
#' @export
random_disk <- function(size, mo = NULL, ab = NULL, ...) {
random_exec("DISK", size = size, mo = mo, ab = ab)
}
#' @rdname random
#' @export
random_rsi <- function(size, prob_RSI = c(0.33, 0.33, 0.33), ...) {
sample(as.rsi(c("R", "S", "I")), size = size, replace = TRUE, prob = prob_RSI)
}
random_exec <- function(type, size, mo = NULL, ab = NULL) {
df <- rsi_translation %pm>%
pm_filter(guideline %like% "EUCAST") %pm>%
pm_arrange(pm_desc(guideline)) %pm>%
subset(guideline == max(guideline) &
method == type)
if (!is.null(mo)) {
mo_coerced <- as.mo(mo)
mo_include <- c(mo_coerced,
as.mo(mo_genus(mo_coerced)),
as.mo(mo_family(mo_coerced)),
as.mo(mo_order(mo_coerced)))
df_new <- df %pm>%
subset(mo %in% mo_include)
if (nrow(df_new) > 0) {
df <- df_new
} else {
warning_("No rows found that match mo '", mo, "', ignoring parameter `mo`", call = FALSE)
}
}
if (!is.null(ab)) {
ab_coerced <- as.ab(ab)
df_new <- df %pm>%
subset(ab %in% ab_coerced)
if (nrow(df_new) > 0) {
df <- df_new
} else {
warning_("No rows found that match ab '", ab, "', ignoring parameter `ab`", call = FALSE)
}
}
if (type == "MIC") {
# all valid MIC levels
valid_range <- as.mic(levels(as.mic(1)))
set_range_max <- max(df$breakpoint_R)
if (log(set_range_max, 2) %% 1 == 0) {
# return powers of 2
valid_range <- unique(as.double(valid_range))
# add one higher MIC level to set_range_max
set_range_max <- 2 ^ (log(set_range_max, 2) + 1)
set_range <- as.mic(valid_range[log(valid_range, 2) %% 1 == 0 & valid_range <= set_range_max])
} else {
# no power of 2, return factors of 2 to left and right side
valid_mics <- suppressWarnings(as.mic(set_range_max / (2 ^ c(-3:3))))
set_range <- valid_mics[!is.na(valid_mics)]
}
return(as.mic(sample(set_range, size = size, replace = TRUE)))
} else if (type == "DISK") {
set_range <- seq(from = as.integer(min(df$breakpoint_R)),
to = as.integer(max(df$breakpoint_S)),
by = 1)
out <- sample(set_range, size = size, replace = TRUE)
out[out < 6] <- sample(c(6:10), length(out[out < 6]), replace = TRUE)
out[out > 50] <- sample(c(40:50), length(out[out > 50]), replace = TRUE)
return(as.disk(out))
}
}

1
_pkgdown.yml

@ -179,6 +179,7 @@ reference: @@ -179,6 +179,7 @@ reference:
- "`like`"
- "`mo_matching_score`"
- "`pca`"
- "`random`"
- title: "Other: statistical tests"
desc: >

2
docs/404.html

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

2
docs/LICENSE-text.html

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

2
docs/articles/index.html

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

2
docs/authors.html

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

85
docs/index.html

@ -43,7 +43,7 @@ @@ -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.4.0.9036</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9037</span>
</span>
</div>
@ -212,24 +212,24 @@ Since you are one of our users, we would like to know how you use the package an @@ -212,24 +212,24 @@ Since you are one of our users, we would like to know how you use the package an
<p>
<a href="./countries_large.png" target="_blank"><img src="./countries.png" class="countries_map"></a> <strong>Used in 135 countries</strong><br> Since its first public release in early 2018, this package has been downloaded from 135 countries. Click the map to enlarge.
</p>
<br><br>
<p><br><br></p>
</div>
<div id="with-amr-for-r-theres-always-a-knowledgeable-microbiologist-by-your-side" class="section level5">
<h5 class="hasAnchor">
<a href="#with-amr-for-r-theres-always-a-knowledgeable-microbiologist-by-your-side" class="anchor"></a>With <code>AMR</code> (for R), there’s always a knowledgeable microbiologist by your side!</h5>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1"></a><span class="co"># AMR works great with dplyr, but it's not required or neccesary</span></span>
<span id="cb1-2"><a href="#cb1-2"></a><span class="kw">library</span>(AMR)</span>
<span id="cb1-3"><a href="#cb1-3"></a><span class="kw">library</span>(dplyr)</span>
<span id="cb1-4"><a href="#cb1-4"></a></span>
<span id="cb1-5"><a href="#cb1-5"></a>example_isolates <span class="op">%&gt;%</span></span>
<span id="cb1-6"><a href="#cb1-6"></a><span class="st"> </span><span class="kw">mutate</span>(<span class="dt">mo =</span> <span class="kw">mo_fullname</span>(mo)) <span class="op">%&gt;%</span></span>
<span id="cb1-7"><a href="#cb1-7"></a><span class="st"> </span><span class="kw">filter</span>(<span class="kw">mo_is_gram_negative</span>(), <span class="kw">mo_is_intrinsic_resistant</span>(<span class="dt">ab =</span> <span class="st">"cefotax"</span>)) <span class="op">%&gt;%</span></span>
<span id="cb1-8"><a href="#cb1-8"></a><span class="st"> </span><span class="kw">select</span>(mo, <span class="kw">aminoglycosides</span>(), <span class="kw">carbapenems</span>())</span>
<span id="cb1-9"><a href="#cb1-9"></a><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column 'mo' as input for mo_is_gram_negative()</span></span>
<span id="cb1-10"><a href="#cb1-10"></a><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column 'mo' as input for mo_is_intrinsic_resistant()</span></span>
<span id="cb1-11"><a href="#cb1-11"></a><span class="co">#&gt; Selecting aminoglycosides: 'AMK' (amikacin), 'GEN' (gentamicin), </span></span>
<span id="cb1-12"><a href="#cb1-12"></a> <span class="st">'KAN'</span> (kanamycin), <span class="st">'TOB'</span> (tobramycin)</span>
<span id="cb1-13"><a href="#cb1-13"></a><span class="co">#&gt; Selecting carbapenems: 'IPM' (imipenem), 'MEM' (meropenem)</span></span></code></pre></div>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># AMR works great with dplyr, but it's not required or neccesary</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(AMR)</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(dplyr)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>example_isolates <span class="sc">%&gt;%</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">mo =</span> <span class="fu">mo_fullname</span>(mo)) <span class="sc">%&gt;%</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="fu">mo_is_gram_negative</span>(), <span class="fu">mo_is_intrinsic_resistant</span>(<span class="at">ab =</span> <span class="st">"cefotax"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(mo, <span class="fu">aminoglycosides</span>(), <span class="fu">carbapenems</span>())</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column 'mo' as input for mo_is_gram_negative()</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column 'mo' as input for mo_is_intrinsic_resistant()</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Selecting aminoglycosides: 'AMK' (amikacin), 'GEN' (gentamicin), </span></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> <span class="st">'KAN'</span> (kanamycin), <span class="st">'TOB'</span> (tobramycin)</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Selecting carbapenems: 'IPM' (imipenem), 'MEM' (meropenem)</span></span></code></pre></div>
<p>With only having defined a row filter on Gram-negative bacteria with intrinsic resistance to cefotaxime (<code><a href="reference/mo_property.html">mo_is_gram_positive()</a></code> and <code><a href="reference/mo_property.html">mo_is_intrinsic_resistant()</a></code>) and a column selection on two antibiotic groups (<code><a href="reference/antibiotic_class_selectors.html">aminoglycosides()</a></code> and <code><a href="reference/antibiotic_class_selectors.html">carbapenems()</a></code>), the reference data about <a href="./reference/microorganisms.html">all microorganisms</a> and <a href="./reference/antibiotics.html">all antibiotics</a> in the <code>AMR</code> package make sure you get what you meant:</p>
<table class="table">
<thead><tr class="header">
@ -317,31 +317,30 @@ Since you are one of our users, we would like to know how you use the package an @@ -317,31 +317,30 @@ Since you are one of our users, we would like to know how you use the package an
</tbody>
</table>
<div class="home-buttons">
<a href="articles/datasets.html">
<div style="background-color: #128f7635;">
<div class="fa fa-database">
</div>
<span>Download our data sets</span>
</div>
</a> <a href="articles/AMR.html">
<div style="background-color: #138F3865;">
<div class="fa fa-chalkboard-teacher">
</div>
<span>Start learning AMR analysis</span>
</div>
</a> <a href="reference/as.rsi.html">
<div style="background-color: #128f7650;">
<div class="fa fa-language">
</div>
<span>Interpret MIC/disk values to R/SI</span>
</div>
</a> <a href="articles/MDR.html">
<div style="background-color: #138F3835;">
<div class="fa fa-skull-crossbones">
</div>
<span>Determine multi-drug resistance (MDR)</span>
</div>
</a>
<div class="sourceCode" id="cb2"><pre class="sourceCode R"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="sc">&lt;</span>a href<span class="ot">=</span><span class="st">"articles/datasets.html"</span><span class="sc">&gt;</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>div style<span class="ot">=</span><span class="st">"background-color: #128f7635;"</span><span class="sc">&gt;</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>div class<span class="ot">=</span><span class="st">"fa fa-database"</span><span class="sc">&gt;</span><span class="er">&lt;/</span>div<span class="sc">&gt;</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>span<span class="sc">&gt;</span>Download our data sets<span class="sc">&lt;</span><span class="er">/</span>span<span class="sc">&gt;</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;/</span>div<span class="sc">&gt;</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="er">&lt;/</span>a<span class="sc">&gt;</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="er">&lt;</span>a href<span class="ot">=</span><span class="st">"articles/AMR.html"</span><span class="sc">&gt;</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>div style<span class="ot">=</span><span class="st">"background-color: #138F3865;"</span><span class="sc">&gt;</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>div class<span class="ot">=</span><span class="st">"fa fa-chalkboard-teacher"</span><span class="sc">&gt;</span><span class="er">&lt;/</span>div<span class="sc">&gt;</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>span<span class="sc">&gt;</span>Start learning AMR analysis<span class="sc">&lt;</span><span class="er">/</span>span<span class="sc">&gt;</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;/</span>div<span class="sc">&gt;</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="er">&lt;/</span>a<span class="sc">&gt;</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="er">&lt;</span>a href<span class="ot">=</span><span class="st">"reference/as.rsi.html"</span><span class="sc">&gt;</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>div style<span class="ot">=</span><span class="st">"background-color: #128f7650;"</span><span class="sc">&gt;</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>div class<span class="ot">=</span><span class="st">"fa fa-language"</span><span class="sc">&gt;</span><span class="er">&lt;/</span>div<span class="sc">&gt;</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>span<span class="sc">&gt;</span>Interpret MIC<span class="sc">/</span>disk values to R<span class="sc">/</span>SI<span class="sc">&lt;</span><span class="er">/</span>span<span class="sc">&gt;</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;/</span>div<span class="sc">&gt;</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a><span class="er">&lt;/</span>a<span class="sc">&gt;</span></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a><span class="er">&lt;</span>a href<span class="ot">=</span><span class="st">"articles/MDR.html"</span><span class="sc">&gt;</span></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>div style<span class="ot">=</span><span class="st">"background-color: #138F3835;"</span><span class="sc">&gt;</span></span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>div class<span class="ot">=</span><span class="st">"fa fa-skull-crossbones"</span><span class="sc">&gt;</span><span class="er">&lt;/</span>div<span class="sc">&gt;</span></span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;</span>span<span class="sc">&gt;</span>Determine multi<span class="sc">-</span>drug <span class="fu">resistance</span> (MDR)<span class="sc">&lt;</span><span class="er">/</span>span<span class="sc">&gt;</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a> <span class="er">&lt;/</span>div<span class="sc">&gt;</span></span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a><span class="er">&lt;/</span>a<span class="sc">&gt;</span></span></code></pre></div>
</div>
</div>
<div id="partners" class="section level4">
@ -349,7 +348,7 @@ Since you are one of our users, we would like to know how you use the package an @@ -349,7 +348,7 @@ Since you are one of our users, we would like to know how you use the package an
<a href="#partners" class="anchor"></a>Partners</h4>
<p>The development of this package is part of, related to, or made possible by:</p>
<div align="center">
<a href="https://www.rug.nl" title="University of Groningen"><img src="./logo_rug.png" class="partner_logo"></a> <a href="https://www.umcg.nl" title="University Medical Center Groningen"><img src="./logo_umcg.png" class="partner_logo"></a> <a href="https://www.certe.nl" title="Certe Medical Diagnostics and Advice"><img src="./logo_certe.png" class="partner_logo"></a> <a href="http://www.eurhealth-1health.eu" title="EurHealth-1-Health"><img src="./logo_eh1h.png" class="partner_logo"></a> <a href="https://www.deutschland-nederland.eu" title="INTERREG"><img src="./logo_interreg.png" class="partner_logo"></a>
<p><a href="https://www.rug.nl" title="University of Groningen"><img src="./logo_rug.png" class="partner_logo"></a> <a href="https://www.umcg.nl" title="University Medical Center Groningen"><img src="./logo_umcg.png" class="partner_logo"></a> <a href="https://www.certe.nl" title="Certe Medical Diagnostics and Advice"><img src="./logo_certe.png" class="partner_logo"></a> <a href="http://www.eurhealth-1health.eu" title="EurHealth-1-Health"><img src="./logo_eh1h.png" class="partner_logo"></a> <a href="https://www.deutschland-nederland.eu" title="INTERREG"><img src="./logo_interreg.png" class="partner_logo"></a></p>
</div>
</div>
</div>
@ -384,7 +383,7 @@ Since you are one of our users, we would like to know how you use the package an @@ -384,7 +383,7 @@ Since you are one of our users, we would like to know how you use the package an
<a href="#latest-released-version" class="anchor"></a>Latest released version</h4>
<p><img src="https://www.r-pkg.org/badges/version-ago/AMR"><img src="https://cranlogs.r-pkg.org/badges/grand-total/AMR"></p>
<p>This package is available <a href="https://cran.r-project.org/package=AMR">here on the official R network (CRAN)</a>, which has a peer-reviewed submission process. Install this package in R from CRAN by using the command:</p>
<div class="sourceCode" id="cb2"><pre class="downlit">
<div class="sourceCode" id="cb3"><pre class="downlit">
<span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"AMR"</span><span class="op">)</span></pre></div>
<p>It will be downloaded and installed automatically. For RStudio, click on the menu <em>Tools</em> &gt; <em>Install Packages…</em> and then type in “AMR” and press <kbd>Install</kbd>.</p>
<p><strong>Note:</strong> Not all functions on this website may be available in this latest release. To use all functions and data sets mentioned on this website, install the latest development version.</p>
@ -393,7 +392,7 @@ Since you are one of our users, we would like to know how you use the package an @@ -393,7 +392,7 @@ Since you are one of our users, we would like to know how you use the package an
<h4 class="hasAnchor">
<a href="#latest-development-version" class="anchor"></a>Latest development version</h4>
<p>The latest and unpublished development version can be installed from GitHub using:</p>
<div class="sourceCode" id="cb3"><pre class="downlit">
<div class="sourceCode" id="cb4"><pre class="downlit">
<span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"remotes"</span><span class="op">)</span>
<span class="fu">remotes</span><span class="fu">::</span><span class="fu"><a href="https://remotes.r-lib.org/reference/install_github.html">install_github</a></span><span class="op">(</span><span class="st">"msberends/AMR"</span><span class="op">)</span></pre></div>
</div>

15
docs/news/index.html

@ -81,7 +81,7 @@ @@ -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.4.0.9036</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9037</span>
</span>
</div>
@ -236,13 +236,13 @@ @@ -236,13 +236,13 @@
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="amr-1409036" class="section level1">
<h1 class="page-header" data-toc-text="1.4.0.9036">
<a href="#amr-1409036" class="anchor"></a>AMR 1.4.0.9036<small> Unreleased </small>
<div id="amr-1409037" class="section level1">
<h1 class="page-header" data-toc-text="1.4.0.9037">
<a href="#amr-1409037" class="anchor"></a>AMR 1.4.0.9037<small> Unreleased </small>
</h1>
<div id="last-updated-11-december-2020" class="section level2">
<div id="last-updated-12-december-2020" class="section level2">
<h2 class="hasAnchor">
<a href="#last-updated-11-december-2020" class="anchor"></a><small>Last updated: 11 December 2020</small>
<a href="#last-updated-12-december-2020" class="anchor"></a><small>Last updated: 12 December 2020</small>
</h2>
<div id="new" class="section level3">
<h3 class="hasAnchor">
@ -258,6 +258,7 @@ @@ -258,6 +258,7 @@
</li>
<li><p>Functions <code><a href="../reference/mo_property.html">mo_is_gram_negative()</a></code> and <code><a href="../reference/mo_property.html">mo_is_gram_positive()</a></code> as wrappers around <code><a href="../reference/mo_property.html">mo_gramstain()</a></code>. They always return <code>TRUE</code> or <code>FALSE</code> (except when the input is <code>NA</code> or the MO code is <code>UNKNOWN</code>), thus always return <code>FALSE</code> for species outside the taxonomic kingdom of Bacteria.</p></li>
<li><p>Function <code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> to test for intrinsic resistance, based on <a href="https://www.eucast.org/expert_rules_and_intrinsic_resistance/">EUCAST Intrinsic Resistance and Unusual Phenotypes v3.2</a> from 2020.</p></li>
<li><p>Functions <code><a href="../reference/random.html">random_mic()</a></code>, <code><a href="../reference/random.html">random_disk()</a></code> and <code><a href="../reference/random.html">random_rsi()</a></code> for random number generation. They take microorganism names and antibiotic names as input to make generation more realistic.</p></li>
</ul>
</div>
<div id="changed" class="section level3">
@ -288,6 +289,8 @@ @@ -288,6 +289,8 @@
<li><p>Fixed a bug where <code><a href="../reference/as.ab.html">as.ab()</a></code> would sometimes fail</p></li>
<li><p>If using <code><a href="../reference/as.rsi.html">as.rsi()</a></code> on MICs or disk diffusion while there is intrinsic antimicrobial resistance, a warning will be thrown to remind about this</p></li>
<li><p>Better tibble printing for MIC values</p></li>
<li><p>Fix for plotting MIC values with <code><a href="../reference/plot.html">plot()</a></code></p></li>
<li><p>Added <code><a href="../reference/plot.html">plot()</a></code> generic to class <code>&lt;disk&gt;</code></p></li>
</ul>
</div>
<div id="other" class="section level3">

4
docs/pkgdown.yml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
pandoc: 2.9.2.1
pandoc: 2.11.2
pkgdown: 1.6.1
pkgdown_sha: ~
articles:
@ -12,7 +12,7 @@ articles: @@ -12,7 +12,7 @@ articles:
datasets: datasets.html
resistance_predict: resistance_predict.html
welcome_to_AMR: welcome_to_AMR.html
last_built: 2020-12-11T11:03Z
last_built: 2020-12-12T21:53Z
urls:
reference: https://msberends.github.io/AMR//reference
article: https://msberends.github.io/AMR//articles

10
docs/reference/index.html

@ -81,7 +81,7 @@ @@ -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.4.0.9036</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9037</span>
</span>
</div>
@ -447,7 +447,7 @@ @@ -447,7 +447,7 @@
</tr><tr>
<td>
<p><code><a href="plot.html">plot(<i>&lt;mic&gt;</i>)</a></code> <code><a href="plot.html">barplot(<i>&lt;mic&gt;</i>)</a></code> <code><a href="plot.html">plot(<i>&lt;rsi&gt;</i>)</a></code> <code><a href="plot.html">barplot(<i>&lt;rsi&gt;</i>)</a></code> </p>
<p><code><a href="plot.html">plot(<i>&lt;disk&gt;</i>)</a></code> <code><a href="plot.html">plot(<i>&lt;mic&gt;</i>)</a></code> <code><a href="plot.html">barplot(<i>&lt;mic&gt;</i>)</a></code> <code><a href="plot.html">plot(<i>&lt;rsi&gt;</i>)</a></code> <code><a href="plot.html">barplot(<i>&lt;rsi&gt;</i>)</a></code> </p>
</td>
<td><p>Plotting for classes <code>rsi</code> and <code>disk</code></p></td>
</tr>
@ -602,6 +602,12 @@ @@ -602,6 +602,12 @@
<p><code><a href="pca.html">pca()</a></code> </p>
</td>
<td><p>Principal Component Analysis (for AMR)</p></td>
</tr><tr>
<td>
<p><code><a href="random.html">random_mic()</a></code> <code><a href="random.html">random_disk()</a></code> <code><a href="random.html">random_rsi()</a></code> </p>
</td>
<td><p>Random MIC values/disk zones/RSI generation</p></td>
</tr>
</tbody><tbody>
<tr>

10
docs/reference/is_new_episode.html

@ -82,7 +82,7 @@ @@ -82,7 +82,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.4.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9037</span>
</span>
</div>
@ -267,13 +267,15 @@ @@ -267,13 +267,15 @@
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least <code>episode_days</code> days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least <code>episode_days</code> days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.</p>
<p>The <code><a href='first_isolate.html'>first_isolate()</a></code> function is a wrapper around the <code>is_new_episode()</code> function, but more efficient for data sets containing microorganism codes or names.</p>
<p>The <code>dplyr</code> package is not required for this function to work, but this function works conveniently inside <code>dplyr</code> verbs such as <code><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter()</a></code>, <code><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate()</a></code> and <code><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise()</a></code>.</p>
<h2 class="hasAnchor" id="experimental-lifecycle"><a class="anchor" href="#experimental-lifecycle"></a>Experimental lifecycle</h2>
<h2 class="hasAnchor" id="stable-lifecycle"><a class="anchor" href="#stable-lifecycle"></a>Stable lifecycle</h2>
<p><img src='figures/lifecycle_experimental.svg' style=margin-bottom:5px /> <br />
The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>experimental</strong>. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this <code>AMR</code> package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough.</p>
<p><img src='figures/lifecycle_stable.svg' style=margin-bottom:5px /> <br />
The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</strong>. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.</p>
<p>If the unlying code needs breaking changes, they will occur gradually. For example, a parameter will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.</p>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>

16
docs/reference/plot.html

@ -82,7 +82,7 @@ @@ -82,7 +82,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.4.0.9032</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9037</span>
</span>
</div>
@ -234,7 +234,7 @@ @@ -234,7 +234,7 @@
<div class="col-md-9 contents">
<div class="page-header">
<h1>Plotting for classes <code>rsi</code> and <code>disk</code></h1>
<small class="dont-index">Source: <a href='https://github.com/msberends/AMR/blob/master/R/amr.R'><code>R/amr.R</code></a>, <a href='https://github.com/msberends/AMR/blob/master/R/mic.R'><code>R/mic.R</code></a>, <a href='https://github.com/msberends/AMR/blob/master/R/rsi.R'><code>R/rsi.R</code></a></small>
<small class="dont-index">Source: <a href='https://github.com/msberends/AMR/blob/master/R/amr.R'><code>R/amr.R</code></a>, <a href='https://github.com/msberends/AMR/blob/master/R/disk.R'><code>R/disk.R</code></a>, <a href='https://github.com/msberends/AMR/blob/master/R/mic.R'><code>R/mic.R</code></a>, and 1 more</small>
<div class="hidden name"><code>plot.Rd</code></div>
</div>
@ -242,7 +242,17 @@ @@ -242,7 +242,17 @@
<p>Functions to print classes of the <code>AMR</code> package.</p>
</div>
<pre class="usage"><span class='co'># S3 method for mic</span>
<pre class="usage"><span class='co'># S3 method for disk</span>
<span class='fu'>plot</span><span class='op'>(</span>
<span class='va'>x</span>,
main <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/paste.html'>paste</a></span><span class='op'>(</span><span class='st'>"Disk zones values of"</span>, <span class='fu'><a href='https://rdrr.io/r/base/deparse.html'>deparse</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/substitute.html'>substitute</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span><span class='op'>)</span><span class='op'>)</span>,
ylab <span class='op'>=</span> <span class='st'>"Frequency"</span>,
xlab <span class='op'>=</span> <span class='st'>"Disk diffusion (mm)"</span>,
axes <span class='op'>=</span> <span class='cn'>FALSE</span>,
<span class='va'>...</span>
<span class='op'>)</span>
<span class='co'># S3 method for mic</span>
<span class='fu'>plot</span><span class='op'>(</span>
<span class='va'>x</span>,
main <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/paste.html'>paste</a></span><span class='op'>(</span><span class='st'>"MIC values of"</span>, <span class='fu'><a href='https://rdrr.io/r/base/deparse.html'>deparse</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/substitute.html'>substitute</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span><span class='op'>)</span><span class='op'>)</span>,

338
docs/reference/random.html

@ -0,0 +1,338 @@ @@ -0,0 +1,338 @@
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random MIC values/disk zones/RSI generation — random • AMR (for R)</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" />
<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>
<!-- bootstrap-toc -->
<link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>
<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>
<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>
<link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script>
<meta property="og:title" content="Random MIC values/disk zones/RSI generation — random" />
<meta property="og:description" content="These functions can be used for generating random MIC values and disk diffusion diameters, for AMR analysis practice." />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#toc">
<div class="container template-reference-topic">
<header>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</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.4.0.9037</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fa 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>
How to
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/AMR.html">
<span class="fa fa-directions"></span>
Conduct AMR analysis
</a>
</li>
<li>
<a href="../articles/resistance_predict.html">
<span class="fa fa-dice"></span>
Predict antimicrobial resistance
</a>
</li>
<li>
<a href="../articles/datasets.html">
<span class="fa fa-database"></span>
Data sets for download / own use
</a>
</li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li>
<a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span>
Determine multi-drug resistance (MDR)
</a>
</li>
<li>
<a href="../articles/WHONET.html">
<span class="fa fa-globe-americas"></span>
Work with WHONET data
</a>
</li>
<li>
<a href="../articles/SPSS.html">
<span class="fa 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>
Apply EUCAST rules
</a>
</li>
<li>
<a href="../reference/mo_property.html">
<span class="fa fa-bug"></span>
Get properties of a microorganism
</a>
</li>
<li>
<a href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
Other: benchmarks
</a>
</li>
</ul>
</li>
<li>
<a href="../reference/index.html">
<span class="fa fa-book-open"></span>
Manual
</a>
</li>
<li>
<a href="../authors.html">
<span class="fa fa-users"></span>
Authors
</a>
</li>
<li>
<a href="../news/index.html">
<span class="far fa far fa-newspaper"></span>
Changelog
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/msberends/AMR">
<span class="fab fa fab fa-github"></span>
Source Code
</a>
</li>
<li>
<a href="../survey.html">
<span class="fa fa-clipboard-list"></span>
Survey
</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header>
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Random MIC values/disk zones/RSI generation</h1>
<small class="dont-index">Source: <a href='https://github.com/msberends/AMR/blob/master/R/random.R'><code>R/random.R</code></a></small>
<div class="hidden name"><code>random.Rd</code></div>
</div>
<div class="ref-description">
<p>These functions can be used for generating random MIC values and disk diffusion diameters, for AMR analysis practice.</p>
</div>
<pre class="usage"><span class='fu'>random_mic</span><span class='op'>(</span><span class='va'>size</span>, mo <span class='op'>=</span> <span class='cn'>NULL</span>, ab <span class='op'>=</span> <span class='cn'>NULL</span>, <span class='va'>...</span><span class='op'>)</span>
<span class='fu'>random_disk</span><span class='op'>(</span><span class='va'>size</span>, mo <span class='op'>=</span> <span class='cn'>NULL</span>, ab <span class='op'>=</span> <span class='cn'>NULL</span>, <span class='va'>...</span><span class='op'>)</span>
<span class='fu'>random_rsi</span><span class='op'>(</span><span class='va'>size</span>, prob_RSI <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>0.33</span>, <span class='fl'>0.33</span>, <span class='fl'>0.33</span><span class='op'>)</span>, <span class='va'>...</span><span class='op'>)</span></pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>size</th>
<td><p>desired size of the returned vector</p></td>
</tr>
<tr>
<th>mo</th>
<td><p>any character that can be coerced to a valid microorganism code with <code><a href='as.mo.html'>as.mo()</a></code></p></td>
</tr>
<tr>
<th>ab</th>
<td><p>any character that can be coerced to a valid antimicrobial agent code with <code><a href='as.ab.html'>as.ab()</a></code></p></td>
</tr>
<tr>
<th>...</th>
<td><p>extension for future versions, not used at the moment</p></td>
</tr>
<tr>
<th>prob_RSI</th>
<td><p>a vector of length 3: the probabilities for R (1st value), S (2nd value) and I (3rd value)</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
<p>class <code>&lt;mic&gt;</code> for <code>random_mic()</code> (see <code><a href='as.mic.html'>as.mic()</a></code>) and class <code>&lt;disk&gt;</code> for <code>random_disk()</code> (see <code><a href='as.disk.html'>as.disk()</a></code>)</p>
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>The base R function <code><a href='https://rdrr.io/r/base/sample.html'>sample()</a></code> is used for generating values.</p>
<p>Generated values are based on the latest EUCAST guideline implemented in the <a href='rsi_translation.html'>rsi_translation</a> data set. To create specific generated values per bug or drug, set the <code>mo</code> and/or <code>ab</code> parameter.</p>
<h2 class="hasAnchor" id="maturing-lifecycle"><a class="anchor" href="#maturing-lifecycle"></a>Maturing lifecycle</h2>
<p><img src='figures/lifecycle_maturing.svg' style=margin-bottom:5px /> <br />
The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing</strong>. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome <a href='https://github.com/msberends/AMR/issues'>to suggest changes at our repository</a> or <a href='AMR.html'>write us an email (see section 'Contact Us')</a>.</p>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
<p>On our website <a href='https://msberends.github.io/AMR/'>https://msberends.github.io/AMR/</a> you can find <a href='https://msberends.github.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.github.io/AMR/reference/'>complete documentation of all functions</a> and <a href='https://msberends.github.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>. As we would like to better understand the backgrounds and needs of our users, please <a href='https://msberends.github.io/AMR/survey.html'>participate in our survey</a>!</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='fu'>random_mic</span><span class='op'>(</span><span class='fl'>100</span><span class='op'>)</span>
<span class='fu'>random_disk</span><span class='op'>(</span><span class='fl'>100</span><span class='op'>)</span>
<span class='fu'>random_rsi</span><span class='op'>(</span><span class='fl'>100</span><span class='op'>)</span>
<span class='co'># \donttest{</span>
<span class='co'># make the random generation more realistic by setting a bug and/or drug:</span>
<span class='fu'>random_mic</span><span class='op'>(</span><span class='fl'>100</span>, <span class='st'>"Klebsiella pneumoniae"</span><span class='op'>)</span> <span class='co'># range 0.0625-64</span>
<span class='fu'>random_mic</span><span class='op'>(</span><span class='fl'>100</span>, <span class='st'>"Klebsiella pneumoniae"</span>, <span class='st'>"meropenem"</span><span class='op'>)</span> <span class='co'># range 0.0625-16</span>
<span class='fu'>random_mic</span><span class='op'>(</span><span class='fl'>100</span>, <span class='st'>"Streptococcus pneumoniae"</span>, <span class='st'>"meropenem"</span><span class='op'>)</span> <span class='co'># range 0.0625-4</span>
<span class='fu'>random_disk</span><span class='op'>(</span><span class='fl'>100</span>, <span class='st'>"Klebsiella pneumoniae"</span><span class='op'>)</span> <span class='co'># range 11-50</span>
<span class='fu'>random_disk</span><span class='op'>(</span><span class='fl'>100</span>, <span class='st'>"Klebsiella pneumoniae"</span>, <span class='st'>"ampicillin"</span><span class='op'>)</span> <span class='co'># range 6-14</span>
<span class='fu'>random_disk</span><span class='op'>(</span><span class='fl'>100</span>, <span class='st'>"Streptococcus pneumoniae"</span>, <span class='st'>"ampicillin"</span><span class='op'>)</span> <span class='co'># range 16-22</span>
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">
<h2 data-toc-skip>Contents</h2>
</nav>
</div>
</div>
<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/'>Alexander 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">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
</div>
</body>
</html>

3
docs/sitemap.xml

@ -144,6 +144,9 @@ @@ -144,6 +144,9 @@
<url>
<loc>https://msberends.github.io/AMR//reference/proportion.html</loc>
</url>
<url>
<loc>https://msberends.github.io/AMR//reference/random.html</loc>
</url>
<url