GOstats and termGraph - Getting all of the plots out of the list
1
0
Entering edit mode
@matt-thornton-8165
Last seen 9.2 years ago
USC, Los Angeles CA

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!

gostats rgraphviz • 1.5k views
ADD COMMENT
0
Entering edit mode
@valerie-obenchain-4275
Last seen 2.8 years ago
United States

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 COMMENT

Login before adding your answer.

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