The toxplot
(Toxicology Plot) package provides a convenient interface to batch process high-throughput toxicology bioassay screening data. It's designed specifically for screening experiment that features a primary assay and a companion cytotoxicity assay. This package provides functions for data normalization, quality-control analysis, dose-response curve fitting, visualization, and a unqiue toxicity-adjusted potency ranking system.
To allow the package process data correctly, it is essential to ensure the data input follows required format. Below are the essential columns to include in the input data. Since this package is designed to look at a primary inhibition assay and a parallel cell viability/cytotoxicity assay simultaneously, data from both assays should be put together in a single input file or dataframe.
Columns required:
Welltype explained:
t: test chemical/sample
n: DMSO negative control pr: positive control of primary assay, for RAIU assay the chemical is NaClO4
nrc: negative chemical control (2,4-D, a chemical that is supposed to be negative in both raiu and celltiter-glo toxicity assay) pc: positive control for celltiter-glo cytotixicity assay (DCNQ)
Load the demo dataset included in the package. Below is the head of the dataframe.
library(dplyr) devtools::load_all() knitr::kable(head(demo_mc), caption = "Head rows of demo data")
Before analyzing the data, it is necessary to define the name of the primary and cytotoxicity assay.
Note that the names defined here should exactly match what's provided in the
#define the names of the primary and toxicity assay. assay_info <- list( prim_assay = "Primary", toxi_assay = "Cytotox" )
The normalize_per_plate
function normalize raw readings as percent of the median/mean of negative control wells (DMSO in this case). The normalized values are included in nval_mean
and nval_median
column.
# normalization demo_mc_norm <- normalize_per_plate(demo_mc, nctrl = "DMSO") knitr::kable(head(demo_mc_norm))
The qc_per_plate
function calculate qc metrics for each assay plate, returns three tables each representing the statistics of negative controls, positive controls and QC measures including the CV of DMSO controls and Z' score.
Z' factor is calculated as follows:
$$Z'=1-\frac{3\sigma_{positive\ control} + 3\sigma_{DMSO\ control}}{|\mu_{positive\ control} - \mu_{DMSO\ control}|}$$
# qc qc <- qc_per_plate(demo_mc_norm, assay_info) knitr::kable(qc$neg_ctrl_sum) knitr::kable(qc$pos_ctrl_sum) knitr::kable(qc$qc)
The fit_curve_tcpl
function uses the hill model provided in U.S.EPA's ToxCast pipeline tcpl
package^[ https://CRAN.R-project.org/package=tcpl] to fit dose-response curves. This function serves as an convenient interface to call the tcplFit
function in the tcpl
package, and returns a list object containing all data and modeling results. Compared to using the tcpl
package, toxplot
package doesn't require usage of mysql/sqlite database.
The Hill Model:
$$f(x) = \frac{tp}{1+10^{(ga-x)gw}}$$
Where x is the log concentration, tp is the top asymptote, ga is the AC50 (the log concentration where the modeled activity equals 50% of the top asymptote), and gw is the hill coefficient. The Hill model provided in the tcpl R package constrains the three parameters as following:
# curve fitting mc_norm <- dplyr::filter(demo_mc_norm, wllt == "t") demo_md <- fit_curve_tcpl(mc_norm, assay_info)
A toxicity-adjusted ranking score is calculated to rank chemical potency.
For more information about the calculation of ranking score, please refer to this publication
# calculate ranking score demo_rank <- rank_tcpl(demo_md) knitr::kable(head(demo_rank))
The plot_tcpl
function uses ggplot2
to plot all the fitted curve with data in original direction. The funciton returns a list of ggplot2 objects.
# make plots demo_plots <- plot_tcpl(demo_md, demo_rank, notation = FALSE) # Visualize plot demo_plots[[1]] demo_plots[[2]]
It is also very convenient to have the interactive version of the plot with the plotly
package.
plotly::ggplotly(demo_plots[[2]])
The save_plot_pdf
function saves all plots into one pdf file.
save_plot_pdf(demo_plots, "allplots.pdf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.