# Showing a correlation and its p-value as a color

I want to convey in a heatmap how well are some correlations $[-1, 1]$ with its p-value $[0, 1]$. To normalize the plotting, the resulting numbers must be between $-1$ and $1$ and the sign must be the same as in the correlation in order to plot with a different color if the correlation is positive or negative. The higher the absolute value of a correlation is and the lowest the p-value, the higher must be the resulting number to be used for the heatmap.

How can I do that transformation to visualize easier the correlation and its p-value?

If $r = 0.8$ and $p = 0.04$, I want it with a value closer to $0$ than a correlation with $r = 0.8$ and $p = 0.03$. But a correlation with $r = -0.8$ and $p = 0.03$ must be minus the same number as for $r = 0.8$ and p-value $0.03$. Because usually low correlations tend to have high p-value (at least on my data) I would like to have the p-value and the correlation with the same influence on color.

• I'll assume you already know that it's not really sensible to interpret p values like this... If you want to combine $r$ and $p$ into a single number then it seems like you'll have to decide the relative importance of each variable (i.e. decide if you want a difference of .1 in $r$ to have the same influence on colour as a difference of .1 in $p$, or a different influence) Nov 16 '16 at 12:20
• Just to be clear, re: your final sentence, you do know that the size of $r$ and $p$ are related? If $N$ is constant then the larger $r$ is, the smaller $p$ will be. Nov 16 '16 at 14:15
• I've re-opened your q. as it seems you're interested in the principle rather than implementation using specific software. Nov 16 '16 at 14:15
• What Jake is getting at is the fact that if $r_1=r_2$, and $N_1=N_2$, then the two $p$ values must be equal. Similarly, if $r_1<r_2$ and $N_1=N_2$ then $r_1$ will always have a larger $p$ value. Furthermore, if $r_1=r_2$, but $p_1<p_2$ then you know that $N_1>N_2$. Nov 16 '16 at 16:15
• If you really think you need to visualise something like this I keep coming back to thinking that what might make more sense is something like this but where the size of the circle instead represents N. I would stay away from visualising p because, as I alluded to earlier, it encourages thinking that there's something meaningful about the difference between, e.g., $p=.03$ and $p=.04$ Nov 16 '16 at 16:21

I use the following transformation: I multiply the correlation measure by 1 minus the p-value: cor.value * (1 - p.value). And the resulting heatmap looks like this:
• One thing that really jumps out at me are the two -.28 correlations in the bottom right corner. The top is not significant at an $\alpha=.05$ level, while the bottom would be significant even at an $\alpha=.001$ level, and yet the difference between the two colours is almost imperceptible. If I have to inspect the $p$-values for two equal correlations to determine which is and which isn't significant then I'm not what the purpose is of having $p$ influence the colours. Nov 17 '16 at 10:20
• Your example does illustrate what I said in my first comment to the question though: If you want to aggregate $r$ and $p$ you need to decide on the relative importance of each. In this formula, they have equal importance so a big difference in what is arguably the less interesting variable can warp differences in the more interesting one Nov 17 '16 at 10:50
• @Llopis The formula you ought to use probably depends on what information you want to convey and, perhaps more critically, what you want to do with the information. It's not obvious why you want to represent differences in $p$-values, when often the only use for a $p$-value is to see if it's below some $\alpha$-level. Nov 17 '16 at 16:08
• But why wouldn't using cor.value^3 * cos(p.value) make it even easier to spot interesting cells? Nov 23 '16 at 17:45