mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 06:02:01 +02:00
rlang dependency, new fungi
This commit is contained in:
@ -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.5.0.9019</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9020</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -192,7 +192,7 @@
|
||||
<h1>Benchmarks</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">27 February 2019</h4>
|
||||
<h4 class="date">28 February 2019</h4>
|
||||
|
||||
|
||||
<div class="hidden name"><code>benchmarks.Rmd</code></div>
|
||||
@ -217,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">3</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") 16.70 16.80 21.50 16.8 17.50 56.6 10</span></a>
|
||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> as.mo("stau") 33.70 34.00 46.60 40.2 50.50 83.7 10</span></a>
|
||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> as.mo("staaur") 16.70 16.80 28.60 17.3 41.90 59.7 10</span></a>
|
||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> as.mo("STAAUR") 16.60 16.70 21.90 17.1 20.00 56.6 10</span></a>
|
||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> as.mo("S. aureus") 24.50 24.90 25.40 25.2 26.10 26.7 10</span></a>
|
||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> as.mo("S. aureus") 24.60 25.00 31.30 25.1 25.30 85.1 10</span></a>
|
||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> as.mo("Staphylococcus aureus") 7.37 7.42 8.17 7.5 8.27 11.8 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") 16.70 16.80 17.10 16.90 17.20 18.4 10</span></a>
|
||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> as.mo("stau") 31.70 31.80 48.90 31.90 73.00 117.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> as.mo("staaur") 16.70 16.80 23.10 16.90 17.90 76.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> as.mo("STAAUR") 16.80 17.00 33.20 18.20 56.00 58.6 10</span></a>
|
||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> as.mo("S. aureus") 24.60 24.70 29.00 24.70 25.30 65.8 10</span></a>
|
||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> as.mo("S. aureus") 24.60 24.70 29.20 24.80 25.10 67.4 10</span></a>
|
||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> as.mo("Staphylococcus aureus") 7.02 7.11 7.73 7.26 7.33 11.9 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 <-<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>
|
||||
@ -235,13 +235,13 @@
|
||||
<a class="sourceLine" id="cb3-6" title="6"> <span class="dt">times =</span> <span class="dv">10</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-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") 289.0 291.0 314.0 312.0 336.0 343 10</span></a>
|
||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> as.mo("THEISL") 290.0 293.0 319.0 331.0 337.0 344 10</span></a>
|
||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> as.mo("T. islandicus") 73.5 73.8 90.6 75.1 114.0 118 10</span></a>
|
||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> as.mo("T. islandicus") 73.7 73.9 78.5 74.6 74.7 115 10</span></a>
|
||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> as.mo("Thermus islandicus") 66.5 67.3 80.3 69.5 107.0 108 10</span></a></code></pre></div>
|
||||
<p>That takes 6.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>
|
||||
<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") 262.0 292.0 296.0 304.0 310 312 10</span></a>
|
||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> as.mo("THEISL") 261.0 263.0 286.0 288.0 307 311 10</span></a>
|
||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> as.mo("T. islandicus") 142.0 143.0 164.0 165.0 184 187 10</span></a>
|
||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> as.mo("T. islandicus") 142.0 143.0 170.0 163.0 192 229 10</span></a>
|
||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> as.mo("Thermus islandicus") 67.7 68.1 94.3 89.4 117 132 10</span></a></code></pre></div>
|
||||
<p>That takes 7.5 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>
|
||||
@ -260,7 +260,7 @@
|
||||
<div id="repetitive-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#repetitive-results" class="anchor"></a>Repetitive results</h3>
|
||||
<p>Repetitive results mean that unique values are present more than once. Unique values will only be calculated once by <code><a href="../reference/as.mo.html">as.mo()</a></code>. We will use <code><a href="../reference/mo_property.html">mo_fullname()</a></code> for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses <code><a href="../reference/as.mo.html">as.mo()</a></code> internally.</p>
|
||||
<p>Repetitive results are unique values that are present more than once. Unique values will only be calculated once by <code><a href="../reference/as.mo.html">as.mo()</a></code>. We will use <code><a href="../reference/mo_property.html">mo_fullname()</a></code> for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses <code><a href="../reference/as.mo.html">as.mo()</a></code> internally.</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(dplyr)</a>
|
||||
<a class="sourceLine" id="cb5-2" title="2"><span class="co"># take all MO codes from the septic_patients data set</span></a>
|
||||
<a class="sourceLine" id="cb5-3" title="3">x <-<span class="st"> </span>septic_patients<span class="op">$</span>mo <span class="op">%>%</span></a>
|
||||
@ -286,9 +286,9 @@
|
||||
<a class="sourceLine" id="cb5-23" title="23"> <span class="dt">times =</span> <span class="dv">10</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-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) 732 768 800 794 799 949 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.79 seconds (793 ms). You only lose time on your unique input values.</p>
|
||||
<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) 732 739 818 819 837 1040 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.82 seconds (818 ms). You only lose time on your unique input values.</p>
|
||||
</div>
|
||||
<div id="precalculated-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -301,10 +301,10 @@
|
||||
<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 10.900 11.300 11.900 11.500 11.700 15.200 10</span></a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#> B 22.000 22.600 26.900 22.600 22.800 62.400 10</span></a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#> C 0.311 0.502 0.531 0.533 0.577 0.765 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.0005 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>
|
||||
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#> A 11.100 11.300 11.500 11.500 11.600 11.700 10</span></a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#> B 22.200 22.500 22.800 22.900 23.000 23.500 10</span></a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#> C 0.325 0.566 0.571 0.579 0.599 0.704 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>
|
||||
<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-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>
|
||||
@ -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-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.274 0.333 0.417 0.412 0.481 0.611 10</span></a>
|
||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#> B 0.337 0.353 0.403 0.411 0.438 0.461 10</span></a>
|
||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#> C 0.336 0.362 0.530 0.528 0.682 0.755 10</span></a>
|
||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#> D 0.263 0.316 0.340 0.331 0.360 0.474 10</span></a>
|
||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#> E 0.252 0.326 0.326 0.329 0.345 0.389 10</span></a>
|
||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#> F 0.250 0.300 0.319 0.327 0.351 0.351 10</span></a>
|
||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#> G 0.240 0.246 0.288 0.277 0.325 0.351 10</span></a>
|
||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#> H 0.242 0.257 0.304 0.294 0.332 0.395 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#> A 0.308 0.392 0.419 0.406 0.478 0.524 10</span></a>
|
||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#> B 0.377 0.406 0.424 0.418 0.442 0.486 10</span></a>
|
||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#> C 0.359 0.516 0.580 0.574 0.664 0.730 10</span></a>
|
||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#> D 0.266 0.326 0.337 0.342 0.350 0.383 10</span></a>
|
||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#> E 0.254 0.281 0.332 0.336 0.359 0.446 10</span></a>
|
||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#> F 0.237 0.315 0.329 0.340 0.360 0.374 10</span></a>
|
||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#> G 0.261 0.295 0.318 0.323 0.341 0.390 10</span></a>
|
||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#> H 0.271 0.290 0.321 0.317 0.343 0.403 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">
|
||||
@ -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-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 14.68 15.11 15.28 15.27 15.34 16.21 10</span></a>
|
||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#> de 23.53 23.65 24.04 23.82 24.63 24.88 10</span></a>
|
||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#> nl 23.36 23.53 27.76 23.81 23.87 63.45 10</span></a>
|
||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#> es 23.59 23.83 23.94 23.96 24.07 24.22 10</span></a>
|
||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#> it 23.30 23.76 27.92 23.83 24.18 64.01 10</span></a>
|
||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#> fr 23.47 23.78 31.80 23.84 24.90 63.25 10</span></a>
|
||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#> pt 23.28 23.69 27.97 23.85 24.42 64.14 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#> en 15.06 15.54 22.29 15.71 31.46 40.83 10</span></a>
|
||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#> de 23.57 23.91 28.72 24.04 26.24 47.77 10</span></a>
|
||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#> nl 23.46 23.87 33.14 24.71 45.69 68.77 10</span></a>
|
||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#> es 23.76 23.98 37.40 24.72 46.85 90.39 10</span></a>
|
||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#> it 23.98 24.07 30.76 24.49 25.18 67.52 10</span></a>
|
||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#> fr 24.03 24.04 27.06 24.14 26.51 47.08 10</span></a>
|
||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#> pt 23.66 24.00 30.90 24.17 25.84 65.76 10</span></a></code></pre></div>
|
||||
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user