AMR
(for R), there’s always a knowledgeable microbiologist by your side!-# AMR works great with dplyr, but it's not required or neccesary ++#> Selecting carbapenems: 'IPM' (imipenem), 'MEM' (meropenem)+# AMR works great with dplyr, but it's not required or neccesary library(AMR) library(dplyr) @@ -229,7 +229,7 @@ Since you are one of our users, we would like to know how you use the package an #> NOTE: Using column 'mo' as input for mo_is_intrinsic_resistant() #> Selecting aminoglycosides: 'AMK' (amikacin), 'GEN' (gentamicin), #> 'KAN' (kanamycin), 'TOB' (tobramycin) -#> Selecting carbapenems: 'IPM' (imipenem), 'MEM' (meropenem)
With only having defined a row filter on Gram-negative bacteria with intrinsic resistance to cefotaxime (mo_is_gram_negative()
and mo_is_intrinsic_resistant()
) and a column selection on two antibiotic groups (aminoglycosides()
and carbapenems()
), the reference data about all microorganisms and all antibiotics in the AMR
package make sure you get what you meant:
<a href="articles/datasets.html">
- <div style="background-color: #128f7635;">
- <div class="fa fa-database"></div>
- <span>Download our data sets</span>
- </div>
-</a>
-<a href="articles/AMR.html">
- <div style="background-color: #138F3865;">
- <div class="fa fa-chalkboard-teacher"></div>
- <span>Start learning AMR analysis</span>
- </div>
-</a>
-<a href="reference/as.rsi.html">
- <div style="background-color: #128f7650;">
- <div class="fa fa-language"></div>
- <span>Interpret MIC/disk values to R/SI</span>
- </div>
-</a>
-<a href="articles/MDR.html">
- <div style="background-color: #138F3835;">
- <div class="fa fa-skull-crossbones"></div>
- <span>Determine multi-drug resistance (MDR)</span>
- </div>
-</a>
This package is available here on the official R network (CRAN), which has a peer-reviewed submission process. Install this package in R from CRAN by using the command:
--install.packages("AMR")
+install.packages("AMR")
It will be downloaded and installed automatically. For RStudio, click on the menu Tools > Install Packages… and then type in “AMR” and press Install.
Note: Not all functions on this website may be available in this latest release. To use all functions and data sets mentioned on this website, install the latest development version.
The latest and unpublished development version can be installed from GitHub using:
--install.packages("remotes") -remotes::install_github("msberends/AMR")
+install.packages("remotes")
+remotes::install_github("msberends/AMR")
NEWS.md
- Function is_new_episode()
to determine patient episodes which are not necessarily based on microorganisms. It also supports grouped variables with e.g. mutate()
, filter()
and summarise()
of the dplyr
package:
++ filter(is_new_episode(date, episode_days = 60))+library(dplyr) example_isolates %>% group_by(patient_id, hospital_id) %>% - filter(is_new_episode(date, episode_days = 60))
Functions mo_is_gram_negative()
and mo_is_gram_positive()
as wrappers around mo_gramstain()
. They always return TRUE
or FALSE
(except when the input is NA
or the MO code is UNKNOWN
), thus always return FALSE
for species outside the taxonomic kingdom of Bacteria.
Function mo_is_intrinsic_resistant()
to test for intrinsic resistance, based on EUCAST Intrinsic Resistance and Unusual Phenotypes v3.2 from 2020.
Reference data used for as.rsi()
can now be set by the user, using the reference_data
parameter. This allows for using own interpretation guidelines. The user-set data must have the same structure as rsi_translation
.
Some functions are now context-aware when used inside dplyr
verbs, such as filter()
, mutate()
and summarise()
. This means that then the data parameter does not need to be set anymore. This is the case for the new functions mo_is_gram_negative()
, mo_is_gram_positive()
, mo_is_intrinsic_resistant()
and for the existing functions first_isolate()
, key_antibiotics()
, mdro()
, brmo()
, mrgn()
, mdr_tb()
, mdr_cmi2012()
, eucast_exceptional_phenotypes()
. This was already the case for antibiotic selection functions (such as using penicillins()
in dplyr::select()
).
++ as_tibble()+# to select first isolates that are Gram-negative # and view results of cephalosporins and aminoglycosides: library(dplyr) example_isolates %>% filter(first_isolate(), mo_is_gram_negative()) %>% select(mo, cephalosporins(), aminoglycosides()) %>% - as_tibble()
For all function parameters in the code, it is now defined what the exact type of user input should be (inspired by the typed
package). If the user input for a certain function does not meet the requirements for a specific parameter (such as the class or length), an informative error will be thrown. This makes the package more robust and the use of it more reproducible and reliable. In total, more than 400 arguments were defined.
Deprecated function p_symbol()
that not really fits the scope of this package. It will be removed in a future version. See here for the source code to preserve it.
Better tibble printing for MIC values
Fix for plotting MIC values with plot()
Added plot()
generic to class <disk>
LA-MRSA and CA-MRSA are now recognised as an abbreviation for Staphylococcus aureus, meaning that e.g. mo_genus("LA-MRSA")
will return "Staphylococcus"
and mo_is_gram_positive("LA-MRSA")
will return TRUE
.
Data set intrinsic_resistant
. This data set contains all bug-drug combinations where the ‘bug’ is intrinsic resistant to the ‘drug’ according to the latest EUCAST insights. It contains just two columns: microorganism
and antibiotic
.
Curious about which enterococci are actually intrinsic resistant to vancomycin?
-Support for veterinary ATC codes
Support for skimming classes <rsi>
, <mic>
, <disk>
and <mo>
with the skimr
package
Support for using dplyr
’s across()
to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.
Cleaning columns in a data.frame now allows you to specify those columns with tidy selection, e.g. as.rsi(df, col1:col9)
Big speed improvement for interpreting MIC values and disk zone diameters. When interpreting 5,000 MIC values of two antibiotics (10,000 values in total), our benchmarks showed a total run time going from 80.7-85.1 seconds to 1.8-2.0 seconds.
Added intelligent data cleaning to as.disk()
, so numbers can also be extracted from text and decimal numbers will always be rounded up:
Improvements for as.mo()
:
Function ab_from_text()
to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses as.ab()
internally
Tidyverse selection helpers for antibiotic classes, 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 selection helpers, like dplyr::select()
and tidyr::pivot_longer()
:
++#> Selecting carbapenems: `IPM` (imipenem), `MEM` (meropenem)+library(dplyr) # Columns 'IPM' and 'MEM' are in the example_isolates data set example_isolates %>% select(carbapenems()) -#> Selecting carbapenems: `IPM` (imipenem), `MEM` (meropenem)
Added mo_domain()
as an alias to mo_kingdom()
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)
Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline
Interpretation from MIC values (and disk zones) to R/SI can now be used with mutate_at()
of the dplyr
package:
Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole
Added uti
(as abbreviation of urinary tract infections) as parameter to as.rsi()
, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs
Support for LOINC codes in the antibiotics
data set. Use ab_loinc()
to retrieve LOINC codes, or use a LOINC code for input in any ab_*
function:
Support for SNOMED CT codes in the microorganisms
data set. Use mo_snomed()
to retrieve SNOMED codes, or use a SNOMED code for input in any mo_*
function:
++#> [1] "Gram-positive"+mo_snomed("S. aureus") #> [1] 115329001 3092008 113961008 mo_name(115329001) #> [1] "Staphylococcus aureus" mo_gramstain(115329001) -#> [1] "Gram-positive"
If you were dependent on the old Enterobacteriaceae family e.g. by using in your code:
--if (mo_family(somebugs) == "Enterobacteriaceae") ...
+
+if (mo_family(somebugs) == "Enterobacteriaceae") ...
then please adjust this to:
--if (mo_order(somebugs) == "Enterobacterales") ...
+
+if (mo_order(somebugs) == "Enterobacterales") ...
Functions susceptibility()
and resistance()
as aliases of proportion_SI()
and proportion_R()
, respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.
Support for a new MDRO guideline: Magiorakos AP, Srinivasan A et al. “Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance.” Clinical Microbiology and Infection (2012).
@@ -750,7 +763,8 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/More intelligent way of coping with some consonants like “l” and “r”
Added a score (a certainty percentage) to mo_uncertainties()
, that is calculated using the Levenshtein distance:
++#> "staphylokok aureuz" -> Staphylococcus aureus (B_STPHY_AURS, score: 85.7%)+as.mo(c("Stafylococcus aureus", "staphylokok aureuz")) #> Warning: @@ -760,7 +774,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ mo_uncertainties() #> "Stafylococcus aureus" -> Staphylococcus aureus (B_STPHY_AURS, score: 95.2%) -#> "staphylokok aureuz" -> Staphylococcus aureus (B_STPHY_AURS, score: 85.7%)
Determination of first isolates now excludes all ‘unknown’ microorganisms at default, i.e. microbial code "UNKNOWN"
. They can be included with the new parameter include_unknown
:
-first_isolate(..., include_unknown = TRUE)
+
+first_isolate(..., include_unknown = TRUE)
For WHONET users, this means that all records/isolates with organism code "con"
(contamination) will be excluded at default, since as.mo("con") = "UNKNOWN"
. The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.
For code consistency, classes ab
and mo
will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in NA
:
++#> invalid microorganism code, NA generated+# how it works in base R: x <- factor("A") x[1] <- "B" @@ -825,7 +841,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ x <- as.mo("E. coli") x[1] <- "testvalue" #> Warning message: -#> invalid microorganism code, NA generated
This is important, because a value like "testvalue"
could never be understood by e.g. mo_name()
, although the class would suggest a valid microbial code.
Function freq()
has moved to a new package, clean
(CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq()
function still works, since it is re-exported from the clean
package (which will be installed automatically upon updating this AMR
package).
Function bug_drug_combinations()
to quickly get a data.frame
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 mo_shortname()
at default:
++#> NOTE: Use 'format()' on this result to get a publicable/printable format.+x <- bug_drug_combinations(example_isolates) #> NOTE: Using column `mo` as input for `col_mo`. x[1:4, ] @@ -858,14 +875,16 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ #> 2 Gram-negative AMK 251 0 2 253 #> 3 Gram-negative AMP 227 0 405 632 #> 4 Gram-negative AMX 227 0 405 632 -#> NOTE: Use 'format()' on this result to get a publicable/printable format.
You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R format()
function:
-format(x, combine_IR = FALSE)
+
+format(x, combine_IR = FALSE)
Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for portion_*
functions or count_*
functions. This can be used to determine the empiric susceptibility of a combination therapy. A new parameter only_all_tested
(which defaults to FALSE
) replaces the old also_single_tested
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 portion
and count
help pages), where the %SI is being determined:
++# --------------------------------------------------------------------+# -------------------------------------------------------------------- # only_all_tested = FALSE only_all_tested = TRUE # ----------------------- ----------------------- @@ -881,17 +900,18 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # S or I <NA> X X - - # R <NA> - - - - # <NA> <NA> - - - - -# --------------------------------------------------------------------
Since this is a major change, usage of the old also_single_tested
will throw an informative error that it has been replaced by only_all_tested
.
tibble
printing support for classes rsi
, mic
, disk
, ab
mo
. When using tibble
s containing antimicrobial columns, values S
will print in green, values I
will print in yellow and values R
will print in red. Microbial IDs (class mo
) will emphasise on the genus and species, not on the kingdom.
Function rsi_df()
to transform a data.frame
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 count_df()
and portion_df()
to immediately show resistance percentages and number of available isolates:
++# 4 Ciprofloxacin R 0.1618169 228+septic_patients %>% select(AMX, CIP) %>% rsi_df() @@ -976,7 +997,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # 1 Amoxicillin SI 0.4442636 546 # 2 Amoxicillin R 0.5557364 683 # 3 Ciprofloxacin SI 0.8381831 1181 -# 4 Ciprofloxacin R 0.1618169 228
Support for all scientifically published pathotypes of E. coli to date (that we could find). Supported are:
@@ -994,13 +1015,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/All these lead to the microbial ID of E. coli:
-++# "Gram-negative"+as.mo("UPEC") # B_ESCHR_COL mo_name("UPEC") # "Escherichia coli" mo_gramstain("EHEC") -# "Gram-negative"
Function mo_info()
as an analogy to ab_info()
. The mo_info()
prints a list with the full taxonomy, authors, and the URL to the online database of a microorganism
Function mo_synonyms()
to get all previously accepted taxonomic names of a microorganism
when all values are unique it now shows a message instead of a warning
support for boxplots:
-New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:
-++filter_tetracyclines()+filter_aminoglycosides() filter_carbapenems() filter_cephalosporins() @@ -1203,24 +1227,26 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ filter_fluoroquinolones() filter_glycopeptides() filter_macrolides() -filter_tetracyclines()
The antibiotics
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 antibiotics
data set. For example:
++# Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R+septic_patients %>% filter_glycopeptides(result = "R") # Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R septic_patients %>% filter_glycopeptides(result = "R", scope = "all") -# Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R
All ab_*
functions are deprecated and replaced by atc_*
functions:
++ab_tradenames -> atc_tradenames()+ab_property -> atc_property() ab_name -> atc_name() ab_official -> atc_official() ab_trivial_nl -> atc_trivial_nl() ab_certe -> atc_certe() ab_umcg -> atc_umcg() -ab_tradenames -> atc_tradenames()
These functions use as.atc()
internally. The old atc_property
has been renamed atc_online_property()
. This is done for two reasons: firstly, not all ATC codes are of antibiotics (ab) but can also be of antivirals or antifungals. Secondly, the input must have class atc
or must be coerable to this class. Properties of these classes should start with the same class name, analogous to as.mo()
and e.g. mo_genus
.
New functions set_mo_source()
and get_mo_source()
to use your own predefined MO codes as input for as.mo()
and consequently all mo_*
functions
New function age_groups()
to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic antimicrobial resistance analysis per age group.
New function ggplot_rsi_predict()
as well as the base R plot()
function can now be used for resistance prediction calculated with resistance_predict()
:
++ggplot_rsi_predict(x)+x <- resistance_predict(septic_patients, col_ab = "amox") plot(x) -ggplot_rsi_predict(x)
Functions filter_first_isolate()
and filter_first_weighted_isolate()
to shorten and fasten filtering on data sets with antimicrobial results, e.g.:
++filter_first_isolate(septic_patients, ...)+septic_patients %>% filter_first_isolate(...) # or -filter_first_isolate(septic_patients, ...)
is equal to:
-++ select(-only_firsts)+septic_patients %>% mutate(only_firsts = first_isolate(septic_patients, ...)) %>% filter(only_firsts == TRUE) %>% - select(-only_firsts)
New function availability()
to check the number of available (non-empty) results in a data.frame
New vignettes about how to conduct AMR analysis, predict antimicrobial resistance, use the G-test and more. These are also available (and even easier readable) on our website: https://msberends.gitlab.io/AMR.
Now handles incorrect spelling, like i
instead of y
and f
instead of ph
:
++#> [1] "Staphylococcus kloosii"+# mo_fullname() uses as.mo() internally mo_fullname("Sthafilokockus aaureuz") #> [1] "Staphylococcus aureus" mo_fullname("S. klossi") -#> [1] "Staphylococcus kloosii"
Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default allow_uncertain = TRUE
is equal to uncertainty level 2. Run ?as.mo
for more info about these levels.
++as.mo(..., allow_uncertain = 0)+# equal: as.mo(..., allow_uncertain = TRUE) as.mo(..., allow_uncertain = 2) # also equal: as.mo(..., allow_uncertain = FALSE) -as.mo(..., allow_uncertain = 0)
Using as.mo(..., allow_uncertain = 3)
could lead to very unreliable results.
Implemented the latest publication of Becker et al. (2019), for categorising coagulase-negative Staphylococci
All microbial IDs that found are now saved to a local file ~/.Rhistory_mo
. Use the new function clean_mo_history()
to delete this file, which resets the algorithms.
Incoercible results will now be considered ‘unknown’, MO code UNKNOWN
. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:
++#> [1] "(género desconocido)"+mo_genus("qwerty", language = "es") # Warning: # one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it. -#> [1] "(género desconocido)"
Fix for vector containing only empty values
Finds better results when input is in other languages
Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:
-++ freq(mo_genus(mo))+# Determine genus of microorganisms (mo) in `septic_patients` data set: # OLD WAY septic_patients %>% @@ -1364,7 +1397,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # Even supports grouping variables: septic_patients %>% group_by(gender) %>% - freq(mo_genus(mo))
Header info is now available as a list, with the header
function
The parameter header
is now set to TRUE
at default, even for markdown
Fewer than 3 characters as input for as.mo
will return NA
Function as.mo
(and all mo_*
wrappers) now supports genus abbreviations with “species” attached
++mo_fullname("S. species") # "Staphylococcus species"+as.mo("E. species") # B_ESCHR mo_fullname("E. spp.") # "Escherichia species" as.mo("S. spp") # B_STPHY -mo_fullname("S. species") # "Staphylococcus species"
Added parameter combine_IR
(TRUE/FALSE) to functions portion_df
and count_df
, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)
Fix for portion_*(..., as_percent = TRUE)
when minimal number of isolates would not be met
Support for grouping variables, test with:
-++ freq(gender)+septic_patients %>% group_by(hospital_id) %>% - freq(gender)
Support for (un)selecting columns:
-Check for hms::is.hms
Now prints in markdown at default in non-interactive sessions
They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:
-++# [1] "Streptococcus grupo A"+mo_gramstain("E. coli") # [1] "Gram negative" mo_gramstain("E. coli", language = "de") # German @@ -1544,12 +1581,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ mo_gramstain("E. coli", language = "es") # Spanish # [1] "Gram negativo" mo_fullname("S. group A", language = "pt") # Portuguese -# [1] "Streptococcus grupo A"
Furthermore, former taxonomic names will give a note about the current taxonomic name:
-++# [1] "Gram negative"+mo_gramstain("Esc blattae") # Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010) -# [1] "Gram negative"
Functions count_R
, count_IR
, count_I
, count_SI
and count_S
to selectively count resistant or susceptible isolates
Function is.rsi.eligible
to check for columns that have valid antimicrobial results, but do not have the rsi
class yet. Transform the columns of your raw data with: data %>% mutate_if(is.rsi.eligible, as.rsi)
Functions as.mo
and is.mo
as replacements for as.bactid
and is.bactid
(since the microoganisms
data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The as.mo
function determines microbial IDs using intelligent rules:
++# [1] B_STRPTC_GRA+as.mo("E. coli") # [1] B_ESCHR_COL as.mo("MRSA") # [1] B_STPHY_AUR as.mo("S group A") -# [1] B_STRPTC_GRA
And with great speed too - on a quite regular Linux server from 2007 it takes us less than 0.02 seconds to transform 25,000 items:
-++# 0.01817717 0.01843957 0.03878077 100+thousands_of_E_colis <- rep("E. coli", 25000) microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s") # Unit: seconds # min median max neval -# 0.01817717 0.01843957 0.03878077 100
Added parameter reference_df
for as.mo
, so users can supply their own microbial IDs, name or codes as a reference table
Added three antimicrobial agents to the antibiotics
data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)
Added 163 trade names to the antibiotics
data set, it now contains 298 different trade names in total, e.g.:
++# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"+ab_official("Bactroban") # [1] "Mupirocin" ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen")) # [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin" ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen")) -# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
For first_isolate
, rows will be ignored when there’s no species available
Function ratio
is now deprecated and will be removed in a future release, as it is not really the scope of this package
Added parameters minimum
and as_percent
to portion_df
Support for quasiquotation in the functions series count_*
and portions_*
, and n_rsi
. This allows to check for more than 2 vectors or columns.
Edited ggplot_rsi
and geom_rsi
so they can cope with count_df
. The new fun
parameter has value portion_df
at default, but can be set to count_df
.
Fix for ggplot_rsi
when the ggplot2
package was not loaded
Added longest en shortest character length in the frequency table (freq
) header of class character
Support for types (classes) list and matrix for freq
+ +freq(my_matrix)
For lists, subsetting is possible:
-++my_list %>% freq(gender)+my_list = list(age = septic_patients$age, gender = septic_patients$gender) my_list %>% freq(age) -my_list %>% freq(gender)
If you have found a bug, please file a new issue at:
https://github.com/msberends/AMR/issues
plot(<disk>)
plot(<mic>)
barplot(<mic>)
plot(<rsi>)
barplot(<rsi>)
Plotting for classes rsi
and disk
Plotting for classes rsi
, mic
and disk
rsi
and disk
rsi
, mic
and disk
R/amr.R
, R/disk.R
, R/mic.R
, and 1 more
plot.Rd