title: heatmap.2- Error: Colv dendrogram doesn't match size of x
body: <p>I am generating a heatmap using R.<br>
  I used the <code>hclust</code> function and got the error:
  <code>Colv dendrogram doesn't match size of x</code>. </p>
  
  <p>Below is my code, it works perfectly with a square matrix. Now my input matrix is <code>400x2000</code>. Can someone tell me why I am getting this error?</p>
  
  <pre><code>data &lt;- read.table("mydata.txt",sep="\t",header=TRUE,row.names=1)
  data_matrix &lt;- data.matrix(data)
  library(gplots)
  library("RColorBrewer")
  colors &lt;- colorRampPalette(rev(brewer.pal(9, "Blues")) )(255)
  hc_dist= dist(data_matrix)
  hc_clust= hclust(hc_dist)
  hr_dist= dist(t(data_matrix))
  hr_clust= hclust(hr_dist)
  heatmap.2(data_matrix, col=brewer.pal(11,"RdBu"), labRow=NA, density.info="none", scale="row",trace="none",Colv=as.dendrogram(hc_clust),     Rowv=as.dendrogram(hr_clust))
  
   Error in heatmap.2(data_matrix, col = brewer.pal(11, "RdBu"), labRow = NA,:Colv dendrogram doesn't match size of x
  </code></pre>