diff --git a/DESCRIPTION b/DESCRIPTION index bf5c408e..10786081 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.4.0.9019 -Date: 2020-11-12 +Version: 1.4.0.9020 +Date: 2020-11-16 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NAMESPACE b/NAMESPACE index 4660150e..7605a88e 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -152,8 +152,6 @@ export(is.mic) export(is.mo) export(is.rsi) export(is.rsi.eligible) -export(is_gram_negative) -export(is_gram_positive) export(key_antibiotics) export(key_antibiotics_equal) export(kurtosis) @@ -173,6 +171,9 @@ export(mo_fullname) export(mo_genus) export(mo_gramstain) export(mo_info) +export(mo_is_gram_negative) +export(mo_is_gram_positive) +export(mo_is_intrinsic_resistant) export(mo_kingdom) export(mo_matching_score) export(mo_name) diff --git a/NEWS.md b/NEWS.md index 6bbad399..5061854f 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,12 +1,18 @@ -# AMR 1.4.0.9019 -## Last updated: 12 November 2020 +# AMR 1.4.0.9020 +## Last updated: 16 November 2020 ### New -* 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: +* 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. If you have the `dplyr` package installed, they can even determine the column with microorganisms themselves when used inside `dplyr` verbs: ```r example_isolates %>% - filter(is_gram_positive()) - #> NOTE: Using column `mo` as input for 'x' + filter(mo_is_gram_positive()) + #> NOTE: Using column `mo` as input for mo_is_gram_positive() + ``` +* Function `mo_is_intrinsic_resistant()` to test for intrinsic resistance, based on [EUCAST Intrinsic Resistance and Unusual Phenotypes v3.2](https://www.eucast.org/expert_rules_and_intrinsic_resistance/) from 2020. As with the new `mo_is_gram_*()` functions, if you have the `dplyr` package installed the column with microorganisms will be automatically determined when used inside `dplyr` verbs: + ```r + example_isolates %>% + filter(mo_is_intrinsic_resistant(ab = "Vancomycin")) + #> NOTE: Using column `mo` as input for mo_is_intrinsic_resistant() ``` * 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. diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R index 6c831854..eb1cf5ce 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(is_gram_positive()) %>% +#' filter(mo_is_gram_positive()) %>% #' select(mo, macrolides()) %>% #' bug_drug_combinations() %>% #' format() diff --git a/R/mo.R b/R/mo.R index fa34ba98..6904e307 100755 --- a/R/mo.R +++ b/R/mo.R @@ -148,8 +148,9 @@ #' as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRPA #' #' # All mo_* functions use as.mo() internally too (see ?mo_property): -#' mo_genus("E. coli") # returns "Escherichia" -#' mo_gramstain("E. coli") # returns "Gram negative" +#' mo_genus("E. coli") # returns "Escherichia" +#' mo_gramstain("E. coli") # returns "Gram negative" +#' mo_is_intrinsic_resistant("E. coli", "vanco") # returns TRUE #' } as.mo <- function(x, Becker = FALSE, @@ -1620,8 +1621,8 @@ get_skimmers.mo <- function(column) { sfl( skim_type = "mo", unique_total = ~pm_n_distinct(., na.rm = TRUE), - gram_negative = ~sum(is_gram_negative(stats::na.omit(.))), - gram_positive = ~sum(is_gram_positive(stats::na.omit(.))), + gram_negative = ~sum(mo_is_gram_negative(stats::na.omit(.))), + gram_positive = ~sum(mo_is_gram_positive(stats::na.omit(.))), top_genus = ~names(sort(-table(mo_genus(stats::na.omit(.), language = NULL))))[1L], top_species = ~names(sort(-table(mo_name(stats::na.omit(.), language = NULL))))[1L] ) diff --git a/R/mo_property.R b/R/mo_property.R index 4429c311..ecc0abf0 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -31,6 +31,7 @@ #' @param property one of the column names of the [microorganisms] data set or `"shortname"` #' @param language language of the returned text, defaults to system language (see [get_locale()]) and can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`, see [translate]. Also used to translate text like "no growth". Use `language = NULL` or `language = ""` to prevent translation. #' @param ... other parameters passed on to [as.mo()], such as 'allow_uncertain' and 'ignore_pattern' +#' @param ab any (vector of) text that can be coerced to a valid antibiotic code with [as.ab()] #' @param open browse the URL using [utils::browseURL()] #' @details All functions will return the most recently known taxonomic property according to the Catalogue of Life, except for [mo_ref()], [mo_authors()] and [mo_year()]. Please refer to this example, knowing that *Escherichia blattae* was renamed to *Shimwellia blattae* in 2010: #' - `mo_name("Escherichia blattae")` will return `"Shimwellia blattae"` (with a message about the renaming) @@ -41,7 +42,9 @@ #' #' 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` (except when the input is `NA` or the MO code is `UNKNOWN`), thus always return `FALSE` for species outside the taxonomic 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 [mo_is_gram_negative()] and [mo_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. +#' +#' Intrinsic resistance - [mo_is_intrinsic_resistant()] - will be determined based on the [intrinsic_resistant] data set, which is based on `r format_eucast_version_nr(3.2)`. The [mo_is_intrinsic_resistant()] can be vectorised over parameters `x` (input for microorganisms) and over `ab` (input for antibiotics). #' #' All output will be [translate]d where possible. #' @@ -139,13 +142,19 @@ #' Lancefield = TRUE, #' language = "nl") # "Streptococcus groep A" #' -#' # gram stains can be used as a filter +#' +#' # other -------------------------------------------------------------------- +#' +#' # gram stains and intrinsic resistance can also be used as a filter in dplyr verbs #' if (require("dplyr")) { #' example_isolates %>% -#' filter(is_gram_positive()) +#' filter(mo_is_gram_positive()) +#' +#' example_isolates %>% +#' filter(mo_is_intrinsic_resistant(ab = "vanco")) #' } #' -#' # 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 @@ -316,23 +325,10 @@ mo_gramstain <- function(x, language = get_locale(), ...) { #' @rdname mo_property #' @export -is_gram_negative <- function(x, language = get_locale(), ...) { +mo_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") - } + # this supports using in dplyr verbs: ... %>% filter(mo_is_gram_negative()) + x <- find_mo_col("mo_is_gram_negative") } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) @@ -342,29 +338,16 @@ is_gram_negative <- function(x, language = get_locale(), ...) { grams <- mo_gramstain(x.mo, language = NULL) load_mo_failures_uncertainties_renamed(metadata) out <- grams == "Gram-negative" & !is.na(grams) - out[x.mo %in% c(NA, "UNKNOWN")] <- NA + out[x.mo %in% c(NA_character_, "UNKNOWN")] <- NA out } #' @rdname mo_property #' @export -is_gram_positive <- function(x, language = get_locale(), ...) { +mo_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") - } + # this supports using in dplyr verbs: ... %>% filter(mo_is_gram_positive()) + x <- find_mo_col("mo_is_gram_positive") } meet_criteria(x, allow_NA = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) @@ -374,10 +357,40 @@ is_gram_positive <- function(x, language = get_locale(), ...) { grams <- mo_gramstain(x.mo, language = NULL) load_mo_failures_uncertainties_renamed(metadata) out <- grams == "Gram-positive" & !is.na(grams) - out[x.mo %in% c(NA, "UNKNOWN")] <- NA + out[x.mo %in% c(NA_character_, "UNKNOWN")] <- NA out } +#' @rdname mo_property +#' @export +mo_is_intrinsic_resistant <- function(x, ab, language = get_locale(), ...) { + if (missing(x)) { + # this supports using in dplyr verbs: ... %>% filter(mo_is_intrinsic_resistant(ab = "amox")) + x <- find_mo_col("mo_is_intrinsic_resistant") + } + meet_criteria(x, allow_NA = TRUE) + meet_criteria(ab, allow_NA = FALSE) + meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) + + x.mo <- as.mo(x, language = language, ...) + x <- mo_name(x.mo, language = NULL) # has to match intrinsic_resistant$microorganism + ab <- ab_name(ab, language = NULL, # has to match intrinsic_resistant$antibiotic + flag_multiple_results = FALSE, + info = FALSE) + if (length(x) == 1 & length(ab) > 1) { + x <- rep(x, length(ab)) + } else if (length(ab) == 1 & length(x) > 1) { + ab <- rep(ab, length(x)) + } + if (length(x) != length(ab)) { + stop_("length of 'x' and 'ab' must be equal, or one of them must be of length 1.") + } + + intrinsic_to_check <- intrinsic_resistant[which(intrinsic_resistant$microorganism %in% x | + intrinsic_resistant$antibiotic %in% ab), , drop = FALSE] + paste(x, ab) %in% paste(intrinsic_to_check$microorganism, intrinsic_to_check$antibiotic) +} + #' @rdname mo_property #' @export mo_snomed <- function(x, language = get_locale(), ...) { @@ -592,3 +605,25 @@ mo_validate <- function(x, property, language, ...) { return(x) } } + +find_mo_col <- function(fn) { + # this function tries to find an mo column using dplyr:::peek_mask() for mo_is_*() functions, + # which is useful when functions are used within dplyr verbs + peek_mask_dplyr <- import_fn("peek_mask", "dplyr", error_on_fail = FALSE) + if (!is.null(peek_mask_dplyr)) { + df <- NULL + mo <- NULL + try({ + df <- as.data.frame(peek_mask_dplyr()$across_cols(), stringsAsFactors = FALSE) + mo <- suppressMessages(search_type_in_df(df, "mo")) + }, silent = TRUE) + if (!is.null(df) && !is.null(mo) && is.data.frame(df)) { + message_("Using column `", font_bold(mo), "` as input for ", fn, "()") + return(df[, mo, drop = TRUE]) + } else { + stop_("Argument 'x' is missing and no column with info about microorganisms could be found.", call = -2) + } + } else { + stop_("Argument 'x' is missing.", call = -2) + } +} diff --git a/docs/404.html b/docs/404.html index 556e709d..333cb5db 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index e93165e5..55d12c2c 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020 diff --git a/docs/articles/index.html b/docs/articles/index.html index 53105e60..7b138a6b 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020 diff --git a/docs/authors.html b/docs/authors.html index 5656650c..c396b164 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020 diff --git a/docs/index.html b/docs/index.html index 2b639a4a..d9700088 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020 diff --git a/docs/news/index.html b/docs/news/index.html index b8446250..f0ee724a 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020 @@ -236,24 +236,31 @@ Source: NEWS.md -
-

-AMR 1.4.0.9019 Unreleased +
+

+AMR 1.4.0.9020 Unreleased

-
+

-Last updated: 12 November 2020 +Last updated: 16 November 2020

New

  • -

    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:

    +

    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. If you have the dplyr package installed, they can even determine the column with microorganisms themselves when used inside dplyr verbs:

     example_isolates %>%
    -  filter(is_gram_positive())
    -#> NOTE: Using column `mo` as input for 'x'
    + filter(mo_is_gram_positive()) +#> NOTE: Using column `mo` as input for mo_is_gram_positive()
+ +
  • +

    Function mo_is_intrinsic_resistant() to test for intrinsic resistance, based on EUCAST Intrinsic Resistance and Unusual Phenotypes v3.2 from 2020. As with the new mo_is_gram_*() functions, if you have the dplyr package installed the column with microorganisms will be automatically determined when used inside dplyr verbs:

    +
    +example_isolates %>%
    +  filter(mo_is_intrinsic_resistant(ab = "Vancomycin"))
    +#> NOTE: Using column `mo` as input for mo_is_intrinsic_resistant()
  • 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.

  • @@ -295,7 +302,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 and antibiotic.

    Curious about which enterococci are actually intrinsic resistant to vancomycin?

    -
    +
     library(AMR)
     library(dplyr)
     intrinsic_resistant %>%
    @@ -317,7 +324,7 @@
     
    • 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.

      -
      +
       # until dplyr 1.0.0
       your_data %>% mutate_if(is.mic, as.rsi)
       your_data %>% mutate_if(is.disk, as.rsi)
      @@ -334,7 +341,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>
       #> [1] 24 24
      @@ -394,7 +401,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 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():

      -
      +
       library(dplyr)
       
       # Columns 'IPM' and 'MEM' are in the example_isolates data set
      @@ -582,7 +589,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 the dplyr package:

      -
      +
       yourdata %>% 
         mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = "E. coli")
       
      @@ -610,7 +617,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
       
      • 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:

        -
        +
         ab_loinc("ampicillin")
         #> [1] "21066-6" "3355-5"  "33562-0" "33919-2" "43883-8" "43884-6" "87604-5"
         ab_name("21066-6")
        @@ -620,7 +627,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
         
      • 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:

        -
        +
         mo_snomed("S. aureus")
         #> [1] 115329001   3092008 113961008
         mo_name(115329001)
        @@ -684,10 +691,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:

          -
          +
           if (mo_order(somebugs) == "Enterobacterales") ...
        @@ -700,7 +707,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
        • 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.

          -
          +
           library(dplyr)
           example_isolates %>%
             group_by(bug = mo_name(mo)) %>% 
          @@ -728,7 +735,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: 
          @@ -786,13 +793,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 parameter include_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, 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:

            -
            +
             # how it works in base R:
             x <- factor("A")
             x[1] <- "B"
            @@ -816,7 +823,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
             
            • 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:

              -
              +
               x <- bug_drug_combinations(example_isolates)
               #> NOTE: Using column `mo` as input for `col_mo`.
               x[1:4, ]
              @@ -838,12 +845,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 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
               #                     -----------------------  -----------------------
              @@ -864,7 +871,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
               
            • tibble printing support for classes rsi, mic, disk, ab mo. When using tibbles 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.

              -
              +
               # (run this on your own console, as this page does not support colour printing)
               library(dplyr)
               example_isolates %>%
              @@ -946,7 +953,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
               
              • 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:

                -
                +
                 septic_patients %>%
                   select(AMX, CIP) %>%
                   rsi_df()
                @@ -972,7 +979,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")
              @@ -1076,7 +1083,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()
              @@ -1170,7 +1177,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()
              @@ -1183,7 +1190,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 the antibiotics 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")
              @@ -1191,7 +1198,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
               
            • All ab_* functions are deprecated and replaced by atc_* functions:

              -
              +
               ab_property -> atc_property()
               ab_name -> atc_name()
               ab_official -> atc_official()
              @@ -1211,19 +1218,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 R plot() function can now be used for resistance prediction calculated with resistance_predict():

              -
              +
               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.:

              -
              +
               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) %>%
              @@ -1255,7 +1262,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
               
              • Now handles incorrect spelling, like i instead of y and f instead of ph:

                -
                +
                 # mo_fullname() uses as.mo() internally
                 
                 mo_fullname("Sthafilokockus aaureuz")
                @@ -1266,7 +1273,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)
                @@ -1280,7 +1287,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 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:

                -
                +
                 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.
                @@ -1329,7 +1336,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 %>%
                  @@ -1412,7 +1419,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • 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

                  -
                  +
                   as.mo("E. species")        # B_ESCHR
                   mo_fullname("E. spp.")     # "Escherichia species"
                   as.mo("S. spp")            # B_STPHY
                  @@ -1428,14 +1435,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:

                    -
                    +
                     septic_patients %>% 
                       freq(hospital_id) %>% 
                       select(-count, -cum_count) # only get item, percent, cum_percent
                    @@ -1514,7 +1521,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"
                   mo_gramstain("E. coli", language = "de") # German
                  @@ -1524,7 +1531,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)
                   # [1] "Gram negative"
                  @@ -1538,7 +1545,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 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:

                  -
                  +
                   as.mo("E. coli")
                   # [1] B_ESCHR_COL
                   as.mo("MRSA")
                  @@ -1546,7 +1553,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")
                   # Unit: seconds
                  @@ -1579,7 +1586,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"))
                  @@ -1595,7 +1602,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • 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.

                  -
                  +
                   septic_patients %>% select(amox, cipr) %>% count_IR()
                   # which is the same as:
                   septic_patients %>% count_IR(amox, cipr)
                  @@ -1614,11 +1621,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 class character

                • Support for types (classes) list and matrix for freq

                  -
                  +
                   my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2))
                   freq(my_matrix)

                  For lists, subsetting is possible:

                  -
                  +
                   my_list = list(age = septic_patients$age, gender = septic_patients$gender)
                   my_list %>% freq(age)
                   my_list %>% freq(gender)
                  diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index d652f1c3..2ae4a883 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-12T10:02Z +last_built: 2020-11-16T09:57Z 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 7c996e9b..12e7a928 100644 --- a/docs/reference/antibiotic_class_selectors.html +++ b/docs/reference/antibiotic_class_selectors.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020
                  @@ -315,7 +315,7 @@ # get bug/drug combinations for only macrolides in Gram-positives: example_isolates %>% - filter(is_gram_positive()) %>% + filter(mo_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 7fa70916..392ceee9 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020
                  @@ -455,8 +455,9 @@ This package contains the complete taxonomic tree of almost all microorganisms ( as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRPA # All mo_* functions use as.mo() internally too (see ?mo_property): -mo_genus("E. coli") # returns "Escherichia" -mo_gramstain("E. coli") # returns "Gram negative" +mo_genus("E. coli") # returns "Escherichia" +mo_gramstain("E. coli") # returns "Gram negative" +mo_is_intrinsic_resistant("E. coli", "vanco") # returns TRUE # }
                • diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index 018908d9..3a9633e8 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020
                  diff --git a/docs/reference/index.html b/docs/reference/index.html index fec5faf1..391fb915 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020
                • @@ -361,7 +361,7 @@ -

                  mo_name() mo_fullname() mo_shortname() mo_subspecies() mo_species() mo_genus() mo_family() mo_order() mo_class() mo_phylum() mo_kingdom() mo_domain() mo_type() mo_gramstain() is_gram_negative() is_gram_positive() mo_snomed() mo_ref() mo_authors() mo_year() mo_rank() mo_taxonomy() mo_synonyms() mo_info() mo_url() mo_property()

                  +

                  mo_name() mo_fullname() mo_shortname() mo_subspecies() mo_species() mo_genus() mo_family() mo_order() mo_class() mo_phylum() mo_kingdom() mo_domain() mo_type() mo_gramstain() mo_is_gram_negative() mo_is_gram_positive() mo_is_intrinsic_resistant() mo_snomed() mo_ref() mo_authors() mo_year() mo_rank() mo_taxonomy() mo_synonyms() mo_info() mo_url() mo_property()

                  Get properties of a microorganism

                  diff --git a/docs/reference/intrinsic_resistant.html b/docs/reference/intrinsic_resistant.html index 7590519c..9034d9af 100644 --- a/docs/reference/intrinsic_resistant.html +++ b/docs/reference/intrinsic_resistant.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020
                  diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index 1609cce0..ed41ba40 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020
                • @@ -270,9 +270,11 @@ mo_gramstain(x, language = get_locale(), ...) -is_gram_negative(x, language = get_locale(), ...) +mo_is_gram_negative(x, language = get_locale(), ...) -is_gram_positive(x, language = get_locale(), ...) +mo_is_gram_positive(x, language = get_locale(), ...) + +mo_is_intrinsic_resistant(x, ab, language = get_locale(), ...) mo_snomed(x, language = get_locale(), ...) @@ -309,6 +311,10 @@ ...

                  other parameters passed on to as.mo(), such as 'allow_uncertain' and 'ignore_pattern'

                  + + ab +

                  any (vector of) text that can be coerced to a valid antibiotic code with as.ab()

                  + open

                  browse the URL using utils::browseURL()

                  @@ -340,7 +346,8 @@

                  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 using as.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() 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), 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.

                  +

                  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 value NA. Functions mo_is_gram_negative() and mo_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.

                  +

                  Intrinsic resistance - mo_is_intrinsic_resistant() - will be determined based on the intrinsic_resistant data set, which is based on 'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.2 from 2020. The mo_is_intrinsic_resistant() can be vectorised over parameters x (input for microorganisms) and over ab (input for antibiotics).

                  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

                  @@ -478,13 +485,19 @@ 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 -if (require("dplyr")) { - example_isolates %>% - filter(is_gram_positive()) -} # other -------------------------------------------------------------------- + +# gram stains and intrinsic resistance can also be used as a filter in dplyr verbs +if (require("dplyr")) { + example_isolates %>% + filter(mo_is_gram_positive()) + + example_isolates %>% + filter(mo_is_intrinsic_resistant(ab = "vanco")) +} + + # 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 b28e6fdc..6563ec90 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9019 + 1.4.0.9020
                  diff --git a/man/antibiotic_class_selectors.Rd b/man/antibiotic_class_selectors.Rd index 8a68cef5..86fe3b06 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(is_gram_positive()) \%>\% + filter(mo_is_gram_positive()) \%>\% select(mo, macrolides()) \%>\% bug_drug_combinations() \%>\% format() diff --git a/man/as.mo.Rd b/man/as.mo.Rd index 5682e6ca..d5f36b38 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -212,8 +212,9 @@ as.mo("S. pyogenes") # will remain species: B_STRPT_PYGN as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRPA # All mo_* functions use as.mo() internally too (see ?mo_property): -mo_genus("E. coli") # returns "Escherichia" -mo_gramstain("E. coli") # returns "Gram negative" +mo_genus("E. coli") # returns "Escherichia" +mo_gramstain("E. coli") # returns "Gram negative" +mo_is_intrinsic_resistant("E. coli", "vanco") # returns TRUE } } \seealso{ diff --git a/man/mo_property.Rd b/man/mo_property.Rd index c3b99514..82d91535 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -16,8 +16,9 @@ \alias{mo_domain} \alias{mo_type} \alias{mo_gramstain} -\alias{is_gram_negative} -\alias{is_gram_positive} +\alias{mo_is_gram_negative} +\alias{mo_is_gram_positive} +\alias{mo_is_intrinsic_resistant} \alias{mo_snomed} \alias{mo_ref} \alias{mo_authors} @@ -57,9 +58,11 @@ mo_type(x, language = get_locale(), ...) mo_gramstain(x, language = get_locale(), ...) -is_gram_negative(x, language = get_locale(), ...) +mo_is_gram_negative(x, language = get_locale(), ...) -is_gram_positive(x, language = get_locale(), ...) +mo_is_gram_positive(x, language = get_locale(), ...) + +mo_is_intrinsic_resistant(x, ab, language = get_locale(), ...) mo_snomed(x, language = get_locale(), ...) @@ -88,6 +91,8 @@ mo_property(x, property = "fullname", language = get_locale(), ...) \item{...}{other parameters passed on to \code{\link[=as.mo]{as.mo()}}, such as 'allow_uncertain' and 'ignore_pattern'} +\item{ab}{any (vector of) text that can be coerced to a valid antibiotic code with \code{\link[=as.ab]{as.ab()}}} + \item{open}{browse the URL using \code{\link[utils:browseURL]{utils::browseURL()}}} \item{property}{one of the column names of the \link{microorganisms} data set or \code{"shortname"}} @@ -116,7 +121,9 @@ 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} (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. +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[=mo_is_gram_negative]{mo_is_gram_negative()}} and \code{\link[=mo_is_gram_positive]{mo_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. + +Intrinsic resistance - \code{\link[=mo_is_intrinsic_resistant]{mo_is_intrinsic_resistant()}} - will be determined based on the \link{intrinsic_resistant} data set, which is based on \href{https://www.eucast.org/expert_rules_and_intrinsic_resistance/}{'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.2} from 2020. The \code{\link[=mo_is_intrinsic_resistant]{mo_is_intrinsic_resistant()}} can be vectorised over parameters \code{x} (input for microorganisms) and over \code{ab} (input for antibiotics). All output will be \link{translate}d where possible. @@ -258,13 +265,19 @@ mo_fullname("S. pyogenes", Lancefield = TRUE, language = "nl") # "Streptococcus groep A" -# gram stains can be used as a filter -if (require("dplyr")) { - example_isolates \%>\% - filter(is_gram_positive()) -} # other -------------------------------------------------------------------- + +# gram stains and intrinsic resistance can also be used as a filter in dplyr verbs +if (require("dplyr")) { + example_isolates \%>\% + filter(mo_is_gram_positive()) + + example_isolates \%>\% + filter(mo_is_intrinsic_resistant(ab = "vanco")) +} + + # 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 af25b6e9..aa1e3f06 100644 --- a/tests/testthat/test-mo_property.R +++ b/tests/testthat/test-mo_property.R @@ -113,14 +113,20 @@ test_that("mo_property works", { expect_equal(nrow(subset(x, f1 != f2)), 0) # is gram pos/neg (also return FALSE for all non-bacteria) - expect_equal(is_gram_negative(c("Escherichia coli", "Staphylococcus aureus", "Candida albicans")), + expect_equal(mo_is_gram_negative(c("Escherichia coli", "Staphylococcus aureus", "Candida albicans")), c(TRUE, FALSE, FALSE)) - expect_equal(is_gram_positive(c("Escherichia coli", "Staphylococcus aureus", "Candida albicans")), + expect_equal(mo_is_gram_positive(c("Escherichia coli", "Staphylococcus aureus", "Candida albicans")), c(FALSE, TRUE, FALSE)) + # is intrinsic resistant + expect_equal(mo_is_intrinsic_resistant(c("Escherichia coli", "Staphylococcus aureus", "Candida albicans"), + "vanco"), + c(TRUE, FALSE, FALSE)) library(dplyr) - expect_equal(example_isolates %>% filter(is_gram_negative()) %>% nrow(), + expect_equal(example_isolates %>% filter(mo_is_gram_negative()) %>% nrow(), 730) - expect_equal(example_isolates %>% filter(is_gram_positive()) %>% nrow(), + expect_equal(example_isolates %>% filter(mo_is_gram_positive()) %>% nrow(), 1238) + expect_equal(example_isolates %>% filter(mo_is_intrinsic_resistant(ab = "Vancomycin")) %>% nrow(), + 710) })