eSetOnDisk: A function to store the assayData of an eSet object as...

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

View source: R/utility-functions.R

Description

If the bigmemoryExtras package is available, this function accepts and eSet object and generates separate file-backed BigMatrix objects for each assayDataElement. Data is only loaded into memory upon subsetting, allowing the retrieval of selected data without loading the (potentially large) object into memory in full.

Usage

1
eSetOnDisk(eset, out.file = NULL)

Arguments

eset

An object inheriting from eSet.

out.file

The path and basename of the output file. Three files will be generated for each eSet assayDataElement, identified by extending 'out.file' by suffices.

Value

An object of the same class as 'eset', with file-backed big.matrix elements in the assayData slot.

Note

Please see the bigmemoryExtras package for more details on BigMatrix objects.

Author(s)

Thomas Sandmann

See Also

eSet memorize

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
26
27
28
29
30
31
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=""))  
}

gCMAP documentation built on April 29, 2020, 3:54 a.m.