-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscaled_inclusivity.m
48 lines (39 loc) · 1.56 KB
/
scaled_inclusivity.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
function V = scaled_inclusivity(X, ith)
%==========================================================================
% This function is used to calcuate the community assignment consistency of
% each nodes among various network partitions X
%
% Input:
% X, M-by-N, M paritions for networks with N nodes, with each row
% stands for a partition
% ith, the index of the reference partition
% Ref: Liao NeuroImage (2017); Steen PRE (2011)
% Xuhong Liao, BNU, BeiJing, 2017/4, liaoxuhong@bnu.edu.cn
%==========================================================================
if nargin<2
error('Please input the reference partition');
end
[M, N] = size(X);
if ith>M
error('Please input the right index of the reference partition');
end
V = zeros(N,1); % N, number of nodes
Ref = X(ith,:);
idx = 1:N;
MQ = sparse(idx, Ref, 1, N, max(Ref), N);
for ii = 1:M
if (ii~=ith)
%disp(['ii = ', num2str(ii)]);
A = X(ii,:);
MA = sparse(idx, A, 1, N, max(A), N);
[S,com_A, com_Ref] = comm_comm_similarity(A, Ref); % pair-wise similarity between modules in A and B
Ind = find(S); % find p and q, with S(p,q)>0
num =length(Ind);
[P, Q] = ind2sub(size(S), Ind); % Pth module in A, Qth module in B
for jj = 1:num % num, number of module pairs with overlapping nodes
Ind_com = MA(:,com_A(P(jj))).*MQ(:,com_Ref(Q(jj)))>0;
V(Ind_com) = V(Ind_com) + S(Ind(jj));
end
end
end
end