thanks for posting the answer! good job on solving it :)
Hi everyone,
I am trying to use EnhancedVolcano in R to plot the results from my rna-seq analysis. However, when I want to use selectLab to label some genes that I want, I only got a weird number labeled on the final plot rather than the gene name...
Here is my code,
raw_data <- read.csv('Directory to raw data .csv file')
mydata <- data.frame(gene = raw_data$gene_name,
log2_fold_change = raw_data$log2FoldChange,
adj_p = raw_data$padj)
EnhancedVolcano(mydata,
lab = mydata$gene,
x = "log2_fold_change",
y = "adj_p",
xlim = c(-6,6),
ylim = c(0,20),
pointSize = 1,
selectLab = c('NOX4'))
Here is the what it looks like in the final plot: https://drive.google.com/file/d/17Txw4QEIo1KSgZHJsa-Mn8OLO7ZZ4-Gp/view?usp=sharing
Here is a snippet of the head in my data file: https://drive.google.com/file/d/1yE9ffhmNg98X6wZmOVQZayEVLPKb6i0B/view?usp=sharing.
I tried grepl("NOX4", mydata$gene), and it returned TRUE on the "NOX4" index and FALSE elsewhere.
My code gives me correct results without using the selectLab argument...
Any comments would be helpful.
Thanks in advance
1 answer
ok, problem solved.
For future reference, after I constructed the data frame, the gene name column became "integer" rather than "character" (use typeof() to check. I know, it doesn't look like integers at all...).
I changed my code to the following and it worked as expected.
EnhancedVolcano(mydata,
lab = as.character(mydata$gene),
x = "log2_fold_change",
y = "adj_p",
xlim = c(-6,6),
ylim = c(0,20),
pointSize = 1,
selectLab = c('NOX4'))
Helpfully this will help someone else.
Log in to answer this question.
fyi the file you are sharing is locked.
okay got access to the file but it's just a plot... can you post a snippet of your data?
thanks for pointing that out. It should be fixed!
can you post a snippet of your data?
Yes, I posted a new screenshot, and added the code to read the file and generate a data frame.
ok, I added a new screenshot.
For future reference when sharing images use: How to add images to a Biostars post
Thank you, I will follow these in the future.