def evaluate_discretization(BG_pos, BG_neg, INT): FHW_bg_pos = open(BG_pos, "w") FHW_bg_neg = open(BG_neg, "w") FHW_int = open(INT, "w") prev = 0 chrom = "chrN" for si in np.linspace(0.1, 5, 15): print si, ":" for l in np.linspace(1, 10, 15): print l, for i in range(25): X = sim.runMany(K=1, SHOW=False, si=si, l=l, wp=1.0, N=1000, NOISE=False, INT=True) X[:, 0] *= 100 X[:, 0] += prev FHW_int.write( chrom + "\t" + str(X[0, 0]) + "\t" + str(X[-1, 0]) + "\t" + str(si) + "," + str(l) + "," + str(i) + "\n" ) for i in range(X.shape[0] - 1): if X[i, 1] > 0: FHW_bg_pos.write( chrom + "\t" + str(X[i, 0]) + "\t" + str(X[i + 1, 0]) + "\t" + str(int(X[i, 1])) + "\n" ) if X[i, 2] > 0: FHW_bg_neg.write( chrom + "\t" + str(X[i, 0]) + "\t" + str(X[i + 1, 0]) + "\t" + str(int(X[i, 2])) + "\n" ) prev = X[-1, 0] print FHW_bg_pos.close() FHW_bg_neg.close() FHW_int.close()
def evaulate_fp_si(BG_pos, BG_neg, INT): FHW_bg_pos = open(BG_pos, "w") FHW_bg_neg = open(BG_neg, "w") FHW_int = open(INT, "w") prev = 0 chrom = "chrN" for si in np.linspace(0.1, 5, 15): print si for fp in np.linspace(0.0, 5, 15): print fp, for i in range(25): X = sim.runMany(K=1, SHOW=False, si=si, l=2, wp=1.0, N=1000, fp=fp, NOISE=False, INT=False) X[:, 0] *= 100 X[:, 0] += prev FHW_int.write( chrom + "\t" + str(X[0, 0]) + "\t" + str(X[-1, 0]) + "\t" + str(si) + "," + str(fp) + "," + str(i) + "\n" ) for i in range(X.shape[0] - 1): if X[i, 1] > 0: FHW_bg_pos.write( chrom + "\t" + str(X[i, 0]) + "\t" + str(X[i + 1, 0]) + "\t" + str(int(X[i, 1])) + "\n" ) if X[i, 2] > 0: FHW_bg_neg.write( chrom + "\t" + str(X[i, 0]) + "\t" + str(X[i + 1, 0]) + "\t" + str(int(X[i, 2])) + "\n" ) prev = X[-1, 0] print FHW_bg_pos.close() FHW_bg_neg.close() FHW_int.close()
def make_many_simulations(BG_pos, BG_neg, INT, N=25, KS=20): FHW_bg_pos = open(BG_pos, "w") FHW_bg_neg = open(BG_neg, "w") FHW_int = open(INT, "w") prev = 0 chrom = "chrN" for wp in np.linspace(0.01, 0.1, 15): for n in np.linspace(10, 10000, 15): for i in range(25): X = sim.runMany(K=1, SHOW=False, si=3, l=10, wp=0.1, N=n, NOISE=False, INT=False) X[:, 0] *= 100 X[:, 0] += prev FHW_int.write( chrom + "\t" + str(X[0, 0]) + "\t" + str(X[-1, 0]) + "\t" + str(wp) + "," + str(n) + "," + str(i) + "\n" ) for i in range(X.shape[0] - 1): if X[i, 1] > 0: FHW_bg_pos.write( chrom + "\t" + str(X[i, 0]) + "\t" + str(X[i + 1, 0]) + "\t" + str(int(X[i, 1])) + "\n" ) if X[i, 2] > 0: FHW_bg_neg.write( chrom + "\t" + str(X[i, 0]) + "\t" + str(X[i + 1, 0]) + "\t" + str(int(X[i, 2])) + "\n" ) prev = X[-1, 0] FHW_bg_pos.close() FHW_bg_neg.close() FHW_int.close()
def make_many_simulations(BG_pos="", BG_neg="", INT="", N=25,KS=20): FHW_bg_pos=open(BG_pos, "w") FHW_bg_neg=open(BG_neg, "w") FHW_int=open(INT, "w") prev=0 chrom="chrN" for K in range(1, KS): print K for n in range(N): X = sim.runMany(K=K, SHOW=False) X[:,0]*=100 X[:,0]+=prev FHW_int.write(chrom+"\t" + str(X[0,0]) + "\t" + str(X[-1,0]) + "\t" + str(K) + ","+ str(n) + "\n" ) for i in range(X.shape[0]-1): if X[i,1] > 0: FHW_bg_pos.write(chrom+"\t" + str(X[i,0]) + "\t" + str(X[i+1,0]) +"\t" + str(int(X[i,1])) + "\n" ) if X[i,2]>0: FHW_bg_neg.write(chrom+"\t" + str(X[i,0]) + "\t" + str(X[i+1,0]) +"\t" + str(int(X[i,2])) + "\n" ) prev=X[-1,0] FHW_bg_pos.close() FHW_bg_neg.close() FHW_int.close()