<!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>APAqtls with Leafcutter</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">APAqtls with Leafcutter</h1>
<h4 class="author"><em>Briana Mittleman</em></h4>
<h4 class="date"><em>8/15/2018</em></h4>

</div>


<p><strong>Last updated:</strong> 2018-08-23</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/f5c2ce22cc4a378370c860fe754af7108ae5e565" target="_blank">f5c2ce2</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/ncbiRefSeq_sm.sort.mRNA.bed
    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/nom_QTL/
    Untracked:  data/nuc6up/
    Untracked:  data/perm_QTL/
    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/cleanupdtseq.internalpriming.Rmd
    Modified:   analysis/dif.iso.usage.leafcutter.Rmd
    Modified:   analysis/explore.filters.Rmd
    Modified:   analysis/peak.cov.pipeline.Rmd
    Modified:   analysis/pheno.leaf.comb.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/f5c2ce22cc4a378370c860fe754af7108ae5e565/analysis/apaQTLwLeafcutter.Rmd" target="_blank">f5c2ce2</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-23
</td>
<td style="text-align:left;">
work more on locus zoom prob
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/b33443c60c0bd42e7b003489770307bad95a9ad9/docs/apaQTLwLeafcutter.html" target="_blank">b33443c</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-23
</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/c1f8d60cea58fda6cfc80bba454436ef2f2283b1/analysis/apaQTLwLeafcutter.Rmd" target="_blank">c1f8d60</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-23
</td>
<td style="text-align:left;">
add qtc characteristics
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/886dc9ad76de9047aa1ad906bd11cd22a27bb678/docs/apaQTLwLeafcutter.html" target="_blank">886dc9a</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-23
</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/dd07e10cdb16919eb06e59fe14083cef31b49fa5/analysis/apaQTLwLeafcutter.Rmd" target="_blank">dd07e10</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-23
</td>
<td style="text-align:left;">
box plot for top snps
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/apaQTLwLeafcutter.html" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</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/0fbf10b5c4210bd78d27d0b0f8da4927323a12f5/analysis/apaQTLwLeafcutter.Rmd" target="_blank">0fbf10b</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
<td style="text-align:left;">
work on plotting top QTL
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/bd21c34a85376d7d769ed310b9c7f128c23634a9/docs/apaQTLwLeafcutter.html" target="_blank">bd21c34</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</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/5ffffe1b8cc40aef93b6f4d5f768087f315a450c/analysis/apaQTLwLeafcutter.Rmd" target="_blank">5ffffe1</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
<td style="text-align:left;">
BH result plots
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/b6e6ed906c8e7e19ee7eafb7a2eb6e3cd20023bb/docs/apaQTLwLeafcutter.html" target="_blank">b6e6ed9</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</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/73516a698eb437501aa622955fecb92beb197dc5/analysis/apaQTLwLeafcutter.Rmd" target="_blank">73516a6</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
<td style="text-align:left;">
chr1 results
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/d682ab62f513ea83a98564f2e54d7f39ed752f3c/docs/apaQTLwLeafcutter.html" target="_blank">d682ab6</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</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/a3c44fb46f6e13e5eefd54b8400b3104527f4de6/analysis/apaQTLwLeafcutter.Rmd" target="_blank">a3c44fb</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
<td style="text-align:left;">
add code for permute fastqtl
</td>
</tr>
<tr>
<td style="text-align:left;">
html
</td>
<td style="text-align:left;">
<a href="https://cdn.rawgit.com/brimittleman/threeprimeseq/5564e259b7b24257b0d4e275873dafca7b024166/docs/apaQTLwLeafcutter.html" target="_blank">5564e25</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-20
</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/6b1b51c30cedc1bbdf21009104f126a8b4add401/analysis/apaQTLwLeafcutter.Rmd" target="_blank">6b1b51c</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-20
</td>
<td style="text-align:left;">
start qtl analsis, add to index
</td>
</tr>
</tbody>
</table>
</ul>
<p></details></p>
<hr />
<p>I need to run fastQTL to call the apaQTLs.</p>
<p>Imputed snp: /project2/yangili1/tonyzeng/genotyping/imputation_results/ `</p>
<pre class="bash"><code>module load samtools
#zip file 
gzip filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt 

module load python
#leafcutter script
python /project2/gilad/briana/threeprimeseq/code/prepare_phenotype_table.py filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz 

#source activate three-prime-env
sh filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz_prepare.sh

#run for nuclear as well 
gzip filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt 
#unload anaconda, load python
python /project2/gilad/briana/threeprimeseq/code/prepare_phenotype_table.py filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz 
#load anaconda and env. 
sh filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz_prepare.sh

#filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.PCs
#filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.PCs
</code></pre>
<p>makeSamplelist.py</p>
<pre class="bash"><code>#make a sample list  

fout = file(&quot;/project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/SAMPLE.txt&quot;,&#39;w&#39;)

for ln in open(&quot;/project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/file_id_mapping_nuc.txt&quot;, &quot;r&quot;):
    bam, sample = ln.split()
    line=sample[:-2]
    fout.write(&quot;NA&quot;+line + &quot;\n&quot;)
fout.close()
</code></pre>
<p>APAqtl_nominal_nuc.sh</p>
<pre class="bash"><code>#!/bin/bash


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

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/nominal_APAqtl/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.qqnorm_chr$i.nominal.out --chunk 1 1  --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/SAMPLE.txt
done
</code></pre>
<p><strong>Remove the non matching ind. from the sample list.</strong></p>
<p>Remove 18500, 19092 and 19193, 18497</p>
<p>Try it on the total ones:</p>
<p>APAqtl_nominal_tot.sh</p>
<pre class="bash"><code>#!/bin/bash


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

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/nominal_APAqtl/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.qqnorm_chr$i.nominal.out --chunk 1 1  --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/SAMPLE.txt
done
</code></pre>
<div id="filter-dose-files" class="section level3">
<h3>Filter dose files</h3>
<p>I need to remove non snps and snps with &lt;.05 from the dosage file.</p>
<p>I will first copy all of the dosage files to my direcory instead of changing tonys.</p>
<pre class="bash"><code>cp *dose.vcf.gz /project2/gilad/briana/YRI_geno_hg19/</code></pre>
<p>I want to write a python script that will read in the files and perform the filters.</p>
<p>I wrote a python script that take in the dose file and a name of an out file. I will write a bash script to wrap this on all of the chrs.</p>
<pre class="bash"><code>#!/bin/bash


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

module load python

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 
do 
python filter_vcf.py chr$i.dose.vcf chr$i.dose.filt.vcf
done</code></pre>
<p>Now I can use these for the fastqtl script instead.</p>
<p>I also updated to only use the first 2 pcs as covariates.</p>
</div>
<div id="run-permuted-version" class="section level2">
<h2>Run permuted version</h2>
<p>Permutation pass to calculate correctedp-values for molecular phenotypes.</p>
<p>APAqtl_perm_tot.sh</p>
<pre class="bash"><code>#!/bin/bash


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

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/perm_APAqtl/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.qqnorm_chr$i.perm.out --chunk 1 1  --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/SAMPLE.txt
done
</code></pre>
<p>APAqtl_perm_nuc.sh</p>
<pre class="bash"><code>#!/bin/bash


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

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/perm_APAqtl/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.qqnorm_chr$i.perm.out --chunk 1 1  --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/SAMPLE.txt
done
</code></pre>
<p>Try with normal approximation for the chroms that dont work:</p>
<p>APAqtl_perm_norm_tot.sh</p>
<pre class="bash"><code>#!/bin/bash


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

for i in 13 18 
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --normal --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/perm_APAqtl/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.qqnorm_chr$i.perm.norm.out --chunk 1 1  --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/SAMPLE.txt
done
</code></pre>
<p>APAqtl_perm_norm_nuc.sh</p>
<pre class="bash"><code>#!/bin/bash


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

for i in 3 13
do
/home/brimittleman/software/bin/FastQTL/bin/fastQTL.static --permute 1000 --normal --vcf /project2/gilad/briana/YRI_geno_hg19/chr$i.dose.filt.vcf.gz --cov /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.2PCs --bed /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.qqnorm_chr$i.gz --out /project2/gilad/briana/threeprimeseq/data/perm_APAqtl/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.qqnorm_chr$i.perm.norm.out --chunk 1 1  --window 5e4 --include-samples /project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/SAMPLE.txt
done</code></pre>
</div>
<div id="evaluate-the-results" class="section level2">
<h2>Evaluate the results</h2>
<p>The results file has the folowing columns:</p>
<ul>
<li>ID of the tested molecular phenotype (in this particular case, the gene ID)<br />
</li>
<li>Number of variants tested in cis for this phenotype<br />
</li>
<li>MLE of the shape1 parameter of the Beta distribution<br />
</li>
<li>MLE of the shape2 parameter of the Beta distribution<br />
</li>
<li>Dummy [To be described later]<br />
</li>
<li>ID of the best variant found for this molecular phenotypes (i.e. with the smallest p-value)<br />
</li>
<li>Distance between the molecular phenotype - variant pair<br />
</li>
<li>The nominal p-value of association that quantifies how significant from 0, the regression coefficient is<br />
</li>
<li>The slope associated with the nominal p-value of association [only in version &gt; v2-184]<br />
</li>
<li>A first permutation p-value directly obtained from the permutations with the direct method. This is basically a corrected version of the nominal p-value that accounts for the fact that multiple variants are tested per molecular phenotype.<br />
</li>
<li>A second permutation p-value obtained via beta approximation. We advice to use this one in any downstream analysis.</li>
</ul>
<p>I can check the experiments as recomended by the FastQTL site.</p>
<pre class="r"><code>d = read.table(&quot;permutations.all.chunks.txt.gz&quot;, hea=F, stringsAsFactors=F)
colnames(d) = c(&quot;pid&quot;, &quot;nvar&quot;, &quot;shape1&quot;, &quot;shape2&quot;, &quot;dummy&quot;, &quot;sid&quot;, &quot;dist&quot;, &quot;npval&quot;, &quot;ppval&quot;, &quot;bpval&quot;)
plot(d$ppval, d$bpval, xlab=&quot;Direct method&quot;, ylab=&quot;Beta approximation&quot;, main=&quot;Check plot&quot;)
abline(0, 1, col=&quot;red&quot;)</code></pre>
<p>I will try this first on the resutls from chr1.</p>
<pre class="r"><code>nuc.chr1= read.table(&quot;../data/perm_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.qqnorm_chr1.perm.out&quot;,head=F, stringsAsFactors=F, col.names = c(&quot;pid&quot;, &quot;nvar&quot;, &quot;shape1&quot;, &quot;shape2&quot;, &quot;dummy&quot;, &quot;sid&quot;, &quot;dist&quot;, &quot;npval&quot;, &quot;slope&quot;, &quot;ppval&quot;, &quot;bpval&quot;))


plot(nuc.chr1$ppval, nuc.chr1$bpval, xlab=&quot;Direct method&quot;, ylab=&quot;Beta approximation&quot;, main=&quot;Nuclear Check plot&quot;)
abline(0, 1, col=&quot;red&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-12-1.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/b6e6ed906c8e7e19ee7eafb7a2eb6e3cd20023bb/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-12-1.png" target="_blank">b6e6ed9</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>tot.chr1=read.table(&quot;../data/perm_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.qqnorm_chr1.perm.out&quot;, head=F, stringsAsFactors = F, col.names= c(&quot;pid&quot;, &quot;nvar&quot;, &quot;shape1&quot;, &quot;shape2&quot;, &quot;dummy&quot;, &quot;sid&quot;, &quot;dist&quot;, &quot;npval&quot;, &quot;slope&quot;, &quot;ppval&quot;, &quot;bpval&quot;))


plot(tot.chr1$ppval, tot.chr1$bpval, xlab=&quot;Direct method&quot;, ylab=&quot;Beta approximation&quot;, main=&quot;Total Check plot&quot;)
abline(0, 1, col=&quot;red&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-12-2.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-12-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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-12-2.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/b6e6ed906c8e7e19ee7eafb7a2eb6e3cd20023bb/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-12-2.png" target="_blank">b6e6ed9</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Correct for multiple testing:</p>
<ul>
<li>Bonferonni</li>
</ul>
<pre class="r"><code>nuc.chr1$bonferroni = p.adjust(nuc.chr1$bpval, method=&quot;bonferroni&quot;)

plot(-log10(nuc.chr1$bonferroni), main=&quot;Nuclear chr1 bonferroni corrected pval&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-13-1.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/bd21c34a85376d7d769ed310b9c7f128c23634a9/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-13-1.png" target="_blank">bd21c34</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>tot.chr1$bonferroni = p.adjust(tot.chr1$bpval, method=&quot;bonferroni&quot;)

plot(-log10(tot.chr1$bonferroni),  main=&quot;Total chr1 bonferroni corrected pval&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-13-2.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-13-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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-13-2.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/bd21c34a85376d7d769ed310b9c7f128c23634a9/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-13-2.png" target="_blank">bd21c34</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>&lt; .05 is 1.3 on this plot.</p>
<ul>
<li>BH</li>
</ul>
<pre class="r"><code>nuc.chr1$bh=p.adjust(nuc.chr1$bpval, method=&quot;fdr&quot;)

plot(-log10(nuc.chr1$bh), main=&quot;Nuclear chr1 BH corrected pval&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-14-1.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/bd21c34a85376d7d769ed310b9c7f128c23634a9/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-14-1.png" target="_blank">bd21c34</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>tot.chr1$bh=p.adjust(tot.chr1$bpval, method=&quot;fdr&quot;)
plot(-log10(tot.chr1$bh), main=&quot;Total chr1 BH corrected pval&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-14-2.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-14-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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-14-2.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
<tr>
<td style="text-align:left;">
<a href="https://github.com/brimittleman/threeprimeseq/blob/bd21c34a85376d7d769ed310b9c7f128c23634a9/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-14-2.png" target="_blank">bd21c34</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-21
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>10% FDR is 1 on this plot.</p>
<p>Extend to all results:</p>
<pre class="r"><code>nuc.res= read.table(&quot;../data/perm_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_permQTLresults.out&quot;,head=F, stringsAsFactors=F, col.names = c(&quot;pid&quot;, &quot;nvar&quot;, &quot;shape1&quot;, &quot;shape2&quot;, &quot;dummy&quot;, &quot;sid&quot;, &quot;dist&quot;, &quot;npval&quot;, &quot;slope&quot;, &quot;ppval&quot;, &quot;bpval&quot;))


plot(nuc.res$ppval, nuc.res$bpval, xlab=&quot;Direct method&quot;, ylab=&quot;Beta approximation&quot;, main=&quot;Nuclear Check plot&quot;)
abline(0, 1, col=&quot;red&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-15-1.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>tot.res=read.table(&quot;../data/perm_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_permQTLresults.out&quot;, head=F, stringsAsFactors = F, col.names= c(&quot;pid&quot;, &quot;nvar&quot;, &quot;shape1&quot;, &quot;shape2&quot;, &quot;dummy&quot;, &quot;sid&quot;, &quot;dist&quot;, &quot;npval&quot;, &quot;slope&quot;, &quot;ppval&quot;, &quot;bpval&quot;))


plot(tot.res$ppval, tot.res$bpval, xlab=&quot;Direct method&quot;, ylab=&quot;Beta approximation&quot;, main=&quot;Total Check plot&quot;)
abline(0, 1, col=&quot;red&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-15-2.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-15-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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-15-2.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
</tbody>
</table>
<p></details></p>
<ul>
<li>BH</li>
</ul>
<pre class="r"><code>nuc.res$bh=p.adjust(nuc.res$bpval, method=&quot;fdr&quot;)

plot(-log10(nuc.res$bh), main=&quot;Nuclear BH corrected pval&quot;)
abline(h=1, col=&quot;red&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-16-1.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
</tbody>
</table>
<p></details></p>
<pre class="r"><code>tot.res$bh=p.adjust(tot.res$bpval, method=&quot;fdr&quot;)
plot(-log10(tot.res$bh), main=&quot;Total BH corrected pval&quot;)
abline(h=1, col=&quot;red&quot;)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-16-2.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-16-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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-16-2.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Next steps:</p>
<ul>
<li><p>make plots for some of these snps</p></li>
<li>/project2/yangili1/yangili/APAqtl/output/ceu.apaqtl.txt.gz.bh.txt (use nominal pvalue)<br />
</li>
<li><ol style="list-style-type: decimal">
<li>plot a qqplot with only these SNPs<br />
</li>
</ol></li>
<li><ol start="2" style="list-style-type: decimal">
<li>plot a qqplot with all SNPs that you tested</li>
</ol></li>
</ul>
<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(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(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>ceu_QTL=read.table(&quot;../data/nom_QTL/ceu.apaqtl.txt.gz.bh.txt&quot;, header = T, stringsAsFactors = F)
nom_nuc=read.table(&quot;../data/nom_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_nomQTLresults.out&quot;, head=F, stringsAsFactors = F, col.names = c(&quot;peakID&quot;, &quot;snpID&quot;, &quot;dist&quot;, &quot;Nuc_pval&quot;, &quot;slope&quot;))
nom_tot=read.table(&quot;../data/nom_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_nomQTLresults.out&quot;,head=F , stringsAsFactors = F,  col.names = c(&quot;peakID&quot;, &quot;snpID&quot;, &quot;dist&quot;, &quot;tot_pval&quot;, &quot;slope&quot;))</code></pre>
<p>First I want to filter the CEU data just for snps. Then I want to reformat them to be in the same configuration as the nps in my results.</p>
<p>chr#:pos</p>
<pre class="r"><code>ceu_QTL_snp=ceu_QTL %&gt;% filter(grepl(&quot;snp&quot;, dummy2)) %&gt;% separate(dummy2, c(&quot;type&quot;, &quot;chr&quot;, &quot;loc&quot;), sep=&quot;_&quot;) %&gt;% unite(snpID, c(&quot;chr&quot;, &quot;loc&quot;), sep=&quot;:&quot;)</code></pre>
<p>Join the data frames by the snp ID.</p>
<pre class="r"><code>ceuAndTot= ceu_QTL_snp %&gt;% inner_join(nom_tot, by=&quot;snpID&quot;) %&gt;% select(snpID, bpval, tot_pval)



ceuAndNuc= ceu_QTL_snp %&gt;% inner_join(nom_nuc, by=&quot;snpID&quot;) %&gt;% select(snpID, bpval, Nuc_pval)</code></pre>
<pre class="r"><code>tot_ceuSNPS=runif(nrow(ceuAndTot))

nuc_ceuSNPS=runif(nrow(ceuAndNuc))</code></pre>
<pre class="r"><code>par(mfrow=c(1,2))
qqplot(-log10(tot_ceuSNPS), -log10(ceuAndTot$tot_pval), ylab=&quot;-log10 Total pvalues&quot;, xlab=&quot;Uniform expectation&quot;, main=&quot;Total pvalues for in CEU snps&quot;)
abline(0,1)


qqplot(-log10(nuc_ceuSNPS), -log10(ceuAndNuc$Nuc_pva), ylab=&quot;-log10 Nuclear pvalues&quot;, xlab=&quot;Uniform expectation&quot;, main=&quot;Nuclear pvalues for in CEU snps&quot;)
abline(0,1)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-22-1.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Try with all of the snps:</p>
<pre class="r"><code>par(mfrow=c(1,2))


qqplot(-log10(runif(nrow(nom_tot))), -log10(nom_tot$tot_pval), ylab=&quot;-log10 Total pvalue&quot;, xlab=&quot;Uniform expectation&quot;, main=&quot;Total pvalues for all snps&quot;)
abline(0,1)

qqplot(-log10(runif(nrow(nom_nuc))), -log10(nom_nuc$Nuc_pval), ylab=&quot;-log10 Nuclear pvalue&quot;, xlab=&quot;Uniform expectation&quot;,main= &quot;Nuclear pvalues for all snps&quot;)
abline(0,1)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-23-1.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Try this with te permuted pvalues:</p>
<pre class="r"><code>par(mfrow=c(1,2))
qqplot(-log10(runif(nrow(tot.res))), -log10(tot.res$bpval),ylab=&quot;-log10 Total permuted pvalue&quot;, xlab=&quot;Uniform expectation&quot;, main=&quot;Total permuted pvalues for all snps&quot;)
abline(0,1)

qqplot(-log10(runif(nrow(nuc.res))), -log10(nuc.res$bpval), ylab=&quot;-log10 Nuclear permuted pvalue&quot;, xlab=&quot;Uniform expectation&quot;, main=&quot;Nuclear permuted pvalues for all snps&quot;)
abline(0,1)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.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/c8f2c7d972f17a18a3b8d24ed14af92eb96fc821/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-24-1.png" target="_blank">c8f2c7d</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-22
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>Locus zoom plots to vizualize the top QTLs:</p>
<p>Kenneth gave me this code for making these plots. I can modify this code.</p>
<pre class="r"><code>plot_locuszoom &lt;- function(this, gen, xlim, ylim, ...)
{
  
  #this is a r object that will have the results from the fastqtl and the genotypes 
  #this$annotations has gene, snp, dist, pvalue, beta, rsid, chr, pos, bpval, and other extra annotations about the snps
  rbPal &lt;- colorRampPalette(c(&#39;lightblue&#39;,&#39;blue&#39;,&#39;purple&#39;,&#39;red&#39;))(101)
  cols &lt;- c()
  
  # gotta figure out how everythign correlates with this snp
  # row &lt;- which(this$annotations$rsid==snp)
  # gen &lt;- as.numeric(this$genotypes[row,10:129])
  nrow &lt;- nrow(this$annotations)
  cors &lt;- sapply(1:nrow, function(j) cor(gen, as.numeric(this$genotypes[j,10:33])))
  
  cols &lt;- c()
  for (j in 1:nrow) cols[j] &lt;- rbPal[round(100*(cors[j])^2)+1]
  
  plot.new()
  plot.window(xlim=xlim, ylim=ylim, xlab=&#39;position&#39;, ylab=&#39;-log10(p-value)&#39;, ...)

 
  points(x=this$annotations$pos, y=-log(this$annotations$bpval,10), pch=19, col=cols)
  axis(2)
  box()
  mtext(&#39;-log10(p-value)&#39;, side=2, line=2, cex=0.7)
}</code></pre>
<p>I will try this with the top total snp first. It is in chrom15, the snip id is 15:76191353. I want to pull genotypes for snp within 50000 bases (window size).</p>
<p>I can write a python script that takes a snp position and filters only the snps 25000 up and 25000 downstream of this snp. I can subset just the individuals in the sample list once i move this into R.</p>
<p>Need to make sure to unzip the specfici vcf file first.</p>
<pre class="bash"><code>python filter_geno.py  15 76191353 /project2/gilad/briana/threeprimeseq/data/filtered_geno/chrom15pos76191353.vcf
</code></pre>
<pre class="r"><code>samples=c(&quot;NA18486&quot;,&quot;NA18505&quot;, &#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;NA18916&#39;,&#39;NA19119&#39;,&#39;NA19128&#39;,&#39;NA19130&#39;,&#39;NA19141&#39;,&#39;NA19160&#39;,&#39;NA19209&#39;,&#39;NA19210&#39;,&#39;NA19223&#39;,&#39;NA19225&#39;,&#39;NA19238&#39;,&#39;NA19239&#39;,&#39;NA19257&#39;)


chr15.76191353geno=read.table(&quot;../data/perm_QTL/chrom15pos76191353.vcf&quot;, col.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;), stringsAsFactors = F) %&gt;% select(one_of(samples))

chr15.76191353geno_anno=read.table(&quot;../data/perm_QTL/chrom15pos76191353.vcf&quot;, col.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;), stringsAsFactors = F) %&gt;% select(CHROM, POS, snpID, REF, ALT, QUAL, FILTER, INFO, FORMAT)
chr15.76191353geno_dose=apply(chr15.76191353geno, 2, function(y)sapply(y, function(x)as.integer(strsplit(x,&quot;:&quot;)[[1]][[2]])))

chr15.76191353geno_dose_full=data.frame(cbind(chr15.76191353geno_anno, chr15.76191353geno_dose))

gen=chr15.76191353geno_dose_full[which(chr15.76191353geno_dose_full$POS==76191353),]
gen</code></pre>
<pre><code>   CHROM      POS       snpID REF ALT QUAL FILTER
84    15 76191353 15:76191353   C   T    .   PASS
                                INFO   FORMAT NA18486 NA18505 NA18508
84 AF=0.08407;MAF=0.08407;R2=0.99998 GT:DS:GP       0       0       1
   NA18511 NA18519 NA18520 NA18853 NA18858 NA18861 NA18870 NA18909 NA18916
84       0       0       0       1       0       0       1       0       0
   NA19119 NA19128 NA19130 NA19141 NA19160 NA19209 NA19210 NA19223 NA19225
84       0       0       0       0       0       0       0       0       0
   NA19238 NA19239 NA19257
84       0       0       0</code></pre>
<pre class="r"><code>snps=chr15.76191353geno_dose_full$snpID
in_both_nom= nom_tot %&gt;% filter(snpID %in% snps)


mylist=list(annotations=tot.res,genotypes=chr15.76191353geno_dose_full )

start=76191353 - 25000
end=76191353 + 25000


#plot_locuszoom(mylist, gen, start, end)</code></pre>
<p>I actually need to do this with the nominal snps.</p>
<p>The most sig. in the nominal total is 4:186328829:186328922:NM_018359.3_-_peak260565, 4:186325141</p>
<p>I want to run the python genotype filter.</p>
<pre class="bash"><code>python filter_geno.py  4 186325141 /project2/gilad/briana/threeprimeseq/data/filtered_geno/chrom4pos186325141.vcf</code></pre>
<pre class="r"><code>chrom4pos18632514=read.table(&quot;../data/nom_QTL/chrom4pos186325141.vcf&quot;, col.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;), stringsAsFactors = F) %&gt;% select(one_of(samples))

chrom4pos18632514_anno=read.table(&quot;../data/nom_QTL/chrom4pos186325141.vcf&quot;, col.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;), stringsAsFactors = F) %&gt;% select(CHROM, POS, snpID, REF, ALT, QUAL, FILTER, INFO, FORMAT)
chrom4pos18632514_dose=apply(chrom4pos18632514, 2, function(y)sapply(y, function(x)as.integer(strsplit(x,&quot;:&quot;)[[1]][[2]])))

chrom4pos18632514_dose_full=data.frame(cbind(chrom4pos18632514_anno, chrom4pos18632514_dose))


snps=chrom4pos18632514_dose_full$snpID
in_both_nom= nom_tot %&gt;% filter(snpID %in% snps)


gen=chrom4pos18632514_dose_full[which(chrom4pos18632514_dose_full$POS==186325141),]


mylist=list(annotations=in_both_nom,genotypes=chrom4pos18632514_dose_full)


start=18632514- 25000
end=18632514 + 25000

#plot_locuszoom(mylist, gen, start, end)

#problem: the in_both_nom has more values because snps can be associated with more than one peak  w</code></pre>
<p>Try to make a boxplot:</p>
<p>FIrst for the strongest total pval.</p>
<pre class="r"><code>geno=chr15.76191353geno_dose_full[which(chr15.76191353geno_dose_full$POS==76191353),10:33]
# find the phentpye values for peak 15:76234771:76234852:NM_138573.3_-_peak118132
#grep -F &quot;15:76234771:76234852:NM_138573.3_-_peak118132&quot; filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.phen_chr15 &gt; ../qtl_example/tot_peak118132
pheno=read.table(&quot;../data/perm_QTL/tot_peak118132&quot;, stringsAsFactors = F, col.names = c(&quot;Chr&quot;,  &quot;start&quot;,    &quot;end&quot;,  &quot;ID&quot;,   &#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;NA18916&#39;,  &#39;NA19092&#39;,  &#39;NA19119&#39;,  &#39;NA19128&#39;   ,&#39;NA19130&#39;, &#39;NA19141&#39;   ,&#39;NA19160&#39;, &#39;NA19193&#39;,  &#39;NA19209&#39;   ,&#39;NA19210&#39;, &#39;NA19223&#39;   ,&#39;NA19225&#39;, &#39;NA19238&#39;,  &#39;NA19239&#39;   ,&#39;NA19257&#39;)) %&gt;%  select(one_of(samples))


for_plot=data.frame(bind_rows(geno,pheno) %&gt;% t)
colnames(for_plot)=c(&quot;Genotype&quot;, &quot;PAS&quot;)
for_plot$Genotype=as.factor(for_plot$Genotype)


ggplot(for_plot, aes(x=Genotype, y=PAS, fill=Genotype, group=Genotype)) + geom_boxplot() + labs(x=&quot;Genotype&quot;, title=&quot;15:76234771:76234852:NM_138573.3_-_peak118132 QTL&quot;) + geom_jitter( aes(x=Genotype, y=PAS))</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-30-1.png" width="672" style="display: block; margin: auto;" /> Generally I will need to grep the correct line from the geno and pheno file then make the plot like this.</p>
<p>Next I will run for the top Nuc QTL.</p>
<p>peak: 12:9092958:9093051:NM_004426.2_+_peak67056 SNP: 12:9049821</p>
<pre class="r"><code>#grep -F &quot;12:9092958:9093051:NM_004426.2_+_peak67056&quot; filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.phen_chr12 &gt; ../qtl_example/nuc_peak67056
pheno_names=c(&quot;Chr&quot;,    &quot;start&quot;,    &quot;end&quot;,  &quot;ID&quot;,   &#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;NA18916&#39;,  &#39;NA19092&#39;,  &#39;NA19119&#39;,  &#39;NA19128&#39;   ,&#39;NA19130&#39;, &#39;NA19141&#39;   ,&#39;NA19160&#39;, &#39;NA19193&#39;,  &#39;NA19209&#39;   ,&#39;NA19210&#39;, &#39;NA19223&#39;   ,&#39;NA19225&#39;, &#39;NA19238&#39;,  &#39;NA19239&#39;   ,&#39;NA19257&#39;)
geno_names=c(&#39;CHROM&#39;, &#39;POS&#39;, &#39;sid&#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;)

top_nuc_geno=read.table(&quot;../data/perm_QTL/genotpye12:904921&quot;, stringsAsFactors = F, col.names = geno_names) %&gt;%  select(one_of(samples))

top_nuc_geno_dose=apply(top_nuc_geno, 2, function(y)sapply(y, function(x)as.integer(strsplit(x,&quot;:&quot;)[[1]][[2]])))


top_nuc_pheo=read.table(&quot;../data/perm_QTL/nuc_peak67056&quot;, stringsAsFactors = F, col.names = pheno_names) %&gt;% select(one_of(samples))



top_nuc_plot=data.frame(bind_rows(top_nuc_geno_dose, top_nuc_pheo) %&gt;% t)
colnames(top_nuc_plot)=c(&quot;Genotype&quot;, &quot;PAS&quot;)
top_nuc_plot$Genotype=as.factor(top_nuc_plot$Genotype)

ggplot(top_nuc_plot, aes(x=Genotype, y=PAS, fill=Genotype, group=Genotype)) + geom_boxplot() + labs(x=&quot;Genotype&quot;, title=&quot;12:9092958:9093051:NM_004426.2_+_peak67056&quot;) + geom_jitter( aes(x=Genotype, y=PAS))</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-31-1.png" width="672" style="display: block; margin: auto;" /></p>
<details> <summary><em>Expand here to see past versions of unnamed-chunk-31-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/b33443c60c0bd42e7b003489770307bad95a9ad9/docs/figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-31-1.png" target="_blank">b33443c</a>
</td>
<td style="text-align:left;">
brimittleman
</td>
<td style="text-align:left;">
2018-08-23
</td>
</tr>
</tbody>
</table>
<p></details></p>
<p>3:119242427:119242509:NM_016589.3_+_peak233134</p>
<p>3:119211867</p>
<pre class="bash"><code>grep -F &quot;3:119242427:119242509:NM_016589.3_+_peak233134&quot; filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.phen_chr3 &gt; ../qtl_example/nuc_peak233134

YRI_geno_hg19]$ less chr3.dose.filt.vcf.gz | grep   &quot;3:119211867&quot; &gt; ../threeprimeseq/data/qtl_example/genotype3:199211867
</code></pre>
<pre class="r"><code>top_nuc_geno2=read.table(&quot;../data/perm_QTL/genotype3:199211867&quot;, stringsAsFactors = F, col.names = geno_names) %&gt;%  select(one_of(samples))

top_nuc_geno2_dose=apply(top_nuc_geno2, 2, function(y)sapply(y, function(x)as.integer(strsplit(x,&quot;:&quot;)[[1]][[2]])))


top_nuc_pheo2=read.table(&quot;../data/perm_QTL/nuc_peak233134&quot;, stringsAsFactors = F, col.names = pheno_names) %&gt;% select(one_of(samples))



top_nuc_plot2=data.frame(bind_rows(top_nuc_geno2_dose, top_nuc_pheo2) %&gt;% t)
colnames(top_nuc_plot2)=c(&quot;Genotype&quot;, &quot;PAS&quot;)
top_nuc_plot2$Genotype=as.factor(top_nuc_plot2$Genotype)

ggplot(top_nuc_plot2, aes(x=Genotype, y=PAS, fill=Genotype, group=Genotype)) + geom_boxplot() + labs(x=&quot;Genotype&quot;, title=&quot;12:9092958:9093051:NM_004426.2_+_peak67056&quot;) + geom_jitter( aes(x=Genotype, y=PAS))</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-33-1.png" width="672" style="display: block; margin: auto;" /></p>
<div id="characteristics-of-the-qtls" class="section level4">
<h4>Characteristics of the QTLs</h4>
<p>I want to look at the distance to the snp for the QTLS</p>
<pre class="r"><code>tot_QTL=tot.res %&gt;% filter(bh &lt; .15 )
nuc_QTL= nuc.res %&gt;% filter(bh&lt; .15)</code></pre>
<pre class="r"><code>tot.res = tot.res %&gt;% mutate(QTL=ifelse(bh&lt;.15, &quot;Yes&quot;, &quot;No&quot;) )
nuc.res = nuc.res %&gt;% mutate(QTL=ifelse(bh&lt;.15, &quot;Yes&quot;, &quot;No&quot;) )</code></pre>
<p>Now I can look at caharacteristics of those that pass the cutoff.</p>
<pre class="r"><code>tot.dist=ggplot(tot.res, aes(x=log10(abs(dist)+1), group=QTL, fill=QTL)) + geom_density(alpha=.4) + labs(title=&quot;Distribtuion of density in Total QTLS&quot;, x=&quot;Log 10 abs. values distance from SNP to peaks&quot;)
nuc.dist=ggplot(nuc.res, aes(x=log10(abs(dist)+1), group=QTL, fill=QTL)) + geom_density(alpha=.4) + labs(title=&quot;Distribtuion of density in Nuclear QTLS&quot;,x=&quot;Log 10 abs. values distance from SNP to peaks&quot;)
plot_grid(tot.dist, nuc.dist)</code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-36-1.png" width="672" style="display: block; margin: auto;" /></p>
<p>I want to assess the number of QTLs we get at different cutoffs. To do this I will wrap a drplyr function in a for look that goes from .05 to .5.</p>
<pre class="r"><code>nQTL_tot=c()
FDR=seq(.05, .5, .01)
for (i in FDR){
  x=tot.res %&gt;% filter(bh &lt; i ) %&gt;% nrow()
  nQTL_tot=c(nQTL_tot, x)
}

FDR=seq(.05, .5, .01)
nQTL_nuc=c()
for (i in FDR){
  x=nuc.res %&gt;% filter(bh &lt; i ) %&gt;% nrow()
  nQTL_nuc=c(nQTL_nuc, x)
}

nQTL=as.data.frame(cbind(FDR, Total=nQTL_tot, Nuclear=nQTL_nuc))
nQTL_long=melt(nQTL, id.vars = &quot;FDR&quot;)

ggplot(nQTL_long, aes(x=FDR, y=value, by=variable, col=variable)) + geom_line(size=1.5) + labs(y=&quot;Number of Significant QTLs&quot;, title=&quot;APAqtls detected by FDR cuttoff&quot;, color=&quot;Fraction&quot;) </code></pre>
<p><img src="figure/apaQTLwLeafcutter.Rmd/unnamed-chunk-37-1.png" width="672" style="display: block; margin: auto;" /></p>
</div>
</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  cowplot_0.9.3   reshape2_1.4.3  workflowr_1.1.1
 [5] forcats_0.3.0   stringr_1.3.1   dplyr_0.7.6     purrr_0.2.5    
 [9] readr_1.1.1     tidyr_0.8.1     tibble_1.4.2    ggplot2_3.0.0  
[13] 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] evaluate_0.11     labeling_0.3      knitr_1.20       
[25] broom_0.5.0       Rcpp_0.12.18      scales_0.5.0     
[28] backports_1.1.2   jsonlite_1.5      hms_0.4.2        
[31] digest_0.6.15     stringi_1.2.4     grid_3.5.1       
[34] rprojroot_1.3-2   cli_1.0.0         tools_3.5.1      
[37] magrittr_1.5      lazyeval_0.2.1    crayon_1.3.4     
[40] whisker_0.3-2     pkgconfig_2.0.1   xml2_1.2.0       
[43] lubridate_1.7.4   assertthat_0.2.0  rmarkdown_1.10   
[46] httr_1.3.1        rstudioapi_0.7    R6_2.2.2         
[49] nlme_3.1-137      git2r_0.23.0      compiler_3.5.1   </code></pre>
</div>

<hr>
<p>
    
</p>
<hr>

<!-- To enable disqus, uncomment the section below and provide your disqus_shortname -->

<!-- disqus
  <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'rmarkdown'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
-->
<!-- Adjust MathJax settings so that all math formulae are shown using
TeX fonts only; see
http://docs.mathjax.org/en/latest/configuration.html.  This will make
the presentation more consistent at the cost of the webpage sometimes
taking slightly longer to load. Note that this only works because the
footer is added to webpages before the MathJax javascript. -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    "HTML-CSS": { availableFonts: ["TeX"] }
  });
</script>

<hr>
<p>
  This reproducible <a href="http://rmarkdown.rstudio.com">R Markdown</a>
  analysis was created with
  <a href="https://github.com/jdblischak/workflowr">workflowr</a> 1.1.1
</p>
<hr>


</div>
</div>

</div>

<script>

// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
  $('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
  bootstrapStylePandocTables();
});


</script>

<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script>

</body>
</html>