Commit 71b6f5ed authored by Rauschenberger's avatar Rauschenberger
Browse files

automation

parent 0cf917ad
......@@ -14,3 +14,4 @@ export(map.snps)
export(match.samples)
export(test.multiple)
export(test.single)
export(visualise)
......@@ -903,6 +903,7 @@ test.multiple <- function(Y,X,map,rho=c(0,0.5,1),spec=1,min=100,steps=20){
if(max != sum(steps)){stop("invalid step",call.=FALSE)}
if(spec==1){
set.seed(1)
pvalue <- lapply(X=seq_len(p),FUN=function(i) spliceQTL::test.single(Y=Y,X=X,map=map,i=i,limit=limit,steps=steps,rho=rho))
} else {
type <- ifelse(test=.Platform$OS.type=="windows",yes="PSOCK",no="FORK")
......@@ -924,6 +925,70 @@ test.multiple <- function(Y,X,map,rho=c(0,0.5,1),spec=1,min=100,steps=20){
return(pvalue)
}
#' @export
#' @title
#' Plot SNP-exon correlations
#'
#' @description
#' This function ...
#'
#' @param Y
#' to do
#'
#' @param X
#' to do
#'
#' @param map
#' to do
#'
#' @param i
#' to do
#'
#' @examples
#' # see vignette
#'
visualise <- function(Y,X,map,i){
# correlation
ys <- map$exons[[i]]
y <- as.matrix(Y[,ys,drop=FALSE])
xs <- map$snps$from[i]:map$snps$to[i]
x <- X[,xs,drop=FALSE]
cor <- matrix(NA,nrow=length(ys),ncol=length(xs))
for(j in seq_along(ys)){
for(k in seq_along(xs)){
cor[j,k] <- abs(cor(y[,j],x[,k],method="spearman"))
}
}
# plot image
graphics::par(mar=c(2,2,2,1))
k <- 9
inc <- 1.2 # Set to 1 for equal spacing.
d <- 1/sum(inc^(0:k))
breaks <- c(0,cumsum(inc^(0:k)*d))
colour <- colorRampPalette(c("white","darkblue"))(k+1)
graphics::image(cor,xlab="",ylab="",breaks=breaks,col=colour,axes=FALSE)
graphics::title(main=map$genes$gene_id[i],xlab="exons",ylab="SNPs",line=1)
graphics::box()
# indicate gene location
#snp.loc <- as.numeric(sapply(strsplit(x=colnames(X),split=":"),function(x) x[[2]]))
#local <- which(map$genes$start[i] <= snp.loc[xs] & snp.loc[xs] <= map$genes$end[i])
#dx <- 1/(length(xs) - 1)
#dy <- 1/(length(ys) - 1)
#y0 <- min(local)/length(xs) - 0.5*dx
#y1 <- max(local)/length(xs) + 0.5*dx
#col <- "black"; lwd <- 1
#segments(x0=-0.5*dy,y0=y0,x1=-0.5*dy,y1=y1,col=col,lwd=4)
#segments(x0=1+0.5*dy,y0=y0,x1=1+0.5*dy,y1=y1,col=col,lwd=4)
#segments(x0=-0.5*dy,y0=y0,x1=1+0.5*dy,y1=y0,col=col,lwd=lwd,lty=2)
#segments(x0=-0.5*dy,y0=y1,x1=1+0.5*dy,y1=y1,col=col,lwd=lwd,lty=2)
}
#' @export
#' @title
#' Plot grid
......
......@@ -172,7 +172,7 @@
<a class="sourceLine" id="cb4-59" data-line-number="59"><span class="co">#exit</span></a>
<a class="sourceLine" id="cb4-60" data-line-number="60">}</a></code></pre></div>
<p>On the virtual machine, execute this chunk to test for alternative splicing.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="cf">for</span>(chr <span class="cf">in</span> <span class="kw">c</span>(<span class="dv">22</span>,<span class="dv">1</span>,<span class="dv">21</span><span class="op">:</span><span class="dv">2</span>)){</a>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="cf">for</span>(chr <span class="cf">in</span> <span class="dv">22</span><span class="op">:</span><span class="dv">1</span>){ <span class="co"># 22:1</span></a>
<a class="sourceLine" id="cb5-2" data-line-number="2"> <span class="cf">for</span>(data <span class="cf">in</span> <span class="kw">c</span>(<span class="st">"Geuvadis"</span>,<span class="st">"LLS"</span>)){</a>
<a class="sourceLine" id="cb5-3" data-line-number="3"> <span class="kw">cat</span>(<span class="st">"Analysing"</span>,data,chr,<span class="st">":"</span>,<span class="kw">as.character</span>(<span class="kw">Sys.time</span>()),<span class="st">"</span><span class="ch">\n</span><span class="st">"</span>)</a>
<a class="sourceLine" id="cb5-4" data-line-number="4"> <span class="kw">rm</span>(<span class="dt">list=</span><span class="kw">setdiff</span>(<span class="kw">ls</span>(),<span class="kw">c</span>(<span class="st">"data"</span>,<span class="st">"chr"</span>,<span class="st">"path"</span>))); <span class="kw">gc</span>(); <span class="kw">cat</span>(<span class="st">"."</span>)</a>
......@@ -182,26 +182,40 @@
<a class="sourceLine" id="cb5-8" data-line-number="8"> }</a>
<a class="sourceLine" id="cb5-9" data-line-number="9">}</a></code></pre></div>
<p>On the virtual machine, execute this chunk to compare the results between the Geuvadis and the BBMRI project.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1">cor &lt;-<span class="st"> </span>chisq &lt;-<span class="st"> </span><span class="kw">rep</span>(<span class="ot">NA</span>,<span class="dt">length=</span><span class="dv">22</span>)</a>
<a class="sourceLine" id="cb6-2" data-line-number="2"><span class="cf">for</span>(chr <span class="cf">in</span> <span class="kw">c</span>(<span class="dv">22</span>,<span class="dv">1</span>,<span class="dv">21</span>,<span class="dv">20</span>)){</a>
<a class="sourceLine" id="cb6-3" data-line-number="3"> sel &lt;-<span class="st"> "rho=1"</span></a>
<a class="sourceLine" id="cb6-4" data-line-number="4"> <span class="kw">load</span>(<span class="kw">file.path</span>(path,<span class="kw">paste0</span>(<span class="st">"pval.Geuvadis.chr"</span>,chr,<span class="st">".RData"</span>)))</a>
<a class="sourceLine" id="cb6-5" data-line-number="5"> a &lt;-<span class="st"> </span>pvalue; pvalue &lt;-<span class="st"> </span><span class="ot">NA</span></a>
<a class="sourceLine" id="cb6-6" data-line-number="6"> <span class="kw">load</span>(<span class="kw">file.path</span>(path,<span class="kw">paste0</span>(<span class="st">"pval.LLS.chr"</span>,chr,<span class="st">".RData"</span>)))</a>
<a class="sourceLine" id="cb6-7" data-line-number="7"> b &lt;-<span class="st"> </span>pvalue; pvalue &lt;-<span class="st"> </span><span class="ot">NA</span></a>
<a class="sourceLine" id="cb6-8" data-line-number="8"></a>
<a class="sourceLine" id="cb6-9" data-line-number="9"> names &lt;-<span class="st"> </span><span class="kw">intersect</span>(<span class="kw">rownames</span>(a),<span class="kw">rownames</span>(b))</a>
<a class="sourceLine" id="cb6-10" data-line-number="10"> <span class="co"># plot(jitter(-log(a[names,sel])),jitter(-log(b[names,sel])))</span></a>
<a class="sourceLine" id="cb6-11" data-line-number="11"> spliceQTL<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/spliceQTL/topics/grid">grid</a></span>(<span class="dt">x=</span><span class="op">-</span><span class="kw">log</span>(a[names,sel]),<span class="dt">y=</span><span class="op">-</span><span class="kw">log</span>(b[names,sel]),<span class="dt">n=</span><span class="dv">20</span>)</a>
<a class="sourceLine" id="cb6-12" data-line-number="12"> </a>
<a class="sourceLine" id="cb6-13" data-line-number="13"> cor[chr] &lt;-<span class="st"> </span>stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/cor">cor</a></span>(a[names,sel],b[names,sel],<span class="dt">method=</span><span class="st">"spearman"</span>)</a>
<a class="sourceLine" id="cb6-14" data-line-number="14"></a>
<a class="sourceLine" id="cb6-15" data-line-number="15"> a &lt;-<span class="st"> </span>stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/p.adjust">p.adjust</a></span>(a[names,sel])<span class="op">&lt;</span><span class="fl">0.05</span></a>
<a class="sourceLine" id="cb6-16" data-line-number="16"> b &lt;-<span class="st"> </span>stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/p.adjust">p.adjust</a></span>(b[names,sel])<span class="op">&lt;</span><span class="fl">0.05</span></a>
<a class="sourceLine" id="cb6-17" data-line-number="17"> <span class="kw">print</span>(<span class="kw">paste0</span>(<span class="st">"chr"</span>,chr))</a>
<a class="sourceLine" id="cb6-18" data-line-number="18"> <span class="kw">print</span>(<span class="kw">table</span>(a,b))</a>
<a class="sourceLine" id="cb6-19" data-line-number="19"> chisq[chr] &lt;-<span class="st"> </span>stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/chisq.test">chisq.test</a></span>(<span class="kw">table</span>(a,b))<span class="op">$</span>p.value</a>
<a class="sourceLine" id="cb6-20" data-line-number="20">}</a></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1">table &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">chr=</span><span class="kw">seq_len</span>(<span class="dv">22</span>))</a>
<a class="sourceLine" id="cb6-2" data-line-number="2"><span class="cf">for</span>(i <span class="cf">in</span> <span class="kw">seq_len</span>(<span class="dv">22</span>)){</a>
<a class="sourceLine" id="cb6-3" data-line-number="3"> <span class="co"># load p-values</span></a>
<a class="sourceLine" id="cb6-4" data-line-number="4"> <span class="kw">load</span>(<span class="kw">file.path</span>(path,<span class="kw">paste0</span>(<span class="st">"pval.Geuvadis.chr"</span>,i,<span class="st">".RData"</span>)))</a>
<a class="sourceLine" id="cb6-5" data-line-number="5"> a &lt;-<span class="st"> </span>pvalue; pvalue &lt;-<span class="st"> </span><span class="ot">NA</span></a>
<a class="sourceLine" id="cb6-6" data-line-number="6"> <span class="kw">load</span>(<span class="kw">file.path</span>(path,<span class="kw">paste0</span>(<span class="st">"pval.LLS.chr"</span>,i,<span class="st">".RData"</span>)))</a>
<a class="sourceLine" id="cb6-7" data-line-number="7"> b &lt;-<span class="st"> </span>pvalue; pvalue &lt;-<span class="st"> </span><span class="ot">NA</span></a>
<a class="sourceLine" id="cb6-8" data-line-number="8"> </a>
<a class="sourceLine" id="cb6-9" data-line-number="9"> <span class="co"># filter tests</span></a>
<a class="sourceLine" id="cb6-10" data-line-number="10"> sel &lt;-<span class="st"> "rho=1"</span></a>
<a class="sourceLine" id="cb6-11" data-line-number="11"> names &lt;-<span class="st"> </span><span class="kw">intersect</span>(<span class="kw">rownames</span>(a),<span class="kw">rownames</span>(b))</a>
<a class="sourceLine" id="cb6-12" data-line-number="12"> a &lt;-<span class="st"> </span>a[names,sel]</a>
<a class="sourceLine" id="cb6-13" data-line-number="13"> b &lt;-<span class="st"> </span>b[names,sel]</a>
<a class="sourceLine" id="cb6-14" data-line-number="14"> </a>
<a class="sourceLine" id="cb6-15" data-line-number="15"> <span class="co"># correlation</span></a>
<a class="sourceLine" id="cb6-16" data-line-number="16"> spliceQTL<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/spliceQTL/topics/grid">grid</a></span>(<span class="dt">x=</span><span class="op">-</span><span class="kw">log</span>(a),<span class="dt">y=</span><span class="op">-</span><span class="kw">log</span>(b),<span class="dt">n=</span><span class="dv">20</span>)</a>
<a class="sourceLine" id="cb6-17" data-line-number="17"> table<span class="op">$</span>cor[i] &lt;-<span class="st"> </span><span class="kw">round</span>(stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/cor">cor</a></span>(<span class="op">-</span><span class="kw">log</span>(a),<span class="op">-</span><span class="kw">log</span>(b),<span class="dt">method=</span><span class="st">"pearson"</span>),<span class="dt">digits=</span><span class="dv">2</span>)</a>
<a class="sourceLine" id="cb6-18" data-line-number="18"> table<span class="op">$</span>cor.test[i] &lt;-<span class="st"> </span><span class="kw">signif</span>(stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/cor.test">cor.test</a></span>(<span class="op">-</span><span class="kw">log</span>(a),<span class="op">-</span><span class="kw">log</span>(b),<span class="dt">method=</span><span class="st">"pearson"</span>)<span class="op">$</span>p.value,<span class="dt">digits=</span><span class="dv">2</span>)</a>
<a class="sourceLine" id="cb6-19" data-line-number="19"> </a>
<a class="sourceLine" id="cb6-20" data-line-number="20"> <span class="co"># significance</span></a>
<a class="sourceLine" id="cb6-21" data-line-number="21"> a &lt;-<span class="st"> </span>stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/p.adjust">p.adjust</a></span>(a)<span class="op">&lt;</span><span class="fl">0.05</span></a>
<a class="sourceLine" id="cb6-22" data-line-number="22"> b &lt;-<span class="st"> </span>stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/p.adjust">p.adjust</a></span>(b)<span class="op">&lt;</span><span class="fl">0.05</span></a>
<a class="sourceLine" id="cb6-23" data-line-number="23"> table<span class="op">$</span>none[i] &lt;-<span class="st"> </span><span class="kw">sum</span>(<span class="op">!</span>a <span class="op">&amp;</span><span class="st"> </span><span class="op">!</span>b)</a>
<a class="sourceLine" id="cb6-24" data-line-number="24"> table<span class="op">$</span>GEU[i] &lt;-<span class="st"> </span><span class="kw">sum</span>(a <span class="op">&amp;</span><span class="st"> </span><span class="op">!</span>b)</a>
<a class="sourceLine" id="cb6-25" data-line-number="25"> table<span class="op">$</span>LLS[i] &lt;-<span class="st"> </span><span class="kw">sum</span>(<span class="op">!</span>a <span class="op">&amp;</span><span class="st"> </span>b)</a>
<a class="sourceLine" id="cb6-26" data-line-number="26"> table<span class="op">$</span>both[i] &lt;-<span class="st"> </span><span class="kw">sum</span>(a <span class="op">&amp;</span><span class="st"> </span>b)</a>
<a class="sourceLine" id="cb6-27" data-line-number="27"> table<span class="op">$</span>chisq.test[i] &lt;-<span class="st"> </span><span class="kw">suppressWarnings</span>(<span class="kw">signif</span>(stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/chisq.test">chisq.test</a></span>(<span class="kw">table</span>(a,b))<span class="op">$</span>p.value,<span class="dt">digits=</span><span class="dv">2</span>))</a>
<a class="sourceLine" id="cb6-28" data-line-number="28"> </a>
<a class="sourceLine" id="cb6-29" data-line-number="29">}</a></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">data &lt;-<span class="st"> "LLS"</span> <span class="co"># "Geuvadis" or "LLS"</span></a>
<a class="sourceLine" id="cb7-2" data-line-number="2">chr &lt;-<span class="st"> </span><span class="dv">1</span> <span class="co"># 1,2,3,...,22</span></a>
<a class="sourceLine" id="cb7-3" data-line-number="3"><span class="kw">load</span>(<span class="kw">file.path</span>(path,<span class="kw">paste0</span>(<span class="st">"temp."</span>,data,<span class="st">".chr"</span>,chr,<span class="st">".RData"</span>)))</a>
<a class="sourceLine" id="cb7-4" data-line-number="4">i &lt;-<span class="st"> </span><span class="kw">which</span>(map<span class="op">$</span>genes<span class="op">$</span>gene_id<span class="op">==</span><span class="st">"ENSG00000116171"</span>)</a>
<a class="sourceLine" id="cb7-5" data-line-number="5"><span class="kw"><a href="../reference/visualise.html">visualise</a></span>(<span class="dt">Y=</span>exons,<span class="dt">X=</span>snps,<span class="dt">map=</span>map,<span class="dt">i=</span>i)</a></code></pre></div>
<!--
#wait <- TRUE
#while(wait){
......
docs/reference/grid-1.png

11.3 KB | W: | H:

docs/reference/grid-1.png

11 KB | W: | H:

docs/reference/grid-1.png
docs/reference/grid-1.png
docs/reference/grid-1.png
docs/reference/grid-1.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -216,6 +216,12 @@
<p><code><a href="grid.html">grid()</a></code> </p>
</td>
<td><p>Plot grid</p></td>
</tr><tr>
<!-- -->
<td>
<p><code><a href="visualise.html">visualise()</a></code> </p>
</td>
<td><p>Plot SNP-exon correlations</p></td>
</tr>
</tbody>
</table>
......
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plot SNP-exon correlations — visualise • spliceQTL</title>
<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<!-- Font Awesome icons -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js" integrity="sha384-cV+rhyOuRHc9Ub/91rihWcGmMmCXDeksTtCihMupQHSsi8GIIRDG0ThDc3HGQFJ3" crossorigin="anonymous"></script>
<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../jquery.sticky-kit.min.js"></script>
<script src="../pkgdown.js"></script>
<meta property="og:title" content="Plot SNP-exon correlations — visualise" />
<meta property="og:description" content="This function ..." />
<meta name="twitter:card" content="summary" />
<!-- mathjax -->
<script src='https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-reference-topic">
<header>
<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>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">spliceQTL</a>
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Released package">0.0.0</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fa fa-home fa-lg"></span>
</a>
</li>
<li>
<a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Articles
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/code.html">rainbow (code)</a>
</li>
<li>
<a href="../articles/text.html">rainbow (text)</a>
</li>
</ul>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/spliceQTL">
<span class="fa fa-github fa-lg"></span>
</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header>
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Plot SNP-exon correlations</h1>
<small class="dont-index">Source: <a href='https://github.com/rauschenberger/spliceQTL/blob/master/R/functions.R'><code>R/functions.R</code></a></small>
<div class="hidden name"><code>visualise.Rd</code></div>
</div>
<div class="ref-description">
<p>This function ...</p>
</div>
<pre class="usage"><span class='fu'>visualise</span>(<span class='no'>Y</span>, <span class='no'>X</span>, <span class='no'>map</span>, <span class='no'>i</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>Y</th>
<td><p>to do</p></td>
</tr>
<tr>
<th>X</th>
<td><p>to do</p></td>
</tr>
<tr>
<th>map</th>
<td><p>to do</p></td>
</tr>
<tr>
<th>i</th>
<td><p>to do</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><div class='input'># see vignette
</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#arguments">Arguments</a></li>
<li><a href="#examples">Examples</a></li>
</ul>
</div>
</div>
<footer>
<div class="copyright">
<p>Developed by Armin Rauschenberger, Renee Menezes.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="http://pkgdown.r-lib.org/">pkgdown</a>.</p>
</div>
</footer>
</div>
</body>
</html>
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
\name{visualise}
\alias{visualise}
\title{Plot SNP-exon correlations}
\usage{
visualise(Y, X, map, i)
}
\arguments{
\item{Y}{to do}
\item{X}{to do}
\item{map}{to do}
\item{i}{to do}
}
\description{
This function ...
}
\examples{
# see vignette
}
......@@ -105,7 +105,7 @@ for(chr in 1:22){
On the virtual machine, execute this chunk to test for alternative splicing.
```{r test,eval=FALSE}
for(chr in c(22,1,21:2)){
for(chr in 22:1){ # 22:1
for(data in c("Geuvadis","LLS")){
cat("Analysing",data,chr,":",as.character(Sys.time()),"\n")
rm(list=setdiff(ls(),c("data","chr","path"))); gc(); cat(".")
......@@ -119,28 +119,49 @@ for(chr in c(22,1,21:2)){
On the virtual machine, execute this chunk to compare the results between the Geuvadis and the BBMRI project.
```{r,eval=FALSE}
cor <- chisq <- rep(NA,length=22)
for(chr in c(22,1,21,20)){
sel <- "rho=1"
load(file.path(path,paste0("pval.Geuvadis.chr",chr,".RData")))
a <- pvalue; pvalue <- NA
load(file.path(path,paste0("pval.LLS.chr",chr,".RData")))
b <- pvalue; pvalue <- NA
names <- intersect(rownames(a),rownames(b))
# plot(jitter(-log(a[names,sel])),jitter(-log(b[names,sel])))
spliceQTL::grid(x=-log(a[names,sel]),y=-log(b[names,sel]),n=20)
cor[chr] <- stats::cor(a[names,sel],b[names,sel],method="spearman")
a <- stats::p.adjust(a[names,sel])<0.05
b <- stats::p.adjust(b[names,sel])<0.05
print(paste0("chr",chr))
print(table(a,b))
chisq[chr] <- stats::chisq.test(table(a,b))$p.value
table <- data.frame(chr=seq_len(22))
for(i in seq_len(22)){
# load p-values
load(file.path(path,paste0("pval.Geuvadis.chr",i,".RData")))
a <- pvalue; pvalue <- NA
load(file.path(path,paste0("pval.LLS.chr",i,".RData")))
b <- pvalue; pvalue <- NA
# filter tests
sel <- "rho=1"
names <- intersect(rownames(a),rownames(b))
a <- a[names,sel]
b <- b[names,sel]
# correlation
spliceQTL::grid(x=-log(a),y=-log(b),n=20)
table$cor[i] <- round(stats::cor(-log(a),-log(b),method="pearson"),digits=2)
table$cor.test[i] <- signif(stats::cor.test(-log(a),-log(b),method="pearson")$p.value,digits=2)
# significance
a <- stats::p.adjust(a)<0.05
b <- stats::p.adjust(b)<0.05
table$none[i] <- sum(!a & !b)
table$GEU[i] <- sum(a & !b)
table$LLS[i] <- sum(!a & b)
table$both[i] <- sum(a & b)
table$chisq.test[i] <- suppressWarnings(signif(stats::chisq.test(table(a,b))$p.value,digits=2))
}
```
```{r,eval=FALSE}
data <- "LLS" # "Geuvadis" or "LLS"
chr <- 1 # 1,2,3,...,22
load(file.path(path,paste0("temp.",data,".chr",chr,".RData")))
i <- which(map$genes$gene_id=="ENSG00000116171")
visualise(Y=exons,X=snps,map=map,i=i)
```
<!--
#wait <- TRUE
#while(wait){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment