-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigure1.py
133 lines (91 loc) · 3 KB
/
figure1.py
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
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 7 11:42:45 2023
@author: Akhilesh Nandan
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
from mpl_toolkits.mplot3d import Axes3D
from math import isclose
import os
import matplotlib.pylab as pylab
import warnings
warnings.filterwarnings("ignore")
params = {'legend.fontsize': 15,
'axes.labelsize': 20,
'axes.labelpad' : 15,
'axes.titlesize':20,
'xtick.labelsize':20,
'ytick.labelsize':20}
pylab.rcParams.update(params)
import tkinter as tk
from tkinter import simpledialog
from quasi_potential_landscape import *
def model_ghost(t, z , para):
alpha=para[0]
d1=alpha+z[0]**2
d2=-z[1]
return np.array([d1, d2])
def model_saddle(t, z , para):
alpha=para[0]
d1=alpha+z[0]
d2=-z[1]
return np.array([d1, d2])
def model_repeller(t, z , para):
alpha=para[0]
d1=alpha+z[0]
d2=z[1]
return np.array([d1, d2])
def model_attractor(t, z , para):
alpha=para[0]
d1=alpha-z[0]
d2=-z[1]
return np.array([d1, d2])
#%% RUN THE MODEL
"""
estimating quasi-potential from steady state probability distribution. For more details refer,
Wang, J., Xu, L., Wang, E., and Huang, S. (2010). The potential landscape of genetic circuits imposes the arrow of time
in stem cell differentiation. Biophysical journal, 99:29–39.
"""
time_point=0
# Create the main application window
root = tk.Tk()
root.withdraw() # Hide the main window
# Show the dialog box and get the input
alpha = simpledialog.askstring("Input", "Please enter '\u03B1' value. Try 0.01 for ghost or -0.4 for saddle")
# Check if the user provided input
if alpha is not None:
print(f"The entered parameter value is: {alpha}")
else:
print("No input provided")
# Destroy the root window after getting the input
root.destroy()
alpha = float(alpha)
input_params=[alpha]
print('estimating quasi-potential landscape. This might take sometime.')
## change the model in the argument to plot potentials of different phase space objects.
## currently set to simulate ghost manifold using 'model_ghost' function.
if alpha>0:
qpl=QuasiPotentialLandscape(time_point,model_ghost,input_params) # for ghost landscape
azim=21;ele=-17
else:
qpl=QuasiPotentialLandscape(time_point,model_saddle,input_params) # for saddle landscape
azim=-43;ele=25
grid_pot,Pt=qpl.find_potential()
U= -np.log(Pt) # quasi-potential value
zlims=[np.min(U)-0.5,np.min(U)+1]
Xpot,Ypot=grid_pot
U=U-(np.nanmin(U)-0.5)
#%%
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
plt.rcParams.update({'font.size': 10})
surf = ax.plot_surface(Xpot,Ypot, U, rstride=1, cstride=1, cmap='hot',alpha=0.3,
linewidth=0.25,antialiased=True,edgecolor='k',vmin=np.nanmin(U),vmax=np.nanmax(U))
ax.set_aspect('auto')
ax.view_init(azim,ele)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('Quasi-potential')
plt.tight_layout()
plt.show()