from trnlib.omeORM import *
from pandas import *
from numpy import array
from sqlalchemy import func
from IPython.core.display import HTML
ome = Session()
diff_exp = read_table('Fnr_diff_expression.txt', index_col='bnum')
diff_exp.ix[diff_exp['current'] == '+']
<class 'pandas.core.frame.DataFrame'> Index: 153 entries, b0022 to b4515 Data columns (total 5 columns): operon 153 non-null values DE 153 non-null values current 153 non-null values previous 153 non-null values RNAseq 153 non-null values dtypes: object(5)
HTML(diff_exp.ix[diff_exp['RNAseq'] == '+'].to_html())
operon | DE | current | previous | RNAseq | |
---|---|---|---|---|---|
bnum | |||||
b0034 | caiF | Activated | - | - | + |
b0621 | dcuC | Activated | - | - | + |
b0836 | bssR | Activated | + | + | + |
b0848 | ybjM | Activated | - | - | + |
b0894 | dmsABC | Activated | + | + | + |
b0929 | ompF | Activated | + | - | + |
b1223 | narK | Activated | + | - | + |
b1224 | narGHJI | Activated | + | - | + |
b1541 | ydfZ | Activated | + | + | + |
b1542 | ydfI | Activated | - | - | + |
b1587 | ynfEFGH-dmsD | Activated | + | + | + |
b1593 | ynfK | Activated | + | - | + |
b1674 | ydhYVWXUT | Activated | + | + | + |
b1750 | ydjXYZ-ynjABCD | Activated | + | + | + |
b1757 | ynjE | Activated | + | + | + |
b1854 | pykA | Activated | + | - | + |
b2298 | yfcC | Activated | - | - | + |
b2498 | upp-uraA | Activated | + | + | + |
b2579 | yfiD | Activated | + | + | + |
b2957 | ansB | Activated | + | - | + |
b3153 | yhbO | Activated | - | - | + |
b3158 | yhbUV | Activated | + | - | + |
b3211 | yhcC | Activated | - | - | + |
b3365 | nirBDC-cysG | Activated | + | + | + |
b3409 | feoB | Activated | + | - | + |
b3476 | nikABCDER | Activated | + | + | + |
b3947 | ptsA-fsaB-gldA | Activated | + | + | + |
b4021 | pepE | Activated | + | - | + |
b4070 | nrfABCDEFG | Activated | - | + | + |
b4115 | adiC | Activated | + | - | + |
b4123 | dcuB-fumB | Activated | + | - | + |
b4154 | frdABCD | Activated | + | + | + |
b4335 | yjiML | Activated | + | + | + |
b4379 | yjjW | Activated | - | - | + |
b4380 | yjjI | Activated | + | - | + |
b0031 | dapB | Repressed | + | - | + |
b0113 | pdhR-aceEF-lpdA | Repressed | - | - | + |
b0118 | acnB | Repressed | + | - | + |
b0124 | gcd | Repressed | - | - | + |
b0304 | ykgC | Repressed | - | - | + |
b0382 | iraP | Repressed | + | + | + |
b0432 | cyoABCDE | Repressed | + | + | + |
b0450 | glnK-amtB | Repressed | + | - | + |
b0453 | ybaY | Repressed | - | - | + |
b0608 | ybdR | Repressed | - | - | + |
b0655 | gltIJKL-sroC | Repressed | + | + | + |
b0720 | gltA | Repressed | + | + | + |
b0721 | sdhCDAB-sucABCD | Repressed | + | + | + |
b0733 | cydAB | Repressed | + | + | + |
b0735 | ybgE | Repressed | + | + | + |
b0753 | ybgS | Repressed | - | - | + |
b0755 | gpmA | Repressed | + | + | + |
b0802 | ybiJ | Repressed | + | - | + |
b0811 | glnHPQ | Repressed | + | - | + |
b0854 | potFGHI | Repressed | + | + | + |
b0887 | cydDC | Repressed | + | - | + |
b0897 | ycaC | Repressed | + | + | + |
b0953 | rmf | Repressed | + | - | + |
b0970 | yccA | Repressed | - | + | + |
b1014 | putA | Repressed | + | + | + |
b1040 | csgDEFG | Repressed | + | + | + |
b1057 | yceJI | Repressed | - | + | + |
b1109 | ndh | Repressed | + | - | + |
b1110 | ycfJ | Repressed | - | - | + |
b1164 | ycgZ-ymgA-ariR-ymgC | Repressed | - | - | + |
b1188 | ycgB | Repressed | + | + | + |
b1189 | dadAX | Repressed | + | - | + |
b1216 | chaA | Repressed | + | + | + |
b1259 | yciGFE | Repressed | - | + | + |
b1276 | acnA | Repressed | + | - | + |
b1283 | osmB | Repressed | + | - | + |
b1324 | tpx | Repressed | - | - | + |
b1332 | ynaJ | Repressed | - | - | + |
b1334 | fnr | Repressed | + | + | + |
b1415 | aldA | Repressed | - | - | + |
b1418 | cybB | Repressed | - | - | + |
b1440 | ydcSTUV | Repressed | - | - | + |
b1469 | narU | Repressed | + | - | + |
b1478 | adhP | Repressed | + | - | + |
b1481 | bdm-sra | Repressed | - | + | + |
b1482 | osmC | Repressed | + | - | + |
b1536 | ydeI | Repressed | - | - | + |
b1612 | fumA | Repressed | + | - | + |
b1656 | sodB | Repressed | + | + | + |
b1732 | katE | Repressed | + | - | + |
b1777 | yeaC | Repressed | - | + | + |
b1778 | msrB | Repressed | + | - | + |
b1783 | yeaGH | Repressed | + | + | + |
b1836 | yebV | Repressed | - | - | + |
b1841 | yobA-yebZY | Repressed | + | + | + |
b1847 | yebF | Repressed | - | - | + |
b1897 | otsBA | Repressed | + | + | + |
b1905 | ftnA | Repressed | - | + | + |
b1967 | hchA | Repressed | + | + | + |
b1988 | nac | Repressed | + | - | + |
b2000 | flu | Repressed | + | - | + |
b2001 | yeeRSTUVW | Repressed | + | - | + |
b2097 | fbaB | Repressed | - | + | + |
b2133 | dld | Repressed | + | + | + |
b2153 | folE-yeiB | Repressed | + | - | + |
b2209 | eco | Repressed | + | - | + |
b2210 | mqo | Repressed | - | - | + |
b2234 | nrdAB-yfaE | Repressed | + | + | + |
b2236 | yfaE | Repressed | + | + | + |
b2303 | folX-yfcH | Repressed | + | + | + |
b2310 | argT-hisJQMP | Repressed | + | + | + |
b2464 | talA-tktB | Repressed | + | + | + |
b2552 | hmp | Repressed | + | - | + |
b2587 | kgtP | Repressed | - | - | + |
b2665 | ygaU | Repressed | + | - | + |
b2670 | ygaW | Repressed | - | - | + |
b2702 | srlAEBD-gutM-srlR-gutQ | Repressed | - | + | + |
b2741 | rpoS | Repressed | + | + | + |
b2809 | ygdI | Repressed | - | - | + |
b2936 | yggG | Repressed | + | - | + |
b3002 | yqhA | Repressed | - | - | + |
b3003 | yghA | Repressed | - | - | + |
b3073 | ygjG | Repressed | + | - | + |
b3160 | yhbW | Repressed | + | + | + |
b3236 | mdh | Repressed | + | + | + |
b3267 | yhdV | Repressed | - | - | + |
b3528 | dctA | Repressed | + | - | + |
b3555 | yiaG | Repressed | - | + | + |
b3615 | yibD | Repressed | + | + | + |
b3617 | kbl-tdh | Repressed | - | - | + |
b3830 | ysgA | Repressed | + | - | + |
b3870 | glnALG | Repressed | + | - | + |
b3894 | fdoGHI-fdhE | Repressed | - | - | + |
b3995 | rsd | Repressed | + | - | + |
b4014 | aceBAK | Repressed | + | + | + |
b4023 | pagB | Repressed | - | - | + |
b4024 | lysC | Repressed | + | - | + |
b4217 | ytfK | Repressed | - | - | + |
b4376 | osmY | Repressed | + | + | + |
unmapped = {
'b0873':{'tu':'hcp-hcr', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1111':{'tu':'ycfQ', 'mistake':False, 'reason': 'not diff expressed'},\
'b1223':{'tu':'narK', 'mistake':False, 'reason': 'potentially mapping, falls just above .05 cutoff'},\
'b1750':{'tu':'ydjXYZ-ynjABCD', 'mistake':False, 'reason': 'potentially mapping, have ynjE but none of the rest'},\
'b1825':{'tu':'yebO', 'mistake':False, 'reason': 'potentially mapping, have mgrB just upstream'},\
'b3409':{'tu':'feoB', 'mistake':False, 'reason': 'just above cutoff for feoA and feoC'},\
'b4335':{'tu':'yijML', 'mistake':False, 'reason': 'potentially mapping, have yjiN just upstream'},\
'b0031':{'tu':'dapB', 'mistake':False, 'reason': 'not significant'},\
'b0080':{'tu':'fruR', 'mistake':False, 'reason': 'not significant'},\
'b0123':{'tu':'cueO', 'mistake':False, 'reason': 'not significant'},\
'b0369':{'tu':'hemB', 'mistake':False, 'reason': 'not significant'},\
'b0759':{'tu':'galETKM', 'mistake':False, 'reason': 'not significant'},\
'b1014':{'tu':'putA', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1164':{'tu':'ycgZ-ymgA-ariR-ymgC', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1195':{'tu':'ymgE', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1216':{'tu':'chaA', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1256':{'tu':'ompW', 'mistake':False, 'reason': 'not significant'},\
'b1276':{'tu':'acnA', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1415':{'tu':'aldA', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1418':{'tu':'cybB', 'mistake':False, 'reason': 'just above cutoff'},\
'b1612':{'tu':'fumA', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1611':{'tu':'fumC', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b1654':{'tu':'grxD', 'mistake':False, 'reason': 'not significant'},\
'b1656':{'tu':'sodB', 'mistake':False, 'reason': 'not significant'},\
'b1817':{'tu':'manXYZ', 'mistake':False, 'reason': 'not significant'},\
'b1905':{'tu':'ftnA', 'mistake':False, 'reason': 'not significant'},\
'b2001':{'tu':'yeeRSTUVW', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b2210':{'tu':'mqo', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b2215':{'tu':'ompC', 'mistake':False, 'reason': 'not significant'},\
'b2552':{'tu':'hmp', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b2924':{'tu':'mscS', 'mistake':False, 'reason': 'just above cutoff'},\
'b3001':{'tu':'yghZ', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'},\
'b3002':{'tu':'yqhA', 'mistake':False, 'reason': 'just above cutoff'},\
'b3347':{'tu':'fkpA', 'mistake':False, 'reason': 'not significant'},\
'b3528':{'tu':'dctA', 'mistake':False, 'reason': 'just above cutoff'},\
'b3712':{'tu':'yieEF', 'mistake':False, 'reason': 'not significant'},\
'b3744':{'tu':'asnA', 'mistake':False, 'reason': 'not significant'},\
'b4410':{'tu':'ecnAB', 'mistake':False, 'reason': 'not differentially analyzed, too noisy?'}
}
len(unmapped.keys())
38
ome.query(AllAnalysis).filter_by(bnum='b4410').all()
[AllAnalysis (fdr: 0.085685, fold change -0.246667): for Gene: ecnA (b4410) Strain: delta-cra-->wt on Condition: C:glucose, N:NH4Cl, e:anaerobic, AllAnalysis (fdr: 0.212821, fold change 0.510000): for Gene: ecnA (b4410) Strain: delta-cra-->wt on Condition: C:glucose, N:NH4Cl, e:O2, AllAnalysis (fdr: 0.411027, fold change -0.030000): for Gene: ecnA (b4410) Strain: delta-cra on Condition: C:glucose, N:NH4Cl, e:O2-->anaerobic, AllAnalysis (fdr: 0.032034, fold change 0.550000): for Gene: ecnA (b4410) Strain: wt-->delta-fnr on Condition: C:glucose, N:NH4Cl, e:NO3, AllAnalysis (fdr: 0.162263, fold change 0.103333): for Gene: ecnA (b4410) Strain: wt-->delta-arcA on Condition: C:glucose, N:NH4Cl, e:NO3, AllAnalysis (fdr: 0.214036, fold change -0.166667): for Gene: ecnA (b4410) Strain: wt on Condition: C:glucose, N:NH4Cl, e:NO3-->anaerobic, AllAnalysis (fdr: 0.117930, fold change -0.620000): for Gene: ecnA (b4410) Strain: wt on Condition: C:glucose, N:NH4Cl, e:O2-->NO3, AllAnalysis (fdr: 0.073150, fold change -0.786667): for Gene: ecnA (b4410) Strain: wt on Condition: C:glucose, N:NH4Cl, e:O2-->anaerobic]
aa = AllAnalysis
ome.query(aa.bnum).filter(and_(or_(aa.target1 == 'delta-fnr', aa.target2 == 'delta-fnr'),\
or_(aa.target1 == 'wt', aa.target2 == 'wt'), aa.fdr < .05, func.abs(aa.fold_change) > 1,\
aa.eacceptor1 == 'NO3', aa.eacceptor2 == 'NO3')).group_by(aa.bnum).count()
469L
aa = AllTUAnalysis
i = 0
for bnum in diff_exp.index:
if bnum in unmapped.keys(): continue
gene = ome.query(Gene).filter_by(bnum=bnum).one()
tu = gene.TU[0]
tu_bnums = [g.bnum for g in tu.genes]
some_regulation = False
for tu_bnum in tu_bnums:
if ome.query(aa).filter(and_(or_(aa.target1 == 'delta-fnr', aa.target2 == 'delta-fnr'),\
or_(aa.target1 == 'wt', aa.target2 == 'wt'), aa.fdr < .05, aa.bnum == tu_bnum,\
aa.eacceptor1 == 'anaerobic', aa.eacceptor2 == 'anaerobic')).all():
some_regulation = True
if not some_regulation:
i+=1
exp_val = array([x.value for x in ome.query(ExpressionData).filter_by(bnum=bnum).all()]).mean()
print str(i)+'\t'+bnum+'\t'+str(diff_exp['operon'].ix[bnum])+'\t'+str(exp_val)+'\t'+tu_bnum
1 b0334 prpDCDE 2.22838235294 b0335 2 b0848 ybjM 3.95823529412 b0848 3 b1044 ymdA 2.95058823529 b1044 4 b1350 recET-lar-ydaCQ-intR 2.27367647059 b1350 5 b1371 lomR_2-stfR-tfaR 2.33705882353 b1373 6 b1407 ydbD 2.48132352941 b1407 7 b1542 ydfI 2.73063829787 b1542 8 b1880 flhBAE 2.95588235294 b1880 9 b1904 yecR 2.5075 b1904 10 b1937 fliE 3.13735294118 b1937 11 b2240 glpTQ 2.23455882353 b2240 12 b2241 glpABC 2.25 b2243 13 b2298 yfcC 3.62073529412 b2298 14 b2444 yffMN 2.23029411765 b2445 15 b2578 yfiK 2.46205882353 b2578 16 b2760 casABCDE12 2.23455882353 b2760 17 b2775 yqcE-ygcE 2.22838235294 b2776 18 b2888 ygfU 2.22838235294 b2888 19 b3211 yhcC 2.25127659574 b3211 20 b3944 yijF 2.54632352941 b3944 21 b4115 adiC 2.2685106383 b4115 22 b4128 yjdKO 3.54529411765 b4559 23 b4479 dgoRKADT nan b4479 24 b4528 rzoR nan b4528 25 b1309 ycjMNOPQRSTUV-ymjB 2.22941176471 b4524 26 b1440 ydcSTUV 2.92470588235 b1443 27 b1444 ydcW 3.85955882353 b1444 28 b1469 narU 3.77102941176 b1469 29 b1505 ydeTSR 2.22838235294 b1505 30 b2028 ugd 3.58073529412 b2028 31 b2252 ais 2.46235294118 b2252 32 b2702 srlAEBD-gutM-srlR-gutQ 2.56632352941 b2708 33 b3267 yhdV 3.56088235294 b3267 34 b3351 kefGB-yheV 3.89397058824 b3351 35 b3615 yibD 2.25 b3615 36 b3846 fadBA 3.48191176471 b3846 37 b4515 ybgT nan b4515