Esempio n. 1
0
def drawClonesizeDist(outdir, options, sample2data):
    options.out = os.path.join( outdir, "cloneVsRead" )
    fig, pdf = iseqlib.initImage( 10.0, 8.0, options )
    axes = fig.add_axes( [0.12, 0.15, 0.85, 0.75] )

    lines = []
    sampleNames = sorted(sample2data.keys())
    #draw
    colors = iseqlib.getColors6()
    lightColors = iseqlib.getColors6light()
    markers = ['o', '*', 's', 'd', '^', 'p', 'v']
    c = 0

    xdata = []
    xticklabels = []
    for sample in sampleNames:
        #xticklabels, ydata = binData( sample2freqs[sample] )
        (xticklabels, ydata) = sample2data[sample]
        print sample
        print xdata
        print ydata
        xdata = range(0, len(xticklabels), 1)
        markersize = 10.0
        m = markers[c]
        if m == '*':
            markersize = 12.0
        elif m == 's':
            markersize = 8.0
        
        l = axes.plot(xdata, ydata, color=colors[c], marker=m, markeredgecolor=colors[c], markersize=markersize, linestyle='none')
        axes.plot(xdata, ydata, color=lightColors[c], linestyle='-', linewidth=0.2)
        lines.append(l)
        c += 1
    
    iseqlib.editSpine(axes)
    
    axes.set_title('Clone Size Distribution', size='xx-large')
    axes.set_xlabel('Clone size as percentage of total reads', size='large')
    axes.set_ylabel('Percentage of total clones', size='large')
    
    fontP = FontProperties()
    fontP.set_size('medium')
    legend = axes.legend( lines, sampleNames, numpoints=1, loc='best', ncol=1, prop=fontP)
    legend._drawFrame = False
    
    axes.xaxis.set_ticklabels( xticklabels )
    axes.xaxis.set_ticks( [x - 0.5 for x in xdata] )
    axes.set_xlim(-0.5, len(xdata) - 0.5)
    
    axes.set_ylim(-0.5, 50)
    for label in axes.get_xticklabels():
        label.set_fontsize('medium')
        label.set_rotation(45)
    for label in axes.get_yticklabels():
        label.set_fontsize('medium')
    
    axes.yaxis.grid(b=True, color="#BDBDBD", linestyle='-', linewidth=0.005)
    axes.xaxis.grid(b=True, color="#BDBDBD", linestyle='-', linewidth=0.005)

    iseqlib.writeImage(fig, pdf, options)
Esempio n. 2
0
def drawDistData(axes, sam2nt2aa):
    #sam2nt2aa = getNumNtPerAa(samples)
    
    lines = []
    labels = []
    colors = iseqlib.getColors6()
    if len(colors) < len(sam2nt2aa.keys()):
        colors.extend( iseqlib.getColors6light() )
    if len(colors) < len(sam2nt2aa.keys()):
        colors.extend( iseqlib.getColors6dark() )
    #colors = iseqlib.getColors0()
    #lightColors = getColors6light()
    markersize = 10.0
    c = -1
    axes.set_yscale('log')
    for s in sorted( sam2nt2aa.keys() ):
        nt2aa = sam2nt2aa[s]
        
        c += 1
        xdata = sorted( nt2aa.keys() )
        ydata = [ nt2aa[x] for x in xdata ]
        
        line = axes.plot(xdata, ydata, color=colors[c], marker='o', markeredgecolor=colors[c], markersize = markersize, linestyle='-', linewidth=2)
        #axes.plot(xdata, ydata, color=lightColors[c], linestyle='-', linewidth=0.5)
        lines.append(line)
        labels.append(s)
        print s
        print xdata
        print ydata
    
    xticks = xrange(0,8,1)
    xticklabels = [ str(x) for x in xticks]
    axes.xaxis.set_ticks(xticks)
    axes.xaxis.set_ticklabels( xticklabels )
    #axes.set_xlim(0.5, 5.5)
    #axes.set_ylim(-0.1, 40)

    axes.set_title('Nucleotide sequences to amino acid sequence', size="xx-large")
    iseqlib.editSpine( axes )
    axes.set_xlabel("Number of nucleotide sequences", size='x-large')
    #axes.set_ylabel("Number of amino acid sequences", size='x-large')
    axes.set_ylabel("Percentage of amino acid sequences", size='x-large')
    legend = axes.legend( lines, labels, numpoints=1, loc='best', ncol=1)
    legend.__drawFrame = False
    axes.yaxis.grid(b=True, color="#BDBDBD", linestyle='-', linewidth=0.005)
    axes.xaxis.grid(b=True, color="#BDBDBD", linestyle='-', linewidth=0.005)
Esempio n. 3
0
def drawOverlapReadsData(axes, exps, sample, sampleOrder):
    if len( exps ) <= 0:
        return
    if sampleOrder:
        exps = sortByOrder(exps, sampleOrder)
    else:
        exps = sorted( exps, key = lambda exp: (exp.exp, exp.size) )

    colors = iseqlib.getColors6()
    lightcolors = iseqlib.getColors6light()
    markers = ['o', '*', 's', 'd', '^', 'p', 'v']
    textsize = 'large'
    lines = []
    expnames = []
   
    cutoffs = exps[0].cutoffs
    xticklabels = [ str(c) for c in cutoffs ]
    xdata = cutoffs
    for i, x in enumerate(xdata):
        if x == 0 and i < len(xdata) - 1:
            xdata[i] = xdata[i + 1]/10.0

    prevexp = ''
    colorIndex = 0
    markerIndex = -1
    axes.set_xscale('log')
    #axes.set_yscale('log')

    maxy = 0
    miny = 'inf'
    for exp in exps:
        expnames.append( exp.name )
        ydata, stddata = getStats(exp, sample)

        maxy = max( [max(ydata), maxy] )
        miny = min( [min(ydata), miny] )
        if prevexp != '' and prevexp != exp.exp:
            colorIndex += 1
            markerIndex = 0
        else:
            markerIndex += 1
        prevexp = exp.exp
        markersize = 12.0
        if markers[markerIndex] == '*':
            markersize += 2.0
        elif markers[markerIndex] == 's':
            markersize -= 2.0

        l = axes.plot(xdata, ydata, color=colors[colorIndex], marker=markers[markerIndex], markeredgecolor=colors[colorIndex], markersize=markersize, linestyle='none')
        axes.plot( xdata, ydata, color=lightcolors[colorIndex], linestyle='-', linewidth=0.2 )
        lines.append(l)
        
    axes.set_title('Percentage of Reads in Overlapped Clones', size='xx-large') 
    axes.set_xlabel('Minimum clone size (percentage of total reads)', size=textsize)
    axes.set_ylabel('Percentage of reads overlapped', size=textsize)
    axes.xaxis.set_ticklabels( xticklabels )
    axes.xaxis.set_ticks( xdata )
    minx = min(xdata)
    maxx = max(xdata)
    axes.set_xlim( 7*minx/10, maxx*1.5 )

    #axes.set_ylim(-2, 102 )
    axes.set_ylim(-0.5, 8 )
    axes.yaxis.grid(b=True, color="#CCCCCC", linestyle='-', linewidth=0.005)
    axes.xaxis.grid(b=True, color="#CCCCCC", linestyle='-', linewidth=0.005)
    legend = axes.legend( lines, expnames , numpoints=1, loc='best', ncol=1)
    legend._drawFrame = False