Question: Use of various distance measures and clustering methods in heatmap creation
0
gravatar for svlachavas
4.3 years ago by
svlachavas740
Greece/Athens/National Hellenic Research Foundation
svlachavas740 wrote:

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"....)

 

ADD COMMENTlink modified 4.3 years ago • written 4.3 years ago by svlachavas740
Answer: Use of various distance measures and clustering methods in heatmap creation
1
gravatar for svlachavas
4.3 years ago by
svlachavas740
Greece/Athens/National Hellenic Research Foundation
svlachavas740 wrote:

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 COMMENTlink written 4.3 years ago by svlachavas740
Answer: Use of various distance measures and clustering methods in heatmap creation
0
gravatar for Keith Hughitt
4.3 years ago by
Keith Hughitt120
United States
Keith Hughitt120 wrote:

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 COMMENTlink written 4.3 years ago by Keith Hughitt120
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 396 users visited in the last hour