-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsat_length_stats.m
325 lines (315 loc) · 11.4 KB
/
sat_length_stats.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
function [anova_sat_RC,anova_sat_PR,anova_sat_PC, anova_length_RC,anova_length_PR, anova_length_PC, anova_combo_RC,anova_combo_PR, anova_combo_PC] = sat_length_stats( mat_control, matp, matR, lipids, species )
%UNTITLED Summary of this function goes here
% % Detailed explanation goes here
% %
% mat_control=uninf;
% matp=DD2f_p_;
% matR=DD2f_R_;
% lipids=DD2f_names;
% species=species;
[r,c]=size(lipids);
group={'PL', 'SL', 'NL', 'DAG'};
match_=cell2mat(species(:,3));
anova_sat=cell.empty;
anova_chain=cell.empty;
anova_combo=cell.empty;
a_count=1;
l_count=1;
co_count=1;
for i=1:4
indx=find(match_==i);
L=species(indx,2);
saturation=double.empty;
chain_length=double.empty;
sum_=double.empty;
time_mat=double.empty;
col_label=double.empty;
levels_control=double.empty;
levels_p=double.empty;
levels_R=double.empty;
n_=1;
for k=1:length(L)
lipid=L{k}; %the name of the lipid we are including
[r,c]=size(lipids);
for j=1:r
text_=lipids{j,1};
text1=text_;
name='';
k_=strfind(text_,' ');
k1=(k_(1)-1);
for p_=1:k1
c_=text_(p_);
name=[name c_];
end
if strcmp (name, 'Acyl')==1 || strcmp(name, 'Lyso')==1
for m_=p_+1:p_+3
c_=text_(m_);
name=[name c_];
end
end
q=strfind(text_,':');
if numel(q)>0 && numel(q)<3
q1=q(1)-1;
else
q1=0;
end
if strcmp(name,lipid)==1 %same family
%look at the chain length
if q1>0
chain='';
sat_='';
Q=strfind(text_, '/');
P=strfind(text_,'-');
if numel(Q)>0
%q1=q(2)-1;
rL=Q-1;
elseif numel(P)>0
%q1=q(2)-1;
rL=P-1;
else
rL=length(text_);
end
for p_=q1-1:q1
c_=text_(p_);
chain=[chain c_] ;
end
chain = str2num(chain);
%chain_length(n_,1)=chain;
for p_=q1+2:rL
c_=text_(p_) ;
sat_=[sat_ c_];
end
sat_=str2num(sat_);
% saturation(n_,1)=sat_;
%FOR ADDING SECOND NUMBER -----------------
rL=length(text_);
if numel(Q)>0
q2=q(2)-1;
%rL=Q-1;
elseif numel(P)>0
q2=q(2)-1;
%rL=P-1;
else
q2=0;
end
if i==2 %PL
chain2='';
sat2='';
for p_=q2-1:q2
c_=text_(p_);
chain2=[chain2 c_] ;
end
chain2 = str2num(chain2);
chain_length(n_,1)=chain + chain2;
for p_=q2+2:rL
c_=text_(p_) ;
sat2=[sat2 c_];
end
sat2=str2num(sat2);
saturation(n_,1)=sat_+sat2;
elseif numel(P)>0
chain2='';
sat2='';
for p_=q2-1:q2
c_=text_(p_);
chain2=[chain2 c_] ;
end
chain2 = str2num(chain2);
chain_length(n_,1)=chain2;
for p_=q2+2:rL
c_=text_(p_) ;
sat2=[sat2 c_];
end
sat2=str2num(sat2);
saturation(n_,1)=sat2;
else
chain_length(n_,1)=chain;
saturation(n_,1)=sat_;
end
levels_control(n_,:)=mat_control(j,:);
levels_p(n_,:)=matp(j,:);
levels_R(n_,:)=matR(j,:);
col_label{n_,1}=text1;
n_=n_+1;
end
end
end
end
%make an average with time for each member of the group
%control--------------------------------------------------------------
[r1,c1]=size(levels_control);
levels_sum=sum(levels_control);
levels_percent_c=zeros(r1,c1);
for k2=1:r1
for j2=1:c1
levels_percent_c(k2,j2)=(levels_control(k2,j2)/levels_sum(j2))*100;
end
end
%parasite-------------------------------------------------------------
[r1,c1]=size(levels_p);
levels_sum=sum(levels_p);
levels_percent_p=zeros(r1,c1);
for k2=1:r1
for j2=1:c1
levels_percent_p(k2,j2)=(levels_p(k2,j2)/levels_sum(j2))*100;
end
end
%RBC-------------------------------------------------------------------
[r1,c1]=size(levels_R);
levels_sum=sum(levels_R);
levels_percent_R=zeros(r1,c1);
for k2=1:r1
for j2=1:c1
levels_percent_R(k2,j2)=(levels_R(k2,j2)/levels_sum(j2))*100;
end
end
unique_sat=unique(saturation);
stat_mat_RC=double.empty;
stat_mat_PC=double.empty;
stat_mat_PR=double.empty;
%for each saturation---------------------------------------------------
for j=1:length(unique_sat)
u=unique_sat(j);
anova_sat_RC{a_count,1}=group{i};
anova_sat_RC{a_count,2}=u;
anova_sat_PR{a_count,1}=group{i};
anova_sat_PR{a_count,2}=u;
anova_sat_PC{a_count,1}=group{i};
anova_sat_PC{a_count,2}=u;
indx=find(saturation==u);
stat_sat_c=levels_percent_c(indx,:);
stat_sat_R=levels_percent_R(indx,:);
stat_sat_p=levels_percent_p(indx,:);
[r3,c3]=size(stat_sat_c);
if r3>1
stat_sat_c=sum(stat_sat_c);
end
[r3,c3]=size(stat_sat_R);
if r3>1
stat_sat_R=sum(stat_sat_R);
end
[r3,c3]=size(stat_sat_p);
if r3>1
stat_sat_p=sum(stat_sat_p);
end
d=1;
%for each timepoint-----------------------------------------------
for k=1:6 %for each timepoint
temp=stat_sat_p(d:d+8);
group_p=temp;
temp=stat_sat_R(d:d+8);
group_R=temp ;
d=d+9;
temp=stat_sat_c(:);
group_c=temp;
[hval, pval]=ttest2(group_p,group_R, 0.05,'both', 'unequal');
anova_sat_PR{a_count,k+2}=pval;
[hval, pval]=ttest2(group_p,group_c, 0.05,'both', 'unequal');
anova_sat_PC{a_count,k+2}=pval;
[hval, pval]=ttest2(group_c,group_R, 0.05,'both','unequal');
anova_sat_RC{a_count,k+2}=pval;
end
a_count=a_count+1;
end
%length---------------------------------------------------------------
unique_length=unique(chain_length);
for j=1:length(unique_length)
u=unique_length(j);
anova_length_RC{l_count,1}=group{i};
anova_length_RC{l_count,2}=u;
anova_length_PR{l_count,1}=group{i};
anova_length_PR{l_count,2}=u;
anova_length_PC{l_count,1}=group{i};
anova_length_PC{l_count,2}=u;
indx=find(chain_length==u);
stat_length_c=levels_percent_c(indx,:);
stat_length_R=levels_percent_R(indx,:);
stat_length_p=levels_percent_p(indx,:);
[r3,c3]=size(stat_length_c);
if r3>1
stat_length_c=sum(stat_length_c);
end
[r3,c3]=size(stat_length_R);
if r3>1
stat_length_R=sum(stat_length_R);
end
[r3,c3]=size(stat_length_p);
if r3>1
stat_length_p=sum(stat_length_p);
end
d=1;
%for each timepoint-----------------------------------------------
for k=1:6 %for each timepoint
temp=stat_length_p(d:d+8);
group_p=temp;
temp=stat_length_R(d:d+8);
group_R=temp ;
d=d+9;
temp=stat_length_c(:);
group_c=temp;
[hval, pval]=ttest2(group_p,group_R, 0.05,'both', 'unequal');
anova_length_PR{l_count,k+2}=pval;
[hval, pval]=ttest2(group_p,group_c, 0.05,'both', 'unequal');
anova_length_PC{l_count,k+2}=pval;
[hval, pval]=ttest2(group_c,group_R, 0.05,'both', 'unequal');
anova_length_RC{l_count,k+2}=pval;
end
l_count=l_count+1;
end
%combo---------------------------------------------------------------
for j=1:length(unique_sat)
us=unique_sat(j);
indxs=find(saturation==us);
for j2=1:length(unique_length)
error=0;
ul=unique_length(j2);
indxl=find(chain_length==ul);
indx=intersect(indxl,indxs);
if numel(indx)>0
anova_combo_RC{co_count,1}=group{i};
anova_combo_RC{co_count,2}=us;
anova_combo_RC{co_count,3}=ul;
anova_combo_PR{co_count,1}=group{i};
anova_combo_PR{co_count,2}=us;
anova_combo_PR{co_count,3}=ul;
anova_combo_PC{co_count,1}=group{i};
anova_combo_PC{co_count,2}=us;
anova_combo_PC{co_count,3}=ul;
stat_length_c=levels_percent_c(indx,:);
stat_length_R=levels_percent_R(indx,:);
stat_length_p=levels_percent_p(indx,:);
[r3,c3]=size(stat_length_c);
if r3>1
stat_length_c=sum(stat_length_c);
end
[r3,c3]=size(stat_length_R);
if r3>1
stat_length_R=sum(stat_length_R);
end
[r3,c3]=size(stat_length_p);
if r3>1
stat_length_p=sum(stat_length_p);
end
d=1;
%for each timepoint-----------------------------------------------
for k=1:6 %for each timepoint
temp=stat_length_p(d:d+8);
group_p=temp;
temp=stat_length_R(d:d+8);
group_R=temp ;
d=d+9;
temp=stat_length_c(:);
group_c=temp;
[hval, pval]=ttest2(group_p,group_R, 0.05,'both', 'unequal');
anova_combo_PR{co_count,k+3}=pval;
[hval, pval]=ttest2(group_p,group_c, 0.05,'both', 'unequal');
anova_combo_PC{co_count,k+3}=pval;
[hval, pval]=ttest2(group_c,group_R, 0.05,'both', 'unequal');
anova_combo_RC{co_count,k+3}=pval;
end
co_count=co_count+1;
end
end
end
end
end