-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostprocess_localsensitivity.m
More file actions
162 lines (133 loc) · 4.68 KB
/
postprocess_localsensitivity.m
File metadata and controls
162 lines (133 loc) · 4.68 KB
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
clear all
% This script can be used to postprocess the local sensitivity analysis
% results
fname = "./Sensitivity/2024-01-15_LocalAnalysis_50days.csv";
dat = readtable(fname);
fname = "./Sensitivity/2023-11-30_LocalAnalysis_50days_base_vals.csv";
base_vals = readtable(fname);
base_Kplas = base_vals.K_plasma;
base_Kmusc = base_vals.K_musc;
%% Get nice parameter names
ParNames = [];
for ii = 1:length(dat.ParameterName)
pname = dat.ParameterName{ii};
%disp(pname)
temp = change_parname(pname);
ParNames = [ParNames; temp];
end
%% Get percent change
up_per = zeros(length(dat.ParameterName), 2);
down_per = zeros(size(up_per));
up_down_per = zeros(size(up_per));
% increase by 10%
up_per(:,1) = (dat.Kplas_Increase - base_Kplas)./base_Kplas * 100.0;
up_per(:,2) = (dat.Kmusc_Increase - base_Kmusc)./base_Kmusc * 100.0;
% decrease by 10%
down_per(:,1) = (dat.Kplas_Decrease - base_Kplas)./base_Kplas * 100.0;
down_per(:,2) = (dat.Kmusc_Decrease - base_Kmusc)./base_Kmusc * 100.0;
% increase by 10% - decrease by 10%
up_down_per(:,1) = (dat.Kplas_Increase - dat.Kplas_Decrease)./base_Kplas * 100.0;
up_down_per(:,2) = (dat.Kmusc_Increase - dat.Kmusc_Decrease)./base_Kmusc * 100.0;
%% Make figures
xlabels = ParNames; %dat.ParameterName;
ylabels_updown = {'\Delta K_{plasma, i}', '\Delta K_{intracellular, i}'};
ylabels_up = {'\Delta K_{plasma, i}^{+10%}', '\Delta K_{intracellular, i}^{+10%}'};
ylabels_down = {'\Delta K_{plasma, i}^{-10%}', '\Delta K_{intracellular, i}^{-10%}'};
%% Figure with up 10 percent
% Up percent
% Find values less than 2%
up_per_h = round(up_per, 2,"significant"); % up_per for heatmap
[r,c] = find(abs(up_per_h) < 1.0);
for ii = 1:length(r)
up_per_h(r(ii), c(ii)) = NaN;
end
figure(1)
clf;
h = heatmap(xlabels, ylabels_up, up_per',...
'colormap', parula, ...
'MissingDataColor', 'w', 'MissingDataLabel', '<2%');
% h = heatmap(xlabels, ylabels_up, up_per_h',...
% 'colormap', parula, ...
% 'MissingDataColor', 'w', 'MissingDataLabel', '<2%');
h.FontSize = 14;
%% Down 10 percent
% Down percent
down_per_h = round(down_per, 2, "significant");
[r,c] = find(abs(down_per_h) < 1.0);
for ii = 1:length(r)
down_per_h(r(ii),c(ii)) = NaN;
end
figure(2)
clf;
h = heatmap(xlabels, ylabels_down, down_per',...
'colormap', parula, ...
'MissingDataColor', 'w', 'MissingDataLabel', '<2%');
% h = heatmap(xlabels, ylabels, down_per_h',...
% 'colormap', parula, ...
% 'MissingDataColor', 'w', 'MissingDataLabel', '<2%');
h.FontSize = 14;
%% Up/Down percent
% Up/Down percent
up_down_per_h = round(up_down_per, 2, "significant");
[r,c] = find(abs(up_down_per_h) < 2.0);
for ii = 1:length(r)
up_down_per_h(r(ii), c(ii)) = NaN;
end
figure(3)
clf;
h = heatmap(xlabels, ylabels_updown, up_down_per_h',...
'colormap', parula, ...
'MissingDataColor', 'w', 'MissingDataLabel', '<2%');
h.FontSize = 14;
fprintf('done \n')
%% Figures with removed values
% Remove where both NaN
rows_notAllNan = find(~all(isnan(up_down_per_h), 2));
% remove V
mask = ~ismember(rows_notAllNan, [2,4]);
rows_notAllNan = rows_notAllNan(mask);
xlabels = ParNames(rows_notAllNan);
up_down_per_h2 = up_down_per_h(rows_notAllNan, :);
up_per_h2 = up_per_h(rows_notAllNan, :);
down_per_h2 = down_per_h(rows_notAllNan, :);
% Switch the order by largest impact on K_IC
[~, sortIDs] = sort(up_down_per_h2(:,2));
% shift so mKALDO is in the right index
index = 7;
% Remove the last element from the array
lastElement = sortIDs(end);
sortIDs(end) = [];
% Insert the last element at the desired index
sortIDs = [sortIDs(1:index-1); lastElement; sortIDs(index:end)];
up_down_per_h2 = up_down_per_h2(sortIDs,:);
up_per_h2 = up_per_h2(sortIDs,:);
down_per_h2 = down_per_h2(sortIDs,:);
xlabels = xlabels(sortIDs);
figure(4)
clf
minValue = min(min([up_per_h2(:); down_per_h2(:)]));
maxValue = max(max([up_per_h2(:); down_per_h2(:)]));
subplot(2,1,1)
h1 = heatmap(xlabels, ylabels_up, up_per_h2',...
'colormap', parula, ...
'MissingDataColor', 'w', 'MissingDataLabel', '<1%');
h1.FontSize = 18;
% Apply the common color limits
h1.ColorLimits = [minValue, maxValue];
% figure(5)
% clf
subplot(2,1,2)
h2 = heatmap(xlabels, ylabels_down, down_per_h2',...
'colormap', parula, ...
'MissingDataColor', 'w', 'MissingDataLabel', '<1%');
h2.FontSize = 18;
h2.ColorLimits = [minValue, maxValue];
%% Up down per
figure(6)
clf;
h = heatmap(xlabels, ylabels_updown, up_down_per_h2',...
'colormap', parula, ...
'MissingDataColor', 'w', 'MissingDataLabel', '<2%');
h.FontSize = 14;
fprintf('done \n')
% Up_per with rows_notAllNan