enrichplot
enrichplot copied to clipboard
How to modify label text size/line width in cnetplot (ReactomePA/clusterProfiler)
Hello,
I am using the cnetplot function in clusterProfiler to plot the top 5 over-represented pathways in my gene list. I would like to increase the font size of the node labels and increase the width of the lines linking genes to their pathway nodes. I can't find a way to do this. There does not seem to be a font.size argument like there are in other clusterProfiler functions. I appreciate clusterProfiler plots can be formatted like ggplot2 objects but I can't find the correct ggplot2 text size parameter to change to increase the node label size in the cnetplot. Attempted code below.
Thank you very much for your help.
cnetplot(reactome, categorySize="pvalue", foldChange = ranks, circular = TRUE, colorEdge = TRUE, showCategory = 5) + ggplot2::labs(title = "DM vs NG") + ggplot2::theme(legend.text=element_text(size=16, face = "bold"), legend.title=element_text(size=16, face = "bold"), plot.title = element_text(size=20, face = "bold"))
I also tried saving the cnetplot as a ggplot object and then modifying the text size but this does not work
a <- cnetplot(reactome, categorySize="pvalue", foldChange = ranks, circular = TRUE, colorEdge = TRUE, showCategory = 5) + ggplot2::labs(title = "DM vs NG") + ggplot2::theme(legend.text=element_text(size=16, face = "bold"), legend.title=element_text(size=16, face = "bold"), plot.title = element_text(size=20, face = "bold")) a$theme$text$size = 20
I think if you save it as a ggplot object and then mod it later it might work? example
g = cnetplot(reactome, categorySize="pvalue")
g + ggtitle ( "hi") + theme(legend.position="none")
Hi Ahdee, Thanks for your reply. I did try that approach but I can't find what elements in the ggplot object need to be modified to change the label text size and line width. Attached a screenshot of the contents of the ggplot object 'a' generated with the cnetplot function but within the object, I cannot find what modifies the text labels and line width. Thank you.
hey @billy-s-lab from experience its usually in the layer however its kind of experimental without knowing how the plot was constrcuted. For example if the size was declared in the aes then something like this might do it. YOURPLOT[[1]]$layers[[1]]$aes_params$size =2