export image from cnet plot and bar plot
1
0
Entering edit mode
2.4 years ago
Shakiba ▴ 20

Hi all, I want to save an image from a plot, created by cnetplot in R. \ However, when I use ggsave, it doesn't save my plot in the size of I wanted. It is just like this: enter image description here

but I want to my image looks like this: enter image description here

Here is my code:

p_cnetplot <- cnetplot(ego,
                                           categorySize="count",
                                           showCategory = 10,
                                           foldChange=OE_foldchanges,
                                           layout = "kk",
                                           vertex.label.font=7,
                                           colorEdge = TRUE)
ggsave("padj.png", p_cnetplot, units = "px", width = 1919, height = 1120)

ego is a "enrichResult" object. Thank you

centplot • 1.3k views
ADD COMMENT
1
Entering edit mode

It's working fine for me. code that is working for me:

library(clusterProfiler)
library(org.Hs.eg.db)
library(ggplot2)

data(geneList, package="DOSE")
gene <- names(geneList)[abs(geneList) > 2]
ego <- enrichGO(gene          = gene,
                universe      = names(geneList),
                OrgDb         = org.Hs.eg.db,
                ont           = "CC",
                pAdjustMethod = "BH",
                pvalueCutoff  = 0.01,
                qvalueCutoff  = 0.05,
                readable      = TRUE)

pc=cnetplot(ego,
         categorySize="count",
         showCategory = 10,
         layout = "kk",
         vertex.label.font=7,
         colorEdge = TRUE)

ggsave("padj.png", pc, units = "px", width = 1919, height = 1120)
ADD REPLY
0
Entering edit mode

Hi, thanks for your reply. I don't know why is not working for me. But I save my plot with png() function and it worked. Have a good time!

ADD REPLY
1
Entering edit mode
2.4 years ago
Shakiba ▴ 20

I save my plot with png() method. It worked.

ADD COMMENT

Login before adding your answer.

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