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

(v0.7.1.9021) CI fix for resistance_predict

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-08-04 10:48:41 +02:00
parent 4f3ef53c78
commit d6ab3896a1
16 changed files with 68 additions and 34 deletions

View File

@ -118,7 +118,7 @@ coverage:
# install missing and outdated packages # install missing and outdated packages
- Rscript -e 'source(".gitlab-ci.R"); gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE, install_pkgdown = FALSE)' - Rscript -e 'source(".gitlab-ci.R"); gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE, install_pkgdown = FALSE)'
# codecov token is set in https://gitlab.com/msberends/AMR/settings/ci_cd # codecov token is set in https://gitlab.com/msberends/AMR/settings/ci_cd
- Rscript -e "cc <- covr::package_coverage(); covr::codecov(coverage = cc, token = '$codecov', exclusions = c('R/atc_online.R', 'R/mo_source.R', 'R/resistance_predict.R')); cat('Code coverage:', covr::percent_coverage(cc))" - Rscript -e "cc <- covr::package_coverage()); covr::codecov(coverage = cc, token = '$codecov'); cat('Code coverage:', covr::percent_coverage(cc))"
coverage: '/Code coverage: \d+\.\d+/' coverage: '/Code coverage: \d+\.\d+/'
pages: pages:

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 0.7.1.9020 Version: 0.7.1.9021
Date: 2019-08-03 Date: 2019-08-04
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(
person( person(

View File

@ -1,4 +1,4 @@
# AMR 0.7.1.9020 # AMR 0.7.1.9021
### Breaking ### Breaking
* Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. We decided to create a new package for data cleaning and checking and it perfectly fits the `freq()` function. The [`clean`](https://github.com/msberends/clean) package is available on CRAN and will be installed automatically when updating the `AMR` package, that now imports it. In a later stage, the `skewness()` and `kurtosis()` functions will be moved to the `clean` package too. * Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. We decided to create a new package for data cleaning and checking and it perfectly fits the `freq()` function. The [`clean`](https://github.com/msberends/clean) package is available on CRAN and will be installed automatically when updating the `AMR` package, that now imports it. In a later stage, the `skewness()` and `kurtosis()` functions will be moved to the `clean` package too.

View File

@ -67,7 +67,10 @@ get_locale <- function() {
} }
lang <- Sys.getlocale("LC_COLLATE") lang <- Sys.getlocale("LC_COLLATE")
# grepl with case = FALSE is faster than like
# Check the locale settings for a start with one of these languages:
# grepl() with ignore.case = FALSE is faster than %like%
if (grepl("^(English|en_|EN_)", lang, ignore.case = FALSE)) { if (grepl("^(English|en_|EN_)", lang, ignore.case = FALSE)) {
# as first option to optimise speed # as first option to optimise speed
"en" "en"

View File

@ -28,8 +28,8 @@
#' @param year_max highest year to use in the prediction model, defaults to 10 years after today #' @param year_max highest year to use in the prediction model, defaults to 10 years after today
#' @param year_every unit of sequence between lowest year found in the data and \code{year_max} #' @param year_every unit of sequence between lowest year found in the data and \code{year_max}
#' @param minimum minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model. #' @param minimum minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.
#' @param model the statistical model of choice. Defaults to a generalised linear regression model with binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for valid options. #' @param model the statistical model of choice. Defaults to a generalised linear regression model with binomial distribution (i.e. using \code{\link{glm}(..., family = \link{binomial})}), assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for valid options.
#' @param I_as_S a logical to indicate whether values \code{I} should be treated as \code{S} #' @param I_as_S a logical to indicate whether values \code{I} should be treated as \code{S} (will otherwise be treated as \code{R})
#' @param preserve_measurements a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be \code{NA}. #' @param preserve_measurements a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be \code{NA}.
#' @param info a logical to indicate whether textual analysis should be printed with the name and \code{\link{summary}} of the statistical model. #' @param info a logical to indicate whether textual analysis should be printed with the name and \code{\link{summary}} of the statistical model.
#' @param main title of the plot #' @param main title of the plot
@ -165,15 +165,16 @@ resistance_predict <- function(x,
df <- x %>% df <- x %>%
mutate_at(col_ab, as.rsi) %>% mutate_at(col_ab, as.rsi) %>%
mutate_at(col_ab, droplevels) %>% mutate_at(col_ab, droplevels)
mutate_at(col_ab, ~(
if (I_as_S == TRUE) { if (I_as_S == TRUE) {
gsub("I", "S", .) df <- df %>%
mutate_at(col_ab, ~gsub("I", "S", .))
} else { } else {
# then I as R # then I as R
gsub("I", "R", .) df <- df %>%
mutate_at(col_ab, ~gsub("I", "R", .))
} }
)) %>% df <- df %>%
filter_at(col_ab, all_vars(!is.na(.))) %>% filter_at(col_ab, all_vars(!is.na(.))) %>%
mutate(year = pull(., col_date) %>% year()) %>% mutate(year = pull(., col_date) %>% year()) %>%
group_by_at(c('year', col_ab)) %>% group_by_at(c('year', col_ab)) %>%

View File

@ -18,4 +18,3 @@ coverage:
ignore: ignore:
- "R/atc_online.R" - "R/atc_online.R"
- "R/mo_source.R" - "R/mo_source.R"
- "R/resistance_predict.R"

View File

@ -78,7 +78,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <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.7.1.9020</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9021</span>
</span> </span>
</div> </div>

View File

@ -78,7 +78,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <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.7.1.9020</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9021</span>
</span> </span>
</div> </div>

View File

@ -78,7 +78,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <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.7.1.9020</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9021</span>
</span> </span>
</div> </div>

View File

@ -42,7 +42,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <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.7.1.9020</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9021</span>
</span> </span>
</div> </div>

View File

@ -78,7 +78,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <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.7.1.9020</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9021</span>
</span> </span>
</div> </div>
@ -225,9 +225,9 @@
</div> </div>
<div id="amr-0-7-1-9020" class="section level1"> <div id="amr-0-7-1-9021" class="section level1">
<h1 class="page-header"> <h1 class="page-header">
<a href="#amr-0-7-1-9020" class="anchor"></a>AMR 0.7.1.9020<small> Unreleased </small> <a href="#amr-0-7-1-9021" class="anchor"></a>AMR 0.7.1.9021<small> Unreleased </small>
</h1> </h1>
<div id="breaking" class="section level3"> <div id="breaking" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">
@ -1198,7 +1198,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<div id="tocnav"> <div id="tocnav">
<h2>Contents</h2> <h2>Contents</h2>
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li><a href="#amr-0-7-1-9020">0.7.1.9020</a></li> <li><a href="#amr-0-7-1-9021">0.7.1.9021</a></li>
<li><a href="#amr-0-7-1">0.7.1</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> <li><a href="#amr-0-7-0">0.7.0</a></li>
<li><a href="#amr-0-6-1">0.6.1</a></li> <li><a href="#amr-0-6-1">0.6.1</a></li>

View File

@ -78,7 +78,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <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.7.1.9020</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9021</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <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.7.1.9015</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9021</span>
</span> </span>
</div> </div>
@ -284,11 +284,11 @@
</tr> </tr>
<tr> <tr>
<th>model</th> <th>model</th>
<td><p>the statistical model of choice. Defaults to a generalised linear regression model with binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for valid options.</p></td> <td><p>the statistical model of choice. Defaults to a generalised linear regression model with binomial distribution (i.e. using <code><a href='https://www.rdocumentation.org/packages/stats/topics/glm'>glm</a>(..., family = <a href='https://www.rdocumentation.org/packages/stats/topics/family'>binomial</a>)</code>), assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for valid options.</p></td>
</tr> </tr>
<tr> <tr>
<th>I_as_S</th> <th>I_as_S</th>
<td><p>a logical to indicate whether values <code>I</code> should be treated as <code>S</code></p></td> <td><p>a logical to indicate whether values <code>I</code> should be treated as <code>S</code> (will otherwise be treated as <code>R</code>)</p></td>
</tr> </tr>
<tr> <tr>
<th>preserve_measurements</th> <th>preserve_measurements</th>

View File

@ -38,9 +38,9 @@ ggplot_rsi_predict(x, main = paste("Resistance Prediction of", x_name),
\item{minimum}{minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.} \item{minimum}{minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.}
\item{model}{the statistical model of choice. Defaults to a generalised linear regression model with binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for valid options.} \item{model}{the statistical model of choice. Defaults to a generalised linear regression model with binomial distribution (i.e. using \code{\link{glm}(..., family = \link{binomial})}), assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for valid options.}
\item{I_as_S}{a logical to indicate whether values \code{I} should be treated as \code{S}} \item{I_as_S}{a logical to indicate whether values \code{I} should be treated as \code{S} (will otherwise be treated as \code{R})}
\item{preserve_measurements}{a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be \code{NA}.} \item{preserve_measurements}{a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be \code{NA}.}

View File

@ -0,0 +1,29 @@
# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Analysis #
# #
# SOURCE #
# https://gitlab.com/msberends/AMR #
# #
# LICENCE #
# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
# #
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# #
# This R package was created for academic research and was publicly #
# released in the hope that it will be useful, but it comes WITHOUT #
# ANY WARRANTY OR LIABILITY. #
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
# ==================================================================== #
context("extended.R")
test_that("extensions work", {
expect_identical(scale_type.mo(), "discrete")
expect_identical(scale_type.ab(), "discrete")
})

View File

@ -24,8 +24,10 @@ context("freq.R")
test_that("frequency table works", { test_that("frequency table works", {
library(clean) library(clean)
# mo # mo
expect_output(print(freq(septic_patients$mo))) expect_true(is.freq(freq(septic_patients$mo)))
# rsi # rsi
expect_output(print(freq(septic_patients$AMX))) expect_true(is.freq(freq(septic_patients$AMX)))
library(dplyr)
expect_true(is.freq(septic_patients %>% freq(mo)))
}) })