Entering edit mode
5.7 years ago
ishackm
▴
110
Hi all,
I would like to know please how to highlight certain genes in a list with a specific colour in a Volcano Plot in R
I have the following code:
genes22= read.csv("../Python/matrix_gene_final v2.csv")
gene_list <- as.vector(genes22)
#All Genes
# MOCS vs MOSE
MOCSvsMOSE = read.csv("../Data/Comparisons/G1 - G2 MOCS vs MOSE.csv") # read csv
res = MOCSvsMOSE
# Make a basic volcano plot
with(res, plot(logFC, -log10(P.Value),pch=20, main="MOCS vs MOS", xlim=c(-8.8,8)))
# if adj.P value less than 0.05 = green
with(subset(res, adj.P.Val<.05 ), points(logFC, -log10(P.Value), pch=20, col="green"))
# if logFC value more than 1 = blue
with(subset(res, abs(logFC)>1), points(logFC, -log10(P.Value), pch=20, col="blue"))
# show the genes in the gene list as pink in the volcano plot
with(res [rownames(res) %in% gene_list]), points(logFC, -log10(P.Value), pch=20, col="pink"))
Everything works except the final line of code:
# show the genes in the gene list as pink in the volcano plot
with(res [rownames(res) %in% gene_list]), points(logFC, -log10(P.Value), pch=20, col="pink"))
I get the following error:
Error: unexpected ',' in "with(res [rownames(res) %in% gene_list]),"
The volcano plot only shows the blue and green colours.
How can I fix this please?
Many Thanks,
Ishack
This is purely a programming question. Hint:
df [1:10,1:10]
is not the same asdf[1:10,1:10]
.Sorry i dont understand. Can you clarify please?
I wrote two lines/statements of code as a hint so you could find the difference between the two statements and apply your learning to your code.
Thanks but i still get the same error.
Is there another way?
Yes, check if your parentheses are matched. Again, this is a simple syntax error that has nothing to do with bioinformatics.
as Ram has been pointing out: the problem is in your last line, specifically the way you subset the data.frame -- why don't you use the same
subset
routine as for the other lines?Hi I have added this code and there is no error but I still don't get the orange colour
How can I fix this, please?
Many Thanks,
Ishack
well, what do you get? Without an error or a plot it's difficult to diagnose
I recommend you to use an online volcano-plot generator like this.