igraph

Plot networks with igraph

血红的双手。 提交于 2019-12-05 17:29:51
I want to create a network from a correlation matrix and plot it. I'm trying to use igraph for this. This is a subset of my data. mydata Taxon CD1 CD2 Actinomycetaceae;g__Actinomyces 0.072998825 0.031399459 Coriobacteriaceae;g__Atopobium 0.040946468 0.002703265 Corynebacteriaceae;g__Corynebacterium 0.002517201 0.006446247 Micrococcaceae;g__Rothia 0.001174694 0.002703265 Porphyromonadaceae;g__Porphyromonas 0.023326061 0.114368892 Prevotellaceae;g__Prevotella 0.252894781 0.102308172 Flavobacteriaceae;g__Capnocytophaga 0.001174694 0.029320025 Aerococcaceae;g__Abiotrophia 0.002013761 0.003327095

Built Family nested tree parent / children relationship in R

余生颓废 提交于 2019-12-05 17:14:49
I am working on families trees : I have adapted Bob Horton's example based on sqldf https://www.r-bloggers.com/exploring-recursive-ctes-with-sqldf/ My data : person father Guillou Arthur NA Cleach Marc NA Guillou Eric Guillou Arthur Guillou Jacques Guillou Arthur Cleach Franck Cleach Marc Cleach Leo Cleach Marc Cleach Herbet Cleach Leo Cleach Adele Cleach Herbet Guillou Jean Guillou Eric Guillou Alan Guillou Eric My results, descendants ordered by levels of "Guillou Arthur" (top person without father) : name parent_name level Guillou Arthur NA 1 Guillou Eric Guillou Arthur 2 Guillou Jacques

sampling subgraphs from different sizes using igraph

六月ゝ 毕业季﹏ 提交于 2019-12-05 17:03:45
问题 I have an igraph object mygraph with ~10,000 nodes and ~145,000 edges, and I need to create a number of subgraphs from this graph but with different sizes. What I need is to create subgraphs from a determined size (from 5 nodes to 500 nodes) where all the nodes are connected in each subgraph. I need to create ~1,000 subgraphs for each size (i.e, 1000 subgraphs for size5, 1000 for size 6, and so on), and then calculate some values for each graph according to different node attributes. I have

How to set edge colors and vertex spacing with R / igraph

冷暖自知 提交于 2019-12-05 12:40:26
I am new to R and trying to figure out how to make a social network map of a system that I have data for. I have managed to figure out most of what I want to do from the FAQ and tutorials, but I am stuck on two things. How do I make the canvas larger / the graph more spaced out? Right now it's way too squashed. At the moment the edge thickness is set based on the weight. The weights represent different statuses (8 = Active, 3 = Requested, 2 = Hidden, 1 = Blocked) and I would like to style the edges rather than change their thickness. In an ideal world, green for Active, green dashed for

Three column graph

纵然是瞬间 提交于 2019-12-05 11:32:30
The result of some process is a list of paths from A to C through B, e.g.: which.effect(A1,A2,10,1,1) [[1]] [1] 10 2 1 [[2]] [1] 10 28 1 [[3]] [1] 10 6 9 [[4]] [1] 10 24 9 [[5]] [1] 10 28 9 What I would like to have is a graph with three parallel columns, the first for the origin, the second for the intermediate point, and the third for the destination. In this example, the first column would have only the node 10 , the second 2, 6, 24, 28 and the third 1, 9 . Then, directed edges (arrows) will go from nodes in the first column to nodes in the second column, and from nodes in the second column

Subset igraph graph by label

耗尽温柔 提交于 2019-12-05 11:32:28
问题 I am trying to subset a igraph graph by an edge characteristics (like its label). In the reproducible example I have shamelessly stolen from another post with a little modification, I would like to be able to separate the Best Friend ties (BF) from the Family ties (FAM): edges <- matrix(c(103, 86, 24, 103, 103, 2, 92, 103, 87, 103, 103, 101, 103, 44), ncol=2, byrow=T) g <- graph(as.vector(t(edges))) E(g)[c(2:4,7)]$label<-"FAM" E(g)[c(1,5,6)]$label<-"BF" The best I can do so far is display the

plotting communities in iGraph

蓝咒 提交于 2019-12-05 10:46:33
问题 I would like to reproduce the kind of "community summary" graph like on page 6 of this paper: http://arxiv.org/pdf/0803.0476v2.pdf First a community algorithm is employed on the graph, e.g.: wc <- walktrap.community(subgraph) mc <- multilevel.community(subgraph) Then the vertices are grouped according to community. The size of the community node is a function of the membership size and the edge width is a function of the total edges going from any member of community A to community B. Please

r creating an adjacency matrix from columns in a dataframe

我只是一个虾纸丫 提交于 2019-12-05 07:53:04
I am interested in testing some network visualization techniques but before trying those functions I want to build an adjacency matrix (from, to) using the dataframe which is as follows. Id Gender Col_Cold_1 Col_Cold_2 Col_Cold_3 Col_Hot_1 Col_Hot_2 Col_Hot_3 10 F pain sleep NA infection medication walking 14 F Bump NA muscle NA twitching flutter 17 M pain hemoloma Callus infection 18 F muscle pain twitching medication My goal is to create an adjacency matrix as follows 1) All values in columns with keyword Cold will contribute to the rows 2) All values in columns with keyword Hot will

From dataframe to vertex/edge array

余生颓废 提交于 2019-12-05 06:15:45
I have the dataframe test <- structure(list( y2002 = c("freshman","freshman","freshman","sophomore","sophomore","senior"), y2003 = c("freshman","junior","junior","sophomore","sophomore","senior"), y2004 = c("junior","sophomore","sophomore","senior","senior",NA), y2005 = c("senior","senior","senior",NA, NA, NA)), .Names = c("2002","2003","2004","2005"), row.names = c(c(1:6)), class = "data.frame") > test 2002 2003 2004 2005 1 freshman freshman junior senior 2 freshman junior sophomore senior 3 freshman junior sophomore senior 4 sophomore sophomore senior <NA> 5 sophomore sophomore senior <NA> 6

R iGraph Heatmap in Vertex

做~自己de王妃 提交于 2019-12-05 03:11:05
问题 I'm quite new to R and stuck on a question. Would it be possible to print a heatmap on a vertex in iGraph ? I know I can do a colored square or circle. But would a small heatmap be possible? This is the code that draws my current graph: # create graph graph <- graph.data.frame(network[,1:2]) vertex_names <- get.vertex.attribute(graph,"name") # define node attributes V(graph)$label.font <- 1 V(graph)$label.font[which(element_types[vertex_names,"type"]=="PRIMARIES")] <- 2 V(graph)$label.font