Compare commits
15 Commits
v1.6.0
...
e405de079c
| Author | SHA1 | Date | |
|---|---|---|---|
| e405de079c | |||
| a9fd4aa49f | |||
| 5e06b20d43 | |||
| c5fff1c95c | |||
| 93683a4ae2 | |||
| 5f9e7bd3ee | |||
| 70b803dbb6 | |||
| c6289c3fc3 | |||
| de66eccf43 | |||
| 24ac18a99d | |||
| 9842ef9660 | |||
| 00d3e437a8 | |||
| d277d58475 | |||
| 6ff5448192 | |||
| 7a3139f7cc |
@@ -1,3 +1,4 @@
|
||||
^.*\.RData$
|
||||
^.*\.Rproj$
|
||||
^\.Renviron$
|
||||
^\.Rprofile$
|
||||
|
||||
14
.github/workflows/check.yaml
vendored
@@ -65,10 +65,10 @@ jobs:
|
||||
- {os: ubuntu-20.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.3', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
# - {os: ubuntu-20.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
# - {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.0', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
|
||||
- {os: ubuntu-16.04, r: 'devel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
@@ -77,10 +77,10 @@ jobs:
|
||||
- {os: ubuntu-16.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.3', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
# - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
# - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.0', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
|
||||
env:
|
||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||
@@ -151,6 +151,8 @@ jobs:
|
||||
if: matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2'
|
||||
env:
|
||||
_R_CHECK_CRAN_INCOMING_: false
|
||||
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
||||
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
|
||||
shell: Rscript {0}
|
||||
|
||||
@@ -159,10 +161,12 @@ jobs:
|
||||
env:
|
||||
_R_CHECK_CRAN_INCOMING_: false
|
||||
_R_CHECK_FORCE_SUGGESTS_: false
|
||||
_R_CHECK_DEPENDS_ONLY_: true
|
||||
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
||||
run: |
|
||||
R CMD check data-raw/AMR_latest.tar.gz --no-manual --no-build-vignettes
|
||||
tar -xvf data-raw/AMR_latest.tar.gz
|
||||
R CMD check AMR --no-manual --no-build-vignettes
|
||||
|
||||
- name: Show testthat output
|
||||
if: always()
|
||||
|
||||
13
DESCRIPTION
@@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 1.6.0
|
||||
Date: 2021-03-14
|
||||
Version: 1.6.0.9014
|
||||
Date: 2021-04-30
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
@@ -35,11 +35,10 @@ Authors@R: c(
|
||||
family = "Souverein", given = "Dennis", email = "d.souvereing@streeklabhaarlem.nl"),
|
||||
person(role = "ctb",
|
||||
family = "Underwood", given = "Anthony", email = "au3@sanger.ac.uk"))
|
||||
Description: Functions to simplify the analysis and prediction of Antimicrobial
|
||||
Resistance (AMR) and to work with microbial and antimicrobial properties by
|
||||
using evidence-based methods, like those defined by Leclercq et al. (2013)
|
||||
<doi:10.1111/j.1469-0691.2011.03703.x> and containing reference data such as
|
||||
LPSN <doi:10.1099/ijsem.0.004332>.
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
data analysis and to work with microbial and antimicrobial properties by
|
||||
using evidence-based methods and reliable reference data such as LPSN
|
||||
<doi:10.1099/ijsem.0.004332>.
|
||||
Depends:
|
||||
R (>= 3.0.0)
|
||||
Suggests:
|
||||
|
||||
11
NAMESPACE
@@ -43,6 +43,8 @@ S3method(as.data.frame,ab)
|
||||
S3method(as.data.frame,mo)
|
||||
S3method(as.double,mic)
|
||||
S3method(as.integer,mic)
|
||||
S3method(as.list,custom_eucast_rules)
|
||||
S3method(as.list,custom_mdro_guideline)
|
||||
S3method(as.matrix,mic)
|
||||
S3method(as.numeric,mic)
|
||||
S3method(as.rsi,data.frame)
|
||||
@@ -57,6 +59,8 @@ S3method(barplot,disk)
|
||||
S3method(barplot,mic)
|
||||
S3method(barplot,rsi)
|
||||
S3method(c,ab)
|
||||
S3method(c,custom_eucast_rules)
|
||||
S3method(c,custom_mdro_guideline)
|
||||
S3method(c,disk)
|
||||
S3method(c,mic)
|
||||
S3method(c,mo)
|
||||
@@ -97,6 +101,7 @@ S3method(plot,rsi)
|
||||
S3method(print,ab)
|
||||
S3method(print,bug_drug_combinations)
|
||||
S3method(print,catalogue_of_life_version)
|
||||
S3method(print,custom_eucast_rules)
|
||||
S3method(print,custom_mdro_guideline)
|
||||
S3method(print,disk)
|
||||
S3method(print,mic)
|
||||
@@ -137,6 +142,8 @@ S3method(unique,mo)
|
||||
S3method(unique,rsi)
|
||||
export("%like%")
|
||||
export("%like_case%")
|
||||
export("%unlike%")
|
||||
export("%unlike_case%")
|
||||
export(ab_atc)
|
||||
export(ab_atc_group1)
|
||||
export(ab_atc_group2)
|
||||
@@ -154,8 +161,10 @@ export(ab_tradenames)
|
||||
export(ab_url)
|
||||
export(age)
|
||||
export(age_groups)
|
||||
export(all_antimicrobials)
|
||||
export(aminoglycosides)
|
||||
export(anti_join_microorganisms)
|
||||
export(antimicrobials_equal)
|
||||
export(as.ab)
|
||||
export(as.disk)
|
||||
export(as.mic)
|
||||
@@ -184,6 +193,7 @@ export(count_all)
|
||||
export(count_df)
|
||||
export(count_resistant)
|
||||
export(count_susceptible)
|
||||
export(custom_eucast_rules)
|
||||
export(custom_mdro_guideline)
|
||||
export(eucast_dosage)
|
||||
export(eucast_exceptional_phenotypes)
|
||||
@@ -229,6 +239,7 @@ export(is.rsi.eligible)
|
||||
export(is_new_episode)
|
||||
export(key_antibiotics)
|
||||
export(key_antibiotics_equal)
|
||||
export(key_antimicrobials)
|
||||
export(kurtosis)
|
||||
export(labels_rsi_count)
|
||||
export(left_join_microorganisms)
|
||||
|
||||
78
NEWS.md
@@ -1,5 +1,41 @@
|
||||
# AMR 1.6.0
|
||||
# `AMR` 1.6.0.9014
|
||||
## <small>Last updated: 30 April 2021</small>
|
||||
|
||||
### New
|
||||
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
||||
* Support for all four methods to determine first isolates as summarised by Hindler *et al* (doi: [10.1086/511864](https://doi.org/10.1086/511864)): isolate-based, patient-based, episode-based and phenotype-based. The last method is now the default.
|
||||
* The `first_isolate()` function gained the argument `method` that has to be "phenotype-based", "episode-based", "patient-based", or "isolate-based". The old behaviour is equal to "episode-based". The new default is "phenotype-based" if antimicrobial test results are available, and "episode-based" otherwise. This new default will yield slightly more isolates for selection (which is a good thing).
|
||||
* Since fungal isolates can also be selected, the functions `key_antibiotics()` and `key_antibiotics_equal()` are now deprecated in favour of the `key_antimicrobials()` and `antimicrobial_equal()` functions. Also, the new `all_antimicrobials()` function works like the old `key_antibiotics()` function, but includes any column with antimicrobial test results. Using `key_antimicrobials()` still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new `antifungal` argument to set antifungal agents (antimycotics).
|
||||
* Using `type == "points"` in the `first_isolate()` function for phenotype-based selection will now consider all antimicrobial drugs in the data set, using the new `all_antimicrobials()`
|
||||
* The `first_isolate()` function can now take a vector of values for `col_keyantibiotics` and can have an episode length of `Inf`
|
||||
* Since the phenotype-based method is the new default, `filter_first_isolate()` renders the `filter_first_weighted_isolate()` function redundant. For this reason, `filter_first_weighted_isolate()` is now deprecated.
|
||||
* The documentation of the `first_isolate()` and `key_antimicrobials()` functions has been completely rewritten.
|
||||
|
||||
### Changed
|
||||
* Custom MDRO guidelines (`mdro()`, `custom_mdro_guideline()`):
|
||||
* Custom MDRO guidelines can now be combined with other custom MDRO guidelines using `c()`
|
||||
* Fix for applying the rules; in previous versions, rows were interpreted according to the last matched rule. Now, rows are interpreted according to the first matched rule
|
||||
* Fix for `age_groups()` for persons aged zero
|
||||
* The `example_isolates` data set now contains some (fictitious) zero-year old patients
|
||||
* Fix for minor translation errors
|
||||
* Printing of microbial codes in a `data.frame` or `tibble` now gives a warning if the data contains old microbial codes (from a previous AMR package version)
|
||||
* Extended the `like()` functions:
|
||||
* Now checks if `pattern` is a *valid* regular expression
|
||||
* Added `%unlike%` and `%unlike_case%` (as negations of the existing `%like%` and `%like_case%`). This greatly improves readability:
|
||||
```r
|
||||
if (!grepl("EUCAST", guideline)) ...
|
||||
# same:
|
||||
if (guideline %unlike% "EUCAST") ...
|
||||
```
|
||||
* Altered the RStudio addin, so it now iterates over `%like%` -> `%unlike%` -> `%like_case%` -> `%unlike_case%` if you keep pressing your keyboard shortcut
|
||||
* Fixed an installation error on R-3.0
|
||||
* Added `info` argument to `as.mo()` to turn on/off the progress bar
|
||||
* Fixed a bug that `col_mo` for some functions (esp. `eucast_rules()` and `mdro()`) could not be column names of the `microorganisms` data set as it would throw an error
|
||||
* Fix for transforming numeric values to RSI (`as.rsi()`) when the `vctrs` package is loaded (i.e., when using tidyverse)
|
||||
* Colour fix for using `barplot()` on an RSI class
|
||||
|
||||
|
||||
# `AMR` 1.6.0
|
||||
|
||||
### New
|
||||
* Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the `eucast_rules()` function and in `as.rsi()` to interpret MIC and disk diffusion values. This is now the default guideline in this package.
|
||||
@@ -59,7 +95,7 @@
|
||||
```
|
||||
|
||||
### Changed
|
||||
* Updated the bacterial taxonomy to 3 March 2021 (using [LSPN](https://lpsn.dsmz.de))
|
||||
* Updated the bacterial taxonomy to 3 March 2021 (using [LPSN](https://lpsn.dsmz.de))
|
||||
* Added 3,372 new species and 1,523 existing species became synomyms
|
||||
* The URL of a bacterial species (`mo_url()`) will now lead to https://lpsn.dsmz.de
|
||||
* Big update for plotting classes `rsi`, `<mic>`, and `<disk>`:
|
||||
@@ -93,7 +129,7 @@
|
||||
* Loading the package (i.e., `library(AMR)`) now is ~50 times faster than before, in costs of package size (which increased by ~3 MB)
|
||||
|
||||
|
||||
# AMR 1.5.0
|
||||
# `AMR` 1.5.0
|
||||
|
||||
### New
|
||||
* Functions `get_episode()` and `is_new_episode()` to determine (patient) episodes which are not necessarily based on microorganisms. The `get_episode()` function returns the index number of the episode per group, while the `is_new_episode()` function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode. They also support `dplyr`s grouping (i.e. using `group_by()`):
|
||||
@@ -170,7 +206,7 @@
|
||||
* Added CodeFactor as a continuous code review to this package: <https://www.codefactor.io/repository/github/msberends/amr/>
|
||||
* Added Dr. Rogier Schade as contributor
|
||||
|
||||
# AMR 1.4.0
|
||||
# `AMR` 1.4.0
|
||||
|
||||
### New
|
||||
* Support for 'EUCAST Expert Rules' / 'EUCAST Intrinsic Resistance and Unusual Phenotypes' version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the `eucast_rules()` function can now correct for more than 180 different antibiotics and the `mdro()` function can determine multidrug resistance based on more than 150 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The `eucast_rules()` function consequently gained the arguments `version_breakpoints` (at the moment defaults to v10.0, 2020) and `version_expertrules` (at the moment defaults to v3.2, 2020). The `example_isolates` data set now also reflects the change from v3.1 to v3.2. The `mdro()` function now accepts `guideline == "EUCAST3.1"` and `guideline == "EUCAST3.2"`.
|
||||
@@ -242,7 +278,7 @@
|
||||
* Removed unnecessary references to the `base` package
|
||||
* Added packages that could be useful for some functions to the `Suggests` field of the `DESCRIPTION` file
|
||||
|
||||
# AMR 1.3.0
|
||||
# `AMR` 1.3.0
|
||||
|
||||
### New
|
||||
* Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally
|
||||
@@ -295,7 +331,7 @@
|
||||
### Other
|
||||
* Moved primary location of this project from GitLab to [GitHub](https://github.com/msberends/AMR), giving us native support for automated syntax checking without being dependent on external services such as AppVeyor and Travis CI.
|
||||
|
||||
# AMR 1.2.0
|
||||
# `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.
|
||||
@@ -333,7 +369,7 @@
|
||||
* Removed previously deprecated function `p.symbol()` - it was replaced with `p_symbol()`
|
||||
* Removed function `read.4d()`, that was only useful for reading data from an old test database.
|
||||
|
||||
# AMR 1.1.0
|
||||
# `AMR` 1.1.0
|
||||
|
||||
### New
|
||||
* Support for easy principal component analysis for AMR, using the new `pca()` function
|
||||
@@ -355,7 +391,7 @@
|
||||
* Support for the upcoming `dplyr` version 1.0.0
|
||||
* More robust assigning for classes `rsi` and `mic`
|
||||
|
||||
# AMR 1.0.1
|
||||
# `AMR` 1.0.1
|
||||
|
||||
### Changed
|
||||
* Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline
|
||||
@@ -371,7 +407,7 @@
|
||||
* Added `uti` (as abbreviation of urinary tract infections) as argument 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)
|
||||
|
||||
# AMR 1.0.0
|
||||
# `AMR` 1.0.0
|
||||
|
||||
This software is now out of beta and considered stable. Nonetheless, this package will be developed continually.
|
||||
|
||||
@@ -419,7 +455,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
||||
* Full support for the upcoming R 4.0
|
||||
* Removed unnecessary `AMR::` calls
|
||||
|
||||
# AMR 0.9.0
|
||||
# `AMR` 0.9.0
|
||||
|
||||
### Breaking
|
||||
* Adopted Adeolu *et al.* (2016), [PMID 27620848](https:/pubmed.ncbi.nlm.nih.gov/27620848/) for the `microorganisms` data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like *Morganellaceae* and *Yersiniaceae*). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with `mdro()` will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
|
||||
@@ -485,7 +521,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
||||
* Change dependency on `clean` to `cleaner`, as this package was renamed accordingly upon CRAN request
|
||||
* Added Dr. Sofia Ny as contributor
|
||||
|
||||
# AMR 0.8.0
|
||||
# `AMR` 0.8.0
|
||||
|
||||
### Breaking
|
||||
* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new argument `include_unknown`:
|
||||
@@ -614,7 +650,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
||||
* Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors
|
||||
* Cleaned the coding style of every single syntax line in this package with the help of the `lintr` package
|
||||
|
||||
# AMR 0.7.1
|
||||
# `AMR` 0.7.1
|
||||
|
||||
#### New
|
||||
* Function `rsi_df()` to transform a `data.frame` to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions `count_df()` and `portion_df()` to immediately show resistance percentages and number of available isolates:
|
||||
@@ -675,7 +711,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
||||
#### Other
|
||||
* Fixed a note thrown by CRAN tests
|
||||
|
||||
# AMR 0.7.0
|
||||
# `AMR` 0.7.0
|
||||
|
||||
#### New
|
||||
* Support for translation of disk diffusion and MIC values to RSI values (i.e. antimicrobial interpretations). Supported guidelines are EUCAST (2011 to 2019) and CLSI (2011 to 2019). Use `as.rsi()` on an MIC value (created with `as.mic()`), a disk diffusion value (created with the new `as.disk()`) or on a complete date set containing columns with MIC or disk diffusion values.
|
||||
@@ -733,13 +769,13 @@ This software is now out of beta and considered stable. Nonetheless, this packag
|
||||
#### Other
|
||||
* Support for R 3.6.0 and later by providing support for [staged install](https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html)
|
||||
|
||||
# AMR 0.6.1
|
||||
# `AMR` 0.6.1
|
||||
|
||||
#### Changed
|
||||
* Fixed a critical bug when using `eucast_rules()` with `verbose = TRUE`
|
||||
* Coercion of microbial IDs are now written to the package namespace instead of the user's home folder, to comply with the CRAN policy
|
||||
|
||||
# AMR 0.6.0
|
||||
# `AMR` 0.6.0
|
||||
|
||||
**New website!**
|
||||
|
||||
@@ -932,7 +968,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
#### Other
|
||||
* Updated licence text to emphasise GPL 2.0 and that this is an R package.
|
||||
|
||||
# AMR 0.5.0
|
||||
# `AMR` 0.5.0
|
||||
|
||||
#### New
|
||||
* Repository moved to GitLab
|
||||
@@ -1015,7 +1051,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
* Updated vignettes to comply with README
|
||||
|
||||
|
||||
# AMR 0.4.0
|
||||
# `AMR` 0.4.0
|
||||
|
||||
#### New
|
||||
* 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.
|
||||
@@ -1126,7 +1162,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
#### Other
|
||||
* More unit tests to ensure better integrity of functions
|
||||
|
||||
# AMR 0.3.0
|
||||
# `AMR` 0.3.0
|
||||
|
||||
#### New
|
||||
* **BREAKING**: `rsi_df` was removed in favour of new functions `portion_R`, `portion_IR`, `portion_I`, `portion_SI` and `portion_S` to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old `rsi` function. The old function still works, but is deprecated.
|
||||
@@ -1196,7 +1232,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
* Windows: https://ci.appveyor.com/project/msberends/amr
|
||||
* Added thesis advisors to DESCRIPTION file
|
||||
|
||||
# AMR 0.2.0
|
||||
# `AMR` 0.2.0
|
||||
|
||||
#### New
|
||||
* Full support for Windows, Linux and macOS
|
||||
@@ -1231,7 +1267,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
* Added build tests for Linux and macOS using Travis CI (https://travis-ci.org/msberends/AMR)
|
||||
* Added line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R)
|
||||
|
||||
# AMR 0.1.1
|
||||
# `AMR` 0.1.1
|
||||
|
||||
* `EUCAST_rules` applies for amoxicillin even if ampicillin is missing
|
||||
* Edited column names to comply with GLIMS, the laboratory information system
|
||||
@@ -1239,6 +1275,6 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
|
||||
* Renamed 'Daily Defined Dose' to 'Defined Daily Dose'
|
||||
* Added barplots for `rsi` and `mic` classes
|
||||
|
||||
# AMR 0.1.0
|
||||
# `AMR` 0.1.0
|
||||
|
||||
* First submission to CRAN.
|
||||
|
||||
@@ -71,7 +71,49 @@ addin_insert_in <- function() {
|
||||
|
||||
# No export, no Rd
|
||||
addin_insert_like <- function() {
|
||||
import_fn("insertText", "rstudioapi")(" %like% ")
|
||||
# we want Shift + Ctrl/Cmd + L to iterate over %like%, %unlike%, %like_case%, and %unlike_case%
|
||||
|
||||
getActiveDocumentContext <- import_fn("getActiveDocumentContext", "rstudioapi")
|
||||
insertText <- import_fn("insertText", "rstudioapi")
|
||||
modifyRange <- import_fn("modifyRange", "rstudioapi")
|
||||
document_range <- import_fn("document_range", "rstudioapi")
|
||||
document_position <- import_fn("document_position", "rstudioapi")
|
||||
|
||||
context <- getActiveDocumentContext()
|
||||
current_row <- context$selection[[1]]$range$end[1]
|
||||
current_col <- context$selection[[1]]$range$end[2]
|
||||
current_row_txt <- context$contents[current_row]
|
||||
if (is.null(current_row) || current_row_txt %unlike% "%(un)?like") {
|
||||
insertText(" %like% ")
|
||||
return(invisible())
|
||||
}
|
||||
|
||||
pos_preceded_by <- function(txt) {
|
||||
if (tryCatch(substr(current_row_txt, current_col - nchar(trimws(txt, which = "right")), current_col) == trimws(txt, which = "right"),
|
||||
error = function(e) FALSE)) {
|
||||
return(TRUE)
|
||||
}
|
||||
tryCatch(substr(current_row_txt, current_col - nchar(txt), current_col) %like% paste0("^", txt),
|
||||
error = function(e) FALSE)
|
||||
}
|
||||
replace_pos <- function(old, with) {
|
||||
modifyRange(document_range(document_position(current_row, current_col - nchar(old)),
|
||||
document_position(current_row, current_col)),
|
||||
text = with,
|
||||
id = context$id)
|
||||
}
|
||||
|
||||
if (pos_preceded_by(" %like% ")) {
|
||||
replace_pos(" %like% ", with = " %unlike% ")
|
||||
} else if (pos_preceded_by(" %unlike% ")) {
|
||||
replace_pos(" %unlike% ", with = " %like_case% ")
|
||||
} else if (pos_preceded_by(" %like_case% ")) {
|
||||
replace_pos(" %like_case% ", with = " %unlike_case% ")
|
||||
} else if (pos_preceded_by(" %unlike_case% ")) {
|
||||
replace_pos(" %unlike_case% ", with = " %like% ")
|
||||
} else {
|
||||
insertText(" %like% ")
|
||||
}
|
||||
}
|
||||
|
||||
check_dataset_integrity <- function() {
|
||||
@@ -148,8 +190,8 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
}
|
||||
# -- key antibiotics
|
||||
if (type == "keyantibiotics") {
|
||||
if (any(colnames(x) %like% "^key.*(ab|antibiotics)")) {
|
||||
found <- sort(colnames(x)[colnames(x) %like% "^key.*(ab|antibiotics)"])[1]
|
||||
if (any(colnames(x) %like% "^key.*(ab|antibiotics|antimicrobials)")) {
|
||||
found <- sort(colnames(x)[colnames(x) %like% "^key.*(ab|antibiotics|antimicrobials)"])[1]
|
||||
}
|
||||
}
|
||||
# -- date
|
||||
@@ -211,10 +253,21 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
||||
found
|
||||
}
|
||||
|
||||
is_possibly_regex <- function(x) {
|
||||
tryCatch(vapply(FUN.VALUE = character(1), strsplit(x, ""),
|
||||
function(y) any(y %in% c("$", "(", ")", "*", "+", "-", ".", "?", "[", "]", "^", "{", "|", "}", "\\"), na.rm = TRUE)),
|
||||
error = function(e) rep(TRUE, length(x)))
|
||||
is_valid_regex <- function(x) {
|
||||
regex_at_all <- tryCatch(vapply(FUN.VALUE = logical(1),
|
||||
X = strsplit(x, ""),
|
||||
FUN = function(y) any(y %in% c("$", "(", ")", "*", "+", "-",
|
||||
".", "?", "[", "]", "^", "{",
|
||||
"|", "}", "\\"),
|
||||
na.rm = TRUE),
|
||||
USE.NAMES = FALSE),
|
||||
error = function(e) rep(TRUE, length(x)))
|
||||
regex_valid <- vapply(FUN.VALUE = logical(1),
|
||||
X = x,
|
||||
FUN = function(y) !"try-error" %in% class(try(grepl(y, "", perl = TRUE),
|
||||
silent = TRUE)),
|
||||
USE.NAMES = FALSE)
|
||||
regex_at_all & regex_valid
|
||||
}
|
||||
|
||||
stop_ifnot_installed <- function(package) {
|
||||
@@ -223,8 +276,8 @@ stop_ifnot_installed <- function(package) {
|
||||
vapply(FUN.VALUE = character(1), package, function(pkg)
|
||||
tryCatch(get(".packageName", envir = asNamespace(pkg)),
|
||||
error = function(e) {
|
||||
if (package == "rstudioapi") {
|
||||
stop("This function only works in RStudio.", call. = FALSE)
|
||||
if (pkg == "rstudioapi") {
|
||||
stop("This function only works in RStudio when using R >= 3.2.", call. = FALSE)
|
||||
} else if (pkg != "base") {
|
||||
stop("This requires the '", pkg, "' package.",
|
||||
"\nTry to install it with: install.packages(\"", pkg, "\")",
|
||||
@@ -265,7 +318,9 @@ word_wrap <- function(...,
|
||||
msg <- paste0(c(...), collapse = "")
|
||||
|
||||
if (isTRUE(as_note)) {
|
||||
msg <- paste0("NOTE: ", gsub("^note:? ?", "", msg, ignore.case = TRUE))
|
||||
# \u2139 is a symbol officially named 'information source'
|
||||
# \ufe0f can add the blue square around it: \u2139\ufe0f
|
||||
msg <- paste0("\u2139 ", gsub("^note:? ?", "", msg, ignore.case = TRUE))
|
||||
}
|
||||
|
||||
if (msg %like% "\n") {
|
||||
@@ -299,8 +354,8 @@ word_wrap <- function(...,
|
||||
msg <- paste0(msg, collapse = " ")
|
||||
msg <- gsub("\n ", "\n", msg, fixed = TRUE)
|
||||
|
||||
if (msg_stripped %like% "^NOTE: ") {
|
||||
indentation <- 6 + extra_indent
|
||||
if (msg_stripped %like% "\u2139 ") {
|
||||
indentation <- 2 + extra_indent
|
||||
} else if (msg_stripped %like% "^=> ") {
|
||||
indentation <- 3 + extra_indent
|
||||
} else {
|
||||
@@ -504,8 +559,8 @@ format_class <- function(class, plural) {
|
||||
if ("matrix" %in% class) {
|
||||
class <- "a matrix"
|
||||
}
|
||||
if ("isolate_identifier" %in% class) {
|
||||
class <- "created with isolate_identifier()"
|
||||
if ("custom_eucast_rules" %in% class) {
|
||||
class <- "input created with `custom_eucast_rules()`"
|
||||
}
|
||||
if (any(c("mo", "ab", "rsi") %in% class)) {
|
||||
class <- paste0("of class <", class[1L], ">")
|
||||
@@ -522,6 +577,7 @@ meet_criteria <- function(object,
|
||||
looks_like = NULL,
|
||||
is_in = NULL,
|
||||
is_positive = NULL,
|
||||
is_positive_or_zero = NULL,
|
||||
is_finite = NULL,
|
||||
contains_column_class = NULL,
|
||||
allow_NULL = FALSE,
|
||||
@@ -590,16 +646,23 @@ meet_criteria <- function(object,
|
||||
ifelse(allow_NA == TRUE, ", or NA", ""),
|
||||
call = call_depth)
|
||||
}
|
||||
if (!is.null(is_positive)) {
|
||||
if (isTRUE(is_positive)) {
|
||||
stop_if(is.numeric(object) && !all(object > 0, na.rm = TRUE), "argument `", obj_name,
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"be a positive number",
|
||||
"all be positive numbers"),
|
||||
" (higher than zero)",
|
||||
"be a number higher than zero",
|
||||
"all be numbers higher than zero"),
|
||||
call = call_depth)
|
||||
}
|
||||
if (!is.null(is_finite)) {
|
||||
if (isTRUE(is_positive_or_zero)) {
|
||||
stop_if(is.numeric(object) && !all(object >= 0, na.rm = TRUE), "argument `", obj_name,
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
"be zero or a positive number",
|
||||
"all be zero or numbers higher than zero"),
|
||||
call = call_depth)
|
||||
}
|
||||
if (isTRUE(is_finite)) {
|
||||
stop_if(is.numeric(object) && !all(is.finite(object[!is.na(object)]), na.rm = TRUE), "argument `", obj_name,
|
||||
"` must ",
|
||||
ifelse(!is.null(has_length) && length(has_length) == 1 && has_length == 1,
|
||||
@@ -633,7 +696,7 @@ get_current_data <- function(arg_name, call) {
|
||||
return(out)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2) {
|
||||
# R-3.0 and R-3.1 do not have an `x` element in the call stack, rendering this function useless
|
||||
if (is.na(arg_name)) {
|
||||
@@ -641,6 +704,7 @@ get_current_data <- function(arg_name, call) {
|
||||
warning_("this function can only be used in R >= 3.2", call = call)
|
||||
return(data.frame())
|
||||
} else {
|
||||
# mimic a default R error, e.g. for example_isolates[which(mo_name() %like% "^ent"), ]
|
||||
stop_("argument `", arg_name, "` is missing with no default", call = call)
|
||||
}
|
||||
}
|
||||
@@ -650,12 +714,17 @@ get_current_data <- function(arg_name, call) {
|
||||
frms <- lapply(sys.frames(), function(el) {
|
||||
if (not_set == TRUE && ".Generic" %in% names(el)) {
|
||||
if (tryCatch(".data" %in% names(el) && is.data.frame(el$`.data`), error = function(e) FALSE)) {
|
||||
# dplyr? - an element `.data` will be in the system call stack
|
||||
# will be used in dplyr::select() (but not in dplyr::filter(), dplyr::mutate() or dplyr::summarise())
|
||||
# - - - -
|
||||
# dplyr
|
||||
# - - - -
|
||||
# an element `.data` will be in the system call stack when using dplyr::select()
|
||||
# [but not when using dplyr::filter(), dplyr::mutate() or dplyr::summarise()]
|
||||
not_set <<- FALSE
|
||||
el$`.data`
|
||||
} else if (tryCatch(any(c("x", "xx") %in% names(el)), error = function(e) FALSE)) {
|
||||
# otherwise try base R:
|
||||
# - - - -
|
||||
# base R
|
||||
# - - - -
|
||||
# an element `x` will be in this environment for only cols, e.g. `example_isolates[, carbapenems()]`
|
||||
# an element `xx` will be in this environment for rows + cols, e.g. `example_isolates[c(1:3), carbapenems()]`
|
||||
if (tryCatch(is.data.frame(el$xx), error = function(e) FALSE)) {
|
||||
@@ -675,6 +744,7 @@ get_current_data <- function(arg_name, call) {
|
||||
}
|
||||
})
|
||||
|
||||
# lookup the matched frame and return its value: a data.frame
|
||||
vars_df <- tryCatch(frms[[which(!vapply(FUN.VALUE = logical(1), frms, is.null))]], error = function(e) NULL)
|
||||
if (is.data.frame(vars_df)) {
|
||||
return(vars_df)
|
||||
@@ -913,8 +983,8 @@ font_stripstyle <- function(x) {
|
||||
gsub("(?:(?:\\x{001b}\\[)|\\x{009b})(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\\x{001b}[A-M]", "", x, perl = TRUE)
|
||||
}
|
||||
|
||||
progress_ticker <- function(n = 1, n_min = 0, ...) {
|
||||
if (!interactive() || n < n_min) {
|
||||
progress_ticker <- function(n = 1, n_min = 0, print = TRUE, ...) {
|
||||
if (print == FALSE || n < n_min) {
|
||||
pb <- list()
|
||||
pb$tick <- function() {
|
||||
invisible()
|
||||
@@ -1087,8 +1157,8 @@ time_track <- function(name = NULL) {
|
||||
paste("(until now:", trimws(round(as.numeric(Sys.time()) * 1000) - pkg_env$time_start), "ms)")
|
||||
}
|
||||
|
||||
# prevent dependency on package 'backports'
|
||||
# these functions were not available in previous versions of R (last checked: R 4.0.3)
|
||||
# prevent dependency on package 'backports' ----
|
||||
# these functions were not available in previous versions of R (last checked: R 4.0.5)
|
||||
# see here for the full list: https://github.com/r-lib/backports
|
||||
strrep <- function(x, times) {
|
||||
x <- as.character(x)
|
||||
@@ -1135,3 +1205,11 @@ isNamespaceLoaded <- function(pkg) {
|
||||
lengths <- function(x, use.names = TRUE) {
|
||||
vapply(x, length, FUN.VALUE = NA_integer_, USE.NAMES = use.names)
|
||||
}
|
||||
|
||||
if (as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.1) {
|
||||
# R-3.0 does not contain these functions, set them here to prevent installation failure
|
||||
# (required for extension of the <mic> class)
|
||||
cospi <- function(...) 1
|
||||
sinpi <- function(...) 1
|
||||
tanpi <- function(...) 1
|
||||
}
|
||||
|
||||
8
R/ab.R
@@ -29,7 +29,7 @@
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x character vector to determine to antibiotic ID
|
||||
#' @param flag_multiple_results logical to indicate whether a note should be printed to the console that probably more than one antibiotic code or name can be retrieved from a single input value.
|
||||
#' @param info logical to indicate whether a progress bar should be printed
|
||||
#' @param info a [logical] to indicate whether a progress bar should be printed, defaults to `TRUE` only in interactive mode
|
||||
#' @param ... arguments passed on to internal functions
|
||||
#' @rdname as.ab
|
||||
#' @inheritSection WHOCC WHOCC
|
||||
@@ -90,7 +90,7 @@
|
||||
#' rename_with(as.ab, where(is.rsi))
|
||||
#'
|
||||
#' }
|
||||
as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
||||
as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
||||
meet_criteria(x, allow_class = c("character", "numeric", "integer", "factor"), allow_NA = TRUE)
|
||||
meet_criteria(flag_multiple_results, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
@@ -155,7 +155,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
||||
}
|
||||
|
||||
if (initial_search == TRUE) {
|
||||
progress <- progress_ticker(n = length(x), n_min = ifelse(isTRUE(info), 25, length(x) + 1)) # start if n >= 25
|
||||
progress <- progress_ticker(n = length(x), n_min = 25, print = info) # start if n >= 25
|
||||
on.exit(close(progress))
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
||||
|
||||
# first 5 except for cephalosporins, then first 7 (those cephalosporins all start quite the same!)
|
||||
found <- suppressWarnings(as.ab(substr(x[i], 1, 5), initial_search = FALSE))
|
||||
if (!is.na(found) && !ab_group(found, initial_search = FALSE) %like% "cephalosporins") {
|
||||
if (!is.na(found) && ab_group(found, initial_search = FALSE) %unlike% "cephalosporins") {
|
||||
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
|
||||
next
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#' @param collapse character to pass on to `paste(, collapse = ...)` to only return one character per element of `text`, see *Examples*
|
||||
#' @param translate_ab if `type = "drug"`: a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]. Defaults to `FALSE`. Using `TRUE` is equal to using "name".
|
||||
#' @param thorough_search logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to `TRUE` will take considerably more time than when using `FALSE`. At default, it will turn `TRUE` when all input elements contain a maximum of three words.
|
||||
#' @param info logical to indicate whether a progress bar should be printed, defaults to `TRUE` only in interactive mode
|
||||
#' @param ... arguments passed on to [as.ab()]
|
||||
#' @details This function is also internally used by [as.ab()], although it then only searches for the first drug name and will throw a note if more drug names could have been returned. Note: the [as.ab()] function may use very long regular expression to match brand names of antimicrobial agents. This may fail on some systems.
|
||||
#'
|
||||
@@ -92,6 +93,7 @@ ab_from_text <- function(text,
|
||||
collapse = NULL,
|
||||
translate_ab = FALSE,
|
||||
thorough_search = NULL,
|
||||
info = interactive(),
|
||||
...) {
|
||||
if (missing(type)) {
|
||||
type <- type[1L]
|
||||
@@ -102,12 +104,13 @@ ab_from_text <- function(text,
|
||||
meet_criteria(collapse, has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(translate_ab, allow_NULL = FALSE) # get_translate_ab() will be more informative about what's allowed
|
||||
meet_criteria(thorough_search, allow_class = "logical", has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
|
||||
type <- tolower(trimws(type))
|
||||
|
||||
text <- tolower(as.character(text))
|
||||
text_split_all <- strsplit(text, "[ ;.,:\\|]")
|
||||
progress <- progress_ticker(n = length(text_split_all), n_min = 5)
|
||||
progress <- progress_ticker(n = length(text_split_all), n_min = 5, print = info)
|
||||
on.exit(close(progress))
|
||||
|
||||
if (type %like% "(drug|ab|anti)") {
|
||||
|
||||
4
R/age.R
@@ -149,8 +149,8 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
|
||||
#' }
|
||||
#' }
|
||||
age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
|
||||
meet_criteria(x, allow_class = c("numeric", "integer"), is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(split_at, allow_class = c("numeric", "integer", "character"), is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(x, allow_class = c("numeric", "integer"), is_positive_or_zero = TRUE, is_finite = TRUE)
|
||||
meet_criteria(split_at, allow_class = c("numeric", "integer", "character"), is_positive_or_zero = TRUE, is_finite = TRUE)
|
||||
meet_criteria(na.rm, allow_class = "logical", has_length = 1)
|
||||
|
||||
if (any(x < 0, na.rm = TRUE)) {
|
||||
|
||||
306
R/custom_eucast_rules.R
Normal file
@@ -0,0 +1,306 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Data Analysis for R #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# We created this package for both routine data analysis and academic #
|
||||
# research and it was publicly released in the hope that it will be #
|
||||
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
||||
# #
|
||||
# Visit our website for the full manual and a complete tutorial about #
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Define Custom EUCAST Rules
|
||||
#'
|
||||
#' Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in [eucast_rules()].
|
||||
#' @inheritSection lifecycle Maturing Lifecycle
|
||||
#' @param ... rules in formula notation, see *Examples*
|
||||
#' @details
|
||||
#' Some organisations have their own adoption of EUCAST rules. This function can be used to define custom EUCAST rules to be used in the [eucast_rules()] function.
|
||||
#'
|
||||
#' @section How it works:
|
||||
#'
|
||||
#' ### Basics
|
||||
#'
|
||||
#' If you are familiar with the [`case_when()`][dplyr::case_when()] function of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation'. The rule itself is written *before* the tilde (`~`) and the consequence of the rule is written *after* the tilde:
|
||||
#'
|
||||
#' ```
|
||||
#' x <- custom_eucast_rules(TZP == "S" ~ aminopenicillins == "S",
|
||||
#' TZP == "R" ~ aminopenicillins == "R")
|
||||
#' ```
|
||||
#'
|
||||
#' These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work:
|
||||
#'
|
||||
#' ```
|
||||
#' x
|
||||
#' #> A set of custom EUCAST rules:
|
||||
#' #>
|
||||
#' #> 1. If TZP is S then set to S:
|
||||
#' #> amoxicillin (AMX), ampicillin (AMP)
|
||||
#' #>
|
||||
#' #> 2. If TZP is R then set to R:
|
||||
#' #> amoxicillin (AMX), ampicillin (AMP)
|
||||
#' ```
|
||||
#'
|
||||
#' The rules (the part *before* the tilde, in above example `TZP == "S"` and `TZP == "R"`) must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column `TZP` must exist. We will create a sample data set and test the rules set:
|
||||
#'
|
||||
#' ```
|
||||
#' df <- data.frame(mo = c("E. coli", "K. pneumoniae"),
|
||||
#' TZP = "R",
|
||||
#' amox = "",
|
||||
#' AMP = "")
|
||||
#' df
|
||||
#' #> mo TZP amox AMP
|
||||
#' #> 1 E. coli R
|
||||
#' #> 2 K. pneumoniae R
|
||||
#'
|
||||
#' eucast_rules(df, rules = "custom", custom_rules = x)
|
||||
#' #> mo TZP amox AMP
|
||||
#' #> 1 E. coli R R R
|
||||
#' #> 2 K. pneumoniae R R R
|
||||
#' ```
|
||||
#'
|
||||
#' ### Using taxonomic properties in rules
|
||||
#'
|
||||
#' There is one exception in variables used for the rules: all column names of the [microorganisms] data set can also be used, but do not have to exist in the data set. These column names are: `r vector_and(colnames(microorganisms), quote = "``", sort = FALSE)`. Thus, this next example will work as well, despite the fact that the `df` data set does not contain a column `genus`:
|
||||
#'
|
||||
#' ```
|
||||
#' y <- custom_eucast_rules(TZP == "S" & genus == "Klebsiella" ~ aminopenicillins == "S",
|
||||
#' TZP == "R" & genus == "Klebsiella" ~ aminopenicillins == "R")
|
||||
#'
|
||||
#' eucast_rules(df, rules = "custom", custom_rules = y)
|
||||
#' #> mo TZP amox AMP
|
||||
#' #> 1 E. coli R
|
||||
#' #> 2 K. pneumoniae R R R
|
||||
#' ```
|
||||
#'
|
||||
#' ### Usage of antibiotic group names
|
||||
#'
|
||||
#' It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part *after* the tilde. In above examples, the antibiotic group `aminopenicillins` is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the antibiotic agents that will be matched when running the rule.
|
||||
#'
|
||||
#' `r paste0(" * ", sapply(DEFINED_AB_GROUPS, function(x) paste0("``", tolower(x), "``\\cr(", paste0(sort(ab_name(eval(parse(text = x), envir = asNamespace("AMR")), language = NULL, tolower = TRUE)), collapse = ", "), ")"), USE.NAMES = FALSE), "\n", collapse = "")`
|
||||
#' @returns A [list] containing the custom rules
|
||||
#' @export
|
||||
#' @examples
|
||||
#' x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||
#' AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
|
||||
#' eucast_rules(example_isolates,
|
||||
#' rules = "custom",
|
||||
#' custom_rules = x,
|
||||
#' info = FALSE)
|
||||
#'
|
||||
#' # combine rule sets
|
||||
#' x2 <- c(x,
|
||||
#' custom_eucast_rules(TZP == "R" ~ carbapenems == "R"))
|
||||
#' x2
|
||||
custom_eucast_rules <- function(...) {
|
||||
|
||||
dots <- tryCatch(list(...),
|
||||
error = function(e) "error")
|
||||
stop_if(identical(dots, "error"),
|
||||
"rules must be a valid formula inputs (e.g., using '~'), see `?custom_eucast_rules`")
|
||||
n_dots <- length(dots)
|
||||
stop_if(n_dots == 0, "no custom rules were set. Please read the documentation using `?custom_eucast_rules`.")
|
||||
out <- vector("list", n_dots)
|
||||
for (i in seq_len(n_dots)) {
|
||||
stop_ifnot(inherits(dots[[i]], "formula"),
|
||||
"rule ", i, " must be a valid formula input (e.g., using '~'), see `?custom_eucast_rules`")
|
||||
|
||||
# Query
|
||||
qry <- dots[[i]][[2]]
|
||||
if (inherits(qry, "call")) {
|
||||
qry <- as.expression(qry)
|
||||
}
|
||||
qry <- as.character(qry)
|
||||
# these will prevent vectorisation, so replace them:
|
||||
qry <- gsub("&&", "&", qry, fixed = TRUE)
|
||||
qry <- gsub("||", "|", qry, fixed = TRUE)
|
||||
# format nicely, setting spaces around operators
|
||||
qry <- gsub(" *([&|+-/*^><==]+) *", " \\1 ", qry)
|
||||
qry <- gsub(" ?, ?", ", ", qry)
|
||||
qry <- gsub("'", "\"", qry, fixed = TRUE)
|
||||
out[[i]]$query <- as.expression(qry)
|
||||
|
||||
# Resulting rule
|
||||
result <- dots[[i]][[3]]
|
||||
stop_ifnot(deparse(result) %like% "==",
|
||||
"the result of rule ", i, " (the part after the `~`) must contain `==`, such as in `... ~ ampicillin == \"R\"`, see `?custom_eucast_rules`")
|
||||
result_group <- as.character(result)[[2]]
|
||||
if (paste0(toupper(result_group), "S") %in% DEFINED_AB_GROUPS) {
|
||||
# support for e.g. 'aminopenicillin' if user meant 'aminopenicillins'
|
||||
result_group <- paste0(result_group, "s")
|
||||
}
|
||||
if (toupper(result_group) %in% DEFINED_AB_GROUPS) {
|
||||
result_group <- eval(parse(text = toupper(result_group)), envir = asNamespace("AMR"))
|
||||
} else {
|
||||
result_group <- tryCatch(
|
||||
suppressWarnings(as.ab(result_group,
|
||||
fast_mode = TRUE,
|
||||
info = FALSE,
|
||||
flag_multiple_results = FALSE)),
|
||||
error = function(e) NA_character_)
|
||||
}
|
||||
|
||||
stop_if(any(is.na(result_group)),
|
||||
"this result of rule ", i, " could not be translated to a single antimicrobial agent/group: \"",
|
||||
as.character(result)[[2]], "\".\n\nThe input can be a name or code of an antimicrobial agent, or be one of: ",
|
||||
vector_or(tolower(DEFINED_AB_GROUPS), quotes = FALSE), ".")
|
||||
result_value <- as.character(result)[[3]]
|
||||
result_value[result_value == "NA"] <- NA
|
||||
stop_ifnot(result_value %in% c("R", "S", "I", NA),
|
||||
"the resulting value of rule ", i, " must be either \"R\", \"S\", \"I\" or NA")
|
||||
result_value <- as.rsi(result_value)
|
||||
|
||||
out[[i]]$result_group <- result_group
|
||||
out[[i]]$result_value <- result_value
|
||||
}
|
||||
|
||||
names(out) <- paste0("rule", seq_len(n_dots))
|
||||
set_clean_class(out, new_class = c("custom_eucast_rules", "list"))
|
||||
}
|
||||
|
||||
#' @method c custom_eucast_rules
|
||||
#' @noRd
|
||||
#' @export
|
||||
c.custom_eucast_rules <- function(x, ...) {
|
||||
if (length(list(...)) == 0) {
|
||||
return(x)
|
||||
}
|
||||
out <- unclass(x)
|
||||
for (e in list(...)) {
|
||||
out <- c(out, unclass(e))
|
||||
}
|
||||
names(out) <- paste0("rule", seq_len(length(out)))
|
||||
set_clean_class(out, new_class = c("custom_eucast_rules", "list"))
|
||||
}
|
||||
|
||||
#' @method as.list custom_eucast_rules
|
||||
#' @noRd
|
||||
#' @export
|
||||
as.list.custom_eucast_rules <- function(x, ...) {
|
||||
c(x, ...)
|
||||
}
|
||||
|
||||
#' @method print custom_eucast_rules
|
||||
#' @export
|
||||
#' @noRd
|
||||
print.custom_eucast_rules <- function(x, ...) {
|
||||
cat("A set of custom EUCAST rules:\n")
|
||||
for (i in seq_len(length(x))) {
|
||||
rule <- x[[i]]
|
||||
rule$query <- format_custom_query_rule(rule$query)
|
||||
if (rule$result_value == "R") {
|
||||
val <- font_rsi_R_bg(font_black(" R "))
|
||||
} else if (rule$result_value == "S") {
|
||||
val <- font_rsi_S_bg(font_black(" S "))
|
||||
} else {
|
||||
val <- font_rsi_I_bg(font_black(" I "))
|
||||
}
|
||||
agents <- paste0(font_blue(ab_name(rule$result_group, language = NULL, tolower = TRUE),
|
||||
collapse = NULL),
|
||||
" (", rule$result_group, ")")
|
||||
agents <- sort(agents)
|
||||
rule_if <- word_wrap(paste0(i, ". ", font_bold("If "), font_blue(rule$query), font_bold(" then "),
|
||||
"set to {result}:"),
|
||||
extra_indent = 5)
|
||||
rule_if <- gsub("{result}", val, rule_if, fixed = TRUE)
|
||||
rule_then <- paste0(" ", word_wrap(paste0(agents, collapse = ", "), extra_indent = 5))
|
||||
cat("\n ", rule_if, "\n", rule_then, "\n", sep = "")
|
||||
}
|
||||
}
|
||||
|
||||
run_custom_eucast_rules <- function(df, rule, info) {
|
||||
n_dots <- length(rule)
|
||||
stop_if(n_dots == 0, "no custom rules set", call = -2)
|
||||
out <- character(length = NROW(df))
|
||||
reasons <- character(length = NROW(df))
|
||||
for (i in seq_len(n_dots)) {
|
||||
qry <- tryCatch(eval(parse(text = rule[[i]]$query), envir = df, enclos = parent.frame()),
|
||||
error = function(e) {
|
||||
pkg_env$err_msg <- e$message
|
||||
return("error")
|
||||
})
|
||||
if (identical(qry, "error")) {
|
||||
warning_("in custom_eucast_rules(): rule ", i,
|
||||
" (`", as.character(rule[[i]]$query), "`) was ignored because of this error message: ",
|
||||
pkg_env$err_msg,
|
||||
call = FALSE,
|
||||
add_fn = font_red)
|
||||
next
|
||||
}
|
||||
stop_ifnot(is.logical(qry), "in custom_eucast_rules(): rule ", i, " (`", rule[[i]]$query,
|
||||
"`) must return `TRUE` or `FALSE`, not ",
|
||||
format_class(class(qry), plural = FALSE), call = FALSE)
|
||||
|
||||
new_eucasts <- which(qry == TRUE & out == "")
|
||||
|
||||
if (info == TRUE) {
|
||||
cat(word_wrap("- Custom EUCAST rule ", i, ": `", as.character(rule[[i]]$query),
|
||||
"` (", length(new_eucasts), " rows matched)"), "\n", sep = "")
|
||||
}
|
||||
val <- rule[[i]]$value
|
||||
out[new_eucasts] <- val
|
||||
reasons[new_eucasts] <- paste0("matched rule ", gsub("rule", "", names(rule)[i]), ": ", as.character(rule[[i]]$query))
|
||||
}
|
||||
out[out == ""] <- "Negative"
|
||||
reasons[out == "Negative"] <- "no rules matched"
|
||||
|
||||
if (isTRUE(attributes(rule)$as_factor)) {
|
||||
out <- factor(out, levels = attributes(rule)$values, ordered = TRUE)
|
||||
}
|
||||
|
||||
columns_nonsusceptible <- as.data.frame(t(df[, is.rsi(df)] == "R"))
|
||||
columns_nonsusceptible <- vapply(FUN.VALUE = character(1),
|
||||
columns_nonsusceptible,
|
||||
function(x) paste0(rownames(columns_nonsusceptible)[which(x)], collapse = " "))
|
||||
columns_nonsusceptible[is.na(out)] <- NA_character_
|
||||
|
||||
data.frame(row_number = seq_len(NROW(df)),
|
||||
EUCAST = out,
|
||||
reason = reasons,
|
||||
columns_nonsusceptible = columns_nonsusceptible,
|
||||
stringsAsFactors = FALSE)
|
||||
}
|
||||
|
||||
format_custom_query_rule <- function(query, colours = has_colour()) {
|
||||
query <- gsub(" & ", font_black(font_bold(" and ")), query, fixed = TRUE)
|
||||
query <- gsub(" | ", font_black(" or "), query, fixed = TRUE)
|
||||
query <- gsub(" + ", font_black(" plus "), query, fixed = TRUE)
|
||||
query <- gsub(" - ", font_black(" minus "), query, fixed = TRUE)
|
||||
query <- gsub(" / ", font_black(" divided by "), query, fixed = TRUE)
|
||||
query <- gsub(" * ", font_black(" times "), query, fixed = TRUE)
|
||||
query <- gsub(" == ", font_black(" is "), query, fixed = TRUE)
|
||||
query <- gsub(" > ", font_black(" is higher than "), query, fixed = TRUE)
|
||||
query <- gsub(" < ", font_black(" is lower than "), query, fixed = TRUE)
|
||||
query <- gsub(" >= ", font_black(" is higher than or equal to "), query, fixed = TRUE)
|
||||
query <- gsub(" <= ", font_black(" is lower than or equal to "), query, fixed = TRUE)
|
||||
query <- gsub(" ^ ", font_black(" to the power of "), query, fixed = TRUE)
|
||||
query <- gsub(" %in% ", font_black(" is one of "), query, fixed = TRUE)
|
||||
query <- gsub(" %like% ", font_black(" resembles "), query, fixed = TRUE)
|
||||
if (colours == TRUE) {
|
||||
query <- gsub('"R"', font_rsi_R_bg(font_black(" R ")), query, fixed = TRUE)
|
||||
query <- gsub('"S"', font_rsi_S_bg(font_black(" S ")), query, fixed = TRUE)
|
||||
query <- gsub('"I"', font_rsi_I_bg(font_black(" I ")), query, fixed = TRUE)
|
||||
}
|
||||
# replace the black colour 'stops' with blue colour 'starts'
|
||||
query <- gsub("\033[39m", "\033[34m", as.character(query), fixed = TRUE)
|
||||
# start with blue
|
||||
query <- paste0("\033[34m", query)
|
||||
if (colours == FALSE) {
|
||||
query <- font_stripstyle(query)
|
||||
}
|
||||
query
|
||||
}
|
||||
2
R/data.R
@@ -98,7 +98,7 @@
|
||||
#' @details
|
||||
#' Please note that entries are only based on the Catalogue of Life and the LPSN (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect.
|
||||
#'
|
||||
#' For example, *Staphylococcus pettenkoferi* was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the AMR package returns 2007 for `mo_year("S. pettenkoferi")`.
|
||||
#' For example, *Staphylococcus pettenkoferi* was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the `AMR` package returns 2007 for `mo_year("S. pettenkoferi")`.
|
||||
#'
|
||||
#' ## Manual additions
|
||||
#' For convenience, some entries were added manually:
|
||||
|
||||
@@ -45,3 +45,96 @@ p_symbol <- function(p, emptychar = " ") {
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
filter_first_weighted_isolate <- function(x = NULL,
|
||||
col_date = NULL,
|
||||
col_patient_id = NULL,
|
||||
col_mo = NULL,
|
||||
...) {
|
||||
|
||||
.Deprecated(old = "filter_first_weighted_isolate()",
|
||||
new = "filter_first_isolate()",
|
||||
package = "AMR")
|
||||
|
||||
if (is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
# is also fix for using a grouped df as input (a dot as first argument)
|
||||
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||
}
|
||||
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
||||
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
|
||||
filter_first_isolate(x = x, col_date = col_date, col_patient_id = col_patient_id, col_mo = col_mo, ...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
key_antibiotics <- function(x = NULL,
|
||||
col_mo = NULL,
|
||||
universal_1 = guess_ab_col(x, "amoxicillin"),
|
||||
universal_2 = guess_ab_col(x, "amoxicillin/clavulanic acid"),
|
||||
universal_3 = guess_ab_col(x, "cefuroxime"),
|
||||
universal_4 = guess_ab_col(x, "piperacillin/tazobactam"),
|
||||
universal_5 = guess_ab_col(x, "ciprofloxacin"),
|
||||
universal_6 = guess_ab_col(x, "trimethoprim/sulfamethoxazole"),
|
||||
GramPos_1 = guess_ab_col(x, "vancomycin"),
|
||||
GramPos_2 = guess_ab_col(x, "teicoplanin"),
|
||||
GramPos_3 = guess_ab_col(x, "tetracycline"),
|
||||
GramPos_4 = guess_ab_col(x, "erythromycin"),
|
||||
GramPos_5 = guess_ab_col(x, "oxacillin"),
|
||||
GramPos_6 = guess_ab_col(x, "rifampin"),
|
||||
GramNeg_1 = guess_ab_col(x, "gentamicin"),
|
||||
GramNeg_2 = guess_ab_col(x, "tobramycin"),
|
||||
GramNeg_3 = guess_ab_col(x, "colistin"),
|
||||
GramNeg_4 = guess_ab_col(x, "cefotaxime"),
|
||||
GramNeg_5 = guess_ab_col(x, "ceftazidime"),
|
||||
GramNeg_6 = guess_ab_col(x, "meropenem"),
|
||||
warnings = TRUE,
|
||||
...) {
|
||||
|
||||
.Deprecated(old = "key_antibiotics()",
|
||||
new = "key_antimicrobials()",
|
||||
package = "AMR")
|
||||
|
||||
if (is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
# is also fix for using a grouped df as input (a dot as first argument)
|
||||
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||
}
|
||||
|
||||
key_antimicrobials(x = x,
|
||||
col_mo = col_mo,
|
||||
universal = c(universal_1, universal_2, universal_3, universal_4, universal_5, universal_6),
|
||||
gram_negative = c(GramNeg_1, GramNeg_2, GramNeg_3, GramNeg_4, GramNeg_5, GramNeg_6),
|
||||
gram_positive = c(GramPos_1, GramPos_2, GramPos_3, GramPos_4, GramPos_5, GramPos_6),
|
||||
antifungal = NULL,
|
||||
only_rsi_columns = FALSE,
|
||||
...)
|
||||
}
|
||||
|
||||
#' @name AMR-deprecated
|
||||
#' @export
|
||||
key_antibiotics_equal <- function(y,
|
||||
z,
|
||||
type = "keyantimicrobials",
|
||||
ignore_I = TRUE,
|
||||
points_threshold = 2,
|
||||
info = FALSE,
|
||||
na.rm = TRUE,
|
||||
...) {
|
||||
|
||||
.Deprecated(old = "key_antibiotics_equal()",
|
||||
new = "antimicrobials_equal()",
|
||||
package = "AMR")
|
||||
|
||||
antimicrobials_equal(y = y,
|
||||
z = z,
|
||||
type = type,
|
||||
ignore_I = ignore_I,
|
||||
points_threshold = points_threshold,
|
||||
info = info)
|
||||
}
|
||||
|
||||
21
R/episode.R
@@ -28,14 +28,14 @@
|
||||
#' These functions determine which items in a vector can be considered (the start of) a new episode, based on the argument `episode_days`. This can be used to determine clinical episodes for any epidemiological analysis. The [get_episode()] function returns the index number of the episode per group, while the [is_new_episode()] function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x vector of dates (class `Date` or `POSIXt`)
|
||||
#' @param episode_days required episode length in days, can also be less than a day, see *Details*
|
||||
#' @param ... currently not used
|
||||
#' @param episode_days required episode length in days, can also be less than a day or `Inf`, see *Details*
|
||||
#' @param ... ignored, only in place to allow future extensions
|
||||
#' @details
|
||||
#' Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least `episode_days` days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least `episode_days` days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.
|
||||
#'
|
||||
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but is more efficient for data sets containing microorganism codes or names.
|
||||
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but is more efficient for data sets containing microorganism codes or names and allows for different isolate selection methods.
|
||||
#'
|
||||
#' The `dplyr` package is not required for these functions to work, but these functions support [variable grouping][dplyr::group_by()] and work conveniently inside `dplyr` verbs such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()].
|
||||
#' The `dplyr` package is not required for these functions to work, but these functions do support [variable grouping][dplyr::group_by()] and work conveniently inside `dplyr` verbs such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()].
|
||||
#' @return
|
||||
#' * [get_episode()]: a [double] vector
|
||||
#' * [is_new_episode()]: a [logical] vector
|
||||
@@ -85,10 +85,11 @@
|
||||
#' n_episodes_30 = sum(is_new_episode(date, episode_days = 30)))
|
||||
#'
|
||||
#'
|
||||
#' # grouping on patients and microorganisms leads to the same results
|
||||
#' # as first_isolate():
|
||||
#' # grouping on patients and microorganisms leads to the same
|
||||
#' # results as first_isolate() when using 'episode-based':
|
||||
#' x <- example_isolates %>%
|
||||
#' filter(first_isolate(., include_unknown = TRUE))
|
||||
#' filter_first_isolate(include_unknown = TRUE,
|
||||
#' method = "episode-based")
|
||||
#'
|
||||
#' y <- example_isolates %>%
|
||||
#' group_by(patient_id, mo) %>%
|
||||
@@ -105,7 +106,7 @@
|
||||
#' }
|
||||
get_episode <- function(x, episode_days, ...) {
|
||||
meet_criteria(x, allow_class = c("Date", "POSIXt"))
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||
|
||||
exec_episode(type = "sequential",
|
||||
x = x,
|
||||
@@ -117,7 +118,7 @@ get_episode <- function(x, episode_days, ...) {
|
||||
#' @export
|
||||
is_new_episode <- function(x, episode_days, ...) {
|
||||
meet_criteria(x, allow_class = c("Date", "POSIXt"))
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||
|
||||
exec_episode(type = "logical",
|
||||
x = x,
|
||||
@@ -126,7 +127,7 @@ is_new_episode <- function(x, episode_days, ...) {
|
||||
}
|
||||
|
||||
exec_episode <- function(type, x, episode_days, ...) {
|
||||
x <- as.double(as.POSIXct(x)) # as.POSIXct() for Date classes
|
||||
x <- as.double(as.POSIXct(x)) # as.POSIXct() required for Date classes
|
||||
# since x is now in seconds, get seconds from episode_days as well
|
||||
episode_seconds <- episode_days * 60 * 60 * 24
|
||||
|
||||
|
||||
512
R/eucast_rules.R
@@ -51,7 +51,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x data with antibiotic columns, such as `amox`, `AMX` and `AMC`
|
||||
#' @param info a logical to indicate whether progress should be printed to the console, defaults to only print while in interactive sessions
|
||||
#' @param rules a character vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`.
|
||||
#' @param rules a character vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"custom"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`. If using `"custom"`, be sure to fill in argument `custom_rules` too. Custom rules can be created with [custom_eucast_rules()].
|
||||
#' @param verbose a [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way. Using Verbose mode takes a lot more time.
|
||||
#' @param version_breakpoints the version number to use for the EUCAST Clinical Breakpoints guideline. Can be either `r vector_or(names(EUCAST_VERSION_BREAKPOINTS), reverse = TRUE)`.
|
||||
#' @param version_expertrules the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be either `r vector_or(names(EUCAST_VERSION_EXPERT_RULES), reverse = TRUE)`.
|
||||
@@ -60,12 +60,26 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
|
||||
#' @param ab any (vector of) text that can be coerced to a valid antibiotic code with [as.ab()]
|
||||
#' @param administration route of administration, either `r vector_or(dosage$administration)`
|
||||
#' @param only_rsi_columns a logical to indicate whether only antibiotic columns must be detected that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @param custom_rules custom rules to apply, created with [custom_eucast_rules()]
|
||||
#' @inheritParams first_isolate
|
||||
#' @details
|
||||
#' **Note:** This function does not translate MIC values to RSI values. Use [as.rsi()] for that. \cr
|
||||
#' **Note:** When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance.
|
||||
#' **Note:** When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance. \cr
|
||||
|
||||
#'
|
||||
#' The file containing all EUCAST rules is located here: <https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv>.
|
||||
#' The file containing all EUCAST rules is located here: <https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv>. **Note:** Old taxonomic names are replaced with the current taxonomy where applicable. For example, *Ochrobactrum anthropi* was renamed to *Brucella anthropi* in 2020; the original EUCAST rules v3.1 and v3.2 did not yet contain this new taxonomic name. The file used as input for this `AMR` package contains the taxonomy updated until [`r CATALOGUE_OF_LIFE$yearmonth_LPSN`][catalogue_of_life()].
|
||||
#'
|
||||
#' ## Custom Rules
|
||||
#'
|
||||
#' Custom rules can be created using [custom_eucast_rules()], e.g.:
|
||||
#'
|
||||
#' ```
|
||||
#' x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||
#' AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
|
||||
#'
|
||||
#' eucast_rules(example_isolates, rules = "custom", custom_rules = x)
|
||||
#' ```
|
||||
#'
|
||||
#'
|
||||
#' ## 'Other' Rules
|
||||
#'
|
||||
@@ -149,19 +163,34 @@ eucast_rules <- function(x,
|
||||
version_expertrules = 3.2,
|
||||
ampc_cephalosporin_resistance = NA,
|
||||
only_rsi_columns = FALSE,
|
||||
custom_rules = NULL,
|
||||
...) {
|
||||
meet_criteria(x, allow_class = "data.frame")
|
||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, is_in = colnames(x), allow_NULL = TRUE)
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(rules, allow_class = "character", has_length = c(1, 2, 3, 4), is_in = c("breakpoints", "expert", "other", "all"))
|
||||
meet_criteria(rules, allow_class = "character", has_length = c(1, 2, 3, 4, 5), is_in = c("breakpoints", "expert", "other", "all", "custom"))
|
||||
meet_criteria(verbose, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(version_breakpoints, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_BREAKPOINTS)))
|
||||
meet_criteria(version_expertrules, allow_class = c("numeric", "integer"), has_length = 1, is_in = as.double(names(EUCAST_VERSION_EXPERT_RULES)))
|
||||
meet_criteria(ampc_cephalosporin_resistance, allow_class = c("logical", "character", "rsi"), has_length = 1, allow_NA = TRUE, allow_NULL = TRUE)
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(custom_rules, allow_class = "custom_eucast_rules", allow_NULL = TRUE)
|
||||
|
||||
if ("custom" %in% rules & is.null(custom_rules)) {
|
||||
warning_("No custom rules were set with the `custom_rules` argument",
|
||||
call = FALSE,
|
||||
immediate = TRUE)
|
||||
rules <- rules[rules != "custom"]
|
||||
if (length(rules) == 0) {
|
||||
if (info == TRUE) {
|
||||
message_("No other rules were set, returning original data", add_fn = font_red, as_note = FALSE)
|
||||
}
|
||||
return(x)
|
||||
}
|
||||
}
|
||||
|
||||
x_deparsed <- deparse(substitute(x))
|
||||
if (length(x_deparsed) > 1 || !all(x_deparsed %like% "[a-z]+")) {
|
||||
if (length(x_deparsed) > 1 || any(x_deparsed %unlike% "[a-z]+")) {
|
||||
x_deparsed <- "your_data"
|
||||
}
|
||||
|
||||
@@ -196,8 +225,6 @@ eucast_rules <- function(x,
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo", info = info)
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
} else {
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
}
|
||||
|
||||
decimal.mark <- getOption("OutDec")
|
||||
@@ -263,238 +290,13 @@ eucast_rules <- function(x,
|
||||
info = info,
|
||||
only_rsi_columns = only_rsi_columns,
|
||||
...)
|
||||
|
||||
AMC <- cols_ab["AMC"]
|
||||
AMK <- cols_ab["AMK"]
|
||||
AMP <- cols_ab["AMP"]
|
||||
AMX <- cols_ab["AMX"]
|
||||
APL <- cols_ab["APL"]
|
||||
APX <- cols_ab["APX"]
|
||||
ATM <- cols_ab["ATM"]
|
||||
AVB <- cols_ab["AVB"]
|
||||
AVO <- cols_ab["AVO"]
|
||||
AZD <- cols_ab["AZD"]
|
||||
AZL <- cols_ab["AZL"]
|
||||
AZM <- cols_ab["AZM"]
|
||||
BAM <- cols_ab["BAM"]
|
||||
BPR <- cols_ab["BPR"]
|
||||
CAC <- cols_ab["CAC"]
|
||||
CAT <- cols_ab["CAT"]
|
||||
CAZ <- cols_ab["CAZ"]
|
||||
CCP <- cols_ab["CCP"]
|
||||
CCV <- cols_ab["CCV"]
|
||||
CCX <- cols_ab["CCX"]
|
||||
CDC <- cols_ab["CDC"]
|
||||
CDR <- cols_ab["CDR"]
|
||||
CDZ <- cols_ab["CDZ"]
|
||||
CEC <- cols_ab["CEC"]
|
||||
CED <- cols_ab["CED"]
|
||||
CEI <- cols_ab["CEI"]
|
||||
CEM <- cols_ab["CEM"]
|
||||
CEP <- cols_ab["CEP"]
|
||||
CFM <- cols_ab["CFM"]
|
||||
CFM1 <- cols_ab["CFM1"]
|
||||
CFP <- cols_ab["CFP"]
|
||||
CFR <- cols_ab["CFR"]
|
||||
CFS <- cols_ab["CFS"]
|
||||
CFZ <- cols_ab["CFZ"]
|
||||
CHE <- cols_ab["CHE"]
|
||||
CHL <- cols_ab["CHL"]
|
||||
CIC <- cols_ab["CIC"]
|
||||
CID <- cols_ab["CID"]
|
||||
CIP <- cols_ab["CIP"]
|
||||
CLI <- cols_ab["CLI"]
|
||||
CLM <- cols_ab["CLM"]
|
||||
CLO <- cols_ab["CLO"]
|
||||
CLR <- cols_ab["CLR"]
|
||||
CMX <- cols_ab["CMX"]
|
||||
CMZ <- cols_ab["CMZ"]
|
||||
CND <- cols_ab["CND"]
|
||||
COL <- cols_ab["COL"]
|
||||
CPD <- cols_ab["CPD"]
|
||||
CPI <- cols_ab["CPI"]
|
||||
CPL <- cols_ab["CPL"]
|
||||
CPM <- cols_ab["CPM"]
|
||||
CPO <- cols_ab["CPO"]
|
||||
CPR <- cols_ab["CPR"]
|
||||
CPT <- cols_ab["CPT"]
|
||||
CPX <- cols_ab["CPX"]
|
||||
CRB <- cols_ab["CRB"]
|
||||
CRD <- cols_ab["CRD"]
|
||||
CRN <- cols_ab["CRN"]
|
||||
CRO <- cols_ab["CRO"]
|
||||
CSL <- cols_ab["CSL"]
|
||||
CTB <- cols_ab["CTB"]
|
||||
CTC <- cols_ab["CTC"]
|
||||
CTF <- cols_ab["CTF"]
|
||||
CTL <- cols_ab["CTL"]
|
||||
CTS <- cols_ab["CTS"]
|
||||
CTT <- cols_ab["CTT"]
|
||||
CTX <- cols_ab["CTX"]
|
||||
CTZ <- cols_ab["CTZ"]
|
||||
CXM <- cols_ab["CXM"]
|
||||
CYC <- cols_ab["CYC"]
|
||||
CZA <- cols_ab["CZA"]
|
||||
CZD <- cols_ab["CZD"]
|
||||
CZO <- cols_ab["CZO"]
|
||||
CZP <- cols_ab["CZP"]
|
||||
CZX <- cols_ab["CZX"]
|
||||
DAL <- cols_ab["DAL"]
|
||||
DAP <- cols_ab["DAP"]
|
||||
DIC <- cols_ab["DIC"]
|
||||
DIR <- cols_ab["DIR"]
|
||||
DIT <- cols_ab["DIT"]
|
||||
DIX <- cols_ab["DIX"]
|
||||
DIZ <- cols_ab["DIZ"]
|
||||
DKB <- cols_ab["DKB"]
|
||||
DOR <- cols_ab["DOR"]
|
||||
DOX <- cols_ab["DOX"]
|
||||
ENX <- cols_ab["ENX"]
|
||||
EPC <- cols_ab["EPC"]
|
||||
ERY <- cols_ab["ERY"]
|
||||
ETP <- cols_ab["ETP"]
|
||||
FEP <- cols_ab["FEP"]
|
||||
FLC <- cols_ab["FLC"]
|
||||
FLE <- cols_ab["FLE"]
|
||||
FLR1 <- cols_ab["FLR1"]
|
||||
FOS <- cols_ab["FOS"]
|
||||
FOV <- cols_ab["FOV"]
|
||||
FOX <- cols_ab["FOX"]
|
||||
FOX1 <- cols_ab["FOX1"]
|
||||
FUS <- cols_ab["FUS"]
|
||||
GAT <- cols_ab["GAT"]
|
||||
GEM <- cols_ab["GEM"]
|
||||
GEN <- cols_ab["GEN"]
|
||||
GRX <- cols_ab["GRX"]
|
||||
HAP <- cols_ab["HAP"]
|
||||
HET <- cols_ab["HET"]
|
||||
IPM <- cols_ab["IPM"]
|
||||
ISE <- cols_ab["ISE"]
|
||||
JOS <- cols_ab["JOS"]
|
||||
KAN <- cols_ab["KAN"]
|
||||
LEN <- cols_ab["LEN"]
|
||||
LEX <- cols_ab["LEX"]
|
||||
LIN <- cols_ab["LIN"]
|
||||
LNZ <- cols_ab["LNZ"]
|
||||
LOM <- cols_ab["LOM"]
|
||||
LOR <- cols_ab["LOR"]
|
||||
LTM <- cols_ab["LTM"]
|
||||
LVX <- cols_ab["LVX"]
|
||||
MAN <- cols_ab["MAN"]
|
||||
MCM <- cols_ab["MCM"]
|
||||
MEC <- cols_ab["MEC"]
|
||||
MEM <- cols_ab["MEM"]
|
||||
MET <- cols_ab["MET"]
|
||||
MEV <- cols_ab["MEV"]
|
||||
MEZ <- cols_ab["MEZ"]
|
||||
MFX <- cols_ab["MFX"]
|
||||
MID <- cols_ab["MID"]
|
||||
MNO <- cols_ab["MNO"]
|
||||
MTM <- cols_ab["MTM"]
|
||||
NAC <- cols_ab["NAC"]
|
||||
NAF <- cols_ab["NAF"]
|
||||
NAL <- cols_ab["NAL"]
|
||||
NEO <- cols_ab["NEO"]
|
||||
NET <- cols_ab["NET"]
|
||||
NIT <- cols_ab["NIT"]
|
||||
NOR <- cols_ab["NOR"]
|
||||
NOV <- cols_ab["NOV"]
|
||||
NVA <- cols_ab["NVA"]
|
||||
OFX <- cols_ab["OFX"]
|
||||
OLE <- cols_ab["OLE"]
|
||||
ORI <- cols_ab["ORI"]
|
||||
OXA <- cols_ab["OXA"]
|
||||
PAZ <- cols_ab["PAZ"]
|
||||
PEF <- cols_ab["PEF"]
|
||||
PEN <- cols_ab["PEN"]
|
||||
PHE <- cols_ab["PHE"]
|
||||
PHN <- cols_ab["PHN"]
|
||||
PIP <- cols_ab["PIP"]
|
||||
PLB <- cols_ab["PLB"]
|
||||
PME <- cols_ab["PME"]
|
||||
PNM <- cols_ab["PNM"]
|
||||
PRC <- cols_ab["PRC"]
|
||||
PRI <- cols_ab["PRI"]
|
||||
PRL <- cols_ab["PRL"]
|
||||
PRP <- cols_ab["PRP"]
|
||||
PRU <- cols_ab["PRU"]
|
||||
PVM <- cols_ab["PVM"]
|
||||
QDA <- cols_ab["QDA"]
|
||||
RAM <- cols_ab["RAM"]
|
||||
RFL <- cols_ab["RFL"]
|
||||
RID <- cols_ab["RID"]
|
||||
RIF <- cols_ab["RIF"]
|
||||
ROK <- cols_ab["ROK"]
|
||||
RST <- cols_ab["RST"]
|
||||
RXT <- cols_ab["RXT"]
|
||||
SAM <- cols_ab["SAM"]
|
||||
SBC <- cols_ab["SBC"]
|
||||
SDI <- cols_ab["SDI"]
|
||||
SDM <- cols_ab["SDM"]
|
||||
SIS <- cols_ab["SIS"]
|
||||
SLF <- cols_ab["SLF"]
|
||||
SLF1 <- cols_ab["SLF1"]
|
||||
SLF10 <- cols_ab["SLF10"]
|
||||
SLF11 <- cols_ab["SLF11"]
|
||||
SLF12 <- cols_ab["SLF12"]
|
||||
SLF13 <- cols_ab["SLF13"]
|
||||
SLF2 <- cols_ab["SLF2"]
|
||||
SLF3 <- cols_ab["SLF3"]
|
||||
SLF4 <- cols_ab["SLF4"]
|
||||
SLF5 <- cols_ab["SLF5"]
|
||||
SLF6 <- cols_ab["SLF6"]
|
||||
SLF7 <- cols_ab["SLF7"]
|
||||
SLF8 <- cols_ab["SLF8"]
|
||||
SLF9 <- cols_ab["SLF9"]
|
||||
SLT1 <- cols_ab["SLT1"]
|
||||
SLT2 <- cols_ab["SLT2"]
|
||||
SLT3 <- cols_ab["SLT3"]
|
||||
SLT4 <- cols_ab["SLT4"]
|
||||
SLT5 <- cols_ab["SLT5"]
|
||||
SLT6 <- cols_ab["SLT6"]
|
||||
SMX <- cols_ab["SMX"]
|
||||
SPI <- cols_ab["SPI"]
|
||||
SPX <- cols_ab["SPX"]
|
||||
SRX <- cols_ab["SRX"]
|
||||
STR <- cols_ab["STR"]
|
||||
STR1 <- cols_ab["STR1"]
|
||||
SUD <- cols_ab["SUD"]
|
||||
SUL <- cols_ab["SUL"]
|
||||
SUT <- cols_ab["SUT"]
|
||||
SXT <- cols_ab["SXT"]
|
||||
SZO <- cols_ab["SZO"]
|
||||
TAL <- cols_ab["TAL"]
|
||||
TAZ <- cols_ab["TAZ"]
|
||||
TCC <- cols_ab["TCC"]
|
||||
TCM <- cols_ab["TCM"]
|
||||
TCY <- cols_ab["TCY"]
|
||||
TEC <- cols_ab["TEC"]
|
||||
TEM <- cols_ab["TEM"]
|
||||
TGC <- cols_ab["TGC"]
|
||||
THA <- cols_ab["THA"]
|
||||
TIC <- cols_ab["TIC"]
|
||||
TIO <- cols_ab["TIO"]
|
||||
TLT <- cols_ab["TLT"]
|
||||
TLV <- cols_ab["TLV"]
|
||||
TMP <- cols_ab["TMP"]
|
||||
TMX <- cols_ab["TMX"]
|
||||
TOB <- cols_ab["TOB"]
|
||||
TRL <- cols_ab["TRL"]
|
||||
TVA <- cols_ab["TVA"]
|
||||
TZD <- cols_ab["TZD"]
|
||||
TZP <- cols_ab["TZP"]
|
||||
VAN <- cols_ab["VAN"]
|
||||
|
||||
ab_missing <- function(ab) {
|
||||
all(ab %in% c(NULL, NA))
|
||||
}
|
||||
|
||||
if (ab_missing(AMP) & !ab_missing(AMX)) {
|
||||
if (!"AMP" %in% names(cols_ab) & "AMX" %in% names(cols_ab)) {
|
||||
# ampicillin column is missing, but amoxicillin is available
|
||||
if (info == TRUE) {
|
||||
message_("Using column '", font_bold(AMX), "' as input for ampicillin since many EUCAST rules depend on it.")
|
||||
message_("Using column '", cols_ab[names(cols_ab) == "AMX"], "' as input for ampicillin since many EUCAST rules depend on it.")
|
||||
}
|
||||
AMP <- AMX
|
||||
cols_ab <- c(cols_ab, c(AMP = unname(cols_ab[names(cols_ab) == "AMX"])))
|
||||
}
|
||||
|
||||
# data preparation ----
|
||||
@@ -502,40 +304,23 @@ eucast_rules <- function(x,
|
||||
message_("Preparing data...", appendLF = FALSE, as_note = FALSE)
|
||||
}
|
||||
|
||||
# nolint start
|
||||
# antibiotic classes ----
|
||||
aminoglycosides <- c(AMK, DKB, GEN, ISE, KAN, NEO, NET, RST, SIS, STR, STR1, TOB)
|
||||
aminopenicillins <- c(AMP, AMX)
|
||||
carbapenems <- c(DOR, ETP, IPM, MEM, MEV)
|
||||
cephalosporins <- c(CDZ, CCP, CAC, CEC, CFR, RID, MAN, CTZ, CZD, CZO, CDR, DIT, FEP, CAT, CFM, CMX, CMZ, DIZ, CID, CFP, CSL, CND, CTX, CTT, CTF, FOX, CPM, CPO, CPD, CPR, CRD, CFS, CPT, CAZ, CCV, CTL, CTB, CZX, BPR, CFM1, CEI, CRO, CXM, LEX, CEP, HAP, CED, LTM, LOR)
|
||||
cephalosporins_1st <- c(CAC, CFR, RID, CTZ, CZD, CZO, CRD, CTL, LEX, CEP, HAP, CED)
|
||||
cephalosporins_2nd <- c(CEC, MAN, CMZ, CID, CND, CTT, CTF, FOX, CPR, CXM, LOR)
|
||||
cephalosporins_3rd <- c(CDZ, CCP, CCX, CDR, DIT, DIX, CAT, CPI, CFM, CMX, DIZ, CFP, CSL, CTX, CTC, CTS, CHE, FOV, CFZ, CPM, CPD, CPX, CDC, CFS, CAZ, CZA, CCV, CEM, CPL, CTB, TIO, CZX, CZP, CRO, LTM)
|
||||
cephalosporins_except_CAZ <- cephalosporins[cephalosporins != ifelse(is.null(CAZ), "", CAZ)]
|
||||
fluoroquinolones <- c(CIP, ENX, FLE, GAT, GEM, GRX, LVX, LOM, MFX, NOR, OFX, PAZ, PEF, PRU, RFL, SPX, TMX, TVA)
|
||||
glycopeptides <- c(AVO, NVA, RAM, TEC, TCM, VAN) # dalba/orita/tela are in lipoglycopeptides
|
||||
lincosamides <- c(CLI, LIN, PRL)
|
||||
lipoglycopeptides <- c(DAL, ORI, TLV)
|
||||
macrolides <- c(AZM, CLR, DIR, ERY, FLR1, JOS, MID, MCM, OLE, ROK, RXT, SPI, TLT, TRL)
|
||||
oxazolidinones <- c(CYC, LNZ, THA, TZD)
|
||||
polymyxins <- c(PLB, COL)
|
||||
streptogramins <- c(QDA, PRI)
|
||||
tetracyclines <- c(DOX, MNO, TCY) # since EUCAST v3.1 tigecycline (TGC) is set apart
|
||||
ureidopenicillins <- c(PIP, TZP, AZL, MEZ)
|
||||
all_betalactams <- c(aminopenicillins, cephalosporins, carbapenems, ureidopenicillins, AMC, OXA, FLC, PEN)
|
||||
# nolint end
|
||||
|
||||
# Some helper functions ---------------------------------------------------
|
||||
get_antibiotic_columns <- function(x, df) {
|
||||
x <- trimws(unlist(strsplit(x, ",", fixed = TRUE)))
|
||||
y <- character(0)
|
||||
for (i in seq_len(length(x))) {
|
||||
if (is.function(get(x[i]))) {
|
||||
stop("Column ", x[i], " is also a function. Please create an issue on github.com/msberends/AMR/issues.")
|
||||
get_antibiotic_columns <- function(x, cols_ab) {
|
||||
x <- strsplit(x, ", *")[[1]]
|
||||
x_new <- character()
|
||||
for (val in x) {
|
||||
if (toupper(val) %in% ls(envir = asNamespace("AMR"))) {
|
||||
# antibiotic group names, as defined in data-raw/_internals.R, such as `CARBAPENEMS`
|
||||
val <- eval(parse(text = toupper(val)), envir = asNamespace("AMR"))
|
||||
} else if (toupper(val) %in% AB_lookup$ab) {
|
||||
# separate drugs, such as `AMX`
|
||||
val <- as.ab(val)
|
||||
} else {
|
||||
stop_("antimicrobial agent (group) not found in EUCAST rules file: ", val, call = FALSE)
|
||||
}
|
||||
y <- c(y, tryCatch(get(x[i]), error = function(e) ""))
|
||||
x_new <- c(x_new, val)
|
||||
}
|
||||
y[y != "" & y %in% colnames(df)]
|
||||
cols_ab[match(x_new, names(cols_ab))]
|
||||
}
|
||||
markup_italics_where_needed <- function(x) {
|
||||
# returns names found in family, genus or species as italics
|
||||
@@ -553,7 +338,7 @@ eucast_rules <- function(x,
|
||||
strsplit(",") %pm>%
|
||||
unlist() %pm>%
|
||||
trimws() %pm>%
|
||||
vapply(FUN.VALUE = character(1), function(x) if (x %in% antibiotics$ab) ab_name(x, language = NULL, tolower = TRUE) else x) %pm>%
|
||||
vapply(FUN.VALUE = character(1), function(x) if (x %in% antibiotics$ab) ab_name(x, language = NULL, tolower = TRUE, fast_mode = TRUE) else x) %pm>%
|
||||
sort() %pm>%
|
||||
paste(collapse = ", ")
|
||||
x <- gsub("_", " ", x, fixed = TRUE)
|
||||
@@ -633,8 +418,11 @@ eucast_rules <- function(x,
|
||||
pm_distinct(`.rowid`, .keep_all = TRUE) %pm>%
|
||||
as.data.frame(stringsAsFactors = FALSE)
|
||||
x[, col_mo] <- as.mo(as.character(x[, col_mo, drop = TRUE]))
|
||||
x <- x %pm>%
|
||||
left_join_microorganisms(by = col_mo, suffix = c("_oldcols", ""))
|
||||
# rename col_mo to prevent interference with joined columns
|
||||
colnames(x)[colnames(x) == col_mo] <- ".col_mo"
|
||||
col_mo <- ".col_mo"
|
||||
# join to microorganisms data set
|
||||
x <- left_join_microorganisms(x, by = col_mo, suffix = c("_oldcols", ""))
|
||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
||||
x$genus_species <- paste(x$genus, x$species)
|
||||
if (info == TRUE & NROW(x) > 10000) {
|
||||
@@ -662,33 +450,47 @@ eucast_rules <- function(x,
|
||||
font_red(paste0("v", utils::packageDescription("AMR")$Version, ", ",
|
||||
format(as.Date(utils::packageDescription("AMR")$Date), format = "%Y"))), "), see ?eucast_rules\n"))))
|
||||
}
|
||||
|
||||
ab_enzyme <- subset(antibiotics, name %like% "/")[, c("ab", "name")]
|
||||
ab_enzyme$base_name <- gsub("^([a-zA-Z0-9]+).*", "\\1", ab_enzyme$name)
|
||||
ab_enzyme$base_ab <- as.ab(ab_enzyme$base_name)
|
||||
colnames(ab_enzyme) <- c("enzyme_ab", "enzyme_name")
|
||||
ab_enzyme$base_name <- gsub("^([a-zA-Z0-9]+).*", "\\1", ab_enzyme$enzyme_name)
|
||||
ab_enzyme$base_ab <- antibiotics[match(ab_enzyme$base_name, antibiotics$name), "ab", drop = TRUE]
|
||||
ab_enzyme <- subset(ab_enzyme, !is.na(base_ab))
|
||||
# make ampicillin and amoxicillin interchangable
|
||||
ampi <- subset(ab_enzyme, base_ab == "AMX")
|
||||
ampi$base_ab <- "AMP"
|
||||
ampi$base_name <- ab_name("AMP", language = NULL)
|
||||
amox <- subset(ab_enzyme, base_ab == "AMP")
|
||||
amox$base_ab <- "AMX"
|
||||
amox$base_name <- ab_name("AMX", language = NULL)
|
||||
# merge and sort
|
||||
ab_enzyme <- rbind(ab_enzyme, ampi, amox)
|
||||
ab_enzyme <- ab_enzyme[order(ab_enzyme$enzyme_name), ]
|
||||
|
||||
for (i in seq_len(nrow(ab_enzyme))) {
|
||||
if (all(c(ab_enzyme[i, ]$ab, ab_enzyme[i, ]$base_ab) %in% names(cols_ab), na.rm = TRUE)) {
|
||||
ab_name_base <- ab_name(cols_ab[ab_enzyme[i, ]$base_ab], language = NULL, tolower = TRUE)
|
||||
ab_name_enzyme <- ab_name(cols_ab[ab_enzyme[i, ]$ab], language = NULL, tolower = TRUE)
|
||||
# check if both base and base + enzyme inhibitor are part of the data set
|
||||
if (all(c(ab_enzyme$base_ab[i], ab_enzyme$enzyme_ab[i]) %in% names(cols_ab), na.rm = TRUE)) {
|
||||
col_base <- unname(cols_ab[ab_enzyme$base_ab[i]])
|
||||
col_enzyme <- unname(cols_ab[ab_enzyme$enzyme_ab[i]])
|
||||
|
||||
# Set base to R where base + enzyme inhibitor is R ----
|
||||
rule_current <- paste0("Set ", ab_name_base, " (", cols_ab[ab_enzyme[i, ]$base_ab], ") = R where ",
|
||||
ab_name_enzyme, " (", cols_ab[ab_enzyme[i, ]$ab], ") = R")
|
||||
rule_current <- paste0(ab_enzyme$base_name[i], " ('", font_bold(col_base), "') = R if ",
|
||||
tolower(ab_enzyme$enzyme_name[i]), " ('", font_bold(col_enzyme), "') = R")
|
||||
if (info == TRUE) {
|
||||
cat(word_wrap(rule_current))
|
||||
cat("\n")
|
||||
cat(word_wrap(rule_current,
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6))
|
||||
}
|
||||
run_changes <- edit_rsi(x = x,
|
||||
col_mo = col_mo,
|
||||
to = "R",
|
||||
rule = c(rule_current, "Other rules", "",
|
||||
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)),
|
||||
rows = which(as.rsi_no_warning(x[, cols_ab[ab_enzyme[i, ]$ab]]) == "R"),
|
||||
cols = cols_ab[ab_enzyme[i, ]$base_ab],
|
||||
rows = which(as.rsi_no_warning(x[, col_enzyme, drop = TRUE]) == "R"),
|
||||
cols = col_base,
|
||||
last_verbose_info = verbose_info,
|
||||
original_data = x.bak,
|
||||
warned = warned,
|
||||
info = info)
|
||||
info = info,
|
||||
verbose = verbose)
|
||||
n_added <- n_added + run_changes$added
|
||||
n_changed <- n_changed + run_changes$changed
|
||||
verbose_info <- run_changes$verbose_info
|
||||
@@ -704,23 +506,25 @@ eucast_rules <- function(x,
|
||||
}
|
||||
|
||||
# Set base + enzyme inhibitor to S where base is S ----
|
||||
rule_current <- paste0("Set ", ab_name_enzyme, " (", cols_ab[ab_enzyme[i, ]$ab], ") = S where ",
|
||||
ab_name_base, " (", cols_ab[ab_enzyme[i, ]$base_ab], ") = S")
|
||||
rule_current <- paste0(ab_enzyme$enzyme_name[i], " ('", font_bold(col_enzyme), "') = S if ",
|
||||
tolower(ab_enzyme$base_name[i]), " ('", font_bold(col_base), "') = S")
|
||||
|
||||
if (info == TRUE) {
|
||||
cat(word_wrap(rule_current))
|
||||
cat("\n")
|
||||
cat(word_wrap(rule_current,
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6))
|
||||
}
|
||||
run_changes <- edit_rsi(x = x,
|
||||
col_mo = col_mo,
|
||||
to = "S",
|
||||
rule = c(rule_current, "Other rules", "",
|
||||
paste0("Non-EUCAST: AMR package v", utils::packageDescription("AMR")$Version)),
|
||||
rows = which(as.rsi_no_warning(x[, cols_ab[ab_enzyme[i, ]$base_ab]]) == "S"),
|
||||
cols = cols_ab[ab_enzyme[i, ]$ab],
|
||||
rows = which(as.rsi_no_warning(x[, col_base, drop = TRUE]) == "S"),
|
||||
cols = col_enzyme,
|
||||
last_verbose_info = verbose_info,
|
||||
original_data = x.bak,
|
||||
warned = warned,
|
||||
info = info)
|
||||
info = info,
|
||||
verbose = verbose)
|
||||
n_added <- n_added + run_changes$added
|
||||
n_changed <- n_changed + run_changes$changed
|
||||
verbose_info <- run_changes$verbose_info
|
||||
@@ -740,10 +544,17 @@ eucast_rules <- function(x,
|
||||
} else {
|
||||
if (info == TRUE) {
|
||||
cat("\n")
|
||||
message_("Skipping inheritance rules defined by this package, such as setting trimethoprim (TMP) = R where trimethoprim/sulfamethoxazole (SXT) = R. Use `eucast_rules(..., rules = \"all\")` to also apply those rules.")
|
||||
message_("Skipping inheritance rules defined by this AMR package, such as setting trimethoprim (TMP) = R where trimethoprim/sulfamethoxazole (SXT) = R. Add \"other\" or \"all\" to the `rules` argument to apply those rules.")
|
||||
}
|
||||
}
|
||||
|
||||
if (!any(c("all", "custom") %in% rules) & !is.null(custom_rules)) {
|
||||
if (info == TRUE) {
|
||||
message_("Skipping custom EUCAST rules, since the `rules` argument does not contain \"custom\".")
|
||||
}
|
||||
custom_rules <- NULL
|
||||
}
|
||||
|
||||
# Official EUCAST rules ---------------------------------------------------
|
||||
eucast_notification_shown <- FALSE
|
||||
if (!is.null(list(...)$eucast_rules_df)) {
|
||||
@@ -757,19 +568,19 @@ eucast_rules <- function(x,
|
||||
# filter on user-set guideline versions ----
|
||||
if (any(c("all", "breakpoints") %in% rules)) {
|
||||
eucast_rules_df <- subset(eucast_rules_df,
|
||||
!reference.rule_group %like% "breakpoint" |
|
||||
reference.rule_group %unlike% "breakpoint" |
|
||||
(reference.rule_group %like% "breakpoint" & reference.version == version_breakpoints))
|
||||
}
|
||||
if (any(c("all", "expert") %in% rules)) {
|
||||
eucast_rules_df <- subset(eucast_rules_df,
|
||||
!reference.rule_group %like% "expert" |
|
||||
reference.rule_group %unlike% "expert" |
|
||||
(reference.rule_group %like% "expert" & reference.version == version_expertrules))
|
||||
}
|
||||
# filter out AmpC de-repressed cephalosporin-resistant mutants ----
|
||||
# cefotaxime, ceftriaxone, ceftazidime
|
||||
if (is.null(ampc_cephalosporin_resistance) || isFALSE(ampc_cephalosporin_resistance)) {
|
||||
eucast_rules_df <- subset(eucast_rules_df,
|
||||
!reference.rule %like% "ampc")
|
||||
reference.rule %unlike% "ampc")
|
||||
} else {
|
||||
if (isTRUE(ampc_cephalosporin_resistance)) {
|
||||
ampc_cephalosporin_resistance <- "R"
|
||||
@@ -777,6 +588,7 @@ eucast_rules <- function(x,
|
||||
eucast_rules_df[which(eucast_rules_df$reference.rule %like% "ampc"), "to_value"] <- as.character(ampc_cephalosporin_resistance)
|
||||
}
|
||||
|
||||
# Go over all rules and apply them ----
|
||||
for (i in seq_len(nrow(eucast_rules_df))) {
|
||||
|
||||
rule_previous <- eucast_rules_df[max(1, i - 1), "reference.rule", drop = TRUE]
|
||||
@@ -784,6 +596,14 @@ eucast_rules <- function(x,
|
||||
rule_next <- eucast_rules_df[min(nrow(eucast_rules_df), i + 1), "reference.rule", drop = TRUE]
|
||||
rule_group_previous <- eucast_rules_df[max(1, i - 1), "reference.rule_group", drop = TRUE]
|
||||
rule_group_current <- eucast_rules_df[i, "reference.rule_group", drop = TRUE]
|
||||
# don't apply rules if user doesn't want to apply them
|
||||
if (rule_group_current %like% "breakpoint" & !any(c("all", "breakpoints") %in% rules)) {
|
||||
next
|
||||
}
|
||||
if (rule_group_current %like% "expert" & !any(c("all", "expert") %in% rules)) {
|
||||
next
|
||||
}
|
||||
|
||||
if (isFALSE(info) | isFALSE(verbose)) {
|
||||
rule_text <- ""
|
||||
} else {
|
||||
@@ -804,17 +624,9 @@ eucast_rules <- function(x,
|
||||
rule_next <- ""
|
||||
}
|
||||
|
||||
# don't apply rules if user doesn't want to apply them
|
||||
if (rule_group_current %like% "breakpoint" & !any(c("all", "breakpoints") %in% rules)) {
|
||||
next
|
||||
}
|
||||
if (rule_group_current %like% "expert" & !any(c("all", "expert") %in% rules)) {
|
||||
next
|
||||
}
|
||||
|
||||
if (info == TRUE) {
|
||||
# Print EUCAST intro ------------------------------------------------------
|
||||
if (!rule_group_current %like% "other" & eucast_notification_shown == FALSE) {
|
||||
if (rule_group_current %unlike% "other" & eucast_notification_shown == FALSE) {
|
||||
cat(
|
||||
paste0("\n", font_grey(strrep("-", 0.95 * options()$width)), "\n",
|
||||
word_wrap("Rules by the ", font_bold("European Committee on Antimicrobial Susceptibility Testing (EUCAST)")), "\n",
|
||||
@@ -899,26 +711,26 @@ eucast_rules <- function(x,
|
||||
source_value <- trimws(unlist(strsplit(eucast_rules_df[i, "have_these_values", drop = TRUE], ",", fixed = TRUE)))
|
||||
target_antibiotics <- eucast_rules_df[i, "then_change_these_antibiotics", drop = TRUE]
|
||||
target_value <- eucast_rules_df[i, "to_value", drop = TRUE]
|
||||
|
||||
|
||||
if (is.na(source_antibiotics)) {
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value),
|
||||
error = function(e) integer(0))
|
||||
} else {
|
||||
source_antibiotics <- get_antibiotic_columns(source_antibiotics, x)
|
||||
source_antibiotics <- get_antibiotic_columns(source_antibiotics, cols_ab)
|
||||
if (length(source_value) == 1 & length(source_antibiotics) > 1) {
|
||||
source_value <- rep(source_value, length(source_antibiotics))
|
||||
}
|
||||
if (length(source_antibiotics) == 0) {
|
||||
rows <- integer(0)
|
||||
} else if (length(source_antibiotics) == 1) {
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
& as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]),
|
||||
error = function(e) integer(0))
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
& as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]),
|
||||
error = function(e) integer(0))
|
||||
} else if (length(source_antibiotics) == 2) {
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
& as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]
|
||||
& as.rsi_no_warning(x[, source_antibiotics[2L]]) == source_value[2L]),
|
||||
error = function(e) integer(0))
|
||||
rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
& as.rsi_no_warning(x[, source_antibiotics[1L]]) == source_value[1L]
|
||||
& as.rsi_no_warning(x[, source_antibiotics[2L]]) == source_value[2L]),
|
||||
error = function(e) integer(0))
|
||||
# nolint start
|
||||
# } else if (length(source_antibiotics) == 3) {
|
||||
# rows <- tryCatch(which(x[, if_mo_property, drop = TRUE] %like% mo_value
|
||||
@@ -932,12 +744,11 @@ eucast_rules <- function(x,
|
||||
}
|
||||
}
|
||||
|
||||
cols <- get_antibiotic_columns(target_antibiotics, x)
|
||||
cols <- get_antibiotic_columns(target_antibiotics, cols_ab)
|
||||
|
||||
# Apply rule on data ------------------------------------------------------
|
||||
# this will return the unique number of changes
|
||||
run_changes <- edit_rsi(x = x,
|
||||
col_mo = col_mo,
|
||||
to = target_value,
|
||||
rule = c(rule_text, rule_group_current, rule_current,
|
||||
ifelse(rule_group_current %like% "breakpoint",
|
||||
@@ -948,7 +759,8 @@ eucast_rules <- function(x,
|
||||
last_verbose_info = verbose_info,
|
||||
original_data = x.bak,
|
||||
warned = warned,
|
||||
info = info)
|
||||
info = info,
|
||||
verbose = verbose)
|
||||
n_added <- n_added + run_changes$added
|
||||
n_changed <- n_changed + run_changes$changed
|
||||
verbose_info <- run_changes$verbose_info
|
||||
@@ -962,6 +774,60 @@ eucast_rules <- function(x,
|
||||
n_added <- 0
|
||||
n_changed <- 0
|
||||
}
|
||||
} # end of going over all rules
|
||||
|
||||
# Apply custom rules ----
|
||||
if (!is.null(custom_rules)) {
|
||||
if (info == TRUE) {
|
||||
cat("\n")
|
||||
cat(font_bold("Custom EUCAST rules, set by user"), "\n")
|
||||
}
|
||||
for (i in seq_len(length(custom_rules))) {
|
||||
rule <- custom_rules[[i]]
|
||||
rows <- which(eval(parse(text = rule$query), envir = x))
|
||||
cols <- as.character(rule$result_group)
|
||||
cols <- c(cols[cols %in% colnames(x)], # direct column names
|
||||
unname(cols_ab[names(cols_ab) %in% cols])) # based on previous cols_ab finding
|
||||
cols <- unique(cols)
|
||||
target_value <- as.character(rule$result_value)
|
||||
rule_text <- paste0("report as '", target_value, "' when ",
|
||||
format_custom_query_rule(rule$query, colours = FALSE), ": ",
|
||||
get_antibiotic_names(cols))
|
||||
if (info == TRUE) {
|
||||
# print rule
|
||||
cat(markup_italics_where_needed(word_wrap(format_custom_query_rule(rule$query, colours = FALSE),
|
||||
width = getOption("width") - 30,
|
||||
extra_indent = 6)))
|
||||
warned <- FALSE
|
||||
}
|
||||
run_changes <- edit_rsi(x = x,
|
||||
to = target_value,
|
||||
rule = c(rule_text,
|
||||
"Custom EUCAST rules",
|
||||
paste0("Custom EUCAST rule ", i),
|
||||
paste0("Object '", deparse(substitute(custom_rules)),
|
||||
"' consisting of ", length(custom_rules), " custom rules")),
|
||||
rows = rows,
|
||||
cols = cols,
|
||||
last_verbose_info = verbose_info,
|
||||
original_data = x.bak,
|
||||
warned = warned,
|
||||
info = info,
|
||||
verbose = verbose)
|
||||
n_added <- n_added + run_changes$added
|
||||
n_changed <- n_changed + run_changes$changed
|
||||
verbose_info <- run_changes$verbose_info
|
||||
x <- run_changes$output
|
||||
warn_lacking_rsi_class <- c(warn_lacking_rsi_class, run_changes$rsi_warn)
|
||||
# Print number of new changes ---------------------------------------------
|
||||
if (info == TRUE & rule_next != rule_current) {
|
||||
# print only on last one of rules in this group
|
||||
txt_ok(n_added = n_added, n_changed = n_changed, warned = warned)
|
||||
# and reset counters
|
||||
n_added <- 0
|
||||
n_changed <- 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Print overview ----------------------------------------------------------
|
||||
@@ -1080,16 +946,16 @@ eucast_rules <- function(x,
|
||||
}
|
||||
|
||||
# helper function for editing the table ----
|
||||
edit_rsi <- function(x,
|
||||
col_mo,
|
||||
to,
|
||||
rule,
|
||||
edit_rsi <- function(x,
|
||||
to,
|
||||
rule,
|
||||
rows,
|
||||
cols,
|
||||
last_verbose_info,
|
||||
last_verbose_info,
|
||||
original_data,
|
||||
warned,
|
||||
info) {
|
||||
info,
|
||||
verbose) {
|
||||
cols <- unique(cols[!is.na(cols) & !is.null(cols)])
|
||||
|
||||
# for Verbose Mode, keep track of all changes and return them
|
||||
@@ -1146,7 +1012,7 @@ edit_rsi <- function(x,
|
||||
)
|
||||
|
||||
track_changes$output <- new_edits
|
||||
if (isTRUE(info) && !isTRUE(all.equal(x, track_changes$output))) {
|
||||
if ((info == TRUE | verbose == TRUE) && !isTRUE(all.equal(x, track_changes$output))) {
|
||||
get_original_rows <- function(rowids) {
|
||||
as.integer(rownames(original_data[which(original_data$.rowid %in% rowids), , drop = FALSE]))
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ find_ab_group <- function(ab_class) {
|
||||
|
||||
find_ab_names <- function(ab_group, n = 3) {
|
||||
ab_group <- gsub("[^a-zA-Z0-9]", ".*", ab_group)
|
||||
drugs <- antibiotics[which(antibiotics$group %like% ab_group & !antibiotics$ab %like% "[0-9]$"), ]$name
|
||||
drugs <- antibiotics[which(antibiotics$group %like% ab_group & antibiotics$ab %unlike% "[0-9]$"), ]$name
|
||||
paste0(sort(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE),
|
||||
tolower = TRUE, language = NULL)),
|
||||
collapse = ", ")
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#' Determine First (Weighted) Isolates
|
||||
#'
|
||||
#' Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use [is_new_episode()] that also supports grouping with the `dplyr` package.
|
||||
#' Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. These functions support all four methods as summarised by Hindler *et al.* in 2007 (\doi{10.1086/511864}). To determine patient episodes not necessarily based on microorganisms, use [is_new_episode()] that also supports grouping with the `dplyr` package.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame] containing isolates. Can be left blank for automatic determination, see *Examples*.
|
||||
#' @param col_date column name of the result date (or date that is was received on the lab), defaults to the first column with a date class
|
||||
@@ -34,74 +34,104 @@
|
||||
#' @param col_testcode column name of the test codes. Use `col_testcode = NULL` to **not** exclude certain test codes (such as test codes for screening). In that case `testcodes_exclude` will be ignored.
|
||||
#' @param col_specimen column name of the specimen type or group
|
||||
#' @param col_icu column name of the logicals (`TRUE`/`FALSE`) whether a ward or department is an Intensive Care Unit (ICU)
|
||||
#' @param col_keyantibiotics column name of the key antibiotics to determine first (weighted) isolates, see [key_antibiotics()]. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' (case insensitive). Use `col_keyantibiotics = FALSE` to prevent this.
|
||||
#' @param col_keyantimicrobials (only useful when `method = "phenotype-based"`) column name of the key antimicrobials to determine first (weighted) isolates, see [key_antimicrobials()]. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' or 'antimicrobials' (case insensitive). Use `col_keyantimicrobials = FALSE` to prevent this. Can also be the output of [key_antimicrobials()].
|
||||
#' @param episode_days episode in days after which a genus/species combination will be determined as 'first isolate' again. The default of 365 days is based on the guideline by CLSI, see *Source*.
|
||||
#' @param testcodes_exclude character vector with test codes that should be excluded (case-insensitive)
|
||||
#' @param icu_exclude logical to indicate whether ICU isolates should be excluded (rows with value `TRUE` in the column set with `col_icu`)
|
||||
#' @param specimen_group value in the column set with `col_specimen` to filter on
|
||||
#' @param type type to determine weighed isolates; can be `"keyantibiotics"` or `"points"`, see *Details*
|
||||
#' @param ignore_I logical to indicate whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantibiotics"`, see *Details*
|
||||
#' @param points_threshold points until the comparison of key antibiotics will lead to inclusion of an isolate when `type = "points"`, see *Details*
|
||||
#' @param info print progress
|
||||
#' @param type type to determine weighed isolates; can be `"keyantimicrobials"` or `"points"`, see *Details*
|
||||
#' @param method the method to apply, either `"phenotype-based"`, `"episode-based"`, `"patient-based"` or `"isolate-based"` (can be abbreviated), see *Details*. The default is `"phenotype-based"` if antimicrobial test results are present in the data, and `"episode-based"` otherwise.
|
||||
#' @param ignore_I logical to indicate whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantimicrobials"`, see *Details*
|
||||
#' @param points_threshold minimum number of points to require before differences in the antibiogram will lead to inclusion of an isolate when `type = "points"`, see *Details*
|
||||
#' @param info a [logical] to indicate info should be printed, defaults to `TRUE` only in interactive mode
|
||||
#' @param include_unknown logical to indicate whether 'unknown' microorganisms should be included too, i.e. microbial code `"UNKNOWN"`, which defaults to `FALSE`. For WHONET users, this means that all records with organism code `"con"` (*contamination*) will be excluded at default. Isolates with a microbial ID of `NA` will always be excluded as first isolate.
|
||||
#' @param include_untested_rsi logical to indicate whether also rows without antibiotic results are still eligible for becoming a first isolate. Use `include_untested_rsi = FALSE` to always return `FALSE` for such rows. This checks the data set for columns of class `<rsi>` and consequently requires transforming columns with antibiotic results using [as.rsi()] first.
|
||||
#' @param ... arguments passed on to [first_isolate()] when using [filter_first_isolate()], or arguments passed on to [key_antibiotics()] when using [filter_first_weighted_isolate()]
|
||||
#' @param ... arguments passed on to [first_isolate()] when using [filter_first_isolate()], otherwise arguments passed on to [key_antimicrobials()] (such as `universal`, `gram_negative`, `gram_positive`)
|
||||
#' @details
|
||||
#' To conduct epidemiological analyses on antimicrobial resistance data, only so-called first isolates should be included to prevent overestimation and underestimation of antimicrobial resistance. Different methods can be used to do so, see below.
|
||||
#'
|
||||
#' These functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#'
|
||||
#' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but more efficient for data sets containing microorganism codes or names.
|
||||
#'
|
||||
#' All isolates with a microbial ID of `NA` will be excluded as first isolate.
|
||||
#'
|
||||
#' ## Why this is so Important
|
||||
#' To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode [(Hindler *et al.* 2007)](https://pubmed.ncbi.nlm.nih.gov/17304462/). If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following week. The resistance percentage of oxacillin of all *S. aureus* isolates would be overestimated, because you included this MRSA more than once. It would be [selection bias](https://en.wikipedia.org/wiki/Selection_bias).
|
||||
#'
|
||||
#' ## `filter_*()` Shortcuts
|
||||
#'
|
||||
#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates.
|
||||
#' ## Different methods
|
||||
#'
|
||||
#' The function [filter_first_isolate()] is essentially equal to either:
|
||||
#' According to Hindler *et al.* (2007, \doi{10.1086/511864}), there are different methods (algorithms) to select first isolates with increasing reliability: isolate-based, patient-based, episode-based and phenotype-based. All methods select on a combination of the taxonomic genus and species (not subspecies).
|
||||
#'
|
||||
#' ```
|
||||
#' x[first_isolate(x, ...), ]
|
||||
#'
|
||||
#' x %>% filter(first_isolate(...))
|
||||
#' ```
|
||||
#' All mentioned methods are covered in the [first_isolate()] function:
|
||||
#'
|
||||
#' The function [filter_first_weighted_isolate()] is essentially equal to:
|
||||
#'
|
||||
#' ```
|
||||
#' x %>%
|
||||
#' mutate(keyab = key_antibiotics(.)) %>%
|
||||
#' mutate(only_weighted_firsts = first_isolate(x,
|
||||
#' col_keyantibiotics = "keyab", ...)) %>%
|
||||
#' filter(only_weighted_firsts == TRUE) %>%
|
||||
#' select(-only_weighted_firsts, -keyab)
|
||||
#' ```
|
||||
#' @section Key Antibiotics:
|
||||
#' There are two ways to determine whether isolates can be included as first weighted isolates which will give generally the same results:
|
||||
#'
|
||||
#' 1. Using `type = "keyantibiotics"` and argument `ignore_I`
|
||||
#' | **Method** | **Function to apply** |
|
||||
#' |--------------------------------------------------|-------------------------------------------------------|
|
||||
#' | **Isolate-based** | `first_isolate(x, method = "isolate-based")` |
|
||||
#' | *(= all isolates)* | |
|
||||
#' | | |
|
||||
#' | | |
|
||||
#' | **Patient-based** | `first_isolate(x, method = "patient-based")` |
|
||||
#' | *(= first isolate per patient)* | |
|
||||
#' | | |
|
||||
#' | | |
|
||||
#' | **Episode-based** | `first_isolate(x, method = "episode-based")`, or: |
|
||||
#' | *(= first isolate per episode)* | |
|
||||
#' | - 7-Day interval from initial isolate | - `first_isolate(x, method = "e", episode_days = 7)` |
|
||||
#' | - 30-Day interval from initial isolate | - `first_isolate(x, method = "e", episode_days = 30)` |
|
||||
#' | | |
|
||||
#' | | |
|
||||
#' | **Phenotype-based** | `first_isolate(x, method = "phenotype-based")`, or: |
|
||||
#' | *(= first isolate per phenotype)* | |
|
||||
#' | - Major difference in any antimicrobial result | - `first_isolate(x, type = "points")` |
|
||||
#' | - Any difference in key antimicrobial results | - `first_isolate(x, type = "keyantimicrobials")` |
|
||||
#'
|
||||
#' Any difference from S to R (or vice versa) will (re)select an isolate as a first weighted isolate. With `ignore_I = FALSE`, also differences from I to S|R (or vice versa) will lead to this. This is a reliable method and 30-35 times faster than method 2. Read more about this in the [key_antibiotics()] function.
|
||||
#' ### Isolate-based
|
||||
#'
|
||||
#' This method does not require any selection, as all isolates should be included. It does, however, respect all arguments set in the [first_isolate()] function. For example, the default setting for `include_unknown` (`FALSE`) will omit selection of rows without a microbial ID.
|
||||
#'
|
||||
#' ### Patient-based
|
||||
#'
|
||||
#' To include every genus-species combination per patient once, set the `episode_days` to `Inf`. Although often inappropriate, this method makes sure that no duplicate isolates are selected from the same patient. In a large longitudinal data set, this could mean that isolates are *excluded* that were found years after the initial isolate.
|
||||
#'
|
||||
#' ### Episode-based
|
||||
#'
|
||||
#' To include every genus-species combination per patient episode once, set the `episode_days` to a sensible number of days. Depending on the type of analysis, this could be 14, 30, 60 or 365. Short episodes are common for analysing specific hospital or ward data, long episodes are common for analysing regional and national data.
|
||||
#'
|
||||
#' This is the most common method to correct for duplicate isolates. Patients are categorised into episodes based on their ID and dates (e.g., the date of specimen receipt or laboratory result). While this is a common method, it does not take into account antimicrobial test results. This means that e.g. a methicillin-resistant *Staphylococcus aureus* (MRSA) isolate cannot be differentiated from a wildtype *Staphylococcus aureus* isolate.
|
||||
#'
|
||||
#' ### Phenotype-based
|
||||
#'
|
||||
#' This is a more reliable method, since it also *weighs* the antibiogram (antimicrobial test results) yielding so-called 'first weighted isolates'. There are two different methods to weigh the antibiogram:
|
||||
#'
|
||||
#' 1. Using `type = "points"` and argument `points_threshold`
|
||||
#'
|
||||
#' This method weighs *all* antimicrobial agents available in the data set. Any difference from I to S or R (or vice versa) counts as 0.5 points, a difference from S to R (or vice versa) counts as 1 point. When the sum of points exceeds `points_threshold`, which defaults to `2`, an isolate will be selected as a first weighted isolate.
|
||||
#'
|
||||
#' 2. Using `type = "points"` and argument `points_threshold`
|
||||
#' All antimicrobials are internally selected using the [all_antimicrobials()] function. The output of this function does not need to be passed to the [first_isolate()] function.
|
||||
#'
|
||||
#' A difference from I to S|R (or vice versa) means 0.5 points, a difference from S to R (or vice versa) means 1 point. When the sum of points exceeds `points_threshold`, which defaults to `2`, an isolate will be (re)selected as a first weighted isolate.
|
||||
#'
|
||||
#' 2. Using `type = "keyantimicrobials"` and argument `ignore_I`
|
||||
#'
|
||||
#' This method only weighs specific antimicrobial agents, called *key antimicrobials*. Any difference from S to R (or vice versa) in these key antimicrobials will select an isolate as a first weighted isolate. With `ignore_I = FALSE`, also differences from I to S or R (or vice versa) will lead to this.
|
||||
#'
|
||||
#' Key antimicrobials are internally selected using the [key_antimicrobials()] function, but can also be added manually as a variable to the data and set in the `col_keyantimicrobials` argument. Another option is to pass the output of the [key_antimicrobials()] function directly to the `col_keyantimicrobials` argument.
|
||||
#'
|
||||
#'
|
||||
#' The default method is phenotype-based (using `type = "points"`) and episode-based (using `episode_days = 365`). This makes sure that every genus-species combination is selected per patient once per year, while taking into account all antimicrobial test results. If no antimicrobial test results are available in the data set, only the episode-based method is applied at default.
|
||||
#' @rdname first_isolate
|
||||
#' @seealso [key_antibiotics()]
|
||||
#' @seealso [key_antimicrobials()]
|
||||
#' @export
|
||||
#' @return A [`logical`] vector
|
||||
#' @source Methodology of this function is strictly based on:
|
||||
#'
|
||||
#' **M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition**, 2014, *Clinical and Laboratory Standards Institute (CLSI)*. <https://clsi.org/standards/products/microbiology/documents/m39/>.
|
||||
#' - **M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition**, 2014, *Clinical and Laboratory Standards Institute (CLSI)*. <https://clsi.org/standards/products/microbiology/documents/m39/>.
|
||||
#'
|
||||
#' - Hindler JF and Stelling J (2007). **Analysis and Presentation of Cumulative Antibiograms: A New Consensus Guideline from the Clinical and Laboratory Standards Institute.** Clinical Infectious Diseases, 44(6), 867–873. \doi{10.1086/511864}
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' example_isolates[first_isolate(example_isolates), ]
|
||||
#'
|
||||
#' \donttest{
|
||||
#' # faster way, only works in R 3.2 and later:
|
||||
#' example_isolates[first_isolate(), ]
|
||||
@@ -114,11 +144,9 @@
|
||||
#' example_isolates %>%
|
||||
#' filter(first_isolate())
|
||||
#'
|
||||
#' # short-hand versions:
|
||||
#' # short-hand version:
|
||||
#' example_isolates %>%
|
||||
#' filter_first_isolate()
|
||||
#' example_isolates %>%
|
||||
#' filter_first_weighted_isolate()
|
||||
#'
|
||||
#' # grouped determination of first isolates (also prints group names):
|
||||
#' example_isolates %>%
|
||||
@@ -132,14 +160,14 @@
|
||||
#' resistance = resistance(GEN)) # gentamicin resistance
|
||||
#'
|
||||
#' B <- example_isolates %>%
|
||||
#' filter_first_weighted_isolate() %>% # the 1st isolate filter
|
||||
#' filter_first_isolate() %>% # the 1st isolate filter
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(count = n_rsi(GEN), # gentamicin availability
|
||||
#' resistance = resistance(GEN)) # gentamicin resistance
|
||||
#'
|
||||
#' # Have a look at A and B.
|
||||
#' # B is more reliable because every isolate is counted only once.
|
||||
#' # Gentamicin resistance in hospital D appears to be 3.7% higher than
|
||||
#' # Gentamicin resistance in hospital D appears to be 4.2% higher than
|
||||
#' # when you (erroneously) would have used all isolates for analysis.
|
||||
#' }
|
||||
#' }
|
||||
@@ -150,18 +178,32 @@ first_isolate <- function(x = NULL,
|
||||
col_testcode = NULL,
|
||||
col_specimen = NULL,
|
||||
col_icu = NULL,
|
||||
col_keyantibiotics = NULL,
|
||||
col_keyantimicrobials = NULL,
|
||||
episode_days = 365,
|
||||
testcodes_exclude = NULL,
|
||||
icu_exclude = FALSE,
|
||||
specimen_group = NULL,
|
||||
type = "keyantibiotics",
|
||||
type = "points",
|
||||
method = c("phenotype-based", "episode-based", "patient-based", "isolate-based"),
|
||||
ignore_I = TRUE,
|
||||
points_threshold = 2,
|
||||
info = interactive(),
|
||||
include_unknown = FALSE,
|
||||
include_untested_rsi = TRUE,
|
||||
...) {
|
||||
|
||||
dots <- unlist(list(...))
|
||||
if (length(dots) != 0) {
|
||||
# backwards compatibility with old arguments
|
||||
dots.names <- names(dots)
|
||||
if ("filter_specimen" %in% dots.names) {
|
||||
specimen_group <- dots[which(dots.names == "filter_specimen")]
|
||||
}
|
||||
if ("col_keyantibiotics" %in% dots.names) {
|
||||
col_keyantimicrobials <- dots[which(dots.names == "col_keyantibiotics")]
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
# is also fix for using a grouped df as input (a dot as first argument)
|
||||
@@ -177,11 +219,25 @@ first_isolate <- function(x = NULL,
|
||||
}
|
||||
meet_criteria(col_specimen, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(col_icu, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
if (isFALSE(col_keyantibiotics)) {
|
||||
col_keyantibiotics <- NULL
|
||||
# method
|
||||
method <- coerce_method(method)
|
||||
meet_criteria(method, allow_class = "character", has_length = 1, is_in = c("phenotype-based", "episode-based", "patient-based", "isolate-based", "p", "e", "i"))
|
||||
# key antimicrobials
|
||||
if (length(col_keyantimicrobials) > 1) {
|
||||
meet_criteria(col_keyantimicrobials, allow_class = "character", has_length = nrow(x))
|
||||
x$keyabcol <- col_keyantimicrobials
|
||||
col_keyantimicrobials <- "keyabcol"
|
||||
} else {
|
||||
if (isFALSE(col_keyantimicrobials)) {
|
||||
col_keyantimicrobials <- NULL
|
||||
# method cannot be phenotype-based anymore
|
||||
if (method == "phenotype-based") {
|
||||
method <- "episode-based"
|
||||
}
|
||||
}
|
||||
meet_criteria(col_keyantimicrobials, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
}
|
||||
meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||
meet_criteria(testcodes_exclude, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(icu_exclude, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(specimen_group, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
@@ -195,16 +251,23 @@ first_isolate <- function(x = NULL,
|
||||
# remove data.table, grouping from tibbles, etc.
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
|
||||
dots <- unlist(list(...))
|
||||
if (length(dots) != 0) {
|
||||
# backwards compatibility with old arguments
|
||||
dots.names <- names(dots)
|
||||
if ("filter_specimen" %in% dots.names) {
|
||||
specimen_group <- dots[which(dots.names == "filter_specimen")]
|
||||
}
|
||||
if ("tbl" %in% dots.names) {
|
||||
x <- dots[which(dots.names == "tbl")]
|
||||
}
|
||||
any_col_contains_rsi <- any(vapply(FUN.VALUE = logical(1),
|
||||
X = x,
|
||||
FUN = function(x) any(as.character(x) %in% c("R", "S", "I"), na.rm = TRUE),
|
||||
USE.NAMES = FALSE))
|
||||
if (method == "phenotype-based" & !any_col_contains_rsi) {
|
||||
method <- "episode-based"
|
||||
}
|
||||
if (info == TRUE & message_not_thrown_before("first_isolate.method")) {
|
||||
message_(paste0("Determining first isolates using the '", font_bold(method), "' method",
|
||||
ifelse(method %in% c("episode-based", "phenotype-based"),
|
||||
ifelse(is.infinite(episode_days),
|
||||
" without a specified episode length",
|
||||
paste(" and an episode length of", episode_days, "days")),
|
||||
"")),
|
||||
as_note = FALSE,
|
||||
add_fn = font_black)
|
||||
remember_thrown_message("first_isolate.method")
|
||||
}
|
||||
|
||||
# try to find columns based on type
|
||||
@@ -214,6 +277,37 @@ first_isolate <- function(x = NULL,
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
}
|
||||
|
||||
# methods ----
|
||||
if (method == "isolate-based") {
|
||||
episode_days <- Inf
|
||||
col_keyantimicrobials <- NULL
|
||||
x$dummy_dates <- Sys.Date()
|
||||
col_date <- "dummy_dates"
|
||||
x$dummy_patients <- paste("dummy", seq_len(nrow(x))) # all 'patients' must be unique
|
||||
col_patient_id <- "dummy_patients"
|
||||
} else if (method == "patient-based") {
|
||||
episode_days <- Inf
|
||||
col_keyantimicrobials <- NULL
|
||||
} else if (method == "episode-based") {
|
||||
col_keyantimicrobials <- NULL
|
||||
} else if (method == "phenotype-based") {
|
||||
if (missing(type) & !is.null(col_keyantimicrobials)) {
|
||||
# type = "points" is default, but not set explicitly, while col_keyantimicrobials is
|
||||
type <- "keyantimicrobials"
|
||||
}
|
||||
if (type == "points") {
|
||||
x$keyantimicrobials <- all_antimicrobials(x, only_rsi_columns = FALSE)
|
||||
col_keyantimicrobials <- "keyantimicrobials"
|
||||
} else if (type == "keyantimicrobials" & is.null(col_keyantimicrobials)) {
|
||||
col_keyantimicrobials <- search_type_in_df(x = x, type = "keyantibiotics")
|
||||
if (is.null(col_keyantimicrobials)) {
|
||||
# still not found as a column, create it ourselves
|
||||
x$keyantimicrobials <- key_antimicrobials(x, only_rsi_columns = FALSE, col_mo = col_mo, ...)
|
||||
col_keyantimicrobials <- "keyantimicrobials"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# -- date
|
||||
if (is.null(col_date)) {
|
||||
col_date <- search_type_in_df(x = x, type = "date")
|
||||
@@ -232,11 +326,6 @@ first_isolate <- function(x = NULL,
|
||||
}
|
||||
stop_if(is.null(col_patient_id), "`col_patient_id` must be set")
|
||||
}
|
||||
|
||||
# -- key antibiotics
|
||||
if (is.null(col_keyantibiotics)) {
|
||||
col_keyantibiotics <- search_type_in_df(x = x, type = "keyantibiotics")
|
||||
}
|
||||
|
||||
# -- specimen
|
||||
if (is.null(col_specimen) & !is.null(specimen_group)) {
|
||||
@@ -256,7 +345,7 @@ first_isolate <- function(x = NULL,
|
||||
check_columns_existance(col_mo)
|
||||
check_columns_existance(col_testcode)
|
||||
check_columns_existance(col_icu)
|
||||
check_columns_existance(col_keyantibiotics)
|
||||
check_columns_existance(col_keyantimicrobials)
|
||||
|
||||
# convert dates to Date
|
||||
dates <- as.Date(x[, col_date, drop = TRUE])
|
||||
@@ -274,10 +363,11 @@ first_isolate <- function(x = NULL,
|
||||
testcodes_exclude <- NULL
|
||||
}
|
||||
# remove testcodes
|
||||
if (!is.null(testcodes_exclude) & info == TRUE) {
|
||||
message_("[Criterion] Exclude test codes: ", toString(paste0("'", testcodes_exclude, "'")),
|
||||
if (!is.null(testcodes_exclude) & info == TRUE & message_not_thrown_before("first_isolate.excludingtestcodes")) {
|
||||
message_("Excluding test codes: ", toString(paste0("'", testcodes_exclude, "'")),
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
remember_thrown_message("first_isolate.excludingtestcodes")
|
||||
}
|
||||
|
||||
if (is.null(col_specimen)) {
|
||||
@@ -287,14 +377,15 @@ first_isolate <- function(x = NULL,
|
||||
# filter on specimen group and keyantibiotics when they are filled in
|
||||
if (!is.null(specimen_group)) {
|
||||
check_columns_existance(col_specimen, x)
|
||||
if (info == TRUE) {
|
||||
message_("[Criterion] Exclude other than specimen group '", specimen_group, "'",
|
||||
if (info == TRUE & message_not_thrown_before("first_isolate.excludingspecimen")) {
|
||||
message_("Excluding other than specimen group '", specimen_group, "'",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
remember_thrown_message("first_isolate.excludingspecimen")
|
||||
}
|
||||
}
|
||||
if (!is.null(col_keyantibiotics)) {
|
||||
x$newvar_key_ab <- x[, col_keyantibiotics, drop = TRUE]
|
||||
if (!is.null(col_keyantimicrobials)) {
|
||||
x$newvar_key_ab <- x[, col_keyantimicrobials, drop = TRUE]
|
||||
}
|
||||
|
||||
if (is.null(testcodes_exclude)) {
|
||||
@@ -335,7 +426,7 @@ first_isolate <- function(x = NULL,
|
||||
}
|
||||
if (row.start == row.end) {
|
||||
if (info == TRUE) {
|
||||
message_("=> Found ", font_bold("1 isolate"), ", as the data only contained 1 row",
|
||||
message_("=> Found ", font_bold("1 first isolate"), ", as the data only contained 1 row",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
}
|
||||
@@ -343,7 +434,7 @@ first_isolate <- function(x = NULL,
|
||||
}
|
||||
if (length(c(row.start:row.end)) == pm_n_distinct(x[c(row.start:row.end), col_mo, drop = TRUE])) {
|
||||
if (info == TRUE) {
|
||||
message_("=> Found ", font_bold(paste(length(c(row.start:row.end)), "isolates")),
|
||||
message_("=> Found ", font_bold(paste(length(c(row.start:row.end)), "first isolates")),
|
||||
", as all isolates were different microorganisms",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
@@ -363,40 +454,38 @@ first_isolate <- function(x = NULL,
|
||||
FALSE,
|
||||
TRUE)
|
||||
x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species)
|
||||
x$more_than_episode_ago <- unlist(lapply(unique(x$episode_group),
|
||||
function(g,
|
||||
df = x,
|
||||
days = episode_days) {
|
||||
is_new_episode(x = df[which(df$episode_group == g), ]$newvar_date,
|
||||
episode_days = days)
|
||||
}))
|
||||
x$more_than_episode_ago <- unlist(lapply(split(x$newvar_date,
|
||||
x$episode_group),
|
||||
is_new_episode,
|
||||
episode_days = episode_days),
|
||||
use.names = FALSE)
|
||||
|
||||
weighted.notice <- ""
|
||||
if (!is.null(col_keyantibiotics)) {
|
||||
if (!is.null(col_keyantimicrobials)) {
|
||||
weighted.notice <- "weighted "
|
||||
if (info == TRUE) {
|
||||
if (type == "keyantibiotics") {
|
||||
message_("[Criterion] Base inclusion on key antibiotics, ",
|
||||
if (info == TRUE & message_not_thrown_before("first_isolate.type")) {
|
||||
if (type == "keyantimicrobials") {
|
||||
message_("Basing inclusion on key antimicrobials, ",
|
||||
ifelse(ignore_I == FALSE, "not ", ""),
|
||||
"ignoring I",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
}
|
||||
if (type == "points") {
|
||||
message_("[Criterion] Base inclusion on key antibiotics, using points threshold of "
|
||||
message_("Basing inclusion on all antimicrobial results, using a points threshold of "
|
||||
, points_threshold,
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
}
|
||||
remember_thrown_message("first_isolate.type")
|
||||
}
|
||||
type_param <- type
|
||||
|
||||
x$other_key_ab <- !key_antibiotics_equal(y = x$newvar_key_ab,
|
||||
z = pm_lag(x$newvar_key_ab),
|
||||
type = type_param,
|
||||
ignore_I = ignore_I,
|
||||
points_threshold = points_threshold,
|
||||
info = info)
|
||||
x$other_key_ab <- !antimicrobials_equal(y = x$newvar_key_ab,
|
||||
z = pm_lag(x$newvar_key_ab),
|
||||
type = type_param,
|
||||
ignore_I = ignore_I,
|
||||
points_threshold = points_threshold)
|
||||
# with key antibiotics
|
||||
x$newvar_first_isolate <- pm_if_else(x$newvar_row_index_sorted >= row.start &
|
||||
x$newvar_row_index_sorted <= row.end &
|
||||
@@ -423,12 +512,12 @@ first_isolate <- function(x = NULL,
|
||||
}
|
||||
if (!is.null(col_icu)) {
|
||||
if (icu_exclude == TRUE) {
|
||||
message_("[Criterion] Exclude isolates from ICU.",
|
||||
message_("Excluding isolates from ICU.",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
x[which(as.logical(x[, col_icu, drop = TRUE])), "newvar_first_isolate"] <- FALSE
|
||||
} else {
|
||||
message_("[Criterion] Include isolates from ICU.",
|
||||
message_("Including isolates from ICU.",
|
||||
add_fn = font_black,
|
||||
as_note = FALSE)
|
||||
}
|
||||
@@ -453,7 +542,9 @@ first_isolate <- function(x = NULL,
|
||||
paste0('"', x, '"')
|
||||
}
|
||||
})
|
||||
cat("\nGroup: ", paste0(names(group), " = ", group, collapse = ", "), "\n", sep = "")
|
||||
message_("\nGroup: ", paste0(names(group), " = ", group, collapse = ", "), "\n",
|
||||
as_note = FALSE,
|
||||
add_fn = font_red)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -491,10 +582,10 @@ first_isolate <- function(x = NULL,
|
||||
n_found <- sum(x$newvar_first_isolate, na.rm = TRUE)
|
||||
p_found_total <- percentage(n_found / nrow(x[which(!is.na(x$newvar_mo)), , drop = FALSE]), digits = 1)
|
||||
p_found_scope <- percentage(n_found / scope.size, digits = 1)
|
||||
if (!p_found_total %like% "[.]") {
|
||||
if (p_found_total %unlike% "[.]") {
|
||||
p_found_total <- gsub("%", ".0%", p_found_total, fixed = TRUE)
|
||||
}
|
||||
if (!p_found_scope %like% "[.]") {
|
||||
if (p_found_scope %unlike% "[.]") {
|
||||
p_found_scope <- gsub("%", ".0%", p_found_scope, fixed = TRUE)
|
||||
}
|
||||
# mark up number of found
|
||||
@@ -502,11 +593,11 @@ first_isolate <- function(x = NULL,
|
||||
if (p_found_total != p_found_scope) {
|
||||
msg_txt <- paste0("=> Found ",
|
||||
font_bold(paste0(n_found, " first ", weighted.notice, "isolates")),
|
||||
" (", p_found_scope, " within scope and ", p_found_total, " of total where a microbial ID was available)")
|
||||
" (", method, ", ", p_found_scope, " within scope and ", p_found_total, " of total where a microbial ID was available)")
|
||||
} else {
|
||||
msg_txt <- paste0("=> Found ",
|
||||
font_bold(paste0(n_found, " first ", weighted.notice, "isolates")),
|
||||
" (", p_found_total, " of total where a microbial ID was available)")
|
||||
" (", method, ", ", p_found_total, " of total where a microbial ID was available)")
|
||||
}
|
||||
message_(msg_txt, add_fn = font_black, as_note = FALSE)
|
||||
}
|
||||
@@ -521,6 +612,8 @@ filter_first_isolate <- function(x = NULL,
|
||||
col_date = NULL,
|
||||
col_patient_id = NULL,
|
||||
col_mo = NULL,
|
||||
episode_days = 365,
|
||||
method = c("phenotype-based", "episode-based", "patient-based", "isolate-based"),
|
||||
...) {
|
||||
if (is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
@@ -531,47 +624,27 @@ filter_first_isolate <- function(x = NULL,
|
||||
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
|
||||
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE)
|
||||
method <- coerce_method(method)
|
||||
meet_criteria(method, allow_class = "character", has_length = 1, is_in = c("phenotype-based", "episode-based", "patient-based", "isolate-based", "p", "e", "i"))
|
||||
|
||||
subset(x, first_isolate(x = x,
|
||||
col_date = col_date,
|
||||
col_patient_id = col_patient_id,
|
||||
col_mo = col_mo,
|
||||
episode_days = episode_days,
|
||||
method = method,
|
||||
...))
|
||||
}
|
||||
|
||||
#' @rdname first_isolate
|
||||
#' @export
|
||||
filter_first_weighted_isolate <- function(x = NULL,
|
||||
col_date = NULL,
|
||||
col_patient_id = NULL,
|
||||
col_mo = NULL,
|
||||
col_keyantibiotics = NULL,
|
||||
...) {
|
||||
if (is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
# is also fix for using a grouped df as input (a dot as first argument)
|
||||
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||
coerce_method <- function(method) {
|
||||
if (is.null(method)) {
|
||||
return(method)
|
||||
}
|
||||
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
||||
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
|
||||
|
||||
y <- x
|
||||
if (is.null(col_keyantibiotics)) {
|
||||
# first try to look for it
|
||||
col_keyantibiotics <- search_type_in_df(x = x, type = "keyantibiotics")
|
||||
# still NULL? Then create it since we are calling filter_first_WEIGHTED_isolate()
|
||||
if (is.null(col_keyantibiotics)) {
|
||||
y$keyab <- suppressMessages(key_antibiotics(x,
|
||||
col_mo = col_mo,
|
||||
...))
|
||||
col_keyantibiotics <- "keyab"
|
||||
}
|
||||
}
|
||||
|
||||
subset(x, first_isolate(x = y,
|
||||
col_date = col_date,
|
||||
col_patient_id = col_patient_id))
|
||||
method <- tolower(as.character(method[1L]))
|
||||
method[method %like% "^(p$|pheno)"] <- "phenotype-based"
|
||||
method[method %like% "^(e$|episode)"] <- "episode-based"
|
||||
method[method %like% "^patient"] <- "patient-based"
|
||||
method[method %like% "^(i$|iso)"] <- "isolate-based"
|
||||
method
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#' @param arrows_textangled a logical whether the text at the end of the arrows should be angled
|
||||
#' @param arrows_alpha the alpha (transparency) of the arrows and their text
|
||||
#' @param base_textsize the text size for all plot elements except the labels and arrows
|
||||
#' @param ... Arguments passed on to functions
|
||||
#' @param ... arguments passed on to functions
|
||||
#' @source The [ggplot_pca()] function is based on the `ggbiplot()` function from the `ggbiplot` package by Vince Vu, as found on GitHub: <https://github.com/vqv/ggbiplot> (retrieved: 2 March 2020, their latest commit: [`7325e88`](https://github.com/vqv/ggbiplot/commit/7325e880485bea4c07465a0304c470608fffb5d9); 12 February 2015).
|
||||
#'
|
||||
#' As per their GPL-2 licence that demands documentation of code changes, the changes made based on the source code were:
|
||||
|
||||
@@ -66,6 +66,7 @@ globalVariables(c(".rowid",
|
||||
"antibiotics",
|
||||
"atc_group1",
|
||||
"atc_group2",
|
||||
"base_ab",
|
||||
"code",
|
||||
"cols",
|
||||
"count",
|
||||
|
||||
@@ -102,6 +102,7 @@ get_column_abx <- function(x,
|
||||
verbose = FALSE,
|
||||
info = TRUE,
|
||||
only_rsi_columns = FALSE,
|
||||
sort = TRUE,
|
||||
...) {
|
||||
meet_criteria(x, allow_class = "data.frame")
|
||||
meet_criteria(soft_dependencies, allow_class = "character", allow_NULL = TRUE)
|
||||
@@ -109,6 +110,7 @@ get_column_abx <- function(x,
|
||||
meet_criteria(verbose, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(sort, allow_class = "logical", has_length = 1)
|
||||
|
||||
if (info == TRUE) {
|
||||
message_("Auto-guessing columns suitable for analysis", appendLF = FALSE, as_note = FALSE)
|
||||
@@ -186,11 +188,15 @@ get_column_abx <- function(x,
|
||||
}
|
||||
|
||||
# sort on name
|
||||
x <- x[order(names(x), x)]
|
||||
if (sort == TRUE) {
|
||||
x <- x[order(names(x), x)]
|
||||
}
|
||||
duplicates <- c(x[duplicated(x)], x[duplicated(names(x))])
|
||||
duplicates <- duplicates[unique(names(duplicates))]
|
||||
x <- c(x[!names(x) %in% names(duplicates)], duplicates)
|
||||
x <- x[order(names(x), x)]
|
||||
if (sort == TRUE) {
|
||||
x <- x[order(names(x), x)]
|
||||
}
|
||||
|
||||
# succeeded with auto-guessing
|
||||
if (info == TRUE) {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#' @param x existing table to join, or character vector
|
||||
#' @param by a variable to join by - if left empty will search for a column with class [`mo`] (created with [as.mo()]) or will be `"mo"` if that column name exists in `x`, could otherwise be a column name of `x` with values that exist in `microorganisms$mo` (such as `by = "bacteria_id"`), or another column in [microorganisms] (but then it should be named, like `by = c("bacteria_id" = "fullname")`)
|
||||
#' @param suffix if there are non-joined duplicate variables in `x` and `y`, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2.
|
||||
#' @param ... ignored
|
||||
#' @param ... ignored, only in place to allow future extensions
|
||||
#' @details **Note:** As opposed to the `join()` functions of `dplyr`, [character] vectors are supported and at default existing columns will get a suffix `"2"` and the newly joined columns will not get a suffix.
|
||||
#'
|
||||
#' If the `dplyr` package is installed, their join functions will be used. Otherwise, the much slower [merge()] function from base R will be used.
|
||||
@@ -279,7 +279,7 @@ check_groups_before_join <- function(x, fn) {
|
||||
if (is.data.frame(x) && !is.null(attributes(x)$groups)) {
|
||||
x <- pm_ungroup(x)
|
||||
attr(x, "groups") <- NULL
|
||||
class(x) <- class(x)[!class(x) %like% "group"]
|
||||
class(x) <- class(x)[class(x) %unlike% "group"]
|
||||
warning_("Groups are dropped, since the ", fn, "() function relies on merge() from base R.", call = FALSE)
|
||||
}
|
||||
x
|
||||
|
||||
@@ -1,380 +0,0 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Data Analysis for R #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# We created this package for both routine data analysis and academic #
|
||||
# research and it was publicly released in the hope that it will be #
|
||||
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
||||
# #
|
||||
# Visit our website for the full manual and a complete tutorial about #
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Key Antibiotics for First (Weighted) Isolates
|
||||
#'
|
||||
#' These function can be used to determine first isolates (see [first_isolate()]). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first 'weighted' isolates.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank to determine automatically
|
||||
#' @param y,z character vectors to compare
|
||||
#' @inheritParams first_isolate
|
||||
#' @param universal_1,universal_2,universal_3,universal_4,universal_5,universal_6 column names of **broad-spectrum** antibiotics, case-insensitive. See details for which antibiotics will be used at default (which are guessed with [guess_ab_col()]).
|
||||
#' @param GramPos_1,GramPos_2,GramPos_3,GramPos_4,GramPos_5,GramPos_6 column names of antibiotics for **Gram-positives**, case-insensitive. See details for which antibiotics will be used at default (which are guessed with [guess_ab_col()]).
|
||||
#' @param GramNeg_1,GramNeg_2,GramNeg_3,GramNeg_4,GramNeg_5,GramNeg_6 column names of antibiotics for **Gram-negatives**, case-insensitive. See details for which antibiotics will be used at default (which are guessed with [guess_ab_col()]).
|
||||
#' @param warnings give a warning about missing antibiotic columns (they will be ignored)
|
||||
#' @param ... other arguments passed on to functions
|
||||
#' @details
|
||||
#' The [key_antibiotics()] function is context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#'
|
||||
#' The function [key_antibiotics()] returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using [key_antibiotics_equal()], to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (`"."`) by [key_antibiotics()] and ignored by [key_antibiotics_equal()].
|
||||
#'
|
||||
#' The [first_isolate()] function only uses this function on the same microbial species from the same patient. Using this, e.g. an MRSA will be included after a susceptible *S. aureus* (MSSA) is found within the same patient episode. Without key antibiotic comparison it would not. See [first_isolate()] for more info.
|
||||
#'
|
||||
#' At default, the antibiotics that are used for **Gram-positive bacteria** are:
|
||||
#' - Amoxicillin
|
||||
#' - Amoxicillin/clavulanic acid
|
||||
#' - Cefuroxime
|
||||
#' - Piperacillin/tazobactam
|
||||
#' - Ciprofloxacin
|
||||
#' - Trimethoprim/sulfamethoxazole
|
||||
#' - Vancomycin
|
||||
#' - Teicoplanin
|
||||
#' - Tetracycline
|
||||
#' - Erythromycin
|
||||
#' - Oxacillin
|
||||
#' - Rifampin
|
||||
#'
|
||||
#' At default the antibiotics that are used for **Gram-negative bacteria** are:
|
||||
#' - Amoxicillin
|
||||
#' - Amoxicillin/clavulanic acid
|
||||
#' - Cefuroxime
|
||||
#' - Piperacillin/tazobactam
|
||||
#' - Ciprofloxacin
|
||||
#' - Trimethoprim/sulfamethoxazole
|
||||
#' - Gentamicin
|
||||
#' - Tobramycin
|
||||
#' - Colistin
|
||||
#' - Cefotaxime
|
||||
#' - Ceftazidime
|
||||
#' - Meropenem
|
||||
#'
|
||||
#' The function [key_antibiotics_equal()] checks the characters returned by [key_antibiotics()] for equality, and returns a [`logical`] vector.
|
||||
#' @inheritSection first_isolate Key Antibiotics
|
||||
#' @rdname key_antibiotics
|
||||
#' @export
|
||||
#' @seealso [first_isolate()]
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' # output of the `key_antibiotics()` function could be like this:
|
||||
#' strainA <- "SSSRR.S.R..S"
|
||||
#' strainB <- "SSSIRSSSRSSS"
|
||||
#'
|
||||
#' # those strings can be compared with:
|
||||
#' key_antibiotics_equal(strainA, strainB)
|
||||
#' # TRUE, because I is ignored (as well as missing values)
|
||||
#'
|
||||
#' key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
|
||||
#' # FALSE, because I is not ignored and so the 4th character differs
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' # set key antibiotics to a new variable
|
||||
#' my_patients <- example_isolates %>%
|
||||
#' mutate(keyab = key_antibiotics()) %>% # no need to define `x`
|
||||
#' mutate(
|
||||
#' # now calculate first isolates
|
||||
#' first_regular = first_isolate(col_keyantibiotics = FALSE),
|
||||
#' # and first WEIGHTED isolates
|
||||
#' first_weighted = first_isolate(col_keyantibiotics = "keyab")
|
||||
#' )
|
||||
#'
|
||||
#' # Check the difference, in this data set it results in a lot more isolates:
|
||||
#' sum(my_patients$first_regular, na.rm = TRUE)
|
||||
#' sum(my_patients$first_weighted, na.rm = TRUE)
|
||||
#' }
|
||||
#' }
|
||||
key_antibiotics <- function(x = NULL,
|
||||
col_mo = NULL,
|
||||
universal_1 = guess_ab_col(x, "amoxicillin"),
|
||||
universal_2 = guess_ab_col(x, "amoxicillin/clavulanic acid"),
|
||||
universal_3 = guess_ab_col(x, "cefuroxime"),
|
||||
universal_4 = guess_ab_col(x, "piperacillin/tazobactam"),
|
||||
universal_5 = guess_ab_col(x, "ciprofloxacin"),
|
||||
universal_6 = guess_ab_col(x, "trimethoprim/sulfamethoxazole"),
|
||||
GramPos_1 = guess_ab_col(x, "vancomycin"),
|
||||
GramPos_2 = guess_ab_col(x, "teicoplanin"),
|
||||
GramPos_3 = guess_ab_col(x, "tetracycline"),
|
||||
GramPos_4 = guess_ab_col(x, "erythromycin"),
|
||||
GramPos_5 = guess_ab_col(x, "oxacillin"),
|
||||
GramPos_6 = guess_ab_col(x, "rifampin"),
|
||||
GramNeg_1 = guess_ab_col(x, "gentamicin"),
|
||||
GramNeg_2 = guess_ab_col(x, "tobramycin"),
|
||||
GramNeg_3 = guess_ab_col(x, "colistin"),
|
||||
GramNeg_4 = guess_ab_col(x, "cefotaxime"),
|
||||
GramNeg_5 = guess_ab_col(x, "ceftazidime"),
|
||||
GramNeg_6 = guess_ab_col(x, "meropenem"),
|
||||
warnings = TRUE,
|
||||
...) {
|
||||
if (is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
# is also fix for using a grouped df as input (a dot as first argument)
|
||||
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||
}
|
||||
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(universal_1, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(universal_2, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(universal_3, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(universal_4, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(universal_5, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(universal_6, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramPos_1, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramPos_2, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramPos_3, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramPos_4, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramPos_5, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramPos_6, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramNeg_1, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramNeg_2, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramNeg_3, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramNeg_4, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramNeg_5, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(GramNeg_6, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(warnings, allow_class = "logical", has_length = 1)
|
||||
|
||||
# force regular data.frame, not a tibble or data.table
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
|
||||
dots <- unlist(list(...))
|
||||
if (length(dots) != 0) {
|
||||
# backwards compatibility with old arguments
|
||||
dots.names <- names(dots)
|
||||
if ("info" %in% dots.names) {
|
||||
warnings <- dots[which(dots.names == "info")]
|
||||
}
|
||||
}
|
||||
|
||||
# try to find columns based on type
|
||||
# -- mo
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo")
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
} else {
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
}
|
||||
|
||||
# check columns
|
||||
col.list <- c(universal_1, universal_2, universal_3, universal_4, universal_5, universal_6,
|
||||
GramPos_1, GramPos_2, GramPos_3, GramPos_4, GramPos_5, GramPos_6,
|
||||
GramNeg_1, GramNeg_2, GramNeg_3, GramNeg_4, GramNeg_5, GramNeg_6)
|
||||
check_available_columns <- function(x, col.list, warnings = TRUE) {
|
||||
# check columns
|
||||
col.list <- col.list[!is.na(col.list) & !is.null(col.list)]
|
||||
names(col.list) <- col.list
|
||||
col.list.bak <- col.list
|
||||
# are they available as upper case or lower case then?
|
||||
for (i in seq_len(length(col.list))) {
|
||||
if (is.null(col.list[i]) | isTRUE(is.na(col.list[i]))) {
|
||||
col.list[i] <- NA
|
||||
} else if (toupper(col.list[i]) %in% colnames(x)) {
|
||||
col.list[i] <- toupper(col.list[i])
|
||||
} else if (tolower(col.list[i]) %in% colnames(x)) {
|
||||
col.list[i] <- tolower(col.list[i])
|
||||
} else if (!col.list[i] %in% colnames(x)) {
|
||||
col.list[i] <- NA
|
||||
}
|
||||
}
|
||||
if (!all(col.list %in% colnames(x))) {
|
||||
if (warnings == TRUE) {
|
||||
warning_("Some columns do not exist and will be ignored: ",
|
||||
col.list.bak[!(col.list %in% colnames(x))] %pm>% toString(),
|
||||
".\nTHIS MAY STRONGLY INFLUENCE THE OUTCOME.",
|
||||
immediate = TRUE,
|
||||
call = FALSE)
|
||||
}
|
||||
}
|
||||
col.list
|
||||
}
|
||||
|
||||
col.list <- check_available_columns(x = x, col.list = col.list, warnings = warnings)
|
||||
universal_1 <- col.list[universal_1]
|
||||
universal_2 <- col.list[universal_2]
|
||||
universal_3 <- col.list[universal_3]
|
||||
universal_4 <- col.list[universal_4]
|
||||
universal_5 <- col.list[universal_5]
|
||||
universal_6 <- col.list[universal_6]
|
||||
GramPos_1 <- col.list[GramPos_1]
|
||||
GramPos_2 <- col.list[GramPos_2]
|
||||
GramPos_3 <- col.list[GramPos_3]
|
||||
GramPos_4 <- col.list[GramPos_4]
|
||||
GramPos_5 <- col.list[GramPos_5]
|
||||
GramPos_6 <- col.list[GramPos_6]
|
||||
GramNeg_1 <- col.list[GramNeg_1]
|
||||
GramNeg_2 <- col.list[GramNeg_2]
|
||||
GramNeg_3 <- col.list[GramNeg_3]
|
||||
GramNeg_4 <- col.list[GramNeg_4]
|
||||
GramNeg_5 <- col.list[GramNeg_5]
|
||||
GramNeg_6 <- col.list[GramNeg_6]
|
||||
|
||||
universal <- c(universal_1, universal_2, universal_3,
|
||||
universal_4, universal_5, universal_6)
|
||||
|
||||
gram_positive <- c(universal,
|
||||
GramPos_1, GramPos_2, GramPos_3,
|
||||
GramPos_4, GramPos_5, GramPos_6)
|
||||
gram_positive <- gram_positive[!is.null(gram_positive)]
|
||||
gram_positive <- gram_positive[!is.na(gram_positive)]
|
||||
if (length(gram_positive) < 12 & message_not_thrown_before("key_antibiotics.grampos")) {
|
||||
warning_("Only using ", length(gram_positive), " different antibiotics as key antibiotics for Gram-positives. See ?key_antibiotics.", call = FALSE)
|
||||
remember_thrown_message("key_antibiotics.grampos")
|
||||
}
|
||||
|
||||
gram_negative <- c(universal,
|
||||
GramNeg_1, GramNeg_2, GramNeg_3,
|
||||
GramNeg_4, GramNeg_5, GramNeg_6)
|
||||
gram_negative <- gram_negative[!is.null(gram_negative)]
|
||||
gram_negative <- gram_negative[!is.na(gram_negative)]
|
||||
if (length(gram_negative) < 12 & message_not_thrown_before("key_antibiotics.gramneg")) {
|
||||
warning_("Only using ", length(gram_negative), " different antibiotics as key antibiotics for Gram-negatives. See ?key_antibiotics.", call = FALSE)
|
||||
remember_thrown_message("key_antibiotics.gramneg")
|
||||
}
|
||||
|
||||
x[, col_mo] <- as.mo(x[, col_mo, drop = TRUE])
|
||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
||||
x$key_ab <- NA_character_
|
||||
|
||||
# Gram +
|
||||
x$key_ab <- pm_if_else(x$gramstain == "Gram-positive",
|
||||
tryCatch(apply(X = x[, gram_positive],
|
||||
MARGIN = 1,
|
||||
FUN = function(x) paste(x, collapse = "")),
|
||||
error = function(e) paste0(rep(".", 12), collapse = "")),
|
||||
x$key_ab)
|
||||
|
||||
# Gram -
|
||||
x$key_ab <- pm_if_else(x$gramstain == "Gram-negative",
|
||||
tryCatch(apply(X = x[, gram_negative],
|
||||
MARGIN = 1,
|
||||
FUN = function(x) paste(x, collapse = "")),
|
||||
error = function(e) paste0(rep(".", 12), collapse = "")),
|
||||
x$key_ab)
|
||||
|
||||
# format
|
||||
key_abs <- toupper(gsub("[^SIR]", ".", gsub("(NA|NULL)", ".", x$key_ab)))
|
||||
|
||||
if (pm_n_distinct(key_abs) == 1) {
|
||||
warning_("No distinct key antibiotics determined.", call = FALSE)
|
||||
}
|
||||
|
||||
key_abs
|
||||
|
||||
}
|
||||
|
||||
#' @rdname key_antibiotics
|
||||
#' @export
|
||||
key_antibiotics_equal <- function(y,
|
||||
z,
|
||||
type = c("keyantibiotics", "points"),
|
||||
ignore_I = TRUE,
|
||||
points_threshold = 2,
|
||||
info = FALSE) {
|
||||
meet_criteria(y, allow_class = "character")
|
||||
meet_criteria(z, allow_class = "character")
|
||||
meet_criteria(type, allow_class = "character", has_length = c(1, 2))
|
||||
meet_criteria(ignore_I, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
|
||||
stop_ifnot(length(y) == length(z), "length of `y` and `z` must be equal")
|
||||
# y is active row, z is lag
|
||||
x <- y
|
||||
y <- z
|
||||
|
||||
type <- type[1]
|
||||
|
||||
# only show progress bar on points or when at least 5000 isolates
|
||||
info_needed <- info == TRUE & (type == "points" | length(x) > 5000)
|
||||
|
||||
result <- logical(length(x))
|
||||
|
||||
if (info_needed == TRUE) {
|
||||
p <- progress_ticker(length(x))
|
||||
on.exit(close(p))
|
||||
}
|
||||
|
||||
for (i in seq_len(length(x))) {
|
||||
|
||||
if (info_needed == TRUE) {
|
||||
p$tick()
|
||||
}
|
||||
|
||||
if (is.na(x[i])) {
|
||||
x[i] <- ""
|
||||
}
|
||||
if (is.na(y[i])) {
|
||||
y[i] <- ""
|
||||
}
|
||||
|
||||
if (x[i] == y[i]) {
|
||||
|
||||
result[i] <- TRUE
|
||||
|
||||
} else if (nchar(x[i]) != nchar(y[i])) {
|
||||
|
||||
result[i] <- FALSE
|
||||
|
||||
} else {
|
||||
|
||||
x_split <- strsplit(x[i], "")[[1]]
|
||||
y_split <- strsplit(y[i], "")[[1]]
|
||||
|
||||
if (type == "keyantibiotics") {
|
||||
|
||||
if (ignore_I == TRUE) {
|
||||
x_split[x_split == "I"] <- "."
|
||||
y_split[y_split == "I"] <- "."
|
||||
}
|
||||
|
||||
y_split[x_split == "."] <- "."
|
||||
x_split[y_split == "."] <- "."
|
||||
|
||||
result[i] <- all(x_split == y_split)
|
||||
|
||||
} else if (type == "points") {
|
||||
# count points for every single character:
|
||||
# - no change is 0 points
|
||||
# - I <-> S|R is 0.5 point
|
||||
# - S|R <-> R|S is 1 point
|
||||
# use the levels of as.rsi (S = 1, I = 2, R = 3)
|
||||
|
||||
suppressWarnings(x_split <- x_split %pm>% as.rsi() %pm>% as.double())
|
||||
suppressWarnings(y_split <- y_split %pm>% as.rsi() %pm>% as.double())
|
||||
|
||||
points <- (x_split - y_split) %pm>% abs() %pm>% sum(na.rm = TRUE) / 2
|
||||
result[i] <- points >= points_threshold
|
||||
|
||||
} else {
|
||||
stop("`", type, '` is not a valid value for type, must be "points" or "keyantibiotics". See ?key_antibiotics')
|
||||
}
|
||||
}
|
||||
}
|
||||
if (info_needed == TRUE) {
|
||||
close(p)
|
||||
}
|
||||
result
|
||||
}
|
||||
325
R/key_antimicrobials.R
Executable file
@@ -0,0 +1,325 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Data Analysis for R #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2021 Berends MS, Luz CF et al. #
|
||||
# Developed at the University of Groningen, the Netherlands, in #
|
||||
# collaboration with non-profit organisations Certe Medical #
|
||||
# Diagnostics & Advice, and University Medical Center Groningen. #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# We created this package for both routine data analysis and academic #
|
||||
# research and it was publicly released in the hope that it will be #
|
||||
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
||||
# #
|
||||
# Visit our website for the full manual and a complete tutorial about #
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' (Key) Antimicrobials for First Weighted Isolates
|
||||
#'
|
||||
#' These functions can be used to determine first weighted isolates by considering the phenotype for isolate selection (see [first_isolate()]). Using a phenotype-based method to determine first isolates is more reliable than methods that disregard phenotypes.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank to determine automatically
|
||||
#' @param y,z character vectors to compare
|
||||
#' @inheritParams first_isolate
|
||||
#' @param universal names of **broad-spectrum** antimicrobial agents, case-insensitive. Set to `NULL` to ignore. See *Details* for the default agents.
|
||||
#' @param gram_negative names of antibiotic agents for **Gram-positives**, case-insensitive. Set to `NULL` to ignore. See *Details* for the default agents.
|
||||
#' @param gram_positive names of antibiotic agents for **Gram-negatives**, case-insensitive. Set to `NULL` to ignore. See *Details* for the default agents.
|
||||
#' @param antifungal names of antifungal agents for **fungi**, case-insensitive. Set to `NULL` to ignore. See *Details* for the default agents.
|
||||
#' @param only_rsi_columns a logical to indicate whether only columns must be included that were transformed to class `<rsi>` (see [as.rsi()]) on beforehand (defaults to `FALSE`)
|
||||
#' @param ... ignored, only in place to allow future extensions
|
||||
#' @details
|
||||
#' The [key_antimicrobials()] and [all_antimicrobials()] functions are context-aware. This means that then the `x` argument can be left blank, see *Examples*.
|
||||
#'
|
||||
#' The function [key_antimicrobials()] returns a character vector with 12 antimicrobial results for every isolate. The function [all_antimicrobials()] returns a character vector with all antimicrobial results for every isolate. These vectors can then be compared using [antimicrobials_equal()], to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (`"."`) by [key_antimicrobials()] and ignored by [antimicrobials_equal()].
|
||||
#'
|
||||
#' Please see the [first_isolate()] function how these important functions enable the 'phenotype-based' method for determination of first isolates.
|
||||
#'
|
||||
#' The default antimicrobial agents used for **all rows** (set in `universal`) are:
|
||||
#'
|
||||
#' - Ampicillin
|
||||
#' - Amoxicillin/clavulanic acid
|
||||
#' - Cefuroxime
|
||||
#' - Ciprofloxacin
|
||||
#' - Piperacillin/tazobactam
|
||||
#' - Trimethoprim/sulfamethoxazole
|
||||
#'
|
||||
#' The default antimicrobial agents used for **Gram-negative bacteria** (set in `gram_negative`) are:
|
||||
#'
|
||||
#' - Cefotaxime
|
||||
#' - Ceftazidime
|
||||
#' - Colistin
|
||||
#' - Gentamicin
|
||||
#' - Meropenem
|
||||
#' - Tobramycin
|
||||
#'
|
||||
#' The default antimicrobial agents used for **Gram-positive bacteria** (set in `gram_positive`) are:
|
||||
#'
|
||||
#' - Erythromycin
|
||||
#' - Oxacillin
|
||||
#' - Rifampin
|
||||
#' - Teicoplanin
|
||||
#' - Tetracycline
|
||||
#' - Vancomycin
|
||||
#'
|
||||
#'
|
||||
#' The default antimicrobial agents used for **fungi** (set in `antifungal`) are:
|
||||
#'
|
||||
#' - Anidulafungin
|
||||
#' - Caspofungin
|
||||
#' - Fluconazole
|
||||
#' - Miconazole
|
||||
#' - Nystatin
|
||||
#' - Voriconazole
|
||||
#' @rdname key_antimicrobials
|
||||
#' @export
|
||||
#' @seealso [first_isolate()]
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # `example_isolates` is a data set available in the AMR package.
|
||||
#' # See ?example_isolates.
|
||||
#'
|
||||
#' # output of the `key_antimicrobials()` function could be like this:
|
||||
#' strainA <- "SSSRR.S.R..S"
|
||||
#' strainB <- "SSSIRSSSRSSS"
|
||||
#'
|
||||
#' # those strings can be compared with:
|
||||
#' antimicrobials_equal(strainA, strainB, type = "keyantimicrobials")
|
||||
#' # TRUE, because I is ignored (as well as missing values)
|
||||
#'
|
||||
#' antimicrobials_equal(strainA, strainB, type = "keyantimicrobials", ignore_I = FALSE)
|
||||
#' # FALSE, because I is not ignored and so the 4th character differs
|
||||
#'
|
||||
#' \donttest{
|
||||
#' if (require("dplyr")) {
|
||||
#' # set key antibiotics to a new variable
|
||||
#' my_patients <- example_isolates %>%
|
||||
#' mutate(keyab = key_antimicrobials(antifungal = NULL)) %>% # no need to define `x`
|
||||
#' mutate(
|
||||
#' # now calculate first isolates
|
||||
#' first_regular = first_isolate(col_keyantimicrobials = FALSE),
|
||||
#' # and first WEIGHTED isolates
|
||||
#' first_weighted = first_isolate(col_keyantimicrobials = "keyab")
|
||||
#' )
|
||||
#'
|
||||
#' # Check the difference, in this data set it results in more isolates:
|
||||
#' sum(my_patients$first_regular, na.rm = TRUE)
|
||||
#' sum(my_patients$first_weighted, na.rm = TRUE)
|
||||
#' }
|
||||
#' }
|
||||
key_antimicrobials <- function(x = NULL,
|
||||
col_mo = NULL,
|
||||
universal = c("ampicillin", "amoxicillin/clavulanic acid", "cefuroxime",
|
||||
"piperacillin/tazobactam", "ciprofloxacin", "trimethoprim/sulfamethoxazole"),
|
||||
gram_negative = c("gentamicin", "tobramycin", "colistin",
|
||||
"cefotaxime", "ceftazidime", "meropenem"),
|
||||
gram_positive = c("vancomycin", "teicoplanin", "tetracycline",
|
||||
"erythromycin", "oxacillin", "rifampin"),
|
||||
antifungal = c("anidulafungin", "caspofungin", "fluconazole",
|
||||
"miconazole", "nystatin", "voriconazole"),
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
if (is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
# is also fix for using a grouped df as input (a dot as first argument)
|
||||
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||
}
|
||||
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
||||
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE, is_in = colnames(x))
|
||||
meet_criteria(universal, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(gram_negative, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(gram_positive, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(antifungal, allow_class = "character", allow_NULL = TRUE)
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
|
||||
# force regular data.frame, not a tibble or data.table
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
cols <- get_column_abx(x, info = FALSE, only_rsi_columns = only_rsi_columns)
|
||||
|
||||
# try to find columns based on type
|
||||
# -- mo
|
||||
if (is.null(col_mo)) {
|
||||
col_mo <- search_type_in_df(x = x, type = "mo", info = FALSE)
|
||||
}
|
||||
if (is.null(col_mo)) {
|
||||
warning_("No column found for `col_mo`, ignoring antibiotics set in `gram_negative` and `gram_positive`, and antimycotics set in `antifungal`", call = FALSE)
|
||||
gramstain <- NA_character_
|
||||
kingdom <- NA_character_
|
||||
} else {
|
||||
x.mo <- as.mo(x[, col_mo, drop = TRUE])
|
||||
gramstain <- mo_gramstain(x.mo, language = NULL)
|
||||
kingdom <- mo_kingdom(x.mo, language = NULL)
|
||||
}
|
||||
|
||||
AMR_string <- function(x, values, name, filter, cols = cols) {
|
||||
if (is.null(values)) {
|
||||
return(rep(NA_character_, length(which(filter))))
|
||||
}
|
||||
|
||||
values_old_length <- length(values)
|
||||
values <- as.ab(values, flag_multiple_results = FALSE, info = FALSE)
|
||||
values <- cols[names(cols) %in% values]
|
||||
values_new_length <- length(values)
|
||||
|
||||
if (values_new_length < values_old_length &
|
||||
any(filter, na.rm = TRUE) &
|
||||
message_not_thrown_before(paste0("key_antimicrobials.", name))) {
|
||||
warning_(ifelse(values_new_length == 0,
|
||||
"No columns available ",
|
||||
paste0("Only using ", values_new_length, " out of ", values_old_length, " defined columns ")),
|
||||
"as key antimicrobials for ", name, "s. See ?key_antimicrobials.",
|
||||
call = FALSE)
|
||||
remember_thrown_message(paste0("key_antimicrobials.", name))
|
||||
}
|
||||
|
||||
generate_antimcrobials_string(x[which(filter), c(universal, values), drop = FALSE])
|
||||
}
|
||||
|
||||
if (is.null(universal)) {
|
||||
universal <- character(0)
|
||||
} else {
|
||||
universal <- as.ab(universal, flag_multiple_results = FALSE, info = FALSE)
|
||||
universal <- cols[names(cols) %in% universal]
|
||||
}
|
||||
|
||||
key_ab <- rep(NA_character_, nrow(x))
|
||||
|
||||
key_ab[which(gramstain == "Gram-negative")] <- AMR_string(x = x,
|
||||
values = gram_negative,
|
||||
name = "Gram-negative",
|
||||
filter = gramstain == "Gram-negative",
|
||||
cols = cols)
|
||||
|
||||
key_ab[which(gramstain == "Gram-positive")] <- AMR_string(x = x,
|
||||
values = gram_positive,
|
||||
name = "Gram-positive",
|
||||
filter = gramstain == "Gram-positive",
|
||||
cols = cols)
|
||||
|
||||
key_ab[which(kingdom == "Fungi")] <- AMR_string(x = x,
|
||||
values = antifungal,
|
||||
name = "antifungal",
|
||||
filter = kingdom == "Fungi",
|
||||
cols = cols)
|
||||
|
||||
# back-up - only use `universal`
|
||||
key_ab[which(is.na(key_ab))] <- AMR_string(x = x,
|
||||
values = character(0),
|
||||
name = "",
|
||||
filter = is.na(key_ab),
|
||||
cols = cols)
|
||||
|
||||
if (length(unique(key_ab)) == 1) {
|
||||
warning_("No distinct key antibiotics determined.", call = FALSE)
|
||||
}
|
||||
|
||||
key_ab
|
||||
}
|
||||
|
||||
#' @rdname key_antimicrobials
|
||||
#' @export
|
||||
all_antimicrobials <- function(x = NULL,
|
||||
only_rsi_columns = FALSE,
|
||||
...) {
|
||||
if (is_null_or_grouped_tbl(x)) {
|
||||
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
|
||||
# is also fix for using a grouped df as input (a dot as first argument)
|
||||
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
|
||||
}
|
||||
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
|
||||
# force regular data.frame, not a tibble or data.table
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
cols <- get_column_abx(x, only_rsi_columns = only_rsi_columns, info = FALSE, sort = FALSE)
|
||||
|
||||
generate_antimcrobials_string(x[ , cols, drop = FALSE])
|
||||
}
|
||||
|
||||
generate_antimcrobials_string <- function(df) {
|
||||
if (NCOL(df) == 0) {
|
||||
return(rep("", NROW(df)))
|
||||
}
|
||||
if (NROW(df) == 0) {
|
||||
return(character(0))
|
||||
}
|
||||
out <- tryCatch(
|
||||
do.call(paste0,
|
||||
lapply(as.list(df),
|
||||
function(x) {
|
||||
x <- toupper(as.character(x))
|
||||
x[!x %in% c("R", "S", "I")] <- "."
|
||||
paste(x)
|
||||
})),
|
||||
error = function(e) rep(strrep(".", NCOL(df)), NROW(df)))
|
||||
out
|
||||
}
|
||||
|
||||
#' @rdname key_antimicrobials
|
||||
#' @export
|
||||
antimicrobials_equal <- function(y,
|
||||
z,
|
||||
type = c("points", "keyantimicrobials"),
|
||||
ignore_I = TRUE,
|
||||
points_threshold = 2,
|
||||
...) {
|
||||
meet_criteria(y, allow_class = "character")
|
||||
meet_criteria(z, allow_class = "character")
|
||||
stop_if(missing(type), "argument \"type\" is missing, with no default")
|
||||
meet_criteria(type, allow_class = "character", has_length = 1, is_in = c("points", "keyantimicrobials"))
|
||||
meet_criteria(ignore_I, allow_class = "logical", has_length = 1)
|
||||
meet_criteria(points_threshold, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
|
||||
stop_ifnot(length(y) == length(z), "length of `y` and `z` must be equal")
|
||||
|
||||
key2rsi <- function(val) {
|
||||
as.double(as.rsi(gsub(".", NA_character_, unlist(strsplit(val, "")), fixed = TRUE)))
|
||||
}
|
||||
y <- lapply(y, key2rsi)
|
||||
z <- lapply(z, key2rsi)
|
||||
|
||||
determine_equality <- function(a, b, type, points_threshold, ignore_I) {
|
||||
if (length(a) != length(b)) {
|
||||
# incomparable, so not equal
|
||||
return(FALSE)
|
||||
}
|
||||
# ignore NAs on both sides
|
||||
NA_ind <- which(is.na(a) | is.na(b))
|
||||
a[NA_ind] <- NA_real_
|
||||
b[NA_ind] <- NA_real_
|
||||
|
||||
if (type == "points") {
|
||||
# count points for every single character:
|
||||
# - no change is 0 points
|
||||
# - I <-> S|R is 0.5 point
|
||||
# - S|R <-> R|S is 1 point
|
||||
# use the levels of as.rsi (S = 1, I = 2, R = 3)
|
||||
# and divide by 2 (S = 0.5, I = 1, R = 1.5)
|
||||
(sum(abs(a - b), na.rm = TRUE) / 2) < points_threshold
|
||||
} else {
|
||||
if (ignore_I == TRUE) {
|
||||
ind <- which(a == 2 | b == 2) # since as.double(as.rsi("I")) == 2
|
||||
a[ind] <- NA_real_
|
||||
b[ind] <- NA_real_
|
||||
}
|
||||
all(a == b, na.rm = TRUE)
|
||||
}
|
||||
}
|
||||
out <- unlist(mapply(FUN = determine_equality,
|
||||
y,
|
||||
z,
|
||||
MoreArgs = list(type = type,
|
||||
points_threshold = points_threshold,
|
||||
ignore_I = ignore_I),
|
||||
SIMPLIFY = FALSE,
|
||||
USE.NAMES = FALSE))
|
||||
out[is.na(y) | is.na(z)] <- NA
|
||||
out
|
||||
}
|
||||
72
R/like.R
@@ -23,30 +23,29 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Pattern Matching with Keyboard Shortcut
|
||||
#' Vectorised Pattern Matching with Keyboard Shortcut
|
||||
#'
|
||||
#' Convenient wrapper around [grepl()] to match a pattern: `x %like% pattern`. It always returns a [`logical`] vector and is always case-insensitive (use `x %like_case% pattern` for case-sensitive matching). Also, `pattern` can be as long as `x` to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param x a character vector where matches are sought, or an object which can be coerced by [as.character()] to a character vector.
|
||||
#' @param pattern a character string containing a regular expression (or [character] string for `fixed = TRUE`) to be matched in the given character vector. Coerced by [as.character()] to a character string if possible. If a [character] vector of length 2 or more is supplied, the first element is used with a warning.
|
||||
#' @param pattern a character vector containing regular expressions (or a [character] string for `fixed = TRUE`) to be matched in the given character vector. Coerced by [as.character()] to a character string if possible.
|
||||
#' @param ignore.case if `FALSE`, the pattern matching is *case sensitive* and if `TRUE`, case is ignored during matching.
|
||||
#' @return A [`logical`] vector
|
||||
#' @return A [logical] vector
|
||||
#' @name like
|
||||
#' @rdname like
|
||||
#' @export
|
||||
#' @details
|
||||
#' The `%like%` function:
|
||||
#' * Is case-insensitive (use `%like_case%` for case-sensitive matching)
|
||||
#' * Supports multiple patterns
|
||||
#' * Checks if `pattern` is a regular expression and sets `fixed = TRUE` if not, to greatly improve speed
|
||||
#' * Always uses compatibility with Perl
|
||||
#' These [like()] and `%like%`/`%unlike%` functions:
|
||||
#' * Are case-insensitive (use `%like_case%`/`%unlike_case%` for case-sensitive matching)
|
||||
#' * Support multiple patterns
|
||||
#' * Check if `pattern` is a valid regular expression and sets `fixed = TRUE` if not, to greatly improve speed (vectorised over `pattern`)
|
||||
#' * Always use compatibility with Perl unless `fixed = TRUE`, to greatly improve speed
|
||||
#'
|
||||
#' Using RStudio? The text `%like%` can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like `Ctrl+Shift+L` or `Cmd+Shift+L` (see `Tools` > `Modify Keyboard Shortcuts...`).
|
||||
#' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/master/R/like.R)
|
||||
#' Using RStudio? The `%like%`/`%unlike%` functions can also be directly inserted in your code from the Addins menu and can have its own keyboard shortcut like `Shift+Ctrl+L` or `Shift+Cmd+L` (see menu `Tools` > `Modify Keyboard Shortcuts...`). If you keep pressing your shortcut, the inserted text will be iterated over `%like%` -> `%unlike%` -> `%like_case%` -> `%unlike_case%`.
|
||||
#' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R), although altered as explained in *Details*.
|
||||
#' @seealso [grepl()]
|
||||
#' @inheritSection AMR Read more on Our Website!
|
||||
#' @examples
|
||||
#' # simple test
|
||||
#' a <- "This is a test"
|
||||
#' b <- "TEST"
|
||||
#' a %like% b
|
||||
@@ -59,16 +58,23 @@
|
||||
#' b <- c( "case", "diff", "yet")
|
||||
#' a %like% b
|
||||
#' #> TRUE TRUE TRUE
|
||||
#' a %unlike% b
|
||||
#' #> FALSE FALSE FALSE
|
||||
#'
|
||||
#' a[1] %like% b
|
||||
#' #> TRUE FALSE FALSE
|
||||
#' a %like% b[1]
|
||||
#' #> TRUE FALSE FALSE
|
||||
#'
|
||||
#' # get isolates whose name start with 'Ent' or 'ent'
|
||||
#' example_isolates[which(mo_name(example_isolates$mo) %like% "^ent"), ]
|
||||
#' \donttest{
|
||||
#' # faster way, only works in R 3.2 and later:
|
||||
#' example_isolates[which(mo_name() %like% "^ent"), ]
|
||||
#'
|
||||
#' if (require("dplyr")) {
|
||||
#' example_isolates %>%
|
||||
#' filter(mo_name(mo) %like% "^ent")
|
||||
#' filter(mo_name() %like% "^ent")
|
||||
#' }
|
||||
#' }
|
||||
like <- function(x, pattern, ignore.case = TRUE) {
|
||||
@@ -79,9 +85,10 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
||||
if (all(is.na(x))) {
|
||||
return(rep(FALSE, length(x)))
|
||||
}
|
||||
|
||||
# set to fixed if no regex found
|
||||
fixed <- !any(is_possibly_regex(pattern))
|
||||
|
||||
# set to fixed if no valid regex (vectorised)
|
||||
fixed <- !is_valid_regex(pattern)
|
||||
|
||||
if (ignore.case == TRUE) {
|
||||
# set here, otherwise if fixed = TRUE, this warning will be thrown: argument `ignore.case = TRUE` will be ignored
|
||||
x <- tolower(x)
|
||||
@@ -91,21 +98,26 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
||||
if (is.factor(x)) {
|
||||
x <- as.character(x)
|
||||
}
|
||||
|
||||
|
||||
if (length(pattern) == 1) {
|
||||
grepl(pattern, x, ignore.case = FALSE, fixed = fixed, perl = !fixed)
|
||||
} else {
|
||||
if (length(x) == 1) {
|
||||
x <- rep(x, length(pattern))
|
||||
} else if (length(pattern) != length(x)) {
|
||||
stop_("arguments `x` and `pattern` must be of same length, or either one must be 1")
|
||||
stop_("arguments `x` and `pattern` must be of same length, or either one must be 1 ",
|
||||
"(`x` has length ", length(x), " and `pattern` has length ", length(pattern), ")")
|
||||
}
|
||||
unlist(
|
||||
Map(f = grepl,
|
||||
pattern,
|
||||
x,
|
||||
MoreArgs = list(ignore.case = FALSE, fixed = fixed, perl = !fixed)),
|
||||
use.names = FALSE)
|
||||
mapply(FUN = grepl,
|
||||
x = x,
|
||||
pattern = pattern,
|
||||
fixed = fixed,
|
||||
perl = !fixed,
|
||||
MoreArgs = list(ignore.case = FALSE),
|
||||
SIMPLIFY = FALSE,
|
||||
USE.NAMES = FALSE)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +129,14 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
||||
like(x, pattern, ignore.case = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname like
|
||||
#' @export
|
||||
"%unlike%" <- function(x, pattern) {
|
||||
meet_criteria(x, allow_NA = TRUE)
|
||||
meet_criteria(pattern, allow_NA = FALSE)
|
||||
!like(x, pattern, ignore.case = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname like
|
||||
#' @export
|
||||
"%like_case%" <- function(x, pattern) {
|
||||
@@ -124,3 +144,11 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
||||
meet_criteria(pattern, allow_NA = FALSE)
|
||||
like(x, pattern, ignore.case = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname like
|
||||
#' @export
|
||||
"%unlike_case%" <- function(x, pattern) {
|
||||
meet_criteria(x, allow_NA = TRUE)
|
||||
meet_criteria(pattern, allow_NA = FALSE)
|
||||
!like(x, pattern, ignore.case = FALSE)
|
||||
}
|
||||
|
||||
127
R/mdro.R
@@ -78,7 +78,7 @@
|
||||
#'
|
||||
#' Custom guidelines can be set with the [custom_mdro_guideline()] function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data.
|
||||
#'
|
||||
#' If you are familiar with `case_when()` of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation':
|
||||
#' If you are familiar with the [`case_when()`][dplyr::case_when()] function of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation'. The rule is written *before* the tilde (`~`) and the consequence of the rule is written *after* the tilde:
|
||||
#'
|
||||
#' ```
|
||||
#' custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A",
|
||||
@@ -102,10 +102,22 @@
|
||||
#' The outcome of the function can be used for the `guideline` argument in the [mdro()] function:
|
||||
#'
|
||||
#' ```
|
||||
#' x <- mdro(example_isolates, guideline = custom)
|
||||
#' x <- mdro(example_isolates,
|
||||
#' guideline = custom)
|
||||
#' table(x)
|
||||
#' #> Elderly Type A Elderly Type B Negative
|
||||
#' #> 43 891 1066
|
||||
#' #> Negative Elderly Type A Elderly Type B
|
||||
#' #> 1070 198 732
|
||||
#' ```
|
||||
#'
|
||||
#' Rules can also be combined with other custom rules by using [c()]:
|
||||
#'
|
||||
#' ```
|
||||
#' x <- mdro(example_isolates,
|
||||
#' guideline = c(custom,
|
||||
#' custom_mdro_guideline(ERY == "R" & age > 50 ~ "Elderly Type C")))
|
||||
#' table(x)
|
||||
#' #> Negative Elderly Type A Elderly Type B Elderly Type C
|
||||
#' #> 961 198 732 109
|
||||
#' ```
|
||||
#'
|
||||
#' The rules set (the `custom` object in this case) could be exported to a shared file location using [saveRDS()] if you collaborate with multiple users. The custom rules set could then be imported using [readRDS()].
|
||||
@@ -246,7 +258,7 @@ mdro <- function(x = NULL,
|
||||
txt <- word_wrap(txt)
|
||||
cat(txt, "\n", sep = "")
|
||||
}
|
||||
x <- run_custom_mdro_guideline(x, guideline)
|
||||
x <- run_custom_mdro_guideline(df = x, guideline = guideline, info = info)
|
||||
if (info.bak == TRUE) {
|
||||
cat(group_msg)
|
||||
if (sum(!is.na(x$MDRO)) == 0) {
|
||||
@@ -299,7 +311,6 @@ mdro <- function(x = NULL,
|
||||
col_mo <- "mo"
|
||||
}
|
||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||
|
||||
if (guideline$code == "cmi2012") {
|
||||
guideline$name <- "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance."
|
||||
@@ -749,7 +760,11 @@ mdro <- function(x = NULL,
|
||||
row_filter <- x[which(row_filter), "row_number", drop = TRUE]
|
||||
rows <- rows[rows %in% row_filter]
|
||||
x[rows, "MDRO"] <<- to
|
||||
x[rows, "reason"] <<- paste0(any_all, " of the required antibiotics ", ifelse(any_all == "any", "is", "are"), " R")
|
||||
x[rows, "reason"] <<- paste0(any_all,
|
||||
" of the required antibiotics ",
|
||||
ifelse(any_all == "any", "is", "are"),
|
||||
" R",
|
||||
ifelse(!isTRUE(combine_SI), " or I", ""))
|
||||
}
|
||||
}
|
||||
trans_tbl2 <- function(txt, rows, lst) {
|
||||
@@ -802,6 +817,9 @@ mdro <- function(x = NULL,
|
||||
}
|
||||
|
||||
x[, col_mo] <- as.mo(as.character(x[, col_mo, drop = TRUE]))
|
||||
# rename col_mo to prevent interference with joined columns
|
||||
colnames(x)[colnames(x) == col_mo] <- ".col_mo"
|
||||
col_mo <- ".col_mo"
|
||||
# join to microorganisms data set
|
||||
x <- left_join_microorganisms(x, by = col_mo)
|
||||
x$MDRO <- ifelse(!is.na(x$genus), 1, NA_integer_)
|
||||
@@ -1015,7 +1033,10 @@ mdro <- function(x = NULL,
|
||||
# PDR (=4): all agents are R
|
||||
x[which(x$classes_affected == 999 & x$classes_in_guideline == x$classes_available), "MDRO"] <- 4
|
||||
if (verbose == TRUE) {
|
||||
x[which(x$MDRO == 4), "reason"] <- paste("all antibiotics in all", x$classes_in_guideline[which(x$MDRO == 4)], "classes were tested R or I")
|
||||
x[which(x$MDRO == 4), "reason"] <- paste("all antibiotics in all",
|
||||
x$classes_in_guideline[which(x$MDRO == 4)],
|
||||
"classes were tested R",
|
||||
ifelse(!isTRUE(combine_SI), " or I", ""))
|
||||
}
|
||||
|
||||
# not enough classes available
|
||||
@@ -1378,7 +1399,12 @@ mdro <- function(x = NULL,
|
||||
# some more info on negative results
|
||||
if (verbose == TRUE) {
|
||||
if (guideline$code == "cmi2012") {
|
||||
x[which(x$MDRO == 1 & !is.na(x$classes_affected)), "reason"] <- paste0(x$classes_affected[which(x$MDRO == 1 & !is.na(x$classes_affected))], " of ", x$classes_available[which(x$MDRO == 1 & !is.na(x$classes_affected))], " available classes contain R or I (3 required for MDR)")
|
||||
x[which(x$MDRO == 1 & !is.na(x$classes_affected)), "reason"] <- paste0(x$classes_affected[which(x$MDRO == 1 & !is.na(x$classes_affected))],
|
||||
" of ",
|
||||
x$classes_available[which(x$MDRO == 1 & !is.na(x$classes_affected))],
|
||||
" available classes contain R",
|
||||
ifelse(!isTRUE(combine_SI), " or I", ""),
|
||||
" (3 required for MDR)")
|
||||
} else {
|
||||
x[which(x$MDRO == 1), "reason"] <- "too few antibiotics are R"
|
||||
}
|
||||
@@ -1419,8 +1445,10 @@ mdro <- function(x = NULL,
|
||||
}
|
||||
|
||||
if (verbose == TRUE) {
|
||||
colnames(x)[colnames(x) == col_mo] <- "microorganism"
|
||||
x$microorganism <- mo_name(x$microorganism, language = NULL)
|
||||
x[, c("row_number",
|
||||
col_mo,
|
||||
"microorganism",
|
||||
"MDRO",
|
||||
"reason",
|
||||
"columns_nonsusceptible"),
|
||||
@@ -1434,6 +1462,8 @@ mdro <- function(x = NULL,
|
||||
#' @rdname mdro
|
||||
#' @export
|
||||
custom_mdro_guideline <- function(..., as_factor = TRUE) {
|
||||
meet_criteria(as_factor, allow_class = "logical", has_length = 1)
|
||||
|
||||
dots <- tryCatch(list(...),
|
||||
error = function(e) "error")
|
||||
stop_if(identical(dots, "error"),
|
||||
@@ -1470,11 +1500,49 @@ custom_mdro_guideline <- function(..., as_factor = TRUE) {
|
||||
|
||||
names(out) <- paste0("rule", seq_len(n_dots))
|
||||
out <- set_clean_class(out, new_class = c("custom_mdro_guideline", "list"))
|
||||
attr(out, "values") <- c("Negative", vapply(FUN.VALUE = character(1), out, function(x) x$value))
|
||||
attr(out, "values") <- unname(c("Negative", vapply(FUN.VALUE = character(1), unclass(out), function(x) x$value)))
|
||||
attr(out, "as_factor") <- as_factor
|
||||
out
|
||||
}
|
||||
|
||||
#' @method c custom_mdro_guideline
|
||||
#' @noRd
|
||||
#' @export
|
||||
c.custom_mdro_guideline <- function(x, ..., as_factor = NULL) {
|
||||
if (length(list(...)) == 0) {
|
||||
return(x)
|
||||
}
|
||||
if (!is.null(as_factor)) {
|
||||
meet_criteria(as_factor, allow_class = "logical", has_length = 1)
|
||||
} else {
|
||||
as_factor <- attributes(x)$as_factor
|
||||
}
|
||||
for (g in list(...)) {
|
||||
stop_ifnot(inherits(g, "custom_mdro_guideline"),
|
||||
"for combining custom MDRO guidelines, all rules must be created with `custom_mdro_guideline()`",
|
||||
call = FALSE)
|
||||
vals <- attributes(x)$values
|
||||
if (!all(attributes(g)$values %in% vals)) {
|
||||
vals <- unname(unique(c(vals, attributes(g)$values)))
|
||||
}
|
||||
attributes(g) <- NULL
|
||||
x <- c(unclass(x), unclass(g))
|
||||
attr(x, "values") <- vals
|
||||
}
|
||||
names(x) <- paste0("rule", seq_len(length(x)))
|
||||
x <- set_clean_class(x, new_class = c("custom_mdro_guideline", "list"))
|
||||
attr(x, "values") <- vals
|
||||
attr(x, "as_factor") <- as_factor
|
||||
x
|
||||
}
|
||||
|
||||
#' @method as.list custom_mdro_guideline
|
||||
#' @noRd
|
||||
#' @export
|
||||
as.list.custom_mdro_guideline <- function(x, ...) {
|
||||
c(x, ...)
|
||||
}
|
||||
|
||||
#' @method print custom_mdro_guideline
|
||||
#' @export
|
||||
#' @noRd
|
||||
@@ -1482,23 +1550,10 @@ print.custom_mdro_guideline <- function(x, ...) {
|
||||
cat("A set of custom MDRO rules:\n")
|
||||
for (i in seq_len(length(x))) {
|
||||
rule <- x[[i]]
|
||||
rule$query <- gsub(" & ", font_black(font_italic(" and ")), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" | ", font_black(" or "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" + ", font_black(" plus "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" - ", font_black(" minus "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" / ", font_black(" divided by "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" * ", font_black(" times "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" == ", font_black(" is "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" > ", font_black(" is higher than "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" < ", font_black(" is lower than "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" >= ", font_black(" is higher than or equal to "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" <= ", font_black(" is lower than or equal to "), rule$query, fixed = TRUE)
|
||||
rule$query <- gsub(" ^ ", font_black(" to the power of "), rule$query, fixed = TRUE)
|
||||
# replace the black colour 'stops' with blue colour 'starts'
|
||||
rule$query <- gsub("\033[39m", "\033[34m", as.character(rule$query), fixed = TRUE)
|
||||
cat(" ", i, ". ", font_blue(rule$query), font_bold(" -> "), font_red(rule$value), "\n", sep = "")
|
||||
rule$query <- format_custom_query_rule(rule$query)
|
||||
cat(" ", i, ". ", font_bold("If "), font_blue(rule$query), font_bold(" then: "), font_red(rule$value), "\n", sep = "")
|
||||
}
|
||||
cat(" ", i + 1, ". Otherwise", font_bold(" -> "), font_red(paste0("Negative")), "\n", sep = "")
|
||||
cat(" ", i + 1, ". ", font_bold("Otherwise: "), font_red(paste0("Negative")), "\n", sep = "")
|
||||
cat("\nUnmatched rows will return ", font_red("NA"), ".\n", sep = "")
|
||||
if (isTRUE(attributes(x)$as_factor)) {
|
||||
cat("Results will be of class <factor>, with ordered levels: ", paste0(attributes(x)$values, collapse = " < "), "\n", sep = "")
|
||||
@@ -1507,7 +1562,7 @@ print.custom_mdro_guideline <- function(x, ...) {
|
||||
}
|
||||
}
|
||||
|
||||
run_custom_mdro_guideline <- function(df, guideline) {
|
||||
run_custom_mdro_guideline <- function(df, guideline, info) {
|
||||
n_dots <- length(guideline)
|
||||
stop_if(n_dots == 0, "no custom guidelines set", call = -2)
|
||||
out <- character(length = NROW(df))
|
||||
@@ -1520,7 +1575,7 @@ run_custom_mdro_guideline <- function(df, guideline) {
|
||||
})
|
||||
if (identical(qry, "error")) {
|
||||
warning_("in custom_mdro_guideline(): rule ", i,
|
||||
" (`", guideline[[i]]$query, "`) was ignored because of this error message: ",
|
||||
" (`", as.character(guideline[[i]]$query), "`) was ignored because of this error message: ",
|
||||
pkg_env$err_msg,
|
||||
call = FALSE,
|
||||
add_fn = font_red)
|
||||
@@ -1529,9 +1584,16 @@ run_custom_mdro_guideline <- function(df, guideline) {
|
||||
stop_ifnot(is.logical(qry), "in custom_mdro_guideline(): rule ", i, " (`", guideline[[i]]$query,
|
||||
"`) must return `TRUE` or `FALSE`, not ",
|
||||
format_class(class(qry), plural = FALSE), call = FALSE)
|
||||
|
||||
new_mdros <- which(qry == TRUE & out == "")
|
||||
|
||||
if (info == TRUE) {
|
||||
cat(word_wrap("- Custom MDRO rule ", i, ": `", as.character(guideline[[i]]$query),
|
||||
"` (", length(new_mdros), " rows matched)"), "\n", sep = "")
|
||||
}
|
||||
val <- guideline[[i]]$value
|
||||
out[which(qry)] <- val
|
||||
reasons[which(qry)] <- paste0("matched rule ", gsub("rule", "", names(guideline)[i]), ": ", as.character(guideline[[i]]$query))
|
||||
out[new_mdros] <- val
|
||||
reasons[new_mdros] <- paste0("matched rule ", gsub("rule", "", names(guideline)[i]), ": ", as.character(guideline[[i]]$query))
|
||||
}
|
||||
out[out == ""] <- "Negative"
|
||||
reasons[out == "Negative"] <- "no rules matched"
|
||||
@@ -1540,8 +1602,7 @@ run_custom_mdro_guideline <- function(df, guideline) {
|
||||
out <- factor(out, levels = attributes(guideline)$values, ordered = TRUE)
|
||||
}
|
||||
|
||||
rsi_cols <- vapply(FUN.VALUE = logical(1), df, function(x) is.rsi(x))
|
||||
columns_nonsusceptible <- as.data.frame(t(df[, rsi_cols] == "R"))
|
||||
columns_nonsusceptible <- as.data.frame(t(df[, is.rsi(df)] == "R"))
|
||||
columns_nonsusceptible <- vapply(FUN.VALUE = character(1),
|
||||
columns_nonsusceptible,
|
||||
function(x) paste0(rownames(columns_nonsusceptible)[which(x)], collapse = " "))
|
||||
|
||||
2
R/mic.R
@@ -133,7 +133,7 @@ as.mic <- function(x, na.rm = FALSE) {
|
||||
# keep only one zero before dot
|
||||
x <- gsub("0+[.]", "0.", x, perl = TRUE)
|
||||
# starting 00 is probably 0.0 if there's no dot yet
|
||||
x[!x %like% "[.]"] <- gsub("^00", "0.0", x[!x %like% "[.]"])
|
||||
x[x %unlike% "[.]"] <- gsub("^00", "0.0", x[!x %like% "[.]"])
|
||||
# remove last zeroes
|
||||
x <- gsub("([.].?)0+$", "\\1", x, perl = TRUE)
|
||||
x <- gsub("(.*[.])0+$", "\\10", x, perl = TRUE)
|
||||
|
||||
65
R/mo.R
@@ -38,6 +38,7 @@
|
||||
#' @param reference_df a [data.frame] to be used for extra reference when translating `x` to a valid [`mo`]. See [set_mo_source()] and [get_mo_source()] to automate the usage of your own codes (e.g. used in your analysis or organisation).
|
||||
#' @param ignore_pattern a regular expression (case-insensitive) of which all matches in `x` must return `NA`. This can be convenient to exclude known non-relevant input and can also be set with the option `AMR_ignore_pattern`, e.g. `options(AMR_ignore_pattern = "(not reported|contaminated flora)")`.
|
||||
#' @param language language to translate text like "no growth", which defaults to the system language (see [get_locale()])
|
||||
#' @param info a [logical] to indicate if a progress bar should be printed if more than 25 items are to be coerced, defaults to `TRUE` only in interactive mode
|
||||
#' @param ... other arguments passed on to functions
|
||||
#' @rdname as.mo
|
||||
#' @aliases mo
|
||||
@@ -161,6 +162,7 @@ as.mo <- function(x,
|
||||
reference_df = get_mo_source(),
|
||||
ignore_pattern = getOption("AMR_ignore_pattern"),
|
||||
language = get_locale(),
|
||||
info = interactive(),
|
||||
...) {
|
||||
meet_criteria(x, allow_class = c("mo", "data.frame", "list", "character", "numeric", "integer", "factor"), allow_NA = TRUE)
|
||||
meet_criteria(Becker, allow_class = c("logical", "character"), has_length = 1)
|
||||
@@ -169,7 +171,8 @@ as.mo <- function(x,
|
||||
meet_criteria(reference_df, allow_class = "data.frame", allow_NULL = TRUE)
|
||||
meet_criteria(ignore_pattern, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
|
||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||
|
||||
check_dataset_integrity()
|
||||
|
||||
if (tryCatch(all(x[!is.na(x)] %in% MO_lookup$mo)
|
||||
@@ -227,6 +230,7 @@ as.mo <- function(x,
|
||||
reference_df = reference_df,
|
||||
ignore_pattern = ignore_pattern,
|
||||
language = language,
|
||||
info = info,
|
||||
...)
|
||||
}
|
||||
|
||||
@@ -253,6 +257,7 @@ exec_as.mo <- function(x,
|
||||
Lancefield = FALSE,
|
||||
allow_uncertain = TRUE,
|
||||
reference_df = get_mo_source(),
|
||||
info = interactive(),
|
||||
property = "mo",
|
||||
initial_search = TRUE,
|
||||
dyslexia_mode = FALSE,
|
||||
@@ -600,7 +605,7 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
|
||||
if (initial_search == TRUE) {
|
||||
progress <- progress_ticker(n = length(x[!already_known]), n_min = 25) # start if n >= 25
|
||||
progress <- progress_ticker(n = length(x[!already_known]), n_min = 25, print = info) # start if n >= 25
|
||||
on.exit(close(progress))
|
||||
}
|
||||
|
||||
@@ -703,7 +708,7 @@ exec_as.mo <- function(x,
|
||||
|
||||
# check for very small input, but ignore the O antigens of E. coli
|
||||
if (nchar(gsub("[^a-zA-Z]", "", x_trimmed[i])) < 3
|
||||
& !toupper(x_backup_without_spp[i]) %like_case% "O?(26|103|104|104|111|121|145|157)") {
|
||||
& toupper(x_backup_without_spp[i]) %unlike_case% "O?(26|103|104|104|111|121|145|157)") {
|
||||
# fewer than 3 chars and not looked for species, add as failure
|
||||
x[i] <- lookup(mo == "UNKNOWN")
|
||||
if (initial_search == TRUE) {
|
||||
@@ -855,7 +860,7 @@ exec_as.mo <- function(x,
|
||||
x[i] <- lookup(genus == "Salmonella", uncertainty = -1)
|
||||
next
|
||||
} else if (x_backup[i] %like_case% "[sS]almonella [A-Z][a-z]+ ?.*" &
|
||||
!x_backup[i] %like% "t[iy](ph|f)[iy]") {
|
||||
x_backup[i] %unlike% "t[iy](ph|f)[iy]") {
|
||||
# Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica
|
||||
# except for S. typhi, S. paratyphi, S. typhimurium
|
||||
x[i] <- lookup(fullname == "Salmonella enterica", uncertainty = -1)
|
||||
@@ -911,7 +916,7 @@ exec_as.mo <- function(x,
|
||||
# FIRST TRY FULLNAMES AND CODES ----
|
||||
# if only genus is available, return only genus
|
||||
|
||||
if (all(!c(x[i], b.x_trimmed) %like_case% " ")) {
|
||||
if (all(c(x[i], b.x_trimmed) %unlike_case% " ")) {
|
||||
found <- lookup(fullname_lower %in% c(h.x_species, i.x_trimmed_species),
|
||||
haystack = data_to_check)
|
||||
if (!is.na(found)) {
|
||||
@@ -1118,8 +1123,8 @@ exec_as.mo <- function(x,
|
||||
if (isTRUE(debug)) {
|
||||
cat(font_bold("\n[ UNCERTAINTY LEVEL", now_checks_for_uncertainty_level, "] (3) look for genus only, part of name\n"))
|
||||
}
|
||||
if (nchar(g.x_backup_without_spp) > 4 & !b.x_trimmed %like_case% " ") {
|
||||
if (!b.x_trimmed %like_case% "^[A-Z][a-z]+") {
|
||||
if (nchar(g.x_backup_without_spp) > 4 & b.x_trimmed %unlike_case% " ") {
|
||||
if (b.x_trimmed %unlike_case% "^[A-Z][a-z]+") {
|
||||
if (isTRUE(debug)) {
|
||||
message("Running '", paste(b.x_trimmed, "species"), "'")
|
||||
}
|
||||
@@ -1263,7 +1268,7 @@ exec_as.mo <- function(x,
|
||||
stringsAsFactors = FALSE)
|
||||
return(found)
|
||||
}
|
||||
if (b.x_trimmed %like_case% "(fungus|fungi)" & !b.x_trimmed %like_case% "fungiphrya") {
|
||||
if (b.x_trimmed %like_case% "(fungus|fungi)" & b.x_trimmed %unlike_case% "fungiphrya") {
|
||||
found <- "F_FUNGUS"
|
||||
found_result <- found
|
||||
found <- lookup(mo == found)
|
||||
@@ -1654,10 +1659,28 @@ pillar_shaft.mo <- function(x, ...) {
|
||||
out[!is.na(x)] <- gsub("^([A-Z]+_)(.*)", paste0(font_subtle("\\1"), "\\2"), out[!is.na(x)], perl = TRUE)
|
||||
# and grey out every _
|
||||
out[!is.na(x)] <- gsub("_", font_subtle("_"), out[!is.na(x)])
|
||||
|
||||
|
||||
# markup NA and UNKNOWN
|
||||
out[is.na(x)] <- font_na(" NA")
|
||||
out[x == "UNKNOWN"] <- font_na(" UNKNOWN")
|
||||
|
||||
if (!all(x[!is.na(x)] %in% MO_lookup$mo)) {
|
||||
# markup old mo codes
|
||||
out[!x %in% MO_lookup$mo] <- font_italic(font_na(x[!x %in% MO_lookup$mo],
|
||||
collapse = NULL),
|
||||
collapse = NULL)
|
||||
# throw a warning with the affected column name
|
||||
mo <- tryCatch(search_type_in_df(get_current_data(arg_name = "x", call = 0), type = "mo", info = FALSE),
|
||||
error = function(e) NULL)
|
||||
if (!is.null(mo)) {
|
||||
col <- paste0("Column '", mo, "'")
|
||||
} else {
|
||||
col <- "The data"
|
||||
}
|
||||
warning_(col, " contains old microbial codes (from a previous AMR package version). ",
|
||||
"Please update your MO codes with `as.mo()`.",
|
||||
call = FALSE)
|
||||
}
|
||||
|
||||
# make it always fit exactly
|
||||
max_char <- max(nchar(x))
|
||||
@@ -1753,11 +1776,16 @@ summary.mo <- function(object, ...) {
|
||||
#' @export
|
||||
#' @noRd
|
||||
as.data.frame.mo <- function(x, ...) {
|
||||
if (!all(x[!is.na(x)] %in% MO_lookup$mo)) {
|
||||
warning_("The data contains old microbial codes (from a previous AMR package version). ",
|
||||
"Please update your MO codes with `as.mo()`.",
|
||||
call = FALSE)
|
||||
}
|
||||
nm <- deparse1(substitute(x))
|
||||
if (!"nm" %in% names(list(...))) {
|
||||
as.data.frame.vector(as.mo(x), ..., nm = nm)
|
||||
as.data.frame.vector(x, ..., nm = nm)
|
||||
} else {
|
||||
as.data.frame.vector(as.mo(x), ...)
|
||||
as.data.frame.vector(x, ...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1875,6 +1903,7 @@ print.mo_uncertainties <- function(x, ...) {
|
||||
collapse = "")
|
||||
# after strwrap, make taxonomic names italic
|
||||
candidates <- gsub("([A-Za-z]+)", font_italic("\\1"), candidates, perl = TRUE)
|
||||
candidates <- gsub(font_italic("and"), "and", candidates, fixed = TRUE)
|
||||
candidates <- gsub(paste(font_italic(c("Also", "matched"), collapse = NULL), collapse = " "),
|
||||
"Also matched",
|
||||
candidates, fixed = TRUE)
|
||||
@@ -2028,13 +2057,15 @@ replace_old_mo_codes <- function(x, property) {
|
||||
x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))]
|
||||
n_matched <- length(matched[!is.na(matched)])
|
||||
if (property != "mo") {
|
||||
message_(font_blue("The input contained old microbial codes (from previous package versions). Please update your MO codes with `as.mo()`."))
|
||||
message_(font_blue(paste0("The input contained ", n_matched,
|
||||
" old microbial code", ifelse(n_matched == 1, "", "s"),
|
||||
" (from a previous AMR package version). Please update your MO codes with `as.mo()`.")))
|
||||
} else {
|
||||
if (n_matched == 1) {
|
||||
message_(font_blue("1 old microbial code (from previous package versions) was updated to a current used MO code."))
|
||||
} else {
|
||||
message_(font_blue(n_matched, "old microbial codes (from previous package versions) were updated to current used MO codes."))
|
||||
}
|
||||
message_(font_blue(paste0(n_matched, " old microbial code", ifelse(n_matched == 1, "", "s"),
|
||||
" (from a previous AMR package version) ",
|
||||
ifelse(n_matched == 1, "was", "were"),
|
||||
" updated to ", ifelse(n_matched == 1, "a ", ""),
|
||||
"currently used MO code", ifelse(n_matched == 1, "", "s"), ".")))
|
||||
}
|
||||
}
|
||||
x
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#' * \ifelse{html}{\out{<i>p<sub>n</sub></i> is the human pathogenic prevalence group of <i>n</i>, as described below;}}{p_n is the human pathogenic prevalence group of \eqn{n}, as described below;}
|
||||
#' * \ifelse{html}{\out{<i>k<sub>n</sub></i> is the taxonomic kingdom of <i>n</i>, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.}}{l_n is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.}
|
||||
#'
|
||||
#' The grouping into human pathogenic prevalence (\eqn{p}) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. **Group 1** (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is *Enterococcus*, *Staphylococcus* or *Streptococcus*. This group consequently contains all common Gram-negative bacteria, such as *Pseudomonas* and *Legionella* and all species within the order Enterobacterales. **Group 2** consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is *Absidia*, *Acremonium*, *Actinotignum*, *Alternaria*, *Anaerosalibacter*, *Apophysomyces*, *Arachnia*, *Aspergillus*, *Aureobacterium*, *Aureobasidium*, *Bacteroides*, *Basidiobolus*, *Beauveria*, *Blastocystis*, *Branhamella*, *Calymmatobacterium*, *Candida*, *Capnocytophaga*, *Catabacter*, *Chaetomium*, *Chryseobacterium*, *Chryseomonas*, *Chrysonilia*, *Cladophialophora*, *Cladosporium*, *Conidiobolus*, *Cryptococcus*, *Curvularia*, *Exophiala*, *Exserohilum*, *Flavobacterium*, *Fonsecaea*, *Fusarium*, *Fusobacterium*, *Hendersonula*, *Hypomyces*, *Koserella*, *Lelliottia*, *Leptosphaeria*, *Leptotrichia*, *Malassezia*, *Malbranchea*, *Mortierella*, *Mucor*, *Mycocentrospora*, *Mycoplasma*, *Nectria*, *Ochroconis*, *Oidiodendron*, *Phoma*, *Piedraia*, *Pithomyces*, *Pityrosporum*, *Prevotella*, *Pseudallescheria*, *Rhizomucor*, *Rhizopus*, *Rhodotorula*, *Scolecobasidium*, *Scopulariopsis*, *Scytalidium*,*Sporobolomyces*, *Stachybotrys*, *Stomatococcus*, *Treponema*, *Trichoderma*, *Trichophyton*, *Trichosporon*, *Tritirachium* or *Ureaplasma*. **Group 3** consists of all other microorganisms.
|
||||
#' The grouping into human pathogenic prevalence (\eqn{p}) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. **Group 1** (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is *Enterococcus*, *Staphylococcus* or *Streptococcus*. This group consequently contains all common Gram-negative bacteria, such as *Pseudomonas* and *Legionella* and all species within the order Enterobacterales. **Group 2** consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is *Absidia*, *Acremonium*, *Actinotignum*, *Alternaria*, *Anaerosalibacter*, *Apophysomyces*, *Arachnia*, *Aspergillus*, *Aureobacterium*, *Aureobasidium*, *Bacteroides*, *Basidiobolus*, *Beauveria*, *Blastocystis*, *Branhamella*, *Calymmatobacterium*, *Candida*, *Capnocytophaga*, *Catabacter*, *Chaetomium*, *Chryseobacterium*, *Chryseomonas*, *Chrysonilia*, *Cladophialophora*, *Cladosporium*, *Conidiobolus*, *Cryptococcus*, *Curvularia*, *Exophiala*, *Exserohilum*, *Flavobacterium*, *Fonsecaea*, *Fusarium*, *Fusobacterium*, *Hendersonula*, *Hypomyces*, *Koserella*, *Lelliottia*, *Leptosphaeria*, *Leptotrichia*, *Malassezia*, *Malbranchea*, *Mortierella*, *Mucor*, *Mycocentrospora*, *Mycoplasma*, *Nectria*, *Ochroconis*, *Oidiodendron*, *Phoma*, *Piedraia*, *Pithomyces*, *Pityrosporum*, *Prevotella*, *Pseudallescheria*, *Rhizomucor*, *Rhizopus*, *Rhodotorula*, *Scolecobasidium*, *Scopulariopsis*, *Scytalidium*, *Sporobolomyces*, *Stachybotrys*, *Stomatococcus*, *Treponema*, *Trichoderma*, *Trichophyton*, *Trichosporon*, *Tritirachium* or *Ureaplasma*. **Group 3** consists of all other microorganisms.
|
||||
#'
|
||||
#' All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., `"E. coli"` will return the microbial ID of *Escherichia coli* (\eqn{m = `r round(mo_matching_score("E. coli", "Escherichia coli"), 3)`}, a highly prevalent microorganism found in humans) and not *Entamoeba coli* (\eqn{m = `r round(mo_matching_score("E. coli", "Entamoeba coli"), 3)`}, a less prevalent microorganism in humans), although the latter would alphabetically come first.
|
||||
#' @export
|
||||
|
||||
@@ -723,20 +723,13 @@ mo_validate <- function(x, property, language, ...) {
|
||||
# special case for mo_* functions where class is already <mo>
|
||||
return(MO_lookup[match(x, MO_lookup$mo), property, drop = TRUE])
|
||||
}
|
||||
|
||||
|
||||
# try to catch an error when inputting an invalid argument
|
||||
# so the 'call.' can be set to FALSE
|
||||
tryCatch(x[1L] %in% MO_lookup[1, property, drop = TRUE],
|
||||
error = function(e) stop(e$message, call. = FALSE))
|
||||
|
||||
if (is.mo(x)
|
||||
& !Becker %in% c(TRUE, "all")
|
||||
& !Lancefield %in% c(TRUE, "all")) {
|
||||
# this will not reset mo_uncertainties and mo_failures
|
||||
# because it's already a valid MO
|
||||
x <- exec_as.mo(x, property = property, initial_search = FALSE, language = language, ...)
|
||||
} else if (!all(x %in% MO_lookup[, property, drop = TRUE])
|
||||
| has_Becker_or_Lancefield) {
|
||||
|
||||
if (!all(x[!is.na(x)] %in% MO_lookup[, property, drop = TRUE]) | has_Becker_or_Lancefield) {
|
||||
x <- exec_as.mo(x, property = property, language = language, ...)
|
||||
}
|
||||
|
||||
|
||||
225
R/plot.R
@@ -93,6 +93,14 @@ plot.mic <- function(x,
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||
|
||||
# translate if not specifically set
|
||||
if (missing(ylab)) {
|
||||
ylab <- translate_AMR(ylab, language = language)
|
||||
}
|
||||
if (missing(xlab)) {
|
||||
xlab <- translate_AMR(xlab, language = language)
|
||||
}
|
||||
|
||||
if (length(colours_RSI) == 1) {
|
||||
colours_RSI <- rep(colours_RSI, 3)
|
||||
}
|
||||
@@ -135,13 +143,14 @@ plot.mic <- function(x,
|
||||
legend_txt <- c(legend_txt, "Resistant")
|
||||
legend_col <- c(legend_col, colours_RSI[1])
|
||||
}
|
||||
legend("top",
|
||||
legend("top",
|
||||
x.intersp = 0.5,
|
||||
legend = translate_AMR(legend_txt, language = language),
|
||||
fill = legend_col,
|
||||
horiz = TRUE,
|
||||
cex = 0.75,
|
||||
box.lwd = 0,
|
||||
cex = 0.75,
|
||||
box.lwd = 0,
|
||||
box.col = "#FFFFFF55",
|
||||
bg = "#FFFFFF55")
|
||||
}
|
||||
}
|
||||
@@ -170,6 +179,14 @@ barplot.mic <- function(height,
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||
|
||||
# translate if not specifically set
|
||||
if (missing(ylab)) {
|
||||
ylab <- translate_AMR(ylab, language = language)
|
||||
}
|
||||
if (missing(xlab)) {
|
||||
xlab <- translate_AMR(xlab, language = language)
|
||||
}
|
||||
|
||||
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
||||
|
||||
plot(x = height,
|
||||
@@ -209,6 +226,14 @@ ggplot.mic <- function(data,
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||
|
||||
# translate if not specifically set
|
||||
if (missing(ylab)) {
|
||||
ylab <- translate_AMR(ylab, language = language)
|
||||
}
|
||||
if (missing(xlab)) {
|
||||
xlab <- translate_AMR(xlab, language = language)
|
||||
}
|
||||
|
||||
if ("main" %in% names(list(...))) {
|
||||
title <- list(...)$main
|
||||
}
|
||||
@@ -285,6 +310,14 @@ plot.disk <- function(x,
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||
|
||||
# translate if not specifically set
|
||||
if (missing(ylab)) {
|
||||
ylab <- translate_AMR(ylab, language = language)
|
||||
}
|
||||
if (missing(xlab)) {
|
||||
xlab <- translate_AMR(xlab, language = language)
|
||||
}
|
||||
|
||||
if (length(colours_RSI) == 1) {
|
||||
colours_RSI <- rep(colours_RSI, 3)
|
||||
}
|
||||
@@ -333,8 +366,9 @@ plot.disk <- function(x,
|
||||
legend = translate_AMR(legend_txt, language = language),
|
||||
fill = legend_col,
|
||||
horiz = TRUE,
|
||||
cex = 0.75,
|
||||
box.lwd = 0,
|
||||
cex = 0.75,
|
||||
box.lwd = 0,
|
||||
box.col = "#FFFFFF55",
|
||||
bg = "#FFFFFF55")
|
||||
}
|
||||
}
|
||||
@@ -363,6 +397,14 @@ barplot.disk <- function(height,
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||
|
||||
# translate if not specifically set
|
||||
if (missing(ylab)) {
|
||||
ylab <- translate_AMR(ylab, language = language)
|
||||
}
|
||||
if (missing(xlab)) {
|
||||
xlab <- translate_AMR(xlab, language = language)
|
||||
}
|
||||
|
||||
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
||||
|
||||
plot(x = height,
|
||||
@@ -402,6 +444,14 @@ ggplot.disk <- function(data,
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||
|
||||
# translate if not specifically set
|
||||
if (missing(ylab)) {
|
||||
ylab <- translate_AMR(ylab, language = language)
|
||||
}
|
||||
if (missing(xlab)) {
|
||||
xlab <- translate_AMR(xlab, language = language)
|
||||
}
|
||||
|
||||
if ("main" %in% names(list(...))) {
|
||||
title <- list(...)$main
|
||||
}
|
||||
@@ -454,79 +504,6 @@ ggplot.disk <- function(data,
|
||||
ggplot2::labs(title = title, x = xlab, y = ylab, subtitle = cols_sub$sub)
|
||||
}
|
||||
|
||||
plot_prepare_table <- function(x, expand) {
|
||||
if (is.mic(x)) {
|
||||
if (expand == TRUE) {
|
||||
# expand range for MIC by adding factors of 2 from lowest to highest so all MICs in between also print
|
||||
extra_range <- max(x) / 2
|
||||
while (min(extra_range) / 2 > min(x)) {
|
||||
extra_range <- c(min(extra_range) / 2, extra_range)
|
||||
}
|
||||
nms <- extra_range
|
||||
extra_range <- rep(0, length(extra_range))
|
||||
names(extra_range) <- nms
|
||||
x <- table(droplevels(x, as.mic = FALSE))
|
||||
extra_range <- extra_range[!names(extra_range) %in% names(x)]
|
||||
x <- as.table(c(x, extra_range))
|
||||
} else {
|
||||
x <- table(droplevels(x, as.mic = FALSE))
|
||||
}
|
||||
x <- x[order(as.double(as.mic(names(x))))]
|
||||
} else if (is.disk(x)) {
|
||||
if (expand == TRUE) {
|
||||
# expand range for disks from lowest to highest so all mm's in between also print
|
||||
extra_range <- rep(0, max(x) - min(x) - 1)
|
||||
names(extra_range) <- seq(min(x) + 1, max(x) - 1)
|
||||
x <- table(x)
|
||||
extra_range <- extra_range[!names(extra_range) %in% names(x)]
|
||||
x <- as.table(c(x, extra_range))
|
||||
} else {
|
||||
x <- table(x)
|
||||
}
|
||||
x <- x[order(as.double(names(x)))]
|
||||
}
|
||||
as.table(x)
|
||||
}
|
||||
|
||||
plot_name_of_I <- function(guideline) {
|
||||
if (!guideline %like% "CLSI" && as.double(gsub("[^0-9]+", "", guideline)) >= 2019) {
|
||||
# interpretation since 2019
|
||||
"Incr. exposure"
|
||||
} else {
|
||||
# interpretation until 2019
|
||||
"Intermediate"
|
||||
}
|
||||
}
|
||||
|
||||
plot_colours_subtitle_guideline <- function(x, mo, ab, guideline, colours_RSI, fn, language, ...) {
|
||||
guideline <- get_guideline(guideline, AMR::rsi_translation)
|
||||
if (!is.null(mo) && !is.null(ab)) {
|
||||
# interpret and give colour based on MIC values
|
||||
mo <- as.mo(mo)
|
||||
ab <- as.ab(ab)
|
||||
rsi <- suppressWarnings(suppressMessages(as.rsi(fn(names(x)), mo = mo, ab = ab, guideline = guideline, ...)))
|
||||
cols <- character(length = length(rsi))
|
||||
cols[is.na(rsi)] <- "#BEBEBE"
|
||||
cols[rsi == "R"] <- colours_RSI[1]
|
||||
cols[rsi == "S"] <- colours_RSI[2]
|
||||
cols[rsi == "I"] <- colours_RSI[3]
|
||||
moname <- mo_name(mo, language = language)
|
||||
abname <- ab_name(ab, language = language)
|
||||
if (all(cols == "#BEBEBE")) {
|
||||
message_("No ", guideline, " interpretations found for ",
|
||||
ab_name(ab, language = NULL, tolower = TRUE), " in ", moname)
|
||||
guideline_txt <- ""
|
||||
} else {
|
||||
guideline_txt <- paste0("(", guideline, ")")
|
||||
}
|
||||
sub <- bquote(.(abname)~"in"~italic(.(moname))~.(guideline_txt))
|
||||
} else {
|
||||
cols <- "#BEBEBE"
|
||||
sub <- NULL
|
||||
}
|
||||
list(cols = cols, count = as.double(x), sub = sub, guideline = guideline)
|
||||
}
|
||||
|
||||
#' @method plot rsi
|
||||
#' @export
|
||||
#' @importFrom graphics plot text axis
|
||||
@@ -599,8 +576,18 @@ barplot.rsi <- function(height,
|
||||
meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE)
|
||||
meet_criteria(expand, allow_class = "logical", has_length = 1)
|
||||
|
||||
# translate if not specifically set
|
||||
if (missing(ylab)) {
|
||||
ylab <- translate_AMR(ylab, language = language)
|
||||
}
|
||||
if (missing(xlab)) {
|
||||
xlab <- translate_AMR(xlab, language = language)
|
||||
}
|
||||
|
||||
if (length(colours_RSI) == 1) {
|
||||
colours_RSI <- rep(colours_RSI, 3)
|
||||
} else {
|
||||
colours_RSI <- c(colours_RSI[2], colours_RSI[3], colours_RSI[1])
|
||||
}
|
||||
main <- gsub(" +", " ", paste0(main, collapse = " "))
|
||||
|
||||
@@ -624,6 +611,7 @@ ggplot.rsi <- function(data,
|
||||
xlab = "Antimicrobial Interpretation",
|
||||
ylab = "Frequency",
|
||||
colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
|
||||
language = get_locale(),
|
||||
...) {
|
||||
stop_ifnot_installed("ggplot2")
|
||||
meet_criteria(title, allow_class = "character", allow_NULL = TRUE)
|
||||
@@ -631,6 +619,14 @@ ggplot.rsi <- function(data,
|
||||
meet_criteria(xlab, allow_class = "character", has_length = 1)
|
||||
meet_criteria(colours_RSI, allow_class = "character", has_length = c(1, 3))
|
||||
|
||||
# translate if not specifically set
|
||||
if (missing(ylab)) {
|
||||
ylab <- translate_AMR(ylab, language = language)
|
||||
}
|
||||
if (missing(xlab)) {
|
||||
xlab <- translate_AMR(xlab, language = language)
|
||||
}
|
||||
|
||||
if ("main" %in% names(list(...))) {
|
||||
title <- list(...)$main
|
||||
}
|
||||
@@ -658,3 +654,76 @@ ggplot.rsi <- function(data,
|
||||
ggplot2::labs(title = title, x = xlab, y = ylab) +
|
||||
ggplot2::theme(legend.position = "none")
|
||||
}
|
||||
|
||||
plot_prepare_table <- function(x, expand) {
|
||||
if (is.mic(x)) {
|
||||
if (expand == TRUE) {
|
||||
# expand range for MIC by adding factors of 2 from lowest to highest so all MICs in between also print
|
||||
extra_range <- max(x) / 2
|
||||
while (min(extra_range) / 2 > min(x)) {
|
||||
extra_range <- c(min(extra_range) / 2, extra_range)
|
||||
}
|
||||
nms <- extra_range
|
||||
extra_range <- rep(0, length(extra_range))
|
||||
names(extra_range) <- nms
|
||||
x <- table(droplevels(x, as.mic = FALSE))
|
||||
extra_range <- extra_range[!names(extra_range) %in% names(x)]
|
||||
x <- as.table(c(x, extra_range))
|
||||
} else {
|
||||
x <- table(droplevels(x, as.mic = FALSE))
|
||||
}
|
||||
x <- x[order(as.double(as.mic(names(x))))]
|
||||
} else if (is.disk(x)) {
|
||||
if (expand == TRUE) {
|
||||
# expand range for disks from lowest to highest so all mm's in between also print
|
||||
extra_range <- rep(0, max(x) - min(x) - 1)
|
||||
names(extra_range) <- seq(min(x) + 1, max(x) - 1)
|
||||
x <- table(x)
|
||||
extra_range <- extra_range[!names(extra_range) %in% names(x)]
|
||||
x <- as.table(c(x, extra_range))
|
||||
} else {
|
||||
x <- table(x)
|
||||
}
|
||||
x <- x[order(as.double(names(x)))]
|
||||
}
|
||||
as.table(x)
|
||||
}
|
||||
|
||||
plot_name_of_I <- function(guideline) {
|
||||
if (guideline %unlike% "CLSI" && as.double(gsub("[^0-9]+", "", guideline)) >= 2019) {
|
||||
# interpretation since 2019
|
||||
"Incr. exposure"
|
||||
} else {
|
||||
# interpretation until 2019
|
||||
"Intermediate"
|
||||
}
|
||||
}
|
||||
|
||||
plot_colours_subtitle_guideline <- function(x, mo, ab, guideline, colours_RSI, fn, language, ...) {
|
||||
guideline <- get_guideline(guideline, AMR::rsi_translation)
|
||||
if (!is.null(mo) && !is.null(ab)) {
|
||||
# interpret and give colour based on MIC values
|
||||
mo <- as.mo(mo)
|
||||
ab <- as.ab(ab)
|
||||
rsi <- suppressWarnings(suppressMessages(as.rsi(fn(names(x)), mo = mo, ab = ab, guideline = guideline, ...)))
|
||||
cols <- character(length = length(rsi))
|
||||
cols[is.na(rsi)] <- "#BEBEBE"
|
||||
cols[rsi == "R"] <- colours_RSI[1]
|
||||
cols[rsi == "S"] <- colours_RSI[2]
|
||||
cols[rsi == "I"] <- colours_RSI[3]
|
||||
moname <- mo_name(mo, language = language)
|
||||
abname <- ab_name(ab, language = language)
|
||||
if (all(cols == "#BEBEBE")) {
|
||||
message_("No ", guideline, " interpretations found for ",
|
||||
ab_name(ab, language = NULL, tolower = TRUE), " in ", moname)
|
||||
guideline_txt <- ""
|
||||
} else {
|
||||
guideline_txt <- paste0("(", guideline, ")")
|
||||
}
|
||||
sub <- bquote(.(abname)~"-"~italic(.(moname))~.(guideline_txt))
|
||||
} else {
|
||||
cols <- "#BEBEBE"
|
||||
sub <- NULL
|
||||
}
|
||||
list(cols = cols, count = as.double(x), sub = sub, guideline = guideline)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#' @param mo any character that can be coerced to a valid microorganism code with [as.mo()]
|
||||
#' @param ab any character that can be coerced to a valid antimicrobial agent code with [as.ab()]
|
||||
#' @param prob_RSI a vector of length 3: the probabilities for R (1st value), S (2nd value) and I (3rd value)
|
||||
#' @param ... extension for future versions, not used at the moment
|
||||
#' @param ... ignored, only in place to allow future extensions
|
||||
#' @details The base R function [sample()] is used for generating values.
|
||||
#'
|
||||
#' Generated values are based on the latest EUCAST guideline implemented in the [rsi_translation] data set. To create specific generated values per bug or drug, set the `mo` and/or `ab` argument.
|
||||
|
||||
23
R/rsi.R
@@ -259,13 +259,14 @@ as.rsi.default <- function(x, ...) {
|
||||
}
|
||||
|
||||
if (inherits(x, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) {
|
||||
x[x == 1] <- "S"
|
||||
x[x == 2] <- "I"
|
||||
x[x == 3] <- "R"
|
||||
x <- as.character(x) # this is needed to prevent the vctrs pkg to throw an error
|
||||
x[x == "1"] <- "S"
|
||||
x[x == "2"] <- "I"
|
||||
x[x == "3"] <- "R"
|
||||
|
||||
} else if (!all(is.na(x)) && !identical(levels(x), c("S", "I", "R"))) {
|
||||
|
||||
if (!any(x %like% "(R|S|I)", na.rm = TRUE)) {
|
||||
} else if (!all(is.na(x)) && !identical(levels(x), c("S", "I", "R")) && !all(x %in% c("R", "S", "I", NA))) {
|
||||
|
||||
if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) {
|
||||
# check if they are actually MICs or disks
|
||||
if (all_valid_mics(x)) {
|
||||
warning_("The input seems to be MIC values. Transform them with `as.mic()` before running `as.rsi()` to interpret them.")
|
||||
@@ -683,7 +684,7 @@ get_guideline <- function(guideline, reference_data) {
|
||||
if (guideline_param %in% c("CLSI", "EUCAST")) {
|
||||
guideline_param <- rev(sort(subset(reference_data, guideline %like% guideline_param)$guideline))[1L]
|
||||
}
|
||||
if (!guideline_param %like% " ") {
|
||||
if (guideline_param %unlike% " ") {
|
||||
# like 'EUCAST2020', should be 'EUCAST 2020'
|
||||
guideline_param <- gsub("([a-z]+)([0-9]+)", "\\1 \\2", guideline_param, ignore.case = TRUE)
|
||||
}
|
||||
@@ -776,7 +777,7 @@ exec_as.rsi <- function(method,
|
||||
any_is_intrinsic_resistant <- any_is_intrinsic_resistant | is_intrinsic_r
|
||||
|
||||
if (isTRUE(add_intrinsic_resistance) & is_intrinsic_r) {
|
||||
if (!guideline_coerced %like% "EUCAST") {
|
||||
if (guideline_coerced %unlike% "EUCAST") {
|
||||
if (message_not_thrown_before("as.rsi2")) {
|
||||
warning_("Using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.", call = FALSE)
|
||||
remember_thrown_message("as.rsi2")
|
||||
@@ -1027,10 +1028,8 @@ summary.rsi <- function(object, ...) {
|
||||
#' @method c rsi
|
||||
#' @export
|
||||
#' @noRd
|
||||
c.rsi <- function(x, ...) {
|
||||
y <- unlist(lapply(list(...), as.character))
|
||||
x <- as.character(x)
|
||||
as.rsi(c(x, y))
|
||||
c.rsi <- function(...) {
|
||||
as.rsi(unlist(lapply(list(...), as.character)))
|
||||
}
|
||||
|
||||
#' @method unique rsi
|
||||
|
||||
BIN
R/sysdata.rda
@@ -157,11 +157,13 @@ translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE, a
|
||||
df_trans$regular_expr[is.na(df_trans$regular_expr)] <- FALSE
|
||||
|
||||
# check if text to look for is in one of the patterns
|
||||
any_form_in_patterns <- tryCatch(any(from_unique %like% paste0("(", paste(df_trans$pattern, collapse = "|"), ")")),
|
||||
error = function(e) {
|
||||
warning_("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).", call = FALSE)
|
||||
return(FALSE)
|
||||
})
|
||||
any_form_in_patterns <- tryCatch(
|
||||
any(from_unique %like% paste0("(", paste(gsub(" +\\(.*", "", df_trans$pattern), collapse = "|"), ")")),
|
||||
error = function(e) {
|
||||
warning_("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).", call = FALSE)
|
||||
return(FALSE)
|
||||
})
|
||||
|
||||
if (NROW(df_trans) == 0 | !any_form_in_patterns) {
|
||||
return(from)
|
||||
}
|
||||
@@ -170,7 +172,7 @@ translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE, a
|
||||
function(i) from_unique_translated <<- gsub(pattern = df_trans$pattern[i],
|
||||
replacement = df_trans[i, language, drop = TRUE],
|
||||
x = from_unique_translated,
|
||||
ignore.case = !df_trans$case_sensitive[i],
|
||||
ignore.case = !df_trans$case_sensitive[i] & df_trans$regular_expr[i],
|
||||
fixed = !df_trans$regular_expr[i],
|
||||
perl = df_trans$regular_expr[i]))
|
||||
|
||||
|
||||
17
R/zzz.R
@@ -61,20 +61,3 @@ pkg_env$mo_failed <- character(0)
|
||||
}
|
||||
}, silent = TRUE)
|
||||
}
|
||||
|
||||
.onAttach <- function(...) {
|
||||
# show notice in 10% of cases in interactive session
|
||||
if (!interactive() || stats::runif(1) > 0.1 || isTRUE(as.logical(getOption("AMR_silentstart", FALSE)))) {
|
||||
return()
|
||||
}
|
||||
packageStartupMessage(word_wrap("Thank you for using the AMR package! ",
|
||||
"If you have a minute, please anonymously fill in this short questionnaire to improve the package and its functionalities: ",
|
||||
font_blue("https://msberends.github.io/AMR/survey.html\n"),
|
||||
"[prevent his notice with ",
|
||||
font_bold("suppressPackageStartupMessages(library(AMR))"),
|
||||
" or use ",
|
||||
font_bold("options(AMR_silentstart = TRUE)"), "]"))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ reference:
|
||||
- "`as.mic`"
|
||||
- "`as.disk`"
|
||||
- "`eucast_rules`"
|
||||
- "`custom_eucast_rules`"
|
||||
|
||||
- title: "Analysing data: antimicrobial resistance"
|
||||
desc: >
|
||||
@@ -154,7 +155,7 @@ reference:
|
||||
- "`count`"
|
||||
- "`is_new_episode`"
|
||||
- "`first_isolate`"
|
||||
- "`key_antibiotics`"
|
||||
- "`key_antimicrobials`"
|
||||
- "`mdro`"
|
||||
- "`count`"
|
||||
- "`plot`"
|
||||
|
||||
@@ -134,7 +134,7 @@ create_intr_resistance <- function() {
|
||||
|
||||
|
||||
|
||||
# Save internal data sets to R/sysdata.rda --------------------------------
|
||||
# Save internal data to R/sysdata.rda -------------------------------------
|
||||
|
||||
# See 'data-raw/eucast_rules.tsv' for the EUCAST reference file
|
||||
eucast_rules_file <- utils::read.delim(file = "data-raw/eucast_rules.tsv",
|
||||
@@ -188,6 +188,35 @@ AB_lookup <- create_AB_lookup()
|
||||
MO_lookup <- create_MO_lookup()
|
||||
MO.old_lookup <- create_MO.old_lookup()
|
||||
|
||||
# antibiotic groups
|
||||
# (these will also be used for eucast_rules() and understanding data-raw/eucast_rules.tsv)
|
||||
globalenv_before_ab <- c(ls(envir = globalenv()), "globalenv_before_ab")
|
||||
AMINOGLYCOSIDES <- antibiotics %>% filter(group %like% "aminoglycoside") %>% pull(ab)
|
||||
AMINOPENICILLINS <- as.ab(c("AMP", "AMX"))
|
||||
CARBAPENEMS <- antibiotics %>% filter(group %like% "carbapenem") %>% pull(ab)
|
||||
CEPHALOSPORINS <- antibiotics %>% filter(group %like% "cephalosporin") %>% pull(ab)
|
||||
CEPHALOSPORINS_1ST <- antibiotics %>% filter(group %like% "cephalosporin.*1") %>% pull(ab)
|
||||
CEPHALOSPORINS_2ND <- antibiotics %>% filter(group %like% "cephalosporin.*2") %>% pull(ab)
|
||||
CEPHALOSPORINS_3RD <- antibiotics %>% filter(group %like% "cephalosporin.*3") %>% pull(ab)
|
||||
CEPHALOSPORINS_EXCEPT_CAZ <- CEPHALOSPORINS[CEPHALOSPORINS != "CAZ"]
|
||||
FLUOROQUINOLONES <- antibiotics %>% filter(atc_group2 %like% "fluoroquinolone") %>% pull(ab)
|
||||
LIPOGLYCOPEPTIDES <- as.ab(c("DAL", "ORI", "TLV")) # dalba/orita/tela
|
||||
GLYCOPEPTIDES <- antibiotics %>% filter(group %like% "glycopeptide") %>% pull(ab)
|
||||
GLYCOPEPTIDES_EXCEPT_LIPO <- GLYCOPEPTIDES[!GLYCOPEPTIDES %in% LIPOGLYCOPEPTIDES]
|
||||
LINCOSAMIDES <- antibiotics %>% filter(atc_group2 %like% "lincosamide") %>% pull(ab) %>% c("PRL")
|
||||
MACROLIDES <- antibiotics %>% filter(atc_group2 %like% "macrolide") %>% pull(ab)
|
||||
OXAZOLIDINONES <- antibiotics %>% filter(group %like% "oxazolidinone") %>% pull(ab)
|
||||
PENICILLINS <- antibiotics %>% filter(group %like% "penicillin") %>% pull(ab)
|
||||
POLYMYXINS <- antibiotics %>% filter(group %like% "polymyxin") %>% pull(ab)
|
||||
STREPTOGRAMINS <- antibiotics %>% filter(atc_group2 %like% "streptogramin") %>% pull(ab)
|
||||
TETRACYCLINES <- antibiotics %>% filter(atc_group2 %like% "tetracycline") %>% pull(ab)
|
||||
TETRACYCLINES_EXCEPT_TGC <- TETRACYCLINES[TETRACYCLINES != "TGC"]
|
||||
UREIDOPENICILLINS <- as.ab(c("PIP", "TZP", "AZL", "MEZ"))
|
||||
BETALACTAMS <- c(PENICILLINS, CEPHALOSPORINS, CARBAPENEMS)
|
||||
|
||||
DEFINED_AB_GROUPS <- ls(envir = globalenv())
|
||||
DEFINED_AB_GROUPS <- DEFINED_AB_GROUPS[!DEFINED_AB_GROUPS %in% globalenv_before_ab]
|
||||
|
||||
# Export to package as internal data ----
|
||||
usethis::use_data(eucast_rules_file,
|
||||
translations_file,
|
||||
@@ -199,6 +228,29 @@ usethis::use_data(eucast_rules_file,
|
||||
AB_lookup,
|
||||
MO_lookup,
|
||||
MO.old_lookup,
|
||||
AMINOGLYCOSIDES,
|
||||
AMINOPENICILLINS,
|
||||
CARBAPENEMS,
|
||||
CEPHALOSPORINS,
|
||||
CEPHALOSPORINS_1ST,
|
||||
CEPHALOSPORINS_2ND,
|
||||
CEPHALOSPORINS_3RD,
|
||||
CEPHALOSPORINS_EXCEPT_CAZ,
|
||||
FLUOROQUINOLONES,
|
||||
LIPOGLYCOPEPTIDES,
|
||||
GLYCOPEPTIDES,
|
||||
GLYCOPEPTIDES_EXCEPT_LIPO,
|
||||
LINCOSAMIDES,
|
||||
MACROLIDES,
|
||||
OXAZOLIDINONES,
|
||||
PENICILLINS,
|
||||
POLYMYXINS,
|
||||
STREPTOGRAMINS,
|
||||
TETRACYCLINES,
|
||||
TETRACYCLINES_EXCEPT_TGC,
|
||||
UREIDOPENICILLINS,
|
||||
BETALACTAMS,
|
||||
DEFINED_AB_GROUPS,
|
||||
internal = TRUE,
|
||||
overwrite = TRUE,
|
||||
version = 2,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -------------------------------------------------------------------------------------------------------------------------------
|
||||
# For editing this EUCAST reference file, these values can all be used for targeting antibiotics:
|
||||
# 'all_betalactams', 'aminoglycosides', 'aminopenicillins', 'carbapenems', 'cephalosporins', 'cephalosporins_1st', 'cephalosporins_2nd', 'cephalosporins_3rd', 'cephalosporins_except_CAZ',
|
||||
# 'fluoroquinolones', 'glycopeptides', 'lincosamides', 'lipoglycopeptides', 'macrolides', 'oxazolidinones', 'polymyxins', 'streptogramins', 'tetracyclines', 'ureidopenicillins',
|
||||
# 'betalactams', 'aminoglycosides', 'aminopenicillins', 'carbapenems', 'cephalosporins', 'cephalosporins_1st', 'cephalosporins_2nd', 'cephalosporins_3rd', 'cephalosporins_except_CAZ',
|
||||
# 'fluoroquinolones', 'glycopeptides', 'glycopeptides_except_lipo', 'lincosamides', 'lipoglycopeptides', 'macrolides', 'oxazolidinones', 'polymyxins', 'streptogramins', 'tetracyclines', 'tetracyclines_except_TGC', 'ureidopenicillins',
|
||||
# and all separate EARS-Net letter codes like 'AMC'. They can be separated by comma: 'AMC, fluoroquinolones'.
|
||||
# The 'if_mo_property' column can be any column name from the AMR::microorganisms data set, or "genus_species" or "gramstain".
|
||||
# The like.is.one_of column must be 'like' or 'is' or 'one_of' ('like' will read the 'this_value' column as regular expression)
|
||||
@@ -14,7 +14,7 @@ order is Enterobacterales AMP I AMX I Enterobacterales (Order) Breakpoints 10
|
||||
order is Enterobacterales AMP R AMX R Enterobacterales (Order) Breakpoints 10
|
||||
genus is Staphylococcus PEN, FOX S AMP, AMX, PIP, TIC S Staphylococcus Breakpoints 10
|
||||
genus is Staphylococcus PEN, FOX R, S OXA, FLC S Staphylococcus Breakpoints 10
|
||||
genus is Staphylococcus FOX R all_betalactams R Staphylococcus Breakpoints 10
|
||||
genus is Staphylococcus FOX R betalactams R Staphylococcus Breakpoints 10
|
||||
genus_species is Staphylococcus saprophyticus AMP S AMX, AMC, PIP, TZP S Staphylococcus Breakpoints 10
|
||||
genus is Staphylococcus FOX S carbapenems, cephalosporins_except_CAZ S Staphylococcus Breakpoints 10
|
||||
genus is Staphylococcus FOX I carbapenems, cephalosporins_except_CAZ I Staphylococcus Breakpoints 10
|
||||
@@ -120,7 +120,7 @@ order is Enterobacterales AMP I AMX I Enterobacterales (Order) Breakpoints 11
|
||||
order is Enterobacterales AMP R AMX R Enterobacterales (Order) Breakpoints 11
|
||||
genus is Staphylococcus PEN, FOX S AMP, AMX, PIP, TIC S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus PEN, FOX R, S OXA, FLC S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus FOX R all_betalactams R Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus FOX R betalactams R Staphylococcus Breakpoints 11
|
||||
genus_species is Staphylococcus saprophyticus AMP S AMX, AMC, PIP, TZP S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus FOX S carbapenems, cephalosporins_except_CAZ S Staphylococcus Breakpoints 11
|
||||
genus is Staphylococcus FOX I carbapenems, cephalosporins_except_CAZ I Staphylococcus Breakpoints 11
|
||||
@@ -224,7 +224,7 @@ genus_species is Burkholderia pseudomallei TCY R DOX R Burkholderia pseudomallei
|
||||
genus is Bacillus NOR S fluoroquinolones S Bacillus Breakpoints 11 added in 11
|
||||
genus is Bacillus NOR I fluoroquinolones I Bacillus Breakpoints 11 added in 11
|
||||
genus is Bacillus NOR R fluoroquinolones R Bacillus Breakpoints 11 added in 11
|
||||
order is Enterobacterales PEN, glycopeptides, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
order is Enterobacterales PEN, glycopeptides_except_lipo, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Enterobacter cloacae aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
@@ -232,17 +232,17 @@ genus_species is Klebsiella aerogenes aminopenicillins, AMC, CZO, FOX R Table
|
||||
genus_species is Escherichia hermannii aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Hafnia alvei aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus is Klebsiella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Morganella morganii aminopenicillins, AMC, CZO, tetracyclines, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Proteus mirabilis tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Proteus penneri aminopenicillins, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Proteus vulgaris aminopenicillins, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Providencia rettgeri aminopenicillins, AMC, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Providencia stuartii aminopenicillins, AMC, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Morganella morganii aminopenicillins, AMC, CZO, DOX, MNO, TCY, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Proteus mirabilis DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Proteus penneri aminopenicillins, CZO, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Proteus vulgaris aminopenicillins, CZO, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Providencia rettgeri aminopenicillins, AMC, CZO, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Providencia stuartii aminopenicillins, AMC, CZO, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus is Raoultella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Serratia marcescens aminopenicillins, AMC, CZO, FOX, CXM, DOX, TCY, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Yersinia enterocolitica aminopenicillins, AMC, TIC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus_species is Yersinia pseudotuberculosis PLB, COL R Table 01: Intrinsic resistance in Enterobacterales (at the time: Enterobacteriaceae) Expert Rules 3.1
|
||||
genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordetella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, FOX, CXM, glycopeptides, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordetella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, FOX, CXM, glycopeptides_except_lipo, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Acinetobacter baumannii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Acinetobacter pittii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Acinetobacter nosocomialis aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
@@ -250,10 +250,10 @@ genus_species is Acinetobacter calcoaceticus aminopenicillins, AMC, CZO, CTX,
|
||||
genus_species is Achromobacter xylosoxidans aminopenicillins, CZO, CTX, CRO, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
fullname like ^Burkholderia (ambifaria|anthina|arboris|cepacia|cenocepacia|contaminans|diffusa|dolosa|lata|latens|metallica|multivorans|paludis|pseudomultivorans|pyrrocinia|pseudomultivorans|seminalis|stabilis|stagnalis|territorii|ubonensis|vietnamiensis) aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, ATM, ETP, CIP, CHL, aminoglycosides, TMP, FOS, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Elizabethkingia meningoseptica aminopenicillins, AMC, TIC, CZO, CTX, CRO, CAZ, FEP, ATM, ETP, IPM, MEM, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Ochrobactrum anthropi aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, CZO, CTX, CRO, ETP, CHL, KAN, NEO, TMP, SXT, tetracyclines, TGC R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Brucella anthropi aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, CZO, CTX, CRO, ETP, CHL, KAN, NEO, TMP, SXT, DOX, MNO, TCY, TGC R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Stenotrophomonas maltophilia aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, ATM, ETP, IPM, MEM, aminoglycosides, TMP, FOS, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules 3.1
|
||||
genus one_of Haemophilus, Moraxella, Neisseria, Campylobacter glycopeptides, LIN, DAP, LNZ R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||
genus one_of Haemophilus, Moraxella, Neisseria, Campylobacter glycopeptides_except_lipo, LIN, DAP, LNZ R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Haemophilus influenzae FUS, streptogramins R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||
genus_species is Moraxella catarrhalis TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||
genus is Neisseria TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules 3.1
|
||||
@@ -279,8 +279,8 @@ genus_species is Enterococcus casseliflavus FUS, CAZ, cephalosporins_except_CA
|
||||
genus_species is Enterococcus faecium FUS, CAZ, cephalosporins_except_CAZ, aminoglycosides, macrolides, TMP, SXT R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus is Corynebacterium FOS R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus_species is Listeria monocytogenes cephalosporins R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus one_of Leuconostoc, Pediococcus glycopeptides R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus is Lactobacillus glycopeptides R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus one_of Leuconostoc, Pediococcus glycopeptides_except_lipo R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus is Lactobacillus glycopeptides_except_lipo R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus_species is Clostridium ramosum VAN R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus_species is Clostridium innocuum VAN R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules 3.1
|
||||
genus_species one_of Streptococcus group A, Streptococcus group B, Streptococcus group C, Streptococcus group G PEN S aminopenicillins, cephalosporins_except_CAZ, carbapenems S Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules 3.1
|
||||
@@ -298,7 +298,7 @@ genus is Staphylococcus MFX R fluoroquinolones R Table 13: Interpretive rules fo
|
||||
genus_species is Streptococcus pneumoniae MFX R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
||||
order is Enterobacterales CIP R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
||||
genus_species is Neisseria gonorrhoeae CIP R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules 3.1
|
||||
order is Enterobacterales PEN, glycopeptides, lipoglycopeptides, FUS, macrolides, lincosamides, streptogramins, RIF, oxazolidinones R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
order is Enterobacterales PEN, glycopeptides_except_lipo, lipoglycopeptides, FUS, macrolides, lincosamides, streptogramins, RIF, oxazolidinones R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Enterobacter cloacae aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
@@ -308,13 +308,13 @@ genus_species is Klebsiella aerogenes aminopenicillins, AMC, SAM, CZO, CEP, LE
|
||||
genus_species is Klebsiella oxytoca aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
fullname like ^Klebsiella( pneumoniae| quasipneumoniae| variicola)? aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Leclercia adecarboxylata FOS R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Morganella morganii aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, tetracyclines, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Morganella morganii aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, DOX, MNO, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Plesiomonas shigelloides aminopenicillins, AMC, SAM R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Proteus mirabilis tetracyclines, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Proteus penneri aminopenicillins, CZO, CEP, LEX, CFR, CXM, tetracyclines, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Proteus vulgaris aminopenicillins, CZO, CEP, LEX, CFR, CXM, tetracyclines, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Providencia rettgeri aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, tetracyclines, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Providencia stuartii aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, tetracyclines, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Proteus mirabilis DOX, MNO, TCY, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Proteus penneri aminopenicillins, CZO, CEP, LEX, CFR, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Proteus vulgaris aminopenicillins, CZO, CEP, LEX, CFR, CXM, DOX, MNO, TCY, TGC, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Providencia rettgeri aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, DOX, MNO, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Providencia stuartii aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, DOX, MNO, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus is Raoultella aminopenicillins, TIC R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Serratia marcescens aminopenicillins, AMC, SAM, CZO, CEP, LEX, CFR, FOX, CXM, DOX, TCY, polymyxins, NIT R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Yersinia enterocolitica aminopenicillins, AMC, SAM, TIC, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
@@ -324,20 +324,20 @@ genus_species is Aeromonas veronii aminopenicillins, AMC, SAM, FOX R Table 1:
|
||||
genus_species is Aeromonas dhakensis aminopenicillins, AMC, SAM, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Aeromonas caviae aminopenicillins, AMC, SAM, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus_species is Aeromonas jandaei aminopenicillins, AMC, SAM, TIC, CZO, CEP, LEX, CFR, FOX R Table 1: Intrinsic resistance in Enterobacterales and Aeromonas spp. Expert Rules 3.2
|
||||
genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordetella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, cephalosporins_1st, cephalosporins_2nd, glycopeptides, lipoglycopeptides, FUS, macrolides, lincosamides, streptogramins, RIF, oxazolidinones R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2
|
||||
genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordetella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, cephalosporins_1st, cephalosporins_2nd, glycopeptides_except_lipo, lipoglycopeptides, FUS, macrolides, lincosamides, streptogramins, RIF, oxazolidinones R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2
|
||||
fullname like ^Acinetobacter (baumannii|pittii|nosocomialis) aminopenicillins, AMC, CRO, CTX, ATM, ETP, TMP, FOS, DOX, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus is Acinetobacter DOX, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus_species is Achromobacter xylosoxidans aminopenicillins, CRO, CTX, ETP R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
fullname like ^Burkholderia (ambifaria|anthina|arboris|cepacia|cenocepacia|contaminans|diffusa|dolosa|lata|latens|metallica|multivorans|paludis|pseudomultivorans|pyrrocinia|pseudomultivorans|seminalis|stabilis|stagnalis|territorii|ubonensis|vietnamiensis) aminopenicillins, AMC, SAM, TIC, TCC, PIP, TZP, CRO, CTX, ATM, ETP, CIP, CHL, aminoglycosides, TMP, FOS, polymyxins R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus_species is Elizabethkingia meningoseptica aminopenicillins, AMC, SAM, TIC, TCC, PIP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP, IPM, MEM, polymyxins R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus_species is Ochrobactrum anthropi aminopenicillins, AMC, SAM, TIC, TCC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, SAM, CTX, CRO, ETP, CHL, KAN, NEO, TMP, tetracyclines, TGC R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus_species is Brucella anthropi aminopenicillins, AMC, SAM, TIC, TCC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, SAM, CTX, CRO, ETP, CHL, KAN, NEO, TMP, DOX, MNO, TCY, TGC R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus_species is Stenotrophomonas maltophilia aminopenicillins, AMC, SAM, TIC, PIP, TZP, CRO, CTX, ATM, ETP, IPM, MEM, aminoglycosides, TMP, FOS, TCY R Table 2: Intrinsic resistance in non-fermentative gram-negative bacteria Expert Rules 3.2 Additional rules from header added in separate rule (genus is one of…)
|
||||
genus_species is Haemophilus influenzae FUS, streptogramins, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
genus_species is Moraxella catarrhalis TMP, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
genus is Neisseria TMP, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
genus_species is Campylobacter fetus FUS, streptogramins, TMP, NAL, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
fullname like ^Campylobacter (jejuni|coli) FUS, streptogramins, TMP, glycopeptides, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
genus_species is Haemophilus influenzae FUS, streptogramins, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
genus_species is Moraxella catarrhalis TMP, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
genus is Neisseria TMP, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
genus_species is Campylobacter fetus FUS, streptogramins, TMP, NAL, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
fullname like ^Campylobacter (jejuni|coli) FUS, streptogramins, TMP, glycopeptides_except_lipo, lipoglycopeptides, lincosamides, oxazolidinones R Table 3: Intrinsic resistance in other gram-negative bacteria Expert Rules 3.2
|
||||
gramstain is Gram-positive ATM, TEM, polymyxins, NAL R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
||||
genus_species is Staphylococcus saprophyticus FUS, CAZ, FOS, NOV R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
||||
genus_species is Staphylococcus cohnii CAZ, NOV R Table 4: Intrinsic resistance in gram-positive bacteria Expert Rules 3.2
|
||||
@@ -372,8 +372,8 @@ fullname like ^(Serratia|Providencia|Morganella morganii) TGC R Expert Rules o
|
||||
genus is Salmonella cephalosporins_2nd R Expert Rules on Salmonella Expert Rules 3.2
|
||||
genus is Salmonella aminoglycosides R Expert Rules on Salmonella Expert Rules 3.2
|
||||
genus is Salmonella PEF R CIP R Expert Rules on Salmonella Expert Rules 3.2
|
||||
genus_species is Staphylococcus aureus FOX1 R all_betalactams R Expert Rules on Staphylococcus Expert Rules 3.2
|
||||
genus_species is Staphylococcus aureus FOX1 S all_betalactams S Expert Rules on Staphylococcus Expert Rules 3.2
|
||||
genus_species is Staphylococcus aureus FOX1 R betalactams R Expert Rules on Staphylococcus Expert Rules 3.2
|
||||
genus_species is Staphylococcus aureus FOX1 S betalactams S Expert Rules on Staphylococcus Expert Rules 3.2
|
||||
genus_species one_of Staphylococcus aureus, Staphylococcus lugdunensis PEN R AMP, AMX, AZL, BAM, CRB, CRN, EPC, HET, MEC, MEZ, MTM, PIP, PME, PVM, SBC, TAL, TEM, TIC R Expert Rules on Staphylococcus Expert Rules 3.2 all penicillins without beta-lactamse inhibitor
|
||||
genus is Staphylococcus ERY, CLI S macrolides, lincosamides S Expert Rules on Staphylococcus Expert Rules 3.2
|
||||
genus is Staphylococcus NOR S CIP, LVX, MFX, OFX S Expert Rules on Staphylococcus Expert Rules 3.2
|
||||
@@ -400,7 +400,7 @@ genus_species is Streptococcus pneumoniae TCY S DOX, MNO S Expert Rules on Strep
|
||||
genus_species is Streptococcus pneumoniae TCY R DOX, MNO R Expert Rules on Streptococcus pneumoniae Expert Rules 3.2
|
||||
genus_species is Streptococcus pneumoniae VAN S lipoglycopeptides S Expert Rules on Streptococcus pneumoniae Expert Rules 3.2
|
||||
fullname like ^Streptococcus (anginosus|australis|bovis|constellatus|cristatus|equinus|gallolyticus|gordonii|infantarius|infantis|intermedius|mitis|mutans|oligofermentans|oralis|parasanguinis|peroris|pseudopneumoniae|salivarius|sanguinis|sinensis|sobrinus|thermophilus|vestibularis|viridans)$ PEN S aminopenicillins, CTX, CRO S Expert Rules on Viridans Group Streptococci Expert Rules 3.2
|
||||
genus_species is Haemophilus influenzae PEN S all_betalactams S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||
genus_species is Haemophilus influenzae PEN S betalactams S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||
genus_species is Haemophilus influenzae NAL S fluoroquinolones S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||
genus_species is Haemophilus influenzae NAL R CIP, LVX, MFX R Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||
genus_species is Haemophilus influenzae TCY S DOX, MNO S Expert Rules on Haemophilus influenzae Expert Rules 3.2
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 96.
|
@@ -136,8 +136,8 @@ read_EUCAST <- function(sheet, file, guideline_name) {
|
||||
disk_R = ifelse(has_zone_diameters, G, NA_character_)) %>%
|
||||
filter(!is.na(drug),
|
||||
!(is.na(MIC_S) & is.na(MIC_R) & is.na(disk_S) & is.na(disk_R)),
|
||||
!MIC_S %like% "(MIC|S ≤|note)",
|
||||
!MIC_S %like% "^[-]",
|
||||
MIC_S %unlike% "(MIC|S ≤|note)",
|
||||
MIC_S %unlike% "^[-]",
|
||||
drug != MIC_S,) %>%
|
||||
mutate(administration = case_when(drug %like% "[( ]oral" ~ "oral",
|
||||
drug %like% "[( ]iv" ~ "iv",
|
||||
|
||||
@@ -114,8 +114,8 @@ abx_atc2 <- ab_old %>%
|
||||
filter(!atc %in% abx_atc1$atc,
|
||||
is.na(ears_net),
|
||||
!is.na(atc_group1),
|
||||
!atc_group1 %like% ("virus|vaccin|viral|immun"),
|
||||
!official %like% "(combinations| with )") %>%
|
||||
atc_group1 %unlike% ("virus|vaccin|viral|immun"),
|
||||
official %unlike% "(combinations| with )") %>%
|
||||
mutate(ab = NA_character_) %>%
|
||||
as.data.frame(stringsAsFactors = FALSE) %>%
|
||||
select(ab, atc, name = official)
|
||||
|
||||
@@ -382,7 +382,7 @@ MOs <- MOs %>%
|
||||
|
||||
# what characters are in the fullnames?
|
||||
table(sort(unlist(strsplit(x = paste(MOs$fullname, collapse = ""), split = ""))))
|
||||
MOs %>% filter(!fullname %like% "^[a-z ]+$") %>% arrange(fullname) %>% View()
|
||||
MOs %>% filter(fullname %unlike% "^[a-z ]+$") %>% arrange(fullname) %>% View()
|
||||
|
||||
table(MOs$kingdom, MOs$rank)
|
||||
table(AMR::microorganisms$kingdom, AMR::microorganisms$rank)
|
||||
|
||||
@@ -160,7 +160,7 @@ updated_microorganisms <- taxonomy %>%
|
||||
TRUE ~ "subsp."),
|
||||
ref = get_author_year(authors),
|
||||
species_id = as.character(record_no),
|
||||
source = "LSPN",
|
||||
source = "LPSN",
|
||||
prevalence = 0,
|
||||
snomed = NA)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ files <- xml2::read_html(paste0("https://github.com/nathaneastwood/poorman/tree/
|
||||
# get full URLs of all raw R files
|
||||
files <- sort(paste0("https://raw.githubusercontent.com", gsub("blob/", "", files[files %like% "/R/.*.R$"])))
|
||||
# remove files with only pkg specific code
|
||||
files <- files[!files %like% "(zzz|init)[.]R$"]
|
||||
files <- files[files %unlike% "(zzz|init)[.]R$"]
|
||||
# also, there's a lot of functions we don't use
|
||||
files <- files[!files %like% "(slice|glimpse|recode|replace_na|coalesce)[.]R$"]
|
||||
files <- files[files %unlike% "(slice|glimpse|recode|replace_na|coalesce)[.]R$"]
|
||||
|
||||
# add our prepend file, containing info about the source of the data
|
||||
intro <- readLines("data-raw/poorman_prepend.R")
|
||||
|
||||
@@ -39,6 +39,10 @@ antibiotic TRUE TRUE FALSE Antibiotikum antibioticum antibiótico
|
||||
Antibiotic TRUE TRUE FALSE Antibiotikum Antibioticum Antibiótico
|
||||
Drug TRUE TRUE FALSE Medikament Middel Fármaco
|
||||
drug TRUE TRUE FALSE Medikament middel fármaco
|
||||
Frequency FALSE TRUE FALSE Zahl Aantal
|
||||
Minimum Inhibitory Concentration (mg/L) FALSE FALSE FALSE Minimale Hemm-Konzentration (mg/L) Minimale inhiberende concentratie (mg/L)
|
||||
Disk diffusion diameter (mm) FALSE FALSE FALSE Durchmesser der Scheibenzone (mm) Diameter diskzone (mm)
|
||||
Antimicrobial Interpretation FALSE FALSE FALSE Antimikrobielle Auswertung Antimicrobiële interpretatie
|
||||
4-aminosalicylic acid FALSE TRUE FALSE 4-Aminosalicylsäure 4-aminosalicylzuur Ácido 4-aminosalicílico
|
||||
Adefovir dipivoxil FALSE TRUE FALSE Adefovir Dipivoxil Adefovir Adefovir dipivoxil
|
||||
Aldesulfone sodium FALSE TRUE FALSE Aldesulfon-Natrium Aldesulfon Aldesulfona sódica
|
||||
|
||||
|
@@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9014</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9014</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Styles for section anchors */
|
||||
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
|
||||
a.anchor-section::before {content: '#';}
|
||||
.hasAnchor:hover a.anchor-section {visibility: visible;}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Do nothing if AnchorJS is used
|
||||
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||
|
||||
// Do nothing if sections are already anchored
|
||||
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Use section id when pandoc runs with --section-divs
|
||||
const section_id = function(x) {
|
||||
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
|
||||
? x.id : '');
|
||||
};
|
||||
|
||||
// Add anchors
|
||||
h.forEach(function(x) {
|
||||
const id = x.id || section_id(x.parentElement);
|
||||
if (id === '') {
|
||||
return null;
|
||||
}
|
||||
let anchor = document.createElement('a');
|
||||
anchor.href = '#' + id;
|
||||
anchor.classList = ['anchor-section'];
|
||||
x.classList.add('hasAnchor');
|
||||
x.appendChild(anchor);
|
||||
});
|
||||
});
|
||||
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 46 KiB |
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,7 +187,8 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="EUCAST_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
||||
</header><link href="EUCAST_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="EUCAST_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to apply EUCAST rules</h1>
|
||||
@@ -215,8 +216,8 @@
|
||||
<a href="#examples" class="anchor"></a>Examples</h2>
|
||||
<p>These rules can be used to discard impossible bug-drug combinations in your data. For example, <em>Klebsiella</em> produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of <em>Klebsiella</em> is resistant to ampicillin.</p>
|
||||
<p>Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, <em>Klebsiella</em>). EUCAST expert rules solve this, that can be applied using <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">oops</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="va">oops</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
||||
<span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||
ampicillin <span class="op">=</span> <span class="st">"S"</span><span class="op">)</span>
|
||||
<span class="va">oops</span>
|
||||
@@ -227,19 +228,19 @@
|
||||
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">oops</span>, info <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
|
||||
<span class="co"># mo ampicillin</span>
|
||||
<span class="co"># 1 Klebsiella R</span>
|
||||
<span class="co"># 2 Escherichia S</span></code></pre></div>
|
||||
<span class="co"># 2 Escherichia S</span></pre></div>
|
||||
<p>A more convenient function is <code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> that uses the same guideline, but allows to check for one or more specific microorganisms or antibiotics:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>, <span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>, <span class="st">"Escherichia"</span><span class="op">)</span>,
|
||||
<span class="st">"ampicillin"</span><span class="op">)</span>
|
||||
<span class="co"># [1] TRUE FALSE</span>
|
||||
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_is_intrinsic_resistant</a></span><span class="op">(</span><span class="st">"Klebsiella"</span>,
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"ampicillin"</span>, <span class="st">"kanamycin"</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="co"># [1] TRUE FALSE</span></code></pre></div>
|
||||
<span class="co"># [1] TRUE FALSE</span></pre></div>
|
||||
<p>EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called <em>interpretive reading</em>, is basically a form of imputation, and is part of the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function as well:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Staphylococcus aureus"</span>,
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Staphylococcus aureus"</span>,
|
||||
<span class="st">"Enterococcus faecalis"</span>,
|
||||
<span class="st">"Escherichia coli"</span>,
|
||||
<span class="st">"Klebsiella pneumoniae"</span>,
|
||||
@@ -251,9 +252,9 @@
|
||||
CXM <span class="op">=</span> <span class="st">"-"</span>, <span class="co"># Cefuroxime</span>
|
||||
PEN <span class="op">=</span> <span class="st">"S"</span>, <span class="co"># Benzylenicillin</span>
|
||||
FOX <span class="op">=</span> <span class="st">"S"</span>, <span class="co"># Cefoxitin</span>
|
||||
stringsAsFactors <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">data</span></code></pre></div>
|
||||
stringsAsFactors <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="va">data</span></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="left">mo</th>
|
||||
@@ -318,8 +319,8 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="left">mo</th>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Styles for section anchors */
|
||||
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
|
||||
a.anchor-section::before {content: '#';}
|
||||
.hasAnchor:hover a.anchor-section {visibility: visible;}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Do nothing if AnchorJS is used
|
||||
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||
|
||||
// Do nothing if sections are already anchored
|
||||
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Use section id when pandoc runs with --section-divs
|
||||
const section_id = function(x) {
|
||||
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
|
||||
? x.id : '');
|
||||
};
|
||||
|
||||
// Add anchors
|
||||
h.forEach(function(x) {
|
||||
const id = x.id || section_id(x.parentElement);
|
||||
if (id === '') {
|
||||
return null;
|
||||
}
|
||||
let anchor = document.createElement('a');
|
||||
anchor.href = '#' + id;
|
||||
anchor.classList = ['anchor-section'];
|
||||
x.classList.add('hasAnchor');
|
||||
x.appendChild(anchor);
|
||||
});
|
||||
});
|
||||
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9018</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,7 +187,8 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="MDR_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
||||
</header><link href="MDR_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="MDR_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to determine multi-drug resistance (MDR)</h1>
|
||||
@@ -243,27 +244,27 @@
|
||||
<a href="#custom-guidelines" class="anchor"></a>Custom Guidelines</h4>
|
||||
<p>You can also use your own custom guideline. Custom guidelines can be set with the <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data.</p>
|
||||
<p>If you are familiar with <code><a href="https://dplyr.tidyverse.org/reference/case_when.html">case_when()</a></code> of the <code>dplyr</code> package, you will recognise the input method to set your own rules. Rules must be set using what considers to be the ‘formula notation’:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">custom</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">custom_mdro_guideline</a></span><span class="op">(</span><span class="va">CIP</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type A"</span>,
|
||||
<span class="va">ERY</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type B"</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="va">custom</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">custom_mdro_guideline</a></span><span class="op">(</span><span class="va">CIP</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type A"</span>,
|
||||
<span class="va">ERY</span> <span class="op">==</span> <span class="st">"R"</span> <span class="op">&</span> <span class="va">age</span> <span class="op">></span> <span class="fl">60</span> <span class="op">~</span> <span class="st">"Elderly Type B"</span><span class="op">)</span></pre></div>
|
||||
<p>If a row/an isolate matches the first rule, the value after the first <code><a href="https://rdrr.io/r/base/tilde.html">~</a></code> (in this case <em>‘Elderly Type A’</em>) will be set as MDRO value. Otherwise, the second rule will be tried and so on. The number of rules is unlimited.</p>
|
||||
<p>You can print the rules set in the console for an overview. Colours will help reading it if your console supports colours.</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">custom</span>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="va">custom</span>
|
||||
<span class="co"># A set of custom MDRO rules:</span>
|
||||
<span class="co"># 1. CIP is "R" and age is higher than 60 -> Elderly Type A</span>
|
||||
<span class="co"># 2. ERY is "R" and age is higher than 60 -> Elderly Type B</span>
|
||||
<span class="co"># 3. Otherwise -> Negative</span>
|
||||
<span class="co"># 1. If CIP is "R" and age is higher than 60 then: Elderly Type A</span>
|
||||
<span class="co"># 2. If ERY is "R" and age is higher than 60 then: Elderly Type B</span>
|
||||
<span class="co"># 3. Otherwise: Negative</span>
|
||||
<span class="co"># </span>
|
||||
<span class="co"># Unmatched rows will return NA.</span>
|
||||
<span class="co"># Results will be of class <factor>, with ordered levels: Negative < Elderly Type A < Elderly Type B</span></code></pre></div>
|
||||
<span class="co"># Results will be of class <factor>, with ordered levels: Negative < Elderly Type A < Elderly Type B</span></pre></div>
|
||||
<p>The outcome of the function can be used for the <code>guideline</code> argument in the [mdro()] function:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">example_isolates</span>, guideline <span class="op">=</span> <span class="va">custom</span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">example_isolates</span>, guideline <span class="op">=</span> <span class="va">custom</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/table.html">table</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||
<span class="co"># x</span>
|
||||
<span class="co"># Negative Elderly Type A Elderly Type B </span>
|
||||
<span class="co"># 1066 43 891</span></code></pre></div>
|
||||
<span class="co"># 1070 198 732</span></pre></div>
|
||||
<p>The rules set (the <code>custom</code> object in this case) could be exported to a shared file location using <code><a href="https://rdrr.io/r/base/readRDS.html">saveRDS()</a></code> if you collaborate with multiple users. The custom rules set could then be imported using <code><a href="https://rdrr.io/r/base/readRDS.html">readRDS()</a></code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -272,15 +273,15 @@
|
||||
<a href="#examples" class="anchor"></a>Examples</h3>
|
||||
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function always returns an ordered <code>factor</code>. For example, the output of the default guideline by Magiorakos <em>et al.</em> returns a <code>factor</code> with levels ‘Negative’, ‘MDR’, ‘XDR’ or ‘PDR’ in that order.</p>
|
||||
<p>The next example uses the <code>example_isolates</code> data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR data analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># to support pipes: %>%</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># to support pipes: %>%</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="op">)</span> <span class="co"># show frequency table of the result</span>
|
||||
<span class="co"># Warning: NA introduced for isolates where the available percentage of antimicrobial</span>
|
||||
<span class="co"># classes was below 50% (set with `pct_required_classes`)</span></code></pre></div>
|
||||
<span class="co"># classes was below 50% (set with `pct_required_classes`)</span></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: factor > ordered (numeric)<br>
|
||||
Length: 2,000<br>
|
||||
@@ -316,8 +317,8 @@ Unique: 2</p>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>For another example, I will create a data set to determine multi-drug resistant TB:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># random_rsi() is a helper function to generate</span>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="co"># random_rsi() is a helper function to generate</span>
|
||||
<span class="co"># a random vector with values S, I and R</span>
|
||||
<span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>rifampicin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
isoniazid <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
@@ -325,44 +326,44 @@ Unique: 2</p>
|
||||
ethambutol <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
pyrazinamide <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
moxifloxacin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
kanamycin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></code></pre></div>
|
||||
kanamycin <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></pre></div>
|
||||
<p>Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>RIF <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||
<span class="va">my_TB_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>RIF <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
INH <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
GAT <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
ETH <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
PZA <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
MFX <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span>,
|
||||
KAN <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></code></pre></div>
|
||||
KAN <span class="op">=</span> <span class="fu"><a href="../reference/random.html">random_rsi</a></span><span class="op">(</span><span class="fl">5000</span><span class="op">)</span><span class="op">)</span></pre></div>
|
||||
<p>The data set now looks like this:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||
<span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
||||
<span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span>
|
||||
<span class="co"># 1 S R S S S I</span>
|
||||
<span class="co"># 2 S I R R R R</span>
|
||||
<span class="co"># 3 R S S I S I</span>
|
||||
<span class="co"># 4 I S S S I S</span>
|
||||
<span class="co"># 5 I I I S I R</span>
|
||||
<span class="co"># 6 S I S R S S</span>
|
||||
<span class="co"># 1 S S S S R R</span>
|
||||
<span class="co"># 2 R S S S I R</span>
|
||||
<span class="co"># 3 R R I R I R</span>
|
||||
<span class="co"># 4 R R S S R I</span>
|
||||
<span class="co"># 5 R R R I I I</span>
|
||||
<span class="co"># 6 R I R R I I</span>
|
||||
<span class="co"># kanamycin</span>
|
||||
<span class="co"># 1 R</span>
|
||||
<span class="co"># 2 I</span>
|
||||
<span class="co"># 3 R</span>
|
||||
<span class="co"># 4 S</span>
|
||||
<span class="co"># 1 I</span>
|
||||
<span class="co"># 2 R</span>
|
||||
<span class="co"># 3 I</span>
|
||||
<span class="co"># 4 I</span>
|
||||
<span class="co"># 5 S</span>
|
||||
<span class="co"># 6 R</span></code></pre></div>
|
||||
<span class="co"># 6 I</span></pre></div>
|
||||
<p>We can now add the interpretation of MDR-TB to our data set. You can use:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">my_TB_data</span>, guideline <span class="op">=</span> <span class="st">"TB"</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/mdro.html">mdro</a></span><span class="op">(</span><span class="va">my_TB_data</span>, guideline <span class="op">=</span> <span class="st">"TB"</span><span class="op">)</span></pre></div>
|
||||
<p>or its shortcut <code><a href="../reference/mdro.html">mdr_tb()</a></code>:</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdr_tb</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
||||
<span class="co"># NOTE: No column found as input for `col_mo`, assuming all records</span>
|
||||
<span class="co"># containMycobacterium tuberculosis.</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit">
|
||||
<span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span> <span class="op"><-</span> <span class="fu"><a href="../reference/mdro.html">mdr_tb</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">)</span>
|
||||
<span class="co"># ℹ No column found as input for `col_mo`, assuming all records</span>
|
||||
<span class="co"># containMycobacterium tuberculosis.</span></pre></div>
|
||||
<p>Create a frequency table of the results:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="downlit">
|
||||
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">my_TB_data</span><span class="op">$</span><span class="va">mdr</span><span class="op">)</span></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: factor > ordered (numeric)<br>
|
||||
Length: 5,000<br>
|
||||
@@ -382,40 +383,40 @@ Unique: 5</p>
|
||||
<tr class="odd">
|
||||
<td align="left">1</td>
|
||||
<td align="left">Mono-resistant</td>
|
||||
<td align="right">3246</td>
|
||||
<td align="right">64.92%</td>
|
||||
<td align="right">3246</td>
|
||||
<td align="right">64.92%</td>
|
||||
<td align="right">3165</td>
|
||||
<td align="right">63.30%</td>
|
||||
<td align="right">3165</td>
|
||||
<td align="right">63.30%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">2</td>
|
||||
<td align="left">Negative</td>
|
||||
<td align="right">976</td>
|
||||
<td align="right">19.52%</td>
|
||||
<td align="right">4222</td>
|
||||
<td align="right">84.44%</td>
|
||||
<td align="right">1000</td>
|
||||
<td align="right">20.00%</td>
|
||||
<td align="right">4165</td>
|
||||
<td align="right">83.30%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">3</td>
|
||||
<td align="left">Multi-drug-resistant</td>
|
||||
<td align="right">467</td>
|
||||
<td align="right">9.34%</td>
|
||||
<td align="right">4689</td>
|
||||
<td align="right">93.78%</td>
|
||||
<td align="right">463</td>
|
||||
<td align="right">9.26%</td>
|
||||
<td align="right">4628</td>
|
||||
<td align="right">92.56%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">4</td>
|
||||
<td align="left">Poly-resistant</td>
|
||||
<td align="right">230</td>
|
||||
<td align="right">4.60%</td>
|
||||
<td align="right">4919</td>
|
||||
<td align="right">98.38%</td>
|
||||
<td align="right">255</td>
|
||||
<td align="right">5.10%</td>
|
||||
<td align="right">4883</td>
|
||||
<td align="right">97.66%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">5</td>
|
||||
<td align="left">Extensively drug-resistant</td>
|
||||
<td align="right">81</td>
|
||||
<td align="right">1.62%</td>
|
||||
<td align="right">117</td>
|
||||
<td align="right">2.34%</td>
|
||||
<td align="right">5000</td>
|
||||
<td align="right">100.00%</td>
|
||||
</tr>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Styles for section anchors */
|
||||
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
|
||||
a.anchor-section::before {content: '#';}
|
||||
.hasAnchor:hover a.anchor-section {visibility: visible;}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Do nothing if AnchorJS is used
|
||||
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||
|
||||
// Do nothing if sections are already anchored
|
||||
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Use section id when pandoc runs with --section-divs
|
||||
const section_id = function(x) {
|
||||
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
|
||||
? x.id : '');
|
||||
};
|
||||
|
||||
// Add anchors
|
||||
h.forEach(function(x) {
|
||||
const id = x.id || section_id(x.parentElement);
|
||||
if (id === '') {
|
||||
return null;
|
||||
}
|
||||
let anchor = document.createElement('a');
|
||||
anchor.href = '#' + id;
|
||||
anchor.classList = ['anchor-section'];
|
||||
x.classList.add('hasAnchor');
|
||||
x.appendChild(anchor);
|
||||
});
|
||||
});
|
||||
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,7 +187,8 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="PCA_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
||||
</header><link href="PCA_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="PCA_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to conduct principal component analysis (PCA) for AMR</h1>
|
||||
@@ -209,8 +210,8 @@
|
||||
<h1 class="hasAnchor">
|
||||
<a href="#transforming" class="anchor"></a>Transforming</h1>
|
||||
<p>For PCA, we need to transform our AMR data first. This is what the <code>example_isolates</code> data set in this package looks like:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://tibble.tidyverse.org/reference/glimpse.html">glimpse</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
||||
<span class="co"># Rows: 2,000</span>
|
||||
@@ -263,10 +264,10 @@
|
||||
<span class="co"># $ CHL <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ COL <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, …</span>
|
||||
<span class="co"># $ MUP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…</span>
|
||||
<span class="co"># $ RIF <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span></code></pre></div>
|
||||
<span class="co"># $ RIF <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…</span></pre></div>
|
||||
<p>Now to transform this to a data set with only resistance percentages per taxonomic order and genus:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">resistance_data</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="va">resistance_data</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span>order <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, <span class="co"># group on anything, like order</span>
|
||||
genus <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span> <span class="co"># and genus as we do here</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise_all.html">summarise_if</a></span><span class="op">(</span><span class="va">is.rsi</span>, <span class="va">resistance</span><span class="op">)</span> <span class="op">%>%</span> <span class="co"># then get resistance of all drugs</span>
|
||||
@@ -275,48 +276,52 @@
|
||||
|
||||
<span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span>
|
||||
<span class="co"># # A tibble: 6 x 10</span>
|
||||
<span class="co"># # Groups: order [2]</span>
|
||||
<span class="co"># order genus AMC CXM CTX CAZ GEN TOB TMP SXT</span>
|
||||
<span class="co"># <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl></span>
|
||||
<span class="co"># 1 (unknown order) (unknown genu… NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 2 Actinomycetales Corynebacteri… NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 3 Actinomycetales Cutibacterium NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 4 Actinomycetales Dermabacter NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 5 Actinomycetales Micrococcus NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 6 Actinomycetales Rothia NA NA NA NA NA NA NA NA</span></code></pre></div>
|
||||
<span class="co"># # Groups: order [5]</span>
|
||||
<span class="co"># order genus AMC CXM CTX CAZ GEN TOB TMP SXT</span>
|
||||
<span class="co"># <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl></span>
|
||||
<span class="co"># 1 (unknown order) (unknown gen… NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 2 Actinomycetales Schaalia NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 3 Bacteroidales Bacteroides NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 4 Campylobacteral… Campylobacter NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 5 Caryophanales Gemella NA NA NA NA NA NA NA NA</span>
|
||||
<span class="co"># 6 Caryophanales Listeria NA NA NA NA NA NA NA NA</span></pre></div>
|
||||
</div>
|
||||
<div id="perform-principal-component-analysis" class="section level1">
|
||||
<h1 class="hasAnchor">
|
||||
<a href="#perform-principal-component-analysis" class="anchor"></a>Perform principal component analysis</h1>
|
||||
<p>The new <code><a href="../reference/pca.html">pca()</a></code> function will automatically filter on rows that contain numeric values in all selected variables, so we now only need to do:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">pca_result</span> <span class="op"><-</span> <span class="fu"><a href="../reference/pca.html">pca</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span>
|
||||
<span class="co"># NOTE: Columns selected for PCA: AMC CXM CTX CAZ GEN TOB TMP SXT. Total</span>
|
||||
<span class="co"># observations available: 7.</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="va">pca_result</span> <span class="op"><-</span> <span class="fu"><a href="../reference/pca.html">pca</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span>
|
||||
<span class="co"># ℹ Columns selected for PCA: "AMC", "CAZ", "CTX", "CXM", "GEN", "SXT", "TMP"</span>
|
||||
<span class="co"># and "TOB". Total observations available: 7.</span></pre></div>
|
||||
<p>The result can be reviewed with the good old <code><a href="https://rdrr.io/r/base/summary.html">summary()</a></code> function:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span>
|
||||
<span class="co"># Groups (n=4, named as 'order'):</span>
|
||||
<span class="co"># [1] "Caryophanales" "Enterobacterales" "Lactobacillales" "Pseudomonadales"</span>
|
||||
<span class="co"># Importance of components:</span>
|
||||
<span class="co"># PC1 PC2 PC3 PC4 PC5 PC6 PC7</span>
|
||||
<span class="co"># Standard deviation 2.154 1.6807 0.61365 0.33902 0.20757 0.03136 1.733e-16</span>
|
||||
<span class="co"># Proportion of Variance 0.580 0.3531 0.04707 0.01437 0.00539 0.00012 0.000e+00</span>
|
||||
<span class="co"># Cumulative Proportion 0.580 0.9331 0.98012 0.99449 0.99988 1.00000 1.000e+00</span></code></pre></div>
|
||||
<span class="co"># PC1 PC2 PC3 PC4 PC5 PC6 PC7</span>
|
||||
<span class="co"># Standard deviation 2.1539 1.6807 0.6138 0.33879 0.20808 0.03140 5.121e-17</span>
|
||||
<span class="co"># Proportion of Variance 0.5799 0.3531 0.0471 0.01435 0.00541 0.00012 0.000e+00</span>
|
||||
<span class="co"># Cumulative Proportion 0.5799 0.9330 0.9801 0.99446 0.99988 1.00000 1.000e+00</span></pre></div>
|
||||
<pre><code># Groups (n=4, named as 'order'):
|
||||
# [1] "Caryophanales" "Enterobacterales" "Lactobacillales" "Pseudomonadales"</code></pre>
|
||||
<p>Good news. The first two components explain a total of 93.3% of the variance (see the PC1 and PC2 values of the <em>Proportion of Variance</em>. We can create a so-called biplot with the base R <code><a href="https://rdrr.io/r/stats/biplot.html">biplot()</a></code> function, to see which antimicrobial resistance per drug explain the difference per microorganism.</p>
|
||||
</div>
|
||||
<div id="plotting-the-results" class="section level1">
|
||||
<h1 class="hasAnchor">
|
||||
<a href="#plotting-the-results" class="anchor"></a>Plotting the results</h1>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/stats/biplot.html">biplot</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="fu"><a href="https://rdrr.io/r/stats/biplot.html">biplot</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></pre></div>
|
||||
<p><img src="PCA_files/figure-html/unnamed-chunk-5-1.png" width="750"></p>
|
||||
<p>But we can’t see the explanation of the points. Perhaps this works better with our new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function, that automatically adds the right labels and even groups:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></pre></div>
|
||||
<p><img src="PCA_files/figure-html/unnamed-chunk-6-1.png" width="750"></p>
|
||||
<p>You can also print an ellipse per group, and edit the appearance:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span>, ellipse <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> <span class="op">+</span>
|
||||
<span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html">labs</a></span><span class="op">(</span>title <span class="op">=</span> <span class="st">"An AMR/PCA biplot!"</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span>, ellipse <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> <span class="op">+</span>
|
||||
<span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html">labs</a></span><span class="op">(</span>title <span class="op">=</span> <span class="st">"An AMR/PCA biplot!"</span><span class="op">)</span></pre></div>
|
||||
<p><img src="PCA_files/figure-html/unnamed-chunk-7-1.png" width="750"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 91 KiB |
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9014</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,13 +187,14 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="SPSS_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
||||
</header><link href="SPSS_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="SPSS_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to import data from SPSS / SAS / Stata</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">02 February 2021</h4>
|
||||
<h4 class="date">27 April 2021</h4>
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/SPSS.Rmd"><code>vignettes/SPSS.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>SPSS.Rmd</code></div>
|
||||
@@ -228,7 +229,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<p><strong>R has a huge community.</strong></p>
|
||||
<p>Many R users just ask questions on websites like <a href="https://stackoverflow.com">StackOverflow.com</a>, the largest online community for programmers. At the time of writing, <a href="https://stackoverflow.com/questions/tagged/r?sort=votes">385,525 R-related questions</a> have already been asked on this platform (that covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.</p>
|
||||
<p>Many R users just ask questions on websites like <a href="https://stackoverflow.com">StackOverflow.com</a>, the largest online community for programmers. At the time of writing, <a href="https://stackoverflow.com/questions/tagged/r?sort=votes">398,952 R-related questions</a> have already been asked on this platform (that covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><strong>R understands any data type, including SPSS/SAS/Stata.</strong></p>
|
||||
@@ -247,8 +248,8 @@
|
||||
</li>
|
||||
</ul>
|
||||
<p>To demonstrate the first point:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># not all values are valid MIC values:</span>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="co"># not all values are valid MIC values:</span>
|
||||
<span class="fu"><a href="../reference/as.mic.html">as.mic</a></span><span class="op">(</span><span class="fl">0.125</span><span class="op">)</span>
|
||||
<span class="co"># Class <mic></span>
|
||||
<span class="co"># [1] 0.125</span>
|
||||
@@ -279,7 +280,7 @@
|
||||
<span class="co"># [4] "fluclox" "flucloxacilina" "flucloxacillin" </span>
|
||||
<span class="co"># [7] "flucloxacilline" "flucloxacillinum" "fluorochloroxacillin"</span>
|
||||
<span class="fu"><a href="../reference/ab_property.html">ab_atc</a></span><span class="op">(</span><span class="st">"floxapen"</span><span class="op">)</span>
|
||||
<span class="co"># [1] "J01CF05"</span></code></pre></div>
|
||||
<span class="co"># [1] "J01CF05"</span></pre></div>
|
||||
</div>
|
||||
<div id="import-data-from-spsssasstata" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
@@ -295,8 +296,8 @@
|
||||
<p><img src="https://github.com/msberends/AMR/raw/master/docs/import2.png"></p>
|
||||
<p>If you want named variables to be imported as factors so it resembles SPSS more, use <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>.</p>
|
||||
<p>The difference is this:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">SPSS_data</span>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="va">SPSS_data</span>
|
||||
<span class="co"># # A tibble: 4,203 x 4</span>
|
||||
<span class="co"># v001 sex status statusage</span>
|
||||
<span class="co"># <dbl> <dbl+lbl> <dbl+lbl> <dbl></span>
|
||||
@@ -326,74 +327,74 @@
|
||||
<span class="co"># 8 10011 Male alive 73.1</span>
|
||||
<span class="co"># 9 10017 Male alive 56.7</span>
|
||||
<span class="co"># 10 10018 Female alive 66.6</span>
|
||||
<span class="co"># # … with 4,193 more rows</span></code></pre></div>
|
||||
<span class="co"># # … with 4,193 more rows</span></pre></div>
|
||||
</div>
|
||||
<div id="base-r" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#base-r" class="anchor"></a>Base R</h3>
|
||||
<p>To import data from SPSS, SAS or Stata, you can use the <a href="https://haven.tidyverse.org/">great <code>haven</code> package</a> yourself:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># download and install the latest version:</span>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="co"># download and install the latest version:</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"haven"</span><span class="op">)</span>
|
||||
<span class="co"># load the package you just installed:</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://haven.tidyverse.org">haven</a></span><span class="op">)</span> </code></pre></div>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://haven.tidyverse.org">haven</a></span><span class="op">)</span> </pre></div>
|
||||
<p>You can now import files as follows:</p>
|
||||
<div id="spss" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#spss" class="anchor"></a>SPSS</h4>
|
||||
<p>To read files from SPSS into R:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># read any SPSS file based on file extension (best way):</span>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="co"># read any SPSS file based on file extension (best way):</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_spss</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># read .sav or .zsav file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_sav</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># read .por file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_por</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_por</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></pre></div>
|
||||
<p>Do not forget about <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>, as mentioned above.</p>
|
||||
<p>To export your R objects to the SPSS file format:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># save as .sav file:</span>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="co"># save as .sav file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># save as compressed .zsav file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, compress <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, compress <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></pre></div>
|
||||
</div>
|
||||
<div id="sas" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#sas" class="anchor"></a>SAS</h4>
|
||||
<p>To read files from SAS into R:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># read .sas7bdat + .sas7bcat files:</span>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="co"># read .sas7bdat + .sas7bcat files:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">read_sas</a></span><span class="op">(</span>data_file <span class="op">=</span> <span class="st">"path/to/file"</span>, catalog_file <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># read SAS transport files (version 5 and version 8):</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">read_xpt</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">read_xpt</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span></pre></div>
|
||||
<p>To export your R objects to the SAS file format:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># save as regular SAS file:</span>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||
<span class="co"># save as regular SAS file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">write_sas</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># the SAS transport format is an open format </span>
|
||||
<span class="co"># (required for submission of the data to the FDA)</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">write_xpt</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, version <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">write_xpt</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"path/to/file"</span>, version <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></pre></div>
|
||||
</div>
|
||||
<div id="stata" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#stata" class="anchor"></a>Stata</h4>
|
||||
<p>To read files from Stata into R:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># read .dta file:</span>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||
<span class="co"># read .dta file:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_stata</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span>
|
||||
|
||||
<span class="co"># works exactly the same:</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_dta</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">read_dta</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"/path/to/file"</span><span class="op">)</span></pre></div>
|
||||
<p>To export your R objects to the Stata file format:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># save as .dta file, Stata version 14:</span>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit">
|
||||
<span class="co"># save as .dta file, Stata version 14:</span>
|
||||
<span class="co"># (supports Stata v8 until v15 at the time of writing)</span>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">write_dta</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"/path/to/file"</span>, version <span class="op">=</span> <span class="fl">14</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_dta.html">write_dta</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">yourdata</span>, path <span class="op">=</span> <span class="st">"/path/to/file"</span>, version <span class="op">=</span> <span class="fl">14</span><span class="op">)</span></pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,7 +187,8 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="WHONET_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
||||
</header><link href="WHONET_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="WHONET_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to work with WHONET data</h1>
|
||||
@@ -205,38 +206,38 @@
|
||||
<a href="#import-of-data" class="anchor"></a>Import of data</h3>
|
||||
<p>This tutorial assumes you already imported the WHONET data with e.g. the <a href="https://readxl.tidyverse.org/"><code>readxl</code> package</a>. In RStudio, this can be done using the menu button ‘Import Dataset’ in the tab ‘Environment’. Choose the option ‘From Excel’ and select your exported file. Make sure date fields are imported correctly.</p>
|
||||
<p>An example syntax could look like this:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://readxl.tidyverse.org">readxl</a></span><span class="op">)</span>
|
||||
<span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://readxl.tidyverse.org/reference/read_excel.html">read_excel</a></span><span class="op">(</span>path <span class="op">=</span> <span class="st">"path/to/your/file.xlsx"</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://readxl.tidyverse.org">readxl</a></span><span class="op">)</span>
|
||||
<span class="va">data</span> <span class="op"><-</span> <span class="fu"><a href="https://readxl.tidyverse.org/reference/read_excel.html">read_excel</a></span><span class="op">(</span>path <span class="op">=</span> <span class="st">"path/to/your/file.xlsx"</span><span class="op">)</span></pre></div>
|
||||
<p>This package comes with an <a href="https://msberends.github.io/AMR/reference/WHONET.html">example data set <code>WHONET</code></a>. We will use it for this analysis.</p>
|
||||
</div>
|
||||
<div id="preparation" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#preparation" class="anchor"></a>Preparation</h3>
|
||||
<p>First, load the relevant packages if you did not yet did this. I use the tidyverse for all of my analyses. All of them. If you don’t know it yet, I suggest you read about it on their website: <a href="https://www.tidyverse.org/" class="uri">https://www.tidyverse.org/</a>.</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># part of tidyverse</span>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># part of tidyverse</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://ggplot2.tidyverse.org">ggplot2</a></span><span class="op">)</span> <span class="co"># part of tidyverse</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span> <span class="co"># this package</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></code></pre></div>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/cleaner">cleaner</a></span><span class="op">)</span> <span class="co"># to create frequency tables</span></pre></div>
|
||||
<p>We will have to transform some variables to simplify and automate the analysis:</p>
|
||||
<ul>
|
||||
<li>Microorganisms should be transformed to our own microorganism IDs (called an <code>mo</code>) using <a href="https://msberends.github.io/AMR/reference/catalogue_of_life">our Catalogue of Life reference data set</a>, which contains all ~70,000 microorganisms from the taxonomic kingdoms Bacteria, Fungi and Protozoa. We do the tranformation with <code><a href="../reference/as.mo.html">as.mo()</a></code>. This function also recognises almost all WHONET abbreviations of microorganisms.</li>
|
||||
<li>Antimicrobial results or interpretations have to be clean and valid. In other words, they should only contain values <code>"S"</code>, <code>"I"</code> or <code>"R"</code>. That is exactly where the <code><a href="../reference/as.rsi.html">as.rsi()</a></code> function is for.</li>
|
||||
</ul>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># transform variables</span>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="co"># transform variables</span>
|
||||
<span class="va">data</span> <span class="op"><-</span> <span class="va">WHONET</span> <span class="op">%>%</span>
|
||||
<span class="co"># get microbial ID based on given organism</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>mo <span class="op">=</span> <span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">Organism</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="co"># transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">AMP_ND10</span><span class="op">:</span><span class="va">CIP_EE</span><span class="op">)</span>, <span class="va">as.rsi</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">AMP_ND10</span><span class="op">:</span><span class="va">CIP_EE</span><span class="op">)</span>, <span class="va">as.rsi</span><span class="op">)</span></pre></div>
|
||||
<p>No errors or warnings, so all values are transformed succesfully.</p>
|
||||
<p>We also created a package dedicated to data cleaning and checking, called the <code>cleaner</code> package. Its <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> function can be used to create frequency tables.</p>
|
||||
<p>So let’s check our data, with a couple of frequency tables:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># our newly created `mo` variable, put in the mo_name() function</span>
|
||||
<span class="va">data</span> <span class="op">%>%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, nmax <span class="op">=</span> <span class="fl">10</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="co"># our newly created `mo` variable, put in the mo_name() function</span>
|
||||
<span class="va">data</span> <span class="op">%>%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span>, nmax <span class="op">=</span> <span class="fl">10</span><span class="op">)</span></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: character<br>
|
||||
Length: 500<br>
|
||||
@@ -337,10 +338,10 @@ Longest: 40</p>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>(omitted 27 entries, n = 56 [11.20%])</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># our transformed antibiotic columns</span>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="co"># our transformed antibiotic columns</span>
|
||||
<span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span>
|
||||
<span class="va">data</span> <span class="op">%>%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">AMC_ND2</span><span class="op">)</span></code></pre></div>
|
||||
<span class="va">data</span> <span class="op">%>%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">AMC_ND2</span><span class="op">)</span></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: factor > ordered > rsi (numeric)<br>
|
||||
Length: 500<br>
|
||||
@@ -391,11 +392,11 @@ Drug group: Beta-lactams/penicillins<br>
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#a-first-glimpse-at-results" class="anchor"></a>A first glimpse at results</h3>
|
||||
<p>An easy <code>ggplot</code> will already give a lot of information, using the included <code><a href="../reference/ggplot_rsi.html">ggplot_rsi()</a></code> function:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">data</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="va">data</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">Country</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">Country</span>, <span class="va">AMP_ND2</span>, <span class="va">AMC_ED20</span>, <span class="va">CAZ_ED10</span>, <span class="va">CIP_ED5</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/ggplot_rsi.html">ggplot_rsi</a></span><span class="op">(</span>translate_ab <span class="op">=</span> <span class="st">'ab'</span>, facet <span class="op">=</span> <span class="st">"Country"</span>, datalabels <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="../reference/ggplot_rsi.html">ggplot_rsi</a></span><span class="op">(</span>translate_ab <span class="op">=</span> <span class="st">'ab'</span>, facet <span class="op">=</span> <span class="st">"Country"</span>, datalabels <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
|
||||
<p><img src="WHONET_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 60 KiB |
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,7 +187,8 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="benchmarks_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
||||
</header><link href="benchmarks_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="benchmarks_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>Benchmarks</h1>
|
||||
@@ -202,15 +203,15 @@
|
||||
|
||||
<p>One of the most important features of this package is the complete microbial taxonomic database, supplied by the <a href="http://www.catalogueoflife.org">Catalogue of Life</a> (CoL) and the <a href="https://lpsn.dsmz.de">List of Prokaryotic names with Standing in Nomenclature</a> (LPSN). We created a function <code><a href="../reference/as.mo.html">as.mo()</a></code> that transforms any user input value to a valid microbial ID by using intelligent rules combined with the microbial taxonomy.</p>
|
||||
<p>Using the <code>microbenchmark</code> package, we can review the calculation performance of this function. Its function <code><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark()</a></code> runs different input expressions independently of each other and measures their time-to-result.</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/joshuaulrich/microbenchmark/">microbenchmark</a></span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/joshuaulrich/microbenchmark/">microbenchmark</a></span><span class="op">)</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span></code></pre></div>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span></pre></div>
|
||||
<p>In the next test, we try to ‘coerce’ different input values into the microbial code of <em>Staphylococcus aureus</em>. Coercion is a computational process of forcing output based on an input. For microorganism names, coercing user input to taxonomically valid microorganism names is crucial to ensure correct interpretation and to enable grouping based on taxonomic properties.</p>
|
||||
<p>The actual result is the same every time: it returns its microorganism code <code>B_STPHY_AURS</code> (<em>B</em> stands for <em>Bacteria</em>, its taxonomic kingdom).</p>
|
||||
<p>But the calculation time differs a lot:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">S.aureus</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit">
|
||||
<span class="va">S.aureus</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"sau"</span><span class="op">)</span>, <span class="co"># WHONET code</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"stau"</span><span class="op">)</span>,
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"STAU"</span><span class="op">)</span>,
|
||||
@@ -224,21 +225,21 @@
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"MRSA"</span><span class="op">)</span>, <span class="co"># Methicillin Resistant S. aureus</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"VISA"</span><span class="op">)</span>, <span class="co"># Vancomycin Intermediate S. aureus</span>
|
||||
times <span class="op">=</span> <span class="fl">25</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">S.aureus</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">2</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">S.aureus</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">2</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># as.mo("sau") 9.9 11.0 13.0 11.0 12.0 43 25</span>
|
||||
<span class="co"># as.mo("stau") 52.0 55.0 68.0 58.0 86.0 95 25</span>
|
||||
<span class="co"># as.mo("STAU") 53.0 56.0 73.0 62.0 93.0 100 25</span>
|
||||
<span class="co"># as.mo("staaur") 10.0 11.0 17.0 11.0 12.0 48 25</span>
|
||||
<span class="co"># as.mo("STAAUR") 10.0 11.0 14.0 11.0 13.0 48 25</span>
|
||||
<span class="co"># as.mo("S. aureus") 27.0 28.0 41.0 33.0 60.0 73 25</span>
|
||||
<span class="co"># as.mo("S aureus") 27.0 28.0 49.0 34.0 64.0 160 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus") 2.9 3.2 4.8 3.4 3.7 36 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 250.0 260.0 270.0 270.0 280.0 320 25</span>
|
||||
<span class="co"># as.mo("Sthafilokkockus aaureuz") 170.0 200.0 210.0 210.0 210.0 310 25</span>
|
||||
<span class="co"># as.mo("MRSA") 10.0 11.0 16.0 12.0 12.0 50 25</span>
|
||||
<span class="co"># as.mo("VISA") 19.0 20.0 27.0 21.0 23.0 60 25</span></code></pre></div>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># as.mo("sau") 25.0 25.0 30 26.0 26.0 83 25</span>
|
||||
<span class="co"># as.mo("stau") 120.0 130.0 150 130.0 180.0 390 25</span>
|
||||
<span class="co"># as.mo("STAU") 120.0 130.0 150 130.0 180.0 190 25</span>
|
||||
<span class="co"># as.mo("staaur") 25.0 26.0 33 26.0 26.0 83 25</span>
|
||||
<span class="co"># as.mo("STAAUR") 25.0 26.0 33 26.0 26.0 83 25</span>
|
||||
<span class="co"># as.mo("S. aureus") 66.0 66.0 89 67.0 120.0 150 25</span>
|
||||
<span class="co"># as.mo("S aureus") 66.0 66.0 74 66.0 67.0 120 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus") 6.8 6.9 14 6.9 7.5 63 25</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 550.0 550.0 560 550.0 560.0 620 25</span>
|
||||
<span class="co"># as.mo("Sthafilokkockus aaureuz") 410.0 420.0 430 420.0 420.0 620 25</span>
|
||||
<span class="co"># as.mo("MRSA") 25.0 26.0 31 26.0 26.0 83 25</span>
|
||||
<span class="co"># as.mo("VISA") 46.0 47.0 65 47.0 98.0 110 25</span></pre></div>
|
||||
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="750"></p>
|
||||
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 200 milliseconds, this is only 5 input values per second. It is clear that accepted taxonomic names are extremely fast, but some variations are up to 200 times slower to determine.</p>
|
||||
<p>To improve performance, we implemented two important algorithms to save unnecessary calculations: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
|
||||
@@ -247,8 +248,8 @@
|
||||
<a href="#repetitive-results" class="anchor"></a>Repetitive results</h3>
|
||||
<p>Repetitive results are values that are present more than once in a vector. Unique values will only be calculated once by <code><a href="../reference/as.mo.html">as.mo()</a></code>. So running <code><a href="../reference/as.mo.html">as.mo(c("E. coli", "E. coli"))</a></code> will check the value <code>"E. coli"</code> only once.</p>
|
||||
<p>To prove this, we will use <code><a href="../reference/mo_property.html">mo_name()</a></code> for testing - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses <code><a href="../reference/as.mo.html">as.mo()</a></code> internally.</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="co"># start with the example_isolates data set</span>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit">
|
||||
<span class="co"># start with the example_isolates data set</span>
|
||||
<span class="va">x</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<span class="co"># take all MO codes from the 'mo' column</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/pull.html">pull</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
@@ -260,8 +261,8 @@
|
||||
<span class="co"># what do these values look like? They are of class <mo>:</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||
<span class="co"># Class <mo></span>
|
||||
<span class="co"># [1] B_STRPT_PYGN B_STPHY_HMNS B_STPHY_CONS B_STRPT_SLVR B_ENTRBC_CLOC</span>
|
||||
<span class="co"># [6] B_STPHY_CONS</span>
|
||||
<span class="co"># [1] B_STPHY_EPDR B_STPHY_EPDR B_STPHY_CONS B_STPHY_CONS B_STPHY_EPDR</span>
|
||||
<span class="co"># [6] B_ESCHR_COLI</span>
|
||||
|
||||
<span class="co"># as the example_isolates data set has 2,000 rows, we should have 2 million items</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/length.html">length</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||
@@ -274,30 +275,30 @@
|
||||
<span class="co"># now let's see:</span>
|
||||
<span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>,
|
||||
times <span class="op">=</span> <span class="fl">10</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># mo_name(x) 161 194 224 204 229 368 10</span></code></pre></div>
|
||||
<p>So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.204 seconds. That is 102 nanoseconds on average. You only lose time on your unique input values.</p>
|
||||
<span class="co"># mo_name(x) 321 378 443 410 438 713 10</span></pre></div>
|
||||
<p>So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.41 seconds. That is 205 nanoseconds on average. You only lose time on your unique input values.</p>
|
||||
</div>
|
||||
<div id="precalculated-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#precalculated-results" class="anchor"></a>Precalculated results</h3>
|
||||
<p>What about precalculated results? If the input is an already precalculated result of a helper function such as <code><a href="../reference/mo_property.html">mo_name()</a></code>, it almost doesn’t take any time at all. In other words, if you run <code><a href="../reference/mo_property.html">mo_name()</a></code> on a valid taxonomic name, it will return the results immediately (see ‘C’ below):</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>A <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"STAAUR"</span><span class="op">)</span>,
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>A <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"STAAUR"</span><span class="op">)</span>,
|
||||
B <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"S. aureus"</span><span class="op">)</span>,
|
||||
C <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"Staphylococcus aureus"</span><span class="op">)</span>,
|
||||
times <span class="op">=</span> <span class="fl">10</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># A 7.45 7.84 12.70 8.62 9.16 51.10 10</span>
|
||||
<span class="co"># B 23.80 24.50 30.60 26.30 28.80 70.20 10</span>
|
||||
<span class="co"># C 1.66 1.74 1.85 1.79 1.92 2.24 10</span></code></pre></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0018 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>A <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span><span class="op">(</span><span class="st">"aureus"</span><span class="op">)</span>,
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># A 17.00 17.1 17.10 17.10 17.20 17.20 10</span>
|
||||
<span class="co"># B 57.20 57.3 68.90 57.60 58.40 117.00 10</span>
|
||||
<span class="co"># C 3.66 3.7 3.74 3.74 3.77 3.89 10</span></pre></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0037 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="va">run_it</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span>A <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span><span class="op">(</span><span class="st">"aureus"</span><span class="op">)</span>,
|
||||
B <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"Staphylococcus"</span><span class="op">)</span>,
|
||||
C <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"Staphylococcus aureus"</span><span class="op">)</span>,
|
||||
D <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_family</a></span><span class="op">(</span><span class="st">"Staphylococcaceae"</span><span class="op">)</span>,
|
||||
@@ -306,25 +307,25 @@
|
||||
G <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_phylum</a></span><span class="op">(</span><span class="st">"Firmicutes"</span><span class="op">)</span>,
|
||||
H <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_kingdom</a></span><span class="op">(</span><span class="st">"Bacteria"</span><span class="op">)</span>,
|
||||
times <span class="op">=</span> <span class="fl">10</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># A 1.59 1.60 1.91 1.97 2.15 2.28 10</span>
|
||||
<span class="co"># B 1.58 1.61 1.87 1.86 1.96 2.39 10</span>
|
||||
<span class="co"># C 1.55 1.57 1.64 1.63 1.69 1.79 10</span>
|
||||
<span class="co"># D 1.57 1.60 1.83 1.72 1.92 2.73 10</span>
|
||||
<span class="co"># E 1.50 1.74 1.86 1.86 2.03 2.24 10</span>
|
||||
<span class="co"># F 1.49 1.55 1.75 1.67 1.90 2.24 10</span>
|
||||
<span class="co"># G 1.54 1.59 1.69 1.65 1.77 1.95 10</span>
|
||||
<span class="co"># H 1.57 1.58 1.75 1.72 1.78 2.21 10</span></code></pre></div>
|
||||
<span class="co"># A 3.70 3.71 3.81 3.74 3.82 4.14 10</span>
|
||||
<span class="co"># B 3.66 3.67 3.76 3.69 3.76 4.10 10</span>
|
||||
<span class="co"># C 3.66 3.70 3.72 3.72 3.73 3.76 10</span>
|
||||
<span class="co"># D 3.63 3.67 3.77 3.71 3.88 4.09 10</span>
|
||||
<span class="co"># E 3.62 3.67 3.75 3.70 3.78 4.07 10</span>
|
||||
<span class="co"># F 3.62 3.64 3.66 3.65 3.65 3.74 10</span>
|
||||
<span class="co"># G 3.63 3.64 3.67 3.67 3.68 3.75 10</span>
|
||||
<span class="co"># H 3.63 3.64 3.74 3.67 3.84 4.07 10</span></pre></div>
|
||||
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> anyway, there is no point in calculating the result. And because this package contains all phyla of all known bacteria, it can just return the initial value immediately.</p>
|
||||
</div>
|
||||
<div id="results-in-other-languages" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#results-in-other-languages" class="anchor"></a>Results in other languages</h3>
|
||||
<p>When the system language is non-English and supported by this <code>AMR</code> package, some functions will have a translated result. This almost does’t take extra time:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"CoNS"</span>, language <span class="op">=</span> <span class="st">"en"</span><span class="op">)</span> <span class="co"># or just mo_name("CoNS") on an English system</span>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"CoNS"</span>, language <span class="op">=</span> <span class="st">"en"</span><span class="op">)</span> <span class="co"># or just mo_name("CoNS") on an English system</span>
|
||||
<span class="co"># [1] "Coagulase-negative Staphylococcus (CoNS)"</span>
|
||||
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"CoNS"</span>, language <span class="op">=</span> <span class="st">"es"</span><span class="op">)</span> <span class="co"># or just mo_name("CoNS") on a Spanish system</span>
|
||||
@@ -341,16 +342,16 @@
|
||||
fr <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"CoNS"</span>, language <span class="op">=</span> <span class="st">"fr"</span><span class="op">)</span>,
|
||||
pt <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="st">"CoNS"</span>, language <span class="op">=</span> <span class="st">"pt"</span><span class="op">)</span>,
|
||||
times <span class="op">=</span> <span class="fl">100</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">4</span><span class="op">)</span>
|
||||
<span class="fu"><a href="https://docs.ropensci.org/skimr/reference/print.html">print</a></span><span class="op">(</span><span class="va">run_it</span>, unit <span class="op">=</span> <span class="st">"ms"</span>, signif <span class="op">=</span> <span class="fl">4</span><span class="op">)</span>
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># en 17.33 18.21 21.97 19.06 20.40 68.32 100</span>
|
||||
<span class="co"># de 20.44 21.37 30.49 22.33 24.97 78.42 100</span>
|
||||
<span class="co"># nl 25.13 26.10 31.91 27.11 28.50 86.00 100</span>
|
||||
<span class="co"># es 20.28 21.16 26.37 22.03 23.67 74.74 100</span>
|
||||
<span class="co"># it 20.06 21.00 26.05 21.95 23.42 94.16 100</span>
|
||||
<span class="co"># fr 19.90 20.63 24.40 21.85 22.82 69.07 100</span>
|
||||
<span class="co"># pt 20.22 21.03 25.63 21.89 23.24 76.63 100</span></code></pre></div>
|
||||
<span class="co"># en 43.15 43.49 48.88 43.66 43.81 122.3 100</span>
|
||||
<span class="co"># de 79.59 80.39 88.27 80.89 81.11 135.8 100</span>
|
||||
<span class="co"># nl 79.69 80.45 87.16 80.81 81.07 136.6 100</span>
|
||||
<span class="co"># es 79.28 80.12 89.84 80.51 81.02 159.5 100</span>
|
||||
<span class="co"># it 51.74 52.20 55.59 52.39 52.61 109.1 100</span>
|
||||
<span class="co"># fr 51.43 51.88 54.83 52.05 52.29 105.5 100</span>
|
||||
<span class="co"># pt 51.58 51.93 59.25 52.28 52.55 111.8 100</span></pre></div>
|
||||
<p>Currently supported non-English languages are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 76 KiB |
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,12 +187,13 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="datasets_files/header-attrs-2.7/header-attrs.js"></script><div class="row">
|
||||
</header><link href="datasets_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="datasets_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>Data sets for download / own use</h1>
|
||||
|
||||
<h4 class="date">11 March 2021</h4>
|
||||
<h4 class="date">27 April 2021</h4>
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>datasets.Rmd</code></div>
|
||||
@@ -211,7 +212,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#microorganisms-currently-accepted-names" class="anchor"></a>Microorganisms (currently accepted names)</h2>
|
||||
<p>A data set with 70,026 rows and 16 columns, containing the following column names:<br><em>mo</em>, <em>fullname</em>, <em>kingdom</em>, <em>phylum</em>, <em>class</em>, <em>order</em>, <em>family</em>, <em>genus</em>, <em>species</em>, <em>subspecies</em>, <em>rank</em>, <em>ref</em>, <em>species_id</em>, <em>source</em>, <em>prevalence</em> and <em>snomed</em>.</p>
|
||||
<p>This data set is in R available as <code>microorganisms</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 11 March 2021 20:59:32 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.html">here</a>.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/microorganisms.rds">R file</a> (2.2 MB)<br>
|
||||
@@ -432,7 +433,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<p>A data set with 14,100 rows and 4 columns, containing the following column names:<br><em>fullname</em>, <em>fullname_new</em>, <em>ref</em> and <em>prevalence</em>.</p>
|
||||
<p><strong>Note:</strong> remember that the ‘ref’ columns contains the scientific reference to the old taxonomic entries, i.e. of column <em>‘fullname’</em>. For the scientific reference of the new names, i.e. of column <em>‘fullname_new’</em>, see the <code>microorganisms</code> data set.</p>
|
||||
<p>This data set is in R available as <code>microorganisms.old</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 5 March 2021 09:46:55 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.old.html">here</a>.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/microorganisms.old.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/microorganisms.old.rds">R file</a> (0.2 MB)<br>
|
||||
@@ -497,7 +498,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#antibiotic-agents" class="anchor"></a>Antibiotic agents</h2>
|
||||
<p>A data set with 456 rows and 14 columns, containing the following column names:<br><em>ab</em>, <em>atc</em>, <em>cid</em>, <em>name</em>, <em>group</em>, <em>atc_group1</em>, <em>atc_group2</em>, <em>abbreviations</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em>, <em>iv_units</em> and <em>loinc</em>.</p>
|
||||
<p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 11 March 2021 20:59:32 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (32 kB)<br>
|
||||
@@ -665,7 +666,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#antiviral-agents" class="anchor"></a>Antiviral agents</h2>
|
||||
<p>A data set with 102 rows and 9 columns, containing the following column names:<br><em>atc</em>, <em>cid</em>, <em>name</em>, <em>atc_group</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em> and <em>iv_units</em>.</p>
|
||||
<p>This data set is in R available as <code>antivirals</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 29 August 2020 19:53:07 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antivirals.rds">R file</a> (5 kB)<br>
|
||||
@@ -792,7 +793,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#intrinsic-bacterial-resistance" class="anchor"></a>Intrinsic bacterial resistance</h2>
|
||||
<p>A data set with 93,892 rows and 2 columns, containing the following column names:<br><em>microorganism</em> and <em>antibiotic</em>.</p>
|
||||
<p>This data set is in R available as <code>intrinsic_resistant</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 5 March 2021 09:46:55 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/intrinsic_resistant.rds">R file</a> (69 kB)<br>
|
||||
@@ -1007,7 +1008,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#interpretation-from-mic-values-disk-diameters-to-rsi" class="anchor"></a>Interpretation from MIC values / disk diameters to R/SI</h2>
|
||||
<p>A data set with 20,486 rows and 10 columns, containing the following column names:<br><em>guideline</em>, <em>method</em>, <em>site</em>, <em>mo</em>, <em>ab</em>, <em>ref_tbl</em>, <em>disk_dose</em>, <em>breakpoint_S</em>, <em>breakpoint_R</em> and <em>uti</em>.</p>
|
||||
<p>This data set is in R available as <code>rsi_translation</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 5 March 2021 09:46:55 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/rsi_translation.html">here</a>.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/rsi_translation.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/rsi_translation.rds">R file</a> (34 kB)<br>
|
||||
@@ -1137,7 +1138,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
|
||||
<a href="#dosage-guidelines-from-eucast" class="anchor"></a>Dosage guidelines from EUCAST</h2>
|
||||
<p>A data set with 169 rows and 9 columns, containing the following column names:<br><em>ab</em>, <em>name</em>, <em>type</em>, <em>dose</em>, <em>dose_times</em>, <em>administration</em>, <em>notes</em>, <em>original_txt</em> and <em>eucast_version</em>.</p>
|
||||
<p>This data set is in R available as <code>dosage</code>, after you load the <code>AMR</code> package.</p>
|
||||
<p>It was last updated on 25 January 2021 20:58:20 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/dosage.html">here</a>.</p>
|
||||
<p>It was last updated on 27 April 2021 08:12:46 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/dosage.html">here</a>.</p>
|
||||
<p><strong>Direct download links:</strong></p>
|
||||
<ul>
|
||||
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/dosage.rds">R file</a> (3 kB)<br>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Styles for section anchors */
|
||||
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
|
||||
a.anchor-section::before {content: '#';}
|
||||
.hasAnchor:hover a.anchor-section {visibility: visible;}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Do nothing if AnchorJS is used
|
||||
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||
|
||||
// Do nothing if sections are already anchored
|
||||
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Use section id when pandoc runs with --section-divs
|
||||
const section_id = function(x) {
|
||||
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
|
||||
? x.id : '');
|
||||
};
|
||||
|
||||
// Add anchors
|
||||
h.forEach(function(x) {
|
||||
const id = x.id || section_id(x.parentElement);
|
||||
if (id === '') {
|
||||
return null;
|
||||
}
|
||||
let anchor = document.createElement('a');
|
||||
anchor.href = '#' + id;
|
||||
anchor.classList = ['anchor-section'];
|
||||
x.classList.add('hasAnchor');
|
||||
x.appendChild(anchor);
|
||||
});
|
||||
});
|
||||
@@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9014</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9018</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,7 +187,8 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="resistance_predict_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
||||
</header><link href="resistance_predict_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="resistance_predict_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>How to predict antimicrobial resistance</h1>
|
||||
@@ -205,37 +206,37 @@
|
||||
<a href="#needed-r-packages" class="anchor"></a>Needed R packages</h2>
|
||||
<p>As with many uses in R, we need some additional packages for AMR data analysis. Our package works closely together with the <a href="https://www.tidyverse.org">tidyverse packages</a> <a href="https://dplyr.tidyverse.org/"><code>dplyr</code></a> and <a href="https://ggplot2.tidyverse.org"><code>ggplot2</code></a> by Dr Hadley Wickham. The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.</p>
|
||||
<p>Our <code>AMR</code> package depends on these packages and even extends their use and functions.</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://ggplot2.tidyverse.org">ggplot2</a></span><span class="op">)</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||
|
||||
<span class="co"># (if not yet installed, install with:)</span>
|
||||
<span class="co"># install.packages(c("tidyverse", "AMR"))</span></code></pre></div>
|
||||
<span class="co"># install.packages(c("tidyverse", "AMR"))</span></pre></div>
|
||||
</div>
|
||||
<div id="prediction-analysis" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#prediction-analysis" class="anchor"></a>Prediction analysis</h2>
|
||||
<p>Our package contains a function <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>, which takes the same input as functions for <a href="./AMR.html">other AMR data analysis</a>. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.</p>
|
||||
<p>It is basically as easy as:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># resistance prediction of piperacillin/tazobactam (TZP):</span></span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">resistance_predict</span>(<span class="at">tbl =</span> example_isolates, <span class="at">col_date =</span> <span class="st">"date"</span>, <span class="at">col_ab =</span> <span class="st">"TZP"</span>, <span class="at">model =</span> <span class="st">"binomial"</span>)</span>
|
||||
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co"># or:</span></span>
|
||||
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>example_isolates <span class="sc">%>%</span> </span>
|
||||
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">resistance_predict</span>(<span class="at">col_ab =</span> <span class="st">"TZP"</span>,</span>
|
||||
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> model <span class="st">"binomial"</span>)</span>
|
||||
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="co"># to bind it to object 'predict_TZP' for example:</span></span>
|
||||
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a>predict_TZP <span class="ot"><-</span> example_isolates <span class="sc">%>%</span> </span>
|
||||
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">resistance_predict</span>(<span class="at">col_ab =</span> <span class="st">"TZP"</span>,</span>
|
||||
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="at">model =</span> <span class="st">"binomial"</span>)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="co"># resistance prediction of piperacillin/tazobactam (TZP):</span></a>
|
||||
<a class="sourceLine" id="cb2-2" title="2"><span class="kw">resistance_predict</span>(<span class="dt">tbl =</span> example_isolates, <span class="dt">col_date =</span> <span class="st">"date"</span>, <span class="dt">col_ab =</span> <span class="st">"TZP"</span>, <span class="dt">model =</span> <span class="st">"binomial"</span>)</a>
|
||||
<a class="sourceLine" id="cb2-3" title="3"></a>
|
||||
<a class="sourceLine" id="cb2-4" title="4"><span class="co"># or:</span></a>
|
||||
<a class="sourceLine" id="cb2-5" title="5">example_isolates <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb2-6" title="6"><span class="st"> </span><span class="kw">resistance_predict</span>(<span class="dt">col_ab =</span> <span class="st">"TZP"</span>,</a>
|
||||
<a class="sourceLine" id="cb2-7" title="7"> model <span class="st">"binomial"</span>)</a>
|
||||
<a class="sourceLine" id="cb2-8" title="8"></a>
|
||||
<a class="sourceLine" id="cb2-9" title="9"><span class="co"># to bind it to object 'predict_TZP' for example:</span></a>
|
||||
<a class="sourceLine" id="cb2-10" title="10">predict_TZP <-<span class="st"> </span>example_isolates <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb2-11" title="11"><span class="st"> </span><span class="kw">resistance_predict</span>(<span class="dt">col_ab =</span> <span class="st">"TZP"</span>,</a>
|
||||
<a class="sourceLine" id="cb2-12" title="12"> <span class="dt">model =</span> <span class="st">"binomial"</span>)</a></code></pre></div>
|
||||
<p>The function will look for a date column itself if <code>col_date</code> is not set.</p>
|
||||
<p>When running any of these commands, a summary of the regression model will be printed unless using <code><a href="../reference/resistance_predict.html">resistance_predict(..., info = FALSE)</a></code>.</p>
|
||||
<pre><code># NOTE: Using column 'date' as input for `col_date`.</code></pre>
|
||||
<pre><code># ℹ Using column 'date' as input for `col_date`.</code></pre>
|
||||
<p>This text is only a printed summary - the actual result (output) of the function is a <code>data.frame</code> containing for each year: the number of observations, the actual observed resistance, the estimated resistance and the standard error below and above the estimation:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">predict_TZP</span>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit">
|
||||
<span class="va">predict_TZP</span>
|
||||
<span class="co"># year value se_min se_max observations observed estimated</span>
|
||||
<span class="co"># 1 2002 0.20000000 NA NA 15 0.20000000 0.05616378</span>
|
||||
<span class="co"># 2 2003 0.06250000 NA NA 32 0.06250000 0.06163839</span>
|
||||
@@ -266,30 +267,30 @@
|
||||
<span class="co"># 27 2028 0.43730688 0.3418075 0.5328063 NA NA 0.43730688</span>
|
||||
<span class="co"># 28 2029 0.46175755 0.3597639 0.5637512 NA NA 0.46175755</span>
|
||||
<span class="co"># 29 2030 0.48639359 0.3782932 0.5944939 NA NA 0.48639359</span>
|
||||
<span class="co"># 30 2031 0.51109592 0.3973697 0.6248221 NA NA 0.51109592</span></code></pre></div>
|
||||
<span class="co"># 30 2031 0.51109592 0.3973697 0.6248221 NA NA 0.51109592</span></pre></div>
|
||||
<p>The function <code>plot</code> is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-4-1.png" width="720"></p>
|
||||
<p>This is the fastest way to plot the result. It automatically adds the right axes, error bars, titles, number of available observations and type of model.</p>
|
||||
<p>We also support the <code>ggplot2</code> package with our custom function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> to create more appealing plots:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit">
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-5-1.png" width="720"></p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit">
|
||||
|
||||
<span class="co"># choose for error bars instead of a ribbon</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span>, ribbon <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span>, ribbon <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-5-2.png" width="720"></p>
|
||||
<div id="choosing-the-right-model" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#choosing-the-right-model" class="anchor"></a>Choosing the right model</h3>
|
||||
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram-positive bacteria, the spread (i.e. standard error) is enormous:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit">
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="va">mo</span>, language <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Gram-positive"</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span>col_ab <span class="op">=</span> <span class="st">"VAN"</span>, year_min <span class="op">=</span> <span class="fl">2010</span>, info <span class="op">=</span> <span class="cn">FALSE</span>, model <span class="op">=</span> <span class="st">"binomial"</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-6-1.png" width="720"></p>
|
||||
<p>Vancomycin resistance could be 100% in ten years, but might also stay around 0%.</p>
|
||||
<p>You can define the model with the <code>model</code> parameter. The model chosen above is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.</p>
|
||||
@@ -330,16 +331,16 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<p>For the vancomycin resistance in Gram-positive bacteria, a linear model might be more appropriate since no binomial distribution is to be expected based on the observed years:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit">
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="va">mo</span>, language <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Gram-positive"</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span>col_ab <span class="op">=</span> <span class="st">"VAN"</span>, year_min <span class="op">=</span> <span class="fl">2010</span>, info <span class="op">=</span> <span class="cn">FALSE</span>, model <span class="op">=</span> <span class="st">"linear"</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
|
||||
<p>This seems more likely, doesn’t it?</p>
|
||||
<p>The model itself is also available from the object, as an <code>attribute</code>:</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R"><span class="va">model</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/attributes.html">attributes</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span><span class="op">$</span><span class="va">model</span>
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit">
|
||||
<span class="va">model</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/attributes.html">attributes</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span><span class="op">$</span><span class="va">model</span>
|
||||
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span><span class="op">$</span><span class="va">family</span>
|
||||
<span class="co"># </span>
|
||||
@@ -349,7 +350,7 @@
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span><span class="op">$</span><span class="va">coefficients</span>
|
||||
<span class="co"># Estimate Std. Error z value Pr(>|z|)</span>
|
||||
<span class="co"># (Intercept) -200.67944891 46.17315349 -4.346237 1.384932e-05</span>
|
||||
<span class="co"># year 0.09883005 0.02295317 4.305725 1.664395e-05</span></code></pre></div>
|
||||
<span class="co"># year 0.09883005 0.02295317 4.305725 1.664395e-05</span></pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 66 KiB |
@@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9018</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -63,77 +63,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -142,21 +142,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -165,14 +165,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
@@ -187,7 +187,8 @@
|
||||
|
||||
|
||||
|
||||
</header><script src="welcome_to_AMR_files/header-attrs-2.6/header-attrs.js"></script><div class="row">
|
||||
</header><link href="welcome_to_AMR_files/anchor-sections-1.0/anchor-sections.css" rel="stylesheet">
|
||||
<script src="welcome_to_AMR_files/anchor-sections-1.0/anchor-sections.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>Welcome to the AMR package</h1>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9014</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -236,14 +236,15 @@
|
||||
<small class="dont-index">Source: <a href='https://github.com/msberends/AMR/blob/master/inst/CITATION'><code>inst/CITATION</code></a></small>
|
||||
</div>
|
||||
|
||||
<p>Berends MS, Luz CF et al. (2019). AMR - An R Package for Working with Antimicrobial Resistance Data. bioRxiv, https://doi.org/10.1101/810622</p>
|
||||
<p>Berends MS, Luz CF et al. (2021). AMR - An R Package for Working with Antimicrobial Resistance Data. bioRxiv, https://doi.org/10.1101/810622</p>
|
||||
<pre>@Article{,
|
||||
title = {AMR - An R Package for Working with Antimicrobial Resistance Data},
|
||||
author = {M S Berends and C F Luz and A W Friedrich and B N M Sinha and C J Albers and C Glasner},
|
||||
doi = {1.24720276528394e-05},
|
||||
journal = {bioRxiv},
|
||||
publisher = {Cold Spring Harbor Laboratory},
|
||||
year = {2019},
|
||||
url = {https://doi.org/10.1101/810622},
|
||||
year = {2021},
|
||||
url = {https://www.biorxiv.org/content/10.1101/810622v4},
|
||||
}</pre>
|
||||
|
||||
<div class="page-header">
|
||||
|
||||
@@ -25,14 +25,18 @@
|
||||
# ==================================================================== #
|
||||
*/
|
||||
|
||||
/* R for Data Science (r4ds) */
|
||||
#r4ds a {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
text-align: right;
|
||||
/* R for Data Science (r4ds) on vignettes (articles) */
|
||||
#r4ds {
|
||||
display: flex;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
#r4ds img {
|
||||
margin-left: 10px;
|
||||
#r4ds .txt {
|
||||
width: 67%;
|
||||
}
|
||||
#r4ds .img {
|
||||
width: 33%;
|
||||
}
|
||||
|
||||
/* class for footer */
|
||||
@@ -196,16 +200,20 @@ div[id^=last-updated] h2 {
|
||||
.table td {
|
||||
padding: 4px !important;
|
||||
}
|
||||
.table thead {
|
||||
.table thead,
|
||||
.template-reference-topic .table tr:first-child {
|
||||
/* tables in manual are in LaTeX and thus have no thead */
|
||||
border-top: 2px solid black;
|
||||
border-bottom: 2px solid black;
|
||||
}
|
||||
.table thead ~ tbody {
|
||||
.table thead ~ tbody,
|
||||
.template-reference-topic .table tr:last-child {
|
||||
/* only when it has a header */
|
||||
/* tables in manual are in LaTeX and thus have no thead */
|
||||
border-bottom: 2px solid black;
|
||||
}
|
||||
.table thead th {
|
||||
text-align: inherit;
|
||||
/* text-align: inherit; */
|
||||
}
|
||||
/* all tables, including argument lists */
|
||||
table a:not(.btn) {
|
||||
@@ -227,6 +235,8 @@ table a:not(.btn):hover {
|
||||
}
|
||||
.template-reference-topic h4 {
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
padding-top: 35px;
|
||||
}
|
||||
|
||||
.template-home h4 {
|
||||
|
||||
@@ -30,12 +30,6 @@ $('head').append('<!-- Updated Font Awesome library --><link rel="stylesheet" hr
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// add SurveyMonkey
|
||||
// $('body').append('<script>(function(t,e,s,o){var n,a,c;t.SMCX=t.SMCX||[],e.getElementById(o)||(n=e.getElementsByTagName(s),a=n[n.length-1],c=e.createElement(s),c.type="text/javascript",c.async=!0,c.id=o,c.src=["https:"===location.protocol?"https://":"http://","widget.surveymonkey.com/collect/website/js/tRaiETqnLgj758hTBazgd_2BrwaGaWbg59AiLjNGdPaaJiBHKqgXKIw46VauwBvZ67.js"].join(""),a.parentNode.insertBefore(c,a))})(window,document,"script","smcx-sdk");</script>');
|
||||
// add link to survey at home sidebar
|
||||
// $('.template-home #sidebar .list-unstyled:first').append('<li><strong>Please fill in our survey at</strong> <br><a href="https://www.surveymonkey.com/r/AMR_for_R" target="_blank">https://www.surveymonkey.com/r/AMR_for_R</a></li>');
|
||||
|
||||
|
||||
// remove version label from header
|
||||
$(".version.label").remove();
|
||||
|
||||
@@ -45,21 +39,38 @@ $(document).ready(function() {
|
||||
if (url_old != url_new) {
|
||||
window.location.replace(url_new);
|
||||
}
|
||||
|
||||
// Edit title of manual
|
||||
$('.template-reference-index h1').text('Manual');
|
||||
|
||||
// Replace 'Value' in manual to 'Returned value'
|
||||
// replace 'Value' in manual with 'Returned value'
|
||||
$(".template-reference-topic h2#value").text("Returned value");
|
||||
|
||||
// replace \donttest and \dontrun texts in Examples
|
||||
if ($("pre.examples").length > 0) {
|
||||
$("pre.examples").html($("pre.examples").html().replaceAll("# \\donttest{", ""));
|
||||
$("pre.examples").html($("pre.examples").html().replaceAll("# \\dontrun{", ""));
|
||||
$("pre.examples").html($("pre.examples").html().replaceAll("# }", ""));
|
||||
}
|
||||
|
||||
// PR for 'R for Data Science' on How To pages
|
||||
if ($(".template-article").length > 0) {
|
||||
$('#sidebar').prepend(
|
||||
$('#pkgdown-sidebar').prepend(
|
||||
'<div id="r4ds">' +
|
||||
' <a target="_blank" href="https://r4ds.had.co.nz/">' +
|
||||
' Learn R reading this great book: R for Data Science.' +
|
||||
' <br><br>' +
|
||||
' Click to read it online - it was published for free.' +
|
||||
' <img src="https://github.com/msberends/AMR/raw/master/docs/cover_r4ds.png" height="100px">' +
|
||||
' </a> ' +
|
||||
' <hr>' +
|
||||
' <div class="txt">' +
|
||||
' <p>' +
|
||||
' Learn R reading this great book: <i>R for Data Science</i>.' +
|
||||
' <br><br>' +
|
||||
' <a target="_blank" href="https://r4ds.had.co.nz/">' +
|
||||
' Click to read it online - it was published for free.' +
|
||||
' </a>' +
|
||||
' </p>' +
|
||||
' </div>' +
|
||||
' <div class="img">' +
|
||||
' <a target="_blank" href="https://r4ds.had.co.nz/">' +
|
||||
' <img src="https://github.com/msberends/AMR/raw/master/docs/cover_r4ds.png">' +
|
||||
' </a>' +
|
||||
' </div>' +
|
||||
'</div>');
|
||||
}
|
||||
|
||||
@@ -96,13 +107,10 @@ $(document).ready(function() {
|
||||
}
|
||||
$(".template-authors").html(doct_tit($(".template-authors").html()));
|
||||
$(".template-citation-authors").html(doct_tit($(".template-citation-authors").html()));
|
||||
$('.template-citation-authors h1').eq(0).text('How to cite');
|
||||
$('.template-citation-authors h1').eq(1).text('All contributors');
|
||||
$('.template-citation-authors h1').eq(0).html("How to cite the <code>AMR</code> package");
|
||||
$('.template-citation-authors h1').eq(1).html("All contributors of the <code>AMR</code> package");
|
||||
$(".developers").html(doct_tit($(".developers").html()));
|
||||
$(".developers a[href='authors.html']").text("All contributors...");
|
||||
|
||||
// Edit title of manual
|
||||
$('.template-reference-index h1').text('Manual');
|
||||
});
|
||||
|
||||
$('head').append("<!-- Global site tag (gtag.js) - Google Analytics --> <script async src=\"https://www.googletagmanager.com/gtag/js?id=UA-172114740-1\"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-172114740-1'); </script><!-- Matomo --><script type='text/javascript'> var _paq = _paq || []; /* tracker methods like 'setCustomDimension' should be called before 'trackPageView' */ _paq.push(['setDomains', ['*.msberends.github.io/AMR']]); _paq.push(['enableCrossDomainLinking']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u='https://analyse.uscloud.nl/'; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', '3']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })();</script><!-- End Matomo Code -->");
|
||||
|
||||
@@ -19,11 +19,10 @@
|
||||
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="pkgdown.css" rel="stylesheet">
|
||||
<script src="pkgdown.js"></script><link href="extra.css" rel="stylesheet">
|
||||
<script src="extra.js"></script><meta property="og:title" content="Antimicrobial Resistance Data Analysis">
|
||||
<meta property="og:description" content="Functions to simplify the analysis and prediction of Antimicrobial
|
||||
Resistance (AMR) and to work with microbial and antimicrobial properties by
|
||||
using evidence-based methods, like those defined by Leclercq et al. (2013)
|
||||
<doi:10.1111/j.1469-0691.2011.03703.x> and containing reference data such as
|
||||
LPSN <doi:10.1099/ijsem.0.004332>.">
|
||||
<meta property="og:description" content="Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
data analysis and to work with microbial and antimicrobial properties by
|
||||
using evidence-based methods and reliable reference data such as LPSN
|
||||
<doi:10.1099/ijsem.0.004332>.">
|
||||
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png">
|
||||
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
@@ -43,7 +42,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9014</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -197,16 +196,12 @@
|
||||
<div class="page-header"><h1 class="hasAnchor">
|
||||
<a href="#amr-for-r-" class="anchor"></a><code>AMR</code> (for R) <img src="./logo.png" align="right" height="120px">
|
||||
</h1></div>
|
||||
<p><em>Note: the rules of ‘EUCAST Clinical Breakpoints v11.0 (2021)’ are now implemented</em></p>
|
||||
<blockquote>
|
||||
<p><span class="fa fa-clipboard-list" style="color: #128f76; font-size: 20pt; margin-right: 5px;"></span> <strong>PLEASE TAKE PART IN OUR SURVEY!</strong><br>
|
||||
Since you are one of our users, we would like to know how you use the package and what it brought you or your organisation. <strong>If you have a minute, please <a href="./survey.html">anonymously fill in this short questionnaire</a></strong>. Your valuable input will help to improve the package and its functionalities. You can answer the open questions in either English, Spanish, French, Dutch, or German. Thank you very much in advance! <br><a class="btn btn-info btn-amr" href="./survey.html">Take me to the 5-min survey!</a></p>
|
||||
</blockquote>
|
||||
<p><em>Note: the rules of ‘EUCAST Clinical Breakpoints v11.0 (2021)’ are now implemented.</em></p>
|
||||
<div id="what-is-amr-for-r" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#what-is-amr-for-r" class="anchor"></a>What is <code>AMR</code> (for R)?</h3>
|
||||
<p><em>(To find out how to conduct AMR data analysis, please <a href="./articles/AMR.html">continue reading here to get started</a>.)</em></p>
|
||||
<p><code>AMR</code> is a free, open-source and independent <a href="https://www.r-project.org">R package</a> to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. <strong>Our aim is to provide a standard</strong> for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting.</p>
|
||||
<p><code>AMR</code> is a free, open-source and independent <a href="https://www.r-project.org">R package</a> to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. <strong>Our aim is to provide a standard</strong> for clean and reproducible AMR data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting.</p>
|
||||
<p>After installing this package, R knows <a href="./reference/microorganisms.html"><strong>~70,000 distinct microbial species</strong></a> and all <a href="./reference/antibiotics.html"><strong>~550 antibiotic, antimycotic and antiviral drugs</strong></a> by name and code (including ATC, EARS-Net, PubChem, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data.</p>
|
||||
<p>This package is <a href="https://en.wikipedia.org/wiki/Dependency_hell">fully independent of any other R package</a> and works on Windows, macOS and Linux with all versions of R since R-3.0.0 (April 2013). <strong>It was designed to work in any setting, including those with very limited resources</strong>. It was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the <a href="https://www.rug.nl">University of Groningen</a>, in collaboration with non-profit organisations <a href="https://www.certe.nl">Certe Medical Diagnostics and Advice Foundation</a> and <a href="https://www.umcg.nl">University Medical Center Groningen</a>. This R package is <a href="./news">actively maintained</a> and is free software (see <a href="#copyright">Copyright</a>).</p>
|
||||
<div class="main-content" style="display: inline-block;">
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9014</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -236,14 +236,78 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-160" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0">
|
||||
<a href="#amr-160" class="anchor"></a>AMR 1.6.0<small> Unreleased </small>
|
||||
</h1>
|
||||
<div id="amr-1609014" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0.9014">
|
||||
<a href="#amr-1609014" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9014</h1>
|
||||
<div id="last-updated-30-april-2021" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-30-april-2021" class="anchor"></a><small>Last updated: 30 April 2021</small>
|
||||
</h2>
|
||||
<div id="new" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>Function <code><a href="../reference/custom_eucast_rules.html">custom_eucast_rules()</a></code> that brings support for custom AMR rules in <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>
|
||||
</li>
|
||||
<li>Support for all four methods to determine first isolates as summarised by Hindler <em>et al</em> (doi: <a href="https://doi.org/10.1086/511864">10.1086/511864</a>): isolate-based, patient-based, episode-based and phenotype-based. The last method is now the default.
|
||||
<ul>
|
||||
<li>The <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function gained the argument <code>method</code> that has to be “phenotype-based”, “episode-based”, “patient-based”, or “isolate-based”. The old behaviour is equal to “episode-based”. The new default is “phenotype-based” if antimicrobial test results are available, and “episode-based” otherwise. This new default will yield slightly more isolates for selection (which is a good thing).</li>
|
||||
<li>Since fungal isolates can also be selected, the functions <code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code> and <code><a href="../reference/AMR-deprecated.html">key_antibiotics_equal()</a></code> are now deprecated in favour of the <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> and <code>antimicrobial_equal()</code> functions. Also, the new <code><a href="../reference/key_antimicrobials.html">all_antimicrobials()</a></code> function works like the old <code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code> function, but includes any column with antimicrobial test results. Using <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new <code>antifungal</code> argument to set antifungal agents (antimycotics).</li>
|
||||
<li>Using <code>type == "points"</code> in the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function for phenotype-based selection will now consider all antimicrobial drugs in the data set, using the new <code><a href="../reference/key_antimicrobials.html">all_antimicrobials()</a></code>
|
||||
</li>
|
||||
<li>The <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function can now take a vector of values for <code>col_keyantibiotics</code> and can have an episode length of <code>Inf</code>
|
||||
</li>
|
||||
<li>Since the phenotype-based method is the new default, <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> renders the <code><a href="../reference/AMR-deprecated.html">filter_first_weighted_isolate()</a></code> function redundant. For this reason, <code><a href="../reference/AMR-deprecated.html">filter_first_weighted_isolate()</a></code> is now deprecated.</li>
|
||||
<li>The documentation of the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> and <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> functions has been completely rewritten.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>Custom MDRO guidelines (<code><a href="../reference/mdro.html">mdro()</a></code>, <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code>):
|
||||
<ul>
|
||||
<li>Custom MDRO guidelines can now be combined with other custom MDRO guidelines using <code><a href="https://rdrr.io/r/base/c.html">c()</a></code>
|
||||
</li>
|
||||
<li>Fix for applying the rules; in previous versions, rows were interpreted according to the last matched rule. Now, rows are interpreted according to the first matched rule</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Fix for <code><a href="../reference/age_groups.html">age_groups()</a></code> for persons aged zero</li>
|
||||
<li>The <code>example_isolates</code> data set now contains some (fictitious) zero-year old patients</li>
|
||||
<li>Fix for minor translation errors</li>
|
||||
<li>Printing of microbial codes in a <code>data.frame</code> or <code>tibble</code> now gives a warning if the data contains old microbial codes (from a previous AMR package version)</li>
|
||||
<li>Extended the <code><a href="../reference/like.html">like()</a></code> functions:
|
||||
<ul>
|
||||
<li><p>Now checks if <code>pattern</code> is a <em>valid</em> regular expression</p></li>
|
||||
<li>
|
||||
<p>Added <code><a href="../reference/like.html">%unlike%</a></code> and <code><a href="../reference/like.html">%unlike_case%</a></code> (as negations of the existing <code><a href="../reference/like.html">%like%</a></code> and <code><a href="../reference/like.html">%like_case%</a></code>). This greatly improves readability:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grepl</a></span><span class="op">(</span><span class="st">"EUCAST"</span>, <span class="va">guideline</span><span class="op">)</span><span class="op">)</span> <span class="va">...</span>
|
||||
<span class="co"># same:</span>
|
||||
<span class="kw">if</span> <span class="op">(</span><span class="va">guideline</span> <span class="op">%unlike%</span> <span class="st">"EUCAST"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
|
||||
</li>
|
||||
<li><p>Altered the RStudio addin, so it now iterates over <code><a href="../reference/like.html">%like%</a></code> -> <code><a href="../reference/like.html">%unlike%</a></code> -> <code><a href="../reference/like.html">%like_case%</a></code> -> <code><a href="../reference/like.html">%unlike_case%</a></code> if you keep pressing your keyboard shortcut</p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Fixed an installation error on R-3.0</li>
|
||||
<li>Added <code>info</code> argument to <code><a href="../reference/as.mo.html">as.mo()</a></code> to turn on/off the progress bar</li>
|
||||
<li>Fixed a bug that <code>col_mo</code> for some functions (esp. <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> and <code><a href="../reference/mdro.html">mdro()</a></code>) could not be column names of the <code>microorganisms</code> data set as it would throw an error</li>
|
||||
<li>Fix for transforming numeric values to RSI (<code><a href="../reference/as.rsi.html">as.rsi()</a></code>) when the <code>vctrs</code> package is loaded (i.e., when using tidyverse)</li>
|
||||
<li>Colour fix for using <code><a href="https://rdrr.io/r/graphics/barplot.html">barplot()</a></code> on an RSI class</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="amr-160" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0">
|
||||
<a href="#amr-160" class="anchor"></a><small> 2021-03-14 </small><code>AMR</code> 1.6.0</h1>
|
||||
<div id="new-1" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new-1" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function and in <code><a href="../reference/as.rsi.html">as.rsi()</a></code> to interpret MIC and disk diffusion values. This is now the default guideline in this package.</p>
|
||||
<ul>
|
||||
@@ -265,7 +329,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<p>Functions <code><a href="../reference/antibiotic_class_selectors.html">oxazolidinones()</a></code> (an antibiotic selector function) and <code><a href="../reference/filter_ab_class.html">filter_oxazolidinones()</a></code> (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
<span class="va">x</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">date</span>, <span class="va">hospital_id</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">oxazolidinones</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>
|
||||
@@ -275,10 +339,10 @@
|
||||
<span class="co">#> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"</span></code></pre></div>
|
||||
</li>
|
||||
<li><p>Support for custom MDRO guidelines, using the new <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function, please see <code><a href="../reference/mdro.html">mdro()</a></code> for additional info</p></li>
|
||||
<li><p><code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot()</a></code> generics for classes <code><mic></code> and <code><disk></code></p></li>
|
||||
<li><p><code>ggplot()</code> generics for classes <code><mic></code> and <code><disk></code></p></li>
|
||||
<li>
|
||||
<p>Function <code><a href="../reference/mo_property.html">mo_is_yeast()</a></code>, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_kingdom</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Aspergillus"</span>, <span class="st">"Candida"</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="co">#> [1] "Fungi" "Fungi"</span>
|
||||
@@ -290,7 +354,7 @@
|
||||
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html">which</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_is_yeast</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>, <span class="op">]</span> <span class="co"># base R</span>
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_is_yeast</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span></code></pre></div>
|
||||
<p>The <code><a href="../reference/mo_property.html">mo_type()</a></code> function has also been updated to reflect this change:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_type</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Aspergillus"</span>, <span class="st">"Candida"</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="co"># [1] "Fungi" "Yeasts"</span>
|
||||
@@ -300,7 +364,7 @@
|
||||
<li><p>Added Pretomanid (PMD, J04AK08) to the <code>antibiotics</code> data set</p></li>
|
||||
<li>
|
||||
<p>MIC values (see <code><a href="../reference/as.mic.html">as.mic()</a></code>) can now be used in any mathematical processing, such as usage inside functions <code><a href="https://rdrr.io/r/base/Extremes.html">min()</a></code>, <code><a href="https://rdrr.io/r/base/Extremes.html">max()</a></code>, <code><a href="https://rdrr.io/r/base/range.html">range()</a></code>, and with binary operators (<code><a href="https://rdrr.io/r/base/Arithmetic.html">+</a></code>, <code><a href="https://rdrr.io/r/base/Arithmetic.html">-</a></code>, etc.). This allows for easy distribution analysis and fast filtering on MIC values:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/random.html">random_mic</a></span><span class="op">(</span><span class="fl">10</span><span class="op">)</span>
|
||||
<span class="va">x</span>
|
||||
@@ -316,11 +380,11 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed" class="section level3">
|
||||
<div id="changed-1" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed" class="anchor"></a>Changed</h3>
|
||||
<a href="#changed-1" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>Updated the bacterial taxonomy to 3 March 2021 (using <a href="https://lpsn.dsmz.de">LSPN</a>)
|
||||
<li>Updated the bacterial taxonomy to 3 March 2021 (using <a href="https://lpsn.dsmz.de">LPSN</a>)
|
||||
<ul>
|
||||
<li>Added 3,372 new species and 1,523 existing species became synomyms</li>
|
||||
<li>The URL of a bacterial species (<code><a href="../reference/mo_property.html">mo_url()</a></code>) will now lead to <a href="https://lpsn.dsmz.de" class="uri">https://lpsn.dsmz.de</a>
|
||||
@@ -332,7 +396,7 @@
|
||||
<li>Plotting of MIC and disk diffusion values now support interpretation colouring if you supply the microorganism and antimicrobial agent</li>
|
||||
<li>All colours were updated to colour-blind friendly versions for values R, S and I for all plot methods (also applies to tibble printing)</li>
|
||||
<li>Interpretation of MIC and disk diffusion values to R/SI will now be translated if the system language is German, Dutch or Spanish (see <code>translate</code>)</li>
|
||||
<li>Plotting is now possible with base R using <code><a href="../reference/plot.html">plot()</a></code> and with ggplot2 using <code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot()</a></code> on any vector of MIC and disk diffusion values</li>
|
||||
<li>Plotting is now possible with base R using <code><a href="../reference/plot.html">plot()</a></code> and with ggplot2 using <code>ggplot()</code> on any vector of MIC and disk diffusion values</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Updated SNOMED codes to US Edition of SNOMED CT from 1 September 2020 and added the source to the help page of the <code>microorganisms</code> data set</li>
|
||||
@@ -376,15 +440,14 @@
|
||||
</div>
|
||||
<div id="amr-150" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.5.0">
|
||||
<a href="#amr-150" class="anchor"></a>AMR 1.5.0<small> 2021-01-06 </small>
|
||||
</h1>
|
||||
<div id="new-1" class="section level3">
|
||||
<a href="#amr-150" class="anchor"></a><small> 2021-01-06 </small><code>AMR</code> 1.5.0</h1>
|
||||
<div id="new-2" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new-1" class="anchor"></a>New</h3>
|
||||
<a href="#new-2" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Functions <code><a href="../reference/get_episode.html">get_episode()</a></code> and <code><a href="../reference/get_episode.html">is_new_episode()</a></code> to determine (patient) episodes which are not necessarily based on microorganisms. The <code><a href="../reference/get_episode.html">get_episode()</a></code> function returns the index number of the episode per group, while the <code><a href="../reference/get_episode.html">is_new_episode()</a></code> function returns values <code>TRUE</code>/<code>FALSE</code> to indicate whether an item in a vector is the start of a new episode. They also support <code>dplyr</code>s grouping (i.e. using <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code>):</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
@@ -396,9 +459,9 @@
|
||||
<li><p>Functions <code><a href="../reference/random.html">random_mic()</a></code>, <code><a href="../reference/random.html">random_disk()</a></code> and <code><a href="../reference/random.html">random_rsi()</a></code> for random value generation. The functions <code><a href="../reference/random.html">random_mic()</a></code> and <code><a href="../reference/random.html">random_disk()</a></code> take microorganism names and antibiotic names as input to make generation more realistic.</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-1" class="section level3">
|
||||
<div id="changed-2" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed-1" class="anchor"></a>Changed</h3>
|
||||
<a href="#changed-2" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li><p>New argument <code>ampc_cephalosporin_resistance</code> in <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> to correct for AmpC de-repressed cephalosporin-resistant mutants</p></li>
|
||||
<li>
|
||||
@@ -425,7 +488,7 @@
|
||||
<li>
|
||||
<code><a href="../reference/first_isolate.html">first_isolate()</a></code>,</li>
|
||||
<li>
|
||||
<code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code>,</li>
|
||||
<code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code>,</li>
|
||||
<li>
|
||||
<code><a href="../reference/mdro.html">mdro()</a></code>,</li>
|
||||
<li>
|
||||
@@ -438,7 +501,7 @@
|
||||
<code><a href="../reference/mdro.html">mdr_cmi2012()</a></code>,</li>
|
||||
<li><code><a href="../reference/mdro.html">eucast_exceptional_phenotypes()</a></code></li>
|
||||
</ul>
|
||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># to select first isolates that are Gram-negative </span>
|
||||
<span class="co"># and view results of cephalosporins and aminoglycosides:</span>
|
||||
@@ -450,7 +513,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<p>For antibiotic selection functions (such as <code><a href="../reference/antibiotic_class_selectors.html">cephalosporins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>) to select columns based on a certain antibiotic group, the dependency on the <code>tidyselect</code> package was removed, meaning that they can now also be used without the need to have this package installed and now also work in base R function calls (they rely on R 3.2 or later):</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># above example in base R:</span>
|
||||
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html">which</a></span><span class="op">(</span><span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="op">)</span> <span class="op">&</span> <span class="fu"><a href="../reference/mo_property.html">mo_is_gram_negative</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>,
|
||||
@@ -490,18 +553,17 @@
|
||||
</div>
|
||||
<div id="amr-140" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.4.0">
|
||||
<a href="#amr-140" class="anchor"></a>AMR 1.4.0<small> 2020-10-08 </small>
|
||||
</h1>
|
||||
<div id="new-2" class="section level3">
|
||||
<a href="#amr-140" class="anchor"></a><small> 2020-10-08 </small><code>AMR</code> 1.4.0</h1>
|
||||
<div id="new-3" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new-2" class="anchor"></a>New</h3>
|
||||
<a href="#new-3" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li><p>Support for ‘EUCAST Expert Rules’ / ‘EUCAST Intrinsic Resistance and Unusual Phenotypes’ version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function can now correct for more than 180 different antibiotics and the <code><a href="../reference/mdro.html">mdro()</a></code> function can determine multidrug resistance based on more than 150 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function consequently gained the arguments <code>version_breakpoints</code> (at the moment defaults to v10.0, 2020) and <code>version_expertrules</code> (at the moment defaults to v3.2, 2020). The <code>example_isolates</code> data set now also reflects the change from v3.1 to v3.2. The <code><a href="../reference/mdro.html">mdro()</a></code> function now accepts <code>guideline == "EUCAST3.1"</code> and <code>guideline == "EUCAST3.2"</code>.</p></li>
|
||||
<li><p>A new vignette and website page with info about all our public and freely available data sets, that can be downloaded as flat files or in formats for use in R, SPSS, SAS, Stata and Excel: <a href="https://msberends.github.io/AMR/articles/datasets.html" class="uri">https://msberends.github.io/AMR/articles/datasets.html</a></p></li>
|
||||
<li>
|
||||
<p>Data set <code>intrinsic_resistant</code>. This data set contains all bug-drug combinations where the ‘bug’ is intrinsic resistant to the ‘drug’ according to the latest EUCAST insights. It contains just two columns: <code>microorganism</code> and <code>antibiotic</code>.</p>
|
||||
<p>Curious about which enterococci are actually intrinsic resistant to vancomycin?</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
@@ -514,9 +576,9 @@
|
||||
<li><p>Support for skimming classes <code><rsi></code>, <code><mic></code>, <code><disk></code> and <code><mo></code> with the <code>skimr</code> package</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-2" class="section level3">
|
||||
<div id="changed-3" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed-2" class="anchor"></a>Changed</h3>
|
||||
<a href="#changed-3" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li><p>Although advertised that this package should work under R 3.0.0, we still had a dependency on R 3.6.0. This is fixed, meaning that our package should now work under R 3.0.0.</p></li>
|
||||
<li>
|
||||
@@ -524,7 +586,7 @@
|
||||
<ul>
|
||||
<li>
|
||||
<p>Support for using <code>dplyr</code>’s <code><a href="https://dplyr.tidyverse.org/reference/across.html">across()</a></code> to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># until dplyr 1.0.0</span>
|
||||
<span class="va">your_data</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_if</a></span><span class="op">(</span><span class="va">is.mic</span>, <span class="va">as.rsi</span><span class="op">)</span>
|
||||
@@ -542,7 +604,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<p>Added intelligent data cleaning to <code><a href="../reference/as.disk.html">as.disk()</a></code>, so numbers can also be extracted from text and decimal numbers will always be rounded up:</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/as.disk.html">as.disk</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"disk zone: 23.4 mm"</span>, <span class="fl">23.4</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="co">#> Class <disk></span>
|
||||
@@ -594,16 +656,15 @@
|
||||
</div>
|
||||
<div id="amr-130" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.3.0">
|
||||
<a href="#amr-130" class="anchor"></a>AMR 1.3.0<small> 2020-07-31 </small>
|
||||
</h1>
|
||||
<div id="new-3" class="section level3">
|
||||
<a href="#amr-130" class="anchor"></a><small> 2020-07-31 </small><code>AMR</code> 1.3.0</h1>
|
||||
<div id="new-4" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new-3" class="anchor"></a>New</h3>
|
||||
<a href="#new-4" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li><p>Function <code><a href="../reference/ab_from_text.html">ab_from_text()</a></code> to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses <code><a href="../reference/as.ab.html">as.ab()</a></code> internally</p></li>
|
||||
<li>
|
||||
<p><a href="https://tidyselect.r-lib.org/reference/language.html">Tidyverse selection helpers</a> for antibiotic classes, that help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. They can be used in any function that allows selection helpers, like <code><a href="https://dplyr.tidyverse.org/reference/select.html">dplyr::select()</a></code> and <code><a href="https://tidyr.tidyverse.org/reference/pivot_longer.html">tidyr::pivot_longer()</a></code>:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
|
||||
@@ -620,9 +681,9 @@
|
||||
<li><p>Added argument <code>conserve_capped_values</code> to <code><a href="../reference/as.rsi.html">as.rsi()</a></code> for interpreting MIC values - it makes sure that values starting with “<” (but not “<=”) will always return “S” and values starting with “>” (but not “>=”) will always return “R”. The default behaviour of <code><a href="../reference/as.rsi.html">as.rsi()</a></code> has not changed, so you need to specifically do <code><a href="../reference/as.rsi.html">as.rsi(..., conserve_capped_values = TRUE)</a></code>.</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-3" class="section level3">
|
||||
<div id="changed-4" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed-3" class="anchor"></a>Changed</h3>
|
||||
<a href="#changed-4" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Big speed improvement for using any function on microorganism codes from earlier package versions (prior to <code>AMR</code> v1.2.0), such as <code><a href="../reference/as.mo.html">as.mo()</a></code>, <code><a href="../reference/mo_property.html">mo_name()</a></code>, <code><a href="../reference/first_isolate.html">first_isolate()</a></code>, <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>, <code><a href="../reference/mdro.html">mdro()</a></code>, etc.</p>
|
||||
@@ -677,8 +738,7 @@
|
||||
</div>
|
||||
<div id="amr-120" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.2.0">
|
||||
<a href="#amr-120" class="anchor"></a>AMR 1.2.0<small> 2020-05-28 </small>
|
||||
</h1>
|
||||
<a href="#amr-120" class="anchor"></a><small> 2020-05-28 </small><code>AMR</code> 1.2.0</h1>
|
||||
<div id="breaking" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#breaking" class="anchor"></a>Breaking</h3>
|
||||
@@ -696,9 +756,9 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-4" class="section level3">
|
||||
<div id="changed-5" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed-4" class="anchor"></a>Changed</h3>
|
||||
<a href="#changed-5" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>Taxonomy:
|
||||
<ul>
|
||||
@@ -741,19 +801,18 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-110" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.1.0">
|
||||
<a href="#amr-110" class="anchor"></a>AMR 1.1.0<small> 2020-04-15 </small>
|
||||
</h1>
|
||||
<div id="new-4" class="section level3">
|
||||
<a href="#amr-110" class="anchor"></a><small> 2020-04-15 </small><code>AMR</code> 1.1.0</h1>
|
||||
<div id="new-5" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new-4" class="anchor"></a>New</h3>
|
||||
<a href="#new-5" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>Support for easy principal component analysis for AMR, using the new <code><a href="../reference/pca.html">pca()</a></code> function</li>
|
||||
<li>Plotting biplots for principal component analysis using the new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-5" class="section level3">
|
||||
<div id="changed-6" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed-5" class="anchor"></a>Changed</h3>
|
||||
<a href="#changed-6" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>Improvements for the algorithm used by <code><a href="../reference/as.mo.html">as.mo()</a></code> (and consequently all <code>mo_*</code> functions, that use <code><a href="../reference/as.mo.html">as.mo()</a></code> internally):
|
||||
<ul>
|
||||
@@ -783,16 +842,15 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-101" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.0.1">
|
||||
<a href="#amr-101" class="anchor"></a>AMR 1.0.1<small> 2020-02-23 </small>
|
||||
</h1>
|
||||
<div id="changed-6" class="section level3">
|
||||
<a href="#amr-101" class="anchor"></a><small> 2020-02-23 </small><code>AMR</code> 1.0.1</h1>
|
||||
<div id="changed-7" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed-6" class="anchor"></a>Changed</h3>
|
||||
<a href="#changed-7" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li><p>Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline</p></li>
|
||||
<li>
|
||||
<p>Interpretation from MIC values (and disk zones) to R/SI can now be used with <code><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at()</a></code> of the <code>dplyr</code> package:</p>
|
||||
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">yourdata</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">antibiotic1</span><span class="op">:</span><span class="va">antibiotic25</span><span class="op">)</span>, <span class="va">as.rsi</span>, mo <span class="op">=</span> <span class="st">"E. coli"</span><span class="op">)</span>
|
||||
@@ -808,12 +866,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-100" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.0.0">
|
||||
<a href="#amr-100" class="anchor"></a>AMR 1.0.0<small> 2020-02-17 </small>
|
||||
</h1>
|
||||
<a href="#amr-100" class="anchor"></a><small> 2020-02-17 </small><code>AMR</code> 1.0.0</h1>
|
||||
<p>This software is now out of beta and considered stable. Nonetheless, this package will be developed continually.</p>
|
||||
<div id="new-5" class="section level3">
|
||||
<div id="new-6" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new-5" class="anchor"></a>New</h3>
|
||||
<a href="#new-6" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>Support for the newest <a href="https://www.eucast.org/clinical_breakpoints/">EUCAST Clinical Breakpoint Tables v.10.0</a>, valid from 1 January 2020. This affects translation of MIC and disk zones using <code><a href="../reference/as.rsi.html">as.rsi()</a></code> and inferred resistance and susceptibility using <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>.</li>
|
||||
<li>The repository of this package now contains a clean version of the EUCAST and CLSI guidelines from 2011-2020 to translate MIC and disk diffusion values to R/SI: <a href="https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt" class="uri">https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt</a>. This <strong>allows for machine reading these guidelines</strong>, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file used to process the EUCAST Clinical Breakpoints Excel file <a href="https://github.com/msberends/AMR/blob/master/data-raw/read_EUCAST.R">can be found here</a>.</li>
|
||||
@@ -821,7 +878,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<ul>
|
||||
<li>
|
||||
<p>Support for LOINC codes in the <code>antibiotics</code> data set. Use <code><a href="../reference/ab_property.html">ab_loinc()</a></code> to retrieve LOINC codes, or use a LOINC code for input in any <code>ab_*</code> function:</p>
|
||||
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/ab_property.html">ab_loinc</a></span><span class="op">(</span><span class="st">"ampicillin"</span><span class="op">)</span>
|
||||
<span class="co">#> [1] "21066-6" "3355-5" "33562-0" "33919-2" "43883-8" "43884-6" "87604-5"</span>
|
||||
@@ -832,7 +889,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
<li>
|
||||
<p>Support for SNOMED CT codes in the <code>microorganisms</code> data set. Use <code><a href="../reference/mo_property.html">mo_snomed()</a></code> to retrieve SNOMED codes, or use a SNOMED code for input in any <code>mo_*</code> function:</p>
|
||||
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_snomed</a></span><span class="op">(</span><span class="st">"S. aureus"</span><span class="op">)</span>
|
||||
<span class="co">#> [1] 115329001 3092008 113961008</span>
|
||||
@@ -887,8 +944,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-090" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.9.0">
|
||||
<a href="#amr-090" class="anchor"></a>AMR 0.9.0<small> 2019-11-29 </small>
|
||||
</h1>
|
||||
<a href="#amr-090" class="anchor"></a><small> 2019-11-29 </small><code>AMR</code> 0.9.0</h1>
|
||||
<div id="breaking-1" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#breaking-1" class="anchor"></a>Breaking</h3>
|
||||
@@ -897,11 +953,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<ul>
|
||||
<li>
|
||||
<p>If you were dependent on the old Enterobacteriaceae family e.g. by using in your code:</p>
|
||||
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_family</a></span><span class="op">(</span><span class="va">somebugs</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Enterobacteriaceae"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
|
||||
<p>then please adjust this to:</p>
|
||||
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">somebugs</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Enterobacterales"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
|
||||
</li>
|
||||
@@ -909,13 +965,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="new-6" class="section level3">
|
||||
<div id="new-7" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new-6" class="anchor"></a>New</h3>
|
||||
<a href="#new-7" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Functions <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> as aliases of <code><a href="../reference/proportion.html">proportion_SI()</a></code> and <code><a href="../reference/proportion.html">proportion_R()</a></code>, respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.</p>
|
||||
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||
@@ -944,7 +1000,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>More intelligent way of coping with some consonants like “l” and “r”</p></li>
|
||||
<li>
|
||||
<p>Added a score (a certainty percentage) to <code><a href="../reference/as.mo.html">mo_uncertainties()</a></code>, that is calculated using the <a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a>:</p>
|
||||
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Stafylococcus aureus"</span>,
|
||||
<span class="st">"staphylokok aureuz"</span><span class="op">)</span><span class="op">)</span>
|
||||
@@ -995,22 +1051,21 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-080" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.8.0">
|
||||
<a href="#amr-080" class="anchor"></a>AMR 0.8.0<small> 2019-10-15 </small>
|
||||
</h1>
|
||||
<a href="#amr-080" class="anchor"></a><small> 2019-10-15 </small><code>AMR</code> 0.8.0</h1>
|
||||
<div id="breaking-2" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#breaking-2" class="anchor"></a>Breaking</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Determination of first isolates now <strong>excludes</strong> all ‘unknown’ microorganisms at default, i.e. microbial code <code>"UNKNOWN"</code>. They can be included with the new argument <code>include_unknown</code>:</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="va">...</span>, include_unknown <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
|
||||
<p>For WHONET users, this means that all records/isolates with organism code <code>"con"</code> (<em>contamination</em>) will be excluded at default, since <code>as.mo("con") = "UNKNOWN"</code>. The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>For code consistency, classes <code>ab</code> and <code>mo</code> will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in <code>NA</code>:</p>
|
||||
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># how it works in base R:</span>
|
||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="st">"A"</span><span class="op">)</span>
|
||||
@@ -1029,13 +1084,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>Renamed data set <code>septic_patients</code> to <code>example_isolates</code></p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="new-7" class="section level3">
|
||||
<div id="new-8" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new-7" class="anchor"></a>New</h3>
|
||||
<a href="#new-8" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Function <code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> to quickly get a <code>data.frame</code> with the results of all bug-drug combinations in a data set. The column containing microorganism codes is guessed automatically and its input is transformed with <code><a href="../reference/mo_property.html">mo_shortname()</a></code> at default:</p>
|
||||
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/bug_drug_combinations.html">bug_drug_combinations</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
||||
<span class="co">#> NOTE: Using column `mo` as input for `col_mo`.</span>
|
||||
@@ -1058,13 +1113,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<span class="co">#> 4 Gram-negative AMX 227 0 405 632</span>
|
||||
<span class="co">#> NOTE: Use 'format()' on this result to get a publicable/printable format.</span></code></pre></div>
|
||||
<p>You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R <code><a href="https://rdrr.io/r/base/format.html">format()</a></code> function:</p>
|
||||
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/format.html">format</a></span><span class="op">(</span><span class="va">x</span>, combine_IR <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
||||
</li>
|
||||
<li>
|
||||
<p>Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibility of a combination therapy. A new argument <code>only_all_tested</code> (<strong>which defaults to <code>FALSE</code></strong>) replaces the old <code>also_single_tested</code> and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
|
||||
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># --------------------------------------------------------------------</span>
|
||||
<span class="co"># only_all_tested = FALSE only_all_tested = TRUE</span>
|
||||
@@ -1086,7 +1141,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
<li>
|
||||
<p><code>tibble</code> printing support for classes <code>rsi</code>, <code>mic</code>, <code>disk</code>, <code>ab</code> <code>mo</code>. When using <code>tibble</code>s containing antimicrobial columns, values <code>S</code> will print in green, values <code>I</code> will print in yellow and values <code>R</code> will print in red. Microbial IDs (class <code>mo</code>) will emphasise on the genus and species, not on the kingdom.</p>
|
||||
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># (run this on your own console, as this page does not support colour printing)</span>
|
||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||
@@ -1096,9 +1151,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-7" class="section level3">
|
||||
<div id="changed-8" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed-7" class="anchor"></a>Changed</h3>
|
||||
<a href="#changed-8" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>Many algorithm improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code> (of which some led to additions to the <code>microorganisms</code> data set). Many thanks to all contributors that helped improving the algorithms.
|
||||
<ul>
|
||||
@@ -1143,7 +1198,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li>Renamed function <code>p.symbol()</code> to <code><a href="../reference/AMR-deprecated.html">p_symbol()</a></code> (the former is now deprecated and will be removed in a future version)</li>
|
||||
<li>Using negative values for <code>x</code> in <code><a href="../reference/age_groups.html">age_groups()</a></code> will now introduce <code>NA</code>s and not return an error anymore</li>
|
||||
<li>Fix for determining the system’s language</li>
|
||||
<li>Fix for <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> on foreign systems</li>
|
||||
<li>Fix for <code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code> on foreign systems</li>
|
||||
<li>Added 80 new LIS codes for microorganisms</li>
|
||||
<li>Relabeled the factor levels of <code><a href="../reference/mdro.html">mdr_tb()</a></code>
|
||||
</li>
|
||||
@@ -1161,15 +1216,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-071" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.7.1">
|
||||
<a href="#amr-071" class="anchor"></a>AMR 0.7.1<small> 2019-06-23 </small>
|
||||
</h1>
|
||||
<div id="new-8" class="section level4">
|
||||
<a href="#amr-071" class="anchor"></a><small> 2019-06-23 </small><code>AMR</code> 0.7.1</h1>
|
||||
<div id="new-9" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#new-8" class="anchor"></a>New</h4>
|
||||
<a href="#new-9" class="anchor"></a>New</h4>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Function <code><a href="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> to immediately show resistance percentages and number of available isolates:</p>
|
||||
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">AMX</span>, <span class="va">CIP</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
@@ -1196,7 +1250,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li>UPEC (Uropathogenic <em>E. coli</em>)</li>
|
||||
</ul>
|
||||
<p>All these lead to the microbial ID of <em>E. coli</em>:</p>
|
||||
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"UPEC"</span><span class="op">)</span>
|
||||
<span class="co"># B_ESCHR_COL</span>
|
||||
@@ -1209,9 +1263,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>Function <code><a href="../reference/mo_property.html">mo_synonyms()</a></code> to get all previously accepted taxonomic names of a microorganism</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-8" class="section level4">
|
||||
<div id="changed-9" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-8" class="anchor"></a>Changed</h4>
|
||||
<a href="#changed-9" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li>Column names of output <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> are now lowercase</li>
|
||||
<li>Fixed bug in translation of microorganism names</li>
|
||||
@@ -1246,11 +1300,10 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-070" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.7.0">
|
||||
<a href="#amr-070" class="anchor"></a>AMR 0.7.0<small> 2019-06-03 </small>
|
||||
</h1>
|
||||
<div id="new-9" class="section level4">
|
||||
<a href="#amr-070" class="anchor"></a><small> 2019-06-03 </small><code>AMR</code> 0.7.0</h1>
|
||||
<div id="new-10" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#new-9" class="anchor"></a>New</h4>
|
||||
<a href="#new-10" class="anchor"></a>New</h4>
|
||||
<ul>
|
||||
<li>Support for translation of disk diffusion and MIC values to RSI values (i.e. antimicrobial interpretations). Supported guidelines are EUCAST (2011 to 2019) and CLSI (2011 to 2019). Use <code><a href="../reference/as.rsi.html">as.rsi()</a></code> on an MIC value (created with <code><a href="../reference/as.mic.html">as.mic()</a></code>), a disk diffusion value (created with the new <code><a href="../reference/as.disk.html">as.disk()</a></code>) or on a complete date set containing columns with MIC or disk diffusion values.</li>
|
||||
<li>Function <code><a href="../reference/mo_property.html">mo_name()</a></code> as alias of <code><a href="../reference/mo_property.html">mo_fullname()</a></code>
|
||||
@@ -1258,9 +1311,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li>Added guidelines of the WHO to determine multi-drug resistance (MDR) for TB (<code><a href="../reference/mdro.html">mdr_tb()</a></code>) and added a new vignette about MDR. Read this tutorial <a href="https://msberends.gitlab.io/AMR/articles/MDR.html">here on our website</a>.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-9" class="section level4">
|
||||
<div id="changed-10" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-9" class="anchor"></a>Changed</h4>
|
||||
<a href="#changed-10" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li>Fixed a critical bug in <code><a href="../reference/first_isolate.html">first_isolate()</a></code> 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.</li>
|
||||
<li>Fixed a bug in <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> where antibiotics from WHONET software would not be recognised</li>
|
||||
@@ -1301,7 +1354,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>when all values are unique it now shows a message instead of a warning</p></li>
|
||||
<li>
|
||||
<p>support for boxplots:</p>
|
||||
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||
<span class="fu">freq</span><span class="op">(</span><span class="va">age</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
@@ -1343,11 +1396,10 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-061" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.6.1">
|
||||
<a href="#amr-061" class="anchor"></a>AMR 0.6.1<small> 2019-03-29 </small>
|
||||
</h1>
|
||||
<div id="changed-10" class="section level4">
|
||||
<a href="#amr-061" class="anchor"></a><small> 2019-03-29 </small><code>AMR</code> 0.6.1</h1>
|
||||
<div id="changed-11" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-10" class="anchor"></a>Changed</h4>
|
||||
<a href="#changed-11" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li>Fixed a critical bug when using <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> with <code>verbose = TRUE</code>
|
||||
</li>
|
||||
@@ -1357,17 +1409,16 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-060" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.6.0">
|
||||
<a href="#amr-060" class="anchor"></a>AMR 0.6.0<small> 2019-03-27 </small>
|
||||
</h1>
|
||||
<a href="#amr-060" class="anchor"></a><small> 2019-03-27 </small><code>AMR</code> 0.6.0</h1>
|
||||
<p><strong>New website!</strong></p>
|
||||
<p>We’ve got a new website: <a href="https://msberends.gitlab.io/AMR/">https://msberends.gitlab.io/AMR</a> (built with the great <a href="https://pkgdown.r-lib.org/"><code>pkgdown</code></a>)</p>
|
||||
<ul>
|
||||
<li>Contains the complete manual of this package and all of its functions with an explanation of their arguments</li>
|
||||
<li>Contains a comprehensive tutorial about how to conduct AMR data analysis, import data from WHONET or SPSS and many more.</li>
|
||||
</ul>
|
||||
<div id="new-10" class="section level4">
|
||||
<div id="new-11" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#new-10" class="anchor"></a>New</h4>
|
||||
<a href="#new-11" class="anchor"></a>New</h4>
|
||||
<ul>
|
||||
<li><p><strong>BREAKING</strong>: removed deprecated functions, arguments and references to ‘bactid’. Use <code><a href="../reference/as.mo.html">as.mo()</a></code> to identify an MO code.</p></li>
|
||||
<li>
|
||||
@@ -1396,7 +1447,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
<li>
|
||||
<p>New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:</p>
|
||||
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>
|
||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_carbapenems</a></span><span class="op">(</span><span class="op">)</span>
|
||||
@@ -1410,7 +1461,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_macrolides</a></span><span class="op">(</span><span class="op">)</span>
|
||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_tetracyclines</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
|
||||
<p>The <code>antibiotics</code> 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 <code>antibiotics</code> data set. For example:</p>
|
||||
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/filter_ab_class.html">filter_glycopeptides</a></span><span class="op">(</span>result <span class="op">=</span> <span class="st">"R"</span><span class="op">)</span>
|
||||
<span class="co"># Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R</span>
|
||||
@@ -1419,7 +1470,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
<li>
|
||||
<p>All <code>ab_*</code> functions are deprecated and replaced by <code>atc_*</code> functions:</p>
|
||||
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">ab_property</span> <span class="op">-></span> <span class="fu">atc_property</span><span class="op">(</span><span class="op">)</span>
|
||||
<span class="va">ab_name</span> <span class="op">-></span> <span class="fu">atc_name</span><span class="op">(</span><span class="op">)</span>
|
||||
@@ -1440,21 +1491,21 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>New function <code><a href="../reference/age_groups.html">age_groups()</a></code> to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic AMR data analysis per age group.</p></li>
|
||||
<li>
|
||||
<p>New function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> as well as the base R <code><a href="../reference/plot.html">plot()</a></code> function can now be used for resistance prediction calculated with <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>:</p>
|
||||
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span><span class="va">septic_patients</span>, col_ab <span class="op">=</span> <span class="st">"amox"</span><span class="op">)</span>
|
||||
<span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
|
||||
</li>
|
||||
<li>
|
||||
<p>Functions <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code><a href="../reference/first_isolate.html">filter_first_weighted_isolate()</a></code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.:</p>
|
||||
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
|
||||
<p>Functions <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code><a href="../reference/AMR-deprecated.html">filter_first_weighted_isolate()</a></code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.:</p>
|
||||
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="va">...</span><span class="op">)</span>
|
||||
<span class="co"># or</span>
|
||||
<span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="va">...</span><span class="op">)</span></code></pre></div>
|
||||
<p>is equal to:</p>
|
||||
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>only_firsts <span class="op">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="va">...</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
@@ -1465,9 +1516,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>New vignettes about how to conduct AMR analysis, predict antimicrobial resistance, use the <em>G</em>-test and more. These are also available (and even easier readable) on our website: <a href="https://msberends.gitlab.io/AMR" class="uri">https://msberends.gitlab.io/AMR</a>.</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-11" class="section level4">
|
||||
<div id="changed-12" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-11" class="anchor"></a>Changed</h4>
|
||||
<a href="#changed-12" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li>Function <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:
|
||||
<ul>
|
||||
@@ -1487,7 +1538,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<ul>
|
||||
<li>
|
||||
<p>Now handles incorrect spelling, like <code>i</code> instead of <code>y</code> and <code>f</code> instead of <code>ph</code>:</p>
|
||||
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># mo_fullname() uses as.mo() internally</span>
|
||||
|
||||
@@ -1499,7 +1550,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
<li>
|
||||
<p>Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default <code>allow_uncertain = TRUE</code> is equal to uncertainty level 2. Run <code><a href="../reference/as.mo.html">?as.mo</a></code> for more info about these levels.</p>
|
||||
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># equal:</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">...</span>, allow_uncertain <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>
|
||||
@@ -1514,7 +1565,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>All microbial IDs that found are now saved to a local file <code>~/.Rhistory_mo</code>. Use the new function <code>clean_mo_history()</code> to delete this file, which resets the algorithms.</p></li>
|
||||
<li>
|
||||
<p>Incoercible results will now be considered ‘unknown’, MO code <code>UNKNOWN</code>. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:</p>
|
||||
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"qwerty"</span>, language <span class="op">=</span> <span class="st">"es"</span><span class="op">)</span>
|
||||
<span class="co"># Warning: </span>
|
||||
@@ -1564,7 +1615,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<ul>
|
||||
<li>
|
||||
<p>Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:</p>
|
||||
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="co"># Determine genus of microorganisms (mo) in `septic_patients` data set:</span>
|
||||
<span class="co"># OLD WAY</span>
|
||||
@@ -1592,7 +1643,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</ul>
|
||||
</li>
|
||||
<li>Function <code><a href="../reference/ggplot_rsi.html">scale_y_percent()</a></code> now contains the <code>limits</code> argument</li>
|
||||
<li>Automatic argument filling for <code><a href="../reference/mdro.html">mdro()</a></code>, <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> and <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>
|
||||
<li>Automatic argument filling for <code><a href="../reference/mdro.html">mdro()</a></code>, <code><a href="../reference/AMR-deprecated.html">key_antibiotics()</a></code> and <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>
|
||||
</li>
|
||||
<li>Updated examples for resistance prediction (<code><a href="../reference/resistance_predict.html">resistance_predict()</a></code> function)</li>
|
||||
<li>Fix for <code><a href="../reference/as.mic.html">as.mic()</a></code> to support more values ending in (several) zeroes</li>
|
||||
@@ -1609,11 +1660,10 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-050" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.5.0">
|
||||
<a href="#amr-050" class="anchor"></a>AMR 0.5.0<small> 2018-11-30 </small>
|
||||
</h1>
|
||||
<div id="new-11" class="section level4">
|
||||
<a href="#amr-050" class="anchor"></a><small> 2018-11-30 </small><code>AMR</code> 0.5.0</h1>
|
||||
<div id="new-12" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#new-11" class="anchor"></a>New</h4>
|
||||
<a href="#new-12" class="anchor"></a>New</h4>
|
||||
<ul>
|
||||
<li>Repository moved to GitLab</li>
|
||||
<li>Function <code>count_all</code> to get all available isolates (that like all <code>portion_*</code> and <code>count_*</code> functions also supports <code>summarise</code> and <code>group_by</code>), the old <code>n_rsi</code> is now an alias of <code>count_all</code>
|
||||
@@ -1624,9 +1674,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li>Functions <code>mo_authors</code> and <code>mo_year</code> to get specific values about the scientific reference of a taxonomic entry</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-12" class="section level4">
|
||||
<div id="changed-13" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-12" class="anchor"></a>Changed</h4>
|
||||
<a href="#changed-13" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li><p>Functions <code>MDRO</code>, <code>BRMO</code>, <code>MRGN</code> and <code>EUCAST_exceptional_phenotypes</code> were renamed to <code>mdro</code>, <code>brmo</code>, <code>mrgn</code> and <code>eucast_exceptional_phenotypes</code></p></li>
|
||||
<li><p><code>EUCAST_rules</code> was renamed to <code>eucast_rules</code>, the old function still exists as a deprecated function</p></li>
|
||||
@@ -1648,7 +1698,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>Fewer than 3 characters as input for <code>as.mo</code> will return NA</p></li>
|
||||
<li>
|
||||
<p>Function <code>as.mo</code> (and all <code>mo_*</code> wrappers) now supports genus abbreviations with “species” attached</p>
|
||||
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"E. species"</span><span class="op">)</span> <span class="co"># B_ESCHR</span>
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="st">"E. spp."</span><span class="op">)</span> <span class="co"># "Escherichia species"</span>
|
||||
@@ -1665,7 +1715,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<ul>
|
||||
<li>
|
||||
<p>Support for grouping variables, test with:</p>
|
||||
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">hospital_id</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
@@ -1673,7 +1723,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
<li>
|
||||
<p>Support for (un)selecting columns:</p>
|
||||
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||
<span class="fu">freq</span><span class="op">(</span><span class="va">hospital_id</span><span class="op">)</span> <span class="op">%>%</span>
|
||||
@@ -1733,11 +1783,10 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-040" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.4.0">
|
||||
<a href="#amr-040" class="anchor"></a>AMR 0.4.0<small> 2018-10-01 </small>
|
||||
</h1>
|
||||
<div id="new-12" class="section level4">
|
||||
<a href="#amr-040" class="anchor"></a><small> 2018-10-01 </small><code>AMR</code> 0.4.0</h1>
|
||||
<div id="new-13" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#new-12" class="anchor"></a>New</h4>
|
||||
<a href="#new-13" class="anchor"></a>New</h4>
|
||||
<ul>
|
||||
<li><p>The data set <code>microorganisms</code> now contains <strong>all microbial taxonomic data from ITIS</strong> (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via <a href="https://itis.gov" class="uri">https://itis.gov</a>. 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 <code>microorganisms.old</code> contains all previously known taxonomic names from those kingdoms.</p></li>
|
||||
<li>
|
||||
@@ -1753,7 +1802,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
</ul>
|
||||
<p>They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:</p>
|
||||
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="st">"E. coli"</span><span class="op">)</span>
|
||||
<span class="co"># [1] "Gram negative"</span>
|
||||
@@ -1764,7 +1813,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="st">"S. group A"</span>, language <span class="op">=</span> <span class="st">"pt"</span><span class="op">)</span> <span class="co"># Portuguese</span>
|
||||
<span class="co"># [1] "Streptococcus grupo A"</span></code></pre></div>
|
||||
<p>Furthermore, former taxonomic names will give a note about the current taxonomic name:</p>
|
||||
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="st">"Esc blattae"</span><span class="op">)</span>
|
||||
<span class="co"># Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)</span>
|
||||
@@ -1779,7 +1828,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>Function <code>is.rsi.eligible</code> to check for columns that have valid antimicrobial results, but do not have the <code>rsi</code> class yet. Transform the columns of your raw data with: <code>data %>% mutate_if(is.rsi.eligible, as.rsi)</code></p></li>
|
||||
<li>
|
||||
<p>Functions <code>as.mo</code> and <code>is.mo</code> as replacements for <code>as.bactid</code> and <code>is.bactid</code> (since the <code>microoganisms</code> data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The <code>as.mo</code> function determines microbial IDs using intelligent rules:</p>
|
||||
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"E. coli"</span><span class="op">)</span>
|
||||
<span class="co"># [1] B_ESCHR_COL</span>
|
||||
@@ -1788,7 +1837,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"S group A"</span><span class="op">)</span>
|
||||
<span class="co"># [1] B_STRPTC_GRA</span></code></pre></div>
|
||||
<p>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:</p>
|
||||
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">thousands_of_E_colis</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html">rep</a></span><span class="op">(</span><span class="st">"E. coli"</span>, <span class="fl">25000</span><span class="op">)</span>
|
||||
<span class="fu">microbenchmark</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span><span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">thousands_of_E_colis</span><span class="op">)</span>, unit <span class="op">=</span> <span class="st">"s"</span><span class="op">)</span>
|
||||
@@ -1815,14 +1864,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>Renamed <code>septic_patients$sex</code> to <code>septic_patients$gender</code></p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-13" class="section level4">
|
||||
<div id="changed-14" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-13" class="anchor"></a>Changed</h4>
|
||||
<a href="#changed-14" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li><p>Added three antimicrobial agents to the <code>antibiotics</code> data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)</p></li>
|
||||
<li>
|
||||
<p>Added 163 trade names to the <code>antibiotics</code> data set, it now contains 298 different trade names in total, e.g.:</p>
|
||||
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="fu">ab_official</span><span class="op">(</span><span class="st">"Bactroban"</span><span class="op">)</span>
|
||||
<span class="co"># [1] "Mupirocin"</span>
|
||||
@@ -1839,7 +1888,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>Added arguments <code>minimum</code> and <code>as_percent</code> to <code>portion_df</code></p></li>
|
||||
<li>
|
||||
<p>Support for quasiquotation in the functions series <code>count_*</code> and <code>portions_*</code>, and <code>n_rsi</code>. This allows to check for more than 2 vectors or columns.</p>
|
||||
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">amox</span>, <span class="va">cipr</span><span class="op">)</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/count.html">count_IR</a></span><span class="op">(</span><span class="op">)</span>
|
||||
<span class="co"># which is the same as:</span>
|
||||
@@ -1859,12 +1908,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li><p>Added longest en shortest character length in the frequency table (<code>freq</code>) header of class <code>character</code></p></li>
|
||||
<li>
|
||||
<p>Support for types (classes) list and matrix for <code>freq</code></p>
|
||||
<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb48"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">my_matrix</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/with.html">with</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="va">age</span>, <span class="va">gender</span><span class="op">)</span>, ncol <span class="op">=</span> <span class="fl">2</span><span class="op">)</span><span class="op">)</span>
|
||||
<span class="fu">freq</span><span class="op">(</span><span class="va">my_matrix</span><span class="op">)</span></code></pre></div>
|
||||
<p>For lists, subsetting is possible:</p>
|
||||
<div class="sourceCode" id="cb48"><pre class="downlit sourceCode r">
|
||||
<div class="sourceCode" id="cb49"><pre class="downlit sourceCode r">
|
||||
<code class="sourceCode R">
|
||||
<span class="va">my_list</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>age <span class="op">=</span> <span class="va">septic_patients</span><span class="op">$</span><span class="va">age</span>, gender <span class="op">=</span> <span class="va">septic_patients</span><span class="op">$</span><span class="va">gender</span><span class="op">)</span>
|
||||
<span class="va">my_list</span> <span class="op">%>%</span> <span class="fu">freq</span><span class="op">(</span><span class="va">age</span><span class="op">)</span>
|
||||
@@ -1882,11 +1931,10 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-030" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.3.0">
|
||||
<a href="#amr-030" class="anchor"></a>AMR 0.3.0<small> 2018-08-14 </small>
|
||||
</h1>
|
||||
<div id="new-13" class="section level4">
|
||||
<a href="#amr-030" class="anchor"></a><small> 2018-08-14 </small><code>AMR</code> 0.3.0</h1>
|
||||
<div id="new-14" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#new-13" class="anchor"></a>New</h4>
|
||||
<a href="#new-14" class="anchor"></a>New</h4>
|
||||
<ul>
|
||||
<li>
|
||||
<strong>BREAKING</strong>: <code>rsi_df</code> was removed in favour of new functions <code>portion_R</code>, <code>portion_IR</code>, <code>portion_I</code>, <code>portion_SI</code> and <code>portion_S</code> to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old <code>rsi</code> function. The old function still works, but is deprecated.
|
||||
@@ -1957,9 +2005,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-14" class="section level4">
|
||||
<div id="changed-15" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-14" class="anchor"></a>Changed</h4>
|
||||
<a href="#changed-15" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li>Improvements for forecasting with <code>resistance_predict</code> and added more examples</li>
|
||||
<li>More antibiotics added as arguments for EUCAST rules</li>
|
||||
@@ -2019,11 +2067,10 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-020" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.2.0">
|
||||
<a href="#amr-020" class="anchor"></a>AMR 0.2.0<small> 2018-05-03 </small>
|
||||
</h1>
|
||||
<div id="new-14" class="section level4">
|
||||
<a href="#amr-020" class="anchor"></a><small> 2018-05-03 </small><code>AMR</code> 0.2.0</h1>
|
||||
<div id="new-15" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#new-14" class="anchor"></a>New</h4>
|
||||
<a href="#new-15" class="anchor"></a>New</h4>
|
||||
<ul>
|
||||
<li>Full support for Windows, Linux and macOS</li>
|
||||
<li>Full support for old R versions, only R-3.0.0 (April 2013) or later is needed (needed packages may have other dependencies)</li>
|
||||
@@ -2043,9 +2090,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
<li>New print format for <code>tibble</code>s and <code>data.table</code>s</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="changed-15" class="section level4">
|
||||
<div id="changed-16" class="section level4">
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-15" class="anchor"></a>Changed</h4>
|
||||
<a href="#changed-16" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li>Fixed <code>rsi</code> class for vectors that contain only invalid antimicrobial interpretations</li>
|
||||
<li>Renamed dataset <code>ablist</code> to <code>antibiotics</code>
|
||||
@@ -2077,8 +2124,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-011" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.1.1">
|
||||
<a href="#amr-011" class="anchor"></a>AMR 0.1.1<small> 2018-03-14 </small>
|
||||
</h1>
|
||||
<a href="#amr-011" class="anchor"></a><small> 2018-03-14 </small><code>AMR</code> 0.1.1</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<code>EUCAST_rules</code> applies for amoxicillin even if ampicillin is missing</li>
|
||||
@@ -2090,8 +2136,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||
</div>
|
||||
<div id="amr-010" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="0.1.0">
|
||||
<a href="#amr-010" class="anchor"></a>AMR 0.1.0<small> 2018-02-22 </small>
|
||||
</h1>
|
||||
<a href="#amr-010" class="anchor"></a><small> 2018-02-22 </small><code>AMR</code> 0.1.0</h1>
|
||||
<ul>
|
||||
<li>First submission to CRAN.</li>
|
||||
</ul>
|
||||
|
||||
@@ -12,7 +12,7 @@ articles:
|
||||
datasets: datasets.html
|
||||
resistance_predict: resistance_predict.html
|
||||
welcome_to_AMR: welcome_to_AMR.html
|
||||
last_built: 2021-03-14T08:55Z
|
||||
last_built: 2021-04-30T08:14Z
|
||||
urls:
|
||||
reference: https://msberends.github.io/AMR//reference
|
||||
article: https://msberends.github.io/AMR//articles
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9016</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9013</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -242,7 +242,51 @@
|
||||
<p>These functions are so-called '<a href='https://rdrr.io/r/base/Deprecated.html'>Deprecated</a>'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).</p>
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>p_symbol</span><span class='op'>(</span><span class='va'>p</span>, emptychar <span class='op'>=</span> <span class='st'>" "</span><span class='op'>)</span></pre>
|
||||
<pre class="usage"><span class='fu'>p_symbol</span><span class='op'>(</span><span class='va'>p</span>, emptychar <span class='op'>=</span> <span class='st'>" "</span><span class='op'>)</span>
|
||||
|
||||
<span class='fu'>filter_first_weighted_isolate</span><span class='op'>(</span>
|
||||
x <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||
col_date <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||
col_patient_id <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||
col_mo <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||
<span class='va'>...</span>
|
||||
<span class='op'>)</span>
|
||||
|
||||
<span class='fu'>key_antibiotics</span><span class='op'>(</span>
|
||||
x <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||
col_mo <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||
universal_1 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"amoxicillin"</span><span class='op'>)</span>,
|
||||
universal_2 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"amoxicillin/clavulanic acid"</span><span class='op'>)</span>,
|
||||
universal_3 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"cefuroxime"</span><span class='op'>)</span>,
|
||||
universal_4 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"piperacillin/tazobactam"</span><span class='op'>)</span>,
|
||||
universal_5 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"ciprofloxacin"</span><span class='op'>)</span>,
|
||||
universal_6 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"trimethoprim/sulfamethoxazole"</span><span class='op'>)</span>,
|
||||
GramPos_1 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"vancomycin"</span><span class='op'>)</span>,
|
||||
GramPos_2 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"teicoplanin"</span><span class='op'>)</span>,
|
||||
GramPos_3 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"tetracycline"</span><span class='op'>)</span>,
|
||||
GramPos_4 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"erythromycin"</span><span class='op'>)</span>,
|
||||
GramPos_5 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"oxacillin"</span><span class='op'>)</span>,
|
||||
GramPos_6 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"rifampin"</span><span class='op'>)</span>,
|
||||
GramNeg_1 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"gentamicin"</span><span class='op'>)</span>,
|
||||
GramNeg_2 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"tobramycin"</span><span class='op'>)</span>,
|
||||
GramNeg_3 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"colistin"</span><span class='op'>)</span>,
|
||||
GramNeg_4 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"cefotaxime"</span><span class='op'>)</span>,
|
||||
GramNeg_5 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"ceftazidime"</span><span class='op'>)</span>,
|
||||
GramNeg_6 <span class='op'>=</span> <span class='fu'><a href='guess_ab_col.html'>guess_ab_col</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='st'>"meropenem"</span><span class='op'>)</span>,
|
||||
warnings <span class='op'>=</span> <span class='cn'>TRUE</span>,
|
||||
<span class='va'>...</span>
|
||||
<span class='op'>)</span>
|
||||
|
||||
<span class='fu'>key_antibiotics_equal</span><span class='op'>(</span>
|
||||
<span class='va'>y</span>,
|
||||
<span class='va'>z</span>,
|
||||
type <span class='op'>=</span> <span class='st'>"keyantimicrobials"</span>,
|
||||
ignore_I <span class='op'>=</span> <span class='cn'>TRUE</span>,
|
||||
points_threshold <span class='op'>=</span> <span class='fl'>2</span>,
|
||||
info <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||
na.rm <span class='op'>=</span> <span class='cn'>TRUE</span>,
|
||||
<span class='va'>...</span>
|
||||
<span class='op'>)</span></pre>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="retired-lifecycle"><a class="anchor" href="#retired-lifecycle"></a>Retired Lifecycle</h2>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9032</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -90,14 +90,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -106,77 +106,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -185,21 +185,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -208,14 +208,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9016</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -90,14 +90,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -106,77 +106,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -185,21 +185,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -208,14 +208,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9016</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -90,14 +90,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -106,77 +106,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -185,21 +185,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -208,14 +208,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9040</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9010</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -248,6 +248,7 @@
|
||||
collapse <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||
translate_ab <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||
thorough_search <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||
info <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/interactive.html'>interactive</a></span><span class='op'>(</span><span class='op'>)</span>,
|
||||
<span class='va'>...</span>
|
||||
<span class='op'>)</span></pre>
|
||||
|
||||
@@ -274,6 +275,10 @@
|
||||
<th>thorough_search</th>
|
||||
<td><p>logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to <code>TRUE</code> will take considerably more time than when using <code>FALSE</code>. At default, it will turn <code>TRUE</code> when all input elements contain a maximum of three words.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>info</th>
|
||||
<td><p>logical to indicate whether a progress bar should be printed, defaults to <code>TRUE</code> only in interactive mode</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>arguments passed on to <code><a href='as.ab.html'>as.ab()</a></code></p></td>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9019</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -90,14 +90,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -106,77 +106,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -185,21 +185,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -208,14 +208,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9016</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -90,14 +90,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -106,77 +106,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -185,21 +185,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -208,14 +208,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9016</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9011</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -90,14 +90,14 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fas fa-home"></span>
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fas fa-question-circle"></span>
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
@@ -106,77 +106,77 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fas fa-directions"></span>
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fas fa-dice"></span>
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/datasets.html">
|
||||
<span class="fas fa-database"></span>
|
||||
<span class="fa fa-database"></span>
|
||||
|
||||
Data sets for download / own use
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/PCA.html">
|
||||
<span class="fas fa-compress"></span>
|
||||
<span class="fa fa-compress"></span>
|
||||
|
||||
Conduct principal component analysis for AMR
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fas fa-skull-crossbones"></span>
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fas fa-globe-americas"></span>
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fas fa-file-upload"></span>
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fas fa-exchange-alt"></span>
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fas fa-bug"></span>
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fas fa-capsules"></span>
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fas fa-shipping-fast"></span>
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
@@ -185,21 +185,21 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">
|
||||
<span class="fas fa-book-open"></span>
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fas fa-users"></span>
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">
|
||||
<span class="far fa-newspaper"></span>
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
@@ -208,14 +208,14 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/msberends/AMR">
|
||||
<span class="fab fa-github"></span>
|
||||
<span class="fab fa fab fa-github"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../survey.html">
|
||||
<span class="fas fa-clipboard-list"></span>
|
||||
<span class="fa fa-clipboard-list"></span>
|
||||
|
||||
Survey
|
||||
</a>
|
||||
|
||||