<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="pandoc" /> <meta name="author" content="Briana Mittleman" /> <title>Peak To Gene Assignment</title> <script src="site_libs/jquery-1.11.3/jquery.min.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="site_libs/bootstrap-3.3.5/css/journal.min.css" rel="stylesheet" /> <script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script> <script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script> <script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script> <script src="site_libs/jqueryui-1.11.4/jquery-ui.min.js"></script> <link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" /> <script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script> <script src="site_libs/navigation-1.1/tabsets.js"></script> <link href="site_libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" /> <script src="site_libs/highlightjs-9.12.0/highlight.js"></script> <link href="site_libs/font-awesome-5.0.13/css/fa-svg-with-js.css" rel="stylesheet" /> <script src="site_libs/font-awesome-5.0.13/js/fontawesome-all.min.js"></script> <script src="site_libs/font-awesome-5.0.13/js/fa-v4-shims.min.js"></script> <style type="text/css">code{white-space: pre;}</style> <style type="text/css"> pre:not([class]) { background-color: white; } </style> <script type="text/javascript"> if (window.hljs) { hljs.configure({languages: []}); hljs.initHighlightingOnLoad(); if (document.readyState && document.readyState === "complete") { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } } </script> <style type="text/css"> h1 { font-size: 34px; } h1.title { font-size: 38px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; } h5 { font-size: 16px; } h6 { font-size: 12px; } .table th:not([align]) { text-align: left; } </style> </head> <body> <style type = "text/css"> .main-container { max-width: 940px; margin-left: auto; margin-right: auto; } code { color: inherit; background-color: rgba(0, 0, 0, 0.04); } img { max-width:100%; height: auto; } .tabbed-pane { padding-top: 12px; } .html-widget { margin-bottom: 20px; } button.code-folding-btn:focus { outline: none; } </style> <style type="text/css"> /* padding for bootstrap navbar */ body { padding-top: 51px; padding-bottom: 40px; } /* offset scroll position for anchor links (for fixed navbar) */ .section h1 { padding-top: 56px; margin-top: -56px; } .section h2 { padding-top: 56px; margin-top: -56px; } .section h3 { padding-top: 56px; margin-top: -56px; } .section h4 { padding-top: 56px; margin-top: -56px; } .section h5 { padding-top: 56px; margin-top: -56px; } .section h6 { padding-top: 56px; margin-top: -56px; } </style> <script> // manage active state of menu based on current page $(document).ready(function () { // active menu anchor href = window.location.pathname href = href.substr(href.lastIndexOf('/') + 1) if (href === "") href = "index.html"; var menuAnchor = $('a[href="' + href + '"]'); // mark it active menuAnchor.parent().addClass('active'); // if it's got a parent navbar menu mark it active as well menuAnchor.closest('li.dropdown').addClass('active'); }); </script> <div class="container-fluid main-container"> <!-- tabsets --> <script> $(document).ready(function () { window.buildTabsets("TOC"); }); </script> <!-- code folding --> <script> $(document).ready(function () { // move toc-ignore selectors from section div to header $('div.section.toc-ignore') .removeClass('toc-ignore') .children('h1,h2,h3,h4,h5').addClass('toc-ignore'); // establish options var options = { selectors: "h1,h2,h3", theme: "bootstrap3", context: '.toc-content', hashGenerator: function (text) { return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_').toLowerCase(); }, ignoreSelector: ".toc-ignore", scrollTo: 0 }; options.showAndHide = true; options.smoothScroll = true; // tocify var toc = $("#TOC").tocify(options).data("toc-tocify"); }); </script> <style type="text/css"> #TOC { margin: 25px 0px 20px 0px; } @media (max-width: 768px) { #TOC { position: relative; width: 100%; } } .toc-content { padding-left: 30px; padding-right: 40px; } div.main-container { max-width: 1200px; } div.tocify { width: 20%; max-width: 260px; max-height: 85%; } @media (min-width: 768px) and (max-width: 991px) { div.tocify { width: 25%; } } @media (max-width: 767px) { div.tocify { width: 100%; max-width: none; } } .tocify ul, .tocify li { line-height: 20px; } .tocify-subheader .tocify-item { font-size: 0.90em; padding-left: 25px; text-indent: 0; } .tocify .list-group-item { border-radius: 0px; } </style> <!-- setup 3col/9col grid for toc_float and main content --> <div class="row-fluid"> <div class="col-xs-12 col-sm-4 col-md-3"> <div id="TOC" class="tocify"> </div> </div> <div class="toc-content col-xs-12 col-sm-8 col-md-9"> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="index.html">Three Prime Sequencing in Human LCLs</a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li> <a href="index.html">Home</a> </li> <li> <a href="about.html">About</a> </li> <li> <a href="license.html">License</a> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li> <a href="https://github.com/brimittleman/threeprimeseq"> <span class="fa fa-github"></span> </a> </li> </ul> </div><!--/.nav-collapse --> </div><!--/.container --> </div><!--/.navbar --> <!-- Add a small amount of space between sections. --> <style type="text/css"> div.section { padding-top: 12px; } </style> <div class="fluid-row" id="header"> <h1 class="title toc-ignore">Peak To Gene Assignment</h1> <h4 class="author"><em>Briana Mittleman</em></h4> <h4 class="date"><em>9/26/2018</em></h4> </div> <p><strong>Last updated:</strong> 2018-12-05</p> <strong>workflowr checks:</strong> <small>(Click a bullet for more information)</small> <ul> <li> <p><details> <summary> <strong style="color:blue;">✔</strong> <strong>R Markdown file:</strong> up-to-date </summary></p> <p>Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.</p> </details> </li> <li> <p><details> <summary> <strong style="color:blue;">✔</strong> <strong>Environment:</strong> empty </summary></p> <p>Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.</p> </details> </li> <li> <p><details> <summary> <strong style="color:blue;">✔</strong> <strong>Seed:</strong> <code>set.seed(12345)</code> </summary></p> <p>The command <code>set.seed(12345)</code> was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.</p> </details> </li> <li> <p><details> <summary> <strong style="color:blue;">✔</strong> <strong>Session information:</strong> recorded </summary></p> <p>Great job! Recording the operating system, R version, and package versions is critical for reproducibility.</p> </details> </li> <li> <p><details> <summary> <strong style="color:blue;">✔</strong> <strong>Repository version:</strong> <a href="https://github.com/brimittleman/threeprimeseq/tree/e230640e18e2c841d3525567d36e24e94d21bdbb" target="_blank">e230640</a> </summary></p> Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated. <br><br> Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use <code>wflow_publish</code> or <code>wflow_git_commit</code>). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated: <pre><code> Ignored files: Ignored: .DS_Store Ignored: .Rhistory Ignored: .Rproj.user/ Ignored: data/.DS_Store Ignored: output/.DS_Store Untracked files: Untracked: KalistoAbundance18486.txt Untracked: analysis/DirectionapaQTL.Rmd Untracked: analysis/ncbiRefSeq_sm.sort.mRNA.bed Untracked: analysis/snake.config.notes.Rmd Untracked: analysis/verifyBAM.Rmd Untracked: data/18486.genecov.txt Untracked: data/APApeaksYL.total.inbrain.bed Untracked: data/ChromHmmOverlap/ Untracked: data/GM12878.chromHMM.bed Untracked: data/GM12878.chromHMM.txt Untracked: data/LocusZoom/ Untracked: data/NuclearApaQTLs.txt Untracked: data/PeakCounts/ Untracked: data/PeaksUsed/ Untracked: data/RNAkalisto/ Untracked: data/TotalApaQTLs.txt Untracked: data/Totalpeaks_filtered_clean.bed Untracked: data/YL-SP-18486-T-combined-genecov.txt Untracked: data/YL-SP-18486-T_S9_R1_001-genecov.txt Untracked: data/apaExamp/ Untracked: data/bedgraph_peaks/ Untracked: data/bin200.5.T.nuccov.bed Untracked: data/bin200.Anuccov.bed Untracked: data/bin200.nuccov.bed Untracked: data/clean_peaks/ Untracked: data/comb_map_stats.csv Untracked: data/comb_map_stats.xlsx Untracked: data/comb_map_stats_39ind.csv Untracked: data/combined_reads_mapped_three_prime_seq.csv Untracked: data/diff_iso_trans/ Untracked: data/ensemble_to_genename.txt Untracked: data/example_gene_peakQuant/ Untracked: data/explainProtVar/ Untracked: data/filtered_APApeaks_merged_allchrom_refseqTrans.closest2End.bed Untracked: data/filtered_APApeaks_merged_allchrom_refseqTrans.closest2End.noties.bed Untracked: data/first50lines_closest.txt Untracked: data/gencov.test.csv Untracked: data/gencov.test.txt Untracked: data/gencov_zero.test.csv Untracked: data/gencov_zero.test.txt Untracked: data/gene_cov/ Untracked: data/joined Untracked: data/leafcutter/ Untracked: data/merged_combined_YL-SP-threeprimeseq.bg Untracked: data/mol_overlap/ Untracked: data/mol_pheno/ Untracked: data/nom_QTL/ Untracked: data/nom_QTL_opp/ Untracked: data/nom_QTL_trans/ Untracked: data/nuc6up/ Untracked: data/other_qtls/ Untracked: data/pQTL_otherphen/ Untracked: data/peakPerRefSeqGene/ Untracked: data/perm_QTL/ Untracked: data/perm_QTL_opp/ Untracked: data/perm_QTL_trans/ Untracked: data/perm_QTL_trans_filt/ Untracked: data/reads_mapped_three_prime_seq.csv Untracked: data/smash.cov.results.bed Untracked: data/smash.cov.results.csv Untracked: data/smash.cov.results.txt Untracked: data/smash_testregion/ Untracked: data/ssFC200.cov.bed Untracked: data/temp.file1 Untracked: data/temp.file2 Untracked: data/temp.gencov.test.txt Untracked: data/temp.gencov_zero.test.txt Untracked: output/picard/ Untracked: output/plots/ Untracked: output/qual.fig2.pdf Unstaged changes: Modified: analysis/28ind.peak.explore.Rmd Modified: analysis/apaQTLoverlapGWAS.Rmd Modified: analysis/cleanupdtseq.internalpriming.Rmd Modified: analysis/coloc_apaQTLs_protQTLs.Rmd Modified: analysis/dif.iso.usage.leafcutter.Rmd Modified: analysis/diff_iso_pipeline.Rmd Modified: analysis/explainpQTLs.Rmd Modified: analysis/explore.filters.Rmd Modified: analysis/flash2mash.Rmd Modified: analysis/overlapMolQTL.Rmd Modified: analysis/overlap_qtls.Rmd Modified: analysis/peakOverlap_oppstrand.Rmd Modified: analysis/pheno.leaf.comb.Rmd Modified: analysis/swarmPlots_QTLs.Rmd Modified: analysis/test.max2.Rmd Modified: code/Snakefile </code></pre> Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes. </details> </li> </ul> <details> <summary> <small><strong>Expand here to see past versions:</strong></small> </summary> <ul> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> File </th> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> <th style="text-align:left;"> Message </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/e230640e18e2c841d3525567d36e24e94d21bdbb/analysis/PeakToGeneAssignment.Rmd" target="_blank">e230640</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-12-05 </td> <td style="text-align:left;"> add code to save relevant figures </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/a5b4cf677cb4da813fbf7aee2733afe7dccfb8d6/docs/PeakToGeneAssignment.html" target="_blank">a5b4cf6</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-29 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/afb0ce901919c79bb2117f5548f0e2839c70aba6/analysis/PeakToGeneAssignment.Rmd" target="_blank">afb0ce9</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-29 </td> <td style="text-align:left;"> change plot colors </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/b78e12e3e2624d10d3900764e74fe77980f919da/docs/PeakToGeneAssignment.html" target="_blank">b78e12e</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-24 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/2d5ac0891350d55eb99769b5b637569b0c951a44/analysis/PeakToGeneAssignment.Rmd" target="_blank">2d5ac08</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-24 </td> <td style="text-align:left;"> leafcutter effect size plots </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/73bc857cbab2fbd4dd6fecb0911a447d04abbe56/docs/PeakToGeneAssignment.html" target="_blank">73bc857</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-05 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/0d453347bbc9bd3309eba0affd114647f1ac1685/analysis/PeakToGeneAssignment.Rmd" target="_blank">0d45334</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-05 </td> <td style="text-align:left;"> new QTL assignment overlap </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/2a6cabdee9bcc7da5674b5d2105099041bc8e296/docs/PeakToGeneAssignment.html" target="_blank">2a6cabd</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-03 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/338174b88da54468d8f4d036ef0e72b943566068/analysis/PeakToGeneAssignment.Rmd" target="_blank">338174b</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-03 </td> <td style="text-align:left;"> qtl window around gene annoation </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/f40b3775cc5784389bbf5d617b14706785d3c287/docs/PeakToGeneAssignment.html" target="_blank">f40b377</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-30 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/b79486f495cc8790030ee3a17852076f86d33dbc/analysis/PeakToGeneAssignment.Rmd" target="_blank">b79486f</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-30 </td> <td style="text-align:left;"> diff iso code </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/51c8b9cd005d95720bccf5b5e0c52c2c60f23877/docs/PeakToGeneAssignment.html" target="_blank">51c8b9c</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-29 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/0f9bd6594285cfb2a99cfe2a3c2420c412b27ee2/analysis/PeakToGeneAssignment.Rmd" target="_blank">0f9bd65</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-29 </td> <td style="text-align:left;"> overlap total/nuc </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/607c71988ecd7ea931e4a800e0d190894d21dfe8/docs/PeakToGeneAssignment.html" target="_blank">607c719</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-29 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/f3779bc75e35b959e47c51dd4d6837c1b87ebcf8/analysis/PeakToGeneAssignment.Rmd" target="_blank">f3779bc</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-29 </td> <td style="text-align:left;"> evaluate number of qtls </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/1cd047d30de769397ea1af496056cff84d614d3f/docs/PeakToGeneAssignment.html" target="_blank">1cd047d</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-27 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/43c3f5bdf5e9049d9badc5394644f5beefb145d9/analysis/PeakToGeneAssignment.Rmd" target="_blank">43c3f5b</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-27 </td> <td style="text-align:left;"> nom and perm qtl </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/27a43dc8ec9a72661a87c54eb4232457e9d6e227/docs/PeakToGeneAssignment.html" target="_blank">27a43dc</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-27 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/22db068cabc5b049ca55d5e33c2775df849ec9ed/analysis/PeakToGeneAssignment.Rmd" target="_blank">22db068</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-27 </td> <td style="text-align:left;"> add filtering by peak score </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/1501499fc21e3a2b3e9fd22375a01acce970929d/docs/PeakToGeneAssignment.html" target="_blank">1501499</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-26 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/dd2b07d906fd854647d2704b2cb869f8992fd11c/analysis/PeakToGeneAssignment.Rmd" target="_blank">dd2b07d</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-26 </td> <td style="text-align:left;"> account for ties </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/149d033c96899a702b4c0a7320484cb980e3fb56/docs/PeakToGeneAssignment.html" target="_blank">149d033</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-26 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> html </td> <td style="text-align:left;"> <a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/aaed5fd02287453b28ab53c96adb5d51b5c385dd/docs/PeakToGeneAssignment.html" target="_blank">aaed5fd</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-26 </td> <td style="text-align:left;"> Build site. </td> </tr> <tr> <td style="text-align:left;"> Rmd </td> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/eda266ec447da55ce6a5e62e907e634cbc547a20/analysis/PeakToGeneAssignment.Rmd" target="_blank">eda266e</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-26 </td> <td style="text-align:left;"> test peak to gene transcript dist </td> </tr> </tbody> </table> </ul> <p></details></p> <hr /> <pre class="r"><code>library(tidyverse)</code></pre> <pre><code>── Attaching packages ───────────────────────────────────────────────────────── tidyverse 1.2.1 ──</code></pre> <pre><code>✔ ggplot2 3.0.0 ✔ purrr 0.2.5 ✔ tibble 1.4.2 ✔ dplyr 0.7.6 ✔ tidyr 0.8.1 ✔ stringr 1.3.1 ✔ readr 1.1.1 ✔ forcats 0.3.0</code></pre> <pre><code>── Conflicts ──────────────────────────────────────────────────────────── tidyverse_conflicts() ── ✖ dplyr::filter() masks stats::filter() ✖ dplyr::lag() masks stats::lag()</code></pre> <pre class="r"><code>library(workflowr)</code></pre> <pre><code>This is workflowr version 1.1.1 Run ?workflowr for help getting started</code></pre> <pre class="r"><code>library(cowplot)</code></pre> <pre><code> Attaching package: 'cowplot'</code></pre> <pre><code>The following object is masked from 'package:ggplot2': ggsave</code></pre> <pre class="r"><code>library(reshape2)</code></pre> <pre><code> Attaching package: 'reshape2'</code></pre> <pre><code>The following object is masked from 'package:tidyr': smiths</code></pre> <pre class="r"><code>library(VennDiagram)</code></pre> <pre><code>Loading required package: grid</code></pre> <pre><code>Loading required package: futile.logger</code></pre> <p>I will use this analysis to investigate further the best way to assign the peaks to a gene. Right now I am using</p> <div id="prepare-referece" class="section level2"> <h2>Prepare referece</h2> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=intGenes_combfilterPeaksOppStrand #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=intGenes_combfilterPeaksOppStrand.out #SBATCH --error=intGenes_combfilterPeaksOppStrand.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END module load Anaconda3 source activate three-prime-env bedtools intersect -wa -wb -sorted -S -a /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom.named.fixed.bed -b /project2/gilad/briana/genome_anotation_data/ncbiRefSeq_sm_noChr.sort.mRNA.bed > /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqGenes.OppStrand.bed</code></pre> <p>This results in peaks being mapped to multiple genes. I want to use a method where I look for the closest end of transcript to each peak then use that gene for the assignment. This would mean each peak is assigned to one gene.</p> <p>Create a python script to process the NCBI file. I want protien coding transcript ends with the associated gene names. Original file: ncbiRefSeq.txt</p> <ul> <li>Column 2 transcript name</li> <li>Column 13 gene name</li> <li>NM is protein coding</li> </ul> <p>EndOfProCodTrans.py</p> <pre class="bash"><code>def main(inF, outF): infile= open(inF, "r") fout = open(outF,'w') for line in infile: linelist=line.split() transcript=linelist[1] transcript_id=transcript.split("_")[0] if transcript_id=="NM": chr=linelist[2][3:] strand=linelist[3] gene= linelist[12] if strand == "+" : end = int(linelist[7]) end2= end - 1 fout.write("%s\t%d\t%d\t%s:%s\t.\t%s\n"%(chr, end2, end, transcript,gene, strand)) if strand == "-": end= int(linelist[4]) end2= end + 1 fout.write("%s\t%d\t%d\t%s:%s\t.\t%s\n"%(chr, end, end2, transcript,gene, strand)) if __name__ == "__main__": inF = "/project2/gilad/briana/genome_anotation_data/ncbiRefSeq.txt" outF= "/project2/gilad/briana/genome_anotation_data/ncbiRefSeq_endProtCodGenes.txt" main(inF, outF)</code></pre> </div> <div id="find-closest-gene-to-each-peak" class="section level2"> <h2>Find closest gene to each peak</h2> <p>bedtools closest</p> <p>-A peaks /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom.named.fixed.bed -B transcript file /project2/gilad/briana/genome_anotation_data/ncbiRefSeq_endProtCodGenes_sort.txt -S (opposite strand) -D b (give distance wrt to gene strand)</p> <pre class="bash"><code> #!/bin/bash #SBATCH --job-name=TransClosest2End #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=TransClosest2End.out #SBATCH --error=TransClosest2End.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END module load Anaconda3 source activate three-prime-env bedtools closest -S -D b -a /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom.named.fixed.bed -b /project2/gilad/briana/genome_anotation_data/ncbiRefSeq_endProtCodGenes_sort.txt > /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqTrans.closest2End.bed</code></pre> <p>I will take a look at this file in R then I will process the file in python.</p> <pre class="r"><code>names=c("PeakChr", "PeakStart", "PeakEnd", "PeakName","PeakScore", "PeakStrand", "GeneChr", "GeneStart", "GeneEnd", "Transcript", "GeneScore", "GeneStrand", "Distance" ) peak2transDist=read.table("../data/filtered_APApeaks_merged_allchrom_refseqTrans.closest2End.bed", col.names = names, stringsAsFactors = F, header=F)</code></pre> <pre class="r"><code>ggplot(peak2transDist, aes(x=abs(Distance)))+ geom_density() + scale_x_log10()</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 4362 rows containing non-finite values (stat_density).</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-6-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-6-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/27a43dc8ec9a72661a87c54eb4232457e9d6e227/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-6-1.png" target="_blank">27a43dc</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-27 </td> </tr> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/aaed5fd02287453b28ab53c96adb5d51b5c385dd/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-6-1.png" target="_blank">aaed5fd</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-26 </td> </tr> </tbody> </table> <p></details></p> <pre class="r"><code>peak2transDist0=peak2transDist %>% filter(Distance==0) nrow(peak2transDist0)</code></pre> <pre><code>[1] 4362</code></pre> <pre class="r"><code>peak2transDist200=peak2transDist %>% filter(abs(Distance)<200) nrow(peak2transDist200)</code></pre> <pre><code>[1] 23778</code></pre> <pre class="r"><code>summary(peak2transDist$Distance)</code></pre> <pre><code> Min. 1st Qu. Median Mean 3rd Qu. Max. -5523243 -57698 -12830 -23711 3373 5592124 </code></pre> <p>try adding the no ties flag -t first.</p> <pre class="r"><code>peak2transDist_noties=read.table("../data/filtered_APApeaks_merged_allchrom_refseqTrans.closest2End.noties.bed", col.names = names, stringsAsFactors = F, header=F) ggplot(peak2transDist_noties, aes(x=abs(Distance)))+ geom_density() + scale_x_log10()</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 2044 rows containing non-finite values (stat_density).</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-8-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-8-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/27a43dc8ec9a72661a87c54eb4232457e9d6e227/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-8-1.png" target="_blank">27a43dc</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-27 </td> </tr> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/1501499fc21e3a2b3e9fd22375a01acce970929d/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-8-1.png" target="_blank">1501499</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-26 </td> </tr> </tbody> </table> <p></details></p> <pre class="r"><code>peak2transDist0_noT=peak2transDist_noties%>% filter(Distance==0) nrow(peak2transDist0_noT)</code></pre> <pre><code>[1] 2044</code></pre> <pre class="r"><code>peak2transDist200_noT=peak2transDist_noties %>% filter(abs(Distance)<200) nrow(peak2transDist200_noT)</code></pre> <pre><code>[1] 10488</code></pre> <pre class="r"><code>summary(peak2transDist$Distance)</code></pre> <pre><code> Min. 1st Qu. Median Mean 3rd Qu. Max. -5523243 -57698 -12830 -23711 3373 5592124 </code></pre> <pre class="r"><code>ggplot(peak2transDist_noties, aes(x=abs(Distance)))+ geom_histogram(binwidth = .5) + scale_x_log10()</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 2044 rows containing non-finite values (stat_bin).</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-9-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-9-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/27a43dc8ec9a72661a87c54eb4232457e9d6e227/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-9-1.png" target="_blank">27a43dc</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-27 </td> </tr> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/1501499fc21e3a2b3e9fd22375a01acce970929d/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-9-1.png" target="_blank">1501499</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-26 </td> </tr> </tbody> </table> <p></details></p> <p>Looking at this visually suggests that we have way too many peaks. I want to compare the peak score which is related to the coverage to the abs(distace)</p> <pre class="r"><code>ggplot(peak2transDist_noties, aes(y=PeakScore, x=abs(Distance + 1))) + geom_point() + scale_x_log10() + scale_y_log10() + geom_density2d(na.rm = TRUE, size = 1, colour = 'red') </code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-10-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-10-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/27a43dc8ec9a72661a87c54eb4232457e9d6e227/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-10-1.png" target="_blank">27a43dc</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-09-27 </td> </tr> </tbody> </table> <p></details></p> <p>Alternatively let me try to remove low peak score values.</p> <pre class="r"><code>allPeakplot=ggplot(peak2transDist_noties, aes(x=abs(Distance + 1)))+ geom_density() + scale_x_log10() + labs(title="Distance all peaks to gene end") + annotate("text", label=nrow(peak2transDist_noties), x=10, y=.4) peak2transDist_score500=peak2transDist_noties%>% filter(PeakScore>500) score500plot=ggplot(peak2transDist_score500, aes(x=abs(Distance + 1)))+ geom_density() + scale_x_log10() + labs(title="Peak Score > 500") + annotate("text", label=nrow(peak2transDist_score500), x=10, y=.4) peak2transDist_score200=peak2transDist_noties%>% filter(PeakScore>200) score200plot=ggplot(peak2transDist_score200, aes(x=abs(Distance + 1)))+ geom_density() + scale_x_log10() + labs(title="Peak Score > 200") + annotate("text", label=nrow(peak2transDist_score200), x=10, y=.4) peak2transDist_score100=peak2transDist_noties%>% filter(PeakScore>100) score100plot=ggplot(peak2transDist_score100, aes(x=abs(Distance + 1)))+ geom_density() + scale_x_log10() + labs(title="Peak Score > 100") + annotate("text", label=nrow(peak2transDist_score100), x=10, y=.4) peak2transDist_score50=peak2transDist_noties%>% filter(PeakScore>50) score50plot=ggplot(peak2transDist_score50, aes(x=abs(Distance + 1)))+ geom_density() + scale_x_log10() + labs(title="Peak Score > 50")+ annotate("text", label=nrow(peak2transDist_score50), x=10, y=.4) peak2transDist_score20=peak2transDist_noties%>% filter(PeakScore>20) score20plot=ggplot(peak2transDist_score20, aes(x=abs(Distance + 1)))+ geom_density() + scale_x_log10() + labs(title="Peak Score > 10")+ annotate("text", label=nrow(peak2transDist_score20), x=10, y=.4) distance2peak_all=plot_grid(allPeakplot,score20plot,score50plot,score100plot,score200plot, score500plot)</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 662 rows containing non-finite values (stat_density).</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 431 rows containing non-finite values (stat_density).</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 327 rows containing non-finite values (stat_density).</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 234 rows containing non-finite values (stat_density).</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 150 rows containing non-finite values (stat_density).</code></pre> <pre><code>Warning: Transformation introduced infinite values in continuous x-axis</code></pre> <pre><code>Warning: Removed 78 rows containing non-finite values (stat_density).</code></pre> <pre class="r"><code>ggsave("../output/plots/QC_plots/distance2peak_all.png", distance2peak_all, width=8, height=6)</code></pre> </div> <div id="call-qtls-with-this-assignment" class="section level2"> <h2>Call QTLS with this assignment</h2> <p>I am gonig to use this assignment method to call QTLs. The bed file I will make the phenotypes from is</p> <ul> <li>Peak CHR<br /> </li> <li>Peak Start<br /> </li> <li>Peak End<br /> </li> <li>Peak Name</li> <li>Peak Score<br /> </li> <li>Gene strand</li> <li>Gene/transcript name</li> </ul> <p>in the filtered_APApeaks_merged_allchrom_refseqTrans.closest2End.noties.bed file this is</p> <pre class="bash"><code>awk '{print $1 "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $12 "\t" $10}' filtered_APApeaks_merged_allchrom_refseqTrans.closest2End.noties.bed > filtered_APApeaks_merged_allchrom_refseqTrans.noties_sm.bed less /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqTrans.noties_sm.SA | tr ":" "-" > /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqTrans.noties_sm.fixed.bed</code></pre> <p>Make this an SAF file with the correct peak ID. bed2saf_peaks2trans.py</p> <pre class="bash"><code>from misc_helper import * fout = file("/project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqTrans.noties_sm.SAF",'w') fout.write("GeneID\tChr\tStart\tEnd\tStrand\n") for ln in open("/project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqTrans.noties_sm.fixed.bed"): chrom, start, end, name, score, strand, gene = ln.split() name_i=int(name) start_i=int(start) end_i=int(end) gene_only=gene.split("-")[1] ID = "peak%d:%s:%d:%d:%s:%s"%(name_i, chrom, start_i, end_i, strand, gene_only) fout.write("%s\t%s\t%d\t%d\t%s\n"%(ID, chrom, start_i, end_i, strand)) fout.close()</code></pre> <p>Run feature counts:<br /> ref_gene_peakTranscript_fc_TN.sh</p> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=ref_gene_peakTranscript_fc_TN #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=ref_gene_peakTranscript_fc_TN.out #SBATCH --error=ref_gene_peakTranscript_fc_TN.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END module load Anaconda3 source activate three-prime-env featureCounts -O -a /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqTrans.noties_sm.SAF -F SAF -o /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.fc /project2/gilad/briana/threeprimeseq/data/sort/*-T-*-sort.bam -s 2 featureCounts -O -a /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqTrans.noties_sm.SAF -F SAF -o /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.fc /project2/gilad/briana/threeprimeseq/data/sort/*-N-*-sort.bam -s 2</code></pre> <p>Fix the headers:</p> <ul> <li>fix_head_fc_opp_transcript_tot.py</li> </ul> <pre class="bash"><code>infile= open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.fc", "r") fout = file("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc",'w') for line, i in enumerate(infile): if line == 1: i_list=i.split() libraries=i_list[:6] for sample in i_list[6:]: full = sample.split("/")[7] samp= full.split("-")[2:4] lim="_" samp_st=lim.join(samp) libraries.append(samp_st) first_line= "\t".join(libraries) fout.write(first_line + '\n') else : fout.write(i) fout.close()</code></pre> <ul> <li>fix_head_fc_opp_transcript_nuc.py</li> </ul> <pre class="bash"><code>infile= open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.fc", "r") fout = file("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc",'w') for line, i in enumerate(infile): if line == 1: i_list=i.split() libraries=i_list[:6] for sample in i_list[6:]: full = sample.split("/")[7] samp= full.split("-")[2:4] lim="_" samp_st=lim.join(samp) libraries.append(samp_st) first_line= "\t".join(libraries) fout.write(first_line + '\n') else : fout.write(i) fout.close()</code></pre> <p>Create file IDS:</p> <ul> <li>create_fileid_opp_transcript_total.py</li> </ul> <pre class="bash"><code>fout = file("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_total_Transcript_head.txt",'w') infile= open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc", "r") for line, i in enumerate(infile): if line == 0: i_list=i.split() files= i_list[10:-2] for each in files: full = each.split("/")[7] samp= full.split("-")[2:4] lim="_" samp_st=lim.join(samp) outLine= full[:-1] + "\t" + samp_st fout.write(outLine + "\n") fout.close()</code></pre> <ul> <li>create_fileid_opp_transcript_nuc.py</li> </ul> <pre class="bash"><code>fout = file("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_nuclear_Transcript_head.txt",'w') infile= open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc", "r") for line, i in enumerate(infile): if line == 0: i_list=i.split() files= i_list[10:-2] for each in files: full = each.split("/")[7] samp= full.split("-")[2:4] lim="_" samp_st=lim.join(samp) outLine= full[:-1] + "\t" + samp_st fout.write(outLine + "\n") fout.close()</code></pre> <p>(remove top line)</p> <pre class="bash"><code>awk '{if (NR!=1) {print}}' /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_nuclear_Transcript_head.txt > /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_nuclear_Transcript.txt awk '{if (NR!=1) {print}}' /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_total_Transcript_head.txt > /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_total_Transcript.txt</code></pre> <p>Make Phenotypes:</p> <ul> <li>makePhenoRefSeqPeaks_Transcript_Total.py</li> </ul> <pre class="bash"><code>#PYTHON 3 dic_IND = {} dic_BAM = {} for ln in open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_total_Transcript.txt"): bam, IND = ln.split("\t") IND = IND.strip() dic_IND[bam] = IND if IND not in dic_BAM: dic_BAM[IND] = [] dic_BAM[IND].append(bam) #now I have ind dic with keys as the bam and ind as the values #I also have a bam dic with ind as the keys and bam as the values inds=list(dic_BAM.keys()) #list of ind libraries #gene start and end dictionaries: dic_geneS = {} dic_geneE = {} for ln in open("/project2/gilad/briana/genome_anotation_data/ncbiRefSeq_endProtCodGenes_sort.txt"): chrom, start, end, geneID, score, strand = ln.split('\t') gene= geneID.split(":")[1] if "-" in gene: gene=gene.split("-")[0] if gene not in dic_geneS: dic_geneS[gene]=int(start) dic_geneE[gene]=int(end) #list of genes count_file=open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc", "r") genes=[] for line , i in enumerate(count_file): if line > 1: i_list=i.split() id=i_list[0] id_list=id.split(":") gene=id_list[5] if gene not in genes: genes.append(gene) #make the ind and gene dic dic_dub={} for g in genes: dic_dub[g]={} for i in inds: dic_dub[g][i]=0 #populate the dictionary count_file=open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc", "r") for line, i in enumerate(count_file): if line > 1: i_list=i.split() id=i_list[0] id_list=id.split(":") g= id_list[5] values=list(i_list[6:]) list_list=[] for ind,val in zip(inds, values): list_list.append([ind, val]) for num, name in enumerate(list_list): dic_dub[g][list_list[num][0]] += int(list_list[num][1]) #write the file by acessing the dictionary and putting values in the table ver the value in the dic fout=open("/project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt","w") peak=["chrom"] inds_noL=[] for each in inds: indsNA= "NA" + each[:-2] inds_noL.append(indsNA) fout.write(" ".join(peak + inds_noL) + '\n' ) count_file=open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc", "r") for line , i in enumerate(count_file): if line > 1: i_list=i.split() id=i_list[0] id_list=id.split(":") gene=id_list[5] start=dic_geneS[id_list[5]] end=dic_geneE[id_list[5]] buff=[] buff.append("chr%s:%d:%d:%s_%s_%s"%(id_list[1], start, end, id_list[5], id_list[4], id_list[0])) for x,y in zip(i_list[6:], inds): b=int(dic_dub[gene][y]) t=int(x) buff.append("%d/%d"%(t,b)) fout.write(" ".join(buff)+ '\n') fout.close()</code></pre> <ul> <li>makePhenoRefSeqPeaks_Transcript_Nuclear.py</li> </ul> <pre class="bash"><code>#PYTHON 3 dic_IND = {} dic_BAM = {} for ln in open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_nuclear_Transcript.txt"): bam, IND = ln.split("\t") IND = IND.strip() dic_IND[bam] = IND if IND not in dic_BAM: dic_BAM[IND] = [] dic_BAM[IND].append(bam) #now I have ind dic with keys as the bam and ind as the values #I also have a bam dic with ind as the keys and bam as the values inds=list(dic_BAM.keys()) #list of ind libraries #gene start and end dictionaries: dic_geneS = {} dic_geneE = {} for ln in open("/project2/gilad/briana/genome_anotation_data/ncbiRefSeq_endProtCodGenes_sort.txt"): chrom, start, end, geneID, score, strand = ln.split('\t') gene= geneID.split(":")[1] if "-" in gene: gene=gene.split("-")[0] if gene not in dic_geneS: dic_geneS[gene]=int(start) dic_geneE[gene]=int(end) #list of genes count_file=open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc", "r") genes=[] for line , i in enumerate(count_file): if line > 1: i_list=i.split() id=i_list[0] id_list=id.split(":") gene=id_list[5] if gene not in genes: genes.append(gene) #make the ind and gene dic dic_dub={} for g in genes: dic_dub[g]={} for i in inds: dic_dub[g][i]=0 #populate the dictionary count_file=open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc", "r") for line, i in enumerate(count_file): if line > 1: i_list=i.split() id=i_list[0] id_list=id.split(":") g= id_list[5] values=list(i_list[6:]) list_list=[] for ind,val in zip(inds, values): list_list.append([ind, val]) for num, name in enumerate(list_list): dic_dub[g][list_list[num][0]] += int(list_list[num][1]) #write the file by acessing the dictionary and putting values in the table ver the value in the dic fout=open("/project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt","w") peak=["chrom"] inds_noL=[] for each in inds: indsNA= "NA" + each[:-2] inds_noL.append(indsNA) fout.write(" ".join(peak + inds_noL) + '\n' ) count_file=open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc", "r") for line , i in enumerate(count_file): if line > 1: i_list=i.split() id=i_list[0] id_list=id.split(":") gene=id_list[5] start=dic_geneS[id_list[5]] end=dic_geneE[id_list[5]] buff=[] buff.append("chr%s:%d:%d:%s_%s_%s"%(id_list[1], start, end, id_list[5], id_list[4], id_list[0])) for x,y in zip(i_list[6:], inds): b=int(dic_dub[gene][y]) t=int(x) buff.append("%d/%d"%(t,b)) fout.write(" ".join(buff)+ '\n') fout.close()</code></pre> <p>I can run these with the following bash script:</p> <ul> <li>run_makePhen_sep_Transcript.sh</li> </ul> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=run_makepheno_sep_trans #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=run_makepheno_sep_trans.out #SBATCH --error=run_makepheno_sep_trans.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END module load Anaconda3 source activate three-prime-env python makePhenoRefSeqPeaks_Transcript_Total.py python makePhenoRefSeqPeaks_Transcript_Nuclear.py </code></pre> </div> <div id="prepare-for-fastqtl" class="section level2"> <h2>Prepare for FastQTL</h2> <p>I will do this in the /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/ directory.</p> <pre class="bash"><code>module load samtools #zip file gzip filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt module load python #leafcutter script python /project2/gilad/briana/threeprimeseq/code/prepare_phenotype_table.py filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz #source activate three-prime-env sh filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz_prepare.sh #run for nuclear as well gzip filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt #unload anaconda, load python python /project2/gilad/briana/threeprimeseq/code/prepare_phenotype_table.py filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz #load anaconda and env. sh filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz_prepare.sh #keep only 2 PCs head -n 3 filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.PCs > filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.2PCs head -n 3 filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz.PCs > filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz.2PCs</code></pre> <p>Make a sample list.</p> <ul> <li>makeSampleList_trascript.py</li> </ul> <pre class="bash"><code>#make a sample list fout = open("/project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/SAMPLE.txt",'w') for ln in open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/file_id_mapping_total_Transcript.txt", "r"): bam, sample = ln.split() line=sample[:-2] fout.write("NA"+line + "\n") fout.close()</code></pre> <p>** Manually ** Remove 18500, 19092 and 19193, 18497</p> </div> <div id="run-fastqtl" class="section level2"> <h2>Run FastQTL</h2> <div id="nominal" class="section level3"> <h3>Nominal</h3> <ul> <li>APAqtl_nominal_transcript.sh</li> </ul> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=APAqtl_nominal_transcript #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=APAqtl_nominal_transcript.out #SBATCH --error=APAqtl_nominal_transcript.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 do /home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/nominal_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.qqnorm_chr$i.nominal.out --chunk 1 1 --window 5e5 --include-samples /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/SAMPLE.txt done for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 do /home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.OppStrand_sm_quant.Total.pheno_fixed.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/nominal_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz.qqnorm_chr$i.nominal.out --chunk 1 1 --window 5e5 --include-samples /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/SAMPLE.txt done </code></pre> </div> <div id="permuted" class="section level3"> <h3>Permuted</h3> <ul> <li>APAqtl_permuted_transcript.sh</li> </ul> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=APAqtl_permuted_transcript #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=APAqtl_permuted_transcript.out #SBATCH --error=APAqtl_permuted_transcript.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 do /home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/perm_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.qqnorm_chr$i.perm.out --chunk 1 1 --window 5e5 --include-samples /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/SAMPLE.txt done for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 do /home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/perm_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total.pheno_fixed.txt.gz.qqnorm_chr$i.perm.out --chunk 1 1 --window 5e5 --include-samples /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/SAMPLE.txt done </code></pre> <p>APAqtlpermCorrectQQplot_trans.R</p> <pre class="r"><code>library(dplyr) ##total results tot.perm= read.table("/project2/gilad/briana/threeprimeseq/data/perm_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_transcript_permRes.txt",head=F, stringsAsFactors=F, col.names = c("pid", "nvar", "shape1", "shape2", "dummy", "sid", "dist", "npval", "slope", "ppval", "bpval")) #BH correction tot.perm$bh=p.adjust(tot.perm$bpval, method="fdr") #plot qqplot png("/project2/gilad/briana/threeprimeseq/output/plots/qqplot_total_APAperm_transcript.png") qqplot_total= qqplot(-log10(runif(nrow(tot.perm))), -log10(tot.perm$bpval),ylab="-log10 Total permuted pvalue", xlab="Uniform expectation", main="Total permuted pvalues for all snps") abline(0,1) dev.off() #write df with BH write.table(tot.perm, file = "/project2/gilad/briana/threeprimeseq/data/perm_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_transcript_permResBH.txt", col.names = T, row.names = F, quote = F) ##nuclear results nuc.perm= read.table("/project2/gilad/briana/threeprimeseq/data/perm_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_transcript_permRes.txt",head=F, stringsAsFactors=F, col.names = c("pid", "nvar", "shape1", "shape2", "dummy", "sid", "dist", "npval", "slope", "ppval", "bpval")) nuc.perm$bh=p.adjust(nuc.perm$bpval, method="fdr") #plot qqplot png("/project2/gilad/briana/threeprimeseq/output/plots/qqplot_nuclear_APAperm_transcript.png") qqplot(-log10(runif(nrow(nuc.perm))), -log10(nuc.perm$bpval),ylab="-log10 Nuclear permuted pvalue", xlab="Uniform expectation", main="Nuclear permuted pvalues for all snps") abline(0,1) dev.off() # write df with BH write.table(nuc.perm, file = "/project2/gilad/briana/threeprimeseq/data/perm_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_transcript_permResBH.txt", col.names = T, row.names = F, quote = F)</code></pre> <p>Write a script to run this:</p> <p>run_APAqtlpermCorrectQQplot_trans.sh</p> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=run_APAqtlpermCorrectQQplot_trans #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=run_APAqtlpermCorrectQQplot_trans.out #SBATCH --error=run_APAqtlpermCorrectQQplot_trans.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END module load Anaconda3 source activate three-prime-env Rscript APAqtlpermCorrectQQplot_trans.R </code></pre> <p>I may want to change this to not use the transcript ID but use the gene ID. I will look at these results then decide.</p> </div> </div> <div id="genes-with-mult-peaks-new-annotation" class="section level2"> <h2>Genes with mult peaks-New annotation</h2> <pre class="r"><code>peak2transDist_noties_gene = peak2transDist_noties %>% separate(Transcript, c("OnlyTranscript", "Gene"), sep=":") %>% select(PeakName, Gene) %>% group_by(Gene) %>% tally() %>% mutate(onePeak=ifelse(n==1, 1, 0 )) %>% mutate(multPeaks=ifelse(n > 1, 1, 0 )) sum(peak2transDist_noties_gene$onePeak==1)</code></pre> <pre><code>[1] 1591</code></pre> <pre class="r"><code>sum(peak2transDist_noties_gene$multPeaks==1)</code></pre> <pre><code>[1] 13923</code></pre> <ul> <li><p>1591 Genes have 1 peak. 13923 genes have multiple, 3717 with 0</p></li> <li><p>In total there are 19231 genes in the annotation.</p></li> </ul> <p>Plot this:</p> <pre class="r"><code>PeakCategory=c("Zero", "One", "Multiple") NumGenes=c(round((19231-sum(peak2transDist_noties_gene$onePeak==1)-sum(peak2transDist_noties_gene$multPeaks==1))/19231, digits = 3), round(sum(peak2transDist_noties_gene$onePeak==1)/19231,digits=3), round(sum(peak2transDist_noties_gene$multPeaks==1)/19231,digits = 3)) GenePeakNumTable=as.data.frame(cbind(PeakCategory,NumGenes)) GenePeakNumTable$NumGenes=as.numeric(as.character(GenePeakNumTable$NumGenes)) lab0=paste("Genes = ", 19231-sum(peak2transDist_noties_gene$onePeak==1)-sum(peak2transDist_noties_gene$multPeaks==1), sep=" ") lab1=paste("Genes = ", sum(peak2transDist_noties_gene$onePeak==1), sep=" ") labmult=paste("Genes = ", sum(peak2transDist_noties_gene$multPeaks==1), sep=" ") GenePeakNumPlot=ggplot(GenePeakNumTable, aes(x="", y=NumGenes, by=PeakCategory, fill=PeakCategory)) + geom_bar(stat="identity",position = "stack") + labs(title="Characterize Protein Coding Genes \n by number of PAS", y="Proportion of genes", x="") + scale_fill_brewer(palette="Paired") + annotate("text", x="", y= .1, label=lab0) + annotate("text", x="", y= .24, label=lab1)+ annotate("text", x="", y= .6, label=labmult) #ggsave(GenePeakNumPlot,filename = "../output/plots/PasPerProteinCodingGene.png")</code></pre> <p>Try this at transcript level:</p> <pre class="r"><code>peak2transDist_noties_transcript = peak2transDist_noties %>% separate(Transcript, c("OnlyTranscript", "Gene"), sep=":") %>% select(PeakName, OnlyTranscript) %>% group_by(OnlyTranscript) %>% tally() %>% mutate(onePeak=ifelse(n==1, 1, 0 )) %>% mutate(multPeaks=ifelse(n > 1, 1, 0 )) sum(peak2transDist_noties_transcript$onePeak==1)</code></pre> <pre><code>[1] 2065</code></pre> <pre class="r"><code>sum(peak2transDist_noties_transcript$multPeaks==1)</code></pre> <pre><code>[1] 15614</code></pre> <p>total transcripts: 45024</p> </div> <div id="evaluate-permuted-results" class="section level2"> <h2>Evaluate permuted results</h2> <pre class="r"><code>tot.perm= read.table("../data/perm_QTL_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_transcript_permResBH.txt",head=T, stringsAsFactors=F) plot(tot.perm$ppval, tot.perm$bpval, xlab="Direct method", ylab="Beta approximation", main="Total Check plot") abline(0, 1, col="red")</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-32-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-32-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/73bc857cbab2fbd4dd6fecb0911a447d04abbe56/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-32-1.png" target="_blank">73bc857</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-05 </td> </tr> </tbody> </table> <p></details></p> <pre class="r"><code>tot_qtl_10= tot.perm %>% filter(-log10(bh) > 1) %>% nrow() tot_qtl_10</code></pre> <pre><code>[1] 118</code></pre> <pre class="r"><code>tot.perm %>% filter(-log10(bh) > 1) %>% summarise(n_distinct(sid)) </code></pre> <pre><code> n_distinct(sid) 1 112</code></pre> <pre class="r"><code>nuc.perm= read.table("../data/perm_QTL_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_transcript_permResBH.txt",head=T, stringsAsFactors=F) plot(nuc.perm$ppval, nuc.perm$bpval, xlab="Direct method", ylab="Beta approximation", main="Nuclear Check plot") abline(0, 1, col="red")</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-34-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-34-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/73bc857cbab2fbd4dd6fecb0911a447d04abbe56/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-34-1.png" target="_blank">73bc857</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-05 </td> </tr> </tbody> </table> <p></details></p> <pre class="r"><code>nuc_qtl_10= nuc.perm %>% filter(-log10(bh) > 1) %>% nrow() nuc_qtl_10</code></pre> <pre><code>[1] 880</code></pre> <pre class="r"><code>nuc.perm %>% filter(-log10(bh) > 1) %>% summarise(n_distinct(sid)) </code></pre> <pre><code> n_distinct(sid) 1 831</code></pre> <div id="compare-number" class="section level3"> <h3>Compare number</h3> <pre class="r"><code>nQTL_tot=c() FDR=seq(.05, .5, .01) for (i in FDR){ x=tot.perm %>% filter(bh < i ) %>% nrow() nQTL_tot=c(nQTL_tot, x) } FDR=seq(.05, .5, .01) nQTL_nuc=c() for (i in FDR){ x=nuc.perm %>% filter(bh < i ) %>% nrow() nQTL_nuc=c(nQTL_nuc, x) } nQTL=as.data.frame(cbind(FDR, Total=nQTL_tot, Nuclear=nQTL_nuc)) nQTL_long=melt(nQTL, id.vars = "FDR") sigQTLbyFDR=ggplot(nQTL_long, aes(x=FDR, y=value, by=variable, col=variable)) + geom_line(size=1.5) + labs(y="Number of Significant QTLs", title="APAqtls detected by FDR cuttoff", color="Fraction")+ scale_color_manual(values=c("#5D478B", "#87CEFF")) ggsave(plot = sigQTLbyFDR,filename = "../output/plots/SigQTLbyFDR.png")</code></pre> <pre><code>Saving 7 x 5 in image</code></pre> </div> <div id="overlap-with-results-from-other-mol-qtls" class="section level3"> <h3>Overlap with results from other mol QTLs</h3> <p>I am going to perform this analysis on midway. I need condition QTLs on being other types of QTLs and plot the results. For this I use the nominal pvalues.</p> <p>overlap_QTLplots_Trans.R</p> <pre class="r"><code>#!/bin/rscripts #this script has no arguments, it will take the nuclear and total results then output qqplots of these results overlaped with the other molecular QTLs library(dplyr) library(scales) #import other QTLs QTL_names=c("gene", "snpID","distance", "pval", "slope") fourSU30= read.table("/project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_4su30.fixed.nominal.out", header=F, stringsAsFactors = F, col.names = QTL_names) fourSU60=read.table("/project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_4su60.fixed.nominal.out", header=F, stringsAsFactors = F, col.names = QTL_names) RNAseq=read.table("/project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_RNAseq_phase2.fixed.nominal.out", header=F, stringsAsFactors = F, col.names = QTL_names) guevardis=read.table("/project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_RNAseqGeuvadis.fixed.nominal.out", header=F, stringsAsFactors = F, col.names = QTL_names) ribo=read.table("/project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_ribo_phase2.fixed.nominal.out", header=F, stringsAsFactors = F, col.names = QTL_names) prot=read.table("/project2/gilad/briana/threeprimeseq/data/molecular_QTLs/nom/fastqtl_qqnorm_prot.fixed.nominal.out", header=F, stringsAsFactors = F, col.names = QTL_names) #import nuc and tot results res_names=c("peakID", "snpID", "dist", "res.pval", "slope") nuc.nom=read.table("/project2/gilad/briana/threeprimeseq/data/nominal_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_NomRes.txt", header = F, col.names = res_names, stringsAsFactors = F) tot.nom=read.table("/project2/gilad/briana/threeprimeseq/data/nominal_APAqtl_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_NomRes.txt", header = F, col.names = res_names, stringsAsFactors = F) #subset total fourSU30AndTot= fourSU30 %>% inner_join(tot.nom, by="snpID") %>% select(snpID, res.pval) fourSU30_unif_T=runif(nrow(fourSU30AndTot)) fourSU60AndTot= fourSU60 %>% inner_join(tot.nom, by="snpID") %>% select(snpID, res.pval) fourSU60_unif_T=runif(nrow(fourSU60AndTot)) RNAAndTot= RNAseq %>% inner_join(tot.nom, by="snpID") %>% select(snpID, res.pval) RNAseq_unif_T=runif(nrow(RNAAndTot)) GuevAndTot= guevardis %>% inner_join(tot.nom, by="snpID") %>% select(snpID, res.pval) guev_unif_T=runif(nrow(GuevAndTot)) riboAndTot= ribo %>% inner_join(tot.nom, by="snpID") %>% select(snpID, res.pval) ribo_unif_T=runif(nrow(riboAndTot)) protAndTot= prot %>% inner_join(tot.nom, by="snpID") %>% select(snpID, res.pval) prot_unif_T=runif(nrow(protAndTot)) #subset nuc fourSU30AndNuc= fourSU30 %>% inner_join(nuc.nom, by="snpID") %>% select(snpID, res.pval) fourSU30_unif_N=runif(nrow(fourSU30AndNuc)) fourSU60AndNuc= fourSU60 %>% inner_join(nuc.nom, by="snpID") %>% select(snpID, res.pval) fourSU60_unif_N=runif(nrow(fourSU60AndNuc)) RNAAndNuc= RNAseq %>% inner_join(nuc.nom, by="snpID") %>% select(snpID, res.pval) RNAseq_unif_N=runif(nrow(RNAAndNuc)) GuevAndNuc= guevardis %>% inner_join(nuc.nom, by="snpID") %>% select(snpID, res.pval) guev_unif_N=runif(nrow(GuevAndNuc)) riboAndNuc= ribo %>% inner_join(nuc.nom, by="snpID") %>% select(snpID, res.pval) ribo_unif_N=runif(nrow(riboAndNuc)) protAndNuc= prot %>% inner_join(nuc.nom, by="snpID") %>% select(snpID, res.pval) prot_unif_N=runif(nrow(protAndNuc)) #plot res ##nuclear png('/project2/gilad/briana/threeprimeseq/output/nuc.allQTLs.png') qqplot(-log10(runif(nrow(nuc.nom))), -log10(nuc.nom$res.pval),ylab="-log10 Nuclear nominal pvalue", xlab="Uniform expectation", main="Nuclear Nominal pvalues for all snps") points(sort(-log10(fourSU30_unif_N)), sort(-log10(fourSU30AndNuc$res.pval)), col= alpha("Red", 0.3)) points(sort(-log10(fourSU60_unif_N)), sort(-log10(fourSU60AndNuc$res.pval)), col=alpha("Orange",.3)) points(sort(-log10(RNAseq_unif_N)), sort(-log10(RNAAndNuc$res.pval)), col=alpha("Yellow",.3)) points(sort(-log10(guev_unif_N)), sort(-log10(GuevAndNuc$res.pval)), col=alpha("Green",.3)) points(sort(-log10(ribo_unif_N)), sort(-log10(riboAndNuc$res.pval)), col=alpha("Blue", .3)) points(sort(-log10(prot_unif_N)), sort(-log10(protAndNuc$res.pval)), col=alpha("Purple",.3)) abline(0,1) legend("topleft", legend=c("All SNPs", "4su 30", "4su 60", "RNAseq", "Guevadis RNA", "Ribo", "Protein"), col=c("black", "red", "orange", "yellow", "green", "blue", "purple"), pch=19) dev.off() ##total png('/project2/gilad/briana/threeprimeseq/output/tot.allQTLs.png') qqplot(-log10(runif(nrow(tot.nom))), -log10(tot.nom$res.pval),ylab="-log10 Total nominal pvalue", xlab="Uniform expectation", main="Total Nominal pvalues for all snps") points(sort(-log10(fourSU30_unif_T)), sort(-log10(fourSU30AndTot$res.pval)), col= alpha("Red", 0.3)) points(sort(-log10(fourSU60_unif_T)), sort(-log10(fourSU60AndTot$res.pval)), col=alpha("Orange",.3)) points(sort(-log10(RNAseq_unif_T)), sort(-log10(RNAAndTot$res.pval)), col=alpha("Yellow",.3)) points(sort(-log10(guev_unif_T)), sort(-log10(GuevAndTot$res.pval)), col=alpha("Green",.3)) points(sort(-log10(ribo_unif_T)), sort(-log10(riboAndTot$res.pval)), col=alpha("Blue", .3)) points(sort(-log10(prot_unif_T)), sort(-log10(protAndTot$res.pval)), col=alpha("Purple",.3)) abline(0,1) legend("topleft", legend=c("All SNPs", "4su 30", "4su 60", "RNAseq", "Guevadis RNA", "Ribo", "Protein"), col=c("black", "red", "orange", "yellow", "green", "blue", "purple"), pch=19) dev.off()</code></pre> <p>Bash script to run this:</p> <p>run_overlap_QTLplots_transcript.sh</p> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=run_overlapQTL_transcript #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=run_overlapQTL_transcript.out #SBATCH --error=run_overlapQTL_transcript.err #SBATCH --partition=bigmem2 #SBATCH --mem=64G #SBATCH --mail-type=END module load Anaconda3 source activate three-prime-env Rscript overlap_QTLplots_Trans.R </code></pre> </div> <div id="evaluate-results" class="section level3"> <h3>Evaluate Results</h3> <pre class="r"><code>tot.perm= tot.perm %>% mutate(sig=ifelse( -log10(bh) >= 1 , "Yes", "No")) tot.perm$sig=as.factor(tot.perm$sig) totQTLdist_plot= ggplot(tot.perm, aes(x=log10(abs(dist)), by=sig, fill=sig)) + geom_density(alpha=.5) + labs(title="Distance between snp and peak\n Total fraction")</code></pre> <pre class="r"><code>nuc.perm= nuc.perm %>% mutate(sig=ifelse( -log10(bh) >= 1 , "Yes", "No")) nuc.perm$sig=as.factor(nuc.perm$sig) nucQTLdist_plot= ggplot(nuc.perm, aes(x=log10(abs(dist)), by=sig, fill=sig)) + geom_density(alpha=.5) + labs(title="Distance between snp and peak\n Nuclear fraction")</code></pre> <pre class="r"><code>plot_grid(totQTLdist_plot, nucQTLdist_plot )</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-41-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-41-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/73bc857cbab2fbd4dd6fecb0911a447d04abbe56/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-41-1.png" target="_blank">73bc857</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-05 </td> </tr> </tbody> </table> <p></details></p> <p>How many of the significant snps are the same.</p> <pre class="r"><code>tot.perm_sigOnly=tot.perm %>% filter(sig=="Yes") nuc.perm_sigOnly=nuc.perm %>% filter(sig=="Yes")</code></pre> <p>I want to know how many overlap. I can use and innner join by the sid.</p> <pre class="r"><code>#nuc in total nuc.perm_sigOnly_inT= nuc.perm_sigOnly %>% semi_join(tot.perm_sigOnly, by=c("sid", "pid")) nrow(nuc.perm_sigOnly_inT)</code></pre> <pre><code>[1] 22</code></pre> <pre class="r"><code>nuc.perm_sigOnly_notT= nuc.perm_sigOnly %>% anti_join(tot.perm_sigOnly, by=c("sid", "pid")) nrow(nuc.perm_sigOnly_notT)</code></pre> <pre><code>[1] 858</code></pre> <pre class="r"><code>#total in nuc tot.perm_sigOnly_inT= tot.perm_sigOnly %>% semi_join(nuc.perm_sigOnly, by=c("sid", "pid")) nrow(tot.perm_sigOnly_inT)</code></pre> <pre><code>[1] 22</code></pre> <pre class="r"><code>tot.perm_sigOnly_notT= tot.perm_sigOnly %>% anti_join(nuc.perm_sigOnly, by=c("sid", "pid")) nrow(tot.perm_sigOnly_notT)</code></pre> <pre><code>[1] 96</code></pre> <pre class="r"><code>grid.newpage() qtloverlap=draw.pairwise.venn(area1 = 3049, area2 = 677, cross.area = 148, category = c("Nuclear: QTLs", "Total: QTLs"), lty = rep("solid", 2), fill = c("light blue", "pink"), alpha = rep(0.5, 2), cat.pos = c(0, 0), cat.dist = rep(0.025, 2))</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-44-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-44-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/73bc857cbab2fbd4dd6fecb0911a447d04abbe56/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-44-1.png" target="_blank">73bc857</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-05 </td> </tr> </tbody> </table> <p></details></p> <p>Overlap accouting for gene.</p> <pre class="r"><code>#nuc genes nuc.perm_sigOnly_gene= nuc.perm_sigOnly %>% separate(pid, sep = ":", into=c("chr", "start", "end", "id")) %>% separate(id, sep = "_", into=c("gene", "strand", "peak")) %>% select(gene) %>% distinct(gene) nrow(nuc.perm_sigOnly_gene)</code></pre> <pre><code>[1] 715</code></pre> <pre class="r"><code>#total genes tot.perm_sigOnly_gene= tot.perm_sigOnly %>% separate(pid, sep = ":", into=c("chr", "start", "end", "id")) %>% separate(id, sep = "_", into=c("gene", "strand", "peak")) %>% select(gene) %>% distinct(gene) nrow(tot.perm_sigOnly_gene) </code></pre> <pre><code>[1] 106</code></pre> <pre class="r"><code>nuc.perm_sigOnly_gene %>% semi_join(tot.perm_sigOnly_gene, by="gene") %>% nrow()</code></pre> <pre><code>[1] 48</code></pre> <pre class="r"><code>nuc.perm_sigOnly_gene %>% anti_join(tot.perm_sigOnly_gene, by="gene") %>% nrow()</code></pre> <pre><code>[1] 667</code></pre> <pre class="r"><code>tot.perm_sigOnly_gene %>% semi_join(nuc.perm_sigOnly_gene, by="gene") %>% nrow()</code></pre> <pre><code>[1] 48</code></pre> <pre class="r"><code>tot.perm_sigOnly_gene %>% anti_join(nuc.perm_sigOnly_gene, by="gene") %>% nrow()</code></pre> <pre><code>[1] 58</code></pre> <pre class="r"><code>grid.newpage() png("../output/plots/geneswithAPAQTL.ven.png") qtloverlap_gene=draw.pairwise.venn(area1 = 2272, area2 = 602, cross.area = 398, category = c("Genes with APAqtls\n Nuclear", "Genes with APAqtls\n Total"), lty = rep("solid", 2), fill = c("light blue", " purple"), alpha = rep(0.5, 2), cat.pos = c(0, 26), cat.dist = c(0.03, 0.03)) dev.off()</code></pre> <pre><code>quartz_off_screen 2 </code></pre> </div> </div> <div id="use-these-phenotypes-for-diff-iso-analysis" class="section level2"> <h2>Use these phenotypes for Diff Iso Analysis</h2> <p>Run on counts:</p> <p>I need to run feature counts on all of the data so the total and nuclear files are in the same file</p> <p>ref_gene_peakTranscript_fc.sh</p> <pre class="bash"><code> #!/bin/bash #SBATCH --job-name=ref_gene_peakTranscript_fc #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=ref_gene_peakTranscript_fc.out #SBATCH --error=ref_gene_peakTranscript_fc.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END module load Anaconda3 source activate three-prime-env featureCounts -O -a /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseqTrans.noties_sm.SAF -F SAF -o /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.fc /project2/gilad/briana/threeprimeseq/data/sort/*-sort.bam -s 2 </code></pre> <p>fix_head_fc_trans.py</p> <pre class="bash"><code>infile= open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.fc", "r") fout = file("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant_fixed.fc",'w') for line, i in enumerate(infile): if line == 1: i_list=i.split() libraries = i_list[:6] print(libraries) for sample in i_list[6:]: full = sample.split("/")[7] samp= full.split("-")[2:4] lim="_" samp_st=lim.join(samp) libraries.append(samp_st) first_line= "\t".join(libraries) fout.write(first_line + '\n') else : fout.write(i) fout.close() </code></pre> <p>fc2leafphen_transcript.py</p> <pre class="bash"><code> inFile= open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant_fixed.fc", "r") outFile= open("/project2/gilad/briana/threeprimeseq/data/pheno_DiffIso_transcript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant_forLC.fc", "w") for num, ln in enumerate(inFile): if num == 1: lines=ln.split()[6:] outFile.write(" ".join(lines)+'\n') if num > 1: ID=ln.split()[0] peak=ID.split(":")[0] chrom=ID.split(":")[1] start=ID.split(":")[2] start=int(start) end=ID.split(":")[3] end=int(end) strand=ID.split(":")[4] gene=ID.split(":")[5] new_ID="chr%s:%d:%d:%s"%(chrom, start, end, gene) pheno=ln.split()[6:] pheno.insert(0, new_ID) outFile.write(" ".join(pheno)+'\n') outFile.close() </code></pre> <p>subset_diffisopheno_transcript.py</p> <pre class="bash"><code> def main(inFile, outFile, target): ifile=open(inFile, "r") ofile=open(outFile, "w") target=int(target) for num, ln in enumerate(ifile): if num == 0: ofile.write(ln) else: ID=ln.split()[0] chrom=ID.split(":")[0][3:] print(chrom) chrom=int(chrom) if chrom == target: ofile.write(ln) if __name__ == "__main__": import sys target = sys.argv[1] inFile = "/project2/gilad/briana/threeprimeseq/data/pheno_DiffIso_transcript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant_forLC.fc" outFile = "/project2/gilad/briana/threeprimeseq/data/pheno_DiffIso_transcript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.ALL.pheno_fixed_%s.txt"%(target) main(inFile, outFile, target)</code></pre> <p>Run this with: run_subset_diffisopheno_transcript.sh</p> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=run_subset_diffisopheno_transcript #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=run_subset_diffisopheno_transcript.out #SBATCH --error=run_subset_diffisopheno_transcript.err #SBATCH --partition=broadwl #SBATCH --mem=12G #SBATCH --mail-type=END module load Anaconda3 source activate three-prime-env for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 do python subset_diffisopheno_transcript.py $i done</code></pre> <p>Make a samples list script.</p> <p>MakeDifIsoSampleList_transcript.py</p> <pre class="bash"><code>outfile=open("/project2/gilad/briana/threeprimeseq/data/diff_iso_transcript/sample_groups.txt", "w") infile=open("/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.fc", "r") for line, i in enumerate(infile): if line == 1: i_list=i.split() libraries=[] for sample in i_list[6:]: full = sample.split("/")[7] samp= full.split("-")[2:4] lim="_" samp_st=lim.join(samp) libraries.append(samp_st) for l in libraries: if l[-1] == "T": outfile.write("%s\tTotal\n"%(l)) else: outfile.write("%s\tNuclear\n"%(l)) else: next outfile.close()</code></pre> <p>run_leafcutter_ds_bychrom_tr.sh</p> <pre class="bash"><code>#!/bin/bash #SBATCH --job-name=run_leafcutter_ds_bychrom_tr #SBATCH --account=pi-yangili1 #SBATCH --time=24:00:00 #SBATCH --output=run_leafcutter_ds_bychrom_tr.out #SBATCH --error=run_leafcutter_ds_bychrom_tr.err #SBATCH --partition=bigmem2 #SBATCH --mem=50G #SBATCH --mail-type=END module load R for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 do Rscript /project2/gilad/briana/davidaknowles-leafcutter-c3d9474/scripts/leafcutter_ds.R --num_threads 4 /project2/gilad/briana/threeprimeseq/data/pheno_DiffIso_transcript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.ALL.pheno_fixed_${i}.txt /project2/gilad/briana/threeprimeseq/data/diff_iso_transcript/sample_groups.txt -o /project2/gilad/briana/threeprimeseq/data/diff_iso_transcript/TN_diff_isoform_chr${i}.txt done</code></pre> <ul> <li><p>Error in colSums(cluster_counts > 0): ‘x’ must be an array of at least two dimensions</p></li> <li><p>Not enough valid samples NA NA NA chr7:TRPV6 NA</p></li> <li><p><=1 sample with coverage>min_coverage NA NA NA chr7:WBSCR17 NA</p></li> </ul> <p>There are duplicates peak IDs in chr 6 and 19. This could be due to the same gene name on diff strands from diff versions of the gene. The problems on 6 come from HLA, the one overlap on 19 is DPP9. I am going to remove the dep lines with low coverage because they will probably drop out of the leafcutter analysis due to low numbers.</p> <p>The errors in the significance files are due to clusters that do not satisfy requirements for leafcutter. Either there is only 1 peak in the gene, there are not enought samples with coverage or the min coverage is not satisfied. I can remove these peaks from the results.</p> <p>Plot results:</p> <pre class="r"><code>diffIso=read.table("../data/diff_iso_trans/TN_diff_isoform_all_cluster_sig_Succ.txt", col.names = c("status", "loglr", "df", "p", "cluster", "p.adjust")) qqplot(-log10(runif(nrow(diffIso))), -log10(diffIso$p.adjust),ylab="-log10 Total Adjusted Leafcutter pvalue", xlab="-log 10 Uniform expectation", main="Leafcutter differencial isoform analysis between fractions") abline(0,1)</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-54-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-54-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/b78e12e3e2624d10d3900764e74fe77980f919da/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-54-1.png" target="_blank">b78e12e</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-24 </td> </tr> </tbody> </table> <p></details></p> <p>A better way to look at this is effect sizes because we expect a large amount of signal here.</p> <pre class="r"><code>effectsize=read.table("../data/diff_iso_trans/TN_diff_isoform_ALL.txt_effect_sizes.fixed.txt", stringsAsFactors = F, col.names=c('intron', 'logef' ,'Nuclear', 'Total','deltapsi'))</code></pre> <p>Plot effect sizes:</p> <pre class="r"><code>effectsize$logef=as.numeric(effectsize$logef) plot(sort(effectsize$logef),main="Leafcutter effect Sizes", ylab="Effect size", xlab="Peak Index")</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-56-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-56-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/b78e12e3e2624d10d3900764e74fe77980f919da/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-56-1.png" target="_blank">b78e12e</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-24 </td> </tr> </tbody> </table> <p></details></p> <p>Negative effect sizes are more in nuclear. There are 193842 negative effect sizes and 70873 positive.</p> <p>I want to color this plot by top and bottom 5%.</p> <pre class="r"><code>quantile(effectsize$logef,na.rm=T,probs = seq(0, 1, .05))</code></pre> <pre><code> 0% 5% 10% 15% 20% -20.08363095 -0.60972092 -0.45829291 -0.36423672 -0.29749657 25% 30% 35% 40% 45% -0.25078432 -0.21370090 -0.18275473 -0.15592521 -0.13132430 50% 55% 60% 65% 70% -0.11103719 -0.09127381 -0.07203322 -0.05144509 -0.02853051 75% 80% 85% 90% 95% 0.04114049 0.20084899 0.41743866 0.73096535 1.18251507 100% 7.45641015 </code></pre> <p>5% is -.61, 95% is 1.18</p> <pre class="r"><code>effectsize$colorsF=ifelse(effectsize$logef >= 1.18, "darkviolet", ifelse(effectsize$logef <= -.61,"deepskyblue3", "black")) plot(effectsize$logef, col = effectsize$colorsF ,main="Leafcutter effect Sizes", ylab="Effect size") legend("bottomleft", legend=c("Top 5%: Total", "Bottom 5%: Nuclear"), col=c( "darkviolet","deepskyblue3"), pch=19, cex=0.8)</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-58-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-58-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/a5b4cf677cb4da813fbf7aee2733afe7dccfb8d6/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-58-1.png" target="_blank">a5b4cf6</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-29 </td> </tr> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/b78e12e3e2624d10d3900764e74fe77980f919da/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-58-1.png" target="_blank">b78e12e</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-24 </td> </tr> </tbody> </table> <p></details></p> <p>I want to plot this by chr.</p> <pre class="r"><code>effectsize$colorsF=as.factor(effectsize$colorsF) effectsize_chr=effectsize %>% tidyr::separate(intron, into=c("chrom", "start", "end", "gene"), sep=":") effectsize_chr$chrom=as.factor(effectsize_chr$chrom) ggplot(effectsize_chr, aes(x=chrom, y=logef, col=chrom)) + geom_jitter()+ theme(axis.text.x = element_text(angle = 90, hjust = 1))</code></pre> <p><img src="figure/PeakToGeneAssignment.Rmd/unnamed-chunk-59-1.png" width="672" style="display: block; margin: auto;" /></p> <details> <summary><em>Expand here to see past versions of unnamed-chunk-59-1.png:</em></summary> <table style="border-collapse:separate; border-spacing:5px;"> <thead> <tr> <th style="text-align:left;"> Version </th> <th style="text-align:left;"> Author </th> <th style="text-align:left;"> Date </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> <a href="https://github.com/brimittleman/threeprimeseq/blob/b78e12e3e2624d10d3900764e74fe77980f919da/docs/figure/PeakToGeneAssignment.Rmd/unnamed-chunk-59-1.png" target="_blank">b78e12e</a> </td> <td style="text-align:left;"> Briana Mittleman </td> <td style="text-align:left;"> 2018-10-24 </td> </tr> </tbody> </table> <p></details></p> </div> <div id="session-information" class="section level2"> <h2>Session information</h2> <pre class="r"><code>sessionInfo()</code></pre> <pre><code>R version 3.5.1 (2018-07-02) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.14.1 Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] bindrcpp_0.2.2 VennDiagram_1.6.20 futile.logger_1.4.3 [4] reshape2_1.4.3 cowplot_0.9.3 workflowr_1.1.1 [7] forcats_0.3.0 stringr_1.3.1 dplyr_0.7.6 [10] purrr_0.2.5 readr_1.1.1 tidyr_0.8.1 [13] tibble_1.4.2 ggplot2_3.0.0 tidyverse_1.2.1 loaded via a namespace (and not attached): [1] tidyselect_0.2.4 haven_1.1.2 lattice_0.20-35 [4] colorspace_1.3-2 htmltools_0.3.6 yaml_2.2.0 [7] rlang_0.2.2 R.oo_1.22.0 pillar_1.3.0 [10] glue_1.3.0 withr_2.1.2 R.utils_2.7.0 [13] lambda.r_1.2.3 modelr_0.1.2 readxl_1.1.0 [16] bindr_0.1.1 plyr_1.8.4 munsell_0.5.0 [19] gtable_0.2.0 cellranger_1.1.0 rvest_0.3.2 [22] R.methodsS3_1.7.1 evaluate_0.11 labeling_0.3 [25] knitr_1.20 broom_0.5.0 Rcpp_0.12.19 [28] formatR_1.5 scales_1.0.0 backports_1.1.2 [31] jsonlite_1.5 hms_0.4.2 digest_0.6.17 [34] stringi_1.2.4 rprojroot_1.3-2 cli_1.0.1 [37] tools_3.5.1 magrittr_1.5 lazyeval_0.2.1 [40] futile.options_1.0.1 crayon_1.3.4 whisker_0.3-2 [43] pkgconfig_2.0.2 MASS_7.3-50 xml2_1.2.0 [46] lubridate_1.7.4 assertthat_0.2.0 rmarkdown_1.10 [49] httr_1.3.1 rstudioapi_0.8 R6_2.3.0 [52] nlme_3.1-137 git2r_0.23.0 compiler_3.5.1 </code></pre> </div> <hr> <p> </p> <hr> <!-- To enable disqus, uncomment the section below and provide your disqus_shortname --> <!-- disqus <div id="disqus_thread"></div> <script type="text/javascript"> /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = 'rmarkdown'; // required: replace example with your forum shortname /* * * DON'T EDIT BELOW THIS LINE * * */ (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a> --> <!-- Adjust MathJax settings so that all math formulae are shown using TeX fonts only; see http://docs.mathjax.org/en/latest/configuration.html. This will make the presentation more consistent at the cost of the webpage sometimes taking slightly longer to load. Note that this only works because the footer is added to webpages before the MathJax javascript. --> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ "HTML-CSS": { availableFonts: ["TeX"] } }); </script> <hr> <p> This reproducible <a href="http://rmarkdown.rstudio.com">R Markdown</a> analysis was created with <a href="https://github.com/jdblischak/workflowr">workflowr</a> 1.1.1 </p> <hr> </div> </div> </div> <script> // add bootstrap table styles to pandoc tables function bootstrapStylePandocTables() { $('tr.header').parent('thead').parent('table').addClass('table table-condensed'); } $(document).ready(function () { bootstrapStylePandocTables(); }); </script> <!-- dynamically load mathjax for compatibility with self-contained --> <script> (function () { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; document.getElementsByTagName("head")[0].appendChild(script); })(); </script> </body> </html>