-
Notifications
You must be signed in to change notification settings - Fork 3
/
DeepPPI_Predict_In_All_Human_Dataset.py
executable file
·135 lines (117 loc) · 4.09 KB
/
DeepPPI_Predict_In_All_Human_Dataset.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 24 09:36:43 2017
@author: sun
"""
import numpy as np
import pandas as pd
from keras.layers import Dense, merge, Input, Dropout
from keras.optimizers import SGD, RMSprop
from keras.models import Model
from keras.regularizers import l2
from sklearn.metrics import roc_curve, auc
import utils.tools as utils
def get_sep_model():
input_1 = Input(shape=(4, ), name='Protein_a')
protein_input1 = Dense(
512,
activation='relu',
init='he_normal',
name='High_dim_proA_feature_1',
W_regularizer=l2(0.01))(input_1)
protein_input1 = Dropout(0.2)(protein_input1)
protein_input1 = Dense(
256,
activation='relu',
init='he_normal',
name='High_dim_proA_feature_2',
W_regularizer=l2(0.01))(protein_input1)
protein_input1 = Dropout(0.2)(protein_input1)
protein_input1 = Dense(
128,
activation='relu',
init='he_normal',
name='High_dim_proA_feature_3',
W_regularizer=l2(0.01))(protein_input1)
protein_input1 = Dropout(0.2)(protein_input1)
input_2 = Input(shape=(4, ), name='Protein_b')
protein_input2 = Dense(
512,
activation='relu',
init='he_normal',
name='High_dim_proB_feature_1',
W_regularizer=l2(0.01))(input_2)
protein_input2 = Dropout(0.2)(protein_input2)
protein_input2 = Dense(
256,
activation='relu',
init='he_normal',
name='High_dim_proB_feature_2',
W_regularizer=l2(0.01))(protein_input2)
protein_input2 = Dropout(0.2)(protein_input2)
protein_input2 = Dense(
128,
activation='relu',
init='he_normal',
name='High_dim_proB_feature_3',
W_regularizer=l2(0.01))(protein_input2)
protein_input2 = Dropout(0.2)(protein_input2)
merged_vector = merge(
[protein_input1, protein_input2],
mode='concat',
concat_axis=1,
name='merge_pro_A_B')
output = Dense(
128, activation='relu', init='he_normal',
name='High_dim_feature_1')(merged_vector)
outputs = Dense(2, activation='softmax', name='output')(output)
model = Model(input=[input_1, input_2], output=outputs)
model.compile(
loss='categorical_crossentropy',
optimizer=RMSprop(),
metrics=['accuracy'])
return model
def train_sep_model(protein):
X = protein.iloc[:, :4].values.astype("float")
y = protein.iloc[:, 4].values.astype("int")
#shuffle data
np.random.seed(1)
index = [i for i in range(len(y))]
np.random.shuffle(index)
X = X[index]
y = y[index]
model = get_sep_model()
y_train = utils.to_categorical(y)
model.fit(
[X, X],
y_train,
nb_epoch=100,
#validation_split=0.1,
batch_size=32,
verbose=0)
return model
def pred_sep_model(model, X_test, y_test):
y_score = model.predict([X_test, X_test])
y_test_tmp = utils.to_categorical(y_test)
fpr, tpr, _ = roc_curve(y_test_tmp[:, 0], y_score[:, 0])
roc_auc = auc(fpr, tpr)
y_class = utils.categorical_probas_to_classes(y_score)
y_test_tmp = y_test
acc, precision, npv, sensitivity, specificity, mcc, f1 = utils.calculate_performace(
len(y_class), y_class, y_test_tmp)
print((
'DeepPPI-sep:acc=%f,precision=%f,npv=%f,sensitivity=%f,specificity=%f,mcc=%f,f1=%f,roc_auc=%f'
% (acc, precision, npv, sensitivity, specificity, mcc, f1, roc_auc)))
human_gold_protein = pd.read_csv(
'dataset/Human/human_gold.tab', sep=' ').iloc[2:, 2:]
human_silver_protein = pd.read_csv(
'dataset/Human/human_silver.tab', sep=' ').iloc[2:, 2:]
gold_sep_model = train_sep_model(human_gold_protein)
silver_sep_model = train_sep_model(human_silver_protein)
test_set = pd.read_csv('dataset/Human/human_all.tab', sep=' ').iloc[2:, 2:]
X_test = test_set.iloc[:, :4].values.astype("float")
y_test = test_set.iloc[:, 4].values.astype("int")
print('train on human gold test human all')
pred_sep_model(gold_sep_model, X_test, y_test)
print('train on human silver test human all')
pred_sep_model(silver_sep_model, X_test, y_test)