def main(simmat_path="data/first_110.atg.txt"): #load similairy matrix mat = load_simmat(simmat_path) #convert to distance matrix dist_mat = sim_to_dist(mat) #the idx to label function llf = lambda i: dist_mat.get_label(i) link_mat = linkage(dist_mat) disp_linakge_mat(link_mat, llf, len(dist_mat)) grps = get_groups(link_mat, llf) for g in grps: print ",".join(g)
def gen_dendrogram(path, out): """(str, str) => None from complex pair-wise distance text file to dendagram """ fig = pylab.figure(figsize = (80,40)) mat = load_simmat(path) print mat.labels dist_mat = sim_to_dist(mat) link_mat = linkage(mat) llf = lambda i: dist_mat.get_label(i) dendrogram(link_mat, leaf_label_func=llf) plt.tick_params(axis='both', which='major', labelsize=18) fig.savefig(out)