kevinblighe / EnhancedVolcano

Publication-ready volcano plots with enhanced colouring and labeling
399 stars 81 forks source link

Both left and right of zero as positive x-axis values #58

Closed CodeInTheSkies closed 4 years ago

CodeInTheSkies commented 4 years ago

Hi Kevin,

Thanks for writing this very useful EnhancedVolcano package! Lovely!

I have a rather unusual customization scenario, where I have two conditions, say WT and KO, each with their own lists of LogFC and adj_pVals. I am only interested in the positive LogFCs. But I wish to plot both the conditions in a single plot, where the left of zero would correspond to WT cases (with positive x-axis values), and the right would correspond to the KO cases, again with positive values. Of course, as per your Vignette, I think I can also choose different colors for the two conditions.

Essentially, since I am not plotting negative logFCs at all, I don't need the negative x-axis part, but instead would like to replace that with the second condition.

I know I can do this another way, where I limit the x-axis to only the positive values, and then plot each condition with a different color, but the problem would be that the points would overlap a lot as they would have similar LogFC values and pValues. So, it would be best if I can split as left and right for the two conditions, so that I can neatly label the genes too without too much overcrowding.

Do you think this is possible?

Would very much appreciate your insights!

Many thanks.

kevinblighe commented 4 years ago

Hey, it's certainly possible to do this but perhaps not with EnhancedVolcano as it's currently designed. You could generate two separate plots and place them side-by-side via _cowplot::plotgrid or using the grid and gridExtra packages, or else try to come up with some other cutomised solution.

CodeInTheSkies commented 4 years ago

Thanks, Kevin. Yes, I am aware of these possibilities. I am looking to see if I can code this somehow, but in case you have some ideas about how to specifically achieve this, i.e., having positive values on the left of zero as well, and also changing the colors for left and right separately, please let me know, if you wouldn't mind. Thanks.

kevinblighe commented 4 years ago

As it turns out, you can sort of 'cheat' to do this via scale_x_continuous(). If you take a look at this example from the vignette: https://github.com/kevinblighe/EnhancedVolcano#custom-axis-tick-marks

Now, we can simply change the labels via:

p1 +
  ggplot2::coord_cartesian(xlim=c(-6, 6)) +
  ggplot2::scale_x_continuous(
  breaks=seq(-6,6, 1), labels = c(6,5,4,3,2,1,0,1,2,3,4,5,6))

h

So, that should do it. The underlying values are still negative on the left-hand-side, though, but you can deal with this, correct?

CodeInTheSkies commented 4 years ago

Thanks a lot, Kevin! That trick works wonderfully!

kevinblighe commented 4 years ago

Excellent!