Learn R Programming

WGCNA (version 1.61)

transposeBigData: Transpose a big matrix or data frame

Description

This transpose command partitions a big matrix (or data frame) into blocks and applies the t() function to each block separately.

Usage

transposeBigData(x, blocksize = 20000)

Arguments

x

a matrix or data frame

blocksize

a positive integer larger than 1, which determines the block size. Default is 20k.

Value

A matrix or data frame (depending on the input x ) which is the transpose of x.

Details

Assume you have a very large matrix with say 500k columns. In this case, the standard transpose function of R t() can take a long time. Solution: Split the original matrix into sub-matrices by dividing the columns into blocks. Next apply t() to each sub-matrix. The same holds if the large matrix contains a large number of rows. The function transposeBigData automatically checks whether the large matrix contains more rows or more columns. If the number of columns is larger than or equal to the number of rows then the block wise splitting will be applied to columns otherwise to the rows.

References

Any linear algebra book will explain the transpose.

See Also

The standard function t .

Examples

Run this code
# NOT RUN {
x=data.frame(matrix(1:10000,nrow=4,ncol=2500))
dimnames(x)[[2]]=paste("Y",1:2500,sep="")
xTranspose=transposeBigData(x)
x[1:4,1:4]
xTranspose[1:4,1:4]

# }

Run the code above in your browser using DataLab