Ejemplo n.º 1
0
def main():
   usage = ( 'usage: %prog --subStatsDir=path/to/dir/ [options]\n\n'
             '%prog takes in a directory of substitution stats files ( --subStatsDir )\n'
             'with filenames as NAME.subStats.[upper|lower].xml and produces a plot.')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   
   if not options.outputRanks:
      fig, pdf = lpt.initImage( 9., 11., options, data )
      axDict = establishAxes( fig, options, data )
   
   assembliesDict = {}
   assembliesDict = readSubStatsDir( assembliesDict, options )
   
   sumErrors( assembliesDict, options )
   normalizeData( assembliesDict, options )

   sortOrder = sorted( assembliesDict, key=lambda key: assembliesDict[ key ].allLo, reverse=False )

   if options.outputRanks:
      rankings( assembliesDict, sortOrder, options, data )
      return

   drawData( assembliesDict, sortOrder, axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
Ejemplo n.º 2
0
def main():
   usage = ( 'usage: %prog [options]\n\n'
             '%prog takes in a reference genome name ( --referenceGenome ),\n'
             'optionally a directory where annotation wig pickles are stored ( --annotPickleDir [optional] ),\n'
             'a directory where maf wig pickles are stored ( --mafPickleDir ), a paired set of chromosome names\n'
             '( --chrNames comma separated ) and chromosome lengths ( --chrLengths comma separated ) and \n'
             'then various other options specifed below to draw a figure.')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser, data )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   loadAnnots( options, data )
   loadMafs( options, data )

   normalizeData( options, data )
   transformData( options, data )

   figHeight = ( data.numberOfMafs + len( data.annotationOrder ) + 0.5 ) / 4.0
   fig, pdf = lpt.initImage( 8.0, figHeight, options, data )
   axDict = establishAxes( fig, options, data )
   labelAxes( fig, axDict, options, data )
   drawAnnotations( axDict, options, data )
   drawMafs( axDict, options, data )
   drawLegend( options, data )

   setAxisLimits( axDict, options, data )
   lpt.writeImage( fig, pdf, options )
def main():
   usage = ( 'usage: %prog --subStatsDir=path/to/dir/ [options]\n\n'
             '%prog takes in a directory of substitution stats files ( --subStatsDir )\n'
             'with filenames as NAME.subStats.[upper|lower].xml and produces a plot showing\n'
             'the difference in subs in hap1 versus hap2.\n')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   
   fig, pdf = lpt.initImage( 11., 8., options, data )
   axDict = establishAxis( fig, options, data )
   
   assembliesDict = {}
   assembliesDict = cssp.readSubStatsDir( assembliesDict, options )
   valuesList = createValsList( assembliesDict.values(), options )
   valuesList = sorted( valuesList, key = lambda x: float(x[1])/x[2], reverse=False)
   drawData( valuesList, axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
Ejemplo n.º 4
0
def main():
    usage = ('usage: %prog [options] --dir=path/to/dir/\n\n'
             '%prog takes in a copy statistics file\n'
             'and creates an image file.')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(args, options, parser)
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)
    if not options.outputRanks:
        fig, pdf = lpt.initImage(8.0, 10.0, options, data)

    stats = readFiles(options)
    sortedOrder = sorted(stats.values(),
                         key=lambda x: x.sumLower,
                         reverse=False)

    if options.outputRanks:
        rankings(sortedOrder, options, data)
        return

    axDict = establishAxes(fig, options, data)
    drawData(axDict, sortedOrder, options, data)
    drawLegend(options, data)
    drawAxisLabels(axDict, stats, options, data)
    setAxisLimits(axDict, options, data)

    lpt.writeImage(fig, pdf, options)
def main():
    usage = (
        'usage: %prog [options] < rankedAssemblies.txt\n\n'
        '%prog takes via STDIN a list of coverage values, each line formatted as:\n'
        '#assembly ave.CovBothGenomes hap1 hap2 delta bac\n'
        'P1 .9885178 .9888077 .9882265 5.782e-04 0\n'
        'B1 .9869388 .9871948 .9866798 5.257e-04 .9978954\n'
        'F5 .9869094 .9872685 .9865338 7.295e-04 .9993371\n'
        '...\n'
        'And produces a plot showing the Total and Bacterial coverages for\n'
        'all assemblies in the input.')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    lpt.checkOptions(options, parser)

    valuesList = readStream(options)
    valuesList = sorted(valuesList, key=lambda key: key.tot, reverse=True)

    fig, pdf = lpt.initImage(8.0, 6.0, options, data)
    ax = establishAxis(fig, options, data)

    drawData(valuesList, ax, options)

    lpt.writeImage(fig, pdf, options)
def main():
   usage = ( 'usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ [options]\n\n'
             '%prog takes a directory of contig path stats xml files\n'
             '( --statsScaffoldsContigPathDir ) named as NAME.contigPathStats.xml and creates a plot.')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   checkOptions( options, parser )
   
   assembliesDict = readDir( options.statsScaffoldsContigPathDir, options )
   assembliesList = assembliesDict.values()
   
   if len(assembliesList) <= 20:
      fig, pdf = lpt.initImage( 14.0, 8.0, options, data )
   else:
      fig, pdf = lpt.initImage( 14.0, 24.0, options, data )
   axDict = establishAxis( len(assembliesList), fig, options, data )
   
   assembliesList = createXYData( assembliesList, options )

   assembliesList = normalizeDist( assembliesList, options )
   assembliesList = sorted( assembliesList, 
                            key=lambda x: max(x.yData['insertionErrorSizeDistribution']), 
                            reverse=True )

   drawData( assembliesList, axDict, options, data )
   drawLegend( assembliesList, axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
def main():
   usage = ( 'usage: %prog [options] --dir=path/to/dir/\n\n'
             '%prog takes in a copy statistics file\n'
             'and creates an image file.' )
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( args, options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   if not options.outputRanks:
      fig, pdf = lpt.initImage( 8.0, 10.0, options, data )

   stats = readFiles( options )
   sortedOrder = sorted( stats.values(), key=lambda x: x.sumLower, reverse=False )
   
   if options.outputRanks:
      rankings( sortedOrder, options, data )
      return

   axDict = establishAxes( fig, options, data )
   drawData( axDict, sortedOrder, options, data )
   drawLegend( options, data )
   drawAxisLabels( axDict, stats, options, data )
   setAxisLimits( axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
Ejemplo n.º 8
0
def main():
    usage = ('usage: %prog [options] file1.xml file2.xml\n\n'
             '%prog reads in pathStats.xml files and create N50 plots')

    parser = OptionParser( usage = usage )
    initOptions( parser )
    libplot.initOptions( parser )
    options, args = parser.parse_args()
    checkOptions( args, options, parser)
    libplot.checkOptions( options, parser )

    statsList = readfiles( options.files )

    #Filter out non-leaf samples:
    statsListF = []
    for xmltree in statsList:
        root = xmltree.getroot()
        allsamples = root.findall( 'statsForSample' )

        samples = getLeaves( allsamples, options.filteredSamples )
        statsListF.append( samples )

    for samples in statsListF:
        drawN50Plot( options, samples )

    if len( statsListF ) >= 2:
        for i in range( len(statsListF) -1 ):
            for j in range( i + 1, len(statsListF) ):
                drawCompareN50Plot( options, statsListF[i], statsListF[j] )
Ejemplo n.º 9
0
def main():
    usage = (
        'usage: %prog --subStatsDir=path/to/dir/ [options]\n\n'
        '%prog takes in a directory of substitution stats files ( --subStatsDir )\n'
        'with filenames as NAME.subStats.[upper|lower].xml and produces a plot showing\n'
        'the difference in subs in hap1 versus hap2.\n')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)

    fig, pdf = lpt.initImage(11., 8., options, data)
    axDict = establishAxis(fig, options, data)

    assembliesDict = {}
    assembliesDict = cssp.readSubStatsDir(assembliesDict, options)
    valuesList = createValsList(assembliesDict.values(), options)
    valuesList = sorted(valuesList,
                        key=lambda x: float(x[1]) / x[2],
                        reverse=False)
    drawData(valuesList, axDict, options, data)

    lpt.writeImage(fig, pdf, options)
Ejemplo n.º 10
0
def main():
   usage = ( 'usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ '
             '--statsContigssContigPathDir=path/to/dir/ [options]\n\n'
             '%prog takes a directory of scaffold-alignment contig path stats xml files\n'
             '( --statsScaffoldsContigPathDir ) named as NAME.pathStats.xml, contig-alignment '
             'contig path stats xml files ( --statsContigsContigPathDir ) named as NAME.pathStats.xml,'
             ' and creates a plot.\n')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   cscp.initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   cscp.checkOptions( options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   checkOptions( options, parser )
   
   assembliesList = readDirs( options )
   assembliesList = sorted( assembliesList, key=lambda x: x.valuesDict[ options.sortOn ], 
                            reverse=True )

   maxesMax, minsMin = findMaxMin( assembliesList, options )
   if options.outputRanks:
      rankings( assembliesList, options )
      return

   fig, pdf = lpt.initImage( 10.0, 8.0, options, data )
   axDict = establishAxis( fig, options, data )

   drawData( assembliesList, maxesMax, minsMin, axDict, options )
   
   lpt.writeImage( fig, pdf, options )
def main():
   usage = ( 'usage: %prog [options] < rankedAssemblies.txt\n\n'
             '%prog takes via STDIN a list of coverage values, each line formatted as:\n'
             '#assembly ave.CovBothGenomes hap1 hap2 delta bac\n'
             'P1 .9885178 .9888077 .9882265 5.782e-04 0\n'
             'B1 .9869388 .9871948 .9866798 5.257e-04 .9978954\n'
             'F5 .9869094 .9872685 .9865338 7.295e-04 .9993371\n'
             '...\n'
             'And produces a plot showing the Total and Bacterial coverages for\n'
             'all assemblies in the input.')
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   
   valuesList = readStream( options )
   valuesList = sorted( valuesList, key=lambda key: key.tot, reverse=True )
   
   fig, pdf = lpt.initImage( 8.0, 6.0, options, data )
   ax = establishAxis( fig, options, data )
   
   drawData( valuesList, ax, options )

   lpt.writeImage( fig, pdf, options )
def main():
   usage = ( 'usage: %prog [options] file1.xml file2.xml\n\n'
             '%prog takes in contiguous path statistics file(s)\n'
             'and creates an image file.' )
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   las.initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( args, options, parser )
   las.checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   if not options.outputRanks:
      fig, pdf = lpt.initImage( 11., 8.0, options, data ) # 8
      axDict = establishAxes( fig, options, data )
   
   data.statsList, data.xData = readFiles( options )
   for i in xrange( 0, len( data.statsList )):
      # ensure that the buckets are all in order by their midpoint.
      data.statsList[i] = sorted( data.statsList[i], key=lambda x: x.mid, reverse=False )
   
   if options.outputRanks:
      ranks = rankFiles( options, data )
      printRanks( ranks, options, data )
      sys.exit(0)
      
   drawData( axDict['main'], data.xData, data.statsList, options, data )
   drawLegend( options, data )
   drawAxisLabels( fig, options, data )
   setAxisLimits( axDict['main'], data.xData, options, data )
   establishTicks( axDict['main'], data.xData, options, data )
   
   lpt.writeImage( fig, pdf, options )
def main():
    usage = (
        "usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ [options]\n\n"
        "%prog takes a directory of contig path stats xml files\n"
        "( --statsScaffoldsContigPathDir ) named as NAME.contigPathStats.xml and creates a plot."
    )
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)
    checkOptions(options, parser)

    assembliesDict = readDir(options.statsScaffoldsContigPathDir, options)
    assembliesList = assembliesDict.values()

    if len(assembliesList) <= 20:
        fig, pdf = lpt.initImage(14.0, 8.0, options, data)
    else:
        fig, pdf = lpt.initImage(14.0, 24.0, options, data)
    axDict = establishAxis(len(assembliesList), fig, options, data)

    assembliesList = createXYData(assembliesList, options)

    assembliesList = normalizeDist(assembliesList, options)
    assembliesList = sorted(assembliesList, key=lambda x: max(x.yData["insertionErrorSizeDistribution"]), reverse=True)

    drawData(assembliesList, axDict, options, data)
    drawLegend(assembliesList, axDict, options, data)

    lpt.writeImage(fig, pdf, options)
Ejemplo n.º 14
0
def main():
    usage = ('Usage: %prog [options] file1.xml file2.xml\n\n')
    parser = OptionParser( usage = usage )
    initOptions( parser )
    libplot.initOptions( parser )

    options, args = parser.parse_args()
    checkOptions( args, options, parser )
    libplot.checkOptions( options, parser )
    
    statsList = readfiles( options )

    drawSnpPlot( options, statsList[0], statsList[1] )
Ejemplo n.º 15
0
def main():
    usage = ('Usage: %prog [options] inputCopyNumberStats.xml')
    parser = OptionParser( usage = usage )
    initOptions( parser )
    libplot.initOptions( parser )
    options, args = parser.parse_args()
    checkOptions( args, options, parser )
    libplot.checkOptions( options, parser )

    #Read in input file:
    samples = readfile( args[0], options.filteredSamples )
    for sample in samples:
        drawCnvPlot( sample, options )
Ejemplo n.º 16
0
def main():
    usage = ('Usage: %prog [options] file1.xml file2.xml\n\n')
    parser = OptionParser( usage = usage )
    initOptions( parser )
    libplot.initOptions( parser )

    options, args = parser.parse_args()
    checkOptions( args, options, parser )
    libplot.checkOptions( options, parser )

    #HACK:
    filteredSamples = getFilteredSamples( os.path.basename(options.indir) )
    if len(filteredSamples) > 0:
        return

    exps = readfiles( options )
    drawPlots( options, exps )
def main():
   usage = ( '%prog --dir=path/to/dir --mode=[scaffPaths|contigs|contigPaths|blocks|contamination] [options]\n\n'
             '%prog takes an aggregate directory ( --dir ) and a mode \n'
             '( --mode ) and then produces a pretty picture.' )
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   
   readFiles( options, data )
   lpt.initImage( 7.0, 8.0, options, data )
   establishAxis( options, data )
   
   drawPlots( options, data )
   
   lpt.writeImage( options, data )
Ejemplo n.º 18
0
def main():
    usage = ( 'usage: %prog [options]'
              '%prog generates summary stats of reference runs of different parameters' )
    parser = OptionParser( usage = usage )
    initOptions( parser )
    libplot.initOptions( parser )
    
    options, args = parser.parse_args()
    checkOptions( options, parser )
    libplot.checkOptions( options, parser )
    
    dirPatternStr = getDirNamePattern( options.params )
    runs = getRuns( options.indir, dirPatternStr, options.params )

    for analysis in options.analyses:
        #Read data:
        sortField = 'sampleName'
        files = analysis.attrib[ 'files' ].split(',')
        analysisName = analysis.attrib[ 'name' ]
        if len(files) == 0:
            sys.stderr.write('No input file(s) for analysis %s\n' %(analysis.attrib['name']) )
            continue
        
        refnames = []
        for file in files:
            refname = getData( options.indir, runs, file, sortField, analysis.attrib['keyField'], analysis.attrib[ 'name' ] )
            refnames.append(refname)
       
        
        dumpData( runs, analysis.attrib[ 'name' ], options.outdir, refnames )
        if options.silent:
            return

        s = 1
        for sortOrder in options.sortOrders:
            #Sort run with 'sortOrder'
            for run in runs:
                run.setSortOrder( sortOrder )
            runs.sort()

            getSummary( runs, analysis, options, s, refnames )
            s += 1
Ejemplo n.º 19
0
def main():
    usage = (
        '%prog --dir=path/to/dir --mode=[scaffPaths|contigs|contigPaths|blocks|contamination] [options]\n\n'
        '%prog takes an aggregate directory ( --dir ) and a mode \n'
        '( --mode ) and then produces a pretty picture.')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    lpt.checkOptions(options, parser)

    readFiles(options, data)
    lpt.initImage(7.0, 8.0, options, data)
    establishAxis(options, data)

    drawPlots(options, data)

    lpt.writeImage(options, data)
Ejemplo n.º 20
0
def main():
    usage = ('Usage: %prog [options] pathStats1.xml pathStats2.xml\n\n'
             '%prog takes in pathStats*.xml files and create the non-linear breakpoint dist. plots\n')
    parser = OptionParser(usage = usage)
    initOptions( parser )
    libplot.initOptions( parser )

    options, args = parser.parse_args()

    checkOptions( args, options, parser )
    libplot.checkOptions( options, parser )
    
    samplesList = readfiles( options.files, options.filteredSamples )
    items = options.samples.split(',')
    sampleNames = []
    for item in items:
        if item not in options.filteredSamples:
            sampleNames.append(item)
    list1 = samplesList[0]
    list2 = samplesList[1]
    drawPlot(samplesList, sampleNames, options)
Ejemplo n.º 21
0
def main():
    usage = ( 'usage: %prog [options] file1.xml file2.xml\n\n'
              '%prog takes in contiguityStats.xml files and create an image file' )

    parser = OptionParser( usage = usage )
    initOptions( parser )
    libplot.initOptions( parser )

    options, args = parser.parse_args()

    checkOptions( args, options, parser )
    libplot.checkOptions( options, parser )
    
    statsList = readfiles( options )
    getAverage(statsList)
    
    #Sort statsList:
    sortedStatsList = []
    for stats in statsList:
        sortedStats = Stats( stats.name )
        sortedStats.setRefName( stats.refname )
        if len(options.samplesOrder) == 0:
            sortedSamples = sorted(stats, key=lambda s:s.name)
            sortedStats.extend( sortedSamples )
        else:
            for name in options.samplesOrder:
                for sample in stats:
                    if sample.name == name:
                        sortedStats.append( sample )

        sortedStatsList.append( sortedStats )

    for stats in sortedStatsList:
        drawContiguityPlot( options, stats )
        
    if len(sortedStatsList) >= 2:
        for i in range( len(sortedStatsList) -1 ):
            for j in range( i + 1, len(sortedStatsList) ):
                drawCompareContiguityPlot( options, sortedStatsList[i], sortedStatsList[j] )
def main():
    usage = (
        'usage: %prog --statsScaffoldsContigPathDir=path/to/dir/ '
        '--statsContigssContigPathDir=path/to/dir/ '
        '--statsScaffoldsContigPathPhasingDir=path/to/dir/ [options]\n\n'
        '%prog takes a directory of scaffold-alignment contig path stats xml files\n'
        '( --statsScaffoldsContigPathDir ) named as NAME.pathStats.xml, contig-alignment '
        'contig path stats xml files ( --statsContigsContigPathDir ) named as NAME.pathStats.xml,'
        'scaffold-alignment contig path phasing stats xml files ( --statsScaffoldsContigPathPhasingDir )'
        ' named as NAME.hap%d.pathStats.xml and creates a  plot.\n')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    cscp.initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    cscp.checkOptions(options, parser)
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)
    checkOptions(options, parser)

    assembliesList = readData(options)
    assembliesList = sorted(assembliesList,
                            key=lambda x: x.valuesDict[options.sortOn],
                            reverse=True)

    maxesMax, minsMin = findMaxMin(assembliesList, options)
    if options.outputRanks:
        rankings(assembliesList, options)
        return

    fig, pdf = lpt.initImage(10.0, 8.0, options, data)
    axDict = establishAxis(fig, options, data)

    drawData(assembliesList, maxesMax, minsMin, axDict, options)

    lpt.writeImage(fig, pdf, options)
Ejemplo n.º 23
0
def main():
   usage = ('usage: %prog --scaffoldsFile=sFile.txt --contigsFile=cFile.txt --size=N --title=TITLE\n\n'
             '%prog takes in a scaffolds file (--scaffoldsFile), a contigs\n'
             'file (--contigs), the size of the genome (--size) and a title (--title)\n'
             'and then produces an N50 style figure.')
   data = Data()
   parser = OptionParser(usage=usage)
   initOptions(parser)
   lpt.initOptions(parser)
   options, args = parser.parse_args()
   checkOptions(options, parser)
   lpt.checkOptions(options, parser)
   
   scaffolds = readFile(options.scaffoldsFile)
   contigs   = readFile(options.contigsFile)
   
   pScaffs, pContigs = processData(scaffolds, contigs, options)
   fig, pdf = lpt.initImage(8.0, 5.0, options, data)
   ax = establishAxis(fig, options)
   
   drawData(pScaffs, pContigs, ax, options)

   lpt.writeImage(fig, pdf, options)
Ejemplo n.º 24
0
def main():
    usage = (
        '%prog --file=file.txt --mode=[scaffPaths|contigs|contigPaths|blocks|contamination] [options]\n\n'
        '%prog takes an aggregate text file ( --file ) and a mode \n'
        '( --mode ) and then produces a pretty picture.')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    lpt.checkOptions(options, parser)
    fig, pdf = lpt.initImage(8.0, 10.0, options, data)
    axDict = establishAxes(fig, options, data)

    data.valuesDict = readFile(options.file, options)
    data.xData = data.valuesDict['columnLength']

    if options.mode != 'contamination':
        data.valuesDict = normalizeDataNormalMode(data.valuesDict, options,
                                                  data)
    else:
        normalizeDataContaminationMode(options, data)

    setAxisLimits(axDict['main'], axDict['crazy'], axDict['blowUp'],
                  data.xData, options, data)
    drawData(axDict['main'], axDict['crazy'], axDict['blowUp'], data.xData,
             data.valuesDict, options, data)
    drawLegend(options, data)
    drawAxisLabels(fig, options, data)

    setAxisLimits(axDict['main'], axDict['crazy'], axDict['blowUp'],
                  data.xData, options, data)

    establishTicks(axDict['main'], axDict['crazy'], axDict['blowUp'], options,
                   data)
    lpt.writeImage(fig, pdf, options)
Ejemplo n.º 25
0
def main():
    usage = "mappingPlot.py [options]"
    parser = OptionParser(usage = usage)
    initOptions( parser )
    libplot.initOptions( parser )
    options, args = parser.parse_args()
    checkOptions( args, options, parser )
    libplot.checkOptions( options, parser )

    refIndir = os.path.join(options.indir, "otherRefs")
    refExps = getRefStats( refIndir )
    #DEBUG:
    #for r in refExps:
    #    sys.stderr.write("Ref: %s\t" %r)
    #    for s in refExps[r]:
    #        sys.stderr.write("%s-%s\t"%(s, refExps[r][s].sample ))
    #    sys.stderr.write("\n")
    
    expSets, setnames = getExpSets(options.indir)
    for i, dirs in enumerate(expSets):
        name = setnames[i]
        exps = getStats(options.indir, dirs)
        #DEBUG:
        #for s in exps:
        #    sys.stderr.write("Sample %s\t" %s)
        #    for exp in exps[s]:
        #        sys.stderr.write("%s-%d\t" %(exp.ref, exp.weight))
        #    sys.stderr.write("\n")
        
        outdir = os.path.join( options.outdir, name )
        system("mkdir -p %s" %(outdir))
        for r in refExps:
            rexps = refExps[r]
            routdir = os.path.join(outdir, r)
            system("mkdir -p %s" %(routdir))
            makeLatexTab( os.path.join(routdir, "mappingStats.tex"), exps, rexps )
            drawPlots(options, routdir, exps, rexps)
Ejemplo n.º 26
0
def main():
    usage = (
        'usage: %prog --subStatsDir=path/to/dir/ [options]\n\n'
        '%prog takes in a directory of substitution stats files ( --subStatsDir )\n'
        'with filenames as NAME.subStats.[upper|lower].xml and produces a plot.'
    )
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    las.initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    las.checkOptions(options, parser)
    lpt.checkOptions(options, parser)

    if not options.outputRanks:
        fig, pdf = lpt.initImage(9., 11., options, data)
        axDict = establishAxes(fig, options, data)

    assembliesDict = {}
    assembliesDict = readSubStatsDir(assembliesDict, options)

    sumErrors(assembliesDict, options)
    normalizeData(assembliesDict, options)

    sortOrder = sorted(assembliesDict,
                       key=lambda key: assembliesDict[key].allLo,
                       reverse=False)

    if options.outputRanks:
        rankings(assembliesDict, sortOrder, options, data)
        return

    drawData(assembliesDict, sortOrder, axDict, options, data)

    lpt.writeImage(fig, pdf, options)
Ejemplo n.º 27
0
def main():
   usage = ( '%prog --file=file.txt --mode=[scaffPaths|contigs|contigPaths|blocks|contamination] [options]\n\n'
             '%prog takes an aggregate text file ( --file ) and a mode \n'
             '( --mode ) and then produces a pretty picture.' )
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( options, parser )
   lpt.checkOptions( options, parser )
   fig, pdf = lpt.initImage( 8.0, 10.0, options, data )
   axDict = establishAxes( fig, options, data )
   
   data.valuesDict = readFile( options.file, options )
   data.xData = data.valuesDict['columnLength']
   
   if options.mode != 'contamination':
      data.valuesDict = normalizeDataNormalMode( data.valuesDict, options, data )
   else:
      normalizeDataContaminationMode( options, data )

   setAxisLimits( axDict['main'], axDict['crazy'], 
                  axDict['blowUp'], data.xData, 
                  options, data )
   drawData( axDict['main'], axDict['crazy'], 
             axDict['blowUp'], data.xData, data.valuesDict, options, data )
   drawLegend( options, data )
   drawAxisLabels( fig, options, data )
   
   setAxisLimits( axDict['main'], axDict['crazy'], 
                  axDict['blowUp'], data.xData,
                  options, data )

   establishTicks( axDict['main'], axDict['crazy'], 
                   axDict['blowUp'], options, data )
   lpt.writeImage( fig, pdf, options )
Ejemplo n.º 28
0
def main():
    usage = ('usage: %prog [options] file1.xml\n\n'
             '%prog takes in a copy number statistics file\n'
             'and creates an image file.')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(args, options, parser)
    lpt.checkOptions(options, parser)
    fig, pdf = lpt.initImage(11.0, 3.25, options, data)

    storedCategories = readFiles(options)

    establishGlobalMinMax(storedCategories, options, data)
    axDict = establishAxes(fig, storedCategories, options, data)

    drawData(axDict, storedCategories, options, data)
    drawLegend(options, data)
    drawAxisLabels(axDict, storedCategories, options, data)
    setAxisLimits(axDict, options, data)

    lpt.writeImage(fig, pdf, options)
Ejemplo n.º 29
0
def main():
    usage = ('usage: %prog [options] file1.xml file2.xml\n\n'
             '%prog reads in pathStats.xml files and create insertion and deltion distribution plots')

    parser = OptionParser( usage = usage )
    initOptions( parser )
    libplot.initOptions( parser )
    options, args = parser.parse_args()
    checkOptions( args, options, parser)
    libplot.checkOptions( options, parser )

    statsList, names = readfiles( options.files )

    #Filter out non-leaf samples:
    statsListF = []
    for xmltree in statsList:
        root = xmltree.getroot()
        allsamples = root.findall( 'statsForSample' )

        samples = getLeaves( allsamples, options.filteredSamples )
        statsListF.append( samples )

    for i, samples in enumerate(statsListF):
        outname = names[i]
        sortedSamples = []
        if len(options.samplesOrder) == 0:
            sortedSamples = sorted(samples, key=lambda s:s.name)
        else:
            for name in options.samplesOrder:
                for sample in samples:
                    if sample.attrib['sampleName'] == name:
                        sortedSamples.append( sample )
        #print outname
        drawPlots( options, sortedSamples, outname, False, False )
        drawPlots( options, sortedSamples, outname, True, False )
        drawPlots( options, sortedSamples, outname, True, True )
Ejemplo n.º 30
0
def main():
    usage = (
        'usage: %prog --scaffoldsFile=sFile.txt --contigsFile=cFile.txt --size=N --title=TITLE\n\n'
        '%prog takes in a scaffolds file (--scaffoldsFile), a contigs\n'
        'file (--contigs), the size of the genome (--size) and a title (--title)\n'
        'and then produces an N50 style figure.')
    data = Data()
    parser = OptionParser(usage=usage)
    initOptions(parser)
    lpt.initOptions(parser)
    options, args = parser.parse_args()
    checkOptions(options, parser)
    lpt.checkOptions(options, parser)

    scaffolds = readFile(options.scaffoldsFile)
    contigs = readFile(options.contigsFile)

    pScaffs, pContigs = processData(scaffolds, contigs, options)
    fig, pdf = lpt.initImage(8.0, 5.0, options, data)
    ax = establishAxis(fig, options)

    drawData(pScaffs, pContigs, ax, options)

    lpt.writeImage(fig, pdf, options)
def main():
   usage = ( 'usage: %prog [options] file1.xml\n\n'
             '%prog takes in a copy number statistics file\n'
             'and creates an image file.' )
   data = Data()
   parser = OptionParser( usage=usage )
   initOptions( parser )
   lpt.initOptions( parser )
   options, args = parser.parse_args()
   checkOptions( args, options, parser )
   lpt.checkOptions( options, parser )
   fig, pdf = lpt.initImage( 11.0, 3.25, options, data )

   storedCategories = readFiles( options )
   
   establishGlobalMinMax( storedCategories, options, data )
   axDict = establishAxes( fig, storedCategories, options, data )
   
   drawData( axDict, storedCategories, options, data )
   drawLegend( options, data )
   drawAxisLabels( axDict, storedCategories, options, data )
   setAxisLimits( axDict, options, data )
   
   lpt.writeImage( fig, pdf, options )
Ejemplo n.º 32
0
def main():
    usage = ( 'usage: %prog [options] file1.xml file2.xml\n\n'
              '%prog takes in coverageStats.xml files and create an image file' )
    parser = OptionParser( usage = usage )
    initOptions( parser )
    libplot.initOptions( parser )

    options, args = parser.parse_args()

    checkOptions( args, options, parser )
    libplot.checkOptions( options, parser )

    statsList = readfiles( options )
    sample2repeat = readRepeatInfo( options.repeatInfo )
    
    for stats in statsList:
        stats.sort()
        stats1 = []
        for s in stats:
            if s.name != 'all':
                stats1.append(s)
        drawCoveragePlot( options, stats1, True, 0 )
        drawCoveragePlot( options, stats1, False, 0 )
        if options.ycutoff > 0:
            drawCoveragePlot( options, stats1, True, options.ycutoff )
            drawCoveragePlot( options, stats1, False, options.ycutoff )

        #sort by totalBases:
        specialcases = {'average':None, 'all':None, 'panTro3':None}
        sortedstats = []
        for i in xrange( len(stats) ):
            if stats[i].name in [ stats[i].referenceName, stats[i].otherReferenceName, 'minusOtherReference' ]:
                continue
            if stats[i].name in specialcases:
                specialcases[ stats[i].name ] = stats[i]
            else:
                sortedstats.append( stats[i] )
        sortedstats = sorted( sortedstats, key=lambda s: s.totalBases, reverse=True )
        for k in specialcases:
            s = specialcases[k]
            if s:
                sortedstats.append( s )
        if len(sortedstats) > 0:
            drawCompareCoveragePlot( options, sortedstats, True )
            drawCompareCoverageTab( options, sortedstats, sample2repeat )

        #sort by totalBases, but include 'otherReference' sample
        sortedstats = []
        for i in xrange( len(stats) ):
            if stats[i].name in [ stats[i].referenceName, 'minusOtherReference' ]:
                continue
            if stats[i].name in specialcases:
                specialcases[ stats[i].name ] = stats[i]
            else:
                sortedstats.append( stats[i] )
        sortedstats = sorted( sortedstats, key=lambda s: s.totalBases, reverse=True )
        for k in specialcases:
            s = specialcases[k]
            if s:
                sortedstats.append( s )
        if len(sortedstats) > 0:
            drawCompareCoveragePlot2( options, sortedstats, True )
        
        #scatter plot
        drawScatterPlot( options, stats, 'consensusVShg19', False )
        drawScatterPlot( options, stats, 'consensusVShg19', True )
        drawScatterPlot( options, stats, 'noHg19', False )
        drawScatterPlot( options, stats, 'noHg19', True )