Adjust Y axis scale in ggplot2
1
0
Entering edit mode
3 months ago

Hi, I am trying to create a volcano plot from RNAseq data. The problem is that the adjusted p-values (plotted in Y-axis) have a very wide range of values (from 0.05 to 10^-100). Most genes differential expression have adjusted p-values near 0.05 and only a few of them have a very low value. However, even when I set Log10 scale for Y-axis, the volcano plot agglomerates most dots together near Y = 0, making it difficult to visualize small differences between those dots.

Note: The data frame contains the adjusted p-values in decimal units.

So the code for my current Y axis scale is this:

  scale_y_continuous(trans = log10_trans(),
                     breaks = trans_breaks("log10", function(x) 10^x),
                     labels = trans_format("log10", math_format(10^.x)))

And the plot I get is this one:

enter image description here

However, what I want is something similar to this (there is a big distance between 1 and 0.01 at Y-axis):

enter image description here

How should I modify Y-axis scale code to separate better the dots with adjusted p values near 0.05, without losing dots with p values near 10^-100?

PS: don't mind the dot labels or colors.

log Y axis ggplot2 scale • 276 views
ADD COMMENT
0
Entering edit mode
3 months ago
Sashu ▴ 10

Hi! I think you can use functions like coord_cartesian to zoom in one interval. Given that the ggplot2 object corresponds to your plot is p1, you can use code like p1+ coord_cartesian(ylim = c(0.01, 0.1)) to zoom in one interval of your original plot.

Reference: https://ggplot2-book.org/scale-position.html

Visit this site for more details!

ADD COMMENT
0
Entering edit mode

Thank you! I will give a try to your suggestion :D

ADD REPLY

Login before adding your answer.

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