mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 09:26:13 +01:00
WHONET fix
This commit is contained in:
parent
0c0c6e289b
commit
b319b89750
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 0.5.0.9021
|
Version: 0.5.0.9021
|
||||||
Date: 2019-03-06
|
Date: 2019-03-09
|
||||||
Title: Antimicrobial Resistance Analysis
|
Title: Antimicrobial Resistance Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(
|
person(
|
||||||
|
10
R/mo.R
10
R/mo.R
@ -122,6 +122,7 @@
|
|||||||
#' @importFrom dplyr %>% pull left_join
|
#' @importFrom dplyr %>% pull left_join
|
||||||
#' @examples
|
#' @examples
|
||||||
#' # These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
#' # These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
||||||
|
#' as.mo("sau") # WHONET code
|
||||||
#' as.mo("stau")
|
#' as.mo("stau")
|
||||||
#' as.mo("STAU")
|
#' as.mo("STAU")
|
||||||
#' as.mo("staaur")
|
#' as.mo("staaur")
|
||||||
@ -598,6 +599,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
|
|||||||
}
|
}
|
||||||
|
|
||||||
# TRY OTHER SOURCES ----
|
# TRY OTHER SOURCES ----
|
||||||
|
# WHONET and other common LIS codes
|
||||||
if (toupper(x_backup[i]) %in% AMR::microorganisms.codes[, 1]) {
|
if (toupper(x_backup[i]) %in% AMR::microorganisms.codes[, 1]) {
|
||||||
mo_found <- AMR::microorganisms.codes[toupper(x_backup[i]) == AMR::microorganisms.codes[, 1], "mo"][1L]
|
mo_found <- AMR::microorganisms.codes[toupper(x_backup[i]) == AMR::microorganisms.codes[, 1], "mo"][1L]
|
||||||
if (length(mo_found) > 0) {
|
if (length(mo_found) > 0) {
|
||||||
@ -606,6 +608,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is.null(reference_df)) {
|
if (!is.null(reference_df)) {
|
||||||
|
# self-defined reference
|
||||||
if (x_backup[i] %in% reference_df[, 1]) {
|
if (x_backup[i] %in% reference_df[, 1]) {
|
||||||
ref_mo <- reference_df[reference_df[, 1] == x_backup[i], "mo"]
|
ref_mo <- reference_df[reference_df[, 1] == x_backup[i], "mo"]
|
||||||
if (ref_mo %in% microorganismsDT[, mo]) {
|
if (ref_mo %in% microorganismsDT[, mo]) {
|
||||||
@ -617,6 +620,13 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# allow no codes less than 4 characters long, was already checked for WHONET above
|
||||||
|
if (nchar(x_trimmed[i]) < 4) {
|
||||||
|
x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]]
|
||||||
|
failures <- c(failures, x_backup[i])
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
check_per_prevalence <- function(data_to_check,
|
check_per_prevalence <- function(data_to_check,
|
||||||
a.x_backup,
|
a.x_backup,
|
||||||
b.x_trimmed,
|
b.x_trimmed,
|
||||||
|
@ -222,32 +222,32 @@ mo_genus <- function(x, language = get_locale(), ...) {
|
|||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
#' @export
|
#' @export
|
||||||
mo_family <- function(x, ...) {
|
mo_family <- function(x, language = get_locale(), ...) {
|
||||||
mo_validate(x = x, property = "family", ...)
|
mo_translate(mo_validate(x = x, property = "family", ...), language = language)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
#' @export
|
#' @export
|
||||||
mo_order <- function(x, ...) {
|
mo_order <- function(x, language = get_locale(), ...) {
|
||||||
mo_validate(x = x, property = "order", ...)
|
mo_translate(mo_validate(x = x, property = "order", ...), language = language)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
#' @export
|
#' @export
|
||||||
mo_class <- function(x, ...) {
|
mo_class <- function(x, language = get_locale(), ...) {
|
||||||
mo_validate(x = x, property = "class", ...)
|
mo_translate(mo_validate(x = x, property = "class", ...), language = language)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
#' @export
|
#' @export
|
||||||
mo_phylum <- function(x, ...) {
|
mo_phylum <- function(x, language = get_locale(), ...) {
|
||||||
mo_validate(x = x, property = "phylum", ...)
|
mo_translate(mo_validate(x = x, property = "phylum", ...), language = language)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
#' @export
|
#' @export
|
||||||
mo_kingdom <- function(x, ...) {
|
mo_kingdom <- function(x, language = get_locale(), ...) {
|
||||||
mo_validate(x = x, property = "kingdom", ...)
|
mo_translate(mo_validate(x = x, property = "kingdom", ...), language = language)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
@ -306,16 +306,16 @@ mo_rank <- function(x, ...) {
|
|||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
#' @export
|
#' @export
|
||||||
mo_taxonomy <- function(x, ...) {
|
mo_taxonomy <- function(x, language = get_locale(), ...) {
|
||||||
x <- AMR::as.mo(x, ...)
|
x <- AMR::as.mo(x, ...)
|
||||||
base::list(kingdom = mo_kingdom(x),
|
base::list(kingdom = mo_kingdom(x, language = language),
|
||||||
phylum = mo_phylum(x),
|
phylum = mo_phylum(x, language = language),
|
||||||
class = mo_class(x),
|
class = mo_class(x, language = language),
|
||||||
order = mo_order(x),
|
order = mo_order(x, language = language),
|
||||||
family = mo_family(x),
|
family = mo_family(x, language = language),
|
||||||
genus = mo_genus(x),
|
genus = mo_genus(x, language = language),
|
||||||
species = mo_species(x),
|
species = mo_species(x, language = language),
|
||||||
subspecies = mo_subspecies(x))
|
subspecies = mo_subspecies(x, language = language))
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mo_property
|
#' @rdname mo_property
|
||||||
|
@ -192,7 +192,7 @@
|
|||||||
<h1>How to import data from SPSS / SAS / Stata</h1>
|
<h1>How to import data from SPSS / SAS / Stata</h1>
|
||||||
<h4 class="author">Matthijs S. Berends</h4>
|
<h4 class="author">Matthijs S. Berends</h4>
|
||||||
|
|
||||||
<h4 class="date">06 March 2019</h4>
|
<h4 class="date">09 March 2019</h4>
|
||||||
|
|
||||||
|
|
||||||
<div class="hidden name"><code>SPSS.Rmd</code></div>
|
<div class="hidden name"><code>SPSS.Rmd</code></div>
|
||||||
|
@ -192,7 +192,7 @@
|
|||||||
<h1>Benchmarks</h1>
|
<h1>Benchmarks</h1>
|
||||||
<h4 class="author">Matthijs S. Berends</h4>
|
<h4 class="author">Matthijs S. Berends</h4>
|
||||||
|
|
||||||
<h4 class="date">06 March 2019</h4>
|
<h4 class="date">09 March 2019</h4>
|
||||||
|
|
||||||
|
|
||||||
<div class="hidden name"><code>benchmarks.Rmd</code></div>
|
<div class="hidden name"><code>benchmarks.Rmd</code></div>
|
||||||
@ -218,13 +218,13 @@
|
|||||||
<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">3</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">3</span>)</a>
|
||||||
<a class="sourceLine" id="cb2-10" title="10"><span class="co">#> Unit: milliseconds</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-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") 16.50 16.60 17.0 16.70 17.00 19.0 10</span></a>
|
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#> as.mo("sau") 16.60 16.60 25.2 16.80 18.00 58.3 10</span></a>
|
||||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> as.mo("stau") 31.70 31.90 51.5 32.10 49.10 166.0 10</span></a>
|
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> as.mo("stau") 31.60 31.80 44.8 32.40 72.20 76.7 10</span></a>
|
||||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> as.mo("staaur") 16.60 16.70 21.8 16.80 17.00 65.7 10</span></a>
|
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> as.mo("staaur") 16.60 16.60 26.4 16.70 17.30 71.9 10</span></a>
|
||||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> as.mo("STAAUR") 16.70 16.70 27.1 16.80 17.60 77.3 10</span></a>
|
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> as.mo("STAAUR") 16.50 16.60 16.6 16.60 16.70 16.8 10</span></a>
|
||||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> as.mo("S. aureus") 24.60 24.70 30.2 25.30 31.80 57.8 10</span></a>
|
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> as.mo("S. aureus") 24.50 24.60 29.0 24.70 25.00 66.6 10</span></a>
|
||||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> as.mo("S. aureus") 24.60 24.60 37.7 25.10 66.00 67.4 10</span></a>
|
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> as.mo("S. aureus") 24.30 24.60 24.6 24.60 24.70 24.9 10</span></a>
|
||||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> as.mo("Staphylococcus aureus") 7.47 7.48 11.1 7.65 8.02 41.1 10</span></a></code></pre></div>
|
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> as.mo("Staphylococcus aureus") 7.45 7.47 11.9 7.53 7.97 50.0 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>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>
|
<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 <-<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>
|
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1">T.islandicus <-<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>
|
||||||
@ -236,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">3</span>)</a>
|
<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">3</span>)</a>
|
||||||
<a class="sourceLine" id="cb3-8" title="8"><span class="co">#> Unit: milliseconds</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-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") 269.0 270.0 294.0 293.0 317 320 10</span></a>
|
<a class="sourceLine" id="cb3-10" title="10"><span class="co">#> as.mo("theisl") 262.0 263.0 284.0 284.0 304 308 10</span></a>
|
||||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> as.mo("THEISL") 272.0 313.0 327.0 316.0 321 476 10</span></a>
|
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> as.mo("THEISL") 263.0 264.0 293.0 304.0 306 308 10</span></a>
|
||||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> as.mo("T. islandicus") 142.0 142.0 159.0 144.0 191 205 10</span></a>
|
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> as.mo("T. islandicus") 142.0 142.0 151.0 143.0 147 187 10</span></a>
|
||||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> as.mo("T. islandicus") 142.0 143.0 166.0 164.0 188 196 10</span></a>
|
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> as.mo("T. islandicus") 142.0 142.0 169.0 184.0 185 194 10</span></a>
|
||||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> as.mo("Thermus islandicus") 68.4 68.6 86.8 69.2 113 116 10</span></a></code></pre></div>
|
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> as.mo("Thermus islandicus") 67.9 68.1 93.3 90.3 116 130 10</span></a></code></pre></div>
|
||||||
<p>That takes 7.4 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>That takes 7.8 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>
|
<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>
|
<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>
|
<a class="sourceLine" id="cb4-2" title="2"></a>
|
||||||
@ -287,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-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-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-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) 688 757 800 758 919 921 10</span></a></code></pre></div>
|
<a class="sourceLine" id="cb5-27" title="27"><span class="co">#> mo_fullname(x) 734 810 840 817 860 973 10</span></a></code></pre></div>
|
||||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.76 seconds (758 ms). You only lose time on your unique input values.</p>
|
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.82 seconds (817 ms). You only lose time on your unique input values.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="precalculated-results" class="section level3">
|
<div id="precalculated-results" class="section level3">
|
||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
@ -301,9 +301,9 @@
|
|||||||
<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-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-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-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 11.200 11.300 11.900 12.200 12.300 12.600 10</span></a>
|
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#> A 11.200 11.300 11.400 11.400 11.600 11.600 10</span></a>
|
||||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#> B 22.300 22.500 23.300 23.100 23.900 24.700 10</span></a>
|
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#> B 22.200 22.400 26.800 22.600 22.800 63.700 10</span></a>
|
||||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#> C 0.339 0.519 0.612 0.564 0.768 0.776 10</span></a></code></pre></div>
|
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#> C 0.328 0.564 0.525 0.568 0.577 0.591 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.0006 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0006 seconds - it doesn’t 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 <-<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>
|
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1">run_it <-<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-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>
|
||||||
@ -317,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-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-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-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.321 0.434 0.481 0.501 0.519 0.665 10</span></a>
|
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#> A 0.318 0.376 0.414 0.419 0.449 0.537 10</span></a>
|
||||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#> B 0.352 0.414 0.482 0.475 0.513 0.715 10</span></a>
|
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#> B 0.343 0.397 0.437 0.447 0.479 0.522 10</span></a>
|
||||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#> C 0.394 0.648 0.670 0.679 0.770 0.839 10</span></a>
|
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#> C 0.325 0.380 0.486 0.482 0.554 0.703 10</span></a>
|
||||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#> D 0.354 0.371 0.393 0.395 0.410 0.428 10</span></a>
|
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#> D 0.334 0.337 0.381 0.372 0.426 0.434 10</span></a>
|
||||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#> E 0.286 0.353 0.370 0.369 0.399 0.443 10</span></a>
|
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#> E 0.304 0.322 0.356 0.335 0.393 0.460 10</span></a>
|
||||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#> F 0.317 0.373 0.377 0.380 0.392 0.437 10</span></a>
|
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#> F 0.295 0.323 0.370 0.362 0.424 0.463 10</span></a>
|
||||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#> G 0.272 0.307 0.352 0.348 0.387 0.431 10</span></a>
|
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#> G 0.296 0.321 0.362 0.348 0.387 0.470 10</span></a>
|
||||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#> H 0.293 0.338 0.366 0.361 0.412 0.441 10</span></a></code></pre></div>
|
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#> H 0.289 0.335 0.355 0.351 0.387 0.421 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>
|
<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>
|
||||||
<div id="results-in-other-languages" class="section level3">
|
<div id="results-in-other-languages" class="section level3">
|
||||||
@ -351,13 +351,13 @@
|
|||||||
<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-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-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-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 14.97 15.49 15.46 15.56 15.60 15.65 10</span></a>
|
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#> en 15.57 15.87 24.21 20.71 37.98 38.78 10</span></a>
|
||||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#> de 27.29 27.76 44.46 27.98 69.27 71.00 10</span></a>
|
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#> de 28.79 34.96 53.24 52.02 56.97 95.22 10</span></a>
|
||||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#> nl 27.22 27.97 28.53 28.03 29.40 31.36 10</span></a>
|
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#> nl 28.31 29.29 47.74 40.57 58.94 97.03 10</span></a>
|
||||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#> es 27.45 27.96 32.24 28.00 28.08 69.99 10</span></a>
|
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#> es 28.97 30.43 42.78 34.70 51.47 72.11 10</span></a>
|
||||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#> it 27.21 27.32 28.01 27.89 28.05 29.41 10</span></a>
|
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#> it 27.71 29.15 38.88 31.19 35.10 76.86 10</span></a>
|
||||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#> fr 27.26 27.94 28.16 28.12 28.25 29.47 10</span></a>
|
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#> fr 28.37 29.28 40.89 41.73 50.43 56.78 10</span></a>
|
||||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#> pt 27.08 27.45 36.14 27.92 28.07 70.34 10</span></a></code></pre></div>
|
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#> pt 27.82 29.03 42.49 29.84 50.14 94.96 10</span></a></code></pre></div>
|
||||||
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
@ -366,6 +366,7 @@ The <code><a href='mo_property.html'>mo_property</a></code> functions (like <cod
|
|||||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||||
<pre class="examples"><span class='co'># NOT RUN {</span>
|
<pre class="examples"><span class='co'># NOT RUN {</span>
|
||||||
<span class='co'># These examples all return "B_STPHY_AUR", the ID of S. aureus:</span>
|
<span class='co'># These examples all return "B_STPHY_AUR", the ID of S. aureus:</span>
|
||||||
|
<span class='fu'>as.mo</span>(<span class='st'>"sau"</span>) <span class='co'># WHONET code</span>
|
||||||
<span class='fu'>as.mo</span>(<span class='st'>"stau"</span>)
|
<span class='fu'>as.mo</span>(<span class='st'>"stau"</span>)
|
||||||
<span class='fu'>as.mo</span>(<span class='st'>"STAU"</span>)
|
<span class='fu'>as.mo</span>(<span class='st'>"STAU"</span>)
|
||||||
<span class='fu'>as.mo</span>(<span class='st'>"staaur"</span>)
|
<span class='fu'>as.mo</span>(<span class='st'>"staaur"</span>)
|
||||||
|
@ -251,15 +251,15 @@
|
|||||||
|
|
||||||
<span class='fu'>mo_genus</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
<span class='fu'>mo_genus</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
||||||
|
|
||||||
<span class='fu'>mo_family</span>(<span class='no'>x</span>, <span class='no'>...</span>)
|
<span class='fu'>mo_family</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
||||||
|
|
||||||
<span class='fu'>mo_order</span>(<span class='no'>x</span>, <span class='no'>...</span>)
|
<span class='fu'>mo_order</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
||||||
|
|
||||||
<span class='fu'>mo_class</span>(<span class='no'>x</span>, <span class='no'>...</span>)
|
<span class='fu'>mo_class</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
||||||
|
|
||||||
<span class='fu'>mo_phylum</span>(<span class='no'>x</span>, <span class='no'>...</span>)
|
<span class='fu'>mo_phylum</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
||||||
|
|
||||||
<span class='fu'>mo_kingdom</span>(<span class='no'>x</span>, <span class='no'>...</span>)
|
<span class='fu'>mo_kingdom</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
||||||
|
|
||||||
<span class='fu'>mo_type</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
<span class='fu'>mo_type</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
||||||
|
|
||||||
@ -273,7 +273,7 @@
|
|||||||
|
|
||||||
<span class='fu'>mo_rank</span>(<span class='no'>x</span>, <span class='no'>...</span>)
|
<span class='fu'>mo_rank</span>(<span class='no'>x</span>, <span class='no'>...</span>)
|
||||||
|
|
||||||
<span class='fu'>mo_taxonomy</span>(<span class='no'>x</span>, <span class='no'>...</span>)
|
<span class='fu'>mo_taxonomy</span>(<span class='no'>x</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='get_locale.html'>get_locale</a></span>(), <span class='no'>...</span>)
|
||||||
|
|
||||||
<span class='fu'>mo_url</span>(<span class='no'>x</span>, <span class='kw'>open</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='no'>...</span>)
|
<span class='fu'>mo_url</span>(<span class='no'>x</span>, <span class='kw'>open</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='no'>...</span>)
|
||||||
|
|
||||||
|
@ -138,6 +138,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
|||||||
|
|
||||||
\examples{
|
\examples{
|
||||||
# These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
# These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
||||||
|
as.mo("sau") # WHONET code
|
||||||
as.mo("stau")
|
as.mo("stau")
|
||||||
as.mo("STAU")
|
as.mo("STAU")
|
||||||
as.mo("staaur")
|
as.mo("staaur")
|
||||||
|
@ -32,15 +32,15 @@ mo_species(x, language = get_locale(), ...)
|
|||||||
|
|
||||||
mo_genus(x, language = get_locale(), ...)
|
mo_genus(x, language = get_locale(), ...)
|
||||||
|
|
||||||
mo_family(x, ...)
|
mo_family(x, language = get_locale(), ...)
|
||||||
|
|
||||||
mo_order(x, ...)
|
mo_order(x, language = get_locale(), ...)
|
||||||
|
|
||||||
mo_class(x, ...)
|
mo_class(x, language = get_locale(), ...)
|
||||||
|
|
||||||
mo_phylum(x, ...)
|
mo_phylum(x, language = get_locale(), ...)
|
||||||
|
|
||||||
mo_kingdom(x, ...)
|
mo_kingdom(x, language = get_locale(), ...)
|
||||||
|
|
||||||
mo_type(x, language = get_locale(), ...)
|
mo_type(x, language = get_locale(), ...)
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ mo_year(x, ...)
|
|||||||
|
|
||||||
mo_rank(x, ...)
|
mo_rank(x, ...)
|
||||||
|
|
||||||
mo_taxonomy(x, ...)
|
mo_taxonomy(x, language = get_locale(), ...)
|
||||||
|
|
||||||
mo_url(x, open = FALSE, ...)
|
mo_url(x, open = FALSE, ...)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user