I do want to cluster it and only plot the lower half of the matrix.

## Advertising

________________________________ From: Peter Langfelder <peter.langfel...@gmail.com> Sent: Thursday, September 15, 2016 11:33:13 PM To: Khan, Saad M. (MU-Student) Cc: r-help@R-project.org Subject: Re: [R] Visualizing and clustering one half of a symmetric matrix Do not set the upper (or lower) triangle to NA. Simply supply the full matrix to pheatmap. I am not an expert on pheatmap but looking at the manual you should supply clustering_distance_rows = "none", clustering_distance_cols = "none" or something like that to make pheatmap interpret the matrix as a distance matrix. Read carefully through the help on pheatmap to make sure the function plots what you want it to plot. HTH, Peter On Thu, Sep 15, 2016 at 7:38 PM, Khan, Saad M. (MU-Student) <smk...@mail.missouri.edu> wrote: > 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. > > library(pheatmap) > pheatmap(newmat) > > 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. > > Regards > Saad > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.