## ---------------------------------------------------------------------
## DIRECT MANIPULATION OF Assays OBJECTS
## ---------------------------------------------------------------------
m1 <- matrix(runif(24), ncol=3)
m2 <- matrix(runif(24), ncol=3)
a <- Assays(SimpleList(m1, m2))
a
as(a, "SimpleList")
length(a)
a[[2]]
dim(a)
b <- a[-4, 2]
b
length(b)
b[[2]]
dim(b)
names(a)
names(a) <- c("a1", "a2")
names(a)
a[["a2"]]
rbind(a, a)
cbind(a, a)
## ---------------------------------------------------------------------
## COPY-ON-CHANGE CONTRACT
## ---------------------------------------------------------------------
## ShallowSimpleListAssays objects have copy-on-change semantics but not
## AssaysInEnv objects. For example:
ssla <- as(SimpleList(m1, m2), "ShallowSimpleListAssays")
aie <- as(SimpleList(m1, m2), "AssaysInEnv")
## No names on 'ssla' and 'aie':
names(ssla)
names(aie)
ssla2 <- ssla
aie2 <- aie
names(ssla2) <- names(aie2) <- c("A1", "A2")
names(ssla) # still NULL (as expected)
names(aie) # changed! (because the names<-,AssaysInEnv method is not
# implemented in a way that respects the copy-on-change
# contract)
Run the code above in your browser using DataLab