Re: Significance level added to matrix correlation in ggplot2

409 views
Skip to first unread message
Message has been deleted

doctorate

unread,
Sep 1, 2012, 4:44:02 AM9/1/12
to ggp...@googlegroups.com


On Saturday, September 1, 2012 10:42:53 AM UTC+2, doctorate wrote:
Hi,
I would like to add the levels of significance (p value) to the heatmap of matrix corrrelation in a GRAPHICAL WAY. Just look at the this short link for reproducible dataset and further details I already posted on SO. Thank in advance
http://stackoverflow.com/questions/12196756/significance-level-added-to-matrix-correlation-heatmap-using-ggplot2
 

Brandon Hurr

unread,
Sep 1, 2012, 3:38:20 PM9/1/12
to doctorate, ggp...@googlegroups.com
Just looking at the pictures... how about an alpha scale. That way your best correlations are the most clear and the lesser ones are moreso. If this is the case I would choose different cutoffs depending on your dataset. For me, an r^2 of 0.70 might be my lowest band while everything above 0.95 would be lumped together rather than have *, **, and ***. 

On Sat, Sep 1, 2012 at 9:42 AM, doctorate <ffsa...@gmail.com> wrote:
Hi,
I would like to add the levels of significance (p value) to the heatmap of matrix corrrelation in a GRAPHICAL WAY. Just look at the this short link for reproducible dataset and further details I already posted on SO. Thank in advance
http://stackoverflow.com/q/12196756/1288722

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

Art

unread,
Sep 1, 2012, 9:29:52 PM9/1/12
to ggp...@googlegroups.com
Doctorate,

Could you provide the code for the last plot you created in your answer on stackoverflow? Thanks

doctorate

unread,
Sep 3, 2012, 1:31:54 PM9/3/12
to ggp...@googlegroups.com
Yup, it is there, thanks for your help in advance.

Brandon Hurr

unread,
Sep 5, 2012, 6:39:21 AM9/5/12
to doctorate, ggplot2
Hey, using the second example in SO. 

ggplot(nbar.m, aes(x=row, y=variable, fill=value, alpha=valuep))+geom_tile()+scale_fill_gradientn(colours=c("red", "yellow", "green"))+theme_bw()+scale_alpha(na.value=0, range=c(1,0), guide=F)

Something like that. 

I reversed the scale_alpha for the p-value so the more significant stuff shows up brighter. I know the colors suck, but you can pick whatever you want using scale_gradientn(). I also hid the legend for alpha. I still think you should adjust the scale for alpha to have >.90 = dark, .70<=x<.90 = middle, and so on... maybe instead of continuous scale, use cut() here to set the alpha more precisely. 

Just an idea. What you need is something that you can look at and determine what's important. I happen to like the way this turned out (other than the colors being a bit too bright). 


B


On Tue, Sep 4, 2012 at 10:17 PM, Brandon Hurr <brando...@gmail.com> wrote:
I'm at a conference this week and have only had a chance to barely look at your code. You need to split the pearson's correlation and the significance of the correlation into two separate columns of data. I think once you do that, rather than have them as a combined factor, you supply scale_color_gradientn() with the r^2 and the significance level with scale_alpha_manual(). 

It will be at least a few days before I can look at it properly though. Good luck. 


On Tue, Sep 4, 2012 at 9:44 PM, doctorate <ffsa...@gmail.com> wrote:
Hi Brandon,
good idea but how? please look again at the SO site to look at the code for my attempt on that and how to do the last two heatmaps with sign in ggplot2. Thanks in advance
Reply all
Reply to author
Forward
0 new messages