@follows( mkdir("plots") )
@transform(loadLongGeneChromatinIntersection, regex(r"(\S+).stats.load"), "plots/"+PARAMS["species"]+"_long_interval_genes_h3k27me3_venn.log")
def plotFigure4LongGenesH3K27Me3Venn( infile, outfile):
    dbhandle = sqlite3.connect( PARAMS["database"] )
    cc = dbhandle.cursor()
    statement = '''select track, chromatin_track, total_merged_intervals, track_and_chromatin_track, track_only, chromatin_track_only
                   from long_intervals_h3k27me3_venn''' % locals()
    print statement
    cc.execute( statement )
    for venn in cc:
        track, chromatin_track, total_merged_intervals, track_and_chromatin_track, track_only, chromatin_track_only = venn
        track = track.replace("_",".").replace("-",".")
        chromatin_track = chromatin_track.replace("_",".").replace("-",".")
        track_total = int(track_and_chromatin_track)+int(track_only)
        total_merged_intervals = int(total_merged_intervals)
        track_only = int(track_only)
        pdffile = "plots/"+track+"."+chromatin_track+".pdf"
        R('''library(VennDiagram) ''')
        R('''track <- seq(1,%(track_total)i)''' % locals() )
        R('''chromatin_track <- seq(%(track_only)i,%(total_merged_intervals)i)''' % locals() )
        R('''x <- list(%(track)s=track,%(chromatin_track)s=chromatin_track)'''  % locals() )
        R('''pdf(file='%(pdffile)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()''')
    
        # Convert pdf to png for web
        pdffile2 = pdffile.replace("pdf","png")
        statement = '''convert %(pdffile)s %(pdffile2)s'''
        P.run()
    statement = '''touch %(outfile)s'''
    P.run()
                                    
############################################################
############################################################
############################################################
## REPORTS
Figure 4: venn diagram of genes overlapped by NMIs ><3kb in length with H3K27Me3 intervals
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_proj007.py/plotFigure4LongGenesH3K27Me3Venn