Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get flat clustering corresponding to color clusters in the dendrogram created by scipy
    primarykey
    data
    text
    <p>Using the code posted <a href="https://stackoverflow.com/questions/2455761/reordering-matrix-elements-to-reflect-column-and-row-clustering-in-naiive-python/3017704#3017704">here</a>, I created a nice hierarchical clustering:</p> <p><img src="https://i.stack.imgur.com/hj00i.png" alt="scipy dendrogram"></p> <p>Let's say the the dendrogram on the left was created by doing something like</p> <pre><code>Y = sch.linkage(D, method='average') # D is a distance matrix cutoff = 0.5*max(Y[:,2]) Z = sch.dendrogram(Y, orientation='right', color_threshold=cutoff) </code></pre> <p>Now <strong>how do I get the indices of the members of each of the colored clusters?</strong> To simplify this situation, ignore the clustering on the top, and focus only on the dendrogram on the left of the matrix.</p> <p>This information should be stored in the dendrogram <code>Z</code> stored variable. There is a function that should do just what I want called <code>fcluster</code> (see documentation <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.fcluster.html#scipy.cluster.hierarchy.fcluster" rel="nofollow noreferrer">here</a>). However I cannot see where I can give fcluster the same <code>cutoff</code> as I specified in the creation of the dendrogram. It seems that the threshold variable in <code>fcluster</code>, <code>t</code> has to be in terms of various obscure measurements (<code>inconsistent</code>, <code>distance</code>, <code>maxclust</code>, <code>monocrit</code>). Any ideas? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload