This is a test version of Biostars. For the public version, visit https://www.biostars.org.
EnhancedVolcano custom color variables by log2FC and p-value

I am trying to over-ride the colouring scheme in EnhancedVolcano with custom key-value pairs. Specifically, I want to color proteins with log2FC > 0.5 and log2FC < -0.5 AND with p-value < 0.05 in 2 different colors and everything else (below FC cutoff and above p-value cutoff) in grey. I was trying to use the nested ifelse statements to include both log2FC and p-value cutoffs, but I am unable to color the proteins with p-value > 0.05 in grey. Is there something wrong with my ifelse statements?

keyvals.colour <- ifelse(
(data$log2FC < -0.5 & data$p.value < 0.5),'royalblue',
  ifelse((data$log2FC > 0.5 & data$p.value < 0.5),'gold',
         'grey50'))
enhancedvolcano

Your p-value is 0.5. You said that you wanted to use 0.05.

Kevin

Ah, that was it. Thanks so much, it works now! I feel dumb (I am still fairly new to R), but glad I asked. Thanks so much for the package Kevin, I love it.

Please don't add an answer unless you're answering the top level question. Use Add Comment or Add Reply instead. I've moved your post to a comment this time, but please be more careful in the future.

1 answer

I never used the package myself. If you want to highlight those below or above a p-value of 0.05, should you try to set that value - 0.05 - instead of 0.5 in data$p.value?

keyvals.colour <- ifelse(
(data$log2FC < -0.5 & data$p.value < 0.05),'royalblue',
  ifelse((data$log2FC > 0.5 & data$p.value < 0.05),'gold',
         'grey50'))

Sorry, não vi que já havia respondido.

Log in to answer this question.