-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBioc-layer.R
192 lines (148 loc) · 4.85 KB
/
Bioc-layer.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
###############################################################################
#' @include KINOMO-class.R
#' @include transforms.R
NULL
NULL
if(!requireNamespace("Biobase")) BiocManager::install("Biobase")
.onLoad.KINOMO.bioc <- function(){
if( pkgmaker::require.quiet('Biobase') ){
# load Biobase package
requireNamespace('Biobase')
#library(Biobase)
#' Performs KINOMO on an ExpressionSet: the target matrix is the expression matrix \code{exprs(x)}.
#' @rdname bioc
setMethod('KINOMO', signature(x='ExpressionSet', rank='ANY', method='ANY'),
function(x, rank, method, ...)
{
# replace missing values by NULL values for correct dispatch
if( missing(method) ) method <- NULL
if( missing(rank) ) rank <- NULL
# apply KINOMO to the gene expression matrix
KINOMO(Biobase::exprs(x), rank, method, ...)
}
)
setMethod('KINOMO', signature(x='matrix', rank='ExpressionSet', method='ANY'),
function(x, rank, method, ...){
# replace missing values by NULL values for correct dispatch
if( missing(method) ) method <- NULL
KINOMO(x, Biobase::exprs(rank), method, ...)
}
)
setMethod('seed', signature(x='ExpressionSet', model='ANY', method='ANY'),
function(x, model, method, ...)
{
# replace missing values by NULL values for correct dispatch
if( missing(method) ) method <- NULL
if( missing(model) ) model <- NULL
# apply KINOMO to the gene expression matrix
seed(Biobase::exprs(x), model, method, ...)
}
)
#' Runs an KINOMO algorithm on the expression matrix of an \code{ExpressionSet} object.
setMethod('run', signature(object='KINOMOStrategy', y='ExpressionSet', x='ANY'),
function(object, y, x, ...){
run(object, Biobase::exprs(y), x, ...)
}
)
###% Method 'KINOMOModel' for 'ExpressionSet' target objects:
###% -> use the expression matrix of 'target' as the target matrix
setMethod('KINOMOModel', signature(rank='ANY', target='ExpressionSet'),
function(rank, target, ...){
if( missing(rank) ) rank <- NULL
# call KINOMOModel on the expression matrix
KINOMOModel(rank, Biobase::exprs(target), ...)
}
)
setMethod('KINOMOModel', signature(rank='ExpressionSet', target='ANY'),
function(rank, target, ...){
if( missing(target) ) target <- NULL
# call KINOMOModel on the expression matrix
KINOMOModel(Biobase::exprs(rank), target, ...)
}
)
###% Method 'rKINOMO' for 'ExpressionSet' target objects:
###% -> use the expression matrix of 'target' as the target matrix
###%
setMethod('rKINOMO', signature(x='ANY', target='ExpressionSet'),
function(x, target, ...){
rKINOMO(x, Biobase::exprs(target), ...)
}
)
###% The method for an \code{ExpressionSet} object returns the data.frame that
###% contains the phenotypic data (i.e. \code{pData(object)})
setMethod('.atrack', 'ExpressionSet',
function(object, data=NULL, ...){
if( is.null(data) ) data <- t(Biobase::exprs(object))
.atrack(Biobase::pData(object), data=data, ...)
}
)
setMethod('nneg', 'ExpressionSet'
, function(object, ...){
Biobase::exprs(object) <- nneg(Biobase::exprs(object), ...)
object
}
)
setMethod('rposneg', 'ExpressionSet'
, function(object, ...){
Biobase::exprs(object) <- rposneg(Biobase::exprs(object), ...)
object
}
)
###% Annotate the genes specific to each cluster.
###%
###% This function uses the \code{annaffy} package to generate an HTML table from the probe identifiers.
## Assign BioConductor aliases
###% number of metagenes
nmeta <- nbasis
###% get/set methods of basis matrix
metagenes <- basis
`metagenes<-` <- `basis<-`
###% get/set methods of mixture coefficients matrix
metaprofiles <- coef
`metaprofiles<-` <- `coef<-`
###% Get/Set methods for rows/columns names of the basis and mixture matrices
# using the Biobase definition standard generics
setGeneric('featureNames', package='Biobase')
setGeneric('featureNames<-', package='Biobase')
setMethod('featureNames', 'KINOMO',
function(object){
rownames(object)
}
)
setReplaceMethod('featureNames', 'KINOMO',
function(object, value){
rownames(object) <- value
object
}
)
###% For KINOMOfitX objects: returns the featureNames of the best fit
###% There is no replace method for KINOMOfitX objects
setMethod('featureNames', 'KINOMOfitX',
function(object){
rownames(fit(object))
}
)
setGeneric('sampleNames', package='Biobase')
setGeneric('sampleNames<-', package='Biobase')
setMethod('sampleNames', 'KINOMO',
function(object){
colnames(object)
}
)
setReplaceMethod('sampleNames', 'KINOMO',
function(object, value){
colnames(object) <- value
object
}
)
###% For KINOMOfitX objects: returns the sampleNames of the best fit
###% There is no replace method for KINOMOfitX objects
setMethod('sampleNames', 'KINOMOfitX',
function(object){
colnames(fit(object))
}
)
# return TRUE
TRUE
}
}