[0b32b6]: / python-scripts / runSingleSVAE2.py

Download this file

64 lines (47 with data), 1.7 kB

 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
46
47
48
49
50
51
52
53
54
from keras.layers import Input, Dense
from keras.models import Model
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn.cluster import k_means
from sklearn.metrics import silhouette_score, davies_bouldin_score
from sklearn.preprocessing import normalize
import time
from sklearn import metrics
from myUtils import *
from SVAEclass import VAE
#from AEclass import AE
import os
if __name__ == '__main__':
datapath = 'data/single-cell/'
resultpath = 'result/single-cell/'
# groundtruth = np.loadtxt('{}/c.txt'.format(datapath))
# groundtruth = list(np.int_(groundtruth))
omics = np.loadtxt('{}/omics.txt'.format(datapath))
omics = np.transpose(omics)
omics1 = omics[0:206]
omics2 = omics[206:412]
omics1 = normalize(omics1, axis=0, norm='max')
omics2 = normalize(omics2, axis=0, norm='max')
#omics = np.concatenate((omics1, omics2), axis=1)
encoding1_dim1 = 2048
encoding2_dim1 = 512
middle_dim1 = 1
dims1 = [encoding1_dim1, encoding2_dim1, middle_dim1]
ae1 = VAE(omics1, dims1)
ae1.train()
ae1.autoencoder.summary()
encoded_factor1 = ae1.predict(omics1)
encoding1_dim2 = 2048
encoding2_dim2 = 512
middle_dim2 = 1
dims2 = [encoding1_dim2, encoding2_dim2, middle_dim2]
ae2 = VAE(omics2, dims2)
ae2.train()
ae2.autoencoder.summary()
encoded_factor2 = ae2.predict(omics2)
encoded_factors = np.concatenate((encoded_factor1, encoded_factor2), axis=1)
if not os.path.exists("{}/SVAE_FAETC_EM.txt".format(resultpath)):
os.mknod("{}/SVAE_FAETC_EM.txt".format(resultpath))
np.savetxt("{}/SVAE_FAETC_EM.txt".format(resultpath), encoded_factors)