Skip to content

Commit

Permalink
version 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
richardjudson authored and cran-robot committed Mar 3, 2022
1 parent 64643bc commit b0a41b3
Show file tree
Hide file tree
Showing 108 changed files with 5,867 additions and 4,376 deletions.
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tcpl
Title: ToxCast Data Analysis Pipeline
Version: 2.0.2
Version: 2.1.0
Authors@R: c(
person("Richard S", "Judson",role = c("cre","ths"), email = "Judson.Richard@epa.gov"),
person("Dayne L", "Filer", role = "aut",email = "dayne.filer@gmail.com"),
Expand All @@ -17,16 +17,17 @@ Description: A set of tools for processing and modeling high-throughput and
can be used for diverse chemical screening efforts.
URL: https://github.com/USEPA/CompTox-ToxCast-tcpl
Depends: R (>= 3.2.0)
Imports: data.table (>= 1.9.4), DBI, RMySQL, numDeriv, RColorBrewer,
Imports: data.table (>= 1.9.4), DBI, RMariaDB, numDeriv, RColorBrewer,
utils, stats, methods, graphics, grDevices, sqldf
Suggests: roxygen2, knitr, prettydoc, rmarkdown, htmlTable
Suggests: roxygen2, knitr, prettydoc, rmarkdown, htmlTable, testthat
(>= 2.1.0)
License: GPL-2
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.1.2
VignetteBuilder: knitr
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2019-07-26 13:41:17 UTC; jbrown20
Packaged: 2022-03-03 17:58:01 UTC; jbrown20
Author: Richard S Judson [cre, ths],
Dayne L Filer [aut],
Jason Brown [ctb],
Expand All @@ -37,4 +38,4 @@ Author: Richard S Judson [cre, ths],
Katie Paul Friedman [ctb]
Maintainer: Richard S Judson <Judson.Richard@epa.gov>
Repository: CRAN
Date/Publication: 2019-07-26 14:50:02 UTC
Date/Publication: 2022-03-03 19:10:02 UTC
208 changes: 107 additions & 101 deletions MD5

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export(tcplMultiplot)
export(tcplObjCnst)
export(tcplObjGnls)
export(tcplObjHill)
export(tcplPlot)
export(tcplPlotFitc)
export(tcplPlotFits)
export(tcplPlotM4ID)
Expand All @@ -56,7 +57,7 @@ export(tcpldbStats)
import(DBI)
import(data.table)
importFrom(RColorBrewer,brewer.pal)
importFrom(RMySQL,MySQL)
importFrom(RMariaDB,MariaDB)
importFrom(grDevices,col2rgb)
importFrom(grDevices,colorRampPalette)
importFrom(grDevices,graphics.off)
Expand Down Expand Up @@ -99,6 +100,3 @@ importFrom(utils,read.table)
importFrom(utils,tail)
importFrom(utils,write.csv)
importFrom(utils,write.table)
importMethodsFrom(RMySQL,dbConnect)
importMethodsFrom(RMySQL,dbDisconnect)
importMethodsFrom(RMySQL,dbWriteTable)
14 changes: 14 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
tcpl v2.1.0
==============
*updated for release with toxcast invitrodb data
*added option to allow change in single conc bmad calculation

tcpl v2.0.3
==============
*Created tcplPlot a generic plotting function with call similar to tcplLoadData
*added option for concentration units to be different during plotting.
*fixed tcpllite bug for schema change
*filtered gnls from tcplCytopt
*updated to Rmariadb
*various bugfixes

tcpl v2.0.2
==============
* Updated tcplLoadChem to return dsstox substance ids
Expand Down
9 changes: 4 additions & 5 deletions R/blineShift.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@

blineShift <- function(resp, logc, wndw) {

wndw <- unique(wndw)[1]
if (any(is.na(resp))) return(resp)
if (length(unique(logc)) < 4) return(resp)

wndw <- unique(wndw)[1]
ordr <- order(logc)
resp <- resp[ordr]
logc <- logc[ordr]

uconc <- unique(logc)
nconc <- length(uconc)

if (any(is.na(resp))) return(resp)
if (nconc < 4) return(resp)


low <- 1:max(ceiling(nconc/4), 2)
rsub <- resp[which(logc %in% uconc[low])]
csub <- logc[which(logc %in% uconc[low])]
Expand Down
5 changes: 4 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
#' Chemical library of tested chemicals in the example datasets with the corresponding sample IDs.
#'
#'
#' @format A data frame with 6 rows and 3 variables:
#' @format A data frame with 6 rows and 6 variables:
#' \describe{
#' \item{spid}{sample ID}
#' \item{casn}{Chemical Abstract Service(CAS) number}
#' \item{chnm}{chemical name}
#' \item{dsstox_substance_id}{chemical-specific DTXSID}
#' \item{code}{CAS number compressed into numeric string}
#' \item{chid}{unique chemical ID number for tcpl}
#'
#' }
#' @source Toxcast database
Expand Down
8 changes: 8 additions & 0 deletions R/mc3_mthds.R
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,14 @@ mc3_mthds <- function() {
resp := 1-(cval/bval)])
list(e1)

},

bval.aeid.nwlls.med = function(aeids) {
e1 <- bquote(dat[J(.(aeids)),
bval := median(cval[wllt == "n"], na.rm = TRUE),
by = list(aeid)])
list(e1)

}

)
Expand Down
18 changes: 18 additions & 0 deletions R/mc5_mthds.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ mc5_mthds <- function(ae) {
e1 <- bquote(coff <- c(coff, 0.3))
list(e1)

},
pc25 = function() {

e1 <- bquote(coff <- c(coff, 25))
list(e1)
},

pc30 = function() {

e1 <- bquote(coff <- c(coff, 30))
list(e1)
},

bmad1 = function() {

e1 <- bquote(coff <- c(coff, dat[ , unique(bmad)]))
list(e1)

}
)
}
Expand Down
5 changes: 4 additions & 1 deletion R/multiplotFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ multiPlotfit <- function(resp, logc, pars) {

do.call(what = plot, args = c(resp[md] ~ logc[md], p), quote = TRUE)

if (is.null(pars$modl)) pars$modl <- "none"
if (is.na(pars$modl)) pars$modl <- "none"

if(pars$modl == "hill") AC50 <- signif(10^pars$hill_ga,4)
if(pars$modl == "gnls") AC50 <- signif(10^pars$gnls_ga,4)
if(pars$modl == "cnst") AC50 <- NA

if(pars$modl == "none") AC50 <- NA

legend("topleft", bty="n", text.font=2,
legend = paste(paste0("AC50: ",AC50),
Expand Down
23 changes: 22 additions & 1 deletion R/plotFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@
ylab <- pars$resp_unit
#y0 <- c(-50, 150)
}

#new labels for x axis
xlab <- NULL
if (is.na(pars$conc_unit)) {
xlab <- expression(bold(paste("Concentration (",mu,"M)")))
}else{
if (pars$conc_unit == "uM") {
xlab <- expression(bold(paste("Concentration (",mu,"M)")))
}
if (pars$conc_unit == "mg/l") {
xlab <- "Concentration (mg/l)"
}
if (pars$conc_unit == "CF") {
xlab <- "Concentration (CF)"
}
}
if (is.null(xlab)) {
xlab <- paste0("Concentration (",pars$conc_unit,")")
}


if(pars$bmad != 0){
y0 <- c(signif(-10*pars$bmad,2), signif(20*pars$bmad,2))
}else{
Expand Down Expand Up @@ -103,7 +124,7 @@
font.lab = 2,
col = "black",
cex = 2,
xlab = expression(bold(paste("Concentration (",mu,"M)"))),
xlab = xlab,
ylab = ylab,
main = "",
bty = "n",
Expand Down
12 changes: 12 additions & 0 deletions R/sc2.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ sc2 <- function(ae, wr = FALSE) {
warning("No level 5 methods for AEID", ae, " -- cutoff will be 0.")
}

## Extract methods that need to overwrite bmad
ms_overwrite <- ms[grepl("ow_",mthd),]
## ignore any other methods
ms <- ms[!grepl("ow_",mthd),]

## Apply bmad overwrite methods first if needed
if (nrow(ms_overwrite) > 0) {
exprs <- lapply(mthd_funcs[ms_overwrite$mthd], do.call, args = list())
fenv <- environment()
invisible(rapply(exprs, eval, envir = fenv))
}

## Apply cutoff methods
exprs <- lapply(mthd_funcs[ms$mthd], do.call, args = list())
fenv <- environment()
Expand Down
26 changes: 25 additions & 1 deletion R/sc2_mthds.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,32 @@ sc2_mthds <- function() {
e1 <- bquote(coff <- c(coff, log2(1.5)))
list(e1)

}
},

pc25 = function() {

e1 <- bquote(coff <- c(coff, 25))
list(e1)

},

ow_bmad_nwells = function() {

e1 <- bquote(dat[ , bmad := mad(resp[wllt == "n"], na.rm = TRUE)])
list(e1)
},
bmad2 = function() {

e1 <- bquote(coff <- c(coff, dat[ , unique(bmad)*2]))
list(e1)

},

log2_0.76 = function() {

e1 <- bquote(coff <- c(coff, 0.76))
list(e1)
}
)
}

Expand Down
8 changes: 4 additions & 4 deletions R/tcplAppend.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
#'
#' @import DBI
#' @import data.table
#' @importFrom RMySQL MySQL
#' @importFrom RMariaDB MariaDB
#' @importFrom utils read.csv read.table tail write.table
#' @importMethodsFrom RMySQL dbConnect dbWriteTable dbDisconnect

tcplAppend <- function(dat, tbl, db, lvl=NULL) {

Expand All @@ -37,11 +36,12 @@ tcplAppend <- function(dat, tbl, db, lvl=NULL) {
"?tcplConf for more details.")
}

db_pars <- list(drv = RMySQL::MySQL(),
db_pars <- list(drv = RMariaDB::MariaDB(),
user = getOption("TCPL_USER"),
password = getOption("TCPL_PASS"),
host = getOption("TCPL_HOST"),
dbname = db)
dbname = db,
bigint = "numeric")

dbcon <- do.call(dbConnect, db_pars)

Expand Down
8 changes: 5 additions & 3 deletions R/tcplCytoPt.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@
#' tcplConfDefault()
#'
#' ## Can only calculate the cytotox burst if using the MySQL database and
#' ## TCPL_DRVR == 'RMySQL'
#' ## TCPL_DRVR == 'MySQL'
#'
#' if (conf_store == 'RMySQL') {
#' if (getOption("TCPL_DRVR") == "MySQL") {
#'
#' ## Load the "burst" endpoints -- none are defined in the example dataset
#' tcplLoadAeid(fld = "burst_assay", val = 1)
Expand Down Expand Up @@ -114,7 +114,7 @@ tcplCytoPt <- function(chid = NULL, aeid = NULL, flag = TRUE,
min.test = TRUE, default.pt = 3) {

## Variable-binding to pass R CMD Check
modl_ga <- hitc <- code <- chnm <- casn <- use_global_mad <- nhit <- NULL
modl_ga <- hitc <- code <- chnm <- casn <- use_global_mad <- nhit <- modl <- NULL
ntst <- global_mad <- cyto_pt <- med <- cyto_pt_um <- lower_bnd_um <- burstpct <- NULL

if (!is.null(aeid) & !is.vector(aeid)) {
Expand Down Expand Up @@ -160,6 +160,8 @@ tcplCytoPt <- function(chid = NULL, aeid = NULL, flag = TRUE,
}
print(8)
zdat <- tcplSubsetChid(dat = zdat, flag = flag)
#filter out gnls curves
zdat <- zdat[modl != "gnls",]
print(9)
zdst <- zdat[, list(med = median(modl_ga[hitc == 1]), mad = mad(modl_ga[hitc ==
1]),
Expand Down
6 changes: 3 additions & 3 deletions R/tcplLiteInit.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tcplLiteInit <- function () {
'assay_component_map'= c('acid', 'acsn'),
'sample'= c('spid', 'chid', 'stkc', 'stkc_unit', 'tested_conc_unit', 'spid_legacy'),
'chemical_library'= c('chid', 'clib'),
'chemical' = c('chid', 'casn', 'chnm', 'dsstox_substance_id', 'code'),

'mc0'= c('m0id', 'acid', 'spid', 'apid', 'rowi', 'coli', 'wllt', 'wllq', 'conc', 'rval', 'srcf', 'created_date', 'modified_date', 'modified_by'),
'mc1' = c('m1id', 'm0id', 'acid', 'cndx', 'repi', 'created_date', 'modified_date', 'modified_by'),
Expand Down Expand Up @@ -44,11 +45,10 @@ tcplLiteInit <- function () {
}
}

methods = c("mc2_methods", "mc3_methods","mc4_methods", "mc5_methods","mc5_fit_categories", "mc6_methods", "sc1_methods", "sc2_methods", "chemical")
methods = c("mc2_methods", "mc3_methods","mc4_methods", "mc5_methods","mc5_fit_categories", "mc6_methods", "sc1_methods", "sc2_methods")#, "chemical")

for (m in methods) {
tcpl_path <- find.package('tcpl')
tcpl_fpath <- paste(tcpl_path,'csv',sep='/')
tcpl_fpath <- file.path(system.file(package = "tcpl"), "csv")
tcpl_fpath <- paste(tcpl_fpath, m, sep='/')
tcpl_fpath <- paste(tcpl_fpath, 'csv', sep='.')
fpath <- paste(db, m, sep='/')
Expand Down
51 changes: 51 additions & 0 deletions R/tcplLoadConcUnit.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#-------------------------------------------------------------------------------
# tcplLoadConcUnit: Load concentration units for assay endpoints
#-------------------------------------------------------------------------------

#' @title Load concentration units for assay endpoints
#'
#' @description
#' \code{tcplLoadUnit} queries the tcpl databases and returns a data.table
#' with the concentration units for the given assay endpoint ids (spid).
#'
#' @param spid Integer, assay endpoint ids
#'
#' @return A data.table containing level 3 correction methods for the given
#' spids.
#'
#' @seealso \code{\link{tcplQuery}}, \code{\link{data.table}}
#'
#' @import data.table

tcplLoadConcUnit <- function(spid) {

qformat <-
"
SELECT
spid,
tested_conc_unit AS conc_unit
FROM
sample
WHERE
spid IN ('%s');
"

qstring <- sprintf(qformat, paste(spid, collapse = "','"))

dat <- tcplQuery(query = qstring, db = getOption("TCPL_DB"), tbl=c("sample"))

if (nrow(dat) == 0) {
#warning("The given spid(s) do not have concentration units.")
return(dat)
}

len_miss <- lw(!spid %in% dat$spid)
if (len_miss > 0) {
#warning(len_miss, " of the given spid(s) do not have concentration units.")
}

dat[]

}

#-------------------------------------------------------------------------------

0 comments on commit b0a41b3

Please sign in to comment.