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

View source: R/as_rbiom.r

as_rbiomR Documentation

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, ...)

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).

Value

An rbiom object.

Examples

    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(list(counts = mtx, metadata = df))
    biom


cmmr/rbiom documentation built on April 28, 2024, 6:38 a.m.