Skip to contents

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

...

Properties to overwrite in biom: 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
#>      Sample1 Sample2 Sample3 Sample4
#> OTU1     320     878     631     635
#> OTU2     945     647       3     690
#> OTU3     662     786     677     588
#> OTU4     474     921     728     165
#> OTU5     339     648     478      41
#> OTU6     807     417     150     462
    
    # 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
#> 
#> ══ My BIOM ═════════════════════════════════════════════════
#> 
#>       4 Samples: Sample1, Sample2, Sample3, and Sample4 
#>       6 OTUs:    OTU1, OTU2, OTU3, OTU4, OTU5, and OTU6 
#>       1 Ranks:   .otu 
#>       3 Fields:  .sample, treatment, and days 
#>         Tree:    <absent>
#> 
#> ── 2.6k - 4.3k reads/sample ────────────────── 2025-01-22 ──
#>