mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 07:26:13 +01:00
First CRAN submission edits
This commit is contained in:
parent
77194527b5
commit
d8da8daf9a
@ -1,7 +1,7 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 0.1.0
|
Version: 0.1.1
|
||||||
Date: 2018-02-20
|
Date: 2018-02-22
|
||||||
Title: Antimicrobial Resistance (AMR) Analysis
|
Title: Antimicrobial Resistance Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(
|
person(
|
||||||
given = c("Matthijs", "S."),
|
given = c("Matthijs", "S."),
|
||||||
@ -20,7 +20,8 @@ Authors@R: c(
|
|||||||
role = "ctb"))
|
role = "ctb"))
|
||||||
Description: Functions to simplify the analysis of Antimicrobial Resistance (AMR)
|
Description: Functions to simplify the analysis of Antimicrobial Resistance (AMR)
|
||||||
of microbial isolates, by using new S3 classes and applying EUCAST expert rules
|
of microbial isolates, by using new S3 classes and applying EUCAST expert rules
|
||||||
on antibiograms.
|
on antibiograms according to Leclercq (2013)
|
||||||
|
<doi:10.1111/j.1469-0691.2011.03703.x>.
|
||||||
Depends: R (>= 3.0)
|
Depends: R (>= 3.0)
|
||||||
Imports: dplyr (>= 0.7.0), reshape2 (>= 1.4.0), xml2, rvest
|
Imports: dplyr (>= 0.7.0), reshape2 (>= 1.4.0), xml2, rvest
|
||||||
URL: https://github.com/msberends/AMR
|
URL: https://github.com/msberends/AMR
|
||||||
|
@ -21,7 +21,6 @@ export(interpretive_reading)
|
|||||||
export(is.mic)
|
export(is.mic)
|
||||||
export(is.rsi)
|
export(is.rsi)
|
||||||
export(key_antibiotics)
|
export(key_antibiotics)
|
||||||
export(key_antibiotics_equal)
|
|
||||||
export(left_join_bactlist)
|
export(left_join_bactlist)
|
||||||
export(mo_property)
|
export(mo_property)
|
||||||
export(right_join_bactlist)
|
export(right_join_bactlist)
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#' @rdname EUCAST
|
#' @rdname EUCAST
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>% left_join select
|
#' @importFrom dplyr %>% left_join select
|
||||||
|
#' @return table with edited variables of antibiotics.
|
||||||
#' @source
|
#' @source
|
||||||
#' EUCAST Expert Rules Version 2.0: \cr
|
#' EUCAST Expert Rules Version 2.0: \cr
|
||||||
#' Leclercq et al. \strong{EUCAST expert rules in antimicrobial susceptibility testing.} \emph{Clin Microbiol Infect.} 2013;19(2):141-60. \cr
|
#' Leclercq et al. \strong{EUCAST expert rules in antimicrobial susceptibility testing.} \emph{Clin Microbiol Infect.} 2013;19(2):141-60. \cr
|
||||||
@ -37,7 +38,7 @@
|
|||||||
#' \url{http://www.eucast.org/expert_rules_and_intrinsic_resistance}
|
#' \url{http://www.eucast.org/expert_rules_and_intrinsic_resistance}
|
||||||
#' @examples
|
#' @examples
|
||||||
#' \dontrun{
|
#' \dontrun{
|
||||||
#' tbl <- interpretive_reading(tbl)
|
#' tbl <- EUCAST_rules(tbl)
|
||||||
#' }
|
#' }
|
||||||
EUCAST_rules <- function(tbl,
|
EUCAST_rules <- function(tbl,
|
||||||
col_bactcode = 'bacteriecode',
|
col_bactcode = 'bacteriecode',
|
||||||
|
10
R/atc.R
10
R/atc.R
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#' Properties of an ATC code
|
#' Properties of an ATC code
|
||||||
#'
|
#'
|
||||||
#' Gets data from the WHO to determine properties of an ATC of e.g. an antibiotic.
|
#' Gets data from the WHO to determine properties of an ATC of e.g. an antibiotic. \strong{This function requires an internet connection.}
|
||||||
#' @param atc_code a character or character vector with ATC code(s) of antibiotic(s)
|
#' @param atc_code a character or character vector with ATC code(s) of antibiotic(s)
|
||||||
#' @param property property of an ATC code. Valid values are \code{"ATC code"}, \code{"Name"}, \code{"DDD"}, \code{"U"} (\code{"unit"}), \code{"Adm.R"} en \code{"Note"}.
|
#' @param property property of an ATC code. Valid values are \code{"ATC code"}, \code{"Name"}, \code{"DDD"}, \code{"U"} (\code{"unit"}), \code{"Adm.R"} en \code{"Note"}.
|
||||||
#' @param administration type of administration, see \emph{Details}
|
#' @param administration type of administration, see \emph{Details}
|
||||||
@ -54,6 +54,11 @@
|
|||||||
#' @importFrom xml2 read_html
|
#' @importFrom xml2 read_html
|
||||||
#' @importFrom rvest html_nodes html_table
|
#' @importFrom rvest html_nodes html_table
|
||||||
#' @source \url{https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/}
|
#' @source \url{https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/}
|
||||||
|
#' @examples
|
||||||
|
#' \donttest{
|
||||||
|
#' atc_property("J01CA04", "DDD", "O") # oral DDD of amoxicillin
|
||||||
|
#' atc_property("J01CA04", "DDD", "P") # parenteral DDD of amoxicillin
|
||||||
|
#' }
|
||||||
atc_property <- function(atc_code,
|
atc_property <- function(atc_code,
|
||||||
property,
|
property,
|
||||||
administration = 'O',
|
administration = 'O',
|
||||||
@ -128,6 +133,7 @@ atc_property <- function(atc_code,
|
|||||||
#' @param textbetween text to put between multiple returned texts
|
#' @param textbetween text to put between multiple returned texts
|
||||||
#' @param tolower return output as lower case with function \code{\link{tolower}}.
|
#' @param tolower return output as lower case with function \code{\link{tolower}}.
|
||||||
#' @keywords ab antibiotics
|
#' @keywords ab antibiotics
|
||||||
|
#' @source \code{\link{ablist}}
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>% filter select slice
|
#' @importFrom dplyr %>% filter select slice
|
||||||
#' @examples
|
#' @examples
|
||||||
@ -148,8 +154,6 @@ atc_property <- function(atc_code,
|
|||||||
#'
|
#'
|
||||||
#' abname("J01CR02", from = "atc", to = "umcg")
|
#' abname("J01CR02", from = "atc", to = "umcg")
|
||||||
#' # "AMCL"
|
#' # "AMCL"
|
||||||
#'
|
|
||||||
#' @source \code{\link{ablist}}
|
|
||||||
abname <- function(abcode, from = 'umcg', to = 'official', textbetween = ' + ', tolower = FALSE) {
|
abname <- function(abcode, from = 'umcg', to = 'official', textbetween = ' + ', tolower = FALSE) {
|
||||||
|
|
||||||
ablist <- AMR::ablist
|
ablist <- AMR::ablist
|
||||||
|
21
R/classes.R
21
R/classes.R
@ -26,8 +26,16 @@
|
|||||||
#' @importFrom dplyr %>%
|
#' @importFrom dplyr %>%
|
||||||
#' @examples
|
#' @examples
|
||||||
#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
|
#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
|
||||||
#'
|
|
||||||
#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C"))
|
#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C"))
|
||||||
|
#' is.rsi(rsi_data)
|
||||||
|
#' plot(rsi_data)
|
||||||
|
#'
|
||||||
|
#' \donttest{
|
||||||
|
#' library(dplyr)
|
||||||
|
#' tbl %>%
|
||||||
|
#' mutate_at(vars(ends_with("_rsi")), as.rsi)
|
||||||
|
#' sapply(mic_data, is.rsi)
|
||||||
|
#' }
|
||||||
as.rsi <- function(x) {
|
as.rsi <- function(x) {
|
||||||
if (is.rsi(x)) {
|
if (is.rsi(x)) {
|
||||||
x
|
x
|
||||||
@ -157,6 +165,17 @@ plot.rsi <- function(x, ...) {
|
|||||||
#' @return New class \code{mic}
|
#' @return New class \code{mic}
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>%
|
#' @importFrom dplyr %>%
|
||||||
|
#' @examples
|
||||||
|
#' mic_data <- as.mic(c(">=32", "1.0", "1", "1.00", 8, "<=0.128", "8", "16", "16"))
|
||||||
|
#' is.mic(mic_data)
|
||||||
|
#' plot(mic_data)
|
||||||
|
#'
|
||||||
|
#' \donttest{
|
||||||
|
#' library(dplyr)
|
||||||
|
#' tbl %>%
|
||||||
|
#' mutate_at(vars(ends_with("_mic")), as.mic)
|
||||||
|
#' sapply(mic_data, is.mic)
|
||||||
|
#' }
|
||||||
as.mic <- function(x, na.rm = FALSE) {
|
as.mic <- function(x, na.rm = FALSE) {
|
||||||
if (is.mic(x)) {
|
if (is.mic(x)) {
|
||||||
x
|
x
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#' @examples
|
#' @examples
|
||||||
#' \dontrun{
|
#' \dontrun{
|
||||||
#'
|
#'
|
||||||
|
#' # set key antibiotics to a new variable
|
||||||
#' tbl$keyab <- key_antibiotics(tbl)
|
#' tbl$keyab <- key_antibiotics(tbl)
|
||||||
#'
|
#'
|
||||||
#' tbl$first_isolate <-
|
#' tbl$first_isolate <-
|
||||||
@ -355,7 +356,13 @@ first_isolate <- function(tbl,
|
|||||||
#' @param amcl,amox,cfot,cfta,cftr,cfur,cipr,clar,clin,clox,doxy,gent,line,mero,peni,pita,rifa,teic,trsu,vanc column names of antibiotics.
|
#' @param amcl,amox,cfot,cfta,cftr,cfur,cipr,clar,clin,clox,doxy,gent,line,mero,peni,pita,rifa,teic,trsu,vanc column names of antibiotics.
|
||||||
#' @export
|
#' @export
|
||||||
#' @importFrom dplyr %>% mutate if_else
|
#' @importFrom dplyr %>% mutate if_else
|
||||||
|
#' @return Character of length 1.
|
||||||
#' @seealso \code{\link{mo_property}} \code{\link{ablist}}
|
#' @seealso \code{\link{mo_property}} \code{\link{ablist}}
|
||||||
|
#' @examples
|
||||||
|
#' \donttest{
|
||||||
|
#' #' # set key antibiotics to a new variable
|
||||||
|
#' tbl$keyab <- key_antibiotics(tbl)
|
||||||
|
#' }
|
||||||
key_antibiotics <- function(tbl,
|
key_antibiotics <- function(tbl,
|
||||||
col_bactcode = 'bacteriecode',
|
col_bactcode = 'bacteriecode',
|
||||||
info = TRUE,
|
info = TRUE,
|
||||||
@ -439,15 +446,17 @@ key_antibiotics <- function(tbl,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' Compare key antibiotics
|
# Compare key antibiotics
|
||||||
#'
|
#
|
||||||
#' Check whether two text values with key antibiotics match. Supports vectors.
|
# Check whether two text values with key antibiotics match. Supports vectors.
|
||||||
#' @param x,y tekst (or multiple text vectors) with antimicrobial interpretations
|
# @param x,y tekst (or multiple text vectors) with antimicrobial interpretations
|
||||||
#' @param ignore_I ignore \code{"I"} as antimicrobial interpretation of key antibiotics (with \code{FALSE}, changes in antibiograms from S to I and I to R will be interpreted as difference)
|
# @param ignore_I ignore \code{"I"} as antimicrobial interpretation of key antibiotics (with \code{FALSE}, changes in antibiograms from S to I and I to R will be interpreted as difference)
|
||||||
#' @param info print progress
|
# @param info print progress
|
||||||
#' @return logical
|
# @return logical
|
||||||
#' @export
|
# @export
|
||||||
#' @seealso \code{\link{key_antibiotics}}
|
# @seealso \code{\link{key_antibiotics}}
|
||||||
|
|
||||||
|
# only internal use
|
||||||
key_antibiotics_equal <- function(x, y, ignore_I = TRUE, info = FALSE) {
|
key_antibiotics_equal <- function(x, y, ignore_I = TRUE, info = FALSE) {
|
||||||
if (length(x) != length(y)) {
|
if (length(x) != length(y)) {
|
||||||
stop('Length of `x` and `y` must be equal.')
|
stop('Length of `x` and `y` must be equal.')
|
||||||
|
13
R/join.R
13
R/join.R
@ -1,4 +1,4 @@
|
|||||||
#' Join van tabel en \code{bactlist}
|
#' Join a table with \code{bactlist}
|
||||||
#'
|
#'
|
||||||
#' Join the list of microorganisms \code{\link{bactlist}} easily to an existing table.
|
#' Join the list of microorganisms \code{\link{bactlist}} easily to an existing table.
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
@ -9,6 +9,17 @@
|
|||||||
#' @param ... other parameters to pass trhough to \code{dplyr::\link[dplyr]{join}}.
|
#' @param ... other parameters to pass trhough to \code{dplyr::\link[dplyr]{join}}.
|
||||||
#' @details As opposed to the \code{\link[dplyr]{join}} functions of \code{dplyr}, at default existing columns will get a suffix \code{"2"} and the newly joined columns will not get a suffix. See \code{\link[dplyr]{join}} for more information.
|
#' @details As opposed to the \code{\link[dplyr]{join}} functions of \code{dplyr}, at default existing columns will get a suffix \code{"2"} and the newly joined columns will not get a suffix. See \code{\link[dplyr]{join}} for more information.
|
||||||
#' @export
|
#' @export
|
||||||
|
#' @examples
|
||||||
|
#' df <- data.frame(date = seq(from = as.Date("2018-01-01"),
|
||||||
|
#' to = as.Date("2018-01-07"),
|
||||||
|
#' by = 1),
|
||||||
|
#' bacteria_id = c("STAAUR", "STAAUR", "STAAUR", "STAAUR",
|
||||||
|
#' "ESCCOL", "ESCCOL", "ESCCOL"),
|
||||||
|
#' stringsAsFactors = FALSE)
|
||||||
|
#'
|
||||||
|
#' colnames(df)
|
||||||
|
#' df2 <- left_join_bactlist(df, "bacteria_id")
|
||||||
|
#' colnames(df2)
|
||||||
inner_join_bactlist <- function(x, by = 'bactid', ...) {
|
inner_join_bactlist <- function(x, by = 'bactid', ...) {
|
||||||
# no name set to `by` parameter
|
# no name set to `by` parameter
|
||||||
if (is.null(names(by))) {
|
if (is.null(names(by))) {
|
||||||
|
@ -167,7 +167,7 @@ rsi_df <- function(tbl,
|
|||||||
|
|
||||||
#' Resistance of isolates
|
#' Resistance of isolates
|
||||||
#'
|
#'
|
||||||
#' This function can be used in \code{\link[dplyr]{summarise}}, see \emph{Examples}. CaBerekent het percentage S, SI, I, IR of R van een lijst isolaten.
|
#' This function can be used in \code{dplyr}s \code{\link[dplyr]{summarise}}, see \emph{Examples}. Calculate the percentage S, SI, I, IR or R of a vector of isolates.
|
||||||
#' @param ab1,ab2 list with interpretations of an antibiotic
|
#' @param ab1,ab2 list with interpretations of an antibiotic
|
||||||
#' @inheritParams rsi_df
|
#' @inheritParams rsi_df
|
||||||
#' @details This function uses the \code{\link{rsi_df}} function internally.
|
#' @details This function uses the \code{\link{rsi_df}} function internally.
|
||||||
@ -177,20 +177,19 @@ rsi_df <- function(tbl,
|
|||||||
#' @examples
|
#' @examples
|
||||||
#' \dontrun{
|
#' \dontrun{
|
||||||
#' tbl %>%
|
#' tbl %>%
|
||||||
#' group_by(year, hospital) %>%
|
|
||||||
#' summarise(
|
|
||||||
#' isolates = n(),
|
|
||||||
#' cipro = rsi(cipr, percent = TRUE),
|
|
||||||
#' amoxi = rsi(amox, percent = TRUE)
|
|
||||||
#' )
|
|
||||||
#'
|
|
||||||
#' tbl %>%
|
|
||||||
#' group_by(hospital) %>%
|
#' group_by(hospital) %>%
|
||||||
#' summarise(cipr = rsi(cipr))
|
#' summarise(cipr = rsi(cipr))
|
||||||
#'
|
#'
|
||||||
#' rsi(isolates$amox)
|
#' tbl %>%
|
||||||
|
#' group_by(year, hospital) %>%
|
||||||
|
#' summarise(
|
||||||
|
#' isolates = n(),
|
||||||
|
#' cipro = rsi(cipr %>% as.rsi(), percent = TRUE),
|
||||||
|
#' amoxi = rsi(amox %>% as.rsi(), percent = TRUE))
|
||||||
#'
|
#'
|
||||||
#' rsi(isolates$amcl, interpretation = "S")
|
#' rsi(as.rsi(isolates$amox))
|
||||||
|
#'
|
||||||
|
#' rsi(as.rsi(isolates$amcl), interpretation = "S")
|
||||||
#' }
|
#' }
|
||||||
rsi <- function(ab1, ab2 = NA, interpretation = 'IR', minimum = 30, percent = FALSE, info = FALSE, warning = FALSE) {
|
rsi <- function(ab1, ab2 = NA, interpretation = 'IR', minimum = 30, percent = FALSE, info = FALSE, warning = FALSE) {
|
||||||
functietekst <- as.character(match.call())
|
functietekst <- as.character(match.call())
|
||||||
@ -258,6 +257,7 @@ rsi <- function(ab1, ab2 = NA, interpretation = 'IR', minimum = 30, percent = FA
|
|||||||
#' rsi_predict(tbl[which(first_isolate == TRUE & genus == "Haemophilus"),], "amcl")
|
#' rsi_predict(tbl[which(first_isolate == TRUE & genus == "Haemophilus"),], "amcl")
|
||||||
#'
|
#'
|
||||||
#' # or with dplyr so you can actually read it:
|
#' # or with dplyr so you can actually read it:
|
||||||
|
#' library(dplyr)
|
||||||
#' tbl %>%
|
#' tbl %>%
|
||||||
#' filter(first_isolate == TRUE,
|
#' filter(first_isolate == TRUE,
|
||||||
#' genus == "Haemophilus") %>%
|
#' genus == "Haemophilus") %>%
|
||||||
|
42
README.md
42
README.md
@ -12,6 +12,26 @@ AMR can also be predicted for the forthcoming years with the `rsi_predict` funct
|
|||||||
|
|
||||||
It also contains functions to translate antibiotic codes from the lab (like `"AMOX"`) or the [WHO](https://www.whocc.no/atc_ddd_index/?code=J01CA04&showdescription=no) (like `"J01CA04"`) to trivial names (like `"amoxicillin"`) and vice versa.
|
It also contains functions to translate antibiotic codes from the lab (like `"AMOX"`) or the [WHO](https://www.whocc.no/atc_ddd_index/?code=J01CA04&showdescription=no) (like `"J01CA04"`) to trivial names (like `"amoxicillin"`) and vice versa.
|
||||||
|
|
||||||
|
## How to get it?
|
||||||
|
[![CRAN_Badge](http://www.r-pkg.org/badges/version/AMR)](http://cran.r-project.org/package=AMR)
|
||||||
|
|
||||||
|
This package is available on CRAN (latest stable version) and also here on GitHub (latest development version).
|
||||||
|
|
||||||
|
#### Latest stable version from CRAN (recommended)
|
||||||
|
RStudio:
|
||||||
|
- Click on `Tools` and then `Install Packages..`
|
||||||
|
- Type in `AMR` and press <kbd>Install</kbd>
|
||||||
|
|
||||||
|
Other:
|
||||||
|
```r
|
||||||
|
install.packages("AMR")
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Latest development version from GitHub
|
||||||
|
```r
|
||||||
|
devtools::install_github("msberends/AMR")
|
||||||
|
```
|
||||||
|
|
||||||
## How to use it?
|
## How to use it?
|
||||||
```r
|
```r
|
||||||
# Call it with:
|
# Call it with:
|
||||||
@ -95,28 +115,6 @@ abname(...)
|
|||||||
abname("J01CR02", from = "atc", to = "umcg") # "AMCL"
|
abname("J01CR02", from = "atc", to = "umcg") # "AMCL"
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to get it?
|
|
||||||
This package is only available here on GitHub, but respects the [CRAN Repository Policy](https://cran.r-project.org/web/packages/policies.html).
|
|
||||||
|
|
||||||
*Installation commands:*
|
|
||||||
```r
|
|
||||||
library(devtools)
|
|
||||||
install_github("msberends/AMR")
|
|
||||||
```
|
|
||||||
|
|
||||||
*Working behind a proxy? Then use:*
|
|
||||||
```r
|
|
||||||
library(httr)
|
|
||||||
library(devtools)
|
|
||||||
set_config(use_proxy("yourproxydomain.com",
|
|
||||||
8080,
|
|
||||||
"username",
|
|
||||||
"password",
|
|
||||||
"any")) # change "any" to "basic" or "digest" if needed
|
|
||||||
install_github("msberends/AMR")
|
|
||||||
reset_config()
|
|
||||||
```
|
|
||||||
|
|
||||||
## Authors
|
## Authors
|
||||||
|
|
||||||
- [Berends MS](https://github.com/msberends)<sup>1,2</sup>, PhD Student
|
- [Berends MS](https://github.com/msberends)<sup>1,2</sup>, PhD Student
|
||||||
|
@ -44,11 +44,14 @@ interpretive_reading(...)
|
|||||||
|
|
||||||
\item{...}{parameters that are passed on to \code{EUCAST_rules}}
|
\item{...}{parameters that are passed on to \code{EUCAST_rules}}
|
||||||
}
|
}
|
||||||
|
\value{
|
||||||
|
table with edited variables of antibiotics.
|
||||||
|
}
|
||||||
\description{
|
\description{
|
||||||
Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
|
Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
\dontrun{
|
\dontrun{
|
||||||
tbl <- interpretive_reading(tbl)
|
tbl <- EUCAST_rules(tbl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ abname("AMCL", to = "atc")
|
|||||||
|
|
||||||
abname("J01CR02", from = "atc", to = "umcg")
|
abname("J01CR02", from = "atc", to = "umcg")
|
||||||
# "AMCL"
|
# "AMCL"
|
||||||
|
|
||||||
}
|
}
|
||||||
\keyword{ab}
|
\keyword{ab}
|
||||||
\keyword{antibiotics}
|
\keyword{antibiotics}
|
||||||
|
@ -20,3 +20,15 @@ New class \code{mic}
|
|||||||
\description{
|
\description{
|
||||||
This transforms a vector to a new class\code{mic}, which is an ordered factor valid MIC values as levels. Invalid MIC values will be translated as \code{NA} with a warning.
|
This transforms a vector to a new class\code{mic}, which is an ordered factor valid MIC values as levels. Invalid MIC values will be translated as \code{NA} with a warning.
|
||||||
}
|
}
|
||||||
|
\examples{
|
||||||
|
mic_data <- as.mic(c(">=32", "1.0", "1", "1.00", 8, "<=0.128", "8", "16", "16"))
|
||||||
|
is.mic(mic_data)
|
||||||
|
plot(mic_data)
|
||||||
|
|
||||||
|
\donttest{
|
||||||
|
library(dplyr)
|
||||||
|
tbl \%>\%
|
||||||
|
mutate_at(vars(ends_with("_mic")), as.mic)
|
||||||
|
sapply(mic_data, is.mic)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,6 +20,14 @@ This transforms a vector to a new class \code{rsi}, which is an ordered factor w
|
|||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
|
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
|
||||||
|
|
||||||
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C"))
|
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C"))
|
||||||
|
is.rsi(rsi_data)
|
||||||
|
plot(rsi_data)
|
||||||
|
|
||||||
|
\donttest{
|
||||||
|
library(dplyr)
|
||||||
|
tbl \%>\%
|
||||||
|
mutate_at(vars(ends_with("_rsi")), as.rsi)
|
||||||
|
sapply(mic_data, is.rsi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ atc_property(atc_code, property, administration = "O",
|
|||||||
\item{url}{url of website of the WHO. The sign \code{\%s} can be used as a placeholder for ATC codes.}
|
\item{url}{url of website of the WHO. The sign \code{\%s} can be used as a placeholder for ATC codes.}
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Gets data from the WHO to determine properties of an ATC of e.g. an antibiotic.
|
Gets data from the WHO to determine properties of an ATC of e.g. an antibiotic. \strong{This function requires an internet connection.}
|
||||||
}
|
}
|
||||||
\details{
|
\details{
|
||||||
Abbreviations for the property \code{"Adm.R"} (parameter \code{administration}):
|
Abbreviations for the property \code{"Adm.R"} (parameter \code{administration}):
|
||||||
@ -49,3 +49,9 @@ Abbreviations for the property \code{"U"} (unit):
|
|||||||
\item{\code{"ml"}}{ = milliliter (e.g. eyedrops)}
|
\item{\code{"ml"}}{ = milliliter (e.g. eyedrops)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
\examples{
|
||||||
|
\donttest{
|
||||||
|
atc_property("J01CA04", "DDD", "O") # oral DDD of amoxicillin
|
||||||
|
atc_property("J01CA04", "DDD", "P") # parenteral DDD of amoxicillin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -57,6 +57,7 @@ To conduct an analysis of antimicrobial resistance, you should only include the
|
|||||||
\examples{
|
\examples{
|
||||||
\dontrun{
|
\dontrun{
|
||||||
|
|
||||||
|
# set key antibiotics to a new variable
|
||||||
tbl$keyab <- key_antibiotics(tbl)
|
tbl$keyab <- key_antibiotics(tbl)
|
||||||
|
|
||||||
tbl$first_isolate <-
|
tbl$first_isolate <-
|
||||||
|
14
man/join.Rd
14
man/join.Rd
@ -9,7 +9,7 @@
|
|||||||
\alias{full_join_bactlist}
|
\alias{full_join_bactlist}
|
||||||
\alias{semi_join_bactlist}
|
\alias{semi_join_bactlist}
|
||||||
\alias{anti_join_bactlist}
|
\alias{anti_join_bactlist}
|
||||||
\title{Join van tabel en \code{bactlist}}
|
\title{Join a table with \code{bactlist}}
|
||||||
\usage{
|
\usage{
|
||||||
inner_join_bactlist(x, by = "bactid", ...)
|
inner_join_bactlist(x, by = "bactid", ...)
|
||||||
|
|
||||||
@ -36,3 +36,15 @@ Join the list of microorganisms \code{\link{bactlist}} easily to an existing tab
|
|||||||
\details{
|
\details{
|
||||||
As opposed to the \code{\link[dplyr]{join}} functions of \code{dplyr}, at default existing columns will get a suffix \code{"2"} and the newly joined columns will not get a suffix. See \code{\link[dplyr]{join}} for more information.
|
As opposed to the \code{\link[dplyr]{join}} functions of \code{dplyr}, at default existing columns will get a suffix \code{"2"} and the newly joined columns will not get a suffix. See \code{\link[dplyr]{join}} for more information.
|
||||||
}
|
}
|
||||||
|
\examples{
|
||||||
|
df <- data.frame(date = seq(from = as.Date("2018-01-01"),
|
||||||
|
to = as.Date("2018-01-07"),
|
||||||
|
by = 1),
|
||||||
|
bacteria_id = c("STAAUR", "STAAUR", "STAAUR", "STAAUR",
|
||||||
|
"ESCCOL", "ESCCOL", "ESCCOL"),
|
||||||
|
stringsAsFactors = FALSE)
|
||||||
|
|
||||||
|
colnames(df)
|
||||||
|
df2 <- left_join_bactlist(df, "bacteria_id")
|
||||||
|
colnames(df2)
|
||||||
|
}
|
||||||
|
@ -20,9 +20,18 @@ key_antibiotics(tbl, col_bactcode = "bacteriecode", info = TRUE,
|
|||||||
|
|
||||||
\item{amcl, amox, cfot, cfta, cftr, cfur, cipr, clar, clin, clox, doxy, gent, line, mero, peni, pita, rifa, teic, trsu, vanc}{column names of antibiotics.}
|
\item{amcl, amox, cfot, cfta, cftr, cfur, cipr, clar, clin, clox, doxy, gent, line, mero, peni, pita, rifa, teic, trsu, vanc}{column names of antibiotics.}
|
||||||
}
|
}
|
||||||
|
\value{
|
||||||
|
Character of length 1.
|
||||||
|
}
|
||||||
\description{
|
\description{
|
||||||
Key antibiotics based on bacteria ID
|
Key antibiotics based on bacteria ID
|
||||||
}
|
}
|
||||||
|
\examples{
|
||||||
|
\donttest{
|
||||||
|
#' # set key antibiotics to a new variable
|
||||||
|
tbl$keyab <- key_antibiotics(tbl)
|
||||||
|
}
|
||||||
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
\code{\link{mo_property}} \code{\link{ablist}}
|
\code{\link{mo_property}} \code{\link{ablist}}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
% Generated by roxygen2: do not edit by hand
|
|
||||||
% Please edit documentation in R/first_isolates.R
|
|
||||||
\name{key_antibiotics_equal}
|
|
||||||
\alias{key_antibiotics_equal}
|
|
||||||
\title{Compare key antibiotics}
|
|
||||||
\usage{
|
|
||||||
key_antibiotics_equal(x, y, ignore_I = TRUE, info = FALSE)
|
|
||||||
}
|
|
||||||
\arguments{
|
|
||||||
\item{x, y}{tekst (or multiple text vectors) with antimicrobial interpretations}
|
|
||||||
|
|
||||||
\item{ignore_I}{ignore \code{"I"} as antimicrobial interpretation of key antibiotics (with \code{FALSE}, changes in antibiograms from S to I and I to R will be interpreted as difference)}
|
|
||||||
|
|
||||||
\item{info}{print progress}
|
|
||||||
}
|
|
||||||
\value{
|
|
||||||
logical
|
|
||||||
}
|
|
||||||
\description{
|
|
||||||
Check whether two text values with key antibiotics match. Supports vectors.
|
|
||||||
}
|
|
||||||
\seealso{
|
|
||||||
\code{\link{key_antibiotics}}
|
|
||||||
}
|
|
21
man/rsi.Rd
21
man/rsi.Rd
@ -24,28 +24,27 @@ rsi(ab1, ab2 = NA, interpretation = "IR", minimum = 30, percent = FALSE,
|
|||||||
Double or, when \code{percent = TRUE}, a character.
|
Double or, when \code{percent = TRUE}, a character.
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
This function can be used in \code{\link[dplyr]{summarise}}, see \emph{Examples}. CaBerekent het percentage S, SI, I, IR of R van een lijst isolaten.
|
This function can be used in \code{dplyr}s \code{\link[dplyr]{summarise}}, see \emph{Examples}. Calculate the percentage S, SI, I, IR or R of a vector of isolates.
|
||||||
}
|
}
|
||||||
\details{
|
\details{
|
||||||
This function uses the \code{\link{rsi_df}} function internally.
|
This function uses the \code{\link{rsi_df}} function internally.
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
\dontrun{
|
\dontrun{
|
||||||
tbl \%>\%
|
|
||||||
group_by(year, hospital) \%>\%
|
|
||||||
summarise(
|
|
||||||
isolates = n(),
|
|
||||||
cipro = rsi(cipr, percent = TRUE),
|
|
||||||
amoxi = rsi(amox, percent = TRUE)
|
|
||||||
)
|
|
||||||
|
|
||||||
tbl \%>\%
|
tbl \%>\%
|
||||||
group_by(hospital) \%>\%
|
group_by(hospital) \%>\%
|
||||||
summarise(cipr = rsi(cipr))
|
summarise(cipr = rsi(cipr))
|
||||||
|
|
||||||
rsi(isolates$amox)
|
tbl \%>\%
|
||||||
|
group_by(year, hospital) \%>\%
|
||||||
|
summarise(
|
||||||
|
isolates = n(),
|
||||||
|
cipro = rsi(cipr \%>\% as.rsi(), percent = TRUE),
|
||||||
|
amoxi = rsi(amox \%>\% as.rsi(), percent = TRUE))
|
||||||
|
|
||||||
rsi(isolates$amcl, interpretation = "S")
|
rsi(as.rsi(isolates$amox))
|
||||||
|
|
||||||
|
rsi(as.rsi(isolates$amcl), interpretation = "S")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\keyword{antibiotics}
|
\keyword{antibiotics}
|
||||||
|
@ -40,6 +40,7 @@ Create a prediction model to predict antimicrobial resistance for the next years
|
|||||||
rsi_predict(tbl[which(first_isolate == TRUE & genus == "Haemophilus"),], "amcl")
|
rsi_predict(tbl[which(first_isolate == TRUE & genus == "Haemophilus"),], "amcl")
|
||||||
|
|
||||||
# or with dplyr so you can actually read it:
|
# or with dplyr so you can actually read it:
|
||||||
|
library(dplyr)
|
||||||
tbl \%>\%
|
tbl \%>\%
|
||||||
filter(first_isolate == TRUE,
|
filter(first_isolate == TRUE,
|
||||||
genus == "Haemophilus") \%>\%
|
genus == "Haemophilus") \%>\%
|
||||||
|
Loading…
Reference in New Issue
Block a user