#!/usr/bin/env python # coding: utf-8 # # Intersect bed on gene-centric features # In[3]: get_ipython().system('date') # In[33]: get_ipython().run_line_magic('pylab', 'inline') import scipy.stats as stats # Feature (from nb -03) # # **tldr** 4 "new" tracks # IGV_and_Directory_Listing_of__halfshell_2015-02-hs-bedgraph__1AA51F1B.png # ``` # /Users/sr320/data-genomic/tentacle/Cuffdiff_geneexp.sig.gtf # /Users/sr320/data-genomic/tentacle/rebuilt.gtf # /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-housekeeping.gff # /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-env-response.gff # ``` # # DEGs # `-wb Write the original entry in B for each overlap. Useful for knowing what A overlaps. Restricted by -f and -r.` # In[6]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.2M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cuffdiff_geneexp.sig.gtf | cut -f 6 | sort | uniq -c') # In[7]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.4M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cuffdiff_geneexp.sig.gtf | cut -f 6 | sort | uniq -c') # In[8]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.6M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cuffdiff_geneexp.sig.gtf | cut -f 6 | sort | uniq -c') # In[10]: get_ipython().system('intersectbed -wb -a /Users/sr320/git-repos/paper-Temp-stress/ipynb/data/array-design/OID40453_probe_locations.gff -b /Users/sr320/data-genomic/tentacle/Cuffdiff_geneexp.sig.gtf | cut -f 11 | sort | uniq -c') # In[34]: # Enter the data comparing Oyster 2 then Probes obs = array([[880, 10028], [117460, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[37]: # Enter the data comparing Oyster 4 then Probes obs = array([[704, 10148], [117460, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[38]: # Enter the data comparing Oyster 6 then Probes obs = array([[632, 11690], [117460, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # # Rebuilt (new gtf based on RNAseq data) # In[15]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.2M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/rebuilt.gtf | cut -f 6 | sort | uniq -c') # In[16]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.4M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/rebuilt.gtf | cut -f 6 | sort | uniq -c') # In[17]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.6M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/rebuilt.gtf | cut -f 6 | sort | uniq -c') # In[18]: get_ipython().system('intersectbed -wb -a /Users/sr320/git-repos/paper-Temp-stress/ipynb/data/array-design/OID40453_probe_locations.gff -b /Users/sr320/data-genomic/tentacle/rebuilt.gtf | cut -f 11 | sort | uniq -c') # In[39]: # Enter the data comparing Oyster 2 then Probes obs = array([[8768, 10028], [1197818, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[40]: # Enter the data comparing Oyster 4 then Probes obs = array([[7694, 10148], [1197818, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[41]: # Enter the data comparing Oyster 6 then Probes obs = array([[6160, 11690], [1197818, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # # Housekeeping Genes # In[23]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.2M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-housekeeping.gff | cut -f 6 | sort | uniq -c') # In[24]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.4M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-housekeeping.gff | cut -f 6 | sort | uniq -c') # In[25]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.6M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-housekeeping.gff | cut -f 6 | sort | uniq -c') # In[26]: get_ipython().system('intersectbed -wb -a /Users/sr320/git-repos/paper-Temp-stress/ipynb/data/array-design/OID40453_probe_locations.gff -b /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-housekeeping.gff | cut -f 11 | sort | uniq -c') # In[42]: # Enter the data comparing Oyster 2 then Probes obs = array([[3210, 10028], [251970, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[43]: # Enter the data comparing Oyster 4 then Probes obs = array([[3369, 10148], [251970, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[47]: # Enter the data comparing Oyster 6 then Probes obs = array([[3819, 11690], [251970, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[ ]: # In[ ]: # # Environmental Response Genes # In[29]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.2M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-env-response.gff | cut -f 6 | sort | uniq -c') # In[30]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.4M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-env-response.gff | cut -f 6 | sort | uniq -c') # In[31]: get_ipython().system('intersectbed -wb -a ./data/2014.07.02.colson/genomeBrowserTracks/logFC_HS-preHS/2014.07.02.6M_sig.bedGraph -b /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-env-response.gff | cut -f 6 | sort | uniq -c') # In[27]: get_ipython().system('intersectbed -wb -a /Users/sr320/git-repos/paper-Temp-stress/ipynb/data/array-design/OID40453_probe_locations.gff -b /Users/sr320/data-genomic/tentacle/Cgigas_v9_gene-env-response.gff | cut -f 11 | sort | uniq -c') # In[45]: # Enter the data comparing Oyster 2 then Probes obs = array([[2809, 10028], [190475, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[48]: # Enter the data comparing Oyster 4 then Probes obs = array([[2738, 10148], [190475, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[49]: # Enter the data comparing Oyster 6 then Probes obs = array([[3216, 11690], [190475, 697753]]) # Calculate the chi-square test chi2_corrected = stats.chi2_contingency(obs, correction=True) chi2_uncorrected = stats.chi2_contingency(obs, correction=False) # Print the result print('CHI SQUARE') print('The corrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_corrected[0], chi2_corrected[1])) print('The uncorrected chi2 value is {0:5.3f}, with p={1:5.3f}'.format(chi2_uncorrected[0], chi2_uncorrected[1])) # In[ ]: