Learn R Programming

MatrixEQTL (version 2.1.0)

SlicedData-class: Class SlicedData for storing large matrices

Description

This class is created for fast and memory efficient manipulations with large datasets presented in matrix form. It is used to load, store, and manipulate large datasets, e.g. genotype and gene expression matrices. When a dataset is loaded, it is sliced in blocks of 1,000 rows (default size). This allows imputing, standardizing, and performing other operations with the data with minimal memory overhead.

Usage

# x[[i]] indexing allows easy access to individual slices.
# It is equivalent to x$GetSlice(i) and x$SetSlice(i,value)
## S3 method for class 'SlicedData':
[[(x, i)
## S3 method for class 'SlicedData':
[[(x, i) <- value

# The following commands work as if x was a simple matrix object
## S3 method for class 'SlicedData':
nrow(x)
## S3 method for class 'SlicedData':
ncol(x)
## S3 method for class 'SlicedData':
dim(x)
## S3 method for class 'SlicedData':
rownames(x)
## S3 method for class 'SlicedData':
colnames(x)
## S3 method for class 'SlicedData':
rownames(x) <- value
## S3 method for class 'SlicedData':
colnames(x) <- value

# SlicedData object can be easily transformed into a matrix
# preserving row and column names
## S3 method for class 'SlicedData':
as.matrix(x)

# length(x) can be used in place of x$nSlices()
# to get the number of slices in the object
## S3 method for class 'SlicedData':
length(x)

Arguments

x
SlicedData object.
i
Number of a slice.
value
New content for the slice / new row or column names.

Extends

SlicedData is a reference classes (envRefClass). Its methods can change the values of the fields of the class.

References

The package website: http://www.bios.unc.edu/research/genomic_software/Matrix_eQTL/

See Also

This class is used to load data for eQTL analysis by Matrix_eQTL_engine.

Examples

Run this code
# Create a SlicedData variable
sd = SlicedData$new();

# Show the details of the empty object
show(sd);

# Create a matrix of values and assign to sd
mat = matrix(1:12, 3, 4);
rownames(mat) = c("row1","row2","row3");
colnames(mat) = c("col1","col2","col3","col4");
sd$CreateFromMatrix( mat );

# Show the detail of the object (one slice)
show(sd);

# Slice it in pieces of 2 rows
sd$ResliceCombined(sliceSize = 2L);

# Show the number of slices (equivalent function calls)
sd$nSlices()
length(sd)

# Is it all in one slice? (No)
sd$IsCombined()

# Show the column names (equivalent function calls)
sd$columnNames
colnames(sd)

# Show row name slices
sd$rowNameSlices

# Show all row names (equivalent function calls)
sd$GetAllRowNames()
rownames(sd)

# Print the second slice
print( sd[[2]] )

# Reorder and subset columns
sd$ColumnSubsample( c(1,3,4) );

# Reorder and subset rows
sd$RowReorder( c(3,1) );

# Show the detail of the object (one slice again)
show(sd);

# Is it all in one slice? (Yes)
sd$IsCombined()

# Find the row with name "row1" (it is second in the first slice)
sd$FindRow("row1");

Run the code above in your browser using DataLab