def _draw_barplot_w_val(genome,ChIP,pval,names,main=None,xlab=None,ylab=None,horiz=False,upsidedown=False, cex_names = 1, cex_text = 1):
    """Draw a barplot with p values
    
    Parameters:
    1. genome: a list of genome background annotation results.
    2. ChIP: a list of ChiP annotation results.
    3. pval: a list of p values.
    4. name: bar plot name
    5. main: the mail title
    6. xlab: x axis label
    7. ylab: y axis label
    8. horiz: horizontal or vertical
    9. upsidedown: reverse the order of bars
    """
    
    # draw bar plot
    # get margins
    maxp=max(max(genome),max(ChIP))
    marg=1.2/maxp # margin for writing percentage and p value. Thus, 1/4 of the height of the plot is taken by texts                      

    if horiz:
        xlim=[0,maxp+marg]
        ylim=None
        if upsidedown:
            genome.reverse()
            ChIP.reverse()
            pval.reverse()
            names.reverse()
    else:
        xlim=None
        ylim=[0,maxp+marg]
    rscript=R.barplot([genome,ChIP],names=names,beside=True,horiz=horiz,col=['lightblue','mistyrose'],\
                    main=main,xlab=xlab,ylab=ylab,xlim=xlim,ylim=ylim, cex_names=cex_names)
    
    # write p values
    pct_genome=_percent_str(genome)
    pct_ChIP=_percent_str(ChIP)
    pval_ChIP=_pval_str(pval)
    if horiz:
        pct_pval_ChIP=_cat_percent_pval_strs(pct_ChIP,pval_ChIP,sep=' ')
        x1=genome
        x2=ChIP
        y1='mp[1,]'
        y2='mp[2,]'
        pos=4
    else:
        pct_pval_ChIP=_cat_percent_pval_strs(pct_ChIP,pval_ChIP,sep='\n')
        x1='mp[1,]'
        x2='mp[2,]'
        y1=genome
        y2=ChIP
        pos=3
    
    # write percentages and pvalues   
    if cex_text == 1:
        rscript+=R.text(x1,y1,pct_genome,pos=pos,offset=0.2)
        rscript+=R.text(x2,y2,pct_pval_ChIP,pos=pos,offset=0.2)
    else:
        rscript+=R.text(x1,y1,pct_genome,pos=pos,offset=0.2,cex=cex_text)
        rscript+=R.text(x2,y2,pct_pval_ChIP,pos=pos,offset=0.2,cex=cex_text)

    return rscript
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/_draw_barplot_w_val/swapped operands of `/`