Exemple #1
0
def output(I, forward, reverse):
	D 	= (list(), list())
	model 	= BIC.get_best_model(I, penality , diff_threshold)
	print model.k
	for rv in model.rvs:
		print rv
	for i,FH in enumerate((forward, reverse)):
		for line in FH:
			chrom,start, stop, cov 	= line.strip("\n").split("\t")
			pos 					= (float(stop) + float(start ) ) /2.
			if pos > I.stop:
				break
			elif I.start<=pos <=I.stop:

				D[i].append((pos, float(cov)))
	minX,maxX 		= min([x for d in D for x,y in d]), max([x for d in D for x,y in d])

	xs 				= np.linspace(0, (maxX-minX)/100., 1000 )
	bins 			= 500
	counts,edges 	= np.histogram([(x-minX)/100. for x,y in D[0]], weights=[y for x,y in D[0]], bins=bins, normed=1)
	edges 			= (edges[:-1] + edges[1:])/2.
	F 				= plt.figure(figsize=(15,10))
	plt.bar(edges, counts,width=(edges[-1]-edges[0])/bins,alpha=0.5)
	plt.plot(xs, map(lambda x: model.pdf(x, 1) , xs), linewidth=2.)

	counts,edges 	= np.histogram([(x-minX)/100. for x,y in D[1]], weights=[y for x,y in D[1]], bins=bins, normed=1)
	edges 			= (edges[:-1] + edges[1:])/2.
	plt.bar(edges, -counts, width=(edges[-1]-edges[0])/bins, color="red",alpha=0.5)
	plt.plot(xs, map(lambda x: -model.pdf(x, -1) ,xs ), linewidth=2.)
	
	plt.show()
Exemple #2
0
def output(I, G):
	model 	= BIC.get_best_model(I, penality , diff_threshold)
	bidirs 	= [rv for rv in model.rvs if check_bidir_component(rv,si_thresh=si_thresh, l_thresh=l_thresh, w_thresh=w_thresh, pi_thresh=pi_thresh)]
	for c in bidirs:
		G["mu"].append(c.mu)
		G["si"].append(c.si)
		G["l"].append(c.l)
		G["pi"].append(c.pi)
		
	pass
Exemple #3
0
def ouput(I, FHW):
    model = BIC.get_best_model(I, penality, diff_threshold)
    bidirs = [
        rv
        for rv in model.rvs
        if check_bidir_component(rv, si_thresh=si_thresh, l_thresh=l_thresh, w_thresh=w_thresh, pi_thresh=pi_thresh)
    ]
    if bidirs:
        FHW.write("#" + I.chrom + ":" + str(I.start) + "-" + str(I.stop) + "\n")
        for N in bidirs:
            XS = bin_ChIP_signal(N, I)
            FHW.write(N.__str__() + "\n")
            for X, data_type, peak in XS:
                FHW.write(data_type + "," + str(peak) + "," + ",".join([str(x) + "-" + str(y) for x, y in X]) + "\n")
Exemple #4
0
def output(I,  FHW, penality,diff_threshold ):
	model 	= BIC.get_best_model(I, penality , diff_threshold)
	FHW.write("#" + I.chrom + ":" + str(I.start) + "-" + str(I.stop) +  "," + str(I.annotation_N) + "\n")
	for rv in model.rvs:
		FHW.write(rv.__str__()+"\n")