예제 #1
0
def main():
    # read the data matrix from stdin
    logging.debug('reading input lines')
    lines = sys.stdin.readlines()
    logging.debug('converting input lines to data matrix')
    X = util.lines_to_comma_separated_matrix(lines, has_headers=True)
    logging.debug('creating the tree')
    root = treebuilder.build_tree(X)
    logging.debug('creating the newick string')
    print root.get_newick_string()
예제 #2
0
def main():
    X = util.file_to_whitespace_separated_matrix("khatrisvd/fivetimes.txt")
    n = len(X)

    permutation = range(n)
    random.shuffle(permutation)
    X = heatmap.get_permuted_rows(X, permutation)

    root = treebuilder.build_tree(X)
    # show the unordered heatmap
    filename = "unordered.png"
    RoR = np.corrcoef(X) ** 2
    heatmap.get_heatmap(RoR, filename)
    # show the ordered heatmap
    filename = "reordered.png"
    ordered_indices = root.ordered_labels()
    M = heatmap.get_permuted_rows_and_columns(RoR, ordered_indices)
    heatmap.get_heatmap(M, filename)
예제 #3
0
def main():
    pathname_in = 'mmc-data-files/Starvation_Residual.TXT'
    X = util.file_to_comma_separated_matrix(pathname_in, has_headers=True)
    print X.shape
    # create the tree from the data
    root = treebuilder.build_tree(X)
    ordered_indices = root.ordered_labels()
    X = heatmap.get_permuted_rows(X, ordered_indices)
    # create the standardized data for drawing the small heatmap
    Z = khorr.get_standardized_matrix(X)
    # show the big heatmap
    pathname_out = 'big.png'
    color_function = gradient.correlation_to_rgb
    im = heatmap.get_heatmap_image(np.dot(Z, Z.T), color_function)
    fout = open(pathname_out, 'wb')
    im.save(fout)
    fout.close()
    # show the small heatmap
    pathname_out = 'small.png'
    im = heatmap.get_reduced_heatmap_image(Z, reduction=5)
    fout = open(pathname_out, 'wb')
    im.save(fout)
    fout.close()