def get_plotter(): from config import mnase_seq_path, pileup_path from src.reference_data import all_orfs_TSS_PAS all_orfs = all_orfs_TSS_PAS() plotter = TyphoonPlotter(mnase_path=mnase_seq_path, rna_seq_pileup_path=pileup_path, orfs=all_orfs) return plotter
def __init__(self): self.all_orfs = all_orfs_TSS_PAS() self.fimo = FIMO() self.window = 80 self.window_2 = self.window/2 # plotting self.bin_scale = 14. self.im_scale = 7 self.tf_threshold = 0.1 self.fc_threshold = 1 self.datastore = ChromatinDataStore()
def entropy_examples(): all_orfs = all_orfs_TSS_PAS() global plotter if plotter is None: plotter = get_plotter() from src.entropy import plot_entropy_example orf = get_orf('CLF1', all_orfs) plot_entropy_example(plotter, orf, (-460, 40), "Low entropy") plt.savefig('%s/low_entropy.pdf' % (misc_figures_dir), dpi=100) from src.entropy import plot_entropy_example orf = get_orf('HSP26', all_orfs) plot_entropy_example(plotter, orf, (200, 700), "High entropy") plt.savefig('%s/high_entropy.pdf' % (misc_figures_dir), dpi=100)
def plot_small_peaks(gene, all_peaks, plotter): all_orfs = all_orfs_TSS_PAS() orf_name = get_orf_name(gene) orf = get_orf(orf_name, all_orfs) span = orf.TSS - 1000, orf.TSS + 1000 plotter.set_span_chrom(span, orf.chr) plotter.dpi = 100 fig, axs, tween_axs = plotter.plot() for i in range(len(times)): time = times[i] ax = axs[i] data = all_peaks[(all_peaks.cross_correlation > 0.05) & (all_peaks.orf == orf.name) & (all_peaks.time == time)] ax.scatter(data.original_mid, data.cross_correlation+10.0)
def collect_small_peaks(): from src.small_peak_calling import call_orf_small_peaks from src.timer import Timer orfs = all_orfs_TSS_PAS() timer = Timer() all_peaks = pd.DataFrame() for chrom in range(1, 17): print("Chromosome %d" % chrom) chr_orfs = orfs[orfs.chr == chrom] # load relevant cross correlations chrom_cross_correlation = pd.read_hdf( '%s/cross_correlation_chr%d.h5.z' % (cc_sense_chrom_dir, chrom)) small_cc = -1 * chrom_cross_correlation.loc['diff'] for idx, orf in chr_orfs.iterrows(): try: peaks = call_orf_small_peaks(small_cc, orf) except KeyError: continue all_peaks = all_peaks.append(peaks) timer.print_time() all_peaks = all_peaks.reset_index(drop=True) all_peaks['name'] = all_peaks['orf'] + '_' + all_peaks['time'].astype(str) + '_' + \ all_peaks['chr'].astype(str) + '_' + all_peaks['original_mid'].astype(str) all_peaks = all_peaks.set_index('name') return all_peaks
def shift_plots(): from src.nucleosome_calling import plot_p123 from src.reference_data import read_sgd_orf_introns, read_sgd_orfs from src.reference_data import read_park_TSS_PAS from src.summary_plotter import SummaryPlotter global plotter orf_cc = pd.read_hdf(cross_corr_sense_path, 'cross_correlation') all_orfs = all_orfs_TSS_PAS() sum_plotter = SummaryPlotter(datastore, all_orfs, orf_cc) if plotter is None: plotter = get_plotter() save_dir = '%s/shift' % OUTPUT_DIR mkdirs_safe([save_dir]) shift_genes = ['RPS7A'] for gene_name in shift_genes: fig = plot_p123(gene_name, orf_cc, plotter, sum_plotter, save_dir) p1 = datastore.p1_shift[[120.0]] p2 = datastore.p2_shift[[120.0]] p3 = datastore.p3_shift[[120.0]] p12 = p1.join(p2, lsuffix='_+1', rsuffix='_+2') p23 = p2.join(p3, lsuffix='_+2', rsuffix='_+3') from src.chromatin_summary_plots import plot_distribution x = datastore.p1_shift[120] y = datastore.transcript_rate_logfold.loc[x.index][120.0] model = plot_distribution(x, y, '$\\Delta$ +1 nucleosome shift', '$\log_2$ fold-change transcription rate', title='+1 shift vs transcription, 0-120 min', xlim=(-40, 40), ylim=(-8, 8), xstep=10, ystep=2, pearson=True, s=10) plt.savefig('%s/shift_+1_xrate.pdf' % save_dir, transparent=True) x = datastore.p1_shift[120] y = datastore.p2_shift[120] model = plot_distribution(x, y, '$\\Delta$ +1 nucleosome shift', '$\\Delta$ +2 nucleosome shift', title='+1, +2 nucleosome shift\n0-120 min', xlim=(-40, 40), ylim=(-40, 40), xstep=10, ystep=10, pearson=False, s=10) plt.savefig('%s/shift_p12.pdf' % save_dir, transparent=True)
import pandas as pd from src.timer import Timer from src.typhoon import TyphoonPlotter from src import met4 from src.typhoon import draw_example_mnase_seq from src.typhoon import draw_example_rna_seq from src.typhoon import plot_example_cross, get_plotter from src.gene_list import get_gene_list, get_paper_list from src.datasets import read_orfs_data from src.summary_plotter import SummaryPlotter from src.chromatin_metrics_data import ChromatinDataStore from src.utils import get_orf from src.reference_data import all_orfs_TSS_PAS, read_sgd_orfs from src.transformations import difference all_orfs = all_orfs_TSS_PAS() timer = Timer() datastore = ChromatinDataStore() genes = get_paper_list() plotter = None selected_genes = ['HSP26', 'RPS7A', 'CKB1'] def go_bar_plots(): from src.go_analysis import GOChromatinAnalysis write_dir = "%s/go" % OUTPUT_DIR save_path = '%s/disorg_terms.csv' % write_dir