Dr.PhilCol
Dr.PhilCol

Reputation: 21

correlation heatmap using heatmaply R

I'm trying to create an heatmap on the base of spearman correlation and with dendrogramm corresponding to spearman correlation values. My input file is composed as follow:

 > data[1:6,1:6]
         group EG   PN        C0      C10     C10.1
    1 Patients 24  729 352.66598 43.80707  75.16226
    2 Patients 24  729 195.48486 17.15763  33.60365
    3 Patients 24  729 106.85937 15.13400  34.47340
    4 Patients 27 1060  76.70645 14.98315  22.09885
    5 Patients 27 1060 354.07169 50.61995  98.36765
    6 Patients 27 1060 331.84956 92.00343 125.46658
> data[150:160,1:6]
       group EG   PN        C0       C10     C10.1
150 Controls 27 1011  99.94756  9.018773 20.207498
151 Controls 30  616 300.20203 25.667548 37.363280
152 Controls 30  616 190.38030 18.811198 46.417332
153 Controls 26  930  79.44666  7.801935  4.569444
154 Controls 24  724 381.74026 39.842241 42.144842
155 Controls 24  724 191.39962 19.008729 31.064398

I'm able to made up a simple correlation plot but i would like to create an unique heatmap with both protein and subjects dendrogram on the base on spearman correlation. Does anyone know how to do? thanks in advance

Upvotes: 1

Views: 722

Answers (1)

alan ocallaghan
alan ocallaghan

Reputation: 3038

The following code displays an interactive heatmap using Spearman's rank correlation to cluster both rows and columns (in this case for the mtcars dataset).

heatmaply(mtcars, 
    distfun = function(x) as.dist(1 - cor(t(x), method="spearman")))

Upvotes: 1

Related Questions