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 (JSON, HDF5, or tabular), or a JSON string.

matrix -

An abundance matrix (base or Matrix) with OTUs in rows and samples in columns.

data.frame -

Treated as an abundance matrix: OTUs in rows (row names) and samples in columns.

list -

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

rbiom -

Returned as-is, unless ... requests changes, in which case a modified clone is returned.

phyloseq -

From the phyloseq Bioconductor R package.

SummarizedExperiment -

From the SummarizedExperiment Bioconductor R package.

TreeSummarizedExperiment -

From the TreeSummarizedExperiment Bioconductor R package.

MultiAssayExperiment -

From the MultiAssayExperiment Bioconductor R package (its first experiment is used).

biom -

From the biomformat Bioconductor R package.

...

Properties to overwrite in biom: metadata, taxonomy, tree, sequences, id, comment, or date (see details). Setting underscores here will pass it to read_tree().

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      80     497      34     388
#> OTU2     834     289     320     975
#> OTU3     600     732     402     289
#> OTU4     157     772     195     678
#> OTU5       7     874     403     735
#> OTU6     466     174      63     195

    # 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>
#> 
#> ── 1.4k - 3.3k reads/sample ────────────────── 2026-11-13 ──
#>