예제 #1
0
def analyze(input_data_path, output_image_path, tree_building_function):
    logging.debug('read the matrix')
    X = util.file_to_comma_separated_matrix(input_data_path, has_headers=True)
    logging.debug('build the tree')
    root = tree_building_function(X)
    logging.debug('extract ordered indices from the tree')
    ordered_indices = root.ordered_labels()
    logging.debug('create the elementwise squared correlation matrix')
    R = np.corrcoef(X)
    logging.debug('permute the elementwise squared correlation matrix according to the ordering')
    M = heatmap.get_permuted_rows_and_columns(R, ordered_indices)
    logging.debug('create the heatmap')
    f = gradient.correlation_to_rgb
    heatmap.get_heatmap_with_dendrogram(M, root, f, output_image_path)
예제 #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)