subset {annmatrix}R Documentation

Subset annmatrix Objects

Description

Methods for selecting a set of rows or columns from annmatrix while keeping the associated annotations intact.

Usage

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

Arguments

x

an R object.

i

subset for rows.

j

subset for columns.

...

further arguments passed to or from methods.

drop

if TRUE (default) subsetting a single row or column will returned a vector.

Details

X[i,j] returns a selected subset of annmatrix object. Row and column 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 return a proper matrix instead.

Value

A selected subset of the provided 'annmatrix' object.

Author(s)

Karolis Koncevičius

See Also

as.annmatrix

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)

# annotations are preserved after subsetting
Y <- X[X@chr == "chr1", X$group == "case"]
Y@chr
Y$''

Y[, 1]
Y[, 1, drop = FALSE]


[Package annmatrix version 0.1.2 Index]