From 8f8a646d031d9932ca4a19d418be35a2e1f313ea Mon Sep 17 00:00:00 2001 From: brown-jason <42772095+brown-jason@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:06:41 -0400 Subject: [PATCH] 151 cran 310 release (#152) * updated docs * added github to buildignore * added documentation for invitrodb_dd data file * updated version number * fixes variable binding note * moved vdiffr from imports to suggests since it is only used in tests and not required to use the package normally * added default multi for old style plots * accepted and resolved minor snapshot test difference based on testing environment * updated news and cran-comments * added additional rhub to cran comments --- .Rbuildignore | 1 + DESCRIPTION | 8 +- NAMESPACE | 2 + NEWS | 6 + R/data.R | 11 + R/mc6.R | 2 +- R/sc2.R | 2 +- R/tcplCytoPt.R | 2 +- R/tcplDefine.R | 4 + R/tcplFit2.R | 5 +- R/tcplLoadData.R | 5 +- R/tcplPlot.R | 5 +- cran-comments.md | 30 +- man/MC2_Methods.Rd | 4 + man/MC4_Methods.Rd | 5 + man/invitrodb_dd.Rd | 24 ++ .../_snaps/tcplPlot/test-output-482273.svg | 354 +++++++++--------- 17 files changed, 276 insertions(+), 194 deletions(-) create mode 100644 man/invitrodb_dd.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 17a3ec91..de8ac21e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,4 @@ cran-comments.md ^CRAN-SUBMISSION$ ^data-raw$ ^LICENSE\.md$ +^\.github$ diff --git a/DESCRIPTION b/DESCRIPTION index ec366879..1491030d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tcpl Title: ToxCast Data Analysis Pipeline -Version: 3.0.1 +Version: 3.1.0 Authors@R: c( person("Richard S", "Judson",role = c("ctb","ths"), email = "Judson.Richard@epa.gov"), person("Dayne L", "Filer", role = "aut",email = "dayne.filer@gmail.com"), @@ -42,8 +42,7 @@ Imports: tcplfit2, ggplot2, gridExtra, - stringr, - vdiffr + stringr Suggests: roxygen2, knitr, @@ -55,7 +54,8 @@ Suggests: viridis, kableExtra, colorspace, - magrittr + magrittr, + vdiffr License: MIT + file LICENSE LazyData: true RoxygenNote: 7.2.3 diff --git a/NAMESPACE b/NAMESPACE index debb3229..522d9aff 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -81,6 +81,7 @@ importFrom(dplyr,rowwise) importFrom(dplyr,select) importFrom(dplyr,summarise) importFrom(dplyr,tibble) +importFrom(dplyr,ungroup) importFrom(ggplot2,aes) importFrom(ggplot2,element_blank) importFrom(ggplot2,element_text) @@ -147,6 +148,7 @@ importFrom(tcplfit2,tcplfit2_core) importFrom(tcplfit2,tcplhit2_core) importFrom(tidyr,pivot_longer) importFrom(tidyr,pivot_wider) +importFrom(utils,data) importFrom(utils,read.csv) importFrom(utils,read.table) importFrom(utils,tail) diff --git a/NEWS b/NEWS index 13ed24f2..2a9ba09a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +tcpl v3.1.0 +============== +*updated vignettes for tcplfit2 fitting +*bidirectional fitting by default +*this is the version used to create invitrodb v4.1 + tcpl v3.0.1 ============== *fixes error from ggplot2 diff --git a/R/data.R b/R/data.R index da447c44..f602d436 100644 --- a/R/data.R +++ b/R/data.R @@ -459,3 +459,14 @@ #' } #' } "sc_vignette" + + +#' Short descriptions of fields for different tables are stored in a data dictionary. +#' @format A data frame with 44 rows and 3 variables: +#' \describe{ +#' \item{invitrodb_table}{Table of the data dictionary} +#' \item{invitrodb_field}{Field of the data dictionary} +#' \item{description}{Description} +#' } +#' @source ToxCast database +"invitrodb_dd" diff --git a/R/mc6.R b/R/mc6.R index 09cb6262..7c4ba0d9 100644 --- a/R/mc6.R +++ b/R/mc6.R @@ -20,7 +20,7 @@ mc6 <- function(ae, wr = FALSE) { ## Variable-binding to pass R CMD Check - mthd_id <- m4id <- m5id <- lval <- rval <- J <- mthd <- bmad <- cell_viability_assay <- NULL + modl <- aeid <- mthd_id <- m4id <- m5id <- lval <- rval <- J <- mthd <- bmad <- cell_viability_assay <- NULL #owarn <- getOption("warn") #options(warn = 1) diff --git a/R/sc2.R b/R/sc2.R index bb8b7a09..e440e010 100644 --- a/R/sc2.R +++ b/R/sc2.R @@ -23,7 +23,7 @@ sc2 <- function(ae, wr = FALSE) { ## Variable-binding to pass R CMD Check - bmad <- resp <- wllt <- tmp <- spid <- logc <- hitc <- max_med <- NULL + max_tmp <- bmad <- resp <- wllt <- tmp <- spid <- logc <- hitc <- max_med <- NULL owarn <- getOption("warn") options(warn = 1) diff --git a/R/tcplCytoPt.R b/R/tcplCytoPt.R index d0b05366..4a054b1e 100644 --- a/R/tcplCytoPt.R +++ b/R/tcplCytoPt.R @@ -114,7 +114,7 @@ tcplCytoPt <- function(chid = NULL, aeid = NULL, flag = TRUE, ## Variable-binding to pass R CMD Check ac50var <- hitc <- code <- chnm <- casn <- used_in_global_mad_calc <- nhit <- modl <- NULL - ntst <- global_mad <- cyto_pt <- med <- cyto_pt_um <- lower_bnd_um <- burstpct <- NULL + top <- ntst <- global_mad <- cyto_pt <- med <- cyto_pt_um <- lower_bnd_um <- burstpct <- NULL cat("1: Checking if aeid or chid is specified\n") if (!is.null(aeid) & !is.vector(aeid)) { diff --git a/R/tcplDefine.R b/R/tcplDefine.R index 3505ef0c..202c4707 100644 --- a/R/tcplDefine.R +++ b/R/tcplDefine.R @@ -47,14 +47,18 @@ #' parameters. #' #' @import data.table +#' @importFrom utils data +#' #' @export tcplDefine <- function(val = NULL) { drvr <- getOption("TCPL_DRVR") + invitrodb_dd <- NULL # example driver if (drvr == "example"){ + data("invitrodb_dd", envir=environment()) dd <- invitrodb_dd[] diff --git a/R/tcplFit2.R b/R/tcplFit2.R index b141366d..335adbfc 100644 --- a/R/tcplFit2.R +++ b/R/tcplFit2.R @@ -51,12 +51,13 @@ tcplFit2 <- function(dat, #' #' #' @return Data.table with key value pairs of hitcalling parameters -#' @importFrom dplyr %>% filter group_by summarise left_join inner_join select rowwise mutate pull +#' @importFrom dplyr %>% filter group_by summarise left_join inner_join select rowwise mutate pull ungroup #' @importFrom tidyr pivot_longer #' @importFrom tcplfit2 tcplhit2_core tcplHit2 <- function(mc4, coff) { #variable binding + top <- a <- b <- ga <- la <- p <- tp <- logc_min <- logc_max <- fitc <- NULL model <- m4id <-model_param <-model_val <-resp <- NULL params <-conc <-bmed <-onesd <-df <-aeid <- NULL fit_method <-hitcall <-cutoff <-top_over_cutoff <-bmd <-hit_val <- NULL @@ -103,7 +104,7 @@ tcplHit2 <- function(mc4, coff) { res <- res %>% rowwise() %>% mutate(ac95 = tcplfit2::acy(.95 * top, list(a = a, b = b, ga = ga, la = la, p = p, q = q, tp = tp)[!is.na(list(a = a, b = b, ga = ga, la = la, p = p, q = q, tp = tp))], fit_method)) %>% - ungroup() + dplyr::ungroup() res <- res %>% mutate(coff_upper = 1.2 * cutoff, coff_lower = .8 * cutoff) res <- res %>% left_join(mc4 %>% select(m4id, logc_min, logc_max) %>% unique(), by = "m4id") %>% diff --git a/R/tcplLoadData.R b/R/tcplLoadData.R index 18e333a4..2882cc7c 100644 --- a/R/tcplLoadData.R +++ b/R/tcplLoadData.R @@ -75,12 +75,13 @@ #' #' @import data.table #' @importFrom tidyr pivot_wider +#' @importFrom utils data #' @export tcplLoadData <- function(lvl, fld = NULL, val = NULL, type = "mc", add.fld = TRUE) { #variable binding model <- model_param <- model_val <- NULL - hit_param <- hit_val <- NULL + hit_param <- hit_val <- sc_vignette <- mc_vignette <- NULL if (length(lvl) > 1 | length(type) > 1) { stop("'lvl' & 'type' must be of length 1.") @@ -91,6 +92,7 @@ tcplLoadData <- function(lvl, fld = NULL, val = NULL, type = "mc", add.fld = TRU drvr <- getOption("TCPL_DRVR") if (drvr == "example"){ if (type == "sc"){ + data("sc_vignette", envir = environment()) if (lvl == 0L) { sc0 <- sc_vignette[["sc0"]] sc0 <- sc0[,c("s0id","spid","acid","apid","rowi","coli","wllt","wllq","conc","rval","srcf")] @@ -118,6 +120,7 @@ tcplLoadData <- function(lvl, fld = NULL, val = NULL, type = "mc", add.fld = TRU } if (type == "mc" ) { + data("mc_vignette", envir = environment()) if (lvl == 0L) { mc0 <- mc_vignette[["mc0"]] mc0 <- mc0[,c("m0id","spid","acid","apid","rowi","coli","wllt","wllq","conc","rval","srcf")] diff --git a/R/tcplPlot.R b/R/tcplPlot.R index 42ef8abf..8f118d4f 100644 --- a/R/tcplPlot.R +++ b/R/tcplPlot.R @@ -55,7 +55,7 @@ #' options(conf_store) tcplPlot <- function(lvl = 5, fld = "m4id", val = NULL, type = "mc", by = NULL, output = c("console", "pdf", "png", "jpg", "svg", "tiff"), fileprefix = paste0("tcplPlot_", Sys.Date()), multi = NULL, verbose = FALSE, nrow = NULL, ncol = NULL, dpi = 600) { #variable binding - resp <- NULL + conc_unit <- bmd <- resp <- NULL # check_tcpl_db_schema is a user-defined function found in v3_schema_functions.R file if (check_tcpl_db_schema()) { # check that input combination is unique @@ -148,6 +148,9 @@ tcplPlot <- function(lvl = 5, fld = "m4id", val = NULL, type = "mc", by = NULL, } } else { + if(is.null(multi)){ + multi <- FALSE + } if (length(lvl) > 1 | !lvl %in% 4:7) stop("invalid lvl input.") if (length(output) > 1) output <- output[1] diff --git a/cran-comments.md b/cran-comments.md index 90c1e3d3..0a155abb 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,20 +1,38 @@ -Minor release for fixing errors on CRAN -Some small bug fixes included +3.1.0 Release integrates package tcplfit2 bidirectional fitting a major update that impacts resulting invitrodb database ## Test environments -* local Windows 10 install, R 4.2.1 -* R Under development (unstable) (2022-10-11 r83083 ucrt) +* local Windows 10 install, R 4.2.2 +* R Under development (unstable) (2023-10-04 r85267 ucrt) +* Rhub Windows Server 2022, R-devel, 64 bit * Rhub Fedora Linux, R-devel, clang, gfortran * Rhub Ubuntu Linux 20.04.1 LTS, R-release, GCC -* Rhub Windows Server 2022, R-devel, 64 bit ## rhub CMD check results -- Note appears to be related to testing environment +- All notes appear to be related to testing (rhub) environment +Found the following (possibly) invalid URLs: + URL: https://www.epa.gov/chemical-research/exploring-toxcast-data-downloadable-data + From: inst/doc/Data_retrieval.html + inst/doc/Introduction_Appendices.html + Status: 403 + Message: Forbidden + URL: https://www.epa.gov/chemical-research/toxicity-forecasting + From: inst/doc/Introduction_Appendices.html + Status: 403 + Message: Forbidden +* checking HTML version of manual ... [13s] NOTE +Skipping checking math rendering: package 'V8' unavailable +* checking for non-standard things in the check directory ... NOTE +Found the following files/directories: + ''NULL'' * checking for detritus in the temp directory ... NOTE Found the following files/directories: 'lastMiKTeXException' +## win devel check results +1 NOTE - Found the following (possibly) invalid URLs... +All links appear to work correctly when hyperlinked from the vignette, similar note to the rhub testing + ## local R CMD check results 0 ERRORs | 0 WARNINGs | 0 NOTES. diff --git a/man/MC2_Methods.Rd b/man/MC2_Methods.Rd index 9324ee74..f73165c5 100644 --- a/man/MC2_Methods.Rd +++ b/man/MC2_Methods.Rd @@ -63,6 +63,10 @@ available in the package vignette, "Data_processing." \subsection{Aggregation Methods}{ \describe{ + \item{agg.mean.rep.apid}{Aggregate technical test replicates (wllt=t) by taking the plate-wise mean per sample id (spid), assay plate (apid), and concentration index (cndx).} + \item{agg.median.rep.apid}{Aggregate technical test replicates (wllt=t) by taking the plate-wise median per sample id (spid), assay plate (apid), and concentration index (cndx).} + \item{agg.percent.rep.spid}{Use for binary data. Aggregate technical replicates as percentage by taking the sum of hits relative to total replicates per sample id (spid) and concentration index (cndx); cval = (sum(rval)/.N)*100.} + \item{agg.percent.rep.spid.min1}{Use for binary data. Aggregate technical replicates as percentage by taking the sum of hits relative to total replicates per per sample id (spid) and concentration index (cndx), where there is more than one replicate; cval = (sum(rval)/.N)*100, where .N>1.} \item{agg.mean.rep.apid}{Aggregate technical replicates by taking the plate-wise mean per sample id (spid), assay plate (apid), and concentration index (cndx).} \item{agg.median.rep.apid}{Aggregate technical replicates by taking the plate-wise median per diff --git a/man/MC4_Methods.Rd b/man/MC4_Methods.Rd index b304b92a..2f6290aa 100644 --- a/man/MC4_Methods.Rd +++ b/man/MC4_Methods.Rd @@ -51,6 +51,11 @@ available in the package vignette, "Data_processing." processing.} \item{bidirectional.false}{Limits bidirectional fitting and processes data in positive analysis direction only. Use for gain-of-signal or inverted data.} + \item{bmad5.onesd16.static}{Replace baseline median absolute deviation + (bmad) with 5 and one standard deviation (osd) of the normalized response + for test compound wells (wllt = t) with a concentration index (cndx) of 1 + or 2 with 16. Typically used for binary data where values would otherwise + be 0; non-zero values are required for tcplfit2 processing.} } } diff --git a/man/invitrodb_dd.Rd b/man/invitrodb_dd.Rd new file mode 100644 index 00000000..1102f906 --- /dev/null +++ b/man/invitrodb_dd.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{invitrodb_dd} +\alias{invitrodb_dd} +\title{Short descriptions of fields for different tables are stored in a data dictionary.} +\format{ +A data frame with 44 rows and 3 variables: +\describe{ + \item{invitrodb_table}{Table of the data dictionary} + \item{invitrodb_field}{Field of the data dictionary} + \item{description}{Description} +} +} +\source{ +ToxCast database +} +\usage{ +invitrodb_dd +} +\description{ +Short descriptions of fields for different tables are stored in a data dictionary. +} +\keyword{datasets} diff --git a/tests/testthat/_snaps/tcplPlot/test-output-482273.svg b/tests/testthat/_snaps/tcplPlot/test-output-482273.svg index a199248f..4fd6daf6 100644 --- a/tests/testthat/_snaps/tcplPlot/test-output-482273.svg +++ b/tests/testthat/_snaps/tcplPlot/test-output-482273.svg @@ -21,186 +21,186 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.0 -0.3 -0.6 - - - - - - - -0.1 -1.0 -10.0 -100.0 -Concentration (uM) -Log2 Fold Induction - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Winning Model -(exp2) -Losing Models -Cutoff -BMD -AC50 -DTXSID80379721 1H,1H,6H,6H-Perfluorohexane-1,6-diol diacrylate -SPID:01504209 AEID:80 AENM:ATG_GLI_CIS_up -M4ID:482273 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.0 +0.3 +0.6 + + + + + + + +0.1 +1.0 +10.0 +100.0 +Concentration (uM) +Log2 Fold Induction + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Winning Model +(exp2) +Losing Models +Cutoff +BMD +AC50 +DTXSID80379721 1H,1H,6H,6H-Perfluorohexane-1,6-diol diacrylate +SPID:01504209 AEID:80 AENM:ATG_GLI_CIS_up +M4ID:482273