<p>Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. These functions support all four methods as summarised by Hindler <em>et al.</em> in 2007 (doi: <ahref='https://doi.org/10.1086/511864'>10.1086/511864</a>
). To determine patient episodes not necessarily based on microorganisms, use <code><ahref='get_episode.html'>is_new_episode()</a></code> that also supports grouping with the <code>dplyr</code> package.</p>
info <spanclass='op'>=</span><spanclass='fu'><ahref='https://rdrr.io/r/base/interactive.html'>interactive</a></span><spanclass='op'>(</span><spanclass='op'>)</span>,
<td><p>a <ahref='https://rdrr.io/r/base/data.frame.html'>data.frame</a> containing isolates. Can be left blank for automatic determination, see <em>Examples</em>.</p></td>
<td><p>column name of the IDs of the microorganisms (see <code><ahref='as.mo.html'>as.mo()</a></code>), defaults to the first column of class <code><ahref='as.mo.html'>mo</a></code>. Values will be coerced using <code><ahref='as.mo.html'>as.mo()</a></code>.</p></td>
<td><p>column name of the test codes. Use <code>col_testcode = NULL</code> to <strong>not</strong> exclude certain test codes (such as test codes for screening). In that case <code>testcodes_exclude</code> will be ignored.</p></td>
<td><p>(only useful when <code>method = "phenotype-based"</code>) column name of the key antimicrobials to determine first (weighted) isolates, see <code><ahref='key_antimicrobials.html'>key_antimicrobials()</a></code>. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' or 'antimicrobials' (case insensitive). Use <code>col_keyantimicrobials = FALSE</code> to prevent this. Can also be the output of <code><ahref='key_antimicrobials.html'>key_antimicrobials()</a></code>.</p></td>
<td><p>episode in days after which a genus/species combination will be determined as 'first isolate' again. The default of 365 days is based on the guideline by CLSI, see <em>Source</em>.</p></td>
<td><p>a <ahref='https://rdrr.io/r/base/logical.html'>logical</a> to indicate whether ICU isolates should be excluded (rows with value <code>TRUE</code> in the column set with <code>col_icu</code>)</p></td>
<td><p>the method to apply, either <code>"phenotype-based"</code>, <code>"episode-based"</code>, <code>"patient-based"</code> or <code>"isolate-based"</code> (can be abbreviated), see <em>Details</em>. The default is <code>"phenotype-based"</code> if antimicrobial test results are present in the data, and <code>"episode-based"</code> otherwise.</p></td>
<td><p><ahref='https://rdrr.io/r/base/logical.html'>logical</a> to indicate whether antibiotic interpretations with <code>"I"</code> will be ignored when <code>type = "keyantimicrobials"</code>, see <em>Details</em></p></td>
<td><p>minimum number of points to require before differences in the antibiogram will lead to inclusion of an isolate when <code>type = "points"</code>, see <em>Details</em></p></td>
<td><p>a <ahref='https://rdrr.io/r/base/logical.html'>logical</a> to indicate info should be printed, defaults to <code>TRUE</code> only in interactive mode</p></td>
<td><p>a <ahref='https://rdrr.io/r/base/logical.html'>logical</a> to indicate whether 'unknown' microorganisms should be included too, i.e. microbial code <code>"UNKNOWN"</code>, which defaults to <code>FALSE</code>. For WHONET users, this means that all records with organism code <code>"con"</code> (<em>contamination</em>) will be excluded at default. Isolates with a microbial ID of <code>NA</code> will always be excluded as first isolate.</p></td>
<td><p>a <ahref='https://rdrr.io/r/base/logical.html'>logical</a> to indicate whether also rows without antibiotic results are still eligible for becoming a first isolate. Use <code>include_untested_rsi = FALSE</code> to always return <code>FALSE</code> for such rows. This checks the data set for columns of class <code><rsi></code> and consequently requires transforming columns with antibiotic results using <code><ahref='as.rsi.html'>as.rsi()</a></code> first.</p></td>
<td><p>arguments passed on to <code>first_isolate()</code> when using <code>filter_first_isolate()</code>, otherwise arguments passed on to <code><ahref='key_antimicrobials.html'>key_antimicrobials()</a></code> (such as <code>universal</code>, <code>gram_negative</code>, <code>gram_positive</code>)</p></td>
<p>Methodology of this function is strictly based on:</p><ul>
<li><p><strong>M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition</strong>, 2014, <em>Clinical and Laboratory Standards Institute (CLSI)</em>. <ahref='https://clsi.org/standards/products/microbiology/documents/m39/'>https://clsi.org/standards/products/microbiology/documents/m39/</a>.</p></li>
<li><p>Hindler JF and Stelling J (2007). <strong>Analysis and Presentation of Cumulative Antibiograms: A New Consensus Guideline from the Clinical and Laboratory Standards Institute.</strong> Clinical Infectious Diseases, 44(6), 867–873. doi: <ahref='https://doi.org/10.1086/511864'>10.1086/511864</a></p></li>
<p>To conduct epidemiological analyses on antimicrobial resistance data, only so-called first isolates should be included to prevent overestimation and underestimation of antimicrobial resistance. Different methods can be used to do so, see below.</p>
<p>These functions are context-aware. This means that the <code>x</code> argument can be left blank if used inside a <ahref='https://rdrr.io/r/base/data.frame.html'>data.frame</a> call, see <em>Examples</em>.</p>
<p>The <code>first_isolate()</code> function is a wrapper around the <code><ahref='get_episode.html'>is_new_episode()</a></code> function, but more efficient for data sets containing microorganism codes or names.</p>
<p>All isolates with a microbial ID of <code>NA</code> will be excluded as first isolate.</p><h3class='hasAnchor'id='different-methods'><aclass='anchor'aria-hidden='true'href='#different-methods'></a>Different methods</h3>
), there are different methods (algorithms) to select first isolates with increasing reliability: isolate-based, patient-based, episode-based and phenotype-based. All methods select on a combination of the taxonomic genus and species (not subspecies).</p>
<p>All mentioned methods are covered in the <code>first_isolate()</code> function:</p><tableclass='table'>
<tr><td><strong>Method</strong></td><td><strong>Function to apply</strong></td></tr>
<p>This method does not require any selection, as all isolates should be included. It does, however, respect all arguments set in the <code>first_isolate()</code> function. For example, the default setting for <code>include_unknown</code> (<code>FALSE</code>) will omit selection of rows without a microbial ID.</p>
<p>To include every genus-species combination per patient once, set the <code>episode_days</code> to <code>Inf</code>. Although often inappropriate, this method makes sure that no duplicate isolates are selected from the same patient. In a large longitudinal data set, this could mean that isolates are <em>excluded</em> that were found years after the initial isolate.</p>
<p>To include every genus-species combination per patient episode once, set the <code>episode_days</code> to a sensible number of days. Depending on the type of analysis, this could be 14, 30, 60 or 365. Short episodes are common for analysing specific hospital or ward data, long episodes are common for analysing regional and national data.</p>
<p>This is the most common method to correct for duplicate isolates. Patients are categorised into episodes based on their ID and dates (e.g., the date of specimen receipt or laboratory result). While this is a common method, it does not take into account antimicrobial test results. This means that e.g. a methicillin-resistant <em>Staphylococcus aureus</em> (MRSA) isolate cannot be differentiated from a wildtype <em>Staphylococcus aureus</em> isolate.</p>
<p>This is a more reliable method, since it also <em>weighs</em> the antibiogram (antimicrobial test results) yielding so-called 'first weighted isolates'. There are two different methods to weigh the antibiogram:</p><ol>
<p>This method weighs <em>all</em> antimicrobial agents available in the data set. Any difference from I to S or R (or vice versa) counts as 0.5 points, a difference from S to R (or vice versa) counts as 1 point. When the sum of points exceeds <code>points_threshold</code>, which defaults to <code>2</code>, an isolate will be selected as a first weighted isolate.</p>
<p>All antimicrobials are internally selected using the <code><ahref='key_antimicrobials.html'>all_antimicrobials()</a></code> function. The output of this function does not need to be passed to the <code>first_isolate()</code> function.</p></li>
<li><p>Using <code>type = "keyantimicrobials"</code> and argument <code>ignore_I</code></p>
<p>This method only weighs specific antimicrobial agents, called <em>key antimicrobials</em>. Any difference from S to R (or vice versa) in these key antimicrobials will select an isolate as a first weighted isolate. With <code>ignore_I = FALSE</code>, also differences from I to S or R (or vice versa) will lead to this.</p>
<p>Key antimicrobials are internally selected using the <code><ahref='key_antimicrobials.html'>key_antimicrobials()</a></code> function, but can also be added manually as a variable to the data and set in the <code>col_keyantimicrobials</code> argument. Another option is to pass the output of the <code><ahref='key_antimicrobials.html'>key_antimicrobials()</a></code> function directly to the <code>col_keyantimicrobials</code> argument.</p></li>
<p>The default method is phenotype-based (using <code>type = "points"</code>) and episode-based (using <code>episode_days = 365</code>). This makes sure that every genus-species combination is selected per patient once per year, while taking into account all antimicrobial test results. If no antimicrobial test results are available in the data set, only the episode-based method is applied at default.</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 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>
<divclass="ref-examples sourceCode"><preclass='sourceCode r'><code><spanclass='co'># `example_isolates` is a data set available in the AMR package.</span>
<spanclass='fu'>filter_first_isolate</span><spanclass='op'>(</span><spanclass='op'>)</span><spanclass='op'>%>%</span><spanclass='co'># the 1st isolate filter</span>
<p><p>Developed by <ahref="https://www.rug.nl/staff/m.s.berends/"class="external-link">Matthijs S. Berends</a>, <ahref="https://www.rug.nl/staff/c.f.luz/"class="external-link">Christian F. Luz</a>, <ahref="https://www.rug.nl/staff/a.w.friedrich/"class="external-link">Alexander W. Friedrich</a>, <ahref="https://www.rug.nl/staff/b.sinha/"class="external-link">Bhanu N. M. Sinha</a>, <ahref="https://www.rug.nl/staff/c.j.albers/"class="external-link">Casper J. Albers</a>, <ahref="https://www.rug.nl/staff/c.glasner/"class="external-link">Corinna Glasner</a>.</p></p>