Commit d95f5839 authored by Rauschenberger's avatar Rauschenberger
Browse files

automation

parent cf0cd653
......@@ -7,6 +7,7 @@ export(get.exons.bbmri)
export(get.exons.geuvadis)
export(get.snps.bbmri)
export(get.snps.geuvadis)
export(grid)
export(map.exons)
export(map.genes)
export(map.snps)
......
......@@ -924,6 +924,69 @@ test.multiple <- function(Y,X,map,rho=c(0,0.5,1),spec=1,min=100,steps=20){
return(pvalue)
}
#' @export
#' @title
#' Plot grid
#'
#' @description
#' This function tests for alternative splicing.
#'
#' @param x
#' vector
#'
#' @param y
#' vector
#'
#' @param xlim
#' horizontal limits
#'
#' @param ylim
#' vertical limits
#'
#' @param n
#' grid resolution
#'
#' @examples
#' x <- stats::rbeta(n=100,shape1=0.2,shape2=0.5)
#' y <- stats::rbeta(n=100,shape1=0.2,shape2=0.5)
#' grid(x,y)
#'
grid <- function(x,y,xlim=NULL,ylim=NULL,n=10){
# open plot
if(is.null(xlim)){xlim <- range(x)}
if(is.null(ylim)){ylim <- range(y)}
graphics::plot.new()
graphics::plot.window(xlim=xlim,ylim=ylim)
graphics::box()
graphics::axis(side=1)
graphics::axis(side=2)
# density
xc <- seq(from=xlim[1],to=xlim[2],length.out=n+1)
yc <- seq(from=ylim[2],to=ylim[1],length.out=n+1)
M <- matrix(integer(),nrow=n,ncol=n)
for(i in seq_len(n)){
for(j in seq_len(n)){
M[i,j] <- sum(x >= xc[i] & x <= xc[i+1] & y <= yc[j] & y >= yc[j+1])
}
}
M <- M/(1.5*max(M))
# fill plot
for(i in seq_len(n)){
for(j in seq_len(n)){
graphics::polygon(x=c(xc[i],xc[i],xc[i+1],xc[i+1]),
y=c(yc[j],yc[j+1],yc[j+1],yc[j]),
col=gray(level=1-M[i,j]))
}
}
graphics::segments(x0=xc,y0=ylim[1],y1=ylim[2],col="white")
graphics::segments(x0=xlim[1],x1=xlim[2],y0=yc,col="white")
graphics::points(x=x,y=y,pch=16,cex=0.5)
}
# test.trial <- function(y,x,limit=NULL,steps=NULL,rho=c(0,0.5,1)){
#
......
......@@ -169,16 +169,15 @@
<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">1</span><span class="op">:</span><span class="dv">22</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="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>
<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"> </a>
<a class="sourceLine" id="cb5-5" data-line-number="5"> <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>
<a class="sourceLine" id="cb5-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">"temp."</span>,data,<span class="st">".chr"</span>,chr,<span class="st">".RData"</span>))); <span class="kw">cat</span>(<span class="st">"."</span>)</a>
<a class="sourceLine" id="cb5-7" data-line-number="7"> pvalue &lt;-<span class="st"> </span>spliceQTL<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/spliceQTL/topics/test.multiple">test.multiple</a></span>(<span class="dt">Y=</span>exons,<span class="dt">X=</span>snps,<span class="dt">map=</span>map,<span class="dt">rho=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>),<span class="dt">spec=</span><span class="dv">16</span>); <span class="kw">cat</span>(<span class="st">"."</span>)</a>
<a class="sourceLine" id="cb5-8" data-line-number="8"> <span class="kw">save</span>(<span class="dt">object=</span>pvalue,<span class="dt">file=</span><span class="kw">file.path</span>(path,<span class="kw">paste0</span>(<span class="st">"pval."</span>,data,<span class="st">".chr"</span>,chr,<span class="st">".RData"</span>))); <span class="kw">cat</span>(<span class="st">"</span><span class="ch">\n</span><span class="st">"</span>)</a>
<a class="sourceLine" id="cb5-9" data-line-number="9"> }</a>
<a class="sourceLine" id="cb5-10" data-line-number="10">}</a></code></pre></div>
<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>
<a class="sourceLine" id="cb5-5" data-line-number="5"> <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>))); <span class="kw">cat</span>(<span class="st">"."</span>)</a>
<a class="sourceLine" id="cb5-6" data-line-number="6"> pvalue &lt;-<span class="st"> </span>spliceQTL<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/spliceQTL/topics/test.multiple">test.multiple</a></span>(<span class="dt">Y=</span>exons,<span class="dt">X=</span>snps,<span class="dt">map=</span>map,<span class="dt">rho=</span><span class="dv">1</span>,<span class="dt">spec=</span><span class="dv">16</span>); <span class="kw">cat</span>(<span class="st">"."</span>)</a>
<a class="sourceLine" id="cb5-7" data-line-number="7"> <span class="kw">save</span>(<span class="dt">object=</span>pvalue,<span class="dt">file=</span><span class="kw">file.path</span>(path,<span class="kw">paste0</span>(<span class="st">"pval."</span>,data,<span class="st">".chr"</span>,chr,<span class="st">".RData"</span>))); <span class="kw">cat</span>(<span class="st">"</span><span class="ch">\n</span><span class="st">"</span>)</a>
<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="dv">22</span><span class="op">:</span><span class="dv">1</span>){</a>
......@@ -206,6 +205,44 @@
#}
memory and CPU usage Linux: htop
-->
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">grid &lt;-<span class="st"> </span><span class="cf">function</span>(x,y,<span class="dt">xlim=</span><span class="ot">NULL</span>,<span class="dt">ylim=</span><span class="ot">NULL</span>,<span class="dt">n=</span><span class="dv">10</span>){</a>
<a class="sourceLine" id="cb7-2" data-line-number="2"> <span class="co"># open plot</span></a>
<a class="sourceLine" id="cb7-3" data-line-number="3"> <span class="cf">if</span>(<span class="kw">is.null</span>(xlim)){xlim &lt;-<span class="st"> </span><span class="kw">range</span>(x)}</a>
<a class="sourceLine" id="cb7-4" data-line-number="4"> <span class="cf">if</span>(<span class="kw">is.null</span>(ylim)){ylim &lt;-<span class="st"> </span><span class="kw">range</span>(y)}</a>
<a class="sourceLine" id="cb7-5" data-line-number="5"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/frame">plot.new</a></span>()</a>
<a class="sourceLine" id="cb7-6" data-line-number="6"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/plot.window">plot.window</a></span>(<span class="dt">xlim=</span>xlim,<span class="dt">ylim=</span>ylim)</a>
<a class="sourceLine" id="cb7-7" data-line-number="7"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/box">box</a></span>()</a>
<a class="sourceLine" id="cb7-8" data-line-number="8"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/axis">axis</a></span>(<span class="dt">side=</span><span class="dv">1</span>)</a>
<a class="sourceLine" id="cb7-9" data-line-number="9"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/axis">axis</a></span>(<span class="dt">side=</span><span class="dv">2</span>)</a>
<a class="sourceLine" id="cb7-10" data-line-number="10"> </a>
<a class="sourceLine" id="cb7-11" data-line-number="11"> <span class="co"># density</span></a>
<a class="sourceLine" id="cb7-12" data-line-number="12"> xc &lt;-<span class="st"> </span><span class="kw">seq</span>(<span class="dt">from=</span>xlim[<span class="dv">1</span>],<span class="dt">to=</span>xlim[<span class="dv">2</span>],<span class="dt">length.out=</span>n<span class="op">+</span><span class="dv">1</span>)</a>
<a class="sourceLine" id="cb7-13" data-line-number="13"> yc &lt;-<span class="st"> </span><span class="kw">seq</span>(<span class="dt">from=</span>ylim[<span class="dv">2</span>],<span class="dt">to=</span>ylim[<span class="dv">1</span>],<span class="dt">length.out=</span>n<span class="op">+</span><span class="dv">1</span>)</a>
<a class="sourceLine" id="cb7-14" data-line-number="14"> M &lt;-<span class="st"> </span><span class="kw">matrix</span>(<span class="kw">integer</span>(),<span class="dt">nrow=</span>n,<span class="dt">ncol=</span>n)</a>
<a class="sourceLine" id="cb7-15" data-line-number="15"> <span class="cf">for</span>(i <span class="cf">in</span> <span class="kw">seq_len</span>(n)){</a>
<a class="sourceLine" id="cb7-16" data-line-number="16"> <span class="cf">for</span>(j <span class="cf">in</span> <span class="kw">seq_len</span>(n)){</a>
<a class="sourceLine" id="cb7-17" data-line-number="17"> M[i,j] &lt;-<span class="st"> </span><span class="kw">sum</span>(x <span class="op">&gt;=</span><span class="st"> </span>xc[i] <span class="op">&amp;</span><span class="st"> </span>x <span class="op">&lt;=</span><span class="st"> </span>xc[i<span class="op">+</span><span class="dv">1</span>] <span class="op">&amp;</span><span class="st"> </span>y <span class="op">&lt;=</span><span class="st"> </span>yc[j] <span class="op">&amp;</span><span class="st"> </span>y <span class="op">&gt;=</span><span class="st"> </span>yc[j<span class="op">+</span><span class="dv">1</span>])</a>
<a class="sourceLine" id="cb7-18" data-line-number="18"> }</a>
<a class="sourceLine" id="cb7-19" data-line-number="19"> }</a>
<a class="sourceLine" id="cb7-20" data-line-number="20"> M &lt;-<span class="st"> </span>M<span class="op">/</span>(<span class="fl">1.5</span><span class="op">*</span><span class="kw">max</span>(M))</a>
<a class="sourceLine" id="cb7-21" data-line-number="21"> </a>
<a class="sourceLine" id="cb7-22" data-line-number="22"> <span class="co"># fill plot</span></a>
<a class="sourceLine" id="cb7-23" data-line-number="23"> <span class="cf">for</span>(i <span class="cf">in</span> <span class="kw">seq_len</span>(n)){</a>
<a class="sourceLine" id="cb7-24" data-line-number="24"> <span class="cf">for</span>(j <span class="cf">in</span> <span class="kw">seq_len</span>(n)){</a>
<a class="sourceLine" id="cb7-25" data-line-number="25"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/polygon">polygon</a></span>(<span class="dt">x=</span><span class="kw">c</span>(xc[i],xc[i],xc[i<span class="op">+</span><span class="dv">1</span>],xc[i<span class="op">+</span><span class="dv">1</span>]),</a>
<a class="sourceLine" id="cb7-26" data-line-number="26"> <span class="dt">y=</span><span class="kw">c</span>(yc[j],yc[j<span class="op">+</span><span class="dv">1</span>],yc[j<span class="op">+</span><span class="dv">1</span>],yc[j]),</a>
<a class="sourceLine" id="cb7-27" data-line-number="27"> <span class="dt">col=</span><span class="kw">gray</span>(<span class="dt">level=</span><span class="dv">1</span><span class="op">-</span>M[i,j]))</a>
<a class="sourceLine" id="cb7-28" data-line-number="28"> }</a>
<a class="sourceLine" id="cb7-29" data-line-number="29"> }</a>
<a class="sourceLine" id="cb7-30" data-line-number="30"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/segments">segments</a></span>(<span class="dt">x0=</span>xc,<span class="dt">y0=</span>ylim[<span class="dv">1</span>],<span class="dt">y1=</span>ylim[<span class="dv">2</span>],<span class="dt">col=</span><span class="st">"white"</span>)</a>
<a class="sourceLine" id="cb7-31" data-line-number="31"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/segments">segments</a></span>(<span class="dt">x0=</span>xlim[<span class="dv">1</span>],<span class="dt">x1=</span>xlim[<span class="dv">2</span>],<span class="dt">y0=</span>yc,<span class="dt">col=</span><span class="st">"white"</span>)</a>
<a class="sourceLine" id="cb7-32" data-line-number="32"> graphics<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/graphics/topics/points">points</a></span>(<span class="dt">x=</span>x,<span class="dt">y=</span>y,<span class="dt">pch=</span><span class="dv">16</span>,<span class="dt">cex=</span><span class="fl">0.5</span>)</a>
<a class="sourceLine" id="cb7-33" data-line-number="33"> </a>
<a class="sourceLine" id="cb7-34" data-line-number="34">}</a>
<a class="sourceLine" id="cb7-35" data-line-number="35"></a>
<a class="sourceLine" id="cb7-36" data-line-number="36">x &lt;-<span class="st"> </span>stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/Beta">rbeta</a></span>(<span class="dt">n=</span><span class="dv">100</span>,<span class="dt">shape1=</span><span class="fl">0.4</span>,<span class="dt">shape2=</span><span class="fl">0.5</span>)</a>
<a class="sourceLine" id="cb7-37" data-line-number="37">y &lt;-<span class="st"> </span>stats<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/stats/topics/Beta">rbeta</a></span>(<span class="dt">n=</span><span class="dv">100</span>,<span class="dt">shape1=</span><span class="fl">0.2</span>,<span class="dt">shape2=</span><span class="fl">0.5</span>)</a>
<a class="sourceLine" id="cb7-38" data-line-number="38"><span class="kw"><a href="../reference/grid.html">grid</a></span>(x,y,<span class="dt">xlim=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>),<span class="dt">ylim=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>),<span class="dt">n=</span><span class="dv">10</span>)</a></code></pre></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
......
<!-- 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 grid — grid • 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 grid — grid" />
<meta property="og:description" content="This function tests for alternative splicing." />
<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>
</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 grid</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>grid.Rd</code></div>
</div>
<div class="ref-description">
<p>This function tests for alternative splicing.</p>
</div>
<pre class="usage"><span class='fu'>grid</span>(<span class='no'>x</span>, <span class='no'>y</span>, <span class='kw'>xlim</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>ylim</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>n</span> <span class='kw'>=</span> <span class='fl'>10</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>x</th>
<td><p>vector</p></td>
</tr>
<tr>
<th>y</th>
<td><p>vector</p></td>
</tr>
<tr>
<th>xlim</th>
<td><p>horizontal limits</p></td>
</tr>
<tr>
<th>ylim</th>
<td><p>vertical limits</p></td>
</tr>
<tr>
<th>n</th>
<td><p>grid resolution</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><div class='input'><span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='kw pkg'>stats</span><span class='kw ns'>::</span><span class='fu'><a href='http://www.rdocumentation.org/packages/stats/topics/Beta'>rbeta</a></span>(<span class='kw'>n</span><span class='kw'>=</span><span class='fl'>100</span>,<span class='kw'>shape1</span><span class='kw'>=</span><span class='fl'>0.2</span>,<span class='kw'>shape2</span><span class='kw'>=</span><span class='fl'>0.5</span>)
<span class='no'>y</span> <span class='kw'>&lt;-</span> <span class='kw pkg'>stats</span><span class='kw ns'>::</span><span class='fu'><a href='http://www.rdocumentation.org/packages/stats/topics/Beta'>rbeta</a></span>(<span class='kw'>n</span><span class='kw'>=</span><span class='fl'>100</span>,<span class='kw'>shape1</span><span class='kw'>=</span><span class='fl'>0.2</span>,<span class='kw'>shape2</span><span class='kw'>=</span><span class='fl'>0.5</span>)
<span class='fu'>grid</span>(<span class='no'>x</span>,<span class='no'>y</span>)</div><div class='img'><img src='grid-1.png' alt='' width='700' height='433' /></div><div class='input'>
</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>
......@@ -207,6 +207,12 @@
<p><code><a href="adjust.variables.html">adjust.variables()</a></code> </p>
</td>
<td><p>Adjust exon length</p></td>
</tr><tr>
<!-- -->
<td>
<p><code><a href="grid.html">grid()</a></code> </p>
</td>
<td><p>Plot grid</p></td>
</tr>
</tbody>
</table>
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
\name{grid}
\alias{grid}
\title{Plot grid}
\usage{
grid(x, y, xlim = NULL, ylim = NULL, n = 10)
}
\arguments{
\item{x}{vector}
\item{y}{vector}
\item{xlim}{horizontal limits}
\item{ylim}{vertical limits}
\item{n}{grid resolution}
}
\description{
This function tests for alternative splicing.
}
\examples{
x <- stats::rbeta(n=100,shape1=0.2,shape2=0.5)
y <- stats::rbeta(n=100,shape1=0.2,shape2=0.5)
grid(x,y)
}
......@@ -105,13 +105,12 @@ 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(1:22)){
for(chr in c(22,1,21:2)){
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(".")
load(file.path(path,paste0("temp.",data,".chr",chr,".RData"))); cat(".")
pvalue <- spliceQTL::test.multiple(Y=exons,X=snps,map=map,rho=c(0,1),spec=16); cat(".")
pvalue <- spliceQTL::test.multiple(Y=exons,X=snps,map=map,rho=1,spec=16); cat(".")
save(object=pvalue,file=file.path(path,paste0("pval.",data,".chr",chr,".RData"))); cat("\n")
}
}
......@@ -147,4 +146,51 @@ for(chr in 22:1){
# if(wait){Sys.sleep(60);cat(".")}
#}
memory and CPU usage Linux: htop
-->
\ No newline at end of file
-->
```{r plot function,eval=FALSE}
grid <- function(x,y,xlim=NULL,ylim=NULL,n=10){
# open plot
if(is.null(xlim)){xlim <- range(x)}
if(is.null(ylim)){ylim <- range(y)}
graphics::plot.new()
graphics::plot.window(xlim=xlim,ylim=ylim)
graphics::box()
graphics::axis(side=1)
graphics::axis(side=2)
# density
xc <- seq(from=xlim[1],to=xlim[2],length.out=n+1)
yc <- seq(from=ylim[2],to=ylim[1],length.out=n+1)
M <- matrix(integer(),nrow=n,ncol=n)
for(i in seq_len(n)){
for(j in seq_len(n)){
M[i,j] <- sum(x >= xc[i] & x <= xc[i+1] & y <= yc[j] & y >= yc[j+1])
}
}
M <- M/(1.5*max(M))
# fill plot
for(i in seq_len(n)){
for(j in seq_len(n)){
graphics::polygon(x=c(xc[i],xc[i],xc[i+1],xc[i+1]),
y=c(yc[j],yc[j+1],yc[j+1],yc[j]),
col=gray(level=1-M[i,j]))
}
}
graphics::segments(x0=xc,y0=ylim[1],y1=ylim[2],col="white")
graphics::segments(x0=xlim[1],x1=xlim[2],y0=yc,col="white")
graphics::points(x=x,y=y,pch=16,cex=0.5)
}
x <- stats::rbeta(n=100,shape1=0.4,shape2=0.5)
y <- stats::rbeta(n=100,shape1=0.2,shape2=0.5)
grid(x,y,xlim=c(0,1),ylim=c(0,1),n=10)
```
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