-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlottingFigure6APFigure.m
159 lines (118 loc) · 3.91 KB
/
PlottingFigure6APFigure.m
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
function PlottingFigure6APFigure()
% This script produces the data used to plot Figure 6
%Simulates response to action potential waveform protocol for literature models and new model (with best fitting parameters to sine wave for cell 5)
% and compares with experimental recording from cell 5
model = 'hh';
fitting_protocol={'sine_wave'};
exp_ref = '16713110';
cd ../ParameterSets
% Imports literature model parameters
W=importdata('WangModelSimulatedParameters.mat');
DV=importdata('DiVeroliRTModelSimulatedParameters.mat');
M=importdata('MazhariModelSimulatedParameters.mat');
TT=importdata('TenTusscherModelSimulatedParameters.mat');
Z=importdata('ZengTolModelSimulatedParameters.mat');
cd ..
% Identifies temperature for appropriate experiment
if strcmp(exp_ref,'16713110')==1
temperature = 21.4;
end
cd Code
% Identifies best fitting parameters to sine wave
[chain,likelihood] = FindingBestFitsAfterMCMC(model,fitting_protocol,exp_ref);
[i,v]= max(likelihood);
MP= chain(v,:);
%Import action potential protocol
cd ../Protocols
V=importdata(['ap_protocol.mat']);
cd ..
cd Code
% Identify appropriate model for simulation
[simulated_parameters,model_type] =modeldata(model);
% Import experimental data
cd ../ExperimentalData
cd(exp_ref)
E=importdata(['ap_',exp_ref,'_dofetilide_subtracted_leak_subtracted.mat']);
cd ..
cd ..
cd Code
% Simulate model with parameters identified as providing bet fit to sine wave
I = SimulatingData(model_type,{'ap'},MP,V,temperature);
% For each literature model simulation we scale the model conductance to minimise the square difference between each model simulation and the experimental
% recording in response to the action potential voltage protocol for cell 5.
% Wang model
IW = SimulatingData(27,{'ap'},W,V,temperature);
c=0;
for a = 0.000001:0.01:5
c=c+1;
Diff(1,c) = sum((E-a.*IW).^2)./length(IW);
end
[i,v]=min((Diff(1,:)));
sw = v*0.01+0.000001;
JW = sw.*IW;
IW=JW;
%DiVeroli model
ID = SimulatingData(5,{'ap'},DV,V,temperature);
c=0;
for a = 0.000001:0.01:5
c=c+1;
Diff(1,c) = sum((E-a.*ID).^2)./length(ID);
end
[i,v]=min((Diff(1,:)));
sd = v*0.01+0.000001;
JD = sd.*ID;
ID=JD;
%Mazhari model
IM = SimulatingData(16,{'ap'},M,V,temperature);
c=0;
for a = 0.000001:0.01:5
c=c+1;
Diff(1,c) = sum((E-a.*IM).^2)./length(IM);
end
[i,v]=min((Diff(1,:)));
sm = v*0.01+0.000001;
JM = sm.*IM;
IM=JM;
%TenTusscher Model
IT = SimulatingData(26,{'ap'},TT,V,temperature);
c=0;
for a = 0.000001:0.01:5
c=c+1;
Diff(1,c) = sum((E-a.*IT).^2)./length(IT);
end
[i,v]=min((Diff(1,:)));
st = v*0.01+0.000001;
JT = st.*IT;
IT=JT;
%Zeng model (note we have to use version with singularities removed to simulate action potential waveform protocol)
IZ = SimulatingData(2999,{'ap'},Z,V,temperature);
c=0;
for a = 0.000001:0.01:5
c=c+1;
Diff(1,c) = sum((E-a.*IZ).^2)./length(IZ);
end
[i,v]=min((Diff(1,:)));
sz = v*0.01+0.000001;
JZ = sz.*IZ;
IZ=JZ;
% Prepare and save data
cd ../Figures/figure_6
wang_data=[[0:0.0001:(length(V)/10000)-0.0001]',IW];
diveroli_data=[[0:0.0001:(length(V)/10000)-0.0001]',ID];
mazhari_data=[[0:0.0001:(length(V)/10000)-0.0001]',IM];
tentusscher_data=[[0:0.0001:(length(V)/10000)-0.0001]',IT];
zeng_data=[[0:0.0001:(length(V)/10000)-0.0001]',IZ];
new_model_data=[[0:0.0001:(length(V)/10000)-0.0001]',I];
experimental_data=[[0:0.0001:(length(V)/10000)-0.0001]',E];
protocol_data=[[0:0.0001:(length(V)/10000)-0.0001]',V];
save figure_6_ap_wang_prediction.txt wang_data -ascii
save figure_6_ap_diveroli_prediction.txt diveroli_data -ascii
save figure_6_ap_mazhari_prediction.txt mazhari_data -ascii
save figure_6_ap_tentusscher_prediction.txt tentusscher_data -ascii
save figure_6_ap_zeng_prediction.txt zeng_data -ascii
save figure_6_ap_new_model_prediction.txt new_model_data -ascii
save figure_6_ap_experimental_data.txt experimental_data -ascii
save figure_6_ap_protocol_data.txt protocol_data -ascii
cd ..
cd ..
cd Code