How to change colour of points in volcano plot by common genes?
1
0
Entering edit mode
5.6 years ago
cilgaiscan ▴ 60

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()
volcano plot RNA-Seq log2FC DESeq2 • 12k views
ADD COMMENT
0
Entering edit mode

You can just use this: EnhancedVolcano: Publication-ready volcano plots with enhanced colouring and labeling

The col argument allows you to change colours as you please.

Kevin

ADD REPLY
0
Entering edit mode

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..

ADD REPLY
0
Entering edit mode
ADD REPLY
0
Entering edit mode

Hang on

ADD REPLY
2
Entering edit mode
5.6 years ago
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"))

h

-----------------------------------------------

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"))

5

Kevin

ADD COMMENT

Login before adding your answer.

Traffic: 1552 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6