如何在R中可视化大型网络? [英] How to visualize a large network in R?

查看:98
本文介绍了如何在R中可视化大型网络?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在实践中,网络可视化在科学中变得很普遍.但是,随着网络规模的扩大,常见的可视化功能就变得不那么有用了.节点/顶点和链接/边太多了.通常,可视化工作最终会产生毛刺".

Network visualizations become common in science in practice. But as networks are increasing in size, common visualizations become less useful. There are simply too many nodes/vertices and links/edges. Often visualization efforts end up in producing "hairballs".

已经提出了一些新的方法来解决此问题,例如:

Some new approaches have been proposed to overcome this issue, e.g.:

  • 边缘捆绑:
    • Edge bundling:
      • http://vis.stanford.edu/papers/divided-edge-bundling or
      • https://gephi.org/tag/edge-bundling/
      • http://wiki.cytoscape.org/Cytoscape_3/UserManual
      • How to make grouped layout in igraph?

      我确信还有更多方法.因此,我的问题是: 如何克服毛发问题,即如何使用R可视化大型网络?

      I am sure that there are many more approaches. Thus, my question is: How to overcome the hairball issue, i.e. how to visualize large networks by using R?

      以下是一些模拟示例网络的代码:

      Here is some code that simulates an exemplary network:

      # Load packages
      lapply(c("devtools", "sna", "intergraph", "igraph", "network"), install.packages)
      library(devtools)
      devtools::install_github(repo="ggally", username="ggobi")
      lapply(c("sna", "intergraph", "GGally", "igraph", "network"), 
             require, character.only=T)
      
      # Set up data
      set.seed(123)
      g <- barabasi.game(1000)
      
      # Plot data
      g.plot <- ggnet(g, mode = "fruchtermanreingold")
      g.plot
      

      这个问题与 是否可视化对GraphViz太大的无向图?.但是,在这里,我不是在搜索通用软件建议,而是在搜索具体示例(使用上面提供的数据),这些技术可以通过使用R 来帮助对大型网络进行良好的可视化(可与以下示例中的示例相比)该线程: R:点太多的散点图).

      This questions is related to Visualizing Undirected Graph That's Too Large for GraphViz?. However, here I am searching not for general software recommendations but for concrete examples (using the data provided above) which techniques help to make a good visualization of a large network by using R (comparable to the examples in this thread: R: Scatterplot with too many points).

      推荐答案

      另一种可视化超大型网络的方法是使用BioFabric(www.BioFabric.org),它使用水平线代替指向代表节点.然后使用垂直线段显示边缘.有关此技术的D3快速演示,请参见: http://www.biofabric.org/gallery/pages/SuperQuickBioFabric.html .

      Another way to visualize very large networks is with BioFabric (www.BioFabric.org), which uses horizontal lines instead of points to represent the nodes. Edges are then shown using vertical line segments. A quick D3 demo of this technique is shown at: http://www.biofabric.org/gallery/pages/SuperQuickBioFabric.html.

      BioFabric是Java应用程序,但是可以在以下位置获得简单的R版本: https://github.com/wjrl /RBioFabric .

      BioFabric is a Java application, but a simple R version is available at: https://github.com/wjrl/RBioFabric.

      这是R代码的一部分:

       # You need 'devtools':
       install.packages("devtools")
       library(devtools)
      
       # you need igraph:
       install.packages("igraph")
       library(igraph)
      
       # install and load 'RBioFabric' from GitHub
       install_github('RBioFabric',  username='wjrl')
       library(RBioFabric)
      
       #
       # This is the example provided in the question:
       #
      
       set.seed(123)
       bfGraph = barabasi.game(1000)
      
       # This example has 1000 nodes, just like the provided example, but it 
       # adds 6 edges in each step, making for an interesting shape; play
       # around with different values.
      
       # bfGraph = barabasi.game(1000, m=6, directed=FALSE)
      
       # Plot it up! For best results, make the PDF in the same
       # aspect ratio as the network, though a little extra height
       # covers the top labels. Given the size of the network,
       # a PDF width of 100 gives us good resolution.
      
       height <- vcount(bfGraph)
       width <- ecount(bfGraph)
       aspect <- height / width;
       plotWidth <- 100.0
       plotHeight <- plotWidth * (aspect * 1.2)
       pdf("myBioFabricOutput.pdf", width=plotWidth, height=plotHeight)
       bioFabric(bfGraph)
       dev.off()
      

      这里是提问者提供的数据的BioFabric版本的快照,尽管使用m> 1的值创建的网络更有趣.插图细节显示了网络左上角的特写镜头;节点BF4是网络中度最高的节点,默认布局是从该节点开始的网络的广度优先搜索(忽略边缘方向),并且按照节点度递减的顺序遍历相邻节点.请注意,我们可以立即看到,例如,节点BF4的邻居中约60%是1级.从严格的45度下边缘也可以看到,这个1000节点的网络有999个边缘,因此是一棵树.

      Here is a shot of the BioFabric version of the data provided by the questioner, though networks created with values of m > 1 are more interesting. The inset detail shows a close-up of the upper left corner of the network; node BF4 is the highest-degree node in the network, and the default layout is a breadth-first search of the network (ignoring edge directions) starting from that node, with neighboring nodes traversed in order of decreasing node degree. Note that we can immediately see that, for example, about 60% of node BF4's neighbors are degree 1. We can also see from the strict 45-degree lower edge that this 1000-node network has 999 edges, and is therefore a tree.

      完全公开:BioFabric是我编写的工具.

      Full disclosure: BioFabric is a tool that I wrote.

      这篇关于如何在R中可视化大型网络?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆