-
Notifications
You must be signed in to change notification settings - Fork 31
/
run_examples.py
58 lines (50 loc) · 2.47 KB
/
run_examples.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
import numpy as np
import tensorflow as tf
import deepcrispr as dc
## On-target Seq-only Regression Task
file_path = 'examples/eg_reg_on_target_seq.rsgt'
input_data = dc.Sgt(file_path, with_y=True)
x, y = input_data.get_dataset()
x = np.expand_dims(x, axis=2) # shape(x) = [10, 4, 1, 23]
sess = tf.InteractiveSession()
on_target_model_dir = 'trained_models/ontar_cnn_reg_seq'
dcmodel = dc.DCModelOntar(sess, on_target_model_dir, is_reg=True, seq_feature_only=True)
predicted_on_target = dcmodel.ontar_predict(x)
## On-target Classification Task
file_path = 'examples/eg_cls_on_target.episgt'
input_data = dc.Episgt(file_path, num_epi_features=4, with_y=True)
x, y = input_data.get_dataset()
x = np.expand_dims(x, axis=2) # shape(x) = [100, 8, 1, 23]
sess = tf.InteractiveSession()
on_target_model_dir = 'trained_models/ontar_ptaug_cnn'
dcmodel = dc.DCModelOntar(sess, on_target_model_dir, is_reg=False, seq_feature_only=False)
predicted_on_target = dcmodel.ontar_predict(x)
## On-target Regression Task
file_path = 'examples/eg_reg_on_target.repisgt'
input_data = dc.Episgt(file_path, num_epi_features=4, with_y=True)
x, y = input_data.get_dataset()
x = np.expand_dims(x, axis=2) # shape(x) = [100, 8, 1, 23]
sess = tf.InteractiveSession()
on_target_model_dir = 'trained_models/ontar_pt_cnn_reg'
dcmodel = dc.DCModelOntar(sess, on_target_model_dir, is_reg=True, seq_feature_only=False)
predicted_on_target = dcmodel.ontar_predict(x)
## Off-target Classification Task
file_path = 'examples/eg_cls_off_target.epiotrt'
input_data = dc.Epiotrt(file_path, num_epi_features=4, with_y=True)
(x_on, x_off), y = input_data.get_dataset()
x_on = np.expand_dims(x_on, axis=2) # shape(x) = [100, 8, 1, 23]
x_off = np.expand_dims(x_off, axis=2) # shape(x) = [100, 8, 1, 23]
sess = tf.InteractiveSession()
off_target_model_dir = 'trained_models/offtar_pt_cnn'
dcmodel = dc.DCModelOfftar(sess, off_target_model_dir, is_reg=False)
predicted_off_target = dcmodel.offtar_predict(x_on, x_off)
## Off-target Regression Task
file_path = 'examples/eg_reg_off_target.repiotrt'
input_data = dc.Epiotrt(file_path, num_epi_features=4, with_y=True)
(x_on, x_off), y = input_data.get_dataset()
x_on = np.expand_dims(x_on, axis=2) # shape(x) = [100, 8, 1, 23]
x_off = np.expand_dims(x_off, axis=2) # shape(x) = [100, 8, 1, 23]
sess = tf.InteractiveSession()
off_target_model_dir = 'trained_models/offtar_pt_cnn_reg'
dcmodel = dc.DCModelOfftar(sess, off_target_model_dir, is_reg=True)
predicted_off_target = dcmodel.offtar_predict(x_on, x_off)