1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 21:26:11 +01:00

(v0.7.0.9013) mo_synonym fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-06-22 14:49:12 +02:00
parent 409397a337
commit c9156c004a
75 changed files with 465 additions and 507 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.7.0.9012
Date: 2019-06-18
Version: 0.7.0.9013
Date: 2019-06-22
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(

View File

@ -1,4 +1,4 @@
# AMR 0.7.0.9012
# AMR 0.7.0.9013
#### New
* Function `rsi_df()` to transform a `data.frame` to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions `count_df()` and `portion_df()` to immediately show resistance percentages and number of available isolates:
@ -12,7 +12,7 @@
# 3 Ciprofloxacin SI 0.8381831 1181
# 4 Ciprofloxacin R 0.1618169 228
```
* Support for all scientifically published pathotypes of *E. coli* to date. Supported are:
* Support for all scientifically published pathotypes of *E. coli* to date (that we could find). Supported are:
* AIEC (Adherent-Invasive *E. coli*)
* ATEC (Atypical Entero-pathogenic *E. coli*)
@ -51,9 +51,10 @@
* Fixed a EUCAST rule for Staphylococci, where amikacin resistance would not be inferred from tobramycin
* Removed `latest_annual_release` from the `catalogue_of_life_version()` function
* Removed antibiotic code `PVM1` from the `antibiotics` data set as this was a duplicate of `PME`
* Fixed bug where not all old taxonomic named would not be printed when using a vector as input for `as.mo()`
* Fixed bug where not all old taxonomic names would be printed, when using a vector as input for `as.mo()`
* Manually added *Trichomonas vaginalis* from the kingdom of Protozoa, which is missing from the Catalogue of Life
* Small improvements to `plot()` and `barplot()` for MIC and RSI classes
* Allow Catalogue of Life IDs to be coerced by `as.mo()`
#### Other
* Fixed a note thrown by CRAN tests

45
R/mo.R
View File

@ -148,9 +148,10 @@
#' as.mo("Staphylococcus aureus")
#' as.mo("Staphylococcus aureus (MRSA)")
#' as.mo("Sthafilokkockus aaureuz") # handles incorrect spelling
#' as.mo("MRSA") # Methicillin Resistant S. aureus
#' as.mo("VISA") # Vancomycin Intermediate S. aureus
#' as.mo("VRSA") # Vancomycin Resistant S. aureus
#' as.mo("MRSA") # Methicillin Resistant S. aureus
#' as.mo("VISA") # Vancomycin Intermediate S. aureus
#' as.mo("VRSA") # Vancomycin Resistant S. aureus
#' as.mo(22242419) # Catalogue of Life ID
#'
#' # Dyslexia is no problem - these all work:
#' as.mo("Ureaplasma urealyticum")
@ -232,11 +233,11 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE,
& isFALSE(Lancefield)) {
y <- x
# } else if (!any(is.na(mo_hist))
# & isFALSE(Becker)
# & isFALSE(Lancefield)) {
# # check previously found results
# y <- mo_hist
# } else if (!any(is.na(mo_hist))
# & isFALSE(Becker)
# & isFALSE(Lancefield)) {
# # check previously found results
# y <- mo_hist
} else if (all(tolower(x) %in% microorganismsDT$fullname_lower)
& isFALSE(Becker)
@ -564,6 +565,17 @@ exec_as.mo <- function(x,
next
}
found <- microorganismsDT[col_id == x_backup[i], ..property][[1]]
# is a valid Catalogue of Life ID
if (NROW(found) > 0) {
x[i] <- found[1L]
if (initial_search == TRUE) {
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history)
}
next
}
# WHONET: xxx = no growth
if (tolower(as.character(paste0(x_backup_without_spp[i], ""))) %in% c("", "xxx", "na", "nan")) {
x[i] <- NA_character_
@ -642,6 +654,18 @@ exec_as.mo <- function(x,
}
next
}
# support for:
# - AIEC (Adherent-Invasive E. coli)
# - ATEC (Atypical Entero-pathogenic E. coli)
# - DAEC (Diffusely Adhering E. coli)
# - EAEC (Entero-Aggresive E. coli)
# - EHEC (Entero-Haemorrhagic E. coli)
# - EIEC (Entero-Invasive E. coli)
# - EPEC (Entero-Pathogenic E. coli)
# - ETEC (Entero-Toxigenic E. coli)
# - NMEC (Neonatal Meningitiscausing E. coli)
# - STEC (Shiga-toxin producing E. coli)
# - UPEC (Uropathogenic E. coli)
if (toupper(x_backup_without_spp[i]) %in% c("AIEC", "ATEC", "DAEC", "EAEC", "EHEC", "EIEC", "EPEC", "ETEC", "NMEC", "STEC", "UPEC")
| x_backup_without_spp[i] %like% "O?(26|103|104|104|111|121|145|157)") {
x[i] <- microorganismsDT[mo == 'B_ESCHR_COL', ..property][[1]][1L]
@ -770,7 +794,7 @@ exec_as.mo <- function(x,
}
}
# FIRST TRY FULLNAMES AND CODES
# FIRST TRY FULLNAMES AND CODES ----
# if only genus is available, return only genus
if (all(!c(x[i], x_trimmed[i]) %like% " ")) {
found <- microorganismsDT[fullname_lower %in% tolower(c(x_species[i], x_trimmed_species[i])), ..property][[1]]
@ -1465,6 +1489,9 @@ unregex <- function(x) {
}
get_mo_code <- function(x, property) {
# don't use right now
return(NULL)
if (property == "mo") {
unique(x)
} else {

View File

@ -279,7 +279,7 @@ mo_ref <- function(x, ...) {
#' @export
mo_authors <- function(x, ...) {
x <- mo_validate(x = x, property = "ref", ...)
# remove last 4 digits and presumably the comma and space that preceeds them
# remove last 4 digits and presumably the comma and space that preceed them
x[!is.na(x)] <- gsub(",? ?[0-9]{4}", "", x[!is.na(x)])
suppressWarnings(x)
}
@ -303,35 +303,52 @@ mo_rank <- function(x, ...) {
#' @export
mo_taxonomy <- function(x, language = get_locale(), ...) {
x <- AMR::as.mo(x, ...)
base::list(kingdom = mo_kingdom(x, language = language),
phylum = mo_phylum(x, language = language),
class = mo_class(x, language = language),
order = mo_order(x, language = language),
family = mo_family(x, language = language),
genus = mo_genus(x, language = language),
species = mo_species(x, language = language),
subspecies = mo_subspecies(x, language = language))
base::list(kingdom = AMR::mo_kingdom(x, language = language),
phylum = AMR::mo_phylum(x, language = language),
class = AMR::mo_class(x, language = language),
order = AMR::mo_order(x, language = language),
family = AMR::mo_family(x, language = language),
genus = AMR::mo_genus(x, language = language),
species = AMR::mo_species(x, language = language),
subspecies = AMR::mo_subspecies(x, language = language))
}
#' @rdname mo_property
#' @export
mo_synonyms <- function(x, ...) {
x <- AMR::as.mo(x, ...)
col_id <- AMR::microorganisms[which(AMR::microorganisms$mo == x), "col_id"]
if (is.na(col_id) | !col_id %in% AMR::microorganisms.old$col_id_new) {
return(NULL)
x <- as.mo(x, ...)
IDs <- AMR::mo_property(x = x, property = "col_id", language = NULL)
syns <- lapply(IDs, function(col_id) {
res <- sort(AMR::microorganisms.old[which(AMR::microorganisms.old$col_id_new == col_id), "fullname"])
if (length(res) == 0) {
NULL
} else {
res
}
})
if (length(syns) > 1) {
names(syns) <- mo_fullname(x)
syns
} else {
unlist(syns)
}
sort(AMR::microorganisms.old[which(AMR::microorganisms.old$col_id_new == col_id), "fullname"])
}
#' @rdname mo_property
#' @export
mo_info <- function(x, language = get_locale(), ...) {
x <- AMR::as.mo(x, ...)
c(mo_taxonomy(x, language = language),
list(synonyms = mo_synonyms(x),
url = unname(mo_url(x, open = FALSE)),
ref = mo_ref(x)))
info <- lapply(x, function(y)
c(mo_taxonomy(y, language = language),
list(synonyms = mo_synonyms(y),
url = unname(mo_url(y, open = FALSE)),
ref = mo_ref(y))))
if (length(info) > 1) {
names(info) <- mo_fullname(x)
info
} else {
info[[1L]]
}
}
#' @rdname mo_property
@ -350,7 +367,7 @@ mo_url <- function(x, open = FALSE, ...) {
NA_character_))
u <- df$url
names(u) <- mo_fullname(mo)
names(u) <- AMR::mo_fullname(mo)
if (open == TRUE) {
if (length(u) > 1) {
warning("only the first URL will be opened, as `browseURL()` only suports one string.")
@ -400,12 +417,15 @@ mo_validate <- function(x, property, ...) {
if (!all(x %in% pull(AMR::microorganisms, property))
| Becker %in% c(TRUE, "all")
| Lancefield %in% c(TRUE, "all")) {
exec_as.mo(x, property = property, ...)
} else {
if (property == "mo") {
return(structure(x, class = "mo"))
} else {
return(x)
}
x <- exec_as.mo(x, property = property, ...)
}
if (property == "mo") {
return(structure(x, class = "mo"))
} else if (property == "col_id") {
return(as.integer(x))
} else {
return(x)
}
}

View File

@ -525,15 +525,19 @@ MOs <- MOs %>%
MOs <- MOs %>% arrange(fullname)
MOs.old <- MOs.old %>% arrange(fullname)
# save it
# transform
MOs <- as.data.frame(MOs, stringsAsFactors = FALSE)
MOs.old <- as.data.frame(MOs.old, stringsAsFactors = FALSE)
class(MOs$mo) <- "mo"
MOs$col_id <- as.integer(MOs$col_id)
MOs.old$col_id <- as.integer(MOs.old$col_id)
MOs.old$col_id_new <- as.integer(MOs.old$col_id_new)
# save
saveRDS(MOs, "microorganisms.rds")
saveRDS(MOs.old, "microorganisms.old.rds")
# on the server:
# on the server, do:
usethis::use_data(microorganisms, overwrite = TRUE, version = 2)
usethis::use_data(microorganisms.old, overwrite = TRUE, version = 2)
rm(microorganisms)

Binary file not shown.

Binary file not shown.

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -192,7 +192,7 @@
<h1>How to conduct AMR analysis</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">18 June 2019</h4>
<h4 class="date">22 June 2019</h4>
<div class="hidden name"><code>AMR.Rmd</code></div>
@ -201,7 +201,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 18 June 2019.</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 22 June 2019.</p>
<div id="introduction" class="section level1">
<h1 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h1>
@ -217,21 +217,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2019-06-18</td>
<td align="center">2019-06-22</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">2019-06-18</td>
<td align="center">2019-06-22</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">2019-06-18</td>
<td align="center">2019-06-22</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -327,71 +327,71 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2012-05-24</td>
<td align="center">H8</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia coli</td>
<td align="center">2014-05-06</td>
<td align="center">Y6</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">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2013-01-14</td>
<td align="center">S5</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia 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">F</td>
</tr>
<tr class="odd">
<td align="center">2011-04-02</td>
<td align="center">G2</td>
<td align="center">Hospital B</td>
<tr class="even">
<td align="center">2010-10-04</td>
<td align="center">M1</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">R</td>
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2015-04-19</td>
<td align="center">L8</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia 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">M</td>
</tr>
<tr class="even">
<td align="center">2011-09-22</td>
<td align="center">B3</td>
<td align="center">2013-08-28</td>
<td align="center">O2</td>
<td align="center">Hospital C</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">F</td>
</tr>
<tr class="odd">
<td align="center">2010-04-25</td>
<td align="center">T1</td>
<td align="center">Hospital C</td>
<td align="center">Escherichia coli</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="odd">
<td align="center">2015-07-30</td>
<td align="center">G10</td>
<td align="center">Hospital A</td>
<td align="center">Klebsiella 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">M</td>
</tr>
<tr class="even">
<td align="center">2017-10-07</td>
<td align="center">X3</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</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="even">
<td align="center">2010-05-31</td>
<td align="center">B3</td>
<td align="center">Hospital A</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>
</tbody>
</table>
<p>Now, lets start the cleaning and the analysis!</p>
@ -411,8 +411,8 @@
#
# Item Count Percent Cum. Count Cum. Percent
# --- ----- ------- -------- ----------- -------------
# 1 M 10,332 51.7% 10,332 51.7%
# 2 F 9,668 48.3% 20,000 100.0%</code></pre>
# 1 M 10,382 51.9% 10,382 51.9%
# 2 F 9,618 48.1% 20,000 100.0%</code></pre>
<p>So, we can draw at least two conclusions immediately. From a data scientists perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researchers perspective: there are slightly more men. Nothing we didnt already know.</p>
<p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The <code><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate()</a></code> function of the <code>dplyr</code> package makes this really easy:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" title="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span></a>
@ -442,14 +442,14 @@
<a class="sourceLine" id="cb14-18" title="18"><span class="co"># Pasteurella multocida (no new changes)</span></a>
<a class="sourceLine" id="cb14-19" title="19"><span class="co"># Staphylococcus (no new changes)</span></a>
<a class="sourceLine" id="cb14-20" title="20"><span class="co"># Streptococcus groups A, B, C, G (no new changes)</span></a>
<a class="sourceLine" id="cb14-21" title="21"><span class="co"># Streptococcus pneumoniae (1,428 new changes)</span></a>
<a class="sourceLine" id="cb14-21" title="21"><span class="co"># Streptococcus pneumoniae (1,472 new changes)</span></a>
<a class="sourceLine" id="cb14-22" title="22"><span class="co"># Viridans group streptococci (no new changes)</span></a>
<a class="sourceLine" id="cb14-23" title="23"><span class="co"># </span></a>
<a class="sourceLine" id="cb14-24" title="24"><span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
<a class="sourceLine" id="cb14-25" title="25"><span class="co"># Table 01: Intrinsic resistance in Enterobacteriaceae (1,339 new changes)</span></a>
<a class="sourceLine" id="cb14-25" title="25"><span class="co"># Table 01: Intrinsic resistance in Enterobacteriaceae (1,278 new changes)</span></a>
<a class="sourceLine" id="cb14-26" title="26"><span class="co"># Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no new changes)</span></a>
<a class="sourceLine" id="cb14-27" title="27"><span class="co"># Table 03: Intrinsic resistance in other Gram-negative bacteria (no new changes)</span></a>
<a class="sourceLine" id="cb14-28" title="28"><span class="co"># Table 04: Intrinsic resistance in Gram-positive bacteria (2,671 new changes)</span></a>
<a class="sourceLine" id="cb14-28" title="28"><span class="co"># Table 04: Intrinsic resistance in Gram-positive bacteria (2,802 new changes)</span></a>
<a class="sourceLine" id="cb14-29" title="29"><span class="co"># Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no new changes)</span></a>
<a class="sourceLine" id="cb14-30" title="30"><span class="co"># Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no new changes)</span></a>
<a class="sourceLine" id="cb14-31" title="31"><span class="co"># Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no new changes)</span></a>
@ -457,24 +457,24 @@
<a class="sourceLine" id="cb14-33" title="33"><span class="co"># Table 13: Interpretive rules for quinolones (no new changes)</span></a>
<a class="sourceLine" id="cb14-34" title="34"><span class="co"># </span></a>
<a class="sourceLine" id="cb14-35" title="35"><span class="co"># Other rules</span></a>
<a class="sourceLine" id="cb14-36" title="36"><span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,233 new changes)</span></a>
<a class="sourceLine" id="cb14-37" title="37"><span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (92 new changes)</span></a>
<a class="sourceLine" id="cb14-36" title="36"><span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,239 new changes)</span></a>
<a class="sourceLine" id="cb14-37" title="37"><span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (112 new changes)</span></a>
<a class="sourceLine" id="cb14-38" title="38"><span class="co"># Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no new changes)</span></a>
<a class="sourceLine" id="cb14-39" title="39"><span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no new changes)</span></a>
<a class="sourceLine" id="cb14-40" title="40"><span class="co"># Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no new changes)</span></a>
<a class="sourceLine" id="cb14-41" title="41"><span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no new changes)</span></a>
<a class="sourceLine" id="cb14-42" title="42"><span class="co"># </span></a>
<a class="sourceLine" id="cb14-43" title="43"><span class="co"># --------------------------------------------------------------------------</span></a>
<a class="sourceLine" id="cb14-44" title="44"><span class="co"># EUCAST rules affected 6,456 out of 20,000 rows, making a total of 7,763 edits</span></a>
<a class="sourceLine" id="cb14-44" title="44"><span class="co"># EUCAST rules affected 6,529 out of 20,000 rows, making a total of 7,903 edits</span></a>
<a class="sourceLine" id="cb14-45" title="45"><span class="co"># =&gt; added 0 test results</span></a>
<a class="sourceLine" id="cb14-46" title="46"><span class="co"># </span></a>
<a class="sourceLine" id="cb14-47" title="47"><span class="co"># =&gt; changed 7,763 test results</span></a>
<a class="sourceLine" id="cb14-48" title="48"><span class="co"># - 95 test results changed from S to I</span></a>
<a class="sourceLine" id="cb14-49" title="49"><span class="co"># - 4,674 test results changed from S to R</span></a>
<a class="sourceLine" id="cb14-50" title="50"><span class="co"># - 1,070 test results changed from I to S</span></a>
<a class="sourceLine" id="cb14-51" title="51"><span class="co"># - 305 test results changed from I to R</span></a>
<a class="sourceLine" id="cb14-52" title="52"><span class="co"># - 1,596 test results changed from R to S</span></a>
<a class="sourceLine" id="cb14-53" title="53"><span class="co"># - 23 test results changed from R to I</span></a>
<a class="sourceLine" id="cb14-47" title="47"><span class="co"># =&gt; changed 7,903 test results</span></a>
<a class="sourceLine" id="cb14-48" title="48"><span class="co"># - 117 test results changed from S to I</span></a>
<a class="sourceLine" id="cb14-49" title="49"><span class="co"># - 4,760 test results changed from S to R</span></a>
<a class="sourceLine" id="cb14-50" title="50"><span class="co"># - 1,044 test results changed from I to S</span></a>
<a class="sourceLine" id="cb14-51" title="51"><span class="co"># - 324 test results changed from I to R</span></a>
<a class="sourceLine" id="cb14-52" title="52"><span class="co"># - 1,642 test results changed from R to S</span></a>
<a class="sourceLine" id="cb14-53" title="53"><span class="co"># - 16 test results changed from R to I</span></a>
<a class="sourceLine" id="cb14-54" title="54"><span class="co"># --------------------------------------------------------------------------</span></a>
<a class="sourceLine" id="cb14-55" title="55"><span class="co"># </span></a>
<a class="sourceLine" id="cb14-56" title="56"><span class="co"># Use verbose = TRUE to get a data.frame with all specified edits instead.</span></a></code></pre></div>
@ -502,7 +502,7 @@
<a class="sourceLine" id="cb16-3" title="3"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
<a class="sourceLine" id="cb16-4" title="4"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
<a class="sourceLine" id="cb16-5" title="5"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb16-6" title="6"><span class="co"># =&gt; Found 5,673 first isolates (28.4% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb16-6" title="6"><span class="co"># =&gt; Found 5,683 first isolates (28.4% of total)</span></a></code></pre></div>
<p>So only 28.4% 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="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" title="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb17-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first <span class="op">==</span><span class="st"> </span><span class="ot">TRUE</span>)</a></code></pre></div>
@ -513,7 +513,7 @@
<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 W10, 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 L1, sorted on date:</p>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -529,8 +529,8 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-01-10</td>
<td align="center">W10</td>
<td align="center">2010-06-13</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -540,8 +540,8 @@
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-04-21</td>
<td align="center">W10</td>
<td align="center">2010-08-25</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -551,30 +551,30 @@
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-05-14</td>
<td align="center">W10</td>
<td align="center">2010-09-09</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-05-21</td>
<td align="center">W10</td>
<td align="center">2010-09-14</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-06-09</td>
<td align="center">W10</td>
<td align="center">2010-10-01</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
@ -584,30 +584,30 @@
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-06-19</td>
<td align="center">W10</td>
<td align="center">2010-11-15</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-07-07</td>
<td align="center">W10</td>
<td align="center">2010-12-31</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-07-10</td>
<td align="center">W10</td>
<td align="center">2011-01-14</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
@ -617,8 +617,8 @@
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2010-08-12</td>
<td align="center">W10</td>
<td align="center">2011-01-31</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -628,10 +628,10 @@
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2010-10-15</td>
<td align="center">W10</td>
<td align="center">2011-03-23</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -650,7 +650,7 @@
<a class="sourceLine" id="cb19-7" title="7"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb19-8" title="8"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></a>
<a class="sourceLine" id="cb19-9" title="9"><span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a>
<a class="sourceLine" id="cb19-10" title="10"><span class="co"># =&gt; Found 15,099 first weighted isolates (75.5% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb19-10" title="10"><span class="co"># =&gt; Found 15,191 first weighted isolates (76.0% of total)</span></a></code></pre></div>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -667,8 +667,8 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-01-10</td>
<td align="center">W10</td>
<td align="center">2010-06-13</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -679,8 +679,8 @@
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-04-21</td>
<td align="center">W10</td>
<td align="center">2010-08-25</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -691,32 +691,32 @@
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-05-14</td>
<td align="center">W10</td>
<td align="center">2010-09-09</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</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>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-05-21</td>
<td align="center">W10</td>
<td align="center">2010-09-14</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-06-09</td>
<td align="center">W10</td>
<td align="center">2010-10-01</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
@ -727,44 +727,44 @@
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-06-19</td>
<td align="center">W10</td>
<td align="center">2010-11-15</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</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">7</td>
<td align="center">2010-07-07</td>
<td align="center">W10</td>
<td align="center">2010-12-31</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-07-10</td>
<td align="center">W10</td>
<td align="center">2011-01-14</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</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>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2010-08-12</td>
<td align="center">W10</td>
<td align="center">2011-01-31</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -775,23 +775,23 @@
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2010-10-15</td>
<td align="center">W10</td>
<td align="center">2011-03-23</td>
<td align="center">L1</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</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">FALSE</td>
<td align="center">TRUE</td>
</tr>
</tbody>
</table>
<p>Instead of 1, now 7 isolates are flagged. In total, 75.5% of all isolates are marked first weighted - 47.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>Instead of 1, now 8 isolates are flagged. In total, 76% of all isolates are marked first weighted - 47.5% 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="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" title="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb20-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</a></code></pre></div>
<p>So we end up with 15,099 isolates for analysis.</p>
<p>So we end up with 15,191 isolates for analysis.</p>
<p>We can remove unneeded columns:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" title="1">data_1st &lt;-<span class="st"> </span>data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb21-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(first, keyab))</a></code></pre></div>
@ -816,31 +816,31 @@
</tr></thead>
<tbody>
<tr class="odd">
<td>2</td>
<td align="center">2013-01-14</td>
<td align="center">S5</td>
<td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td>1</td>
<td align="center">2014-05-06</td>
<td align="center">Y6</td>
<td align="center">Hospital D</td>
<td align="center">B_STRPT_PNE</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-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</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="even">
<td>3</td>
<td align="center">2011-04-02</td>
<td align="center">G2</td>
<td align="center">Hospital B</td>
<td>2</td>
<td align="center">2010-10-04</td>
<td align="center">M1</td>
<td align="center">Hospital D</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</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-negative</td>
<td align="center">Escherichia</td>
@ -848,14 +848,14 @@
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>4</td>
<td align="center">2011-09-22</td>
<td align="center">B3</td>
<td align="center">Hospital C</td>
<td>3</td>
<td align="center">2015-04-19</td>
<td align="center">L8</td>
<td align="center">Hospital D</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</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">M</td>
<td align="center">Gram-negative</td>
@ -864,51 +864,51 @@
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>5</td>
<td align="center">2015-07-30</td>
<td align="center">G10</td>
<td align="center">Hospital A</td>
<td align="center">B_KLBSL_PNE</td>
<td>4</td>
<td align="center">2013-08-28</td>
<td align="center">O2</td>
<td align="center">Hospital C</td>
<td align="center">B_STRPT_PNE</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">M</td>
<td align="center">Gram-negative</td>
<td align="center">Klebsiella</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>6</td>
<td align="center">2017-10-07</td>
<td align="center">X3</td>
<td>7</td>
<td align="center">2012-05-09</td>
<td align="center">B2</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COL</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>
<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">TRUE</td>
</tr>
<tr class="even">
<td>7</td>
<td align="center">2015-11-01</td>
<td align="center">O1</td>
<td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</td>
<td>8</td>
<td align="center">2016-11-07</td>
<td align="center">J4</td>
<td align="center">Hospital D</td>
<td align="center">B_STPHY_AUR</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>
<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>
</tbody>
@ -928,9 +928,9 @@
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb23-1" title="1"><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/paste">paste</a></span>(data_1st<span class="op">$</span>genus, data_1st<span class="op">$</span>species))</a></code></pre></div>
<p>Or can be used like the <code>dplyr</code> way, which is easier readable:</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb24-1" title="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus, species)</a></code></pre></div>
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from <code>data_1st</code> (15,099 x 13)</strong></p>
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from <code>data_1st</code> (15,191 x 13)</strong></p>
<p>Columns: 2<br>
Length: 15,099 (of which NA: 0 = 0.00%)<br>
Length: 15,191 (of which NA: 0 = 0.00%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -947,33 +947,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,513</td>
<td align="right">49.8%</td>
<td align="right">7,513</td>
<td align="right">49.8%</td>
<td align="right">7,443</td>
<td align="right">49.0%</td>
<td align="right">7,443</td>
<td align="right">49.0%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">3,708</td>
<td align="right">24.6%</td>
<td align="right">11,221</td>
<td align="right">74.3%</td>
<td align="right">3,827</td>
<td align="right">25.2%</td>
<td align="right">11,270</td>
<td align="right">74.2%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,266</td>
<td align="right">15.0%</td>
<td align="right">13,487</td>
<td align="right">89.3%</td>
<td align="right">2,353</td>
<td align="right">15.5%</td>
<td align="right">13,623</td>
<td align="right">89.7%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,612</td>
<td align="right">10.7%</td>
<td align="right">15,099</td>
<td align="right">1,568</td>
<td align="right">10.3%</td>
<td align="right">15,191</td>
<td align="right">100.0%</td>
</tr>
</tbody>
@ -984,7 +984,7 @@ Longest: 24</p>
<a href="#resistance-percentages" class="anchor"></a>Resistance percentages</h2>
<p>The functions <code><a href="../reference/portion.html">portion_S()</a></code>, <code><a href="../reference/portion.html">portion_SI()</a></code>, <code><a href="../reference/portion.html">portion_I()</a></code>, <code><a href="../reference/portion.html">portion_IR()</a></code> and <code><a href="../reference/portion.html">portion_R()</a></code> can be used to determine the portion of a specific antimicrobial outcome. As per the EUCAST guideline of 2019, we calculate resistance as the portion of R (<code><a href="../reference/portion.html">portion_R()</a></code>) and susceptibility as the portion of S and I (<code><a href="../reference/portion.html">portion_SI()</a></code>). These functions can be used on their own:</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" title="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_R</a></span>(AMX)</a>
<a class="sourceLine" id="cb25-2" title="2"><span class="co"># [1] 0.4679118</span></a></code></pre></div>
<a class="sourceLine" id="cb25-2" title="2"><span class="co"># [1] 0.4710684</span></a></code></pre></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="cb26"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb26-1" title="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb26-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital) <span class="op">%&gt;%</span><span class="st"> </span></a>
@ -997,19 +997,19 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4754386</td>
<td align="center">0.4769129</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4673058</td>
<td align="center">0.4643125</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4625054</td>
<td align="center">0.4723793</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4617169</td>
<td align="center">0.4731788</td>
</tr>
</tbody>
</table>
@ -1027,23 +1027,23 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4754386</td>
<td align="center">4560</td>
<td align="center">0.4769129</td>
<td align="center">4548</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4673058</td>
<td align="center">5215</td>
<td align="center">0.4643125</td>
<td align="center">5324</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4625054</td>
<td align="center">2307</td>
<td align="center">0.4723793</td>
<td align="center">2299</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4617169</td>
<td align="center">3017</td>
<td align="center">0.4731788</td>
<td align="center">3020</td>
</tr>
</tbody>
</table>
@ -1063,27 +1063,27 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Escherichia</td>
<td align="center">0.9237322</td>
<td align="center">0.8957806</td>
<td align="center">0.9952083</td>
<td align="center">0.9226119</td>
<td align="center">0.8988311</td>
<td align="center">0.9943571</td>
</tr>
<tr class="even">
<td align="center">Klebsiella</td>
<td align="center">0.8207196</td>
<td align="center">0.8957816</td>
<td align="center">0.9844913</td>
<td align="center">0.8010204</td>
<td align="center">0.8903061</td>
<td align="center">0.9795918</td>
</tr>
<tr class="odd">
<td align="center">Staphylococcus</td>
<td align="center">0.9161273</td>
<td align="center">0.9180151</td>
<td align="center">0.9927184</td>
<td align="center">0.9263130</td>
<td align="center">0.9140319</td>
<td align="center">0.9934675</td>
</tr>
<tr class="even">
<td align="center">Streptococcus</td>
<td align="center">0.6160635</td>
<td align="center">0.6162346</td>
<td align="center">0.0000000</td>
<td align="center">0.6160635</td>
<td align="center">0.6162346</td>
</tr>
</tbody>
</table>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -40,7 +40,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="Released version">0.7.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -125,13 +125,6 @@
Create frequency tables
</a>
</li>
<li>
<a href="../reference/g.test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -199,7 +192,7 @@
<h1>How to apply EUCAST rules</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 June 2019</h4>
<h4 class="date">22 June 2019</h4>
<div class="hidden name"><code>EUCAST.Rmd</code></div>

View File

@ -40,7 +40,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="Released version">0.7.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -125,13 +125,6 @@
Create frequency tables
</a>
</li>
<li>
<a href="../reference/g.test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -199,7 +192,7 @@
<h1>How to determine multi-drug resistance (MDR)</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 June 2019</h4>
<h4 class="date">22 June 2019</h4>
<div class="hidden name"><code>MDR.Rmd</code></div>
@ -242,19 +235,19 @@
<p>The data set looks like this now:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(my_TB_data)</a>
<a class="sourceLine" id="cb3-2" title="2"><span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span></a>
<a class="sourceLine" id="cb3-3" title="3"><span class="co"># 1 R S R R I R</span></a>
<a class="sourceLine" id="cb3-4" title="4"><span class="co"># 2 I S S I S R</span></a>
<a class="sourceLine" id="cb3-5" title="5"><span class="co"># 3 S R S R I R</span></a>
<a class="sourceLine" id="cb3-6" title="6"><span class="co"># 4 R R R R R R</span></a>
<a class="sourceLine" id="cb3-7" title="7"><span class="co"># 5 S S S S R S</span></a>
<a class="sourceLine" id="cb3-8" title="8"><span class="co"># 6 S I S R R I</span></a>
<a class="sourceLine" id="cb3-3" title="3"><span class="co"># 1 S S R S R I</span></a>
<a class="sourceLine" id="cb3-4" title="4"><span class="co"># 2 S S R S R S</span></a>
<a class="sourceLine" id="cb3-5" title="5"><span class="co"># 3 R R S S S S</span></a>
<a class="sourceLine" id="cb3-6" title="6"><span class="co"># 4 S I S I S S</span></a>
<a class="sourceLine" id="cb3-7" title="7"><span class="co"># 5 S S I I R R</span></a>
<a class="sourceLine" id="cb3-8" title="8"><span class="co"># 6 R R R R R R</span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="co"># kanamycin</span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="co"># 1 S</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co"># 2 S</span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="co"># 1 R</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co"># 2 I</span></a>
<a class="sourceLine" id="cb3-12" title="12"><span class="co"># 3 R</span></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co"># 4 I</span></a>
<a class="sourceLine" id="cb3-14" title="14"><span class="co"># 5 S</span></a>
<a class="sourceLine" id="cb3-15" title="15"><span class="co"># 6 S</span></a></code></pre></div>
<a class="sourceLine" id="cb3-14" title="14"><span class="co"># 5 R</span></a>
<a class="sourceLine" id="cb3-15" title="15"><span class="co"># 6 I</span></a></code></pre></div>
<p>We can now add the interpretation of MDR-TB to our data set:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1">my_TB_data<span class="op">$</span>mdr &lt;-<span class="st"> </span><span class="kw"><a href="../reference/mdro.html">mdr_tb</a></span>(my_TB_data)</a>
<a class="sourceLine" id="cb4-2" title="2"><span class="co"># </span><span class="al">NOTE</span><span class="co">: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.</span></a>
@ -284,40 +277,40 @@ Unique: 5</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Mono-resistance</td>
<td align="right">3,283</td>
<td align="right">3,284</td>
<td align="right">65.7%</td>
<td align="right">3,283</td>
<td align="right">3,284</td>
<td align="right">65.7%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Negative</td>
<td align="right">650</td>
<td align="right">13.0%</td>
<td align="right">3,933</td>
<td align="right">78.7%</td>
<td align="right">675</td>
<td align="right">13.5%</td>
<td align="right">3,959</td>
<td align="right">79.2%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Multidrug resistance</td>
<td align="right">593</td>
<td align="right">11.9%</td>
<td align="right">4,526</td>
<td align="right">90.5%</td>
<td align="right">570</td>
<td align="right">11.4%</td>
<td align="right">4,529</td>
<td align="right">90.6%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Poly-resistance</td>
<td align="right">259</td>
<td align="right">5.2%</td>
<td align="right">4,785</td>
<td align="right">95.7%</td>
<td align="right">263</td>
<td align="right">5.3%</td>
<td align="right">4,792</td>
<td align="right">95.8%</td>
</tr>
<tr class="odd">
<td align="left">5</td>
<td align="left">Extensive drug resistance</td>
<td align="right">215</td>
<td align="right">4.3%</td>
<td align="right">208</td>
<td align="right">4.2%</td>
<td align="right">5,000</td>
<td align="right">100.0%</td>
</tr>

View File

@ -40,7 +40,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="Released version">0.7.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -125,13 +125,6 @@
Create frequency tables
</a>
</li>
<li>
<a href="../reference/g.test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -199,7 +192,7 @@
<h1>How to import data from SPSS / SAS / Stata</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 June 2019</h4>
<h4 class="date">22 June 2019</h4>
<div class="hidden name"><code>SPSS.Rmd</code></div>
@ -259,7 +252,7 @@
<a class="sourceLine" id="cb1-8" title="8"></a>
<a class="sourceLine" id="cb1-9" title="9"><span class="co"># the Gram stain is avaiable for all bacteria:</span></a>
<a class="sourceLine" id="cb1-10" title="10"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>)</a>
<a class="sourceLine" id="cb1-11" title="11"><span class="co"># [1] "Gram negative"</span></a>
<a class="sourceLine" id="cb1-11" title="11"><span class="co"># [1] "Gram-negative"</span></a>
<a class="sourceLine" id="cb1-12" title="12"></a>
<a class="sourceLine" id="cb1-13" title="13"><span class="co"># Klebsiella is intrinsic resistant to amoxicllin, according to EUCAST:</span></a>
<a class="sourceLine" id="cb1-14" title="14">klebsiella_test &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/data.frame">data.frame</a></span>(<span class="dt">mo =</span> <span class="st">"klebsiella"</span>, </a>

View File

@ -40,7 +40,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="Released version">0.7.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -125,13 +125,6 @@
Create frequency tables
</a>
</li>
<li>
<a href="../reference/g.test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -199,7 +192,7 @@
<h1>How to work with WHONET data</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 June 2019</h4>
<h4 class="date">22 June 2019</h4>
<div class="hidden name"><code>WHONET.Rmd</code></div>

View File

@ -40,7 +40,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="Released version">0.7.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -125,13 +125,6 @@
Create frequency tables
</a>
</li>
<li>
<a href="../reference/g.test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -199,7 +192,7 @@
<h1>How to get properties of an antibiotic</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 June 2019</h4>
<h4 class="date">22 June 2019</h4>
<div class="hidden name"><code>ab_property.Rmd</code></div>

View File

@ -40,7 +40,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="Released version">0.7.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -125,13 +125,6 @@
Create frequency tables
</a>
</li>
<li>
<a href="../reference/g.test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -199,7 +192,7 @@
<h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 June 2019</h4>
<h4 class="date">22 June 2019</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div>
@ -224,14 +217,14 @@
<a class="sourceLine" id="cb2-8" title="8"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb2-9" title="9"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb2-10" title="10"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb2-11" title="11"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co"># as.mo("sau") 18 18.0 18 18.0 18.0 19 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co"># as.mo("stau") 41 41.0 50 42.0 43.0 86 10</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co"># as.mo("staaur") 18 18.0 22 18.0 18.0 64 10</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co"># as.mo("STAAUR") 18 18.0 40 19.0 63.0 97 10</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co"># as.mo("S. aureus") 28 28.0 33 28.0 29.0 73 10</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co"># as.mo("S. aureus") 28 28.0 37 28.0 28.0 120 10</span></a>
<a class="sourceLine" id="cb2-18" title="18"><span class="co"># as.mo("Staphylococcus aureus") 8 8.1 13 8.1 8.3 53 10</span></a></code></pre></div>
<a class="sourceLine" id="cb2-11" title="11"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co"># as.mo("sau") 18.0 18.0 22 18.0 18.0 63 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co"># as.mo("stau") 66.0 66.0 71 66.0 66.0 110 10</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co"># as.mo("staaur") 18.0 18.0 18 18.0 18.0 18 10</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co"># as.mo("STAAUR") 18.0 18.0 18 18.0 18.0 20 10</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co"># as.mo("S. aureus") 53.0 53.0 70 53.0 55.0 180 10</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co"># as.mo("S. aureus") 52.0 53.0 73 54.0 97.0 110 10</span></a>
<a class="sourceLine" id="cb2-18" title="18"><span class="co"># as.mo("Staphylococcus aureus") 8.2 8.2 17 8.3 8.4 53 10</span></a></code></pre></div>
<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. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.</p>
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Thermus islandicus</em> (<code>B_THERMS_ISL</code>), a bug probably never found before in humans:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1">T.islandicus &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"theisl"</span>),</a>
@ -243,12 +236,12 @@
<a class="sourceLine" id="cb3-7" title="7"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(T.islandicus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb3-8" title="8"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="co"># as.mo("theisl") 370 370 390 370 420 420 10</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co"># as.mo("THEISL") 370 420 420 420 420 440 10</span></a>
<a class="sourceLine" id="cb3-12" title="12"><span class="co"># as.mo("T. islandicus") 190 190 200 190 230 250 10</span></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co"># as.mo("T. islandicus") 190 190 210 210 230 240 10</span></a>
<a class="sourceLine" id="cb3-14" title="14"><span class="co"># as.mo("Thermus islandicus") 73 73 83 74 74 120 10</span></a></code></pre></div>
<p>That takes 8.6 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
<a class="sourceLine" id="cb3-10" title="10"><span class="co"># as.mo("theisl") 400 400 430 430 450 450 10</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co"># as.mo("THEISL") 390 400 420 420 450 460 10</span></a>
<a class="sourceLine" id="cb3-12" title="12"><span class="co"># as.mo("T. islandicus") 210 210 260 240 270 430 10</span></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co"># as.mo("T. islandicus") 210 210 250 260 260 270 10</span></a>
<a class="sourceLine" id="cb3-14" title="14"><span class="co"># as.mo("Thermus islandicus") 74 75 94 76 120 120 10</span></a></code></pre></div>
<p>That takes 7 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these 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>Thermus islandicus</em> (which is very uncommon):</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/par">par</a></span>(<span class="dt">mar =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">5</span>, <span class="dv">16</span>, <span class="dv">4</span>, <span class="dv">2</span>)) <span class="co"># set more space for left margin text (16)</span></a>
<a class="sourceLine" id="cb4-2" title="2"></a>
@ -294,8 +287,8 @@
<a class="sourceLine" id="cb5-24" title="24"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb5-25" title="25"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb5-26" title="26"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb5-27" title="27"><span class="co"># mo_fullname(x) 1220 1320 1410 1390 1540 1570 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 1.39 seconds (1393 ms). You only lose time on your unique input values.</p>
<a class="sourceLine" id="cb5-27" title="27"><span class="co"># mo_fullname(x) 1090 1130 1190 1170 1230 1320 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 1.17 seconds (1167 ms). You only lose time on your unique input values.</p>
</div>
<div id="precalculated-results" class="section level3">
<h3 class="hasAnchor">
@ -307,11 +300,11 @@
<a class="sourceLine" id="cb6-4" title="4"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb6-5" title="5"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb6-6" title="6"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb6-7" title="7"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb6-8" title="8"><span class="co"># A 13.70 13.90 14.40 14.40 14.60 15.30 10</span></a>
<a class="sourceLine" id="cb6-9" title="9"><span class="co"># B 25.60 26.10 26.80 26.80 27.40 28.30 10</span></a>
<a class="sourceLine" id="cb6-10" title="10"><span class="co"># C 1.59 1.78 1.95 1.96 2.06 2.39 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.002 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>
<a class="sourceLine" id="cb6-7" title="7"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb6-8" title="8"><span class="co"># A 13.00 13.20 13.70 13.60 14.10 14.70 10</span></a>
<a class="sourceLine" id="cb6-9" title="9"><span class="co"># B 50.40 50.90 57.80 51.80 52.80 104.00 10</span></a>
<a class="sourceLine" id="cb6-10" title="10"><span class="co"># C 1.72 1.77 1.86 1.83 1.98 2.02 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0018 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"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1">run_it &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</a>
<a class="sourceLine" id="cb7-2" title="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</a>
<a class="sourceLine" id="cb7-3" title="3"> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"Staphylococcus aureus"</span>),</a>
@ -324,14 +317,14 @@
<a class="sourceLine" id="cb7-10" title="10"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb7-11" title="11"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb7-12" title="12"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb7-13" title="13"><span class="co"># A 0.555 0.585 0.666 0.619 0.777 0.788 10</span></a>
<a class="sourceLine" id="cb7-14" title="14"><span class="co"># B 0.574 0.653 0.771 0.740 0.857 1.080 10</span></a>
<a class="sourceLine" id="cb7-15" title="15"><span class="co"># C 1.630 1.790 1.950 1.930 2.120 2.280 10</span></a>
<a class="sourceLine" id="cb7-16" title="16"><span class="co"># D 0.571 0.671 0.726 0.702 0.725 1.090 10</span></a>
<a class="sourceLine" id="cb7-17" title="17"><span class="co"># E 0.528 0.569 0.704 0.762 0.807 0.833 10</span></a>
<a class="sourceLine" id="cb7-18" title="18"><span class="co"># F 0.511 0.556 0.618 0.580 0.694 0.752 10</span></a>
<a class="sourceLine" id="cb7-19" title="19"><span class="co"># G 0.481 0.538 0.649 0.674 0.736 0.791 10</span></a>
<a class="sourceLine" id="cb7-20" title="20"><span class="co"># H 0.213 0.282 0.336 0.298 0.348 0.636 10</span></a></code></pre></div>
<a class="sourceLine" id="cb7-13" title="13"><span class="co"># A 0.591 0.635 0.719 0.681 0.808 0.968 10</span></a>
<a class="sourceLine" id="cb7-14" title="14"><span class="co"># B 0.575 0.643 0.702 0.688 0.738 0.893 10</span></a>
<a class="sourceLine" id="cb7-15" title="15"><span class="co"># C 1.550 1.660 1.780 1.730 1.920 2.170 10</span></a>
<a class="sourceLine" id="cb7-16" title="16"><span class="co"># D 0.594 0.685 0.725 0.732 0.760 0.928 10</span></a>
<a class="sourceLine" id="cb7-17" title="17"><span class="co"># E 0.584 0.614 0.667 0.650 0.730 0.782 10</span></a>
<a class="sourceLine" id="cb7-18" title="18"><span class="co"># F 0.473 0.479 0.617 0.629 0.712 0.810 10</span></a>
<a class="sourceLine" id="cb7-19" title="19"><span class="co"># G 0.495 0.526 0.576 0.559 0.602 0.756 10</span></a>
<a class="sourceLine" id="cb7-20" title="20"><span class="co"># H 0.489 0.519 0.565 0.575 0.607 0.647 10</span></a></code></pre></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> too, 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">
@ -357,14 +350,14 @@
<a class="sourceLine" id="cb8-17" title="17"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb8-18" title="18"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</a>
<a class="sourceLine" id="cb8-19" title="19"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb8-20" title="20"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb8-21" title="21"><span class="co"># en 18.63 19.06 19.30 19.19 19.41 20.33 10</span></a>
<a class="sourceLine" id="cb8-22" title="22"><span class="co"># de 21.18 21.46 21.63 21.54 21.97 22.09 10</span></a>
<a class="sourceLine" id="cb8-23" title="23"><span class="co"># nl 34.84 35.19 40.04 35.54 36.43 80.26 10</span></a>
<a class="sourceLine" id="cb8-24" title="24"><span class="co"># es 21.00 21.17 21.58 21.49 21.62 23.30 10</span></a>
<a class="sourceLine" id="cb8-25" title="25"><span class="co"># it 21.10 21.26 30.82 21.66 22.58 67.88 10</span></a>
<a class="sourceLine" id="cb8-26" title="26"><span class="co"># fr 20.99 21.25 21.88 21.54 22.50 23.15 10</span></a>
<a class="sourceLine" id="cb8-27" title="27"><span class="co"># pt 21.11 21.24 21.59 21.55 21.91 22.34 10</span></a></code></pre></div>
<a class="sourceLine" id="cb8-20" title="20"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb8-21" title="21"><span class="co"># en 43.75 43.82 44.07 43.93 44.28 44.90 10</span></a>
<a class="sourceLine" id="cb8-22" title="22"><span class="co"># de 45.96 46.09 47.68 46.20 46.65 59.40 10</span></a>
<a class="sourceLine" id="cb8-23" title="23"><span class="co"># nl 59.57 59.72 64.49 59.88 60.34 104.30 10</span></a>
<a class="sourceLine" id="cb8-24" title="24"><span class="co"># es 45.82 45.89 50.72 46.30 46.60 90.94 10</span></a>
<a class="sourceLine" id="cb8-25" title="25"><span class="co"># it 45.77 45.94 55.86 46.46 48.05 96.85 10</span></a>
<a class="sourceLine" id="cb8-26" title="26"><span class="co"># fr 45.67 45.99 55.17 46.39 46.78 92.03 10</span></a>
<a class="sourceLine" id="cb8-27" title="27"><span class="co"># pt 45.84 45.92 46.27 46.04 46.36 47.24 10</span></a></code></pre></div>
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
</div>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -40,7 +40,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="Released version">0.7.0.9000</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -125,13 +125,6 @@
Create frequency tables
</a>
</li>
<li>
<a href="../reference/g.test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -199,7 +192,7 @@
<h1>How to create frequency tables</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 June 2019</h4>
<h4 class="date">22 June 2019</h4>
<div class="hidden name"><code>freq.Rmd</code></div>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -42,7 +42,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -385,9 +385,10 @@ The <code><a href='mo_property.html'>mo_property</a></code> functions (like <cod
<span class='fu'>as.mo</span>(<span class='st'>"Staphylococcus aureus"</span>)
<span class='fu'>as.mo</span>(<span class='st'>"Staphylococcus aureus (MRSA)"</span>)
<span class='fu'>as.mo</span>(<span class='st'>"Sthafilokkockus aaureuz"</span>) <span class='co'># handles incorrect spelling</span>
<span class='fu'>as.mo</span>(<span class='st'>"MRSA"</span>) <span class='co'># Methicillin Resistant S. aureus</span>
<span class='fu'>as.mo</span>(<span class='st'>"VISA"</span>) <span class='co'># Vancomycin Intermediate S. aureus</span>
<span class='fu'>as.mo</span>(<span class='st'>"VRSA"</span>) <span class='co'># Vancomycin Resistant S. aureus</span>
<span class='fu'>as.mo</span>(<span class='st'>"MRSA"</span>) <span class='co'># Methicillin Resistant S. aureus</span>
<span class='fu'>as.mo</span>(<span class='st'>"VISA"</span>) <span class='co'># Vancomycin Intermediate S. aureus</span>
<span class='fu'>as.mo</span>(<span class='st'>"VRSA"</span>) <span class='co'># Vancomycin Resistant S. aureus</span>
<span class='fu'>as.mo</span>(<span class='fl'>22242419</span>) <span class='co'># Catalogue of Life ID</span>
<span class='co'># Dyslexia is no problem - these all work:</span>
<span class='fu'>as.mo</span>(<span class='st'>"Ureaplasma urealyticum"</span>)

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -81,7 +81,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -81,7 +81,7 @@ top_freq can be used to get the top/bottom n items of a frequency table, with co
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -237,7 +237,7 @@
<div class="ref-description">
<p>Use these functions to create bar plots for antimicrobial resistance analysis. All functions rely on internal <code><a href='https://www.rdocumentation.org/packages/ggplot2/topics/ggplot'>ggplot</a>2</code> functions.</p>
<p>Use these functions to create bar plots for antimicrobial resistance analysis. All functions rely on internal <code><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a>2</code> functions.</p>
</div>
@ -371,11 +371,11 @@
<p>At default, the names of antibiotics will be shown on the plots using <code><a href='ab_property.html'>ab_name</a></code>. This can be set with the <code>translate_ab</code> parameter. See <code><a href='count.html'>count_df</a></code>.</p>
<p><strong>The functions</strong><br />
<code>geom_rsi</code> will take any variable from the data that has an <code>rsi</code> class (created with <code><a href='as.rsi.html'>as.rsi</a></code>) using <code>fun</code> (<code><a href='count.html'>count_df</a></code> at default, can also be <code><a href='portion.html'>portion_df</a></code>) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.</p>
<p><code>facet_rsi</code> creates 2d plots (at default based on S/I/R) using <code><a href='https://www.rdocumentation.org/packages/ggplot2/topics/facet_wrap'>facet_wrap</a></code>.</p>
<p><code>facet_rsi</code> creates 2d plots (at default based on S/I/R) using <code><a href='https://ggplot2.tidyverse.org/reference/facet_wrap.html'>facet_wrap</a></code>.</p>
<p><code>scale_y_percent</code> transforms the y axis to a 0 to 100% range using <code>scale_continuous</code>.</p>
<p><code>scale_rsi_colours</code> sets colours to the bars: pastel blue for S, pastel turquoise for I and pastel red for R, using <code>scale_brewer</code>.</p>
<p><code>theme_rsi</code> is a <code>ggplot <a href='https://www.rdocumentation.org/packages/ggplot2/topics/theme'>theme</a></code> with minimal distraction.</p>
<p><code>labels_rsi_count</code> print datalabels on the bars with percentage and amount of isolates using <code><a href='https://www.rdocumentation.org/packages/ggplot2/topics/geom_text'>geom_text</a></code></p>
<p><code>theme_rsi</code> is a <code>ggplot <a href='https://ggplot2.tidyverse.org/reference/theme.html'>theme</a></code> with minimal distraction.</p>
<p><code>labels_rsi_count</code> print datalabels on the bars with percentage and amount of isolates using <code><a href='https://ggplot2.tidyverse.org/reference/geom_text.html'>geom_text</a></code></p>
<p><code>ggplot_rsi</code> is a wrapper around all above functions that uses data as first input. This makes it possible to use this function after a pipe (<code>%&gt;%</code>). See Examples.</p>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
@ -390,12 +390,12 @@
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>ggplot2</span>)
<span class='co'># get antimicrobial results for drugs against a UTI:</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/ggplot'>ggplot</a></span>(<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)) +
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)) +
<span class='fu'>geom_rsi</span>()
<span class='co'># prettify the plot using some additional functions:</span>
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/ggplot'>ggplot</a></span>(<span class='no'>df</span>) +
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>df</span>) +
<span class='fu'>geom_rsi</span>() +
<span class='fu'>scale_y_percent</span>() +
<span class='fu'>scale_rsi_colours</span>() +
@ -439,7 +439,7 @@
<span class='co'># for colourblind mode, use divergent colours from the viridis package:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>() + <span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/scale_viridis'>scale_fill_viridis_d</a></span>()
<span class='fu'>ggplot_rsi</span>() + <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_fill_viridis_d</a></span>()
<span class='co'># a shorter version which also adjusts data label colours:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

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

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -81,7 +81,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>
@ -379,21 +379,21 @@
<span class='kw'>info</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
<span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>15</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/ggplot'>ggplot</a></span>(<span class='no'>data</span>,
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/aes'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>year</span>)) +
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/geom_bar'>geom_col</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/aes'>aes</a></span>(<span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>value</span>),
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>data</span>,
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>year</span>)) +
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/geom_bar.html'>geom_col</a></span>(<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span>(<span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>value</span>),
<span class='kw'>fill</span> <span class='kw'>=</span> <span class='st'>"grey75"</span>) +
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/geom_linerange'>geom_errorbar</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/aes'>aes</a></span>(<span class='kw'>ymin</span> <span class='kw'>=</span> <span class='no'>se_min</span>,
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/geom_linerange.html'>geom_errorbar</a></span>(<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span>(<span class='kw'>ymin</span> <span class='kw'>=</span> <span class='no'>se_min</span>,
<span class='kw'>ymax</span> <span class='kw'>=</span> <span class='no'>se_max</span>),
<span class='kw'>colour</span> <span class='kw'>=</span> <span class='st'>"grey50"</span>) +
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/scale_continuous'>scale_y_continuous</a></span>(<span class='kw'>limits</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>0</span>, <span class='fl'>1</span>),
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_continuous.html'>scale_y_continuous</a></span>(<span class='kw'>limits</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>0</span>, <span class='fl'>1</span>),
<span class='kw'>breaks</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/seq'>seq</a></span>(<span class='fl'>0</span>, <span class='fl'>1</span>, <span class='fl'>0.1</span>),
<span class='kw'>labels</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/paste'>paste0</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/seq'>seq</a></span>(<span class='fl'>0</span>, <span class='fl'>100</span>, <span class='fl'>10</span>), <span class='st'>"%"</span>)) +
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/labs'>labs</a></span>(<span class='kw'>title</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/expression'>expression</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/paste'>paste</a></span>(<span class='st'>"Forecast of amoxicillin resistance in "</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='fu'><a href='https://www.rdocumentation.org/packages/base/topics/expression'>expression</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/paste'>paste</a></span>(<span class='st'>"Forecast of amoxicillin resistance in "</span>,
<span class='fu'><a href='https://www.rdocumentation.org/packages/grDevices/topics/plotmath'>italic</a></span>(<span class='st'>"E. coli"</span>))),
<span class='kw'>y</span> <span class='kw'>=</span> <span class='st'>"%IR"</span>,
<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"Year"</span>) +
<span class='fu'><a href='https://www.rdocumentation.org/packages/ggplot2/topics/ggtheme'>theme_minimal</a></span>(<span class='kw'>base_size</span> <span class='kw'>=</span> <span class='fl'>13</span>)
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggtheme.html'>theme_minimal</a></span>(<span class='kw'>base_size</span> <span class='kw'>=</span> <span class='fl'>13</span>)
}
<span class='co'># }</span></pre>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

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

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.0.9013</span>
</span>
</div>

View File

@ -158,9 +158,10 @@ as.mo("S aureus")
as.mo("Staphylococcus aureus")
as.mo("Staphylococcus aureus (MRSA)")
as.mo("Sthafilokkockus aaureuz") # handles incorrect spelling
as.mo("MRSA") # Methicillin Resistant S. aureus
as.mo("VISA") # Vancomycin Intermediate S. aureus
as.mo("VRSA") # Vancomycin Resistant S. aureus
as.mo("MRSA") # Methicillin Resistant S. aureus
as.mo("VISA") # Vancomycin Intermediate S. aureus
as.mo("VRSA") # Vancomycin Resistant S. aureus
as.mo(22242419) # Catalogue of Life ID
# Dyslexia is no problem - these all work:
as.mo("Ureaplasma urealyticum")

View File

@ -33,6 +33,7 @@ test_that("as.mo works", {
expect_equal(as.character(as.mo("Escherichia coli")), "B_ESCHR_COL")
expect_equal(as.character(as.mo("Escherichia coli")), "B_ESCHR_COL")
expect_equal(as.character(as.mo(22242416)), "B_ESCHR_COL")
expect_equal(as.character(as.mo("Escherichia species")), "B_ESCHR")
expect_equal(as.character(as.mo("Escherichia")), "B_ESCHR")
expect_equal(as.character(as.mo("Esch spp.")), "B_ESCHR")

View File

@ -38,10 +38,12 @@ test_that("mo_property works", {
expect_equal(names(mo_taxonomy("Escherichia coli")), c("kingdom", "phylum", "class", "order",
"family", "genus", "species", "subspecies"))
expect_equal(mo_synonyms("Escherichia coli"), NULL)
expect_gt(length(mo_synonyms("C. albicans")), 1)
expect_gt(length(mo_synonyms("Candida albicans")), 1)
expect_equal(class(mo_synonyms(c("Candida albicans", "Escherichia coli"))), "list")
expect_equal(names(mo_info("Escherichia coli")), c("kingdom", "phylum", "class", "order",
"family", "genus", "species", "subspecies",
"synonyms", "url", "ref"))
expect_equal(class(mo_info(c("Escherichia coli", "Staphylococcus aureus"))), "list")
expect_equal(mo_ref("Escherichia coli"), "Castellani et al., 1919")
expect_equal(mo_authors("Escherichia coli"), "Castellani et al.")

View File

@ -1,25 +0,0 @@
---
title: "How to get properties of an antibiotic"
author: "Matthijs S. Berends"
date: '`r format(Sys.Date(), "%d %B %Y")`'
output:
rmarkdown::html_vignette:
toc: true
vignette: >
%\VignetteIndexEntry{How to get properties of an antibiotic}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---
```{r setup, include = FALSE, results = 'markup'}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#"
)
# set to original language (English)
Sys.setlocale(locale = "C")
```
*(will be available soon)*

View File

@ -1,25 +0,0 @@
---
title: "How to get properties of a microorganism"
author: "Matthijs S. Berends"
date: '`r format(Sys.Date(), "%d %B %Y")`'
output:
rmarkdown::html_vignette:
toc: true
vignette: >
%\VignetteIndexEntry{How to get properties of a microorganism}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---
```{r setup, include = FALSE, results = 'markup'}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#"
)
# set to original language (English)
Sys.setlocale(locale = "C")
```
*(will be available soon)*