Learn R Programming

⚠️There's a newer version (2.2.0) of this package.Take me there.

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, and sample subsetting. Standalone functions for reading, writing, and subsetting phylogenetic trees are also provided. All CPU intensive operations are encoded in C with multi-thread support.

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 downloaded from CRAN.

install.packages("rbiom")

The development version is available on GitHub.

install.packages("remotes")
remotes::install_github("cmmr/rbiom")

Usage

library(rbiom)

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

# Rarefy to 1000 reads per sample
biom <- rarefy(biom, depth=1000)

# Summarize counts by phylum
phyla <- taxa.rollup(biom, 'Phylum')
phyla[1:4,1:6]

# Work with metadata
table(biom$metadata$Sex, biom$metadata$Body.Site)
sprintf("Mean age: %.1f", mean(biom$metadata$Age))

# Draw the phylogenetic tree
plot(biom$phylogeny)

# Get unifrac distance matrix
dm <- beta.div(biom, 'unifrac')

Several functions will by default use all available CPU cores. To limit the number of cores used, you can set the numThreads option:

RcppParallel::setThreadOptions(numThreads = 4)

Copy Link

Version

Install

install.packages('rbiom')

Monthly Downloads

14,605

Version

1.0.3

License

AGPL-3

Maintainer

Daniel P. Smith

Last Published

November 5th, 2021

Functions in rbiom (1.0.3)

info

Get biom's misc information.
print

Summarize the contents of a BIOM object
counts

Get the abundance counts.
phylogeny

Get the phylogenetic tree.
%>%

Pipe operator
ntaxa

Number of taxa in a BIOM.
nsamples

Number of samples in a BIOM.
metadata

Get the sample metadata.
beta.div

Make a distance matrix of samples vs samples.
alpha.div

Estimate the diversity of each sample.
select

Reduce samples to a specific list
sample.names

Get the sample names.
read.tree

Read a newick formatted phylogenetic tree.
write.biom

Write counts, metadata, taxonomy, and phylogeny to a biom file.
write.fasta

Write sequences from a BIOM object to a file in fasta format.
read.fasta

Parse a fasta file into a named character vector.
unifrac

Compute Weighted and Unweighted UniFrac distance matrices.
read.biom

Extracts counts, metadata, taxonomy, and phylogeny from a biom file.
tips

Names of a phylogenetic tree's tips/leafs.
write.xlsx

Write data and summary information to a Microsoft Excel-compatible workbook.
write.tree

Write a newick formatted phylogenetic tree.
rbiom

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

Subset counts so that all samples have the same number of observations.
subtree

Create a subtree by specifying tips to keep.
subset

Subset samples using the BIOM object's metadata
taxa.rollup

Generate a matrix of samples by taxa, at the specified taxonomic rank.
taxa.names

Get the taxa names.
sequences

DNA sequence associated with each taxonomic identifier.
taxa.ranks

Get the taxa ranks.
taxonomy

Get the taxonomy table.