-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKINOMOns-class.R
52 lines (42 loc) · 1.04 KB
/
KINOMOns-class.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
#' @include KINOMOstd-class.R
NULL
#'
setClass('KINOMOns'
, representation(
theta = 'numeric' # smoothing matrix
)
, contains = 'KINOMOstd'
, prototype = prototype(
theta = 0.5
)
, validity = function(object){
if( object@theta < 0 || object@theta > 1 )
return(paste("Invalid value for theta (",object@theta,"): must be between 0 and 1", sep=''))
TRUE
}
)
#' Show method for objects of class \code{KINOMOns}
#' @export
setMethod('show', 'KINOMOns',
function(object)
{
callNextMethod()
cat("theta:", object@theta, "\n")
}
)
#'
setMethod('fitted', signature(object='KINOMOns'),
function(object, W, H, S, ...){
if( missing(W) ) W <- object@W
if( missing(H) ) H <- object@H
if( missing(S) ) S <- smoothing(object, ...)
W %*% (S %*% H)
}
)
#'
smoothing <- function(x, theta=x@theta, ...){
# check validity of theta
if( theta < 0 || theta > 1 )
stop("Invalid smoothing parameter theta [",theta,"]: theta must be susch that 0 <= theta <=1")
diag(1-theta, nbasis(x)) + theta / nbasis(x)
}