mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 18:46:11 +01:00
new col names for key_antibiotics
This commit is contained in:
parent
0d64c166f0
commit
ad662d7bab
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 0.2.0.9013
|
||||
Date: 2018-07-17
|
||||
Version: 0.2.0.9014
|
||||
Date: 2018-07-19
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
person(
|
||||
|
1
NEWS.md
1
NEWS.md
@ -24,6 +24,7 @@
|
||||
#### Changed
|
||||
* Pretty printing for tibbles removed as it is not really the scope of this package
|
||||
* Improved speed of key antibiotics comparison for determining first isolates
|
||||
* Column names for the `key_antibiotics` function are now generic: 6 for broadspectrum ABs, 6 for Gram-positive specific and 6 for Gram-negative specific ABs
|
||||
* Printing of class `mic` now shows all MIC values
|
||||
* `%like%` now supports multiple patterns
|
||||
* Frequency tables are now actual `data.frame`s with altered console printing to make it look like a frequency table. Because of this, the parameter `toConsole` is not longer needed.
|
||||
|
@ -162,7 +162,7 @@ first_isolate <- function(tbl,
|
||||
}
|
||||
# remove testcodes
|
||||
if (!is.na(testcodes_exclude[1]) & testcodes_exclude[1] != '' & info == TRUE) {
|
||||
cat('Isolates from these test codes will be ignored:\n', toString(testcodes_exclude), '\n')
|
||||
cat('[Criteria] Excluded test codes:\n', toString(testcodes_exclude), '\n')
|
||||
}
|
||||
|
||||
if (is.na(col_icu)) {
|
||||
@ -181,7 +181,7 @@ first_isolate <- function(tbl,
|
||||
if (!is.na(filter_specimen) & filter_specimen != '') {
|
||||
check_columns_existance(col_specimen, tbl)
|
||||
if (info == TRUE) {
|
||||
cat('Isolates other than of specimen group \'', filter_specimen, '\' will be ignored. ', sep = '')
|
||||
cat('[Criteria] Excluded other than specimen group \'', filter_specimen, '\'\n', sep = '')
|
||||
}
|
||||
} else {
|
||||
filter_specimen <- ''
|
||||
@ -209,8 +209,8 @@ first_isolate <- function(tbl,
|
||||
if (filter_specimen == '') {
|
||||
|
||||
if (icu_exclude == FALSE) {
|
||||
if (info == TRUE) {
|
||||
cat('Isolates from ICU will *NOT* be ignored.\n')
|
||||
if (info == TRUE & !is.na(col_icu)) {
|
||||
cat('[Criteria] Included isolates from ICU.\n')
|
||||
}
|
||||
tbl <- tbl %>%
|
||||
arrange_at(c(col_patient_id,
|
||||
@ -221,7 +221,7 @@ first_isolate <- function(tbl,
|
||||
row.end <- nrow(tbl)
|
||||
} else {
|
||||
if (info == TRUE) {
|
||||
cat('Isolates from ICU will be ignored.\n')
|
||||
cat('[Criteria] Excluded isolates from ICU.\n')
|
||||
}
|
||||
tbl <- tbl %>%
|
||||
arrange_at(c(col_icu,
|
||||
@ -241,8 +241,8 @@ first_isolate <- function(tbl,
|
||||
} else {
|
||||
# sort on specimen and only analyse these row to save time
|
||||
if (icu_exclude == FALSE) {
|
||||
if (info == TRUE) {
|
||||
cat('Isolates from ICU will *NOT* be ignored.\n')
|
||||
if (info == TRUE & !is.na(col_icu)) {
|
||||
cat('[Criteria] Included isolates from ICU.\n')
|
||||
}
|
||||
tbl <- tbl %>%
|
||||
arrange_at(c(col_specimen,
|
||||
@ -258,7 +258,7 @@ first_isolate <- function(tbl,
|
||||
)
|
||||
} else {
|
||||
if (info == TRUE) {
|
||||
cat('Isolates from ICU will be ignored.\n')
|
||||
cat('[Criteria] Excluded isolates from ICU.\n')
|
||||
}
|
||||
tbl <- tbl %>%
|
||||
arrange_at(c(col_icu,
|
||||
@ -281,7 +281,7 @@ first_isolate <- function(tbl,
|
||||
|
||||
if (abs(row.start) == Inf | abs(row.end) == Inf) {
|
||||
if (info == TRUE) {
|
||||
cat('No isolates found.\n')
|
||||
message('No isolates found.')
|
||||
}
|
||||
# NA's where genus is unavailable
|
||||
tbl <- tbl %>%
|
||||
@ -317,15 +317,15 @@ first_isolate <- function(tbl,
|
||||
if (col_keyantibiotics != '') {
|
||||
if (info == TRUE) {
|
||||
if (type == 'keyantibiotics') {
|
||||
cat('Key antibiotics for first weighted isolates will be compared (')
|
||||
cat('[Criteria] Inclusion based on key antibiotics, ')
|
||||
if (ignore_I == FALSE) {
|
||||
cat('NOT ')
|
||||
cat('not ')
|
||||
}
|
||||
cat('ignoring I).')
|
||||
cat('ignoring I.\n')
|
||||
}
|
||||
if (type == 'points') {
|
||||
cat(paste0('Comparing antibiotics for first weighted isolates (using points threshold of '
|
||||
, points_threshold, ')...\n'))
|
||||
cat(paste0('[Criteria] Inclusion based on key antibiotics, using points threshold of '
|
||||
, points_threshold, '.\n'))
|
||||
}
|
||||
}
|
||||
type_param <- type
|
||||
@ -350,9 +350,6 @@ first_isolate <- function(tbl,
|
||||
TRUE,
|
||||
FALSE))
|
||||
)
|
||||
if (info == TRUE) {
|
||||
cat('\n')
|
||||
}
|
||||
} else {
|
||||
# suppress warnings because dplyr want us to use library(dplyr) when using filter(row_number())
|
||||
suppressWarnings(
|
||||
@ -388,13 +385,13 @@ first_isolate <- function(tbl,
|
||||
pull(real_first_isolate)
|
||||
|
||||
if (info == TRUE) {
|
||||
cat(paste0('\nFound ',
|
||||
message(paste0('Found ',
|
||||
all_first %>% sum(na.rm = TRUE),
|
||||
' first ', weighted.notice, 'isolates (',
|
||||
(all_first %>% sum(na.rm = TRUE) / scope.size) %>% percent(),
|
||||
' of isolates in scope [where genus was not empty] and ',
|
||||
(all_first %>% sum(na.rm = TRUE) / tbl %>% nrow()) %>% percent(),
|
||||
' of total)\n'))
|
||||
' of total)'))
|
||||
}
|
||||
|
||||
if (output_logical == FALSE) {
|
||||
|
@ -22,14 +22,16 @@
|
||||
#' @param tbl table with antibiotics coloms, like \code{amox} and \code{amcl}.
|
||||
#' @param x,y characters to compare
|
||||
#' @inheritParams first_isolate
|
||||
#' @param amcl,amox,cfot,cfta,cfur,cipr,coli,eryt,gent,mero,oxac,pita,rifa,teic,tetr,tobr,trsu,vanc column names of antibiotics, case-insensitive
|
||||
#' @param universal_1,universal_2,universal_3,universal_4,universal_5,universal_6 column names of \strong{broad-spectrum} antibiotics, case-insensitive
|
||||
#' @param GramPos_1,GramPos_2,GramPos_3,GramPos_4,GramPos_5,GramPos_6 column names of antibiotics for \strong{Gram positives}, case-insensitive
|
||||
#' @param GramNeg_1,GramNeg_2,GramNeg_3,GramNeg_4,GramNeg_5,GramNeg_6 column names of antibiotics for \strong{Gram negatives}, case-insensitive
|
||||
#' @details The function \code{key_antibiotics} returns a character vector with antibiotic results.
|
||||
#'
|
||||
#' The antibiotics that are used for \strong{Gram positive bacteria} are (colum names): \cr
|
||||
#' amox, amcl, cfur, pita, cipr, trsu, vanc, teic, tetr, eryt, oxac, rifa.
|
||||
#' At default, the antibiotics that are used for \strong{Gram positive bacteria} are (colum names): \cr
|
||||
#' \code{"amox"}, \code{"amcl"}, \code{"cfur"}, \code{"pita"}, \code{"cipr"}, \code{"trsu"} (until here is universal), \code{"vanc"}, \code{"teic"}, \code{"tetr"}, \code{"eryt"}, \code{"oxac"}, \code{"rifa"}.
|
||||
#'
|
||||
#' The antibiotics that are used for \strong{Gram negative bacteria} are (colum names): \cr
|
||||
#' amox, amcl, cfur, pita, cipr, trsu, gent, tobr, coli, cfot, cfta, mero.
|
||||
#' At default, the antibiotics that are used for \strong{Gram negative bacteria} are (colum names): \cr
|
||||
#' \code{"amox"}, \code{"amcl"}, \code{"cfur"}, \code{"pita"}, \code{"cipr"}, \code{"trsu"} (until here is universal), \code{"gent"}, \code{"tobr"}, \code{"coli"}, \code{"cfot"}, \code{"cfta"}, \code{"mero"}.
|
||||
#'
|
||||
#'
|
||||
#' The function \code{key_antibiotics_equal} checks the characters returned by \code{key_antibiotics} for equality, and returns a logical value.
|
||||
@ -54,24 +56,24 @@
|
||||
#' }
|
||||
key_antibiotics <- function(tbl,
|
||||
col_bactid = "bactid",
|
||||
amcl = "amcl",
|
||||
amox = "amox",
|
||||
cfot = "cfot",
|
||||
cfta = "cfta",
|
||||
cfur = "cfur",
|
||||
cipr = "cipr",
|
||||
coli = "coli",
|
||||
eryt = "eryt",
|
||||
gent = "gent",
|
||||
mero = "mero",
|
||||
oxac = "oxac",
|
||||
pita = "pita",
|
||||
rifa = "rifa",
|
||||
teic = "teic",
|
||||
tetr = "tetr",
|
||||
tobr = "tobr",
|
||||
trsu = "trsu",
|
||||
vanc = "vanc",
|
||||
universal_1 = "amox",
|
||||
universal_2 = "amcl",
|
||||
universal_3 = "cfur",
|
||||
universal_4 = "pita",
|
||||
universal_5 = "cipr",
|
||||
universal_6 = "trsu",
|
||||
GramPos_1 = "vanc",
|
||||
GramPos_2 = "teic",
|
||||
GramPos_3 = "tetr",
|
||||
GramPos_4 = "eryt",
|
||||
GramPos_5 = "oxac",
|
||||
GramPos_6 = "rifa",
|
||||
GramNeg_1 = "gent",
|
||||
GramNeg_2 = "tobr",
|
||||
GramNeg_3 = "coli",
|
||||
GramNeg_4 = "cfot",
|
||||
GramNeg_5 = "cfta",
|
||||
GramNeg_6 = "mero",
|
||||
info = TRUE) {
|
||||
|
||||
if (!col_bactid %in% colnames(tbl)) {
|
||||
@ -79,37 +81,40 @@ key_antibiotics <- function(tbl,
|
||||
}
|
||||
|
||||
# check columns
|
||||
col.list <- c(amcl, amox, cfot, cfta, cfur, cipr,
|
||||
coli, eryt, gent, mero, oxac, pita,
|
||||
rifa, teic, tetr, tobr, trsu, vanc)
|
||||
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)
|
||||
col.list <- check_available_columns(tbl = tbl, col.list = col.list, info = info)
|
||||
amcl <- col.list[amcl]
|
||||
amox <- col.list[amox]
|
||||
cfot <- col.list[cfot]
|
||||
cfta <- col.list[cfta]
|
||||
cfur <- col.list[cfur]
|
||||
cipr <- col.list[cipr]
|
||||
coli <- col.list[coli]
|
||||
eryt <- col.list[eryt]
|
||||
gent <- col.list[gent]
|
||||
mero <- col.list[mero]
|
||||
oxac <- col.list[oxac]
|
||||
pita <- col.list[pita]
|
||||
rifa <- col.list[rifa]
|
||||
teic <- col.list[teic]
|
||||
tetr <- col.list[tetr]
|
||||
tobr <- col.list[tobr]
|
||||
trsu <- col.list[trsu]
|
||||
vanc <- col.list[vanc]
|
||||
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]
|
||||
|
||||
gram_positive = c(amox, amcl, cfur, pita, cipr, trsu,
|
||||
# specific for G+:
|
||||
vanc, teic, tetr, eryt, oxac, rifa)
|
||||
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.na(gram_positive)]
|
||||
|
||||
gram_negative = c(amox, amcl, cfur, pita, cipr, trsu,
|
||||
# specific for G-:
|
||||
gent, tobr, coli, cfot, cfta, mero)
|
||||
gram_negative = c(universal,
|
||||
GramNeg_1, GramNeg_2, GramNeg_3,
|
||||
GramNeg_4, GramNeg_5, GramNeg_6)
|
||||
gram_negative <- gram_negative[!is.na(gram_negative)]
|
||||
|
||||
# join microorganisms
|
||||
|
@ -5,12 +5,13 @@
|
||||
\alias{key_antibiotics_equal}
|
||||
\title{Key antibiotics for first \emph{weighted} isolates}
|
||||
\usage{
|
||||
key_antibiotics(tbl, col_bactid = "bactid", amcl = "amcl", amox = "amox",
|
||||
cfot = "cfot", cfta = "cfta", cfur = "cfur", cipr = "cipr",
|
||||
coli = "coli", eryt = "eryt", gent = "gent", mero = "mero",
|
||||
oxac = "oxac", pita = "pita", rifa = "rifa", teic = "teic",
|
||||
tetr = "tetr", tobr = "tobr", trsu = "trsu", vanc = "vanc",
|
||||
info = TRUE)
|
||||
key_antibiotics(tbl, col_bactid = "bactid", universal_1 = "amox",
|
||||
universal_2 = "amcl", universal_3 = "cfur", universal_4 = "pita",
|
||||
universal_5 = "cipr", universal_6 = "trsu", GramPos_1 = "vanc",
|
||||
GramPos_2 = "teic", GramPos_3 = "tetr", GramPos_4 = "eryt",
|
||||
GramPos_5 = "oxac", GramPos_6 = "rifa", GramNeg_1 = "gent",
|
||||
GramNeg_2 = "tobr", GramNeg_3 = "coli", GramNeg_4 = "cfot",
|
||||
GramNeg_5 = "cfta", GramNeg_6 = "mero", info = TRUE)
|
||||
|
||||
key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"),
|
||||
ignore_I = TRUE, points_threshold = 2, info = FALSE)
|
||||
@ -20,7 +21,11 @@ key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"),
|
||||
|
||||
\item{col_bactid}{column name of the unique IDs of the microorganisms (should occur in the \code{\link{microorganisms}} dataset). Get your bactid's with the function \code{\link{guess_bactid}}, that takes microorganism names as input.}
|
||||
|
||||
\item{amcl, amox, cfot, cfta, cfur, cipr, coli, eryt, gent, mero, oxac, pita, rifa, teic, tetr, tobr, trsu, vanc}{column names of antibiotics, case-insensitive}
|
||||
\item{universal_1, universal_2, universal_3, universal_4, universal_5, universal_6}{column names of \strong{broad-spectrum} antibiotics, case-insensitive}
|
||||
|
||||
\item{GramPos_1, GramPos_2, GramPos_3, GramPos_4, GramPos_5, GramPos_6}{column names of antibiotics for \strong{Gram positives}, case-insensitive}
|
||||
|
||||
\item{GramNeg_1, GramNeg_2, GramNeg_3, GramNeg_4, GramNeg_5, GramNeg_6}{column names of antibiotics for \strong{Gram negatives}, case-insensitive}
|
||||
|
||||
\item{info}{print progress}
|
||||
|
||||
@ -38,11 +43,11 @@ These function can be used to determine first isolates (see \code{\link{first_is
|
||||
\details{
|
||||
The function \code{key_antibiotics} returns a character vector with antibiotic results.
|
||||
|
||||
The antibiotics that are used for \strong{Gram positive bacteria} are (colum names): \cr
|
||||
amox, amcl, cfur, pita, cipr, trsu, vanc, teic, tetr, eryt, oxac, rifa.
|
||||
At default, the antibiotics that are used for \strong{Gram positive bacteria} are (colum names): \cr
|
||||
\code{"amox"}, \code{"amcl"}, \code{"cfur"}, \code{"pita"}, \code{"cipr"}, \code{"trsu"} (until here is universal), \code{"vanc"}, \code{"teic"}, \code{"tetr"}, \code{"eryt"}, \code{"oxac"}, \code{"rifa"}.
|
||||
|
||||
The antibiotics that are used for \strong{Gram negative bacteria} are (colum names): \cr
|
||||
amox, amcl, cfur, pita, cipr, trsu, gent, tobr, coli, cfot, cfta, mero.
|
||||
At default, the antibiotics that are used for \strong{Gram negative bacteria} are (colum names): \cr
|
||||
\code{"amox"}, \code{"amcl"}, \code{"cfur"}, \code{"pita"}, \code{"cipr"}, \code{"trsu"} (until here is universal), \code{"gent"}, \code{"tobr"}, \code{"coli"}, \code{"cfot"}, \code{"cfta"}, \code{"mero"}.
|
||||
|
||||
|
||||
The function \code{key_antibiotics_equal} checks the characters returned by \code{key_antibiotics} for equality, and returns a logical value.
|
||||
|
Loading…
Reference in New Issue
Block a user