Esempio n. 1
0
def tab(f, rowname2cells, index2colname):
    for rowname in sorted( rowname2cells.keys() ):
        row = rowname2cells[rowname]
        f.write("%s" %rowname)
        for i, m in enumerate( row ):
            if i % 2 == 0 and m != 'NA' and m != '' and m != '-':
                colname = index2colname[i]
                if colname in ['uniqClones', 'fisherAlpha']:
                    f.write( " & %s " % iseqlib.prettyInt( int(float(m)) ) )
                else:
                    f.write( " & %.3f " % float(m) )
            elif i%2 == 1 and m != 'NA' and m != '' and m != '-':
                colname = index2colname[i -1]
                if colname in ['uniqClones', 'fisherAlpha']:
                    f.write( " $\\pm$ %s " % iseqlib.prettyInt(int(float(m))) )
                else:
                    f.write( " $\\pm$ %.3f " % float(m) )
        f.write("\\\\\n")
        f.write("\\hline\n")
Esempio n. 2
0
def getClonesizeTextTab(samples, groupsamples, group2samples, outfile, simpson):
    if len(groupsamples) >0:
        samples = sortSamplesByGroup(samples, groupsamples, group2samples)
    else:
        samples = sorted(samples, key=lambda sample: sample.totalCount) 
    f = open(outfile, 'w')
    if simpson:
        f.write("Sample\tClones\tTotal Reads\tSimpson Index\n")
    else:
        f.write("Sample\tClones\tTotal Reads\n")
    for s in samples:
        if s.name in group2samples:
            f.write("Avr %s\t%s\t%s" %(s.name.replace('_', "-"), iseqlib.prettyInt(s.totalClones), iseqlib.prettyInt(s.totalCount)))
            if simpson:
                f.write("\t%.3f" %s.simpson)
            f.write("\n")
            f.write("#\n")
        else:
            f.write("%s\t%s\t%s" %(s.name.replace('_', "-"), iseqlib.prettyInt(s.totalClones), iseqlib.prettyInt(s.totalCount)))
            if simpson:
                f.write("\t%.3f" %s.simpson)
            f.write("\n")
    f.close()
Esempio n. 3
0
def tab(f, samples, groupsamples, group2samples, simpson):
    if len(groupsamples) > 0:
        samples = sortSamplesByGroup(samples, groupsamples, group2samples)

    for s in samples:
        if s.name in group2samples:
            f.write("\\cellcolor[gray]{0.9} Avr %s & \\cellcolor[gray]{0.9} %s & \\cellcolor[gray]{0.9} %s" %(s.name.replace('_', "-"), iseqlib.prettyInt(s.totalClones), iseqlib.prettyInt(s.totalCount)))
            if simpson:
                f.write("& \\cellcolor[gray]{0.9} %.3f" % s.simpson)
            f.write("\\\\\n")
            f.write("\\hline\n")
        else:
            f.write("%s & %s & %s" %(s.name.replace('_', "-"), iseqlib.prettyInt(s.totalClones), iseqlib.prettyInt(s.totalCount)))
            if simpson:
                f.write("& %.3f" %s.simpson)
            f.write("\\\\\n")

    if len(groupsamples) == 0:
        f.write("\\hline\n")
Esempio n. 4
0
def textTab(f, sampleToExps, cutoff, sampleOrder):
    #f.write("#S1\tS2\tSize\tClones1\tClones2\t%O.Clones1\t%O.Clones2\t%O.Reads1\t%O.Reads2\n")
    f.write("#S1\tS2\tSize\tClones1\t%O.Clones1\t%O.Reads1\tClones2\t%O.Clones2\t%O.Reads2\n")
    samples = sampleOrder
    if not sampleOrder:
        samples = sorted( sampleToExps.keys() )

    for sample in samples:
        exps = sampleToExps[sample]
        for exp in exps:
            #Find index of the cutoff
            index = -1
            for i,c in enumerate(exp.cutoffs):
                if c == cutoff:
                    index = i
                    break
            if index == -1:
                continue

            samsize = str(exp.size)
            if samsize == '0':
                samsize = 'NA'
            if exp.sample1 == sample:
                f.write("%s\t%s\t%s\t%s\t%.2f\t%.2f\t%s\t%.2f\t%.2f \n" %(exp.sample1, exp.sample2, samsize, iseqlib.prettyInt(int(exp.clones1[index])), exp.oclones1[index], exp.reads1o2[index], iseqlib.prettyInt(int(exp.clones2[index])), exp.oclones2[index], exp.reads2o1[index]) )
                #f.write("%s\t%s\t%s\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f \n" %(exp.sample1, exp.sample2, samsize, iseqlib.prettyInt(int(exp.clones1[index])), iseqlib.prettyInt(int(exp.clones2[index])), exp.oclones1[index], exp.oclones2[index], exp.reads1o2[index], exp.reads2o1[index]) )
            else:
                f.write("%s\t%s\t%s\t%s\t%.2f\t%.2f\t%s\t%.2f\t%.2f \n" %(exp.sample2, exp.sample1, samsize, iseqlib.prettyInt(int(exp.clones2[index])), exp.oclones2[index], exp.reads2o1[index], iseqlib.prettyInt(int(exp.clones1[index])), exp.oclones1[index], exp.reads1o2[index]) )
                #f.write("%s\t%s\t%s\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f \n" %(exp.sample2, exp.sample1, samsize, iseqlib.prettyInt(int(exp.clones2[index])), iseqlib.prettyInt(int(exp.clones1[index])), exp.oclones2[index], exp.oclones1[index], exp.reads2o1[index], exp.reads1o2[index]) )
        f.write("#\n")        
Esempio n. 5
0
def tab2(f, sampleToExps, cutoff, sampleOrder):
    samples = sampleOrder
    if not sampleOrder:
        samples = sorted( sampleToExps.keys() )

    for sample in samples:
        exps = sampleToExps[sample]
        for exp in exps:
            #Find index of the cutoff
            index = -1
            for i,c in enumerate(exp.cutoffs):
                if c == cutoff:
                    index = i
                    break
            if index == -1:
                continue

            samsize = str(exp.size)
            if samsize == '0':
                samsize = 'NA'
            if exp.sample1 == sample:
                #f.write("%s & %s & %s & %s & %s & %.2f & %.2f & %.2f & %.2f \\\\\n" %(exp.sample1, exp.sample2, samsize, iseqlib.prettyInt(int(exp.clones1[index])), iseqlib.prettyInt(int(exp.clones2[index])), exp.oclones1[index], exp.oclones2[index], exp.reads1o2[index], exp.reads2o1[index]) )
                f.write("%s & %s & %s & %s & %.2f & %.2f & %s & %.2f & %.2f \\\\\n" %(exp.sample1, exp.sample2, samsize, iseqlib.prettyInt(int(exp.clones1[index])), exp.oclones1[index], exp.reads1o2[index], iseqlib.prettyInt(int(exp.clones2[index])), exp.oclones2[index], exp.reads2o1[index]) )
            else:
                #f.write("%s & %s & %s & %s & %s & %.2f & %.2f & %.2f & %.2f \\\\\n" %(exp.sample2, exp.sample1, samsize, iseqlib.prettyInt(int(exp.clones2[index])), iseqlib.prettyInt(int(exp.clones1[index])), exp.oclones2[index], exp.oclones1[index], exp.reads2o1[index], exp.reads1o2[index]) )
                f.write("%s & %s & %s & %s & %.2f & %.2f & %s & %.2f & %.2f \\\\\n" %(exp.sample2, exp.sample1, samsize, iseqlib.prettyInt(int(exp.clones2[index])), exp.oclones2[index], exp.reads2o1[index], iseqlib.prettyInt(int(exp.clones1[index])), exp.oclones1[index], exp.reads1o2[index]) )
        f.write("\\hline\n")