Ejemplo n.º 1
0
def run_both_scad(lamP, lamR, lamS, outf, sub_s, sub_i, sub_t, it,k, it_s):
    (bs_e, bs_t , bs_genes, bs_tfs) = load_B_subtilis(sub_s)
    (BS_priors, sign) = load_priors('gsSDnamesWithActivitySign082213','B_subtilis')
    (ba_e, ba_t, ba_genes, ba_tfs) = load_B_anthracis(sub_i, sub_t)
    (BA_priors, sign) = ([], [])

    Xs = [bs_t, ba_t]
    Ys = [bs_e, ba_e]
    priors = BS_priors + BA_priors
    
    orth = load_orth('bs_ba_ortho_804',['B_anthracis','B_subtilis'])
    #orth = load_orth('',['B_subtilis'])
    organisms = ['B_subtilis','B_anthracis']
    #ortht = random_orth(bs_tfs, ba_tfs, organisms, 250)
    #orthg = random_orth(bs_genes, ba_genes, organisms, 2500)
    #orth = ortht+orthg
    #print orth
    #return
    gene_ls = [bs_genes, ba_genes]
    tf_ls = [bs_tfs, ba_tfs]


    Bs = fl.solve_ortho_scad_refit(organisms, gene_ls, tf_ls, Xs, Ys, orth, priors, lamP, lamR, lamS, it, k, it_s)
    write_bs(bs_genes, bs_tfs, Bs[0], outf+'_subtilis')
    write_bs(ba_genes, ba_tfs, Bs[1], outf+'_anthracis')
Ejemplo n.º 2
0
def test_scadBs_refit(b1, b2, fusiongroups, xsamples1, xsamples2, noise_std1, noise_std2, p_falsep, p_falseneg, lamP, lamR, lamS, it, k, s_it):
#    TFs = [map(lambda x: str(x)+'tfa', range(b1.shape[0])), map(lambda x: str(x)+'tfb', range(b2.shape[0]))]
#    Gs = [map(lambda x: str(x)+'ga', range(b1.shape[1])), map(lambda x: str(x)+'gb', range(b2.shape[1]))]
    TFs = [map(lambda x: x, range(b1.shape[0])), map(lambda x: x, range(b2.shape[0]))]
    Gs = [map(lambda x: x, range(b1.shape[1])), map(lambda x: x, range(b2.shape[1]))]

    xdims1 = (xsamples1, b1.shape[0])
    xdims2 = (xsamples2, b2.shape[0])
    (x1, y1) = generate_from_linear(xdims1, b1, noise_std1)
    (x2, y2) = generate_from_linear(xdims2, b2, noise_std2)
    (x1test, y1test) = generate_from_linear(xdims1, b1, noise_std1)
    (x2test, y2test) = generate_from_linear(xdims2, b2, noise_std2)
    p1 = messwpriors(b1, p_falsep, p_falseneg)
    p2 = messwpriors(b2, p_falsep, p_falseneg)
    priorset = []
    for i in range(len(p1)):
        tf = fr.one_gene(TFs[0][p1[i][0]], 0)
        gene = fr.one_gene(Gs[0][p1[i][1]], 0)
        priorset.append((tf,gene))
    for i in range(len(p2)):
        tf = fr.one_gene(TFs[1][p2[i][0]], 1)
        gene = fr.one_gene(Gs[1][p2[i][1]], 1)
        priorset.append((tf,gene))
    organisms = [0,1]
#    constraints=[]
#    for i in range(len(fusiongroups)):
#        fg = fusiongroups[i]
#        for j in range(len(fg[0])):        
#            for m in range(len(fg[1])):
#                coeff1 = fr.coefficient(0,fg[0][j][0], fg[0][j][1])
#                coeff2 = fr.coefficient(1,fg[1][m][0], fg[1][m][1])
#                constr = fr.constraint(coeff1,coeff2, lamS)
#                constraints.append(constr)
    #bs_solve = fr.solve_ortho_scad_refit_bench(organisms, Gs, TFs, [x1, x2], [y1, y2], constraints, priorset, lamP, lamR, lamS, it, k, s_it)
    bs_solve = fr.solve_ortho_scad_refit(organisms, Gs, TFs, [x1, x2], [y1, y2], fusiongroups, priorset, lamP, lamR, lamS, it, k, s_it)

    err1 = B_err(bs_solve[0], b1)
    err2 = B_err(bs_solve[1], b2)
    support_score1 = check_support(bs_solve[0], b1)
    support_score2 = check_support(bs_solve[1], b2)
    err1p = pred_err_grps(bs_solve[0], x1test, y1test)
    err2p = pred_err_grps(bs_solve[1], x2test, y2test)    
    return (bs_solve, err1, err2, err1p, err2p, support_score1, support_score2)