title: Permutation vectors from the CLUSTERGRAM object (MATLAB)
body: <p>I'm using the <a href="http://www.mathworks.com/help/toolbox/bioinfo/ref/clustergram.html" rel="nofollow noreferrer"><strong>CLUSTERGRAM</strong></a> object from the Bioinformatics Toolbox (ver 3.7).
  MATLAB version R2011a.</p>
  
  <p>I'd like to get permutation vectors for row and columns for clustergram, as I can do with <a href="http://www.mathworks.com/help/toolbox/stats/dendrogram.html" rel="nofollow noreferrer">dendrogram</a> function:</p>
  
  <pre><code>x = magic(10);
  &gt;&gt; [~,~,permrows] = dendrogram(linkage(x,'average','euc'))
  permrows =
       9    10     6     7     8     1     2     4     5     3
  &gt;&gt; [~,~,permcols] = dendrogram(linkage(x','average','euc'))
  permcols =
       6     7     8     9     2     1     3     4     5    10
  </code></pre>
  
  <p>I found that the clustering is not the same from clustergram and dendrogram, most probably due to optimal leaf ordering calculation (I don't want to disable it).</p>
  
  <p>For example, for clustergram from:</p>
  
  <pre><code>clustergram(x)
  </code></pre>
  
  <p>(<code>'average'</code> and <code>'eucledian'</code> are default methods for clustergram)</p>
  
  <p>the vectors (as on the figure attached) should be:</p>
  
  <pre><code>permrows = [1 2 4 5 3 10 9 6 7 8];
  permcols = [1 2 8 9 6 7 10 5 4 3];
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Ivna0.png" alt="clustergram example"></p>
  
  <p>So, how to get those vectors programmatically? Anybody well familiar with this object?</p>
  
  <p>Do anyone can suggest a good alternative? I know I can create a similar figure combining imagesc and dendrogram functions, but leaf ordering is much better (optimal) in clustergram, than in dendrogram.</p>