<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>mo_*</code> functions like <code><ahref='mo_property.html'>mo_genus()</a></code> and <code><ahref='mo_property.html'>mo_gramstain()</a></code>.</p>
<td><p>location of your reference file, see Details. Can be <code>""</code>, <code>NULL</code> or <code>FALSE</code> to delete the reference file.</p></td>
<p>The reference file can be a text file seperated with commas (CSV) or tabs or pipes, an Excel file (either 'xls' or 'xlsx' format) or an R object file (extension '.rds'). To use an Excel file, you 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 <code><ahref='https://rdrr.io/r/base/data.frame.html'>data.frame</a></code>, 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 R and export it to <code>"~/.mo_source.rds"</code>. This compressed data file will then 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 of the original file will be saved as option with <code><ahref='https://rdrr.io/r/base/options.html'>options(mo_source = path)</a></code>. Its timestamp will be saved with <code><ahref='https://rdrr.io/r/base/options.html'>options(mo_source_datetime = ...)</a></code>.</p>
<p><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'>readRDS()</a></code>. If the original file has changed (the file defined with <code>path</code>), it will call <code>set_mo_source()</code> to update the data file automatically.</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>
<h2class="hasAnchor"id="how-to-setup"><aclass="anchor"href="#how-to-setup"></a>How to setup</h2>
<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><pre> | A | B |
<p>We save it as <code>"home/me/ourcodes.xlsx"</code>. Now we have to set it as a source:</p><pre><spanclass='fu'>set_mo_source</span>(<spanclass='st'>"home/me/ourcodes.xlsx"</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><pre><spanclass='fu'><ahref='as.mo.html'>as.mo</a></span>(<spanclass='st'>"lab_mo_ecoli"</span>)
<p>...any new usage of an MO function in this package will update your data file:</p><pre><spanclass='fu'><ahref='as.mo.html'>as.mo</a></span>(<spanclass='st'>"lab_mo_ecoli"</span>)
<spanclass='co'>#&gt; NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'</span>
<spanclass='co'>#&gt; (columns "Organisation XYZ" and "mo")</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><pre><spanclass='fu'>set_mo_source</span>(<spanclass='kw'>NULL</span>)
<p>If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of <code><ahref='as.mo.html'>as.mo()</a></code>. If the mo_source file is manually deleted (i.e. without using <code>set_mo_source()</code>), the references to the mo_source file will be removed upon the next use of <code><ahref='as.mo.html'>as.mo()</a></code>.</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, a parameter 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.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <ahref='https://msberends.gitlab.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR analysis, the <ahref='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <ahref='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
<p>Developed by <ahref='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <ahref='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <ahref='https://www.rug.nl/staff/a.w.friedrich/'>Alexander W. Friedrich</a>, <ahref='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <ahref='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <ahref='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>