示例#1
0
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)
示例#2
0
文件: plot.py 项目: sejooning/PyLOH
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)
示例#3
0
def run_preprocess(args):        
    normal_bam = pysam.Samfile(args.normal_bam, 'rb')
    tumor_bam = pysam.Samfile(args.tumor_bam, 'rb')
    
    segments = Segments()
    
    if args.segments_bed == None:
        print 'Loading segments by 22 autosomes...'
        sys.stdout.flush()
        segments.segmentation_by_chrom(normal_bam, tumor_bam)
    else:
        print 'Loading segments by {0}...'.format(args.segments_bed)
        sys.stdout.flush()
        segments.segmentation_by_bed(normal_bam, tumor_bam, args.segments_bed)
    
    normal_bam.close()
    tumor_bam.close()
    
    time_start = time.time()           
    
    converter = BamToDataConverter(
                                   args.normal_bam,
                                   args.tumor_bam,
                                   args.reference_genome,
                                   args.filename_base,
                                   segments,
                                   WES_flag=args.WES,
                                   min_depth=args.min_depth,
                                   min_bqual=args.min_base_qual,
                                   min_mqual=args.min_map_qual,
                                   process_num = args.process_num
                                   )
    
    converter.convert()
    
    time_end = time.time()
    
    print 'Run time: {0:.2f} seconds'.format(time_end - time_start)
    sys.stdout.flush()