mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 22:41:52 +02:00
(v0.6.1.9044) first_isolate fix for species
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.6.1.9040</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9044</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -199,7 +199,7 @@
|
||||
<h1>Benchmarks</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">28 May 2019</h4>
|
||||
<h4 class="date">31 May 2019</h4>
|
||||
|
||||
|
||||
<div class="hidden name"><code>benchmarks.Rmd</code></div>
|
||||
@ -224,14 +224,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.0 18 28 18 18.0 76 10</span></a>
|
||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co"># as.mo("stau") 48.0 48 70 48 92.0 130 10</span></a>
|
||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co"># as.mo("staaur") 18.0 18 18 18 18.0 19 10</span></a>
|
||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co"># as.mo("STAAUR") 17.0 17 27 18 18.0 63 10</span></a>
|
||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co"># as.mo("S. aureus") 28.0 28 29 28 29.0 29 10</span></a>
|
||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co"># as.mo("S. aureus") 28.0 28 29 28 29.0 30 10</span></a>
|
||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co"># as.mo("Staphylococcus aureus") 7.9 8 17 8 8.1 52 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") 17 18 24 18 18 78.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co"># as.mo("stau") 48 48 52 48 48 92.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co"># as.mo("staaur") 18 18 27 18 18 62.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co"># as.mo("STAAUR") 18 18 18 18 18 18.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co"># as.mo("S. aureus") 28 29 46 29 73 73.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co"># as.mo("S. aureus") 28 29 42 29 29 110.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co"># as.mo("Staphylococcus aureus") 8 8 8 8 8 8.1 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>
|
||||
@ -244,10 +244,10 @@
|
||||
<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") 470 470 500 520 520 520 10</span></a>
|
||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co"># as.mo("THEISL") 470 470 490 470 520 520 10</span></a>
|
||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co"># as.mo("T. islandicus") 74 74 79 74 75 120 10</span></a>
|
||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co"># as.mo("T. islandicus") 74 74 92 74 120 120 10</span></a>
|
||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co"># as.mo("Thermus islandicus") 73 73 80 73 73 140 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co"># as.mo("THEISL") 470 470 500 500 520 520 10</span></a>
|
||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co"># as.mo("T. islandicus") 74 74 79 75 76 120 10</span></a>
|
||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co"># as.mo("T. islandicus") 74 74 90 74 120 140 10</span></a>
|
||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co"># as.mo("Thermus islandicus") 73 73 83 74 76 120 10</span></a></code></pre></div>
|
||||
<p>That takes 8.1 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>
|
||||
@ -294,8 +294,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) 637 674 745 720 764 936 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.72 seconds (720 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) 725 767 825 792 903 944 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.79 seconds (791 ms). You only lose time on your unique input values.</p>
|
||||
</div>
|
||||
<div id="precalculated-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -307,10 +307,10 @@
|
||||
<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.10 13.2 13.50 13.40 13.60 14.30 10</span></a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co"># B 25.50 25.8 30.60 25.80 26.70 70.70 10</span></a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co"># C 1.62 1.8 1.85 1.81 1.92 2.04 10</span></a></code></pre></div>
|
||||
<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.20 13.30 17.90 13.40 13.40 58.30 10</span></a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co"># B 25.60 25.80 26.00 26.00 26.20 26.50 10</span></a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co"># C 1.62 1.81 1.78 1.81 1.82 1.86 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 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>
|
||||
@ -324,14 +324,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.517 0.559 0.605 0.582 0.648 0.771 10</span></a>
|
||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co"># B 0.549 0.602 0.681 0.684 0.720 0.856 10</span></a>
|
||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co"># C 1.640 1.710 1.830 1.790 2.000 2.090 10</span></a>
|
||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co"># D 0.620 0.672 0.768 0.759 0.846 0.985 10</span></a>
|
||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co"># E 0.487 0.576 0.659 0.673 0.749 0.834 10</span></a>
|
||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co"># F 0.489 0.590 0.639 0.637 0.692 0.751 10</span></a>
|
||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co"># G 0.471 0.478 0.646 0.689 0.753 0.856 10</span></a>
|
||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co"># H 0.200 0.251 0.348 0.341 0.454 0.531 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb7-13" title="13"><span class="co"># A 0.517 0.550 0.608 0.588 0.637 0.839 10</span></a>
|
||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co"># B 0.540 0.548 0.666 0.679 0.744 0.829 10</span></a>
|
||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co"># C 1.690 1.790 1.880 1.860 1.990 2.050 10</span></a>
|
||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co"># D 0.588 0.632 0.704 0.694 0.731 0.944 10</span></a>
|
||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co"># E 0.487 0.504 0.629 0.614 0.703 0.920 10</span></a>
|
||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co"># F 0.477 0.540 0.587 0.579 0.640 0.754 10</span></a>
|
||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co"># G 0.505 0.550 0.628 0.605 0.755 0.768 10</span></a>
|
||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co"># H 0.189 0.266 0.294 0.297 0.362 0.379 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">
|
||||
@ -358,13 +358,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 18.47 18.50 23.02 18.55 18.75 62.99 10</span></a>
|
||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co"># de 23.26 23.35 23.55 23.52 23.75 23.93 10</span></a>
|
||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co"># nl 36.79 36.90 50.46 37.27 81.55 81.90 10</span></a>
|
||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co"># es 23.28 23.40 27.94 23.50 23.64 67.84 10</span></a>
|
||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co"># it 23.12 23.23 23.38 23.33 23.60 23.67 10</span></a>
|
||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co"># fr 23.30 23.38 23.61 23.47 23.86 24.32 10</span></a>
|
||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co"># pt 23.33 23.38 23.63 23.64 23.87 23.95 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb8-21" title="21"><span class="co"># en 18.45 18.51 18.69 18.72 18.78 19.01 10</span></a>
|
||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co"># de 23.32 23.41 23.67 23.45 24.00 24.41 10</span></a>
|
||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co"># nl 36.79 36.88 41.71 37.39 37.57 81.66 10</span></a>
|
||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co"># es 23.32 23.39 23.75 23.65 23.93 24.82 10</span></a>
|
||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co"># it 23.31 23.33 33.07 23.38 29.77 69.13 10</span></a>
|
||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co"># fr 23.33 23.38 27.93 23.43 23.55 67.91 10</span></a>
|
||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co"># pt 23.35 23.38 28.12 23.47 23.82 67.82 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