mirror of
https://github.com/msberends/AMR.git
synced 2024-12-27 08:06:13 +01:00
more unit tests
This commit is contained in:
parent
82fec5cc51
commit
0b22ddef8e
2
NEWS.md
2
NEWS.md
@ -1,6 +1,7 @@
|
|||||||
# 0.2.0
|
# 0.2.0
|
||||||
#### New
|
#### New
|
||||||
* Full support for Windows, Linux and macOS
|
* 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
|
* 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
|
* 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
|
* 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
|
* New print format for tibbles and data.tables
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
* Support for old R versions, only R-3.0.0 (April 2013) or later is needed
|
|
||||||
* Renamed dataset `ablist` to `antibiotics`
|
* Renamed dataset `ablist` to `antibiotics`
|
||||||
* Renamed dataset `bactlist` to `microorganisms`
|
* Renamed dataset `bactlist` to `microorganisms`
|
||||||
* Added more microorganisms to `bactlist`
|
* Added more microorganisms to `bactlist`
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr arrange_at lag between row_number filter mutate arrange
|
#' @importFrom dplyr arrange_at lag between row_number filter mutate arrange
|
||||||
#' @return A vector to add to table, see Examples.
|
#' @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
|
#' @examples
|
||||||
#' # septic_patients is a dataset available in the AMR package
|
#' # septic_patients is a dataset available in the AMR package
|
||||||
#' ?septic_patients
|
#' ?septic_patients
|
||||||
|
15
README.md
15
README.md
@ -8,12 +8,15 @@ This R package was created for academic research by PhD students of the Faculty
|
|||||||
## Why this package?
|
## 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).
|
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).
|
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.
|
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?
|
## How to get it?
|
||||||
@ -32,7 +35,7 @@ This package is available on CRAN and also here on GitHub.
|
|||||||
- `install.packages("AMR")`
|
- `install.packages("AMR")`
|
||||||
|
|
||||||
- <img src="https://exploratory.io/favicon.ico" alt="Exploratory favicon" height="20px"> In [Exploratory.io](https://exploratory.io):
|
- <img src="https://exploratory.io/favicon.ico" alt="Exploratory favicon" height="20px"> 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
|
- Start the software and log in
|
||||||
- Click on your username at the right hand side top
|
- Click on your username at the right hand side top
|
||||||
- Click on `R Packages`
|
- Click on `R Packages`
|
||||||
@ -276,7 +279,7 @@ bactlist # A tibble: 2,507 x 10
|
|||||||
|
|
||||||
<sup>1</sup> Department of Medical Microbiology, University of Groningen, University Medical Center Groningen, Groningen, the Netherlands
|
<sup>1</sup> Department of Medical Microbiology, University of Groningen, University Medical Center Groningen, Groningen, the Netherlands
|
||||||
|
|
||||||
<sup>2</sup> Department of Medical, Market and Innovation (MMI), Certe Medische diagnostiek & advies, Groningen, the Netherlands
|
<sup>2</sup> Certe Medical Diagnostics & Advice, Groningen, the Netherlands
|
||||||
|
|
||||||
## Copyright
|
## Copyright
|
||||||
[![License](https://img.shields.io/github/license/msberends/AMR.svg?colorB=3679BC)](https://github.com/msberends/AMR/blob/master/LICENSE)
|
[![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 be used for private purposes
|
||||||
|
|
||||||
|
- May **not** be used for patent purposes
|
||||||
|
|
||||||
- May be modified, although:
|
- May be modified, although:
|
||||||
|
|
||||||
- Modifications **must** be released under the same license when distributing the package
|
- Modifications **must** be released under the same license when distributing the package
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
\name{first_isolate}
|
\name{first_isolate}
|
||||||
\alias{first_isolate}
|
\alias{first_isolate}
|
||||||
\title{Determine first (weighted) isolates}
|
\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{
|
\usage{
|
||||||
first_isolate(tbl, col_date, col_patient_id, col_bactid = NA,
|
first_isolate(tbl, col_date, col_patient_id, col_bactid = NA,
|
||||||
col_testcode = NA, col_specimen = NA, col_icu = NA,
|
col_testcode = NA, col_specimen = NA, col_icu = NA,
|
||||||
|
@ -17,7 +17,6 @@ test_that("first isolates work", {
|
|||||||
info = FALSE)), 1960)
|
info = FALSE)), 1960)
|
||||||
|
|
||||||
# septic_patients contains 1962 out of 2000 first *weighted* isolates
|
# septic_patients contains 1962 out of 2000 first *weighted* isolates
|
||||||
#septic_ptns$keyab <- suppressWarnings(key_antibiotics(septic_ptns))
|
|
||||||
expect_equal(
|
expect_equal(
|
||||||
suppressWarnings(sum(
|
suppressWarnings(sum(
|
||||||
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||||
@ -29,6 +28,13 @@ test_that("first isolates work", {
|
|||||||
info = TRUE))),
|
info = TRUE))),
|
||||||
1962)
|
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'
|
# set 1500 random observations to be of specimen type 'Urine'
|
||||||
random_rows <- sample(x = 1:2000, size = 1500, replace = FALSE)
|
random_rows <- sample(x = 1:2000, size = 1500, replace = FALSE)
|
||||||
expect_lt(sum(
|
expect_lt(sum(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
context("misc.R")
|
context("misc.R")
|
||||||
|
|
||||||
test_that("`like` works", {
|
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("test" %like% "TEST")
|
expect_true("test" %like% "TEST")
|
||||||
expect_true(as.factor("test") %like% "TEST")
|
expect_true(as.factor("test") %like% "TEST")
|
||||||
|
@ -3,6 +3,9 @@ context("print.R")
|
|||||||
|
|
||||||
test_that("tibble printing works", {
|
test_that("tibble printing works", {
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
|
library(data.table)
|
||||||
expect_output(print(starwars))
|
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))
|
expect_output(print(septic_patients))
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user