def draw_wig_heatmap_overview(swig, ylim=None, chrominfo=None, colormap='GBR256'):
    """Draw wig heatmap overview"""
    
    # header print out in the R script
    rscript = '\n'
    rscript += R.comment('')
    rscript += R.comment('Wig heatmap overview')
    rscript += R.comment('')
    rscript += '\n'
    
    #    
    # get chromosome information
    #
    chroms=swig.get_chroms()
    n_chroms=len(chroms)
    if n_chroms==0: return rscript
    
    # parmeters
    # the height from the mid point (vertical) of the middle of the chromosome
    # when n_chroms is 6, 0.2 and n_chroms is 24, 0.4.
    hdelta = (0.4 - 0.2)/(24 - 6) * (n_chroms - 6) + 0.2 
    delta = 100 # delta added to the last point of wig
    widths = [1, 1]
    heights=[1, 5.5]
    mat= [[1, 0], [2, 2]]
    
    # get the largest chrom length and set the lower and upper length
    mins=[]
    maxs=[]
    if chrominfo:
        mins=[chrominfo[chrom]['start'][0] for chrom in chrominfo.get_chroms()]
        maxs=[chrominfo[chrom]['end'][-1] for chrom in chrominfo.get_chroms()] 
    else:
        mins=[swig[chrom][0][0] for chrom in swig.get_chroms()]
        maxs=[swig[chrom][0][-1] for chrom in swig.get_chroms()] 
    mins.sort()
    maxs.sort()
    maxchrom=[mins[0], maxs[-1]]
    
    #
    # get the lower and upper limits of the wig signal
    #   
    #if ylim is not given, decide the ylim as [-max of wig, max of wig]
    if not ylim: 
        percentage = 98
        left, right = swig.get_middle_percent(percentage)
        ylim=[-1*max(abs(left),abs(right)), max(abs(left),abs(right))]
        maxmax = max(ylim)
    
    # get the histogram of wig
    n_bins = 127
    histogram = swig.histogram(breaks=linspace(ylim[0], ylim[1], n_bins+1))
    
    #
    # draw the color bar and heatmaps
    #
        
    # put color code
    cmd = 'cm = graphics.%s' %colormap
    exec(cmd) 
    cmap = 'cmap'
    rscript += R.vector(cm, varname=cmap)
    
    # draw color bar 
    rscript += R.par(mar=[4,4,5,3.8],oma=[4, 2, 4, 2])
    rscript += R.layout(mat=mat,widths=widths,heights=heights)
    rscript += draw_colorbar(ylim, vertical=False, hist=histogram, linecol='cyan')
    rscript += R.plot(maxchrom, [1 - hdelta, n_chroms + hdelta], tp="n", col="", ylab="Chromosome", xlim=maxchrom, ylim=[1 - hdelta, n_chroms + hdelta], frame=False, xaxt="s", yaxt="n", main="Enrichment over Chromosomes", xlab="Chromosome Size (bp)")
    counter = n_chroms
    for chrom in chroms:
        bot = counter - hdelta
        top = counter + hdelta
        rscript += draw_a_chrom_heatmap(swig[chrom], chrom, ylim, [swig[chrom][0][0],swig[chrom][0][-1] + delta], maxchrom, centromere=None, bot=bot, top=top, line=True, linecol = 'cyan')
        rscript += R.mtext(chrom.rsplit('chr', 1)[-1], side=2, at=(top+bot)/2)
        counter -= 1
        
    return rscript
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/draw_wig_heatmap_overview/original