-
Notifications
You must be signed in to change notification settings - Fork 1
/
Task21b_Collection_Key_Results_2e3.Rmd
143 lines (115 loc) · 3.86 KB
/
Task21b_Collection_Key_Results_2e3.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
---
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/Task20b_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()
```
# 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}
d = data_focus[1,]
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, dose_nmol, CL, tau, T0_sim, L0_sim, TL0_sim, Ttotss_sim, Lss_sim, TLss_sim, AFIR_sim, SCIM_sim, SCIM_Lfold_adhoc_thy) %>%
mutate(Dss_calc = Dss_calc) %>%
kable()
```
# Continue looking at patient with all assumptions true and large error
```{r, warning = FALSE, message = FALSE}
i=2
out = plot_param(data_focus[i,],model)
kable(out$param)
kable(out$compare)
i=3
out = plot_param(data_focus[i,],model)
kable(out$param)
kable(out$compare)
i=4
out = plot_param(data_focus[i,],model)
kable(out$param)
kable(out$compare)
i=5
out = plot_param(data_focus[i,],model)
kable(out$param)
kable(out$compare)
```