Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Armin Rauschenberger
joinet
Commits
10c41a50
Commit
10c41a50
authored
Jun 14, 2018
by
Rauschenberger
Browse files
automation
parent
f2468757
Changes
9
Hide whitespace changes
Inline
Side-by-side
NAMESPACE
View file @
10c41a50
# Generated by roxygen2: do not edit by hand
export(adjust.
exon.length
)
export(adjust.
library.siz
es)
export(adjust.
covariates
)
export(adjust.
sampl
es)
export(drop.trivial.genes)
export(map.exons)
export(map.genes)
export(map.snps)
export(
prepare.data.matric
es)
export(
match.sampl
es)
export(spliceQTL)
R/function.R
View file @
10c41a50
...
...
@@ -4,64 +4,116 @@
#' Prepare data matrices
#'
#' @description
#' This function removes duplicate samples, retains overlapping samples, and
#' orders samples.
#' This function removes duplicate samples from each matrix,
#' only retains samples appearing in all matrices,
#' and brings them into the same order.
#'
#' @param Y
#' matrix with \eqn{n_y} rows (samples) and \eqn{p_y} columns (exons)
#' @param ...
#' matrices with samples in the rows and variables in the columns
#' (separated by commas)
#'
#' @param
X
#'
matrix with \eqn{n_x} rows (samples) and \eqn{p_x} columns (SNPs)
#' @param
message
#'
display messages\strong{:} logical
#'
#' @examples
#' NA
#'
prepare.data.matrices
<-
function
(
Y
,
X
){
match.samples
<-
function
(
...
,
message
=
TRUE
){
list
<-
list
(
...
)
if
(
length
(
list
)
==
1
&
is.list
(
list
[[
1
]])){
list
<-
list
[[
1
]]}
names
<-
names
(
list
)
# check input
if
(
!
is.matrix
(
Y
)
|!
is.matrix
(
X
)){
stop
(
"Provide X and Y as matrices!"
,
call.
=
FALSE
)
cond
<-
sapply
(
list
,
function
(
x
)
!
is.matrix
(
x
))
if
(
any
(
cond
)){
stop
(
"Provide matrices!"
,
call.
=
FALSE
)
}
if
(
is.null
(
rownames
(
Y
))
|
is.null
(
rownames
(
X
))){
stop
(
"Missing sample names!"
,
call.
=
FALSE
)
cond
<-
sapply
(
list
,
function
(
x
)
is.null
(
rownames
(
x
)))
if
(
any
(
cond
)){
stop
(
"Provide row names!"
,
call.
=
FALSE
)
}
# remove duplicate samples
dup
_y
<-
duplicated
(
rownames
(
Y
))
dup_x
<-
duplicated
(
rownames
(
X
))
message
(
"Duplicates: removing "
,
round
(
100
*
mean
(
dup
_y
)),
"% of Y."
)
message
(
"D
uplicates
: remov
in
g
"
,
round
(
100
*
mean
(
dup_x
)),
"% of X."
)
Y
<-
Y
[
!
dup_y
,]
X
<-
X
[
!
dup_x
,]
# remove duplicate
d
samples
dup
lic
<-
lapply
(
list
,
function
(
x
)
duplicated
(
x
))
for
(
i
in
seq_along
(
list
))
{
percent
<-
round
(
100
*
mean
(
dup
lic
[[
i
]])
)
if
(
message
){
message
(
percent
,
"% d
uplicates
in "
,
names
[
i
])}
list
[[
i
]]
<-
list
[[
i
]][
!
duplic
[[
i
]]
,]
}
# retain overlapping samples
both
<-
intersect
(
x
=
rownames
(
Y
),
y
=
rownames
(
X
))
message
(
"Overlap: retaining "
,
round
(
100
*
mean
(
rownames
(
Y
)
%in%
both
)),
"% of Y."
)
message
(
"Overlap: retaining "
,
round
(
100
*
mean
(
rownames
(
X
)
%in%
both
)),
"% of X."
)
Y
<-
Y
[
both
,]
X
<-
X
[
both
,]
all
<-
Reduce
(
f
=
intersect
,
x
=
lapply
(
list
,
rownames
))
for
(
i
in
seq_along
(
list
)){
percent
<-
round
(
100
*
mean
(
rownames
(
list
[[
i
]])
%in%
all
))
if
(
message
){
message
(
percent
,
"% overlap in"
,
names
[
i
])}
list
[[
i
]]
<-
list
[[
i
]][
all
,]
}
# check output
if
(
any
(
duplicated
(
rownames
(
Y
)))
|
any
(
duplicated
(
rownames
(
X
)))){
cond
<-
sapply
(
list
,
function
(
x
)
any
(
duplicated
(
rownames
(
x
))))
if
(
any
(
cond
)){
stop
(
"Duplicate samples!"
,
call.
=
FALSE
)
}
if
(
nrow
(
Y
)
!=
nrow
(
X
)){
cond
<-
sapply
(
list
,
function
(
x
)
nrow
(
x
)
!=
nrow
(
list
[[
1
]]))
if
(
any
(
cond
)){
stop
(
"Different sample sizes!"
,
call.
=
FALSE
)
}
if
(
any
(
rownames
(
Y
)
!=
rownames
(
X
))){
cond
<-
sapply
(
list
,
function
(
x
)
any
(
rownames
(
x
)
!=
rownames
(
list
[[
1
]])))
if
(
any
(
cond
)){
stop
(
"Different sample names!"
,
call.
=
FALSE
)
}
return
(
list
(
Y
=
Y
,
X
=
X
)
)
return
(
list
)
}
# prepare.data.matrices <- function(Y,X){
#
# # check input
# if(!is.matrix(Y)|!is.matrix(X)){
# stop("Provide X and Y as matrices!",call.=FALSE)
# }
# if(is.null(rownames(Y))|is.null(rownames(X))){
# stop("Missing sample names!",call.=FALSE)
# }
#
# # remove duplicate samples
# dup_y <- duplicated(rownames(Y))
# dup_x <- duplicated(rownames(X))
# message("Duplicates: removing ",round(100*mean(dup_y)),"% of Y.")
# message("Duplicates: removing ",round(100*mean(dup_x)),"% of X.")
# Y <- Y[!dup_y,]
# X <- X[!dup_x,]
#
# # retain overlapping samples
# both <- intersect(x=rownames(Y),y=rownames(X))
# message("Overlap: retaining ",round(100*mean(rownames(Y) %in% both)),"% of Y.")
# message("Overlap: retaining ",round(100*mean(rownames(X) %in% both)),"% of X.")
# Y <- Y[both,]
# X <- X[both,]
#
# # check output
# if(any(duplicated(rownames(Y))) | any(duplicated(rownames(X)))){
# stop("Duplicate samples!",call.=FALSE)
# }
# if(nrow(Y)!=nrow(X)){
# stop("Different sample sizes!",call.=FALSE)
# }
# if(any(rownames(Y)!=rownames(X))){
# stop("Different sample names!",call.=FALSE)
# }
#
# return(list(Y=Y,X=X))
# }
#' @export
#' @title
#' Adjust library sizes
#'
#' @description
#' This function adjusts
exon
expression data for different library sizes.
#' This function adjusts
RNA-seq
expression data for different library sizes.
#'
#' @param x
#' matrix with \eqn{n} rows (samples) and \eqn{p} columns (variables)
...
...
@@ -69,7 +121,7 @@ prepare.data.matrices <- function(Y,X){
#' @examples
#' NA
#'
adjust.
library.siz
es
<-
function
(
x
){
adjust.
sampl
es
<-
function
(
x
){
if
(
!
is.matrix
(
x
)){
stop
(
"no matrix argument"
,
call.
=
FALSE
)
}
...
...
@@ -114,21 +166,22 @@ adjust.library.sizes <- function(x){
#' @examples
#' NA
#'
adjust.
exon.length
<-
function
(
x
,
group
,
offset
){
adjust.
covariates
<-
function
(
x
,
offset
,
group
){
if
(
!
is.numeric
(
x
)
|!
is.matrix
(
x
)){
stop
(
"Argument \"x\" is no numeric matrix."
,
call.
=
FALSE
)
}
if
(
!
is.numeric
(
offset
)
|!
is.vector
(
offset
)
|
any
(
offset
<
0
)){
stop
(
"Argument \"offset\" is no (positive) numeric vector."
,
call.
=
FALSE
)
}
if
(
!
is.character
(
group
)
|!
is.vector
(
group
)){
stop
(
"Argument \"group\" is no character vector."
,
call.
=
FALSE
)
}
if
(
!
is.numeric
(
offset
)
|!
is.vector
(
offset
)){
stop
(
"Argument \"offset\" is no numeric vector."
,
call.
=
FALSE
)
}
if
(
ncol
(
x
)
!=
length
(
group
)
|
ncol
(
x
)
!=
length
(
offset
)){
stop
(
"Contradictory dimensions."
,
call.
=
FALSE
)
}
n
<-
nrow
(
x
);
p
<-
ncol
(
x
);
names
<-
dimnames
(
x
)
x
<-
as.numeric
(
x
)
offset
<-
rep
(
offset
,
each
=
n
)
group
<-
strsplit
(
group
,
split
=
","
)
group
<-
sapply
(
group
,
function
(
x
)
x
[[
1
]][
1
])
group
<-
rep
(
group
,
each
=
n
)
...
...
docs/reference/adjust.
exon.length
.html
→
docs/reference/adjust.
covariates
.html
View file @
10c41a50
...
...
@@ -6,7 +6,7 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Adjust exon length — adjust.
exon.length
• spliceQTL
</title>
<title>
Adjust exon length — adjust.
covariates
• spliceQTL
</title>
<!-- jquery -->
<script
src=
"https://code.jquery.com/jquery-3.1.0.min.js"
integrity=
"sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq"
crossorigin=
"anonymous"
></script>
...
...
@@ -28,7 +28,7 @@
<meta
property=
"og:title"
content=
"Adjust exon length — adjust.
exon.length
"
/>
<meta
property=
"og:title"
content=
"Adjust exon length — adjust.
covariates
"
/>
<meta
property=
"og:description"
content=
"This function adjusts exon expression data for different exon lengths."
/>
<meta
name=
"twitter:card"
content=
"summary"
/>
...
...
@@ -111,7 +111,7 @@
<div
class=
"page-header"
>
<h1>
Adjust exon length
</h1>
<small
class=
"dont-index"
>
Source:
<a
href=
'https://github.com/rauschenberger/spliceQTL/blob/master/R/function.R'
><code>
R/function.R
</code></a></small>
<div
class=
"hidden name"
><code>
adjust.
exon.length
.Rd
</code></div>
<div
class=
"hidden name"
><code>
adjust.
covariates
.Rd
</code></div>
</div>
<div
class=
"ref-description"
>
...
...
@@ -120,7 +120,7 @@
</div>
<pre
class=
"usage"
><span
class=
'fu'
>
adjust.
exon.length
</span>
(
<span
class=
'no'
>
x
</span>
,
<span
class=
'no'
>
group
</span>
,
<span
class=
'no'
>
offset
</span>
)
</pre>
<pre
class=
"usage"
><span
class=
'fu'
>
adjust.
covariates
</span>
(
<span
class=
'no'
>
x
</span>
,
<span
class=
'no'
>
offset
</span>
,
<span
class=
'no'
>
group
</span>
)
</pre>
<h2
class=
"hasAnchor"
id=
"arguments"
><a
class=
"anchor"
href=
"#arguments"
></a>
Arguments
</h2>
<table
class=
"ref-arguments"
>
...
...
@@ -129,15 +129,15 @@
<th>
x
</th>
<td><p>
matrix with \(n\) rows (samples) and \(p\) columns (exons)
</p></td>
</tr>
<tr>
<th>
group
</th>
<td><p>
gene (not exon) names
<strong>
:
</strong>
vector of length \(p\)
</p></td>
</tr>
<tr>
<th>
offset
</th>
<td><p>
exon start positions
<strong>
:
</strong>
vector of length \(p\)
exon end positions
<strong>
:
</strong>
vector of length \(p\)
</p></td>
</tr>
<tr>
<th>
group
</th>
<td><p>
gene (not exon) names
<strong>
:
</strong>
vector of length \(p\)
</p></td>
</tr>
</table>
<h2
class=
"hasAnchor"
id=
"details"
><a
class=
"anchor"
href=
"#details"
></a>
Details
</h2>
...
...
docs/reference/adjust.
library.siz
es.html
→
docs/reference/adjust.
sampl
es.html
View file @
10c41a50
...
...
@@ -6,7 +6,7 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Adjust library sizes — adjust.
library.siz
es • spliceQTL
</title>
<title>
Adjust library sizes — adjust.
sampl
es • spliceQTL
</title>
<!-- jquery -->
<script
src=
"https://code.jquery.com/jquery-3.1.0.min.js"
integrity=
"sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq"
crossorigin=
"anonymous"
></script>
...
...
@@ -28,9 +28,9 @@
<meta
property=
"og:title"
content=
"Adjust library sizes — adjust.
library.siz
es"
/>
<meta
property=
"og:title"
content=
"Adjust library sizes — adjust.
sampl
es"
/>
<meta
property=
"og:description"
content=
"This function adjusts
exon
expression data for different library sizes."
/>
<meta
property=
"og:description"
content=
"This function adjusts
RNA-seq
expression data for different library sizes."
/>
<meta
name=
"twitter:card"
content=
"summary"
/>
...
...
@@ -111,16 +111,16 @@
<div
class=
"page-header"
>
<h1>
Adjust library sizes
</h1>
<small
class=
"dont-index"
>
Source:
<a
href=
'https://github.com/rauschenberger/spliceQTL/blob/master/R/function.R'
><code>
R/function.R
</code></a></small>
<div
class=
"hidden name"
><code>
adjust.
library.siz
es.Rd
</code></div>
<div
class=
"hidden name"
><code>
adjust.
sampl
es.Rd
</code></div>
</div>
<div
class=
"ref-description"
>
<p>
This function adjusts
exon
expression data for different library sizes.
</p>
<p>
This function adjusts
RNA-seq
expression data for different library sizes.
</p>
</div>
<pre
class=
"usage"
><span
class=
'fu'
>
adjust.
library.siz
es
</span>
(
<span
class=
'no'
>
x
</span>
)
</pre>
<pre
class=
"usage"
><span
class=
'fu'
>
adjust.
sampl
es
</span>
(
<span
class=
'no'
>
x
</span>
)
</pre>
<h2
class=
"hasAnchor"
id=
"arguments"
><a
class=
"anchor"
href=
"#arguments"
></a>
Arguments
</h2>
<table
class=
"ref-arguments"
>
...
...
docs/reference/index.html
View file @
10c41a50
...
...
@@ -124,18 +124,6 @@
</th>
</tr>
<tr>
<!-- -->
<td>
<p><code><a
href=
"adjust.library.sizes.html"
>
adjust.library.sizes()
</a></code>
</p>
</td>
<td><p>
Adjust library sizes
</p></td>
</tr><tr>
<!-- -->
<td>
<p><code><a
href=
"adjust.exon.length.html"
>
adjust.exon.length()
</a></code>
</p>
</td>
<td><p>
Adjust exon length
</p></td>
</tr><tr>
<!-- -->
<td>
<p><code><a
href=
"map.genes.html"
>
map.genes()
</a></code>
</p>
...
...
@@ -168,9 +156,21 @@
</tr><tr>
<!-- -->
<td>
<p><code><a
href=
"
prepare.data.matrices.html"
>
prepare.data.matric
es()
</a></code>
</p>
<p><code><a
href=
"
match.samples.html"
>
match.sampl
es()
</a></code>
</p>
</td>
<td><p>
Prepare data matrices
</p></td>
</tr><tr>
<!-- -->
<td>
<p><code><a
href=
"adjust.samples.html"
>
adjust.samples()
</a></code>
</p>
</td>
<td><p>
Adjust library sizes
</p></td>
</tr><tr>
<!-- -->
<td>
<p><code><a
href=
"adjust.covariates.html"
>
adjust.covariates()
</a></code>
</p>
</td>
<td><p>
Adjust exon length
</p></td>
</tr>
</tbody>
</table>
...
...
docs/reference/
prepare.data.matric
es.html
→
docs/reference/
match.sampl
es.html
View file @
10c41a50
...
...
@@ -6,7 +6,7 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Prepare data matrices —
prepare.data.matric
es • spliceQTL
</title>
<title>
Prepare data matrices —
match.sampl
es • spliceQTL
</title>
<!-- jquery -->
<script
src=
"https://code.jquery.com/jquery-3.1.0.min.js"
integrity=
"sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq"
crossorigin=
"anonymous"
></script>
...
...
@@ -28,10 +28,11 @@
<meta
property=
"og:title"
content=
"Prepare data matrices —
prepare.data.matric
es"
/>
<meta
property=
"og:title"
content=
"Prepare data matrices —
match.sampl
es"
/>
<meta
property=
"og:description"
content=
"This function removes duplicate samples, retains overlapping samples, and
orders samples."
/>
<meta
property=
"og:description"
content=
"This function removes duplicate samples from each matrix,
only retains samples appearing in all matrices,
and brings them into the same order."
/>
<meta
name=
"twitter:card"
content=
"summary"
/>
...
...
@@ -112,28 +113,30 @@ orders samples." />
<div
class=
"page-header"
>
<h1>
Prepare data matrices
</h1>
<small
class=
"dont-index"
>
Source:
<a
href=
'https://github.com/rauschenberger/spliceQTL/blob/master/R/function.R'
><code>
R/function.R
</code></a></small>
<div
class=
"hidden name"
><code>
prepare.data.matric
es.Rd
</code></div>
<div
class=
"hidden name"
><code>
match.sampl
es.Rd
</code></div>
</div>
<div
class=
"ref-description"
>
<p>
This function removes duplicate samples, retains overlapping samples, and
orders samples.
</p>
<p>
This function removes duplicate samples from each matrix,
only retains samples appearing in all matrices,
and brings them into the same order.
</p>
</div>
<pre
class=
"usage"
><span
class=
'fu'
>
prepare.data.matrices
</span>
(
<span
class=
'
no
'
>
Y
</span>
,
<span
class=
'
no'
>
X
</span>
)
</pre>
<pre
class=
"usage"
><span
class=
'fu'
>
match.samples
</span>
(
<span
class=
'no'
>
...
</span>
,
<span
class=
'kw'
>
message
</span>
<span
class=
'
kw
'
>
=
</span>
<span
class=
'
fl'
>
TRUE
</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>
matrix with \(n_y\) rows (samples) and \(p_y\) columns (exons)
</p></td>
<th>
...
</th>
<td><p>
matrices with samples in the rows and variables in the columns
(separated by commas)
</p></td>
</tr>
<tr>
<th>
X
</th>
<td><p>
matrix with \(n_x\) rows (samples) and \(p_x\) columns (SNPs)
</p></td>
<th>
message
</th>
<td><p>
display messages
<strong>
:
</strong>
logical
</p></td>
</tr>
</table>
...
...
man/adjust.
exon.length
.Rd
→
man/adjust.
covariates
.Rd
View file @
10c41a50
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/function.R
\name{adjust.
exon.length
}
\alias{adjust.
exon.length
}
\name{adjust.
covariates
}
\alias{adjust.
covariates
}
\title{Adjust exon length}
\usage{
adjust.
exon.length(x, group, offset
)
adjust.
covariates(x, offset, group
)
}
\arguments{
\item{x}{matrix with \eqn{n} rows (samples) and \eqn{p} columns (exons)}
\item{group}{gene (not exon) names\strong{:} vector of length \eqn{p}}
\item{offset}{exon start positions\strong{:} vector of length \eqn{p}
exon end positions\strong{:} vector of length \eqn{p}}
\item{group}{gene (not exon) names\strong{:} vector of length \eqn{p}}
}
\description{
This function adjusts exon expression data for different exon lengths.
...
...
man/adjust.
library.siz
es.Rd
→
man/adjust.
sampl
es.Rd
View file @
10c41a50
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/function.R
\name{adjust.
library.siz
es}
\alias{adjust.
library.siz
es}
\name{adjust.
sampl
es}
\alias{adjust.
sampl
es}
\title{Adjust library sizes}
\usage{
adjust.
library.siz
es(x)
adjust.
sampl
es(x)
}
\arguments{
\item{x}{matrix with \eqn{n} rows (samples) and \eqn{p} columns (variables)}
}
\description{
This function adjusts
exon
expression data for different library sizes.
This function adjusts
RNA-seq
expression data for different library sizes.
}
\examples{
NA
...
...
man/
prepare.data.matric
es.Rd
→
man/
match.sampl
es.Rd
View file @
10c41a50
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/function.R
\name{
prepare.data.matric
es}
\alias{
prepare.data.matric
es}
\name{
match.sampl
es}
\alias{
match.sampl
es}
\title{Prepare data matrices}
\usage{
prepare.data.matrices(Y, X
)
match.samples(..., message = TRUE
)
}
\arguments{
\item{Y}{matrix with \eqn{n_y} rows (samples) and \eqn{p_y} columns (exons)}
\item{...}{matrices with samples in the rows and variables in the columns
(separated by commas)}
\item{
X}{matrix with \eqn{n_x} rows (samples) and \eqn{p_x} columns (SNPs)
}
\item{
message}{display messages\strong{:} logical
}
}
\description{
This function removes duplicate samples, retains overlapping samples, and
orders samples.
This function removes duplicate samples from each matrix,
only retains samples appearing in all matrices,
and brings them into the same order.
}
\examples{
NA
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment