-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
66 lines (48 loc) · 1.89 KB
/
main.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
% main file
% Author: Chang Lu
clear all
% you can put your data folder under 'data'
currentFolder = pwd;
datapath = [currentFolder,filesep,'data',filesep,'mix with cd163'];
% or set you own path( replace the sentence above to the example below):
% datapath = 'F:\New folder\mix with cd163'; % your own data path
addpath(genpath('fun'));
directory = [datapath,filesep,'results',filesep];
if ~exist(directory,'dir')
mkdir(directory);
end
files=dir(fullfile(datapath));
isub = [files(:).isdir];
fileNames={files(isub).name}';
fileNames(ismember(fileNames,{'.','..','results'})) = [];
%% step 1 : extractzip
% input: .zip file
extractzip(datapath, fileNames);
%% step 2 getCellNuanFeaMat
run('getCellNuanFeaMat.m');
%% step 3 : combine all cells
t=3;
run('nuancematcombination.m');
%% step 4 : SAVE the intergrated cell intensities
run('SAVEnuancematcombination.m');
fprintf('file name is %s \n', ['cellmarker_rescale_intergration_t=',num2str(t),'.mat'])
%% step 5: clustering
k = 10;
dn = 'cosine';
%% step 5.1: clustering
% use cell-nuance intensity matrix (from step 4) to get clusters by
% k-mediods
load([datapath,filesep, 'cellmarker_rescale_intergration_t=',num2str(t),'.mat']);
fprintf('k= %d \n',k);
[labels,~,~] = kmedoids(norm_inten, k,'Distance',dn);
centers=getmedian(norm_inten, labels);
save([datapath, filesep, dn, '_kmedoids_k=', num2str(k),'.mat'], 'labels', 'centers','dn');
%% step 5.2: visualization
% the number of cell per cluster is saved in 'cellcountpercluster.xlsx'
% the number of cell per folder is saved in 'cellcountperfolder.xlsx'
% the number of cell per cluster in each folder is saved in 'cell count per cluster in each folder.xlsx'
% other visualization including: tsne, MST and cell location on H&E images
% (For example , 'TP11' means the cell cluster 1 on 'TP1' image)
clustername = [dn, '_kmedoids_k=', num2str(k)];
run('ClusteringAnalysis.m');