Create Volcano Plot

Hi,

I'm trying to create a volcano plot but I can't seem to figure out how. I tried using the NormalizeMets and ggplot2 package but I don't seem to understand how the syntax works. The syntax used for NormalizeMets doesn't seem in include Fold Change values and ggplot2 seems like its mostly used to make the graph pretty.

I have a table with a list of metabolite retention time/mass-to-charge ratio along with their corresponding fold-change values and p-values. My goal is to create a volcano plot which highlights p-values that are less than 0.05 and to label each point with the retention time/mass-to-charge ratio.

How should I go about doing this?

So far, I've only managed to upload the table and created variables of the Fold-Change and P-Value data.

Here's the script I used:

EM <- read.csv(file = "D:/metabolomics/4E5/em.csv", row.names = 1)
pvals = EM$pvalues
FC = EM$Fold.changes
log10FC <- log10(FC)
logpv <- -log2(pvals)
library (ggplot2)

I found this form (https://stackoverflow.com/questions/44322793/volcano-plot-in-r) which contains a script for building a volcano plot but it doesn't include assigning the log(10)FC values to the x-axis.

I have the same issue with NormalizeMets - I can't define the x-axis. I'm using the script provided in the reference manual: https://cran.r-project.org/web/packages/NormalizeMets/NormalizeMets.pdf

Hi! I don’t have a direct answer for you, but in the interest of getting you a good answer faster, I do have some suggestions:

  • To reach helpers with the right interests, I recommend moving this question to the #tidyverse category, since it seems to involve ggplot2. You could also choose #general if you feel like your question isn’t tightly tied to ggplot2, but either way your question does not sound like it’s about the RStudio IDE.
  • You will be most likely to get an answer quickly if you provide a self-contained, reproducible example of what you’ve got so far. It doesn’t have to work! But at minimum you’ll need to supply some sample data and the code you’ve been working on. This may sound like a chore, but it is the single best thing you can do to increase your chances of getting an answer. When you post your code, please also be sure to format it as code:sparkles: !
  • If you’ve already tried searching for answers elsewhere, posting links to what you’ve found can help your helpers understand where you’re getting stuck (if you’ve posted this question anywhere else, definitely say so and post a link, to stay on the right side of this site’s cross-posting policy).
2 Likes

It is difficult to answer without a reproducible example however this should make your volcano plot:

library (ggplot2)
EM <- read.csv(file = "D:/metabolomics/4E5/em.csv", row.names = 1)

df <- data.frame(log10FC = log10(EM$Fold.changes),
                 logpv = -log2(EM$pvalues))

ggplot(df, aes(x=log10FC, y=logpv)) +
  geom_point()

Maybe it would help working through the NormalizeMets vignette which guides you through an example analysis.

I echo the comments about producing a reprex, but I just taught a workshop - proteomics rather than metabolomics - but you're more than welcome to look at the materials for creating a volcano plot here:

The preceding sections deal with how to wrangle your data, and the link takes you to the plotting with ggplot2 part.

All the best,

Alistair

1 Like