2021年5月3日星期一

How to make a heatmap-like graph with significance level based on two tables in R?

Basically, I have two 7x7 tables, which are saved as long_iccs and pvalues in data.

For the long_iccs table, the x-axis is titled as 03m, 06m, 09m, 12m, 18m, 24m, and 36m, and the y-axis is also titled as 03m, 06m, 09m, 12m, 18m, 24m, and 36m-- I want to keep this format in my output graph.

03m 06m 09m 12m 18m 24m 36m
03m 1 0.25 -0.002 0.10 -0.057 -0.063 NaN
06m 0.25 1 0.384 0.265 0.209 0.021 0.209
09m -0.0021 0.374 1 0.454 0.426 -0.0132 0.361
12m 0.100 0.265 0.454 1 0.286 0.118 0.414
18m -0.0572 0.209 0.426 0.286 1 0.248 0.409
24m -0.0632 0.0213 -0.0132 0.118 0.248 1 -0.163
36m NaN 0.209 0.361 0.414 0.409 -0.163 1

For the pvalues dataframe, it looks like this:

V1 V2 V3 V4 V5 V6 V7
1 NaN 0.146821255 0.5032691552 0.2744200984 0.696125633 0.68544985 0.809989049
2 1.468213e-01 NaN 0.0046248855 0.0255566484 0.084404798 0.42822440 0.081061255
3 5.032692e-01 0.004624886 NaN 0.0004159696 0.002517379 0.53866956 0.006688649
4 2.744201e-01 0.025556648 0.0004159696 NaN 0.040601011 0.21443715 0.002414332
5 6.961256e-01 0.084404798 0.0025173792 0.0406010109 NaN 0.07311703 0.008312505
6 6.854499e-01 0.428224404 0.5386695582 0.2144371492 0.073117029 NaN 0.840898661
7 8.099890e-01 0.081061255 0.0066886493 0.0024143322 0.008312505 0.84089866 NaN

Now talking about what the output graph should look like:

  1. basically it should look like heatmap (these values are from the long_iccs):

  2. then, on each block, I want to add *, **, *** at the top right corner of the numbers if the corresponding values from the pvalues table are <.05, <.005, < .0005 respectively (if the block shows NaN, no need to add any asterisks).

I have tried to "hack" the corrplot package but the significance level given to me is not based on my pvalues table, but the correlations of long_iccs. Some brilliant people please help, thanks a lot!

https://stackoverflow.com/questions/67376993/how-to-make-a-heatmap-like-graph-with-significance-level-based-on-two-tables-in May 04, 2021 at 07:32AM

没有评论:

发表评论