Learn R Programming

⚠️There's a newer version (2.2.1) 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

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.biom", 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

2,025

Version

1.0.0

License

AGPL-3

Maintainer

Daniel P. Smith

Last Published

May 26th, 2020

Functions in rbiom (1.0.0)

rarefy

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

Compute Weighted and Unweighted UniFrac distance matrices.
sample.names

Get the sample names.
tips

Names of a phylogenetic tree's tips/leafs.
read.tree

Read a newick formatted phylogenetic tree.
read.biom

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

Parse a fasta file into a named character vector.
sequences

DNA sequence associated with each taxonomic identifier.
select

Reduce samples to a specific list
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.
rbiom

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

Create a subtree by specifying tips to keep.
taxa.rollup

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

Subset samples using the BIOM object's metadata
print

Summarize the contents of a BIOM object
taxa.names

Get the taxa names.
taxa.ranks

Get the taxa ranks.
write.xlsx

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

Get the taxonomy table.
write.tree

Write a newick formatted phylogenetic tree.
phylogeny

Get the phylogenetic tree.
alpha.div

Estimate the diversity of each sample.
nsamples

Number of samples in a BIOM.
ntaxa

Number of taxa in a BIOM.
beta.div

Make a distance matrix of samples vs samples.
counts

Get the abundance counts.
%>%

Pipe operator
metadata

Get the sample metadata.
info

Get biom's misc information.