How to plot heatmap for the matrix for the pairwise comparison of sequence similarity in R ?
1
0
Entering edit mode
6.5 years ago
lokraj2003 ▴ 120

I am working sequence alignment and I want to show the percentage of difference among all the pairs. I got a pairwise comparison table in CSV format from MEGA in the following format :

Table 1.

a                   
b   1               
c   2   5           
d   1   8   7       
e   3   9   6   6

As you can see the output table does not contain names for the columns. Ideally, columns should be a,b,c,d,e so that (a,a=0), (a,b=1),(a,c=2) and so on.

My initial thought is that it might be easier if I convert this table into the format like follow :

Table 2.

    a   b   c   d   e
a   0   1   2   1   3
b   1   0   5   8   9
c   2   5   0   7   6
d   1   8   7   0   6
e   3   9   6   6   0

1) Is it possible to make heatmap without converting table 1 to table 2 in R ?

2) Since my table has 380 columns , how do I convert table 1 to table 2 in R ?

3) Are there any visualization tool better than heatmap to plot this kind of data in R ?

r R heatmap • 6.5k views
ADD COMMENT
4
Entering edit mode
6.5 years ago
Chirag Parsania ★ 2.0k

You can use corrplot from package corrplot to generate the matrix heatmap. You can use your Table 2 as input. However, it will show you one of the half of given matrix. as.matrix should work to convert Table 1 to Table 2

corrplot::corrplot(as.matrix(dd) , is.corr = FALSE , type = "upper",diag = F,method = "color",tl.cex = 3,cl.cex = 1)

Rplot03

ADD COMMENT

Login before adding your answer.

Traffic: 1708 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6