Learn R Programming

rbiom

This package is a toolkit for working with Biological Observation Matrix (BIOM) files. Features include reading/writing all ‘BIOM’ formats, rarefaction, alpha diversity, beta diversity (including ‘UniFrac’), summarizing counts by taxonomic level, subsetting, visualizations, and statistical analysis. All CPU intensive operations are written in C.

Reference material is available online at https://cmmr.github.io/rbiom/index.html

Source code can be found at https://github.com/cmmr/rbiom

Installation

The latest stable version can be installed from CRAN.

install.packages("pak")
pak::pak("rbiom")

The development version is available on GitHub.

pak::pak("cmmr/rbiom")

Usage

Import and rarefy abundance counts.

library(rbiom)

infile <- system.file(package = "rbiom", "extdata", "hmp50.bz2")
biom   <- rarefy(infile)

Explore associations with metadata.

bdiv_ord_plot(biom, stat.by = "Body Site", facet.by = "Sex")

adiv_boxplot(biom, x = "Sex", adiv = c("otu", "shan"), stat.by = "Body Site")

subset(biom, `Body Site` == 'Buccal mucosa') %>% 
  taxa_corrplot("Age", taxa = 2, layers = 'ptc', fit = 'lm', test = 'emtrends')

Summarize counts by taxonomic rank.

taxa_heatmap(biom, taxa = 10, tracks = c("body", "age"))

taxa_stacked(biom, rank = "Phylum")

taxa_table(biom, 'Phylum')
#> # A tibble: 294 × 8
#>    .rank  .sample .taxa          .abundance   Age   BMI `Body Site`   Sex   
#>    <fct>  <chr>   <fct>               <dbl> <dbl> <dbl> <fct>         <fct> 
#>  1 Phylum HMP01   Firmicutes            856    22    20 Buccal mucosa Female
#>  2 Phylum HMP01   Bacteroidetes         199    22    20 Buccal mucosa Female
#>  3 Phylum HMP01   Actinobacteria         16    22    20 Buccal mucosa Female
#>  4 Phylum HMP01   Proteobacteria         72    22    20 Buccal mucosa Female
#>  5 Phylum HMP01   Fusobacteria           32    22    20 Buccal mucosa Female
#>  6 Phylum HMP01   Tenericutes             0    22    20 Buccal mucosa Female
#>  7 Phylum HMP02   Firmicutes            803    24    23 Buccal mucosa Male  
#>  8 Phylum HMP02   Bacteroidetes         192    24    23 Buccal mucosa Male  
#>  9 Phylum HMP02   Actinobacteria         52    24    23 Buccal mucosa Male  
#> 10 Phylum HMP02   Proteobacteria         96    24    23 Buccal mucosa Male  
#> # ℹ 284 more rows

Copy Link

Version

Install

install.packages('rbiom')

Monthly Downloads

1,380

Version

2.2.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel P. Smith

Last Published

June 27th, 2025

Functions in rbiom (2.2.1)

convert_to

Convert biom data to an external package class.
biom_merge

Combine several rbiom objects into one.
bdiv_heatmap

Display beta diversities in an all vs all grid.
bdiv_ord_plot

Ordinate samples and taxa on a 2D plane based on beta diversity distances.
documentation_biom.rbiom

documentation_biom.rbiom
documentation_clusters

documentation_clusters
bdiv_table

Distance / dissimilarity between samples.
bdply

Apply a function to each subset of an rbiom object.
distmat_stats

Run statistics on a distance matrix vs a categorical or numeric variable.
distmat_ord_table

Run ordinations on a distance matrix.
adiv_stats

Test alpha diversity for associations with metadata.
bdiv_ord_table

Calculate PCoA and other ordinations, including taxa biplots and statistics.
bdiv_stats

Test beta diversity for associations with metadata.
pull.rbiom

Map sample names to metadata field values.
plot_heatmap

Create a heatmap with tracks and dendrograms from any matrix.
read_biom

Parse counts, metadata, taxonomy, and phylogeny from a BIOM file.
read_fasta

Parse a fasta file into a named character vector.
documentation_plot_return

documentation_plot_return
bdiv_clusters

Cluster samples by beta diversity k-means.
documentation_taxa.4

documentation_taxa.4
bdiv_corrplot

Visualize beta diversity with scatterplots and trendlines.
read_tree

Read a newick formatted phylogenetic tree.
documentation_cmp

documentation_cmp
modify_metadata

Create, modify, and delete metadata fields.
export

Export data to QIIME 2 or mothur.
rare_corrplot

Visualize rarefaction curves with scatterplots and trendlines.
documentation_heatmap

documentation_heatmap
hmp50

Human Microbiome Project - demo dataset (n = 50)
documentation_default

documentation_default
glimpse.rbiom

Get a glimpse of your metadata.
documentation_rank.2

documentation_rank.2
documentation_dist_test

documentation_dist_test
gems

Global Enteric Multicenter Study (n = 1,006)
rare_stacked

Visualize the number of observations per sample.
tree_subset

Create a subtree by specifying tips to keep.
reexports

Objects exported from other packages
rbiom-package

rbiom: Read/Write, Transform, and Summarize BIOM Data
rbiom_objects

Working with rbiom Objects.
write_biom

Save an rbiom object to a file.
stats_corrplot

Visualize regression with scatterplots and trendlines.
taxa_boxplot

Visualize BIOM data with boxplots.
with

Evaluate expressions on metadata.
rarefy

Rarefy OTU counts.
subset

Subset an rbiom object by sample names, OTU names, metadata, or taxonomy.
rarefy_cols

Transform a counts matrix.
stats_table

Run non-parametric statistics on a data.frame.
rare_multiplot

Combines rare_corrplot and rare_stacked into a single figure.
speed

Speed Ups.
documentation_rank.NULL

documentation_rank.NULL
documentation_return.biom

documentation_return.biom
rbiom-deprecated

Deprecated functions in package rbiom.
slice_metadata

Subset to a specific number of samples.
sample_sums

Summarize the taxa observations in each sample.
taxa_heatmap

Display taxa abundances as a heatmap.
taxa_map

Map OTUs names to taxa names at a given rank.
stats_boxplot

Visualize categorical metadata effects on numeric values.
taxa_clusters

Cluster samples by taxa abundances k-means.
taxa_corrplot

Visualize taxa abundance with scatterplots and trendlines.
taxa_stats

Test taxa abundances for associations with metadata.
taxa_sums

Get summary taxa abundances.
taxa_table

Taxa abundances per sample.
taxa_stacked

Display taxa abundances as a stacked bar graph.
adiv_boxplot

Visualize alpha diversity with boxplots.
babies

Longitudinal Stool Samples from Infants (n = 2,684)
adiv_corrplot

Visualize alpha diversity with scatterplots and trendlines.
as_rbiom

Convert a variety of data types to an rbiom object.
adiv_table

Calculate the alpha diversity of each sample.
adiv_matrix

Create a matrix of samples x alpha diversity metrics.
as.list.rbiom

Convert an rbiom object to a base R list.
bdiv_boxplot

Visualize BIOM data with boxplots.
as.matrix.rbiom

Convert an rbiom object to a simple count matrix.