-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_MTGP.py
More file actions
40 lines (32 loc) · 1.32 KB
/
test_MTGP.py
File metadata and controls
40 lines (32 loc) · 1.32 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
# 2016/06/18 Trial of MTGP in MTGP_imputation directory #
import pandas as pd
from MTGP_imputation import mktensor as mt
from MTGP_imputation import mkkernel as mkk
from MTGP_imputation import MTGP as MG
import os
import numpy as np
Dir_name = "tests"
Dir_trait="tests/traits"
filenames = os.listdir(Dir_trait)
ngeno = Dir_name + "/genotype_marker_sample.csv"
genos = pd.read_csv(ngeno, index_col=0).ix[0:30, 0:200].values
# Actual treatment#
ntrait = [Dir_trait + "/" + filenames[i] for i in [0] + range(2, len(filenames))]
tendata = mt.make_tensor_data(ntrait)
##
miss_rate = 0.1
length = tendata.shape[0] * tendata.shape[1] * tendata.shape[2]
pos = np.random.permutation(range(length))[0:int(length * miss_rate)]
tenvec_miss = tendata.reshape(length, order="F")
tenvec_miss[pos] = np.nan
tendata_miss = np.reshape(tenvec_miss, tendata.shape, order="F")
nd, kern, kerngeno, genomat, mode, r2 = tendata_miss, mkk.Gauss_kernel, mkk.median_RBF_kernel, genos, "fiber", 3
parameter_kouho = {
'gpara_kouho': [2],
'mparag_kouho': [i * 0.1 for i in range(1, 9)],
'pars_kouho': [0.01, 0.1, 1, 10],
'sig2_kouho': [0.01, 0.1, 1, 10]
}
MTGP1 = MG.MTGP_impute(nd, kern, kerngeno, genomat, mode, r2, parameter_kouho)
from matplotlib import pyplot as plt
plt.plot(tendata[np.isnan(tendata_miss)],MTGP1['est'][np.isnan(tendata_miss)],'o')