82 | 83 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,100 @@ |
1 |
+#' sbcms |
|
2 |
+#' |
|
3 |
+#' Signal/batch correction using SMCBMS package |
|
4 |
+#' @export sb_corr |
|
5 |
+#' @examples |
|
6 |
+#' M = sb_corr() |
|
7 |
+sb_corr<-setClass( |
|
8 |
+ "sb_corr", |
|
9 |
+ contains = c('method'), |
|
10 |
+ slots=c( |
|
11 |
+ params.order_col='entity', |
|
12 |
+ params.batch_col='entity', |
|
13 |
+ params.qc_col='entity', |
|
14 |
+ params.smooth='entity', |
|
15 |
+ params.use_log='entity', |
|
16 |
+ params.min_qc='entity', |
|
17 |
+ outputs.corrected='entity' |
|
18 |
+ ), |
|
19 |
+ |
|
20 |
+ prototype=list( |
|
21 |
+ name = 'Signal/batch correction for mass spectrometry data', |
|
22 |
+ description = 'Applies Quality Control Robust Spline (QC-RSC) method to |
|
23 |
+ correct for signal drift and batch differences in mass spectrometry data.', |
|
24 |
+ type = 'correction', |
|
25 |
+ predicted = 'corrected', |
|
26 |
+ |
|
27 |
+ params.order_col=entity( |
|
28 |
+ name = 'Sample run order column', |
|
29 |
+ description = 'The column name of sample_meta indicating the run order of the samples.', |
|
30 |
+ value = character(0), |
|
31 |
+ type='character'), |
|
32 |
+ |
|
33 |
+ params.batch_col=entity( |
|
34 |
+ name = 'Batch ID column', |
|
35 |
+ description = 'The column name of sample_meta indicating the batch each sample was measured in.', |
|
36 |
+ value = character(0), |
|
37 |
+ type='character'), |
|
38 |
+ |
|
39 |
+ params.qc_col=entity( |
|
40 |
+ name = 'Class ID column', |
|
41 |
+ description = 'The column name of sample_meta indicating the group each sample is a member of.', |
|
42 |
+ value = character(0), |
|
43 |
+ type='character'), |
|
44 |
+ |
|
45 |
+ params.smooth=entity( |
|
46 |
+ name = 'Spline smoothing parameter', |
|
47 |
+ description = 'Should be in the range 0 to 1. If set to 0 (default) it will be estimated using |
|
48 |
+ leave-one-out cross-validation.', |
|
49 |
+ value = 0, |
|
50 |
+ type='numeric'), |
|
51 |
+ |
|
52 |
+ params.use_log=entity( |
|
53 |
+ name = 'Use log transformed data', |
|
54 |
+ description = 'TRUE or FALSE to perform the signal correction fit on the log scaled data. Default is TRUE.', |
|
55 |
+ value = 0, |
|
56 |
+ type='numeric'), |
|
57 |
+ |
|
58 |
+ params.min_qc=entity( |
|
59 |
+ name = 'Minimum number of QCs', |
|
60 |
+ description = 'Minimum number of QC samples required for signal correction.', |
|
61 |
+ value = 4, |
|
62 |
+ type='numeric'), |
|
63 |
+ |
|
64 |
+ outputs.corrected=entity(name = 'Signal/batch corrected dataset', |
|
65 |
+ description = 'THe dataset after signal/batch correction has been applied.', |
|
66 |
+ type='dataset', |
|
67 |
+ value=dataset() |
|
68 |
+ ) |
|
69 |
+ ) |
|
70 |
+) |
|
71 |
+ |
|
72 |
+#' @export |
|
73 |
+setMethod(f="method.apply", |
|
74 |
+ signature=c("sb_corr","dataset"), |
|
75 |
+ definition=function(M,D) |
|
76 |
+ { |
|
77 |
+ rn=rownames(D$data) |
|
78 |
+ cn=colnames(D$data) |
|
79 |
+ # uses transposed data |
|
80 |
+ X=as.data.frame(t(D$data)) |
|
81 |
+ |
|
82 |
+ # apply correction |
|
83 |
+ corrected_data <- sbcms::QCRSC( |
|
84 |
+ df=X, |
|
85 |
+ order=D$sample_meta[[M$order_col]], |
|
86 |
+ batch=D$sample_meta[[M$batch_col]], |
|
87 |
+ classes=D$sample_meta[[M$qc_col]], |
|
88 |
+ spar=M$smooth, |
|
89 |
+ minQC=M$min_qc, |
|
90 |
+ log=M$use_log |
|
91 |
+ ) |
|
92 |
+ |
|
93 |
+ D$data=as.data.frame(t(corrected_data)) |
|
94 |
+ rownames(D$data)=rn |
|
95 |
+ colnames(D$data)=cn |
|
96 |
+ |
|
97 |
+ M$corrected=D |
|
98 |
+ return(M) |
|
99 |
+ } |
|
100 |
+) |
0 | 101 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,13 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/sb_corr.R |
|
3 |
+\docType{class} |
|
4 |
+\name{sb_corr-class} |
|
5 |
+\alias{sb_corr-class} |
|
6 |
+\alias{sb_corr} |
|
7 |
+\title{sbcms} |
|
8 |
+\description{ |
|
9 |
+Signal/batch correction using SMCBMS package |
|
10 |
+} |
|
11 |
+\examples{ |
|
12 |
+M = sb_corr() |
|
13 |
+} |