* [Tidyverse selections](https://tidyselect.r-lib.org/reference/language.html), that help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. They can be used in any function that allows Tidyverse selections, like `dplyr::select()` and `tidyr::pivot_longer()`:
* Fixed a bug where `eucast_rules()` would not work on a tibble when the `tibble` or `dplyr` package was loaded
* Fixed a bug where `eucast_rules()` would not work on a tibble when the `tibble` or `dplyr` package was loaded
* All `*_join_microorganisms()` functions now return the original data class (e.g. tibbles and data.tables)
* All `*_join_microorganisms()` functions now return the original data class (e.g. tibbles and data.tables)
* Fixed a bug where `as.ab()` would return an error on invalid input values
* Fixed a bug where `as.ab()` would return an error on invalid input values
* Fixed a bug for using grouped versions of `rsi_df()`, `proportion_df()` and `count_df()`
* Fixed a bug for using grouped versions of `rsi_df()`, `proportion_df()` and `count_df()`, and fixed a bug where not all different antimicrobial results were added as rows
* Added function `filter_penicillins()` to filter isolates on a specific result in any column with a name in the antimicrobial 'penicillins' class (more specific: ATC subgroup *Beta-lactam antibacterials, penicillins*)
* Added function `filter_penicillins()` to filter isolates on a specific result in any column with a name in the antimicrobial 'penicillins' class (more specific: ATC subgroup *Beta-lactam antibacterials, penicillins*)
* Added official antimicrobial names to all `filter_ab_class()` functions, such as `filter_aminoglycosides()`
* Added official antimicrobial names to all `filter_ab_class()` functions, such as `filter_aminoglycosides()`
* Added antibiotics code "FOX1" for cefoxitin screening (abbreviation "cfsc") to the `antibiotics` data set
* Added antibiotics code "FOX1" for cefoxitin screening (abbreviation "cfsc") to the `antibiotics` data set
* Improved auto-determination for columns of types <mo> and <Date>
* Improved auto-determination for columns of types `<mo>` and `<Date>`
#' Use these selection helpers inside any function that allows [Tidyverse selections](https://tidyselect.r-lib.org/reference/language.html), like `dplyr::select()` or `tidyr::pivot_longer()`. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
#' @details All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a selector like e.g. [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
#'
#' These functions only work if the `tidyselect` package is installed, that comes with the `dplyr` package. An error will be thrown if `tidyselect` package is not installed, or if the functions are used outside a function that allows Tidyverse selections like `select()` or `pivot_longer()`.
#' @rdname antibiotic_class_selectors
#' @seealso [filter_ab_class()] for the `filter()` equivalent.
#' @name antibiotic_class_selectors
#' @export
#' @examples
#' if (require("dplyr")) {
#'
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
#' example_isolates %>%
#' select(carbapenems())
#'
#'
#' # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
#' example_isolates %>%
#' select(mo, aminoglycosides())
#'
#'
#' data.frame(irrelevant = "value",
#' J01CA01 = "S") %>% # ATC code of ampicillin
#' select(penicillins()) # so the 'J01CA01' column is selected
#' Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs.
#' Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs.
#' @inheritSection lifecycle Stable lifecycle
#' @inheritSection lifecycle Stable lifecycle
#' @param x a data set
#' @param x a data set
#' @param ab_class an antimicrobial class, like `"carbapenems"`, as can be found in [`antibiotics$group`][antibiotics]
#' @param ab_class an antimicrobial class, like `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value.
#' @param result an antibiotic result: S, I or R (or a combination of more of them)
#' @param result an antibiotic result: S, I or R (or a combination of more of them)
#' @param scope the scope to check which variables to check, can be `"any"` (default) or `"all"`
#' @param scope the scope to check which variables to check, can be `"any"` (default) or `"all"`
#' @param ... parameters passed on to `filter_at` from the `dplyr` package
#' @param ... parameters passed on to `filter_at` from the `dplyr` package
#' @details The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched for the input given in `ab_class` (case-insensitive). Next, `x` will be checked for column names with a value in any abbreviation, code or official name found in the [antibiotics] data set.
#' @details All columns of `x` will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a filter function like e.g. [filter_aminoglycosides()] will include column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
#' @rdname filter_ab_class
#' @rdname filter_ab_class
#' @seealso [antibiotic_class_selectors()] for the `select()` equivalent.
<p><ahref="https://tidyselect.r-lib.org/reference/language.html">Tidyverse selections</a>, that help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. They can be used in any function that allows Tidyverse selections, like <code><ahref="https://dplyr.tidyverse.org/reference/select.html">dplyr::select()</a></code> and <code><ahref="https://tidyr.tidyverse.org/reference/pivot_longer.html">tidyr::pivot_longer()</a></code>:</p>
<li>Fixed a bug where <code><ahref="../reference/eucast_rules.html">eucast_rules()</a></code> would not work on a tibble when the <code>tibble</code> or <code>dplyr</code> package was loaded</li>
<li>Fixed a bug where <code><ahref="../reference/eucast_rules.html">eucast_rules()</a></code> would not work on a tibble when the <code>tibble</code> or <code>dplyr</code> package was loaded</li>
<li>All <code>*_join_microorganisms()</code> functions now return the original data class (e.g.tibbles and data.tables)</li>
<li>All <code>*_join_microorganisms()</code> functions now return the original data class (e.g.tibbles and data.tables)</li>
<li>Fixed a bug where <code><ahref="../reference/as.ab.html">as.ab()</a></code> would return an error on invalid input values</li>
<li>Fixed a bug where <code><ahref="../reference/as.ab.html">as.ab()</a></code> would return an error on invalid input values</li>
<li>Fixed a bug for using grouped versions of <code><ahref="../reference/proportion.html">rsi_df()</a></code>, <code><ahref="../reference/proportion.html">proportion_df()</a></code> and <code><ahref="../reference/count.html">count_df()</a></code>
<li>Fixed a bug for using grouped versions of <code><ahref="../reference/proportion.html">rsi_df()</a></code>, <code><ahref="../reference/proportion.html">proportion_df()</a></code> and <code><ahref="../reference/count.html">count_df()</a></code>, and fixed a bug where not all different antimicrobial results were added as rows</li>
</li>
<li>Added function <code><ahref="../reference/filter_ab_class.html">filter_penicillins()</a></code> to filter isolates on a specific result in any column with a name in the antimicrobial ‘penicillins’ class (more specific: ATC subgroup <em>Beta-lactam antibacterials, penicillins</em>)</li>
<li>Added function <code><ahref="../reference/filter_ab_class.html">filter_penicillins()</a></code> to filter isolates on a specific result in any column with a name in the antimicrobial ‘penicillins’ class (more specific: ATC subgroup <em>Beta-lactam antibacterials, penicillins</em>)</li>
<li>Added official antimicrobial names to all <code><ahref="../reference/filter_ab_class.html">filter_ab_class()</a></code> functions, such as <code><ahref="../reference/filter_ab_class.html">filter_aminoglycosides()</a></code>
<li>Added official antimicrobial names to all <code><ahref="../reference/filter_ab_class.html">filter_ab_class()</a></code> functions, such as <code><ahref="../reference/filter_ab_class.html">filter_aminoglycosides()</a></code>
</li>
</li>
<li>Added antibiotics code “FOX1” for cefoxitin screening (abbreviation “cfsc”) to the <code>antibiotics</code> data set</li>
<li>Added antibiotics code “FOX1” for cefoxitin screening (abbreviation “cfsc”) to the <code>antibiotics</code> data set</li>
<li>Improved auto-determination for columns of types <mo> and <date></date></mo>
<li>Improved auto-determination for columns of types <code><mo></code> and <code><Date></code>
</li>
</li>
</ul>
</ul>
</div>
</div>
@ -324,9 +341,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li>Support for easy principal component analysis for AMR, using the new <code><ahref="../reference/pca.html">pca()</a></code> function</li>
<li>Support for easy principal component analysis for AMR, using the new <code><ahref="../reference/pca.html">pca()</a></code> function</li>
<li>Plotting biplots for principal component analysis using the new <code><ahref="../reference/ggplot_pca.html">ggplot_pca()</a></code> function</li>
<li>Plotting biplots for principal component analysis using the new <code><ahref="../reference/ggplot_pca.html">ggplot_pca()</a></code> function</li>
@ -373,11 +390,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline</p></li>
<li><p>Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline</p></li>
<li>
<li>
<p>Interpretation from MIC values (and disk zones) to R/SI can now be used with <code><ahref="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at()</a></code> of the <code>dplyr</code> package:</p>
<p>Interpretation from MIC values (and disk zones) to R/SI can now be used with <code><ahref="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at()</a></code> of the <code>dplyr</code> package:</p>
<li><p>Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole</p></li>
<li><p>Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole</p></li>
<li><p>Added <code>uti</code> (as abbreviation of urinary tract infections) as parameter to <code><ahref="../reference/as.rsi.html">as.rsi()</a></code>, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs</p></li>
<li><p>Added <code>uti</code> (as abbreviation of urinary tract infections) as parameter to <code><ahref="../reference/as.rsi.html">as.rsi()</a></code>, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs</p></li>
@ -390,9 +407,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<p>This software is now out of beta and considered stable. Nonetheless, this package will be developed continually.</p>
<p>This software is now out of beta and considered stable. Nonetheless, this package will be developed continually.</p>
<divid="new-1" class="section level3">
<divid="new-2" class="section level3">
<h3class="hasAnchor">
<h3class="hasAnchor">
<ahref="#new-1" class="anchor"></a>New</h3>
<ahref="#new-2" class="anchor"></a>New</h3>
<ul>
<ul>
<li>Support for the newest <ahref="http://www.eucast.org/clinical_breakpoints/">EUCAST Clinical Breakpoint Tables v.10.0</a>, valid from 1 January 2020. This affects translation of MIC and disk zones using <code><ahref="../reference/as.rsi.html">as.rsi()</a></code> and inferred resistance and susceptibility using <code><ahref="../reference/eucast_rules.html">eucast_rules()</a></code>.</li>
<li>Support for the newest <ahref="http://www.eucast.org/clinical_breakpoints/">EUCAST Clinical Breakpoint Tables v.10.0</a>, valid from 1 January 2020. This affects translation of MIC and disk zones using <code><ahref="../reference/as.rsi.html">as.rsi()</a></code> and inferred resistance and susceptibility using <code><ahref="../reference/eucast_rules.html">eucast_rules()</a></code>.</li>
<li>The repository of this package now contains a clean version of the EUCAST and CLSI guidelines from 2011-2020 to translate MIC and disk diffusion values to R/SI: <ahref="https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt"class="uri">https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt</a>. This <strong>allows for machine reading these guidelines</strong>, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file used to process the EUCAST Clinical Breakpoints Excel file <ahref="https://gitlab.com/msberends/AMR/blob/master/data-raw/read_EUCAST.R">can be found here</a>.</li>
<li>The repository of this package now contains a clean version of the EUCAST and CLSI guidelines from 2011-2020 to translate MIC and disk diffusion values to R/SI: <ahref="https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt"class="uri">https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt</a>. This <strong>allows for machine reading these guidelines</strong>, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file used to process the EUCAST Clinical Breakpoints Excel file <ahref="https://gitlab.com/msberends/AMR/blob/master/data-raw/read_EUCAST.R">can be found here</a>.</li>
@ -400,7 +417,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<ul>
<ul>
<li>
<li>
<p>Support for LOINC codes in the <code>antibiotics</code> data set. Use <code><ahref="../reference/ab_property.html">ab_loinc()</a></code> to retrieve LOINC codes, or use a LOINC code for input in any <code>ab_*</code> function:</p>
<p>Support for LOINC codes in the <code>antibiotics</code> data set. Use <code><ahref="../reference/ab_property.html">ab_loinc()</a></code> to retrieve LOINC codes, or use a LOINC code for input in any <code>ab_*</code> function:</p>
@ -409,7 +426,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
</li>
<li>
<li>
<p>Support for SNOMED CT codes in the <code>microorganisms</code> data set. Use <code><ahref="../reference/mo_property.html">mo_snomed()</a></code> to retrieve SNOMED codes, or use a SNOMED code for input in any <code>mo_*</code> function:</p>
<p>Support for SNOMED CT codes in the <code>microorganisms</code> data set. Use <code><ahref="../reference/mo_property.html">mo_snomed()</a></code> to retrieve SNOMED codes, or use a SNOMED code for input in any <code>mo_*</code> function:</p>
<p>Functions <code><ahref="../reference/proportion.html">susceptibility()</a></code> and <code><ahref="../reference/proportion.html">resistance()</a></code> as aliases of <code><ahref="../reference/proportion.html">proportion_SI()</a></code> and <code><ahref="../reference/proportion.html">proportion_R()</a></code>, respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.</p>
<p>Functions <code><ahref="../reference/proportion.html">susceptibility()</a></code> and <code><ahref="../reference/proportion.html">resistance()</a></code> as aliases of <code><ahref="../reference/proportion.html">proportion_SI()</a></code> and <code><ahref="../reference/proportion.html">proportion_R()</a></code>, respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.</p>
@ -513,7 +530,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>More intelligent way of coping with some consonants like “l” and “r”</p></li>
<li><p>More intelligent way of coping with some consonants like “l” and “r”</p></li>
<li>
<li>
<p>Added a score (a certainty percentage) to <code><ahref="../reference/as.mo.html">mo_uncertainties()</a></code>, that is calculated using the <ahref="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a>:</p>
<p>Added a score (a certainty percentage) to <code><ahref="../reference/as.mo.html">mo_uncertainties()</a></code>, that is calculated using the <ahref="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a>:</p>
<spanclass="co">#> Results of two values were guessed with uncertainty. Use mo_uncertainties() to review them.</span>
<spanclass="co">#> Results of two values were guessed with uncertainty. Use mo_uncertainties() to review them.</span>
@ -570,12 +587,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<ul>
<ul>
<li>
<li>
<p>Determination of first isolates now <strong>excludes</strong> all ‘unknown’ microorganisms at default, i.e.microbial code <code>"UNKNOWN"</code>. They can be included with the new parameter <code>include_unknown</code>:</p>
<p>Determination of first isolates now <strong>excludes</strong> all ‘unknown’ microorganisms at default, i.e.microbial code <code>"UNKNOWN"</code>. They can be included with the new parameter <code>include_unknown</code>:</p>
<p>For WHONET users, this means that all records/isolates with organism code <code>"con"</code> (<em>contamination</em>) will be excluded at default, since <code>as.mo("con") = "UNKNOWN"</code>. The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.</p>
<p>For WHONET users, this means that all records/isolates with organism code <code>"con"</code> (<em>contamination</em>) will be excluded at default, since <code>as.mo("con") = "UNKNOWN"</code>. The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.</p>
</li>
</li>
<li>
<li>
<p>For code consistency, classes <code>ab</code> and <code>mo</code> will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in <code>NA</code>:</p>
<p>For code consistency, classes <code>ab</code> and <code>mo</code> will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in <code>NA</code>:</p>
<divclass="sourceCode"id="cb9"><preclass="r"><spanclass="co"># how it works in base R:</span>
<divclass="sourceCode"id="cb10"><preclass="r"><spanclass="co"># how it works in base R:</span>
@ -592,13 +609,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>Renamed data set <code>septic_patients</code> to <code>example_isolates</code></p></li>
<li><p>Renamed data set <code>septic_patients</code> to <code>example_isolates</code></p></li>
</ul>
</ul>
</div>
</div>
<divid="new-3" class="section level3">
<divid="new-4" class="section level3">
<h3class="hasAnchor">
<h3class="hasAnchor">
<ahref="#new-3" class="anchor"></a>New</h3>
<ahref="#new-4" class="anchor"></a>New</h3>
<ul>
<ul>
<li>
<li>
<p>Function <code><ahref="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> to quickly get a <code>data.frame</code> with the results of all bug-drug combinations in a data set. The column containing microorganism codes is guessed automatically and its input is transformed with <code><ahref="../reference/mo_property.html">mo_shortname()</a></code> at default:</p>
<p>Function <code><ahref="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> to quickly get a <code>data.frame</code> with the results of all bug-drug combinations in a data set. The column containing microorganism codes is guessed automatically and its input is transformed with <code><ahref="../reference/mo_property.html">mo_shortname()</a></code> at default:</p>
<spanclass="co">#> NOTE: Use 'format()' on this result to get a publicable/printable format.</span></pre></div>
<spanclass="co">#> NOTE: Use 'format()' on this result to get a publicable/printable format.</span></pre></div>
<p>You can format this to a printable format, ready for reporting or exporting to e.g.Excel with the base R <code><ahref="https://rdrr.io/r/base/format.html">format()</a></code> function:</p>
<p>You can format this to a printable format, ready for reporting or exporting to e.g.Excel with the base R <code><ahref="https://rdrr.io/r/base/format.html">format()</a></code> function:</p>
<p>Additional way to calculate co-resistance, i.e.when using multiple antimicrobials as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibility of a combination therapy. A new parameter <code>only_all_tested</code> (<strong>which defaults to <code>FALSE</code></strong>) replaces the old <code>also_single_tested</code> and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
<p>Additional way to calculate co-resistance, i.e.when using multiple antimicrobials as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibility of a combination therapy. A new parameter <code>only_all_tested</code> (<strong>which defaults to <code>FALSE</code></strong>) replaces the old <code>also_single_tested</code> and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
# Drug A Drug B include as include as include as include as
# Drug A Drug B include as include as include as include as
@ -643,7 +660,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
</li>
<li>
<li>
<p><code>tibble</code> printing support for classes <code>rsi</code>, <code>mic</code>, <code>disk</code>, <code>ab</code><code>mo</code>. When using <code>tibble</code>s containing antimicrobial columns, values <code>S</code> will print in green, values <code>I</code> will print in yellow and values <code>R</code> will print in red. Microbial IDs (class <code>mo</code>) will emphasise on the genus and species, not on the kingdom.</p>
<p><code>tibble</code> printing support for classes <code>rsi</code>, <code>mic</code>, <code>disk</code>, <code>ab</code><code>mo</code>. When using <code>tibble</code>s containing antimicrobial columns, values <code>S</code> will print in green, values <code>I</code> will print in yellow and values <code>R</code> will print in red. Microbial IDs (class <code>mo</code>) will emphasise on the genus and species, not on the kingdom.</p>
<divclass="sourceCode"id="cb13"><preclass="r"><spanclass="co"># (run this on your own console, as this page does not support colour printing)</span>
<divclass="sourceCode"id="cb14"><preclass="r"><spanclass="co"># (run this on your own console, as this page does not support colour printing)</span>
<p>Function <code><ahref="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions <code><ahref="../reference/count.html">count_df()</a></code> and <code><ahref="../reference/AMR-deprecated.html">portion_df()</a></code> to immediately show resistance percentages and number of available isolates:</p>
<p>Function <code><ahref="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions <code><ahref="../reference/count.html">count_df()</a></code> and <code><ahref="../reference/AMR-deprecated.html">portion_df()</a></code> to immediately show resistance percentages and number of available isolates:</p>
<li>Support for translation of disk diffusion and MIC values to RSI values (i.e.antimicrobial interpretations). Supported guidelines are EUCAST (2011 to 2019) and CLSI (2011 to 2019). Use <code><ahref="../reference/as.rsi.html">as.rsi()</a></code> on an MIC value (created with <code><ahref="../reference/as.mic.html">as.mic()</a></code>), a disk diffusion value (created with the new <code><ahref="../reference/as.disk.html">as.disk()</a></code>) or on a complete date set containing columns with MIC or disk diffusion values.</li>
<li>Support for translation of disk diffusion and MIC values to RSI values (i.e.antimicrobial interpretations). Supported guidelines are EUCAST (2011 to 2019) and CLSI (2011 to 2019). Use <code><ahref="../reference/as.rsi.html">as.rsi()</a></code> on an MIC value (created with <code><ahref="../reference/as.mic.html">as.mic()</a></code>), a disk diffusion value (created with the new <code><ahref="../reference/as.disk.html">as.disk()</a></code>) or on a complete date set containing columns with MIC or disk diffusion values.</li>
<li>Function <code><ahref="../reference/mo_property.html">mo_name()</a></code> as alias of <code><ahref="../reference/mo_property.html">mo_fullname()</a></code>
<li>Function <code><ahref="../reference/mo_property.html">mo_name()</a></code> as alias of <code><ahref="../reference/mo_property.html">mo_fullname()</a></code>
@ -856,7 +873,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>when all values are unique it now shows a message instead of a warning</p></li>
<li><p>when all values are unique it now shows a message instead of a warning</p></li>
@ -916,9 +933,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li>Contains the complete manual of this package and all of its functions with an explanation of their parameters</li>
<li>Contains the complete manual of this package and all of its functions with an explanation of their parameters</li>
<li>Contains a comprehensive tutorial about how to conduct antimicrobial resistance analysis, import data from WHONET or SPSS and many more.</li>
<li>Contains a comprehensive tutorial about how to conduct antimicrobial resistance analysis, import data from WHONET or SPSS and many more.</li>
</ul>
</ul>
<divid="new-6" class="section level4">
<divid="new-7" class="section level4">
<h4class="hasAnchor">
<h4class="hasAnchor">
<ahref="#new-6" class="anchor"></a>New</h4>
<ahref="#new-7" class="anchor"></a>New</h4>
<ul>
<ul>
<li><p><strong>BREAKING</strong>: removed deprecated functions, parameters and references to ‘bactid’. Use <code><ahref="../reference/as.mo.html">as.mo()</a></code> to identify an MO code.</p></li>
<li><p><strong>BREAKING</strong>: removed deprecated functions, parameters and references to ‘bactid’. Use <code><ahref="../reference/as.mo.html">as.mo()</a></code> to identify an MO code.</p></li>
<li>
<li>
@ -947,7 +964,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
</li>
<li>
<li>
<p>New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:</p>
<p>New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:</p>
<p>The <code>antibiotics</code> data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the <code>antibiotics</code> data set. For example:</p>
<p>The <code>antibiotics</code> data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the <code>antibiotics</code> data set. For example:</p>
@ -985,17 +1002,17 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>New function <code><ahref="../reference/age_groups.html">age_groups()</a></code> to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic antimicrobial resistance analysis per age group.</p></li>
<li><p>New function <code><ahref="../reference/age_groups.html">age_groups()</a></code> to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic antimicrobial resistance analysis per age group.</p></li>
<li>
<li>
<p>New function <code><ahref="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> as well as the base R <code><ahref="https://rdrr.io/r/base/plot.html">plot()</a></code> function can now be used for resistance prediction calculated with <code><ahref="../reference/resistance_predict.html">resistance_predict()</a></code>:</p>
<p>New function <code><ahref="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> as well as the base R <code><ahref="https://rdrr.io/r/base/plot.html">plot()</a></code> function can now be used for resistance prediction calculated with <code><ahref="../reference/resistance_predict.html">resistance_predict()</a></code>:</p>
<p>Functions <code><ahref="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code><ahref="../reference/first_isolate.html">filter_first_weighted_isolate()</a></code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.:</p>
<p>Functions <code><ahref="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code><ahref="../reference/first_isolate.html">filter_first_weighted_isolate()</a></code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.:</p>
@ -1036,7 +1053,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
</li>
<li>
<li>
<p>Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default <code>allow_uncertain = TRUE</code> is equal to uncertainty level 2. Run <code><ahref="../reference/as.mo.html">?as.mo</a></code> for more info about these levels.</p>
<p>Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default <code>allow_uncertain = TRUE</code> is equal to uncertainty level 2. Run <code><ahref="../reference/as.mo.html">?as.mo</a></code> for more info about these levels.</p>
@ -1049,7 +1066,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>All microbial IDs that found are now saved to a local file <code>~/.Rhistory_mo</code>. Use the new function <code>clean_mo_history()</code> to delete this file, which resets the algorithms.</p></li>
<li><p>All microbial IDs that found are now saved to a local file <code>~/.Rhistory_mo</code>. Use the new function <code>clean_mo_history()</code> to delete this file, which resets the algorithms.</p></li>
<li>
<li>
<p>Incoercible results will now be considered ‘unknown’, MO code <code>UNKNOWN</code>. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:</p>
<p>Incoercible results will now be considered ‘unknown’, MO code <code>UNKNOWN</code>. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:</p>
<spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(-<spanclass="no">count</span>, -<spanclass="no">cum_count</span>) <spanclass="co"># only get item, percent, cum_percent</span></pre></div>
<spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(-<spanclass="no">count</span>, -<spanclass="no">cum_count</span>) <spanclass="co"># only get item, percent, cum_percent</span></pre></div>
</li>
</li>
@ -1261,9 +1278,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>The data set <code>microorganisms</code> now contains <strong>all microbial taxonomic data from ITIS</strong> (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via <ahref="https://itis.gov"class="uri">https://itis.gov</a>. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set <code>microorganisms.old</code> contains all previously known taxonomic names from those kingdoms.</p></li>
<li><p>The data set <code>microorganisms</code> now contains <strong>all microbial taxonomic data from ITIS</strong> (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via <ahref="https://itis.gov"class="uri">https://itis.gov</a>. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set <code>microorganisms.old</code> contains all previously known taxonomic names from those kingdoms.</p></li>
<li>
<li>
@ -1279,7 +1296,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li>
</li>
</ul>
</ul>
<p>They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:</p>
<p>They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:</p>
@ -1301,14 +1318,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>Function <code>is.rsi.eligible</code> to check for columns that have valid antimicrobial results, but do not have the <code>rsi</code> class yet. Transform the columns of your raw data with: <code>data %>% mutate_if(is.rsi.eligible, as.rsi)</code></p></li>
<li><p>Function <code>is.rsi.eligible</code> to check for columns that have valid antimicrobial results, but do not have the <code>rsi</code> class yet. Transform the columns of your raw data with: <code>data %>% mutate_if(is.rsi.eligible, as.rsi)</code></p></li>
<li>
<li>
<p>Functions <code>as.mo</code> and <code>is.mo</code> as replacements for <code>as.bactid</code> and <code>is.bactid</code> (since the <code>microoganisms</code> data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The <code>as.mo</code> function determines microbial IDs using intelligent rules:</p>
<p>Functions <code>as.mo</code> and <code>is.mo</code> as replacements for <code>as.bactid</code> and <code>is.bactid</code> (since the <code>microoganisms</code> data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The <code>as.mo</code> function determines microbial IDs using intelligent rules:</p>
@ -1340,7 +1357,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>Added three antimicrobial agents to the <code>antibiotics</code> data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)</p></li>
<li><p>Added three antimicrobial agents to the <code>antibiotics</code> data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)</p></li>
<li>
<li>
<p>Added 163 trade names to the <code>antibiotics</code> data set, it now contains 298 different trade names in total, e.g.:</p>
<p>Added 163 trade names to the <code>antibiotics</code> data set, it now contains 298 different trade names in total, e.g.:</p>
@ -1355,7 +1372,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>Added parameters <code>minimum</code> and <code>as_percent</code> to <code>portion_df</code></p></li>
<li><p>Added parameters <code>minimum</code> and <code>as_percent</code> to <code>portion_df</code></p></li>
<li>
<li>
<p>Support for quasiquotation in the functions series <code>count_*</code> and <code>portions_*</code>, and <code>n_rsi</code>. This allows to check for more than 2 vectors or columns.</p>
<p>Support for quasiquotation in the functions series <code>count_*</code> and <code>portions_*</code>, and <code>n_rsi</code>. This allows to check for more than 2 vectors or columns.</p>
<strong>BREAKING</strong>: <code>rsi_df</code> was removed in favour of new functions <code>portion_R</code>, <code>portion_IR</code>, <code>portion_I</code>, <code>portion_SI</code> and <code>portion_S</code> to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old <code>rsi</code> function. The old function still works, but is deprecated.
<strong>BREAKING</strong>: <code>rsi_df</code> was removed in favour of new functions <code>portion_R</code>, <code>portion_IR</code>, <code>portion_I</code>, <code>portion_SI</code> and <code>portion_S</code> to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old <code>rsi</code> function. The old function still works, but is deprecated.
@ -1531,9 +1548,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<metaproperty="og:title"content="Antibiotic class selectors — antibiotic_class_selectors"/>
<metaproperty="og:description"content="Use these selection helpers inside any function that allows Tidyverse selections, like dplyr::select() or tidyr::pivot_longer(). They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations."/>
<p>Use these selection helpers inside any function that allows <ahref='https://tidyselect.r-lib.org/reference/language.html'>Tidyverse selections</a>, like <code><ahref='https://dplyr.tidyverse.org/reference/select.html'>dplyr::select()</a></code> or <code><ahref='https://tidyr.tidyverse.org/reference/pivot_longer.html'>tidyr::pivot_longer()</a></code>. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.</p>
<p>All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a selector like e.g. <code>aminoglycosides()</code> will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.</p>
<p>These functions only work if the <code>tidyselect</code> package is installed, that comes with the <code>dplyr</code> package. An error will be thrown if <code>tidyselect</code> package is not installed, or if the functions are used outside a function that allows Tidyverse selections like <code><ahref='https://dplyr.tidyverse.org/reference/select.html'>select()</a></code> or <code>pivot_longer()</code>.</p>
<divclass='dont-index'><p><code><ahref='filter_ab_class.html'>filter_ab_class()</a></code> for the <code><ahref='https://dplyr.tidyverse.org/reference/filter.html'>filter()</a></code> equivalent.</p></div>
<spanclass='kw'>J01CA01</span><spanclass='kw'>=</span><spanclass='st'>"S"</span>) <spanclass='kw'>%>%</span><spanclass='co'># ATC code of ampicillin</span>
<spanclass='fu'><ahref='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<spanclass='fu'>penicillins</span>()) <spanclass='co'># so the 'J01CA01' column is selected</span>
<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>
</div>
<divclass="pkgdown">
<p>Site built with <ahref="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
<spanclass="version label label-default"data-toggle="tooltip"data-placement="bottom"title="Latest development version">1.2.0.9003</span>
<spanclass="version label label-default"data-toggle="tooltip"data-placement="bottom"title="Latest development version">1.2.0.9007</span>
</span>
</span>
</div>
</div>
@ -272,7 +272,7 @@
</tr>
</tr>
<tr>
<tr>
<th>ab_class</th>
<th>ab_class</th>
<td><p>an antimicrobial class, like <code>"carbapenems"</code>, as can be found in <code><ahref='antibiotics.html'>antibiotics$group</a></code></p></td>
<td><p>an antimicrobial class, like <code>"carbapenems"</code>. The columns <code>group</code>, <code>atc_group1</code> and <code>atc_group2</code> of the <ahref='antibiotics.html'>antibiotics</a> data set will be searched (case-insensitive) for this value.</p></td>
<p>The columns <code>group</code>, <code>atc_group1</code> and <code>atc_group2</code> of the <ahref='antibiotics.html'>antibiotics</a> data set will be searched for the input given in <code>ab_class</code> (case-insensitive). Next, <code>x</code> will be checked for column names with a value in any abbreviation, code or official name found in the <ahref='antibiotics.html'>antibiotics</a> data set.</p>
<p>All columns of <code>x</code> will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a filter function like e.g. <code>filter_aminoglycosides()</code> will include column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.</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>
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>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>
<divclass='dont-index'><p><code><ahref='antibiotic_class_selectors.html'>antibiotic_class_selectors()</a></code> for the <code><ahref='https://dplyr.tidyverse.org/reference/select.html'>select()</a></code> equivalent.</p></div>
% Please edit documentation in R/ab_class_selectors.R
\name{antibiotic_class_selectors}
\alias{antibiotic_class_selectors}
\alias{aminoglycosides}
\alias{carbapenems}
\alias{cephalosporins}
\alias{cephalosporins_1st}
\alias{cephalosporins_2nd}
\alias{cephalosporins_3rd}
\alias{cephalosporins_4th}
\alias{cephalosporins_5th}
\alias{fluoroquinolones}
\alias{glycopeptides}
\alias{macrolides}
\alias{penicillins}
\alias{tetracyclines}
\title{Antibiotic class selectors}
\usage{
aminoglycosides()
carbapenems()
cephalosporins()
cephalosporins_1st()
cephalosporins_2nd()
cephalosporins_3rd()
cephalosporins_4th()
cephalosporins_5th()
fluoroquinolones()
glycopeptides()
macrolides()
penicillins()
tetracyclines()
}
\description{
Use these selection helpers inside any function that allows \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selections}, like \code{dplyr::select()} or \code{tidyr::pivot_longer()}. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
}
\details{
All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a selector like e.g. \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
These functions only work if the \code{tidyselect} package is installed, that comes with the \code{dplyr} package. An error will be thrown if \code{tidyselect} package is not installed, or if the functions are used outside a function that allows Tidyverse selections like \code{select()} or \code{pivot_longer()}.
}
\examples{
if (require("dplyr")) {
# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
example_isolates \%>\%
select(carbapenems())
# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
example_isolates \%>\%
select(mo, aminoglycosides())
data.frame(irrelevant = "value",
J01CA01 = "S") \%>\% # ATC code of ampicillin
select(penicillins()) # so the 'J01CA01' column is selected
}
}
\seealso{
\code{\link[=filter_ab_class]{filter_ab_class()}} for the \code{filter()} equivalent.
\item{ab_class}{an antimicrobial class, like \code{"carbapenems"}, as can be found in \code{\link[=antibiotics]{antibiotics$group}}}
\item{ab_class}{an antimicrobial class, like \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.}
\item{result}{an antibiotic result: S, I or R (or a combination of more of them)}
\item{result}{an antibiotic result: S, I or R (or a combination of more of them)}
Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs.
Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs.
}
}
\details{
\details{
The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched for the input given in \code{ab_class} (case-insensitive). Next, \code{x} will be checked for column names with a value in any abbreviation, code or official name found in the \link{antibiotics} data set.
All columns of \code{x} will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a filter function like e.g. \code{\link[=filter_aminoglycosides]{filter_aminoglycosides()}} will include column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
}
}
\section{Stable lifecycle}{
\section{Stable lifecycle}{
@ -103,3 +103,6 @@ example_isolates \%>\%
filter_fluoroquinolones("R", "all")
filter_fluoroquinolones("R", "all")
}
}
}
}
\seealso{
\code{\link[=antibiotic_class_selectors]{antibiotic_class_selectors()}} for the \code{select()} equivalent.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.