Adjust Y axis scale in ggplot2
Entering edit mode
10 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.

ggplot2 • 438 views
Entering edit mode
10 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.


Visit this site for more details!

Entering edit mode

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


Login before adding your answer.

Traffic: 2503 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6