This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Scaling to remove Whitespace not working in ClusterProfiler

Hi,

I have the following dotplot generated from the following code;

 tot <- list(H3K4me3='BT_ctrl_K4_genes.tsv',H3K27me3='BT_ctrl_K27_genes.tsv',reCUTRUN='BT_ctl_re_genes.tsv')

gene_lists <- lapply(tot,read.table, header=T)

genes <- lapply(gene_lists, function(i) data.frame(i)[,4])


compKEGG <- compareCluster(geneCluster   = genes,
                           fun           = "enrichKEGG",
                           pvalueCutoff  = 0.05,
                           pAdjustMethod = "BH")
dotplot(compKEGG, showCategory = 15 , title = "KEGG Pathway Enrichment Analysis for BT474 Control") 

ggsave(filename="BT_ctrl_dotplot.png", device = "png", scale = 1.2)
BT_ctrl_dotplot

enter image description here

As you can see, there is a lot of whitespace between the dots and decreasing that would allow for the text to be easier to read. I have tried using scale_x_discrete to attempt to remedy this (based on what I have read and the error messages). The closest I can get by using this:

dotplot(compKEGG, showCategory = 15 , title = "KEGG Pathway Enrichment Analysis for BT474 Control") + scale_x_discrete(expand = c(0.5,0.5,2,2))

And that produces this;

enter image description here

If I try to add limits via the limits option (IE scale_x_discrete(expand = c(0.5,0.5,2,2),limits = c(0,10))) I get the error

"Continuous limits supplied to discrete scale."

If I supply them as a factor, none of the dots show up. So there appears to be some sort or mix up under the hood as to how to limit the whitespace via scale_x (I tried scale_x_continous to be thorough and I get the error Error: Discrete value supplied to continuous scale). I have looked around at the tutorials for how to remove white space from the plots, and I have not found anything. Does anyone know how to reduce the whitespace so there is more room for the text on the y-axis to be larger and more readable?

Thank you!

clusterprofiler

Thank you! That worked out (although there is some odd whitespace on either side of the plot when I ggsave, but that can easily be cropped out).

0 answers

No answers yet.

Log in to answer this question.