In [1]:
#import library
import numpy as np
%matplotlib inline
import scipy.stats as stats
import xlrd as xl

In [2]:
#Load book, define sheet as X1, print the number of rows, set n to number of rows
#of sheet 1 column 1, numbers is column,row format.  List is X1a, creates array z.
X = xl.open_workbook('avpfloat.xlsx')
X1 = X.sheet_by_name('NoFormulas')

In [3]:
#id test, should be 34730 x 36
m =X1.ncols
n =X1.nrows
print 'cols',m,'rows',n


cols 36 rows 34730

In [5]:
#test and append if DE shows significant regulation (D29E + pCPP45::avrPto I96A,2xA). Append ratios of DE ('PTI'), AE (AvrPto
#suppressed 'PTI').
#pde-> pvalue DE
#rde-> ratio DE
#rae-> ratio AE
#d-> RPKM D_mean
#e-> RPKM E_mean
#DE-> list of DE induction values when logic test is true
#AE-> list of AE induction values when logic test is true

DE = []
AE = []
for i in range (1,n):
    pde= X1.cell_value(rowx=i, colx=21)
    rde= X1.cell_value(rowx=i, colx=20)
    rae= X1.cell_value(rowx=i, colx=16)
    e= X1.cell_value(rowx=i, colx=18)
    d= X1.cell_value(rowx=i, colx=19)
    if (pde<=0.05 and (rde>=2 or rde<=0.5) and (d>=3 or e>=3)):
        DE.append(rde)
        AE.append(rae)

In [6]:
import matplotlib.pyplot as plt
#Scatter plot generation
D29E = plt.scatter(DE, DE, s=1, alpha=1, color='k', linewidth=None)
AvrPto = plt.scatter(DE, AE, s=1, alpha=1, color='r', linewidth=None)

#Logarithmic scales with grid
plt.xscale('log', basex=2)
plt.yscale('log', basey=2)
plt.grid(True)

#Font size
font = {'family' : 'Arial','weight' : 'normal','size'   :  14}

plt.rc('font', **font)

axis_font = {'fontname':'Serif', 'size':'14', 'weight':'bold'}
title_font = {'fontname': 'Serif', 'size':'16', 'weight':'bold'}

#set x-axis ticks
xtck = [0.015625, 0.03125, .0625, .125, .25, .5, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]
xlbl = ['1/64', '1/32', '1/16', '1/8', '1/4', '1/2', '1', '2', '4', '8', '16', '32', '64', '128', '256', '512', '1024', '2048', '4096']
plt.xticks(xtck,xlbl,y=-0.02,rotation=270)

#set y-axis ticks
ytck= [0.015625, 0.03125, .0625, .125, .25, .5, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]
ylbl= ['1/64', '1/32', '1/16', '1/8', '1/4', '1/2', '1', '2', '4', '8', '16', '32', '64', '128', '256', '512', '1024', '2048', '4096']
plt.yticks(ytck,ylbl, x=-0.02)

#Axis labels

plt.ylabel('Sample RPKM / mock RPKM', **axis_font)
plt.xlabel('CD$^{-}$/CTD$^{-}$ RPKM / mock RPKM', **axis_font)

#Reference lines
plt.axhline(y=1, color='k')
plt.axvline(x=1, color='k')

#Legend
plt.legend((D29E, AvrPto),('CD$^{-}$/CTD$^{-}$', 'WT AvrPto'),scatterpoints=1,markerscale=4,loc='upper left',ncol=1,fontsize=14)

#Plot size and settings
fig = plt.gcf()
fig.set_size_inches(8,8)
fig.set_dpi(300)
plt.tight_layout()
fig.savefig('AvrPto Suppression of PTI vs Mock.png',bbox_inches='tight',dpi=300)
plt.show()



In [6]: