title: R hierarchical clustering visualizing classifications without clustering on them
body: <p>I've been studying some data sets using hierarchical clustering. In these data sets, there are a certain number of variables that I want to use to cluster data, and then there are other classification variables that I do not want to cluster on but still want to visualize. </p>
  
  <p>What I want to do is find a way to "add a tier" to the heat map generated by the clustering algorithm where I can view binary classifications (colored red for 1, blue for 0), without actually clustering on this data. That way, I can evaluate how well my classification responses are grouped together by clustering.</p>
  
  <p>Here is a simplified example: </p>
  
  <pre><code>library("gplots")
  set.seed(1)
  
  ## creating random data to input into hierarchial clustering algorithm
  data &lt;- matrix(rexp(100, rate = 0.1), ncol = 10) 
  colnames(data) &lt;- c("var1", "var2", "var3", "var4", "var5", "var6", 
      "var7", "var8", "var9", "var10")
  
  # these are the two classification labels for each data point
  classification1 &lt;- c(1, 1, 0, 1, 1, 0, 0, 0, 1, 1)  
  
  # I want to visualize how well the clustering algorithm groups
  # the data correlates with the classifications without
  # clustering on these classifications
  classification2 &lt;- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 0)  
  
  par(mar = c(1, 4.5, 0.1, 0.1))
  matrix = rbind(c(1, 2), c(3, 4), c(5, 6))
  wid = c(1, 1)
  hei = c(0.5, 10)
  hclustfunc &lt;- function(x) hclust(x, method = "complete")
  distfunc &lt;- function(x) dist(x, method = "euclidean")
  my_palette &lt;- colorRampPalette(c("yellow", "orange", "darkorange", 
      "red", "darkred"))(n = 1000)
  heatmap.2(as.matrix(data), dendrogram = "row", trace = "none", 
      margin = c(8, 9), hclust = hclustfunc, distfun = distfunc, 
      col = my_palette, key = FALSE, key.xlab = "", key.title = "Clustering Algorithm", 
      key.ylab = "", keysize = 1.25, density.info = "density", 
      lhei = hei) 
  </code></pre>
  
  <p>This generates the heat map that has given me a lot of information. What I would now like to do is append two more columns to the right of the heat map that the clustering algorithm does not use for clustering. </p>
  
  <p>These two columns would be binary labels for "classification 1" and "classification 2" (and have a red cell for 1, a blue cell for 0). I just want a visualization of how well these classification responses are grouped together in the dendogram. </p>