@follows( mkdir("plots") )
@transform(getCapseqCGIOverlapCount, regex(r"(\S+).cgi_overlap"), r"plots/\1.nmi.cgi.venn.pdf")
def plotFigure1b( infile, outfile):
    track= P.snip( os.path.basename(infile), ".cgi_overlap").replace(".","_").replace("-","_")
    dbhandle = sqlite3.connect( PARAMS["database"] )
    cc = dbhandle.cursor()
    statement = '''SELECT overlap FROM %(track)s_cgi_venn where track like "%%ucsc%%"''' % locals()
    print statement
    cc.execute( statement )
    overlap=int(cc.fetchone()[0])
    statement = '''SELECT intervals FROM external_interval_sets where bed like "%%ucsc%%"''' % locals()
    print statement
    cc.execute( statement )
    cgi=int(cc.fetchone()[0])
    statement = '''SELECT count(*) FROM %(track)s_intervals ''' % locals()
    print statement
    cc.execute( statement )
    nmi=int(cc.fetchone()[0])
    offset = cgi - overlap
    nmi2 = offset+int(nmi)
    R('''library(VennDiagram) ''')
    R('''CGI <- seq(1,%(cgi)i)''' % locals() )
    R('''NMI <- seq(%(offset)i,%(nmi2)i)''' % locals() )
    R('''x <- list(CGI=CGI,NMI=NMI)''' )
    R('''pdf(file='%(outfile)s', height=8, width=8, onefile=TRUE, family='Helvetica', paper='A4', pointsize=12)''' % locals() )
    R('''venn <- venn.diagram( x, filename=NULL, col="#58595B", fill=c("#EC1C24","#69BC45"), alpha=0.75, label.col=c("darkred", "white", "darkgreen"), cex=2.0, fontfamily="Helvetica", fontface="bold")''' % locals() )
    R('''grid.draw(venn)''')
    R('''dev.off()''')

############################################################
Figure 1b: Venn diagrams of CAPseq NMIs vs UCSC CGIs
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_proj007.py/plotFigure1b