-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaml_s3_7v8.html
217 lines (183 loc) · 9.43 KB
/
laml_s3_7v8.html
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
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--
This HTML was auto-generated from MATLAB code.
To make changes, update the MATLAB code and republish this document.
--><title>Real data example</title><meta name="generator" content="MATLAB 9.8"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2020-09-14"><meta name="DC.source" content="laml_s3_7v8.m"><style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}
html { min-height:100%; margin-bottom:1px; }
html body { height:100%; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000; line-height:140%; background:#fff none; overflow-y:scroll; }
html body td { vertical-align:top; text-align:left; }
h1 { padding:0px; margin:0px 0px 25px; font-family:Arial, Helvetica, sans-serif; font-size:1.5em; color:#d55000; line-height:100%; font-weight:normal; }
h2 { padding:0px; margin:0px 0px 8px; font-family:Arial, Helvetica, sans-serif; font-size:1.2em; color:#000; font-weight:bold; line-height:140%; border-bottom:1px solid #d6d4d4; display:block; }
h3 { padding:0px; margin:0px 0px 5px; font-family:Arial, Helvetica, sans-serif; font-size:1.1em; color:#000; font-weight:bold; line-height:140%; }
a { color:#005fce; text-decoration:none; }
a:hover { color:#005fce; text-decoration:underline; }
a:visited { color:#004aa0; text-decoration:none; }
p { padding:0px; margin:0px 0px 20px; }
img { padding:0px; margin:0px 0px 20px; border:none; }
p img, pre img, tt img, li img, h1 img, h2 img { margin-bottom:0px; }
ul { padding:0px; margin:0px 0px 20px 23px; list-style:square; }
ul li { padding:0px; margin:0px 0px 7px 0px; }
ul li ul { padding:5px 0px 0px; margin:0px 0px 7px 23px; }
ul li ol li { list-style:decimal; }
ol { padding:0px; margin:0px 0px 20px 0px; list-style:decimal; }
ol li { padding:0px; margin:0px 0px 7px 23px; list-style-type:decimal; }
ol li ol { padding:5px 0px 0px; margin:0px 0px 7px 0px; }
ol li ol li { list-style-type:lower-alpha; }
ol li ul { padding-top:7px; }
ol li ul li { list-style:square; }
.content { font-size:1.2em; line-height:140%; padding: 20px; }
pre, code { font-size:12px; }
tt { font-size: 1.2em; }
pre { margin:0px 0px 20px; }
pre.codeinput { padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; }
pre.codeoutput { padding:10px 11px; margin:0px 0px 20px; color:#4c4c4c; }
pre.error { color:red; }
@media print { pre.codeinput, pre.codeoutput { word-wrap:break-word; width:100%; } }
span.keyword { color:#0000FF }
span.comment { color:#228B22 }
span.string { color:#A020F0 }
span.untermstring { color:#B20000 }
span.syscmd { color:#B28C00 }
span.typesection { color:#A0522D }
.footer { width:auto; padding:10px 0px; margin:25px 0px 0px; border-top:1px dotted #878787; font-size:0.8em; line-height:140%; font-style:italic; color:#878787; text-align:left; float:none; }
.footer p { margin:0px; }
.footer a { color:#878787; }
.footer a:hover { color:#878787; text-decoration:underline; }
.footer a:visited { color:#878787; }
table th { padding:7px 5px; text-align:left; vertical-align:middle; border: 1px solid #d6d4d4; font-weight:bold; }
table td { padding:7px 5px; text-align:left; vertical-align:top; border:1px solid #d6d4d4; }
</style></head><body><div class="content"><h1>Real data example</h1><!--introduction--><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Step 1: detect communities as the backbone ICN structure (load the results)</a></li><li><a href="#2">Step 2: Test interconnectivity by KL, choose cluster 7 and 8 as an example</a></li><li><a href="#3">Step 3: rearrange and identify connecting edges between community 7 and 8</a></li></ul></div><h2 id="1">Step 1: detect communities as the backbone ICN structure (load the results)</h2><pre class="codeinput">clear
load(<span class="string">'laml_s3_step1.mat'</span>);
<span class="comment">% Raw network</span>
figure;imagesc(Cor_perm);colormap <span class="string">jet</span>;colorbar;snapnow
<span class="comment">% Diagonals</span>
<span class="keyword">for</span> i=1:16
Diag{i}=Cor_perm(A{i},A{i});
<span class="keyword">end</span>
<span class="comment">% Off-diagnals</span>
Off_1vec = [];
<span class="keyword">for</span> i=1:15
<span class="keyword">for</span> j=(i+1):16
Off{i,j} = Cor_perm(A{i},A{j});
CC = Cor_perm(A{i},A{j});
Off_vec{i,j} = CC(:);
VV = CC(:);
Off_1vec = [Off_1vec VV'];
<span class="keyword">end</span>
<span class="keyword">end</span>
idx = 1:size(Cor_perm,2);
idx_select2 = [A{1:16}];
idx_left2 = setdiff(idx,idx_select2);
<span class="comment">% reorganized network</span>
figure;imagesc(Cor_perm([idx_select2 idx_left2], [idx_select2 idx_left2]));colormap <span class="string">jet</span>;colorbar;snapnow
</pre><img vspace="5" hspace="5" src="laml_s3_7v8_01.png" alt=""> <img vspace="5" hspace="5" src="laml_s3_7v8_02.png" alt=""> <h2 id="2">Step 2: Test interconnectivity by KL, choose cluster 7 and 8 as an example</h2><p>Null graph</p><pre class="codeinput">clu00 = Cor_perm(idx_left2,idx_left2);
<span class="comment">% figure;imagesc(clu00);colormap jet;colorbar;snapnow</span>
<span class="comment">% Random samples</span>
i=7; j=8;
figure;imagesc(Cor_perm([A{7} A{8}], [A{7} A{8}]));colormap <span class="string">jet</span>;colorbar;snapnow
whole = squareform(clu00);
true = randsample(whole,size(Off_vec{i,j},1));
null = Off_1vec;
width= 0.001;
addpath(<span class="string">'/Users/qwu/Downloads/Don/Interconnected'</span>)
s = Off_vec{i,j}';
[P,R]=KLtest(s,null,true,0.05,width);
<span class="keyword">if</span> R==1
fprintf(<span class="string">'cluster %d and %d are interconnected'</span>, i,j);
<span class="keyword">else</span>
fprintf(<span class="string">'cluster %d and %d are not interconnected'</span>, i,j);
<span class="keyword">end</span>
Vec12 = Off_vec{i,j};
Vec12_pos = Vec12(Vec12>0);
prop = size(Vec12_pos,1)/size(Vec12,1);
prop(prop<0.5)=-1;
prop(prop>0.5)=1;
</pre><img vspace="5" hspace="5" src="laml_s3_7v8_03.png" alt=""> <pre class="codeoutput">cluster 7 and 8 are interconnected</pre><h2 id="3">Step 3: rearrange and identify connecting edges between community 7 and 8</h2><pre class="codeinput">C1 = Diag{i};
C2 = Diag{j};
C12 = Off{i,j};
lambda0=0.8;
r=0.1:0.005:0.8;
r_max=InterCut(C1,C2,C12,r,lambda0);
r_cut = r_max(1);
<span class="keyword">if</span> prop==-1
direction = <span class="string">'neg'</span>;
<span class="keyword">else</span>
direction = <span class="string">'pos'</span>;
<span class="keyword">end</span>
[IR,IC,C1_sort,C2_sort,C12_sort,C] = InterRearrange(C1,C2,C12,r_max,direction);
figure;imagesc(C);colormap <span class="string">jet</span>;c=colorbar;snapnow
caxis([-1 1])
</pre><img vspace="5" hspace="5" src="laml_s3_7v8_04.png" alt=""> <img vspace="5" hspace="5" src="laml_s3_7v8_05.png" alt=""> <p class="footer"><br><a href="https://www.mathworks.com/products/matlab/">Published with MATLAB® R2020a</a><br></p></div><!--
##### SOURCE BEGIN #####
%% Real data example
%% Step 1: detect communities as the backbone ICN structure (load the results)
clear
load('laml_s3_step1.mat');
% Raw network
figure;imagesc(Cor_perm);colormap jet;colorbar;snapnow
% Diagonals
for i=1:16
Diag{i}=Cor_perm(A{i},A{i});
end
% Off-diagnals
Off_1vec = [];
for i=1:15
for j=(i+1):16
Off{i,j} = Cor_perm(A{i},A{j});
CC = Cor_perm(A{i},A{j});
Off_vec{i,j} = CC(:);
VV = CC(:);
Off_1vec = [Off_1vec VV'];
end
end
idx = 1:size(Cor_perm,2);
idx_select2 = [A{1:16}];
idx_left2 = setdiff(idx,idx_select2);
% reorganized network
figure;imagesc(Cor_perm([idx_select2 idx_left2], [idx_select2 idx_left2]));colormap jet;colorbar;snapnow
%% Step 2: Test interconnectivity by KL, choose cluster 7 and 8 as an example
% Null graph
clu00 = Cor_perm(idx_left2,idx_left2);
% figure;imagesc(clu00);colormap jet;colorbar;snapnow
% Random samples
i=7; j=8;
figure;imagesc(Cor_perm([A{7} A{8}], [A{7} A{8}]));colormap jet;colorbar;snapnow
whole = squareform(clu00);
true = randsample(whole,size(Off_vec{i,j},1));
null = Off_1vec;
width= 0.001;
addpath('/Users/qwu/Downloads/Don/Interconnected')
s = Off_vec{i,j}';
[P,R]=KLtest(s,null,true,0.05,width);
if R==1
fprintf('cluster %d and %d are interconnected', i,j);
else
fprintf('cluster %d and %d are not interconnected', i,j);
end
Vec12 = Off_vec{i,j};
Vec12_pos = Vec12(Vec12>0);
prop = size(Vec12_pos,1)/size(Vec12,1);
prop(prop<0.5)=-1;
prop(prop>0.5)=1;
%% Step 3: rearrange and identify connecting edges between community 7 and 8
C1 = Diag{i};
C2 = Diag{j};
C12 = Off{i,j};
lambda0=0.8;
r=0.1:0.005:0.8;
r_max=InterCut(C1,C2,C12,r,lambda0);
r_cut = r_max(1);
if prop==-1
direction = 'neg';
else
direction = 'pos';
end
[IR,IC,C1_sort,C2_sort,C12_sort,C] = InterRearrange(C1,C2,C12,r_max,direction);
figure;imagesc(C);colormap jet;c=colorbar;snapnow
caxis([-1 1])
##### SOURCE END #####
--></body></html>