Commit ea777429 authored by Rauschenberger's avatar Rauschenberger
Browse files

automation

parent 7bb9a7cf
...@@ -63,20 +63,26 @@ prepare.data.matrices <- function(Y,X){ ...@@ -63,20 +63,26 @@ prepare.data.matrices <- function(Y,X){
#' @description #' @description
#' This function adjusts exon expression data for different library sizes. #' This function adjusts exon expression data for different library sizes.
#' #'
#' @param y #' @param Y
#' matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons) #' matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons)
#' #'
#' @examples #' @examples
#' NA #' NA
#' #'
adjust.library.sizes <- function(y){ adjust.library.sizes <- function(Y){
n <- nrow(y); p <- ncol(y) if(!is.matrix(Y)){
lib.size <- rowSums(y) stop("Argument Y is no matrix.",call.=FALSE)
norm.factors <- edgeR::calcNormFactors(object=t(y),lib.size=lib.size) }
if(!is.numeric(Y)){
stop("Argument Y is not numeric.",call.=FALSE)
}
n <- nrow(Y); p <- ncol(Y)
lib.size <- rowSums(Y)
norm.factors <- edgeR::calcNormFactors(object=t(Y),lib.size=lib.size)
gamma <- norm.factors*lib.size/mean(lib.size) gamma <- norm.factors*lib.size/mean(lib.size)
gamma <- matrix(gamma,nrow=n,ncol=p,byrow=FALSE) gamma <- matrix(gamma,nrow=n,ncol=p,byrow=FALSE)
y <- y/gamma Y <- Y/gamma
return(y) return(Y)
} }
#' @export #' @export
...@@ -86,7 +92,7 @@ adjust.library.sizes <- function(y){ ...@@ -86,7 +92,7 @@ adjust.library.sizes <- function(y){
#' @description #' @description
#' This function adjusts exon expression data for different exon lengths. #' This function adjusts exon expression data for different exon lengths.
#' #'
#' @param y #' @param Y
#' matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons) #' matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons)
#' #'
#' @param gene #' @param gene
...@@ -104,14 +110,23 @@ adjust.library.sizes <- function(y){ ...@@ -104,14 +110,23 @@ adjust.library.sizes <- function(y){
#' @examples #' @examples
#' NA #' NA
#' #'
adjust.exon.length <- function(y,gene,start,end){ adjust.exon.length <- function(Y,gene,start,end){
n <- nrow(y); p <- ncol(y); names <- dimnames(y) if(!is.matrix(Y)){
y <- as.numeric(y) stop("Argument Y is no matrix.",call.=FALSE)
x <- rep(end-start,times=n) }
gene <- rep(gene,times=n) if(any(ncol(Y)!=c(length(gene),length(start),length(end)))){
lmer <- lme4::lmer(y ~ x + (1|gene)) stop("Contradictory dimensions.",call.=FALSE)
y <- matrix(stats::residuals(lmer),nrow=p,ncol=n,dimnames=names) }
return(y - min(y)) n <- nrow(Y); p <- ncol(Y); names <- dimnames(Y)
Y <- as.numeric(Y) # wrong?
x <- rep(end-start,each=n)
gene <- strsplit(gene,split=",")
gene <- sapply(gene,function(x) x[[1]][1])
gene <- rep(gene,each=n)
lmer <- lme4::lmer(Y ~ x + (1|gene))
Y <- matrix(stats::residuals(lmer),nrow=n,ncol=p,dimnames=names)
Y <- Y-min(Y)
return(Y)
} }
#' @export #' @export
......
...@@ -13,17 +13,11 @@ knitr::opts_chunk$set( ...@@ -13,17 +13,11 @@ knitr::opts_chunk$set(
) )
``` ```
## Scope
spliceQTL
## Installation
```{r,eval=FALSE} ```{r,eval=FALSE}
#install.packages("devtools") #install.packages("devtools")
devtools::install_github("rauschenberger/spliceQTL") devtools::install_github("rauschenberger/spliceQTL")
``` ```
## Reference
<!-- Modify xxx.Rmd, not xxx.md! --> <!-- Modify xxx.Rmd, not xxx.md! -->
## Scope
spliceQTL
## Installation
``` r ``` r
#install.packages("devtools") #install.packages("devtools")
devtools::install_github("rauschenberger/spliceQTL") devtools::install_github("rauschenberger/spliceQTL")
``` ```
## Reference
...@@ -83,21 +83,8 @@ ...@@ -83,21 +83,8 @@
<!-- Modify xxx.Rmd, not xxx.md! --> <!-- Modify xxx.Rmd, not xxx.md! -->
<div id="scope" class="section level2">
<h2 class="hasAnchor">
<a href="#scope" class="anchor"></a>Scope</h2>
<p>spliceQTL</p>
</div>
<div id="installation" class="section level2">
<h2 class="hasAnchor">
<a href="#installation" class="anchor"></a>Installation</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="co">#install.packages("devtools")</span></a> <div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="co">#install.packages("devtools")</span></a>
<a class="sourceLine" id="cb1-2" data-line-number="2">devtools<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/devtools/topics/install_github">install_github</a></span>(<span class="st">"rauschenberger/spliceQTL"</span>)</a></code></pre></div> <a class="sourceLine" id="cb1-2" data-line-number="2">devtools<span class="op">::</span><span class="kw"><a href="http://www.rdocumentation.org/packages/devtools/topics/install_github">install_github</a></span>(<span class="st">"rauschenberger/spliceQTL"</span>)</a></code></pre></div>
</div>
<div id="reference" class="section level2">
<h2 class="hasAnchor">
<a href="#reference" class="anchor"></a>Reference</h2>
</div>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
......
...@@ -120,13 +120,13 @@ ...@@ -120,13 +120,13 @@
</div> </div>
<pre class="usage"><span class='fu'>adjust.exon.length</span>(<span class='no'>y</span>, <span class='no'>gene</span>, <span class='no'>start</span>, <span class='no'>end</span>)</pre> <pre class="usage"><span class='fu'>adjust.exon.length</span>(<span class='no'>Y</span>, <span class='no'>gene</span>, <span class='no'>start</span>, <span class='no'>end</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments"> <table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup> <colgroup><col class="name" /><col class="desc" /></colgroup>
<tr> <tr>
<th>y</th> <th>Y</th>
<td><p>matrix with \(n\) rows (samples) and \(p\) columns (exons)</p></td> <td><p>matrix with \(n\) rows (samples) and \(p\) columns (exons)</p></td>
</tr> </tr>
<tr> <tr>
......
...@@ -120,13 +120,13 @@ ...@@ -120,13 +120,13 @@
</div> </div>
<pre class="usage"><span class='fu'>adjust.library.sizes</span>(<span class='no'>y</span>)</pre> <pre class="usage"><span class='fu'>adjust.library.sizes</span>(<span class='no'>Y</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments"> <table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup> <colgroup><col class="name" /><col class="desc" /></colgroup>
<tr> <tr>
<th>y</th> <th>Y</th>
<td><p>matrix with \(n\) rows (samples) and \(p\) columns (exons)</p></td> <td><p>matrix with \(n\) rows (samples) and \(p\) columns (exons)</p></td>
</tr> </tr>
</table> </table>
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
\alias{adjust.exon.length} \alias{adjust.exon.length}
\title{Adjust exon length} \title{Adjust exon length}
\usage{ \usage{
adjust.exon.length(y, gene, start, end) adjust.exon.length(Y, gene, start, end)
} }
\arguments{ \arguments{
\item{y}{matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons)} \item{Y}{matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons)}
\item{gene}{gene (not exon) names\strong{:} vector of length \eqn{p}} \item{gene}{gene (not exon) names\strong{:} vector of length \eqn{p}}
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
\alias{adjust.library.sizes} \alias{adjust.library.sizes}
\title{Adjust library sizes} \title{Adjust library sizes}
\usage{ \usage{
adjust.library.sizes(y) adjust.library.sizes(Y)
} }
\arguments{ \arguments{
\item{y}{matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons)} \item{Y}{matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons)}
} }
\description{ \description{
This function adjusts exon expression data for different library sizes. This function adjusts exon expression data for different library sizes.
......
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