This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Adjust Y axis scale in ggplot2

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.

ggplot2

1 answer

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!

Log in to answer this question.