The support.bioconductor.org editor has been updated to markdown! Please see more info at: Tutorial: Updated Support Site Editor

Question: GOstats and termGraph - Getting all of the plots out of the list
0
gravatar for Matt Thornton
3.5 years ago by
USC, Los Angeles CA
Matt Thornton0 wrote:

I am using the R/Bioconductor package GOstats. I am having a problem that isn't related to the function of the program only my ability to redirect output in Rscripts. I am running a procedure called 'termGraph' and the output is a list of graphNEL graphs which I can plot individually using the code below.

y2 = termGraphs(hgOver2, use.terms=TRUE, pvalue=0.01)
y2.1 = termGraphs(hgCondOver2, use.terms=TRUE, pvalue=0.01)

b1 <- y2$`1`
b2 <- y2.1$`1`

png(paste(dt,"_GO_Tree_hgOver_BP_q_v_all_under_0.01.png", sep=""), width=6*1000, height=4*1000)
par(mar=c(5,5,2,2), xaxs ="i", yaxs="i", cex.axis=1.3, cex.lab=1.4)
plotGOTermGraph(b1, hgOver2, node.colors=c(sig="darkorange", not="deepskyblue1"), node.shape="ellipse", add.counts=TRUE)
dev.off()

png(paste(dt,"_GO_Tree_hgCondOver_BP_q_v_all_0.01.png", sep=""), width=6*1000, height=4*1000)
par(mar=c(5,5,2,2), xaxs ="i", yaxs="i", cex.axis=1.3, cex.lab=1.4)
plotGOTermGraph(b2, hgCondOver2, node.colors=c(sig="darkorange", not="deepskyblue1"), node.shape="ellipse", add.counts=TRUE)
dev.off()

The accessor for each graph is `1` to an unknown amount. There could be as many as 200 graphNEL graphs. I would like to be able to pull out each graphNEL graph from y2 and y2.1 and plot them. Afterward, I would throw out the 1 node or 2 node graphs (unless they are relevant)

If you have a better way to get the different plots out from termGraph. I would like to hear about it. Thanks!

rgraphviz gostats • 523 views
ADD COMMENTlink modified 3.5 years ago by Valerie Obenchain6.7k • written 3.5 years ago by Matt Thornton0
Answer: GOstats and termGraph - Getting all of the plots out of the list
0
gravatar for Valerie Obenchain
3.5 years ago by
United States
Valerie Obenchain6.7k wrote:

Hi,

I think this boils down to lapply()ing over the termGraph but I could be missing your point.

Plot all graphs to a single png:

fun <- function(graph, source) {
  plotGOTermGraph(graph, source,
                  node.colors=c(sig="darkorange", not="deepskyblue1"),
                  node.shape="ellipse",
                  add.counts=TRUE)
}
png(paste(dt,"all_hgOver.png", sep=""), width=6*1000, height=4*1000)
par(mar=c(5,5,2,2), xaxs ="i", yaxs="i", cex.axis=1.3, cex.lab=1.4)
## shown here for y2 but can also be used for y2.1 and hgCondOver2:
lapply(y2, fun, source=hgOver2)
dev.off()


I don't know what 'dt' in the paste statement is so I'm not sure if you want these printed to the same file or separately. To plot to separately, you could use the graph names as identifiers.

fun2 <- function(graph, name, source) {
  png(paste(name,"_hgOver.png", sep=""), width=6*1000, height=4*1000)
  par(mar=c(5,5,2,2), xaxs ="i", yaxs="i", cex.axis=1.3, cex.lab=1.4)
  plotGOTermGraph(graph, source=source,
                  node.colors=c(sig="darkorange", not="deepskyblue1"),
                  node.shape="ellipse",
                  add.counts=TRUE)
  dev.off()
}
lapply(y2, fun2, name=names(y2), source=hgOver2)


Valerie

ADD COMMENTlink written 3.5 years ago by Valerie Obenchain6.7k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 379 users visited in the last hour