title: Clustering and heatmap in R
body: <p>I am a newbie to R and I am trying to do some clustering on a data table where rows represent individual objects and columns represent the features that have been measured for these objects. I've worked through some clustering tutorials and I do get some output, however, the heatmap that I get after clustering does not correspond at all to the heatmap produced from the same data table with another programme. While the heatmap of that programme does indicate clear differences in marker expression between the objects, my heatmap doesn't show much differences and I cannot recognize any clustering (i.e., colour) pattern on the heatmap, it just seems to be a randomly jumbled set of colours that are close to each other (no big contrast). Here is an example of the code I am using, maybe someone has an idea on what I might be doing wrong.</p>
  
  <pre><code>mydata &lt;- read.table("mydata.csv")
  datamat &lt;- as.matrix(mydata)
  datalog &lt;- log(datamat)
  </code></pre>
  
  <p>I am using log values for the clustering because I know that the other programme does so, too</p>
  
  <pre><code>library(gplots)
  
  hr &lt;- hclust(as.dist(1-cor(t(datalog), method="pearson")), method="complete")
  mycl &lt;- cutree(hr, k=7)
  mycol &lt;- sample(rainbow(256)); mycol &lt;- mycol[as.vector(mycl)]
  heatmap(datamat, Rowv=as.dendrogram(hr), Colv=NA,
      col=colorpanel(40, "black","yellow","green"),
      scale="column", RowSideColors=mycol) 
  </code></pre>
  
  <p>Again, I plot the original colours but use the log-clusters because I know that this is what the other programme does.</p>
  
  <p>I tried to play around with the methods, but I don't get anything that would at least somehow look like a clustered heatmap. When I take out the scaling, the heatmap becomes extremely dark (and I am actually quite sure that I have somehow to scale or normalize the data by column). I also tried to cluster with k-means, but again, this didn't help. My idea was that the colour scale might not be used completely because of two outliers, but although removing them slightly increased the range of colours plotted on the heatmap, this still did not reveal proper clusters.</p>
  
  <p>Is there anything else I could play around with?</p>
  
  <p>And is it possible to change the colour scale with heatmap so that outliers are found in the last bin that has a range of "everything greater than a particular value"? I tried to do this with heatmap.2 (argument "breaks"), but I didn't quite succeed and also I didn't manage to put the row side colours that I use with the heatmap function.</p>