vignettes/datasets.Rmd
datasets.Rmd
AMR
1.8.0.9000AMR
1.8.0.9001All functions in this package are considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months.
+Support for antibiotic interpretations of the MIPS laboratory system: "U"
for S (‘susceptible urine’), "D"
for I (‘susceptible dose-dependent’)
Improved algorithm of as.mo()
, especially for ignoring non-taxonomic text, such as:
+
+mo_name("methicillin-resistant S. aureus (MRSA)")
+#> [1] "Staphylococcus aureus"
AMR
1.8.02022-01-07All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months from now on.
p_symbol()
and all filter_*()
functions (except for filter_first_isolate()
), which were all deprecated in a previous package versionSupport for all antimicrobial drug (group) names and colloquial microorganism names in Danish, Dutch, English, French, German, Italian, Portuguese, Russian, Spanish and Swedish
Function set_ab_names()
to rename data set columns that resemble antimicrobial drugs. This allows for quickly renaming columns to official names, ATC codes, etc. Its second argument can be a tidyverse way of selecting:
+@@ -208,14 +224,14 @@example_isolates %>% set_ab_names(where(is.rsi)) example_isolates %>% set_ab_names(AMC:GEN, property = "atc")
Added more selectors for antibiotic classes: aminopenicillins()
, antifungals()
, antimycobacterials()
, lincosamides()
, lipoglycopeptides()
, polymyxins()
, quinolones()
, streptogramins()
, trimethoprims()
and ureidopenicillins()
Added specific selectors for certain types for treatment: administrable_per_os()
and administrable_iv()
, which are based on available Defined Daily Doses (DDDs), as defined by the WHOCC. These are ideal for e.g. analysing pathogens in primary care where IV treatment is not an option. They can be combined with other AB selectors, e.g. to select penicillins that are only administrable per os (i.e., orally):
+example_isolates[, penicillins() & administrable_per_os()] # base R example_isolates %>% select(penicillins() & administrable_per_os()) # dplyr
Added the selector ab_selector()
, which accepts a filter to be used internally on the antibiotics
data set, yielding great flexibility on drug properties, such as selecting antibiotic columns with an oral DDD of at least 1 gram:
+@@ -273,7 +289,7 @@example_isolates[, ab_selector(oral_ddd > 1 & oral_units == "g")] # base R example_isolates %>% select(ab_selector(oral_ddd > 1 & oral_units == "g")) # dplyr
Breaking change
All antibiotic class selectors (such as carbapenems()
, aminoglycosides()
) can now be used for filtering as well, making all their accompanying filter_*()
functions redundant (such as filter_carbapenems()
, filter_aminoglycosides()
). These functions are now deprecated and will be removed in a next release. Examples of how the selectors can be used for filtering:
+# select columns with results for carbapenems example_isolates[, carbapenems()] # base R @@ -328,7 +344,7 @@
Now checks if
pattern
is a valid regular expressionAdded
-%unlike%
and%unlike_case%
(as negations of the existing%like%
and%like_case%
). This greatly improves readability:+if (!grepl("EUCAST", guideline)) ... # same: @@ -381,7 +397,7 @@
Functions
-oxazolidinones()
(an antibiotic selector function) andfilter_oxazolidinones()
(an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid+library(dplyr) x <- example_isolates %>% select(date, hospital_id, oxazolidinones()) @@ -394,7 +410,7 @@
ggplot()
generics for classes<mic>
and<disk>
Function
-mo_is_yeast()
, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:+mo_kingdom(c("Aspergillus", "Candida")) #> [1] "Fungi" "Fungi" @@ -406,7 +422,7 @@ example_isolates[which(mo_is_yeast()), ] # base R example_isolates %>% filter(mo_is_yeast()) # dplyr
The
-mo_type()
function has also been updated to reflect this change:+mo_type(c("Aspergillus", "Candida")) # [1] "Fungi" "Yeasts" @@ -416,7 +432,7 @@
Added Pretomanid (PMD, J04AK08) to the
antibiotics
data setMIC values (see
-as.mic()
) can now be used in any mathematical processing, such as usage inside functionsmin()
,max()
,range()
, and with binary operators (+
,-
, etc.). This allows for easy distribution analysis and fast filtering on MIC values:+x <- random_mic(10) x @@ -485,7 +501,7 @@
New
Functions
-get_episode()
andis_new_episode()
to determine (patient) episodes which are not necessarily based on microorganisms. Theget_episode()
function returns the index number of the episode per group, while theis_new_episode()
function returns valuesTRUE
/FALSE
to indicate whether an item in a vector is the start of a new episode. They also supportdplyr
s grouping (i.e. usinggroup_by()
):+library(dplyr) example_isolates %>% @@ -530,7 +546,7 @@
mdr_cmi2012()
,- -
eucast_exceptional_phenotypes()
+# to select first isolates that are Gram-negative # and view results of cephalosporins and aminoglycosides: @@ -542,7 +558,7 @@
For antibiotic selection functions (such as
-cephalosporins()
,aminoglycosides()
) to select columns based on a certain antibiotic group, the dependency on thetidyselect
package was removed, meaning that they can now also be used without the need to have this package installed and now also work in base R function calls (they rely on R 3.2 or later):+# above example in base R: example_isolates[which(first_isolate() & mo_is_gram_negative()), @@ -585,7 +601,7 @@
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
andantibiotic
.Curious about which enterococci are actually intrinsic resistant to vancomycin?
-+library(AMR) library(dplyr) @@ -604,7 +620,7 @@
Improvements for
as.rsi()
:
Support for using
-dplyr
’sacross()
to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.+# until dplyr 1.0.0 your_data %>% mutate_if(is.mic, as.rsi) @@ -621,7 +637,7 @@
Added intelligent data cleaning to
-as.disk()
, so numbers can also be extracted from text and decimal numbers will always be rounded up:+as.disk(c("disk zone: 23.4 mm", 23.4)) #> Class <disk> @@ -670,7 +686,7 @@
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 usesas.ab()
internallyTidyverse 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()
andtidyr::pivot_longer()
:+library(dplyr) @@ -811,7 +827,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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 thedplyr
package:+yourdata %>% mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = "E. coli") @@ -834,7 +850,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
- Support for LOINC and SNOMED codes
Support for LOINC codes in the
-antibiotics
data set. Useab_loinc()
to retrieve LOINC codes, or use a LOINC code for input in anyab_*
function:+ab_loinc("ampicillin") #> [1] "21066-6" "3355-5" "33562-0" "33919-2" "43883-8" "43884-6" "87604-5" @@ -845,7 +861,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Support for SNOMED CT codes in the
-microorganisms
data set. Usemo_snomed()
to retrieve SNOMED codes, or use a SNOMED code for input in anymo_*
function:+mo_snomed("S. aureus") #> [1] 115329001 3092008 113961008 @@ -893,11 +909,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
- Adopted Adeolu et al. (2016), PMID 27620848 for the
microorganisms
data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like Morganellaceae and Yersiniaceae). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations withmdro()
will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
If you were dependent on the old Enterobacteriaceae family e.g. by using in your code:
-+if (mo_family(somebugs) == "Enterobacteriaceae") ...
then please adjust this to:
-+@@ -907,7 +923,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/if (mo_order(somebugs) == "Enterobacterales") ...
New
Functions
-susceptibility()
andresistance()
as aliases ofproportion_SI()
andproportion_R()
, respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.+library(dplyr) example_isolates %>% @@ -930,7 +946,7 @@ 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:+as.mo(c("Stafylococcus aureus", "staphylokok aureuz")) @@ -978,14 +994,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Breaking
Determination of first isolates now excludes all ‘unknown’ microorganisms at default, i.e. microbial code
-"UNKNOWN"
. They can be included with the new argumentinclude_unknown
:+first_isolate(..., include_unknown = TRUE)
For WHONET users, this means that all records/isolates with organism code
"con"
(contamination) will be excluded at default, sinceas.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
andmo
will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result inNA
:+# how it works in base R: x <- factor("A") @@ -1007,7 +1023,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
New
Function
-bug_drug_combinations()
to quickly get adata.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 withmo_shortname()
at default:+x <- bug_drug_combinations(example_isolates) #> NOTE: Using column `mo` as input for `col_mo`. @@ -1030,13 +1046,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ #> 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)
Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for
-portion_*
functions orcount_*
functions. This can be used to determine the empiric susceptibility of a combination therapy. A new argumentonly_all_tested
(which defaults toFALSE
) replaces the oldalso_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 theportion
andcount
help pages), where the %SI is being determined:+# -------------------------------------------------------------------- # only_all_tested = FALSE only_all_tested = TRUE @@ -1058,7 +1074,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
-
tibble
printing support for classesrsi
,mic
,disk
,ab
mo
. When usingtibble
s containing antimicrobial columns, valuesS
will print in green, valuesI
will print in yellow and valuesR
will print in red. Microbial IDs (classmo
) will emphasise on the genus and species, not on the kingdom.+# (run this on your own console, as this page does not support colour printing) library(dplyr) @@ -1126,7 +1142,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
New
Function
-rsi_df()
to transform adata.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 functionscount_df()
andportion_df()
to immediately show resistance percentages and number of available isolates:+septic_patients %>% select(AMX, CIP) %>% @@ -1151,7 +1167,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
- STEC (Shiga-toxin producing E. coli)
- UPEC (Uropathogenic E. coli)
All these lead to the microbial ID of E. coli:
-+as.mo("UPEC") # B_ESCHR_COL @@ -1235,7 +1251,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
when all values are unique it now shows a message instead of a warning
support for boxplots:
-+septic_patients %>% freq(age) %>% @@ -1310,7 +1326,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:
-+filter_aminoglycosides() filter_carbapenems() @@ -1324,7 +1340,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ 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 theantibiotics
data set. For example:+septic_patients %>% filter_glycopeptides(result = "R") # Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R @@ -1333,7 +1349,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
All
-ab_*
functions are deprecated and replaced byatc_*
functions:+ab_property -> atc_property() ab_name -> atc_name() @@ -1354,7 +1370,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
New function
age_groups()
to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic AMR data analysis per age group.New function
-ggplot_rsi_predict()
as well as the base Rplot()
function can now be used for resistance prediction calculated withresistance_predict()
:+x <- resistance_predict(septic_patients, col_ab = "amox") plot(x) @@ -1362,13 +1378,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Functions
-filter_first_isolate()
andfilter_first_weighted_isolate()
to shorten and fasten filtering on data sets with antimicrobial results, e.g.:+septic_patients %>% filter_first_isolate(...) # or filter_first_isolate(septic_patients, ...)
is equal to:
-+septic_patients %>% mutate(only_firsts = first_isolate(septic_patients, ...)) %>% @@ -1395,7 +1411,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
- Improvements for
as.mo()
:
Now handles incorrect spelling, like
-i
instead ofy
andf
instead ofph
:+# mo_fullname() uses as.mo() internally @@ -1407,7 +1423,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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.+# equal: as.mo(..., allow_uncertain = TRUE) @@ -1458,7 +1474,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
- Frequency tables (
freq()
function):
Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:
-+# Determine genus of microorganisms (mo) in `septic_patients` data set: # OLD WAY @@ -1528,7 +1544,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Fewer than 3 characters as input for
as.mo
will return NAFunction
-as.mo
(and allmo_*
wrappers) now supports genus abbreviations with “species” attached+as.mo("E. species") # B_ESCHR mo_fullname("E. spp.") # "Escherichia species" @@ -1544,7 +1560,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Frequency tables -
freq()
:
Support for grouping variables, test with:
-+septic_patients %>% group_by(hospital_id) %>% @@ -1552,7 +1568,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Support for (un)selecting columns:
-+septic_patients %>% freq(hospital_id) %>% @@ -1619,7 +1635,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
- Author and year:
mo_ref
They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:
-+mo_gramstain("E. coli") # [1] "Gram negative" @@ -1630,7 +1646,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ 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:
-+mo_gramstain("Esc blattae") # Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010) @@ -1643,7 +1659,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Function
is.rsi.eligible
to check for columns that have valid antimicrobial results, but do not have thersi
class yet. Transform the columns of your raw data with:data %>% mutate_if(is.rsi.eligible, as.rsi)
Functions
-as.mo
andis.mo
as replacements foras.bactid
andis.bactid
(since themicrooganisms
data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. Theas.mo
function determines microbial IDs using intelligent rules:+