Drawing induced GO graphs
1
0
Entering edit mode
@daniel-jupiter-3011
Last seen 10.2 years ago
Hi all, undoubtedly this is a silly question. After struggling for quite some time, I think I've been able to do hypergerometric tests for GO enrichment using hyperGTest. The documentation is a bit thin, but it's eventually become clear. The next step is to draw the DAG, with significant genes highlighted, and term names replacing GO IDs. A wrinkle: I am just interested in a particular set of genes, relative to a universe - there is no array, no annotation involved. In any case, here is my code. params <- new("GOHyperGParams", geneIds = test, universeGeneIds = universe,annotation="org.Rn.eg.db", conditional = FALSE, categoryName="GO", ontology="CC", pvalueCutoff=.01) x=hyperGTest(params) y=termGraphs(x,use.terms=TRUE , pvalue=.01) plotGOTermGraph(y,x, node.colors=c(sig="white",not="blue"), node.shape="circle", add.counts=FALSE) I am returned the following error: Error in function (classes, fdef, mtable) : unable to find an inherited method for function "nodes", for signature "list" Am I doing something obviously wrong? Any help is greatly appreciated. Thanks Dan Jupiter. -- Daniel C. Jupiter, Ph.D. Postdoctoral Research Associate Department of Systems Biology and Translational Medicine College of Medicine Texas A&M Health Science Center 702 SW H.K. Dodgen Loop Temple, TX 76504 979.997.2106 | Fax 254.742.7145 djupiter@tamu.edu | www.tamhsc.edu [[alternative HTML version deleted]]
Annotation GO Annotation GO • 1.7k views
ADD COMMENT
0
Entering edit mode
@wolfgang-huber-3550
Last seen 3 months ago
EMBL European Molecular Biology Laborat…
Dear Daniel thank you for your feedback! Would it be possible to (i) send a code example that we can reproduce (i.e. where the variables "test" and "universe" are defined)? (ii) send the output of sessionInfo() after running the example? Best wishes Wolfgang -- ---------------------------------------------------- Wolfgang Huber, EMBL-EBI, http://www.ebi.ac.uk/huber daniel jupiter wrote: > Hi all, > > undoubtedly this is a silly question. > After struggling for quite some time, I think I've been able to do > hypergerometric tests for GO enrichment using hyperGTest. > The documentation is a bit thin, but it's eventually become clear. > The next step is to draw the DAG, with significant genes highlighted, and > term names replacing GO IDs. > A wrinkle: I am just interested in a particular set of genes, relative to a > universe - there is no array, no annotation involved. > > In any case, here is my code. > > params <- new("GOHyperGParams", geneIds = test, > universeGeneIds = universe,annotation="org.Rn.eg.db", > conditional = FALSE, categoryName="GO", ontology="CC", pvalueCutoff=.01) > > x=hyperGTest(params) > > y=termGraphs(x,use.terms=TRUE , pvalue=.01) > > plotGOTermGraph(y,x, node.colors=c(sig="white",not="blue"), > node.shape="circle", add.counts=FALSE) > > I am returned the following error: > Error in function (classes, fdef, mtable) : > unable to find an inherited method for function "nodes", for signature > "list" > > Am I doing something obviously wrong? > > Any help is greatly appreciated. > > Thanks > > Dan Jupiter. >
ADD COMMENT
0
Entering edit mode
Wolfgang, thanks! As you suggested, here is a full script, followed by the error message, and then the sessionInfo(). Best regards, Dan. library(GO.db) library(GOstats) library(annotate) library(org.Rn.eg.db) library("Rgraphviz") library("RBGL") library("graph") library("RColorBrewer") library("geneplotter") library("RbcBook1") # Just some dummy genes to play with bkg=dbGetQuery(org.Rn.eg_dbconn(), "SELECT * from genes") bkg=bkg$gene_id test=bkg[1:100] params <- new("GOHyperGParams", geneIds = test, universeGeneIds = bkg,annotation="org.Rn.eg.db", conditional = FALSE, categoryName="GO", ontology="CC") x=hyperGTest(params) y=termGraphs(x,use.terms=TRUE , pvalue=.01) plotGOTermGraph(y,x, node.colors=c(sig="white",not="blue"), node.shape="circle", add.counts=FALSE) Error in function (classes, fdef, mtable) : unable to find an inherited method for function "nodes", for signature "list" > sessionInfo() R version 2.7.1 (2008-06-23) i386-apple-darwin8.10.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid splines tools stats graphics [6] grDevices utils datasets methods base other attached packages: [1] RbcBook1_1.8.0 geneplotter_1.18.0 [3] lattice_0.17-8 RColorBrewer_1.0-2 [5] Rgraphviz_1.18.1 org.Rn.eg.db_2.2.0 [7] GOstats_2.6.0 Category_2.6.0 [9] genefilter_1.20.0 survival_2.34-1 [11] RBGL_1.16.0 annotate_1.18.0 [13] xtable_1.5-2 graph_1.18.1 [15] GO.db_2.2.0 AnnotationDbi_1.2.2 [17] RSQLite_0.6-9 DBI_0.2-4 [19] Biobase_2.0.1 loaded via a namespace (and not attached): [1] KernSmooth_2.22-22 cluster_1.11.11 > On Thu, Sep 4, 2008 at 11:17 AM, Wolfgang Huber <huber@ebi.ac.uk> wrote: > > Dear Daniel > > thank you for your feedback! Would it be possible to > > (i) send a code example that we can reproduce (i.e. where the variables > "test" and "universe" are defined)? > > (ii) send the output of sessionInfo() after running the example? > > Best wishes > Wolfgang > > -- > ---------------------------------------------------- > Wolfgang Huber, EMBL-EBI, http://www.ebi.ac.uk/huber > > > > daniel jupiter wrote: > >> Hi all, >> >> undoubtedly this is a silly question. >> After struggling for quite some time, I think I've been able to do >> hypergerometric tests for GO enrichment using hyperGTest. >> The documentation is a bit thin, but it's eventually become clear. >> The next step is to draw the DAG, with significant genes highlighted, and >> term names replacing GO IDs. >> A wrinkle: I am just interested in a particular set of genes, relative to >> a >> universe - there is no array, no annotation involved. >> >> In any case, here is my code. >> >> params <- new("GOHyperGParams", geneIds = test, >> universeGeneIds = universe,annotation="org.Rn.eg.db", >> conditional = FALSE, categoryName="GO", ontology="CC", pvalueCutoff=.01) >> >> x=hyperGTest(params) >> >> y=termGraphs(x,use.terms=TRUE , pvalue=.01) >> >> plotGOTermGraph(y,x, node.colors=c(sig="white",not="blue"), >> node.shape="circle", add.counts=FALSE) >> >> I am returned the following error: >> Error in function (classes, fdef, mtable) : >> unable to find an inherited method for function "nodes", for signature >> "list" >> >> Am I doing something obviously wrong? >> >> Any help is greatly appreciated. >> >> Thanks >> >> Dan Jupiter. >> >> -- Daniel C. Jupiter, Ph.D. Postdoctoral Research Associate Department of Systems Biology and Translational Medicine College of Medicine Texas A&M Health Science Center 702 SW H.K. Dodgen Loop Temple, TX 76504 979.997.2106 | Fax 254.742.7145 djupiter@tamu.edu | www.tamhsc.edu [[alternative HTML version deleted]]
ADD REPLY
0
Entering edit mode
Dear Daniel thanks, and sorry for the delayed reply. I don't have much experience with this function, but it seems that if you replace the last line of your example code by par(mfrow=c(3,3)) lapply(y, plotGOTermGraph, x, node.colors=c(sig="white", not="blue"), node.shape="circle", add.counts=FALSE) a result is produced. AfaIu, plotGOTermGraph wants to work on elements of the list y, not on y itself. I agree that the documentation in the function's manual page ("g : A graph object as returned by inducedTermGraph or termGraphs") would benefit from clarification/correction. Best wishes Wolfgang > sessionInfo() R version 2.8.0 Under development (unstable) (2008-09-12 r46536) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB .UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_N AME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTI FICATION=C attached base packages: [1] grid splines tools stats graphics [6] grDevices utils datasets methods base other attached packages: [1] RbcBook1_1.9.0 geneplotter_1.19.1 [3] lattice_0.17-14 RColorBrewer_1.0-2 [5] Rgraphviz_1.19.3 org.Rn.eg.db_2.2.3 [7] GOstats_2.7.0 Category_2.7.4 [9] genefilter_1.21.1 survival_2.34-1 [11] RBGL_1.17.2 annotate_1.19.2 [13] xtable_1.5-3 graph_1.19.1 [15] GO.db_2.2.3 AnnotationDbi_1.3.10 [17] RSQLite_0.7-0 DBI_0.2-4 [19] Biobase_2.1.7 fortunes_1.3-5 loaded via a namespace (and not attached): [1] cluster_1.11.11 GSEABase_1.3.5 KernSmooth_2.22-22 [4] XML_1.96-0 ---------------------------------------------------- Wolfgang Huber, EMBL-EBI, http://www.ebi.ac.uk/huber daniel jupiter wrote: > Wolfgang, > > thanks! > As you suggested, here is a full script, followed by the error message, > and then the sessionInfo(). > > Best regards, > > Dan. > > library(GO.db) > library(GOstats) > library(annotate) > library(org.Rn.eg.db) > library("Rgraphviz") > library("RBGL") > library("graph") > library("RColorBrewer") > library("geneplotter") > library("RbcBook1") > > # Just some dummy genes to play with > bkg=dbGetQuery(org.Rn.eg_dbconn(), "SELECT * from genes") > bkg=bkg$gene_id > test=bkg[1:100] > > params <- new("GOHyperGParams", geneIds = test, > universeGeneIds = bkg,annotation="org.Rn.eg.db", > conditional = FALSE, categoryName="GO", ontology="CC") > > x=hyperGTest(params) > > y=termGraphs(x,use.terms=TRUE , pvalue=.01) > > plotGOTermGraph(y,x, node.colors=c(sig="white",not="blue"), > node.shape="circle", add.counts=FALSE) > > > Error in function (classes, fdef, mtable) : > unable to find an inherited method for function "nodes", for signature > "list" > > > > > sessionInfo() > R version 2.7.1 (2008-06-23) > i386-apple-darwin8.10.1 > > locale: > en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 > > attached base packages: > [1] grid splines tools stats graphics > [6] grDevices utils datasets methods base > > other attached packages: > [1] RbcBook1_1.8.0 geneplotter_1.18.0 > [3] lattice_0.17-8 RColorBrewer_1.0-2 > [5] Rgraphviz_1.18.1 org.Rn.eg.db_2.2.0 > [7] GOstats_2.6.0 Category_2.6.0 > [9] genefilter_1.20.0 survival_2.34-1 > [11] RBGL_1.16.0 annotate_1.18.0 > [13] xtable_1.5-2 graph_1.18.1 > [15] GO.db_2.2.0 AnnotationDbi_1.2.2 > [17] RSQLite_0.6-9 DBI_0.2-4 > [19] Biobase_2.0.1 > > loaded via a namespace (and not attached): > [1] KernSmooth_2.22-22 cluster_1.11.11 > > > > > On Thu, Sep 4, 2008 at 11:17 AM, Wolfgang Huber <huber at="" ebi.ac.uk=""> <mailto:huber at="" ebi.ac.uk="">> wrote: > > > Dear Daniel > > thank you for your feedback! Would it be possible to > > (i) send a code example that we can reproduce (i.e. where the > variables "test" and "universe" are defined)? > > (ii) send the output of sessionInfo() after running the example? > > Best wishes > Wolfgang > > -- > ---------------------------------------------------- > Wolfgang Huber, EMBL-EBI, http://www.ebi.ac.uk/huber > > > > daniel jupiter wrote: > > Hi all, > > undoubtedly this is a silly question. > After struggling for quite some time, I think I've been able to do > hypergerometric tests for GO enrichment using hyperGTest. > The documentation is a bit thin, but it's eventually become clear. > The next step is to draw the DAG, with significant genes > highlighted, and > term names replacing GO IDs. > A wrinkle: I am just interested in a particular set of genes, > relative to a > universe - there is no array, no annotation involved. > > In any case, here is my code. > > params <- new("GOHyperGParams", geneIds = test, > universeGeneIds = universe,annotation="org.Rn.eg.db", > conditional = FALSE, categoryName="GO", ontology="CC", > pvalueCutoff=.01) > > x=hyperGTest(params) > > y=termGraphs(x,use.terms=TRUE , pvalue=.01) > > plotGOTermGraph(y,x, node.colors=c(sig="white",not="blue"), > node.shape="circle", add.counts=FALSE) > > I am returned the following error: > Error in function (classes, fdef, mtable) : > unable to find an inherited method for function "nodes", for > signature > "list" > > Am I doing something obviously wrong? > > Any help is greatly appreciated. > > Thanks > > Dan Jupiter. > > > > > -- > Daniel C. Jupiter, Ph.D. > Postdoctoral Research Associate > Department of Systems Biology and Translational Medicine > College of Medicine > Texas A&M Health Science Center > 702 SW H.K. Dodgen Loop > Temple, TX 76504 > > 979.997.2106 | Fax 254.742.7145 > djupiter at tamu.edu <mailto:djupiter at="" tamu.edu=""> | www.tamhsc.edu > <http: www.tamhsc.edu="">
ADD REPLY
0
Entering edit mode
Thanks Wolfgang. Yes it does indeed produce a nice graph! But with its own problems: Odd node sizes (tried changing fixedsize to TRUE with fixInNamespace(plotGOTermGraph, "GOstats"), and that didn't work). If you change add.counts to TRUE, it doesn't show the colors. I'm really looking to see the following. The induced graph of all the nodes declared significant, with those nodes in a different color, with counts, and labels that are terms, not IDs. It seems that you've given me yet another piece of the puzzle.... but they don't all fit together. I can get many of these things with the various suggestions I've received, I just can't get them all at once. It may just be that without a lot of work R/BioC can't quite do what I'd like. I keep plugging away at this problem. Thanks. Dan. On Fri, Sep 12, 2008 at 6:58 PM, Wolfgang Huber <huber@ebi.ac.uk> wrote: > Dear Daniel > > thanks, and sorry for the delayed reply. I don't have much experience with > this function, but it seems that if you replace the last line of your > example code by > > par(mfrow=c(3,3)) > > lapply(y, plotGOTermGraph, x, > node.colors=c(sig="white", not="blue"), > node.shape="circle", add.counts=FALSE) > > a result is produced. AfaIu, plotGOTermGraph wants to work on elements of > the list y, not on y itself. I agree that the documentation in the > function's manual page ("g : A graph object as returned by inducedTermGraph > or termGraphs") would benefit from clarification/correction. > > Best wishes > Wolfgang > > > sessionInfo() > R version 2.8.0 Under development (unstable) (2008-09-12 r46536) > x86_64-unknown-linux-gnu > > locale: > > LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_ GB.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC _NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDEN TIFICATION=C > > attached base packages: > [1] grid splines tools stats graphics > [6] grDevices utils datasets methods base > > other attached packages: > [1] RbcBook1_1.9.0 geneplotter_1.19.1 > [3] lattice_0.17-14 RColorBrewer_1.0-2 > [5] Rgraphviz_1.19.3 org.Rn.eg.db_2.2.3 > [7] GOstats_2.7.0 Category_2.7.4 > [9] genefilter_1.21.1 survival_2.34-1 > [11] RBGL_1.17.2 annotate_1.19.2 > [13] xtable_1.5-3 graph_1.19.1 > [15] GO.db_2.2.3 AnnotationDbi_1.3.10 > [17] RSQLite_0.7-0 DBI_0.2-4 > [19] Biobase_2.1.7 fortunes_1.3-5 > > loaded via a namespace (and not attached): > [1] cluster_1.11.11 GSEABase_1.3.5 KernSmooth_2.22-22 > [4] XML_1.96-0 > > > ---------------------------------------------------- > Wolfgang Huber, EMBL-EBI, http://www.ebi.ac.uk/huber > > > > > > daniel jupiter wrote: > >> Wolfgang, >> >> thanks! >> As you suggested, here is a full script, followed by the error message, >> and then the sessionInfo(). >> >> Best regards, >> >> Dan. >> >> library(GO.db) >> library(GOstats) >> library(annotate) >> library(org.Rn.eg.db) >> library("Rgraphviz") >> library("RBGL") >> library("graph") >> library("RColorBrewer") >> library("geneplotter") >> library("RbcBook1") >> >> # Just some dummy genes to play with >> bkg=dbGetQuery(org.Rn.eg_dbconn(), "SELECT * from genes") >> bkg=bkg$gene_id >> test=bkg[1:100] >> >> params <- new("GOHyperGParams", geneIds = test, >> universeGeneIds = bkg,annotation="org.Rn.eg.db", >> conditional = FALSE, categoryName="GO", ontology="CC") >> x=hyperGTest(params) >> >> y=termGraphs(x,use.terms=TRUE , pvalue=.01) >> >> plotGOTermGraph(y,x, node.colors=c(sig="white",not="blue"), >> node.shape="circle", add.counts=FALSE) >> >> >> Error in function (classes, fdef, mtable) : >> unable to find an inherited method for function "nodes", for signature >> "list" >> >> >> >> > sessionInfo() >> R version 2.7.1 (2008-06-23) >> i386-apple-darwin8.10.1 >> >> locale: >> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 >> >> attached base packages: >> [1] grid splines tools stats graphics >> [6] grDevices utils datasets methods base >> other attached packages: >> [1] RbcBook1_1.8.0 geneplotter_1.18.0 >> [3] lattice_0.17-8 RColorBrewer_1.0-2 >> [5] Rgraphviz_1.18.1 org.Rn.eg.db_2.2.0 >> [7] GOstats_2.6.0 Category_2.6.0 [9] genefilter_1.20.0 >> survival_2.34-1 [11] RBGL_1.16.0 annotate_1.18.0 [13] >> xtable_1.5-2 graph_1.18.1 [15] GO.db_2.2.0 >> AnnotationDbi_1.2.2 >> [17] RSQLite_0.6-9 DBI_0.2-4 [19] Biobase_2.0.1 >> loaded via a namespace (and not attached): >> [1] KernSmooth_2.22-22 cluster_1.11.11 > >> >> >> On Thu, Sep 4, 2008 at 11:17 AM, Wolfgang Huber <huber@ebi.ac.uk <mailto:="">> huber@ebi.ac.uk>> wrote: >> >> >> Dear Daniel >> >> thank you for your feedback! Would it be possible to >> >> (i) send a code example that we can reproduce (i.e. where the >> variables "test" and "universe" are defined)? >> >> (ii) send the output of sessionInfo() after running the example? >> >> Best wishes >> Wolfgang >> >> -- ---------------------------------------------------- >> Wolfgang Huber, EMBL-EBI, http://www.ebi.ac.uk/huber >> >> >> >> daniel jupiter wrote: >> >> Hi all, >> >> undoubtedly this is a silly question. >> After struggling for quite some time, I think I've been able to do >> hypergerometric tests for GO enrichment using hyperGTest. >> The documentation is a bit thin, but it's eventually become clear. >> The next step is to draw the DAG, with significant genes >> highlighted, and >> term names replacing GO IDs. >> A wrinkle: I am just interested in a particular set of genes, >> relative to a >> universe - there is no array, no annotation involved. >> >> In any case, here is my code. >> >> params <- new("GOHyperGParams", geneIds = test, >> universeGeneIds = universe,annotation="org.Rn.eg.db", >> conditional = FALSE, categoryName="GO", ontology="CC", >> pvalueCutoff=.01) >> >> x=hyperGTest(params) >> >> y=termGraphs(x,use.terms=TRUE , pvalue=.01) >> >> plotGOTermGraph(y,x, node.colors=c(sig="white",not="blue"), >> node.shape="circle", add.counts=FALSE) >> >> I am returned the following error: >> Error in function (classes, fdef, mtable) : >> unable to find an inherited method for function "nodes", for >> signature >> "list" >> >> Am I doing something obviously wrong? >> >> Any help is greatly appreciated. >> >> Thanks >> >> Dan Jupiter. >> >> >> >> >> -- >> Daniel C. Jupiter, Ph.D. >> Postdoctoral Research Associate >> Department of Systems Biology and Translational Medicine >> College of Medicine >> Texas A&M Health Science Center >> 702 SW H.K. Dodgen Loop >> Temple, TX 76504 >> >> 979.997.2106 | Fax 254.742.7145 >> djupiter@tamu.edu <mailto:djupiter@tamu.edu> | www.tamhsc.edu < >> http://www.tamhsc.edu> >> > -- Daniel C. Jupiter, Ph.D. Postdoctoral Research Associate Department of Systems Biology and Translational Medicine College of Medicine Texas A&M Health Science Center 702 SW H.K. Dodgen Loop Temple, TX 76504 979.997.2106 | Fax 254.742.7145 djupiter@tamu.edu | www.tamhsc.edu [[alternative HTML version deleted]]
ADD REPLY
0
Entering edit mode
* Wolfgang: > > AfaIu, plotGOTermGraph wants to work on elements of the list y, > > not on y itself. I agree that the documentation in the function's > > manual page ("g : A graph object as returned by inducedTermGraph > > or termGraphs") would benefit from clarification/correction. Yes, it should be something like: g: A 'graph' object as returned by 'inducedTermGraph' or an element of the list returned by 'termGraphs'. * On 2008-09-12 at 19:42 -0500 daniel jupiter wrote: > I'm really looking to see the following. The induced graph of all > the nodes declared significant, with those nodes in a different > color, with counts, and labels that are terms, not IDs. It seems > that you've given me yet another piece of the puzzle.... but they > don't all fit together. I can get many of these things with the > various suggestions I've received, I just can't get them all at > once. It may just be that without a lot of work R/BioC can't quite > do what I'd like. Perhaps the following is what you want? ## using the same example data as you posted... x = hyperGTest(params) tgs = termGraphs(x,use.terms=TRUE , pvalue=.01) ## tgs is a list of graph objects that represent the connected ## components of the subgraph of the tested GO DAG consisting of ## significant nodes. g1 = tgs[[1]] ## here we add parents and children of a connected graph of ## significant nodes. bigg = inducedTermGraph(x, id=nodes(g1)) ## as you noted, inducedTermGraph doesn't add GO term labels, so we'll ## add them in the way that plotGOTermGraph is expecting # first add a default value for the node attribute named "term" nodeDataDefaults(bigg) <- c(nodeDataDefaults(bigg), list(term=as.character(NA))) # then add the terms theTerms = as.character(sapply(mget(nodes(bigg), GOTERM), Term)) nodeData(bigg, attr="term") = theTerms # the resulting graph has 38 nodes and I find the plot rather # unsatisfying. But if you use pdf, you can zoom in. pdf("bigg.pdf") plotGOTermGraph(bigg, x, node.shape="ellipse") dev.off() Perhaps that gives you another piece of your puzzle? Writing functions to visualize arbitrary GO graphs is difficult because once the node count grows the resulting plot tends to get difficult to read. + seth -- Seth Falcon | http://userprimary.net/user/
ADD REPLY
0
Entering edit mode
Seth, that's great! It is another piece of the puzzle, and a little more exposure to the ways that graphs can be handled. Based on some code by Elliot Kleiman and a suggestion or two from Vince Carey, I think I've managed to solve my problem. I admit, it is nowhere near as elegant as the solutions which others have been suggesting, but that is merely my "newbie"ness with R/BioC showing. As you mentioned, the best route here is to go directly to PDF, perhaps changing some font sizes. In any case, the code is included below. Thanks again. Dan. GOTermsAndIds <- as.list(GOTERM) GOIDS=0 GOTERMS=0 # Place them into easily accessible arrays. for(i in 1:length(GOTermsAndIds)){ GOIDS[i]=GOID(GOTermsAndIds[[i]]) GOTERMS[i]=Term(GOTermsAndIds[[i]]) } # Babies are the significant terms, whose parents/ancestors we will obtain to build our # induced trees. babies=0 babiesCounter=1 params <- new("GOHyperGParams", geneIds = test, universeGeneIds = bkg,annotation="org.Rn.eg.db", conditional = FALSE, categoryName="GO", ontology="BP") MyHyperG=hyperGTest(params) Summary=summary(MyHyperG) # NEL graph object gGO <- goDag( MyHyperG ) # Choose those nodes with significant p-value and add to babies. for(i in seq(along=nodes(gGO))) { nm <- nodes(gGO)[[i]] mn <- match(nm, names(pvalues(MyHyperG))) if(!is.na(mn)) { if(as.vector(pvalues(MyHyperG))[mn] < MyHyperG@pvalueCutoff){ babies[babiesCounter]=nodes(gGO)[[i]] babiesCounter=babiesCounter+1 } } } g=GOGraph(x, GOBPPARENTS), g=removeNode("all", g) # Put root node on the top, transpose adjacency matrix g <- as(t(as(g, 'matrix')), 'graphNEL') # Graph NEL attributes (node attribute graph object) nAgo <- makeNodeAttrs(g, shape="circle", label=nodes(g), fillcolor = "white" ) # Ragraph object agGO <- agopen(g, recipEdges="distinct", layoutType="dot", nodeAttrs=nAgo, name="") # Get node info from Ragraph object and store as agraph node object agNO <- AgNode(agGO) # Color nodes below p-value cutoff, and add node labels for(i in seq(along=agNO)) { nm <- labelText(txtLabel(agNO[[i]])) mn <- match(nm, names(pvalues(MyHyperG))) # Also find the term in the lists of terms and IDs. termMatch=match(nm, GOIDS) if(!is.na(mn)) { # match # If we're below pvalue, color red, otherwise color white. agNO[[i]]@fillcolor <- ifelse( as.vector(pvalues(MyHyperG))[mn] < MyHyperG@pvalueCutoff, "#e31a1c", "#edf8fb") # If we're below the pvalue, we want the number of genes annotated by the term. if(as.vector(pvalues(MyHyperG))[mn] < MyHyperG@pvalueCutoff){ count=Summary[row.names(Summary)==nm,]$Count # Build the label. agNO[[i]]@txtLabel@labelText <- paste(GOTERMS[termMatch], "\nNo. Genes:", count,sep=" ") } else{ # Otherwise we just label with the term name. agNO[[i]]@txtLabel@labelText <-GOTERMS[termMatch] } } else { # no match agNO[[i]]@fillcolor <- "white" agNO[[i]]@txtLabel@labelText <- "" } } # Update Ragraph object's AgNode slot with agNO agGO@AgNode <- agNO # Plot name=paste("~/Desktop/",ontologies[k],fileName,".pdf", sep="") pdf(name, width=40, height=40, paper="special", pagecentre=TRUE) #fixInNamespace(drawAgNode, "Rgraphviz") fixInNamespace(drawTxtLabel, "Rgraphviz") plot(agGO) dev.off() On Sat, Sep 13, 2008 at 12:34 PM, Seth Falcon <seth@userprimary.net> wrote: > * Wolfgang: > > > AfaIu, plotGOTermGraph wants to work on elements of the list y, > > > not on y itself. I agree that the documentation in the function's > > > manual page ("g : A graph object as returned by inducedTermGraph > > > or termGraphs") would benefit from clarification/correction. > > Yes, it should be something like: > > g: A 'graph' object as returned by 'inducedTermGraph' or > an element of the list returned by 'termGraphs'. > > * On 2008-09-12 at 19:42 -0500 daniel jupiter wrote: > > I'm really looking to see the following. The induced graph of all > > the nodes declared significant, with those nodes in a different > > color, with counts, and labels that are terms, not IDs. It seems > > that you've given me yet another piece of the puzzle.... but they > > don't all fit together. I can get many of these things with the > > various suggestions I've received, I just can't get them all at > > once. It may just be that without a lot of work R/BioC can't quite > > do what I'd like. > > Perhaps the following is what you want? > > ## using the same example data as you posted... > x = hyperGTest(params) > tgs = termGraphs(x,use.terms=TRUE , pvalue=.01) > > ## tgs is a list of graph objects that represent the connected > ## components of the subgraph of the tested GO DAG consisting of > ## significant nodes. > > g1 = tgs[[1]] > > ## here we add parents and children of a connected graph of > ## significant nodes. > bigg = inducedTermGraph(x, id=nodes(g1)) > > ## as you noted, inducedTermGraph doesn't add GO term labels, so we'll > ## add them in the way that plotGOTermGraph is expecting > > # first add a default value for the node attribute named "term" > nodeDataDefaults(bigg) <- c(nodeDataDefaults(bigg), > list(term=as.character(NA))) > > # then add the terms > theTerms = as.character(sapply(mget(nodes(bigg), GOTERM), Term)) > nodeData(bigg, attr="term") = theTerms > > # the resulting graph has 38 nodes and I find the plot rather > # unsatisfying. But if you use pdf, you can zoom in. > > pdf("bigg.pdf") > plotGOTermGraph(bigg, x, node.shape="ellipse") > dev.off() > > Perhaps that gives you another piece of your puzzle? Writing > functions to visualize arbitrary GO graphs is difficult because once > the node count grows the resulting plot tends to get difficult to > read. > > + seth > > -- > Seth Falcon | http://userprimary.net/user/ > -- Daniel C. Jupiter, Ph.D. Postdoctoral Research Associate Department of Systems Biology and Translational Medicine College of Medicine Texas A&M Health Science Center 702 SW H.K. Dodgen Loop Temple, TX 76504 979.997.2106 | Fax 254.742.7145 djupiter@tamu.edu | www.tamhsc.edu [[alternative HTML version deleted]]
ADD REPLY

Login before adding your answer.

Traffic: 785 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