# 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]
Run the code above in your browser using DataLab