<!-- 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, shrink-to-fit=no"><metaname="description"content='Use this function to get a valid microorganism code (mo) based on arbitrary user input. Determination is done using intelligent rules and the complete taxonomic tree of the kingdoms Animalia, Archaea, Bacteria, and Protozoa, and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like "Staphylococcus aureus"), an abbreviated name (such as "S. aureus"), an abbreviation known in the field (such as "MRSA"), or just a genus. See Examples.'><title>Transform Arbitrary Input to Valid Microbial Taxonomy — as.mo • 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"><scriptsrc="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no"><linkhref="../deps/bootstrap-5.3.1/bootstrap.min.css"rel="stylesheet"><scriptsrc="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><linkhref="../deps/Lato-0.4.9/font.css"rel="stylesheet"><linkhref="../deps/Fira_Code-0.4.9/font.css"rel="stylesheet"><!-- 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"><!-- bootstrap-toc --><scriptsrc="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js"integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo="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><!-- clipboard.js --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js"integrity="sha512-7O5pXpc0oCRrxk8RUfDYFgn0nO1t+jLuIOQdOMRp4APB7uZ4vSjspzp5y6YDtDs4VzUSTbWzBFZ/LKJhnyFOKw=="crossorigin="anonymous"referrerpolicy="no-referrer"></script><!-- search --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js"integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A=="crossorigin="anonymous"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js"integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg=="crossorigin="anonymous"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js"integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww=="crossorigin="anonymous"></script><!-- pkgdown --><scriptsrc="../pkgdown.js"></script><linkhref="../extra.css"rel="stylesheet"><scriptsrc="../extra.js"></script><metaproperty="og:title"content="TransformArbitraryInputtoValid
<p>Use this function to get a valid microorganism code (<code>mo</code>) based on arbitrary user input. Determination is done using intelligent rules and the complete taxonomic tree of the kingdoms Animalia, Archaea, Bacteria, and Protozoa, and most microbial species from the kingdom Fungi (see <em>Source</em>). The input can be almost anything: a full name (like <code>"Staphylococcus aureus"</code>), an abbreviated name (such as <code>"S. aureus"</code>), an abbreviation known in the field (such as <code>"MRSA"</code>), or just a genus. See <em>Examples</em>.</p>
<span> language <spanclass="op">=</span><spanclass="fu"><ahref="translate.html">get_AMR_locale</a></span><spanclass="op">(</span><spanclass="op">)</span>,</span>
<span> info <spanclass="op">=</span><spanclass="fu"><ahref="https://rdrr.io/r/base/interactive.html"class="external-link">interactive</a></span><spanclass="op">(</span><spanclass="op">)</span>,</span>
<dd><p>a <ahref="https://rdrr.io/r/base/character.html"class="external-link">character</a> vector or a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> with one or two columns</p></dd>
<dd><p>a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate whether staphylococci should be categorised into coagulase-negative staphylococci ("CoNS") and coagulase-positive staphylococci ("CoPS") instead of their own species, according to Karsten Becker <em>et al.</em> (see <em>Source</em>). Please see <em>Details</em> for a full list of staphylococcal species that will be converted.</p>
<dd><p>a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate whether a beta-haemolytic <em>Streptococcus</em> should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield (see <em>Source</em>). These streptococci will be categorised in their first group, e.g. <em>Streptococcus dysgalactiae</em> will be group C, although officially it was also categorised into groups G and L. . Please see <em>Details</em> for a full list of streptococcal species that will be converted.</p>
<p>This excludes enterococci at default (who are in group D), use <code>Lancefield = "all"</code> to also categorise all enterococci as group D.</p></dd>
<dd><p>a numeric value to set as the lower limit for the <ahref="mo_matching_score.html">MO matching score</a>. When left blank, this will be determined automatically based on the character length of <code>x</code>, its <ahref="microorganisms.html">taxonomic kingdom</a> and <ahref="mo_matching_score.html">human pathogenicity</a>.</p></dd>
<dd><p>a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate if old, previously valid taxonomic names must be preserved and not be corrected to currently accepted names. The default is <code>FALSE</code>, which will return a note if old taxonomic names were processed. The default can be set with the <ahref="AMR-options.html">package option</a><code><ahref="AMR-options.html">AMR_keep_synonyms</a></code>, i.e. <code>options(AMR_keep_synonyms = TRUE)</code> or <code>options(AMR_keep_synonyms = FALSE)</code>.</p></dd>
<dd><p>a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> to be used for extra reference when translating <code>x</code> to a valid <code>mo</code>. See <code><ahref="mo_source.html">set_mo_source()</a></code> and <code><ahref="mo_source.html">get_mo_source()</a></code> to automate the usage of your own codes (e.g. used in your analysis or organisation).</p></dd>
<dd><p>a Perl-compatible <ahref="https://rdrr.io/r/base/regex.html"class="external-link">regular expression</a> (case-insensitive) of which all matches in <code>x</code> must return <code>NA</code>. This can be convenient to exclude known non-relevant input and can also be set with the <ahref="AMR-options.html">package option</a><code><ahref="AMR-options.html">AMR_ignore_pattern</a></code>, e.g. <code>options(AMR_ignore_pattern = "(not reported|contaminated flora)")</code>.</p></dd>
<dd><p>a Perl-compatible <ahref="https://rdrr.io/r/base/regex.html"class="external-link">regular expression</a> (case-insensitive) to clean the input of <code>x</code>. Every matched part in <code>x</code> will be removed. At default, this is the outcome of <code>mo_cleaning_regex()</code>, which removes texts between brackets and texts such as "species" and "serovar". The default can be set with the <ahref="AMR-options.html">package option</a><code><ahref="AMR-options.html">AMR_cleaning_regex</a></code>.</p></dd>
<dd><p>language to translate text like "no growth", which defaults to the system language (see <code><ahref="translate.html">get_AMR_locale()</a></code>)</p></dd>
<dd><p>a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate if a progress bar should be printed if more than 25 items are to be coerced - the default is <code>TRUE</code> only in interactive mode</p></dd>
<spanid="cb1-8"><ahref="#cb1-8"tabindex="-1"></a><spanclass="er">|</span><spanclass="er">|</span><spanclass="er">|</span> \<spanclass="sc">--</span><spanclass="ot">-></span> subspecies, a <spanclass="dv">3-5</span> letter acronym</span>
<spanid="cb1-9"><ahref="#cb1-9"tabindex="-1"></a><spanclass="sc">|</span><spanclass="er">|</span> \<spanclass="sc">---</span><spanclass="ot">-></span> species, a <spanclass="dv">3-6</span> letter acronym</span>
<spanid="cb1-10"><ahref="#cb1-10"tabindex="-1"></a><spanclass="sc">|</span> \<spanclass="sc">---</span><spanclass="ot">-></span> genus, a <spanclass="dv">4-8</span> letter acronym</span>
<p>The <code>as.mo()</code> function uses a novel <ahref="mo_matching_score.html">matching score algorithm</a> (see <em>Matching Score for Microorganisms</em> below) to match input against the <ahref="microorganisms.html">available microbial taxonomy</a> in this package. This will lead to the effect that e.g. <code>"E. coli"</code> (a microorganism highly prevalent in humans) will return the microbial ID of <em>Escherichia coli</em> and not <em>Entamoeba coli</em> (a microorganism less prevalent in humans), although the latter would alphabetically come first.</p>
<p>Results of non-exact taxonomic input are based on their <ahref="mo_matching_score.html">matching score</a>. The lowest allowed score can be set with the <code>minimum_matching_score</code> argument. At default this will be determined based on the character length of the input, and the <ahref="microorganisms.html">taxonomic kingdom</a> and <ahref="mo_matching_score.html">human pathogenicity</a> of the taxonomic outcome. If values are matched with uncertainty, a message will be shown to suggest the user to evaluate the results with <code>mo_uncertainties()</code>, which returns a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> with all specifications.</p>
<p>To increase the quality of matching, the <code>cleaning_regex</code> argument can be used to clean the input (i.e., <code>x</code>). This must be a <ahref="https://rdrr.io/r/base/regex.html"class="external-link">regular expression</a> that matches parts of the input that should be removed before the input is matched against the <ahref="microorganisms.html">available microbial taxonomy</a>. It will be matched Perl-compatible and case-insensitive. The default value of <code>cleaning_regex</code> is the outcome of the helper function <code>mo_cleaning_regex()</code>.</p>
<p>There are three helper functions that can be run after using the <code>as.mo()</code> function:</p><ul><li><p>Use <code>mo_uncertainties()</code> to get a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> that prints in a pretty format with all taxonomic names that were guessed. The output contains the matching score for all matches (see <em>Matching Score for Microorganisms</em> below).</p></li>
<li><p>Use <code>mo_failures()</code> to get a <ahref="https://rdrr.io/r/base/character.html"class="external-link">character</a><ahref="https://rdrr.io/r/base/vector.html"class="external-link">vector</a> with all values that could not be coerced to a valid value.</p></li>
<li><p>Use <code>mo_renamed()</code> to get a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> with all values that could be coerced based on old, previously accepted taxonomic names.</p></li>
</ul></div>
<divclass="section">
<h3id="microbial-prevalence-of-pathogens-in-humans">Microbial Prevalence of Pathogens in Humans<aclass="anchor"aria-label="anchor"href="#microbial-prevalence-of-pathogens-in-humans"></a></h3>
<p>The coercion rules consider the prevalence of microorganisms in humans, which is available as the <code>prevalence</code> column in the <ahref="microorganisms.html">microorganisms</a> data set. The grouping into human pathogenic prevalence is explained in the section <em>Matching Score for Microorganisms</em> below.</p>
<ol><li><p>Berends MS <em>et al.</em> (2022). <strong>AMR: An R Package for Working with Antimicrobial Resistance Data</strong>. <em>Journal of Statistical Software</em>, 104(3), 1-31; <ahref="https://doi.org/10.18637/jss.v104.i03"class="external-link">doi:10.18637/jss.v104.i03</a></p></li>
<li><p>Becker K <em>et al.</em> (2019). <strong>Implications of identifying the recently defined members of the <em>S. aureus</em> complex, <em>S. argenteus</em> and <em>S. schweitzeri</em>: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).</strong><em>Clin Microbiol Infect</em>; <ahref="https://doi.org/10.1016/j.cmi.2019.02.028"class="external-link">doi:10.1016/j.cmi.2019.02.028</a></p></li>
<li><p>Becker K <em>et al.</em> (2020). <strong>Emergence of coagulase-negative staphylococci.</strong><em>Expert Rev Anti Infect Ther.</em> 18(4):349-366; <ahref="https://doi.org/10.1080/14787210.2020.1730813"class="external-link">doi:10.1080/14787210.2020.1730813</a></p></li>
<li><p>Lancefield RC (1933). <strong>A serological differentiation of human and other groups of hemolytic streptococci.</strong><em>J Exp Med.</em> 57(4): 571-95; <ahref="https://doi.org/10.1084/jem.57.4.571"class="external-link">doi:10.1084/jem.57.4.571</a></p></li>
<li><p>Berends MS <em>et al.</em> (2022). <strong>Trends in Occurrence and Phenotypic Resistance of Coagulase-Negative Staphylococci (CoNS) Found in Human Blood in the Northern Netherlands between 2013 and 2019/</strong><em>Micro.rganisms</em> 10(9), 1801; <ahref="https://doi.org/10.3390/microorganisms10091801"class="external-link">doi:10.3390/microorganisms10091801</a></p></li>
<li><p>Parte, AC <em>et al.</em> (2020). <strong>List of Prokaryotic names with Standing in Nomenclature (LPSN) moves to the DSMZ.</strong> International Journal of Systematic and Evolutionary Microbiology, 70, 5607-5612; <ahref="https://doi.org/10.1099/ijsem.0.004332"class="external-link">doi:10.1099/ijsem.0.004332</a>
<li><p>Reimer, LC <em>et al.</em> (2022). <strong><em>BacDive</em> in 2022: the knowledge base for standardized bacterial and archaeal data.</strong> Nucleic Acids Res., 50(D1):D741-D74; <ahref="https://doi.org/10.1093/nar/gkab961"class="external-link">doi:10.1093/nar/gkab961</a>
. Accessed from <ahref="https://bacdive.dsmz.de"class="external-link">https://bacdive.dsmz.de</a> on May 12th, 2023.</p></li>
<li><p>Public Health Information Network Vocabulary Access and Distribution System (PHIN VADS). US Edition of SNOMED CT from 1 September 2020. Value Set Name 'Microorganism', OID 2.16.840.1.114222.4.11.1009 (v12). URL: <ahref="https://phinvads.cdc.gov"class="external-link">https://phinvads.cdc.gov</a></p></li>
<li><p>Bartlett A <em>et al.</em> (2022). <strong>A comprehensive list of bacterial pathogens infecting humans</strong><em>Microbiology</em> 168:001269; <ahref="https://doi.org/10.1099/mic.0.001269"class="external-link">doi:10.1099/mic.0.001269</a></p></li>
<h2id="matching-score-for-microorganisms">Matching Score for Microorganisms<aclass="anchor"aria-label="anchor"href="#matching-score-for-microorganisms"></a></h2>
<p>With ambiguous user input in <code>as.mo()</code> and all the <code><ahref="mo_property.html">mo_*</a></code> functions, the returned results are chosen based on their matching score using <code><ahref="mo_matching_score.html">mo_matching_score()</a></code>. This matching score \(m\), is calculated as:</p>
<li><p>\(n\) is a taxonomic name (genus, species, and subspecies);</p></li>
<li><p>\(l_n\) is the length of \(n\);</p></li>
<li><p>\(lev\) is the <ahref="https://en.wikipedia.org/wiki/Levenshtein_distance"class="external-link">Levenshtein distance function</a> (counting any insertion as 1, and any deletion or substitution as 2) that is needed to change \(x\) into \(n\);</p></li>
</ul><p>The grouping into human pathogenic prevalence \(p\) is based on recent work from Bartlett <em>et al.</em> (2022, <ahref="https://doi.org/10.1099/mic.0.001269"class="external-link">doi:10.1099/mic.0.001269</a>
) who extensively studied medical-scientific literature to categorise all bacterial species into these groups:</p><ul><li><p><strong>Established</strong>, if a taxonomic species has infected at least three persons in three or more references. These records have <code>prevalence = 1.0</code> in the <ahref="microorganisms.html">microorganisms</a> data set;</p></li>
<li><p><strong>Putative</strong>, if a taxonomic species has fewer than three known cases. These records have <code>prevalence = 1.25</code> in the <ahref="microorganisms.html">microorganisms</a> data set.</p></li>
</ul><p>Furthermore,</p><ul><li><p>Any genus present in the <strong>established</strong> list also has <code>prevalence = 1.0</code> in the <ahref="microorganisms.html">microorganisms</a> data set;</p></li>
<li><p>Any other genus present in the <strong>putative</strong> list has <code>prevalence = 1.25</code> in the <ahref="microorganisms.html">microorganisms</a> data set;</p></li>
<li><p>Any other species or subspecies of which the genus is present in the two aforementioned groups, has <code>prevalence = 1.5</code> in the <ahref="microorganisms.html">microorganisms</a> data set;</p></li>
</ul><p>When calculating the matching score, all characters in \(x\) and \(n\) are ignored that are other than A-Z, a-z, 0-9, spaces and parentheses.</p>
<p>All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., <code>"E. coli"</code> will return the microbial ID of <em>Escherichia coli</em> (\(m = 0.688\), a highly prevalent microorganism found in humans) and not <em>Entamoeba coli</em> (\(m = 0.381\), a less prevalent microorganism in humans), although the latter would alphabetically come first.</p>
<h2id="reference-data-publicly-available">Reference Data Publicly Available<aclass="anchor"aria-label="anchor"href="#reference-data-publicly-available"></a></h2>
<p>All data sets in this <code>AMR</code> package (about microorganisms, antibiotics, SIR interpretation, EUCAST rules, etc.) are publicly and freely available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. We also provide tab-separated plain text files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please visit <ahref="https://msberends.github.io/AMR/articles/datasets.html">our website for the download links</a>. The actual files are of course available on <ahref="https://github.com/msberends/AMR/tree/main/data-raw"class="external-link">our GitHub repository</a>.</p>
<divclass="dont-index"><p><ahref="microorganisms.html">microorganisms</a> for the <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> that is being used to determine ID's.</p>
<p>The <code><ahref="mo_property.html">mo_*</a></code> functions (such as <code><ahref="mo_property.html">mo_genus()</a></code>, <code><ahref="mo_property.html">mo_gramstain()</a></code>) to get properties based on the returned code.</p></div>
<spanclass="r-in"><span><spanclass="fu">as.mo</span><spanclass="op">(</span><spanclass="st">"Streptococcus group A"</span><spanclass="op">)</span></span></span>
<spanclass="r-in"><span><spanclass="fu">as.mo</span><spanclass="op">(</span><spanclass="st">"S. epidermidis"</span>, Becker <spanclass="op">=</span><spanclass="cn">TRUE</span><spanclass="op">)</span><spanclass="co"># will not remain species: B_STPHY_CONS</span></span></span>
<spanclass="r-in"><span><spanclass="fu">as.mo</span><spanclass="op">(</span><spanclass="st">"S. pyogenes"</span>, Lancefield <spanclass="op">=</span><spanclass="cn">TRUE</span><spanclass="op">)</span><spanclass="co"># will not remain species: B_STRPT_GRPA</span></span></span>
<spanclass="r-in"><span><spanclass="fu"><ahref="mo_property.html">mo_is_intrinsic_resistant</a></span><spanclass="op">(</span><spanclass="st">"ESCCOL"</span>, ab <spanclass="op">=</span><spanclass="st">"vanco"</span><spanclass="op">)</span></span></span>
<p><code>AMR</code> (for R). Free and open-source, licenced under the <atarget="_blank"href="https://github.com/msberends/AMR/blob/main/LICENSE"class="external-link">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <atarget="_blank"href="https://www.rug.nl"class="external-link">University of Groningen</a> and <atarget="_blank"href="https://www.umcg.nl"class="external-link">University Medical Center Groningen</a> in The Netherlands.</p>