-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnmf-main-real.py
More file actions
34 lines (28 loc) · 898 Bytes
/
nmf-main-real.py
File metadata and controls
34 lines (28 loc) · 898 Bytes
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
from lib.functions import *
from lib.NmfClass import *
from matplotlib import pyplot as plt
import nimfa as nf
import os
from pathlib import Path as pth
os.chdir(pth(__file__).parent)
x_ori = pd.read_csv('data/input_CCLE_drug_IC50_zero-one.csv', index_col=0, header=0)
x = clean_df(x_ori).as_matrix()
k_list = [30, 25, 10, 3, 40, 2, 5, 6, 40, ]
data_name = "CCLE_drug"
# x = nf.examples.medulloblastoma.read(normalize=True)
# data_name = "medulloblastoma"
# k_list = list(range(2, 10))
k_list.sort()
for k in k_list:
m = NmfModel(x, k, niter=1000, super_niter=2)
m.super_wrapper(verbose=1)
print("K = %i Error = %f" % (k, m.error))
plt.subplot(121)
plt.suptitle("k = %s" % k)
heatmap(m.consensus_matrix_h)
plt.title("H")
plt.subplot(122)
heatmap(m.consensus_matrix_w)
plt.title("W")
plt.show()
plt.savefig("plots/%s-k=%i.jpg" % (data_name, k))