def draw_wig_overview(wig,plots_per_pg=4):
    """Draw wig overview"""
    
    # parameters
    rscript=R.comment('')
    rscript+=R.comment('Wig Overview over the Genome')
    rscript+=R.comment('')
    
    # count how many chromosomes and draw four chromosomes per page by default
    chroms=wig.get_chroms()
    if len(chroms)==0: return rscript
    
    chromcnt=1
    for chrom in chroms:
        if chromcnt%plots_per_pg==1: rscript+=R.par(mar=[4,4,5,3.8],oma=[4,2,4,2])
        rscript+=R.barplot(wig[chrom][1],names=wig[chrom][0],col=["red"],border=False,space=0,main=chrom,ylab="Profile",xlab="Chromosome (nt)")
        chromcnt+=1
           
    return rscript
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/draw_wig_overview/original