<!-- 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>Define Custom EUCAST Rules — custom_eucast_rules • 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="Define Custom EUCAST Rules — custom_eucast_rules"><metaproperty="og:description"content="Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in eucast_rules()."><metaproperty="og:image"content="https://msberends.github.io/AMR/logo.png"><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>Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in <code><ahref="eucast_rules.html">eucast_rules()</a></code>.</p>
<dd><p>rules in formula notation, see <em>Examples</em></p></dd>
</dl></div>
<divid="value">
<h2>Value</h2>
<p>A <ahref="https://rdrr.io/r/base/list.html"class="external-link">list</a> containing the custom rules</p>
</div>
<divid="details">
<h2>Details</h2>
<p>Some organisations have their own adoption of EUCAST rules. This function can be used to define custom EUCAST rules to be used in the <code><ahref="eucast_rules.html">eucast_rules()</a></code> function.</p>
<p>If you are familiar with the <code><ahref="https://dplyr.tidyverse.org/reference/case_when.html"class="external-link">case_when()</a></code> function of the <code>dplyr</code> package, you will recognise the input method to set your own rules. Rules must be set using what <spanstyle="R">R</span> considers to be the 'formula notation'. The rule itself is written <em>before</em> the tilde (<code>~</code>) and the consequence of the rule is written <em>after</em> the tilde:</p><divclass="sourceCode"><pre><code><spanclass="va">x</span><spanclass="op"><-</span><spanclass="fu"><ahref="../reference/custom_eucast_rules.html">custom_eucast_rules</a></span><spanclass="op">(</span><spanclass="va">TZP</span><spanclass="op">==</span><spanclass="st">"S"</span><spanclass="op">~</span><spanclass="va">aminopenicillins</span><spanclass="op">==</span><spanclass="st">"S"</span>,
<p>These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work:</p><divclass="sourceCode"><pre><code><spanclass="va">x</span>
<spanclass="co">#> A set of custom EUCAST rules:</span>
<spanclass="co">#></span>
<spanclass="co">#> 1. If TZP is S then set to S:</span>
<p>The rules (the part <em>before</em> the tilde, in above example <code>TZP == "S"</code> and <code>TZP == "R"</code>) must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column <code>TZP</code> must exist. We will create a sample data set and test the rules set:</p><divclass="sourceCode"><pre><code><spanclass="va">df</span><spanclass="op"><-</span><spanclass="fu"><ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a></span><spanclass="op">(</span>mo <spanclass="op">=</span><spanclass="fu"><ahref="https://rdrr.io/r/base/c.html"class="external-link">c</a></span><spanclass="op">(</span><spanclass="st">"E. coli"</span>, <spanclass="st">"K. pneumoniae"</span><spanclass="op">)</span>,
<h3id="using-taxonomic-properties-in-rules">Using taxonomic properties in rules<aclass="anchor"aria-label="anchor"href="#using-taxonomic-properties-in-rules"></a></h3>
<p>There is one exception in variables used for the rules: all column names of the <ahref="microorganisms.html">microorganisms</a> data set can also be used, but do not have to exist in the data set. These column names are: <code>mo</code>, <code>fullname</code>, <code>kingdom</code>, <code>phylum</code>, <code>class</code>, <code>order</code>, <code>family</code>, <code>genus</code>, <code>species</code>, <code>subspecies</code>, <code>rank</code>, <code>ref</code>, <code>species_id</code>, <code>source</code>, <code>prevalence</code> and <code>snomed</code>. Thus, this next example will work as well, despite the fact that the <code>df</code> data set does not contain a column <code>genus</code>:</p><divclass="sourceCode"><pre><code><spanclass="va">y</span><spanclass="op"><-</span><spanclass="fu"><ahref="../reference/custom_eucast_rules.html">custom_eucast_rules</a></span><spanclass="op">(</span><spanclass="va">TZP</span><spanclass="op">==</span><spanclass="st">"S"</span><spanclass="op">&</span><spanclass="va">genus</span><spanclass="op">==</span><spanclass="st">"Klebsiella"</span><spanclass="op">~</span><spanclass="va">aminopenicillins</span><spanclass="op">==</span><spanclass="st">"S"</span>,
<h3id="usage-of-antibiotic-group-names">Usage of antibiotic group names<aclass="anchor"aria-label="anchor"href="#usage-of-antibiotic-group-names"></a></h3>
<p>It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part <em>after</em> the tilde. In above examples, the antibiotic group <code>aminopenicillins</code> is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the agents that will be matched when running the rule.</p><ul><li><p><code>aminoglycosides</code><br>(amikacin, amikacin/fosfomycin, amphotericin B-high, apramycin, arbekacin, astromicin, bekanamycin, dibekacin, framycetin, gentamicin, gentamicin-high, habekacin, hygromycin, isepamicin, kanamycin, kanamycin-high, kanamycin/cephalexin, micronomicin, neomycin, netilmicin, pentisomicin, plazomicin, propikacin, ribostamycin, sisomicin, streptoduocin, streptomycin, streptomycin-high, tobramycin and tobramycin-high)</p></li>
<li><p><code>aminopenicillins</code><br>(amoxicillin and ampicillin)</p></li>
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 an 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>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>