1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 19:26:13 +01:00

(v0.8.0.9017) keywords update

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-11-06 14:43:23 +01:00
parent be9a3e6b12
commit e2d05cb1b0
55 changed files with 755 additions and 108 deletions

View File

@ -21,7 +21,7 @@
^pkgdown$
^public$
^data-raw$
R/aa_test.R$
^\.lintr$
^vignettes/benchmark.*
^vignettes/SPSS.*
^tests/appveyor$

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.8.0.9016
Date: 2019-11-05
Version: 0.8.0.9017
Date: 2019-11-06
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),

View File

@ -1,5 +1,5 @@
# AMR 0.8.0.9016
<small>Last updated: 05-Nov-2019</small>
# AMR 0.8.0.9017
<small>Last updated: 06-Nov-2019</small>
### New
* Support for a new MDRO guideline: Magiorakos AP, Srinivasan A *et al.* "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012).

1
R/ab.R
View File

@ -25,7 +25,6 @@
#' @param x character vector to determine to antibiotic ID
#' @param ... arguments passed on to internal functions
#' @rdname as.ab
#' @keywords atc
#' @inheritSection WHOCC WHOCC
#' @export
#' @importFrom dplyr %>% filter slice pull

View File

@ -83,6 +83,7 @@ ab_name <- function(x, language = get_locale(), tolower = FALSE, ...) {
}
#' @rdname ab_property
#' @aliases ATC
#' @export
ab_atc <- function(x, ...) {
ab_validate(x = x, property = "atc", ...)

View File

@ -106,7 +106,6 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE) {
#' \item{\code{"tens"}, equivalent of: \code{1:10 * 10}. This will split on 0-9, 10-19, 20-29, ... 80-89, 90-99, 100+.}
#' }
#' }
#' @keywords age_group age
#' @return Ordered \code{\link{factor}}
#' @seealso To determine ages, based on one or more reference dates, use the \code{\link{age}} function.
#' @export

View File

@ -37,7 +37,6 @@
#' @inheritSection portion Combination therapy
#' @source Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
#' @seealso \code{\link{portion}_*} to calculate microbial resistance and susceptibility.
#' @keywords resistance susceptibility rsi antibiotics isolate isolates
#' @return Integer
#' @rdname count
#' @name count

View File

@ -27,7 +27,7 @@
#' @param na.rm a logical indicating whether missing values should be removed
#' @details Interpret disk values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI.
#' @return Ordered integer factor with new class \code{disk}
#' @keywords disk
#' @aliases disk
#' @export
#' @seealso \code{\link{as.rsi}}
#' @inheritSection AMR Read more on our website!

View File

@ -122,7 +122,7 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016"
#' \strong{TMP}: trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EA01}{J01EA01}),
#' \strong{SXT}: trimethoprim/sulfamethoxazole (\href{https://www.whocc.no/atc_ddd_index/?code=J01EE01}{J01EE01}),
#' \strong{VAN}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}).
#' @keywords interpretive eucast reading resistance
#' @aliases EUCAST
#' @rdname eucast_rules
#' @export
#' @importFrom dplyr %>% select pull mutate_at vars group_by summarise n

View File

@ -29,7 +29,6 @@
#' @param ... parameters passed on to \code{filter_at} from the \code{dplyr} package
#' @details The \code{group} column in \code{\link{antibiotics}} data set will be searched for \code{ab_class} (case-insensitive). If no results are found, the \code{atc_group1} and \code{atc_group2} columns will be searched. Next, \code{x} will be checked for column names with a value in any abbreviations, codes or official names found in the \code{antibiotics} data set.
#' @rdname filter_ab_class
#' @keywords filter fillter_class
#' @importFrom dplyr filter_at %>% select vars any_vars all_vars
#' @importFrom crayon bold blue
#' @export

View File

@ -70,7 +70,6 @@
#' \strong{2. Using} \code{type = "points"} \strong{and parameter} \code{points_threshold} \cr
#' A difference from I to S|R (or vice versa) means 0.5 points, a difference from S to R (or vice versa) means 1 point. When the sum of points exceeds \code{points_threshold}, which default to \code{2}, an isolate will be (re)selected as a first weighted isolate.
#' @rdname first_isolate
#' @keywords isolate isolates first
#' @seealso \code{\link{key_antibiotics}}
#' @export
#' @importFrom dplyr arrange_at lag between row_number filter mutate arrange pull ungroup

View File

@ -61,7 +61,6 @@
#' where \code{df} are the degrees of freedom.
#'
#' If there are more than two categories and you want to find out which ones are significantly different from their null expectation, you can use the same method of testing each category vs. the sum of all categories, with the Bonferroni correction. You use \emph{G}-tests for each category, of course.
#' @keywords chi
#' @seealso \code{\link{chisq.test}}
#' @references [1] McDonald, J.H. 2014. \strong{Handbook of Biological Statistics (3rd ed.)}. Sparky House Publishing, Baltimore, Maryland. \url{http://www.biostathandbook.com/gtestgof.html}.
#' @source This code is almost identical to \code{\link{chisq.test}}, except that:

View File

@ -49,9 +49,8 @@
#' # get frequencies of bacteria whose name start with 'Ent' or 'ent'
#' library(dplyr)
#' example_isolates %>%
#' left_join_microorganisms() %>%
#' filter(genus %like% '^ent') %>%
#' freq(genus, species)
#' filter(mo_genus(mo) %like% '^ent') %>%
#' freq(mo_fullname(mo))
like <- function(x, pattern, ignore.case = TRUE) {
if (length(pattern) > 1) {
if (length(x) != length(pattern)) {

View File

@ -26,6 +26,7 @@
#' @param info print progress
#' @inheritParams eucast_rules
#' @param pct_required_classes minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for \emph{S. aureus}. Setting this \code{pct_required_classes} argument to \code{0.5} (default) means that for every \emph{S. aureus} isolate at least 8 different classes must be available. Any lower number of available classes will return \code{NA} for that isolate.
#' @param combine_SI a logical to indicate whether all values of S and I must be merged into one, so resistance is only considered when isolates are R, not I. As this is the default behaviour of the \code{mdro()} function, it follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. When using \code{combine_SI = FALSE}, resistance is considered when isolates are R or I.
#' @param verbose a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.
#' @inheritSection eucast_rules Antibiotics
#' @details
@ -43,7 +44,7 @@
#' Please suggest your own (country-specific) guidelines by letting us know: \url{https://gitlab.com/msberends/AMR/issues/new}.
#'
#' \strong{Note:} Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named order Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu \emph{et al.} in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this \code{mdro()} function makes sure that results from before 2016 and after 2016 are identical.
#'
#' @inheritSection as.rsi Interpretation of S, I and R
#' @return \itemize{
#' \item{CMI 2012 paper - function \code{mdr_cmi2012()} or \code{mdro()}:\cr Ordered factor with levels \code{Negative < Multi-drug-resistant (MDR) < Extensively drug-resistant (XDR) < Pandrug-resistant (PDR)}}
#' \item{TB guideline - function \code{mdr_tb()} or \code{mdro(..., guideline = "TB")}:\cr Ordered factor with levels \code{Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant < Extensively drug-resistant}}
@ -51,6 +52,7 @@
#' \item{Everything else:\cr Ordered factor with levels \code{Negative < Positive, unconfirmed < Positive}. The value \code{"Positive, unconfirmed"} means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests}
#' }
#' @rdname mdro
#' @aliases MDR XDR PDR BRMO 3MRGN 4MRGN
#' @importFrom dplyr %>% filter_at vars all_vars pull mutate_at
#' @importFrom crayon blue bold italic
#' @importFrom cleaner percentage
@ -80,8 +82,9 @@ mdro <- function(x,
guideline = NULL,
col_mo = NULL,
info = TRUE,
verbose = FALSE,
pct_required_classes = 0.5,
combine_SI = TRUE,
verbose = FALSE,
...) {
if (verbose == TRUE & interactive()) {
@ -411,7 +414,18 @@ mdro <- function(x,
stop("No antimycobacterials found in data set.", call. = FALSE)
}
if (combine_SI == TRUE) {
search_result <- "R"
} else {
search_result <- c("R", "I")
}
if (info == TRUE) {
if (combine_SI == TRUE) {
cat("\nOnly results with 'R' are considered as resistance. Use `combine_SI = FALSE` to also consider 'I' as resistance.\n")
} else {
cat("\nResults with 'R' or 'I' are considered as resistance. Use `combine_SI = TRUE` to only consider 'R' as resistance.\n")
}
cat("\nDetermining multidrug-resistant organisms (MDRO), according to:\n",
bold("Guideline: "), italic(guideline$name), "\n",
bold("Version: "), guideline$version, "\n",
@ -444,19 +458,21 @@ mdro <- function(x,
x <<- x %>% mutate_at(vars(cols), as.rsi)
x[rows, "columns_nonsusceptible"] <<- sapply(rows,
function(row, group_vct = cols) {
cols_nonsus <- sapply(x[row, group_vct, drop = FALSE], function(y) y == "R")
cols_nonsus <- sapply(x[row, group_vct, drop = FALSE],
function(y) y %in% search_result)
paste(sort(c(unlist(strsplit(x[row, "columns_nonsusceptible", drop = TRUE], ", ")),
names(cols_nonsus)[cols_nonsus])),
collapse = ", ")
})
if (any_all == "any") {
row_filter <- which(x[, cols] == "R")
search_function <- dplyr::any_vars
} else if (any_all == "all") {
row_filter <- x %>%
mutate(index = seq_len(nrow(.))) %>%
filter_at(vars(cols), all_vars(. == "R")) %>%
pull((index))
search_function <- dplyr::all_vars
}
row_filter <- x %>%
filter_at(vars(cols), search_function(. %in% search_result)) %>%
pull("row_number")
rows <- rows[rows %in% row_filter]
x[rows, "MDRO"] <<- to
x[rows, "reason"] <<- paste0(any_all, " of the required antibiotics ", ifelse(any_all == "any", "is", "are"), " R")
@ -479,7 +495,7 @@ mdro <- function(x,
if (verbose == TRUE) {
x[rows, "columns_nonsusceptible"] <<- sapply(rows,
function(row, group_vct = lst_vector) {
cols_nonsus <- sapply(x[row, group_vct, drop = FALSE], function(y) y %in% c("I", "R"))
cols_nonsus <- sapply(x[row, group_vct, drop = FALSE], function(y) y %in% search_result)
paste(sort(names(cols_nonsus)[cols_nonsus]), collapse = ", ")
})
}
@ -487,14 +503,14 @@ mdro <- function(x,
function(row, group_tbl = lst) {
sum(sapply(group_tbl,
function(group) {
any(x[row, group[!is.na(group)]] == "R", na.rm = TRUE) |
any(x[row, group[!is.na(group)]] == "I", na.rm = TRUE)
any(unlist(x[row, group[!is.na(group)], drop = TRUE]) %in% search_result, na.rm = TRUE)
}),
na.rm = TRUE)
})
# for PDR; all agents are R (or I if combine_SI = FALSE)
x[filter_at(x[rows, ],
vars(lst_vector),
all_vars(. %in% c("R", "I")))$row_number, "classes_affected"] <<- 999
all_vars(. %in% search_result))$row_number, "classes_affected"] <<- 999
}
if (info == TRUE) {

View File

@ -27,7 +27,7 @@
#' @param na.rm a logical indicating whether missing values should be removed
#' @details Interpret MIC values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI.
#' @return Ordered factor with new class \code{mic}
#' @keywords mic
#' @aliases MIC
#' @export
#' @importFrom dplyr %>%
#' @seealso \code{\link{as.rsi}}

View File

@ -79,7 +79,6 @@
#'
#' Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
#' @seealso \code{\link[AMR]{count}_*} to count resistant and susceptible isolates.
#' @keywords resistance susceptibility rsi_df rsi antibiotics isolate isolates
#' @return Double or, when \code{as_percent = TRUE}, a character.
#' @rdname portion
#' @name portion

View File

@ -36,7 +36,7 @@
#'
#' The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains at most 5\% invalid antimicrobial interpretations (not S and/or I and/or R), and \code{FALSE} otherwise. The threshold of 5\% can be set with the \code{threshold} parameter.
#' @section Interpretation of S, I and R:
#' In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
#' In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
#'
#' \itemize{
#' \item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
@ -48,7 +48,7 @@
#'
#' This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
#' @return Ordered factor with new class \code{rsi}
#' @keywords rsi
#' @aliases RSI
#' @export
#' @importFrom dplyr %>% desc arrange filter
#' @seealso \code{\link{as.mic}}

View File

@ -23,7 +23,7 @@
init:
ps: |
$ErrorActionPreference = "Stop"
Invoke-WebRequest https://raw.githubusercontent.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
Invoke-WebRequest https://gitlab.com/msberends/AMR/raw/master/tests/appveyor/appveyor_tool.ps1 -OutFile "..\appveyor-tool.ps1"
Import-Module '..\appveyor-tool.ps1'
install:

View File

@ -84,7 +84,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9016</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -84,7 +84,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9016</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -84,7 +84,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9016</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -84,7 +84,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9016</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -45,7 +45,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9016</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -84,7 +84,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9016</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>
@ -231,11 +231,11 @@
</div>
<div id="amr-0-8-0-9016" class="section level1">
<div id="amr-0-8-0-9017" class="section level1">
<h1 class="page-header">
<a href="#amr-0-8-0-9016" class="anchor"></a>AMR 0.8.0.9016<small> Unreleased </small>
<a href="#amr-0-8-0-9017" class="anchor"></a>AMR 0.8.0.9017<small> Unreleased </small>
</h1>
<p><small>Last updated: 05-Nov-2019</small></p>
<p><small>Last updated: 06-Nov-2019</small></p>
<div id="new" class="section level3">
<h3 class="hasAnchor">
<a href="#new" class="anchor"></a>New</h3>
@ -1333,7 +1333,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<div id="tocnav">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#amr-0-8-0-9016">0.8.0.9016</a></li>
<li><a href="#amr-0-8-0-9017">0.8.0.9017</a></li>
<li><a href="#amr-0-8-0">0.8.0</a></li>
<li><a href="#amr-0-7-1">0.7.1</a></li>
<li><a href="#amr-0-7-0">0.7.0</a></li>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>
@ -298,7 +298,7 @@
<p>In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<p>In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<ul>
<li><p><strong>S</strong> - Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li>
<li><p><strong>I</strong> - Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.</p></li>

View File

@ -86,7 +86,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>
@ -305,7 +305,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
<p>In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<p>In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<ul>
<li><p><strong>S</strong> - Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li>
<li><p><strong>I</strong> - Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.</p></li>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -84,7 +84,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9016</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>
@ -305,9 +305,8 @@
<span class='co'># get frequencies of bacteria whose name start with 'Ent' or 'ent'</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='join.html'>left_join_microorganisms</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>genus</span> <span class='kw'>%like%</span> <span class='st'>'^ent'</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>(<span class='no'>genus</span>, <span class='no'>species</span>)</pre>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='no'>mo</span>) <span class='kw'>%like%</span> <span class='st'>'^ent'</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>(<span class='fu'><a href='mo_property.html'>mo_fullname</a></span>(<span class='no'>mo</span>))</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>

View File

@ -85,7 +85,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9013</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>
@ -238,7 +238,8 @@
</div>
<pre class="usage"><span class='fu'>mdro</span>(<span class='no'>x</span>, <span class='kw'>guideline</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>col_mo</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>info</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>pct_required_classes</span> <span class='kw'>=</span> <span class='fl'>0.5</span>, <span class='no'>...</span>)
<span class='kw'>pct_required_classes</span> <span class='kw'>=</span> <span class='fl'>0.5</span>, <span class='kw'>combine_SI</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
<span class='no'>...</span>)
<span class='fu'>brmo</span>(<span class='no'>x</span>, <span class='kw'>guideline</span> <span class='kw'>=</span> <span class='st'>"BRMO"</span>, <span class='no'>...</span>)
@ -269,14 +270,18 @@
<th>info</th>
<td><p>print progress</p></td>
</tr>
<tr>
<th>verbose</th>
<td><p>a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.</p></td>
</tr>
<tr>
<th>pct_required_classes</th>
<td><p>minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for <em>S. aureus</em>. Setting this <code>pct_required_classes</code> argument to <code>0.5</code> (default) means that for every <em>S. aureus</em> isolate at least 8 different classes must be available. Any lower number of available classes will return <code>NA</code> for that isolate.</p></td>
</tr>
<tr>
<th>combine_SI</th>
<td><p>a logical to indicate whether all values of S and I must be merged into one, so resistance is only considered when isolates are R, not I. As this is the default behaviour of the <code>mdro()</code> function, it follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. When using <code>combine_SI = FALSE</code>, resistance is considered when isolates are R or I.</p></td>
</tr>
<tr>
<th>verbose</th>
<td><p>a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.</p></td>
</tr>
<tr>
<th>...</th>
<td><p>column name of an antibiotic, see section Antibiotics</p></td>
@ -394,6 +399,19 @@
<strong>TMP</strong>: trimethoprim (<a href='https://www.whocc.no/atc_ddd_index/?code=J01EA01'>J01EA01</a>),
<strong>SXT</strong>: trimethoprim/sulfamethoxazole (<a href='https://www.whocc.no/atc_ddd_index/?code=J01EE01'>J01EE01</a>),
<strong>VAN</strong>: vancomycin (<a href='https://www.whocc.no/atc_ddd_index/?code=J01XA01'>J01XA01</a>).</p>
<h2 class="hasAnchor" id="interpretation-of-s-i-and-r"><a class="anchor" href="#interpretation-of-s-i-and-r"></a>Interpretation of S, I and R</h2>
<p>In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<ul>
<li><p><strong>S</strong> - Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li>
<li><p><strong>I</strong> - Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.</p></li>
<li><p><strong>R</strong> - Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.</p></li>
</ul>
<p>Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.</p>
<p>This AMR package honours this new insight. Use <code><a href='portion.html'>portion_SI</a></code> to determine antimicrobial susceptibility and <code><a href='count.html'>count_SI</a></code> to count susceptible isolates.</p>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
@ -427,6 +445,7 @@
<li><a href="#value">Value</a></li>
<li><a href="#details">Details</a></li>
<li><a href="#antibiotics">Antibiotics</a></li>
<li><a href="#interpretation-of-s-i-and-r">Interpretation of S, I and R</a></li>
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
<li><a href="#examples">Examples</a></li>
</ul>

View File

@ -86,7 +86,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9017</span>
</span>
</div>
@ -353,7 +353,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<p>In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<p>In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<ul>
<li><p><strong>S</strong> - Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li>
<li><p><strong>I</strong> - Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.</p></li>

View File

@ -4,6 +4,7 @@
\alias{ab_property}
\alias{ab_name}
\alias{ab_atc}
\alias{ATC}
\alias{ab_cid}
\alias{ab_synonyms}
\alias{ab_tradenames}

View File

@ -74,5 +74,3 @@ example_isolates \%>\%
\seealso{
To determine ages, based on one or more reference dates, use the \code{\link{age}} function.
}
\keyword{age}
\keyword{age_group}

View File

@ -72,4 +72,3 @@ ab_name("eryt") # "Erythromycin"
\seealso{
\code{\link{antibiotics}} for the dataframe that is being used to determine ATCs.
}
\keyword{atc}

View File

@ -2,6 +2,7 @@
% Please edit documentation in R/disk.R
\name{as.disk}
\alias{as.disk}
\alias{disk}
\alias{is.disk}
\title{Class 'disk'}
\usage{
@ -42,4 +43,3 @@ as.rsi(x = 12,
\seealso{
\code{\link{as.rsi}}
}
\keyword{disk}

View File

@ -2,6 +2,7 @@
% Please edit documentation in R/mic.R
\name{as.mic}
\alias{as.mic}
\alias{MIC}
\alias{is.mic}
\title{Class 'mic'}
\usage{
@ -52,4 +53,3 @@ freq(mic_data)
\seealso{
\code{\link{as.rsi}}
}
\keyword{mic}

View File

@ -2,6 +2,7 @@
% Please edit documentation in R/rsi.R
\name{as.rsi}
\alias{as.rsi}
\alias{RSI}
\alias{as.rsi.mic}
\alias{as.rsi.disk}
\alias{as.rsi.data.frame}
@ -52,7 +53,7 @@ The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains
}
\section{Interpretation of S, I and R}{
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
\itemize{
\item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
@ -110,4 +111,3 @@ is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
\seealso{
\code{\link{as.mic}}
}
\keyword{rsi}

View File

@ -66,7 +66,7 @@ The function \code{rsi_df} works exactly like \code{count_df}, but adds the perc
}
\section{Interpretation of S, I and R}{
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
\itemize{
\item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
@ -182,9 +182,3 @@ example_isolates \%>\%
\seealso{
\code{\link{portion}_*} to calculate microbial resistance and susceptibility.
}
\keyword{antibiotics}
\keyword{isolate}
\keyword{isolates}
\keyword{resistance}
\keyword{rsi}
\keyword{susceptibility}

View File

@ -2,6 +2,7 @@
% Please edit documentation in R/eucast_rules.R
\name{eucast_rules}
\alias{eucast_rules}
\alias{EUCAST}
\title{EUCAST rules}
\source{
\itemize{
@ -183,7 +184,3 @@ b
c <- eucast_rules(a, verbose = TRUE)
}
}
\keyword{eucast}
\keyword{interpretive}
\keyword{reading}
\keyword{resistance}

View File

@ -89,5 +89,3 @@ example_isolates \%>\%
filter_aminoglycosides("R", "all") \%>\%
filter_fluoroquinolones("R", "all")
}
\keyword{fillter_class}
\keyword{filter}

View File

@ -160,6 +160,3 @@ x$first_blood_isolate <- first_isolate(x, specimen_group = "Blood")
\seealso{
\code{\link{key_antibiotics}}
}
\keyword{first}
\keyword{isolate}
\keyword{isolates}

View File

@ -145,4 +145,3 @@ g.test(x)
\seealso{
\code{\link{chisq.test}}
}
\keyword{chi}

View File

@ -63,9 +63,8 @@ a \%like\% b
# get frequencies of bacteria whose name start with 'Ent' or 'ent'
library(dplyr)
example_isolates \%>\%
left_join_microorganisms() \%>\%
filter(genus \%like\% '^ent') \%>\%
freq(genus, species)
filter(mo_genus(mo) \%like\% '^ent') \%>\%
freq(mo_fullname(mo))
}
\seealso{
\code{\link[base]{grep}}

View File

@ -2,6 +2,12 @@
% Please edit documentation in R/mdro.R
\name{mdro}
\alias{mdro}
\alias{MDR}
\alias{XDR}
\alias{PDR}
\alias{BRMO}
\alias{3MRGN}
\alias{4MRGN}
\alias{brmo}
\alias{mrgn}
\alias{mdr_tb}
@ -13,7 +19,8 @@ Please see Details for the list of publications used for this function.
}
\usage{
mdro(x, guideline = NULL, col_mo = NULL, info = TRUE,
verbose = FALSE, pct_required_classes = 0.5, ...)
pct_required_classes = 0.5, combine_SI = TRUE, verbose = FALSE,
...)
brmo(x, guideline = "BRMO", ...)
@ -34,10 +41,12 @@ eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...)
\item{info}{print progress}
\item{verbose}{a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.}
\item{pct_required_classes}{minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for \emph{S. aureus}. Setting this \code{pct_required_classes} argument to \code{0.5} (default) means that for every \emph{S. aureus} isolate at least 8 different classes must be available. Any lower number of available classes will return \code{NA} for that isolate.}
\item{combine_SI}{a logical to indicate whether all values of S and I must be merged into one, so resistance is only considered when isolates are R, not I. As this is the default behaviour of the \code{mdro()} function, it follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. When using \code{combine_SI = FALSE}, resistance is considered when isolates are R or I.}
\item{verbose}{a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.}
\item{...}{column name of an antibiotic, see section Antibiotics}
}
\value{
@ -154,6 +163,21 @@ The following antibiotics are used for the functions \code{\link{eucast_rules}}
\strong{VAN}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}).
}
\section{Interpretation of S, I and R}{
In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
\itemize{
\item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
\item{\strong{I} - }{Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.}
\item{\strong{R} - }{Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.}
}
Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
}
\section{Read more on our website!}{
On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}.

View File

@ -114,7 +114,7 @@ Using \code{only_all_tested} has no impact when only using one antibiotic as inp
\section{Interpretation of S, I and R}{
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
\itemize{
\item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
@ -226,10 +226,3 @@ my_table \%>\%
\seealso{
\code{\link[AMR]{count}_*} to count resistant and susceptible isolates.
}
\keyword{antibiotics}
\keyword{isolate}
\keyword{isolates}
\keyword{resistance}
\keyword{rsi}
\keyword{rsi_df}
\keyword{susceptibility}

View File

@ -0,0 +1,193 @@
if ( -not(Test-Path Env:\CRAN) ) {
$CRAN = "https://cran.rstudio.com"
}
Else {
$CRAN = $env:CRAN
}
# Found at http://zduck.com/2012/powershell-batch-files-exit-codes/
Function Exec
{
[CmdletBinding()]
param (
[Parameter(Position=0, Mandatory=1)]
[scriptblock]$Command,
[Parameter(Position=1, Mandatory=0)]
[string]$ErrorMessage = "Execution of command failed.`n$Command"
)
$ErrorActionPreference = "Continue"
& $Command 2>&1 | %{ "$_" }
if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage`nExit code: $LastExitCode"
}
}
Function Progress
{
[CmdletBinding()]
param (
[Parameter(Position=0, Mandatory=0)]
[string]$Message = ""
)
$ProgressMessage = '== ' + (Get-Date) + ': ' + $Message
Write-Host $ProgressMessage -ForegroundColor Magenta
}
Function TravisTool
{
[CmdletBinding()]
param (
[Parameter(Position=0, Mandatory=1)]
[string[]]$Params
)
Exec { bash.exe ../travis_tool.sh $Params }
}
Function InstallR {
[CmdletBinding()]
Param()
if ( -not(Test-Path Env:\R_VERSION) ) {
$version = "patched"
}
Else {
$version = $env:R_VERSION
}
if ( -not(Test-Path Env:\R_ARCH) ) {
$arch = "x64"
}
Else {
$arch = $env:R_ARCH
}
If ($arch -eq "i386") {
$mingw_path = "mingw_32"
}
Else {
$mingw_path = "mingw_64"
}
Progress ("Version: " + $version)
If ($version -eq "devel") {
$url_path = ""
$version = "devel"
}
ElseIf (($version -eq "stable") -or ($version -eq "release")) {
$url_path = ""
$version = $(ConvertFrom-JSON $(Invoke-WebRequest http://rversions.r-pkg.org/r-release-win).Content).version
If ($version -eq "3.2.4") {
$version = "3.2.4revised"
}
}
ElseIf ($version -eq "patched") {
$url_path = ""
$version = $(ConvertFrom-JSON $(Invoke-WebRequest http://rversions.r-pkg.org/r-release-win).Content).version + "patched"
}
ElseIf ($version -eq "oldrel") {
$version = $(ConvertFrom-JSON $(Invoke-WebRequest http://rversions.r-pkg.org/r-oldrel).Content).version
$url_path = ("old/" + $version + "/")
}
Else {
$url_path = ("old/" + $version + "/")
}
Progress ("URL path: " + $url_path)
$rurl = $CRAN + "/bin/windows/base/" + $url_path + "R-" + $version + "-win.exe"
Progress ("Downloading R from: " + $rurl)
& "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../R-win.exe -L $rurl
Progress "Running R installer"
Start-Process -FilePath ..\R-win.exe -ArgumentList "/VERYSILENT /DIR=C:\R" -NoNewWindow -Wait
$RDrive = "C:"
echo "R is now available on drive $RDrive"
Progress "Setting PATH"
$env:PATH = $RDrive + '\R\bin\' + $arch + ';' + 'C:\Rtools\' + $mingw_path + '\bin;' + 'C:\MinGW\msys\1.0\bin;' + $env:PATH
Progress "Testing R installation"
Rscript -e "sessionInfo()"
}
Function InstallRtools {
if ( -not(Test-Path Env:\RTOOLS_VERSION) ) {
Progress "Determining Rtools version"
$rtoolsver = $(Invoke-WebRequest ($CRAN + "/bin/windows/Rtools/VERSION.txt")).Content.Split(' ')[2].Split('.')[0..1] -Join ''
}
Else {
$rtoolsver = $env:RTOOLS_VERSION
}
$rtoolsurl = $CRAN + "/bin/windows/Rtools/Rtools$rtoolsver.exe"
Progress ("Downloading Rtools from: " + $rtoolsurl)
& "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../Rtools-current.exe -L $rtoolsurl
Progress "Running Rtools installer"
Start-Process -FilePath ..\Rtools-current.exe -ArgumentList /VERYSILENT -NoNewWindow -Wait
$RtoolsDrive = "C:"
echo "Rtools is now available on drive $RtoolsDrive"
Progress "Setting PATH"
if ( -not(Test-Path Env:\GCC_PATH) ) {
$gcc_path = "gcc-4.6.3"
}
Else {
$gcc_path = $env:GCC_PATH
}
$env:PATH = $RtoolsDrive + '\Rtools\bin;' + $RtoolsDrive + '\Rtools\MinGW\bin;' + $RtoolsDrive + '\Rtools\' + $gcc_path + '\bin;' + $env:PATH
$env:BINPREF=$RtoolsDrive + '/Rtools/mingw_$(WIN)/bin/'
}
Function Bootstrap {
[CmdletBinding()]
Param()
Progress "Bootstrap: Start"
Progress "Adding GnuWin32 tools to PATH"
$env:PATH = "C:\Program Files (x86)\Git\bin;" + $env:PATH
Progress "Setting time zone"
tzutil /g
tzutil /s "GMT Standard Time"
tzutil /g
InstallR
if ((Test-Path "src") -or ($env:USE_RTOOLS -eq "true") -or ($env:USE_RTOOLS -eq "yes")) {
InstallRtools
}
Else {
Progress "Skipping download of Rtools because src/ directory is missing."
}
Progress "Downloading and installing travis_tool.sh"
Invoke-WebRequest https://gitlab.com/msberends/AMR/raw/master/tests/appveyor/travis_tool.sh -OutFile "..\travis_tool.sh"
echo '@bash.exe ../travis_tool.sh %*' | Out-File -Encoding ASCII .\travis_tool.sh.cmd
cat .\travis_tool.sh.cmd
bash -c "( echo; echo '^travis_tool\.sh\.cmd$' ) >> .Rbuildignore"
cat .\.Rbuildignore
$env:PATH.Split(";")
Progress "Setting R_LIBS_USER"
$env:R_LIBS_USER = 'c:\RLibrary'
if ( -not(Test-Path $env:R_LIBS_USER) ) {
mkdir $env:R_LIBS_USER
}
Progress "Setting TAR to 'internal'"
$env:TAR = 'internal'
Progress "Bootstrap: Done"
}

View File

@ -0,0 +1,428 @@
#!/bin/bash
# -*- sh-basic-offset: 4; sh-indentation: 4 -*-
# Bootstrap an R/travis environment.
set -e
# Comment out this line for quieter output:
set -x
CRAN=${CRAN:-"https://cran.rstudio.com"}
BIOC=${BIOC:-"http://bioconductor.org/biocLite.R"}
PKGTYPE=${PKGTYPE:-"win.binary"}
BIOC_USE_DEVEL=${BIOC_USE_DEVEL:-"TRUE"}
OS=$(uname -s)
DOWNLOAD_FILE_METHOD=${DOWNLOAD_FILE_METHOD:-"auto"}
PANDOC_VERSION='1.13.1'
PANDOC_DIR="${HOME}/opt/pandoc"
PANDOC_URL="https://s3.amazonaws.com/rstudio-buildtools/pandoc-${PANDOC_VERSION}.zip"
# MacTeX installs in a new $PATH entry, and there's no way to force
# the *parent* shell to source it from here. So we just manually add
# all the entries to a location we already know to be on $PATH.
#
# TODO(craigcitro): Remove this once we can add `/usr/texbin` to the
# root path.
PATH="${PATH}:/usr/texbin"
R_BUILD_ARGS=${R_BUILD_ARGS-"--no-manual"}
R_CHECK_ARGS=${R_CHECK_ARGS-"--no-manual --as-cran"}
R_VERSION_TEST="getRversion() >= '3.5.0'"
R_USE_BIOC_INST="source('${BIOC}');"\
" tryCatch(useDevel(${BIOC_USE_DEVEL}),"\
" error=function(e) {if (!grepl('already in use', e$message)) {e}});"\
" options(repos=biocinstallRepos())"
R_USE_BIOC_MNGR="if (!requireNamespace('BiocManager', quietly=TRUE))"\
" install.packages('BiocManager', repos=c(CRAN='${CRAN}'));"\
" if (${BIOC_USE_DEVEL})"\
" BiocManager::install(version = 'devel', ask = FALSE);"\
" options(repos=BiocManager::repositories())"
R_USE_BIOC_CMDS="if (${R_VERSION_TEST}) {${R_USE_BIOC_MNGR}} else {${R_USE_BIOC_INST}};"
BIOC_INSTALL="{if (${R_VERSION_TEST}) BiocManager::install else BiocInstaller::biocLite}"
Bootstrap() {
if [[ "Darwin" == "${OS}" ]]; then
BootstrapMac
elif [[ "Linux" == "${OS}" ]]; then
BootstrapLinux
else
echo "Unknown OS: ${OS}"
exit 1
fi
if ! (test -e .Rbuildignore && grep -q 'travis-tool' .Rbuildignore); then
echo '^travis-tool\.sh$' >>.Rbuildignore
fi
}
InstallPandoc() {
local os_path="$1"
mkdir -p "${PANDOC_DIR}"
curl -o /tmp/pandoc-${PANDOC_VERSION}.zip ${PANDOC_URL}
unzip -j /tmp/pandoc-${PANDOC_VERSION}.zip "pandoc-${PANDOC_VERSION}/${os_path}/pandoc" -d "${PANDOC_DIR}"
chmod +x "${PANDOC_DIR}/pandoc"
sudo ln -s "${PANDOC_DIR}/pandoc" /usr/local/bin
unzip -j /tmp/pandoc-${PANDOC_VERSION}.zip "pandoc-${PANDOC_VERSION}/${os_path}/pandoc-citeproc" -d "${PANDOC_DIR}"
chmod +x "${PANDOC_DIR}/pandoc-citeproc"
sudo ln -s "${PANDOC_DIR}/pandoc-citeproc" /usr/local/bin
}
BootstrapLinux() {
# Set up our CRAN mirror.
sudo add-apt-repository "deb ${CRAN}/bin/linux/ubuntu $(lsb_release -cs)/"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
# Add marutter's c2d4u repository.
sudo add-apt-repository -y "ppa:marutter/rrutter"
sudo add-apt-repository -y "ppa:marutter/c2d4u"
# Update after adding all repositories. Retry several times to work around
# flaky connection to Launchpad PPAs.
Retry sudo apt-get update -qq
# Install an R development environment. qpdf is also needed for
# --as-cran checks:
# https://stat.ethz.ch/pipermail/r-help//2012-September/335676.html
Retry sudo apt-get install -y --no-install-recommends r-base-dev r-recommended qpdf
# Change permissions for /usr/local/lib/R/site-library
# This should really be via 'staff adduser travis staff'
# but that may affect only the next shell
sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library
# Process options
BootstrapLinuxOptions
}
BootstrapLinuxOptions() {
if [[ -n "$BOOTSTRAP_LATEX" ]]; then
# We add a backports PPA for more recent TeX packages.
sudo add-apt-repository -y "ppa:texlive-backports/ppa"
Retry sudo apt-get install -y --no-install-recommends \
texlive-base texlive-latex-base texlive-generic-recommended \
texlive-fonts-recommended texlive-fonts-extra \
texlive-extra-utils texlive-latex-recommended texlive-latex-extra \
texinfo lmodern
fi
if [[ -n "$BOOTSTRAP_PANDOC" ]]; then
InstallPandoc 'linux/debian/x86_64'
fi
}
BootstrapMac() {
# Install from latest CRAN binary build for OS X
wget ${CRAN}/bin/macosx/R-latest.pkg -O /tmp/R-latest.pkg
echo "Installing OS X binary package for R"
sudo installer -pkg "/tmp/R-latest.pkg" -target /
rm "/tmp/R-latest.pkg"
# Process options
BootstrapMacOptions
}
BootstrapMacOptions() {
if [[ -n "$BOOTSTRAP_LATEX" ]]; then
# TODO: Install MacTeX.pkg once there's enough disk space
MACTEX=BasicTeX.pkg
wget http://ctan.math.utah.edu/ctan/tex-archive/systems/mac/mactex/$MACTEX -O "/tmp/$MACTEX"
echo "Installing OS X binary package for MacTeX"
sudo installer -pkg "/tmp/$MACTEX" -target /
rm "/tmp/$MACTEX"
# We need a few more packages than the basic package provides; this
# post saved me so much pain:
# https://stat.ethz.ch/pipermail/r-sig-mac/2010-May/007399.html
sudo tlmgr update --self
sudo tlmgr install inconsolata upquote courier courier-scaled helvetic
fi
if [[ -n "$BOOTSTRAP_PANDOC" ]]; then
InstallPandoc 'mac'
fi
}
EnsureDevtools() {
if ! Rscript -e 'if (!("devtools" %in% rownames(installed.packages()))) q(status=1)' ; then
# Install devtools and testthat.
RBinaryInstall devtools testthat
fi
}
EnsureRemotes() {
if ! Rscript -e 'if (!("remotes" %in% rownames(installed.packages()))) q(status=1)' ; then
# Install remotes.
RBinaryInstall remotes
fi
if ! Rscript -e 'if (!("remotes" %in% rownames(installed.packages()))) q(status=1)' ; then
# Fallback: Install remotes from URL.
Rscript -e 'path <- file.path(tempdir(), "remotes_1.0.0.tar.gz"); download.file("https://cran.rstudio.com/src/contrib/Archive/remotes/remotes_1.0.0.tar.gz", path); install.packages(path, repos = NULL, type = "source")'
fi
}
AptGetInstall() {
if [[ "Linux" != "${OS}" ]]; then
echo "Wrong OS: ${OS}"
exit 1
fi
if [[ "" == "$*" ]]; then
echo "No arguments to aptget_install"
exit 1
fi
echo "Installing apt package(s) $@"
Retry sudo apt-get -y install "$@"
}
DpkgCurlInstall() {
if [[ "Linux" != "${OS}" ]]; then
echo "Wrong OS: ${OS}"
exit 1
fi
if [[ "" == "$*" ]]; then
echo "No arguments to dpkgcurl_install"
exit 1
fi
echo "Installing remote package(s) $@"
for rf in "$@"; do
curl -OL ${rf}
f=$(basename ${rf})
sudo dpkg -i ${f}
rm -v ${f}
done
}
RInstall() {
if [[ "" == "$*" ]]; then
echo "No arguments to r_install"
exit 1
fi
echo "Installing R package(s): $@"
Rscript -e 'install.packages(commandArgs(TRUE), repos="'"${CRAN}"'", INSTALL_opts="", type="'"${PKGTYPE}"'")' "$@"
}
BiocInstall() {
if [[ "" == "$*" ]]; then
echo "No arguments to bioc_install"
exit 1
fi
echo "Installing R Bioconductor package(s): $@"
Rscript -e "${R_USE_BIOC_CMDS}"" ${BIOC_INSTALL}(commandArgs(TRUE))" "$@"
}
RBinaryInstall() {
if [[ -z "$#" ]]; then
echo "No arguments to r_binary_install"
exit 1
fi
if [[ "Linux" != "${OS}" ]] || [[ -n "${FORCE_SOURCE_INSTALL}" ]]; then
echo "Fallback: Installing from source"
RInstall "$@"
return
fi
echo "Installing *binary* R packages: $*"
r_packages=$(echo $* | tr '[:upper:]' '[:lower:]')
r_debs=$(for r_package in ${r_packages}; do echo -n "r-cran-${r_package} "; done)
AptGetInstall ${r_debs}
}
InstallGithub() {
EnsureRemotes
echo "Installing GitHub packages: $@"
# Install the package.
Rscript -e 'options(repos = c(CRAN = "'"${CRAN}"'"), download.file.method = "'"${DOWNLOAD_FILE_METHOD}"'"); remotes::install_github(commandArgs(TRUE), type="'"${PKGTYPE}"'")' "$@"
}
InstallDeps() {
EnsureRemotes
echo "Installing dependencies"
Rscript -e 'options(repos = c(CRAN = "'"${CRAN}"'"), download.file.method = "'"${DOWNLOAD_FILE_METHOD}"'"); remotes::install_deps(dependencies = TRUE, type="'"${PKGTYPE}"'")'
}
InstallBiocDeps() {
EnsureDevtools
Rscript -e "${R_USE_BIOC_CMDS}"' library(devtools); install_deps(dependencies = TRUE, type="'"${PKGTYPE}"'")'
}
DumpSysinfo() {
echo "Dumping system information."
R -e '.libPaths(); sessionInfo(); installed.packages()'
}
DumpLogsByExtension() {
if [[ -z "$1" ]]; then
echo "dump_logs_by_extension requires exactly one argument, got: $@"
exit 1
fi
extension=$1
shift
package=$(find . -maxdepth 1 -name "*.Rcheck" -type d)
if [[ ${#package[@]} -ne 1 ]]; then
echo "Could not find package Rcheck directory, skipping log dump."
exit 0
fi
for name in $(find "${package}" -type f -name "*${extension}"); do
echo ">>> Filename: ${name} <<<"
cat ${name}
done
}
DumpLogs() {
echo "Dumping test execution logs."
DumpLogsByExtension "out"
DumpLogsByExtension "log"
DumpLogsByExtension "fail"
}
RunTests() {
echo "Building with: R CMD build ${R_BUILD_ARGS}"
if [[ "${KEEP_VIGNETTES}" == "" ]]; then
if [[ "${OS:0:5}" == "MINGW" || "${OS:0:4}" == "MSYS" ]]; then
if [[ -d vignettes ]]; then
rm -rf vignettes
Rscript -e "d <- read.dcf('DESCRIPTION'); d[, colnames(d) == 'VignetteBuilder'] <- NA; write.dcf(d, 'DESCRIPTION')"
fi
fi
fi
R CMD build ${R_BUILD_ARGS} .
# We want to grab the version we just built.
FILE=$(ls -1t *.tar.gz | head -n 1)
# Create binary package (currently Windows only)
if [[ "${OS:0:5}" == "MINGW" || "${OS:0:4}" == "MSYS" ]]; then
R_CHECK_INSTALL_ARGS="--install-args=--build"
fi
echo "Testing with: R CMD check \"${FILE}\" ${R_CHECK_ARGS} ${R_CHECK_INSTALL_ARGS}"
_R_CHECK_CRAN_INCOMING_=${_R_CHECK_CRAN_INCOMING_:-FALSE}
if [[ "$_R_CHECK_CRAN_INCOMING_" == "FALSE" ]]; then
echo "(CRAN incoming checks are off)"
fi
_R_CHECK_CRAN_INCOMING_=${_R_CHECK_CRAN_INCOMING_} R_QPDF=true R CMD check "${FILE}" ${R_CHECK_ARGS} ${R_CHECK_INSTALL_ARGS}
# Check reverse dependencies
if [[ -n "$R_CHECK_REVDEP" ]]; then
echo "Checking reverse dependencies"
EnsureDevtools
Rscript -e 'library(devtools); checkOutput <- unlist(revdep_check(as.package(".")$package));if (!is.null(checkOutput)) {print(data.frame(pkg = names(checkOutput), error = checkOutput));for(i in seq_along(checkOutput)){;cat("\n", names(checkOutput)[i], " Check Output:\n ", paste(readLines(regmatches(checkOutput[i], regexec("/.*\\.out", checkOutput[i]))[[1]]), collapse = "\n ", sep = ""), "\n", sep = "")};q(status = 1, save = "no")}'
fi
if [[ -n "${WARNINGS_ARE_ERRORS}" ]]; then
if DumpLogsByExtension "00check.log" | grep -q WARNING; then
echo "Found warnings, treated as errors."
echo "Clear or unset the WARNINGS_ARE_ERRORS environment variable to ignore warnings."
exit 1
fi
fi
}
Retry() {
if "$@"; then
return 0
fi
for wait_time in 5 20 30 60; do
echo "Command failed, retrying in ${wait_time} ..."
sleep ${wait_time}
if "$@"; then
return 0
fi
done
echo "Failed all retries!"
exit 1
}
COMMAND=$1
echo "Running command: ${COMMAND}"
shift
case $COMMAND in
##
## Bootstrap a new core system
"bootstrap")
Bootstrap
;;
##
## Ensure devtools is loaded (implicitly called)
"install_devtools"|"devtools_install")
EnsureDevtools
;;
##
## Ensure remotes is loaded (implicitly called)
"install_remotes"|"remotes_install")
EnsureRemotes
;;
##
## Install a binary deb package via apt-get
"install_aptget"|"aptget_install")
AptGetInstall "$@"
;;
##
## Install a binary deb package via a curl call and local dpkg -i
"install_dpkgcurl"|"dpkgcurl_install")
DpkgCurlInstall "$@"
;;
##
## Install an R dependency from CRAN
"install_r"|"r_install")
RInstall "$@"
;;
##
## Install an R dependency from Bioconductor
"install_bioc"|"bioc_install")
BiocInstall "$@"
;;
##
## Install an R dependency as a binary (via c2d4u PPA)
"install_r_binary"|"r_binary_install")
RBinaryInstall "$@"
;;
##
## Install a package from github sources (needs remotes)
"install_github"|"github_package")
InstallGithub "$@"
;;
##
## Install package dependencies from CRAN (needs remotes)
"install_deps")
InstallDeps
;;
##
## Install package dependencies from Bioconductor and CRAN (needs devtools)
"install_bioc_deps")
InstallBiocDeps
;;
##
## Run the actual tests, ie R CMD check
"run_tests")
RunTests
;;
##
## Dump information about installed packages
"dump_sysinfo")
DumpSysinfo
;;
##
## Dump build or check logs
"dump_logs")
DumpLogs
;;
##
## Dump selected build or check logs
"dump_logs_by_extension")
DumpLogsByExtension "$@"
;;
esac