Spaces:
Sleeping
Sleeping
Tanguyvans
commited on
Commit
•
9333b89
1
Parent(s):
551646a
get_metrics
Browse files- .DS_Store +0 -0
- MATLAB/get_metrics.m +57 -14
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
MATLAB/get_metrics.m
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
% Read the CSV file
|
2 |
data = readtable('../MGREL.RRF', Delimiter='|', FileType='text', NumHeaderLines=0, VariableNamingRule='preserve');
|
3 |
-
data = renamevars(data,
|
|
|
4 |
ids_1 = data.CUI1;
|
5 |
for k = 1 : length(ids_1)
|
6 |
cellContents = ids_1{k};
|
@@ -16,6 +17,29 @@ for k = 1 : length(ids_2)
|
|
16 |
end
|
17 |
ids_2 = str2double(ids_2);
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
% Get the number of unique nodes
|
20 |
%nodes = unique([ids_1; ids_2]);
|
21 |
%num_nodes = length(nodes);
|
@@ -25,17 +49,36 @@ ids_2 = str2double(ids_2);
|
|
25 |
% Display adjacency matrix
|
26 |
%disp(A);
|
27 |
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
%
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
% Read the CSV file
|
2 |
data = readtable('../MGREL.RRF', Delimiter='|', FileType='text', NumHeaderLines=0, VariableNamingRule='preserve');
|
3 |
+
data = renamevars(data, '#CUI1', 'CUI1');
|
4 |
+
|
5 |
ids_1 = data.CUI1;
|
6 |
for k = 1 : length(ids_1)
|
7 |
cellContents = ids_1{k};
|
|
|
17 |
end
|
18 |
ids_2 = str2double(ids_2);
|
19 |
|
20 |
+
edges = [ids_1, ids_2];
|
21 |
+
edges = edges(~any(isnan(edges), 2), :);
|
22 |
+
|
23 |
+
ids_1 = edges(:, 1);
|
24 |
+
ids_2 = edges(:, 2);
|
25 |
+
|
26 |
+
G = digraph(ids_1, ids_2);
|
27 |
+
|
28 |
+
% Compute PageRank centrality
|
29 |
+
pg_ranks = centrality(G, 'pagerank');
|
30 |
+
|
31 |
+
% Assign PageRank to each node
|
32 |
+
G.Nodes.PageRank = pg_ranks;
|
33 |
+
|
34 |
+
for i = 1:numnodes(G)
|
35 |
+
if pg_ranks(i) > 1.6487e-07
|
36 |
+
disp(['Node ', num2str(i), ' PageRank: ', num2str(pg_ranks(i))]);
|
37 |
+
end
|
38 |
+
end
|
39 |
+
|
40 |
+
%idx = G.Nodes.PageRank > 1.6487e-07;
|
41 |
+
%disp(G.Nodes(idx, :));
|
42 |
+
|
43 |
% Get the number of unique nodes
|
44 |
%nodes = unique([ids_1; ids_2]);
|
45 |
%num_nodes = length(nodes);
|
|
|
49 |
% Display adjacency matrix
|
50 |
%disp(A);
|
51 |
|
52 |
+
connections = {
|
53 |
+
'A1', 'B2';
|
54 |
+
'A1', 'A2'
|
55 |
+
};
|
56 |
|
57 |
+
% Extract unique nodes
|
58 |
+
nodes = unique(connections(:));
|
59 |
+
|
60 |
+
% Create a directed graph
|
61 |
+
num_nodes = length(nodes);
|
62 |
+
node_indices = containers.Map(nodes, 1:num_nodes);
|
63 |
+
A = zeros(num_nodes);
|
64 |
+
for i = 1:size(connections, 1)
|
65 |
+
from_node = connections{i, 1};
|
66 |
+
to_node = connections{i, 2};
|
67 |
+
from_index = node_indices(from_node);
|
68 |
+
to_index = node_indices(to_node);
|
69 |
+
A(from_index, to_index) = 1;
|
70 |
+
end
|
71 |
+
|
72 |
+
% Display adjacency matrix
|
73 |
+
disp(A);
|
74 |
+
|
75 |
+
% Create directed graph
|
76 |
+
G = digraph(A, nodes);
|
77 |
+
|
78 |
+
% Compute PageRank centrality
|
79 |
+
pg_ranks = centrality(G, 'pagerank');
|
80 |
+
|
81 |
+
% Display PageRank for each node
|
82 |
+
for i = 1:num_nodes
|
83 |
+
disp(['PageRank for ', nodes{i}, ': ', num2str(pg_ranks(i))]);
|
84 |
+
end
|