def plot_BAF_heatmap(args): if PLT_AVAIL == True: pass else: print "matplotlib.pyplot not available, skip plotting..." sys.stdout.flush() sys.exit(-1) BAF_heatmap = BAFHeatMap() BAF_heatmap.read_heatmap(args.filename_base) BAF_heatmap.get_color_max() segments = Segments() inseg_file_name = args.filename_base + ".PyLOH.segments" segments.read_segfile(inseg_file_name) seg_num = segments.num outheatmap_dir_name = args.filename_base + ".PyLOH.heatmap.plot" if os.path.exists(outheatmap_dir_name) == False: os.mkdir(outheatmap_dir_name) for j in range(0, seg_num): BAF_counts_j = BAF_heatmap.BAF_counts[j] seg_name_j = segments[j][0] print "Plotting segment {0}...".format(seg_name_j) sys.stdout.flush() plot_BAF_heatmap_by_segment(BAF_counts_j, seg_name_j, outheatmap_dir_name)
def convert(self): seg_num = self.segments.num process_num = self.process_num if process_num > seg_num: process_num = seg_num pool = Pool(processes = process_num) args_list = [] for j in range(0, seg_num): seg_name = self.segments[j][0] chrom = self.segments[j][1] start = self.segments[j][2] end = self.segments[j][3] args_tuple = (seg_name, chrom, start, end, self.normal_bam_filename, self.tumor_bam_filename, self.reference_genome_filename, self.min_depth, self.min_bqual, self.min_mqual) args_list.append(args_tuple) counts_tuple_list = pool.map(process_by_segment, args_list) paired_counts = [] BAF_counts = [] for counts_tuple_j in counts_tuple_list: paired_counts_j, BAF_counts_j = counts_tuple_j paired_counts.append(paired_counts_j) BAF_counts.append(BAF_counts_j) BAF_heatmap = BAFHeatMap(BAF_counts) BAF_heatmap.write_heatmap(self.filename_base) data = Data(self.segments, paired_counts) data.tumor_LOH_test(self.WES_flag) data.write_data(self.filename_base)
def plot_BAF_heatmap(args): if PLT_AVAIL == True: pass else: print "matplotlib.pyplot not available, skip plotting..." sys.stdout.flush() sys.exit(-1) BAF_heatmap = BAFHeatMap() BAF_heatmap.read_heatmap(args.filename_base) BAF_heatmap.get_color_max() segments = Segments() inseg_file_name = args.filename_base + '.PyLOH.segments' segments.read_segfile(inseg_file_name) seg_num = segments.num outheatmap_dir_name = args.filename_base + '.PyLOH.heatmap.plot' if os.path.exists(outheatmap_dir_name) == False: os.mkdir(outheatmap_dir_name) for j in range(0, seg_num): BAF_counts_j = BAF_heatmap.BAF_counts[j] seg_name_j = segments[j][0] print 'Plotting segment {0}...'.format(seg_name_j) sys.stdout.flush() plot_BAF_heatmap_by_segment(BAF_counts_j, seg_name_j, outheatmap_dir_name)