Browse code

RLE = DESEQ and added CLR

mbcole authored on 05/04/2017 19:21:35
Showing 5 changed files

... ...
@@ -1,9 +1,9 @@
1 1
 # Generated by roxygen2: do not edit by hand
2 2
 
3
+export(CLR_FN)
3 4
 export(DESEQ_FN)
4 5
 export(FQT_FN)
5 6
 export(FQ_FN)
6
-export(RLE_FN)
7 7
 export(SUM_FN)
8 8
 export(SconeExperiment)
9 9
 export(TMM_FN)
... ...
@@ -43,7 +43,6 @@ import(methods)
43 43
 import(plotly)
44 44
 import(visNetwork)
45 45
 importClassesFrom(SummarizedExperiment,SummarizedExperiment)
46
-importFrom(DESeq,estimateSizeFactorsForMatrix)
47 46
 importFrom(DT,dataTableOutput)
48 47
 importFrom(DT,dataTableProxy)
49 48
 importFrom(DT,formatSignif)
... ...
@@ -57,6 +56,7 @@ importFrom(boot,inv.logit)
57 56
 importFrom(boot,logit)
58 57
 importFrom(class,knn)
59 58
 importFrom(cluster,silhouette)
59
+importFrom(compositions,clr)
60 60
 importFrom(diptest,dip.test)
61 61
 importFrom(edgeR,calcNormFactors)
62 62
 importFrom(fpc,pamk)
... ...
@@ -33,7 +33,7 @@ TMM_FN = function(ei) {
33 33
   return(eo)
34 34
 }
35 35
 
36
-#' Relative log-expression (RLE) scaling normalization wrapper function
36
+#' Relative log-expression (RLE; DESeq) scaling normalization wrapper function
37 37
 #' @importFrom edgeR calcNormFactors
38 38
 #' @details SCONE scaling wrapper for \code{\link[edgeR]{calcNormFactors}}).
39 39
 #' @export
... ...
@@ -42,9 +42,9 @@ TMM_FN = function(ei) {
42 42
 #'   
43 43
 #' @examples
44 44
 #' ei <- matrix(0:20,nrow = 7)
45
-#' eo <- RLE_FN(ei)
45
+#' eo <- DESEQ_FN(ei)
46 46
 #' 
47
-RLE_FN = function(ei) {
47
+DESEQ_FN = function(ei) {
48 48
   size_fac = calcNormFactors(ei, method = "RLE")
49 49
   scales = (colSums(ei) * size_fac)
50 50
   eo = t(t(ei) * mean(scales) / scales)
... ...
@@ -100,20 +100,24 @@ FQT_FN = function(ei) {
100 100
   return(eo)
101 101
 }
102 102
 
103
-#' DESeq size factor scaling normalization wrapper function
104
-#' @importFrom DESeq estimateSizeFactorsForMatrix
103
+#' Centered log-ratio (CLR) normalization wrapper function
104
+#' @importFrom compositions clr
105
+#' @importFrom matrixStats colMedians
105 106
 #' @details SCONE scaling wrapper for 
106
-#'   \code{\link[DESeq]{estimateSizeFactorsForMatrix}}).
107
+#'   \code{\link[compositions]{clr}}).
107 108
 #' @export
108 109
 #' @param ei Numerical matrix. (rows = genes, cols = samples).
109
-#' @return DESeq size factor normalized matrix.
110
+#' @return CLR normalized matrix.
110 111
 #'   
111 112
 #' @examples
112 113
 #' ei <- matrix(0:20,nrow = 7)
113
-#' eo <- DESEQ_FN(ei)
114
+#' eo <- CLR_FN(ei)
114 115
 #' 
115
-DESEQ_FN = function(ei) {
116
-  size_fac = estimateSizeFactorsForMatrix(ei)
117
-  eo = t(t(ei) / size_fac)
116
+CLR_FN = function (ei)
117
+{
118
+  scale_mat <- t(clr(t(ei))) - log(ei)
119
+  scale_mat[ei == 0] = NA
120
+  scales = exp(-colMedians(scale_mat, na.rm = TRUE))
121
+  eo = t(t(ei) * mean(scales) / scales)
118 122
   return(eo)
119 123
 }
120 124
\ No newline at end of file
121 125
new file mode 100644
... ...
@@ -0,0 +1,26 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/SCONE_DEFAULTS.R
3
+\name{CLR_FN}
4
+\alias{CLR_FN}
5
+\title{Centered log-ratio (CLR) normalization wrapper function}
6
+\usage{
7
+CLR_FN(ei)
8
+}
9
+\arguments{
10
+\item{ei}{Numerical matrix. (rows = genes, cols = samples).}
11
+}
12
+\value{
13
+CLR normalized matrix.
14
+}
15
+\description{
16
+Centered log-ratio (CLR) normalization wrapper function
17
+}
18
+\details{
19
+SCONE scaling wrapper for 
20
+  \code{\link[compositions]{clr}}).
21
+}
22
+\examples{
23
+ei <- matrix(0:20,nrow = 7)
24
+eo <- CLR_FN(ei)
25
+
26
+}
... ...
@@ -2,7 +2,7 @@
2 2
 % Please edit documentation in R/SCONE_DEFAULTS.R
3 3
 \name{DESEQ_FN}
4 4
 \alias{DESEQ_FN}
5
-\title{DESeq size factor scaling normalization wrapper function}
5
+\title{Relative log-expression (RLE; DESeq) scaling normalization wrapper function}
6 6
 \usage{
7 7
 DESEQ_FN(ei)
8 8
 }
... ...
@@ -10,14 +10,13 @@ DESEQ_FN(ei)
10 10
 \item{ei}{Numerical matrix. (rows = genes, cols = samples).}
11 11
 }
12 12
 \value{
13
-DESeq size factor normalized matrix.
13
+RLE normalized matrix.
14 14
 }
15 15
 \description{
16
-DESeq size factor scaling normalization wrapper function
16
+Relative log-expression (RLE; DESeq) scaling normalization wrapper function
17 17
 }
18 18
 \details{
19
-SCONE scaling wrapper for 
20
-  \code{\link[DESeq]{estimateSizeFactorsForMatrix}}).
19
+SCONE scaling wrapper for \code{\link[edgeR]{calcNormFactors}}).
21 20
 }
22 21
 \examples{
23 22
 ei <- matrix(0:20,nrow = 7)
24 23
new file mode 100644
... ...
@@ -0,0 +1,25 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/SCONE_DEFAULTS.R
3
+\name{SUM_FN}
4
+\alias{SUM_FN}
5
+\title{Sum scaling normalization function}
6
+\usage{
7
+SUM_FN(ei)
8
+}
9
+\arguments{
10
+\item{ei}{Numerical matrix. (rows = genes, cols = samples).}
11
+}
12
+\value{
13
+Sum-scaled normalized matrix.
14
+}
15
+\description{
16
+Sum scaling normalization function
17
+}
18
+\details{
19
+SCONE scaling by library size or summed expression.
20
+}
21
+\examples{
22
+ei <- matrix(0:20,nrow = 7)
23
+eo <- SUM_FN(ei)
24
+
25
+}