forked from SkBlaz/py3plex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualization.html
168 lines (141 loc) · 9.86 KB
/
visualization.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Network visualization — py3plex 0.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="network-visualization">
<h1>Network visualization<a class="headerlink" href="#network-visualization" title="Permalink to this headline">¶</a></h1>
<p>This section includes basic examples on network visualization.</p>
<div class="section" id="hairball-plots">
<h2>Hairball plots<a class="headerlink" href="#hairball-plots" title="Permalink to this headline">¶</a></h2>
<p>Hairball plots are conventional way of visualizing networks. Py3plex implements a simple, force layout-based visualization.</p>
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">py3plex.visualization.multilayer</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">py3plex.visualization.colors</span> <span class="kn">import</span> <span class="n">all_color_names</span>
<span class="kn">from</span> <span class="nn">py3plex.core</span> <span class="kn">import</span> <span class="n">multinet</span>
<span class="c1"># initialize the network object</span>
<span class="n">multilayer_network</span> <span class="o">=</span> <span class="n">multinet</span><span class="o">.</span><span class="n">multi_layer_network</span><span class="p">()</span>
<span class="c1"># load the file</span>
<span class="n">multilayer_network</span><span class="o">.</span><span class="n">load_network</span><span class="p">(</span><span class="s2">"imdb_gml.gml"</span><span class="p">,</span><span class="n">directed</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span><span class="n">label_delimiter</span><span class="o">=</span><span class="s2">"---"</span><span class="p">)</span>
<span class="c1"># visualize</span>
<span class="n">network_colors</span><span class="p">,</span> <span class="n">graph</span> <span class="o">=</span> <span class="n">multilayer_network</span><span class="o">.</span><span class="n">get_layers</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s2">"hairball"</span><span class="p">)</span>
<span class="n">hairball_plot</span><span class="p">(</span><span class="n">graph</span><span class="p">,</span><span class="n">network_colors</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</td></tr></table></div>
<img alt="_images/hairball.png" src="_images/hairball.png" />
</div>
<div class="section" id="multilayer-plots">
<h2>Multilayer plots<a class="headerlink" href="#multilayer-plots" title="Permalink to this headline">¶</a></h2>
<p>Multilayer plots are a novel approach developed by our group, aimed at displaying macro-level properties of network connectivity. Node types are split into many layers, which are connected via custom bernstein polynomial parameterization.</p>
<img alt="_images/multilayer.png" src="_images/multilayer.png" />
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">py3plex.visualization.multilayer</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">py3plex.visualization.colors</span> <span class="kn">import</span> <span class="n">all_color_names</span>
<span class="kn">from</span> <span class="nn">py3plex.core</span> <span class="kn">import</span> <span class="n">multinet</span>
<span class="n">multilayer_network</span> <span class="o">=</span> <span class="n">multinet</span><span class="o">.</span><span class="n">multi_layer_network</span><span class="p">()</span>
<span class="n">multilayer_network</span><span class="o">.</span><span class="n">load_network</span><span class="p">(</span><span class="s2">"epigenetics.gpickle"</span><span class="p">,</span>
<span class="n">directed</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">input_type</span><span class="o">=</span><span class="s2">"gpickle_biomine"</span><span class="p">)</span>
<span class="n">multilayer_network</span><span class="o">.</span><span class="n">basic_stats</span><span class="p">()</span> <span class="c1">## check core imports</span>
<span class="c1"># get layer structure</span>
<span class="n">network_labels</span><span class="p">,</span> <span class="n">graphs</span><span class="p">,</span> <span class="n">multilinks</span> <span class="o">=</span> <span class="n">multilayer_network</span><span class="o">.</span><span class="n">get_layers</span><span class="p">()</span>
<span class="c1"># draw</span>
<span class="n">draw_multilayer_default</span><span class="p">(</span><span class="n">graphs</span><span class="p">,</span><span class="n">display</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span><span class="n">background_shape</span><span class="o">=</span><span class="s2">"circle"</span><span class="p">,</span><span class="n">labels</span><span class="o">=</span><span class="n">network_labels</span><span class="p">)</span>
<span class="n">enum</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">color_mappings</span> <span class="o">=</span> <span class="p">{</span><span class="n">idx</span> <span class="p">:</span> <span class="n">col</span> <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">all_color_names</span><span class="o">.</span><span class="n">keys</span><span class="p">()))}</span>
<span class="k">for</span> <span class="n">edge_type</span><span class="p">,</span><span class="n">edges</span> <span class="ow">in</span> <span class="n">multilinks</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">draw_multiedges</span><span class="p">(</span><span class="n">graphs</span><span class="p">,</span><span class="n">edges</span><span class="p">,</span><span class="n">alphachannel</span><span class="o">=</span><span class="mf">0.7</span><span class="p">,</span><span class="n">linepoints</span><span class="o">=</span><span class="s2">"-."</span><span class="p">,</span>
<span class="n">linecolor</span><span class="o">=</span><span class="n">color_mappings</span><span class="p">[</span><span class="n">enum</span><span class="p">],</span><span class="n">curve_height</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span><span class="n">linmod</span><span class="o">=</span><span class="s2">"upper"</span><span class="p">,</span><span class="n">linewidth</span><span class="o">=</span><span class="mf">0.4</span><span class="p">)</span>
<span class="n">enum</span><span class="o">+=</span><span class="mi">1</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</td></tr></table></div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper"><div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2018, Blaž Škrlj.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.8.2</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/visualization.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>