<!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" />

<meta name="date" content="2018-11-12" />

<title>Peak coverage along Gene examples</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 coverage along Gene examples</h1>
<h4 class="author"><em>Briana Mittleman</em></h4>
<h4 class="date"><em>11/12/2018</em></h4>

</div>


<p><strong>Last updated:</strong> 2018-11-14</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/f3efe0fc9d70bf7f3fae12b9c17fdbeaf13f132b" target="_blank">f3efe0f</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/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/NuclearApaQTLs.txt
    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/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/peakPerRefSeqGene/
    Untracked:  data/perm_QTL/
    Untracked:  data/perm_QTL_opp/
    Untracked:  data/perm_QTL_trans/
    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/39indQC.Rmd
    Modified:   analysis/chromHmm_enrichment.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/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/f3efe0fc9d70bf7f3fae12b9c17fdbeaf13f132b/analysis/peakGeneCovEx.Rmd" target="_blank">f3efe0f</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-14
</td>
<td style="text-align:left;">
add prop cov plots
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/d4ff15bb6d39d47797377a541e5d96e49afaa4be/docs/peakGeneCovEx.html" target="_blank">d4ff15b</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-14
</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/acc74e7fc3a97b1f103febe1503c47a4a7d65402/analysis/peakGeneCovEx.Rmd" target="_blank">acc74e7</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-14
</td>
<td style="text-align:left;">
add example by genotype plots
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/d254fd2658506a41fe9d2afe08d945f4d0e3fab8/docs/peakGeneCovEx.html" target="_blank">d254fd2</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-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/42991264aeb6f5c4095a40de261e9911fcf125a0/analysis/peakGeneCovEx.Rmd" target="_blank">4299126</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
<td style="text-align:left;">
investigate which peak is sig
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/peakGeneCovEx.html" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-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/f8d8c94dfe19af73199a5127e413af9e28859250/analysis/peakGeneCovEx.Rmd" target="_blank">f8d8c94</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
<td style="text-align:left;">
add plots for peak coverage
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/24821f2e800b26456114ff1400996f16ebbaff3d/docs/peakGeneCovEx.html" target="_blank">24821f2</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-12
</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/7d1bd9ac68750e5346974f06ef39a47987716f90/analysis/peakGeneCovEx.Rmd" target="_blank">7d1bd9a</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-12
</td>
<td style="text-align:left;">
add code for looking at sig gene peaks
</td>
</tr>
</tbody>
</table>
</ul>
<p></details></p>
<hr />
<p>The quantified peak files are:</p>
<ul>
<li>/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc</li>
<li>/project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc</li>
</ul>
<p>I want to grep specific genes and look at the read distribution for peaks along a gene. In these files the peakIDs stil have the peak locations. Before I ran the QTL analysis I changed the final coverage (ex /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.qqnorm_chr$i.gz) to have the TSS as the ID.</p>
<p>Librarys</p>
<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(reshape2)
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(VennDiagram)</code></pre>
<pre><code>Loading required package: grid</code></pre>
<pre><code>Loading required package: futile.logger</code></pre>
<pre class="r"><code>library(data.table)</code></pre>
<pre><code>
Attaching package: &#39;data.table&#39;</code></pre>
<pre><code>The following objects are masked from &#39;package:dplyr&#39;:

    between, first, last</code></pre>
<pre><code>The following object is masked from &#39;package:purrr&#39;:

    transpose</code></pre>
<pre><code>The following objects are masked from &#39;package:reshape2&#39;:

    dcast, melt</code></pre>
<pre class="r"><code>library(ggpubr)</code></pre>
<pre><code>Loading required package: magrittr</code></pre>
<pre><code>
Attaching package: &#39;magrittr&#39;</code></pre>
<pre><code>The following object is masked from &#39;package:purrr&#39;:

    set_names</code></pre>
<pre><code>The following object is masked from &#39;package:tidyr&#39;:

    extract</code></pre>
<pre><code>
Attaching package: &#39;ggpubr&#39;</code></pre>
<pre><code>The following object is masked from &#39;package:VennDiagram&#39;:

    rotate</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:ggpubr&#39;:

    get_legend</code></pre>
<pre><code>The following object is masked from &#39;package:ggplot2&#39;:

    ggsave</code></pre>
<pre class="r"><code>nuc_names=c(&#39;Geneid&#39;,   &#39;Chr&#39;,  &#39;Start&#39;,    &#39;End&#39;,  &#39;Strand&#39;,   &#39;Length&#39;,   &#39;NA18486&#39;   ,&#39;NA18497&#39;, &#39;NA18500&#39;   ,&#39;NA18505&#39;, &#39;NA18508&#39;   ,&#39;NA18511&#39;, &#39;NA18519&#39;,  &#39;NA18520&#39;,  &#39;NA18853&#39;,&#39;NA18858&#39;,    &#39;NA18861&#39;,  &#39;NA18870&#39;   ,&#39;NA18909&#39;  ,&#39;NA18912&#39;  ,&#39;NA18916&#39;, &#39;NA19092&#39;   ,&#39;NA19093&#39;, &#39;NA19119&#39;,  &#39;NA19128&#39;   ,&#39;NA19130&#39;, &#39;NA19131&#39;   ,&#39;NA19137&#39;, &#39;NA19140&#39;,  &#39;NA19141&#39;   ,&#39;NA19144&#39;, &#39;NA19152&#39;   ,&#39;NA19153&#39;, &#39;NA19160&#39;   ,&#39;NA19171&#39;, &#39;NA19193&#39;   ,&#39;NA19200&#39;, &#39;NA19207&#39;,  &#39;NA19209&#39;,  &#39;NA19210&#39;,  &#39;NA19223&#39;   ,&#39;NA19225&#39;, &#39;NA19238&#39;   ,&#39;NA19239&#39;, &#39;NA19257&#39;)


tot_names=c(&#39;Geneid&#39;,   &#39;Chr&#39;,  &#39;Start&#39;,    &#39;End&#39;,  &#39;Strand&#39;,   &#39;Length&#39;,   &#39;NA18486&#39;   ,&#39;NA18497&#39;, &#39;NA18500&#39;   ,&#39;NA18505&#39;, &#39;NA18508&#39;   ,&#39;NA18511&#39;, &#39;NA18519&#39;,  &#39;NA18520&#39;,  &#39;NA18853&#39;,&#39;NA18858&#39;,    &#39;NA18861&#39;,  &#39;NA18870&#39;   ,&#39;NA18909&#39;  ,&#39;NA18912&#39;  ,&#39;NA18916&#39;, &#39;NA19092&#39;   ,&#39;NA19093&#39;, &#39;NA19119&#39;,  &#39;NA19128&#39;   ,&#39;NA19130&#39;, &#39;NA19131&#39;   ,&#39;NA19137&#39;, &#39;NA19140&#39;,  &#39;NA19141&#39;   ,&#39;NA19144&#39;, &#39;NA19152&#39;   ,&#39;NA19153&#39;, &#39;NA19160&#39;   ,&#39;NA19171&#39;, &#39;NA19193&#39;   ,&#39;NA19200&#39;, &#39;NA19207&#39;,  &#39;NA19209&#39;,  &#39;NA19210&#39;,  &#39;NA19223&#39;   ,&#39;NA19225&#39;, &#39;NA19238&#39;   ,&#39;NA19239&#39;, &#39;NA19257&#39;)</code></pre>
<pre class="r"><code>NuclearAPA=read.table(&quot;../data/perm_QTL_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_transcript_permResBH.txt&quot;, stringsAsFactors = F, header=T)  %&gt;% mutate(sig=ifelse(-log10(bh)&gt;=1, 1,0 )) %&gt;%  separate(pid, sep = &quot;:&quot;, into=c(&quot;chr&quot;, &quot;start&quot;, &quot;end&quot;, &quot;id&quot;)) %&gt;% separate(id, sep = &quot;_&quot;, into=c(&quot;gene&quot;, &quot;strand&quot;, &quot;peak&quot;)) %&gt;% filter(sig==1)
totalAPA=read.table(&quot;../data/perm_QTL_trans/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_transcript_permResBH.txt&quot;, stringsAsFactors = F, header=T)  %&gt;% mutate(sig=ifelse(-log10(bh)&gt;=1, 1,0 )) %&gt;%  separate(pid, sep = &quot;:&quot;, into=c(&quot;chr&quot;, &quot;start&quot;, &quot;end&quot;, &quot;id&quot;)) %&gt;% separate(id, sep = &quot;_&quot;, into=c(&quot;gene&quot;, &quot;strand&quot;, &quot;peak&quot;)) %&gt;% filter(sig==1)</code></pre>
<p>examples to look at Nuclear: IRF5, HSF1, NOL9,DCAF16,</p>
<p>Total: NBEAL2, SACM1L, COX7A2L</p>
<pre class="bash"><code>
#nuclear
grep IRF5 /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/IRF5_NuclearCov_peaks.txt

grep HSF1 /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/HSF1_NuclearCov_peaks.txt


grep NOL9 /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/NOL9_NuclearCov_peaks.txt

grep DCAF16 /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/DCAF16_NuclearCov_peaks.txt

grep PPP4C /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/PPP4C_NuclearCov_peaks.txt



#total
grep NBEAL2 /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/NBEAL2_TotalCov_peaks.txt

grep SACM1L /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/SACM1L_TotalCov_peaks.txt



grep TESK1 /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/TESK1_TotalCov_peaks.txt  


grep DGCR14 /project2/gilad/briana/threeprimeseq/data/filtPeakOppstrand_cov/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Total_fixed.fc &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/DGCR14_TotalCov_peaks.txt  
</code></pre>
<p>Copy these to my computer so I can work with them here. I am going to want to make a function that makes the histogram reproducibly for anyfile. I will need to know how many bins to include in the histogram. First I will make the graph for one example then I will make it more general.</p>
<p>Files are in /Users/bmittleman1/Documents/Gilad_lab/threeprimeseq/data/example_gene_peakQuant</p>
<p>Start wit a small file.</p>
<pre class="r"><code>pos=c(3,4,7:39)
PPP4c=read.table(&quot;../data/example_gene_peakQuant/PPP4C_NuclearCov_peaks.txt&quot;, stringsAsFactors = F, col.names = nuc_names) %&gt;% select(pos) 

PPP4c$peaks=seq(0, (nrow(PPP4c)-1))

PPP4c_melt=melt(PPP4c, id.vars=c(&#39;peaks&#39;,&#39;Start&#39;,&#39;End&#39;))</code></pre>
<p>Plot:</p>
<pre class="r"><code>ggplot(PPP4c_melt, aes(x=peaks, y=value, by=variable, fill=variable)) + geom_histogram(stat=&quot;identity&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.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/d4ff15bb6d39d47797377a541e5d96e49afaa4be/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-6-1.png" target="_blank">d4ff15b</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-14
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-6-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Try with actual location as the center of the peak.</p>
<pre class="r"><code>pos=c(3,4,7:39)
PPP4c_2=read.table(&quot;../data/example_gene_peakQuant/PPP4C_NuclearCov_peaks.txt&quot;, stringsAsFactors = F, col.names = tot_names) %&gt;% select(pos)
PPP4c_2$peaks=seq(0, (nrow(PPP4c_2)-1))
PPP4c_2= PPP4c_2 %&gt;% mutate(PeakCenter=(Start+ (End-Start)/2))
PPP4c2_melt=melt(PPP4c_2, id.vars=c(&#39;peaks&#39;,&#39;PeakCenter&#39;, &quot;Start&quot;, &quot;End&quot;))
colnames(PPP4c2_melt)= c(&#39;peaks&#39;,&#39;PeakCenter&#39;, &quot;Start&quot;, &quot;End&quot;, &quot;Individual&quot;, &quot;ReadCount&quot;)</code></pre>
<p>Plot:</p>
<pre class="r"><code>ggplot(PPP4c2_melt, aes(x=PeakCenter, y=ReadCount, by=Individual, fill=Individual)) + geom_histogram(stat=&quot;identity&quot;) + labs(title=&quot;Peak Coverage and Location PP4c&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.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/d4ff15bb6d39d47797377a541e5d96e49afaa4be/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-8-1.png" target="_blank">d4ff15b</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-14
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-8-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Generalize this for more genes:</p>
<pre class="r"><code>makePeakLocplot=function(file, geneName,fraction){
  pos=c(3,4,7:39)
  if (fraction==&quot;Total&quot;){
  gene=read.table(file, stringsAsFactors = F, col.names = tot_names) %&gt;% select(pos)
  }
  else{
    gene=read.table(file, stringsAsFactors = F, col.names = nuc_names) %&gt;% select(pos)
  }
  
  gene$peaks=seq(0, (nrow(gene)-1))
  gene= gene %&gt;% mutate(PeakCenter=(Start+ (End-Start)/2))
  gene_melt=melt(gene, id.vars=c(&#39;peaks&#39;,&#39;PeakCenter&#39;, &quot;Start&quot;, &quot;End&quot;))
  colnames(gene_melt)= c(&#39;peaks&#39;,&#39;PeakCenter&#39;, &quot;Start&quot;, &quot;End&quot;, &quot;Individual&quot;, &quot;ReadCount&quot;)
  finalplot=ggplot(gene_melt, aes(x=PeakCenter, y=ReadCount, by=Individual, fill=Individual)) + geom_histogram(stat=&quot;identity&quot;, show.legend = FALSE) + labs(title=paste(&quot;Peak Coverage and Location&quot;, geneName, sep = &quot; &quot;)) 
  return(finalplot)
}</code></pre>
<p>Try for another gene:</p>
<pre class="r"><code>makePeakLocplot(&quot;../data/example_gene_peakQuant/PPP4C_NuclearCov_peaks.txt&quot;,&#39;PPP4c&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-10-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>makePeakLocplot(&quot;../data/example_gene_peakQuant/DCAF16_NuclearCov_peaks.txt&quot;,&#39;DCAF16&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-11-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>makePeakLocplot(&quot;../data/example_gene_peakQuant/DGCR14_TotalCov_peaks.txt&quot;,&#39;DGCR14&#39;,&quot;Total&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-12-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-12-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-12-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>makePeakLocplot(&quot;../data/example_gene_peakQuant/IRF5_NuclearCov_peaks.txt&quot;,&#39;IRF5&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-13-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>makePeakLocplot(&quot;../data/example_gene_peakQuant/HSF1_NuclearCov_peaks.txt&quot;,&#39;HSF1&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-14-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-14-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-14-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>makePeakLocplot(&quot;../data/example_gene_peakQuant/NOL9_NuclearCov_peaks.txt&quot;,&#39;NOL9&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-15-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-15-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-15-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>makePeakLocplot(&quot;../data/example_gene_peakQuant/SACM1L_TotalCov_peaks.txt&quot;,&#39;SACM1L&#39;,&quot;Total&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-16-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-16-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-16-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Make a function to do this by peak number (ignoring direction)</p>
<pre class="r"><code>makePeakNumplot=function(file, geneName,fraction){
  pos=c(7:39)
  if (fraction==&quot;Total&quot;){
  gene=read.table(file, stringsAsFactors = F, col.names = tot_names) %&gt;% select(pos)
  }
  else{
    gene=read.table(file, stringsAsFactors = F, col.names = nuc_names) %&gt;% select(pos)
  }
  
  gene$peaks=seq(0, (nrow(gene)-1))
  gene_melt=melt(gene, id.vars=c(&#39;peaks&#39;))
  colnames(gene_melt)= c(&#39;peaks&#39;,&quot;Individual&quot;, &quot;ReadCount&quot;)
  finalplot=ggplot(gene_melt, aes(x=peaks, y=ReadCount, by=Individual, fill=Individual)) + geom_histogram(stat=&quot;identity&quot;, show.legend = FALSE) + labs(title=paste(&quot;Peak Coverage&quot;, geneName, sep = &quot; &quot;)) 
  return(finalplot)
}</code></pre>
<p>I can plot them next to eachother using cowplot</p>
<pre class="r"><code>ppp4c_loc=makePeakLocplot(&quot;../data/example_gene_peakQuant/PPP4C_NuclearCov_peaks.txt&quot;,&#39;PPP4c&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>ppp4c_num=makePeakNumplot(&quot;../data/example_gene_peakQuant/PPP4C_NuclearCov_peaks.txt&quot;,&#39;PPP4c&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>plot_grid(ppp4c_loc,ppp4c_num)</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-18-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-18-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-18-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>dcaf16_loc=makePeakLocplot(&quot;../data/example_gene_peakQuant/DCAF16_NuclearCov_peaks.txt&quot;,&#39;DCAF16&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>dcaf16_num=makePeakNumplot(&quot;../data/example_gene_peakQuant/DCAF16_NuclearCov_peaks.txt&quot;,&#39;DCAF16&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>plot_grid(dcaf16_loc,dcaf16_num)</code></pre>
<p><img src="figure/peakGeneCovEx.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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-19-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>dgcr14_loc=makePeakLocplot(&quot;../data/example_gene_peakQuant/DGCR14_TotalCov_peaks.txt&quot;,&#39;DGCR14&#39;,&quot;Total&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>dgcr14_num=makePeakNumplot(&quot;../data/example_gene_peakQuant/DGCR14_TotalCov_peaks.txt&quot;,&#39;DGCR14&#39;,&quot;Total&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>plot_grid(dgcr14_loc,dgcr14_num)</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-20-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-20-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-20-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>irf5_loc=makePeakLocplot(&quot;../data/example_gene_peakQuant/IRF5_NuclearCov_peaks.txt&quot;,&#39;IRF5&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>irf5_num=makePeakNumplot(&quot;../data/example_gene_peakQuant/IRF5_NuclearCov_peaks.txt&quot;,&#39;IRF5&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>plot_grid(irf5_loc,irf5_num)</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-21-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-21-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-21-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>HSF1_loc=makePeakLocplot(&quot;../data/example_gene_peakQuant/HSF1_NuclearCov_peaks.txt&quot;,&#39;HSF1&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>HSF1_num=makePeakNumplot(&quot;../data/example_gene_peakQuant/HSF1_NuclearCov_peaks.txt&quot;,&#39;HSF1&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>plot_grid(HSF1_loc,HSF1_num)</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-22-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-22-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-22-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>NOL9_loc=makePeakLocplot(&quot;../data/example_gene_peakQuant/NOL9_NuclearCov_peaks.txt&quot;,&#39;NOL9&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>NOL9_num=makePeakNumplot(&quot;../data/example_gene_peakQuant/NOL9_NuclearCov_peaks.txt&quot;,&#39;NOL9&#39;,&quot;Nuclear&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>plot_grid(NOL9_loc,NOL9_num)</code></pre>
<p><img src="figure/peakGeneCovEx.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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-23-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>SACM1L_loc=makePeakLocplot(&quot;../data/example_gene_peakQuant/SACM1L_TotalCov_peaks.txt&quot;,&#39;SACM1L&#39;,&quot;Total&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>SACM1L_num=makePeakNumplot(&quot;../data/example_gene_peakQuant/SACM1L_TotalCov_peaks.txt&quot;,&#39;SACM1L&#39;,&quot;Total&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>plot_grid(SACM1L_loc,SACM1L_num)</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-24-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-24-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/e2da5c45d30dcb3df83e5b4abcf50bd0e8bdc675/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-24-1.png" target="_blank">e2da5c4</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>NBEAL2_loc=makePeakLocplot(&quot;../data/example_gene_peakQuant/NBEAL2_TotalCov_peaks.txt&quot;,&#39;NBEAL2&#39;,&quot;Total&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>NBEAL2_num=makePeakNumplot(&quot;../data/example_gene_peakQuant/NBEAL2_TotalCov_peaks.txt&quot;,&#39;NBEAL2&#39;,&quot;Total&quot;)</code></pre>
<pre><code>Warning: Ignoring unknown parameters: binwidth, bins, pad</code></pre>
<pre class="r"><code>plot_grid(NBEAL2_loc,NBEAL2_num)</code></pre>
<p><img src="figure/peakGeneCovEx.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/d254fd2658506a41fe9d2afe08d945f4d0e3fab8/docs/figure/peakGeneCovEx.Rmd/unnamed-chunk-25-1.png" target="_blank">d254fd2</a>
</td>
<td style="text-align:left;">
Briana Mittleman
</td>
<td style="text-align:left;">
2018-11-13
</td>
</tr>
</tbody>
</table>
<p></details></p>
<div id="which-peak-is-sig" class="section level2">
<h2>Which Peak is Sig</h2>
<p>It would be interesting to know which peak in these gene plots is associated with the QTL.</p>
<p>Nuclear: * IRF5 : peak305794-7:128635754, peak305795,128681297, peak305798-7:128661132</p>
<pre class="r"><code>IRF5_all=read.table(&quot;../data/example_gene_peakQuant/IRF5_NuclearCov_peaks.txt&quot;, col.names = nuc_names)</code></pre>
<p>peak305794-peak 4 peak305795-peak 5 peak305798-peak 6</p>
<ul>
<li>HSF1: peak323832- 8:145516593</li>
</ul>
<pre class="r"><code>HSF1_all=read.table(&quot;../data/example_gene_peakQuant/HSF1_NuclearCov_peaks.txt&quot;, col.names = nuc_names)</code></pre>
<p>The QTL is the first peak. (peak 0)</p>
<ul>
<li>NOL9: peak702- 1:6604621</li>
</ul>
<pre class="r"><code>NOL9_all=read.table(&quot;../data/example_gene_peakQuant/NOL9_NuclearCov_peaks.txt&quot;, col.names = nuc_names)</code></pre>
<p>QTL is peak 7 in the graph</p>
<ul>
<li>DCAF16: peak236311- 4:17797455</li>
</ul>
<pre class="r"><code>DCAF16_all=read.table(&quot;../data/example_gene_peakQuant/DCAF16_NuclearCov_peaks.txt&quot;, col.names = nuc_names)</code></pre>
<p>QTL is peak 3 in graph</p>
<ul>
<li>PPP4C: peak122195-16:30482494</li>
</ul>
<pre class="r"><code>pprc_all=read.table(&quot;../data/example_gene_peakQuant/PPP4C_NuclearCov_peaks.txt&quot;, col.names = nuc_names)</code></pre>
<p>The QTL peak is the lower expressed peak (peak1 in graph)</p>
<p>Total: * NBEAL2: peak216374- 3:47080127</p>
<pre class="r"><code>NBEAL2_all=read.table(&quot;../data/example_gene_peakQuant/NBEAL2_TotalCov_peaks.txt&quot;, col.names = tot_names)</code></pre>
<p>peak 15 in graph</p>
<ul>
<li>SACM1L: peak216084-3:45780980, peak216086-3:45780980, peak216087-3:45790569</li>
</ul>
<pre class="r"><code>SACM1L_all=read.table(&quot;../data/example_gene_peakQuant/SACM1L_TotalCov_peaks.txt&quot;, col.names = tot_names)</code></pre>
<p>peak216084-12</p>
<p>peak216086 - 14 (major peak)</p>
<p>peak216087 -15</p>
<ul>
<li>DGCR14: peak204736-22:18647341</li>
</ul>
<pre class="r"><code>DGCR14_all=read.table(&quot;../data/example_gene_peakQuant/DGCR14_TotalCov_peaks.txt&quot;, col.names = tot_names)</code></pre>
<p>peak204736- peak 7</p>
<p>This has shown me that most of the QTL peaks are not the major/most used peak. This leads me to beleive I would get different QTLs if I made one metric per gene because I may ont be able to capture these effects.</p>
</div>
<div id="seperate-by-genotype" class="section level2">
<h2>Seperate by genotype</h2>
<p>It would be good to look at these seperated by genotype.</p>
<ul>
<li>IRF5 : peak305794-7:128635754, peak305795,7:128681297, peak305798-7:128661132</li>
</ul>
<pre class="r"><code>geno_names=c(&#39;CHROM&#39;, &#39;POS&#39;, &#39;snpID&#39;, &#39;REF&#39;, &#39;ALT&#39;, &#39;QUAL&#39;, &#39;FILTER&#39;, &#39;INFO&#39;, &#39;FORMAT&#39;, &#39;NA18486&#39;, &#39;NA18487&#39;, &#39;NA18488&#39;, &#39;NA18489&#39;, &#39;NA18498&#39;, &#39;NA18499&#39;, &#39;NA18501&#39;, &#39;NA18502&#39;, &#39;NA18504&#39;, &#39;NA18505&#39;, &#39;NA18507&#39;, &#39;NA18508&#39;, &#39;NA18510&#39;, &#39;NA18511&#39;, &#39;NA18516&#39;, &#39;NA18517&#39;, &#39;NA18519&#39;, &#39;NA18520&#39;, &#39;NA18522&#39;, &#39;NA18523&#39;, &#39;NA18852&#39;, &#39;NA18853&#39;, &#39;NA18855&#39;, &#39;NA18856&#39;, &#39;NA18858&#39;, &#39;NA18859&#39;, &#39;NA18861&#39;, &#39;NA18862&#39;, &#39;NA18867&#39;, &#39;NA18868&#39;, &#39;NA18870&#39;, &#39;NA18871&#39;, &#39;NA18873&#39;, &#39;NA18874&#39;, &#39;NA18907&#39;, &#39;NA18909&#39;, &#39;NA18910&#39;, &#39;NA18912&#39;, &#39;NA18913&#39;, &#39;NA18916&#39;, &#39;NA18917&#39;, &#39;NA18923&#39;, &#39;NA18924&#39;, &#39;NA18933&#39;, &#39;NA18934&#39;, &#39;NA19093&#39;, &#39;NA19095&#39;, &#39;NA19096&#39;, &#39;NA19098&#39;, &#39;NA19099&#39;, &#39;NA19101&#39;, &#39;NA19102&#39;, &#39;NA19107&#39;, &#39;NA19108&#39;, &#39;NA19113&#39;, &#39;NA19114&#39;, &#39;NA19116&#39;, &#39;NA19117&#39;, &#39;NA19118&#39;, &#39;NA19119&#39;, &#39;NA19121&#39;, &#39;NA19122&#39;, &#39;NA19127&#39;, &#39;NA19128&#39;, &#39;NA19129&#39;, &#39;NA19130&#39;, &#39;NA19131&#39;, &#39;NA19137&#39;, &#39;NA19138&#39;, &#39;NA19140&#39;, &#39;NA19141&#39;, &#39;NA19143&#39;, &#39;NA19144&#39;, &#39;NA19146&#39;, &#39;NA19147&#39;, &#39;NA19149&#39;, &#39;NA19150&#39;, &#39;NA19152&#39;, &#39;NA19153&#39;, &#39;NA19159&#39;, &#39;NA19160&#39;, &#39;NA19171&#39;, &#39;NA19172&#39;, &#39;NA19175&#39;, &#39;NA19176&#39;, &#39;NA19184&#39;, &#39;NA19185&#39;, &#39;NA19189&#39;, &#39;NA19190&#39;, &#39;NA19197&#39;, &#39;NA19198&#39;, &#39;NA19200&#39;, &#39;NA19201&#39;, &#39;NA19203&#39;, &#39;NA19204&#39;, &#39;NA19206&#39;, &#39;NA19207&#39;, &#39;NA19209&#39;, &#39;NA19210&#39;, &#39;NA19213&#39;, &#39;NA19214&#39;, &#39;NA19222&#39;, &#39;NA19223&#39;, &#39;NA19225&#39;, &#39;NA19226&#39;, &#39;NA19235&#39;, &#39;NA19236&#39;, &#39;NA19238&#39;, &#39;NA19239&#39;, &#39;NA19247&#39;, &#39;NA19248&#39;, &#39;NA19256&#39;, &#39;NA19257&#39;)
#the samples I ran the QTLs for
samples=c(&#39;NA18486&#39;,&#39;NA18505&#39;,&#39;NA18508&#39;,&#39;NA18511&#39;,&#39;NA18519&#39;,&#39;NA18520&#39;,&#39;NA18853&#39;,&#39;NA18858&#39;,&#39;NA18861&#39;,&#39;NA18870&#39;,&#39;NA18909&#39;,&#39;NA18912&#39;,&#39;NA18916&#39;,&#39;NA19093&#39;,&#39;NA19119&#39;,&#39;NA19128&#39;,&#39;NA19130&#39;,&#39;NA19131&#39;,&#39;NA19137&#39;,&#39;NA19140&#39;,&#39;NA19141&#39;,&#39;NA19144&#39;,&#39;NA19152&#39;,&#39;NA19153&#39;,&#39;NA19160&#39;,&#39;NA19171&#39;,&#39;NA19200&#39;,&#39;NA19207&#39;,&#39;NA19209&#39;,&#39;NA19210&#39;,&#39;NA19223&#39;,&#39;NA19225&#39;,&#39;NA19238&#39;,&#39;NA19239&#39;,&#39;NA19257&#39;)</code></pre>
<pre class="bash"><code>#grep the genotpe file results to /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/
grep 7:128635754 chr7.dose.filt.vcf &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/Genotypes_7:128635754.txt
grep 7:128681297 chr7.dose.filt.vcf &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/Genotypes_7:128681297.txt
grep 7:128661132 chr7.dose.filt.vcf &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/Genotypes_7:128661132.txt</code></pre>
<p>Transfer to computer:</p>
<p>Make a function to take a file and format it the way I can use it.</p>
<pre class="r"><code>#this gives me 35x1 data frame with the genotpes for each ind at this snp.  
prepare_genotpes=function(file, genName=geno_names, samp=samples){
  geno=read.table(file, col.names=genName, stringsAsFactors = F) %&gt;% select(one_of(samp))
  geno_dose=apply(geno, 2, function(y)sapply(y, function(x)as.integer(strsplit(x,&quot;:&quot;)[[1]][[2]])))
  geno_dose=as.data.frame(geno_dose) %&gt;% rownames_to_column(var=&quot;individual&quot;)
  return(geno_dose)
}

chr7_128681297= prepare_genotpes(&quot;../data/example_gene_peakQuant/Genotypes_7:128681297.txt&quot;)</code></pre>
<p>I want a dataframe that has individual, genotype, then all of the peaks. I also need to remove individuals not in that genotype file.</p>
<pre class="r"><code>IRF5_pheno=IRF5_all%&gt;% select(one_of(samples))
row.names(IRF5_pheno)=paste(&quot;IRF5_peak&quot;, seq(1,nrow(IRF5_all)),sep=&quot;_&quot;)

IRF5_pheno= IRF5_pheno %&gt;% t
IRF5_pheno= as.data.frame(IRF5_pheno) %&gt;% rownames_to_column(var=&quot;individual&quot;)
IRF5_pheno_geno=IRF5_pheno %&gt;% inner_join(chr7_128681297, by=&quot;individual&quot;)
IRF5_pheno_geno_melt= melt(IRF5_pheno_geno, id.vars=c(&quot;geno_dose&quot;, &quot;individual&quot;)) %&gt;% group_by(variable,geno_dose) %&gt;% summarise(mean=mean(value),sd=sd(value))

IRF5_pheno_geno_melt$geno_dose=as.factor(IRF5_pheno_geno_melt$geno_dose)</code></pre>
<pre class="r"><code>irf5_readplot=ggplot(IRF5_pheno_geno_melt,aes(x=variable, y=mean, by=geno_dose, fill=geno_dose)) + geom_bar(stat=&quot;identity&quot;) +theme(axis.text.x = element_text(angle = 90, hjust = 1)) + labs(y=&quot;Mean read count&quot;, x=&quot;Peak&quot;, title=&quot;IRF5 peaks by chr7:128681297 genotype&quot;) +  annotate(&quot;pointrange&quot;, x = 6, y = 750, ymin = 750, ymax = 750,
  colour = &quot;black&quot;, size = 1.5)</code></pre>
<p>Try this with a different gene.</p>
<pre class="bash"><code>#grep the genotpe file results to /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/
grep 16:30482494 chr16.dose.filt.vcf &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/Genotypes_16:30482494.txt
</code></pre>
<pre class="r"><code>chr16_30482494= prepare_genotpes(&quot;../data/example_gene_peakQuant/Genotypes_16:30482494.txt&quot;)


pprc_pheno=pprc_all%&gt;% select(one_of(samples))
row.names(pprc_pheno)=paste(&quot;PPRC_peak&quot;, seq(1,nrow(pprc_all)),sep=&quot;_&quot;)

pprc_pheno= pprc_pheno %&gt;% t
pprc_pheno= as.data.frame(pprc_pheno) %&gt;% rownames_to_column(var=&quot;individual&quot;)
pprc_pheno_geno=pprc_pheno %&gt;% inner_join(chr16_30482494, by=&quot;individual&quot;)
pprc_pheno_geno_melt= melt(pprc_pheno_geno, id.vars=c(&quot;geno_dose&quot;, &quot;individual&quot;)) %&gt;% group_by(variable,geno_dose) %&gt;% summarise(mean=mean(value),sd=sd(value))

pprc_pheno_geno_melt$geno_dose=as.factor(pprc_pheno_geno_melt$geno_dose)</code></pre>
<p>Plot</p>
<pre class="r"><code>pprc_countplot=ggplot(pprc_pheno_geno_melt,aes(x=variable, y=mean, by=geno_dose, fill=geno_dose)) + geom_bar(stat=&quot;identity&quot;) +theme(axis.text.x = element_text(angle = 90, hjust = 1))+ labs(y=&quot;Mean read count&quot;, x=&quot;Peak&quot;, title=&quot;PPRC peaks by 16:30482494 genotype&quot;) +  annotate(&quot;pointrange&quot;, x = 2, y = 20, ymin = 20, ymax = 20,colour = &quot;black&quot;, size = .5)</code></pre>
<p>I want to see if this looks similar when I use the normalized usage from leafcutter (what the QTLs actually ran on)</p>
<p>I am going to grab both the perc. and normalized.</p>
<pre class="bash"><code>

#nuclear
less /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.qqnorm_chr7.gz | grep IRF5 &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/IRF5_NuclearPropCovNorm_peaks.txt

grep IRF5 /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.phen_chr7 &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/IRF5_NuclearPropCov_peaks.txt


less /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.qqnorm_chr16.gz | grep PPP4C &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/PPP4C_NuclearPropCovNorm_peaks.txt

grep PPP4C /project2/gilad/briana/threeprimeseq/data/phenotypes_filtPeakTranscript/filtered_APApeaks_merged_allchrom_refseqGenes.Transcript_sm_quant.Nuclear.pheno_fixed.txt.gz.phen_chr16 &gt; /project2/gilad/briana/threeprimeseq/data/example_gene_peakQuant/PPP4C_NuclearPropCov_peaks.txt</code></pre>
<pre class="r"><code>cov_names=c(&#39;chr&#39;,  &#39;start&#39;,    &#39;end&#39;,  &#39;PeakID&#39;,&#39;NA18486&#39;  ,&#39;NA18497&#39;, &#39;NA18500&#39;   ,&#39;NA18505&#39;, &#39;NA18508&#39;   ,&#39;NA18511&#39;, &#39;NA18519&#39;,  &#39;NA18520&#39;,  &#39;NA18853&#39;,&#39;NA18858&#39;,    &#39;NA18861&#39;,  &#39;NA18870&#39;   ,&#39;NA18909&#39;  ,&#39;NA18912&#39;  ,&#39;NA18916&#39;, &#39;NA19092&#39;   ,&#39;NA19093&#39;, &#39;NA19119&#39;,  &#39;NA19128&#39;   ,&#39;NA19130&#39;, &#39;NA19131&#39;   ,&#39;NA19137&#39;, &#39;NA19140&#39;,  &#39;NA19141&#39;   ,&#39;NA19144&#39;, &#39;NA19152&#39;   ,&#39;NA19153&#39;, &#39;NA19160&#39;   ,&#39;NA19171&#39;, &#39;NA19193&#39;   ,&#39;NA19200&#39;, &#39;NA19207&#39;,  &#39;NA19209&#39;,  &#39;NA19210&#39;,  &#39;NA19223&#39;   ,&#39;NA19225&#39;, &#39;NA19238&#39;   ,&#39;NA19239&#39;, &#39;NA19257&#39;)

IRF5cov_all=read.table(&quot;../data/example_gene_peakQuant/IRF5_NuclearPropCov_peaks.txt&quot;, col.names = cov_names)
IRF5covNorm_all=read.table(&quot;../data/example_gene_peakQuant/IRF5_NuclearPropCovNorm_peaks.txt&quot;, col.names = cov_names)


IRF5cov_pheno=IRF5cov_all%&gt;% select(one_of(samples))
row.names(IRF5cov_pheno)=paste(&quot;IRF5_peak&quot;, seq(1,nrow(IRF5cov_all)),sep=&quot;_&quot;)

IRF5cov_pheno= IRF5cov_pheno %&gt;% t
IRF5cov_pheno= as.data.frame(IRF5cov_pheno) %&gt;% rownames_to_column(var=&quot;individual&quot;)
IRF5cov_pheno_geno=IRF5cov_pheno %&gt;% inner_join(chr7_128681297, by=&quot;individual&quot;)
IRF5cov_pheno_geno_melt= melt(IRF5cov_pheno_geno, id.vars=c(&quot;geno_dose&quot;, &quot;individual&quot;)) %&gt;% group_by(variable,geno_dose) %&gt;% summarise(mean=mean(value),sd=sd(value))

IRF5cov_pheno_geno_melt$geno_dose=as.factor(IRF5cov_pheno_geno_melt$geno_dose)


irf5_covplot=ggplot(IRF5cov_pheno_geno_melt,aes(x=variable, y=mean, by=geno_dose, fill=geno_dose)) + geom_bar(stat=&quot;identity&quot;,position = &quot;dodge&quot;) +theme(axis.text.x = element_text(angle = 90, hjust = 1)) +labs(y=&quot;Mean Coverage Prop&quot;, x=&quot;Peak&quot;, title=&quot;IRF5 peaks by chr7:128681297 genotype&quot;) + annotate(&quot;pointrange&quot;, x = 6, y = .75, ymin = .750, ymax = .750,colour = &quot;black&quot;, size = .5)</code></pre>
<pre class="r"><code>IRF5covNorm_pheno=IRF5covNorm_all%&gt;% select(one_of(samples))
row.names(IRF5covNorm_pheno)=paste(&quot;IRF5_peak&quot;, seq(1,nrow(IRF5covNorm_all)),sep=&quot;_&quot;)

IRF5covNorm_pheno= IRF5covNorm_pheno %&gt;% t
IRF5covNorm_pheno= as.data.frame(IRF5covNorm_pheno) %&gt;% rownames_to_column(var=&quot;individual&quot;)
IRF5covNorm_pheno_geno=IRF5covNorm_pheno %&gt;% inner_join(chr7_128681297, by=&quot;individual&quot;)
IRF5covNorm_pheno_geno_melt= melt(IRF5covNorm_pheno_geno, id.vars=c(&quot;geno_dose&quot;, &quot;individual&quot;)) %&gt;% group_by(variable,geno_dose) %&gt;% summarise(mean=mean(value),sd=sd(value))

IRF5covNorm_pheno_geno_melt$geno_dose=as.factor(IRF5covNorm_pheno_geno_melt$geno_dose)


irf5_normplot=ggplot(IRF5covNorm_pheno_geno_melt,aes(x=variable, y=mean, by=geno_dose, fill=geno_dose)) + geom_bar(stat=&quot;identity&quot;,position = &quot;dodge&quot;) +theme(axis.text.x = element_text(angle = 90, hjust = 1)) +labs(y=&quot;Mean Normalized Coverage Prop&quot;, x=&quot;Peak&quot;, title=&quot;IRF5 peaks by chr7:128681297 genotype&quot;) + annotate(&quot;pointrange&quot;, x = 6, y = .75, ymin = .750, ymax = .750,colour = &quot;black&quot;, size = .5)</code></pre>
<pre class="r"><code>pprccov_all=read.table(&quot;../data/example_gene_peakQuant/PPP4C_NuclearPropCov_peaks.txt&quot;, col.names = cov_names)
pprccovNorm_all=read.table(&quot;../data/example_gene_peakQuant/PPP4C_NuclearPropCovNorm_peaks.txt&quot;, col.names = cov_names)


pprcCov_pheno=pprccov_all%&gt;% select(one_of(samples))
row.names(pprcCov_pheno)=paste(&quot;PPRC_peak&quot;, seq(1,nrow(pprccov_all)),sep=&quot;_&quot;)

pprcCov_pheno= pprcCov_pheno %&gt;% t
pprcCov_pheno= as.data.frame(pprcCov_pheno) %&gt;% rownames_to_column(var=&quot;individual&quot;)
pprcCov_pheno_geno=pprcCov_pheno %&gt;% inner_join(chr16_30482494, by=&quot;individual&quot;)
pprcCov_pheno_geno_melt= melt(pprcCov_pheno_geno, id.vars=c(&quot;geno_dose&quot;, &quot;individual&quot;)) %&gt;% group_by(variable,geno_dose) %&gt;% summarise(mean=mean(value),sd=sd(value))

pprcCov_pheno_geno_melt$geno_dose=as.factor(pprcCov_pheno_geno_melt$geno_dose)

pprc_covplot=ggplot(pprcCov_pheno_geno_melt,aes(x=variable, y=mean, by=geno_dose, fill=geno_dose)) + geom_bar(stat=&quot;identity&quot;,position = &#39;dodge&#39;) +theme(axis.text.x = element_text(angle = 90, hjust = 1))+ labs(y=&quot;Mean coverage proportion&quot;, x=&quot;Peak&quot;, title=&quot;PPRC peaks by 16:30482494 genotype&quot;) + annotate(&quot;pointrange&quot;, x = 2, y = .4, ymin = .4, ymax = .4,colour = &quot;black&quot;, size = .5)</code></pre>
<pre class="r"><code>pprcCovNorm_pheno=pprccovNorm_all%&gt;% select(one_of(samples))
row.names(pprcCovNorm_pheno)=paste(&quot;PPRC_peak&quot;, seq(1,nrow(pprccovNorm_all)),sep=&quot;_&quot;)

pprcCovNorm_pheno= pprcCovNorm_pheno %&gt;% t
pprcCovNorm_pheno= as.data.frame(pprcCovNorm_pheno) %&gt;% rownames_to_column(var=&quot;individual&quot;)
pprcCovNorm_pheno_geno=pprcCovNorm_pheno %&gt;% inner_join(chr16_30482494, by=&quot;individual&quot;)
pprcCovNorm_pheno_geno_melt= melt(pprcCovNorm_pheno_geno, id.vars=c(&quot;geno_dose&quot;, &quot;individual&quot;)) %&gt;% group_by(variable,geno_dose) %&gt;% summarise(mean=mean(value),sd=sd(value))

pprcCovNorm_pheno_geno_melt$geno_dose=as.factor(pprcCovNorm_pheno_geno_melt$geno_dose)

pprc_normplot=ggplot(pprcCovNorm_pheno_geno_melt,aes(x=variable, y=mean, by=geno_dose, fill=geno_dose)) + geom_bar(stat=&quot;identity&quot;,position = &#39;dodge&#39;) +theme(axis.text.x = element_text(angle = 90, hjust = 1))+ labs(y=&quot;Mean coverage proportion&quot;, x=&quot;Peak&quot;, title=&quot;PPRC peaks by 16:30482494 genotype&quot;) + annotate(&quot;pointrange&quot;, x = 2, y = 1, ymin = 1, ymax = 1,colour = &quot;black&quot;, size = .5)</code></pre>
<pre class="r"><code>plot_grid(irf5_readplot,irf5_covplot,irf5_normplot)</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-47-1.png" width="672" style="display: block; margin: auto;" /></p>
<pre class="r"><code>plot_grid(pprc_countplot,pprc_covplot,pprc_normplot)</code></pre>
<p><img src="figure/peakGeneCovEx.Rmd/unnamed-chunk-48-1.png" width="672" style="display: block; margin: auto;" /></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] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] bindrcpp_0.2.2      cowplot_0.9.3       ggpubr_0.1.8       
 [4] magrittr_1.5        data.table_1.11.8   VennDiagram_1.6.20 
 [7] futile.logger_1.4.3 forcats_0.3.0       stringr_1.3.1      
[10] dplyr_0.7.6         purrr_0.2.5         readr_1.1.1        
[13] tidyr_0.8.1         tibble_1.4.2        ggplot2_3.0.0      
[16] tidyverse_1.2.1     reshape2_1.4.3      workflowr_1.1.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          backports_1.1.2      scales_1.0.0        
[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          lazyeval_0.2.1       futile.options_1.0.1
[40] crayon_1.3.4         whisker_0.3-2        pkgconfig_2.0.2     
[43] xml2_1.2.0           lubridate_1.7.4      assertthat_0.2.0    
[46] rmarkdown_1.10       httr_1.3.1           rstudioapi_0.8      
[49] R6_2.3.0             nlme_3.1-137         git2r_0.23.0        
[52] 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>