Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sueinchoi committed Feb 27, 2024
1 parent 6fd5a19 commit 3c5a312
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 92 deletions.
83 changes: 39 additions & 44 deletions 06.Rmd

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions _render.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ for (f in list.files('_book', '[.]html$', full.names = TRUE)) {
if (length(formats) > 1) bookdown::publish_book()

setwd(owd)

Binary file modified media-07/ADA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media-07/TMDD_ADA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media-07/TMDD_PhaseA_R0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media-07/TMDD_PhaseA_dose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media-07/TMDD_PhaseBC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media-07/TMDD_PhaseKEC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media-07/mm_tmdd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 50 additions & 48 deletions simulation/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ library(ggpubr)
library(rlang)
library(httpgd)
library(ggthemes)
library(ggsci)
library(ggpubr)
mod <- mread_cache('simulation/TMDD.cpp')
mod <- param(mod, list(KINT = 0.003,
KOFF = 0.001,
Expand All @@ -15,12 +17,11 @@ mod <- param(mod, list(KINT = 0.003,
VC = 0.04,
KON = 0.002
))
install.packages('bookdown')
#### Change of dose ####

amt_vec <- c(10, 15, 20, 25)

dose_change_plot <- mod %>%
amt_vec2 <- c(3, 5, 10, 15)
dose_change_plotA <- mod %>%
data_set(as_data_set(data.frame(amt = amt_vec, ID = 1:4, cmt = 2) %>% mutate(dose = amt))) %>%
carry_out(dose) %>%
zero_re() %>%
Expand All @@ -33,16 +34,26 @@ dose_change_plot <- mod %>%
labs(x = "Time (hr)",
y = "Concentration (nM/L)",
col = "Dose (nM)")+
theme_few() +
scale_color_calc()
dose_change_plot
scale_y_continuous(limits = c(0.05, 1000), breaks = c( 0.1, 1, 10, 100, 1000), trans = "log10") +
scale_x_continuous(limits = c(0, 3000)) +
scale_color_npg() +
theme_bw()

plot_grid(dose_change_plotA, dose_change_plotA, labels = c("A", "B"), label_size = 18)
dose_change_plotA
ggsave('media-07/TMDD_dose.png', width = 7.5, height = 6, unit = "in")
dose_change_plot_log <- dose_change_plot + scale_y_continuous(trans = 'log10')

dose_change_plot_log
ggarrange(dose_change_plot_log, dose_change_plot, common.legend = TRUE, labels = c("A", "B"))
ggsave("media-07/DOSEA.png", width = 6, height = 4, unit = "in")

#### Change of parameter ####
library(scales)
NotFancy <- function(l) {
l <- format(l, scientific = FALSE)
parse(text = l)
}

param_change <- function(PAR, SEQ, TIME = 800) {
PAR2 <- as_name(enquo(PAR))
Expand All @@ -60,9 +71,9 @@ param_change <- function(PAR, SEQ, TIME = 800) {
labs(x = "Time (hr)",
y = "Concentration (nM/L)",
col = paste0(as_label(enquo(PAR)), " (nM)")) +
theme_few() +
scale_color_calc() +
scale_y_continuous(breaks = c(0, 50, 100), limits = c(0, 130))
theme_bw() +
scale_color_npg(labels = c("0.0005", "0.001", "0.005", "0.01", "0.05")) +
scale_y_continuous(breaks = c(0, 50, 100), limits = c(0, 130))
p1
#p2 <- p1 + scale_y_continuous(trans = "log10")
#ggarrange(p1, p2, common.legend = TRUE, labels = c("A", "B"))
Expand All @@ -75,9 +86,9 @@ param_change(R0, seq(1, 20, length.out = 5), 100)
ggsave('media-07/R0.png', width = 7.5, height = 6, unit = "in")
param_change(KEL, seq(0.00015, 0.01, length.out = 5), 300)
ggsave('media-07/KEL.png', width = 6, height = 4, unit = "in")
param_change(KDEG, seq(0.00015, 0.01, length.out = 5), 300)
param_change(KDEG, c(0.00015, 0.0015, 0.015, 0.15, 1.5), 300)
ggsave('media-07/KDEG.png', width = 6, height = 4, unit = "in")
param_change(KINT, seq(0.00015, 0.01, length.out = 5), 1000) + scale_y_continuous(trans = 'log10') + labs(color = "Kec (nM)")
param_change(KINT, c(0.0005, 0.001, 0.005, 0.01, 0.05), 1000) + scale_y_continuous(trans = "log10") + labs(color = "Kec (nM)")
ggsave('media-07/KINT.png', width = 6, height = 4, unit = "in")
param_change(KON, seq(0.00015, 0.01, length.out = 5), 300)
ggsave('media-07/KON.png', width = 6, height = 4, unit = "in")
Expand Down Expand Up @@ -105,7 +116,6 @@ dose_change_plot <- mod %>%
col = "Dose (nM)"
)


mod %>%
ev(amt = 10, cmt = 2) %>%
mrgsim(nid = 5, end = 1800) %>%
Expand Down Expand Up @@ -145,21 +155,24 @@ moddata <- mod2 %>%

savedata2 <- moddata
finaldata <- moddata

head(moddata)
moddata %>%
filter(CP > 1E-8, time %in% sample) %>%
filter(!(ID %in% 1:4 & time > 1000)) %>%
filter(CP > 1E-2, time %in% sample) %>%
# filter(!(ID %in% 1:4 & time > 1000)) %>%
mutate(ADA = ifelse(ID %in% c(1, 2, 3, 4), "ADA (+)", "ADA (-)")) %>%
ggplot(aes(x = time, y = CP, col = as.factor(ID))) +
geom_point() +
geom_point(alpha = 0.5) +
geom_line() +
scale_y_continuous(trans = "log10") +
facet_grid(cols = vars(ADA))+
theme_bw() +
labs(
x = "Time (hr)",
y = "Concentration",
col = "ID"
)

) +
scale_color_npg()
?facet_grid
ggsave('media-07/ADA.png', width = 6, height = 4, unit = "in")

write.csv(finaldata, "simulation/adadata.csv", row.names= F)
Expand All @@ -168,6 +181,7 @@ moddata <- read_csv('simulation/adadata.csv')

#### MM model VS TMDD model ####
mod <- mread_cache("simulation/TMDD.cpp")
mod_mm <- mread_cache("simulation/MMmodel.cpp")
mod <- param(mod, list(
KINT = 0.003,
KOFF = 0.001,
Expand All @@ -182,7 +196,7 @@ mod <- param(mod, list(

amt_vec <- c(1, 5, 10, 15, 20)

dose_change_plot <- mod %>%
dose_change_plot_log <- mod %>%
data_set(as_data_set(data.frame(amt = amt_vec, ID = 1:5, cmt = 2) %>% mutate(dose = amt))) %>%
carry_out(dose) %>%
zero_re() %>%
Expand All @@ -196,38 +210,21 @@ dose_change_plot <- mod %>%
theme_bw() +
labs(
x = "Time (hr)",
y = "Concentration (nM/L)",
col = "Dose (nM)"
)

dose_change_plot_log <- dose_change_plot + scale_y_continuous(trans = "log10")

dose_change_plot_log
y = "Concentration (ng/mL)",
col = "Dose (mg)"
) +
scale_y_continuous(trans = "log10", limits = c(0.01, 500))


ggarrange(dose_change_plot, dose_change_plot_log, common.legend = TRUE, labels = c("A", "B"))
ggsave("media-07/DOSE.png", width = 6, height = 4, unit = "in")
mod_mm <- mread_cache('simulation/MMmodel.cpp')

mod_mm %>%
ev(amt = 100) %>%
mrgsim() %>%
plot()

param(mod_mm)
mod_mm <- param(mod_mm, list(
VMAX = 100,
KM = 10
))
amt_vec <- c(10, 30, 50, 70, 100)

mod_mm %>%
data_set(as_data_set(data.frame(amt = 100*amt_vec, ID = 1:5, cmt = 1) %>% mutate(dose = amt))) %>%
tmdd.plot <- dose_change_plot_log + scale_color_npg()
tmdd.plot
dose_change_plot_log_mm <-mod_mm %>%
data_set(as_data_set(data.frame(amt = 300*amt_vec, ID = 1:5, cmt = 1) %>% mutate(dose = amt))) %>%
carry_out(dose) %>%
zero_re() %>%
mrgsim(end = 1000) %>%
as.data.frame() %>%
mutate(dose = as.factor(dose/100)) %>%
mutate(dose = as.factor(dose/100/3)) %>%
filter(CP > 1E-2) %>%
ggplot(aes(x = time, y = CP, col = dose)) +
geom_line() +
Expand All @@ -238,6 +235,11 @@ mod_mm %>%
y = "Concentration (ng/mL)",
col = "Dose (mg)"
) +
scale_y_continuous(trans = 'log10')

ggsave('media-07/MM.png', width = 6, height = 4, unit = "in")
scale_y_continuous(trans = 'log10', limits = c(0.01, 500))
scale_y_continuous
mm.plot <- dose_change_plot_log_mm + scale_color_npg()
mm.plot
library(cowplot)
plot_grid(tmdd.plot, mm.plot, ncol = 2, labels = c("A", "B"), label_size = 18)
grid.arrange(tmdd.plot, mm.plot, ncol = 2)
library(gridExtra)

0 comments on commit 3c5a312

Please sign in to comment.