[R] Visualizing and clustering one half of a symmetric matrix

Khan, Saad M. (MU-Student) smk5g5 at mail.missouri.edu
Fri Sep 16 04:38:12 CEST 2016

Hi all,

I have a distance matrix (symmetric) which looks somewhat like this (only a small portion shown)

                ENSG00000101413 ENSG00000176884 ENSG00000185532 ENSG00000106829
ENSG00000101413           1.000           1.000           1.000           1.000
ENSG00000176884           0.328           0.258           0.260           0.390
ENSG00000185532           1.000           1.000           1.000           1.000
ENSG00000106829           0.684           0.443           0.531           0.701

These distances are custom measures that I need to cluster. Since it's a symmetric matrix I only need to consider one half triangle of the matrix. So I do something like this :-

newmat <- ensembl_copygosimmat
newmat[upper.tri(ensembl_copygosimmat)] <- NA

Then I wanted to visualize how the lower triangle looked using pheatmap which does hierarchical clustering itself.


But since there are NA values in the matrix (in the upper half) it always throws an error. I was wondering what would be the ideal way to visualize as well as cluster such a matrix.


	[[alternative HTML version deleted]]

More information about the R-help mailing list