diff --git a/DESCRIPTION b/DESCRIPTION index f00fe5e6..b375bd7f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR Version: 0.5.0.9021 -Date: 2019-03-05 +Date: 2019-03-06 Title: Antimicrobial Resistance Analysis Authors@R: c( person( diff --git a/NEWS.md b/NEWS.md index 282d57a1..140911f4 100755 --- a/NEWS.md +++ b/NEWS.md @@ -19,12 +19,34 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git This data is updated annually - check the included version with the new function `catalogue_of_life_version()`. * Due to this change, some `mo` codes changed (e.g. *Streptococcus* changed from `B_STRPTC` to `B_STRPT`). A translation table is used internally to support older microorganism IDs, so users will not notice this difference. -* New function `mo_rank()` for the taxonomic rank (genus, species, infraspecies, etc.) -* New function `mo_url()` to get the URL to the Catalogue of Life + * New function `mo_rank()` for the taxonomic rank (genus, species, infraspecies, etc.) + * New function `mo_url()` to get the direct URL of a species from the Catalogue of Life * Support for data from [WHONET](https://whonet.org/) and [EARS-Net](https://ecdc.europa.eu/en/about-us/partnerships-and-networks/disease-and-laboratory-networks/ears-net) (European Antimicrobial Resistance Surveillance Network): * Exported files from WHONET can be read and used in this package. For functions like `first_isolate()` and `eucast_rules()`, all parameters will be filled in automatically. * This package now knows all antibiotic abbrevations by EARS-Net (which are also being used by WHONET) - the `antibiotics` data set now contains a column `ears_net`. * The function `as.mo()` now knows all WHONET species abbreviations too, because more than 1,600 microbial abbreviations were added to the `microorganisms.codes` data set. +* New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class: + ```r + filter_aminoglycosides() + filter_carbapenems() + filter_cephalosporins() + filter_1st_cephalosporins() + filter_2nd_cephalosporins() + filter_3rd_cephalosporins() + filter_4th_cephalosporins() + filter_fluoroquinolones() + filter_glycopeptides() + filter_macrolides() + filter_tetracyclines() + ``` + The `antibiotics` data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the `antibiotics` data set. + For example: + ```r + septic_patients %>% filter_glycopeptides(result = "R") + # Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R + septic_patients %>% filter_glycopeptides(result = "R", scope = "all") + # Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R + ``` * All `ab_*` functions are deprecated and replaced by `atc_*` functions: ```r ab_property -> atc_property() diff --git a/R/filter_ab_class.R b/R/filter_ab_class.R index fed9838a..9884ae42 100644 --- a/R/filter_ab_class.R +++ b/R/filter_ab_class.R @@ -27,8 +27,9 @@ #' @param result an antibiotic result: S, I or R (or a combination of more of them) #' @param scope the scope to check which variables to check, can be \code{"any"} (default) or \code{"all"} #' @param ... parameters passed on to \code{\link[dplyr]{filter_at}} -#' @details The \code{\code{antibiotics}} data set will be searched for \code{ab_class} in the columns \code{atc_group1} and \code{atc_group2} (case-insensitive). Next, \code{tbl} will be checked for column names with a value in any abbreviations, codes or official names found in the \code{antibiotics} data set. +#' @details The \code{\link{antibiotics}} data set will be searched for \code{ab_class} in the columns \code{atc_group1} and \code{atc_group2} (case-insensitive). Next, \code{tbl} will be checked for column names with a value in any abbreviations, codes or official names found in the \code{antibiotics} data set. #' @rdname filter_ab_class +#' @keywords filter fillter_class #' @importFrom dplyr filter_at %>% select vars any_vars all_vars #' @importFrom crayon bold blue #' @export @@ -89,7 +90,7 @@ filter_ab_class <- function(tbl, scope_fn <- all_vars } message(blue(paste0("Filtering on ", atc_groups, ": ", scope, " of ", - paste(bold(vars_df), collapse = scope_txt), operator, toString(result)))) + paste(bold(paste0("`", vars_df, "`")), collapse = scope_txt), operator, toString(result)))) tbl %>% filter_at(.vars = vars(vars_df), .vars_predicate = scope_fn(. %in% result), diff --git a/docs/news/index.html b/docs/news/index.html index 635a33e1..256228bf 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -259,10 +259,10 @@

The responsible author(s) and year of scientific publication

This data is updated annually - check the included version with the new function catalogue_of_life_version().
  • Due to this change, some mo codes changed (e.g. Streptococcus changed from B_STRPTC to B_STRPT). A translation table is used internally to support older microorganism IDs, so users will not notice this difference.
  • +
  • New function mo_rank() for the taxonomic rank (genus, species, infraspecies, etc.)
  • +
  • New function mo_url() to get the direct URL of a species from the Catalogue of Life
  • -
  • New function mo_rank() for the taxonomic rank (genus, species, infraspecies, etc.)
  • -
  • New function mo_url() to get the URL to the Catalogue of Life
  • Support for data from WHONET and EARS-Net (European Antimicrobial Resistance Surveillance Network):
  • +

    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()
    +filter_1st_cephalosporins()
    +filter_2nd_cephalosporins()
    +filter_3rd_cephalosporins()
    +filter_4th_cephalosporins()
    +filter_fluoroquinolones()
    +filter_glycopeptides()
    +filter_macrolides()
    +filter_tetracyclines()
    +

    The antibiotics data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the antibiotics data set. For example:

    +
    septic_patients %>% filter_glycopeptides(result = "R")
    +# Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R
    +septic_patients %>% filter_glycopeptides(result = "R", scope = "all")
    +# Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R
    +
  • +
  • All ab_* functions are deprecated and replaced by atc_* functions:

    -
    ab_property -> atc_property()
    -ab_name -> atc_name()
    -ab_official -> atc_official()
    -ab_trivial_nl -> atc_trivial_nl()
    -ab_certe -> atc_certe()
    -ab_umcg -> atc_umcg()
    -ab_tradenames -> atc_tradenames()
    +
    ab_property -> atc_property()
    +ab_name -> atc_name()
    +ab_official -> atc_official()
    +ab_trivial_nl -> atc_trivial_nl()
    +ab_certe -> atc_certe()
    +ab_umcg -> atc_umcg()
    +ab_tradenames -> atc_tradenames()
    These functions use as.atc() internally. The old atc_property has been renamed atc_online_property(). This is done for two reasons: firstly, not all ATC codes are of antibiotics (ab) but can also be of antivirals or antifungals. Secondly, the input must have class atc or must be coerable to this class. Properties of these classes should start with the same class name, analogous to as.mo() and e.g. mo_genus.
  • New functions set_mo_source() and get_mo_source() to use your own predefined MO codes as input for as.mo() and consequently all mo_* functions
  • Support for the upcoming dplyr version 0.8.0
  • @@ -290,20 +309,20 @@ These functions use as.atc()
  • 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)
    +
    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, ...)
    +
    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) %>%
    -  select(-only_firsts)
    +
    septic_patients %>%
    +  mutate(only_firsts = first_isolate(septic_patients, ...)) %>%
    +  filter(only_firsts == TRUE) %>%
    +  select(-only_firsts)
  • New function availability() to check the number of available (non-empty) results in a data.frame
  • @@ -332,10 +351,10 @@ These functions use as.atc() -
    mo_genus("qwerty", language = "es")
    -# Warning: 
    -# one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it.
    -#> [1] "(género desconocido)"
    +
    mo_genus("qwerty", language = "es")
    +# Warning: 
    +# one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it.
    +#> [1] "(género desconocido)"