data[p['name']] = pd.read_csv(os.path.join(out_path, p['file']), comment='#') data[p['name']].index = range( 0 + p.get('start_on_seq', 1), p.get('start_on_seq', 1) + len(data[p['name']])) data[p['name']].rename(columns={ p['datacolumn']: p['name'], p.get('sitecolumn', 'Site'): 'Site_' + p['name'] }, inplace=True) columns.append(p['name']) site_column_df = pd.DataFrame( { 'Site': [ '%d%s' % (n, l) for n, l in zip(range(1, 1 + len(sets['seq'])), sets['seq']) ] }, index=range(1, 1 + len(sets['seq']))) result = pd.concat(data.values() + [site_column_df], axis=1) # print result temp = tempfile.TemporaryFile() result.to_csv(temp) temp.seek(0) plot_prof_on_seq(temp,DNAseq=sets['seq'],\ graphshow=True,pngfileout=os.path.join(out_path,sets['pngfileout']),title=sets['name'],\ prof_columns=columns,seq_column="Site",rescale=sets['rescale'],zero_at=sets['zero_at'],\ ylab=sets.get('ylab',None), colorb={'A':'#0b0','T':'#00b','G':'#fff','C':'#fff'},colorf={'A':'#fafafa','T':'#fafafa','G':'#000','C':'#000'},\ plot_options={'linewidth':1.0,'markersize':8.0,'figsize':(12,3),'fontsize':None,'legendloc':'upper right'}) temp.close()
'gg_601, Top Strand, Experiment B, Cleavage frequency profile along DNA' }, { 'file': 'gg_601_BS_a_fitted_intensities.csv', 'seq': BS_seq, 'pngfileout': 'gg_601_BS_a_cl_freq_profile.png', 'title': 'gg_601, Bottom Strand, Experiment A, Cleavage frequency profile along DNA' }, { 'file': 'gg_601_BS_b_fitted_intensities.csv', 'seq': BS_seq, 'pngfileout': 'gg_601_BS_b_cl_freq_profile.png', 'title': 'gg_601, Bottom Strand, Experiment B, Cleavage frequency profile along DNA' }] #Common code: # will iterate through the lanes and plot the profile values along DNA sequence # For interactive exploration of the plot set graphshow=True ################################### for s in lane_data: plot_prof_on_seq(os.path.join(out_path,s['file']),DNAseq=s['seq'],\ graphshow=True,pngfileout=os.path.join(out_path,s['pngfileout']),title=s['title'],\ prof_columns='Intensity',seq_column="Site",\ colorb={'A':'#0b0','T':'#00b','G':'#fff','C':'#fff'},colorf={'A':'#fafafa','T':'#fafafa','G':'#000','C':'#000'})
#by simply stacking columns from files together #then provide column names to plotting functions as array for p in sets['profiles']: data[p['file']] = pd.read_csv(os.path.join(out_path, p['file']), comment='#') data[p['file']].index = range(1, 1 + len(data[p['file']])) data[p['file']].rename(columns={ p['column']: p['name'], 'Site': 'Site_' + p['name'] }, inplace=True) columns.append(p['name']) site_column_df = pd.DataFrame( { 'Site': [ '%d%s' % (n, l) for n, l in zip(range(1, 1 + len(sets['seq'])), sets['seq']) ] }, index=range(1, 1 + len(sets['seq']))) result = pd.concat(data.values() + [site_column_df], axis=1) temp = tempfile.TemporaryFile() result.to_csv(temp) temp.seek(0) plot_prof_on_seq(temp,DNAseq=sets['seq'],\ graphshow=True,pngfileout=os.path.join(out_path,sets['pngfileout']),title=sets['name'],\ prof_columns=columns,seq_column="Site",normalize='together',zero_at=sets['zero_at'],\ colorb={'A':'#0b0','T':'#00b','G':'#fff','C':'#fff'},colorf={'A':'#fafafa','T':'#fafafa','G':'#000','C':'#000'}) temp.close()