-
Notifications
You must be signed in to change notification settings - Fork 0
/
analysis2.py
88 lines (52 loc) · 1.85 KB
/
analysis2.py
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
#!/usr/bin/python
# coding: UTF-8
# CSVファイルの読み込み
import csv
import networkx as nx
import matplotlib.pyplot as plt
from networkx.algorithms import bipartite
G=nx.DiGraph()
filename = "TF_analysis.csv"
csvfile = open(filename) #1~300
# print G.node
for row in csv.reader(csvfile):
G.add_edges_from([(row[0],row[1])],weight=row[2])
print "average_neighbor_degree"
print nx.average_neighbor_degree(G)
print "degree_assortativity_coefficient"
print nx.degree_assortativity_coefficient(G)
print "degree_pearson_correlation_coefficient"
print nx.degree_pearson_correlation_coefficient(G)
#print nx.k_nearest_neighbors(G)
print "bipartite.closeness_centrality"
print bipartite.closeness_centrality(G,G.node)
print "degree_centrality"
print nx.degree_centrality(G)
print "betweenness_centrality"
print nx.betweenness_centrality(G)
print "k_nearest_neighbors"
print nx.k_nearest_neighbors(G)
#print nx.current_flow_closeness_centrality(G, normalized=True, weight='weight', dtype='float', solver='lu')
#centrality=nx.eigenvector_centrality(G)
#print(['%s %0.2f'%(node,centrality[node]) for node in centrality])
#print nx.eigenvector_centrality(G, max_iter=100, tol=1e-02, nstart=None)
#print nx.communicability(G)
#print nx.triangles(G)
#directed Graphでなくてはだめ
#print(nx.clustering(G,0))
#print nx.average_clustering(G)
# print nx.diameter(G, e=None)
#print nx.center(G, e=None)
print "max_flow(G, 'Fosl2.48h', 'Hoxa9.48h')"
print nx.max_flow(G, 'Fosl2.48h', 'Hoxa9.48h')
#print nx.network_simplex(G)
#print nx.pagerank(G,alpha=0.9)
print "pagerank_numpy"
print nx.pagerank_numpy(G,alpha=0.9)
print "hits_numpy"
print nx.hits_numpy(G)
# print(nx.shortest_path(G,source=0,target=4))
# print(nx.average_shortest_path_length(G))
#paths = nx.all_simple_paths(G, source=0, target=3, cutoff=2)
#print(list(paths))
csvfile.close()