<!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>28 Ind. Peak Quant</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">28 Ind. Peak Quant</h1>
<h4 class="author"><em>Briana Mittleman</em></h4>
<h4 class="date"><em>8/9/2018</em></h4>

</div>


<p><strong>Last updated:</strong> 2018-08-13</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/e2ded68cffbc80b0afdcc1353043336e9721760b" target="_blank">e2ded68</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:    output/.DS_Store

Untracked files:
    Untracked:  analysis/snake.config.notes.Rmd
    Untracked:  data/18486.genecov.txt
    Untracked:  data/APApeaksYL.total.inbrain.bed
    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/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/combined_reads_mapped_three_prime_seq.csv
    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/nuc6up/
    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/cleanupdtseq.internalpriming.Rmd
    Modified:   analysis/dif.iso.usage.leafcutter.Rmd
    Modified:   analysis/explore.filters.Rmd
    Modified:   analysis/peak.cov.pipeline.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/e2ded68cffbc80b0afdcc1353043336e9721760b/analysis/28ind.peak.explore.Rmd" target="_blank">e2ded68</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
<td style="text-align:left;">
refseq gene
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/2e06a709381efd1768bf354c4a300161b58c55f0/docs/28ind.peak.explore.html" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</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/3901f7e5e803eb923911ee362288fc71f5859534/analysis/28ind.peak.explore.Rmd" target="_blank">3901f7e</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
<td style="text-align:left;">
pre and post clean peaks per gene
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/28ind.peak.explore.html" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</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/03761cbbf00f95021204eefca436dbb1f2146cbc/analysis/28ind.peak.explore.Rmd" target="_blank">03761cb</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
<td style="text-align:left;">
start peak explore analysis for 54 libraries
</td>
</tr>
</tbody>
</table>
</ul>
<p></details></p>
<hr />
<p>I know have 28 individuals sequences on 2 lanes. I have combined these and used the peak coverage pipeline to call and clean peaks. I will use this analysis to explore the library sizes and coverage at these peaks.</p>
<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: &#39;cowplot&#39;</code></pre>
<pre><code>The following object is masked from &#39;package:ggplot2&#39;:

    ggsave</code></pre>
<pre class="r"><code>library(reshape2)</code></pre>
<pre><code>
Attaching package: &#39;reshape2&#39;</code></pre>
<pre><code>The following object is masked from &#39;package:tidyr&#39;:

    smiths</code></pre>
<pre class="r"><code>library(devtools)</code></pre>
<div id="reads-and-mapping-stats" class="section level2">
<h2>Reads and Mapping Stats:</h2>
<pre class="r"><code>map_stats=read.csv(&quot;../data/comb_map_stats.csv&quot;, header=T)
map_stats$line=as.factor(map_stats$line)
map_stats$batch=as.factor(map_stats$batch)</code></pre>
<p>The number of reads for each library and the number of mapped reads.</p>
<pre class="r"><code>read_plot=ggplot(map_stats, aes(x=line, y=comb_reads, fill=fraction))+ geom_bar(stat=&quot;identity&quot;, position=&quot;dodge&quot;) +labs(y=&quot;Reads&quot;, title=&quot;Reads by line and fraction&quot;) 
map_plot=ggplot(map_stats, aes(x=line, y=comb_mapped, fill=fraction))+ geom_bar(stat=&quot;identity&quot;, position=&quot;dodge&quot;) +labs(y=&quot;Mapped Reads&quot;, title=&quot;Mapped reads by line and fraction&quot;) + geom_hline(yintercept=10000000) + annotate(&quot;text&quot;,label=&quot;10 million mapped reads&quot;, y=9000000, x=10)

plot_grid(read_plot, map_plot)</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-3-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-3-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/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-3-1.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>The percent of reads that map per line are pretty uniform accross libraries. The mean is 72%.</p>
<pre class="r"><code>ggplot(map_stats, aes(x=line, y=comb_prop_mapped, fill=fraction))+ geom_bar(stat=&quot;identity&quot;, position=&quot;dodge&quot;) +labs(y=&quot;Mapped Percent&quot;, title=&quot;Percent of reads mapping by line and fraction&quot;) </code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-4-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-4-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/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-4-1.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>mean(map_stats$comb_prop_mapped)</code></pre>
<pre><code>[1] 0.7230478</code></pre>
</div>
<div id="clean-peak-exploration" class="section level2">
<h2>Clean peak exploration</h2>
<pre class="r"><code>peak_quant=read.table(file = &quot;../data/clean_peaks/APAquant.fc.cleanpeaks.fc&quot;, header=T)</code></pre>
<p>Fix the names</p>
<pre class="r"><code>file_names=colnames(peak_quant)[7:62]
file_names_split=lapply(file_names, function(x)strsplit(x,&quot;.&quot;, fixed=T))
libraries=c()
for (i in file_names_split){
  unlist_i=unlist(i)
  libraries=c(libraries, paste(unlist_i[10], unlist_i[11], sep=&quot;-&quot;))
}
colnames(peak_quant)=c(colnames(peak_quant)[1:6], libraries)  </code></pre>
<p>Explore the peaks before quantifications:</p>
<pre class="r"><code>#length of peaks
plot(sort(peak_quant$Length,decreasing = T), main=&quot;Peak Lengths&quot;, ylab=&quot;Peak Length&quot;, xlab=&quot;Peak index&quot;)</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-7-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-7-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/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-7-1.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>#mean cov of peaks

peak_cov=peak_quant %&gt;% select(contains(&quot;-&quot;))

peak_mean=apply(peak_cov,1,mean)
peak_var=apply(peak_cov, 1, var)

plot(log10(sort(peak_mean,decreasing = T)))</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-7-2.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-7-2.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/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-7-2.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>plot(peak_var)</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-7-3.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-7-3.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/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-7-3.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>plot(log10(peak_var)~log10(peak_mean))</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-7-4.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-7-4.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/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-7-4.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Plot the coverage vs the length:</p>
<pre class="r"><code>plot(peak_mean~peak_quant$Length)</code></pre>
<p><img src="figure/28ind.peak.explore.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/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-8-1.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
</div>
<div id="clustering" class="section level2">
<h2>Clustering:</h2>
<p>CLustering:</p>
<pre class="r"><code>pca_peak= prcomp(peak_cov,center = TRUE,scale. = TRUE)
summary(pca_peak)</code></pre>
<pre><code>Importance of components:
                          PC1    PC2     PC3     PC4    PC5    PC6     PC7
Standard deviation     6.5936 2.7291 1.66983 0.71519 0.6392 0.5651 0.52807
Proportion of Variance 0.7763 0.1330 0.04979 0.00913 0.0073 0.0057 0.00498
Cumulative Proportion  0.7763 0.9093 0.95915 0.96828 0.9756 0.9813 0.98626
                           PC8     PC9    PC10    PC11    PC12    PC13
Standard deviation     0.35808 0.29502 0.25231 0.23732 0.22343 0.19515
Proportion of Variance 0.00229 0.00155 0.00114 0.00101 0.00089 0.00068
Cumulative Proportion  0.98855 0.99010 0.99124 0.99224 0.99314 0.99382
                         PC14    PC15    PC16    PC17    PC18    PC19
Standard deviation     0.1832 0.17407 0.16032 0.14346 0.14122 0.13574
Proportion of Variance 0.0006 0.00054 0.00046 0.00037 0.00036 0.00033
Cumulative Proportion  0.9944 0.99496 0.99542 0.99578 0.99614 0.99647
                         PC20    PC21    PC22    PC23    PC24    PC25
Standard deviation     0.1300 0.12760 0.11966 0.11231 0.10982 0.10799
Proportion of Variance 0.0003 0.00029 0.00026 0.00023 0.00022 0.00021
Cumulative Proportion  0.9968 0.99706 0.99732 0.99754 0.99776 0.99796
                          PC26    PC27    PC28    PC29    PC30    PC31
Standard deviation     0.10167 0.09704 0.09243 0.08607 0.08012 0.07887
Proportion of Variance 0.00018 0.00017 0.00015 0.00013 0.00011 0.00011
Cumulative Proportion  0.99815 0.99832 0.99847 0.99860 0.99872 0.99883
                          PC32    PC33    PC34    PC35    PC36    PC37
Standard deviation     0.07689 0.07601 0.07153 0.06993 0.06656 0.06334
Proportion of Variance 0.00011 0.00010 0.00009 0.00009 0.00008 0.00007
Cumulative Proportion  0.99893 0.99904 0.99913 0.99922 0.99929 0.99937
                          PC38    PC39    PC40    PC41    PC42    PC43
Standard deviation     0.06152 0.05822 0.05643 0.05371 0.05236 0.04715
Proportion of Variance 0.00007 0.00006 0.00006 0.00005 0.00005 0.00004
Cumulative Proportion  0.99943 0.99949 0.99955 0.99960 0.99965 0.99969
                          PC44    PC45    PC46    PC47    PC48    PC49
Standard deviation     0.04656 0.04584 0.04252 0.04214 0.03873 0.03696
Proportion of Variance 0.00004 0.00004 0.00003 0.00003 0.00003 0.00002
Cumulative Proportion  0.99973 0.99977 0.99980 0.99983 0.99986 0.99988
                          PC50    PC51    PC52    PC53    PC54    PC55
Standard deviation     0.03557 0.03351 0.03191 0.03020 0.02938 0.02733
Proportion of Variance 0.00002 0.00002 0.00002 0.00002 0.00002 0.00001
Cumulative Proportion  0.99991 0.99993 0.99994 0.99996 0.99998 0.99999
                          PC56
Standard deviation     0.02525
Proportion of Variance 0.00001
Cumulative Proportion  1.00000</code></pre>
<pre class="r"><code>pc_df=as.data.frame(pca_peak$rotation) %&gt;% rownames_to_column(var=&quot;lib&quot;) %&gt;% mutate(fraction=ifelse(grepl(&quot;T&quot;, lib), &quot;total&quot;, &quot;nuclear&quot;))

ggplot(pc_df, aes(x=PC1, y=PC2, col=fraction)) + geom_point() + labs(x=&quot;PC1: Prop explained 0.7763&quot;, y=&quot;PC2: Prop explained 0.1330&quot;, title=&quot;Raw PAS qunatification data&quot;)</code></pre>
<p><img src="figure/28ind.peak.explore.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/2e06a709381efd1768bf354c4a300161b58c55f0/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-10-1.png" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-10-1.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>I now want to explore what the first PC is representing. Some ideas are:</p>
<ul>
<li><p>batch</p></li>
<li><p>sequencing depth</p></li>
<li><p>mapped reads</p></li>
</ul>
<p>All of this info is in the map stats.</p>
<pre class="r"><code>pc_df=as.data.frame(pca_peak$rotation) %&gt;% rownames_to_column(var=&quot;lib&quot;) %&gt;% mutate(fraction=ifelse(grepl(&quot;T&quot;, lib), &quot;total&quot;, &quot;nuclear&quot;)) %&gt;% mutate(reads=map_stats$comb_reads) %&gt;% mutate(batch=map_stats$batch) %&gt;% mutate(mapped=map_stats$comb_mapped)


batch_gg= ggplot(pc_df, aes(x=PC1, y=PC2, col=batch)) + geom_point() + labs(x=&quot;PC1: Prop explained 0.7763&quot;, y=&quot;PC2: Prop explained 0.1330&quot;, title=&quot;Batch&quot;)

frac_gg= ggplot(pc_df, aes(x=PC1, y=PC2, col=fraction)) + geom_point() + labs(x=&quot;PC1: Prop explained 0.7763&quot;, y=&quot;PC2: Prop explained 0.1330&quot;, title=&quot;Fraction&quot;)

reads_gg= ggplot(pc_df, aes(x=PC1, y=PC2, col=reads)) + geom_point() + labs(x=&quot;PC1: Prop explained 0.7763&quot;, y=&quot;PC2: Prop explained 0.1330&quot;, title=&quot;Reads&quot;)


mapped_gg= ggplot(pc_df, aes(x=PC1, y=PC2, col=mapped)) + geom_point() + labs(x=&quot;PC1: Prop explained 0.7763&quot;, y=&quot;PC2: Prop explained 0.1330&quot;, title=&quot;Mapped Reads&quot;)

plot_grid(frac_gg,batch_gg,reads_gg,mapped_gg)</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-11-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-11-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/2e06a709381efd1768bf354c4a300161b58c55f0/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-11-1.png" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Proportion of reads mapping to peaks. This may be in the feature counts summary.</p>
<pre class="r"><code>map_summary=read.table(&quot;../data/clean_peaks/APAquant.fc.cleanpeaks.fc.summary&quot;, header=T)

colnames(map_summary)=c(colnames(map_summary)[1], libraries) 

map_summary_m=map_summary[,2:57] %&gt;% t 
colnames(map_summary_m)=map_summary$Status

map_summary_m_df= as.data.frame(map_summary_m) %&gt;% mutate(perc_feature=(Assigned/(Assigned+Unassigned_NoFeatures)))</code></pre>
<pre class="r"><code>pc_df_mapsum=as.data.frame(pca_peak$rotation) %&gt;% rownames_to_column(var=&quot;lib&quot;) %&gt;% mutate(fraction=ifelse(grepl(&quot;T&quot;, lib), &quot;total&quot;, &quot;nuclear&quot;)) %&gt;% mutate(reads=map_stats$comb_reads) %&gt;% mutate(batch=map_stats$batch) %&gt;% mutate(mapped=map_stats$comb_mapped) %&gt;% mutate(PercFeature=map_summary_m_df$perc_feature)

propfrac_gg= ggplot(pc_df_mapsum, aes(x=PC1, y=PC2, col=PercFeature)) + geom_point() + labs(x=&quot;PC1: Prop explained 0.7763&quot;, y=&quot;PC2: Prop explained 0.1330&quot;, title=&quot;Percent Reads mapping to a feature&quot;)


propfrac_gg</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-13-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-13-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/2e06a709381efd1768bf354c4a300161b58c55f0/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-13-1.png" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/38bfbaf6b3e1b6f8e8fd397af1b86d34dd711a9e/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-13-1.png" target="_blank">38bfbaf</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-09
</td>
</tr>
</tbody>
</table>
<p></details></p>
</div>
<div id="map-peaks-to-genes" class="section level2">
<h2>Map peaks to genes</h2>
<p>I want to use the bedtools closest command to find the clostest protein coding gene to each peak.</p>
<ul>
<li><p>-s (require same strandedness)</p></li>
<li><p>-d add a column with distance to closest (strand spec) report distance wrt the genes</p></li>
<li><p>A is the peak</p></li>
<li><p>B is protein coding genes</p></li>
</ul>
<pre class="bash"><code>#!/bin/bash

#SBATCH --job-name=mapgene2peak
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=mapgene2peak.out
#SBATCH --error=mapgene2peak.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END

module load Anaconda3
source activate three-prime-env


bedtools closest -s -d -a /project2/gilad/briana/threeprimeseq/data/clean.peaks_comb/APApeaks_combined_clean_fixed.bed -b /project2/gilad/briana/genome_anotation_data/gencode.v19.annotation.proteincodinggene.bed &gt; /project2/gilad/briana/threeprimeseq/data/clean.peaks_comb/APApeaks_comb_clean_dist2gene.txt</code></pre>
<pre class="r"><code>clean_peaks=read.table(&quot;../data/clean_peaks/APApeaks_combined_clean.bed&quot;, header=F)</code></pre>
<p>This scirpt is called fix_cleanpeakbed.py</p>
<pre class="bash"><code>from misc_helper import *
fout = file(&quot;/project2/gilad/briana/threeprimeseq/data/clean.peaks_comb/APApeaks_combined_clean_fixed.bed&quot;,&#39;w&#39;)
for ln in open(&quot;/project2/gilad/briana/threeprimeseq/data/clean.peaks_comb/APApeaks_combined_clean.bed&quot;):
    chrom, start, end, name, cov, strand, score2 = ln.split()
    chrom_nochr= int(chrom[3:])
    start_i = int(start)
    end_i = int(end)
    cov_i=float(cov)
    fout.write(&quot;%d\t%d\t%d\t%s\t%f\t%s\n&quot;%(chrom_nochr, start_i, end_i, name, cov_i, strand))
fout.close()
</code></pre>
<p>Second option is to use bedtools map. This will tell me directly how many peaks overlap each gene. I will use the -c and -o commands. I want it to tell me the number of peaks rather than the mean of the coverage. I can give it the name column as the -c and -0 count_distinct</p>
<pre class="bash"><code>#!/bin/bash

#SBATCH --job-name=mapgene2peak2
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=mapgene2peak2.out
#SBATCH --error=mapgene2peak2.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END

module load Anaconda3
source activate three-prime-env


bedtools map -c 4 -o count_distinct -a /project2/gilad/briana/genome_anotation_data/gencode.v19.annotation.proteincodinggene.bed -b /project2/gilad/briana/threeprimeseq/data/clean.peaks_comb/APApeaks_combined_clean_fixed.bed &gt; /project2/gilad/briana/threeprimeseq/data/clean.peaks_comb/APApeaks_combined_clean_countdistgenes.txt</code></pre>
<p>First look at the count for peaks in genes. this will not give us information for peaks outside of the annotaiton.</p>
<pre class="r"><code>genes_per_peak=read.table(&quot;../data/clean_peaks/APApeaks_combined_clean_countdistgenes.txt&quot;, header=F, stringsAsFactors = F, col.names = c(&quot;chr&quot;, &quot;strart&quot;, &quot;end&quot;, &quot;gene&quot;, &quot;score&quot;, &quot;strand&quot;, &quot;numPeaks&quot;))
nrow(genes_per_peak)</code></pre>
<pre><code>[1] 20345</code></pre>
<pre class="r"><code>genes_with_peak= genes_per_peak %&gt;% filter(numPeaks&gt;0) %&gt;% nrow()
genes_with_peak</code></pre>
<pre><code>[1] 12867</code></pre>
<pre class="r"><code>genes_with_2peak= genes_per_peak %&gt;% filter(numPeaks&gt;1) %&gt;% nrow()
genes_with_2peak</code></pre>
<pre><code>[1] 10797</code></pre>
<p>There are in total 20,345 genes in the protein coding gene set. There are 12,867 with at least 1 peak and 10,797 with at least 2 peaks.</p>
<p>Look at the distribution:</p>
<pre class="r"><code>plot(sort(genes_per_peak$numPeaks, decreasing = T), ylab=&quot;Number of Peaks&quot;, main=&quot;Number of peaks mapping to each protein coding gene&quot;)</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-19-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-19-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/2e06a709381efd1768bf354c4a300161b58c55f0/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-19-1.png" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>The next dataset has more information aboutthe distance to the gene. If it overlaps, the distance should be 0.</p>
<pre class="r"><code>dist_to_peak=read.table(&quot;../data/clean_peaks/APApeaks_comb_clean_dist2gene.txt&quot;, header=F)</code></pre>
</div>
<div id="compare-this-to-rnaseq" class="section level2">
<h2>Compare this to RNAseq</h2>
<pre class="r"><code>rnaseq_18486=read.table(&quot;../data/18486.genecov.txt&quot;, header=F,col.names = c(&quot;chr&quot;, &quot;start&quot;, &quot;end&quot;, &quot;name&quot;, &quot;score&quot;, &quot;strand&quot;, &quot;count&quot;))

expressed_genes=rnaseq_18486 %&gt;% filter(count&gt;0) %&gt;% nrow()
expressed_genes</code></pre>
<pre><code>[1] 16925</code></pre>
<p>Get gene level coverage for 18486T 3’ seq data. I have this in /project2/gilad/briana/threeprimeseq/data/gene_cov.</p>
<pre class="r"><code>threeprime_18486T=read.table(&quot;../data/YL-SP-18486-T-combined-genecov.txt&quot;, header=F, col.names = c(&quot;chr&quot;, &quot;start&quot;, &quot;end&quot;, &quot;name&quot;, &quot;score&quot;, &quot;strand&quot;, &quot;count&quot;))</code></pre>
<pre class="r"><code>rnaseq_sm=rnaseq_18486 %&gt;% select(&quot;name&quot;, &quot;count&quot;)
threeprime_sm=threeprime_18486T %&gt;% select(&quot;name&quot;, &quot;count&quot;)

gene_cov=rnaseq_sm %&gt;% left_join(threeprime_sm, by= &quot;name&quot;) 
names(gene_cov)= c(&quot;name&quot;, &quot;rnaseq&quot;, &quot;threeprime&quot;)

ggplot(gene_cov,aes(x=log10(rnaseq), y=log10(threeprime)))+ geom_point(na.rm=TRUE, size=.1) + geom_density2d(na.rm = TRUE, size = 1, colour = &#39;red&#39;) + labs(y=&#39;Log(three prime seq gene Count)&#39;, x=&#39;Log(RNA seq gene Count)&#39;, title=&quot;Correlation between three prime seq and rna seq read counts&quot;) + xlab(&#39;Log(RNA seq gene Count)&#39;) + geom_smooth(method=&quot;lm&quot;)</code></pre>
<pre><code>Warning: Removed 6778 rows containing non-finite values (stat_smooth).</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-23-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-23-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/2e06a709381efd1768bf354c4a300161b58c55f0/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-23-1.png" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Subset genes with coverage in RNA seq but not in three prime seq.</p>
<pre class="r"><code>genecov_onlyRNA=gene_cov %&gt;% filter(threeprime==0 &amp; rnaseq !=0) %&gt;% arrange(desc(rnaseq))</code></pre>
<p>What I actually want to look at genes with no peaks but RNA reads.</p>
<pre class="r"><code>colnames(rnaseq_sm)=c(&quot;gene&quot;, &quot;RNAseqCount&quot;)

cov_rnavthreeprime= rnaseq_sm %&gt;% left_join(genes_per_peak, by=&quot;gene&quot;) %&gt;% select(gene, RNAseqCount, numPeaks)</code></pre>
<pre><code>Warning: Column `gene` joining factor and character vector, coercing into
character vector</code></pre>
<pre class="r"><code>ggplot(cov_rnavthreeprime,aes(x=log10(RNAseqCount), y=log10(numPeaks)))+ geom_point(na.rm=TRUE, size=.1) + geom_density2d(na.rm = TRUE, size = 1, colour = &#39;red&#39;)  + geom_smooth(method=&quot;lm&quot;)</code></pre>
<pre><code>Warning: Removed 7575 rows containing non-finite values (stat_smooth).</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-25-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-25-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/2e06a709381efd1768bf354c4a300161b58c55f0/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-25-1.png" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Explore how many genes have coverage in the RNAseq set but not the</p>
<pre class="r"><code>NotInThreePrime=cov_rnavthreeprime %&gt;% filter(numPeaks==0 &amp; RNAseqCount !=0) %&gt;% arrange(desc(RNAseqCount))</code></pre>
<pre class="r"><code>par(mfrow=c(1,2))

plot(log10(sort(cov_rnavthreeprime$RNAseqCount, decreasing = T)))
plot(log10(NotInThreePrime$RNAseqCount), main=&quot;Post-clean up, coverage of RNA seq without a PAS&quot;, xlab=&quot;gene&quot;, ylab=&quot;log10 coverage RNA seq 18486&quot;)</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-27-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-27-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/2e06a709381efd1768bf354c4a300161b58c55f0/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-27-1.png" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Top RNA seq without peaks:</p>
<ul>
<li><p>GAPDH - doesnt male sense. Visually see peak</p></li>
<li><p>EEF2</p></li>
<li><p>PFN1</p></li>
<li><p>PTMA</p></li>
</ul>
<div id="try-with-peaks-before-cleaning" class="section level3">
<h3>Try with peaks before cleaning</h3>
<p>In looking at IGV the places have coverage and peaks are called in Yang protocol but they are all removed in the cleaning step. I want to look at how many genes have APA when we use the pre-cleaned list of peaks. This file is filtered_APApeaks_merged_allchrom.bed. I need to map these to genes like I did the other peaks.</p>
<p>This scirpt is called fix_dirtypeakbed.py</p>
<pre class="bash"><code>from misc_helper import *
fout = file(&quot;/project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom.named.fixed.bed&quot;,&#39;w&#39;)
for ln in open(&quot;/project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom.named.bed&quot;):
    chrom, start, end, name, cov, strand, score2 = ln.split()
    chrom_nochr= int(chrom[3:])
    start_i = int(start)
    end_i = int(end)
    cov_i=float(cov)
    fout.write(&quot;%d\t%d\t%d\t%s\t%f\t%s\n&quot;%(chrom_nochr, start_i, end_i, name, cov_i, strand))
fout.close()
</code></pre>
<p>mapgene2peak_dirty.sh</p>
<pre class="bash"><code>#!/bin/bash

#SBATCH --job-name=mapgene2peak_dirty
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=mapgene2peak_dirty.out
#SBATCH --error=mapgene2peak_dirty.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END

module load Anaconda3
source activate three-prime-env


bedtools closest -s -d -a /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom.named.fixed.bed -b /project2/gilad/briana/genome_anotation_data/gencode.v19.annotation.proteincodinggene.bed &gt; /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_dist2gene.txt</code></pre>
<pre class="bash"><code>#!/bin/bash

#SBATCH --job-name=mapgene2peak2_dirty
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=mapgene2peak2_dirty.out
#SBATCH --error=mapgene2peak2_dirty.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END

module load Anaconda3
source activate three-prime-env


bedtools map -c 4 -o count_distinct -a /project2/gilad/briana/genome_anotation_data/gencode.v19.annotation.proteincodinggene.bed -b /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom.named.fixed.bed &gt; /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_countdistgenes.txt</code></pre>
<pre class="r"><code>dirty_peak=read.table(&quot;../data/clean_peaks/filtered_APApeaks_merged_allchrom_countdistgenes.txt&quot;, col.names = c(&quot;chr&quot;, &quot;start&quot;, &quot;end&quot;, &quot;gene&quot;, &quot;score&quot;, &quot;strand&quot;, &quot;numPeaks&quot;))


genes_with_peak_dirty= dirty_peak %&gt;% filter(numPeaks&gt;0) %&gt;% nrow()
genes_with_peak_dirty</code></pre>
<pre><code>[1] 14678</code></pre>
<pre class="r"><code>genes_with_2peak_dirty=  dirty_peak %&gt;% filter(numPeaks&gt;1) %&gt;% nrow()
genes_with_2peak_dirty</code></pre>
<pre><code>[1] 12761</code></pre>
<pre class="r"><code>rnaseq_dirtypeaks=rnaseq_sm %&gt;% left_join(dirty_peak, by=&quot;gene&quot;) %&gt;% mutate(length=end-start) %&gt;% select(gene, RNAseqCount, numPeaks, length, start, end, chr)


dirty_onlyinRNA= rnaseq_dirtypeaks %&gt;% filter(numPeaks==0 &amp; RNAseqCount !=0) %&gt;% arrange(desc(RNAseqCount))


summary(rnaseq_dirtypeaks$length)</code></pre>
<pre><code>   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
     59    8547   25654   65309   67508 2304638 </code></pre>
<pre class="r"><code>summary(dirty_onlyinRNA$length)</code></pre>
<pre><code>   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
     59    4500   16166   51003   53592 1117544 </code></pre>
<pre class="r"><code>par(mfrow=c(1,2))


plot(log10(dirty_onlyinRNA$RNAseqCount), main=&quot;Pre-clean up, \n coverage of RNA seq without a PAS&quot;, xlab=&quot;gene&quot;, ylab=&quot;log10 coverage RNA seq 18486&quot;)

plot(log10(NotInThreePrime$RNAseqCount), main=&quot;Post-clean up, \n coverage of RNA seq without a PAS&quot;, xlab=&quot;gene&quot;, ylab=&quot;log10 coverage RNA seq 18486&quot;)</code></pre>
<p><img src="figure/28ind.peak.explore.Rmd/unnamed-chunk-33-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-33-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/2e06a709381efd1768bf354c4a300161b58c55f0/docs/figure/28ind.peak.explore.Rmd/unnamed-chunk-33-1.png" target="_blank">2e06a70</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
</div>
</div>
<div id="map-to-refseq" class="section level2">
<h2>Map to refseq</h2>
<p>It looks like mapping to the refseq genes may be more effective here due to the better 3’ UTR annotatations</p>
<pre class="bash"><code>#!/bin/bash

#SBATCH --job-name=mapgene2peak2_dirty_refseq
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=mapgene2peak2_dirty_rs.out
#SBATCH --error=mapgene2peak2_dirty_rs.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END

module load Anaconda3
source activate three-prime-env


bedtools map -c 4 -o count_distinct -a /project2/gilad/briana/genome_anotation_data/ncbiRefSeq_sm_noChr.sort.bed -b /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom.named.fixed.bed &gt; /project2/gilad/briana/threeprimeseq/data/mergedPeaks_comb/filtered_APApeaks_merged_allchrom_refseq_countdistgenes.txt
</code></pre>
<p>Also do coverage for the RNA seq with this.</p>
<pre class="bash"><code>#!/bin/bash

#SBATCH --job-name=refseq-rnaseqcov18486
#SBATCH --account=pi-yangili1
#SBATCH --time=24:00:00
#SBATCH --output=refseq-rnaseqcov18486.out
#SBATCH --error=refseq-rnaseqcov18486.err
#SBATCH --partition=broadwl
#SBATCH --mem=12G
#SBATCH --mail-type=END


module load Anaconda3  

source activate three-prime-env




bedtools coverage -counts -sorted -a /project2/gilad/briana/genome_anotation_data/ncbiRefSeq_sm.sort.bed-b /project2/gilad/briana/threeprimeseq/data/rnaseq_bed/18486.bed &gt; /project2/gilad/briana/threeprimeseq/data/rnaseq_cov/18486.refseq.gencov.txt</code></pre>
<p>bedfile is currupt. i need to make one from teh original vcf.</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 Sierra 10.12.6

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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] bindrcpp_0.2.2  devtools_1.13.6 reshape2_1.4.3  cowplot_0.9.3  
 [5] workflowr_1.1.1 forcats_0.3.0   stringr_1.3.1   dplyr_0.7.6    
 [9] purrr_0.2.5     readr_1.1.1     tidyr_0.8.1     tibble_1.4.2   
[13] 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.1.19      
 [7] rlang_0.2.1       R.oo_1.22.0       pillar_1.3.0     
[10] glue_1.3.0        withr_2.1.2       R.utils_2.6.0    
[13] modelr_0.1.2      readxl_1.1.0      bindr_0.1.1      
[16] plyr_1.8.4        munsell_0.5.0     gtable_0.2.0     
[19] cellranger_1.1.0  rvest_0.3.2       R.methodsS3_1.7.1
[22] memoise_1.1.0     evaluate_0.11     labeling_0.3     
[25] knitr_1.20        broom_0.5.0       Rcpp_0.12.18     
[28] backports_1.1.2   scales_0.5.0      jsonlite_1.5     
[31] hms_0.4.2         digest_0.6.15     stringi_1.2.4    
[34] grid_3.5.1        rprojroot_1.3-2   cli_1.0.0        
[37] tools_3.5.1       magrittr_1.5      lazyeval_0.2.1   
[40] crayon_1.3.4      whisker_0.3-2     pkgconfig_2.0.1  
[43] MASS_7.3-50       xml2_1.2.0        lubridate_1.7.4  
[46] assertthat_0.2.0  rmarkdown_1.10    httr_1.3.1       
[49] rstudioapi_0.7    R6_2.2.2          nlme_3.1-137     
[52] 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>