Example #1
0
def main():
    usage = ('Usage: %prog [options] inputDirectory\n')

    parser = OptionParser(usage = usage)
    initOptions( parser )
    #libplot.initOptions( parser )
    iseqlib.initPlotOptions( parser )
    options, args = parser.parse_args()
    checkOptions( args, options, parser )
    #libplot.checkOptions( options, parser )
    iseqlib.checkPlotOptions( options, parser )

    samples = readfiles( args[0], options.cumulative )
    if options.group:
        group2samples = readGroup2Samples(options.group) 
        samples = getAvrSamples(samples, group2samples, options.cumulative)
    
    #drawCloneSizeDist( samples, options, True, False, False, options.cumulative )
    #drawCloneSizeDist( samples, options, False, False, False, options.cumulative )
    #drawCloneSizeDist( samples, options, True, False, True, options.cumulative )
    #drawCloneSizeDist( samples, options, False, False, True, options.cumulative )
    #drawCloneSizeDist( samples, options, True, True, False, options.cumulative )
    #drawCloneSizeDist( samples, options, False, True, False, options.cumulative )
    
    #drawCloneSizeDist( samples, options, options.isAbs, options.yaxisPcReads, options.yaxisPcClones, options.cumulative )
    
    #if not options.group:
    #    drawCloneVsRead( samples, options, True )
    #    drawCloneVsRead( samples, options, False )

    drawCombine( samples, options )
Example #2
0
def main():
    parser = immunoseqLib.initOptions()
    initOptions( parser )
    immunoseqLib.initPlotOptions( parser )
    options, args = parser.parse_args()
    checkOptions( args, options, parser )
    immunoseqLib.checkPlotOptions( options, parser )

    samples, stds = readfiles( options.indir, options.noheader )
    type2intersectGenes = getIntersect(samples) #Get genes that are present in all samples
    type2selectedGenes = getSelectedGenes(type2intersectGenes, options.vs, options.js) #Select only genes of interest that are present in all samples
    
    group2samples = readGroup2samples(options.group2samples)
    
    #Intersect VJ:
    if options.ttest or options.vj or options.pca:
        #intersectVJ(samples, type2intersectGenes, options.vjs) #added intersectVJusage, normIntersectVJusage
        intersectVJ(samples, type2selectedGenes) #added intersectVJusage, normIntersectVJusage

    #Pca:
    if options.pca:
        vPcaOut = os.path.join(options.outdir, "vPca")
        getPcaTransformedMatrix(samples, group2samples, type2intersectGenes, options.vjs, 'v', options.abs, vPcaOut, options)
        vjPcaOut = os.path.join(options.outdir, "vjPca")
        getPcaTransformedMatrix(samples, group2samples, type2intersectGenes, options.vjs, 'vj', options.abs, vjPcaOut, options)
    #return

    #Student's t test:
    if options.ttest:
        outfile = os.path.join(options.outdir, "ttest.txt")
        ttests(samples, group2samples, outfile, type2selectedGenes, options.vjs, options.ttestTargetGroup, options.abs, options.pval)
    
    #HACK: Sort samples:
    #sampleOrder = 'SBC1,SBC7,SBC3,SBC4,SBC5,SBC6,SBC2,SBC8,Patient-01-R,Patient-01-D,Patient-10,Patient-11,Patient-12,Patient-13,Patient-B-R,Patient-B-D,Patient-8-D,Patient-15-D'
    if options.sampleOrder:
        orders = options.sampleOrder
        sortedSamples = []
        for s in orders:
            for sample in samples:
                if sample.name == s:
                    sortedSamples.append(sample)
        for s in samples:
            if s not in sortedSamples:
                sortedSamples.append(s)
    else:
        sortedSamples = samples

    #checkSamples( samples )
    if not options.noplot:
        drawUsageDist( sortedSamples, stds, options, 'v', type2selectedGenes['v'] )
        drawUsageDist( sortedSamples, stds, options, 'j', type2selectedGenes['j'] )
    
    if options.vj:
        minvj, maxvj = getMinMaxVJusage(samples, options.abs)
        for sample in samples:
            drawVJ( sample, type2selectedGenes['v'], type2selectedGenes['j'], options, minvj, maxvj )
Example #3
0
def main():
    parser = iseqlib.initOptions()
    Stack.addJobTreeOptions( parser )
    iseqlib.initPlotOptions( parser )
    addOptions(parser)
    
    options, args = parser.parse_args()
    iseqlib.checkPlotOptions( options, parser )

    mincount = options.mincount
    #samples = readfiles(options.indir, mincount)

    i = Stack( Setup(options) ).startJobTree(options)
    if i:
        raise RuntimeError("The jobtree contains %d failed jobs.\n" %i)
Example #4
0
def main():
    usage=('Usage: %prog [options] inputDir outputDir')
    parser = OptionParser(usage=usage)
    parser.add_option('-s', '--sampling', dest='sampling', action='store_true', default=False, help='If specified, will randomly sampling sequences from each file with sampling size equals to size of the smallest sample')
    parser.add_option('--numSamplings', dest='numSamplings', type='int', default=100, help='Number of samplings. Default=%default')
    iseqlib.initPlotOptions(parser)
    options, args = parser.parse_args()
    iseqlib.checkPlotOptions(options, parser)
    
    indir = args[0]
    outdir = args[1]
    sample2freqs = readfiles(indir)
    if options.sampling:
        sample2data = samplingSamples(sample2freqs, options.numSamplings)
    else:
        sample2data = binDataSamples(sample2freqs) 

    drawClonesizeDist(outdir, options, sample2data)
Example #5
0
def main():
    parser = iseqlib.initOptions()
    iseqlib.initPlotOptions(parser)
    parser.add_option('-i', '--indir', dest='indir')
    parser.add_option('-o', '--outdir', dest='outdir', default = '.')
    
    parser.add_option('-m', '--mode', dest='mode', default='1,2', type='string', help='Specify how you would like to aggregate the data. Should be a comma seperated list of any of the valid choices: [1, 2]. Mode 1 is one statistics of interest across different cutoffs. Mode 2 is different statistics for 1 cutoff.')

    parser.add_option('-s', '--stats_type', dest='stats_type', default='readAvr', help='Option for mode 1. Specify which overlapping statistics of interest to print out. Default = %default. Valid values are [clone1, clone2, cloneAvr, read1, read2, readAvr], where clone# is percentage of clones in sample # that passed each cutoff and are also in the other sample; cloneAvr is average of clone1 and clone2; read# is percentage of reads in clones of sample # that passed cutoff and also in the other sample; readAvr: average of read1 and read2')
    parser.add_option('-c', '--cutoffs', dest='cutoffs', default='all', help='Option for mode 2. Comma separated list of cutoffs of interest. Default=%default' )
    parser.add_option('-a', '--sampleOrder', dest='sampleOrder')
    parser.add_option('-l', '--latex', dest='latex', action='store_true', default=False)
    parser.add_option('-g', '--groupToSamples', dest='group2samples')

    options, args = parser.parse_args()
    iseqlib.checkPlotOptions( options, parser )

    if options.sampleOrder:
        options.sampleOrder = options.sampleOrder.split(',')
    indir = options.indir
    if not os.path.isdir(indir):
        raise ValueError("Input directory %s is not a directory\n" %indir)
    options.mode = options.mode.split(',')
    options.cutoffs = options.cutoffs.split(',')

    exps = []
    for file in os.listdir(indir):
        if os.path.isdir( os.path.join(indir, file) ):
            continue
        exp = readFile( os.path.join(indir, file) )
        exps.append(exp)
    
    if options.group2samples:
        options.group2samples = readGroup2Samples(options.group2samples)

    orfile = os.path.join(options.outdir, "overlapReads-%s.tex" %options.stats_type)
    #getOverlapReadsTab(exps, orfile)
    if '1' in options.mode:
        getCutoffsLatexTab(exps, orfile, options.stats_type, options.sampleOrder)
        #drawOverlapReads(exps, options)
    
    if '2' in options.mode:
        getAllStatsLatexTabs(exps, options.outdir, options.cutoffs, options.sampleOrder, options.latex)
Example #6
0
def main():
    parser = iseqlib.initOptions()
    parser.add_option('-i', '--infile', dest='infile', default='-', help='Input file. Default is stdin')
    parser.add_option('-o', '--outdir', dest='outdir', default='.', help='Output directory. Default is current directory')
    parser.add_option('--noplot', dest='noplot', action='store_true', default=False, help='If specified, do not draw plot')
    parser.add_option('-t', '--table', dest='table', action='store_true', default=False, help='If specified, make latex table')
    #parser.add_option('-o', '--outfile', dest='outfile', default='-', help='Output file. Default is stdout')

    iseqlib.initPlotOptions(parser)
    options, args = parser.parse_args()
    iseqlib.checkPlotOptions( options, parser )

    rowname2row, index2colname = readfile(options.infile)
    if not options.noplot:
        drawPlots(options, options.outdir, rowname2row, index2colname)

    if options.table:
        outfile = os.path.join(options.outdir, "%s.tex" %( os.path.basename(options.infile).split('.')[0] ))
        getLatexTab(outfile, rowname2row, index2colname)
Example #7
0
def main():
    parser = iseqlib.initOptions()
    iseqlib.initPlotOptions( parser )
    addOptions(parser)
    
    options, args = parser.parse_args()
    iseqlib.checkPlotOptions( options, parser )

    samples = readfiles(options.indir, options.count, options.translate)

    if options.drawdist:
        drawDist(samples, options) 
    
    #printSharedSeqFreqAll( samples, minsam, "counts-atleast3sams" )
    if options.fasta:
        faoutdir = os.path.join(options.outdir, "fasta-atleast%dsams" %options.minsam)
        system("mkdir -p %s" %faoutdir)
        filterByNumSampleAll(samples, options.minsam, faoutdir, options.freq)
    
    if options.clonematrix:
        printCloneMatrixAll(options.outdir, samples, options.minsam, options.freqTransform)