---
title: "Honda et al. (2019): Updated Armitage et al. (2014) Model"
author: "Gregory S. Honda"
date: "July 13, 2018"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Honda et al. (2019): Updated Armitage et al. (2014) Model}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.width=6, fig.height=5)
```
from "Using the concordance of in vitro and in vivo data to evaluate extrapolation assumptionst"

Gregory S. Honda, Robert G. Pearce, Ly L. Pham, R. W. Setzer, Barbara A. Wetmore,
Nisha S. Sipes, Jon Gilbert, Briana Franz, Russell S. Thomas, John F. Wambaugh 

PLoS ONE 14(5): e0217564.

https://doi.org/10.1371/journal.pone.0217564

The authors thank James Armitage for providing a revised version of his model (
https://doi.org/10.1021/es501955g). 

## Abstract
Linking in vitro bioactivity and in vivo toxicity on a dose basis enables the 
use of high-throughput in vitro assays as an alternative to traditional animal 
studies. In this study, we evaluated assumptions in the use of a 
high-throughput, physiologically based toxicokinetic (PBTK) model to relate 
in vitro bioactivity and rat in vivo toxicity data. The fraction unbound in 
plasma (fup) and intrinsic hepatic clearance (Clint) were measured for rats 
(for 67 and 77 chemicals, respectively), combined with fup and Clint 
literature data for 97 chemicals, and incorporated in the PBTK model. Of 
these chemicals, 84 had corresponding in vitro ToxCast bioactivity data and 
in vivo toxicity data. For each possible comparison of in vitro and in vivo 
endpoint, the concordance between the in vivo and in vitro data was evaluated 
by a regression analysis. For a base set of assumptions, the PBTK results 
were more frequently better associated than either the results from a 
"random" model parameterization or direct comparison of the "untransformed" 
values of AC50 and dose (performed best in 51%, 28%, and 21% of cases, 
respectively). We also investigated several assumptions in the application 
of PBTK for IVIVE, including clearance and internal dose selection. One of 
the better assumptions sets-restrictive clearance and comparing free in vivo 
venous plasma concentration with free in vitro concentration-outperformed 
the random and untransformed results in 71% of the in vitro-in vivo endpoint 
comparisons. These results demonstrate that applying PBTK improves our 
ability to observe the association between in vitro bioactivity and in vivo 
toxicity data in general. This suggests that potency values from in vitro 
screening should be transformed using in vitro-in vivo extrapolation (IVIVE) 
to build potentially better machine learning and other statistical models 
for predicting in vivo toxicity in humans.

## Updated Armitage 2014 Top Panel Figure 3

This produces an updated version of the top panel of Figure 3 from the paper Armitage, J. M.; Wania, F.; Arnot, J. A. Environ. Sci. Technol. 2014, 48, 9770-9779.

```{r InitialPrep}
library(data.table)
library(magrittr)
library(ggplot2)
library(httk)
# We love to give warning messages whenever assumptions are used by HTTK,
# but they will overwhelm the output of this vignette so we turn them
# off:
options(warn = -1)
```
```{r MakeTable}
armitage.dt <- copy(armitage_input)
armitage.dt[,well_number:=384] %>% 
  .[,option.bottom:=TRUE] %>% 
  .[,option.plastic:=TRUE] %>% 
  .[,Tsys:=37] %>% 
  .[,Tref:=298.15] %>% 
  .[,FBSf:=0.1] %>% 
  .[,nomconc:=50]

# Make sure we have data for the chemical:
armitage.dt <- subset(armitage.dt,casrn%in%get_cheminfo())
# These chemicals are missing water solubilities:
armitage.dt <- subset(armitage.dt,!(casrn%in%c("71751-41-2","34590-94-8","1024-57-3")))

armitage.dt2 <- armitage_estimate_sarea(tcdata = armitage.dt)
armitage_output1 <- armitage_eval(tcdata = armitage.dt2[,ac50:=50])
armitage_output2 <- armitage_eval(tcdata = armitage.dt2[,ac50:=1])
armitage_output3 <- armitage_eval(tcdata = armitage.dt2[,ac50:=0.001])

```

## Plot results

```{r MakePlot, echo=TRUE}
armitage_output <- rbind(armitage_output1[,xfill:="50 \U00B5M"],
                         armitage_output2[,xfill:="1 \U00B5M"],
                         armitage_output3[,xfill:="1 nM"])
armitage_output[,xfill:=factor(xfill,levels=c("50 \U00B5M","1 \U00B5M","1 nM"))]

ggplot(armitage_output) +
  geom_point(aes(x=gkow,y=log10(ccells/MW*1e9),color=xfill),shape=1) +
  labs(color=expression("AC"["50"]),x="log P", y = "log(ng chemical/g cells)") +
  theme_bw()
```


