How to change colour of points in volcano plot by common genes?
this is my code to draw volcano plot. but i need to give green dots color for genes in up; red ones for genes in down. how can i do?
down<- intersect(down_our$hgnc_symbol,down_pre$Gene)
up<-intersect(up_our$hgnc_symbol,up_pre$Gene)
res <- read.table(file = "path for csv", header=TRUE, sep = ",")
png("diffexpr-volcanoplot-mm-ourpipeline1.png", 1200, 1000, pointsize=20)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-2.5,2)))
# Add colored points: red if padj<0.05&log2FC<1, green if padj<0.05&log2FC>1
with(subset(res , padj<.05), points(log2FoldChange, -log10(pvalue), pch=20,col="black"))
with(subset(res, (log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
with(subset(res, padj<.05 & (log2FoldChange)<1), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
dev.off()
• 13,486 views
•
link
1 answer
library(airway)
library(magrittr)
data("airway")
airway$dex %<>% relevel("untrt")
library("DESeq2")
dds <- DESeqDataSet(airway, design = ~cell + dex)
dds <- DESeq(dds, betaPrior = FALSE)
res <- results(dds, contrast = c("dex", "trt", "untrt"))
first way
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot"))
with(subset(res , padj<.05), points(log2FoldChange, -log10(pvalue), pch=20,col="black"))
with(subset(res, (log2FoldChange)>1), points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
with(subset(res, padj<.05 & (log2FoldChange)<(1*-1)), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
-----------------------------------------------
second way
up <- rownames(res)[which(res$log2FoldChange>1)]
down <- rownames(res)[which(res$log2FoldChange<(1*-1))]
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot"))
with(subset(res , padj<.05), points(log2FoldChange, -log10(pvalue), pch=20,col="black"))
with(res[which(rownames(res) %in% up),], points(log2FoldChange, -log10(pvalue), pch=20, col="green"))
with(res[which(rownames(res) %in% down),], points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
Kevin
• 1 views
•
link
Log in to answer this question.


You can just use this: EnhancedVolcano: Publication-ready volcano plots with enhanced colouring and labeling
The
colargument allows you to change colours as you please.Kevin
i will look for this link. and i am already using the col argument in my code but the problem the things i would like to color is in different dataframe..
No, the
colargument of my EnhancedVolcano function. It accepts 4 colours: https://bioconductor.org/packages/devel/bioc/vignettes/EnhancedVolcano/inst/doc/EnhancedVolcano.html#adjust-colour-and-alpha-for-point-shading.Hang on