-
Notifications
You must be signed in to change notification settings - Fork 2
/
GetEdgeEssentiality.m
executable file
·98 lines (80 loc) · 3.11 KB
/
GetEdgeEssentiality.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
function [ edge_essen ] = GetEdgeEssentiality(connectivity, y, alpha, w)
%This function computes edge essentialities using network inversion. Given the gene-centric
%essentialities 'y', and the network topology 'connectivity', the interaction essentialities
%are estimated using
%inputs:
%connectivity - connectivity matrix is an N x M incidence matrix where
% N and M are the numbers of edges and vertices
% respectively, such that connectivity(i,j) = 1 if the
% edge ei and vertex vj are incident and 0 otherwise.
%y - a vector of size M representing essentialities of M genes(proteins)
%alpha - scalar, smoothing parameter used to weight nieghboring essentialities for
% each network node when estimating interaction essentialities. A value of '0' means
% that each node should be handled independently of its neighbors.
%w - scalar, weighting parameter for network inversion. w represents how
% much the essentiality of proteins affects the essentiality of interactions
% in between. Larger values of w show that an interaction is essential
% if the corresponding proteins are essential, and smaller values of w show
% that no matter how essential the corresponding proteins are the
% interaction is important.
%outputs:
%edge_essen - a vector of size N indicating essentialities of N
% interactions of M proteins.
%Licensed to the Apache Software Foundation (ASF) under one
%or more contributor license agreements. See the NOTICE file
%distributed with this work for additional information
%regarding copyright ownership. The ASF licenses this file
%to you under the Apache License, Version 2.0 (the
%"License"); you may not use this file except in compliance
%with the License. You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
%Unless required by applicable law or agreed to in writing,
%software distributed under the License is distributed on an
%"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%KIND, either express or implied. See the License for the
%specific language governing permissions and limitations
%under the License.
inds = find(sum(connectivity,2) > 0);
C = connectivity(inds, :);
y = y(inds);
m = size(C,2);
graph_edges= zeros(m,2);
for i=1:m
nds = find(C(:,i)==1);
graph_edges(i,1) = nds(1);
graph_edges(i,2) = nds(2);
end
v_imp = y;
B = C;
M = size(B,2);
N = size(B,1);
G = zeros(M,M);
for u=1:N
x = find(B(u,:) > 0);
for i=1:length(x)
for j=i+1:length(x)
G(x(i), x(j)) = exp(w*v_imp(u));
G(x(j), x(i)) = G(x(i), x(j)) ;
end
end
end
[~, cc] = graphconncomp(sparse(G), 'Directed', 'false');
large_con = mode(cc);
inds = find(large_con~=cc);
G(:, inds) = [];
G(inds,:) = [];
edge_essen = zeros(M,1);
new_inds = large_con==cc;
GX = diag(1./sum(G))*G;
D = diag(sum(GX,2));
GN = alpha*GX + (1-alpha)*D;
[vv,~] = eigs(GN',1);
vec = vv(:,1);
if(isempty(inds))
edge_essen(1:end) = vec;
else
edge_essen(new_inds) = vec;
end
end