Skip to content

Commit

Permalink
resolve CRAN notes on debian with data.table usage
Browse files Browse the repository at this point in the history
to skip computationally intensive tests and limit DT threads in vignette and testthat
  • Loading branch information
certara-jcraig committed Oct 30, 2023
1 parent 2d88c91 commit 86aeff6
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 30 deletions.
7 changes: 5 additions & 2 deletions R/vpcstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ simulated.tidyvpcobj <- function(o, data, ysim, ..., xsim) {
#' values for lower/upper limit of quantification. Logicals for \code{blq} and \code{alq} are returned that indicate whether the DV value lies below/above limit
#' of quantification.
#' @examples
#' \donttest{
#' require(magrittr)
#'
#' vpc <- observed(obs_data, x=TIME, y=DV) %>%
Expand All @@ -147,7 +148,7 @@ simulated.tidyvpcobj <- function(o, data, ysim, ..., xsim) {
#' stratify(~ STUDY) %>%
#' binning(bin = "kmeans", nbins = 4) %>%
#' vpcstats()
#'
#' }
#'
#' @seealso \code{\link{observed}} \code{\link{simulated}} \code{\link{stratify}} \code{\link{predcorrect}} \code{\link{binning}} \code{\link{binless}} \code{\link{vpcstats}}

Expand Down Expand Up @@ -245,6 +246,7 @@ censoring.tidyvpcobj <- function(o, blq, lloq, alq, uloq, data=o$data, ...) {
#' is \code{obs} split by unique levels of stratification variable(s). Resulting datasets are of class object \code{data.frame}
#' and \code{data.table}.
#' @examples
#' \donttest{
#' require(magrittr)
#'
#' vpc <- observed(obs_data, x=TIME, y=DV) %>%
Expand All @@ -259,6 +261,7 @@ censoring.tidyvpcobj <- function(o, blq, lloq, alq, uloq, data=o$data, ...) {
#' stratify(~ GENDER + STUDY) %>%
#' binning(bin = "centers", centers = c(1,3,5,7,10)) %>%
#' vpcstats()
#' }
#'
#' @seealso \code{\link{observed}} \code{\link{simulated}} \code{\link{censoring}} \code{\link{predcorrect}} \code{\link{binning}} \code{\link{binless}} \code{\link{vpcstats}}

Expand Down Expand Up @@ -557,6 +560,7 @@ binning.tidyvpcobj <- function(o, bin, data=o$data, xbin="xmedian", centers, bre
#' prediction corrected VPC is to be performed, the \code{predcor.log} logical indicating whether the DV is on a log-scale, and the \code{pred} prediction
#' column from the original data.
#' @examples
#' \donttest{
#' require(magrittr)
#'
#' obs_data <- obs_data[MDV == 0]
Expand All @@ -573,7 +577,6 @@ binning.tidyvpcobj <- function(o, bin, data=o$data, xbin="xmedian", centers, bre
#' predcorrect(pred=PRED) %>%
#' vpcstats()
#'
#' \donttest{
#' # For binless loess prediction corrected, use predcorrect() before
#' # binless() and set loess.ypc = TRUE
#'
Expand Down
3 changes: 2 additions & 1 deletion man/censoring.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/predcorrect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/stratify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
library(testthat)
library(tidyvpc)

registered_threads <- data.table::getDTthreads()
data.table::setDTthreads(2)
on.exit(data.table::setDTthreads(registered_threads))
test_check("tidyvpc")
2 changes: 2 additions & 0 deletions tests/testthat/test-binless.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ test_that("cont vpc predcorrect binless vpcstats are correct", {
})

test_that("cont vpc binless censoring vpcstats are correct", {
skip_on_cran()
obs_data <- obs_data[MDV == 0]
sim_data <- sim_data[MDV == 0]

Expand Down Expand Up @@ -200,6 +201,7 @@ test_that("binless.tidyvpcobj returns correct errors and warnings", {

test_that("binless.tidyvpcobj uses supplied lambda and span if optimize = FALSE", {
# continuous VPC
skip_on_cran()
obs_data <- obs_data[MDV == 0]
sim_data <- sim_data[MDV == 0]
obs_data$PRED <- sim_data[REP == 1, PRED]
Expand Down
4 changes: 4 additions & 0 deletions vignettes/tidyvpc_cat.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ library(data.table)
set.seed(1014)
```

```{r, echo=FALSE}
data.table::setDTthreads(2)
```


## Introduction

Expand Down
34 changes: 9 additions & 25 deletions vignettes/tidyvpc_cont.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ library(magrittr)
set.seed(1014)
```

```{r, echo=FALSE}
data.table::setDTthreads(2)
```


## Introduction

**When deriving a Visual Predictive Check (VPC) you must:**
Expand Down Expand Up @@ -232,27 +237,7 @@ vpc <- observed(obs_data, x=TIME, y=DV) %>%
plot(vpc, censoring.type = "blq")
```

Censoring using `LLOQ` variable in the data.

First, let's add an LLOQ variable to the observed data.
```{r}
obs_data$LLOQ <- 50
```

Then, we'll specify lower limit of quantification as the unquoted variable name `LLOQ` in our data. Let's also provide our own lambda values.

```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE}
vpc <- observed(obs_data, x=TIME, y=DV) %>%
simulated(sim_data, y=DV) %>%
censoring(blq=(DV < LLOQ), lloq=LLOQ) %>%
binless(optimize = FALSE, lambda = c(1.5, 2.5, 1.7)) %>%
vpcstats()
plot(vpc, censoring.type = "blq")
```


The `tidyvpc` package also allows you to use different LLOQ for each level of stratification variable. We'll set an `LLOQ` value of `50` for `Study A` and `25` for `Study B` and calculate statistics at 10%, 50%, 90% quantiles.
The `tidyvpc` package also allows you to use LLOQ values within your data and different LLOQ for each level of stratification variable. We'll set an `LLOQ` value of `50` for `Study A` and `25` for `Study B` and calculate statistics at 10%, 50%, 90% quantiles.

```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE}
obs_data$LLOQ <- obs_data[, ifelse(STUDY == "Study A", 50, 25)]
Expand All @@ -269,7 +254,7 @@ plot(vpc, censoring.type = "blq", facet.scales = "fixed")

The `tidyvpc` package also supports usage of `censoring()` with ALQ data, similar to above usage with BLQ data.

```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE}
```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE, eval = FALSE}
obs_data$ULOQ <- obs_data[, ifelse(STUDY == "Study A", 125, 100)]
vpc <- observed(obs_data, x = TIME, y = DV) |>
Expand All @@ -278,11 +263,10 @@ vpc <- observed(obs_data, x = TIME, y = DV) |>
stratify(~ STUDY) |>
binning(bin = NTIME) |>
vpcstats(qpred = c(0.1, 0.5, 0.9))
plot(vpc, censoring.type = "alq")
```

To plot the above `vpc` and include the percentage of ALQ plot, you'd run `plot(vpc, censoring.type = "alq")`.

If using `censoring()` with both ALQ and BLQ data, set `censoring.type = "both"` in the `plot()` function to display both percentage of BLQ and ALQ plots as a grid in the resulting VPC plot.

```{r fig.width = 9, fig.height = 6, out.width=640, warning = FALSE}
Expand Down
4 changes: 4 additions & 0 deletions vignettes/tidyvpc_nlmixr2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ knitr::opts_chunk$set(
)
```

```{r, echo=FALSE}
data.table::setDTthreads(2)
```

# Introduction

`tidyvpc` and `nlmixr2` can work together seamlessly. The information below
Expand Down

0 comments on commit 86aeff6

Please sign in to comment.