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 [12]:
#test and append if AD shows significant regulation (D29E + pCPP45::avrPto I96A,2xA). Append ratios of DE ('PTI'), AE (AvrPto
#suppressed 'PTI').
#pad-> pvalue AD
#rad-> ratio AD
#rde-> ratio DE
#d-> RPKM D_mean
#a-> RPKM A_mean
#DE, AE -> list of induction values for specified samples when logic test is true
#BCE -> a combination of the two domains separately. Adds the differences between the two domains and the
#PTI-induced transcriptome. This finds the difference between the values and the PTI-induced transrciptome ('rde'),
#which is what was found when the domains were used in Fig. 5A.

AE = []
DE = []
BCE = []
TEST = []
for i in range (1,n):
    pde= X1.cell_value(rowx=i, colx=21)
    rae= X1.cell_value(rowx=i, colx=16)
    rde= X1.cell_value(rowx=i, colx=20)
    rbe= X1.cell_value(rowx=i, colx=28)
    rce= X1.cell_value(rowx=i, colx=32)
    d= X1.cell_value(rowx=i, colx=2)
    e= X1.cell_value(rowx=i, colx=18) 
    if (pde<=0.05 and (d>=3 or e>=3) and (rde<=.5 or rde>=2)):
        BCE.append(2**(np.log2(rde)-((np.log2(rde)-np.log2(rbe))+(np.log2(rde)-np.log2(rce)))))
        AE.append(rae)
        DE.append(rde)
        TEST.append(rbe*rce)

In [13]:
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)
BCE = plt.scatter(DE, BCE, s=1, alpha=1, color='b', 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, BCE),('CD$^{-}$/CTD$^{-}$', 'WT AvrPto', 'CD x CTD'),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('Domain-potential Suppression of PTI vs Mock.png',bbox_inches='tight',dpi=300)
plt.show()



In [9]:
#Finds numbers where the multiplied domains' value is greater or less than 1 if the mock value for that is up or down
#regulated. Shows the same test performed on the WT.

greater = []
less= []
greaterae= []
lessae= []

for i in range(0,len(BCE)):
    if (DE[i]<=0.5):
        if (BCE[i]>=1):
            greater.append(BCE[i])
        if (BCE[i]<1):
            less.append(BCE[i])
    if (DE[i]<=0.5 and AE[i]>=1):
        greaterae.append(AE[i])
    if (DE[i]<=0.5 and AE[i]<1):
        lessae.append(AE[i])
print "Number where ABC is greater than or equal to 1:", len(greater)
print "Number where ABC is less than 1:", len(less)
print "same test for AE greater or equal to 1:", len(greaterae), ", less:", len(lessae)
print len(greater) + len(less)


Number where ABC is greater than or equal to 1: 572
Number where ABC is less than 1: 2246
same test for AE greater or equal to 1: 29 , less: 2789
2818

In [7]:



<matplotlib.collections.PathCollection object at 0x0CAF4930>

In [ ]: