|
a |
|
b/python-scripts/runSingleDAE.py |
|
|
1 |
from keras.layers import Input, Dense |
|
|
2 |
from keras.models import Model |
|
|
3 |
import numpy as np |
|
|
4 |
import pandas as pd |
|
|
5 |
import matplotlib.pyplot as plt |
|
|
6 |
from sklearn.cluster import KMeans |
|
|
7 |
from sklearn.cluster import k_means |
|
|
8 |
from sklearn.metrics import silhouette_score, davies_bouldin_score |
|
|
9 |
from sklearn.preprocessing import normalize |
|
|
10 |
import time |
|
|
11 |
from sklearn import metrics |
|
|
12 |
from myUtils import * |
|
|
13 |
from DAEclass import DAE |
|
|
14 |
import os |
|
|
15 |
|
|
|
16 |
if __name__ == '__main__': |
|
|
17 |
datapath = 'data/single-cell/' |
|
|
18 |
resultpath = 'result/single-cell/' |
|
|
19 |
# groundtruth = np.loadtxt('{}/c.txt'.format(datapath)) |
|
|
20 |
# groundtruth = list(np.int_(groundtruth)) |
|
|
21 |
|
|
|
22 |
omics = np.loadtxt('{}/omics.txt'.format(datapath)) |
|
|
23 |
omics = np.transpose(omics) |
|
|
24 |
omics1 = omics[0:206] |
|
|
25 |
omics2 = omics[206:412] |
|
|
26 |
omics1 = normalize(omics1, axis=0, norm='max') |
|
|
27 |
omics2 = normalize(omics2, axis=0, norm='max') |
|
|
28 |
omics = np.concatenate((omics1, omics2), axis=1) |
|
|
29 |
|
|
|
30 |
data = omics |
|
|
31 |
input_dim = data.shape[1] |
|
|
32 |
encoding1_dim = 4096 |
|
|
33 |
encoding2_dim = 1024 |
|
|
34 |
middle_dim = 2 |
|
|
35 |
dims = [encoding1_dim, encoding2_dim, middle_dim] |
|
|
36 |
# ae = AE(data, dims) |
|
|
37 |
# ae.train() |
|
|
38 |
# encoded_factors = ae.predict(data) |
|
|
39 |
|
|
|
40 |
noise_factor = 0.1 |
|
|
41 |
dae = DAE(data, dims, noise_factor) |
|
|
42 |
dae.autoencoder.summary() |
|
|
43 |
dae.train() |
|
|
44 |
encoded_factors = dae.predict(data) |
|
|
45 |
|
|
|
46 |
if not os.path.exists("{}/DAE_FCTAE_EM.txt".format(resultpath)): |
|
|
47 |
os.mknod("{}/DAE_FCTAE_EM.txt".format(resultpath)) |
|
|
48 |
np.savetxt("{}/DAE_FCTAE_EM.txt".format(resultpath), encoded_factors) |
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|