Use of various distance measures and clustering methods in heatmap creation
2
0
Entering edit mode
svlachavas ▴ 830
@svlachavas-7225
Last seen 6 months ago
Germany/Heidelberg/German Cancer Resear…

Dear Bioconductor Community,

i would like to ask a specific and simple question about defining specific arguments than the default in the heatmap.2 function of the gplots R package. In detail, if i want to use as a distance measure the pearson correlation distance and as clustering method the average for clustering both my rows(genes) and columns(samples), should i proceed like this ? :

eset # my expression set

corr.dist = function(x) as.dist(1-cor(t(x))) 
avg = function(x) hclust(x, method="average")

heatmap.2(exprs(eset), distfun=corr.dist, hclustfun=avg, col=greenred(75), scale="none"....)

 

gplots heatmap.2 bioconductor pearsoncorrelation average • 10k views
ADD COMMENT
1
Entering edit mode
svlachavas ▴ 830
@svlachavas-7225
Last seen 6 months ago
Germany/Heidelberg/German Cancer Resear…

Dear Keith,

thank you for your answer-on the other hand, because i posted the question to get as much feedback i can-the function cor(x) computes the correlation on the columns on the matrix-object x-thats why i used the function transpose.

Also, from the link http://manuals.bioinformatics.ucr.edu/home/R_BioCondManual#R_clustering

i noticed that if you want to use different cluster methodologies for row and colums respectively, for instanse for a matrix named y:

hr <- hclust(as.dist(1-cor(t(y), method="pearson")), method="complete") # Clusters rows by Pearson correlation as distance method.
hc <- hclust(as.dist(1-cor(y, method="spearman")), method="complete") # Colums by spearman

and then heatmap(y, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc))  or heatmap.2

So, i want to confirm that the code is fine for both perspectives

Best,

Efstathios

 

ADD COMMENT
0
Entering edit mode
Keith Hughitt ▴ 180
@keith-hughitt-6740
Last seen 9 weeks ago
United States

Hi svlachavas,

I haven't tried passing a custom function to hclustfun before, but from a quick glance at the code it looks like it should work fine. To use Pearson correlation instead of euclidian distance, I would just pass in the correlation matrix directly:

heatmap.2(cor(exprs(eset)), ...)

HTH,

Keith

ADD COMMENT

Login before adding your answer.

Traffic: 659 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