diff --git a/DESCRIPTION b/DESCRIPTION index 3c30d0df..c7bc1f63 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.2.0 -Date: 2020-05-28 +Version: 1.2.0.9000 +Date: 2020-06-02 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index ebf649cc..b941d20f 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ -# AMR 1.2.0 +# AMR 1.2.0.9000 +## Last updated: 02-Jun-2020 +### Changed +* Fixed a bug where `eucast_rules()` would not work on a tibble when the `tibble` or `dplyr` package was loaded +* Fixed a bug where `as.ab()` would return an error on invalid input values + +# AMR 1.2.0 ### Breaking * Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users. diff --git a/R/ab.R b/R/ab.R index 6c7ca3eb..baf11e39 100755 --- a/R/ab.R +++ b/R/ab.R @@ -103,21 +103,20 @@ as.ab <- function(x, ...) { x <- unique(x_bak_clean) x_new <- rep(NA_character_, length(x)) x_unknown <- character(0) - + for (i in seq_len(length(x))) { if (is.na(x[i]) | is.null(x[i])) { next } - if (identical(x[i], "")) { + if (identical(x[i], "") | + # no short names: + nchar(x[i]) <= 2 | + # prevent "bacteria" from coercing to TMP, since Bacterial is a brand name of it: + identical(tolower(x[i]), "bacteria")) { x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1]) next } - # prevent "bacteria" from coercing to TMP, since Bacterial is a brand name of it - if (identical(tolower(x[i]), "bacteria")) { - x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1]) - next - } - + # exact AB code found <- antibiotics[which(antibiotics$ab == toupper(x[i])), ]$ab if (length(found) > 0) { @@ -217,7 +216,7 @@ as.ab <- function(x, ...) { x_spelling <- gsub("(.)\\1+", "\\1+", x_spelling) # replace spaces and slashes with a possibility on both x_spelling <- gsub("[ /]", "( .*|.*/)", x_spelling) - + # try if name starts with it found <- antibiotics[which(antibiotics$name %like% paste0("^", x_spelling)), ]$ab if (length(found) > 0) { @@ -303,7 +302,7 @@ as.ab <- function(x, ...) { next } } - + # not found x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1]) } diff --git a/R/eucast_rules.R b/R/eucast_rules.R index 97f63ed5..efc39c49 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -518,6 +518,8 @@ eucast_rules <- function(x, # save original table x_original <- x + x_original_attr <- attributes(x) + x_original <- as.data.frame(x_original, stringsAsFactors = FALSE) # no tibbles, data.tables, etc. # join to microorganisms data set x <- as.data.frame(x, stringsAsFactors = FALSE) @@ -922,6 +924,8 @@ eucast_rules <- function(x, rownames(verbose_info) <- NULL verbose_info } else { + # reset original attributes + attributes(x_original) <- x_original_attr x_original } } diff --git a/R/filter_ab_class.R b/R/filter_ab_class.R index 3c524867..aa7a454c 100644 --- a/R/filter_ab_class.R +++ b/R/filter_ab_class.R @@ -70,6 +70,14 @@ filter_ab_class <- function(x, check_dataset_integrity() + if (!is.data.frame(x)) { + stop("`x` must be a data frame.", call. = FALSE) + } + + # save to return later + x_class <- class(x) + x <- as.data.frame(x, stringsAsFactors = FALSE) + scope <- scope[1L] if (is.null(result)) { result <- c("S", "I", "R") @@ -116,13 +124,16 @@ filter_ab_class <- function(x, } message(font_blue(paste0("Filtering on ", ab_group, ": ", scope, paste0(font_bold(paste0("`", vars_df, "`"), collapse = NULL), collapse = scope_txt), operator, toString(result)))) - x[as.logical(by(x, seq_len(nrow(x)), function(row) scope_fn(unlist(row[, vars_df]) %in% result, na.rm = TRUE))), , drop = FALSE] + filtered <<- as.logical(by(x, seq_len(nrow(x)), + function(row) scope_fn(unlist(row[, vars_df]) %in% result, na.rm = TRUE))) + x <- x[which(filtered), , drop = FALSE] } else { message(font_blue(paste0("NOTE: no antimicrobial agents of class ", ab_group, " (such as ", find_ab_names(ab_group), ") found, data left unchanged."))) - x } + class(x) <- x_class + x } #' @rdname filter_ab_class diff --git a/docs/404.html b/docs/404.html index 528cd0c4..a142f5ad 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 351386e6..e5df0e43 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html index a46a3176..76f9b45b 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 5e489fbd..b878a3e7 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ diff --git a/docs/index.html b/docs/index.html index 7758a052..31c5afe2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ @@ -186,9 +186,9 @@METHODS PAPER PREPRINTED
@@ -278,9 +278,9 @@ A methods paper about this package has been preprinted at bioRxiv (DOI: 10.1101/NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package. See https://www.whocc.no/copyright_disclaimer/.
Read more about the data from WHOCC in our manual.
We support WHONET and EARS-Net data. Exported files from WHONET can be imported into R and can be analysed easily using this package. For education purposes, we created an example data set WHONET
with the exact same structure as a WHONET export file. Furthermore, this package also contains a data set antibiotics with all EARS-Net antibiotic abbreviations, and knows almost all WHONET abbreviations for microorganisms. When using WHONET data as input for analysis, all input parameters will be set automatically.
Read our tutorial about how to work with WHONET data here.
NEWS.md
eucast_rules()
would not work on a tibble when the tibble
or dplyr
package was loadedas.ab()
would return an error on invalid input valuesRemoved code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users.
Making this package independent of especially the tidyverse (e.g. packages dplyr
and tidyr
) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Good for users, but hard for package maintainers. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.
Negative effects of this change are:
freq()
that was borrowed from the cleaner
package was removed. Use cleaner::freq()
, or run library("cleaner")
before you use freq()
.mo
or rsi
in a tibble will no longer be in colour and printing rsi
in a tibble will show the class <ord>
, not <rsi>
anymore. This is purely a visual effect.ab_url()
to return the direct URL of an antimicrobial agent from the official WHO websiteas.ab()
, so that e.g. as.ab("ampi sul")
and ab_name("ampi sul")
workas.ab()
, so that e.g. as.ab("ampi sul")
and ab_name("ampi sul")
workab_atc()
and ab_group()
now return NA
if no antimicrobial agent could be foundggplot_pca()
functionFixed 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 %>% @@ -352,15 +370,15 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ yourdata %>% mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = .$mybacteria)
uti
(as abbreviation of urinary tract infections) as parameter to as.rsi()
, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIsAdded antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole
Added uti
(as abbreviation of urinary tract infections) as parameter to as.rsi()
, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs
Info printing in functions eucast_rules()
, first_isolate()
, mdro()
and resistance_predict()
will now at default only print when R is in an interactive mode (i.e. not in RMarkdown)
This software is now out of beta and considered stable. Nonetheless, this package will be developed continually.
antibiotics
data set (thanks to Peter Dutey):
RIF
) to rifampicin/isoniazid (RFI
). Please note that the combination rifampicin/isoniazid has no DDDs defined, so e.g. ab_ddd("Rimactazid")
will now return NA
.RIF
) to rifampicin/isoniazid (RFI
). Please note that the combination rifampicin/isoniazid has no DDDs defined, so e.g. ab_ddd("Rimactazid")
will now return NA
.SMX
) to trimethoprim/sulfamethoxazole (SXT
)Support for a new MDRO guideline: Magiorakos AP, Srinivasan A et al. “Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance.” Clinical Microbiology and Infection (2012).
mdro()
functionmdro(...., verbose = TRUE)
) returns an informative data set where the reason for MDRO determination is given for every isolate, and an list of the resistant antimicrobial agentsas.mo()
:
Now allows “ou” where “au” should have been used and vice versa
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:
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)
"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 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:
@@ -557,8 +577,9 @@ For WHONET users, this means that all records/isolates with organism code
x[1] <- "testvalue"
#> Warning message:
#> invalid microorganism code, NA generated
"testvalue"
could never be understood by e.g. mo_name()
, although the class would suggest a valid microbial code.freq()
has moved to a new package, clean
(CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq()
function still works, since it is re-exported from the clean
package (which will be installed automatically upon updating this AMR
package).This is important, because a value like "testvalue"
could never be understood by e.g. mo_name()
, although the class would suggest a valid microbial code.
Function freq()
has moved to a new package, clean
(CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq()
function still works, since it is re-exported from the clean
package (which will be installed automatically upon updating this AMR
package).
Renamed data set septic_patients
to example_isolates
"testvalue"
could never be
# R <NA> - - - -
# <NA> <NA> - - - -
# --------------------------------------------------------------------also_single_tested
will throw an informative error that it has been replaced by only_all_tested
.
+Since this is a major change, usage of the old also_single_tested
will throw an informative error that it has been replaced by only_all_tested
.
tibble
printing support for classes rsi
, mic
, disk
, ab
mo
. When using tibble
s 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)
@@ -620,9 +642,9 @@ Since this is a major change, usage of the old also_single_tested
w
as.mo()
(of which some led to additions to the microorganisms
data set). Many thanks to all contributors that helped improving the algorithms.
also_single_tested
w
eucast_rules(..., verbose = TRUE)
) returns more informative and readable outputeucast_rules(..., verbose = TRUE)
) returns more informative and readable outputalso_single_tested
w
also_single_tested
w
mo_gramstain("EHEC")
# "Gram-negative"mo_info()
as an analogy to ab_info()
. The mo_info()
prints a list with the full taxonomy, authors, and the URL to the online database of a microorganismFunction mo_info()
as an analogy to ab_info()
. The mo_info()
prints a list with the full taxonomy, authors, and the URL to the online database of a microorganism
Function mo_synonyms()
to get all previously accepted taxonomic names of a microorganism
count_df()
and portion_df()
are now lowercasealso_single_tested
w
also_single_tested
w
mdr_tb()
) and added a new vignette about MDR. Read this tutorial here on our website.first_isolate()
where missing species would lead to incorrect FALSEs. This bug was not present in AMR v0.5.0, but was in v0.6.0 and v0.6.1.eucast_rules()
where antibiotics from WHONET software would not be recognisedantibiotics
data set:
+Fixed a critical bug in first_isolate()
where missing species would lead to incorrect FALSEs. This bug was not present in AMR v0.5.0, but was in v0.6.0 and v0.6.1.
Fixed a bug in eucast_rules()
where antibiotics from WHONET software would not be recognised
Completely reworked the antibiotics
data set:
All entries now have 3 different identifiers:
ab
contains a human readable EARS-Net code, used by ECDC and WHO/WHONET - this is the primary identifier used in this packageatc
contains the ATC code, used by WHO/WHOCCcid
contains the CID code (Compound ID), used by PubChemAMX
for amoxicillinatc_certe
, ab_umcg
and atc_trivial_nl
have been removedatc_*
functions are superceded by ab_*
functionsBased on the Compound ID, almost 5,000 official brand names have been added from many different countries
All references to antibiotics in our package now use EARS-Net codes, like AMX
for amoxicillin
Functions atc_certe
, ab_umcg
and atc_trivial_nl
have been removed
All atc_*
functions are superceded by ab_*
functions
All output will be translated by using an included translation file which can be viewed here.
-Please create an issue in one of our repositories if you want additions in this file.Please create an issue in one of our repositories if you want additions in this file.
+ggplot_rsi()
:
+Improvements to plotting AMR results with ggplot_rsi()
:
colours
to set the bar colourstitle
, subtitle
, caption
, x.title
and y.title
to set titles and axis descriptionsguess_ab_col()
-microorganisms.old
data set, which leads to better results finding when using the as.mo()
functionportion_df()
and count_df()
this means that their new parameter combine_SI
is TRUE at default. Our plotting function ggplot_rsi()
also reflects this change since it uses count_df()
internally.age()
function gained a new parameter exact
to determine ages with decimalsguess_mo()
, guess_atc()
, EUCAST_rules()
, interpretive_reading()
, rsi()
-freq()
):
+Improved intelligence of looking up antibiotic columns in a data set using guess_ab_col()
Added ~5,000 more old taxonomic names to the microorganisms.old
data set, which leads to better results finding when using the as.mo()
function
This package now honours the new EUCAST insight (2019) that S and I are but classified as susceptible, where I is defined as ‘increased exposure’ and not ‘intermediate’ anymore. For functions like portion_df()
and count_df()
this means that their new parameter combine_SI
is TRUE at default. Our plotting function ggplot_rsi()
also reflects this change since it uses count_df()
internally.
The age()
function gained a new parameter exact
to determine ages with decimals
Removed deprecated functions guess_mo()
, guess_atc()
, EUCAST_rules()
, interpretive_reading()
, rsi()
Frequency tables (freq()
):
speed improvement for microbial IDs
fixed factor level names for R Markdown
when all values are unique it now shows a message instead of a warning
support for boxplots:
septic_patients %>% @@ -835,20 +860,17 @@ Please can be viewed here. -Please create an issue in one of our repositories if you want changes in this file. -
Please create an issue in one of our repositories if you want changes in this file.
age_groups()
, to let groups of fives and tens end with 100+ instead of 120+freq()
for when all values are NA
-first_isolate()
for when dates are missingguess_ab_col()
-as.mo()
now gently interprets any number of whitespace characters (like tabs) as one spaceas.mo()
now returns UNKNOWN
for "con"
(WHONET ID of ‘contamination’) and returns NA
for "xxx"
(WHONET ID of ‘no growth’)as.mo()
-microorganisms.codes
and cleaned it upAdded ceftazidim intrinsic resistance to Streptococci
Changed default settings for age_groups()
, to let groups of fives and tens end with 100+ instead of 120+
Fix for freq()
for when all values are NA
Fix for first_isolate()
for when dates are missing
Improved speed of guess_ab_col()
Function as.mo()
now gently interprets any number of whitespace characters (like tabs) as one space
Function as.mo()
now returns UNKNOWN
for "con"
(WHONET ID of ‘contamination’) and returns NA
for "xxx"
(WHONET ID of ‘no growth’)
Small algorithm fix for as.mo()
Removed viruses from data set microorganisms.codes
and cleaned it up
Fix for mo_shortname()
where species would not be determined correctly
eucast_rules()
with verbose = TRUE
New website!
We’ve got a new website: https://msberends.gitlab.io/AMR (built with the great pkgdown
)
BREAKING: removed deprecated functions, parameters and references to ‘bactid’. Use as.mo()
to identify an MO code.
as.mo()
to identify an MO code.microorganisms
data set now contains:
+Catalogue of Life as a new taxonomic source for data about microorganisms, which also contains all ITIS data we used previously. The microorganisms
data set now contains:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria and Protozoa
All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales (covering at least like all species of Aspergillus, Candida, Pneumocystis, Saccharomyces and Trichophyton)
All ~2,000 (sub)species from ~100 other relevant genera, from the kingdoms of Animalia and Plantae (like Strongyloides and Taenia)
All ~15,000 previously accepted names of included (sub)species that have been taxonomically renamed
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 LifeThis 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
Support for data from WHONET and EARS-Net (European Antimicrobial Resistance Surveillance Network):
first_isolate()
and eucast_rules()
, all parameters will be filled in automatically.antibiotics
data set now contains a column ears_net
.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.0guess_ab_col()
to find an antibiotic column in a tablemo_failures()
to review values that could not be coerced to a valid MO code, using as.mo()
. This latter function will now only show a maximum of 10 uncoerced values and will refer to mo_failures()
.mo_uncertainties()
to review values that could be coerced to a valid MO code using as.mo()
, but with uncertainty.mo_renamed()
to get a list of all returned values from as.mo()
that have had taxonomic renamingage()
to calculate the (patients) age in yearsage_groups()
to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic antimicrobial resistance analysis per age group.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
New function guess_ab_col()
to find an antibiotic column in a table
New function mo_failures()
to review values that could not be coerced to a valid MO code, using as.mo()
. This latter function will now only show a maximum of 10 uncoerced values and will refer to mo_failures()
.
New function mo_uncertainties()
to review values that could be coerced to a valid MO code using as.mo()
, but with uncertainty.
New function mo_renamed()
to get a list of all returned values from as.mo()
that have had taxonomic renaming
New function age()
to calculate the (patients) age in years
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") @@ -966,14 +991,13 @@ These functions useas.atc()
internally. The oldatc_property filter(only_firsts == TRUE) %>% select(-only_firsts)
availability()
to check the number of available (non-empty) results in a data.frame
-New function availability()
to check the number of available (non-empty) results in a data.frame
New vignettes about how to conduct AMR analysis, predict antimicrobial resistance, use the G-test and more. These are also available (and even easier readable) on our website: https://msberends.gitlab.io/AMR.
as.mo(..., allow_uncertain = 3)
could lead to very unreliable results.
-Using as.mo(..., allow_uncertain = 3)
could lead to very unreliable results.
~/.Rhistory_mo
. Use the new function clean_mo_history()
to delete this file, which resets the algorithms.Implemented the latest publication of Becker et al. (2019), for categorising coagulase-negative Staphylococci
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")
@@ -1021,17 +1045,16 @@ Using as.mo(..., allow_uncertain = 3)# one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it.
#> [1] "(género desconocido)"
Fix for vector containing only empty values
Finds better results when input is in other languages
Better handling for subspecies
Better handling for Salmonellae, especially the ‘city like’ serovars like Salmonella London
Understanding of highly virulent E. coli strains like EIEC, EPEC and STEC
There will be looked for uncertain results at default - these results will be returned with an informative warning
Manual (help page) now contains more info about the algorithms
Progress bar will be shown when it takes more than 3 seconds to get results
Support for formatted console text
Console will return the percentage of uncoercable input
first_isolate()
:
@@ -1079,17 +1102,15 @@ Using as.mo(..., allow_uncertain = 3)group_by(gender) %>%
freq(mo_genus(mo))
header
functionheader
is now set to TRUE
at default, even for markdownmo
to show unique count of families, genera and speciesdecimal.mark
setting, which just like format
defaults to getOption("OutDec")
-big.mark
parameter will at default be ","
when decimal.mark = "."
and "."
otherwiseNA
-droplevels
to exclude empty factor levels when input is a factorselect()
on frequency tablesHeader info is now available as a list, with the header
function
The parameter header
is now set to TRUE
at default, even for markdown
Added header info for class mo
to show unique count of families, genera and species
Now honours the decimal.mark
setting, which just like format
defaults to getOption("OutDec")
The new big.mark
parameter will at default be ","
when decimal.mark = "."
and "."
otherwise
Fix for header text where all observations are NA
New parameter droplevels
to exclude empty factor levels when input is a factor
Factor levels will be in header when present in input data (maximum of 5)
Fix for using select()
on frequency tables
scale_y_percent()
now contains the limits
parameteras.mo(..., allow_uncertain = 3)
as.mo(..., allow_uncertain = 3)Functions mo_authors
and mo_year
to get specific values about the scientific reference of a taxonomic entry
MDRO
, BRMO
, MRGN
and EUCAST_exceptional_phenotypes
were renamed to mdro
, brmo
, mrgn
and eucast_exceptional_phenotypes
-Functions MDRO
, BRMO
, MRGN
and EUCAST_exceptional_phenotypes
were renamed to mdro
, brmo
, mrgn
and eucast_exceptional_phenotypes
EUCAST_rules
was renamed to eucast_rules
, the old function still exists as a deprecated function
EUCAST_rules
was renamed to eucast_rules
, the old function still exists as a deprecated functioneucast_rules
function:
+Big changes to the eucast_rules
function:
rules
to specify which rules should be applied (expert rules, breakpoints, others or all)as.mo(..., allow_uncertain = 3)Small fixes to EUCAST clinical breakpoint rules
kingdom
to the microorganisms data set, and function mo_kingdom
to look up valuesas.mo
(and subsequently all mo_*
functions), as empty values wil be ignored a priori
-as.mo
will return NAAdded column kingdom
to the microorganisms data set, and function mo_kingdom
to look up values
Tremendous speed improvement for as.mo
(and subsequently all mo_*
functions), as empty values wil be ignored a priori
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
@@ -1157,14 +1176,13 @@ Using as.mo(..., allow_uncertain = 3)as.mo("S. spp") # B_STPHY
mo_fullname("S. species") # "Staphylococcus species"
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 metalso_single_tested
for portion_*
and count_*
functions to also include cases where not all antibiotics were tested but at least one of the tested antibiotics includes the target antimicribial interpretation, see ?portion
-portion_*
functions now throws a warning when total available isolate is below parameter minimum
-as.mo
, as.rsi
, as.mic
, as.atc
and freq
will not set package name as attribute anymorefreq()
:
+Added parameter 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)
Fix for portion_*(..., as_percent = TRUE)
when minimal number of isolates would not be met
Added parameter also_single_tested
for portion_*
and count_*
functions to also include cases where not all antibiotics were tested but at least one of the tested antibiotics includes the target antimicribial interpretation, see ?portion
Using portion_*
functions now throws a warning when total available isolate is below parameter minimum
Functions as.mo
, as.rsi
, as.mic
, as.atc
and freq
will not set package name as attribute anymore
Frequency tables - freq()
:
Support for grouping variables, test with:
@@ -1178,29 +1196,25 @@ Usingas.mo(..., allow_uncertain = 3)freq(hospital_id) %>%
select(-count, -cum_count) # only get item, percent, cum_percent
hms::is.hms
-difftime
-na
, to choose which character to print for empty valuesheader
to turn the header info off (default when markdown = TRUE
)title
to manually setbthe title of the frequency tableCheck for hms::is.hms
Now prints in markdown at default in non-interactive sessions
No longer adds the factor level column and sorts factors on count again
Support for class difftime
New parameter na
, to choose which character to print for empty values
New parameter header
to turn the header info off (default when markdown = TRUE
)
New parameter title
to manually setbthe title of the frequency table
first_isolate
now tries to find columns to use as input when parameters are left blank
Improvements for MDRO algorithm (function mdro
)
Data set septic_patients
is now a data.frame
, not a tibble anymore
Removed diacritics from all authors (columns microorganisms$ref
and microorganisms.old$ref
) to comply with CRAN policy to only allow ASCII characters
Fix for mo_property
not working properly
Fix for eucast_rules
where some Streptococci would become ceftazidime R in EUCAST rule 4.5
Support for named vectors of class mo
, useful for top_freq()
ggplot_rsi
and scale_y_percent
have breaks
parameter
first_isolate
now tries to find columns to use as input when parameters are left blankmdro
)septic_patients
is now a data.frame
, not a tibble anymoremicroorganisms$ref
and microorganisms.old$ref
) to comply with CRAN policy to only allow ASCII charactersmo_property
not working properlyeucast_rules
where some Streptococci would become ceftazidime R in EUCAST rule 4.5mo
, useful for top_freq()
-ggplot_rsi
and scale_y_percent
have breaks
parameteras.mo
:
+AI improvements for as.mo
:
"CRS"
-> Stenotrophomonas maltophilia
@@ -1216,12 +1230,11 @@ Using as.mo(..., allow_uncertain = 3)
join
functionsis.rsi.eligible
, now 15-20 times fasterg.test
, when sum(x)
is below 1000 or any of the expected values is below 5, Fisher’s Exact Test will be suggestedab_name
will try to fall back on as.atc
when no results are foundFix for join
functions
Speed improvement for is.rsi.eligible
, now 15-20 times faster
In g.test
, when sum(x)
is below 1000 or any of the expected values is below 5, Fisher’s Exact Test will be suggested
ab_name
will try to fall back on as.atc
when no results are found
Removed the addin to view data sets
Percentages will now will rounded more logically (e.g. in freq
function)
as.mo(..., allow_uncertain = 3)
microorganisms
now contains all microbial taxonomic data from ITIS (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via https://itis.gov. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set microorganisms.old
contains all previously known taxonomic names from those kingdoms.mo_property
:
+The data set microorganisms
now contains all microbial taxonomic data from ITIS (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via https://itis.gov. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set microorganisms.old
contains all previously known taxonomic names from those kingdoms.
New functions based on the existing function mo_property
:
mo_phylum
, mo_class
, mo_order
, mo_family
, mo_genus
, mo_species
, mo_subspecies
as.mo(..., allow_uncertain = 3)# 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
+Functions count_R
, count_IR
, count_I
, count_SI
and count_S
to selectively count resistant or susceptible isolates
count_df
(which works like portion_df
) to get all counts of S, I and R of a data set with antibiotic columns, with support for grouped variablesis.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)
-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")
@@ -1291,8 +1305,9 @@ Using as.mo(..., allow_uncertain = 3)# min median max neval
# 0.01817717 0.01843957 0.03878077 100
reference_df
for as.mo
, so users can supply their own microbial IDs, name or codes as a reference tablebactid
to mo
, like:
+Added parameter reference_df
for as.mo
, so users can supply their own microbial IDs, name or codes as a reference table
Renamed all previous references to bactid
to mo
, like:
EUCAST_rules
, first_isolate
and key_antibiotics
as.mo(..., allow_uncertain = 3)All old syntaxes will still work with this version, but will throw warnings
labels_rsi_count
to print datalabels on a RSI ggplot2
modelFunction labels_rsi_count
to print datalabels on a RSI ggplot2
model
Functions as.atc
and is.atc
to transform/look up antibiotic ATC codes as defined by the WHO. The existing function guess_atc
is now an alias of as.atc
.
ab_property
and its aliases: ab_name
, ab_tradenames
, ab_certe
, ab_umcg
and ab_trivial_nl
-Function ab_property
and its aliases: ab_name
, ab_tradenames
, ab_certe
, ab_umcg
and ab_trivial_nl
Introduction to AMR as a vignette
Removed clipboard functions as it violated the CRAN policy
Renamed septic_patients$sex
to septic_patients$gender
antibiotics
data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)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")
@@ -1324,13 +1338,12 @@ Using as.mo(..., allow_uncertain = 3)ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
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.mic
for values ending in zeroes after a real numbermicroorganisms.umcg
data setprevalence
column to the microorganisms
data setminimum
and as_percent
to portion_df
-For first_isolate
, rows will be ignored when there’s no species available
Function ratio
is now deprecated and will be removed in a future release, as it is not really the scope of this package
Fix for as.mic
for values ending in zeroes after a real number
Small fix where B. fragilis would not be found in the microorganisms.umcg
data set
Added prevalence
column to the microorganisms
data set
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()
@@ -1341,16 +1354,14 @@ Using as.mo(..., allow_uncertain = 3)septic_patients %>% portion_S(amcl, gent)
septic_patients %>% portion_S(amcl, gent, pita)
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 loadedlabels_rsi_count
to ggplot_rsi
-geom_rsi
(and ggplot_rsi
) so you can set your own preferencesquote
to the freq
functiondiff
for frequency tablesfreq
) header of class character
-Edited 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
.
Fix for ggplot_rsi
when the ggplot2
package was not loaded
Added datalabels function labels_rsi_count
to ggplot_rsi
Added possibility to set any parameter to geom_rsi
(and ggplot_rsi
) so you can set your own preferences
Fix for joins, where predefined suffices would not be honoured
Added parameter quote
to the freq
function
Added generic function diff
for frequency tables
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))
@@ -1370,9 +1381,9 @@ Using as.mo(..., allow_uncertain = 3)
as.mo(..., allow_uncertain = 3)
resistance_predict
and added more examplesas.mo(..., allow_uncertain = 3)
as.mic("<= 0.002")
now worksas.mic("<= 0.002")
now worksrsi
and mic
do not add the attribute package.version
anymore"groups"
option for atc_property(..., property)
. It will return a vector of the ATC hierarchy as defined by the WHO. The new function atc_groups
is a convenient wrapper around this.atc_property
as it requires the host set by url
to be responsiveas.mo(..., allow_uncertain = 3)
as.mo(..., allow_uncertain = 3)New print format for tibble
s and data.table
s
rsi
class for vectors that contain only invalid antimicrobial interpretationsablist
to antibiotics
@@ -1565,9 +1576,9 @@ Using as.mo(..., allow_uncertain = 3)
as.mo(..., allow_uncertain = 3)Added barplots for rsi
and mic
classes