Every wanted to do a phase plot for a toggle switch or any two-dimensional model? Here is an example of using a stream plot combined with SBML models using Tellurium based on a simple toggle switch.

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 |
import numpy as np import matplotlib.pyplot as plt import tellurium as te Y, X = np.mgrid[0:8:200j, 0:8:200j] r = te.loada(''' J1: -> x; k1/(1+y^n1) - k2*x; J2: -> y; k3/(1+x^n2) - k4*y; x = 4; y = -4; k1 = 12; k3 = 12; k2 = 2; k4 = 2 n1 = 4; n2 = 4 ''') m = r.simulate (0, 8, 100) U = np.empty_like(X) V = np.empty_like(X) for (i,j), value in np.ndenumerate(X): r.x = X[i][j]; r.y = Y[i][j] U[i][j] = r.J1; V[i][j] = r.J2 plt.figure(figsize=(10,7)) plt.xlabel('x', fontsize='16') plt.ylabel('y', fontsize='16') plt.ylim((-0.1,8)) plt.xlim((-0.1,8)) plt.streamplot(X, Y, U, V, density=[2, 2]) r.steadyStateSolver.allow_presimulation = False r.x = 5.999; r.y = 0.00462 r.steadyState() plt.plot(r.x, r.y, 'ro', markersize=12) r.x = 0.0046; r.y = 5.999 r.steadyState() plt.plot(r.x, r.y, 'bo', markersize=12) r.x = 1.359; r.y = 1.359 r.steadyState() plt.plot(r.x, r.y, 'go', markersize=12) plt.show() |

The colored circles mark the three steady states. The green circle in the middle is on a saddle-node which is unstable (unless you’re exactly on the saddle ridge) and the two on either side are stable nodes.