Skip to content

Commit d6e15f5

Browse files
committed
some corrections in all examples
1 parent d914924 commit d6e15f5

4 files changed

Lines changed: 75 additions & 37 deletions

File tree

examples/runBirthDeath.m

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,57 +200,57 @@
200200

201201

202202
%% Test of cross-species sensitivities
203-
i = 1;
204-
j = 1;
205-
eps_theta = 1e-3;
203+
i = 4;
204+
j = 4;
205+
eps_theta = 1e-4;
206206
[MRE,Var,sMRE,sVar,s2MRE,s2Var] = BirthDeath_LNA(Theta,tspan);
207207
[MRE_per,Var_per,sMRE_per,sVar_per,s2MRE_per,s2Var_per] = BirthDeath_LNA(Theta+[0*[1:i-1],1,0*[i+1:4]]*eps_theta,tspan);
208208

209209
k1 = 50;
210210
k2 = 100;
211211

212-
%
213-
figure
212+
% 1st order sensitivity matrix
213+
figure('Name','Test of 1st order sensitivity matrix')
214214
subplot(1,3,1)
215215
imagesc((Var_per(:,:,k1,k2)-Var(:,:,k1,k2))./eps_theta)
216216
colorbar
217217
title('finite differences');
218218
subplot(1,3,2)
219-
imagesc(sVar(:,:,k1,k2,i))
219+
imagesc(sVar(:,:,i,k1,k2))
220220
colorbar
221221
title('analytical sensitivities');
222222
subplot(1,3,3)
223-
imagesc((Var_per(:,:,k1,k2)-Var(:,:,k1,k2))./eps_theta - sVar(:,:,k1,k2,i))
223+
imagesc((Var_per(:,:,k1,k2)-Var(:,:,k1,k2))./eps_theta - sVar(:,:,i,k1,k2))
224224
colorbar
225225
title('error');
226226

227-
% 2nd order test - diagonal
228-
figure
227+
% 2nd order sensitivity matrix for temporal cross-covariance of protein (species 2) abundance
228+
figure('Name','Test of 2nd order sensitivity matrix for temporal cross-covariance of protein abundance')
229229
subplot(1,3,1)
230-
imagesc(squeeze((sVar_per(1,1,:,:,j)-sVar(1,1,:,:,j))./eps_theta))
230+
imagesc(squeeze((sVar_per(2,2,j,:,:)-sVar(2,2,j,:,:))./eps_theta))
231231
colorbar
232232
title('finite differences');
233233
subplot(1,3,2)
234-
imagesc(squeeze(s2Var(1,1,i,j,:,:)))
234+
imagesc(squeeze(s2Var(2,2,i,j,:,:)))
235235
colorbar
236236
title('analytical sensitivities');
237237
subplot(1,3,3)
238-
imagesc(squeeze((sVar_per(1,1,:,:,j)-sVar(1,1,:,:,j))./eps_theta) - squeeze(s2Var(1,1,i,j,:,:)))
238+
imagesc(squeeze((sVar_per(2,2,j,:,:)-sVar(2,2,j,:,:))./eps_theta) - squeeze(s2Var(2,2,i,j,:,:)))
239239
colorbar
240240
title('error');
241241

242-
% 2nd order test - off-diagonal
243-
figure
242+
% 2nd order sensitivity matrix for temporal cross-covariance of two time points
243+
figure('Name','Test of 2nd order sensitivity matrix for temporal cross-covariance of two time points')
244244
subplot(1,3,1)
245-
imagesc((sVar_per(:,:,k1,k2,j)-sVar(:,:,k1,k2,j))./eps_theta)
245+
imagesc((sVar_per(:,:,j,k1,k2)-sVar(:,:,j,k1,k2))./eps_theta)
246246
colorbar
247247
title('finite differences');
248248
subplot(1,3,2)
249249
imagesc(s2Var(:,:,i,j,k1,k2))
250250
colorbar
251251
title('analytical sensitivities');
252252
subplot(1,3,3)
253-
imagesc((sVar_per(:,:,k1,k2,j)-sVar(:,:,k1,k2,j))./eps_theta - s2Var(:,:,i,j,k1,k2))
253+
imagesc((sVar_per(:,:,j,k1,k2)-sVar(:,:,j,k1,k2))./eps_theta - s2Var(:,:,i,j,k1,k2))
254254
colorbar
255255
title('error');
256256

examples/runBirthDeath.py

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ def plot(plotToFile, filename):
9595
ax4.set_xlabel('Time')
9696
ax4.set_ylabel('Time')
9797
ax4.set_title('Autocovariance of protein')
98-
plot(plotToFile, 'BirthDeath1.pdf')
99-
10098

10199

102100
# Simulate: IC = steady state; observable = mRNA and protein
@@ -131,8 +129,6 @@ def plot(plotToFile, filename):
131129
ax4.set_xlabel('Time')
132130
ax4.set_ylabel('Time')
133131
ax4.set_title('Autocovariance of protein')
134-
plot(plotToFile, 'BirthDeath2.pdf')
135-
136132

137133

138134
# Simulate: IC = steady state; observable = protein
@@ -157,8 +153,6 @@ def plot(plotToFile, filename):
157153
ax2.set_xlabel('Time')
158154
ax2.set_ylabel('Time')
159155
ax2.set_title('Autocovariance of protein')
160-
plot(plotToFile, 'BirthDeath3.pdf')
161-
162156

163157

164158
# Simulate: IC = no steady state; observable = protein
@@ -187,8 +181,6 @@ def plot(plotToFile, filename):
187181
ax2.set_xlabel('Time')
188182
ax2.set_ylabel('Time')
189183
ax2.set_title('Autocovariance of protein')
190-
plot(plotToFile, 'BirthDeath4.pdf')
191-
192184

193185

194186
# Simulate: IC = no steady state; observable = protein; sensitivity = 1st order
@@ -211,8 +203,6 @@ def plot(plotToFile, filename):
211203
ax2.set_xlabel('Time')
212204
ax2.set_ylabel('Sensitivity of autocovariance')
213205
ax2.set_title(parameterNames[i])
214-
plot(plotToFile, 'BirthDeath5.pdf')
215-
216206

217207

218208
# Simulate: IC = no steady state; observable = protein; sensitivity = 1st & 2nd order
@@ -231,7 +221,6 @@ def plot(plotToFile, filename):
231221
ax1.set_xlabel('Time')
232222
ax1.set_ylabel('Sensitivity of mean')
233223
ax1.set_title('(%s, %s)' % (parameterNames[i], parameterNames[j]))
234-
plot(plotToFile, 'BirthDeath6.pdf')
235224

236225
fig, axs = plt.subplots(len(Theta), len(Theta))
237226
fig.suptitle('Simulation of autocovariance: IC = no steady state; observable = protein; sensitivity = 1st & 2nd order')
@@ -243,5 +232,54 @@ def plot(plotToFile, filename):
243232
ax1.set_xlabel('Time')
244233
ax1.set_ylabel('Time')
245234
ax1.set_title('(%s, %s)' % (parameterNames[i], parameterNames[j]))
246-
plot(plotToFile, 'BirthDeath7.pdf')
247235

236+
# Test of cross-species sensitivities
237+
i = 4-1;
238+
j = 4-1;
239+
eps_theta = 1e-4;
240+
Theta_per = Theta[:]
241+
Theta_per[i] += eps_theta
242+
[MRE,Var,sMRE,sVar,s2MRE,s2Var] = BirthDeathLNA.LNA(Theta, tspan, Y0=MRE0, V0=Var0, computeSens2=True);
243+
[MRE_per,Var_per,sMRE_per,sVar_per,s2MRE_per,s2Var_per] = BirthDeathLNA.LNA(Theta_per, tspan, Y0=MRE0, V0=Var0, computeSens2=True);
244+
245+
k1 = 50-1;
246+
k2 = 100-1;
247+
248+
# 1st order sensitivity matrix
249+
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
250+
im = ax1.imshow((Var_per[:, :, k1, k2] - Var[:, :, k1, k2]) / eps_theta)
251+
ax1.set_title('finite differences')
252+
fig.colorbar(im, ax=ax1)
253+
im = ax2.imshow(sVar[:, :, i, k1, k2])
254+
ax2.set_title('analytical sensitivities')
255+
fig.colorbar(im, ax=ax2)
256+
im = ax3.imshow((Var_per[:, :, k1, k2] - Var[:, :, k1, k2]) / eps_theta - sVar[:, :, i, k1, k2])
257+
ax3.set_title('error')
258+
fig.colorbar(im, ax=ax3)
259+
plt.show()
260+
261+
# 2nd order sensitivity matrix for temporal cross-covariance of protein (species 2) abundance
262+
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
263+
im = ax1.imshow(np.squeeze((sVar_per[1, 1, j, :, :] - sVar[1, 1, j, :, :]) / eps_theta))
264+
ax1.set_title('finite differences')
265+
fig.colorbar(im, ax=ax1)
266+
im = ax2.imshow(np.squeeze(s2Var[1, 1, i, j, :, :]))
267+
ax2.set_title('analytical sensitivities')
268+
fig.colorbar(im, ax=ax2)
269+
im = ax3.imshow(np.squeeze((sVar_per[1, 1, j, :, :] - sVar[1, 1, j, :, :]) / eps_theta) - np.squeeze(s2Var[1, 1, i, j, :, :]))
270+
ax3.set_title('error')
271+
fig.colorbar(im, ax=ax3)
272+
plt.show()
273+
274+
# 2nd order sensitivity matrix for temporal cross-covariance of two time points
275+
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
276+
im = ax1.imshow((sVar_per[:, :, j, k1, k2] - sVar[:, :, j, k1, k2]) / eps_theta)
277+
ax1.set_title('finite differences')
278+
fig.colorbar(im, ax=ax1)
279+
im = ax2.imshow(s2Var[:, :, i, j, k1, k2])
280+
ax2.set_title('analytical sensitivities')
281+
fig.colorbar(im, ax=ax2)
282+
im = ax3.imshow((sVar_per[:, :, j, k1, k2] - sVar[:, :, j, k1, k2]) / eps_theta - s2Var[:, :, i, j, k1, k2])
283+
ax3.set_title('error')
284+
fig.colorbar(im, ax=ax3)
285+
plt.show()

examples/runWang2010.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
k1 = 50;
6868
k2 = 100;
6969

70-
%%
71-
figure
70+
% 1st order sensitivity matrix
71+
figure('Name','Test of 1st order sensitivity matrix')
7272
subplot(1,3,1)
7373
imagesc((Var_per(:,:,k1,k2)-Var(:,:,k1,k2))./eps_theta)
7474
colorbar
@@ -82,8 +82,8 @@
8282
colorbar
8383
title('error');
8484

85-
%% 2nd order test - diagonal
86-
figure
85+
% 2nd order sensitivity matrix for temporal cross-covariance for species 1
86+
figure('Name','Test of 2nd order sensitivity matrix for temporal cross-covariance of protein abundance')
8787
subplot(1,3,1)
8888
imagesc(squeeze((sVar_per(1,1,j,:,:)-sVar(1,1,j,:,:))./eps_theta))
8989
colorbar
@@ -97,8 +97,8 @@
9797
colorbar
9898
title('error');
9999

100-
%% 2nd order test - off-diagonal
101-
figure
100+
% 2nd order sensitivity matrix for temporal cross-covariance of two time points
101+
figure('Name','Test of 2nd order sensitivity matrix for temporal cross-covariance of two time points')
102102
subplot(1,3,1)
103103
imagesc((sVar_per(:,:,j,k1,k2)-sVar(:,:,j,k1,k2))./eps_theta)
104104
colorbar

examples/runWang2010.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@
7777
eps_theta = 1e-3;
7878
Theta_per = Theta[:]
7979
Theta_per[i] += eps_theta
80-
#[MRE_per,Var_per,sMRE_per,sVar_per,s2MRE_per,s2Var_per] = Wang2010LNA.LNA(Theta_per, tspan, merr=0.0, Y0=MRE0, V0=Var0, computeSens2=True)
8180
[MRE_per,Var_per,sMRE_per,sVar_per] = Wang2010LNA.LNA(Theta_per, tspan, merr=0.0, Y0=MRE0, V0=Var0, computeSens=True)
8281

8382
k1 = 50-1;
8483
k2 = 100-1;
8584

85+
# 1st order sensitivity matrix
8686
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
8787
im = ax1.imshow((Var_per[:, :, k1, k2] - Var[:, :, k1, k2]) / eps_theta)
8888
ax1.set_title('finite differences')
@@ -95,7 +95,7 @@
9595
fig.colorbar(im, ax=ax3)
9696
plt.show()
9797

98-
# 2nd order test - diagonal
98+
# 2nd order sensitivity matrix for temporal cross-covariance for species 1
9999
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
100100
im = ax1.imshow(np.squeeze((sVar_per[1, 1, j, :, :] - sVar[1, 1, j, :, :]) / eps_theta))
101101
ax1.set_title('finite differences')
@@ -108,7 +108,7 @@
108108
fig.colorbar(im, ax=ax3)
109109
plt.show()
110110

111-
# 2nd order test - off-diagonal
111+
# 2nd order sensitivity matrix for temporal cross-covariance of two time points
112112
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
113113
im = ax1.imshow((sVar_per[:, :, j, k1, k2] - sVar[:, :, j, k1, k2]) / eps_theta)
114114
ax1.set_title('finite differences')

0 commit comments

Comments
 (0)