Color layer in ggplot (Volcano plot)
0
1
Entering edit mode
3 months ago
arsa ▴ 20

I'm trying to plotĀ a volcano plot with ggplot's vplot. My issue is that I want the colored dots on the front layer rather than the back layer. Is there a way? For example: In the figure I want all the red dots to pop up but I see few of them are masked by the grey dots. enter image description here

R volcano plot ggplot • 473 views
ADD COMMENT
0
Entering edit mode

It could have been simpler if you had posted the code... In case you plot the dots with separate plot orders, you can just change the order, plot gray first, then red. In case you use a color vector, you may need to subset the data points for the red dots and plot the explicitly after those for the gray ones.

Also, please edit your question to be a question, not a forum post.

ADD REPLY
0
Entering edit mode

Lets say I have subset the data like followning:

GeneA <- compare_results[grep("GeneA",compare_results$gene),]

Other <- compare_results[grep("Other",compare_results$gene),]

ggplot(GeneA, aes(x=log2FoldChange, y= -log10(padj)))+geom_point()+xlim(-8.5, 8.5)

ggplot(Other, aes(x=log2FoldChange, y= -log10(padj)))+geom_point()+xlim(-8.5, 8.5)

This gives me unique two plots. Please can you guide me how can I plot these two one after another like you mentioned in the comment.

ADD REPLY
0
Entering edit mode

In ggplot2 the points are plotted as they are ordered in the input data. So you can sort your input data so that your points of interest are plotted afterwards. See this example (I plotted some of the points very big so that they would hide the other points of interest):

foo <- data.frame(logFC = runif(1000),
                  pval = runif(1000),
                  sig = sample(c("sig","nonsig"), 200, replace = T, prob = c(0.1,1)))

ggplot(foo, aes(x = logFC, y = pval, col = sig, size = sig)) + 
  geom_point() + scale_size_manual(values = c(sig = 1, nonsig = 5))

foo <- dplyr::arrange(foo,sig)

ggplot(foo, aes(x = logFC, y = pval, col = sig, size = sig)) + 
  geom_point() + geom_point() + scale_size_manual(values = c(sig = 1, nonsig = 5))
ADD REPLY

Login before adding your answer.

Traffic: 2923 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