1
0
mirror of https://github.com/msberends/AMR.git synced 2025-08-26 03:42:09 +02:00

(v1.3.0.9005) website update

This commit is contained in:
2020-08-17 21:49:58 +02:00
parent dab017a50f
commit 818d0441e0
54 changed files with 13094 additions and 424 deletions

View File

@@ -39,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9005</span>
</span>
</div>
@@ -75,6 +75,13 @@
Predict antimicrobial resistance
</a>
</li>
<li>
<a href="../articles/datasets.html">
<span class="fa fa-database"></span>
Download our reference data sets for own use
</a>
</li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
@@ -184,9 +191,7 @@
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1 data-toc-skip>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">14 August 2020</h4>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/benchmarks.Rmd"><code>vignettes/benchmarks.Rmd</code></a></small>
<div class="hidden name"><code>benchmarks.Rmd</code></div>
@@ -224,56 +229,30 @@
times = <span class="fl">10</span>)
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="kw">S.aureus</span>, unit = <span class="st">"ms"</span>, signif = <span class="fl">2</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># as.mo("sau") 9.1 11.0 21 11 13 77 10</span>
<span class="co"># as.mo("stau") 180.0 180.0 190 180 190 210 10</span>
<span class="co"># as.mo("STAU") 170.0 170.0 190 180 210 210 10</span>
<span class="co"># as.mo("staaur") 8.7 12.0 18 12 14 47 10</span>
<span class="co"># as.mo("STAAUR") 9.9 10.0 12 12 12 13 10</span>
<span class="co"># as.mo("S. aureus") 13.0 15.0 29 28 43 47 10</span>
<span class="co"># as.mo("S aureus") 12.0 16.0 25 17 40 52 10</span>
<span class="co"># as.mo("Staphylococcus aureus") 9.1 9.7 14 11 11 44 10</span>
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 920.0 960.0 990 980 1000 1100 10</span>
<span class="co"># as.mo("Sthafilokkockus aaureuz") 430.0 440.0 460 460 460 510 10</span>
<span class="co"># as.mo("MRSA") 9.1 11.0 16 12 12 37 10</span>
<span class="co"># as.mo("VISA") 15.0 17.0 23 18 20 47 10</span>
<span class="co"># as.mo("VRSA") 15.0 17.0 27 19 44 50 10</span>
<span class="co"># as.mo(22242419) 140.0 140.0 150 150 160 170 10</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># as.mo("sau") 8.8 10.0 24 12 38 57 10</span>
<span class="co"># as.mo("stau") 170.0 170.0 180 170 190 210 10</span>
<span class="co"># as.mo("STAU") 160.0 170.0 180 170 200 220 10</span>
<span class="co"># as.mo("staaur") 9.6 10.0 13 11 12 36 10</span>
<span class="co"># as.mo("STAAUR") 10.0 10.0 25 12 34 80 10</span>
<span class="co"># as.mo("S. aureus") 14.0 15.0 21 15 18 47 10</span>
<span class="co"># as.mo("S aureus") 12.0 15.0 21 16 18 45 10</span>
<span class="co"># as.mo("Staphylococcus aureus") 8.9 9.4 15 11 12 37 10</span>
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 900.0 920.0 940 940 960 1000 10</span>
<span class="co"># as.mo("Sthafilokkockus aaureuz") 410.0 420.0 450 450 470 520 10</span>
<span class="co"># as.mo("MRSA") 8.8 10.0 16 11 12 38 10</span>
<span class="co"># as.mo("VISA") 13.0 16.0 27 19 41 47 10</span>
<span class="co"># as.mo("VRSA") 13.0 16.0 22 18 19 42 10</span>
<span class="co"># as.mo(22242419) 140.0 140.0 150 140 160 170 10</span>
</pre></div>
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="562.5"></p>
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second.</p>
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside of this is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Methanosarcina semesiae</em> (<code>B_MTHNSR_SEMS</code>), a bug probably never found before in humans:</p>
<div class="sourceCode" id="cb3"><pre class="downlit">
<span class="kw">M.semesiae</span> <span class="op">&lt;-</span> <span class="fu">microbenchmark</span>(<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"metsem"</span>),
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"METSEM"</span>),
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"M. semesiae"</span>),
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"M. semesiae"</span>),
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Methanosarcina semesiae"</span>),
times = <span class="fl">10</span>)
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="kw">M.semesiae</span>, unit = <span class="st">"ms"</span>, signif = <span class="fl">4</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max</span>
<span class="co"># as.mo("metsem") 193.600 200.200 209.30 202.800 218.00 238.20</span>
<span class="co"># as.mo("METSEM") 186.500 193.500 208.40 202.600 228.90 244.80</span>
<span class="co"># as.mo("M. semesiae") 12.280 13.090 18.86 14.430 15.48 59.40</span>
<span class="co"># as.mo("M. semesiae") 14.060 14.520 20.98 16.420 17.56 46.18</span>
<span class="co"># as.mo("Methanosarcina semesiae") 8.065 9.203 12.65 9.715 10.65 39.96</span>
<span class="co"># neval</span>
<span class="co"># 10</span>
<span class="co"># 10</span>
<span class="co"># 10</span>
<span class="co"># 10</span>
<span class="co"># 10</span>
</pre></div>
<p>Looking up arbitrary codes of less prevalent microorganisms costs the most time. Full names (like <em>Methanosarcina semesiae</em>) are always very fast and only take some thousands of seconds to coerce - they are the most probable input from most data sets.</p>
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Methanosarcina semesiae</em> (which is uncommon):</p>
<p><img src="benchmarks_files/figure-html/unnamed-chunk-6-1.png" width="900"></p>
<p>Uncommon microorganisms take some more time than common microorganisms. To further improve performance, two important calculations take almost no time at all: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
<p>To improve performance, two important calculations take almost no time at all: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
<div id="repetitive-results" class="section level3">
<h3 class="hasAnchor">
<a href="#repetitive-results" class="anchor"></a>Repetitive results</h3>
<p>Repetitive results are unique values that are present more than once. Unique values will only be calculated once by <code><a href="../reference/as.mo.html">as.mo()</a></code>. We will use <code><a href="../reference/mo_property.html">mo_name()</a></code> for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses <code><a href="../reference/as.mo.html">as.mo()</a></code> internally.</p>
<div class="sourceCode" id="cb4"><pre class="downlit">
<div class="sourceCode" id="cb3"><pre class="downlit">
<span class="co"># take all MO codes from the example_isolates data set</span>
<span class="kw">x</span> <span class="op">&lt;-</span> <span class="kw">example_isolates</span><span class="op">$</span><span class="kw">mo</span> <span class="op">%&gt;%</span>
<span class="co"># keep only the unique ones</span>
@@ -299,28 +278,28 @@
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="kw">run_it</span>, unit = <span class="st">"ms"</span>, signif = <span class="fl">3</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># mo_name(x) 1920 1940 2010 1990 2060 2120 10</span>
<span class="co"># mo_name(x) 1810 1850 1980 1940 2130 2230 10</span>
</pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 1.99 seconds. You only lose time on your unique input values.</p>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 1.94 seconds. You only lose time on your unique input values.</p>
</div>
<div id="precalculated-results" class="section level3">
<h3 class="hasAnchor">
<a href="#precalculated-results" class="anchor"></a>Precalculated results</h3>
<p>What about precalculated results? If the input is an already precalculated result of a helper function like <code><a href="../reference/mo_property.html">mo_name()</a></code>, it almost doesnt take any time at all (see C below):</p>
<div class="sourceCode" id="cb5"><pre class="downlit">
<div class="sourceCode" id="cb4"><pre class="downlit">
<span class="kw">run_it</span> <span class="op">&lt;-</span> <span class="fu">microbenchmark</span>(A = <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"B_STPHY_AURS"</span>),
B = <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"S. aureus"</span>),
C = <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),
times = <span class="fl">10</span>)
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="kw">run_it</span>, unit = <span class="st">"ms"</span>, signif = <span class="fl">3</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># A 5.90 6.16 6.93 7.24 7.43 7.89 10</span>
<span class="co"># B 11.40 12.00 16.20 13.20 14.20 45.20 10</span>
<span class="co"># C 1.05 1.07 1.18 1.13 1.28 1.40 10</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># A 5.080 5.220 5.81 5.66 6.46 7.16 10</span>
<span class="co"># B 10.000 10.200 14.40 10.60 11.30 49.00 10</span>
<span class="co"># C 0.862 0.875 1.04 1.05 1.14 1.40 10</span>
</pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0011 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="cb6"><pre class="downlit">
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.001 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="cb5"><pre class="downlit">
<span class="kw">run_it</span> <span class="op">&lt;-</span> <span class="fu">microbenchmark</span>(A = <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),
B = <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),
C = <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),
@@ -332,15 +311,15 @@
times = <span class="fl">10</span>)
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="kw">run_it</span>, unit = <span class="st">"ms"</span>, signif = <span class="fl">3</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># A 0.976 0.993 1.13 1.07 1.29 1.34 10</span>
<span class="co"># B 1.000 1.060 1.13 1.07 1.15 1.40 10</span>
<span class="co"># C 0.927 1.030 1.08 1.06 1.11 1.35 10</span>
<span class="co"># D 0.896 0.983 1.11 1.08 1.27 1.41 10</span>
<span class="co"># E 0.866 1.020 1.10 1.07 1.23 1.37 10</span>
<span class="co"># F 0.967 0.993 1.16 1.05 1.32 1.61 10</span>
<span class="co"># G 0.855 1.020 1.07 1.07 1.17 1.31 10</span>
<span class="co"># H 0.966 1.010 1.12 1.06 1.19 1.36 10</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># A 0.869 0.889 0.951 0.904 1.010 1.19 10</span>
<span class="co"># B 0.837 0.873 0.977 0.937 1.010 1.36 10</span>
<span class="co"># C 0.869 0.874 1.020 0.921 1.130 1.40 10</span>
<span class="co"># D 0.829 0.858 0.898 0.862 0.873 1.21 10</span>
<span class="co"># E 0.862 0.870 0.983 0.918 1.050 1.36 10</span>
<span class="co"># F 0.841 0.850 0.915 0.867 0.907 1.24 10</span>
<span class="co"># G 0.842 0.851 0.940 0.898 1.000 1.16 10</span>
<span class="co"># H 0.854 0.864 1.030 0.920 1.170 1.60 10</span>
</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> anyway, there is no point in calculating the result. And because this package knows all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
</div>
@@ -348,7 +327,7 @@
<h3 class="hasAnchor">
<a href="#results-in-other-languages" class="anchor"></a>Results in other languages</h3>
<p>When the system language is non-English and supported by this <code>AMR</code> package, some functions will have a translated result. This almost doest take extra time:</p>
<div class="sourceCode" id="cb7"><pre class="downlit">
<div class="sourceCode" id="cb6"><pre class="downlit">
<span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, language = <span class="st">"en"</span>) <span class="co"># or just mo_name("CoNS") on an English system</span>
<span class="co"># [1] "Coagulase-negative Staphylococcus (CoNS)"</span>
@@ -368,14 +347,14 @@
times = <span class="fl">100</span>)
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="kw">run_it</span>, unit = <span class="st">"ms"</span>, signif = <span class="fl">4</span>)
<span class="co"># Unit: milliseconds</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># en 13.09 14.02 18.36 14.59 16.22 61.92 100</span>
<span class="co"># de 14.00 14.83 18.06 15.48 16.85 56.01 100</span>
<span class="co"># nl 17.71 18.99 24.79 20.09 22.22 58.50 100</span>
<span class="co"># es 13.99 15.02 20.94 15.88 16.70 141.90 100</span>
<span class="co"># it 13.68 14.97 19.02 15.52 16.72 50.26 100</span>
<span class="co"># fr 13.96 15.05 20.63 15.72 17.14 52.71 100</span>
<span class="co"># pt 14.13 14.86 19.81 15.69 17.46 53.89 100</span>
<span class="co"># expr min lq mean median uq max neval</span>
<span class="co"># en 10.72 11.54 15.34 12.76 13.82 44.53 100</span>
<span class="co"># de 11.47 12.77 17.24 13.60 14.78 55.48 100</span>
<span class="co"># nl 14.58 15.91 19.06 16.96 18.46 46.24 100</span>
<span class="co"># es 11.24 11.96 16.86 13.17 14.70 50.05 100</span>
<span class="co"># it 11.35 12.42 17.79 13.52 16.28 50.31 100</span>
<span class="co"># fr 11.41 12.29 17.08 13.43 15.44 53.91 100</span>
<span class="co"># pt 11.34 12.06 16.23 13.25 14.80 51.96 100</span>
</pre></div>
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
</div>