-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefig_localsens_all.m
218 lines (194 loc) · 6.35 KB
/
makefig_localsens_all.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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
% postprocess output from all the local sensitivity analysis
% output from compute_localsensitivity.m
clear all;
% male
fname = './results_localsens/16-May-2023_localsens_sexORrep-male_notes-may16.mat';
male_dat = load(fname);
% female
fname = './results_localsens/16-May-2023_localsens_sexORrep-female_notes-may16.mat';
female_dat = load(fname);
% preg
fname = './results_localsens/16-May-2023_localsens_sexORrep-preg_notes-PTH2.mat';
preg_dat = load(fname);
% lact
fname = './results_localsens/16-May-2023_localsens_sexORrep-lact_notes-PTH2.mat';
lact_dat = load(fname);
[male_xlabs, male_vals] = getdata(male_dat);
[female_xlabs, female_vals] = getdata(female_dat);
[preg_xlabs, preg_vals] = getdata(preg_dat);
[lact_xlabs, lact_vals] = getdata(lact_dat);
% sanity check: check that xlabels are the same
flag = 0;
if size(male_xlabs) ~= size(female_xlabs)
flag = 1;
elseif size(male_xlabs) ~= size(preg_xlabs)
flag = 1;
elseif size(male_xlabs) ~= size(lact_xlabs)
flag = 1;
end
for ii = 1:size(male_xlabs,2)
if ~strcmp(male_xlabs{ii}, female_xlabs{ii})
flag = 1;
elseif ~strcmp(male_xlabs{ii}, preg_xlabs{ii})
flag = 1;
elseif ~strcmp(male_xlabs{ii}, lact_xlabs{ii})
flag = 1;
end
end
if flag
error('xlabels do not match')
end
xlabels = male_xlabs;
% Make figures
temp = [male_vals, female_vals, preg_vals, lact_vals];
clims = [min(temp, [], 'all'), max(temp, [], 'all')];
ylabels = {'[PTH]_p', '[Ca^{2+}]_p', '[1,25(OH)_2D_3]_p'};
fsize = 14;
colmap = parula;
cmissdat = 'w';
labmissdat = '<1.0%';
% figure without removing
fig_noremove = 0;
if fig_noremove
figure(1)
clf
% male fig
subplot(4,1,1)
h1 = heatmap(xlabels, ylabels, male_vals,...
'colormap', colmap,...
'MissingDataColor', cmissdat, 'MissingDataLabel', labmissdat, ...
'ColorLimits', clims, 'colorbarvisible', 'off');
h1.FontSize = fsize;
ylabel('Male')
% female fig
subplot(4,1,2)
h1 = heatmap(xlabels, ylabels, female_vals,...
'colormap', colmap,...
'MissingDataColor', cmissdat, 'MissingDataLabel', labmissdat, ...
'ColorLimits', clims, 'colorbarvisible', 'on');
h1.FontSize = fsize;
ylabel('Female')
% preg fig
subplot(4,1,3)
h1 = heatmap(xlabels, ylabels, preg_vals,...
'colormap', colmap,...
'MissingDataColor', cmissdat, 'MissingDataLabel', labmissdat, ...
'ColorLimits', clims, 'colorbarvisible', 'off');
h1.FontSize = fsize;
ylabel('Pregnancy')
% lact fig
subplot(4,1,4)
h1 = heatmap(xlabels, ylabels, lact_vals,...
'colormap', colmap,...
'MissingDataColor', cmissdat, 'MissingDataLabel', labmissdat, ...
'ColorLimits', clims, 'colorbarvisible', 'off');
h1.FontSize = fsize;
ylabel('Lactation')
end
% remove Nan values
Nan_male = find_all_Nan(male_vals);
Nan_female = find_all_Nan(female_vals);
temp = intersect(Nan_male, Nan_female);
Nan_preg = find_all_Nan(preg_vals);
temp = intersect(temp, Nan_preg);
Nan_lact = find_all_Nan(lact_vals);
AllNan = intersect(temp, Nan_lact);
[xlabs_rm, male_vals_rm] = removeAllNan(AllNan, xlabels, male_vals);
[~, female_vals_rm] = removeAllNan(AllNan, xlabels, female_vals);
[~, preg_vals_rm] = removeAllNan(AllNan, xlabels, preg_vals);
[~, lact_vals_rm] = removeAllNan(AllNan, xlabels, lact_vals);
% change gamma_fetusORmilk
rmxlabs_preg = xlabs_rm;
for ii = 1:length(rmxlabs_preg)
disp(rmxlabs_preg{ii})
if strcmp(rmxlabs_preg{ii}, '\Gamma_{x}')
rmxlabs_preg{ii} = '\Gamma_{Fetus}';
end
end
rmxlabs_lact = xlabs_rm;
for ii = 1:length(rmxlabs_lact)
if strcmp(rmxlabs_lact{ii}, '\Gamma_{x}')
rmxlabs_lact{ii} = '\Gamma_{Milk}';
end
end
% figure with removing
fig_remove = 1;
if fig_remove
figure(2)
clf
% male fig
subplot(4,1,1)
h1 = heatmap(xlabs_rm, ylabels, male_vals_rm,...
'colormap', colmap,...
'MissingDataColor', cmissdat, 'MissingDataLabel', labmissdat, ...
'ColorLimits', clims, 'colorbarvisible', 'off');
h1.FontSize = fsize;
ylabel('Male')
% remove xlabels
%Ax = gca;
%Ax.XDisplayLabels = nan(size(Ax.XDisplayData));
% female fig
subplot(4,1,2)
h1 = heatmap(xlabs_rm, ylabels, female_vals_rm,...
'colormap', colmap,...
'MissingDataColor', cmissdat, 'MissingDataLabel', labmissdat, ...
'ColorLimits', clims, 'colorbarvisible', 'off');
h1.FontSize = fsize;
ylabel('Female')
% remove xlabels
%Ax = gca;
%Ax.XDisplayLabels = nan(size(Ax.XDisplayData));
% preg fig
subplot(4,1,3)
h1 = heatmap(rmxlabs_preg, ylabels, preg_vals_rm,...
'colormap', colmap,...
'MissingDataColor', cmissdat, 'MissingDataLabel', labmissdat, ...
'ColorLimits', clims, 'colorbarvisible', 'on');
h1.FontSize = fsize;
ylabel('Pregnancy')
% remove xlabels
%Ax = gca;
%Ax.XDisplayLabels = nan(size(Ax.XDisplayData));
% lact fig
subplot(4,1,4)
h1 = heatmap(rmxlabs_lact, ylabels, lact_vals_rm,...
'colormap', colmap,...
'MissingDataColor', cmissdat, 'MissingDataLabel', labmissdat, ...
'ColorLimits', clims, 'colorbarvisible', 'off');
h1.FontSize = fsize;
ylabel('Lactation')
%sgtitle('Local sensitivity analysis', 'fontsize', 24)
end
%------------------
% functions used
%------------------
function [xlabels, round_data] = getdata(dat)
frac_sens = dat.frac_change;
labels = cell(size(dat.param_names));
for ii = 1:size(dat.param_names, 2)
labels{ii} = convert_param_name(dat.param_names{ii});
end
xlabels = labels;
round_data = round(frac_sens', 2, 'significant');
[r,c] = find(abs(round_data) <= 1.0);% r - row values, c - column value
for ii = 1:length(r)
round_data(r(ii),c(ii)) = NaN;
end
end
function AllNan_vals = find_all_Nan(round_data)
% finds which indices are all Nan values
PTH_Nan = find(isnan(round_data(1,:)));
Ca_Nan = find(isnan(round_data(2,:)));
temp = intersect(PTH_Nan, Ca_Nan);
D3_Nan = find(isnan(round_data(3,:)));
AllNan_vals = intersect(temp, D3_Nan);
end
function [rmNan_xlabels, rmNan_round_data] = removeAllNan(AllNan_vals, xlabels, round_data)
% removes columns listed in indices from AllNan_vals
rmNan_round_data = round_data;
rmNan_xlabels = xlabels;
rmNan_round_data(:,AllNan_vals) = [];
for ii = length(AllNan_vals):-1:1
rmNan_xlabels(AllNan_vals(ii)) = [];
end
end