SimpleMatrixReshaping: Convert matrix data between dense, sparse, and list...

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

Description

Convert two-dimensional data between ordinary (dense) matrix type, sparse representation, and a list of rows (or columns).

Usage

1
2
3

Arguments

x

object to convert (matrix)

dim

number of rows and columns (length-two integer)

Details

BIOM (Biological Observation Matrix) is a simple prescription for storing an annotated table of data. It may be described as a format, standard, or data structure.

The JSON (JavaScript Object Notation) standard for expressing general data objects as text is employed to define BIOM. Therefore the native form of BIOM data is structured text, conforming to the JSON specification in general and the BIOM specification in particular. Familiarity with BIOM is assumed here.

The S3 class codebiom and its methods facilitate analyses by expressing BIOM data as objects in the R environment. These manipulations of two-dimensional (matrix) data are sometimes handy when working with BIOM data. The sparse format used by BIOM is conventional, but see the reference for exact details.

All names() and dimnames() are removed.

Value

sparse2dense() and dense2sparse() return a matrix.

matrix2list() returns a list of the rows of x.

Note

Like R these functions begin indices at 1, whereas BIOM counts from 0, so adjust if necessary.

Author(s)

Daniel T. Braithwaite

References

BIOM format
JSON

See Also

biom, as.matrix.biom

Examples

1
2
3
4
5
6
7
xx <- smat
xx[,1:2] <- xx[,1:2] + 1
sparse2dense (xx)
sparse2dense (xx, c(266,10))

matrix2list (dmat)
matrix2list (t(dmat))

BIOM.utils documentation built on May 1, 2019, 7:32 p.m.