(v1.1.0.9019) mo_source fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-05-25 01:01:14 +02:00
parent f5ff2e6634
commit ae1969b941
73 changed files with 619 additions and 571 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 1.1.0.9018
Date: 2020-05-22
Version: 1.1.0.9019
Date: 2020-05-25
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),

View File

@ -1,5 +1,5 @@
# AMR 1.1.0.9018
## <small>Last updated: 22-May-2020</small>
# AMR 1.1.0.9019
## <small>Last updated: 25-May-2020</small>
### Breaking
* Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users.
@ -20,7 +20,8 @@
* Improvements for algorithm in `as.ab()`, so that e.g. `as.ab("ampi sul")` and `ab_name("ampi sul")` work
* Functions `ab_atc()` and `ab_group()` now return `NA` if no antimicrobial agent could be found
* Small fix for some text input that could not be coerced as valid MIC values
* Fixed interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)
* Fix for interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)
* Fix for `set_mo_source()` to make sure that column `mo` will always be the second column
### Other
* Removed previously deprecated function `p.symbol()` - it was replaced with `p_symbol()`

View File

@ -22,7 +22,7 @@
#' Property of an antibiotic
#'
#' Use these functions to return a specific property of an antibiotic from the [antibiotics] data set. All input values will be evaluated internally with [as.ab()].
#' @inheritSection lifecycle Maturing lifecycle
#' @inheritSection lifecycle Stable lifecycle
#' @param x any (vector of) text that can be coerced to a valid microorganism code with [as.ab()]
#' @param tolower logical to indicate whether the first character of every output should be transformed to a lower case character. This will lead to e.g. "polymyxin B" and not "polymyxin b".
#' @param property one of the column names of one of the [antibiotics] data set
@ -33,7 +33,7 @@
#' @param ... other parameters passed on to [as.ab()]
#' @details All output will be [translate]d where possible.
#'
#' The function [ab_url()] will return the direct URL to the official WHO website. A warning will be returned if the reauired ATC code is not available.
#' The function [ab_url()] will return the direct URL to the official WHO website. A warning will be returned if the required ATC code is not available.
#' @inheritSection as.ab Source
#' @rdname ab_property
#' @name ab_property

View File

@ -22,6 +22,7 @@
#' Property of a microorganism
#'
#' Use these functions to return a specific property of a microorganism. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. Please see *Examples*.
#' @inheritSection lifecycle Stable lifecycle
#' @param x any (vector of) text that can be coerced to a valid microorganism code with [as.mo()]
#' @param property one of the column names of the [microorganisms] data set or `"shortname"`
#' @param language language of the returned text, defaults to system language (see [get_locale()]) and can also be set with `getOption("AMR_locale")`. Use `language = NULL` or `language = ""` to prevent translation.

View File

@ -19,13 +19,13 @@
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
# ==================================================================== #
#' Use predefined reference data set
#' User-defined reference data set for microorganisms
#'
#' @description These functions can be used to predefine your own reference to be used in [as.mo()] and consequently all `mo_*` functions like [mo_genus()] and [mo_gramstain()].
#'
#' This is **the fastest way** to have your organisation (or analysis) specific codes picked up and translated by this package.
#' @inheritSection lifecycle Stable lifecycle
#' @param path location of your reference file, see Details
#' @param path location of your reference file, see Details. Can be `""`, `NULL` or `FALSE` to delete the reference file.
#' @rdname mo_source
#' @name mo_source
#' @aliases set_mo_source get_mo_source
@ -35,11 +35,12 @@
#'
#' [get_mo_source()] will return the data set by reading `"~/.mo_source.rds"` with [readRDS()]. If the original file has changed (the file defined with `path`), it will call [set_mo_source()] to update the data file automatically.
#'
#' Reading an Excel file (`.xlsx`) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by [get_mo_source()] in only a couple of microseconds (a millionth of a second).
#' Reading an Excel file (`.xlsx`) with only one row has a size of 8-9 kB. The compressed file created with [set_mo_source()] will then have a size of 0.1 kB and can be read by [get_mo_source()] in only a couple of microseconds (millionths of a second).
#'
#' ## How it works
#' @section How to setup:
#'
#' Imagine this data on a sheet of an Excel file (mo codes were looked up in the [microorganisms] data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:
#'
#' Imagine this data on a sheet of an Excel file (mo codes were looked up in the `microorganisms` data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:
#' ```
#' | A | B |
#' --|--------------------|--------------|
@ -50,27 +51,31 @@
#' ```
#'
#' We save it as `"home/me/ourcodes.xlsx"`. Now we have to set it as a source:
#'
#' ```
#' set_mo_source("home/me/ourcodes.xlsx")
#' # Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#' #> NOTE: Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
#' #> (columns "Organisation XYZ" and "mo")
#' ```
#'
#' It has now created a file `"~/.mo_source.rds"` with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept.
#' It has now created a file `"~/.mo_source.rds"` with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file.
#'
#' And now we can use it in our functions:
#'
#' ```
#' as.mo("lab_mo_ecoli")
#' [1] B_ESCHR_COLI
#' #> [1] B_ESCHR_COLI
#'
#' mo_genus("lab_mo_kpneumoniae")
#' [1] "Klebsiella"
#' #> [1] "Klebsiella"
#'
#' # other input values still work too
#' as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
#' [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
#' #> [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
#' ```
#'
#' If we edit the Excel file to, let's say, by adding row 4 like this:
#' If we edit the Excel file by, let's say, adding row 4 like this:
#'
#' ```
#' | A | B |
#' --|--------------------|--------------|
@ -82,36 +87,41 @@
#' ```
#'
#' ...any new usage of an MO function in this package will update your data file:
#'
#' ```
#' as.mo("lab_mo_ecoli")
#' # Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#' [1] B_ESCHR_COLI
#' #> NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
#' #> (columns "Organisation XYZ" and "mo")
#' #> [1] B_ESCHR_COLI
#'
#' mo_genus("lab_Staph_aureus")
#' [1] "Staphylococcus"
#' #> [1] "Staphylococcus"
#' ```
#'
#' To remove the reference data file completely, just use `""` or `NULL` as input for `[set_mo_source()]`:
#' To delete the reference data file, just use `""`, `NULL` or `FALSE` as input for [set_mo_source()]:
#'
#' ```
#' set_mo_source(NULL)
#' # Removed mo_source file '~/.mo_source.rds'.
#' ```
#'
#' If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of [as.mo()]. If the mo_source file is manually deleted (i.e. without using [set_mo_source()]), the references to the mo_source file will be removed upon the next use of [as.mo()].
#' @export
#' @inheritSection AMR Read more on our website!
set_mo_source <- function(path) {
file_location <- path.expand("~/mo_source.rds")
if (!is.character(path) | length(path) > 1) {
stop("`path` must be a character of length 1.")
if (length(path) > 1) {
stop("`path` must be of length 1.")
}
if (path %in% c(NULL, "")) {
if (is.null(path) || path %in% c(FALSE, "")) {
options(mo_source = NULL)
options(mo_source_timestamp = NULL)
if (file.exists(file_location)) {
unlink(file_location)
message("Removed mo_source file '", file_location, "'.")
message(font_red(paste0("Removed mo_source file '", font_bold(file_location), "'")))
}
return(invisible())
}
@ -154,13 +164,13 @@ set_mo_source <- function(path) {
# check integrity
mo_source_isvalid(df)
df <- df %>% filter(!is.na(mo))
df <- subset(df, !is.na(mo))
# keep only first two columns, second must be mo
if (colnames(df)[1] == "mo") {
df <- df[, c(2, 1)]
df <- df[, c(colnames(df)[2], "mo")]
} else {
df <- df[, c(1, 2)]
df <- df[, c(colnames(df)[1], "mo")]
}
df <- as.data.frame(df, stringAsFactors = FALSE)
@ -174,30 +184,40 @@ set_mo_source <- function(path) {
saveRDS(df, file_location)
options(mo_source = path)
options(mo_source_timestamp = as.character(file.info(path)$mtime))
message(action, " mo_source file '", file_location, "' from '", path, "'.")
message(font_blue(paste0("NOTE: ",
action, " mo_source file '", font_bold(file_location), "'",
" from '", font_bold(path), "'",
'\n (columns "', colnames(df)[1], '" and "', colnames(df)[2], '")')))
}
#' @rdname mo_source
#' @export
get_mo_source <- function() {
if (is.null(getOption("mo_source", NULL))) {
NULL
} else {
old_time <- as.POSIXct(getOption("mo_source_timestamp"))
new_time <- as.POSIXct(as.character(file.info(getOption("mo_source", ""))$mtime))
if (is.na(new_time)) {
# source file was deleted, remove reference too
set_mo_source("")
return(NULL)
}
if (new_time != old_time) {
# set updated source
set_mo_source(getOption("mo_source"))
}
file_location <- path.expand("~/mo_source.rds")
readRDS(file_location)
return(NULL)
}
if (!file.exists(path.expand("~/mo_source.rds"))) {
options(mo_source = NULL)
options(mo_source_timestamp = NULL)
message(font_blue("NOTE: Removed references to deleted mo_source file (see ?mo_source)"))
return(NULL)
}
old_time <- as.POSIXct(getOption("mo_source_timestamp"))
new_time <- as.POSIXct(as.character(file.info(getOption("mo_source", ""))$mtime))
if (is.na(new_time)) {
# source file was deleted, remove reference too
set_mo_source("")
return(NULL)
}
if (new_time != old_time) {
# set updated source
set_mo_source(getOption("mo_source"))
}
file_location <- path.expand("~/mo_source.rds")
readRDS(file_location)
}
mo_source_isvalid <- function(x, refer_to_name = "`reference_df`", stop_on_error = TRUE) {

View File

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

View File

@ -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.1.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -186,7 +186,7 @@
<h1 data-toc-skip>How to conduct AMR analysis</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">20 May 2020</h4>
<h4 class="date">25 May 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/AMR.Rmd"><code>vignettes/AMR.Rmd</code></a></small>
<div class="hidden name"><code>AMR.Rmd</code></div>
@ -195,7 +195,7 @@
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 20 May 2020.</p>
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 25 May 2020.</p>
<div id="introduction" class="section level1">
<h1 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h1>
@ -226,21 +226,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2020-05-20</td>
<td align="center">2020-05-25</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
<td align="center">2020-05-20</td>
<td align="center">2020-05-25</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
<td align="center">2020-05-20</td>
<td align="center">2020-05-25</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -336,41 +336,63 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2013-03-27</td>
<td align="center">L8</td>
<td align="center">2015-03-17</td>
<td align="center">U1</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2017-08-02</td>
<td align="center">P6</td>
<td align="center">Hospital B</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2017-06-24</td>
<td align="center">E4</td>
<td align="center">Hospital C</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2015-12-30</td>
<td align="center">K1</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">2011-02-12</td>
<td align="center">I10</td>
<td align="center">Hospital D</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2016-06-06</td>
<td align="center">D3</td>
<td align="center">Hospital B</td>
<td align="center">2010-03-17</td>
<td align="center">Q3</td>
<td align="center">Hospital C</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2011-07-04</td>
<td align="center">H10</td>
<td align="center">2010-08-19</td>
<td align="center">A7</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
@ -379,28 +401,6 @@
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2012-04-12</td>
<td align="center">M3</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2017-03-06</td>
<td align="center">S4</td>
<td align="center">Hospital C</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
</tbody>
</table>
<p>Now, lets start the cleaning and the analysis!</p>
@ -432,16 +432,16 @@ Longest: 1</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">M</td>
<td align="right">10,319</td>
<td align="right">51.60%</td>
<td align="right">10,319</td>
<td align="right">51.60%</td>
<td align="right">10,403</td>
<td align="right">52.02%</td>
<td align="right">10,403</td>
<td align="right">52.02%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">F</td>
<td align="right">9,681</td>
<td align="right">48.41%</td>
<td align="right">9,597</td>
<td align="right">47.99%</td>
<td align="right">20,000</td>
<td align="right">100.00%</td>
</tr>
@ -456,11 +456,7 @@ Longest: 1</p>
<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">AMX</span>:<span class="no">GEN</span>), <span class="no">as.rsi</span>)</pre></body></html></div>
<p>Finally, we will apply <a href="http://www.eucast.org/expert_rules_and_intrinsic_resistance/">EUCAST rules</a> on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function can also apply additional rules, like forcing <help title="ATC: J01CA01">ampicillin</help> = R when <help title="ATC: J01CR02">amoxicillin/clavulanic acid</help> = R.</p>
<p>Because the amoxicillin (column <code>AMX</code>) and amoxicillin/clavulanic acid (column <code>AMC</code>) in our data were generated randomly, some rows will undoubtedly contain AMX = S and AMC = R, which is technically impossible. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> fixes this:</p>
<div class="sourceCode" id="cb13"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(<span class="no">data</span>, <span class="kw">col_mo</span> <span class="kw">=</span> <span class="st">"bacteria"</span>)
<span class="co"># [31m</span>
<span class="co"># Skipping inheritance rules defined by this package, such as setting trimethoprim (TMP) = R where trimethoprim/sulfamethoxazole (SXT) = R.</span>
<span class="co"># Use eucast_rules(..., rules = "all") to also apply those rules.</span>
<span class="co"># [39m</span></pre></body></html></div>
<div class="sourceCode" id="cb13"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(<span class="no">data</span>, <span class="kw">col_mo</span> <span class="kw">=</span> <span class="st">"bacteria"</span>)</pre></body></html></div>
</div>
<div id="adding-new-variables" class="section level1">
<h1 class="hasAnchor">
@ -482,10 +478,10 @@ Longest: 1</p>
<p>This <code>AMR</code> package includes this methodology with the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function. It adopts the episode of a year (can be changed by user) and it starts counting days after every selected isolate. This new variable can easily be added to our data:</p>
<div class="sourceCode" id="cb15"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="no">data</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="kw">first</span> <span class="kw">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span>(<span class="no">.</span>))
<span class="co"># [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mdate[22m` as input for `col_date`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mpatient_id[22m` as input for `col_patient_id`.[39m</span></pre></body></html></div>
<p>So only 28.5% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<span class="co"># NOTE: Using column `date` as input for `col_date`.</span>
<span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span></pre></body></html></div>
<p>So only 28.2% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb16"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">&lt;-</span> <span class="no">data</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="no">first</span> <span class="kw">==</span> <span class="fl">TRUE</span>)</pre></body></html></div>
<p>For future use, the above two syntaxes can be shortened with the <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> function:</p>
@ -495,7 +491,7 @@ Longest: 1</p>
<div id="first-weighted-isolates" class="section level2">
<h2 class="hasAnchor">
<a href="#first-weighted-isolates" class="anchor"></a>First <em>weighted</em> isolates</h2>
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient S1, sorted on date:</p>
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient K4, sorted on date:</p>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -511,32 +507,32 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-02-10</td>
<td align="center">S1</td>
<td align="center">2010-01-01</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-02-27</td>
<td align="center">S1</td>
<td align="center">2010-02-09</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-03-05</td>
<td align="center">S1</td>
<td align="center">2010-03-03</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
@ -544,8 +540,8 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-04-03</td>
<td align="center">S1</td>
<td align="center">2010-04-25</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -555,19 +551,19 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-05-22</td>
<td align="center">S1</td>
<td align="center">2010-07-04</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-07-19</td>
<td align="center">S1</td>
<td align="center">2010-09-04</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
@ -577,10 +573,10 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-07-19</td>
<td align="center">S1</td>
<td align="center">2010-10-01</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
@ -588,30 +584,30 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-08-28</td>
<td align="center">S1</td>
<td align="center">2011-03-20</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">S</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2010-09-09</td>
<td align="center">S1</td>
<td align="center">2011-06-26</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2010-09-20</td>
<td align="center">S1</td>
<td align="center">2011-10-22</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -621,16 +617,16 @@ Longest: 1</p>
</tr>
</tbody>
</table>
<p>Only 1 isolates are marked as first according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
<p>Only 2 isolates are marked as first according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
<p>If a column exists with a name like key(…)ab the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:</p>
<div class="sourceCode" id="cb18"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="no">data</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="kw">keyab</span> <span class="kw">=</span> <span class="fu"><a href="../reference/key_antibiotics.html">key_antibiotics</a></span>(<span class="no">.</span>)) <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="kw">first_weighted</span> <span class="kw">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span>(<span class="no">.</span>))
<span class="co"># [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mdate[22m` as input for `col_date`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mpatient_id[22m` as input for `col_patient_id`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mkeyab[22m` as input for `col_keyantibiotics`. Use [1mcol_keyantibiotics = FALSE[22m to prevent this.[39m</span></pre></body></html></div>
<span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<span class="co"># NOTE: Using column `date` as input for `col_date`.</span>
<span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span>
<span class="co"># NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></pre></body></html></div>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -647,44 +643,44 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-02-10</td>
<td align="center">S1</td>
<td align="center">2010-01-01</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-02-27</td>
<td align="center">S1</td>
<td align="center">2010-02-09</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-03-05</td>
<td align="center">S1</td>
<td align="center">2010-03-03</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-04-03</td>
<td align="center">S1</td>
<td align="center">2010-04-25</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -695,34 +691,34 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-05-22</td>
<td align="center">S1</td>
<td align="center">2010-07-04</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-07-19</td>
<td align="center">S1</td>
<td align="center">2010-09-04</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-07-19</td>
<td align="center">S1</td>
<td align="center">2010-10-01</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
@ -731,32 +727,32 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-08-28</td>
<td align="center">S1</td>
<td align="center">2011-03-20</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">S</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2010-09-09</td>
<td align="center">S1</td>
<td align="center">2011-06-26</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2010-09-20</td>
<td align="center">S1</td>
<td align="center">2011-10-22</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -767,11 +763,11 @@ Longest: 1</p>
</tr>
</tbody>
</table>
<p>Instead of 1, now 10 isolates are flagged. In total, 78.4% of all isolates are marked first weighted - 49.9% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>Instead of 2, now 7 isolates are flagged. In total, 78.4% of all isolates are marked first weighted - 50.1% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, theres a shortcut for this new algorithm too:</p>
<div class="sourceCode" id="cb19"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">&lt;-</span> <span class="no">data</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</pre></body></html></div>
<p>So we end up with 15,684 isolates for analysis.</p>
<p>So we end up with 15,673 isolates for analysis.</p>
<p>We can remove unneeded columns:</p>
<div class="sourceCode" id="cb20"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">&lt;-</span> <span class="no">data_1st</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(-<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="no">first</span>, <span class="no">keyab</span>))</pre></body></html></div>
@ -797,14 +793,46 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td>1</td>
<td align="center">2013-03-27</td>
<td align="center">L8</td>
<td align="center">2015-03-17</td>
<td align="center">U1</td>
<td align="center">Hospital D</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>2</td>
<td align="center">2017-08-02</td>
<td align="center">P6</td>
<td align="center">Hospital B</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">F</td>
<td align="center">Gram-positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>4</td>
<td align="center">2011-02-12</td>
<td align="center">I10</td>
<td align="center">Hospital D</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">M</td>
<td align="center">Gram-positive</td>
<td align="center">Streptococcus</td>
@ -812,41 +840,9 @@ Longest: 1</p>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>2</td>
<td align="center">2015-12-30</td>
<td align="center">K1</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>3</td>
<td align="center">2016-06-06</td>
<td align="center">D3</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>4</td>
<td align="center">2011-07-04</td>
<td align="center">H10</td>
<td>6</td>
<td align="center">2010-08-19</td>
<td align="center">A7</td>
<td align="center">Hospital D</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
@ -860,35 +856,35 @@ Longest: 1</p>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>6</td>
<td align="center">2017-03-06</td>
<td align="center">S4</td>
<td align="center">Hospital C</td>
<td align="center">B_ESCHR_COLI</td>
<td>7</td>
<td align="center">2013-04-06</td>
<td align="center">H5</td>
<td align="center">Hospital A</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">M</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>7</td>
<td align="center">2014-08-08</td>
<td align="center">C5</td>
<td>8</td>
<td align="center">2013-12-11</td>
<td align="center">J8</td>
<td align="center">Hospital C</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">B_KLBSL_PNMN</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">Klebsiella</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
</tbody>
@ -910,8 +906,8 @@ Longest: 1</p>
<div class="sourceCode" id="cb23"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="no">genus</span>, <span class="no">species</span>)</pre></body></html></div>
<p><strong>Frequency table</strong></p>
<p>Class: character<br>
Length: 15,684<br>
Available: 15,684 (100%, NA: 0 = 0%)<br>
Length: 15,673<br>
Available: 15,673 (100%, NA: 0 = 0%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -928,33 +924,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,819</td>
<td align="right">49.85%</td>
<td align="right">7,819</td>
<td align="right">49.85%</td>
<td align="right">7,843</td>
<td align="right">50.04%</td>
<td align="right">7,843</td>
<td align="right">50.04%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">3,992</td>
<td align="right">25.45%</td>
<td align="right">11,811</td>
<td align="right">75.31%</td>
<td align="right">3,949</td>
<td align="right">25.20%</td>
<td align="right">11,792</td>
<td align="right">75.24%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,332</td>
<td align="right">14.87%</td>
<td align="right">14,143</td>
<td align="right">90.17%</td>
<td align="right">2,320</td>
<td align="right">14.80%</td>
<td align="right">14,112</td>
<td align="right">90.04%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,541</td>
<td align="right">9.83%</td>
<td align="right">15,684</td>
<td align="right">1,561</td>
<td align="right">9.96%</td>
<td align="right">15,673</td>
<td align="right">100.00%</td>
</tr>
</tbody>
@ -966,7 +962,7 @@ Longest: 24</p>
<p>The functions <code><a href="../reference/proportion.html">resistance()</a></code> and <code><a href="../reference/proportion.html">susceptibility()</a></code> can be used to calculate antimicrobial resistance or susceptibility. For more specific analyses, the functions <code><a href="../reference/proportion.html">proportion_S()</a></code>, <code><a href="../reference/proportion.html">proportion_SI()</a></code>, <code><a href="../reference/proportion.html">proportion_I()</a></code>, <code><a href="../reference/proportion.html">proportion_IR()</a></code> and <code><a href="../reference/proportion.html">proportion_R()</a></code> can be used to determine the proportion of a specific antimicrobial outcome.</p>
<p>As per the EUCAST guideline of 2019, we calculate resistance as the proportion of R (<code><a href="../reference/proportion.html">proportion_R()</a></code>, equal to <code><a href="../reference/proportion.html">resistance()</a></code>) and susceptibility as the proportion of S and I (<code><a href="../reference/proportion.html">proportion_SI()</a></code>, equal to <code><a href="../reference/proportion.html">susceptibility()</a></code>). These functions can be used on their own:</p>
<div class="sourceCode" id="cb24"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">%&gt;%</span> <span class="fu"><a href="../reference/proportion.html">resistance</a></span>(<span class="no">AMX</span>)
<span class="co"># [1] 0.4410227</span></pre></body></html></div>
<span class="co"># [1] 0.441396</span></pre></body></html></div>
<p>Or can be used in conjuction with <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise()</a></code>, both from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb25"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="no">hospital</span>) <span class="kw">%&gt;%</span>
@ -979,19 +975,19 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4448217</td>
<td align="center">0.4339461</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4476345</td>
<td align="center">0.4463033</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4299828</td>
<td align="center">0.4511013</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4317450</td>
<td align="center">0.4368288</td>
</tr>
</tbody>
</table>
@ -1009,23 +1005,23 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4448217</td>
<td align="center">4712</td>
<td align="center">0.4339461</td>
<td align="center">4678</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4476345</td>
<td align="center">5538</td>
<td align="center">0.4463033</td>
<td align="center">5559</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4299828</td>
<td align="center">2328</td>
<td align="center">0.4511013</td>
<td align="center">2270</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4317450</td>
<td align="center">3106</td>
<td align="center">0.4368288</td>
<td align="center">3166</td>
</tr>
</tbody>
</table>
@ -1045,27 +1041,27 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Escherichia</td>
<td align="center">0.8199258</td>
<td align="center">0.8988362</td>
<td align="center">0.9842691</td>
<td align="center">0.8236644</td>
<td align="center">0.8999107</td>
<td align="center">0.9832972</td>
</tr>
<tr class="even">
<td align="center">Klebsiella</td>
<td align="center">0.8189487</td>
<td align="center">0.8916288</td>
<td align="center">0.9857236</td>
<td align="center">0.8315183</td>
<td align="center">0.8923767</td>
<td align="center">0.9820628</td>
</tr>
<tr class="odd">
<td align="center">Staphylococcus</td>
<td align="center">0.8166333</td>
<td align="center">0.9170842</td>
<td align="center">0.9857214</td>
<td align="center">0.8219802</td>
<td align="center">0.9161813</td>
<td align="center">0.9853127</td>
</tr>
<tr class="even">
<td align="center">Streptococcus</td>
<td align="center">0.6170669</td>
<td align="center">0.6224138</td>
<td align="center">0.0000000</td>
<td align="center">0.6170669</td>
<td align="center">0.6224138</td>
</tr>
</tbody>
</table>
@ -1141,8 +1137,7 @@ Longest: 24</p>
<a href="#independence-test" class="anchor"></a>Independence test</h2>
<p>The next example uses the <code>example_isolates</code> data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR analysis.</p>
<p>We will compare the resistance to fosfomycin (column <code>FOS</code>) in hospital A and D. The input for the <code><a href="https://rdrr.io/r/stats/fisher.test.html">fisher.test()</a></code> can be retrieved with a transformation like this:</p>
<div class="sourceCode" id="cb33"><html><body><pre class="r"><span class="co"># use package 'tidyr' to pivot data; </span>
<span class="co"># it gets installed with this 'AMR' package</span>
<div class="sourceCode" id="cb33"><html><body><pre class="r"><span class="co"># use package 'tidyr' to pivot data:</span>
<span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">tidyr</span>)
<span class="no">check_FOS</span> <span class="kw">&lt;-</span> <span class="no">example_isolates</span> <span class="kw">%&gt;%</span>
@ -1173,7 +1168,7 @@ Longest: 24</p>
<span class="co"># sample estimates:</span>
<span class="co"># odds ratio </span>
<span class="co"># 0.4488318</span></pre></body></html></div>
<p>As can be seen, the p value is 0.031, which means that the fosfomycin resistance found in hospital A and D are really different.</p>
<p>As can be seen, the p value is 0.031, which means that the fosfomycin resistance found in isolates from patients in hospital A and D are really different.</p>
</div>
</div>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -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.1.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -186,7 +186,7 @@
<h1 data-toc-skip>How to determine multi-drug resistance (MDR)</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">20 May 2020</h4>
<h4 class="date">25 May 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/MDR.Rmd"><code>vignettes/MDR.Rmd</code></a></small>
<div class="hidden name"><code>MDR.Rmd</code></div>
@ -235,9 +235,9 @@ The German national guideline - Mueller et al. (2015) Antimicrobial Resistance a
<div class="sourceCode" id="cb2"><html><body><pre class="r"><span class="no">example_isolates</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="../reference/mdro.html">mdro</a></span>() <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>() <span class="co"># show frequency table of the result</span>
<span class="co"># [34mNOTE: Using column `[1mmo[22m` as input for `col_mo`.[39m</span>
<span class="co"># [34mNOTE: Auto-guessing columns suitable for analysis...[39m[34mOK.[39m</span>
<span class="co"># [34mNOTE: Reliability would be improved if these antimicrobial results would be available too: ceftaroline ([1mCPT[22m), fusidic acid ([1mFUS[22m), telavancin ([1mTLV[22m), daptomycin ([1mDAP[22m), quinupristin/dalfopristin ([1mQDA[22m), minocycline ([1mMNO[22m), gentamicin-high ([1mGEH[22m), streptomycin-high ([1mSTH[22m), doripenem ([1mDOR[22m), levofloxacin ([1mLVX[22m), netilmicin ([1mNET[22m), ticarcillin/clavulanic acid ([1mTCC[22m), ertapenem ([1mETP[22m), cefotetan ([1mCTT[22m), aztreonam ([1mATM[22m), ampicillin/sulbactam ([1mSAM[22m), polymyxin B ([1mPLB[22m)[39m</span>
<span class="co"># NOTE: Using column `mo` as input for `col_mo`.</span>
<span class="co"># NOTE: Auto-guessing columns suitable for analysis...OK.</span>
<span class="co"># NOTE: Reliability would be improved if these antimicrobial results would be available too: ceftaroline (CPT), fusidic acid (FUS), telavancin (TLV), daptomycin (DAP), quinupristin/dalfopristin (QDA), minocycline (MNO), gentamicin-high (GEH), streptomycin-high (STH), doripenem (DOR), levofloxacin (LVX), netilmicin (NET), ticarcillin/clavulanic acid (TCC), ertapenem (ETP), cefotetan (CTT), aztreonam (ATM), ampicillin/sulbactam (SAM), polymyxin B (PLB)</span>
<span class="co"># Warning in mdro(.): NA introduced for isolates where the available percentage of</span>
<span class="co"># antimicrobial classes was below 50% (set with `pct_required_classes`)</span></pre></body></html></div>
<p><strong>Frequency table</strong></p>
@ -302,26 +302,26 @@ Unique: 2</p>
<p>The data set now looks like this:</p>
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span>(<span class="no">my_TB_data</span>)
<span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span>
<span class="co"># 1 R R R R S S</span>
<span class="co"># 2 S S S I R S</span>
<span class="co"># 3 S R S I S I</span>
<span class="co"># 4 S R S S S R</span>
<span class="co"># 5 R S R S S R</span>
<span class="co"># 6 I S R R R R</span>
<span class="co"># 1 S S R R S S</span>
<span class="co"># 2 R R S R S R</span>
<span class="co"># 3 R S S R S S</span>
<span class="co"># 4 R S S S S R</span>
<span class="co"># 5 S R R S R R</span>
<span class="co"># 6 R R R R R R</span>
<span class="co"># kanamycin</span>
<span class="co"># 1 I</span>
<span class="co"># 1 R</span>
<span class="co"># 2 S</span>
<span class="co"># 3 R</span>
<span class="co"># 4 I</span>
<span class="co"># 5 I</span>
<span class="co"># 6 S</span></pre></body></html></div>
<span class="co"># 3 S</span>
<span class="co"># 4 S</span>
<span class="co"># 5 R</span>
<span class="co"># 6 R</span></pre></body></html></div>
<p>We can now add the interpretation of MDR-TB to our data set. You can use:</p>
<div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="fu"><a href="../reference/mdro.html">mdro</a></span>(<span class="no">my_TB_data</span>, <span class="kw">guideline</span> <span class="kw">=</span> <span class="st">"TB"</span>)</pre></body></html></div>
<p>or its shortcut <code><a href="../reference/mdro.html">mdr_tb()</a></code>:</p>
<div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="no">my_TB_data</span>$<span class="no">mdr</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/mdro.html">mdr_tb</a></span>(<span class="no">my_TB_data</span>)
<span class="co"># [34mNOTE: No column found as input for `col_mo`, [1massuming all records contain [3mMycobacterium tuberculosis.[23m[22m[39m</span>
<span class="co"># [34mNOTE: Auto-guessing columns suitable for analysis...[39m[34mOK.[39m</span>
<span class="co"># [34mNOTE: Reliability would be improved if these antimicrobial results would be available too: capreomycin ([1mCAP[22m), rifabutin ([1mRIB[22m), rifapentine ([1mRFP[22m)[39m</span></pre></body></html></div>
<span class="co"># NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.</span>
<span class="co"># NOTE: Auto-guessing columns suitable for analysis...OK.</span>
<span class="co"># NOTE: Reliability would be improved if these antimicrobial results would be available too: capreomycin (CAP), rifabutin (RIB), rifapentine (RFP)</span></pre></body></html></div>
<p>Create a frequency table of the results:</p>
<div class="sourceCode" id="cb8"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="no">my_TB_data</span>$<span class="no">mdr</span>)</pre></body></html></div>
<p><strong>Frequency table</strong></p>
@ -343,40 +343,40 @@ Unique: 5</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Mono-resistant</td>
<td align="right">3288</td>
<td align="right">65.76%</td>
<td align="right">3288</td>
<td align="right">65.76%</td>
<td align="right">3239</td>
<td align="right">64.78%</td>
<td align="right">3239</td>
<td align="right">64.78%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Negative</td>
<td align="right">631</td>
<td align="right">12.62%</td>
<td align="right">3919</td>
<td align="right">78.38%</td>
<td align="right">655</td>
<td align="right">13.10%</td>
<td align="right">3894</td>
<td align="right">77.88%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Multi-drug-resistant</td>
<td align="right">582</td>
<td align="right">11.64%</td>
<td align="right">4501</td>
<td align="right">90.02%</td>
<td align="right">593</td>
<td align="right">11.86%</td>
<td align="right">4487</td>
<td align="right">89.74%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Poly-resistant</td>
<td align="right">298</td>
<td align="right">5.96%</td>
<td align="right">4799</td>
<td align="right">95.98%</td>
<td align="right">304</td>
<td align="right">6.08%</td>
<td align="right">4791</td>
<td align="right">95.82%</td>
</tr>
<tr class="odd">
<td align="left">5</td>
<td align="left">Extensively drug-resistant</td>
<td align="right">201</td>
<td align="right">4.02%</td>
<td align="right">209</td>
<td align="right">4.18%</td>
<td align="right">5000</td>
<td align="right">100.00%</td>
</tr>

View File

@ -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.1.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -186,7 +186,7 @@
<h1 data-toc-skip>How to conduct principal component analysis (PCA) for AMR</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">15 April 2020</h4>
<h4 class="date">25 May 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/PCA.Rmd"><code>vignettes/PCA.Rmd</code></a></small>
<div class="hidden name"><code>PCA.Rmd</code></div>
@ -217,47 +217,47 @@
<span class="co"># $ age &lt;dbl&gt; 65, 65, 45, 45, 45, 45, 78, 78, 45, 79, 67, 67, 71, 7…</span>
<span class="co"># $ gender &lt;chr&gt; "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M"…</span>
<span class="co"># $ patient_id &lt;chr&gt; "A77334", "A77334", "067927", "067927", "067927", "06…</span>
<span class="co"># $ mo &lt;mo&gt; B_ESCHR_COLI, B_ESCHR_COLI, B_STPHY_EPDR, B_STPHY_EPDR</span>
<span class="co"># $ PEN &lt;rsi&gt; R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R,…</span>
<span class="co"># $ OXA &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ FLC &lt;rsi&gt; NA, NA, R, R, R, R, S, S, R, S, S, S, NA, NA, NA, NA,…</span>
<span class="co"># $ AMX &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ AMC &lt;rsi&gt; I, I, NA, NA, NA, NA, S, S, NA, NA, S, S, I, I, R, I,…</span>
<span class="co"># $ AMP &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ TZP &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ CZO &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ FEP &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ CXM &lt;rsi&gt; I, I, R, R, R, R, S, S, R, S, S, S, S, S, NA, S, S, R…</span>
<span class="co"># $ FOX &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ CTX &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,…</span>
<span class="co"># $ CAZ &lt;rsi&gt; NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, …</span>
<span class="co"># $ CRO &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,…</span>
<span class="co"># $ GEN &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ TOB &lt;rsi&gt; NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, S, S, N…</span>
<span class="co"># $ AMK &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ KAN &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ TMP &lt;rsi&gt; R, R, S, S, R, R, R, R, S, S, NA, NA, S, S, S, S, S, …</span>
<span class="co"># $ SXT &lt;rsi&gt; R, R, S, S, NA, NA, NA, NA, S, S, NA, NA, S, S, S, S,…</span>
<span class="co"># $ NIT &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ FOS &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ LNZ &lt;rsi&gt; R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span>
<span class="co"># $ CIP &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA,…</span>
<span class="co"># $ MFX &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ VAN &lt;rsi&gt; R, R, S, S, S, S, S, S, S, S, NA, NA, R, R, R, R, R, …</span>
<span class="co"># $ TEC &lt;rsi&gt; R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span>
<span class="co"># $ TCY &lt;rsi&gt; R, R, S, S, S, S, S, S, S, I, S, S, NA, NA, I, R, R, …</span>
<span class="co"># $ TGC &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ DOX &lt;rsi&gt; NA, NA, S, S, S, S, S, S, S, NA, S, S, NA, NA, NA, R,…</span>
<span class="co"># $ ERY &lt;rsi&gt; R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R,…</span>
<span class="co"># $ CLI &lt;rsi&gt; NA, NA, NA, NA, NA, R, NA, NA, NA, NA, NA, NA, NA, NA…</span>
<span class="co"># $ AZM &lt;rsi&gt; R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R,…</span>
<span class="co"># $ IPM &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,…</span>
<span class="co"># $ MEM &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ MTR &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ CHL &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ COL &lt;rsi&gt; NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, …</span>
<span class="co"># $ MUP &lt;rsi&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ RIF &lt;rsi&gt; R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span></pre></body></html></div>
<span class="co"># $ mo &lt;mo&gt; "B_ESCHR_COLI", "B_ESCHR_COLI", "B_STPHY_EPDR", "B_STP…</span>
<span class="co"># $ PEN &lt;ord&gt; R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R,…</span>
<span class="co"># $ OXA &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ FLC &lt;ord&gt; NA, NA, R, R, R, R, S, S, R, S, S, S, NA, NA, NA, NA,…</span>
<span class="co"># $ AMX &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ AMC &lt;ord&gt; I, I, NA, NA, NA, NA, S, S, NA, NA, S, S, I, I, R, I,…</span>
<span class="co"># $ AMP &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ TZP &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ CZO &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ FEP &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ CXM &lt;ord&gt; I, I, R, R, R, R, S, S, R, S, S, S, S, S, NA, S, S, R…</span>
<span class="co"># $ FOX &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ CTX &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,…</span>
<span class="co"># $ CAZ &lt;ord&gt; NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, …</span>
<span class="co"># $ CRO &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,…</span>
<span class="co"># $ GEN &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ TOB &lt;ord&gt; NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, S, S, N…</span>
<span class="co"># $ AMK &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ KAN &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ TMP &lt;ord&gt; R, R, S, S, R, R, R, R, S, S, NA, NA, S, S, S, S, S, …</span>
<span class="co"># $ SXT &lt;ord&gt; R, R, S, S, NA, NA, NA, NA, S, S, NA, NA, S, S, S, S,…</span>
<span class="co"># $ NIT &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ FOS &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ LNZ &lt;ord&gt; R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span>
<span class="co"># $ CIP &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA,…</span>
<span class="co"># $ MFX &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ VAN &lt;ord&gt; R, R, S, S, S, S, S, S, S, S, NA, NA, R, R, R, R, R, …</span>
<span class="co"># $ TEC &lt;ord&gt; R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span>
<span class="co"># $ TCY &lt;ord&gt; R, R, S, S, S, S, S, S, S, I, S, S, NA, NA, I, R, R, …</span>
<span class="co"># $ TGC &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ DOX &lt;ord&gt; NA, NA, S, S, S, S, S, S, S, NA, S, S, NA, NA, NA, R,…</span>
<span class="co"># $ ERY &lt;ord&gt; R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R,…</span>
<span class="co"># $ CLI &lt;ord&gt; NA, NA, NA, NA, NA, R, NA, NA, NA, NA, NA, NA, NA, NA…</span>
<span class="co"># $ AZM &lt;ord&gt; R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R,…</span>
<span class="co"># $ IPM &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,…</span>
<span class="co"># $ MEM &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ MTR &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ CHL &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ COL &lt;ord&gt; NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, …</span>
<span class="co"># $ MUP &lt;ord&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
<span class="co"># $ RIF &lt;ord&gt; R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span></pre></body></html></div>
<p>Now to transform this to a data set with only resistance percentages per taxonomic order and genus:</p>
<div class="sourceCode" id="cb2"><html><body><pre class="r"><span class="no">resistance_data</span> <span class="kw">&lt;-</span> <span class="no">example_isolates</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="kw">order</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_order</a></span>(<span class="no">mo</span>), <span class="co"># group on anything, like order</span>
@ -283,7 +283,7 @@
<a href="#perform-principal-component-analysis" class="anchor"></a>Perform principal component analysis</h1>
<p>The new <code><a href="../reference/pca.html">pca()</a></code> function will automatically filter on rows that contain numeric values in all selected variables, so we now only need to do:</p>
<div class="sourceCode" id="cb3"><html><body><pre class="r"><span class="no">pca_result</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/pca.html">pca</a></span>(<span class="no">resistance_data</span>)
<span class="co"># NOTE: Columns selected for PCA: AMC/CXM/CTX/CAZ/GEN/TOB/TMP/SXT.</span>
<span class="co"># NOTE: Columns selected for PCA: AMC CXM CTX CAZ GEN TOB TMP SXT.</span>
<span class="co"># Total observations available: 7.</span></pre></body></html></div>
<p>The result can be reviewed with the good old <code><a href="https://rdrr.io/r/base/summary.html">summary()</a></code> function:</p>
<div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span>(<span class="no">pca_result</span>)
@ -303,8 +303,7 @@
<div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span>(<span class="no">pca_result</span>)</pre></body></html></div>
<p><img src="PCA_files/figure-html/unnamed-chunk-6-1.png" width="750"></p>
<p>You can also print an ellipse per group, and edit the appearance:</p>
<div class="sourceCode" id="cb7"><html><body><pre class="r">
<span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span>(<span class="no">pca_result</span>, <span class="kw">ellipse</span> <span class="kw">=</span> <span class="fl">TRUE</span>) +
<div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span>(<span class="no">pca_result</span>, <span class="kw">ellipse</span> <span class="kw">=</span> <span class="fl">TRUE</span>) +
<span class="kw pkg">ggplot2</span><span class="kw ns">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html">labs</a></span>(<span class="kw">title</span> <span class="kw">=</span> <span class="st">"An AMR/PCA biplot!"</span>)</pre></body></html></div>
<p><img src="PCA_files/figure-html/unnamed-chunk-7-1.png" width="750"></p>
</div>
@ -325,7 +324,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
</div>
</footer>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View File

@ -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.1.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -186,7 +186,7 @@
<h1 data-toc-skip>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">20 May 2020</h4>
<h4 class="date">25 May 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/benchmarks.Rmd"><code>vignettes/benchmarks.Rmd</code></a></small>
<div class="hidden name"><code>benchmarks.Rmd</code></div>
@ -221,21 +221,21 @@
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">10</span>)
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">S.aureus</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">2</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># as.mo("sau") 8.7 9.4 13.0 9.5 11 39.0 10</span>
<span class="co"># as.mo("stau") 140.0 150.0 160.0 170.0 180 180.0 10</span>
<span class="co"># as.mo("STAU") 140.0 140.0 160.0 150.0 170 180.0 10</span>
<span class="co"># as.mo("staaur") 8.7 9.6 16.0 11.0 11 41.0 10</span>
<span class="co"># as.mo("STAAUR") 8.7 9.2 13.0 10.0 11 37.0 10</span>
<span class="co"># as.mo("S. aureus") 10.0 12.0 23.0 13.0 39 41.0 10</span>
<span class="co"># as.mo("S aureus") 9.4 10.0 11.0 11.0 12 12.0 10</span>
<span class="co"># as.mo("Staphylococcus aureus") 7.5 7.5 8.3 8.4 9 9.3 10</span>
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 890.0 930.0 940.0 940.0 950 980.0 10</span>
<span class="co"># as.mo("Sthafilokkockus aaureuz") 370.0 390.0 420.0 400.0 440 510.0 10</span>
<span class="co"># as.mo("MRSA") 8.0 8.9 15.0 10.0 11 39.0 10</span>
<span class="co"># as.mo("VISA") 20.0 21.0 36.0 25.0 53 60.0 10</span>
<span class="co"># as.mo("VRSA") 19.0 22.0 29.0 24.0 26 53.0 10</span>
<span class="co"># as.mo(22242419) 150.0 150.0 170.0 150.0 160 290.0 10</span></pre></body></html></div>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># as.mo("sau") 9.7 11.0 15 11.0 12.0 49 10</span>
<span class="co"># as.mo("stau") 130.0 150.0 180 170.0 190.0 270 10</span>
<span class="co"># as.mo("STAU") 130.0 130.0 140 140.0 150.0 170 10</span>
<span class="co"># as.mo("staaur") 7.9 9.6 15 11.0 12.0 40 10</span>
<span class="co"># as.mo("STAAUR") 9.1 9.4 16 11.0 12.0 41 10</span>
<span class="co"># as.mo("S. aureus") 8.5 11.0 12 12.0 13.0 16 10</span>
<span class="co"># as.mo("S aureus") 8.4 11.0 17 12.0 14.0 47 10</span>
<span class="co"># as.mo("Staphylococcus aureus") 6.4 8.6 12 8.8 9.8 40 10</span>
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 830.0 860.0 910 900.0 930.0 1100 10</span>
<span class="co"># as.mo("Sthafilokkockus aaureuz") 370.0 390.0 410 400.0 430.0 440 10</span>
<span class="co"># as.mo("MRSA") 9.2 9.5 16 11.0 11.0 63 10</span>
<span class="co"># as.mo("VISA") 22.0 22.0 36 26.0 54.0 59 10</span>
<span class="co"># as.mo("VRSA") 21.0 23.0 48 27.0 55.0 180 10</span>
<span class="co"># as.mo(22242419) 150.0 160.0 160 160.0 170.0 190 10</span></pre></body></html></div>
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="562.5"></p>
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second.</p>
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside of this is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Methanosarcina semesiae</em> (<code>B_MTHNSR_SEMS</code>), a bug probably never found before in humans:</p>
@ -247,18 +247,18 @@
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">10</span>)
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">M.semesiae</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">4</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq</span>
<span class="co"># as.mo("metsem") 163.900 165.300 180.600 176.600 192.600</span>
<span class="co"># as.mo("METSEM") 153.500 156.100 177.300 176.000 200.400</span>
<span class="co"># as.mo("M. semesiae") 9.155 10.250 15.980 10.800 12.790</span>
<span class="co"># as.mo("M. semesiae") 9.498 10.160 16.700 10.560 11.050</span>
<span class="co"># as.mo("Methanosarcina semesiae") 7.006 7.345 7.993 7.814 8.413</span>
<span class="co"># max neval</span>
<span class="co"># 206.600 10</span>
<span class="co"># 206.800 10</span>
<span class="co"># 38.630 10</span>
<span class="co"># 46.810 10</span>
<span class="co"># 9.659 10</span></pre></body></html></div>
<span class="co"># expr min lq mean median uq max</span>
<span class="co"># as.mo("metsem") 152.700 163.100 172.10 171.40 176.20 213.80</span>
<span class="co"># as.mo("METSEM") 148.300 167.900 181.50 185.30 196.70 204.60</span>
<span class="co"># as.mo("M. semesiae") 8.610 9.468 13.88 10.05 15.28 35.20</span>
<span class="co"># as.mo("M. semesiae") 9.164 9.530 21.29 11.58 42.98 50.57</span>
<span class="co"># as.mo("Methanosarcina semesiae") 6.625 7.229 14.25 7.98 11.32 42.18</span>
<span class="co"># neval</span>
<span class="co"># 10</span>
<span class="co"># 10</span>
<span class="co"># 10</span>
<span class="co"># 10</span>
<span class="co"># 10</span></pre></body></html></div>
<p>Looking up arbitrary codes of less prevalent microorganisms costs the most time. Full names (like <em>Methanosarcina semesiae</em>) are always very fast and only take some thousands of seconds to coerce - they are the most probable input from most data sets.</p>
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Methanosarcina semesiae</em> (which is uncommon):</p>
<p><img src="benchmarks_files/figure-html/unnamed-chunk-6-1.png" width="900"></p>
@ -267,8 +267,7 @@
<h3 class="hasAnchor">
<a href="#repetitive-results" class="anchor"></a>Repetitive results</h3>
<p>Repetitive results are unique values that are present more than once. Unique values will only be calculated once by <code><a href="../reference/as.mo.html">as.mo()</a></code>. We will use <code><a href="../reference/mo_property.html">mo_name()</a></code> for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses <code><a href="../reference/as.mo.html">as.mo()</a></code> internally.</p>
<div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">dplyr</span>)</pre></body></html></div>
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="co"># take all MO codes from the example_isolates data set</span>
<div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="co"># take all MO codes from the example_isolates data set</span>
<span class="no">x</span> <span class="kw">&lt;-</span> <span class="no">example_isolates</span>$<span class="no">mo</span> <span class="kw">%&gt;%</span>
<span class="co"># keep only the unique ones</span>
<span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span>() <span class="kw">%&gt;%</span>
@ -293,25 +292,25 @@
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">run_it</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">3</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># mo_name(x) 1690 1710 1770 1760 1810 1870 10</span></pre></body></html></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 1.76 seconds. You only lose time on your unique input values.</p>
<span class="co"># mo_name(x) 1700 1760 1780 1770 1800 1880 10</span></pre></body></html></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 1.77 seconds. You only lose time on your unique input values.</p>
</div>
<div id="precalculated-results" class="section level3">
<h3 class="hasAnchor">
<a href="#precalculated-results" class="anchor"></a>Precalculated results</h3>
<p>What about precalculated results? If the input is an already precalculated result of a helper function like <code><a href="../reference/mo_property.html">mo_name()</a></code>, it almost doesnt take any time at all (see C below):</p>
<div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="no">run_it</span> <span class="kw">&lt;-</span> <span class="fu">microbenchmark</span>(<span class="kw">A</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"B_STPHY_AURS"</span>),
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="no">run_it</span> <span class="kw">&lt;-</span> <span class="fu">microbenchmark</span>(<span class="kw">A</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"B_STPHY_AURS"</span>),
<span class="kw">B</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"S. aureus"</span>),
<span class="kw">C</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">10</span>)
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">run_it</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">3</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># A 6.240 6.490 6.860 6.910 7.15 7.510 10</span>
<span class="co"># B 10.500 10.600 15.300 12.000 12.10 49.300 10</span>
<span class="co"># C 0.198 0.243 0.266 0.278 0.29 0.322 10</span></pre></body></html></div>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># A 5.640 5.890 10.300 6.580 6.850 44.400 10</span>
<span class="co"># B 11.000 11.300 11.500 11.400 11.500 12.400 10</span>
<span class="co"># C 0.217 0.238 0.271 0.267 0.298 0.383 10</span></pre></body></html></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0003 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
<div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="no">run_it</span> <span class="kw">&lt;-</span> <span class="fu">microbenchmark</span>(<span class="kw">A</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),
<div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="no">run_it</span> <span class="kw">&lt;-</span> <span class="fu">microbenchmark</span>(<span class="kw">A</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),
<span class="kw">B</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),
<span class="kw">C</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),
<span class="kw">D</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_family</a></span>(<span class="st">"Staphylococcaceae"</span>),
@ -323,21 +322,21 @@
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">run_it</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">3</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># A 0.248 0.253 0.266 0.256 0.271 0.323 10</span>
<span class="co"># B 0.248 0.254 0.272 0.255 0.257 0.420 10</span>
<span class="co"># C 0.245 0.259 0.265 0.268 0.271 0.286 10</span>
<span class="co"># D 0.248 0.252 0.268 0.261 0.278 0.323 10</span>
<span class="co"># E 0.250 0.256 0.265 0.261 0.268 0.312 10</span>
<span class="co"># F 0.237 0.238 0.249 0.243 0.246 0.317 10</span>
<span class="co"># G 0.239 0.242 0.252 0.245 0.245 0.319 10</span>
<span class="co"># H 0.233 0.241 0.262 0.256 0.272 0.347 10</span></pre></body></html></div>
<span class="co"># A 0.205 0.208 0.230 0.219 0.240 0.307 10</span>
<span class="co"># B 0.201 0.216 0.227 0.223 0.229 0.293 10</span>
<span class="co"># C 0.209 0.210 0.224 0.218 0.241 0.255 10</span>
<span class="co"># D 0.200 0.211 0.222 0.217 0.224 0.279 10</span>
<span class="co"># E 0.199 0.209 0.220 0.211 0.219 0.280 10</span>
<span class="co"># F 0.201 0.205 0.228 0.212 0.217 0.346 10</span>
<span class="co"># G 0.193 0.208 0.218 0.217 0.220 0.272 10</span>
<span class="co"># H 0.190 0.195 0.206 0.200 0.203 0.263 10</span></pre></body></html></div>
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> anyway, there is no point in calculating the result. And because this package knows all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
</div>
<div id="results-in-other-languages" class="section level3">
<h3 class="hasAnchor">
<a href="#results-in-other-languages" class="anchor"></a>Results in other languages</h3>
<p>When the system language is non-English and supported by this <code>AMR</code> package, some functions will have a translated result. This almost doest take extra time:</p>
<div class="sourceCode" id="cb8"><html><body><pre class="r"><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"en"</span>) <span class="co"># or just mo_name("CoNS") on an English system</span>
<div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"en"</span>) <span class="co"># or just mo_name("CoNS") on an English system</span>
<span class="co"># [1] "Coagulase-negative Staphylococcus (CoNS)"</span>
<span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"es"</span>) <span class="co"># or just mo_name("CoNS") on a Spanish system</span>
@ -357,13 +356,13 @@
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">run_it</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">4</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># en 20.99 21.59 26.64 22.35 22.94 69.49 100</span>
<span class="co"># de 22.02 22.54 26.83 22.98 23.87 63.13 100</span>
<span class="co"># nl 25.78 26.55 34.69 27.25 28.22 182.90 100</span>
<span class="co"># es 21.92 22.67 26.97 23.26 24.01 62.68 100</span>
<span class="co"># it 21.96 22.58 25.11 22.90 23.50 66.81 100</span>
<span class="co"># fr 21.82 22.76 27.53 23.26 23.84 66.75 100</span>
<span class="co"># pt 21.76 22.56 25.84 23.13 23.90 63.63 100</span></pre></body></html></div>
<span class="co"># en 20.45 21.03 25.78 21.63 27.29 71.19 100</span>
<span class="co"># de 21.48 22.06 28.50 22.81 28.56 73.54 100</span>
<span class="co"># nl 25.11 26.21 33.48 27.31 35.01 81.28 100</span>
<span class="co"># es 21.59 22.20 29.02 23.05 30.33 73.83 100</span>
<span class="co"># it 21.46 22.05 28.45 22.79 29.45 64.36 100</span>
<span class="co"># fr 21.47 22.12 31.87 22.83 31.24 174.10 100</span>
<span class="co"># pt 21.53 22.22 27.19 22.91 25.67 71.87 100</span></pre></body></html></div>
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
</div>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -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.1.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -186,7 +186,7 @@
<h1 data-toc-skip>How to predict antimicrobial resistance</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">15 April 2020</h4>
<h4 class="date">25 May 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/resistance_predict.Rmd"><code>vignettes/resistance_predict.Rmd</code></a></small>
<div class="hidden name"><code>resistance_predict.Rmd</code></div>
@ -221,7 +221,7 @@ example_isolates %&gt;%
model "binomial")
# to bind it to object 'predict_TZP' for example:
predict_TZP %
predict_TZP &lt;- example_isolates %&gt;%
resistance_predict(col_ab = "TZP",
model = "binomial")</pre></body></html></div>
<p>The function will look for a date column itself if <code>col_date</code> is not set.</p>
@ -230,36 +230,37 @@ predict_TZP %
<p>This text is only a printed summary - the actual result (output) of the function is a <code>data.frame</code> containing for each year: the number of observations, the actual observed resistance, the estimated resistance and the standard error below and above the estimation:</p>
<div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="no">predict_TZP</span>
<span class="co"># year value se_min se_max observations observed estimated</span>
<span class="co"># 1 2003 0.06250000 NA NA 32 0.06250000 0.05486389</span>
<span class="co"># 2 2004 0.08536585 NA NA 82 0.08536585 0.06089002</span>
<span class="co"># 3 2005 0.05000000 NA NA 60 0.05000000 0.06753075</span>
<span class="co"># 4 2006 0.05084746 NA NA 59 0.05084746 0.07483801</span>
<span class="co"># 5 2007 0.12121212 NA NA 66 0.12121212 0.08286570</span>
<span class="co"># 6 2008 0.04166667 NA NA 72 0.04166667 0.09166918</span>
<span class="co"># 7 2009 0.01639344 NA NA 61 0.01639344 0.10130461</span>
<span class="co"># 8 2010 0.05660377 NA NA 53 0.05660377 0.11182814</span>
<span class="co"># 9 2011 0.18279570 NA NA 93 0.18279570 0.12329488</span>
<span class="co"># 10 2012 0.30769231 NA NA 65 0.30769231 0.13575768</span>
<span class="co"># 11 2013 0.06896552 NA NA 58 0.06896552 0.14926576</span>
<span class="co"># 12 2014 0.10000000 NA NA 60 0.10000000 0.16386307</span>
<span class="co"># 13 2015 0.23636364 NA NA 55 0.23636364 0.17958657</span>
<span class="co"># 14 2016 0.22619048 NA NA 84 0.22619048 0.19646431</span>
<span class="co"># 15 2017 0.16279070 NA NA 86 0.16279070 0.21451350</span>
<span class="co"># 16 2018 0.23373852 0.2021578 0.2653193 NA NA 0.23373852</span>
<span class="co"># 17 2019 0.25412909 0.2168525 0.2914057 NA NA 0.25412909</span>
<span class="co"># 18 2020 0.27565854 0.2321869 0.3191302 NA NA 0.27565854</span>
<span class="co"># 19 2021 0.29828252 0.2481942 0.3483709 NA NA 0.29828252</span>
<span class="co"># 20 2022 0.32193804 0.2649008 0.3789753 NA NA 0.32193804</span>
<span class="co"># 21 2023 0.34654311 0.2823269 0.4107593 NA NA 0.34654311</span>
<span class="co"># 22 2024 0.37199700 0.3004860 0.4435080 NA NA 0.37199700</span>
<span class="co"># 23 2025 0.39818127 0.3193839 0.4769787 NA NA 0.39818127</span>
<span class="co"># 24 2026 0.42496142 0.3390173 0.5109056 NA NA 0.42496142</span>
<span class="co"># 25 2027 0.45218939 0.3593720 0.5450068 NA NA 0.45218939</span>
<span class="co"># 26 2028 0.47970658 0.3804212 0.5789920 NA NA 0.47970658</span>
<span class="co"># 27 2029 0.50734745 0.4021241 0.6125708 NA NA 0.50734745</span>
<span class="co"># 28 2030 0.53494347 0.4244247 0.6454622 NA NA 0.53494347</span></pre></body></html></div>
<span class="co"># 1 2002 0.20000000 NA NA 15 0.20000000 0.05616378</span>
<span class="co"># 2 2003 0.06250000 NA NA 32 0.06250000 0.06163839</span>
<span class="co"># 3 2004 0.08536585 NA NA 82 0.08536585 0.06760841</span>
<span class="co"># 4 2005 0.05000000 NA NA 60 0.05000000 0.07411100</span>
<span class="co"># 5 2006 0.05084746 NA NA 59 0.05084746 0.08118454</span>
<span class="co"># 6 2007 0.12121212 NA NA 66 0.12121212 0.08886843</span>
<span class="co"># 7 2008 0.04166667 NA NA 72 0.04166667 0.09720264</span>
<span class="co"># 8 2009 0.01639344 NA NA 61 0.01639344 0.10622731</span>
<span class="co"># 9 2010 0.05660377 NA NA 53 0.05660377 0.11598223</span>
<span class="co"># 10 2011 0.18279570 NA NA 93 0.18279570 0.12650615</span>
<span class="co"># 11 2012 0.30769231 NA NA 65 0.30769231 0.13783610</span>
<span class="co"># 12 2013 0.06896552 NA NA 58 0.06896552 0.15000651</span>
<span class="co"># 13 2014 0.10000000 NA NA 60 0.10000000 0.16304829</span>
<span class="co"># 14 2015 0.23636364 NA NA 55 0.23636364 0.17698785</span>
<span class="co"># 15 2016 0.22619048 NA NA 84 0.22619048 0.19184597</span>
<span class="co"># 16 2017 0.16279070 NA NA 86 0.16279070 0.20763675</span>
<span class="co"># 17 2018 0.22436641 0.1938710 0.2548618 NA NA 0.22436641</span>
<span class="co"># 18 2019 0.24203228 0.2062911 0.2777735 NA NA 0.24203228</span>
<span class="co"># 19 2020 0.26062172 0.2191758 0.3020676 NA NA 0.26062172</span>
<span class="co"># 20 2021 0.28011130 0.2325557 0.3276669 NA NA 0.28011130</span>
<span class="co"># 21 2022 0.30046606 0.2464567 0.3544755 NA NA 0.30046606</span>
<span class="co"># 22 2023 0.32163907 0.2609011 0.3823771 NA NA 0.32163907</span>
<span class="co"># 23 2024 0.34357130 0.2759081 0.4112345 NA NA 0.34357130</span>
<span class="co"># 24 2025 0.36619175 0.2914934 0.4408901 NA NA 0.36619175</span>
<span class="co"># 25 2026 0.38941799 0.3076686 0.4711674 NA NA 0.38941799</span>
<span class="co"># 26 2027 0.41315710 0.3244399 0.5018743 NA NA 0.41315710</span>
<span class="co"># 27 2028 0.43730688 0.3418075 0.5328063 NA NA 0.43730688</span>
<span class="co"># 28 2029 0.46175755 0.3597639 0.5637512 NA NA 0.46175755</span>
<span class="co"># 29 2030 0.48639359 0.3782932 0.5944939 NA NA 0.48639359</span></pre></body></html></div>
<p>The function <code>plot</code> is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions:</p>
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/graphics/plot.html">plot</a></span>(<span class="no">predict_TZP</span>)</pre></body></html></div>
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/plot.html">plot</a></span>(<span class="no">predict_TZP</span>)</pre></body></html></div>
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-4-1.png" width="720"></p>
<p>This is the fastest way to plot the result. It automatically adds the right axes, error bars, titles, number of available observations and type of model.</p>
<p>We also support the <code>ggplot2</code> package with our custom function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> to create more appealing plots:</p>
@ -272,7 +273,7 @@ predict_TZP %
<div id="choosing-the-right-model" class="section level3">
<h3 class="hasAnchor">
<a href="#choosing-the-right-model" class="anchor"></a>Choosing the right model</h3>
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:</p>
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram-positive bacteria, the spread (i.e. standard error) is enormous:</p>
<div class="sourceCode" id="cb8"><html><body><pre class="r"><span class="no">example_isolates</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="no">mo</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="kw">NULL</span>) <span class="kw">==</span> <span class="st">"Gram-positive"</span>) <span class="kw">%&gt;%</span>
<span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="kw">col_ab</span> <span class="kw">=</span> <span class="st">"VAN"</span>, <span class="kw">year_min</span> <span class="kw">=</span> <span class="fl">2010</span>, <span class="kw">info</span> <span class="kw">=</span> <span class="fl">FALSE</span>, <span class="kw">model</span> <span class="kw">=</span> <span class="st">"binomial"</span>) <span class="kw">%&gt;%</span>
@ -317,7 +318,7 @@ predict_TZP %
</tr>
</tbody>
</table>
<p>For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on the observed years:</p>
<p>For the vancomycin resistance in Gram-positive bacteria, a linear model might be more appropriate since no binomial distribution is to be expected based on the observed years:</p>
<div class="sourceCode" id="cb9"><html><body><pre class="r"><span class="no">example_isolates</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="no">mo</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="kw">NULL</span>) <span class="kw">==</span> <span class="st">"Gram-positive"</span>) <span class="kw">%&gt;%</span>
<span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="kw">col_ab</span> <span class="kw">=</span> <span class="st">"VAN"</span>, <span class="kw">year_min</span> <span class="kw">=</span> <span class="fl">2010</span>, <span class="kw">info</span> <span class="kw">=</span> <span class="fl">FALSE</span>, <span class="kw">model</span> <span class="kw">=</span> <span class="st">"linear"</span>) <span class="kw">%&gt;%</span>
@ -334,9 +335,9 @@ predict_TZP %
<span class="co"># Link function: logit</span>
<span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span>(<span class="no">model</span>)$<span class="no">coefficients</span>
<span class="co"># Estimate Std. Error z value Pr(&gt;|z|)</span>
<span class="co"># (Intercept) -224.3987194 48.0335384 -4.671709 2.987038e-06</span>
<span class="co"># year 0.1106102 0.0238753 4.632831 3.606990e-06</span></pre></body></html></div>
<span class="co"># Estimate Std. Error z value Pr(&gt;|z|)</span>
<span class="co"># (Intercept) -200.67944891 46.17315349 -4.346237 1.384932e-05</span>
<span class="co"># year 0.09883005 0.02295317 4.305725 1.664395e-05</span></pre></body></html></div>
</div>
</div>
</div>
@ -356,7 +357,7 @@ predict_TZP %
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
</div>
</footer>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View File

@ -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.1.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -215,6 +215,11 @@ table a:not(.btn):hover, .table a:not(.btn):hover {
font-size: 15px;
}
.template-home h4 {
padding-top: 40px !important;
font-weight: bold !important;
}
/* logos on index page */
.logo_img {
display: inline-block;

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.1.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -197,10 +197,10 @@ A methods paper about this package has been preprinted at bioRxiv (DOI: 10.1101/
<div id="what-is-amr-for-r" class="section level3">
<h3 class="hasAnchor">
<a href="#what-is-amr-for-r" class="anchor"></a>What is <code>AMR</code> (for R)?</h3>
<p><em>(To find out how to conduct AMR analysis, please <a href="./articles/AMR.html">continue reading here to get started</a>.</em></p>
<p><em>(To find out how to conduct AMR analysis, please <a href="./articles/AMR.html">continue reading here to get started</a>.)</em></p>
<p><code>AMR</code> is a free, open-source and independent <a href="https://www.r-project.org">R package</a> to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. <strong>Our aim is to provide a standard</strong> for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting.</p>
<p>After installing this package, R knows <a href="./reference/microorganisms.html"><strong>~70,000 distinct microbial species</strong></a> and all <a href="./reference/antibiotics.html"><strong>~550 antibiotic, antimycotic and antiviral drugs</strong></a> by name and code (including ATC, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data.</p>
<p>This package was created for both routine data analysis and academic research, at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology &amp; Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is <a href="./news">actively maintained</a> and is free software (see <a href="#copyright">Copyright</a>). It is fully independent of any other R package and can be used with all versions of R since R-3.0.0 (April 2013) and has a total file size of only 5 MB. It was designed to work in any setting, including those with very limited resources.</p>
<p>This package was created for both routine data analysis and academic research, at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology &amp; Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is <a href="./news">actively maintained</a> and is free software (see <a href="#copyright">Copyright</a>). It is fully independent of any other R package, can be used with all versions of R since R-3.0.0 (April 2013) and has a total file size of only 5 MB. It was designed to work in any setting, including those with very limited resources.</p>
<div class="main-content">
<p>
<a href="./countries_large.png" target="_blank"><img src="./countries.png" class="countries_map"></a> <strong>Used in more than 100 countries</strong><br> Since its first public release in early 2018, this package has been downloaded from more than 100 countries <small>(source: <a href="https://cran-logs.rstudio.com" target="_blank">CRAN logs</a>)</small>. Click the map to enlarge, to see the names of the countries.

View File

@ -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.1.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -229,13 +229,13 @@
<small>Source: <a href='https://gitlab.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="amr-1-1-0-9018" class="section level1">
<h1 class="page-header" data-toc-text="1.1.0.9018">
<a href="#amr-1-1-0-9018" class="anchor"></a>AMR 1.1.0.9018<small> Unreleased </small>
<div id="amr-1-1-0-9019" class="section level1">
<h1 class="page-header" data-toc-text="1.1.0.9019">
<a href="#amr-1-1-0-9019" class="anchor"></a>AMR 1.1.0.9019<small> Unreleased </small>
</h1>
<div id="last-updated-22-may-2020" class="section level2">
<div id="last-updated-25-may-2020" class="section level2">
<h2 class="hasAnchor">
<a href="#last-updated-22-may-2020" class="anchor"></a><small>Last updated: 22-May-2020</small>
<a href="#last-updated-25-may-2020" class="anchor"></a><small>Last updated: 25-May-2020</small>
</h2>
<div id="breaking" class="section level3">
<h3 class="hasAnchor">
@ -269,7 +269,8 @@ Negative effects of this change are:
<li>Improvements for algorithm in <code><a href="../reference/as.ab.html">as.ab()</a></code>, so that e.g. <code><a href="../reference/as.ab.html">as.ab("ampi sul")</a></code> and <code><a href="../reference/ab_property.html">ab_name("ampi sul")</a></code> work</li>
<li>Functions <code><a href="../reference/ab_property.html">ab_atc()</a></code> and <code><a href="../reference/ab_property.html">ab_group()</a></code> now return <code>NA</code> if no antimicrobial agent could be found</li>
<li>Small fix for some text input that could not be coerced as valid MIC values</li>
<li>Fixed interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)</li>
<li>Fix for interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)</li>
<li>Fix for <code><a href="../reference/mo_source.html">set_mo_source()</a></code> to make sure that column <code>mo</code> will always be the second column</li>
</ul>
</div>
<div id="other" class="section level3">

View File

@ -10,7 +10,7 @@ articles:
WHONET: WHONET.html
benchmarks: benchmarks.html
resistance_predict: resistance_predict.html
last_built: 2020-05-22T18:29Z
last_built: 2020-05-24T22:55Z
urls:
reference: https://msberends.gitlab.io/AMR/reference
article: https://msberends.gitlab.io/AMR/articles

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -311,13 +311,14 @@
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>All output will be <a href='translate.html'>translate</a>d where possible.</p>
<p>The function <code>ab_url()</code> will return the direct URL to the official WHO website. A warning will be returned if the reauired ATC code is not available.</p>
<h2 class="hasAnchor" id="maturing-lifecycle"><a class="anchor" href="#maturing-lifecycle"></a>Maturing lifecycle</h2>
<p>The function <code>ab_url()</code> will return the direct URL to the official WHO website. A warning will be returned if the required ATC code is not available.</p>
<h2 class="hasAnchor" id="stable-lifecycle"><a class="anchor" href="#stable-lifecycle"></a>Stable 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. This function needs wider usage and more extensive testing in order to optimise the unlying code.</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="source"><a class="anchor" href="#source"></a>Source</h2>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -83,7 +83,7 @@ This function requires an internet connection." />
</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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -83,7 +83,7 @@ count_resistant() should be used to count resistant isolates, count_susceptible(
</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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
</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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -295,7 +295,7 @@
<td>
<p><code><a href="mo_source.html">set_mo_source()</a></code> <code><a href="mo_source.html">get_mo_source()</a></code> </p>
</td>
<td><p>Use predefined reference data set</p></td>
<td><p>User-defined reference data set for microorganisms</p></td>
</tr>
</tbody><tbody>
<tr>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -84,7 +84,7 @@ This page contains a section for every lifecycle (with text borrowed from the af
</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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -329,6 +329,13 @@
<p>The Gram stain - <code>mo_gramstain()</code> - will be determined on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002) who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a value <code>NA</code>.</p>
<p>All output will be <a href='translate.html'>translate</a>d where possible.</p>
<p>The function <code>mo_url()</code> will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species.</p>
<h2 class="hasAnchor" id="stable-lifecycle"><a class="anchor" href="#stable-lifecycle"></a>Stable lifecycle</h2>
<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="catalogue-of-life"><a class="anchor" href="#catalogue-of-life"></a>Catalogue of Life</h2>

View File

@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Use predefined reference data set — mo_source • AMR (for R)</title>
<title>User-defined reference data set for microorganisms — mo_source • AMR (for R)</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
@ -48,7 +48,7 @@
<link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script>
<meta property="og:title" content="Use predefined reference data set — mo_source" />
<meta property="og:title" content="User-defined reference data set for microorganisms — mo_source" />
<meta property="og:description" content="These functions can be used to predefine your own reference to be used in as.mo() and consequently all mo_* functions like mo_genus() and mo_gramstain().
This is the fastest way to have your organisation (or analysis) specific codes picked up and translated by this package." />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.svg" />
@ -83,7 +83,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
</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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -227,7 +227,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Use predefined reference data set</h1>
<h1>User-defined reference data set for microorganisms</h1>
<small class="dont-index">Source: <a href='https://gitlab.com/msberends/AMR/blob/master/R/mo_source.R'><code>R/mo_source.R</code></a></small>
<div class="hidden name"><code>mo_source.Rd</code></div>
</div>
@ -246,7 +246,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>path</th>
<td><p>location of your reference file, see Details</p></td>
<td><p>location of your reference file, see Details. Can be <code>""</code>, <code>NULL</code> or <code>FALSE</code> to delete the reference file.</p></td>
</tr>
</table>
@ -255,10 +255,13 @@ This is the fastest way to have your organisation (or analysis) specific codes p
<p>The reference file can be a text file seperated with commas (CSV) or tabs or pipes, an Excel file (either 'xls' or 'xlsx' format) or an R object file (extension '.rds'). To use an Excel file, you need to have the <code>readxl</code> package installed.</p>
<p><code>set_mo_source()</code> will check the file for validity: it must be a <code><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></code>, must have a column named <code>"mo"</code> which contains values from <code><a href='microorganisms.html'>microorganisms$mo</a></code> and must have a reference column with your own defined values. If all tests pass, <code>set_mo_source()</code> will read the file into R and export it to <code>"~/.mo_source.rds"</code>. This compressed data file will then be used at default for MO determination (function <code><a href='as.mo.html'>as.mo()</a></code> and consequently all <code>mo_*</code> functions like <code><a href='mo_property.html'>mo_genus()</a></code> and <code><a href='mo_property.html'>mo_gramstain()</a></code>). The location of the original file will be saved as option with <code><a href='https://rdrr.io/r/base/options.html'>options(mo_source = path)</a></code>. Its timestamp will be saved with <code><a href='https://rdrr.io/r/base/options.html'>options(mo_source_datetime = ...)</a></code>.</p>
<p><code>get_mo_source()</code> will return the data set by reading <code>"~/.mo_source.rds"</code> with <code><a href='https://rdrr.io/r/base/readRDS.html'>readRDS()</a></code>. If the original file has changed (the file defined with <code>path</code>), it will call <code>set_mo_source()</code> to update the data file automatically.</p>
<p>Reading an Excel file (<code>.xlsx</code>) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by <code>get_mo_source()</code> in only a couple of microseconds (a millionth of a second).</p><h3>How it works</h3>
<p>Reading an Excel file (<code>.xlsx</code>) with only one row has a size of 8-9 kB. The compressed file created with <code>set_mo_source()</code> will then have a size of 0.1 kB and can be read by <code>get_mo_source()</code> in only a couple of microseconds (millionths of a second).</p>
<h2 class="hasAnchor" id="how-to-setup"><a class="anchor" href="#how-to-setup"></a>How to setup</h2>
<p>Imagine this data on a sheet of an Excel file (mo codes were looked up in the <code>microorganisms</code> data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:</p><pre> | A | B |
<p>Imagine this data on a sheet of an Excel file (mo codes were looked up in the <a href='microorganisms.html'>microorganisms</a> data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:</p><pre> | A | B |
--|--------------------|--------------|
1 | Organisation XYZ | mo |
2 | lab_mo_ecoli | B_ESCHR_COLI |
@ -267,21 +270,21 @@ This is the fastest way to have your organisation (or analysis) specific codes p
</pre>
<p>We save it as <code>"home/me/ourcodes.xlsx"</code>. Now we have to set it as a source:</p><pre><span class='fu'>set_mo_source</span>(<span class='st'>"home/me/ourcodes.xlsx"</span>)
<span class='co'># Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.</span></pre>
<span class='co'>#&amp;gt; NOTE: Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'</span>
<span class='co'>#&amp;gt; (columns "Organisation XYZ" and "mo")</span></pre>
<p>It has now created a file <code>"~/.mo_source.rds"</code> with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept.</p>
<p>And now we can use it in our functions:</p><pre>as.mo("lab_mo_ecoli")
[1] B_ESCHR_COLI
<p>It has now created a file <code>"~/.mo_source.rds"</code> with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file.</p>
<p>And now we can use it in our functions:</p><pre><span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"lab_mo_ecoli"</span>)
<span class='co'>#&amp;gt; [1] B_ESCHR_COLI</span>
mo_genus("lab_mo_kpneumoniae")
[1] "Klebsiella"
<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='st'>"lab_mo_kpneumoniae"</span>)
<span class='co'>#&amp;gt; [1] "Klebsiella"</span>
# other input values still work too
as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
[1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
</pre>
<span class='co'># other input values still work too</span>
<span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"Escherichia coli"</span>, <span class='st'>"E. coli"</span>, <span class='st'>"lab_mo_ecoli"</span>))
<span class='co'>#&amp;gt; [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI</span></pre>
<p>If we edit the Excel file to, let's say, by adding row 4 like this:</p><pre> | A | B |
<p>If we edit the Excel file by, let's say, adding row 4 like this:</p><pre> | A | B |
--|--------------------|--------------|
1 | Organisation XYZ | mo |
2 | lab_mo_ecoli | B_ESCHR_COLI |
@ -290,18 +293,18 @@ as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
5 | | |
</pre>
<p>...any new usage of an MO function in this package will update your data file:</p><pre>as.mo("lab_mo_ecoli")
# Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
[1] B_ESCHR_COLI
<p>...any new usage of an MO function in this package will update your data file:</p><pre><span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"lab_mo_ecoli"</span>)
<span class='co'>#&amp;gt; NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'</span>
<span class='co'>#&amp;gt; (columns "Organisation XYZ" and "mo")</span>
<span class='co'>#&amp;gt; [1] B_ESCHR_COLI</span>
mo_genus("lab_Staph_aureus")
[1] "Staphylococcus"
</pre>
<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='st'>"lab_Staph_aureus"</span>)
<span class='co'>#&amp;gt; [1] "Staphylococcus"</span></pre>
<p>To remove the reference data file completely, just use <code>""</code> or <code>NULL</code> as input for <code>[set_mo_source()]</code>:</p><pre><span class='fu'>set_mo_source</span>(<span class='kw'>NULL</span>)
<p>To delete the reference data file, just use <code>""</code>, <code>NULL</code> or <code>FALSE</code> as input for <code>set_mo_source()</code>:</p><pre><span class='fu'>set_mo_source</span>(<span class='kw'>NULL</span>)
<span class='co'># Removed mo_source file '~/.mo_source.rds'.</span></pre>
<p>If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of <code><a href='as.mo.html'>as.mo()</a></code>. If the mo_source file is manually deleted (i.e. without using <code>set_mo_source()</code>), the references to the mo_source file will be removed upon the next use of <code><a href='as.mo.html'>as.mo()</a></code>.</p>
<h2 class="hasAnchor" id="stable-lifecycle"><a class="anchor" href="#stable-lifecycle"></a>Stable lifecycle</h2>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -83,7 +83,7 @@ resistance() should be used to calculate resistance, susceptibility() should be
</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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -83,7 +83,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr
</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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -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.1.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>

View File

@ -5,13 +5,13 @@
### What is `AMR` (for R)?
*(To find out how to conduct AMR analysis, please [continue reading here to get started](./articles/AMR.html).*
*(To find out how to conduct AMR analysis, please [continue reading here to get started](./articles/AMR.html).)*
`AMR` is a free, open-source and independent [R package](https://www.r-project.org) to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. **Our aim is to provide a standard** for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting.
After installing this package, R knows [**~70,000 distinct microbial species**](./reference/microorganisms.html) and all [**~550 antibiotic, antimycotic and antiviral drugs**](./reference/antibiotics.html) by name and code (including ATC, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data.
This package was created for both routine data analysis and academic research, at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is [actively maintained](./news) and is free software (see [Copyright](#copyright)). It is fully independent of any other R package and can be used with all versions of R since R-3.0.0 (April 2013) and has a total file size of only 5 MB. It was designed to work in any setting, including those with very limited resources.
This package was created for both routine data analysis and academic research, at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is [actively maintained](./news) and is free software (see [Copyright](#copyright)). It is fully independent of any other R package, can be used with all versions of R since R-3.0.0 (April 2013) and has a total file size of only 5 MB. It was designed to work in any setting, including those with very limited resources.
<div class="main-content">
<p>

View File

@ -74,12 +74,14 @@ Use these functions to return a specific property of an antibiotic from the \lin
\details{
All output will be \link{translate}d where possible.
The function \code{\link[=ab_url]{ab_url()}} will return the direct URL to the official WHO website. A warning will be returned if the reauired ATC code is not available.
The function \code{\link[=ab_url]{ab_url()}} will return the direct URL to the official WHO website. A warning will be returned if the required ATC code is not available.
}
\section{Maturing lifecycle}{
\section{Stable lifecycle}{
\if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \cr}
The \link[AMR:lifecycle]{lifecycle} of this function is \strong{maturing}. The unlying code of a maturing function has been roughed out, but finer details might still change. This function needs wider usage and more extensive testing in order to optimise the unlying code.
\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr}
The \link[AMR:lifecycle]{lifecycle} of this function is \strong{stable}. 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.
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.
}
\section{Source}{

View File

@ -111,6 +111,14 @@ All output will be \link{translate}d where possible.
The function \code{\link[=mo_url]{mo_url()}} will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species.
}
\section{Stable lifecycle}{
\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr}
The \link[AMR:lifecycle]{lifecycle} of this function is \strong{stable}. 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.
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.
}
\section{Catalogue of Life}{
\if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr}

View File

@ -4,14 +4,14 @@
\alias{mo_source}
\alias{set_mo_source}
\alias{get_mo_source}
\title{Use predefined reference data set}
\title{User-defined reference data set for microorganisms}
\usage{
set_mo_source(path)
get_mo_source()
}
\arguments{
\item{path}{location of your reference file, see Details}
\item{path}{location of your reference file, see Details. Can be \code{""}, \code{NULL} or \code{FALSE} to delete the reference file.}
}
\description{
These functions can be used to predefine your own reference to be used in \code{\link[=as.mo]{as.mo()}} and consequently all \verb{mo_*} functions like \code{\link[=mo_genus]{mo_genus()}} and \code{\link[=mo_gramstain]{mo_gramstain()}}.
@ -25,10 +25,12 @@ The reference file can be a text file seperated with commas (CSV) or tabs or pip
\code{\link[=get_mo_source]{get_mo_source()}} will return the data set by reading \code{"~/.mo_source.rds"} with \code{\link[=readRDS]{readRDS()}}. If the original file has changed (the file defined with \code{path}), it will call \code{\link[=set_mo_source]{set_mo_source()}} to update the data file automatically.
Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by \code{\link[=get_mo_source]{get_mo_source()}} in only a couple of microseconds (a millionth of a second).
\subsection{How it works}{
Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The compressed file created with \code{\link[=set_mo_source]{set_mo_source()}} will then have a size of 0.1 kB and can be read by \code{\link[=get_mo_source]{get_mo_source()}} in only a couple of microseconds (millionths of a second).
}
\section{How to setup}{
Imagine this data on a sheet of an Excel file (mo codes were looked up in the \code{microorganisms} data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:\preformatted{ | A | B |
Imagine this data on a sheet of an Excel file (mo codes were looked up in the \link{microorganisms} data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:\preformatted{ | A | B |
--|--------------------|--------------|
1 | Organisation XYZ | mo |
2 | lab_mo_ecoli | B_ESCHR_COLI |
@ -37,23 +39,24 @@ Imagine this data on a sheet of an Excel file (mo codes were looked up in the \c
}
We save it as \code{"home/me/ourcodes.xlsx"}. Now we have to set it as a source:\preformatted{set_mo_source("home/me/ourcodes.xlsx")
# Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#> NOTE: Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
#> (columns "Organisation XYZ" and "mo")
}
It has now created a file \code{"~/.mo_source.rds"} with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept.
It has now created a file \code{"~/.mo_source.rds"} with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file.
And now we can use it in our functions:\preformatted{as.mo("lab_mo_ecoli")
[1] B_ESCHR_COLI
#> [1] B_ESCHR_COLI
mo_genus("lab_mo_kpneumoniae")
[1] "Klebsiella"
#> [1] "Klebsiella"
# other input values still work too
as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
[1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
#> [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
}
If we edit the Excel file to, let's say, by adding row 4 like this:\preformatted{ | A | B |
If we edit the Excel file by, let's say, adding row 4 like this:\preformatted{ | A | B |
--|--------------------|--------------|
1 | Organisation XYZ | mo |
2 | lab_mo_ecoli | B_ESCHR_COLI |
@ -63,18 +66,21 @@ If we edit the Excel file to, let's say, by adding row 4 like this:\preformatted
}
...any new usage of an MO function in this package will update your data file:\preformatted{as.mo("lab_mo_ecoli")
# Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
[1] B_ESCHR_COLI
#> NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
#> (columns "Organisation XYZ" and "mo")
#> [1] B_ESCHR_COLI
mo_genus("lab_Staph_aureus")
[1] "Staphylococcus"
#> [1] "Staphylococcus"
}
To remove the reference data file completely, just use \code{""} or \code{NULL} as input for \verb{[set_mo_source()]}:\preformatted{set_mo_source(NULL)
To delete the reference data file, just use \code{""}, \code{NULL} or \code{FALSE} as input for \code{\link[=set_mo_source]{set_mo_source()}}:\preformatted{set_mo_source(NULL)
# Removed mo_source file '~/.mo_source.rds'.
}
If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of \code{\link[=as.mo]{as.mo()}}. If the mo_source file is manually deleted (i.e. without using \code{\link[=set_mo_source]{set_mo_source()}}), the references to the mo_source file will be removed upon the next use of \code{\link[=as.mo]{as.mo()}}.
}
}
\section{Stable lifecycle}{
\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr}

View File

@ -215,6 +215,11 @@ table a:not(.btn):hover, .table a:not(.btn):hover {
font-size: 15px;
}
.template-home h4 {
padding-top: 40px !important;
font-weight: bold !important;
}
/* logos on index page */
.logo_img {
display: inline-block;

View File

@ -477,8 +477,7 @@ The next example uses the `example_isolates` data set. This is a data set includ
We will compare the resistance to fosfomycin (column `FOS`) in hospital A and D. The input for the `fisher.test()` can be retrieved with a transformation like this:
```{r, results = 'markup'}
# use package 'tidyr' to pivot data;
# it gets installed with this 'AMR' package
# use package 'tidyr' to pivot data:
library(tidyr)
check_FOS <- example_isolates %>%
@ -501,4 +500,4 @@ We can apply the test now with:
fisher.test(check_FOS)
```
As can be seen, the p value is `r round(fisher.test(check_FOS)$p.value, 3)`, which means that the fosfomycin resistance found in hospital A and D are really different.
As can be seen, the p value is `r round(fisher.test(check_FOS)$p.value, 3)`, which means that the fosfomycin resistance found in isolates from patients in hospital A and D are really different.

View File

@ -65,7 +65,6 @@ example_isolates %>%
freq() # show frequency table of the result
```
```{r, echo = FALSE, results = 'asis', message = FALSE, warning = FALSE}
library(dplyr)
example_isolates %>%
mdro(info = FALSE) %>%
freq() # show frequency table of the result

View File

@ -86,7 +86,6 @@ ggplot_pca(pca_result)
You can also print an ellipse per group, and edit the appearance:
```{r}
ggplot_pca(pca_result, ellipse = TRUE) +
ggplot2::labs(title = "An AMR/PCA biplot!")
```

View File

@ -122,9 +122,6 @@ Uncommon microorganisms take some more time than common microorganisms. To furth
Repetitive results are unique values that are present more than once. Unique values will only be calculated once by `as.mo()`. We will use `mo_name()` for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses `as.mo()` internally.
```{r, message = FALSE, eval = FALSE}
library(dplyr)
```
```{r, message = FALSE}
# take all MO codes from the example_isolates data set
x <- example_isolates$mo %>%

View File

@ -89,7 +89,7 @@ ggplot_rsi_predict(predict_TZP, ribbon = FALSE)
### Choosing the right model
Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:
Resistance is not easily predicted; if we look at vancomycin resistance in Gram-positive bacteria, the spread (i.e. standard error) is enormous:
```{r}
example_isolates %>%
@ -110,7 +110,7 @@ Valid values are:
| `"loglin"` or `"poisson"` | `glm(..., family = poisson)` | Generalised linear model with poisson distribution |
| `"lin"` or `"linear"` | `lm()` | Linear model |
For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on the observed years:
For the vancomycin resistance in Gram-positive bacteria, a linear model might be more appropriate since no binomial distribution is to be expected based on the observed years:
```{r}
example_isolates %>%