graph object question
2
0
Entering edit mode
@iain-gallagher-2532
Last seen 9.3 years ago
United Kingdom
Hello list I'm trying to build graph objects showing the relationship between miRNA and genes. Is there a quick way to do this from a dataframe (see toy code below)? When building my graph object I can't think my way through getting the 'edges' list name into my list of edges (see below)! > testData symbol mirbase_id 6 2'-PDE hsa-let-7b 86 A2BP1 hsa-let-7b 331 AAK1 hsa-let-7b 1003 ABCB9 hsa-let-7b 1071 ABCC10 hsa-let-7b 1195 ABCC5 hsa-let-7b 3520 ACSL6 hsa-let-7b 3583 ACTA1 hsa-let-7b 4102 ACTR2 hsa-let-7b 4480 ACVR1B hsa-let-7b t2<-as.list(testData[,2],) names(t2)<-testData[,1] nodes<-testData[,1] for (i in 1:length(t2)) t2[[i]] <- c(names(t2[i]), t2[[i]]) > t2 $`2'-PDE` [1] "2'-PDE" "hsa-let-7b" ... But what I need is... > t2 $`2'-PDE` $`2'-PDE`$edges [1] "2'-PDE" "hsa-let-7b" ... Thanks for any help. Iain > sessionInfo() R version 2.10.1 (2009-12-14) x86_64-pc-linux-gnu locale: [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_GB.UTF-8 [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] RColorBrewer_1.0-2 Rgraphviz_1.24.0 graph_1.24.1 loaded via a namespace (and not attached): [1] tools_2.10.1
graph graph • 1.3k views
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 10.2 years ago
Hi Iain, On 2/12/10 2:17 PM, Iain Gallagher wrote: > I'm trying to build graph objects showing the relationship between > miRNA and genes. Is there a quick way to do this from a dataframe > (see toy code below)? When building my graph object I can't think my > way through getting the 'edges' list name into my list of edges (see > below)! I think maybe you are looking for graph::ftM2graphNEL. Here's an example: library("graph") s <- "symbol mirbase_id 2'-PDE hsa-let-7b A2BP1 hsa-let-7b AAK1 hsa-let-7b ABCB9 hsa-let-7b ABCC10 hsa-let-7b ABCC5 hsa-let-7b ACSL6 hsa-let-7b ACTA1 hsa-let-7b ACTR2 hsa-let-7b ACVR1B hsa-let-7b " con <- textConnection(s) df <- read.table(con, sep = " ", quote = "", header = TRUE) ft <- as.matrix(df) close(con) g <- ftM2graphNEL(ft) ## or perhaps you want an undirected graph? gu <- ftM2graphNEL(ft, edgemode = "undirected") + seth -- Seth Falcon Bioconductor Core Team | FHCRC
ADD COMMENT
0
Entering edit mode
Thanks Vincent and Seth. ftM2graphNEL - very sweet! iain --- On Fri, 12/2/10, Seth Falcon <sfalcon at="" fhcrc.org=""> wrote: > From: Seth Falcon <sfalcon at="" fhcrc.org=""> > Subject: Re: [BioC] graph object question > To: bioconductor at stat.math.ethz.ch > Date: Friday, 12 February, 2010, 23:01 > Hi Iain, > > On 2/12/10 2:17 PM, Iain Gallagher wrote: > > I'm trying to build graph objects showing the > relationship between > > miRNA and genes. Is there a quick way to do this from > a dataframe > > (see toy code below)? When building my graph object I > can't think my > > way through getting the 'edges' list name into my list > of edges (see > > below)! > > I think maybe you are looking for > graph::ftM2graphNEL.? Here's an example: > > library("graph") > s <- "symbol mirbase_id > 2'-PDE hsa-let-7b > A2BP1 hsa-let-7b > AAK1 hsa-let-7b > ABCB9 hsa-let-7b > ABCC10 hsa-let-7b > ABCC5 hsa-let-7b > ACSL6 hsa-let-7b > ACTA1 hsa-let-7b > ACTR2 hsa-let-7b > ACVR1B hsa-let-7b > " > > con <- textConnection(s) > df <- read.table(con, sep = " ", quote = "", header = > TRUE) > ft <- as.matrix(df) > close(con) > g <- ftM2graphNEL(ft) > ## or perhaps you want an undirected graph? > gu <- ftM2graphNEL(ft, edgemode = "undirected") > > + seth > > -- Seth Falcon > Bioconductor Core Team | FHCRC > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >
ADD REPLY
0
Entering edit mode
@vincent-j-carey-jr-4
Last seen 9 weeks ago
United States
as usual there are many way to proceed. i'd suggest that you do not try to build the edge list by hand, but start your graph with your set of nodes library(graph) g = new("graphNEL", nodes = nodevec) and then use addEdge in the graph package to build the thing up directly as a graphNEL instance On Fri, Feb 12, 2010 at 5:17 PM, Iain Gallagher <iaingallagher at="" btopenworld.com=""> wrote: > Hello list > > I'm trying to build graph objects showing the relationship between miRNA and genes. Is there a quick way to do this from a dataframe (see toy code below)? > When building my graph object I can't think my way through getting the 'edges' list name into my list of edges (see below)! > > >> testData > ? ? symbol mirbase_id > 6 ? ?2'-PDE hsa-let-7b > 86 ? ?A2BP1 hsa-let-7b > 331 ? ?AAK1 hsa-let-7b > 1003 ?ABCB9 hsa-let-7b > 1071 ABCC10 hsa-let-7b > 1195 ?ABCC5 hsa-let-7b > 3520 ?ACSL6 hsa-let-7b > 3583 ?ACTA1 hsa-let-7b > 4102 ?ACTR2 hsa-let-7b > 4480 ACVR1B hsa-let-7b > > t2<-as.list(testData[,2],) > names(t2)<-testData[,1] > nodes<-testData[,1] > > for (i in 1:length(t2)) t2[[i]] <- c(names(t2[i]), t2[[i]]) > >> t2 > $`2'-PDE` > [1] "2'-PDE" ? ? "hsa-let-7b" > ... > > But what I need is... > >> t2 > $`2'-PDE` > $`2'-PDE`$edges > [1] "2'-PDE" ? ? "hsa-let-7b" > ... > > Thanks for any help. > > Iain > >> sessionInfo() > R version 2.10.1 (2009-12-14) > x86_64-pc-linux-gnu > > locale: > ?[1] LC_CTYPE=en_GB.UTF-8 ? ? ? LC_NUMERIC=C > ?[3] LC_TIME=en_GB.UTF-8 ? ? ? ?LC_COLLATE=en_GB.UTF-8 > ?[5] LC_MONETARY=C ? ? ? ? ? ? ?LC_MESSAGES=en_GB.UTF-8 > ?[7] LC_PAPER=en_GB.UTF-8 ? ? ? LC_NAME=C > ?[9] LC_ADDRESS=C ? ? ? ? ? ? ? LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] grid ? ? ?stats ? ? graphics ?grDevices utils ? ? datasets ?methods > [8] base > > other attached packages: > [1] RColorBrewer_1.0-2 Rgraphviz_1.24.0 ? graph_1.24.1 > > loaded via a namespace (and not attached): > [1] tools_2.10.1 > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >
ADD COMMENT

Login before adding your answer.

Traffic: 538 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6