mainPEP.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:PEP 作者: ma-compbio 项目源码 文件源码
def run_shuffle(word, num_features,k,type,cell,sel_num,thresh_mode):

    warnings.filterwarnings("ignore")

    word = int(word)
    num_features = int(num_features)
    k = int(k)
    sel_num = int(sel_num)  

    print "Loading motif data"
    filename = "./pairs_%s%s_motif.mat"%(str(type),str(cell))
    data = scipy.io.loadmat(filename)
    x1 = np.asarray(data['seq_m'])
    y = np.ravel(data['lab_m'])
    y[y<0]=0
    print "Positive: %d Negative: %d" % (sum(y==1), sum(y==0))

    serial3 = np.array(range(0,x1.shape[1]))
    print serial3.shape
    print "shuffle features..."
    random.shuffle(serial3)
    x = x1[:,serial3]   

    filename4 = "test_%s%s_motifidx_shuffle%d.txt"%(str(type), str(cell), sel_num)
    np.savetxt(filename4, np.array((range(0,x1.shape[1]),serial3)).T, fmt='%d %d', delimiter='\t')

    k_fold = 10
    if thresh_mode==0:
        k_fold1 = 0
    elif thresh_mode==1:
        k_fold1 = 1
    else:
        k_fold1 = 5
    metrics_vec, pred, predicted, features1 = parametered_cv(x,y,k_fold,k_fold1)

    filename1 = "test_%s%s_motiflab_shuffle%d.txt"%(str(type), str(cell), sel_num)
    filename2 = "test_%s%s_motifprob_shuffle%d.txt"%(str(type), str(cell), sel_num)
    filename3 = "test_%s%s_motiffeature_shuffle%d.txt"%(str(type), str(cell), sel_num)
    np.savetxt(filename1, pred, fmt='%d %d %d', delimiter='\t')
    np.savetxt(filename2, predicted, fmt='%f %f', delimiter='\t')
    np.savetxt(filename3, features1, fmt='%d %f', delimiter='\t')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号