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

taxa_corrplot(biom, x = "Age", layers = "ptc", taxa = 2, stat.by = "bod")

Summarize counts by taxonomic rank.

taxa_heatmap(biom, taxa = 30, 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

25,998

Version

2.2.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel P. Smith

Last Published

April 4th, 2025

Functions in rbiom (2.2.0)

biom_merge

Combine several rbiom objects into one.
bdiv_stats

Test beta diversity for associations with metadata.
bdiv_corrplot

Visualize beta diversity with scatterplots and trendlines.
bdiv_table

Distance / dissimilarity between samples.
bdiv_clusters

Cluster samples by beta diversity k-means.
bdply

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

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

Display beta diversities in an all vs all grid.
bdiv_ord_table

Calculate PCoA and other ordinations, including taxa biplots and statistics.
documentation_biom.rbiom

documentation_biom.rbiom
distmat_ord_table

Run ordinations on a distance matrix.
documentation_clusters

documentation_clusters
distmat_stats

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

documentation_cmp
documentation_default

documentation_default
documentation_heatmap

documentation_heatmap
documentation_dist_test

documentation_dist_test
modify_metadata

Create, modify, and delete metadata fields.
hmp50

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

Global Enteric Multicenter Study (n = 1,006)
glimpse.rbiom

Get a glimpse of your metadata.
convert_to

Convert biom data to an external package class.
documentation_rank.2

documentation_rank.2
documentation_rank.NULL

documentation_rank.NULL
documentation_return.biom

documentation_return.biom
documentation_plot_return

documentation_plot_return
plot_heatmap

Create a heatmap with tracks and dendrograms from any matrix.
pull.rbiom

Map sample names to metadata field values.
export

Export data to QIIME 2 or mothur.
documentation_taxa.4

documentation_taxa.4
rare_stacked

Visualize the number of observations per sample.
rare_multiplot

Combines rare_corrplot and rare_stacked into a single figure.
rare_corrplot

Visualize rarefaction curves with scatterplots and trendlines.
rarefy_cols

Transform a counts matrix.
read_biom

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

Parse a fasta file into a named character vector.
rbiom-deprecated

Deprecated functions in package rbiom.
rbiom-package

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

Working with rbiom Objects.
read_tree

Read a newick formatted phylogenetic tree.
speed

Speed Ups.
subset

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

Visualize categorical metadata effects on numeric values.
stats_corrplot

Visualize regression with scatterplots and trendlines.
stats_table

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

Rarefy OTU counts.
sample_sums

Summarize the taxa observations in each sample.
slice_metadata

Subset to a specific number of samples.
taxa_boxplot

Visualize BIOM data with boxplots.
taxa_table

Taxa abundances per sample.
taxa_stacked

Display taxa abundances as a stacked bar graph.
taxa_heatmap

Display taxa abundances as a heatmap.
taxa_map

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

Objects exported from other packages
taxa_stats

Test taxa abundances for associations with metadata.
taxa_sums

Get summary taxa abundances.
taxa_clusters

Cluster samples by taxa abundances k-means.
write_biom

Save an rbiom object to a file.
taxa_corrplot

Visualize taxa abundance with scatterplots and trendlines.
tree_subset

Create a subtree by specifying tips to keep.
with

Evaluate expressions on metadata.
adiv_table

Calculate the alpha diversity of each sample.
adiv_matrix

Create a matrix of samples x alpha diversity metrics.
babies

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

Visualize BIOM data with boxplots.
as.list.rbiom

Convert an rbiom object to a base R list.
adiv_boxplot

Visualize alpha diversity with boxplots.
adiv_corrplot

Visualize alpha diversity with scatterplots and trendlines.
adiv_stats

Test alpha diversity for associations with metadata.
as.matrix.rbiom

Convert an rbiom object to a simple count matrix.
as_rbiom

Convert a variety of data types to an rbiom object.