NEWS.md
- first_isolate()
can now take a vector of values for col_keyantibiotics
and can have an episode length of Inf
like()
functions:
+Now checks if pattern
is a valid regular expression
like()
(and %like%
) 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:
+if (guideline %unlike% "EUCAST") ...
Altered the RStudio addin, so it now iterates over %like%
-> %unlike%
-> %like_case%
-> %unlike_case%
if you keep pressing your keyboard shortcut
info
argument to as.mo()
to turn on/off the progress barcol_mo
for some functions (esp. eucast_rules()
and mdro()
) could not be column names of the microorganisms
data set as it would throw an errorFunctions oxazolidinones()
(an antibiotic selector function) and filter_oxazolidinones()
(an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid
+library(dplyr) x <- example_isolates %>% select(date, hospital_id, oxazolidinones()) @@ -320,7 +333,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" @@ -332,7 +345,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" @@ -342,7 +355,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 @@ -426,7 +439,7 @@
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 %>% @@ -480,7 +493,7 @@
mdr_cmi2012()
,- -
eucast_exceptional_phenotypes()
+# to select first isolates that are Gram-negative # and view results of cephalosporins and aminoglycosides: @@ -492,7 +505,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()), @@ -543,7 +556,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) @@ -566,7 +579,7 @@
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) @@ -584,7 +597,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> @@ -645,7 +658,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) @@ -834,7 +847,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") @@ -863,7 +876,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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" @@ -874,7 +887,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 @@ -939,11 +952,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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:
-+@@ -957,7 +970,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/if (mo_order(somebugs) == "Enterobacterales") ...
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 %>% @@ -986,7 +999,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")) @@ -1045,14 +1058,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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") @@ -1077,7 +1090,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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`. @@ -1100,13 +1113,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 @@ -1128,7 +1141,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) @@ -1211,7 +1224,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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) %>% @@ -1238,7 +1251,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
- UPEC (Uropathogenic E. coli)
All these lead to the microbial ID of E. coli:
-+as.mo("UPEC") # B_ESCHR_COL @@ -1343,7 +1356,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) %>% @@ -1438,7 +1451,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() @@ -1452,7 +1465,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 @@ -1461,7 +1474,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() @@ -1482,7 +1495,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) @@ -1490,13 +1503,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, ...)) %>% @@ -1529,7 +1542,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Now handles incorrect spelling, like
-i
instead ofy
andf
instead ofph
:+# mo_fullname() uses as.mo() internally @@ -1541,7 +1554,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) @@ -1556,7 +1569,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
All microbial IDs that found are now saved to a local file
~/.Rhistory_mo
. Use the new functionclean_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:+mo_genus("qwerty", language = "es") # Warning: @@ -1606,7 +1619,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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 @@ -1690,7 +1703,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" @@ -1707,7 +1720,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Support for grouping variables, test with:
-+septic_patients %>% group_by(hospital_id) %>% @@ -1715,7 +1728,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Support for (un)selecting columns:
-+septic_patients %>% freq(hospital_id) %>% @@ -1795,7 +1808,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:
-+mo_gramstain("E. coli") # [1] "Gram negative" @@ -1806,7 +1819,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) @@ -1821,7 +1834,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:+as.mo("E. coli") # [1] B_ESCHR_COL @@ -1830,7 +1843,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ 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:
-+thousands_of_E_colis <- rep("E. coli", 25000) microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s") @@ -1864,7 +1877,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
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.:+ab_official("Bactroban") # [1] "Mupirocin" @@ -1881,7 +1894,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Added arguments
minimum
andas_percent
toportion_df
Support for quasiquotation in the functions series
-count_*
andportions_*
, andn_rsi
. This allows to check for more than 2 vectors or columns.+septic_patients %>% select(amox, cipr) %>% count_IR() # which is the same as: @@ -1901,12 +1914,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Added longest en shortest character length in the frequency table (
freq
) header of classcharacter
Support for types (classes) list and matrix for
-freq
+