Volcano plot color threshold

1,325 views
Skip to first unread message

Irshad Ul Haq

unread,
Feb 18, 2015, 3:59:59 AM2/18/15
to ggp...@googlegroups.com, i.u...@rug.nl
Dear all,

This is my first time on this forum of experts and I would like to ask for your help and suggestions in customizing the volcano plot I am trying to generate.
I am using the following script which works well and generates the plot, however, I am keen to set a threshold both for log2 fold change (>1.5 and <1.5) and p.value (>0.05 and <0.05).


ggplot(data=T3, aes(x=log2FoldChange, y=-log10(pval))) + geom_point(alpha=0.4, size=1.75) + theme(legend.position = "none") + xlim(c(-10, 10)) + ylim(c(0, 15)) +  xlab("log2 fold change") + ylab("-log10 p-value")

Could you please guide me in this regard. File is attached for your perusal.

Thank you very much!

Best
Irshad

T3_1.csv

Ben Bond-Lamberty

unread,
Feb 18, 2015, 3:27:32 PM2/18/15
to ggplot2
Hi Irshad, first, that file has a "csv" extension but seems to have
both semicolons and commas as delimiters (?). Can you give an example
of how it's supposed to be parsed, or (much better) use `dput` to
generate a simple reproducible example?

Second, what do you mean that you want to "set a threshold"? Do you
mean axis limits? Please clarify.

Ben
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Rajesh Sahasrabuddhe

unread,
Feb 18, 2015, 5:31:25 PM2/18/15
to ggp...@googlegroups.com
Just guessing but I think you have an issue in that you map y to the log value but don't adjust your ylim arguments accordingly. I typically keep y on the orginal scale and use scale_* calls to adjust the plot

Ben Bond-Lamberty

unread,
Feb 19, 2015, 10:23:37 AM2/19/15
to Irshad Ul Haq, ggplot2
Thanks for the clarification.

Re putting points in different colors, you can do something like this:

ggplot(data=T3, aes(x=log2FoldChange, y=-log10(pval),
color=log2FoldChange < 1.5)) +...

To incorporate both the conditions you mentioned:

T3$clr <- paste(T3$log2FoldChange < 1.5, T3$pval < 0.05)
ggplot(data=T3, aes(x=log2FoldChange, y=-log10(pval), color=clr)) +...

This gives a total of four colors on the plot, since there are four
possible combinations.

Ben




On Thu, Feb 19, 2015 at 10:13 AM, Irshad Ul Haq <irshad...@gmail.com> wrote:
> Hi Ben,
>
> Thank you for your response.
>
> 1) Using RStudio I import the file with (.csv) extension and click yes
> "heading". Then I write the script mentioned before and gets the plot, BUT
> with a warning (please see attached print screen).
>
> 2). By threshold I mean to color upregulated genes (log2 fold change >1.5)
> in red and downregulated (log2 fold change <1.5) in blue. Also, distinguish
> between genes with statistical significance (p< 0.05 and p>0.05 in different
> colors).
>
> Thank you very much!
> Irshad
> --
>
> Marie-Curie PhD fellow
> Department of Microbial Ecology
> Groningen Institute for Evolutionary Life Sciences (GELIFES)
> Faculty of Mathematics and Natural Science
> University of Groningen, Nijenborgh 7, 9747 AG, Groningen, The Netherlands
>
>
>
>
Reply all
Reply to author
Forward
0 new messages