From 8db87a15e957c772d3f35d6565763ef8fc2d0db4 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Tue, 15 Jan 2019 16:38:54 +0100 Subject: [PATCH] fixes --- NAMESPACE | 1 + R/globals.R | 12 +- R/resistance_predict.R | 3 +- docs/index.html | 26 +-- docs/news/index.html | 211 ++++++++++++++++++++----- docs/pkgdown.yml | 2 +- docs/reference/resistance_predict.html | 4 + man/resistance_predict.Rd | 2 + 8 files changed, 208 insertions(+), 53 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e5ea1a50..9aac9a76 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -228,6 +228,7 @@ importFrom(dplyr,summarise) importFrom(dplyr,summarise_if) importFrom(dplyr,tibble) importFrom(dplyr,top_n) +importFrom(dplyr,transmute) importFrom(dplyr,ungroup) importFrom(dplyr,vars) importFrom(grDevices,boxplot.stats) diff --git a/R/globals.R b/R/globals.R index aa0d6ae2..ee8aa43a 100755 --- a/R/globals.R +++ b/R/globals.R @@ -19,12 +19,20 @@ # Visit our website for more info: https://msberends.gitab.io/AMR. # # ==================================================================== # + + + globalVariables(c(".", - "atc", + "atc", "certe", - "official", + "official", "trade_name", "umcg", + 'se_min', + 'se_max', + 'labs', + 'transmute', + 'observed', "..property", "antibiotic", "Antibiotic", diff --git a/R/resistance_predict.R b/R/resistance_predict.R index bf2ea9e7..50654f9b 100755 --- a/R/resistance_predict.R +++ b/R/resistance_predict.R @@ -34,6 +34,7 @@ #' @param I_as_R a logical to indicate whether values \code{I} should be treated as \code{R} #' @param preserve_measurements a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be \code{NA}. #' @param info a logical to indicate whether textual analysis should be printed with the name and \code{\link{summary}} of the statistical model. +#' @param main title of the plot #' @return \code{data.frame} with extra class \code{"resistance_predict"} with columns: #' \itemize{ #' \item{\code{year}} @@ -48,7 +49,7 @@ #' @rdname resistance_predict #' @export #' @importFrom stats predict glm lm -#' @importFrom dplyr %>% pull mutate mutate_at n group_by_at summarise filter filter_at all_vars n_distinct arrange case_when n_groups +#' @importFrom dplyr %>% pull mutate mutate_at n group_by_at summarise filter filter_at all_vars n_distinct arrange case_when n_groups transmute #' @inheritSection AMR Read more on our website! #' @examples #' x <- resistance_predict(septic_patients, col_ab = "amox", year_min = 2010) diff --git a/docs/index.html b/docs/index.html index d5063da5..2efd8420 100644 --- a/docs/index.html +++ b/docs/index.html @@ -221,7 +221,7 @@

Get this package

This package is available on the official R network (CRAN). Install this package in R with:

-
install.packages("AMR")
+
install.packages("AMR")

It will be downloaded and installed automatically.

@@ -245,17 +245,17 @@ Overview of functions

The AMR package basically does four important things:

    -
  1. It cleanses existing data, by transforming it to reproducible and profound classes, making the most efficient use of R. These functions all use artificial intelligence to guess results that you would expect:
  2. -
+
  • +

    It cleanses existing data, by transforming it to reproducible and profound classes, making the most efficient use of R. These functions all use artificial intelligence to guess results that you would expect:

    • Use as.mo() to get an ID of a microorganism. The IDs are human readable for the trained eye - the ID of Klebsiella pneumoniae is “B_KLBSL_PNE” (B stands for Bacteria) and the ID of S. aureus is “B_STPHY_AUR”. The function takes almost any text as input that looks like the name or code of a microorganism like “E. coli”, “esco” or “esccol” and tries to find expected results using artificial intelligence (AI) on the included ITIS data set, consisting of almost 20,000 microorganisms. It is very fast, please see our benchmarks. Moreover, it can group Staphylococci into coagulase negative and positive (CoNS and CoPS, see source) and can categorise Streptococci into Lancefield groups (like beta-haemolytic Streptococcus Group B, source).
    • Use as.rsi() to transform values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like “<=0.002; S” (combined MIC/RSI) will result in “S”.
    • Use as.mic() to cleanse your MIC values. It produces a so-called factor (called ordinal in SPSS) with valid MIC values as levels. A value like “<=0.002; S” (combined MIC/RSI) will result in “<=0.002”.
    • Use as.atc() to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values “Furabid”, “Furadantin”, “nitro” all return the ATC code of Nitrofurantoine.
    -
      -
    1. It enhances existing data and adds new data from data sets included in this package.
    2. -
    +
  • +
  • +

    It enhances existing data and adds new data from data sets included in this package.

    • Use eucast_rules() to apply EUCAST expert rules to isolates.
    • Use first_isolate() to identify the first isolates of every patient using guidelines from the CLSI (Clinical and Laboratory Standards Institute). @@ -267,9 +267,9 @@
    • The data set microorganisms contains the complete taxonomic tree of more than 18,000 microorganisms (bacteria, fungi/yeasts and protozoa). Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like mo_genus(), mo_family(), mo_gramstain() or even mo_phylum(). As they use as.mo() internally, they also use artificial intelligence. For example, mo_genus("MRSA") and mo_genus("S. aureus") will both return "Staphylococcus". They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.
    • The data set antibiotics contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like ab_name() and ab_tradenames() to look up values. The ab_* functions use as.atc() internally so they support AI to guess your expected result. For example, ab_name("Fluclox"), ab_name("Floxapen") and ab_name("J01CF05") will all return "Flucloxacillin". These functions can again be used to add new variables to your data.
    -
      -
    1. It analyses the data with convenient functions that use well-known methods.
    2. -
    +
  • +
  • +

    It analyses the data with convenient functions that use well-known methods.

    -
      -
    1. It teaches the user how to use all the above actions.
    2. -
    +
  • +
  • +

    It teaches the user how to use all the above actions.

    • The package contains extensive help pages with many examples.
    • It also contains an example data set called septic_patients. This data set contains: @@ -290,6 +290,8 @@
  • + +

    diff --git a/docs/news/index.html b/docs/news/index.html index e1d1981c..3e0c888e 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -229,33 +229,53 @@

    Changed

    @@ -496,15 +603,21 @@ New

    + +
  • Determining bacterial ID: +
    • New functions as.bactid and is.bactid to transform/ look up microbial ID’s.
    • The existing function guess_bactid is now an alias of as.bactid
    • New Becker classification for Staphylococcus to categorise them into Coagulase Negative Staphylococci (CoNS) and Coagulase Positve Staphylococci (CoPS)
    • New Lancefield classification for Streptococcus to categorise them into Lancefield groups
    • +
    +
  • For convience, new descriptive statistical functions kurtosis and skewness that are lacking in base R - they are generic functions and have support for vectors, data.frames and matrices
  • Function g.test to perform the Χ2 distributed G-test, which use is the same as chisq.test
  • -
  • Function ratio to transform a vector of values to a preset ratio
  • +
  • +Function ratio to transform a vector of values to a preset ratio + +
  • Support for Addins menu in RStudio to quickly insert %in% or %like% (and give them keyboard shortcuts), or to view the datasets that come with this package
  • Function p.symbol to transform p values to their related symbols: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  • Functions clipboard_import and clipboard_export as helper functions to quickly copy and paste from/to software like Excel and SPSS. These functions use the clipr package, but are a little altered to also support headless Linux servers (so you can use it in RStudio Server)
  • -
  • New for frequency tables (function freq):
  • +
  • New for frequency tables (function freq): +
    • A vignette to explain its usage
    • Support for rsi (antimicrobial resistance) to use as input
    • Support for table to use as input: freq(table(x, y)) @@ -545,6 +668,8 @@
    • Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)
    • Possibility to globally set the default for the amount of items to print, with options(max.print.freq = n) where n is your preset value
    +
  • +

    @@ -566,21 +691,27 @@
  • Small improvements to the microorganisms dataset (especially for Salmonella) and the column bactid now has the new class "bactid"
  • -
  • Combined MIC/RSI values will now be coerced by the rsi and mic functions:
  • +
  • Combined MIC/RSI values will now be coerced by the rsi and mic functions: + +
  • Now possible to coerce MIC values with a space between operator and value, i.e. as.mic("<= 0.002") now works
  • Classes rsi and mic do not add the attribute package.version anymore
  • Added "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.
  • Build-in host check for atc_property as it requires the host set by url to be responsive
  • Improved first_isolate algorithm to exclude isolates where bacteria ID or genus is unavailable
  • Fix for warning hybrid evaluation forced for row_number (924b62) from the dplyr package v0.7.5 and above
  • -
  • Support for empty values and for 1 or 2 columns as input for guess_bactid (now called as.bactid)
  • +
  • Support for empty values and for 1 or 2 columns as input for guess_bactid (now called as.bactid) +
    • So yourdata %>% select(genus, species) %>% as.bactid() now also works
    • +
    +
  • Other small fixes
  • @@ -588,11 +719,14 @@

    Other

    @@ -611,10 +745,13 @@
  • Function guess_bactid to determine the ID of a microorganism based on genus/species or known abbreviations like MRSA
  • Function guess_atc to determine the ATC of an antibiotic based on name, trade name, or known abbreviations
  • Function freq to create frequency tables, with additional info in a header
  • -
  • Function MDRO to determine Multi Drug Resistant Organisms (MDRO) with support for country-specific guidelines.
  • +
  • Function MDRO to determine Multi Drug Resistant Organisms (MDRO) with support for country-specific guidelines. + +
  • New algorithm to determine weighted isolates, can now be "points" or "keyantibiotics", see ?first_isolate
  • New print format for tibbles and data.tables
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 3c396dbb..31227eab 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,4 +1,4 @@ -pandoc: 1.17.2 +pandoc: 2.3.1 pkgdown: 1.3.0 pkgdown_sha: ~ articles: diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index 4a9d5ab7..1f1eb990 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -297,6 +297,10 @@ single plotting structure, function or any R object with a plot method can be provided.

    + + main +

    title of the plot

    + ...

    parameters passed on to the first_isolate function

    diff --git a/man/resistance_predict.Rd b/man/resistance_predict.Rd index 55819daa..c1e16737 100644 --- a/man/resistance_predict.Rd +++ b/man/resistance_predict.Rd @@ -50,6 +50,8 @@ ggplot_rsi_predict(x, main = paste("Resistance prediction of", single plotting structure, function or \emph{any \R object with a \code{plot} method} can be provided.} +\item{main}{title of the plot} + \item{...}{parameters passed on to the \code{first_isolate} function} } \value{