5

dendogramThis is the heatmap I am able to generateI am trying to take my dataset which is made up of protein dna interaction, cluster the data and generate a heatmap that displays the resulting data such that the data looks clustered with the clusters lining up on the diagonal. I am able to cluster the data and generate a dendrogram of that data however when I generate the heatmap of the data using the heatmap function in R, the clusters are not visible. If you look at the first 2 images one is of the dendrogram I am able to generate, the second is of the heatmap that I am able to generate, and the third is just an example of a clustered heatmap that shows how I expect the result to look roughly. As you can see from comparing the second and third images, it is clear that there are clusters in the third but not in the second image. Example heatmap

Here is a link to my dataset: http://pastebin.com/wQ9tYmjy

I am able to cluster the data and generate a just fine in R:

args <- commandArgs(TRUE);

matrix_a <- read.table(args[1], sep='\t', header=T, row.names=1);

location <- args[2];

matrix_d <- dist(matrix_a);

hc <- hclust(matrix_d,"average");

mypng <- function(filename = "mydefault.png") {

png(filename)

}

options(device = "mypng")

plot(hc);

I am also able to generate a heatmap okay as well:

matrix_a <- read.table("Arda_list.txt.binary.matrix.txt", sep='\t', header=T, row.names=1);

mtscaled <- as.matrix(scale(matrix_a))

heatmap(mtscaled, Colv=F, scale='none')

I tried to follow the post: http://digitheadslabnotebook.blogspot.com/2011/06/drawing-heatmaps-in-r.html by by Christopher Bare but I am missing something. Any ideas would be appreciated. I have attached an image of the heatmap that I am getting, as well as the dendrogram. Image 3 was taken from Christopher Bare's post. Thanks

Argalatyr
  • 4,639
  • 3
  • 36
  • 62
Alos
  • 2,657
  • 5
  • 35
  • 47
  • 4
    So you can cluster, and generate the heatmap...what exactly is the problem? – Paul Hiemstra Aug 06 '12 at 15:45
  • Hi Paul when I generate the heatmap the data is not clustered. I seem to be able to generate the tree of clustered data, and I can generate a heatmap of the data but when I generate the heatmap the data is not clustered. – Alos Aug 06 '12 at 16:59
  • Please provide a reproducible example, and include the output of the clustering, and the heatmap. From the example and the output you need to show us exactly what you expected, and why what you get is wrong. – Paul Hiemstra Aug 06 '12 at 17:29
  • Hi Paul the issue was that I was expecting clear clusters and was not getting anything like that, but it turns out that I should have run my data through pearson or something to generate good distance values. Once I did that I am seeing clusters in the data. – Alos Aug 06 '12 at 17:44
  • @PaulHiemstra I have tried to answer all of your comments, let me know if it still does not make sense. Thanks – Alos Aug 07 '12 at 15:19
  • I can't say if your result are good because I don't know your data. I asked for clarification because it was unclear what your problem was. – Paul Hiemstra Aug 07 '12 at 16:27

1 Answers1

7

enter image description here

It turns out I should have generated a distance matrix using some kind of correlation on my data first. I calculated similarity values on the matrix using pearson, then called the heapmap function which made it easier to cluster the data. Once I was able to generate clusters I made it so that they would line up on the diagonal. Above is what the result looks like now. I had to alter how I called heatmap on my data set so that the clusters line up on the axis:

heatmap(mtscaled, Colv=T,Rowv=T, scale='none',symm = T)
Alos
  • 2,657
  • 5
  • 35
  • 47