<!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("/project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/SAMPLE.txt",'w') for ln in open("/project2/gilad/briana/threeprimeseq/data/filt_peak_refGene_cov/file_id_mapping_nuc.txt", "r"): bam, sample = ln.split() line=sample[:-2] fout.write("NA"+line + "\n") 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 <.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 > 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("permutations.all.chunks.txt.gz", hea=F, stringsAsFactors=F) colnames(d) = c("pid", "nvar", "shape1", "shape2", "dummy", "sid", "dist", "npval", "ppval", "bpval") plot(d$ppval, d$bpval, xlab="Direct method", ylab="Beta approximation", main="Check plot") abline(0, 1, col="red")</code></pre> <p>I will try this first on the resutls from chr1.</p> <pre class="r"><code>nuc.chr1= read.table("../data/perm_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.qqnorm_chr1.perm.out",head=F, stringsAsFactors=F, col.names = c("pid", "nvar", "shape1", "shape2", "dummy", "sid", "dist", "npval", "slope", "ppval", "bpval")) plot(nuc.chr1$ppval, nuc.chr1$bpval, xlab="Direct method", ylab="Beta approximation", main="Nuclear Check plot") abline(0, 1, col="red")</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("../data/perm_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.qqnorm_chr1.perm.out", head=F, stringsAsFactors = F, col.names= c("pid", "nvar", "shape1", "shape2", "dummy", "sid", "dist", "npval", "slope", "ppval", "bpval")) plot(tot.chr1$ppval, tot.chr1$bpval, xlab="Direct method", ylab="Beta approximation", main="Total Check plot") abline(0, 1, col="red")</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="bonferroni") plot(-log10(nuc.chr1$bonferroni), main="Nuclear chr1 bonferroni corrected pval")</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="bonferroni") plot(-log10(tot.chr1$bonferroni), main="Total chr1 bonferroni corrected pval")</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>< .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="fdr") plot(-log10(nuc.chr1$bh), main="Nuclear chr1 BH corrected pval")</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="fdr") plot(-log10(tot.chr1$bh), main="Total chr1 BH corrected pval")</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("../data/perm_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_permQTLresults.out",head=F, stringsAsFactors=F, col.names = c("pid", "nvar", "shape1", "shape2", "dummy", "sid", "dist", "npval", "slope", "ppval", "bpval")) plot(nuc.res$ppval, nuc.res$bpval, xlab="Direct method", ylab="Beta approximation", main="Nuclear Check plot") abline(0, 1, col="red")</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("../data/perm_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_permQTLresults.out", head=F, stringsAsFactors = F, col.names= c("pid", "nvar", "shape1", "shape2", "dummy", "sid", "dist", "npval", "slope", "ppval", "bpval")) plot(tot.res$ppval, tot.res$bpval, xlab="Direct method", ylab="Beta approximation", main="Total Check plot") abline(0, 1, col="red")</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="fdr") plot(-log10(nuc.res$bh), main="Nuclear BH corrected pval") abline(h=1, col="red")</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="fdr") plot(-log10(tot.res$bh), main="Total BH corrected pval") abline(h=1, col="red")</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: 'reshape2'</code></pre> <pre><code>The following object is masked from 'package:tidyr': smiths</code></pre> <pre class="r"><code>library(cowplot)</code></pre> <pre><code> Attaching package: 'cowplot'</code></pre> <pre><code>The following object is masked from 'package:ggplot2': ggsave</code></pre> <pre class="r"><code>ceu_QTL=read.table("../data/nom_QTL/ceu.apaqtl.txt.gz.bh.txt", header = T, stringsAsFactors = F) nom_nuc=read.table("../data/nom_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear_nomQTLresults.out", head=F, stringsAsFactors = F, col.names = c("peakID", "snpID", "dist", "Nuc_pval", "slope")) nom_tot=read.table("../data/nom_QTL/filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total_nomQTLresults.out",head=F , stringsAsFactors = F, col.names = c("peakID", "snpID", "dist", "tot_pval", "slope"))</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 %>% filter(grepl("snp", dummy2)) %>% separate(dummy2, c("type", "chr", "loc"), sep="_") %>% unite(snpID, c("chr", "loc"), sep=":")</code></pre> <p>Join the data frames by the snp ID.</p> <pre class="r"><code>ceuAndTot= ceu_QTL_snp %>% inner_join(nom_tot, by="snpID") %>% select(snpID, bpval, tot_pval) ceuAndNuc= ceu_QTL_snp %>% inner_join(nom_nuc, by="snpID") %>% 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="-log10 Total pvalues", xlab="Uniform expectation", main="Total pvalues for in CEU snps") abline(0,1) qqplot(-log10(nuc_ceuSNPS), -log10(ceuAndNuc$Nuc_pva), ylab="-log10 Nuclear pvalues", xlab="Uniform expectation", main="Nuclear pvalues for in CEU snps") 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="-log10 Total pvalue", xlab="Uniform expectation", main="Total pvalues for all snps") abline(0,1) qqplot(-log10(runif(nrow(nom_nuc))), -log10(nom_nuc$Nuc_pval), ylab="-log10 Nuclear pvalue", xlab="Uniform expectation",main= "Nuclear pvalues for all snps") 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="-log10 Total permuted pvalue", xlab="Uniform expectation", main="Total permuted pvalues for all snps") abline(0,1) qqplot(-log10(runif(nrow(nuc.res))), -log10(nuc.res$bpval), ylab="-log10 Nuclear permuted pvalue", xlab="Uniform expectation", main="Nuclear permuted pvalues for all snps") 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 <- 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 <- colorRampPalette(c('lightblue','blue','purple','red'))(101) cols <- c() # gotta figure out how everythign correlates with this snp # row <- which(this$annotations$rsid==snp) # gen <- as.numeric(this$genotypes[row,10:129]) nrow <- nrow(this$annotations) cors <- sapply(1:nrow, function(j) cor(gen, as.numeric(this$genotypes[j,10:33]))) cols <- c() for (j in 1:nrow) cols[j] <- rbPal[round(100*(cors[j])^2)+1] plot.new() plot.window(xlim=xlim, ylim=ylim, xlab='position', ylab='-log10(p-value)', ...) points(x=this$annotations$pos, y=-log(this$annotations$bpval,10), pch=19, col=cols) axis(2) box() mtext('-log10(p-value)', 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("NA18486","NA18505", 'NA18508','NA18511','NA18519','NA18520','NA18853','NA18858','NA18861','NA18870','NA18909','NA18916','NA19119','NA19128','NA19130','NA19141','NA19160','NA19209','NA19210','NA19223','NA19225','NA19238','NA19239','NA19257') chr15.76191353geno=read.table("../data/perm_QTL/chrom15pos76191353.vcf", col.names=c('CHROM', 'POS', 'snpID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT', 'NA18486', 'NA18487', 'NA18488', 'NA18489', 'NA18498', 'NA18499', 'NA18501', 'NA18502', 'NA18504', 'NA18505', 'NA18507', 'NA18508', 'NA18510', 'NA18511', 'NA18516', 'NA18517', 'NA18519', 'NA18520', 'NA18522', 'NA18523', 'NA18852', 'NA18853', 'NA18855', 'NA18856', 'NA18858', 'NA18859', 'NA18861', 'NA18862', 'NA18867', 'NA18868', 'NA18870', 'NA18871', 'NA18873', 'NA18874', 'NA18907', 'NA18909', 'NA18910', 'NA18912', 'NA18913', 'NA18916', 'NA18917', 'NA18923', 'NA18924', 'NA18933', 'NA18934', 'NA19093', 'NA19095', 'NA19096', 'NA19098', 'NA19099', 'NA19101', 'NA19102', 'NA19107', 'NA19108', 'NA19113', 'NA19114', 'NA19116', 'NA19117', 'NA19118', 'NA19119', 'NA19121', 'NA19122', 'NA19127', 'NA19128', 'NA19129', 'NA19130', 'NA19131', 'NA19137', 'NA19138', 'NA19140', 'NA19141', 'NA19143', 'NA19144', 'NA19146', 'NA19147', 'NA19149', 'NA19150', 'NA19152', 'NA19153', 'NA19159', 'NA19160', 'NA19171', 'NA19172', 'NA19175', 'NA19176', 'NA19184', 'NA19185', 'NA19189', 'NA19190', 'NA19197', 'NA19198', 'NA19200', 'NA19201', 'NA19203', 'NA19204', 'NA19206', 'NA19207', 'NA19209', 'NA19210', 'NA19213', 'NA19214', 'NA19222', 'NA19223', 'NA19225', 'NA19226', 'NA19235', 'NA19236', 'NA19238', 'NA19239', 'NA19247', 'NA19248', 'NA19256', 'NA19257'), stringsAsFactors = F) %>% select(one_of(samples)) chr15.76191353geno_anno=read.table("../data/perm_QTL/chrom15pos76191353.vcf", col.names=c('CHROM', 'POS', 'snpID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT', 'NA18486', 'NA18487', 'NA18488', 'NA18489', 'NA18498', 'NA18499', 'NA18501', 'NA18502', 'NA18504', 'NA18505', 'NA18507', 'NA18508', 'NA18510', 'NA18511', 'NA18516', 'NA18517', 'NA18519', 'NA18520', 'NA18522', 'NA18523', 'NA18852', 'NA18853', 'NA18855', 'NA18856', 'NA18858', 'NA18859', 'NA18861', 'NA18862', 'NA18867', 'NA18868', 'NA18870', 'NA18871', 'NA18873', 'NA18874', 'NA18907', 'NA18909', 'NA18910', 'NA18912', 'NA18913', 'NA18916', 'NA18917', 'NA18923', 'NA18924', 'NA18933', 'NA18934', 'NA19093', 'NA19095', 'NA19096', 'NA19098', 'NA19099', 'NA19101', 'NA19102', 'NA19107', 'NA19108', 'NA19113', 'NA19114', 'NA19116', 'NA19117', 'NA19118', 'NA19119', 'NA19121', 'NA19122', 'NA19127', 'NA19128', 'NA19129', 'NA19130', 'NA19131', 'NA19137', 'NA19138', 'NA19140', 'NA19141', 'NA19143', 'NA19144', 'NA19146', 'NA19147', 'NA19149', 'NA19150', 'NA19152', 'NA19153', 'NA19159', 'NA19160', 'NA19171', 'NA19172', 'NA19175', 'NA19176', 'NA19184', 'NA19185', 'NA19189', 'NA19190', 'NA19197', 'NA19198', 'NA19200', 'NA19201', 'NA19203', 'NA19204', 'NA19206', 'NA19207', 'NA19209', 'NA19210', 'NA19213', 'NA19214', 'NA19222', 'NA19223', 'NA19225', 'NA19226', 'NA19235', 'NA19236', 'NA19238', 'NA19239', 'NA19247', 'NA19248', 'NA19256', 'NA19257'), stringsAsFactors = F) %>% 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,":")[[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 %>% 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("../data/nom_QTL/chrom4pos186325141.vcf", col.names=c('CHROM', 'POS', 'snpID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT', 'NA18486', 'NA18487', 'NA18488', 'NA18489', 'NA18498', 'NA18499', 'NA18501', 'NA18502', 'NA18504', 'NA18505', 'NA18507', 'NA18508', 'NA18510', 'NA18511', 'NA18516', 'NA18517', 'NA18519', 'NA18520', 'NA18522', 'NA18523', 'NA18852', 'NA18853', 'NA18855', 'NA18856', 'NA18858', 'NA18859', 'NA18861', 'NA18862', 'NA18867', 'NA18868', 'NA18870', 'NA18871', 'NA18873', 'NA18874', 'NA18907', 'NA18909', 'NA18910', 'NA18912', 'NA18913', 'NA18916', 'NA18917', 'NA18923', 'NA18924', 'NA18933', 'NA18934', 'NA19093', 'NA19095', 'NA19096', 'NA19098', 'NA19099', 'NA19101', 'NA19102', 'NA19107', 'NA19108', 'NA19113', 'NA19114', 'NA19116', 'NA19117', 'NA19118', 'NA19119', 'NA19121', 'NA19122', 'NA19127', 'NA19128', 'NA19129', 'NA19130', 'NA19131', 'NA19137', 'NA19138', 'NA19140', 'NA19141', 'NA19143', 'NA19144', 'NA19146', 'NA19147', 'NA19149', 'NA19150', 'NA19152', 'NA19153', 'NA19159', 'NA19160', 'NA19171', 'NA19172', 'NA19175', 'NA19176', 'NA19184', 'NA19185', 'NA19189', 'NA19190', 'NA19197', 'NA19198', 'NA19200', 'NA19201', 'NA19203', 'NA19204', 'NA19206', 'NA19207', 'NA19209', 'NA19210', 'NA19213', 'NA19214', 'NA19222', 'NA19223', 'NA19225', 'NA19226', 'NA19235', 'NA19236', 'NA19238', 'NA19239', 'NA19247', 'NA19248', 'NA19256', 'NA19257'), stringsAsFactors = F) %>% select(one_of(samples)) chrom4pos18632514_anno=read.table("../data/nom_QTL/chrom4pos186325141.vcf", col.names=c('CHROM', 'POS', 'snpID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT', 'NA18486', 'NA18487', 'NA18488', 'NA18489', 'NA18498', 'NA18499', 'NA18501', 'NA18502', 'NA18504', 'NA18505', 'NA18507', 'NA18508', 'NA18510', 'NA18511', 'NA18516', 'NA18517', 'NA18519', 'NA18520', 'NA18522', 'NA18523', 'NA18852', 'NA18853', 'NA18855', 'NA18856', 'NA18858', 'NA18859', 'NA18861', 'NA18862', 'NA18867', 'NA18868', 'NA18870', 'NA18871', 'NA18873', 'NA18874', 'NA18907', 'NA18909', 'NA18910', 'NA18912', 'NA18913', 'NA18916', 'NA18917', 'NA18923', 'NA18924', 'NA18933', 'NA18934', 'NA19093', 'NA19095', 'NA19096', 'NA19098', 'NA19099', 'NA19101', 'NA19102', 'NA19107', 'NA19108', 'NA19113', 'NA19114', 'NA19116', 'NA19117', 'NA19118', 'NA19119', 'NA19121', 'NA19122', 'NA19127', 'NA19128', 'NA19129', 'NA19130', 'NA19131', 'NA19137', 'NA19138', 'NA19140', 'NA19141', 'NA19143', 'NA19144', 'NA19146', 'NA19147', 'NA19149', 'NA19150', 'NA19152', 'NA19153', 'NA19159', 'NA19160', 'NA19171', 'NA19172', 'NA19175', 'NA19176', 'NA19184', 'NA19185', 'NA19189', 'NA19190', 'NA19197', 'NA19198', 'NA19200', 'NA19201', 'NA19203', 'NA19204', 'NA19206', 'NA19207', 'NA19209', 'NA19210', 'NA19213', 'NA19214', 'NA19222', 'NA19223', 'NA19225', 'NA19226', 'NA19235', 'NA19236', 'NA19238', 'NA19239', 'NA19247', 'NA19248', 'NA19256', 'NA19257'), stringsAsFactors = F) %>% 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,":")[[1]][[2]]))) chrom4pos18632514_dose_full=data.frame(cbind(chrom4pos18632514_anno, chrom4pos18632514_dose)) snps=chrom4pos18632514_dose_full$snpID in_both_nom= nom_tot %>% 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 "15:76234771:76234852:NM_138573.3_-_peak118132" filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Total.txt.gz.phen_chr15 > ../qtl_example/tot_peak118132 pheno=read.table("../data/perm_QTL/tot_peak118132", stringsAsFactors = F, col.names = c("Chr", "start", "end", "ID", 'NA18486', 'NA18497', 'NA18500', 'NA18505','NA18508' ,'NA18511', 'NA18519', 'NA18520', 'NA18853', 'NA18858', 'NA18861' ,'NA18870', 'NA18909', 'NA18916', 'NA19092', 'NA19119', 'NA19128' ,'NA19130', 'NA19141' ,'NA19160', 'NA19193', 'NA19209' ,'NA19210', 'NA19223' ,'NA19225', 'NA19238', 'NA19239' ,'NA19257')) %>% select(one_of(samples)) for_plot=data.frame(bind_rows(geno,pheno) %>% t) colnames(for_plot)=c("Genotype", "PAS") for_plot$Genotype=as.factor(for_plot$Genotype) ggplot(for_plot, aes(x=Genotype, y=PAS, fill=Genotype, group=Genotype)) + geom_boxplot() + labs(x="Genotype", title="15:76234771:76234852:NM_138573.3_-_peak118132 QTL") + 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 "12:9092958:9093051:NM_004426.2_+_peak67056" filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.phen_chr12 > ../qtl_example/nuc_peak67056 pheno_names=c("Chr", "start", "end", "ID", 'NA18486', 'NA18497', 'NA18500', 'NA18505','NA18508' ,'NA18511', 'NA18519', 'NA18520', 'NA18853', 'NA18858', 'NA18861' ,'NA18870', 'NA18909', 'NA18916', 'NA19092', 'NA19119', 'NA19128' ,'NA19130', 'NA19141' ,'NA19160', 'NA19193', 'NA19209' ,'NA19210', 'NA19223' ,'NA19225', 'NA19238', 'NA19239' ,'NA19257') geno_names=c('CHROM', 'POS', 'sid', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT', 'NA18486', 'NA18487', 'NA18488', 'NA18489', 'NA18498', 'NA18499', 'NA18501', 'NA18502', 'NA18504', 'NA18505', 'NA18507', 'NA18508', 'NA18510', 'NA18511', 'NA18516', 'NA18517', 'NA18519', 'NA18520', 'NA18522', 'NA18523', 'NA18852', 'NA18853', 'NA18855', 'NA18856', 'NA18858', 'NA18859', 'NA18861', 'NA18862', 'NA18867', 'NA18868', 'NA18870', 'NA18871', 'NA18873', 'NA18874', 'NA18907', 'NA18909', 'NA18910', 'NA18912', 'NA18913', 'NA18916', 'NA18917', 'NA18923', 'NA18924', 'NA18933', 'NA18934', 'NA19093', 'NA19095', 'NA19096', 'NA19098', 'NA19099', 'NA19101', 'NA19102', 'NA19107', 'NA19108', 'NA19113', 'NA19114', 'NA19116', 'NA19117', 'NA19118', 'NA19119', 'NA19121', 'NA19122', 'NA19127', 'NA19128', 'NA19129', 'NA19130', 'NA19131', 'NA19137', 'NA19138', 'NA19140', 'NA19141', 'NA19143', 'NA19144', 'NA19146', 'NA19147', 'NA19149', 'NA19150', 'NA19152', 'NA19153', 'NA19159', 'NA19160', 'NA19171', 'NA19172', 'NA19175', 'NA19176', 'NA19184', 'NA19185', 'NA19189', 'NA19190', 'NA19197', 'NA19198', 'NA19200', 'NA19201', 'NA19203', 'NA19204', 'NA19206', 'NA19207', 'NA19209', 'NA19210', 'NA19213', 'NA19214', 'NA19222', 'NA19223', 'NA19225', 'NA19226', 'NA19235', 'NA19236', 'NA19238', 'NA19239', 'NA19247', 'NA19248', 'NA19256', 'NA19257') top_nuc_geno=read.table("../data/perm_QTL/genotpye12:904921", stringsAsFactors = F, col.names = geno_names) %>% select(one_of(samples)) top_nuc_geno_dose=apply(top_nuc_geno, 2, function(y)sapply(y, function(x)as.integer(strsplit(x,":")[[1]][[2]]))) top_nuc_pheo=read.table("../data/perm_QTL/nuc_peak67056", stringsAsFactors = F, col.names = pheno_names) %>% select(one_of(samples)) top_nuc_plot=data.frame(bind_rows(top_nuc_geno_dose, top_nuc_pheo) %>% t) colnames(top_nuc_plot)=c("Genotype", "PAS") 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="Genotype", title="12:9092958:9093051:NM_004426.2_+_peak67056") + 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 "3:119242427:119242509:NM_016589.3_+_peak233134" filtered_APApeaks_merged_allchrom_refseqGenes_pheno_Nuclear.txt.gz.phen_chr3 > ../qtl_example/nuc_peak233134 YRI_geno_hg19]$ less chr3.dose.filt.vcf.gz | grep "3:119211867" > ../threeprimeseq/data/qtl_example/genotype3:199211867 </code></pre> <pre class="r"><code>top_nuc_geno2=read.table("../data/perm_QTL/genotype3:199211867", stringsAsFactors = F, col.names = geno_names) %>% select(one_of(samples)) top_nuc_geno2_dose=apply(top_nuc_geno2, 2, function(y)sapply(y, function(x)as.integer(strsplit(x,":")[[1]][[2]]))) top_nuc_pheo2=read.table("../data/perm_QTL/nuc_peak233134", stringsAsFactors = F, col.names = pheno_names) %>% select(one_of(samples)) top_nuc_plot2=data.frame(bind_rows(top_nuc_geno2_dose, top_nuc_pheo2) %>% t) colnames(top_nuc_plot2)=c("Genotype", "PAS") 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="Genotype", title="12:9092958:9093051:NM_004426.2_+_peak67056") + 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 %>% filter(bh < .15 ) nuc_QTL= nuc.res %>% filter(bh< .15)</code></pre> <pre class="r"><code>tot.res = tot.res %>% mutate(QTL=ifelse(bh<.15, "Yes", "No") ) nuc.res = nuc.res %>% mutate(QTL=ifelse(bh<.15, "Yes", "No") )</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="Distribtuion of density in Total QTLS", x="Log 10 abs. values distance from SNP to peaks") nuc.dist=ggplot(nuc.res, aes(x=log10(abs(dist)+1), group=QTL, fill=QTL)) + geom_density(alpha=.4) + labs(title="Distribtuion of density in Nuclear QTLS",x="Log 10 abs. values distance from SNP to peaks") 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 %>% filter(bh < i ) %>% nrow() nQTL_tot=c(nQTL_tot, x) } FDR=seq(.05, .5, .01) nQTL_nuc=c() for (i in FDR){ x=nuc.res %>% filter(bh < i ) %>% nrow() nQTL_nuc=c(nQTL_nuc, x) } nQTL=as.data.frame(cbind(FDR, Total=nQTL_tot, Nuclear=nQTL_nuc)) nQTL_long=melt(nQTL, id.vars = "FDR") ggplot(nQTL_long, aes(x=FDR, y=value, by=variable, col=variable)) + geom_line(size=1.5) + labs(y="Number of Significant QTLs", title="APAqtls detected by FDR cuttoff", color="Fraction") </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>