@@ -95,8 +95,6 @@ def plot(plotToFile, filename):
9595ax4 .set_xlabel ('Time' )
9696ax4 .set_ylabel ('Time' )
9797ax4 .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):
131129ax4 .set_xlabel ('Time' )
132130ax4 .set_ylabel ('Time' )
133131ax4 .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):
157153ax2 .set_xlabel ('Time' )
158154ax2 .set_ylabel ('Time' )
159155ax2 .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):
187181ax2 .set_xlabel ('Time' )
188182ax2 .set_ylabel ('Time' )
189183ax2 .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
236225fig , axs = plt .subplots (len (Theta ), len (Theta ))
237226fig .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 ()
0 commit comments