-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepBloodData.m
145 lines (130 loc) · 3.92 KB
/
prepBloodData.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
function bloodData = prepBloodData(showPlot, exportData, useBloodFlowModel)
% Prepares the blood data by loading it from disk, fitting a linear model to
% the diffusion coefficients, etc.
%
% Make sure the path is in the project base before continuing
%
if (nargin < 1)
showPlot = false;
end
if (nargin < 2)
exportData = false;
end
if (nargin < 3)
useBloodFlowModel = false;
end
%read metabolites and constraints from the excel file with metabolite
%concentrations in blood
bloodConcTable = readtable('data/BloodData.txt');
metabolites = bloodConcTable{:,1};
bloodConc = bloodConcTable{:,2};
diffCoeff = bloodConcTable{:,3};
mw = bloodConcTable{:,4};
%We do not have all metabolites. Estimate those from the others using a
%linear model on MW
filt = ~isnan(diffCoeff);
%don't use diffusion coefficients for oxygen and albumin in the model, they
%have very different MW - the linearity only holds in small intervals
filt2 = filt & ~ismember(metabolites, {'O2','NEFA blood pool in','cholesterol','albumin'});
x = mw(filt2);
y = diffCoeff(filt2);
fit = fitlm(x,y);
fit %show R^2 for the fit, 0.665
%save to file for plot in R
if showPlot
figure
plot(fit)
xlabel('Molecular weight')
ylabel('Diffusion constant')
end
if exportData
%export the x and y to file so we can plot it in R
plotExp = struct;
plotExp.x = x;
plotExp.y = y;
plotExp.mets = metabolites(filt2);
save('data/diffCoeff.mat', 'plotExp')
end
diffCoeff(~filt) = predict(fit, mw(~filt));
if ~useBloodFlowModel
CxD = bloodConc.*diffCoeff;
else
%Here, we don't multiply with the diffusion coefficient.
%We also increase the oxygen concentration
CxD = bloodConc;
CxD(strcmp(metabolites,'O2')) = 9200; %9200 (9.2 mmolar)comes from "The oxygen status of the arterial blood revised: relevant oxygen parameters for monitoring the arterial oxygen availability"
end
% hamsMediaMets ={'glucose'
% 'arginine'
% 'histidine'
% 'lysine'
% 'methionine'
% 'phenylalanine'
% 'tryptophan'
% 'tyrosine'
% 'alanine'
% 'glycine'
% 'serine'
% 'threonine'
% 'aspartate'
% 'glutamate'
% 'asparagine'
% 'glutamine'
% 'isoleucine'
% 'leucine'
% 'proline'
% 'valine'
% 'cysteine'
% 'thiamin'
% 'hypoxanthine'
% 'folate'
% 'biotin'
% 'pantothenate'
% 'choline'
% 'inositol'
% 'nicotinamide'
% 'pyridoxine'
% 'riboflavin'
% 'thymidine'
% 'aquacob(III)alamin'
% 'lipoic acid'
% 'sulfate'
% 'linoleate'
% 'linolenate'
% 'O2'
% 'H2O'
% 'retinoate'
% 'Fe2+'
% 'Pi'
% 'alpha-tocopherol'
% 'gamma-tocopherol'};
%check which metabolites in ham's media that are not present in the blood
%data
%uniqueInHam = setdiff(hamsMediaMets, metabolites);
%uniqueInHam
%There are a lot of vitamins etc in the Ham's media that causes problems if left
%unconstrained. We use the strategy to set these to a small value, such as
%the flux of the metabolite with the smallest detected concentration in blood
%times 10 times the proportionality constant.
constrainedHamMets={
'alpha-tocopherol'
'aquacob(III)alamin'
'biotin'
'folate'
'gamma-tocopherol'
'inositol'
'linoleate'
'linolenate'
'lipoic acid'
'nicotinamide'
'pantothenate'
'pyridoxine'
'retinoate'
'riboflavin'
'thiamin'
'thymidine'
'hypoxanthine'};
bloodData.totDxC = [CxD;repmat(min(CxD)*10, length(constrainedHamMets),1)];
bloodData.totMets = [metabolites; constrainedHamMets];
bloodData.totMets = strcat(bloodData.totMets, '[e]');
%table(bloodData.totMets, bloodData.totDxC)