diff --git a/NEWS.md b/NEWS.md index 8e3030ac..47d167ed 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # 0.2.0 #### New * Full support for Windows, Linux and macOS +* Full support for old R versions, only R-3.0.0 (April 2013) or later is needed * Function `guess_bactid` to determine the ID of a microorganism based on genus/species or known abbreviations like MRSA * Functions `clipboard_import` and `clipboard_export` as helper functions to quickly copy and paste from/to software like Excel and SPSS * Function `MDRO` to determine Multi Drug Resistant Organisms (MDRO) with support for country-specific guidelines. Suggest your own via [this link](https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E). Functions `BRMO` and `MRGN` are wrappers for Dutch and German guidelines, respectively @@ -9,7 +10,6 @@ * New print format for tibbles and data.tables #### Changed -* Support for old R versions, only R-3.0.0 (April 2013) or later is needed * Renamed dataset `ablist` to `antibiotics` * Renamed dataset `bactlist` to `microorganisms` * Added more microorganisms to `bactlist` diff --git a/R/first_isolates.R b/R/first_isolates.R index e4f83a59..e8294cd2 100644 --- a/R/first_isolates.R +++ b/R/first_isolates.R @@ -50,6 +50,7 @@ #' @export #' @importFrom dplyr arrange_at lag between row_number filter mutate arrange #' @return A vector to add to table, see Examples. +#' @source Methodology of this function is based on: "M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition", 2014, Clinical and Laboratory Standards Institute. \url{https://clsi.org/standards/products/microbiology/documents/m39/}. #' @examples #' # septic_patients is a dataset available in the AMR package #' ?septic_patients diff --git a/README.md b/README.md index 205f5fec..81745b40 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,15 @@ This R package was created for academic research by PhD students of the Faculty ## Why this package? This R package contains functions to make microbiological, epidemiological data analysis easier. It allows the use of some new classes to work with MIC values and antimicrobial interpretations (i.e. values S, I and R). -With AMR you can also apply EUCAST rules to isolates, identify first isolates of every patient, translate antibiotic codes from the lab (like `"AMOX"`) or the [WHO](https://www.whocc.no/atc_ddd_index/?code=J01CA04&showdescription=no) (like `"J01CA04"`) to trivial names (like `"amoxicillin"`), or predict antimicrobial resistance for the nextcoming years with the `rsi_predict` function. +With `AMR` you can also: +* Conduct AMR analysis with the `rsi()` function, that can also be used with the `dplyr` package (e.g. in conjunction with `summarise`) to calculate the resistance percentages of different antibiotic columns of a table. +* Predict antimicrobial resistance for the nextcoming years with the `rsi_predict()` function +* Apply [EUCAST rules to isolates](http://www.eucast.org/expert_rules_and_intrinsic_resistance/) with the `EUCAST_rules()` function +* Identify first isolates of every patient [using guidelines from the CLSI](https://clsi.org/standards/products/microbiology/documents/m39/) (Clinical and Laboratory Standards Institute) with the `first_isolate()` function +* Translate antibiotic codes from the lab (like `"AMOX"`) or the [WHO](https://www.whocc.no/atc_ddd_index/?code=J01CA04&showdescription=no) (like `"J01CA04"`) to trivial names (like `"amoxicillin"`) with the `abname()` function With the `MDRO` function (abbreviation of mutli-drug resistant organisms), you can check your isolates for exceptional resistance with country-specific guidelines. Currently guidelines for Germany and the Netherlands are supported. Please suggest addition of your own country here: [https://github.com/msberends/AMR/issues](https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E). -For regular AMR analysis, the `rsi` function can be used. This function als works with the `dplyr` package (e.g. in conjunction with `summarise`) to calculate the resistance percentages of different antibiotic columns of a table. - This package contains an example data set `septic_patients`, consisting of 2000 isolates from anonymised septic patients between 2001 and 2017. ## How to get it? @@ -32,7 +35,7 @@ This package is available on CRAN and also here on GitHub. - `install.packages("AMR")` - Exploratory favicon In [Exploratory.io](https://exploratory.io): - - (Exploratory.io costs $40/month, but is free for students and teachers; if you have an `@umcg.nl` or `@rug.nl` email address, [click here to enroll](https://exploratory.io/plan?plan=Community)) + - (Exploratory.io costs $40/month but the somewhat limited Community Plan is free for students and teachers, [click here to enroll](https://exploratory.io/plan?plan=Community)) - Start the software and log in - Click on your username at the right hand side top - Click on `R Packages` @@ -276,7 +279,7 @@ bactlist # A tibble: 2,507 x 10 1 Department of Medical Microbiology, University of Groningen, University Medical Center Groningen, Groningen, the Netherlands -2 Department of Medical, Market and Innovation (MMI), Certe Medische diagnostiek & advies, Groningen, the Netherlands +2 Certe Medical Diagnostics & Advice, Groningen, the Netherlands ## Copyright [![License](https://img.shields.io/github/license/msberends/AMR.svg?colorB=3679BC)](https://github.com/msberends/AMR/blob/master/LICENSE) @@ -287,6 +290,8 @@ This R package is licensed under the [GNU General Public License (GPL) v2.0](htt - May be used for private purposes +- May **not** be used for patent purposes + - May be modified, although: - Modifications **must** be released under the same license when distributing the package diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index 9fe300a2..c0ee9a95 100644 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -3,6 +3,9 @@ \name{first_isolate} \alias{first_isolate} \title{Determine first (weighted) isolates} +\source{ +Methodology of this function is based on: "M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition", 2014, Clinical and Laboratory Standards Institute. \url{https://clsi.org/standards/products/microbiology/documents/m39/}. +} \usage{ first_isolate(tbl, col_date, col_patient_id, col_bactid = NA, col_testcode = NA, col_specimen = NA, col_icu = NA, diff --git a/tests/testthat/test-first_isolates.R b/tests/testthat/test-first_isolates.R index 6a1627e1..f8228250 100644 --- a/tests/testthat/test-first_isolates.R +++ b/tests/testthat/test-first_isolates.R @@ -17,7 +17,6 @@ test_that("first isolates work", { info = FALSE)), 1960) # septic_patients contains 1962 out of 2000 first *weighted* isolates - #septic_ptns$keyab <- suppressWarnings(key_antibiotics(septic_ptns)) expect_equal( suppressWarnings(sum( first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)), @@ -29,6 +28,13 @@ test_that("first isolates work", { info = TRUE))), 1962) + # septic_patients contains 1733 out of 2000 first non-ICU isolates + expect_equal( + sum( + first_isolate(septic_patients, col_bactid = "bactid", col_date = "date", col_patient_id = "patient_id", col_icu = "ward_icu", info = TRUE, icu_exclude = TRUE)), + 1733 + ) + # set 1500 random observations to be of specimen type 'Urine' random_rows <- sample(x = 1:2000, size = 1500, replace = FALSE) expect_lt(sum( diff --git a/tests/testthat/test-misc.R b/tests/testthat/test-misc.R index 30792859..b94e2899 100644 --- a/tests/testthat/test-misc.R +++ b/tests/testthat/test-misc.R @@ -1,7 +1,7 @@ context("misc.R") test_that("`like` works", { - expect_true("test" %like% "^t") + expect_true(suppressWarnings("test" %like% c("^t", "^s"))) expect_true("test" %like% "test") expect_true("test" %like% "TEST") expect_true(as.factor("test") %like% "TEST") diff --git a/tests/testthat/test-print.R b/tests/testthat/test-print.R index 57d8d583..ca3e0ad8 100644 --- a/tests/testthat/test-print.R +++ b/tests/testthat/test-print.R @@ -3,6 +3,9 @@ context("print.R") test_that("tibble printing works", { library(dplyr) + library(data.table) expect_output(print(starwars)) + expect_output(print(starwars %>% group_by(homeworld, gender))) + expect_output(print(starwars %>% as.data.table(), print.keys = TRUE)) expect_output(print(septic_patients)) })