if(suppressWarnings(require("bigmemoryExtras",
quietly=TRUE, character.only=TRUE))){
## load ExpressionSet
data("sample.ExpressionSet") ## from Biobase
sample.ExpressionSet ## two assayDataElements: exprs, se
## 'exprs' data matrix
class( assayDataElement( sample.ExpressionSet, "exprs" ) )
## convert assayData to BigMatrix objects
storage.file <- tempfile() ## create path & basemane for BigMatrices
storage.file
on.disk <- eSetOnDisk( sample.ExpressionSet, storage.file )
on.disk ## ExpressionSet
dir(dirname( storage.file )) ## created 3 files per channel
class( assayDataElement( on.disk, "exprs" ) ) ## BigMatrix object
## BigMatrix objects are loaded only upon subsetting
assayDataElement( on.disk, "exprs") ## retrieves BigMatrix, NOT matrix
assayDataElement( on.disk, "exprs")[1:10,1:10] ## loads subset only
dim( assayDataElement( on.disk, "exprs")[,] ) ## retrieves full matrix
## convert back to standard in-memory ExpressionSet
in.memory <- memorize( on.disk )
class( assayDataElement( in.memory, "exprs" ) ) ## standard matrix object
## remove tempfiles generated for this example
unlink(paste(storage.file,"*", sep=""))
}
Run the code above in your browser using DataLab