Microbial Network Analysis in igraph

℡╲_俬逩灬. 提交于 2021-01-29 20:14:10

问题


I have bacterial OTU table at all taxonomy levels. I want to plot network using igraph (or any other package). I have never created such plot so please if anyone know some tutorial link for beginner? OR If someone guide me with scripts, you time would be really appreciated. Thank you!


回答1:


  1. A relationship dataset in network analysis is made of, at least, one data.frame (or matrix) which describe the links and contains at least 2 cols, in order to indicate 'from' and 'to' link on the 2 first cols of the data.frame. Others col's of this 'edges list' indicates the caracteristics of each of theselinks. Hereafter, lets call this data.frame edgeslist
  2. You maybe wan't a second dataset, in order to indicate caracteristics for your nodes, aka 'nodes-list'. These are a second data.frame (or matrix) with first col indicate the nodes-names, and others cols indicate caracteristics of each nodes. The nodes-list in Igraph have to indicate each of the single nodes. Each node had to appear only once in the nodes-list, and not a single of the nodes that are in the edgeslist ('from' or 'to' columns) is allowed to be missing in the nodes-list. Hereafter, lets call this data.frame nodeslist.

    1. Then, you have to create an Igraph object with igraph::graph_from_data_frame(edgeslist, directed = F, vertices = nodeslist)

    2. And you can access to this object for compile a bunch of global statistics or obtain some new-data associated with some nodes (e.g., cliques <- igraph::largest_cliques(mygraph) or igraph::edge_density(mygraph, loops=T) )

    3. Or access to a very precise set of nodes or edges (e.g., igraph::E(mygraph)$weight <- 1 or whatever func.
    4. I suggest to play with the edge-list and the tidyverse, in order to made group-statistics.

Try to find some of the existing tutorials like this one.




回答2:


I don't understand what data did you have, here an example of routine for small network analysis:

  1. You first have to define what kind of link you want to analyse (e.g., what relationship ? Are the edges directed - and maybe reciprocal - or not ? which caracteristics for nodes and edges are relevant ?).
  2. Then you have to build your edges-list. In my case the most common way for small network (no need of big performance) is to made a data.frame with the tidyverse. In every case in network analysis, you want an edges-list. It's usually a data.frame whith the links between 2 entities that you call your network. Then the analysis:

    • FOR SMALL GRAPH ONLY, you start by plotting and read the plot. Hereafter, an edges-list sent to igraph and plotted, assuming you require about the tidyverse syntax (%>%):

    myedgeslist <- data.frame(from = c('man1', 'man2','man3', 'man3'), to = c('man3','man1','man1', 'man2') ) mygraph <- myedgeslist %>% igraph::graph_from_data_frame(directed = T) mygraph %>% igraph::plot.igraph()

Which plot a small Directed Network between 3 nodes and with 4 links (Igraph said: IGRAPH DN-- 3 4 -- to indicate DN directed network, 3 nodes and 4 links).

  • In parallel, you have to made some tidyverse group-statistics, e.g.,

myedgeslist %>% group_by(to) %>% summarise(nlinksto= n(), n_nodes=n_distinct(from)) %>% arrange(desc(n_nodes)) said that 'man1' is the most central nodes, 'cause 2 links go to him (vs. one single link for man3 and man2).

  • In parallel, like I said above, read some theorical stuff of network analysis and compute indicators for understand the network (centrality, reciprocity . . .). e.g.,

    mygraph %>% igraph::edge_density() said that 66 % of the directed links are realized in this network.

PS: it's usually a bad idea to plot large network, you must slice them in several parts or to resume the network by global/grouped statistics.



来源:https://stackoverflow.com/questions/62069657/microbial-network-analysis-in-igraph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!