Browse Source

guess_ab_col, benchmarks

new-mo-algorithm
parent
commit
641d866db2
  1. 2
      DESCRIPTION
  2. 2
      NAMESPACE
  3. 2
      NEWS.md
  4. 2
      R/age.R
  5. 254
      R/eucast_rules.R
  6. 83
      R/guess_ab_col.R
  7. 47
      R/key_antibiotics.R
  8. 240
      R/mdro.R
  9. 13
      _pkgdown.yml
  10. 7
      docs/LICENSE-text.html
  11. 477
      docs/articles/AMR.html
  12. BIN
      docs/articles/AMR_files/figure-html/plot 1-1.png
  13. BIN
      docs/articles/AMR_files/figure-html/plot 3-1.png
  14. BIN
      docs/articles/AMR_files/figure-html/plot 4-1.png
  15. BIN
      docs/articles/AMR_files/figure-html/plot 5-1.png
  16. 9
      docs/articles/EUCAST.html
  17. 9
      docs/articles/G_test.html
  18. 9
      docs/articles/Predict.html
  19. 9
      docs/articles/ab_property.html
  20. 371
      docs/articles/benchmarks.html
  21. 9
      docs/articles/freq.html
  22. 8
      docs/articles/index.html
  23. 9
      docs/articles/mo_property.html
  24. 7
      docs/authors.html
  25. 7
      docs/extra.css
  26. 10
      docs/index.html
  27. 9
      docs/news/index.html
  28. 1
      docs/pkgdown.yml
  29. 7
      docs/reference/AMR-deprecated.html
  30. 7
      docs/reference/AMR.html
  31. 7
      docs/reference/ITIS.html
  32. 7
      docs/reference/ab_property.html
  33. 7
      docs/reference/abname.html
  34. 7
      docs/reference/age.html
  35. 15
      docs/reference/age_groups.html
  36. 7
      docs/reference/antibiotics.html
  37. 7
      docs/reference/as.atc.html
  38. 7
      docs/reference/as.mic.html
  39. 13
      docs/reference/as.mo.html
  40. 11
      docs/reference/as.rsi.html
  41. 7
      docs/reference/atc_property.html
  42. 21
      docs/reference/count.html
  43. 62
      docs/reference/eucast_rules.html
  44. 19
      docs/reference/first_isolate.html
  45. 23
      docs/reference/freq.html
  46. 7
      docs/reference/g.test.html
  47. 7
      docs/reference/get_locale.html
  48. 43
      docs/reference/ggplot_rsi.html
  49. 7
      docs/reference/guess_ab.html
  50. 316
      docs/reference/guess_ab_col.html
  51. 13
      docs/reference/index.html
  52. 7
      docs/reference/join.html
  53. 40
      docs/reference/key_antibiotics.html
  54. 7
      docs/reference/kurtosis.html
  55. 9
      docs/reference/like.html
  56. 59
      docs/reference/mdro.html
  57. 7
      docs/reference/microorganisms.certe.html
  58. 7
      docs/reference/microorganisms.html
  59. 7
      docs/reference/microorganisms.old.html
  60. 7
      docs/reference/microorganisms.umcg.html
  61. 7
      docs/reference/mo_failures.html
  62. 7
      docs/reference/mo_property.html
  63. 7
      docs/reference/mo_renamed.html
  64. 7
      docs/reference/p.symbol.html
  65. 31
      docs/reference/portion.html
  66. 7
      docs/reference/read.4D.html
  67. 15
      docs/reference/resistance_predict.html
  68. 7
      docs/reference/rsi.html
  69. 7
      docs/reference/septic_patients.html
  70. 7
      docs/reference/skewness.html
  71. 7
      docs/reference/supplementary_data.html
  72. 5
      docs/sitemap.xml
  73. 4
      index.md
  74. 55
      man/eucast_rules.Rd
  75. 23
      man/guess_ab_col.Rd
  76. 33
      man/key_antibiotics.Rd
  77. 52
      man/mdro.Rd
  78. 7
      pkgdown/extra.css
  79. 36
      tests/testthat/test-guess_ab_col.R
  80. 2
      vignettes/AMR.Rmd
  81. 2
      vignettes/EUCAST.Rmd
  82. 2
      vignettes/G_test.Rmd
  83. 2
      vignettes/Predict.Rmd
  84. 205
      vignettes/benchmarks.Rmd
  85. 2
      vignettes/freq.Rmd
  86. 2
      vignettes/mo_property.Rmd

2
DESCRIPTION

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Package: AMR
Version: 0.5.0.9009
Date: 2019-01-08
Date: 2019-01-11
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(

2
NAMESPACE

@ -76,7 +76,7 @@ export(g.test) @@ -76,7 +76,7 @@ export(g.test)
export(geom_rsi)
export(get_locale)
export(ggplot_rsi)
export(guess_ab)
export(guess_ab_col)
export(guess_atc)
export(guess_mo)
export(header)

2
NEWS.md

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
* Contains the complete manual of this package and all of its functions with an explanation of their parameters
* Contains a comprehensive tutorial about how to conduct antimicrobial resistance analysis
* Support for [`dplyr`](https://dplyr.tidyverse.org) version 0.8.0
* Function `guess_ab` to find an antibiotic column in a table
* Function `guess_ab_col` to find an antibiotic column in a table
* Function `mo_failures()` to review values that could not be coerced to a valid MO code, using `as.mo()`. This latter function will now only show a maximum of 25 uncoerced values.
* Function `mo_renamed()` to get a list of all returned values from `as.mo()` that have had taxonomic renaming
* Function `age()` to calculate the (patients) age in years

2
R/age.R

@ -48,7 +48,7 @@ age <- function(x, reference = Sys.Date()) { @@ -48,7 +48,7 @@ age <- function(x, reference = Sys.Date()) {
as.integer(years_gap - 1),
as.integer(years_gap))
if (any(ages > 120)) {
warning("Some ages are >120.")
warning("Some ages are > 120.")
}
ages
}

254
R/eucast_rules.R

@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
#' @param ... parameters that are passed on to \code{eucast_rules}
#' @inheritParams first_isolate
#' @section Antibiotics:
#' To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab}} or input a text (case-insensitive) or use \code{NULL} to skip a column (e.g. \code{tica = NULL}). Non-existing columns will anyway be skipped with a warning.
#' To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab_col}} or input a text (case-insensitive) or use \code{NULL} to skip a column (e.g. \code{tica = NULL}). Non-existing columns will anyway be skipped with a warning.
#'
#' Abbrevations of the column containing antibiotics in the form: \strong{abbreviation}: generic name (\emph{ATC code})
#'
@ -158,69 +158,69 @@ eucast_rules <- function(tbl, @@ -158,69 +158,69 @@ eucast_rules <- function(tbl,
info = TRUE,
rules = c("breakpoints", "expert", "other", "all"),
verbose = FALSE,
amcl = guess_ab(),
amik = guess_ab(),
amox = guess_ab(),
ampi = guess_ab(),
azit = guess_ab(),
azlo = guess_ab(),
aztr = guess_ab(),
cefa = guess_ab(),
cfep = guess_ab(),
cfot = guess_ab(),
cfox = guess_ab(),
cfra = guess_ab(),
cfta = guess_ab(),
cftr = guess_ab(),
cfur = guess_ab(),
chlo = guess_ab(),
cipr = guess_ab(),
clar = guess_ab(),
clin = guess_ab(),
clox = guess_ab(),
coli = guess_ab(),
czol = guess_ab(),
dapt = guess_ab(),
doxy = guess_ab(),
erta = guess_ab(),
eryt = guess_ab(),
fosf = guess_ab(),
fusi = guess_ab(),
gent = guess_ab(),
imip = guess_ab(),
kana = guess_ab(),
levo = guess_ab(),
linc = guess_ab(),
line = guess_ab(),
mero = guess_ab(),
mezl = guess_ab(),
mino = guess_ab(),
moxi = guess_ab(),
nali = guess_ab(),
neom = guess_ab(),
neti = guess_ab(),
nitr = guess_ab(),
norf = guess_ab(),
novo = guess_ab(),
oflo = guess_ab(),
oxac = guess_ab(),
peni = guess_ab(),
pipe = guess_ab(),
pita = guess_ab(),
poly = guess_ab(),
pris = guess_ab(),
qida = guess_ab(),
rifa = guess_ab(),
roxi = guess_ab(),
siso = guess_ab(),
teic = guess_ab(),
tetr = guess_ab(),
tica = guess_ab(),
tige = guess_ab(),
tobr = guess_ab(),
trim = guess_ab(),
trsu = guess_ab(),
vanc = guess_ab()) {
amcl = guess_ab_col(),
amik = guess_ab_col(),
amox = guess_ab_col(),
ampi = guess_ab_col(),
azit = guess_ab_col(),
azlo = guess_ab_col(),
aztr = guess_ab_col(),
cefa = guess_ab_col(),
cfep = guess_ab_col(),
cfot = guess_ab_col(),
cfox = guess_ab_col(),
cfra = guess_ab_col(),
cfta = guess_ab_col(),
cftr = guess_ab_col(),
cfur = guess_ab_col(),
chlo = guess_ab_col(),
cipr = guess_ab_col(),
clar = guess_ab_col(),
clin = guess_ab_col(),
clox = guess_ab_col(),
coli = guess_ab_col(),
czol = guess_ab_col(),
dapt = guess_ab_col(),
doxy = guess_ab_col(),
erta = guess_ab_col(),
eryt = guess_ab_col(),
fosf = guess_ab_col(),
fusi = guess_ab_col(),
gent = guess_ab_col(),
imip = guess_ab_col(),
kana = guess_ab_col(),
levo = guess_ab_col(),
linc = guess_ab_col(),
line = guess_ab_col(),
mero = guess_ab_col(),
mezl = guess_ab_col(),
mino = guess_ab_col(),
moxi = guess_ab_col(),
nali = guess_ab_col(),
neom = guess_ab_col(),
neti = guess_ab_col(),
nitr = guess_ab_col(),
norf = guess_ab_col(),
novo = guess_ab_col(),
oflo = guess_ab_col(),
oxac = guess_ab_col(),
peni = guess_ab_col(),
pipe = guess_ab_col(),
pita = guess_ab_col(),
poly = guess_ab_col(),
pris = guess_ab_col(),
qida = guess_ab_col(),
rifa = guess_ab_col(),
roxi = guess_ab_col(),
siso = guess_ab_col(),
teic = guess_ab_col(),
tetr = guess_ab_col(),
tica = guess_ab_col(),
tige = guess_ab_col(),
tobr = guess_ab_col(),
trim = guess_ab_col(),
trsu = guess_ab_col(),
vanc = guess_ab_col()) {
EUCAST_VERSION_BREAKPOINTS <- "8.1, 2018"
EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016"
@ -268,69 +268,69 @@ eucast_rules <- function(tbl, @@ -268,69 +268,69 @@ eucast_rules <- function(tbl,
}
# check columns
if (identical(amcl, as.name("guess_ab"))) { amcl <- guess_ab(tbl, "amcl", verbose = verbose) }
if (identical(amik, as.name("guess_ab"))) { amik <- guess_ab(tbl, "amik", verbose = verbose) }
if (identical(amox, as.name("guess_ab"))) { amox <- guess_ab(tbl, "amox", verbose = verbose) }
if (identical(ampi, as.name("guess_ab"))) { ampi <- guess_ab(tbl, "ampi", verbose = verbose) }
if (identical(azit, as.name("guess_ab"))) { azit <- guess_ab(tbl, "azit", verbose = verbose) }
if (identical(azlo, as.name("guess_ab"))) { azlo <- guess_ab(tbl, "azlo", verbose = verbose) }
if (identical(aztr, as.name("guess_ab"))) { aztr <- guess_ab(tbl, "aztr", verbose = verbose) }
if (identical(cefa, as.name("guess_ab"))) { cefa <- guess_ab(tbl, "cefa", verbose = verbose) }
if (identical(cfep, as.name("guess_ab"))) { cfep <- guess_ab(tbl, "cfep", verbose = verbose) }
if (identical(cfot, as.name("guess_ab"))) { cfot <- guess_ab(tbl, "cfot", verbose = verbose) }
if (identical(cfox, as.name("guess_ab"))) { cfox <- guess_ab(tbl, "cfox", verbose = verbose) }
if (identical(cfra, as.name("guess_ab"))) { cfra <- guess_ab(tbl, "cfra", verbose = verbose) }
if (identical(cfta, as.name("guess_ab"))) { cfta <- guess_ab(tbl, "cfta", verbose = verbose) }
if (identical(cftr, as.name("guess_ab"))) { cftr <- guess_ab(tbl, "cftr", verbose = verbose) }
if (identical(cfur, as.name("guess_ab"))) { cfur <- guess_ab(tbl, "cfur", verbose = verbose) }
if (identical(chlo, as.name("guess_ab"))) { chlo <- guess_ab(tbl, "chlo", verbose = verbose) }
if (identical(cipr, as.name("guess_ab"))) { cipr <- guess_ab(tbl, "cipr", verbose = verbose) }
if (identical(clar, as.name("guess_ab"))) { clar <- guess_ab(tbl, "clar", verbose = verbose) }
if (identical(clin, as.name("guess_ab"))) { clin <- guess_ab(tbl, "clin", verbose = verbose) }
if (identical(clox, as.name("guess_ab"))) { clox <- guess_ab(tbl, "clox", verbose = verbose) }
if (identical(coli, as.name("guess_ab"))) { coli <- guess_ab(tbl, "coli", verbose = verbose) }
if (identical(czol, as.name("guess_ab"))) { czol <- guess_ab(tbl, "czol", verbose = verbose) }
if (identical(dapt, as.name("guess_ab"))) { dapt <- guess_ab(tbl, "dapt", verbose = verbose) }
if (identical(doxy, as.name("guess_ab"))) { doxy <- guess_ab(tbl, "doxy", verbose = verbose) }
if (identical(erta, as.name("guess_ab"))) { erta <- guess_ab(tbl, "erta", verbose = verbose) }
if (identical(eryt, as.name("guess_ab"))) { eryt <- guess_ab(tbl, "eryt", verbose = verbose) }
if (identical(fosf, as.name("guess_ab"))) { fosf <- guess_ab(tbl, "fosf", verbose = verbose) }
if (identical(fusi, as.name("guess_ab"))) { fusi <- guess_ab(tbl, "fusi", verbose = verbose) }
if (identical(gent, as.name("guess_ab"))) { gent <- guess_ab(tbl, "gent", verbose = verbose) }
if (identical(imip, as.name("guess_ab"))) { imip <- guess_ab(tbl, "imip", verbose = verbose) }
if (identical(kana, as.name("guess_ab"))) { kana <- guess_ab(tbl, "kana", verbose = verbose) }
if (identical(levo, as.name("guess_ab"))) { levo <- guess_ab(tbl, "levo", verbose = verbose) }
if (identical(linc, as.name("guess_ab"))) { linc <- guess_ab(tbl, "linc", verbose = verbose) }
if (identical(line, as.name("guess_ab"))) { line <- guess_ab(tbl, "line", verbose = verbose) }
if (identical(mero, as.name("guess_ab"))) { mero <- guess_ab(tbl, "mero", verbose = verbose) }
if (identical(mezl, as.name("guess_ab"))) { mezl <- guess_ab(tbl, "mezl", verbose = verbose) }
if (identical(mino, as.name("guess_ab"))) { mino <- guess_ab(tbl, "mino", verbose = verbose) }
if (identical(moxi, as.name("guess_ab"))) { moxi <- guess_ab(tbl, "moxi", verbose = verbose) }
if (identical(nali, as.name("guess_ab"))) { nali <- guess_ab(tbl, "nali", verbose = verbose) }
if (identical(neom, as.name("guess_ab"))) { neom <- guess_ab(tbl, "neom", verbose = verbose) }
if (identical(neti, as.name("guess_ab"))) { neti <- guess_ab(tbl, "neti", verbose = verbose) }
if (identical(nitr, as.name("guess_ab"))) { nitr <- guess_ab(tbl, "nitr", verbose = verbose) }
if (identical(norf, as.name("guess_ab"))) { norf <- guess_ab(tbl, "norf", verbose = verbose) }
if (identical(novo, as.name("guess_ab"))) { novo <- guess_ab(tbl, "novo", verbose = verbose) }
if (identical(oflo, as.name("guess_ab"))) { oflo <- guess_ab(tbl, "oflo", verbose = verbose) }
if (identical(oxac, as.name("guess_ab"))) { oxac <- guess_ab(tbl, "oxac", verbose = verbose) }
if (identical(peni, as.name("guess_ab"))) { peni <- guess_ab(tbl, "peni", verbose = verbose) }
if (identical(pipe, as.name("guess_ab"))) { pipe <- guess_ab(tbl, "pipe", verbose = verbose) }
if (identical(pita, as.name("guess_ab"))) { pita <- guess_ab(tbl, "pita", verbose = verbose) }
if (identical(poly, as.name("guess_ab"))) { poly <- guess_ab(tbl, "poly", verbose = verbose) }
if (identical(pris, as.name("guess_ab"))) { pris <- guess_ab(tbl, "pris", verbose = verbose) }
if (identical(qida, as.name("guess_ab"))) { qida <- guess_ab(tbl, "qida", verbose = verbose) }
if (identical(rifa, as.name("guess_ab"))) { rifa <- guess_ab(tbl, "rifa", verbose = verbose) }
if (identical(roxi, as.name("guess_ab"))) { roxi <- guess_ab(tbl, "roxi", verbose = verbose) }
if (identical(siso, as.name("guess_ab"))) { siso <- guess_ab(tbl, "siso", verbose = verbose) }
if (identical(teic, as.name("guess_ab"))) { teic <- guess_ab(tbl, "teic", verbose = verbose) }
if (identical(tetr, as.name("guess_ab"))) { tetr <- guess_ab(tbl, "tetr", verbose = verbose) }
if (identical(tica, as.name("guess_ab"))) { tica <- guess_ab(tbl, "tica", verbose = verbose) }
if (identical(tige, as.name("guess_ab"))) { tige <- guess_ab(tbl, "tige", verbose = verbose) }
if (identical(tobr, as.name("guess_ab"))) { tobr <- guess_ab(tbl, "tobr", verbose = verbose) }
if (identical(trim, as.name("guess_ab"))) { trim <- guess_ab(tbl, "trim", verbose = verbose) }
if (identical(trsu, as.name("guess_ab"))) { trsu <- guess_ab(tbl, "trsu", verbose = verbose) }
if (identical(vanc, as.name("guess_ab"))) { vanc <- guess_ab(tbl, "vanc", verbose = verbose) }
if (identical(amcl, as.name("guess_ab_col"))) { amcl <- guess_ab_col(tbl, "amcl", verbose = verbose) }
if (identical(amik, as.name("guess_ab_col"))) { amik <- guess_ab_col(tbl, "amik", verbose = verbose) }
if (identical(amox, as.name("guess_ab_col"))) { amox <- guess_ab_col(tbl, "amox", verbose = verbose) }
if (identical(ampi, as.name("guess_ab_col"))) { ampi <- guess_ab_col(tbl, "ampi", verbose = verbose) }
if (identical(azit, as.name("guess_ab_col"))) { azit <- guess_ab_col(tbl, "azit", verbose = verbose) }
if (identical(azlo, as.name("guess_ab_col"))) { azlo <- guess_ab_col(tbl, "azlo", verbose = verbose) }
if (identical(aztr, as.name("guess_ab_col"))) { aztr <- guess_ab_col(tbl, "aztr", verbose = verbose) }
if (identical(cefa, as.name("guess_ab_col"))) { cefa <- guess_ab_col(tbl, "cefa", verbose = verbose) }
if (identical(cfep, as.name("guess_ab_col"))) { cfep <- guess_ab_col(tbl, "cfep", verbose = verbose) }
if (identical(cfot, as.name("guess_ab_col"))) { cfot <- guess_ab_col(tbl, "cfot", verbose = verbose) }
if (identical(cfox, as.name("guess_ab_col"))) { cfox <- guess_ab_col(tbl, "cfox", verbose = verbose) }
if (identical(cfra, as.name("guess_ab_col"))) { cfra <- guess_ab_col(tbl, "cfra", verbose = verbose) }
if (identical(cfta, as.name("guess_ab_col"))) { cfta <- guess_ab_col(tbl, "cfta", verbose = verbose) }
if (identical(cftr, as.name("guess_ab_col"))) { cftr <- guess_ab_col(tbl, "cftr", verbose = verbose) }
if (identical(cfur, as.name("guess_ab_col"))) { cfur <- guess_ab_col(tbl, "cfur", verbose = verbose) }
if (identical(chlo, as.name("guess_ab_col"))) { chlo <- guess_ab_col(tbl, "chlo", verbose = verbose) }
if (identical(cipr, as.name("guess_ab_col"))) { cipr <- guess_ab_col(tbl, "cipr", verbose = verbose) }
if (identical(clar, as.name("guess_ab_col"))) { clar <- guess_ab_col(tbl, "clar", verbose = verbose) }
if (identical(clin, as.name("guess_ab_col"))) { clin <- guess_ab_col(tbl, "clin", verbose = verbose) }
if (identical(clox, as.name("guess_ab_col"))) { clox <- guess_ab_col(tbl, "clox", verbose = verbose) }
if (identical(coli, as.name("guess_ab_col"))) { coli <- guess_ab_col(tbl, "coli", verbose = verbose) }
if (identical(czol, as.name("guess_ab_col"))) { czol <- guess_ab_col(tbl, "czol", verbose = verbose) }
if (identical(dapt, as.name("guess_ab_col"))) { dapt <- guess_ab_col(tbl, "dapt", verbose = verbose) }
if (identical(doxy, as.name("guess_ab_col"))) { doxy <- guess_ab_col(tbl, "doxy", verbose = verbose) }
if (identical(erta, as.name("guess_ab_col"))) { erta <- guess_ab_col(tbl, "erta", verbose = verbose) }
if (identical(eryt, as.name("guess_ab_col"))) { eryt <- guess_ab_col(tbl, "eryt", verbose = verbose) }
if (identical(fosf, as.name("guess_ab_col"))) { fosf <- guess_ab_col(tbl, "fosf", verbose = verbose) }
if (identical(fusi, as.name("guess_ab_col"))) { fusi <- guess_ab_col(tbl, "fusi", verbose = verbose) }
if (identical(gent, as.name("guess_ab_col"))) { gent <- guess_ab_col(tbl, "gent", verbose = verbose) }
if (identical(imip, as.name("guess_ab_col"))) { imip <- guess_ab_col(tbl, "imip", verbose = verbose) }
if (identical(kana, as.name("guess_ab_col"))) { kana <- guess_ab_col(tbl, "kana", verbose = verbose) }
if (identical(levo, as.name("guess_ab_col"))) { levo <- guess_ab_col(tbl, "levo", verbose = verbose) }
if (identical(linc, as.name("guess_ab_col"))) { linc <- guess_ab_col(tbl, "linc", verbose = verbose) }
if (identical(line, as.name("guess_ab_col"))) { line <- guess_ab_col(tbl, "line", verbose = verbose) }
if (identical(mero, as.name("guess_ab_col"))) { mero <- guess_ab_col(tbl, "mero", verbose = verbose) }
if (identical(mezl, as.name("guess_ab_col"))) { mezl <- guess_ab_col(tbl, "mezl", verbose = verbose) }
if (identical(mino, as.name("guess_ab_col"))) { mino <- guess_ab_col(tbl, "mino", verbose = verbose) }
if (identical(moxi, as.name("guess_ab_col"))) { moxi <- guess_ab_col(tbl, "moxi", verbose = verbose) }
if (identical(nali, as.name("guess_ab_col"))) { nali <- guess_ab_col(tbl, "nali", verbose = verbose) }
if (identical(neom, as.name("guess_ab_col"))) { neom <- guess_ab_col(tbl, "neom", verbose = verbose) }
if (identical(neti, as.name("guess_ab_col"))) { neti <- guess_ab_col(tbl, "neti", verbose = verbose) }
if (identical(nitr, as.name("guess_ab_col"))) { nitr <- guess_ab_col(tbl, "nitr", verbose = verbose) }
if (identical(norf, as.name("guess_ab_col"))) { norf <- guess_ab_col(tbl, "norf", verbose = verbose) }
if (identical(novo, as.name("guess_ab_col"))) { novo <- guess_ab_col(tbl, "novo", verbose = verbose) }
if (identical(oflo, as.name("guess_ab_col"))) { oflo <- guess_ab_col(tbl, "oflo", verbose = verbose) }
if (identical(oxac, as.name("guess_ab_col"))) { oxac <- guess_ab_col(tbl, "oxac", verbose = verbose) }
if (identical(peni, as.name("guess_ab_col"))) { peni <- guess_ab_col(tbl, "peni", verbose = verbose) }
if (identical(pipe, as.name("guess_ab_col"))) { pipe <- guess_ab_col(tbl, "pipe", verbose = verbose) }
if (identical(pita, as.name("guess_ab_col"))) { pita <- guess_ab_col(tbl, "pita", verbose = verbose) }
if (identical(poly, as.name("guess_ab_col"))) { poly <- guess_ab_col(tbl, "poly", verbose = verbose) }
if (identical(pris, as.name("guess_ab_col"))) { pris <- guess_ab_col(tbl, "pris", verbose = verbose) }
if (identical(qida, as.name("guess_ab_col"))) { qida <- guess_ab_col(tbl, "qida", verbose = verbose) }
if (identical(rifa, as.name("guess_ab_col"))) { rifa <- guess_ab_col(tbl, "rifa", verbose = verbose) }
if (identical(roxi, as.name("guess_ab_col"))) { roxi <- guess_ab_col(tbl, "roxi", verbose = verbose) }
if (identical(siso, as.name("guess_ab_col"))) { siso <- guess_ab_col(tbl, "siso", verbose = verbose) }
if (identical(teic, as.name("guess_ab_col"))) { teic <- guess_ab_col(tbl, "teic", verbose = verbose) }
if (identical(tetr, as.name("guess_ab_col"))) { tetr <- guess_ab_col(tbl, "tetr", verbose = verbose) }
if (identical(tica, as.name("guess_ab_col"))) { tica <- guess_ab_col(tbl, "tica", verbose = verbose) }
if (identical(tige, as.name("guess_ab_col"))) { tige <- guess_ab_col(tbl, "tige", verbose = verbose) }
if (identical(tobr, as.name("guess_ab_col"))) { tobr <- guess_ab_col(tbl, "tobr", verbose = verbose) }
if (identical(trim, as.name("guess_ab_col"))) { trim <- guess_ab_col(tbl, "trim", verbose = verbose) }
if (identical(trsu, as.name("guess_ab_col"))) { trsu <- guess_ab_col(tbl, "trsu", verbose = verbose) }
if (identical(vanc, as.name("guess_ab_col"))) { vanc <- guess_ab_col(tbl, "vanc", verbose = verbose) }
col.list <- c(amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfra, cfep, cfot,
cfox, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli,
czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana,

83
R/guess_ab.R → R/guess_ab_col.R

@ -21,18 +21,28 @@ @@ -21,18 +21,28 @@
#' Guess antibiotic column
#'
#' This tries to find a column name in a data set based on information from the \code{\link{antibiotics}} data set.
#' This tries to find a column name in a data set based on information from the \code{\link{antibiotics}} data set. You can look for an antibiotic (trade) of abbreviation and it will search the data for any column containing a name or ATC code of that antibiotic.
#' @param tbl a \code{data.frame}
#' @param col a character to look for
#' @param verbose a logical to indicate whether additional info should be printed
#' @importFrom dplyr %>% select filter_all any_vars
#' @export
#' @inheritSection AMR Read more on our website!
# @examples
#
guess_ab <- function(tbl = NULL, col = NULL, verbose = FALSE) {
#' @examples
#' df <- data.frame(amox = "S",
#' tetr = "R")
#'
#' guess_ab_col(df, "amoxicillin")
#' # [1] "amox"
#' guess_ab_col(df, "J01AA07") # ATC code of Tetracycline
#' # [1] "tetr"
#'
#' guess_ab_col(df, "J01AA07", verbose = TRUE)
#' # using column `tetr` for col "J01AA07"
#' # [1] "tetr"
guess_ab_col <- function(tbl = NULL, col = NULL, verbose = FALSE) {
if (is.null(tbl) & is.null(col)) {
return(as.name("guess_ab"))
return(as.name("guess_ab_col"))
}
#stop("This function should not be called directly.")
if (length(col) > 1) {
@ -42,35 +52,58 @@ guess_ab <- function(tbl = NULL, col = NULL, verbose = FALSE) { @@ -42,35 +52,58 @@ guess_ab <- function(tbl = NULL, col = NULL, verbose = FALSE) {
if (!is.data.frame(tbl)) {
stop("`tbl` must be a data.frame")
}
tbl_names <- colnames(tbl)
if (col %in% tbl_names) {
return(col)
}
ab_result <- antibiotics %>%
select(atc:trade_name) %>%
filter_all(any_vars(tolower(.) == tolower(col)))
filter_all(any_vars(tolower(.) == tolower(col))) %>%
filter_all(any_vars(. %in% tbl_names))
if (nrow(ab_result) == 0 & nchar(col) > 4) {
# use like when col >= 5 characters
ab_result <- antibiotics %>%
select(atc:trade_name) %>%
filter_all(any_vars(tolower(.) %like% tolower(col))) %>%
filter_all(any_vars(. %in% tbl_names))
}
if (nrow(ab_result) > 1) {
# get most likely one
if (col %in% ab_result$atc) {
ab_result <- ab_result %>% filter(atc == col)
} else if (col %in% ab_result$certe) {
ab_result <- ab_result %>% filter(certe == col)
} else if (col %in% ab_result$umcg) {
ab_result <- ab_result %>% filter(umcg == col)
} else if (col %in% ab_result$umcg) {
ab_result <- ab_result %>% filter(official == col)
} else {
ab_result <- ab_result[1,]
# looking more and more for reliable hit
ab_result_1 <- ab_result %>% filter(tolower(atc) == tolower(col))
if (nrow(ab_result_1) == 0) {
ab_result_1 <- ab_result %>% filter(tolower(certe) == tolower(col))
}
if (nrow(ab_result_1) == 0) {
ab_result_1 <- ab_result %>% filter(tolower(umcg) == tolower(col))
}
if (nrow(ab_result_1) == 0) {
ab_result_1 <- ab_result %>% filter(tolower(official) == tolower(col))
}
if (nrow(ab_result_1) == 0) {
ab_result_1 <- ab_result[1, ]
}
ab_result <- ab_result_1
}
tbl_result <- tbl_names[tbl_names %in% ab_result]
if (length(tbl_result) > 1) {
tbl_result <- tbl_result[1]
warning('using column `', tbl_result, '` for col "', col, '"', call. = FALSE)
} else if (length(tbl_result) == 0) {
if (length(ab_result) == 0) {
if (verbose == TRUE) {
message('no result found for col "', col, '"')
}
return(NULL)
} else if (verbose == TRUE) {
message('using column `', tbl_result, '` for col "', col, '"')
} else {
result <- tbl_names[tbl_names %in% ab_result]
if (length(result) == 0) {
if (verbose == TRUE) {
message('no result found for col "', col, '"')
}
return(NULL)
}
if (verbose == TRUE) {
message('using column `', result, '` for col "', col, '"')
}
return(result)
}
tbl_result
}

47
R/key_antibiotics.R

@ -25,12 +25,12 @@ @@ -25,12 +25,12 @@
#' @param tbl table with antibiotics coloms, like \code{amox} and \code{amcl}.
#' @param x,y characters to compare
#' @inheritParams first_isolate
#' @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
#' @param universal_1,universal_2,universal_3,universal_4,universal_5,universal_6 column names of \strong{broad-spectrum} antibiotics, case-insensitive. At default, the columns containing these antibiotics will be guessed with \code{\link{guess_ab_col}}.
#' @param GramPos_1,GramPos_2,GramPos_3,GramPos_4,GramPos_5,GramPos_6 column names of antibiotics for \strong{Gram positives}, case-insensitive. At default, the columns containing these antibiotics will be guessed with \code{\link{guess_ab_col}}.
#' @param GramNeg_1,GramNeg_2,GramNeg_3,GramNeg_4,GramNeg_5,GramNeg_6 column names of antibiotics for \strong{Gram negatives}, case-insensitive. At default, the columns containing these antibiotics will be guessed with \code{\link{guess_ab_col}}.
#' @param warnings give warning about missing antibiotic columns, they will anyway be ignored
#' @param ... other parameters passed on to function
#' @details The function \code{key_antibiotics} returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using \code{key_antibiotics_equal}, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (\code{"."}). The \code{\link{first_isolate}} function only uses this function on the same microbial species from the same patient. Using this, an MRSA will be included after a susceptible \emph{S. aureus} (MSSA) found within the same episode (see \code{episode} parameter of \code{\link{first_isolate}}). Without key antibiotic comparison it wouldn't.
#' @details The function \code{key_antibiotics} returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using \code{key_antibiotics_equal}, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (\code{"."}). The \code{\link{first_isolate}} function only uses this function on the same microbial species from the same patient. Using this, an MRSA will be included after a susceptible \emph{S. aureus} (MSSA) found within the same episode (see \code{episode} parameter of \code{\link{first_isolate}}). Without key antibiotic comparison it would not.
#'
#' 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"}.
@ -78,24 +78,24 @@ @@ -78,24 +78,24 @@
#' # FALSE, because I is not ignored and so the 4th value differs
key_antibiotics <- function(tbl,
col_mo = NULL,
universal_1 = guess_ab(tbl, "amox"),
universal_2 = guess_ab(tbl, "amcl"),
universal_3 = guess_ab(tbl, "cfur"),
universal_4 = guess_ab(tbl, "pita"),
universal_5 = guess_ab(tbl, "cipr"),
universal_6 = guess_ab(tbl, "trsu"),
GramPos_1 = guess_ab(tbl, "vanc"),
GramPos_2 = guess_ab(tbl, "teic"),
GramPos_3 = guess_ab(tbl, "tetr"),
GramPos_4 = guess_ab(tbl, "eryt"),
GramPos_5 = guess_ab(tbl, "oxac"),
GramPos_6 = guess_ab(tbl, "rifa"),
GramNeg_1 = guess_ab(tbl, "gent"),
GramNeg_2 = guess_ab(tbl, "tobr"),
GramNeg_3 = guess_ab(tbl, "coli"),
GramNeg_4 = guess_ab(tbl, "cfot"),
GramNeg_5 = guess_ab(tbl, "cfta"),
GramNeg_6 = guess_ab(tbl, "mero"),
universal_1 = guess_ab_col(tbl, "amox"),
universal_2 = guess_ab_col(tbl, "amcl"),
universal_3 = guess_ab_col(tbl, "cfur"),
universal_4 = guess_ab_col(tbl, "pita"),
universal_5 = guess_ab_col(tbl, "cipr"),
universal_6 = guess_ab_col(tbl, "trsu"),
GramPos_1 = guess_ab_col(tbl, "vanc"),
GramPos_2 = guess_ab_col(tbl, "teic"),
GramPos_3 = guess_ab_col(tbl, "tetr"),
GramPos_4 = guess_ab_col(tbl, "eryt"),
GramPos_5 = guess_ab_col(tbl, "oxac"),
GramPos_6 = guess_ab_col(tbl, "rifa"),
GramNeg_1 = guess_ab_col(tbl, "gent"),
GramNeg_2 = guess_ab_col(tbl, "tobr"),
GramNeg_3 = guess_ab_col(tbl, "coli"),
GramNeg_4 = guess_ab_col(tbl, "cfot"),
GramNeg_5 = guess_ab_col(tbl, "cfta"),
GramNeg_6 = guess_ab_col(tbl, "mero"),
warnings = TRUE,
...) {
@ -153,9 +153,6 @@ key_antibiotics <- function(tbl, @@ -153,9 +153,6 @@ key_antibiotics <- function(tbl,
left_join_microorganisms(by = col_mo) %>%
mutate(key_ab = NA_character_)
print(as.character(gram_positive))
print(gram_negative)
# Gram +
tbl <- tbl %>% mutate(key_ab =
if_else(gramstain == "Gram positive",

240
R/mdro.R

@ -46,66 +46,66 @@ mdro <- function(tbl, @@ -46,66 +46,66 @@ mdro <- function(tbl,
country = NULL,
col_mo = NULL,
info = TRUE,
amcl = guess_ab(),
amik = guess_ab(),
amox = guess_ab(),
ampi = guess_ab(),
azit = guess_ab(),
aztr = guess_ab(),
cefa = guess_ab(),
cfra = guess_ab(),
cfep = guess_ab(),
cfot = guess_ab(),
cfox = guess_ab(),
cfta = guess_ab(),
cftr = guess_ab(),
cfur = guess_ab(),
chlo = guess_ab(),
cipr = guess_ab(),
clar = guess_ab(),
clin = guess_ab(),
clox = guess_ab(),
coli = guess_ab(),
czol = guess_ab(),
dapt = guess_ab(),
doxy = guess_ab(),
erta = guess_ab(),
eryt = guess_ab(),
fosf = guess_ab(),
fusi = guess_ab(),
gent = guess_ab(),
imip = guess_ab(),
kana = guess_ab(),
levo = guess_ab(),
linc = guess_ab(),
line = guess_ab(),
mero = guess_ab(),
metr = guess_ab(),
mino = guess_ab(),
moxi = guess_ab(),
nali = guess_ab(),
neom = guess_ab(),
neti = guess_ab(),
nitr = guess_ab(),
novo = guess_ab(),
norf = guess_ab(),
oflo = guess_ab(),
peni = guess_ab(),
pipe = guess_ab(),
pita = guess_ab(),
poly = guess_ab(),
qida = guess_ab(),
rifa = guess_ab(),
roxi = guess_ab(),
siso = guess_ab(),
teic = guess_ab(),
tetr = guess_ab(),
tica = guess_ab(),
tige = guess_ab(),
tobr = guess_ab(),
trim = guess_ab(),
trsu = guess_ab(),
vanc = guess_ab()) {
amcl = guess_ab_col(),
amik = guess_ab_col(),
amox = guess_ab_col(),
ampi = guess_ab_col(),
azit = guess_ab_col(),
aztr = guess_ab_col(),
cefa = guess_ab_col(),
cfra = guess_ab_col(),
cfep = guess_ab_col(),
cfot = guess_ab_col(),
cfox = guess_ab_col(),
cfta = guess_ab_col(),
cftr = guess_ab_col(),
cfur = guess_ab_col(),
chlo = guess_ab_col(),
cipr = guess_ab_col(),
clar = guess_ab_col(),
clin = guess_ab_col(),
clox = guess_ab_col(),
coli = guess_ab_col(),
czol = guess_ab_col(),
dapt = guess_ab_col(),
doxy = guess_ab_col(),
erta = guess_ab_col(),
eryt = guess_ab_col(),
fosf = guess_ab_col(),
fusi = guess_ab_col(),
gent = guess_ab_col(),
imip = guess_ab_col(),
kana = guess_ab_col(),
levo = guess_ab_col(),
linc = guess_ab_col(),
line = guess_ab_col(),
mero = guess_ab_col(),
metr = guess_ab_col(),
mino = guess_ab_col(),
moxi = guess_ab_col(),
nali = guess_ab_col(),
neom = guess_ab_col(),
neti = guess_ab_col(),
nitr = guess_ab_col(),
novo = guess_ab_col(),
norf = guess_ab_col(),
oflo = guess_ab_col(),
peni = guess_ab_col(),
pipe = guess_ab_col(),
pita = guess_ab_col(),
poly = guess_ab_col(),
qida = guess_ab_col(),
rifa = guess_ab_col(),
roxi = guess_ab_col(),
siso = guess_ab_col(),
teic = guess_ab_col(),
tetr = guess_ab_col(),
tica = guess_ab_col(),
tige = guess_ab_col(),
tobr = guess_ab_col(),
trim = guess_ab_col(),
trsu = guess_ab_col(),
vanc = guess_ab_col()) {
if (!is.data.frame(tbl)) {
stop("`tbl` must be a data frame.", call. = FALSE)
@ -169,66 +169,66 @@ mdro <- function(tbl, @@ -169,66 +169,66 @@ mdro <- function(tbl,
}
# check columns
if (identical(amcl, as.name("guess_ab"))) { amcl <- guess_ab(tbl, "amcl", verbose = info) }
if (identical(amik, as.name("guess_ab"))) { amik <- guess_ab(tbl, "amik", verbose = info) }
if (identical(amox, as.name("guess_ab"))) { amox <- guess_ab(tbl, "amox", verbose = info) }
if (identical(ampi, as.name("guess_ab"))) { ampi <- guess_ab(tbl, "ampi", verbose = info) }
if (identical(azit, as.name("guess_ab"))) { azit <- guess_ab(tbl, "azit", verbose = info) }
if (identical(aztr, as.name("guess_ab"))) { aztr <- guess_ab(tbl, "aztr", verbose = info) }
if (identical(cefa, as.name("guess_ab"))) { cefa <- guess_ab(tbl, "cefa", verbose = info) }
if (identical(cfra, as.name("guess_ab"))) { cfra <- guess_ab(tbl, "cfra", verbose = info) }
if (identical(cfep, as.name("guess_ab"))) { cfep <- guess_ab(tbl, "cfep", verbose = info) }
if (identical(cfot, as.name("guess_ab"))) { cfot <- guess_ab(tbl, "cfot", verbose = info) }
if (identical(cfox, as.name("guess_ab"))) { cfox <- guess_ab(tbl, "cfox", verbose = info) }
if (identical(cfta, as.name("guess_ab"))) { cfta <- guess_ab(tbl, "cfta", verbose = info) }
if (identical(cftr, as.name("guess_ab"))) { cftr <- guess_ab(tbl, "cftr", verbose = info) }
if (identical(cfur, as.name("guess_ab"))) { cfur <- guess_ab(tbl, "cfur", verbose = info) }
if (identical(chlo, as.name("guess_ab"))) { chlo <- guess_ab(tbl, "chlo", verbose = info) }
if (identical(cipr, as.name("guess_ab"))) { cipr <- guess_ab(tbl, "cipr", verbose = info) }
if (identical(clar, as.name("guess_ab"))) { clar <- guess_ab(tbl, "clar", verbose = info) }
if (identical(clin, as.name("guess_ab"))) { clin <- guess_ab(tbl, "clin", verbose = info) }
if (identical(clox, as.name("guess_ab"))) { clox <- guess_ab(tbl, "clox", verbose = info) }
if (identical(coli, as.name("guess_ab"))) { coli <- guess_ab(tbl, "coli", verbose = info) }
if (identical(czol, as.name("guess_ab"))) { czol <- guess_ab(tbl, "czol", verbose = info) }
if (identical(dapt, as.name("guess_ab"))) { dapt <- guess_ab(tbl, "dapt", verbose = info) }
if (identical(doxy, as.name("guess_ab"))) { doxy <- guess_ab(tbl, "doxy", verbose = info) }
if (identical(erta, as.name("guess_ab"))) { erta <- guess_ab(tbl, "erta", verbose = info) }
if (identical(eryt, as.name("guess_ab"))) { eryt <- guess_ab(tbl, "eryt", verbose = info) }
if (identical(fosf, as.name("guess_ab"))) { fosf <- guess_ab(tbl, "fosf", verbose = info) }
if (identical(fusi, as.name("guess_ab"))) { fusi <- guess_ab(tbl, "fusi", verbose = info) }
if (identical(gent, as.name("guess_ab"))) { gent <- guess_ab(tbl, "gent", verbose = info) }
if (identical(imip, as.name("guess_ab"))) { imip <- guess_ab(tbl, "imip", verbose = info) }
if (identical(kana, as.name("guess_ab"))) { kana <- guess_ab(tbl, "kana", verbose = info) }
if (identical(levo, as.name("guess_ab"))) { levo <- guess_ab(tbl, "levo", verbose = info) }
if (identical(linc, as.name("guess_ab"))) { linc <- guess_ab(tbl, "linc", verbose = info) }
if (identical(line, as.name("guess_ab"))) { line <- guess_ab(tbl, "line", verbose = info) }
if (identical(mero, as.name("guess_ab"))) { mero <- guess_ab(tbl, "mero", verbose = info) }
if (identical(metr, as.name("guess_ab"))) { metr <- guess_ab(tbl, "metr", verbose = info) }
if (identical(mino, as.name("guess_ab"))) { mino <- guess_ab(tbl, "mino", verbose = info) }
if (identical(moxi, as.name("guess_ab"))) { moxi <- guess_ab(tbl, "moxi", verbose = info) }
if (identical(nali, as.name("guess_ab"))) { nali <- guess_ab(tbl, "nali", verbose = info) }
if (identical(neom, as.name("guess_ab"))) { neom <- guess_ab(tbl, "neom", verbose = info) }
if (identical(neti, as.name("guess_ab"))) { neti <- guess_ab(tbl, "neti", verbose = info) }
if (identical(nitr, as.name("guess_ab"))) { nitr <- guess_ab(tbl, "nitr", verbose = info) }
if (identical(novo, as.name("guess_ab"))) { novo <- guess_ab(tbl, "novo", verbose = info) }
if (identical(norf, as.name("guess_ab"))) { norf <- guess_ab(tbl, "norf", verbose = info) }
if (identical(oflo, as.name("guess_ab"))) { oflo <- guess_ab(tbl, "oflo", verbose = info) }
if (identical(peni, as.name("guess_ab"))) { peni <- guess_ab(tbl, "peni", verbose = info) }
if (identical(pipe, as.name("guess_ab"))) { pipe <- guess_ab(tbl, "pipe", verbose = info) }
if (identical(pita, as.name("guess_ab"))) { pita <- guess_ab(tbl, "pita", verbose = info) }
if (identical(poly, as.name("guess_ab"))) { poly <- guess_ab(tbl, "poly", verbose = info) }
if (identical(qida, as.name("guess_ab"))) { qida <- guess_ab(tbl, "qida", verbose = info) }
if (identical(rifa, as.name("guess_ab"))) { rifa <- guess_ab(tbl, "rifa", verbose = info) }
if (identical(roxi, as.name("guess_ab"))) { roxi <- guess_ab(tbl, "roxi", verbose = info) }
if (identical(siso, as.name("guess_ab"))) { siso <- guess_ab(tbl, "siso", verbose = info) }
if (identical(teic, as.name("guess_ab"))) { teic <- guess_ab(tbl, "teic", verbose = info) }
if (identical(tetr, as.name("guess_ab"))) { tetr <- guess_ab(tbl, "tetr", verbose = info) }
if (identical(tica, as.name("guess_ab"))) { tica <- guess_ab(tbl, "tica", verbose = info) }
if (identical(tige, as.name("guess_ab"))) { tige <- guess_ab(tbl, "tige", verbose = info) }
if (identical(tobr, as.name("guess_ab"))) { tobr <- guess_ab(tbl, "tobr", verbose = info) }
if (identical(trim, as.name("guess_ab"))) { trim <- guess_ab(tbl, "trim", verbose = info) }
if (identical(trsu, as.name("guess_ab"))) { trsu <- guess_ab(tbl, "trsu", verbose = info) }
if (identical(vanc, as.name("guess_ab"))) { vanc <- guess_ab(tbl, "vanc", verbose = info) }
if (identical(amcl, as.name("guess_ab_col"))) { amcl <- guess_ab_col(tbl, "amcl", verbose = info) }
if (identical(amik, as.name("guess_ab_col"))) { amik <- guess_ab_col(tbl, "amik", verbose = info) }
if (identical(amox, as.name("guess_ab_col"))) { amox <- guess_ab_col(tbl, "amox", verbose = info) }
if (identical(ampi, as.name("guess_ab_col"))) { ampi <- guess_ab_col(tbl, "ampi", verbose = info) }
if (identical(azit, as.name("guess_ab_col"))) { azit <- guess_ab_col(tbl, "azit", verbose = info) }
if (identical(aztr, as.name("guess_ab_col"))) { aztr <- guess_ab_col(tbl, "aztr", verbose = info) }
if (identical(cefa, as.name("guess_ab_col"))) { cefa <- guess_ab_col(tbl, "cefa", verbose = info) }
if (identical(cfra, as.name("guess_ab_col"))) { cfra <- guess_ab_col(tbl, "cfra", verbose = info) }
if (identical(cfep, as.name("guess_ab_col"))) { cfep <- guess_ab_col(tbl, "cfep", verbose = info) }
if (identical(cfot, as.name("guess_ab_col"))) { cfot <- guess_ab_col(tbl, "cfot", verbose = info) }
if (identical(cfox, as.name("guess_ab_col"))) { cfox <- guess_ab_col(tbl, "cfox", verbose = info) }
if (identical(cfta, as.name("guess_ab_col"))) { cfta <- guess_ab_col(tbl, "cfta", verbose = info) }
if (identical(cftr, as.name("guess_ab_col"))) { cftr <- guess_ab_col(tbl, "cftr", verbose = info) }
if (identical(cfur, as.name("guess_ab_col"))) { cfur <- guess_ab_col(tbl, "cfur", verbose = info) }
if (identical(chlo, as.name("guess_ab_col"))) { chlo <- guess_ab_col(tbl, "chlo", verbose = info) }
if (identical(cipr, as.name("guess_ab_col"))) { cipr <- guess_ab_col(tbl, "cipr", verbose = info) }
if (identical(clar, as.name("guess_ab_col"))) { clar <- guess_ab_col(tbl, "clar", verbose = info) }
if (identical(clin, as.name("guess_ab_col"))) { clin <- guess_ab_col(tbl, "clin", verbose = info) }
if (identical(clox, as.name("guess_ab_col"))) { clox <- guess_ab_col(tbl, "clox", verbose = info) }
if (identical(coli, as.name("guess_ab_col"))) { coli <- guess_ab_col(tbl, "coli", verbose = info) }
if (identical(czol, as.name("guess_ab_col"))) { czol <- guess_ab_col(tbl, "czol", verbose = info) }
if (identical(dapt, as.name("guess_ab_col"))) { dapt <- guess_ab_col(tbl, "dapt", verbose = info) }
if (identical(doxy, as.name("guess_ab_col"))) { doxy <- guess_ab_col(tbl, "doxy", verbose = info) }
if (identical(erta, as.name("guess_ab_col"))) { erta <- guess_ab_col(tbl, "erta", verbose = info) }
if (identical(eryt, as.name("guess_ab_col"))) { eryt <- guess_ab_col(tbl, "eryt", verbose = info) }
if (identical(fosf, as.name("guess_ab_col"))) { fosf <- guess_ab_col(tbl, "fosf", verbose = info) }
if (identical(fusi, as.name("guess_ab_col"))) { fusi <- guess_ab_col(tbl, "fusi", verbose = info) }
if (identical(gent, as.name("guess_ab_col"))) { gent <- guess_ab_col(tbl, "gent", verbose = info) }
if (identical(imip, as.name("guess_ab_col"))) { imip <- guess_ab_col(tbl, "imip", verbose = info) }
if (identical(kana, as.name("guess_ab_col"))) { kana <- guess_ab_col(tbl, "kana", verbose = info) }
if (identical(levo, as.name("guess_ab_col"))) { levo <- guess_ab_col(tbl, "levo", verbose = info) }
if (identical(linc, as.name("guess_ab_col"))) { linc <- guess_ab_col(tbl, "linc", verbose = info) }
if (identical(line, as.name("guess_ab_col"))) { line <- guess_ab_col(tbl, "line", verbose = info) }
if (identical(mero, as.name("guess_ab_col"))) { mero <- guess_ab_col(tbl, "mero", verbose = info) }
if (identical(metr, as.name("guess_ab_col"))) { metr <- guess_ab_col(tbl, "metr", verbose = info) }
if (identical(mino, as.name("guess_ab_col"))) { mino <- guess_ab_col(tbl, "mino", verbose = info) }
if (identical(moxi, as.name("guess_ab_col"))) { moxi <- guess_ab_col(tbl, "moxi", verbose = info) }
if (identical(nali, as.name("guess_ab_col"))) { nali <- guess_ab_col(tbl, "nali", verbose = info) }
if (identical(neom, as.name("guess_ab_col"))) { neom <- guess_ab_col(tbl, "neom", verbose = info) }
if (identical(neti, as.name("guess_ab_col"))) { neti <- guess_ab_col(tbl, "neti", verbose = info) }
if (identical(nitr, as.name("guess_ab_col"))) { nitr <- guess_ab_col(tbl, "nitr", verbose = info) }
if (identical(novo, as.name("guess_ab_col"))) { novo <- guess_ab_col(tbl, "novo", verbose = info) }
if (identical(norf, as.name("guess_ab_col"))) { norf <- guess_ab_col(tbl, "norf", verbose = info) }
if (identical(oflo, as.name("guess_ab_col"))) { oflo <- guess_ab_col(tbl, "oflo", verbose = info) }
if (identical(peni, as.name("guess_ab_col"))) { peni <- guess_ab_col(tbl, "peni", verbose = info) }
if (identical(pipe, as.name("guess_ab_col"))) { pipe <- guess_ab_col(tbl, "pipe", verbose = info) }
if (identical(pita, as.name("guess_ab_col"))) { pita <- guess_ab_col(tbl, "pita", verbose = info) }
if (identical(poly, as.name("guess_ab_col"))) { poly <- guess_ab_col(tbl, "poly", verbose = info) }
if (identical(qida, as.name("guess_ab_col"))) { qida <- guess_ab_col(tbl, "qida", verbose = info) }
if (identical(rifa, as.name("guess_ab_col"))) { rifa <- guess_ab_col(tbl, "rifa", verbose = info) }
if (identical(roxi, as.name("guess_ab_col"))) { roxi <- guess_ab_col(tbl, "roxi", verbose = info) }
if (identical(siso, as.name("guess_ab_col"))) { siso <- guess_ab_col(tbl, "siso", verbose = info) }
if (identical(teic, as.name("guess_ab_col"))) { teic <- guess_ab_col(tbl, "teic", verbose = info) }
if (identical(tetr, as.name("guess_ab_col"))) { tetr <- guess_ab_col(tbl, "tetr", verbose = info) }
if (identical(tica, as.name("guess_ab_col"))) { tica <- guess_ab_col(tbl, "tica", verbose = info) }
if (identical(tige, as.name("guess_ab_col"))) { tige <- guess_ab_col(tbl, "tige", verbose = info) }
if (identical(tobr, as.name("guess_ab_col"))) { tobr <- guess_ab_col(tbl, "tobr", verbose = info) }
if (identical(trim, as.name("guess_ab_col"))) { trim <- guess_ab_col(tbl, "trim", verbose = info) }
if (identical(trsu, as.name("guess_ab_col"))) { trsu <- guess_ab_col(tbl, "trsu", verbose = info) }
if (identical(vanc, as.name("guess_ab_col"))) { vanc <- guess_ab_col(tbl, "vanc", verbose = info) }
col.list <- c(amcl, amik, amox, ampi, azit, aztr, cefa, cfra, cfep, cfot,
cfox, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli,
czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana,

13
_pkgdown.yml

@ -53,6 +53,9 @@ navbar: @@ -53,6 +53,9 @@ navbar:
- text: 'Use the G-test'
icon: 'fa-clipboard-check'
href: 'articles/G_test.html'
- text: 'Other: benchmarks'
icon: 'fa-shipping-fast'
href: 'articles/benchmarks.html'
- text: 'Manual'
icon: 'fa-book-open'
href: 'reference/'
@ -73,7 +76,8 @@ navbar: @@ -73,7 +76,8 @@ navbar:
reference:
- title: 'Background information'
desc: >
Some pages about our package and its external sources.
Some pages about our package and its external sources. Be sure to read our [How To's](./../articles/index.html)
for more information about how to work with functions in this package.
contents:
- '`AMR`'
- '`ITIS`'
@ -85,7 +89,7 @@ reference: @@ -85,7 +89,7 @@ reference:
contents:
- starts_with("as.")
- '`eucast_rules`'
- '`guess_ab`'
- '`guess_ab_col`'
- '`read.4D`'
- title: 'Adding variables to your data'
desc: >
@ -129,7 +133,10 @@ reference: @@ -129,7 +133,10 @@ reference:
- '`microorganisms.umcg`'
- '`supplementary_data`'
- title: Other
desc: ~
desc: >
These functions are mostly for internal use, but some of
them may also be suitable for your analysis. Especially the
'like' function can be useful: `if (x %like% y) {...}`.
contents:
- '`get_locale`'
- '`like`'

7
docs/LICENSE-text.html

@ -149,6 +149,13 @@ @@ -149,6 +149,13 @@
Use the G-test
</a>
</li>
<li>
<a href="articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
Other: benchmarks
</a>
</li>
</ul>
</li>
<li>

477
docs/articles/AMR.html

@ -111,6 +111,13 @@ @@ -111,6 +111,13 @@
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
Other: benchmarks
</a>
</li>
</ul>
</li>
<li>
@ -171,7 +178,7 @@ @@ -171,7 +178,7 @@
<h1>How to conduct AMR analysis</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 January 2019</h4>
<h4 class="date">11 January 2019</h4>
<div class="hidden name"><code>AMR.Rmd</code></div>
@ -180,7 +187,7 @@ @@ -180,7 +187,7 @@
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">RMarkdown</a>. However, the methodology remains unchanged. This page was generated on 08 January 2019.</p>
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">RMarkdown</a>. However, the methodology remains unchanged. This page was generated on 11 January 2019.</p>
<div id="introduction" class="section level2">
<h2 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h2>
@ -196,21 +203,21 @@ @@ -196,21 +203,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2019-01-08</td>
<td align="center">2019-01-11</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
<td align="center">2019-01-08</td>
<td align="center">2019-01-11</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
<td align="center">2019-01-08</td>
<td align="center">2019-01-11</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -268,18 +275,18 @@ @@ -268,18 +275,18 @@
<div id="put-everything-together" class="section level4">
<h4 class="hasAnchor">
<a href="#put-everything-together" class="anchor"></a>Put everything together</h4>
<p>Using the <code><a href="https://dplyr.tidyverse.org/reference/sample.html">sample()</a></code> function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the <code>prob</code> parameter.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">data &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/data.frame">data.frame</a></span>(<span class="dt">date =</span> <span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(dates, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),</a>
<a class="sourceLine" id="cb7-2" data-line-number="2"> <span class="dt">patient_id =</span> <span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(patients, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),</a>
<a class="sourceLine" id="cb7-3" data-line-number="3"> <span class="dt">hospital =</span> <span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(hospitals, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.30</span>, <span class="fl">0.35</span>, <span class="fl">0.15</span>, <span class="fl">0.20</span>)),</a>
<a class="sourceLine" id="cb7-4" data-line-number="4"> <span class="dt">bacteria =</span> <span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(bacteria, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.50</span>, <span class="fl">0.25</span>, <span class="fl">0.15</span>, <span class="fl">0.10</span>)),</a>
<a class="sourceLine" id="cb7-5" data-line-number="5"> <span class="dt">amox =</span> <span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.60</span>, <span class="fl">0.05</span>, <span class="fl">0.35</span>)),</a>
<a class="sourceLine" id="cb7-6" data-line-number="6"> <span class="dt">amcl =</span> <span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.75</span>, <span class="fl">0.10</span>, <span class="fl">0.15</span>)),</a>
<a class="sourceLine" id="cb7-7" data-line-number="7"> <span class="dt">cipr =</span> <span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.80</span>, <span class="fl">0.00</span>, <span class="fl">0.20</span>)),</a>
<a class="sourceLine" id="cb7-8" data-line-number="8"> <span class="dt">gent =</span> <span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.92</span>, <span class="fl">0.00</span>, <span class="fl">0.08</span>))</a>
<p>Using the <code><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample()</a></code> function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the <code>prob</code> parameter.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">data &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/data.frame">data.frame</a></span>(<span class="dt">date =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample</a></span>(dates, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),</a>
<a class="sourceLine" id="cb7-2" data-line-number="2"> <span class="dt">patient_id =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample</a></span>(patients, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),</a>
<a class="sourceLine" id="cb7-3" data-line-number="3"> <span class="dt">hospital =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample</a></span>(hospitals, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.30</span>, <span class="fl">0.35</span>, <span class="fl">0.15</span>, <span class="fl">0.20</span>)),</a>
<a class="sourceLine" id="cb7-4" data-line-number="4"> <span class="dt">bacteria =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample</a></span>(bacteria, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.50</span>, <span class="fl">0.25</span>, <span class="fl">0.15</span>, <span class="fl">0.10</span>)),</a>
<a class="sourceLine" id="cb7-5" data-line-number="5"> <span class="dt">amox =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.60</span>, <span class="fl">0.05</span>, <span class="fl">0.35</span>)),</a>
<a class="sourceLine" id="cb7-6" data-line-number="6"> <span class="dt">amcl =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.75</span>, <span class="fl">0.10</span>, <span class="fl">0.15</span>)),</a>
<a class="sourceLine" id="cb7-7" data-line-number="7"> <span class="dt">cipr =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.80</span>, <span class="fl">0.00</span>, <span class="fl">0.20</span>)),</a>
<a class="sourceLine" id="cb7-8" data-line-number="8"> <span class="dt">gent =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/sample">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.92</span>, <span class="fl">0.00</span>, <span class="fl">0.08</span>))</a>
<a class="sourceLine" id="cb7-9" data-line-number="9"> )</a></code></pre></div>
<p>Using the <code><a href="https://dplyr.tidyverse.org/reference/join.html">left_join()</a></code> function from the <code>dplyr</code> package, we can ‘map’ the gender to the patient ID using the <code>patients_table</code> object we created earlier:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/join.html">left_join</a></span>(patients_table)</a></code></pre></div>
<p>Using the <code><a href="https://www.rdocumentation.org/packages/dplyr/topics/join">left_join()</a></code> function from the <code>dplyr</code> package, we can ‘map’ the gender to the patient ID using the <code>patients_table</code> object we created earlier:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/join">left_join</a></span>(patients_table)</a></code></pre></div>
<p>The resulting data set contains 5,000 blood culture isolates. With the <code><a href="https://www.rdocumentation.org/packages/utils/topics/head">head()</a></code> function we can preview the first 6 values of this data set:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(data)</a></code></pre></div>
<table class="table">
@ -296,70 +303,70 @@ @@ -296,70 +303,70 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2011-02-27</td>
<td align="center">M6</td>
<td align="center">Hospital C</td>
<td align="center">2014-02-02</td>
<td align="center">P8</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2012-07-12</td>
<td align="center">C2</td>
<td align="center">2013-10-26</td>
<td align="center">Q1</td>
<td align="center">Hospital B</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">Escherichia coli</td>