-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_model_tables.m
157 lines (131 loc) · 4.74 KB
/
make_model_tables.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
% script to make tables with SS and parameter values
% exports to .xlsx files
clear all;
% filenames
% male file
fn1 = './SSbest/12-May-2023_calcium_mod_SS_sexORrep-male_notes-newmale.mat';
dat_male = load(fn1);
% female file
fn2 = './SSbest/12-May-2023_calcium_mod_SS_sexORrep-female_notes-newfemale.mat';
dat_female = load(fn2);
% preg file
fn3 = './SSbest/16-May-2023_calcium_mod_SS_sexORrep-preg_notes-PTHupdate2.mat';
dat_preg = load(fn3);
% lact file
fn4 = './SSbest/16-May-2023_calcium_mod_SS_sexORrep-lact_notes-PTHupdate2.mat';
dat_lact = load(fn4);
% check par names match for all simulations
parcheck = dat_male.param_names;
flag = 0;
for ii = 1:size(parcheck,2)
if ~strcmp(parcheck{ii}, dat_female.param_names{ii})
flag = 1;
fprintf('parval %i does not match in female and male \n', ii)
end
if ~strcmp(parcheck{ii},dat_preg.param_names{ii})
flag = 1;
fprintf('parval %i does not match in preg and male \n', ii)
end
if ~strcmp(parcheck{ii},dat_lact.param_names{ii})
flag = 1;
fprintf('parval %i does not match in lact and male \n', ii)
end
end
if flag
error('parameter names not matching')
end
%% Params table variables
VarNames = {'Male', 'Female', 'Pregnant', 'Lactation',...
'Female2Male', 'Preg2Female', 'Lact2Female', 'Lact2Preg'};
RowNames = dat_male.param_names';
ParNames = dat_male.param_names';
MalePars = dat_male.params';
FemalePars = dat_female.params';
PregPars = dat_preg.params';
LactPars = dat_lact.params';
F2Mratio = round(FemalePars./MalePars,3,'decimals');
temp = find(F2Mratio == 1.0);
F2Mratio(temp) = NaN;
P2Fratio = round(PregPars./FemalePars,3,'decimals');
temp = P2Fratio == 1.0;
P2Fratio(temp) = NaN;
L2Fratio = round(LactPars./FemalePars,3,'decimals');
temp = find(L2Fratio == 1.0);
L2Fratio(temp) = NaN;
L2Pratio = round(LactPars./PregPars,3,'decimals');
temp = find(L2Pratio == 1.0);
L2Pratio(temp) = NaN;
T_pars = table(MalePars, FemalePars, PregPars, LactPars, ...
F2Mratio, P2Fratio, L2Fratio, L2Pratio,...
'VariableNames', VarNames, ...
'RowNames', RowNames);
% fname = strcat(date, '_model_parameters.xlsx');
% writetable(T_pars, fname,...
% 'WriteRowNames', true)
%% SS values table variables
VarNames = {'Male', 'Female', 'Pregnant', 'Lactation',...
'Female2Male', 'Preg2Female', 'Lact2Female', 'Lact2Preg'};
RowNames = {'[PTHp]', '[Cap]', '[1,25(OH)2D3]',...
'PTHg', 'PTHp', 'Cap', 'D3p', 'NCaf', 'NCas',...
'GutFracAbs', 'GutAbs', ...
'BoneResorption', 'Plasma2FastPool', 'FastPool2Plasma', ...
'RenalFracReab', 'UrineExcretion', ...
'BoneAccretion'};
MaleVals = getvals(dat_male);
FemaleVals = getvals(dat_female);
PregVals = getvals(dat_preg);
LactVals = getvals(dat_lact);
F2Mratio = round(FemaleVals./MaleVals,3,'decimals');
temp = find(F2Mratio == 1.0);
F2Mratio(temp) = NaN;
P2Fratio = round(PregVals./FemaleVals,3,'decimals');
temp = P2Fratio == 1.0;
P2Fratio(temp) = NaN;
L2Fratio = round(LactVals./FemaleVals,3,'decimals');
temp = find(L2Fratio == 1.0);
L2Fratio(temp) = NaN;
L2Pratio = round(LactVals./PregVals,3,'decimals');
temp = find(L2Pratio == 1.0);
L2Pratio(temp) = NaN;
T_vars = table(MaleVals, FemaleVals, PregVals, LactVals, ...
F2Mratio, P2Fratio, L2Fratio, L2Pratio,...
'VariableNames', VarNames, ...
'RowNames', RowNames);
% fname = strcat(date, '_model_variables.xlsx');
% writetable(T_vars, fname,...
% 'WriteRowNames', true)
fname = strcat(date, '_model_results.xlsx');
writetable(T_pars, fname,'WriteRowNames',true, 'Sheet', 'parameters');
writetable(T_vars, fname, 'WriteRowNames', true, 'Sheet', 'variables');
%--------------------------
% functions used
%--------------------------
function vals = getvals(dat)
SS = dat.SS;
params = dat.params;
param_names = dat.param_names;
valsSS = dat.valsSS;
Ind_Vp = 0;
for ii = 1:size(param_names,2)
if strcmp(param_names{ii}, 'Vp')
Ind_Vp = ii;
end
end
if Ind_Vp ~= 18
fprintf('Ind_VP: %i, expected: 18 \n', Ind_Vp)
error('Vp index not same')
end
Vp = params(Ind_Vp);
vals = [SS(2)/Vp;
SS(3)/Vp;
SS(4)/Vp;
SS;
valsSS.Gut_frac_absorption;
valsSS.Gut_absorption;
valsSS.Bone_resorption;
valsSS.Plasma_to_FastPool;
valsSS.FastPool_to_Plasma;
valsSS.Renal_frac_reab;
valsSS.Urine_excretion;
valsSS.Bone_accretion];
end