core: annmatrix Objects and Basic Functionality

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Functions used to construct, test and use the objects of class annmatrix.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
annmatrix(x, rann, cann)

is.annmatrix(x)

## S3 method for class 'annmatrix'
as.matrix(x, ...)

## S3 method for class 'annmatrix'
x[i, j, ..., drop = TRUE]

colanns(x, names)

rowanns(x, names)

colanns(x, names) <- value

rowanns(x, names) <- value

Arguments

x

an R object to be converted, used or tested

rann

annotation data.frame for rows of the annmatrix object

cann

annotation data.frame for columns of the annmatrix object

...

further arguments passed to or from methods

i

subset for rows

j

subset for columns

drop

if TRUE (default) the result of subsetting a single row or column is returned as a vector.

names

a character vector of existing row/column annotation names

value

newly assigned value to row/column annotation field

Details

annmatrix constructs an object of class annmatrix. The function expects x to be a matrix and rowanns and colanns to be of class data.frame. If the passed objects are of a different class the function will try to convert them via the use of as.matrix and as.data.frame.

is.annmatrix checks if the object is an instance of annmatrix.

as.matrix. will turn an annmatrix object into plain matrix.

`[.` returns a selected subset of annmatrix object. Row and column meta-data annotations are preserved and subsetted where needed. In the special case when only one column or row is selected - in order to be consistent with the matrix behavior the dimensions of matrix are dropped and a vector is returned. Just like in the case of matrices the additional argument drop=FALSE can be provided in order to bypass this and return a proper matrix instead.

rowanns and colanns returns the selected field from column and row annotation data.frame respectively. When the selected field is not specified the whole annotation data.frame is returned.

rowanns<- and colanns<- functions can be used to replace the fields from column and row annotation data.frame respectively. When the selected field is not specified the whole annotation data.frame is replaced.

Value

annmatrix - an annmatrix object

is.annmatrix - either TRUE or FALSE

as.matrix - a matrix object

[email protected] - a column named "value" from the row annotation data.frame

annMat$value - a column named "value" from the column annotation data.frame

`[` - a subset of annmatrix and reletad meta-data annotations

Author(s)

Karolis Koncevičius

See Also

'$.annmatrix' '@.annmatrix'

Examples

 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
coldata <- data.frame(group=c(rep("case", 20), rep("control", 20)),
                      gender=sample(c("M", "F"), 40, replace=TRUE)
                      )
rowdata <- data.frame(chr=sample(c("chr1", "chr2"), 100, replace=TRUE),
                      pos=runif(100, 0, 1000000)
                      )
mat <- matrix(rnorm(100*40), 100, 40)
annMat <- annmatrix(mat, rowdata, coldata)

is.annmatrix(mat)
is.annmatrix(annMat)

annMat[1:2,1:2]
annMat[1,,drop=FALSE]

rowanns(annMat)
colanns(annMat)
rowanns(annMat, "chr")
colanns(annMat, c("group", "gender"))

rowanns(annMat, "newField") <- 1:nrow(annMat)
colanns(annMat, "newField") <- 1:ncol(annMat)
colanns(annMat, "newField")
colanns(annMat, "newField") <- NULL
colanns(annMat, "newField")

KKPMW/annmatrix documentation built on Dec. 23, 2018, 10:08 p.m.