diff --git a/DESCRIPTION b/DESCRIPTION
index 3396a01c..558e0511 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: AMR
-Version: 1.4.0.9012
-Date: 2020-11-05
+Version: 1.4.0.9013
+Date: 2020-11-09
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),
diff --git a/NEWS.md b/NEWS.md
index b533a07b..e8f2d755 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,8 +1,13 @@
-# AMR 1.4.0.9012
-## Last updated: 5 November 2020
+# AMR 1.4.0.9013
+## Last updated: 9 November 2020
### New
-* Functions `is_gram_negative()` and `is_gram_positive()` as wrappers around `mo_gramstain()`. They always return `TRUE` or `FALSE`, thus always return `FALSE` for species outside the taxonomic kingdom of Bacteria.
+* Functions `is_gram_negative()` and `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. If you have the `dplyr` package installed, they can even determine the column with microorganisms themselves inside `dplyr` functions:
+ ```r
+ example_isolates %>%
+ filter(is_gram_positive())
+ #> NOTE: Using column `mo` as input for 'x'
+ ```
* Functions `%not_like%` and `%not_like_case%` as wrappers around `%like%` and `%like_case%`. The RStudio addin to insert the text " %like% " as provided in this package now iterates over all like variants. So if you have defined the keyboard shortcut Ctrl/Cmd + L to this addin, it will first insert ` %like% ` and by pressing it again it will be replaced with ` %not_like% `, etc.
### Changed
diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R
index 7d58173c..54be0406 100644
--- a/R/ab_class_selectors.R
+++ b/R/ab_class_selectors.R
@@ -54,7 +54,7 @@
#'
#' # get bug/drug combinations for only macrolides in Gram-positives:
#' example_isolates %>%
-#' filter(mo %>% is_gram_positive()) %>%
+#' filter(is_gram_positive()) %>%
#' select(mo, macrolides()) %>%
#' bug_drug_combinations() %>%
#' format()
diff --git a/R/eucast_rules.R b/R/eucast_rules.R
index 464910b3..f0a9b0dd 100755
--- a/R/eucast_rules.R
+++ b/R/eucast_rules.R
@@ -773,7 +773,7 @@ eucast_rules <- function(x,
like_is_one_of <- trimws(eucast_rules_df[i, "like.is.one_of", drop = TRUE])
mo_value <- trimws(eucast_rules_df[i, "this_value", drop = TRUE])
- # be sure to comprise all coagulase-negative/-positive Staphylococci when they are mentioned
+ # be sure to comprise all coagulase-negative/-positive staphylococci when they are mentioned
if (mo_value %like% "coagulase" && any(x$genus == "Staphylococcus", na.rm = TRUE)) {
if (mo_value %like% "negative") {
eucast_rules_df[i, "this_value"] <- paste0("^(", paste0(all_staph[which(all_staph$CNS_CPS %like% "negative"),
diff --git a/R/mo.R b/R/mo.R
index 3dccdf3c..08fb4a32 100755
--- a/R/mo.R
+++ b/R/mo.R
@@ -28,7 +28,7 @@
#' Use this function to determine a valid microorganism ID ([`mo`]). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like `"Staphylococcus aureus"`), an abbreviated name (like `"S. aureus"`), an abbreviation known in the field (like `"MRSA"`), or just a genus. Please see *Examples*.
#' @inheritSection lifecycle Stable lifecycle
#' @param x a character vector or a [data.frame] with one or two columns
-#' @param Becker a logical to indicate whether *Staphylococci* should be categorised into coagulase-negative *Staphylococci* ("CoNS") and coagulase-positive *Staphylococci* ("CoPS") instead of their own species, according to Karsten Becker *et al.* (1,2,3).
+#' @param Becker a logical to indicate whether staphylococci should be categorised into coagulase-negative staphylococci ("CoNS") and coagulase-positive staphylococci ("CoPS") instead of their own species, according to Karsten Becker *et al.* (1,2,3).
#'
#' This excludes *Staphylococcus aureus* at default, use `Becker = "all"` to also categorise *S. aureus* as "CoPS".
#' @param Lancefield a logical to indicate whether beta-haemolytic *Streptococci* should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield (4). These *Streptococci* will be categorised in their first group, e.g. *Streptococcus dysgalactiae* will be group C, although officially it was also categorised into groups G and L.
diff --git a/R/mo_property.R b/R/mo_property.R
index c5132733..7011fe06 100755
--- a/R/mo_property.R
+++ b/R/mo_property.R
@@ -41,7 +41,7 @@
#'
#' Since the top-level of the taxonomy is sometimes referred to as 'kingdom' and sometimes as 'domain', the functions [mo_kingdom()] and [mo_domain()] return the exact same results.
#'
-#' The Gram stain - [mo_gramstain()] - will be determined based on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002, [PMID 11837318](https://pubmed.ncbi.nlm.nih.gov/11837318)), who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a value `NA`. Functions [is_gram_negative()] and [is_gram_positive()] always return `TRUE` or `FALSE`, even for species outside the kingdom of Bacteria.
+#' The Gram stain - [mo_gramstain()] - will be determined based on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002, [PMID 11837318](https://pubmed.ncbi.nlm.nih.gov/11837318)), who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a value `NA`. Functions [is_gram_negative()] and [is_gram_positive()] 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.
#'
#' All output will be [translate]d where possible.
#'
@@ -122,7 +122,7 @@
#' mo_shortname("S. pyo", Lancefield = TRUE) # "GAS" (='Group A Streptococci')
#'
#'
-#' # language support for German, Dutch, Spanish, Portuguese, Italian and French
+#' # language support --------------------------------------------------------
#' mo_gramstain("E. coli", language = "de") # "Gramnegativ"
#' mo_gramstain("E. coli", language = "nl") # "Gram-negatief"
#' mo_gramstain("E. coli", language = "es") # "Gram negativo"
@@ -139,7 +139,11 @@
#' Lancefield = TRUE,
#' language = "nl") # "Streptococcus groep A"
#'
+#' # gram stains can be used as a filter
+#' example_isolates %>%
+#' filter(is_gram_positive())
#'
+#' # other --------------------------------------------------------------------
#' # get a list with the complete taxonomy (from kingdom to subspecies)
#' mo_taxonomy("E. coli")
#' # get a list with the taxonomy, the authors, Gram-stain and URL to the online database
@@ -177,10 +181,10 @@ mo_shortname <- function(x, language = get_locale(), ...) {
# exceptions for where no species is known
shortnames[shortnames %like% ".[.] spp[.]"] <- genera[shortnames %like% ".[.] spp[.]"]
- # exceptions for Staphylococci
+ # exceptions for staphylococci
shortnames[shortnames == "S. coagulase-negative"] <- "CoNS"
shortnames[shortnames == "S. coagulase-positive"] <- "CoPS"
- # exceptions for Streptococci: Streptococcus Group A -> GAS
+ # exceptions for streptococci: Group A Streptococcus -> GAS
shortnames[shortnames %like% "S. group [ABCDFGHK]"] <- paste0("G", gsub("S. group ([ABCDFGHK])", "\\1", shortnames[shortnames %like% "S. group [ABCDFGHK]"]), "S")
# unknown species etc.
shortnames[shortnames %like% "unknown"] <- paste0("(", trimws(gsub("[^a-zA-Z -]", "", shortnames[shortnames %like% "unknown"])), ")")
@@ -311,6 +315,23 @@ mo_gramstain <- function(x, language = get_locale(), ...) {
#' @rdname mo_property
#' @export
is_gram_negative <- function(x, language = get_locale(), ...) {
+ if (missing(x)) {
+ peek_mask_dplyr <- import_fn("peek_mask", "dplyr", error_on_fail = FALSE)
+ if (!is.null(peek_mask_dplyr)) {
+ try({
+ df <- as.data.frame(peek_mask_dplyr()$across_cols(), stringsAsFactors = FALSE)
+ mo <- suppressMessages(search_type_in_df(df, "mo"))
+ if (!is.null(mo)) {
+ message_("Using column `", font_bold(mo), "` as input for 'x'")
+ x <- df[, mo, drop = TRUE]
+ } else {
+ stop_("Argument 'x' is missing")
+ }
+ }, silent = TRUE)
+ } else {
+ stop_("Argument 'x' is missing")
+ }
+ }
meet_criteria(x, allow_NA = TRUE)
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
@@ -318,12 +339,31 @@ is_gram_negative <- function(x, language = get_locale(), ...) {
metadata <- get_mo_failures_uncertainties_renamed()
grams <- mo_gramstain(x.mo, language = NULL)
load_mo_failures_uncertainties_renamed(metadata)
- grams == "Gram-negative" & !is.na(grams)
+ out <- grams == "Gram-negative" & !is.na(grams)
+ out[x.mo %in% c(NA, "UNKNOWN")] <- NA
+ out
}
#' @rdname mo_property
#' @export
is_gram_positive <- function(x, language = get_locale(), ...) {
+ if (missing(x)) {
+ peek_mask_dplyr <- import_fn("peek_mask", "dplyr", error_on_fail = FALSE)
+ if (!is.null(peek_mask_dplyr)) {
+ try({
+ df <- as.data.frame(peek_mask_dplyr()$across_cols(), stringsAsFactors = FALSE)
+ mo <- suppressMessages(search_type_in_df(df, "mo"))
+ if (!is.null(mo)) {
+ message_("Using column `", font_bold(mo), "` as input for 'x'")
+ x <- df[, mo, drop = TRUE]
+ } else {
+ stop_("Argument 'x' is missing")
+ }
+ }, silent = TRUE)
+ } else {
+ stop_("Argument 'x' is missing")
+ }
+ }
meet_criteria(x, allow_NA = TRUE)
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
@@ -331,7 +371,9 @@ is_gram_positive <- function(x, language = get_locale(), ...) {
metadata <- get_mo_failures_uncertainties_renamed()
grams <- mo_gramstain(x.mo, language = NULL)
load_mo_failures_uncertainties_renamed(metadata)
- grams == "Gram-positive" & !is.na(grams)
+ out <- grams == "Gram-positive" & !is.na(grams)
+ out[x.mo %in% c(NA, "UNKNOWN")] <- NA
+ out
}
#' @rdname mo_property
diff --git a/docs/404.html b/docs/404.html
index e52ba3cd..e697ec40 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
NEWS.md
-
is_gram_negative()
and is_gram_positive()
as wrappers around mo_gramstain()
. They always return TRUE
or FALSE
, thus always return FALSE
for species outside the taxonomic kingdom of Bacteria.%not_like%
and %not_like_case%
as wrappers around %like%
and %like_case%
. The RStudio addin to insert the text " %like% " as provided in this package now iterates over all like variants. So if you have defined the keyboard shortcut Ctrl/Cmd + L to this addin, it will first insert %like%
and by pressing it again it will be replaced with %not_like%
, etc.Functions is_gram_negative()
and 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. If you have the dplyr
package installed, they can even determine the column with microorganisms themselves inside dplyr
functions:
+example_isolates %>% + filter(is_gram_positive()) +#> NOTE: Using column `mo` as input for 'x'
Functions %not_like%
and %not_like_case%
as wrappers around %like%
and %like_case%
. The RStudio addin to insert the text " %like% " as provided in this package now iterates over all like variants. So if you have defined the keyboard shortcut Ctrl/Cmd + L to this addin, it will first insert %like%
and by pressing it again it will be replaced with %not_like%
, etc.
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?
-+library(AMR) library(dplyr) intrinsic_resistant %>% @@ -309,7 +315,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) your_data %>% mutate_if(is.disk, as.rsi) @@ -326,7 +332,7 @@Added intelligent data cleaning to
-as.disk()
, so numbers can also be extracted from text and decimal numbers will always be rounded up:+ @@ -386,7 +392,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) # Columns 'IPM' and 'MEM' are in the example_isolates data set @@ -574,7 +580,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") @@ -602,7 +608,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" ab_name("21066-6") @@ -612,7 +618,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 mo_name(115329001) @@ -676,10 +682,10 @@ 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:
-+@@ -692,7 +698,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 %>% group_by(bug = mo_name(mo)) %>% @@ -720,7 +726,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")) #> Warning: @@ -778,13 +784,13 @@ 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 parameterinclude_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") x[1] <- "B" @@ -808,7 +814,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`. x[1:4, ] @@ -830,12 +836,12 @@ 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 parameteronly_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 # ----------------------- ----------------------- @@ -856,7 +862,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) example_isolates %>% @@ -938,7 +944,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) %>% rsi_df() @@ -964,7 +970,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 mo_name("UPEC") @@ -1068,7 +1074,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) %>% boxplot() @@ -1162,7 +1168,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() filter_cephalosporins() @@ -1175,7 +1181,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 septic_patients %>% filter_glycopeptides(result = "R", scope = "all") @@ -1183,7 +1189,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() ab_official -> atc_official() @@ -1203,19 +1209,19 @@ 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 antimicrobial resistance 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) ggplot_rsi_predict(x)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, ...)) %>% filter(only_firsts == TRUE) %>% @@ -1247,7 +1253,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 mo_fullname("Sthafilokockus aaureuz") @@ -1258,7 +1264,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) as.mo(..., allow_uncertain = 2) @@ -1272,7 +1278,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: # one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it. @@ -1321,7 +1327,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 septic_patients %>% @@ -1404,7 +1410,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" as.mo("S. spp") # B_STPHY @@ -1420,14 +1426,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
Support for grouping variables, test with:
-+septic_patients %>% group_by(hospital_id) %>% freq(gender)Support for (un)selecting columns:
-+@@ -1506,7 +1512,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/septic_patients %>% freq(hospital_id) %>% select(-count, -cum_count) # only get item, percent, cum_percentThey also come with support for German, Dutch, French, Italian, Spanish and Portuguese:
-+mo_gramstain("E. coli") # [1] "Gram negative" mo_gramstain("E. coli", language = "de") # German @@ -1516,7 +1522,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:
-+@@ -1530,7 +1536,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/mo_gramstain("Esc blattae") # Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010) # [1] "Gram negative"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 as.mo("MRSA") @@ -1538,7 +1544,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ as.mo("S group A") # [1] B_STRPTC_GRAAnd 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") # Unit: seconds @@ -1571,7 +1577,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" ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen")) @@ -1587,7 +1593,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/Added parameters
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: septic_patients %>% count_IR(amox, cipr) @@ -1606,11 +1612,11 @@ 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
@@ -270,7 +270,7 @@+For lists, subsetting is possible:
-@@ -315,7 +315,7 @@ # get bug/drug combinations for only macrolides in Gram-positives: example_isolates %>% - filter(mo %>% is_gram_positive()) %>% + filter(is_gram_positive()) %>% select(mo, macrolides()) %>% bug_drug_combinations() %>% format() diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index 64a0351b..65a66c23 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -82,7 +82,7 @@+diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 40ff0ae0..4bc7fd58 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2020-11-05T00:11Z +last_built: 2020-11-09T12:06Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/antibiotic_class_selectors.html b/docs/reference/antibiotic_class_selectors.html index 9878f8be..d21b93e9 100644 --- a/docs/reference/antibiotic_class_selectors.html +++ b/docs/reference/antibiotic_class_selectors.html @@ -82,7 +82,7 @@my_list = list(age = septic_patients$age, gender = septic_patients$gender) my_list %>% freq(age) my_list %>% freq(gender)Becker -a logical to indicate whether Staphylococci should be categorised into coagulase-negative Staphylococci ("CoNS") and coagulase-positive Staphylococci ("CoPS") instead of their own species, according to Karsten Becker et al. (1,2,3).
+a logical to indicate whether staphylococci should be categorised into coagulase-negative staphylococci ("CoNS") and coagulase-positive staphylococci ("CoPS") instead of their own species, according to Karsten Becker et al. (1,2,3).
This excludes Staphylococcus aureus at default, use
Becker = "all"
to also categorise S. aureus as "CoPS".diff --git a/docs/reference/index.html b/docs/reference/index.html index 4745e7ac..aa5dedce 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index c7e8aeea..b5bac64e 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -82,7 +82,7 @@ @@ -340,7 +340,7 @@The short name -
mo_shortname()
- almost always returns the first character of the genus and the full species, like"E. coli"
. Exceptions are abbreviations of staphylococci (like "CoNS", Coagulase-Negative Staphylococci) and beta-haemolytic streptococci (like "GBS", Group B Streptococci). Please bear in mind that e.g. E. coli could mean Escherichia coli (kingdom of Bacteria) as well as Entamoeba coli (kingdom of Protozoa). Returning to the full name will be done usingas.mo()
internally, giving priority to bacteria and human pathogens, i.e."E. coli"
will be considered Escherichia coli. In other words,mo_fullname(mo_shortname("Entamoeba coli"))
returns"Escherichia coli"
.Since the top-level of the taxonomy is sometimes referred to as 'kingdom' and sometimes as 'domain', the functions
-mo_kingdom()
andmo_domain()
return the exact same results.The Gram stain -
+mo_gramstain()
- will be determined based on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002, PMID 11837318), who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a valueNA
. Functionsis_gram_negative()
andis_gram_positive()
always returnTRUE
orFALSE
, even for species outside the kingdom of Bacteria.The Gram stain -
mo_gramstain()
- will be determined based on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002, PMID 11837318), who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a valueNA
. Functionsis_gram_negative()
andis_gram_positive()
always returnTRUE
orFALSE
(except when the input isNA
or the MO code isUNKNOWN
), thus always returnFALSE
for species outside the taxonomic kingdom of Bacteria.All output will be translated where possible.
The function
mo_url()
will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species.Stable lifecycle
@@ -461,7 +461,7 @@ This package contains the complete taxonomic tree of almost all microorganisms ( mo_shortname("S. pyo", Lancefield = TRUE) # "GAS" (='Group A Streptococci') -# language support for German, Dutch, Spanish, Portuguese, Italian and French +# language support -------------------------------------------------------- mo_gramstain("E. coli", language = "de") # "Gramnegativ" mo_gramstain("E. coli", language = "nl") # "Gram-negatief" mo_gramstain("E. coli", language = "es") # "Gram negativo" @@ -478,7 +478,11 @@ This package contains the complete taxonomic tree of almost all microorganisms ( Lancefield = TRUE, language = "nl") # "Streptococcus groep A" +# gram stains can be used as a filter +example_isolates %>% + filter(is_gram_positive()) +# other -------------------------------------------------------------------- # get a list with the complete taxonomy (from kingdom to subspecies) mo_taxonomy("E. coli") # get a list with the taxonomy, the authors, Gram-stain and URL to the online database diff --git a/docs/survey.html b/docs/survey.html index a7216eac..6f52806c 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ diff --git a/man/antibiotic_class_selectors.Rd b/man/antibiotic_class_selectors.Rd index ec087d35..8a68cef5 100644 --- a/man/antibiotic_class_selectors.Rd +++ b/man/antibiotic_class_selectors.Rd @@ -85,7 +85,7 @@ if (require("dplyr")) { # get bug/drug combinations for only macrolides in Gram-positives: example_isolates \%>\% - filter(mo \%>\% is_gram_positive()) \%>\% + filter(is_gram_positive()) \%>\% select(mo, macrolides()) \%>\% bug_drug_combinations() \%>\% format() diff --git a/man/as.mo.Rd b/man/as.mo.Rd index edf90246..5682e6ca 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -31,7 +31,7 @@ mo_renamed() \arguments{ \item{x}{a character vector or a \link{data.frame} with one or two columns} -\item{Becker}{a logical to indicate whether \emph{Staphylococci} should be categorised into coagulase-negative \emph{Staphylococci} ("CoNS") and coagulase-positive \emph{Staphylococci} ("CoPS") instead of their own species, according to Karsten Becker \emph{et al.} (1,2,3). +\item{Becker}{a logical to indicate whether staphylococci should be categorised into coagulase-negative staphylococci ("CoNS") and coagulase-positive staphylococci ("CoPS") instead of their own species, according to Karsten Becker \emph{et al.} (1,2,3). This excludes \emph{Staphylococcus aureus} at default, use \code{Becker = "all"} to also categorise \emph{S. aureus} as "CoPS".} diff --git a/man/mo_property.Rd b/man/mo_property.Rd index fac2dfaf..dc4a2bee 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -116,7 +116,7 @@ The short name - \code{\link[=mo_shortname]{mo_shortname()}} - almost always ret Since the top-level of the taxonomy is sometimes referred to as 'kingdom' and sometimes as 'domain', the functions \code{\link[=mo_kingdom]{mo_kingdom()}} and \code{\link[=mo_domain]{mo_domain()}} return the exact same results. -The Gram stain - \code{\link[=mo_gramstain]{mo_gramstain()}} - will be determined based on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002, \href{https://pubmed.ncbi.nlm.nih.gov/11837318}{PMID 11837318}), who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a value \code{NA}. Functions \code{\link[=is_gram_negative]{is_gram_negative()}} and \code{\link[=is_gram_positive]{is_gram_positive()}} always return \code{TRUE} or \code{FALSE}, even for species outside the kingdom of Bacteria. +The Gram stain - \code{\link[=mo_gramstain]{mo_gramstain()}} - will be determined based on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002, \href{https://pubmed.ncbi.nlm.nih.gov/11837318}{PMID 11837318}), who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a value \code{NA}. Functions \code{\link[=is_gram_negative]{is_gram_negative()}} and \code{\link[=is_gram_positive]{is_gram_positive()}} always return \code{TRUE} or \code{FALSE} (except when the input is \code{NA} or the MO code is \code{UNKNOWN}), thus always return \code{FALSE} for species outside the taxonomic kingdom of Bacteria. All output will be \link{translate}d where possible. @@ -241,7 +241,7 @@ mo_shortname("S. pyo") # "S. pyogenes" mo_shortname("S. pyo", Lancefield = TRUE) # "GAS" (='Group A Streptococci') -# language support for German, Dutch, Spanish, Portuguese, Italian and French +# language support -------------------------------------------------------- mo_gramstain("E. coli", language = "de") # "Gramnegativ" mo_gramstain("E. coli", language = "nl") # "Gram-negatief" mo_gramstain("E. coli", language = "es") # "Gram negativo" @@ -258,7 +258,11 @@ mo_fullname("S. pyogenes", Lancefield = TRUE, language = "nl") # "Streptococcus groep A" +# gram stains can be used as a filter +example_isolates \%>\% + filter(is_gram_positive()) +# other -------------------------------------------------------------------- # get a list with the complete taxonomy (from kingdom to subspecies) mo_taxonomy("E. coli") # get a list with the taxonomy, the authors, Gram-stain and URL to the online database diff --git a/tests/testthat/test-mo_property.R b/tests/testthat/test-mo_property.R index 88af6221..af25b6e9 100644 --- a/tests/testthat/test-mo_property.R +++ b/tests/testthat/test-mo_property.R @@ -117,4 +117,10 @@ test_that("mo_property works", { c(TRUE, FALSE, FALSE)) expect_equal(is_gram_positive(c("Escherichia coli", "Staphylococcus aureus", "Candida albicans")), c(FALSE, TRUE, FALSE)) + + library(dplyr) + expect_equal(example_isolates %>% filter(is_gram_negative()) %>% nrow(), + 730) + expect_equal(example_isolates %>% filter(is_gram_positive()) %>% nrow(), + 1238) })