scale {annmatrix} | R Documentation |
Scaling and Centering of annmatrix Objects
Description
Centers and scales the columns of an annmatrix object.
Usage
## S3 method for class 'annmatrix'
scale(x, center = TRUE, scale = TRUE)
Arguments
x |
annmatrix object. |
center |
either a logical value or a numeric vector of length equal to the number of columns of 'x' (default is TRUE). |
scale |
either a logical value or a numeric vector of length equal to the number of columns of 'x' (default is TRUE). |
Details
Behaves exactly as scale
on a regular matrix with the preservation of 'annmatrix' class being the only difference.
Value
The centered and/or scaled annmatrix object with additional attributes "scaled:center" and "scaled:scale" holding the numbers used for centering and scaling of each column.
Author(s)
Karolis Koncevičius
See Also
scale.default
Examples
# construct annmatrix object
x <- matrix(rnorm(20*10), 20, 10)
coldata <- data.frame(group = rep(c("case", "control"), each = 5),
gender = sample(c("M", "F"), 10, replace = TRUE))
rowdata <- data.frame(chr = sample(c("chr1", "chr2"), 20, replace = TRUE),
pos = runif(20, 0, 1000000))
X <- annmatrix(x, rowdata, coldata)
scale(X)
scale(X, center = colMeans(X))
[Package annmatrix version 0.1.2 Index]