Learn R Programming

rbiom (version 2.2.0)

as_rbiom: Convert a variety of data types to an rbiom object.

Description

Construct an rbiom object. The returned object is an R6 reference class. Use b <- a$clone() to create copies, not b <- a.

Usage

as_rbiom(biom, ...)

Value

An rbiom object.

Arguments

biom

Object which can be coerced to an rbiom-class object. For example:

file -

Filepath or URL to a biom file.

matrix -

An abundance matrix with OTUs in rows and samples in columns.

phyloseq-class object -

From the phyloseq Bioconductor R package.

list -

With counts and optionally metadata, taxonomy, tree, etc (see details).

...

Properties to overwrite in biom: metadata, taxonomy, tree, etc (see details). Setting underscores here will pass it to read_tree().

Examples

Run this code
    library(rbiom)
    
    # create a simple matrix ------------------------
    mtx <- matrix(
      data     = floor(runif(24) * 1000), 
      nrow     = 6, 
      dimnames = list(paste0("OTU", 1:6), paste0("Sample", 1:4)) )
    mtx
    
    # and some sample metadata ----------------------
    df <- data.frame(
      .sample   = paste0("Sample", 1:4),
      treatment = c("A", "B", "A", "B"),
      days      = c(12, 3, 7, 8) )
    
    # convert data set to rbiom ---------------------
    biom <- as_rbiom(mtx, metadata = df, id = "My BIOM")
    biom

Run the code above in your browser using DataLab