def tab(f, stats, sample2repeat): altColor = 1 for sample in stats: repeat = 'NA' repeatPc = '' if sample.name in sample2repeat: repeat = libplot.prettyInt( sample2repeat[sample.name][1] ) repeatPc = "(%.2f \\%%)" %sample2repeat[sample.name][2] otherRef = libplot.prettyInt(sample.otherReferenceBasesMapped) otherRefPc = "%.2f" % (100.0*sample.otherReferenceBasesMapped/sample.totalBases) ref = libplot.prettyInt(sample.referenceBasesMapped) refPc = "%.2f" % (100.0*sample.referenceBasesMapped/sample.totalBases) total = libplot.prettyInt(sample.totalBases) sampleName = libplot.properName(sample.name) if altColor == 1: f.write("%s & %s %s & %s (%s \\%%) & %s (%s \\%%) & %s \\\\\n" %(sampleName, repeat, repeatPc, otherRef, otherRefPc, ref, refPc, total )) else: f.write("\\cellcolor[gray]{0.9} %s & \\cellcolor[gray]{0.9} %s %s & \\cellcolor[gray]{0.9} %s (%s \\%%) & \\cellcolor[gray]{0.9} %s (%s \\%%) & \\cellcolor[gray]{0.9} %s \\\\\n" %(sampleName, repeat, repeatPc, otherRef, otherRefPc, ref, refPc, total )) altColor = 1 - altColor f.write("\\hline\n")
def tab( f, exps, rexps, samples ): for sample in samples: expList = copy.copy(exps[sample]) expList.sort() expList.append( rexps[sample] ) #sys.stderr.write('expList for sample %s: %s\n' %(sample, '\t'.join([ '%s%d' %(e.ref, e.weight)for e in expList]))) f.write( "\\multirow{%d}{*}{%s} " %( len(expList), sample ) ) #f.write( "\\multirow{%d}{*}{%s} " %( len(expList) -1, sample ) ) #HACK for e in expList: #if e.ref == 'cactusRef' and e.weight == 1: #HACK # continue ref = libplot.properName(e.ref) if re.search('cactusRef', e.ref): r = e.ref.lstrip('cactusRef') ref = "%s %s" % (libplot.properName('cactusRef'), r) if e.ref != 'cactusRef': f.write("& %s & %s & %s & %s & %s & %s \\\\\n" %(ref, libplot.prettyInt(e.mapped), libplot.prettyInt(e.uniquelyMapped), libplot.prettyInt(e.properlyPaired), libplot.prettyInt(e.uniquelyMappedAndProperlyPaired), libplot.prettyInt(e.snps))) elif e.ref == 'cactusRef' and e.weight == 2: f.write("& \\cellcolor{cyan!30} %s%d & \\cellcolor{cyan!30} %s & \\cellcolor{cyan!30} %s & \\cellcolor{cyan!30} %s & \\cellcolor{cyan!30} %s & \\cellcolor{cyan!30} %s \\\\\n" %(ref, e.weight, libplot.prettyInt(e.mapped), libplot.prettyInt(e.uniquelyMapped), libplot.prettyInt(e.properlyPaired), libplot.prettyInt(e.uniquelyMappedAndProperlyPaired), libplot.prettyInt(e.snps))) else: f.write("& %s%d & %s & %s & %s & %s & %s \\\\\n" %(ref, e.weight, libplot.prettyInt(e.mapped), libplot.prettyInt(e.uniquelyMapped), libplot.prettyInt(e.properlyPaired), libplot.prettyInt(e.uniquelyMappedAndProperlyPaired), libplot.prettyInt(e.snps))) f.write("\\hline\n")
def tab(f, data ): altColor = 1 sortedsamples = sorted( data.keys() ) for i,s in enumerate(sortedsamples): if s == 'average': sortedsamples.pop(i) sortedsamples.append('average') for sample in sorted( data.keys() ): stats = data[sample] if altColor == 1: f.write( "%s & %s & %s & %.2f \\%% & %.4f & %.4f\\\\\n" %(sample, libplot.prettyInt(stats[0]), libplot.prettyInt(stats[1]), stats[2], stats[3], stats[3]/stats[4]) ) else: f.write( "\\cellcolor[gray]{0.9} %s & \\cellcolor[gray]{0.9} %s & \\cellcolor[gray]{0.9} %s & \\cellcolor[gray]{0.9} %.2f \\%% & \\cellcolor[gray]{0.9} %.4f & \\cellcolor[gray]{0.9} %.4f\\\\\n" %(sample, libplot.prettyInt(stats[0]), libplot.prettyInt(stats[1]), stats[2], stats[3], stats[3]/stats[4]) ) altColor = 1 - altColor f.write("\\hline\n") return