title: Error with multiscale hierarchical clustering in R
body: <p>I'm doing hierarchical clustering with an R package called <code>pvclust</code>, which builds on <code>hclust</code> by incorporating bootstrapping to calculate significance levels for the clusters obtained.</p>
  
  <p>Consider the following data set with 3 dimensions and 10 observations:</p>
  
  <pre><code>mat &lt;- as.matrix(data.frame("A"=c(9000,2,238),"B"=c(10000,6,224),"C"=c(1001,3,259),
                          "D"=c(9580,94,51),"E"=c(9328,5,248),"F"=c(10000,100,50),
                          "G"=c(1020,2,240),"H"=c(1012,3,260),"I"=c(1012,3,260),
                          "J"=c(984,98,49)))
  </code></pre>
  
  <p>When I use <code>hclust</code> alone, the clustering runs fine for both Euclidean measures and correlation measures:</p>
  
  <pre><code># euclidean-based distance
  dist1 &lt;- dist(t(mat),method="euclidean")
  mat.cl1 &lt;- hclust(dist1,method="average")
  
  # correlation-based distance
  dist2 &lt;- as.dist(1 - cor(mat))
  mat.cl2 &lt;- hclust(dist2, method="average")
  </code></pre>
  
  <p>However, when using the each set up with <code>pvclust</code>, as follows:</p>
  
  <pre><code>library(pvclust)
  
  # euclidean-based distance
  mat.pcl1 &lt;- pvclust(mat, method.hclust="average", method.dist="euclidean", nboot=1000)
  
  # correlation-based distance
  mat.pcl2 &lt;- pvclust(mat, method.hclust="average", method.dist="correlation", nboot=1000)
  </code></pre>
  
  <p>... I get the following errors:</p>
  
  <ul>
  <li>Euclidean: <code>Error in hclust(distance, method = method.hclust) : 
  must have n &gt;= 2 objects to cluster</code></li>
  <li>Correlation: <code>Error in cor(x, method = "pearson", use = use.cor) : 
  supply both 'x' and 'y' or a matrix-like 'x'</code>.</li>
  </ul>
  
  <p>Note that the distance is calculated by <code>pvclust</code> so there is no need for a distance calculation beforehand. Also note that the <code>hclust</code> method (average, median, etc.) does not affect the problem.</p>
  
  <p>When I increase the dimensionality of the data set to 4, <code>pvclust</code> now runs fine. Why is it that I'm getting these errors for <code>pvclust</code> at 3 dimensions and below but not for <code>hclust</code>? Furthermore, why do the errors disappear when I use a data set above 4 dimensions?</p>