<!-- 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>User-Defined Reference Data Set for Microorganisms — mo_source • 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="User-Defined Reference Data Set for Microorganisms — mo_source"><metaproperty="og:description"content="Thesefunctionscanbeusedtopredefineyourownreferencetobeusedinas.mo()andconsequentlyallmo_*functions(suchasmo_genus()andmo_gramstain()).
This is the fastest way to have your organisation (or analysis) specific codes picked up and translated by this package, since you don't have to bother about it again after setting it up once."><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>These functions can be used to predefine your own reference to be used in <code><ahref="as.mo.html">as.mo()</a></code> and consequently all <code><ahref="mo_property.html">mo_*</a></code> functions (such as <code><ahref="mo_property.html">mo_genus()</a></code> and <code><ahref="mo_property.html">mo_gramstain()</a></code>).</p>
<p>This is <strong>the fastest way</strong> to have your organisation (or analysis) specific codes picked up and translated by this package, since you don't have to bother about it again after setting it up once.</p>
<dd><p>location of your reference file, see <em>Details</em>. Can be <code>""</code>, <code>NULL</code> or <code>FALSE</code> to delete the reference file.</p></dd>
<dt>destination</dt>
<dd><p>destination of the compressed data file, default to the user's home directory.</p></dd>
<p>The reference file can be a text file separated with commas (CSV) or tabs or pipes, an Excel file (either 'xls' or 'xlsx' format) or an <spanstyle="R">R</span> object file (extension '.rds'). To use an Excel file, you will need to have the <code>readxl</code> package installed.</p>
<p><code>set_mo_source()</code> will check the file for validity: it must be a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a>, must have a column named <code>"mo"</code> which contains values from <code><ahref="microorganisms.html">microorganisms$mo</a></code> and must have a reference column with your own defined values. If all tests pass, <code>set_mo_source()</code> will read the file into <spanstyle="R">R</span> and will ask to export it to <code>"~/mo_source.rds"</code>. The CRAN policy disallows packages to write to the file system, although '<em>exceptions may be allowed in interactive sessions if the package obtains confirmation from the user</em>'. For this reason, this function only works in interactive sessions so that the user can <strong>specifically confirm and allow</strong> that this file will be created. The destination of this file can be set with the <code>destination</code> argument and defaults to the user's home directory. It can also be set as an <spanstyle="R">R</span> option, using <code>options(AMR_mo_source = "my/location/file.rds")</code>.</p>
<p>The created compressed data file <code>"mo_source.rds"</code> will be used at default for MO determination (function <code><ahref="as.mo.html">as.mo()</a></code> and consequently all <code>mo_*</code> functions like <code><ahref="mo_property.html">mo_genus()</a></code> and <code><ahref="mo_property.html">mo_gramstain()</a></code>). The location and timestamp of the original file will be saved as an attribute to the compressed data file.</p>
<p>The function <code>get_mo_source()</code> will return the data set by reading <code>"mo_source.rds"</code> with <code><ahref="https://rdrr.io/r/base/readRDS.html"class="external-link">readRDS()</a></code>. If the original file has changed (by checking the location and timestamp of the original file), it will call <code>set_mo_source()</code> to update the data file automatically if used in an interactive session.</p>
<p>Reading an Excel file (<code>.xlsx</code>) with only one row has a size of 8-9 kB. The compressed file created with <code>set_mo_source()</code> will then have a size of 0.1 kB and can be read by <code>get_mo_source()</code> in only a couple of microseconds (millionths of a second).</p>
<p>Imagine this data on a sheet of an Excel file (mo codes were looked up in the <ahref="microorganisms.html">microorganisms</a> data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:</p><divclass="sourceCode"><pre><code> | A | B |
<p>We save it as <code>"home/me/ourcodes.xlsx"</code>. Now we have to set it as a source:</p><divclass="sourceCode"><pre><code><spanclass="fu"><ahref="../reference/mo_source.html">set_mo_source</a></span><spanclass="op">(</span><spanclass="st">"home/me/ourcodes.xlsx"</span><spanclass="op">)</span>
<spanclass="co">#> NOTE: Created mo_source file '/Users/me/mo_source.rds' (0.3 kB) from</span>
<p>It has now created a file <code>"~/mo_source.rds"</code> with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file.</p>
<p>And now we can use it in our functions:</p><divclass="sourceCode"><pre><code><spanclass="fu"><ahref="../reference/as.mo.html">as.mo</a></span><spanclass="op">(</span><spanclass="st">"lab_mo_ecoli"</span><spanclass="op">)</span>
<p>...any new usage of an MO function in this package will update your data file:</p><divclass="sourceCode"><pre><code><spanclass="fu"><ahref="../reference/as.mo.html">as.mo</a></span><spanclass="op">(</span><spanclass="st">"lab_mo_ecoli"</span><spanclass="op">)</span>
<spanclass="co">#> NOTE: Updated mo_source file '/Users/me/mo_source.rds' (0.3 kB) from </span>
<p>To delete the reference data file, just use <code>""</code>, <code>NULL</code> or <code>FALSE</code> as input for <code>set_mo_source()</code>:</p><divclass="sourceCode"><pre><code><spanclass="fu"><ahref="../reference/mo_source.html">set_mo_source</a></span><spanclass="op">(</span><spanclass="cn">NULL</span><spanclass="op">)</span>
<p>If the original file (in the previous case an Excel file) is moved or deleted, the <code>mo_source.rds</code> file will be removed upon the next use of <code><ahref="as.mo.html">as.mo()</a></code> or any <code><ahref="mo_property.html">mo_*</a></code> function.</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 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>
<p></p><p>Developed by <ahref="https://www.rug.nl/staff/m.s.berends/"class="external-link">Matthijs S. Berends</a>, Christian F. Luz, Dennis Souverein, Erwin E. A. Hassing.</p>