Change color of enrichGO bar plot
1
0
Entering edit mode
12 weeks ago
nbe • 0
library (clusterProfiler)
library (AnnotationDbi)
library (org.Mm.eg.db)

and then I get my files set up and do the enrichGO step like so:

goctrl <- enrichGO (gene = ctrl, OrgDb = "org.Mm.eg.db", keyType = "SYMBOL", ont = "BP")

I can use the default barplot to create a bar plot showing the top 20 results, but I cannot figure out how to change the color on the p-value gradient. I believe the color argument is coming from clusterprofiler, but all I see are arguments to set the scale to another value (like q-value instead of p-value) but not change the colors.

ctrlplot <- plot(barplot (goctrl, showCategory = 20))

When I use ctrlplot + scale_color_gradientn(colors = c("green", "red")), it tells me "Scale for colour is already present. Adding another scale for colour, which will replace the existing scale." which is indeed fine by me but, alas, it does not let me do it.

enter image description here

enrichgo r clusterprofiler • 413 views
ADD COMMENT
0
Entering edit mode
12 weeks ago
nbe • 0

ctrlplot + viridis::scale_fill_viridis() worked even though it still gave me the same message of "Scale for fill is already present. Adding another scale for fill, which will replace the existing scale."

I'd love to know why this worked and the custom gradient didn't but luckily I at least have a solution, haha.

ADD COMMENT
0
Entering edit mode

color is the outline for the bars, and fill is the actual bar color.

ADD REPLY

Login before adding your answer.

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