forked from MorrisStatLab/FunctionalQuantileRegression
-
Notifications
You must be signed in to change notification settings - Fork 0
/
figures_and_tables.m
324 lines (270 loc) · 8.15 KB
/
figures_and_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
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
322
323
324
clear;
%% Figure 1
load('Y:/submission/realdata/ProteomicsData.mat');
% x_12096 and Yraw refer to the spectral locations (in Daltons) and
% functional responses of the raw (i.e. unpreprocessed) spectrometry
% dataset that covers the spectral region [4000D, 40000D] and
% includes 12096 observations per spectrum.
% Y_6654, the starting point of the dataset for which we performed FQR,
% was preprocessed from Yraw including baseline correction,
% normalization, denoising and log2 transformation.
% x_6654_new and Y_6654 include only part of the spectral region surveyed
% in x_12096 and Yraw, i.e. [4000D, 19154D] with 6654 observations
% per spectrum.
idx1=(x_12096>=5e3 & x_12096<=8e3);
idx2=(x_6654_new>=5e3 & x_6654_new<=8e3);
g=figure;
subplot(2,2,1)
plot(x_12096(idx1),Yraw(1,idx1),'k-')
xlim([5e3 8e3])
title('(a)')
xlabel('m/z(Daltons)')
ylabel('Intensity')
subplot(2,2,2)
plot(x_6654_new(idx2),Y_6654(1,idx2),'k-')
xlim([5e3 8e3])
title('(b)')
xlabel('m/z(Daltons)')
ylabel('Intensity (log_2 scale)')
subplot(2,2,3)
plot(x_12096(idx1),Yraw(2,idx1),'k-')
xlim([5e3 8e3])
title('(c)')
xlabel('m/z(Daltons)')
ylabel('Intensity')
subplot(2,2,4)
plot(x_6654_new(idx2),Y_6654(2,idx2),'k-')
xlim([5e3 8e3])
title('(d)')
xlabel('m/z(Daltons)')
ylabel('Intensity (log_2 scale)')
savefig(g,'Y:/submission/Figure1.fig')
close(g)
clear;
%% Figure 2
x0=dlmread('Y:/submission/realdata/x0.txt');
X=dlmread('Y:/submission/realdata/X.txt');
Y=dlmread('Y:/submission/realdata/Y.txt');
[n,p]=size(X);
T=size(Y,2);
idx=find(x0>5764 & x0<5765);
y1=Y(X(:,2)==1,idx);
y2=Y(X(:,2)==-1,idx);
g=figure;
subplot(2,2,[1,2])
plot(x0,mean(Y(X(:,2)==1,:))-mean(Y(X(:,2)==-1,:)),'k-')
hold on
plot(x0,quantile(Y(X(:,2)==1,:),0.1)-quantile(Y(X(:,2)==-1,:),0.1),'b-')
plot(x0,quantile(Y(X(:,2)==1,:),0.25)-quantile(Y(X(:,2)==-1,:),0.25),'g-')
plot(x0,quantile(Y(X(:,2)==1,:),0.5)-quantile(Y(X(:,2)==-1,:),0.5),'y-')
plot(x0,quantile(Y(X(:,2)==1,:),0.75)-quantile(Y(X(:,2)==-1,:),0.75),'r-')
plot(x0,quantile(Y(X(:,2)==1,:),0.9)-quantile(Y(X(:,2)==-1,:),0.9),'m-')
xlim([5e3 8e3])
ylim([-1.5 2.5])
plot([5764.1 5764.1],[-2 3],'color',[0.8 0.8 0.8])
title('(a)')
legend('mean','0.1','0.25','0.5','0.75','0.9')
legend('boxoff')
hold off
subplot(2,2,3)
h1=histfit(y1,15,'kernel');
set(h1(1),'EdgeColor','none');
h1(1).FaceColor = [0.8 0.8 0.8];
h1(2).Color = [0.5 0.5 0.5];
hold on
h1a=plot([mean(y1) mean(y1)],[0 22],'k-');
h1b=plot([quantile(y1,0.1) quantile(y1,0.1)],[0 14],'b-');
h1c=plot([quantile(y1,0.25) quantile(y1,0.25)],[0 25],'g-');
h1d=plot([quantile(y1,0.5) quantile(y1,0.5)],[0 27],'y-');
h1e=plot([quantile(y1,0.75) quantile(y1,0.75)],[0 11],'r-');
h1f=plot([quantile(y1,0.9) quantile(y1,0.9)],[0 7],'m-');
xlim([min(Y(:,idx))-0.5 max(Y(:,idx))+0.5])
title('(b)')
legend([h1a h1b h1c h1d h1e h1f],{'mean','0.1','0.25','0.5','0.75','0.9'})
legend('boxoff')
hold off
subplot(2,2,4)
h2=histfit(y2,12,'kernel');
set(h2(1),'EdgeColor','none');
h2(1).FaceColor = [0.8 0.8 0.8];
h2(2).Color = [0.5 0.5 0.5];
hold on
h2a=plot([mean(y2) mean(y2)],[0 33],'k-');
h2b=plot([quantile(y2,0.1) quantile(y2,0.1)],[0 9],'b-');
h2c=plot([quantile(y2,0.25) quantile(y2,0.25)],[0 33],'g-');
h2d=plot([quantile(y2,0.5) quantile(y2,0.5)],[0 33],'y-');
h2e=plot([quantile(y2,0.75) quantile(y2,0.75)],[0 42],'r-');
h2f=plot([quantile(y2,0.9) quantile(y2,0.9)],[0 13],'m-');
xlim([min(Y(:,idx))-0.5 max(Y(:,idx))+0.5])
ylim([0 45])
title('(c)' )
legend([h2a h2b h2c h2d h2e h2f],{'mean','0.1','0.25','0.5','0.75','0.9'})
legend('boxoff')
hold off
savefig(g,'Y:/submission/Figure2.fig')
close(g)
clear;
%% Figure 3
x0=dlmread('Y:/submission/simulations1/x0.txt');
beta2=dlmread('Y:/submission/simulations1/beta2.txt');
g=figure;
subplot(2,2,1)
plot(x0,beta2(1,:),'b-')
hold on
plot(x0,beta2(2,:),'g-')
plot(x0,beta2(3,:),'y-')
plot(x0,beta2(4,:),'r-')
plot(x0,beta2(5,:),'m-')
xlim([0 15])
ylim([-2.7 2.7])
title('(a)')
legend('0.1','0.2','0.5','0.8','0.9')
legend('boxoff')
hold off
x0=dlmread('Y:/submission/simulations2/x0.txt');
beta2=dlmread('Y:/submission/simulations2/beta2.txt');
subplot(2,2,2)
plot(x0,beta2(1,:),'b-')
hold on
plot(x0,beta2(2,:),'g-')
plot(x0,beta2(3,:),'y-')
plot(x0,beta2(4,:),'r-')
plot(x0,beta2(5,:),'m-')
xlim([0 15])
ylim([-2.7 2.7])
title('(b)')
legend('0.1','0.2','0.5','0.8','0.9')
legend('boxoff')
hold off
subplot(2,2,3)
load('Y:/submission/simulations1/data/model1.mat')
plot(model.x0,model.Y(1,:),'r-.')
hold on
plot(model.x0,model.Y(324,:),'k-')
title('(c)')
xlabel('\it t','Interpreter','tex')
ylabel('\it y','Interpreter','tex')
legend('Group 1','Group 2','location','Northeast')
legend('boxoff')
hold off
subplot(2,2,4)
load('Y:/submission/simulations2/data/model1.mat')
plot(model.x0,model.Y(146,:),'r-.')
hold on
plot(model.x0,model.Y(201,:),'k-')
title('(d)')
xlabel('\it t','Interpreter','tex')
ylabel('\it y','Interpreter','tex')
legend('Group 1','Group 2','location','Northeast')
legend('boxoff')
hold off
savefig(g,'Y:/submission/Figure3.fig')
close(g)
clear;
%% Figure 4
addpath('Y:/submission/Plotfunctions');
alpha=0.05;
delta=log2(1.5)/2;
x0=dlmread('Y:/submission/realdata/x0.txt');
Y=dlmread('Y:/submission/realdata/Y.txt');
qt=0.9;
% Bayesian FQR
MCMC_P1=dlmread(sprintf('Y:/submission/realdata/output/HS/MCMC_betat_%d.txt',qt*100));
[SimBaS1,upr1,lwr1]=jointband_simbas(MCMC_P1,alpha);
upr1_pt=mean(MCMC_P1)+1.96*std(MCMC_P1);
lwr1_pt=mean(MCMC_P1)-1.96*std(MCMC_P1);
flag1=(SimBaS1<0.05) & (abs(mean(MCMC_P1))>delta);
flag1=flag_contiguous_sites(flag1);
idx1=find(flag1~=0);
% QR with wavelet denoising
MCMC_P2=dlmread(sprintf('Y:/submission/realdata/output/freqQR/wavelets/BS_betat_%d.txt',qt*100));
[SimBaS2,upr2,lwr2]=jointband_simbas(MCMC_P2,alpha);
upr2_pt=mean(MCMC_P2)+1.96*std(MCMC_P2);
lwr2_pt=mean(MCMC_P2)-1.96*std(MCMC_P2);
flag2=(SimBaS2<0.05) & (abs(mean(MCMC_P2))>delta);
flag2=flag_contiguous_sites(flag2);
idx2=find(flag2~=0);
% GFMM mean regression
MCMC_P3=dlmread('Y:/submission/realdata/output/GFMM/MCMC_betat.txt');
[SimBaS3,upr3,lwr3]=jointband_simbas(MCMC_P3,alpha);
upr3_pt=mean(MCMC_P3)+1.96*std(MCMC_P3);
lwr3_pt=mean(MCMC_P3)-1.96*std(MCMC_P3);
flag3=(SimBaS3<0.05) & (abs(mean(MCMC_P3))>delta);
flag3=flag_contiguous_sites(flag3);
idx3=find(flag3~=0);
% plot
g=figure;
subplot(3,1,1)
x=[x0',fliplr(x0')];
y=[lwr1,fliplr(upr1)];
ypt=[lwr1_pt,fliplr(upr1_pt)];
h=fill(x,y,[0.8 0.8 0.8],x,ypt,[0.5 0.5 0.5]);
set(h,'EdgeColor','none');
hold on
plot(x0,mean(MCMC_P1),'k-')
hline = refline([0 delta]);
hline.Color = 'g';
hline = refline([0 -delta]);
hline.Color = 'g';
hline = refline([0 0]);
hline.Color = 'b';
xlim([5e3 8e3])
ylim([-1 1.5])
for i=1:size(idx1,2)
plot([x0(idx1(i)) x0(idx1(i))],[-1 -0.92],'r-');
end
title('(a)')
xlabel('m/z(Daltons)')
ylabel('Intensity (log_2 scale)')
hold off
subplot(3,1,2)
x=[x0',fliplr(x0')];
y=[lwr2,fliplr(upr2)];
ypt=[lwr2_pt,fliplr(upr2_pt)];
h=fill(x,y,[0.8 0.8 0.8],x,ypt,[0.5 0.5 0.5]);
set(h,'EdgeColor','none');
hold on
plot(x0,mean(MCMC_P2),'k-')
hline = refline([0 delta]);
hline.Color = 'g';
hline = refline([0 -delta]);
hline.Color = 'g';
hline = refline([0 0]);
hline.Color = 'b';
xlim([5e3 8e3])
ylim([-1 1.5])
for i=1:size(idx2,2)
plot([x0(idx2(i)) x0(idx2(i))],[-1 -0.92],'r-');
end
title('(b)')
xlabel('m/z(Daltons)')
ylabel('Intensity (log_2 scale)')
hold off
subplot(3,1,3)
x=[x0',fliplr(x0')];
y=[lwr3,fliplr(upr3)];
ypt=[lwr3_pt,fliplr(upr3_pt)];
h=fill(x,y,[0.8 0.8 0.8],x,ypt,[0.5 0.5 0.5]);
set(h,'EdgeColor','none');
hold on
plot(x0,mean(MCMC_P3),'k-')
hline = refline([0 delta]);
hline.Color = 'g';
hline = refline([0 -delta]);
hline.Color = 'g';
hline = refline([0 0]);
hline.Color = 'b';
xlim([5e3 8e3])
ylim([-1 1.5])
for i=1:size(idx3,2)
plot([x0(idx3(i)) x0(idx3(i))],[-1 -0.92],'r-');
end
title('(c)')
xlabel('m/z(Daltons)')
ylabel('Intensity (log_2 scale)')
hold off
orient(g,'tall')
savefig(g,'Y:/submission/Figure4.fig')
close(g)
clear;
rmpath('Y:/submission/Plotfunctions');