Construct an object of class
biom from given data, supplementing missing fields as
1 2 3 4 5 6 7 8 9 10
an object convertible to
the type of BIOM table to be constructed (string)
file containing JSON text for BIOM data (string)
print messages and warnings? (
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 S3 class
biom and its methods facilitate analyses
by expressing BIOM data as objects in the R environment.
Each function above transforms an object of a basic R type into class
character method is suitable for importing BIOM data properly speaking,
that is, JSON text conforming to the BIOM specification.
The data is read from
file, when provided.
... are passed to
in order to allow for different character encodings,
To make a
biom object from a TSV or CSV file, see examples below.
Of course, it is possible to bring
in and out of the session with
matrix method accepts an ordinary (
or a three-column sparse matrix representation
(using indices starting at zero, per BIOM).
If the latter,
sparse should also be provided,
as a length-two
integer giving the data table's
or a length-two list giving its row and column
It may also be simply
in which case the smallest possible
shape is assigned.
list method accepts a
list of components allowed or required by BIOM,
inventing something reasonable for missing components, with certain qualifications:
shape is required if
matrix_type is specified as
data may be given as a
list of rows,
list of triples sparsely representing a matrix, or a
in the last case, its
dimnames() may be used
to provide row and column
if provided, supercede
An object of class
biom object reflects its
storage.mode() of its
storage.mode<-() prior to
biom() can be useful.
See examples below.
Also, note that values seeming to be integers in R often are not.
Daniel T. Braithwaite
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 32
tt <- tempfile() ## two ways to the same result: ff <- exampleBiomFile() txt <- readLines (ff) biom (txt) biom (file=ff) ## choose what fields to include with a list: biom (list (data=smat, matrix_type="sparse", shape=c(266,4), matrix_element_type="unicode", comment="no comment"), quiet=TRUE) xx <- matrix2list (cbind (LETTERS[1:20], paste ("some metadata for row", 1:20))) xx <- lapply (xx, "names<-", c("id", "metadata")) biom (list (data=dmat, type="Gene table", rows=xx, id="1234567890"), quiet=TRUE) ## the same result in two ways, again: write.table (dmat, file=tt, sep=",") biom (dmat, "Function table") biom (as.matrix (read.table (file=tt, sep=",")), "Func") ## all the same: biom (smat, sparse=TRUE, quiet=TRUE) biom (smat, sparse=c(266,4), quiet=TRUE) biom (smat, sparse=list (paste ("row", 1:266), paste ("column", 1:4)), quiet=TRUE) ## enforce matrix_element_type to be "int": mm <- dmat storage.mode (mm) <- "integer" biom (mm, quiet=TRUE) unlink (tt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.