Scaling to remove Whitespace not working in ClusterProfiler
0
0
Entering edit mode
22 months ago
DKaukonen • 0

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 • 833 views
ADD COMMENT
1
Entering edit mode

Instead of scale_x_discrete you can use coord_fixed for scaling. https://ggplot2.tidyverse.org/reference/coord_fixed.html

ADD REPLY
0
Entering edit mode

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).

ADD REPLY

Login before adding your answer.

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