<!-- Generated by pkgdown: do not edit by hand --><htmllang="en"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><metacharset="utf-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metaname="viewport"content="width=device-width, initial-scale=1.0"><title>Interpret MIC and Disk Values, or Clean Raw R/SI Data — as.rsi • AMR (for R)</title><!-- favicons --><linkrel="icon"type="image/png"sizes="16x16"href="../favicon-16x16.png"><linkrel="icon"type="image/png"sizes="32x32"href="../favicon-32x32.png"><linkrel="apple-touch-icon"type="image/png"sizes="180x180"href="../apple-touch-icon.png"><linkrel="apple-touch-icon"type="image/png"sizes="120x120"href="../apple-touch-icon-120x120.png"><linkrel="apple-touch-icon"type="image/png"sizes="76x76"href="../apple-touch-icon-76x76.png"><linkrel="apple-touch-icon"type="image/png"sizes="60x60"href="../apple-touch-icon-60x60.png"><!-- jquery --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="crossorigin="anonymous"></script><!-- Bootstrap --><linkhref="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css"rel="stylesheet"crossorigin="anonymous"><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js"integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4="crossorigin="anonymous"></script><!-- bootstrap-toc --><linkrel="stylesheet"href="../bootstrap-toc.css"><scriptsrc="../bootstrap-toc.js"></script><!-- Font Awesome icons --><linkrel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css"integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk="crossorigin="anonymous"><linkrel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css"integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw="crossorigin="anonymous"><!-- clipboard.js --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js"integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI="crossorigin="anonymous"></script><!-- headroom.js --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js"integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0="crossorigin="anonymous"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js"integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4="crossorigin="anonymous"></script><!-- pkgdown --><linkhref="../pkgdown.css"rel="stylesheet"><scriptsrc="../pkgdown.js"></script><linkhref="../extra.css"rel="stylesheet"><scriptsrc="../extra.js"></script><metaproperty="og:title"content="Interpret MIC and Disk Values, or Clean Raw R/SI Data — as.rsi"><metaproperty="og:description"content="Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class rsi, which is an ordered factor with levels S &lt; I &lt; R."><metaproperty="og:image"content="https://msberends.github.io/AMR/logo.svg"><metaname="twitter:card"content="summary_large_image"><metaname="twitter:creator"content="@msberends"><metaname="twitter:site"content="@univgroningen"><!-- mathjax --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k="crossorigin="anonymous"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js"integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA="crossorigin="anonymous"></script><!--[if lt IE 9]>
<p>Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class <code>rsi</code>, which is an ordered <ahref="https://rdrr.io/r/base/factor.html"class="external-link">factor</a> with levels <code>S < I < R</code>.</p>
mo <spanclass="op">=</span><spanclass="cn">NULL</span>,
ab <spanclass="op">=</span><spanclass="fu"><ahref="https://rdrr.io/r/base/deparse.html"class="external-link">deparse</a></span><spanclass="op">(</span><spanclass="fu"><ahref="https://rdrr.io/r/base/substitute.html"class="external-link">substitute</a></span><spanclass="op">(</span><spanclass="va">x</span><spanclass="op">)</span><spanclass="op">)</span>,
mo <spanclass="op">=</span><spanclass="cn">NULL</span>,
ab <spanclass="op">=</span><spanclass="fu"><ahref="https://rdrr.io/r/base/deparse.html"class="external-link">deparse</a></span><spanclass="op">(</span><spanclass="fu"><ahref="https://rdrr.io/r/base/substitute.html"class="external-link">substitute</a></span><spanclass="op">(</span><spanclass="va">x</span><spanclass="op">)</span><spanclass="op">)</span>,
<dd><p>vector of values (for class <code><ahref="as.mic.html">mic</a></code>: MIC values in mg/L, for class <code><ahref="as.disk.html">disk</a></code>: a disk diffusion radius in millimetres)</p></dd>
<dd><p>for using on a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a>: names of columns to apply <code>as.rsi()</code> on (supports tidy selection such as <code>column1:column4</code>). Otherwise: arguments passed on to methods.</p></dd>
<dd><p>maximum fraction of invalid antimicrobial interpretations of <code>x</code>, see <em>Examples</em></p></dd>
<dt>mo</dt>
<dd><p>any (vector of) text that can be coerced to valid microorganism codes with <code><ahref="as.mo.html">as.mo()</a></code>, can be left empty to determine it automatically</p></dd>
<dt>ab</dt>
<dd><p>any (vector of) text that can be coerced to a valid antimicrobial code with <code><ahref="as.ab.html">as.ab()</a></code></p></dd>
<dt>guideline</dt>
<dd><p>defaults to the latest included EUCAST guideline, see <em>Details</em> for all options</p></dd>
<dt>uti</dt>
<dd><p>(Urinary Tract Infection) A vector with <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a>s (<code>TRUE</code> or <code>FALSE</code>) to specify whether a UTI specific interpretation from the guideline should be chosen. For using <code>as.rsi()</code> on a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a>, this can also be a column containing <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a>s or when left blank, the data set will be searched for a column 'specimen', and rows within this column containing 'urin' (such as 'urine', 'urina') will be regarded isolates from a UTI. See <em>Examples</em>.</p></dd>
<dt>conserve_capped_values</dt>
<dd><p>a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate that MIC values starting with <code>">"</code> (but not <code>">="</code>) must always return "R" , and that MIC values starting with <code>"<"</code> (but not <code>"<="</code>) must always return "S"</p></dd>
<dd><p><em>(only useful when using a EUCAST guideline)</em> a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate whether intrinsic antibiotic resistance must also be considered for applicable bug-drug combinations, meaning that e.g. ampicillin will always return "R" in <em>Klebsiella</em> species. Determination is based on the <ahref="intrinsic_resistant.html">intrinsic_resistant</a> data set, that itself is based on <ahref="https://www.eucast.org/expert_rules_and_expected_phenotypes/"class="external-link">'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.3</a> (2021).</p></dd>
<dd><p>a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> to be used for interpretation, which defaults to the <ahref="rsi_translation.html">rsi_translation</a> data set. Changing this argument allows for using own interpretation guidelines. This argument must contain a data set that is equal in structure to the <ahref="rsi_translation.html">rsi_translation</a> data set (same column names and column types). Please note that the <code>guideline</code> argument will be ignored when <code>reference_data</code> is manually set.</p></dd>
<dt>col_mo</dt>
<dd><p>column name of the IDs of the microorganisms (see <code><ahref="as.mo.html">as.mo()</a></code>), defaults to the first column of class <code><ahref="as.mo.html">mo</a></code>. Values will be coerced using <code><ahref="as.mo.html">as.mo()</a></code>.</p></dd>
</dl></div>
<divid="value">
<h2>Value</h2>
<p>Ordered <ahref="https://rdrr.io/r/base/factor.html"class="external-link">factor</a> with new class <code><rsi></code></p>
<p>The <code>as.rsi()</code> function works in four ways:</p><ol><li><p>For <strong>cleaning raw / untransformed data</strong>. The data will be cleaned to only contain values S, I and R and will try its best to determine this with some intelligence. For example, mixed values with R/SI interpretations and MIC values such as <code>"<0.25; S"</code> will be coerced to <code>"S"</code>. Combined interpretations for multiple test methods (as seen in laboratory records) such as <code>"S; S"</code> will be coerced to <code>"S"</code>, but a value like <code>"S; I"</code> will return <code>NA</code> with a warning that the input is unclear.</p></li>
<li><p>For <strong>interpreting minimum inhibitory concentration (MIC) values</strong> according to EUCAST or CLSI. You must clean your MIC values first using <code><ahref="as.mic.html">as.mic()</a></code>, that also gives your columns the new data class <code><ahref="as.mic.html">mic</a></code>. Also, be sure to have a column with microorganism names or codes. It will be found automatically, but can be set manually using the <code>mo</code> argument.</p><ul><li><p>Using <code>dplyr</code>, R/SI interpretation can be done very easily with either:</p><divclass="sourceCode"><pre><code><spanclass="va">your_data</span><spanclass="op"><ahref="https://magrittr.tidyverse.org/reference/pipe.html"class="external-link">%>%</a></span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/mutate_all.html"class="external-link">mutate_if</a></span><spanclass="op">(</span><spanclass="va">is.mic</span>, <spanclass="va">as.rsi</span><spanclass="op">)</span><spanclass="co"># until dplyr 1.0.0</span>
<spanclass="va">your_data</span><spanclass="op"><ahref="https://magrittr.tidyverse.org/reference/pipe.html"class="external-link">%>%</a></span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/mutate.html"class="external-link">mutate</a></span><spanclass="op">(</span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/across.html"class="external-link">across</a></span><spanclass="op">(</span><spanclass="fu">where</span><spanclass="op">(</span><spanclass="va">is.mic</span><spanclass="op">)</span>, <spanclass="va">as.rsi</span><spanclass="op">)</span><spanclass="op">)</span><spanclass="co"># since dplyr 1.0.0</span></code></pre></div></li>
<li><p>Operators like "<=" will be stripped before interpretation. When using <code>conserve_capped_values = TRUE</code>, an MIC value of e.g. ">2" will always return "R", even if the breakpoint according to the chosen guideline is ">=4". This is to prevent that capped values from raw laboratory data would not be treated conservatively. The default behaviour (<code>conserve_capped_values = FALSE</code>) considers ">2" to be lower than ">=4" and might in this case return "S" or "I".</p></li>
<li><p>For <strong>interpreting disk diffusion diameters</strong> according to EUCAST or CLSI. You must clean your disk zones first using <code><ahref="as.disk.html">as.disk()</a></code>, that also gives your columns the new data class <code><ahref="as.disk.html">disk</a></code>. Also, be sure to have a column with microorganism names or codes. It will be found automatically, but can be set manually using the <code>mo</code> argument.</p><ul><li><p>Using <code>dplyr</code>, R/SI interpretation can be done very easily with either:</p><divclass="sourceCode"><pre><code><spanclass="va">your_data</span><spanclass="op"><ahref="https://magrittr.tidyverse.org/reference/pipe.html"class="external-link">%>%</a></span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/mutate_all.html"class="external-link">mutate_if</a></span><spanclass="op">(</span><spanclass="va">is.disk</span>, <spanclass="va">as.rsi</span><spanclass="op">)</span><spanclass="co"># until dplyr 1.0.0</span>
<spanclass="va">your_data</span><spanclass="op"><ahref="https://magrittr.tidyverse.org/reference/pipe.html"class="external-link">%>%</a></span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/mutate.html"class="external-link">mutate</a></span><spanclass="op">(</span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/across.html"class="external-link">across</a></span><spanclass="op">(</span><spanclass="fu">where</span><spanclass="op">(</span><spanclass="va">is.disk</span><spanclass="op">)</span>, <spanclass="va">as.rsi</span><spanclass="op">)</span><spanclass="op">)</span><spanclass="co"># since dplyr 1.0.0</span></code></pre></div></li>
<li><p>For <strong>interpreting a complete data set</strong>, with automatic determination of MIC values, disk diffusion diameters, microorganism names or codes, and antimicrobial test results. This is done very simply by running <code>as.rsi(your_data)</code>.</p></li>
<p>Thus, the <code>guideline</code> argument must be set to e.g., <code>"EUCAST 2021"</code> or <code>"CLSI 2021"</code>. By simply using <code>"EUCAST"</code> (the default) or <code>"CLSI"</code> as input, the latest included version of that guideline will automatically be selected. You can set your own data set using the <code>reference_data</code> argument. The <code>guideline</code> argument will then be ignored.</p>
<p>After using <code>as.rsi()</code>, you can use the <code><ahref="eucast_rules.html">eucast_rules()</a></code> defined by EUCAST to (1) apply inferred susceptibility and resistance based on results of other antimicrobials and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.</p>
<p>The repository of this package <ahref="https://github.com/msberends/AMR/blob/main/data-raw/rsi_translation.txt"class="external-link">contains a machine-readable version</a> of all guidelines. This is a CSV file consisting of 20,318 rows and 11 columns. This file is machine-readable, since it contains one row for every unique combination of the test method (MIC or disk diffusion), the antimicrobial agent and the microorganism. <strong>This allows for easy implementation of these rules in laboratory information systems (LIS)</strong>. Note that it only contains interpretation guidelines for humans - interpretation guidelines from CLSI for animals were removed.</p>
<p>The function <code>is.rsi()</code> detects if the input contains class <code><rsi></code>. If the input is a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a>, it iterates over all columns and returns a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> vector.</p>
<p>The function <code>is.rsi.eligible()</code> returns <code>TRUE</code> when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and <code>FALSE</code> otherwise. The threshold of 5% can be set with the <code>threshold</code> argument. If the input is a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a>, it iterates over all columns and returns a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> vector.</p>
<p>In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories R and S/I as shown below (<ahref="https://www.eucast.org/newsiandr/"class="external-link">https://www.eucast.org/newsiandr/</a>).</p><ul><li><p><strong>R = Resistant</strong><br>
A microorganism is categorised as <em>Resistant</em> when there is a high likelihood of therapeutic failure even when there is increased exposure. Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.</p></li>
A microorganism is categorised as <em>Susceptible, standard dosing regimen</em>, when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li>
A microorganism is categorised as <em>Susceptible, Increased exposure</em> when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.</p></li>
</ul><p>This AMR package honours this (new) insight. Use <code><ahref="proportion.html">susceptibility()</a></code> (equal to <code><ahref="proportion.html">proportion_SI()</a></code>) to determine antimicrobial susceptibility and <code><ahref="count.html">count_susceptible()</a></code> (equal to <code><ahref="count.html">count_SI()</a></code>) to count susceptible isolates.</p>
The <ahref="lifecycle.html">lifecycle</a> of this function is <strong>stable</strong>. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.</p>
<p>If the unlying code needs breaking changes, they will occur gradually. For example, an argument will be deprecated and first continue to work, but will emit a message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.</p>
<p>All reference data sets (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) in this <code>AMR</code> package are publicly and freely available. We continually export our data sets to formats for use in R, SPSS, SAS, Stata and Excel. We also supply flat files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please find <ahref="https://msberends.github.io/AMR/articles/datasets.html">all download links on our website</a>, which is automatically updated with every code change.</p>
<p>On our website <ahref="https://msberends.github.io/AMR/">https://msberends.github.io/AMR/</a> you can find <ahref="https://msberends.github.io/AMR/articles/AMR.html">a comprehensive tutorial</a> about how to conduct AMR data analysis, the <ahref="https://msberends.github.io/AMR/reference/">complete documentation of all functions</a> and <ahref="https://msberends.github.io/AMR/articles/WHONET.html">an example analysis using WHONET data</a>.</p>
<divclass="sourceCode"><preclass="sourceCode r"><code><spanclass="fu"><ahref="https://rdrr.io/r/base/summary.html"class="external-link">summary</a></span><spanclass="op">(</span><spanclass="va">example_isolates</span><spanclass="op">)</span><spanclass="co"># see all R/SI results at a glance</span>
GEN <spanclass="op">=</span><spanclass="fu"><ahref="as.disk.html">as.disk</a></span><spanclass="op">(</span><spanclass="fl">18</span><spanclass="op">)</span>,
mo <spanclass="op">=</span><spanclass="fu"><ahref="as.mo.html">as.mo</a></span><spanclass="op">(</span><spanclass="st">"S. pneumoniae"</span><spanclass="op">)</span>,
ab <spanclass="op">=</span><spanclass="st">"AMP"</span>,
<spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/mutate_all.html"class="external-link">mutate_at</a></span><spanclass="op">(</span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/vars.html"class="external-link">vars</a></span><spanclass="op">(</span><spanclass="va">AMP</span><spanclass="op">:</span><spanclass="va">TOB</span><spanclass="op">)</span>, <spanclass="va">as.rsi</span>, mo <spanclass="op">=</span><spanclass="va">.</span><spanclass="op">$</span><spanclass="va">microorganism</span><spanclass="op">)</span>
<spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/mutate_all.html"class="external-link">mutate_at</a></span><spanclass="op">(</span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/vars.html"class="external-link">vars</a></span><spanclass="op">(</span><spanclass="va">AMP</span><spanclass="op">:</span><spanclass="va">NIT</span><spanclass="op">)</span>, <spanclass="va">as.rsi</span>, mo <spanclass="op">=</span><spanclass="st">"E. coli"</span>, uti <spanclass="op">=</span><spanclass="cn">TRUE</span><spanclass="op">)</span>
<spanclass="op">}</span>
<spanclass="co"># For CLEANING existing R/SI values ------------------------------------</span>
<spanclass="fu"><ahref="plot.html">plot</a></span><spanclass="op">(</span><spanclass="va">rsi_data</span><spanclass="op">)</span><spanclass="co"># for percentages</span>
<spanclass="fu"><ahref="https://rdrr.io/r/graphics/barplot.html"class="external-link">barplot</a></span><spanclass="op">(</span><spanclass="va">rsi_data</span><spanclass="op">)</span><spanclass="co"># for frequencies</span>