Construct an rbiom object. The returned object is an R6 reference class.
Use b <- a$clone()
to create copies, not b <- a
.
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 optionallymetadata
,taxonomy
,tree
, etc (see details).
- ...
Properties to overwrite in biom:
metadata
,taxonomy
,tree
, etc (see details). Settingunderscores
here will pass it toread_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 339 648 478 41
#> OTU2 807 417 150 462
#> OTU3 878 631 635 168
#> OTU4 647 3 690 289
#> OTU5 786 677 588 333
#> OTU6 921 728 165 402
# 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.7k - 4.4k reads/sample ────────────────── 2025-06-30 ──
#>