How to produce png files from printGraph
1
0
Entering edit mode
mictadlo ▴ 10
@mictadlo-10885
Last seen 4.9 years ago

Hi, Is there a way that printGraph produces png files?

showSigOfNodes(sampleGOdata, 
               score(resultKS.elim), 
               firstSigNodes = 5, 
               useInfo='all')

printGraph(sampleGOdata, 
           resultKS.elim, 
           firstSigNodes = 5, 
           fn.prefix = paste(comparisons,"-goNodes"), 
           useInfo = "all", 
           pdfSW = TRUE)

Thank you in advance.

topgo • 2.3k views
ADD COMMENT
0
Entering edit mode

In your code, you need to declare the variables 'sampleGOdata', 'resultKS.elim', and 'comparisons'. Also you need to include all import statements (e.g. 'library(topGO)'). You should be able to just paste the code example into an R shell and have it run.

ADD REPLY
0
Entering edit mode

Yes, the code runs and produces a pdf file but how to change it that it produces png rather than pdf file?

ADD REPLY
0
Entering edit mode

Yes, but can't run the code. No one else can either. The variables 'sampleGOdata', 'resultKS.elim', and 'comparison' are not defined. I had to look up the topGO vignette to find the definitions of 'sampleGOdata' and 'resultKS.elim'. But still I don't know what 'comparisons' is. How is 'comparisons' declared in your code?

ADD REPLY
0
Entering edit mode
arendsee ▴ 10
@arendsee-14118
Last seen 7.2 years ago
Iowa State University

Here is a complete example:

library(topGO)
library(ALL)
data(geneList)
sampleGOdata <- new("topGOdata",
                    description = "Simple session", ontology = "BP",
                    allGenes = geneList, geneSel = topDiffGenes,
                    nodeSize = 10,
                    annot = annFUN.db, affyLib = affyLib)

resultKS.elim <- runTest(sampleGOdata, algorithm = "elim", statistic = "ks")

png("sampleGOdata.png")
showSigOfNodes(sampleGOdata, 
               score(resultKS.elim), 
               firstSigNodes = 5, 
               useInfo='all')
dev.off()

The functions printGraph and showSigOfNodes do the same thing, except that printGraph automatically makes a PDF or PS file.

I don't have enough rep to write another comment, so I'll have to just edit my answer. If you want better resolution, you might try reading this blog post.

If this was helpful, you I'd appreciate it if you upvote the answer (then maybe I'll be able to write more than 5 comments a day).

ADD COMMENT
0
Entering edit mode

Although, your example isn't quite complete. I don't know offhand what package `showSigOfNodes` is from, so I can't immediately replicate your code. You should add the import statements (e.g. `library(whatever)`). I assume that `printGraph` is producing a figure of some sort?

ADD REPLY
0
Entering edit mode

It is library(topGO) and I follow the instruction from there manual.

ADD REPLY
0
Entering edit mode

Unfortunately, it did not work and I only got in terminal

png
  3

What did I miss?

ADD REPLY
0
Entering edit mode

Thank you, but how is it possible to improve the resolution?


> png("~/sampleGOdata.png", res = 300)
> showSigOfNodes(sampleGOdata,
+                score(resultKS.elim),
+                firstSigNodes = 5,
+                useInfo='all')
Error in plot.new() : figure margins too large
ADD REPLY

Login before adding your answer.

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