-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_sacess_400_manu.py
205 lines (154 loc) · 7.12 KB
/
plot_sacess_400_manu.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
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
from sys import builtin_module_names
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
cm = 1/2.54
textwidth = 14.79788*cm
matplotlib.rc('font', size=8)
plt.xlim(left=0)
B = np.array([0, 51, 204])/255
G = np.array([0, 128, 0])/255
O = np.array([255, 153, 0])/255
Y = np.array([255, 190, 0])/255
R = np.array([255, 0, 0])/255
GRAY = np.array([100, 100, 100])/255
V = np.array([155, 0, 255])/255
T = np.array([0, 255, 255])/255
# Options
exp = '../Stallaert_CellSystems2021_Data_2rounds.tsv'
opt = 'optimisation.tsv'
con = 'convergence_v4.0.0.csv'
image_file = 'v4.0.0_manu' # 'corr_n300_std0.8_vars9.png'
df_exp = pd.read_csv(exp, sep='\t').pivot(index='time', columns='observableId', values='measurement').iloc[::10, :]
df_opt = pd.read_csv(opt, sep='\t').pivot(index='time', columns='observableId', values='measurement')
df_con = pd.read_csv(con)
x_label = 'Time (h)'
y_label = 'Abundance (AU)'
y_label1 = 'Abundance (AU)'
legend_labels1 = ['CCNE', 'CCNA', 'CCNB1']
legend_labels2 = ['E2F1', 'RB1(Ser807_Ser811~p)', 'SKP2']
legend_labels3 = ['CDKN1A', 'CDKN1B']
variables1 = ['obs_cycE__nuc_median', 'obs_cycA__nuc_median', 'obs_cycB1__nuc_median']
variables2 = ['obs_E2F1__nuc_median', 'obs_pRB__nuc_median', 'obs_Skp2__nuc_median']
variables3 = ['obs_p21__nuc_median', 'obs_p27__nuc_median']
variables4 = ['obs_cycE__cyt_median', 'obs_cycA__cyt_median', 'obs_cycB1__cyt_median']
variables5 = ['obs_E2F1__cyt_median', 'obs_pRB__cyt_median', 'obs_Skp2__cyt_median']
variables6 = ['obs_p21__cyt_median', 'obs_p27__cyt_median']
fig, axs = plt.subplots(4,2, figsize=(textwidth, 2*textwidth/1.33))
((a, b), (c, d), (e, f), (g, h)) = axs
fig.subplots_adjust(left=0.1, right=0.99, bottom=2*0.1/1.5, hspace=0.7, wspace=0.4)
##### Plotting A #####
colors = [B, G, O, Y, R, GRAY, V, T]
x_exp = df_exp.index/3600
x_opt = df_opt.index/3600 # df.loc[:, x_var_name]
a.set_prop_cycle(color=colors)
y = df_exp.loc[:, variables1] # df.loc[order, y_var_names]
a.plot(x_exp, np.array(y), 'o', markersize=1) # See matplotlib.lines.Line2D for details
y = df_opt.loc[:, variables1] # df.loc[order, y_var_names]
a.set_prop_cycle(color=colors)
a.plot(x_opt, np.array(y)) # See matplotlib.lines.Line2D for details
# Labelling
a.set_xlabel(x_label)
a.set_ylabel(y_label)
# Scientific notation
a.ticklabel_format(style='sci', scilimits=(-3,3))
a.annotate('a', xy=(-0.2, 1.15), fontsize=14, fontweight='bold', xycoords='axes fraction')
a.set_title('Nucleus', fontdict={'fontweight': 'bold'})
##### Plotting B #####
x_exp = df_exp.index/3600
x_opt = df_opt.index/3600 # df.loc[:, x_var_name]
b.set_prop_cycle(color=colors)
y = df_exp.loc[:, variables4] # df.loc[order, y_var_names]
b.plot(x_exp, np.array(y), 'o', markersize=1, ) # See matplotlib.lines.Line2D for details
y = df_opt.loc[:, variables4] # df.loc[order, y_var_names]
b.set_prop_cycle(color=colors)
b.plot(x_opt, np.array(y)) # See matplotlib.lines.Line2D for details
# Labelling
b.set_xlabel(x_label)
b.set_ylabel(y_label1)
# Scientific notation
b.ticklabel_format(style='sci', scilimits=(-3,3))
b.annotate('b', xy=(-0.2, 1.15), fontsize=14, fontweight='bold', xycoords='axes fraction')
b.set_title('Cytoplasm', fontdict={'fontweight': 'bold'})
##### Plotting C #####
y = df_exp.loc[:, variables2] # df.loc[order, y_var_names]
c.set_prop_cycle(color=colors[3:])
c.plot(x_exp, np.array(y), 'o', markersize=1, ) # See matplotlib.lines.Line2D for details
y = df_opt.loc[:, variables2] # df.loc[order, y_var_names]
c.set_prop_cycle(color=colors[3:])
c.plot(x_opt, np.array(y)) # See matplotlib.lines.Line2D for details
# Labelling
c.set_xlabel(x_label)
c.set_ylabel(y_label)
# Scientific notation
c.ticklabel_format(style='sci', scilimits=(-3,3))
c.annotate('c', xy=(-0.2, 1.15), fontsize=14, fontweight='bold', xycoords='axes fraction')
##### Plotting D #####
y = df_exp.loc[:, variables5] # df.loc[order, y_var_names]
d.set_prop_cycle(color=colors[3:])
d.plot(x_exp, np.array(y), 'o', markersize=1, ) # See matplotlib.lines.Line2D for details
y = df_opt.loc[:, variables5] # df.loc[order, y_var_names]
d.set_prop_cycle(color=colors[3:])
d.plot(x_opt, np.array(y)) # See matplotlib.lines.Line2D for details
# Labelling
d.set_xlabel(x_label)
d.set_ylabel(y_label)
# Scientific notation
d.ticklabel_format(style='sci', scilimits=(-3,3))
d.annotate('d', xy=(-0.2, 1.15), fontsize=14, fontweight='bold', xycoords='axes fraction')
##### Plotting E #####
y = df_exp.loc[:, variables3] # df.loc[order, y_var_names]
e.set_prop_cycle(color=colors[6:])
e.plot(x_exp, np.array(y), 'o', markersize=1, ) # See matplotlib.lines.Line2D for details
y = df_opt.loc[:, variables3] # df.loc[order, y_var_names]
e.set_prop_cycle(color=colors[6:])
e.plot(x_opt, np.array(y)) # See matplotlib.lines.Line2D for details
# Labelling
e.set_xlabel(x_label)
e.set_ylabel(y_label)
# Scientific notation
e.ticklabel_format(style='sci', scilimits=(-3,3))
e.annotate('e', xy=(-0.2, 1.15), fontsize=14, fontweight='bold', xycoords='axes fraction')
##### Plotting F #####
y = df_exp.loc[:, variables6] # df.loc[order, y_var_names]
f.set_prop_cycle(color=colors[6:])
f.plot(x_exp, np.array(y), 'o', markersize=1, ) # See matplotlib.lines.Line2D for details
y = df_opt.loc[:, variables6] # df.loc[order, y_var_names]
f.set_prop_cycle(color=colors[6:])
f.plot(x_opt, np.array(y)) # See matplotlib.lines.Line2D for details
# Labelling
f.set_xlabel(x_label)
f.set_ylabel(y_label)
# Scientific notation
f.ticklabel_format(style='sci', scilimits=(-3,3))
f.annotate('f', xy=(-0.2, 1.15), fontsize=14, fontweight='bold', xycoords='axes fraction')
# ##### Plotting G #####
x = df_con.loc[:, 'time(s)']/3600 # df.loc[:, x_var_name]
y = df_con.loc[:, 'fx'] # df.loc[order, y_var_names]
sacess = g.plot(x, y, markersize=1, color='k', label='saCeSS') # See matplotlib.lines.Line2D for details
# cc.axhline(-429.247946, linestyle=':', color=GRAY, markersize=0.3, label='Ground truth')
# ground_truth = cc.annotate('Ground truth', xy=(0.2, 0.2), xycoords='axes fraction', label='Ground truth')
g.set_title('Convergence curve', fontdict={'fontweight': 'bold'})
# cc.legend(frameon=True)
# Labelling
g.set_xlabel(x_label)
g.set_ylabel('Objective value')
# Scientific notation
g.ticklabel_format(style='sci', scilimits=(-1,1))
g.set_xscale('log')
g.annotate('g', xy=(-0.2, 1.15), fontsize=14, fontweight='bold', xycoords='axes fraction')
# a.set_title('Dot plot of cell population', fontdict={'fontweight': 'bold'})
##### Plotting H #####
h.set_axis_off()
# Legend
handles = []
for c, l in zip(colors, legend_labels1+legend_labels2+legend_labels3):
handles.append(matplotlib.lines.Line2D([], [], color=c, marker='s', linestyle='None', label=l))
styles = [matplotlib.lines.Line2D([], [], color='k', marker='_', linestyle='None', label='Simulation'), matplotlib.lines.Line2D([], [], color='k', marker='o', linestyle='None', markerfacecolor='k', label='Data', markersize=2)]
handles = handles + styles
f.legend(handles=handles, frameon=True, loc='lower left', bbox_to_anchor=(-0.25, -1.67), ncol=2, columnspacing=0.7, labelspacing=0.7, handletextpad=0.2) # lower right 1.025, -1.75
plt.savefig(image_file+'.pdf', dpi=600)
plt.savefig(image_file+'.png', dpi=600)
plt.savefig(image_file+'.svg', dpi=600)
plt.close()