-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript-20090714a.py
45 lines (38 loc) · 1.21 KB
/
script-20090714a.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
This is a junk script.
Test the box-filtering.
"""
import logging
import numpy as np
from khatrisvd import treebuilder
from khatrisvd import splitbuilder
from khatrisvd import khorr
from khatrisvd import heatmap
from khatrisvd import util
from khatrisvd import gradient
logging.basicConfig(level=logging.DEBUG)
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()
if __name__ == '__main__':
main()