def iterate_over_files(thresh="0.05"): DIR = "/Users/joazofeifa/Lab/TF_predictions/assignments_refined/" LST = list() t = 0 for FILE in os.listdir(DIR): if FILE.split("_")[-1]==thresh and "Puc" not in FILE: print FILE G = ec.load(DIR+FILE, test=False) weighted,unweigthed, IDS, TFS,G,LABELS, colors, colors2,cc = make_adjacency(G, display= False) LST.append((FILE, (weighted,unweigthed, IDS, TFS,G,LABELS, colors, colors2, cc) )) if t > 1: break t+=1 return dict(LST)
ax.set_xticklabels([labels[x].split("_")[0][:6] for x in xs], minor=False,rotation=45, fontsize=10) ax.set_yticklabels([labels[x].split("_")[0][:6] for x in ys], minor=False,rotation=45, fontsize=10) def compares_all(G,ranks, TSS_T): F = plt.figure(figsize=(15,10)) ax1 = F.add_axes([0.05, 0.15, 0.35, 0.8]) ax1.set_title("Bidirectionals not in Promoters (eRNAs)\nPaused Probability") ax2 = F.add_axes([0.5, 0.15, 0.35, 0.8]) make_counts(G,ranks,ax1,FILTER1=None, FILTER2=None) ax2.set_title("Bidirectionals in Promoters (genes)\Paused Probability") make_counts(G,ranks,ax2,FILTER1=None, FILTER2=None) cmap = mpl.cm.Blues norm = mpl.colors.Normalize(vmin=0, vmax=1) ax3 = F.add_axes([0.9, 0.15, 0.05, 0.8]) cb1 = mpl.colorbar.ColorbarBase(ax3, cmap=cmap, norm=norm, orientation='vertical') plt.show() if __name__ == "__main__": TSS_T = at.get_TSS_tree("/Users/joazofeifa/Lab/genome_files/TSS.bed") TF_RANKS = "/Users/joazofeifa/Lab/EMG/TF_predictions/TF_Ranks.csv" ranks = load_ranks(TF_RANKS) eRNA_motif = "/Users/joazofeifa/Lab/TF_predictions/assignments_refined/Allen2014_DMSO2_3-1_0.05" B = ec.load(eRNA_motif,test=True) compares_all(B, ranks, TSS_T)
# # print hg.expectation() # # print "------------------------------" # print "testing eRNA motif1 only" # hg = HG([motif1_all, W-motif1_all],eRNA) # print hg.pmf((motif_1_only,eRNA-motif_1_only)) # print hg.expectation() # print "------------------------------" # hg = hypergeom(W, motif1_all,eRNA) # print hg.pmf((motif_1_only,motif_1_only)) # print hg.mean() if LOAD: IN = "/Users/joazofeifa/Lab/TF_predictions/DNase_motif_eRNA_counts.tsv" A, M, toIDS, fromIDS=load_counts(IN) compute_pvalues(A, M, toIDS, fromIDS) if WRITE: OUT = "/Users/joazofeifa/Lab/TF_predictions/DNase_motif_eRNA_counts.tsv" eRNA_motif = "/Users/joazofeifa/Lab/TF_predictions/assignments_refined/Allen2014_DMSO2_3-1_0.05" DNase_motif = "/Users/joazofeifa/Lab/TF_predictions/DNAse_motif_overlap.bed" B = ec.load(eRNA_motif,test=False) TFS = dict([(tf.split("_")[0],1) for chrom in B for b in B[chrom] for TF in b.TFS for tf in TF.split(",") ]) D = load_DNAse(DNase_motif, FILTER=TFS, test=False) label_DNase(B,D, attr="eRNA") label_DNase(D,B, attr="DNAse") write_out(D, B, OUT, TFS) pass