igraph

Applying a function over consecutive pairs of list elements in R without loops

情到浓时终转凉″ 提交于 2019-12-12 13:12:49
问题 I am trying to find an efficient (i.e. avoid using loops) way to apply a function that iteratively takes as arguments the current and previous (or next) elements of a list and returns a lists of the result (the length of which will necessarily be 1 element shorter). As a concrete example, I have a list of vertices defining a path in some graph vlist <- c(1,2,7,12,17) which come from a lattice graph constructed using the igraph function "lattice" G <- graph.lattice(c(5,7)) I want to apply the

Output Venn gList object and Network plot side-by-side [duplicate]

假如想象 提交于 2019-12-12 11:11:35
问题 This question already has an answer here : Arrange base plots and grid.tables on the same page (1 answer) Closed 3 years ago . How can we plot Network plot ( igraph package plot ) and Venn diagram ( VennDiagram gList object ) side-by-side in one PDF page ? Tried to follow below solutions, didn't work: Plot gList side by side Plot 2 tmap objects side-by-side Side-by-side Venn diagram using Vennerable Here is an example, which plots them in two pages. I used grid.newpage() to make it plot in

Turning an igraph.vs into a data frame

依然范特西╮ 提交于 2019-12-12 10:50:52
问题 So I am using all_shortest_paths to get an output, which looks like this: PathsE $res[[1]] + 4/990 vertices, named: [1] Sortilin GGA1 Ubiquitin PIMT $res[[2]] + 4/990 vertices, named: [1] Sortilin TrkA PLK1 PIMT $res[[3]] + 4/990 vertices, named: [1] Sortilin APP JAB1 PIMT I would like to turn this into a dataframe so that I can manipulate it. For reference, I would like the dataframe to look like this: Prot1 Prot2 Prot3 Prot4 Pathway1 Sortilin GGA1 PLK1 PIMT Pathway2 Sortilin TrkA PLK1 PIMT

Pathways: Manipulate list of events in parent-child 'nodes' in R

醉酒当歌 提交于 2019-12-12 07:21:46
问题 I am interested in visualizing pathways patients have based on a pre-specified list of events (e.g. diagnosis, surgery, treatment1, treatment2, death). A test data set might look like this: df <- structure(list(ID = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), .Label = c("a", "b", "c"), class = "factor"), Event = structure(c(2L, 3L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 5L, 1L), .Label = c("death", "diagnosis", "surgery", "treatment1", "treatment2"), class = "factor"), date =

subset igraph object to just 2nd order ego graph of certain vertices

杀马特。学长 韩版系。学妹 提交于 2019-12-12 05:27:58
问题 Building off this question here, is there a way to extend this subgraph to include vertices connected by two degrees to a subset of vertices? I'm thinking of a command similar to the functions in make_ego_graph() where order=2 and mode="in". I'm working with a directed graph object. Thus far, I've come up with the following, but it's not producing the graph I'm looking for. first_degree <- V(graph)$condition == "something" second_degree <- V(graph)[to(first_degree)] edges_subset <- E(graph)

fast split of data.frame into list of data.frames in R

烂漫一生 提交于 2019-12-12 05:16:58
问题 I have a data.frame with 93 millon elements and 3 numeric variables. The third variable, "component" groups some rows by an id. The data consists of an edge list of a huge graph, the component number indicates the rows that belong to the same connected component. There are about 83 million such components. I am now trying t split the data frame into a list 83 million of data.frames. I do this in order to apply some igraph functions to each component. This SO answer indicates that split() is

Py2app with native Python 2.6

你说的曾经没有我的故事 提交于 2019-12-12 05:00:09
问题 I have a python application primarily dependent on matplotlib, tkinter, numpy and scipy I have been distributing for multiple operating systems. I build these on top of the python.org version of python 2.6. For mac, I have had good success in the past with py2app and pyinstaller to build standalone versions of my application. Recently, however, I have included functions that require patsy, pandas and igraph and have had to move to the mac distributed version of python 2.6 in order to get

finding edge sequences (and nodes) of branches in igraph

倖福魔咒の 提交于 2019-12-12 04:43:29
问题 I would like to use igraph to find edge sequences corresponding to branches from a tree. Ideally, I would like to retain the branches in a data frame. Consider this example: library(igraph) g <-erdos.renyi.game(50, 3/50) mg <- minimum.spanning.tree(g) diam <- get.diameter(mg) E(mg)$color = "black" E(mg, path = diam)$color = "purple" E(mg, path = diam)$width = 6 plot(mg) Here the main path is diam , the purple line. Mr. Flick already kindly answered how to find the edges which are incident on

how to built tripartite network using .csv file in dataframe?

天涯浪子 提交于 2019-12-12 04:23:23
问题 enter image description here I have tried this code of tripartite graph. but i have to use .csv file library(igraph) data = "From, To Recipe:Chicken Marsala,flour Recipe:Chicken Marsala,sage Recipe:Chicken Marsala,chicken Recipe:Chicken Marsala,wine Recipe:Chicken Marsala,butter Recipe:Glazed Carrots,butter Recipe:Glazed Carrots,vinegar Recipe:Glazed Carrots,carrot Recipe:Glazed Carrots,chive flour,compound:X2 sage,compound:X3 chicken,compound:X6 chicken,compound:X7 wine,compound:X1 wine

R: igraph, graph.data.frame error “Some vertex names in edge list are not listed in vertex data frame”

无人久伴 提交于 2019-12-12 04:20:02
问题 I am attempting to assign attributes to the vertices in my network. The code I am using is: g2 <- graph.data.frame(edgelist2014, vertices=nodelabels2014, directed=FALSE) where edgelist2014 is an edgelist with 514,000+ observations in this format: fromRespondent toRespondent weight 1 2 6 1 3 4 ... ... ... 1014 1015 7 and nodelabels2014 is a data frame where the first column is fromRespondent and lists 1 - 1015 followed by 14 columns of attribute data. I have also tried this with 1 - 1014. I