-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFigure3ISD_Virus.jl
More file actions
172 lines (134 loc) · 7.76 KB
/
Figure3ISD_Virus.jl
File metadata and controls
172 lines (134 loc) · 7.76 KB
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
using RCall
include("ProblemGenerator.jl")
include("VirusCallBacks.jl")
########################################################################
#Plotting States (Figure 3)
########################################################################
#--------------ISD (Det)--------------
ISDprob = ModelSetup(:ISD, :notStochastic, :Homo)
ISDsol = @time solve(ISDprob, CVODE_BDF(linear_solver = :GMRES), saveat = 0.1)
allStateDataISDDet = DataFrame()
for (i, st) in enumerate(statesNames)
allStateDataISDDet[!, Symbol(st)] = vec(ISDsol[:, :, i, :])
end
timeLength = length(ISDsol.t)
allStateDataISDDet.Cell = repeat(1:nCells, timeLength)
allStateDataISDDet.Time = repeat(ISDsol.t, inner = nCells)
allStateDataISDDet.Infected = repeat(vec(ISDprob.u0[:, :, 2] .> 0.0), timeLength)
#--------------ISD (Stoch)--------------
ISDprob = ModelSetup(:ISD, :Stochastic, :Hetero)
ISDsol = @time solve(ISDprob, CVODE_BDF(linear_solver = :GMRES), saveat = 0.1)
allStateDataISDStoch = DataFrame()
for (i, st) in enumerate(statesNames)
allStateDataISDStoch[!, Symbol(st)] = vec(ISDsol[:, :, i, :])
end
timeLength = length(ISDsol.t)
allStateDataISDStoch.Cell = repeat(1:nCells, timeLength)
allStateDataISDStoch.Time = repeat(ISDsol.t, inner = nCells)
allStateDataISDStoch.Infected = repeat(vec(ISDprob.u0[:, :, 2] .> 0.0), timeLength)
#--------------Virus--------------
Virusprob = ModelSetup(:Virus, :Stochastic, :Hetero)
Virussol = @time solve(Virusprob,CVODE_BDF(linear_solver = :GMRES),saveat = 0.1,callback = cb)
allStateDataVirus = DataFrame()
for (i, st) in enumerate(statesNames)
allStateDataVirus[!, Symbol(st)] = vec(Virussol[:, :, i, :])
end
timeLength = length(Virussol.t)
allStateDataVirus.Cell = repeat(1:nCells, timeLength)
allStateDataVirus.Time = repeat(Virussol.t, inner = nCells)
allStateDataVirus.Infected = repeat(vec(Virusprob.u0[:, :, 2] .> 0.0), timeLength)
@rput allStateDataISDDet
@rput allStateDataISDStoch
@rput allStateDataVirus
R"""
library(ggplot2)
library(ggpubr)
#--------------ISD (Det)--------------
stateAveISDDet = aggregate(allStateDataISDDet[,1:14], list(allStateDataISDDet$Infected,allStateDataISDDet$Time), mean)
colnames(stateAveISDDet)[1] <- "Cell.State"
colnames(stateAveISDDet)[2] <- "Time"
logic<- unlist(lapply(stateAveISDDet$Cell.State, function(x) x == TRUE))
stateAveISDDet$Cell.State[which(logic == TRUE)] <- "Primary"
stateAveISDDet$Cell.State[which(logic == FALSE)] <- "Secondary"
lowISDDet = aggregate(allStateDataISDDet[,1:14], list(allStateDataISDDet$Infected,allStateDataISDDet$Time), FUN = 'quantile',probs=0.05)
highISDDet = aggregate(allStateDataISDDet[,1:14], list(allStateDataISDDet$Infected,allStateDataISDDet$Time), FUN = 'quantile',probs=0.95)
#--------------ISD (Stoch)--------------
stateAveISDStoch = aggregate(allStateDataISDStoch[,1:14], list(allStateDataISDStoch$Infected,allStateDataISDStoch$Time), mean)
colnames(stateAveISDStoch)[1] <- "Cell.State"
colnames(stateAveISDStoch)[2] <- "Time"
logic<- unlist(lapply(stateAveISDStoch$Cell.State, function(x) x == TRUE))
stateAveISDStoch$Cell.State[which(logic == TRUE)] <- "Primary"
stateAveISDStoch$Cell.State[which(logic == FALSE)] <- "Secondary"
lowISDStoch = aggregate(allStateDataISDStoch[,1:14], list(allStateDataISDStoch$Infected,allStateDataISDStoch$Time), FUN = 'quantile',probs=0.05)
highISDStoch = aggregate(allStateDataISDStoch[,1:14], list(allStateDataISDStoch$Infected,allStateDataISDStoch$Time), FUN = 'quantile',probs=0.95)
#--------------Virus--------------
stateAveVirus = aggregate(allStateDataVirus[,1:14], list(allStateDataVirus$Infected,allStateDataVirus$Time), mean)
colnames(stateAveVirus)[1] <- "Cell.State"
colnames(stateAveVirus)[2] <- "Time"
logic<- unlist(lapply(stateAveVirus$Cell.State, function(x) x == TRUE))
stateAveVirus$Cell.State[which(logic == TRUE)] <- "Primary"
stateAveVirus$Cell.State[which(logic == FALSE)] <- "Secondary"
lowVirus = aggregate(allStateDataVirus[,1:14], list(allStateDataVirus$Infected,allStateDataVirus$Time), FUN = 'quantile',probs=0.05)
highVirus = aggregate(allStateDataVirus[,1:14], list(allStateDataVirus$Infected,allStateDataVirus$Time), FUN = 'quantile',probs=0.95)
commonFigureOptions <- list( scale_x_continuous(breaks=seq(0, 48, 12)),
theme_pubr(border=TRUE),
ylab("nM"),
xlab("Time (hours)"),
theme(plot.title = element_text(hjust = 0.5),aspect.ratio = 1))
#--------------ISD Plots--------------
p1 <- ggplot(stateAveISDDet) + geom_line(aes(y=DNA, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowISDDet$DNA, ymax=highISDDet$DNA, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("DNA") +
commonFigureOptions
p2 <- ggplot(stateAveISDDet) + geom_line(aes(y=IFNb, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowISDDet$IFNb, ymax=highISDDet$IFNb, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("IFNb") +
commonFigureOptions
p3 <- ggplot(stateAveISDDet) + geom_line(aes(y=IRF7, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowISDDet$IRF7, ymax=highISDDet$IRF7, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("IRF7") +
commonFigureOptions
p4 <- ggplot(stateAveISDDet) + geom_line(aes(y=TREX1, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowISDDet$TREX1, ymax=highISDDet$TREX1, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("TREX1") +
commonFigureOptions
p5 <- ggplot(stateAveISDStoch) + geom_line(aes(y=DNA, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowISDStoch$DNA, ymax=highISDStoch$DNA, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("DNA") +
commonFigureOptions
p6 <- ggplot(stateAveISDStoch) + geom_line(aes(y=IFNb, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowISDStoch$IFNb, ymax=highISDStoch$IFNb, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("IFNb") +
commonFigureOptions
p7 <- ggplot(stateAveISDStoch) + geom_line(aes(y=IRF7, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowISDStoch$IRF7, ymax=highISDStoch$IRF7, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("IRF7") +
commonFigureOptions
p8 <- ggplot(stateAveISDStoch) + geom_line(aes(y=TREX1, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowISDStoch$TREX1, ymax=highISDStoch$TREX1, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("TREX1") +
commonFigureOptions
#--------------Virus Plots--------------
p9 <- ggplot(stateAveVirus) + geom_line(aes(y=DNA, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowVirus$DNA, ymax=highVirus$DNA, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("DNA") +
commonFigureOptions
p10 <- ggplot(stateAveVirus) + geom_line(aes(y=IFNb, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowVirus$IFNb, ymax=highVirus$IFNb, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("IFNb") +
commonFigureOptions
p11 <- ggplot(stateAveVirus) + geom_line(aes(y=IRF7, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowVirus$IRF7, ymax=highVirus$IRF7, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("IRF7") +
commonFigureOptions
p12 <- ggplot(stateAveVirus) + geom_line(aes(y=TREX1, x=Time, group=Cell.State, color = Cell.State))+
geom_ribbon(aes(ymin=lowVirus$TREX1, ymax=highVirus$TREX1, x=Time,group=Cell.State,fill = Cell.State), alpha = 0.3) +
ggtitle("TREX1") +
commonFigureOptions
figure <- ggarrange(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12,
labels = "AUTO",
common.legend = TRUE, legend = "right",
align = "hv",
ncol = 4, nrow = 3)
ggsave("./Figures/Figure3Stoch.pdf",width = 15,height=8,units="in")
"""