티스토리 뷰

R

R | Clustering된 Heatmap 그리기, pheatmap,

Chloe A_Choe 2020. 1. 16. 14:06

matrix.csv
0.00MB

 

pheatmap을 이용해서 clustering된 heatmap을 그리는 방법

(본 포스팅에 사용된 데이터 셋은 위 링크를 통해 받을 수 있습니다.)

 

# 목표 히트맵

 

1. Importing Test Data

> myData <- read.csv(sprintf('C:/chloe-with-data/Heatmap_Cluster/matrix.csv'), header = T, row.names = 1)
> myData %>% dim
[1] 15 15
> myData %>% head
      A     B     C     D     E     F    G    H    I    J    K    L    M    N    O
A 100.0  79.7  79.8  80.6  80.4  80.9 80.0 79.9 79.1 94.6 79.7 94.7 95.0 95.0 78.8
B  79.7 100.0  84.8  84.7  84.3  86.0 92.0 85.3 83.6 80.3 85.0 79.8 79.8 78.7 85.3
C  79.8  84.8 100.0  88.9  90.7  90.9 84.7 88.8 85.6 79.8 93.4 79.6 79.6 79.9 85.6
D  80.6  84.7  88.9 100.0  89.6  89.7 84.8 88.3 85.0 80.8 88.8 80.6 80.7 80.6 85.6
E  80.4  84.3  90.7  89.6 100.0  94.6 84.7 89.4 85.0 80.3 89.8 80.4 80.4 79.5 86.8
F  80.9  86.0  90.9  89.7  94.6 100.0 85.9 89.7 86.7 80.9 90.1 80.6 80.6 80.8 87.3

 

2. pheatmap : default

> p <- pheatmap(myData)
> p

 

3. pheatmap : without clustering

> p <- pheatmap(myData, 
+               cluster_rows = F,
+               cluster_cols = F)
> p

 

3. pheatmap : with values

> p <- pheatmap(myData,  
+               display_numbers = T) 
> p 

 

4. pheatmap : white border

> p <- pheatmap(myData, 
+               display_numbers = T,
+               border_color = 'white')  
> p

5. pheatmap : show colnames False

> p <- pheatmap(myData, 
+               display_numbers = T,
+               border_color = 'white',
+               show_colnames = F,
+               show_rownames = T)

6. pheatmap : cutree

> p <- pheatmap(myData,  
+               display_numbers = T, 
+               border_color = 'white', 
+               show_colnames = F, 
+               show_rownames = T,
+               cutree_rows = 2, 
+               cutree_cols = 2)
 
> p

 

3. pheatmap : set color

> p <- pheatmap(myData, 
+               cutree_rows = 2,
+               cutree_cols = 2,
+               color = colorRampPalette(c('#2471A3','white','#C0392B'))(50), 
+               border_color = 'white',
+               display_numbers = T,
+               show_colnames = F,
+               show_rownames = T)
> p

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함