def plotPair2(oValues, aValues, tStart, tEnd, oTcc, aTcc, oSeq, dSeq, misPositions):
        #everything should be set up like the alignment...oRNA is 5 to 3'

        maxO = max(oValues[tStart:tEnd + 1]) # might want to change to max only within the small range
        maxA = max(aValues)
      
        oValues = [(float(x)/maxO) * 20 for x in oValues]
        aValues = [(float(x)/maxA) * 50 for x in aValues]
     
     
        fig = plt.figure()
        ax1 = fig.add_subplot(111)
      
        #plot the small NTs
        smallNT = [oValues[x] if tStart <= x <= tEnd else -10 for x in range(len(oValues))]
        ax1.plot(smallNT, 'bo', markersize = 9)
        
        #plot the small expression line + letters
        ax1.plot(oValues, 'b-')
        
        #plot small letters
        for i, val in enumerate(oValues):
                plt.text(i, val, oSeq[i])
      
        #small conservation
        phastScores = [1.0 for i in range(tStart, tEnd + 1)]
        phastScores[0] = 0.0
        for i, a in enumerate(range(tStart, tEnd + 1)):
                plt.text(a, 10 + 2*phastScores[i] - .4, '*')
                plt.text(a, 10, '--')
                plt.text(a, 12, '--')

        #plot sequence above
        plt.text(tStart - 1, 66, '5\'')
        plt.text(tEnd + 1, 66, '3\'')
        plt.text(tStart - 1, 68, '3\'')
        plt.text(tEnd + 1, 68, '5\'')
        print misPositions
        for i in range(tStart, tEnd + 1):
                plt.text(i, 66, oSeq[i], color = 'b')
                plt.text(i, 68, bioLibCG.compSeq(dSeq[i]), color = 'r')
                if i not in misPositions:
                        plt.axvline(x = i + .12, ymin = .96, ymax = .97, color='k')
                else:
                        plt.text(i, 67, 'x')

        ax1.set_ylim(0, 70)
        ax1.yaxis.set_major_locator(MaxNLocator(7))
        ax1.set_yticklabels( [str((float(x)/20) * maxO) for x in [0, 10, 20, 30, 40, 50, 60, 70]] )
        ax1.set_xlabel('nt of small/target')
        ax1.set_ylabel('Expression Level (origin RNA)')
        ax1.set_title('oRNA/Target Expression Pair')

        #plot deg line, letters
        ax2 = ax1.twinx()
        ax2.plot(aValues, 'r-')
        for i, val in enumerate(aValues):
                plt.text(i, val, dSeq[i])
        ax2.set_ylim(-30, 70)
        ax2.set_yticklabels( [str((float(x)/50) * maxA) for x in [-30,-20, -10, 0, 10, 20, 30, 40, 50, 60, 70]] )
        ax2.set_ylabel('Expression Level (target RNA)')
        ax2.yaxis.set_major_locator(MaxNLocator(10))
       
        #x axis stuff
        ax2.xaxis.set_major_locator(MaxNLocator(len(oValues) - 1))
        ax1.xaxis.set_major_locator(MaxNLocator(len(oValues) - 1))
        ax2.set_xlim(0, len(oValues))
        
        #expression boundaries
        cStart = tStart + 9 - 2
        cEnd = tStart + 10 + 2
        plt.axvline(x = cStart, color='g')
        plt.axvline(x = cEnd, color = 'g')
        plt.axvspan(cStart, cEnd, facecolor='g', alpha=.25)

        #info box
        plt.text(42, 60, 'tcc: %s' % oTcc, color = 'b')
        plt.text(42, 58, 'gene: %s' % 'None', color = 'b')
        plt.text(42, 56, 'context: %s' % 'None', color = 'b')
        plt.text(42, 54, 'type: %s' % 'None', color = 'b')

        plt.text(42, 50, 'tcc: %s' % aTcc, color = 'r')
        plt.text(42, 48, 'gene: %s' % 'None', color = 'r')
        plt.text(42, 46, 'context: %s' % 'None', color = 'r')
        plt.text(42, 44, 'type: %s' % 'None', color = 'r')
        
        plt.show()
Esempio n. 2
0
def plotPair2(oValues, aValues, tStart, tEnd, oTcc, aTcc, oSeq, dSeq,
              misPositions, oContext, aContext, imgName):
    #everything should be set up like the alignment...oRNA is 5 to 3'

    maxO = max(
        oValues[tStart:tEnd +
                1])  # might want to change to max only within the small range
    maxA = max(aValues)

    oValues = [(float(x) / maxO) * 20 for x in oValues]
    aValues = [(float(x) / maxA) * 50 for x in aValues]

    fig = plt.figure()
    ax1 = fig.add_subplot(111)

    #plot the small NTs
    smallNT = [
        oValues[x] if tStart <= x <= tEnd else -10 for x in range(len(oValues))
    ]
    ax1.plot(smallNT, 'ko', markersize=9)

    #plot the small expression line + letters
    ax1.plot(oValues, 'b-')

    #t is x, s is y ---> fill
    t = range(len(oValues))
    s = oValues
    ax1.fill_between(t, -10, s, color='b')

    #plot small letters
    for i, val in enumerate(oValues):
        plt.text(i, val, oSeq[i])

    #small conservation
    #phastScores = [1.0 for i in range(tStart, tEnd + 1)]
    #phastScores[0] = 0.0
    #for i, a in enumerate(range(tStart, tEnd + 1)):
    #plt.text(a, 10 + 2*phastScores[i] - .4, '*')
    #plt.text(a, 10, '--')
    #plt.text(a, 12, '--')

    #plot sequence above
    plt.text(tStart - 1, 66, '5\'')
    plt.text(tEnd + 1, 66, '3\'')
    plt.text(tStart - 1, 68, '3\'')
    plt.text(tEnd + 1, 68, '5\'')
    print misPositions
    for i in range(tStart, tEnd + 1):
        plt.text(i, 66, oSeq[i], color='b')
        plt.text(i, 68, bioLibCG.compSeq(dSeq[i]), color='r')
        if i not in misPositions:
            plt.axvline(x=i + .12, ymin=.96, ymax=.97, color='k')
        else:
            plt.text(i, 67, 'x')

    ax1.set_ylim(0, 70)
    ax1.yaxis.set_major_locator(MaxNLocator(7))
    ax1.set_yticklabels(
        [str((float(x) / 20) * maxO) for x in [0, 10, 20, 30, 40, 50, 60, 70]])
    ax1.set_xlabel('nt of small/target')
    ax1.set_ylabel('Expression Level (origin RNA)')
    ax1.set_title('oRNA/Target Expression Pair')

    #plot deg line, letters
    ax2 = ax1.twinx()
    dLine = ax2.plot(aValues, 'k-')

    #t is x, s is y ---> fill
    t = range(len(aValues))
    s = aValues
    ax2.fill_between(t, 0, s, color='r')

    for i, val in enumerate(aValues):
        plt.text(i, val, dSeq[i])
    ax2.set_ylim(-30, 70)
    ax2.set_yticklabels([
        str((float(x) / 50) * maxA)
        for x in [-30, -20, -10, 0, 10, 20, 30, 40, 50, 60, 70]
    ])
    ax2.set_ylabel('Expression Level (target RNA)')
    ax2.yaxis.set_major_locator(MaxNLocator(10))

    #x axis stuff
    ax2.xaxis.set_major_locator(MaxNLocator(len(oValues) - 1))
    ax1.xaxis.set_major_locator(MaxNLocator(len(oValues) - 1))
    ax2.set_xlim(0, len(oValues))

    #expression boundaries
    #cStart = tStart + 9 - 2
    #cEnd = tStart + 10 + 2
    #plt.axvline(x = cStart, color='g')
    #plt.axvline(x = cEnd, color = 'g')
    #plt.axvspan(cStart, cEnd, facecolor='g', alpha=.25)

    #info box
    #plt.text(42, 60, 'tcc: %s' % oTcc, color = 'b')
    #plt.text(42, 58, 'gene: %s' % 'None', color = 'b')
    #plt.text(42, 56, 'context: %s' % oContext, color = 'b')
    #plt.text(42, 54, 'type: %s' % 'None', color = 'b')

    #plt.text(42, 50, 'tcc: %s' % aTcc, color = 'r')
    #plt.text(42, 48, 'gene: %s' % 'None', color = 'r')
    #plt.text(42, 46, 'context: %s' % aContext, color = 'r')
    #plt.text(42, 44, 'type: %s' % 'None', color = 'r')

    #plt.savefig(imgName, dpi=300, bbox_inches='tight', pad_inches=.22)
    plt.show()
    plt.close('all')