def dunnindex_clusternumber(linkage,df_zscores, output_dir ="."):
     index_list=[]
     for n_clusters in range(2,30):
         assignments = hierarchy.fcluster(linkage, n_clusters, criterion="maxclust")
         df_assign_id = pd.DataFrame()

         df_assign_id['cluster_id'] = assignments

         clusters = np.unique(assignments)
         num_cluster = len(clusters)

         cluster_list = []  # for dunn index calculation

         df_cluster = pd.DataFrame()
         df_zscore_cluster = pd.DataFrame()
         for i in clusters:
            ids = np.nonzero(assignments == i)[0]  # starting from  0
            df_zscore_cluster = df_zscores.iloc[ids]
            cluster_list.append(df_zscore_cluster.values)

         dunn_index = dunn(cluster_list)
         index_list.append(dunn_index)
     pl.figure()
     pl.plot(range(2,30),index_list,"*-")
     pl.xlabel("cluster number")
     pl.ylabel("dunn index")
     pl.savefig(output_dir+'/dunnindex_clusternumber.pdf')
     #pl.show()
     return