-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bifurcations and phase plots.R
262 lines (188 loc) · 9.58 KB
/
Bifurcations and phase plots.R
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
####################### Bifurcations ##########################
rm(list=ls())
library(deSolve)
library(ggplot2)
params <- c(BRAF = 0.005, NRAS =0.01, Ras = 0.5,
PTEN_base = 0.8, A = 0.2, omega = 0.02,
beta_ras = 0.4,
beta_nras = 0.25,
beta_braf = 6, beta_raf = 0.1,
beta_nras1 = 0.1, beta_ras1 = 0.15, beta_pi3k = 0.25,
beta_pten = 0.1,
beta_mek = 0.25,
alpha_raf = 0.05, alpha_mek = 0.1, alpha_erk = 0.1,
alpha_pi3k = 0.08, alpha_pip3 = 0.11
)
# Define the initial conditions
initial_conditions <- c(Raf = 1,
MEK = 1.2,
PI3K = 1,
PIP3 = 1,
ERK = 1)
# Define the time sequence for the simulation
times <- seq(0, 1000, by = 0.1)
#times <- seq(0, 86400, by = 10)
# Define the ODE function
MAPK_pathway <- function(time, state, parameters) {
with(as.list(c(state, parameters)), {
# Sinusoidal PTEN with time-dependent oscillations
PTEN <- PTEN_base + A * sin(omega * time)
# ODEs for MAPK pathway
# dRaf <- beta_nras * NRAS + beta_ras * Ras - alpha_raf * Raf
dRaf <- 1/(1+(ERK/1.3)^30)* beta_ras * Ras + beta_nras * NRAS - alpha_raf * Raf
dMEK <- beta_braf * BRAF + beta_raf * Raf - alpha_mek * MEK
dERK <- beta_mek * MEK - alpha_erk * ERK
# ODEs for Akt pathway
dPI3K <- beta_nras1 * NRAS + beta_ras1 * Ras - alpha_pi3k * PI3K
dPIP3 <- beta_pi3k * PI3K - beta_pten * PTEN - alpha_pip3 * PIP3
return(list(c(dRaf, dMEK, dPI3K, dPIP3, dERK)))
})
}
out <- ode(y = initial_conditions, times = times, func = MAPK_pathway, parms = params)
out_df <- as.data.frame(out)
###########################################################################
############################ Amplitude vs BRAF ############################
###########################################################################
# Initialize a vector to store the amplitudes for each BRAF value
braf_values <- seq(0.003, 0.01, by = 0.001)
amplitudes <- numeric(length(braf_values))
# Loop through the different BRAF values
for (i in 1:length(braf_values)) {
# Update the BRAF parameter
params["BRAF"] <- braf_values[i]
# Run the ODE simulation
out <- ode(y = initial_conditions, times = times, func = MAPK_pathway, parms = params)
out_df <- as.data.frame(out)
# Step 1: Remove the initial transient data (e.g., the first 500 time points)
steady_state_erk <- out_df$ERK[out_df$time > 500] # Adjust time as needed to skip transients
# Step 2: Calculate the amplitude of the steady-state oscillations
amplitude_erk <- max(steady_state_erk) - min(steady_state_erk)
# Store the amplitude for the current BRAF value
amplitudes[i] <- amplitude_erk
# Optional: Plot ERK for each BRAF value
plot(out_df$time, out_df$ERK, type = "l", col = "blue", lwd = 2, main = paste("BRAF =", round(braf_values[i], 4)),
xlab = "Time", ylab = "ERK", ylim = c(0, 3))
# lines(out_df$time, out_df$PIP3, col = "magenta", lwd = 2)
legend("bottomright", legend = c("ERK"), col = c("blue"), lty = 1, lwd = 2)
# Pause between plots (optional)
Sys.sleep(0.5) # Adds a small delay so each plot is visible
}
# Print the amplitudes for each BRAF value
print("Amplitudes for each BRAF value:")
print(amplitudes)
# Plot the amplitude vs BRAF value
plot(braf_values, amplitudes, type = "b", col = "blue", pch = 19, main = "Amplitude of ERK vs BRAF",
xlab = "BRAF", ylab = "Amplitude", ylim = c(0, max(amplitudes)))
### Nice plot
# Enhanced plot of Amplitude vs BRAF value
par(mfrow = c(1, 1))
plot(braf_values, amplitudes, type = "b", col = "dodgerblue3", pch = 19, lwd = 2,
main = "Amplitude of ERK vs BRAF",
xlab = "BRAF", ylab = "Amplitude", ylim = c(0, max(amplitudes) * 1.1),
cex.main = 1.5, cex.lab = 1.2, cex.axis = 1.1, font.main = 2)
# Add a subtle grid for better readability
grid(col = "gray85", lty = "dotted")
# Optional: Add a smoother line to emphasize trends if it suits your data
lines(smooth.spline(braf_values, amplitudes), col = "darkblue", lwd = 1.5, lty = "solid")
# Highlight data points
points(braf_values, amplitudes, col = "dodgerblue3", pch = 19, cex = 1.3)
###########################################################################
############################ Amplitude vs NRAS ############################
###########################################################################
# Initialize a vector to store the amplitudes for each BRAF value
nras_values <- seq(0.01, 0.08, by = 0.005)
amplitudes <- numeric(length(nras_values))
# Loop through the different BRAF values
for (i in 1:length(nras_values)) {
# Update the NRAS parameter
params["NRAS"] <- nras_values[i]
# Run the ODE simulation
out <- ode(y = initial_conditions, times = times, func = MAPK_pathway, parms = params)
out_df <- as.data.frame(out)
# Step 1: Remove the initial transient data (e.g., the first 500 time points)
steady_state_erk <- out_df$ERK[out_df$time > 500] # Adjust time as needed to skip transients
# Step 2: Calculate the amplitude of the steady-state oscillations
amplitude_erk <- max(steady_state_erk) - min(steady_state_erk)
# Store the amplitude for the current BRAF value
amplitudes[i] <- amplitude_erk
# Optional: Plot ERK for each BRAF value
plot(out_df$time, out_df$ERK, type = "l", col = "blue", lwd = 2, main = paste("NRAS =", round(nras_values[i], 4)),
xlab = "Time", ylab = "ERK", ylim = c(0, 3))
lines(out_df$time, out_df$PIP3, col = "magenta", lwd = 2)
legend("bottomright", legend = c("ERK"), col = c("blue"), lty = 1, lwd = 2)
# Pause between plots (optional)
Sys.sleep(0.5) # Adds a small delay so each plot is visible
}
# Print the amplitudes for each BRAF value
print("Amplitudes for each NRAS value:")
print(amplitudes)
### Nice plot
# Enhanced plot of Amplitude vs BRAF value
par(mfrow = c(1, 1))
plot(nras_values, amplitudes, type = "b", col = "forestgreen", pch = 19, lwd = 2,
main = "Amplitude of ERK vs NRAS",
xlab = "NRAS", ylab = "Amplitude", ylim = c(0, max(amplitudes) * 1.1),
cex.main = 1.5, cex.lab = 1.2, cex.axis = 1.1, font.main = 2)
# Add a subtle grid for better readability
grid(col = "gray85", lty = "dotted")
# Optional: Add a smoother line to emphasize trends if it suits your data
lines(smooth.spline(nras_values, amplitudes), col = "darkgreen", lwd = 1.5, lty = "solid")
# Highlight data points
points(nras_values, amplitudes, col = "forestgreen", pch = 19, cex = 1.3)
###########################################################################
######################### Phase plot of ERK vs MEK ########################
###########################################################################
rm(list=ls())
params <- c(BRAF = 0.005, NRAS =0.01, Ras = 0.5,
PTEN_base = 0.8, A = 0.2, omega = 0.02,
beta_ras = 0.4,
beta_nras = 0.25,
beta_braf = 6, beta_raf = 0.1,
beta_nras1 = 0.1, beta_ras1 = 0.15, beta_pi3k = 0.25,
beta_pten = 0.1,
beta_mek = 0.25,
alpha_raf = 0.05, alpha_mek = 0.1, alpha_erk = 0.1,
alpha_pi3k = 0.08, alpha_pip3 = 0.11
)
# Define the initial conditions
initial_conditions <- c(Raf = 1,
MEK = 1.2,
PI3K = 1,
PIP3 = 1,
ERK = 1)
# Define the time sequence for the simulation
times <- seq(0, 1000, by = 0.1)
#times <- seq(0, 86400, by = 10)
# Define the ODE function
MAPK_pathway <- function(time, state, parameters) {
with(as.list(c(state, parameters)), {
# Sinusoidal PTEN with time-dependent oscillations
PTEN <- PTEN_base + A * sin(omega * time)
# ODEs for MAPK pathway
# dRaf <- beta_nras * NRAS + beta_ras * Ras - alpha_raf * Raf
dRaf <- 1/(1+(ERK/1.3)^30)* beta_ras * Ras + beta_nras * NRAS - alpha_raf * Raf
dMEK <- beta_braf * BRAF + beta_raf * Raf - alpha_mek * MEK
dERK <- beta_mek * MEK - alpha_erk * ERK
# ODEs for Akt pathway
dPI3K <- beta_nras1 * NRAS + beta_ras1 * Ras - alpha_pi3k * PI3K
dPIP3 <- beta_pi3k * PI3K - beta_pten * PTEN - alpha_pip3 * PIP3
return(list(c(dRaf, dMEK, dPI3K, dPIP3, dERK)))
})
}
out <- ode(y = initial_conditions, times = times, func = MAPK_pathway, parms = params)
out_df <- as.data.frame(out)
# Remove the initial transient data (e.g., the first 500 time points)
steady_state_erk <- out_df$ERK[out_df$time > 500] # Adjust time as needed to skip transients
steady_state_mek <- out_df$MEK[out_df$time > 500] # MEK values after transient
# Create a phase plot (ERK vs MEK)
par(mfrow = c(1, 1))
plot(steady_state_erk, steady_state_mek, type = "l", col = "dodgerblue", lwd = 2,
xlab = "ERK", ylab = "MEK", main = "Phase Plot: ERK vs MEK",
cex.main = 1.5, cex.lab = 1.2, cex.axis = 1.1, font.main = 2,
xlim = c(min(steady_state_erk), max(steady_state_erk)), # Adjust X-axis limits
ylim = c(min(steady_state_mek), max(steady_state_mek))) # Adjust Y-axis limits
# Add a subtle grid for better readability
grid(col = "gray85", lty = "dotted")
###########################################################################
####################### Phase plot of PI3K vs PIP3 ########################
###########################################################################