Formatting p-value cut-off line in a volcano plot in R

I am using the following function in R to develop a simple volcano plot:

EnhancedVolcano(all_genes, x = "logFC", y = "adjust.p.value", lab = all_genes$Gene.ID,
                pCutoff =  10e-2, FCcutoff = 1)

I would like my horizontal pCutoff line to appear to represent p = 0.05, which on a log scale for this figure would appear as 1.3 on the y-axis. However, changing "10e-2" to say "10e-2.5" generates an error :

Error: unexpected numeric constant in: "EnhancedVolcano(all_genes, x =
"logFC", y = "adjust.p.value", lab = all_genes$Gene.ID,
pCutoff = 10e-2.5"

Any suggestions on how I can get a horizontal p-value cut-off line at exactly 1.3 (currently appears at 1.2)?

Here is some reproducible data:

structure(list(X = 1:14, Gene.ID = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N"), logFC = c(1.5, 0.17212922, 0.145542174, 0.304348578, 0.124636936, 0.247841044, 0.160818268, 0.123741518, 0.148530876, 0.148960225, 0.114135472, -0.147118359, 0.095549291, 0.138521594), AveExpr = c(5.426424957, 4.289728233, 4.901134193, 4.742864705, 5.447030699, 4.539641767, 4.650750102, 5.901020922, 5.365944907, 5.818788787, 4.837214384, 7.017656548, 4.531897822, 5.192294452), t = c(6.15098624, 5.452898247, 4.979246654, 4.949519834, 4.818043279, 4.73403717, 4.701937811, 4.522692175, 4.518518374, 4.281900066, 4.247981727, -4.194421592, 4.10350597, 4.088357671), p.value = c(1.27e-09, 6.8e-08, 7.99e-07, 9.26e-07, 1.77e-06, 2.65e-06, 3.09e-06, 7.13e-06, 7.27e-06, 2.1e-05, 2.44e-05, 3.07e-05, 4.53e-05, 4.83e-05), adjust.p.value = c(1.64e-05, 0.000438854, 0.002987004, 0.002987004, 0.004558267, 0.005687325, 0.005687325, 0.010422933, 0.010422933, 0.027128901, 0.028601707, 0.033061438, 0.04452146, 0.04452146), B = c(11.2786109, 7.664706936, 5.439886439, 5.306497286, 4.725465519, 4.361868581, 4.224515919, 3.473656504, 3.45649938, 2.508304771, 2.376338878, 2.169980059, 1.825392322, 1.76867543)), class = "data.frame", row.names = c(NA, -14L))

I'm confused about what value you want to use as a cutoff.

A common value is 1e-2 which is a shorthand for 1*10^(-2), i.e. the value 0.01. If you used this value as cutoff, it would appear on the Y axis as -log10(1e-2) = -log10(10^-2) = 2

In your example, you used 10e-2 i.e. 10*10^-2, the value 0.1, which on the Y-axis appears as 1 (and not 1.2).

[advanced: You can double check by re=plotting the line yourself, since EnhancedVolcano() returns a ggplot object, you can add a line on the Y-axis scale that ignores the p-value scale:

EnhancedVolcano(all_genes, x = "logFC", y = "adjust.p.value", lab = all_genes$Gene.ID,
                pCutoff =  .1, FCcutoff = 1) +
  geom_hline(aes(yintercept=1), color='red')

If you are not familiar with {ggplot2}, this paragraph probably looks meaningless to you, you can ignore it]

So in your case, if you are interested in, say, any p-value where -log10(p) > 2.5, this means p < 10^(-2.5) = 0.003162278, so you can use:

EnhancedVolcano(all_genes, x = "logFC", y = "adjust.p.value", lab = all_genes$Gene.ID,
                pCutoff =  10^(-2.5), FCcutoff = 1)

Or for the common 0.05 you can give it explicitly (and EnhancedVolcano will do the conversion to -log10(0.05) = 1.3`):

EnhancedVolcano(all_genes, x = "logFC", y = "adjust.p.value", lab = all_genes$Gene.ID,
                pCutoff =  0.05, FCcutoff = 1)

To be explicit, the notations 0.01, 1e-2, and 10^-2 are completely equivalent ways to represent the same number, for R it doesn't make any difference which one you use, they are available for your convenience. The e notation, also called "scientific notation", only seems to work for integers, just use one of the other two.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.