-
Notifications
You must be signed in to change notification settings - Fork 0
/
CEP1_PCA_DBSCAN_plot_cropped.m
319 lines (277 loc) · 10.1 KB
/
CEP1_PCA_DBSCAN_plot_cropped.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
clear; clc;
dbscan_res_file = 'E:\Septin_structure_analysis\updated_pictures\data7\CEP1_structures\DBSCAN.mat';
load(dbscan_res_file);
bLab{1} = {'001', '002', '005', '016'};
bLab{2} = {'001', '003', '004', '009', '010', '012'};
bLab{3} = {'007', '012', '013', '021', '022', '024'};
bLoc{1} = 'CEP1 Structures/Control CEP1 Structures/Ctrl_CEP1-EGFP_';
bLoc{2} = 'CEP1 Structures/Septin7-Knockdown CEP1 Structures/Sept7-KD_CEP1-EGFP_';
bLoc{3} = 'CEP1 Structures/100uM FCF CEP1 Structures/100uM FCF_CEP1-EGFP_';
b_IDX = cell(1,3);
b_IDX_rest = cell(1,3);
b_IDX_unclassified = cell(1,3);
cnt = 0;
cnt2 = 0;
cl_num = max(unique(cl_idx_sel));
for uu = 1:3
ulab = bLab{uu};
for w = 1:length(ulab)
disp([uu,w]);
loc = [bLoc{uu} ulab{w}];
load([loc '.mat']);
ndat = size(features1,1);
im_obj_ids = unique(sort(Lexcl(Lexcl>0)));
sel_indx = filt_vect(cnt+1:cnt+ndat);
im_obj_sel_ids = im_obj_ids(sel_indx);
ndat2 = sum(sel_indx);
indx = cl_idx_sel(cnt2+1:cnt2+ndat2);
indx_init = cl_idx(cnt2+1:cnt2+ndat2);
b_IDX{uu}{w} = {};
for cl_id = 1:length(cl_top_idx)
im_indx = ismember(Lexcl(:), im_obj_sel_ids(indx == cl_id));
b_IDX{uu}{w}{cl_id} = im_indx;
end
b_IDX_unclassified{uu}{w} = ismember(Lexcl(:), im_obj_sel_ids(indx_init == -1));
rest_indx = (~ismember(indx_init, cl_top_idx)) & (indx_init ~= -1);
b_IDX_rest{uu}{w} = ismember(Lexcl(:), im_obj_sel_ids(rest_indx));
cnt = cnt + ndat;
cnt2 = cnt2 + ndat2;
end
end
fr_size = [300, 300];
cm = jet(cl_num);
fig = figure();
uu = 1;
ulab = bLab{uu};
w = 4;
loc = [bLoc{uu} ulab{w}];
mkdir([loc '_PCA_DBSCAN_plot_crop']);
fr_loc = [1100 1300];
load([loc '.mat']);
IM_rgb = zeros(size(Lexcl, 1), size(Lexcl, 2), 3);
IM_rgb_crop = zeros(fr_size(1), fr_size(2), 3);
for cl_id_i = 1:length(cl_top_idx)
cl_id = cl_top_idx(cl_id_i);
im_indx = b_IDX{uu}{w}{cl_id_i};
IM_r = zeros(size(Lexcl));
IM_g = zeros(size(Lexcl));
IM_b = zeros(size(Lexcl));
IM_r(im_indx) = cm(cl_id,1);
%IM_r(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1) = 1;
IM_g(im_indx) = cm(cl_id,2);
IM_b(im_indx) = cm(cl_id,3);
IM_rgb(:,:,1) = IM_rgb(:,:,1) + IM_r;
IM_rgb(:,:,2) = IM_rgb(:,:,2) + IM_g;
IM_rgb(:,:,3) = IM_rgb(:,:,3) + IM_b;
IM_rgb_i = zeros(size(Lexcl, 1), size(Lexcl, 2), 3);
IM_rgb_i(:,:,1) = IM_r;
IM_rgb_i(:,:,2) = IM_g;
IM_rgb_i(:,:,3) = IM_b;
IM_r_crop = IM_r(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_g_crop = IM_g(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_b_crop = IM_b(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_rgb_crop(:,:,1) = IM_rgb_crop(:,:,1) + IM_r_crop;
IM_rgb_crop(:,:,2) = IM_rgb_crop(:,:,2) + IM_g_crop;
IM_rgb_crop(:,:,3) = IM_rgb_crop(:,:,3) + IM_b_crop;
IM_rgb_crop_i = zeros(fr_size(1), fr_size(2), 3);
IM_rgb_crop_i(:,:,1) = IM_r_crop;
IM_rgb_crop_i(:,:,2) = IM_g_crop;
IM_rgb_crop_i(:,:,3) = IM_b_crop;
clf;
hold on;
axis ij;
axis off;
image(IM_rgb_crop_i);
set(gca, 'box','off','XTickLabel',[],'XTick',[],'YTickLabel',[],'YTick',[])
set(gca,'position',[0 0 1 1]);
set(gca, 'XLim', [0 fr_size(1)], 'YLim', [0 fr_size(2)]);
set(fig,'PaperUnits','points');
set(fig,'PaperSize',[fr_size(1) fr_size(1)]);
set(fig,'PaperPosition',[0 0 fr_size(1) fr_size(2)]);
set(gca,'Color','k');
fig.Color = 'black';
fig.InvertHardcopy = 'off';
drawnow;
saveas(fig, [loc '_PCA_DBSCAN_plot_crop', '\cluster=' num2str(cl_id) '.png']);
end
% set(fig, 'Position',get(0,'Screensize'));
% clf;
% hold on;
% axis ij;
% axis image;
% axis off;
% image(IM_rgb);
% title('all selected clusters');
% drawnow;
clf;
hold on;
axis ij;
axis off;
image(IM_rgb_crop);
set(gca, 'box','off','XTickLabel',[],'XTick',[],'YTickLabel',[],'YTick',[])
set(gca,'position',[0 0 1 1]);
set(gca, 'XLim', [0 fr_size(1)], 'YLim', [0 fr_size(2)]);
set(fig,'PaperUnits','points');
set(fig,'PaperSize',[fr_size(1) fr_size(1)]);
set(fig,'PaperPosition',[0 0 fr_size(1) fr_size(2)]);
set(gca,'Color','k');
fig.Color = 'black';
fig.InvertHardcopy = 'off';
drawnow;
saveas(fig, [loc '_PCA_DBSCAN_plot_crop', '\all selected clusters.png']);
uu = 2;
ulab = bLab{uu};
w = 3;
loc = [bLoc{uu} ulab{w}];
mkdir([loc '_PCA_DBSCAN_plot_crop']);
fr_loc = [1100 850];
load([loc '.mat']);
IM_rgb = zeros(size(Lexcl, 1), size(Lexcl, 2), 3);
IM_rgb_crop = zeros(fr_size(1), fr_size(2), 3);
for cl_id_i = 1:length(cl_top_idx)
cl_id = cl_top_idx(cl_id_i);
im_indx = b_IDX{uu}{w}{cl_id_i};
IM_r = zeros(size(Lexcl));
IM_g = zeros(size(Lexcl));
IM_b = zeros(size(Lexcl));
IM_r(im_indx) = cm(cl_id,1);
%IM_r(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1) = 1;
IM_g(im_indx) = cm(cl_id,2);
IM_b(im_indx) = cm(cl_id,3);
IM_rgb(:,:,1) = IM_rgb(:,:,1) + IM_r;
IM_rgb(:,:,2) = IM_rgb(:,:,2) + IM_g;
IM_rgb(:,:,3) = IM_rgb(:,:,3) + IM_b;
IM_rgb_i = zeros(size(Lexcl, 1), size(Lexcl, 2), 3);
IM_rgb_i(:,:,1) = IM_r;
IM_rgb_i(:,:,2) = IM_g;
IM_rgb_i(:,:,3) = IM_b;
IM_r_crop = IM_r(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_g_crop = IM_g(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_b_crop = IM_b(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_rgb_crop(:,:,1) = IM_rgb_crop(:,:,1) + IM_r_crop;
IM_rgb_crop(:,:,2) = IM_rgb_crop(:,:,2) + IM_g_crop;
IM_rgb_crop(:,:,3) = IM_rgb_crop(:,:,3) + IM_b_crop;
IM_rgb_crop_i = zeros(fr_size(1), fr_size(2), 3);
IM_rgb_crop_i(:,:,1) = IM_r_crop;
IM_rgb_crop_i(:,:,2) = IM_g_crop;
IM_rgb_crop_i(:,:,3) = IM_b_crop;
clf;
hold on;
axis ij;
axis off;
image(IM_rgb_crop_i);
set(gca, 'box','off','XTickLabel',[],'XTick',[],'YTickLabel',[],'YTick',[])
set(gca,'position',[0 0 1 1]);
set(gca, 'XLim', [0 fr_size(1)], 'YLim', [0 fr_size(2)]);
set(fig,'PaperUnits','points');
set(fig,'PaperSize',[fr_size(1) fr_size(1)]);
set(fig,'PaperPosition',[0 0 fr_size(1) fr_size(2)]);
set(gca,'Color','k');
fig.Color = 'black';
fig.InvertHardcopy = 'off';
drawnow;
saveas(fig, [loc '_PCA_DBSCAN_plot_crop', '\cluster=' num2str(cl_id) '.png']);
end
% set(fig, 'Position',get(0,'Screensize'));
% clf;
% hold on;
% axis ij;
% axis image;
% axis off;
% image(IM_rgb);
% title('all selected clusters');
% drawnow;
clf;
hold on;
axis ij;
axis off;
image(IM_rgb_crop);
set(gca, 'box','off','XTickLabel',[],'XTick',[],'YTickLabel',[],'YTick',[])
set(gca,'position',[0 0 1 1]);
set(gca, 'XLim', [0 fr_size(1)], 'YLim', [0 fr_size(2)]);
set(fig,'PaperUnits','points');
set(fig,'PaperSize',[fr_size(1) fr_size(1)]);
set(fig,'PaperPosition',[0 0 fr_size(1) fr_size(2)]);
set(gca,'Color','k');
fig.Color = 'black';
fig.InvertHardcopy = 'off';
drawnow;
saveas(fig, [loc '_PCA_DBSCAN_plot_crop', '\all selected clusters.png']);
uu = 3;
ulab = bLab{uu};
w = 2;
loc = [bLoc{uu} ulab{w}];
mkdir([loc '_PCA_DBSCAN_plot_crop']);
fr_loc = [550 1250];
load([loc '.mat']);
IM_rgb = zeros(size(Lexcl, 1), size(Lexcl, 2), 3);
IM_rgb_crop = zeros(fr_size(1), fr_size(2), 3);
for cl_id_i = 1:length(cl_top_idx)
cl_id = cl_top_idx(cl_id_i);
im_indx = b_IDX{uu}{w}{cl_id_i};
IM_r = zeros(size(Lexcl));
IM_g = zeros(size(Lexcl));
IM_b = zeros(size(Lexcl));
IM_r(im_indx) = cm(cl_id,1);
%IM_r(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1) = 1;
IM_g(im_indx) = cm(cl_id,2);
IM_b(im_indx) = cm(cl_id,3);
IM_rgb(:,:,1) = IM_rgb(:,:,1) + IM_r;
IM_rgb(:,:,2) = IM_rgb(:,:,2) + IM_g;
IM_rgb(:,:,3) = IM_rgb(:,:,3) + IM_b;
IM_rgb_i = zeros(size(Lexcl, 1), size(Lexcl, 2), 3);
IM_rgb_i(:,:,1) = IM_r;
IM_rgb_i(:,:,2) = IM_g;
IM_rgb_i(:,:,3) = IM_b;
IM_r_crop = IM_r(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_g_crop = IM_g(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_b_crop = IM_b(fr_loc(1):fr_loc(1)+fr_size(1)-1, fr_loc(2):fr_loc(2)+fr_size(2)-1);
IM_rgb_crop(:,:,1) = IM_rgb_crop(:,:,1) + IM_r_crop;
IM_rgb_crop(:,:,2) = IM_rgb_crop(:,:,2) + IM_g_crop;
IM_rgb_crop(:,:,3) = IM_rgb_crop(:,:,3) + IM_b_crop;
IM_rgb_crop_i = zeros(fr_size(1), fr_size(2), 3);
IM_rgb_crop_i(:,:,1) = IM_r_crop;
IM_rgb_crop_i(:,:,2) = IM_g_crop;
IM_rgb_crop_i(:,:,3) = IM_b_crop;
clf;
hold on;
axis ij;
axis off;
image(IM_rgb_crop_i);
set(gca, 'box','off','XTickLabel',[],'XTick',[],'YTickLabel',[],'YTick',[])
set(gca,'position',[0 0 1 1]);
set(gca, 'XLim', [0 fr_size(1)], 'YLim', [0 fr_size(2)]);
set(fig,'PaperUnits','points');
set(fig,'PaperSize',[fr_size(1) fr_size(1)]);
set(fig,'PaperPosition',[0 0 fr_size(1) fr_size(2)]);
set(gca,'Color','k');
fig.Color = 'black';
fig.InvertHardcopy = 'off';
drawnow;
saveas(fig, [loc '_PCA_DBSCAN_plot_crop', '\cluster=' num2str(cl_id) '.png']);
end
% set(fig, 'Position',get(0,'Screensize'));
% clf;
% hold on;
% axis ij;
% axis image;
% axis off;
% image(IM_rgb);
% title('all selected clusters');
% drawnow;
clf;
hold on;
axis ij;
axis off;
image(IM_rgb_crop);
set(gca, 'box','off','XTickLabel',[],'XTick',[],'YTickLabel',[],'YTick',[])
set(gca,'position',[0 0 1 1]);
set(gca, 'XLim', [0 fr_size(1)], 'YLim', [0 fr_size(2)]);
set(fig,'PaperUnits','points');
set(fig,'PaperSize',[fr_size(1) fr_size(1)]);
set(fig,'PaperPosition',[0 0 fr_size(1) fr_size(2)]);
set(gca,'Color','k');
fig.Color = 'black';
fig.InvertHardcopy = 'off';
drawnow;
saveas(fig, [loc '_PCA_DBSCAN_plot_crop', '\all selected clusters.png']);