コード例 #1
0
np.savetxt("./Data/smalldata/ML_B.csv", B, '%5.2f', delimiter=",")

import lmm_lasso
# hyperparameters for lasso
mu = 1
min = -0.5
max = 0.5
numintv = 1000
rho = 1
alpha = 1.5

res = lmm_lasso.train(X,
                      K,
                      Y,
                      mu=mu,
                      numintervals=numintv,
                      ldeltamin=min,
                      ldeltamax=max,
                      rho=rho,
                      alpha=alpha)
beta = res["weights"]
print len(beta)
np.savetxt("./Data/smalldata/lasso_B.csv", beta, '%5.2f', delimiter=",")
np.savez("./Data/smalldata/ML", B_reml, B, beta)

beta_true = beta_true.reshape((-1, ))
beta_lasso = beta.reshape((-1, ))
beta_ml = np.asarray(B).reshape((-1, ))
beta_reml = np.asarray(B_reml).reshape((-1, ))

choose = len(np.nonzero(beta_true)[0])
コード例 #2
0
import sys
# calculate the kinship (why?)
K = lmm.calculateKinship(Z)
# return beta, sigma
# ML solution
begin = time.time()
B_reml = lmm.GWAS(Y, X, K)
end = time.time()
sys.stderr.write("Total time for 100 SNPs: %0.3f\n" % (end- begin))
# print B_reml
np.savetxt(datapath + "REML_B.csv", B_reml, '%5.2f',delimiter=",")
B_ml = lmm.GWAS(Y, X, K, REML=False)
np.savetxt(datapath + "ML_B.csv", B_ml, '%5.2f',delimiter=",")

import lmm_lasso
res = lmm_lasso.train(X, K, Y, 0.5)
beta = res["weights"]
print len(beta)
np.savetxt(datapath + "lasso_B.csv", beta, '%5.2f',delimiter=",")
np.savez(datapath + "ML",B_reml,B_ml,beta)

#################################################################
#						draw ROC								#
#################################################################
beta_true = B.reshape((-1,))
beta_reml = np.asarray(B_reml)
beta_ml   = np.asarray(B_ml)
beta_lasso = np.asarray(beta)
beta_ml = beta_ml.reshape((-1,))
beta_lasso = beta_lasso.reshape((-1,))
beta_reml = beta_reml.reshape((-1,))
コード例 #3
0
import sys
# calculate the kinship (why?)
K = lmm.calculateKinship(Z)
# return beta, sigma
# ML solution
begin = time.time()
B_reml = lmm.GWAS(Y, X, K)
end = time.time()
sys.stderr.write("Total time for 100 SNPs: %0.3f\n" % (end - begin))
# print B_reml
np.savetxt(datapath + "REML_B.csv", B_reml, '%5.2f', delimiter=",")
B_ml = lmm.GWAS(Y, X, K, REML=False)
np.savetxt(datapath + "ML_B.csv", B_ml, '%5.2f', delimiter=",")

import lmm_lasso
res = lmm_lasso.train(X, K, Y, 0.5)
beta = res["weights"]
print len(beta)
np.savetxt(datapath + "lasso_B.csv", beta, '%5.2f', delimiter=",")
np.savez(datapath + "ML", B_reml, B_ml, beta)

#################################################################
#						draw ROC								#
#################################################################
beta_true = B.reshape((-1, ))
beta_reml = np.asarray(B_reml)
beta_ml = np.asarray(B_ml)
beta_lasso = np.asarray(beta)
beta_ml = beta_ml.reshape((-1, ))
beta_lasso = beta_lasso.reshape((-1, ))
beta_reml = beta_reml.reshape((-1, ))
コード例 #4
0
sys.stderr.write("Total time for 100 SNPs: %0.3f\n" % (end- begin))
# print B_reml
np.savetxt("./Data/smalldata/REML_B.csv", B_reml, '%5.2f',delimiter=",")
B = lmm.GWAS(Y, X, K, REML=False)
np.savetxt("./Data/smalldata/ML_B.csv", B, '%5.2f',delimiter=",")

import lmm_lasso
# hyperparameters for lasso
mu = 1
min = -0.5
max = 0.5
numintv = 1000
rho= 1
alpha= 1.5

res = lmm_lasso.train(X, K, Y, mu=mu, numintervals=numintv, ldeltamin=min, ldeltamax=max, rho=rho, alpha=alpha)
beta = res["weights"]
print len(beta)
np.savetxt("./Data/smalldata/lasso_B.csv", beta, '%5.2f',delimiter=",")
np.savez("./Data/smalldata/ML",B_reml,B,beta)



beta_true = beta_true.reshape((-1,))
beta_lasso = beta.reshape((-1,))
beta_ml = np.asarray(B).reshape((-1,))
beta_reml = np.asarray(B_reml).reshape((-1,))

choose = len(np.nonzero(beta_true)[0])
beta_ml[np.argsort(beta_ml)[:(np.shape(beta_true)[0]-choose)]] = 0
beta_reml[np.argsort(beta_reml)[:(np.shape(beta_true)[0]-choose)]] = 0