This is a test version of Biostars. For the public version, visit https://www.biostars.org.
export image from cnet plot and bar plot

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

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)

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!

1 answer

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

Log in to answer this question.