From a069f7fcabb847b072b89df6a0e008d5f5015689 Mon Sep 17 00:00:00 2001 From: ElizabethGilson Date: Fri, 20 Dec 2024 15:22:29 -0500 Subject: [PATCH 1/4] Update Vignette bug: mc4 summary stat plots not displaying Resolves #319 where the summary stat plots were not displaying by changing eval = TRUE. --- vignettes/Introduction_Appendices.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/Introduction_Appendices.Rmd b/vignettes/Introduction_Appendices.Rmd index 66a6c04..a4482fe 100644 --- a/vignettes/Introduction_Appendices.Rmd +++ b/vignettes/Introduction_Appendices.Rmd @@ -1360,7 +1360,7 @@ mc3 <- tcplPrepOtpt(mc3) For demonstration purposes, the mc_vignette R data object is provided in the package since the vignette is not directly connected to such a database. The mc_vignette object contains a subset of data from levels 3 through 5 from invitrodb v4.2. The following code loads the example mc3 data object, then plots the concentration-response series for an example spid with the summary estimates indicated. -```{r fig.align='center',message=FALSE,message=FALSE,fig.dim=c(8,10),eval = FALSE} +```{r fig.align='center',message=FALSE,message=FALSE,fig.dim=c(8,10),eval = TRUE} # Load the example data from the `tcpl` package. data(mc_vignette, package = 'tcpl') # Allocate the level 3 example data to `mc3`. From 6153d02597425e9dedcd1b5a97ad946075527d80 Mon Sep 17 00:00:00 2001 From: ElizabethGilson Date: Fri, 3 Jan 2025 16:37:50 -0500 Subject: [PATCH 2/4] Update Introduction_Appendices.Rmd to fix bug of plots not appearing --- vignettes/Introduction_Appendices.Rmd | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/vignettes/Introduction_Appendices.Rmd b/vignettes/Introduction_Appendices.Rmd index a4482fe..d4e4e6b 100644 --- a/vignettes/Introduction_Appendices.Rmd +++ b/vignettes/Introduction_Appendices.Rmd @@ -1370,6 +1370,9 @@ mc3_example[, logc := log10(conc)] # Obtain the MC4 example data. mc4_example <- mc_vignette[["mc4"]] # Obtain the minimum response observed and the 'logc' group - 'resp_min'. + + + level3_min <- mc3_example %>% dplyr::group_by(spid, chnm) %>% dplyr::filter(resp == min(resp)) %>% @@ -1423,11 +1426,12 @@ B <- mc3_example %>% theme(legend.position = 'bottom') # Plot the maximum mean & median responses at the related log-concentration - # 'max_mean' & 'max_mean_conc'. + C <- mc3_example %>% dplyr::filter(spid == "01504209") %>% ggplot(data = .,aes(logc, resp)) + geom_point(pch = 1, size = 2) + - geom_point(data = dplyr::filter(mc4, spid == "01504209"), + geom_point(data = dplyr::filter(mc4_example, spid == "01504209"), aes(x = log10(max_mean_conc), y = max_mean, col = 'maximum mean response'), alpha = 0.75, size = 2)+ @@ -1441,11 +1445,11 @@ C <- mc3_example %>% theme(legend.position = 'bottom') # Plot the maximum mean & median responses at the related log-concentration - # 'max_med' & 'max_med_conc'. -D <- example %>% +D <- mc3_example %>% dplyr::filter(spid == "01504209") %>% ggplot(data = ., aes(logc, resp)) + geom_point(pch = 1, size = 2) + - geom_point(data = dplyr::filter(mc4, spid == "01504209"), + geom_point(data = dplyr::filter(mc4_example, spid == "01504209"), aes(x = log10(max_med_conc), y = max_med, col = "maximum median response"), alpha = 0.75, size = 2)+ @@ -1484,11 +1488,11 @@ G <- mc3_example %>% dplyr::filter(spid == "01504209") %>% ggplot(data = ., aes(logc, resp)) + geom_point(pch = 1, size = 2) + - geom_vline(data = dplyr::filter(mc4, spid == "01504209"), + geom_vline(data = dplyr::filter(mc4_example, spid == "01504209"), aes(xintercept = log10(conc_min), col = 'minimum concentration'), lty = "dashed") + - geom_vline(data = dplyr::filter(mc4, spid == "01504209"), + geom_vline(data = dplyr::filter(mc4_example, spid == "01504209"), aes(xintercept = log10(conc_max), col = 'maximum concentration'), lty = "dashed") + @@ -1501,10 +1505,20 @@ G <- mc3_example %>% theme_bw() + theme(legend.position = 'bottom') ## Compile Summary Plots in One Figure ## +# +# gridExtra::grid.arrange( +# A, +# nrow = 3, ncol = 2, +# top = mc3[which(mc4[,spid] == "01504209"), aenm] +# ) + +# +aenm = "TOX21_ERa_BLA_Agonist_ratio" +spid = "01504209" gridExtra::grid.arrange( A,B,C,D,E,G, nrow = 3, ncol = 2, - top = mc3[which(mc4[,spid] == "01504209"), aenm] + top = mc3[which(mc4_example[,spid] == "01504209"), aenm] ) ``` From 1029cd143b95cf7918a5b5aa17f8e2569141294d Mon Sep 17 00:00:00 2001 From: ElizabethGilson Date: Wed, 8 Jan 2025 11:32:35 -0500 Subject: [PATCH 3/4] Add code folding and delete unnecessary comments --- vignettes/Introduction_Appendices.Rmd | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/vignettes/Introduction_Appendices.Rmd b/vignettes/Introduction_Appendices.Rmd index d4e4e6b..782a1a3 100644 --- a/vignettes/Introduction_Appendices.Rmd +++ b/vignettes/Introduction_Appendices.Rmd @@ -4,6 +4,7 @@ author: US EPA's Center for Computational Toxicology and Exposure ccte@epa.gov output: rmdformats::readthedown: fig_retina: false + code_folding: hide params: my_css: css/rmdformats.css vignette: > @@ -1505,14 +1506,7 @@ G <- mc3_example %>% theme_bw() + theme(legend.position = 'bottom') ## Compile Summary Plots in One Figure ## -# -# gridExtra::grid.arrange( -# A, -# nrow = 3, ncol = 2, -# top = mc3[which(mc4[,spid] == "01504209"), aenm] -# ) - -# + aenm = "TOX21_ERa_BLA_Agonist_ratio" spid = "01504209" gridExtra::grid.arrange( From fbdad6525bf6c13a947d3aaff31a75b5ffc185cc Mon Sep 17 00:00:00 2001 From: ElizabethGilson Date: Wed, 15 Jan 2025 11:52:34 -0500 Subject: [PATCH 4/4] Update Introduction_Appendices.Rmd code folding --- vignettes/Introduction_Appendices.Rmd | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/vignettes/Introduction_Appendices.Rmd b/vignettes/Introduction_Appendices.Rmd index 782a1a3..c3b84cd 100644 --- a/vignettes/Introduction_Appendices.Rmd +++ b/vignettes/Introduction_Appendices.Rmd @@ -4,21 +4,23 @@ author: US EPA's Center for Computational Toxicology and Exposure ccte@epa.gov output: rmdformats::readthedown: fig_retina: false - code_folding: hide + code_folding: show params: my_css: css/rmdformats.css + vignette: > %\VignetteIndexEntry{1. Introduction to tcpl and invitrodb} %\VignetteEngine{knitr::rmarkdown} %\usepackage[utf8]{inputenc} + --- ```{css, code = readLines(params$my_css), hide=TRUE, echo = FALSE} ``` ```{r, echo = FALSE, message = FALSE, warning = FALSE} -#devtools::load_all() #use this instead of lbrary(tcpl) when dev versions are installed locally +# devtools::load_all() #use this instead of lbrary(tcpl) when dev versions are installed locally library(tcpl) library(tcplfit2) # Data Formatting Packages # @@ -84,6 +86,7 @@ library(data.table) # recommended for interacting with tcpl data frame-like obje library(tcpl) ``` + After loading tcpl, the function tcplConf is used to establish connection to a database server or the API. While a typical database connection requires 5 parameters to be provided, using an API connection requires the user to only specify password (`pass`) and driver (`drvr`): ```{r setup-api, eval=FALSE} @@ -916,7 +919,7 @@ Once the Level 0 data are loaded, data processing occurs via the TRUE indicates successful processing, and (2) "l#_failed" containing the names of any ids that failed processing, where "#" is the processing level. +For tcplRun, the user must supply a starting level (slvl) and ending level (elvl). There are four phases of processing, as reflected by messages printed in console: (1) data for the given IDs are loaded, (2) the data are processed, (3) data for the same ID in subsequent levels are deleted, and (4) the processed data is written to the database. The 'outfile' parameter can give the user the option of printing this output text to a file. If an id fails while processing multiple levels, the function will not attempt to process the failed ids in subsequent levels. When finished processing, a list indicating the processing success of each ID is returned. For each level processed, the list will contain two elements: (1) "l#" a named Boolean vector where TRUE indicates successful processing, and (2) "l#_failed" containing the names of any ids that failed processing, where "#" is the processing level. Processing of multiple assay components or endpoints can be executed simultaneously. This is done with the internal utilization of the mclapply function from the parallel package. Parallel processing is done by id. Depending on the system environment and memory constraints, the user may wish to use more or less processing power. For processing on a Windows operating system, the default is $mc.cores = 1$, unless otherwise specified. For processing on a Unix-based operating system, the default is $mc.cores = NULL$ i.e. to utilize all cores except for one, which is necessary for 'overhead' processes. The user can specify more or less processing power by setting the "mc.cores" parameter to the desired level. **Note, this specification should meet the following criteria $1 \space \leq \space \mathit{mc.cores} \space \leq \space \mathit{detectCores()}-1$.** @@ -1265,7 +1268,7 @@ tcplMthdAssign(lvl = 3, # processing level mc3_res <- tcplRun(id = 1, slvl = 3, elvl = 3, type = "mc") ``` -Notice that MC3 processing takes an acid, not an aeid, as the input ID. As mentioned in previous sections, the user must will assign MC3 normalization methods by aeid then process by acid. The MC3 processing will attempt to process all endpoints for a given component. If one endpoint fails for any reason (e.g., does not have appropriate methods assigned), the processing for the entire component fails. +Notice that MC3 processing takes an acid, not an aeid, as the input ID. As mentioned in previous sections, the user must assign MC3 normalization methods by aeid then process by acid. The MC3 processing will attempt to process all endpoints for a given component. If one endpoint fails for any reason (e.g., does not have appropriate methods assigned), the processing for the entire component fails. ::: {.noticebox data-latex=""} @@ -1361,7 +1364,7 @@ mc3 <- tcplPrepOtpt(mc3) For demonstration purposes, the mc_vignette R data object is provided in the package since the vignette is not directly connected to such a database. The mc_vignette object contains a subset of data from levels 3 through 5 from invitrodb v4.2. The following code loads the example mc3 data object, then plots the concentration-response series for an example spid with the summary estimates indicated. -```{r fig.align='center',message=FALSE,message=FALSE,fig.dim=c(8,10),eval = TRUE} +```{r class.source="fold-hide", fig.align='center',message=FALSE,message=FALSE,fig.dim=c(8,10),eval = TRUE} # Load the example data from the `tcpl` package. data(mc_vignette, package = 'tcpl') # Allocate the level 3 example data to `mc3`. @@ -1626,7 +1629,7 @@ where $n$ is the number of observations. The following plots provide simulated concentration-response curves to illustrate the general curve shapes captured by tcplFit2 models. When fitting 'real-world' experimental data, the resulting curve shapes will minimize the error between the observed data and the concentration-response curve. Thus, the shape for each model fit may or may not reflect what is illustrated below: -```{r class.source="scroll-100",fig.align='center'} +```{r class.source="fold-hide", fig.align='center'} ## Example Data ## # example fit concentration series ex_conc <- seq(0.03, 100, length.out = 100) @@ -1719,7 +1722,7 @@ A subset of MC4 data is available within the mc_vignette **tcplMthdList** function returns methods available for processing at a specified level (i.e. step in the tcpl pipeline). The user defined function in the following code chunk retrieves and outputs all available methods for both the SC and MC data levels. -```{r mthd_list, fig.align='center',class.source="scroll-100",message=FALSE, eval=FALSE} +```{r mthd_list, fig.align='center',message=FALSE, eval=FALSE} # Create a function to list all available methods function (SC & MC). method_list <- function() { # Single Concentration @@ -2581,7 +2584,7 @@ mc0 <- tcplPrepOtpt(tcplLoadData(lvl = 0, fld = "acid", val = 1, type = "mc")) The goal of this section is to provide example quantitative metrics, such as z-prime and coefficient of variance, to evaluate assay performance relative to controls. -```{r mc0_aq, fig.align='center', class.source = "scroll-100", message=FALSE, eval=FALSE} +```{r mc0_aq, fig.align='center', message=FALSE, eval=FALSE} # Create a function to review assay quality metrics using indexed Level 0 data. aq <- function(ac){ # obtain level 1 multiple concentration data for specified acids @@ -2674,7 +2677,7 @@ sc2 <- tcplPrepOtpt(tcplLoadData(lvl = 2, fld = "aeid", val = aeids$aeid, type = ## - Load SC Methods -```{r sc2_mthd, fig.align='center',class.source="scroll-100",message=FALSE, eval=FALSE} +```{r sc2_mthd, fig.align='center',message=FALSE, eval=FALSE} # Create a function to load methods for single concentration data processing # steps for given aeids. sc_methods <- function(aeids) { @@ -2718,7 +2721,7 @@ mc5 <- tcplPrepOtpt(tcplLoadData(lvl = 5, fld = "aeid", val = aeids$aeid, type = ## - Load MC Methods -```{r mc5_methods, fig.align='center',class.source="scroll-100",message=FALSE, eval=FALSE} +```{r mc5_methods, fig.align='center',message=FALSE, eval=FALSE} # Create a function to load methods for MC data processing # for select aeids. mc_methods <- function(aeids) {