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 functioncatalogue_of_life_version()
.
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.mo_rank()
for the taxonomic rank (genus, species, infraspecies, etc.)mo_url()
to get the direct URL of a species from the Catalogue of Lifemo_rank()
for the taxonomic rank (genus, species, infraspecies, etc.)mo_url()
to get the URL to the Catalogue of Lifefirst_isolate()
and eucast_rules()
, all parameters will be filled in automatically.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:
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()
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
.set_mo_source()
and get_mo_source()
to use your own predefined MO codes as input for as.mo()
and consequently all mo_*
functionsdplyr
version 0.8.0as.atc()
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()
:
Functions filter_first_isolate()
and filter_first_weighted_isolate()
to shorten and fasten filtering on data sets with antimicrobial results, e.g.:
is equal to:
- +availability()
to check the number of available (non-empty) results in a data.frame
as.atc()
UNKNOWN
. Properties of these will be translated on foreign systems in all language 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.
-#> [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)"
as.atc()
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 %>%
- mutate(genus = mo_genus(mo)) %>%
- freq(genus)
-# NEW WAY
-septic_patients %>%
- freq(mo_genus(mo))
-
-# Even supports grouping variables:
-septic_patients %>%
- group_by(gender) %>%
- freq(mo_genus(mo))
# Determine genus of microorganisms (mo) in `septic_patients` data set:
+# OLD WAY
+septic_patients %>%
+ mutate(genus = mo_genus(mo)) %>%
+ freq(genus)
+# NEW WAY
+septic_patients %>%
+ freq(mo_genus(mo))
+
+# Even supports grouping variables:
+septic_patients %>%
+ group_by(gender) %>%
+ freq(mo_genus(mo))
header
functionheader
is now set to TRUE
at default, even for markdownas.atc()
as.mo
will return NAFunction as.mo
(and all mo_*
wrappers) now supports genus abbreviations with “species” attached
combine_IR
(TRUE/FALSE) to functions portion_df
and count_df
, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)portion_*(..., as_percent = TRUE)
when minimal number of isolates would not be metas.atc()
Support for grouping variables, test with:
- +Support for (un)selecting columns:
- +hms::is.hms
as.atc()
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
-# [1] "Gramnegativ"
-mo_gramstain("E. coli", language = "es") # Spanish
-# [1] "Gram negativo"
-mo_fullname("S. group A", language = "pt") # Portuguese
-# [1] "Streptococcus grupo A"
mo_gramstain("E. coli")
+# [1] "Gram negative"
+mo_gramstain("E. coli", language = "de") # German
+# [1] "Gramnegativ"
+mo_gramstain("E. coli", language = "es") # Spanish
+# [1] "Gram negativo"
+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"
mo_gramstain("Esc blattae")
+# Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)
+# [1] "Gram negative"
count_R
, count_IR
, count_I
, count_SI
and count_S
to selectively count resistant or susceptible isolates
as.atc()
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 Artificial Intelligence (AI):
as.mo("E. coli")
-# [1] B_ESCHR_COL
-as.mo("MRSA")
-# [1] B_STPHY_AUR
-as.mo("S group A")
-# [1] B_STRPTC_GRA
as.mo("E. coli")
+# [1] B_ESCHR_COL
+as.mo("MRSA")
+# [1] B_STPHY_AUR
+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:
- +reference_df
for as.mo
, so users can supply their own microbial IDs, name or codes as a reference tablebactid
to mo
, like:
@@ -632,12 +651,12 @@ These functions use as.atc()
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.:
first_isolate
, rows will be ignored when there’s no species availableratio
is now deprecated and will be removed in a future release, as it is not really the scope of this packageas.atc()
Support for quasiquotation in the functions series count_*
and portions_*
, and n_rsi
. This allows to check for more than 2 vectors or columns.
ggplot_rsi
and geom_rsi
so they can cope with count_df
. The new fun
parameter has value portion_df
at default, but can be set to count_df
.ggplot_rsi
when the ggplot2
package was not loadedas.atc()
Support for types (classes) list and matrix for freq
For lists, subsetting is possible:
- +The
data set will be searched for antibiotics
ab_class
in the columns atc_group1
and atc_group2
(case-insensitive). Next, tbl
will be checked for column names with a value in any abbreviations, codes or official names found in the antibiotics
data set.
The antibiotics
data set will be searched for ab_class
in the columns atc_group1
and atc_group2
(case-insensitive). Next, tbl
will be checked for column names with a value in any abbreviations, codes or official names found in the antibiotics
data set.