<!-- 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 determine a valid microorganism code (mo). Determination is done using intelligent rules and the complete taxonomic 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 Input to a Microorganism Code — 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.1.3/bootstrap.min.css"rel="stylesheet"><scriptsrc="../deps/bootstrap-5.1.3/bootstrap.bundle.min.js"></script><linkhref="../deps/Fira_Code-0.4.2/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.rawgit.com/afeld/bootstrap-toc/v1.0.1/dist/bootstrap-toc.min.js"></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.6/clipboard.min.js"integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI="crossorigin="anonymous"></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="Transform Input to a Microorganism Code — as.mo"><metaproperty="og:description"content='Usethisfunctiontodetermineavalidmicroorganismcode(mo).DeterminationisdoneusingintelligentrulesandthecompletetaxonomickingdomsAnimalia,Archaea,BacteriaandProtozoa,andmostmicrobialspeciesfrom
<p>Use this function to determine a valid microorganism code (<code>mo</code>). Determination is done using intelligent rules and the complete taxonomic 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 Source).</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 Source). 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.</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>
<dt>keep_synonyms</dt>
<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 <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 <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 option <code>AMR_ignore_pattern</code>, e.g. <code>options(AMR_ignore_pattern = "(not reported|contaminated flora)")</code>.</p></dd>
<dt>remove_from_input</dt>
<dd><p>a <ahref="https://rdrr.io/r/base/regex.html"class="external-link">regular expression</a> (case-insensitive) to clean the input of <code>x</code>. Everything matched 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".</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>
<dt>info</dt>
<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, defaults to <code>TRUE</code> only in interactive mode</p></dd>
<dt>...</dt>
<dd><p>other arguments passed on to functions</p></dd>
<spanid="cb1-8"><ahref="#cb1-8"aria-hidden="true"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"aria-hidden="true"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"aria-hidden="true"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. The algorithm uses data from the List of Prokaryotic names with Standing in Nomenclature (LPSN) and the Global Biodiversity Information Facility (GBIF) (see <ahref="microorganisms.html">microorganisms</a>).</p><divclass="section">
<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>remove_from_input</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>remove_from_input</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 grouped into three groups, which is available as the <code>prevalence</code> columns 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>Microorganisms</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>
. Accessed from <ahref="https://lpsn.dsmz.de"class="external-link">https://lpsn.dsmz.de</a> on 12 September, 2022.</p></li>
. Accessed from <ahref="https://www.gbif.org"class="external-link">https://www.gbif.org</a> on 12 September, 2022.</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 'Microoganism', 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>
<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><i>lev</i> 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 <i>x</i> into <i>n</i>;</p></li>
</ul><p>The grouping into human pathogenic prevalence (\(p\)) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence:</p>
<p><strong>Group 1</strong> (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is <em>Enterococcus</em>, <em>Staphylococcus</em> or <em>Streptococcus</em>. This group consequently contains all common Gram-negative bacteria, such as <em>Pseudomonas</em> and <em>Legionella</em> and all species within the order Enterobacterales.</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.119\), 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, R/SI 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-out co"><spanclass="r-pr">#></span> Class <mo></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-out co"><spanclass="r-pr">#></span> Class <mo></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>
</main><asideclass="col-md-3"><navid="toc"><h2>On this page</h2>
</nav></aside></div>
<footer><divclass="pkgdown-footer-left">
<p></p><p><code>AMR</code> (for R). Developed at the <atarget="_blank"href="https://www.rug.nl"class="external-link">University of Groningen</a> in collaboration with non-profit organisations<br><atarget="_blank"href="https://www.certe.nl"class="external-link">Certe Medical Diagnostics and Advice Foundation</a> and <atarget="_blank"href="https://www.umcg.nl"class="external-link">University Medical Center Groningen</a>.</p>