-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTask21_Collection_Key_Results.Rmd
178 lines (143 loc) · 4.81 KB
/
Task21_Collection_Key_Results.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
---
title: "Task21 - Key Examples, perhaps for discussion"
author: Andrew Stein
output:
html_document:
toc: true
toc_float: true
code_folding: hide
---
# Introduction
The idea is to identify cases where AFIR theory doesn't match SCIM simulation and understand why and build in tests for this.
# Setup and Read Data
```{r, warning=FALSE, message=FALSE}
source("ams_initialize_script.R")
source("SCIM_calculation.R")
source("ivsc_2cmt_RR_V1.R")
library(RxODE)
model = ivsc_2cmt_RR_KdT0L0()
dirs$rscript_name = "Task21_Collection_Key_Results.Rmd"
dirs$filename_prefix= str_extract(dirs$rscript_name,"^Task\\d\\d\\w?_")
data_in = read.csv("results/Task20_data.csv",stringsAsFactors = FALSE)
data = data_in %>%
mutate(target = ifelse(is_soluble==1,"soluble","membrane"))
assumptions = data %>%
select(id,AFIR_thy,AFIR_sim,SCIM_simplest_thy,SCIM_adhoc_thy,SCIM_sim,starts_with("assumption")) %>%
arrange(SCIM_sim)
nam = names(assumptions) %>%
str_replace("^assumption_","")
names(assumptions) = nam
```
# Explore agreement between AFIR theory and SCIM simulation
List of assumptions
* AFIR < 0.30,
* Cavgss >> Ttotss (5x larger)
* Cavgss >> Kss_DT (5x)
* koff_DT > keT (binding faster than elimination)
* koff_TL > 1/30 (not too slow)
* Cavgss >> Kss_DT*Lss/Kss_TL (enough binding)
* Lss/L0 ~ 1 (no accumulation of ligand)
```{r, warning = FALSE, message = FALSE}
data_plot = data
g = ggplot(data_plot, aes(AFIR_SCIM_pcterr*100, fill = assumption_all_AFIR))
g = g + geom_histogram()
g = g + xgx_scale_x_log10()
g = g + facet_wrap(~target)
g = g + scale_fill_manual(values = c(`TRUE`="grey50",`FALSE`="pink"))
g = g + labs(x = "Percent Error",
y = "Number of Simulations")
g = g + ggtitle("AFIR theory vs\nSCIM simulation")
print(g)
```
# Explore agreemnet between SCIM theory and SCIM simulation
List of assumptions. They are similar to the AFIR assumptions, but now we allow for accumulation of Ligand
* SCIM < 30%
* Cavgss >> Ttotss (5x larger)
* Cavgss >> Kss_DT (5x)
* koff_DT > keT (binding faster than elimination)
* koff_TL > 1/30 (not too slow)
* Cavgss >> Kss_DT*Lss/Kss_TL (enough binding)
```{r, warning = FALSE, message = FALSE}
g = ggplot(data_plot, aes(SCIM_SCIM_pcterr*100, fill = assumption_all_SCIM))
g = g + geom_histogram()
g = g + xgx_scale_x_log10()
g = g + facet_wrap(~target)
g = g + scale_fill_manual(values = c(`TRUE`="grey50",`FALSE`="pink"))
g = g + labs(x = "Percent Error",
y = "Number of Simulations")
g = g + ggtitle("SCIM adhoc Lfold theory vs\nSCIM simulation")
print(g)
```
# Look into large error with assumptions - check tol for ODE
```{r, warning = FALSE, message = FALSE}
data_focus = data %>%
filter(assumption_all_SCIM == TRUE) %>%
arrange(desc(SCIM_SCIM_pcterr)) %>%
mutate(Dss_TLss_thy_ratio = Dss_thy/TLss_thy,
Dss_TLss_sim_ratio = Dss_sim/TLss_sim)
data_focus %>%
select(id,SCIM_SCIM_pcterr,contains("Dss_TLss")) %>%
slice(1:10) %>%
kable()
```
# D is way lower than predicted
### Because Dss < Ccrit, so all the Drug is getting internalized
From the theory:
* Ttotss = 100
* Dss = 600
* keDT = 13
* CL = .27
* V = 3
* ...
* linear elimination = Dss*CL = 600*.27 ~ 150
* nonlinear elimination =
* Ccrit = Vm/CL = ksynT*V1/CL = 1375*3/.27 = 15,000
Ok, so Dss is not large enough. We need a check that it's above Ccrit.
Shoot, I forgot what run illustrated this issue... It's not 9129. I think it's a mistake that I plot it below.
```{r, warning = FALSE, message = FALSE}
id_plot = 9129
d = data %>% filter(id==id_plot)
out = plot_param(d,model)
kable(out$param)
kable(out$compare)
```
# This simulation seems to be giving a negative TLss
### This is due to the large difference between Dss and TLss
ODE can't solve it accurately. But only one patient like this (see above)
```{r, warning = FALSE, message = FALSE}
id_plot = 7651
d = data %>% filter(id==id_plot)
print(paste("Cavgss: ", d$Cavgss))
print(paste("TLss: ", d$TLss_thy))
out = plot_param(d,model, plot_flag = FALSE)
print(out$plot)
kable(out$param)
kable(out$compare)
print(d$SCIM_sim)
```
# Look at a patient with all assumptions true and large error
### Something strange is going on, with the Dss_sim and Dss_thy
```{r, warning = FALSE, message = FALSE}
x = data_focus
d = x[2,]
out = plot_param(d,model)
kable(out$param)
kable(out$compare)
print("original simulation result")
Dss_calc = with(d,dose_nmol/CL/tau)
d %>%
select(id,Dss_sim, Dss_thy, T0_sim, L0_sim, TL0_sim, Ttotss_sim, Lss_sim, TLss_sim, AFIR_sim, SCIM_sim, SCIM_Lfold_adhoc_thy) %>%
kable()
```
# Continue looking at patient with all assumptions true and large error
```{r, warning = FALSE, message = FALSE}
out = plot_param(x[3,],model)
kable(out$param)
kable(out$compare)
out = plot_param(x[4,],model)
kable(out$param)
kable(out$compare)
out = plot_param(x[5,],model)
kable(out$param)
kable(out$compare)
```