Contents

1 Introduction

The microbiome R package facilitates exploration and analysis of microbiome profiling data, in particular 16S taxonomic profiling.

This vignette provides a brief overview with example data sets from published microbiome profiling studies (L. Lahti et al. 2014, L. Lahti et al. (2013), O’Keefe et al. (2015)). A more comprehensive tutorial is available on-line.

Tools are provided for the manipulation, statistical analysis, and visualization of taxonomic profiling data. In addition to targeted case-control studies, the package facilitates scalable exploration of large population cohorts (L. Lahti et al. 2014). Whereas sample collections are rapidly accumulating for the human body and other environments, few general-purpose tools for targeted microbiome analysis are available in R. This package supports the independent phyloseq data format and expands the available toolkit in order to facilitate the standardization of the analyses and the development of best practices. See also the related PathoStat pipeline mare pipeline, phylofactor, and structSSI for additional 16S rRNA amplicon analysis tools in R. The aim is to complement the other available packages, but in some cases alternative solutions have been necessary in order to streamline the tools and to improve complementarity.

We welcome feedback, bug reports, and suggestions for new features from the user community via the issue tracker and pull requests. See the Github site for source code and other details. These R tools have been utilized in recent publications and in introductory courses (Salonen et al. 2014, Faust et al. (2015), Shetty et al. (2017)), and they are released under the Two-clause FreeBSD license.

Kindly cite the work as follows: “Leo Lahti et al. (2017). Tools for microbiome analysis in R. Microbiome package version . URL: (http://microbiome.github.io/microbiome)

2 Installation

To install microbiome package (the latest development version) in R, use

library(devtools) # Load the devtools package
install_github("microbiome/microbiome") # Install the package

Then load the package in R

library(microbiome)  

3 Data

The microbiome package relies on the independent phyloseq data format. A phyloseq data object typically contains an OTU table (taxa abundances), sample metadata (age, BMI, sex, …), taxonomy table (mapping between OTUs and higher-level taxonomic classifications), and a phylogenetic tree (relations between the taxa).

3.1 Example data sets

Example data sets are provided to facilitate reproducible examples and further methods development.

The HITChip Atlas data set Lahti et al. Nat. Comm. 5:4344, 2014 contains 130 genus-level taxonomic groups across 1006 western adults. Load the example data in R with

# Data from 
# http://www.nature.com/ncomms/2014/140708/ncomms5344/full/ncomms5344.html
data(atlas1006) 
atlas1006
## phyloseq-class experiment-level object
## otu_table()   OTU Table:         [ 130 taxa and 1172 samples ]
## sample_data() Sample Data:       [ 1172 samples by 10 sample variables ]
## tax_table()   Taxonomy Table:    [ 130 taxa by 2 taxonomic ranks ]

The two-week diet swap study between western (USA) and traditional (rural Africa) diets, reported in O’Keefe et al. Nat. Comm. 6:6342, 2015

data(dietswap) # Data from http://dx.doi.org/10.1038/ncomms7342
dietswap
## phyloseq-class experiment-level object
## otu_table()   OTU Table:         [ 130 taxa and 222 samples ]
## sample_data() Sample Data:       [ 222 samples by 8 sample variables ]
## tax_table()   Taxonomy Table:    [ 130 taxa by 2 taxonomic ranks ]

A parallel profiling of gut microbiota versus blood metabolites from Lahti et al. PeerJ 1:e32, 2013 to characterize associations between human intestinal microbiota and blood serum lipids

data(peerj32) # Data from https://peerj.com/articles/32/

3.2 Data import

The tutorial describes how to import data from standard formats (Mother, BIOM, CSV, etc.).

3.3 Data manipulation

A phyloseq object can be subsetted, filtered, aggregated, transformed, and otherwise manipulated. For a comprehensive list of tools, see the online tutorial.

The microbiome package provides a wrapper for many standard transformations such as Z, centered log-ratio, hellinger, log10, and others. To convert absolute counts to compositional (relative) abundances, for instance, use

# dietswap is a phyloseq object; see above
dietswap.compositional <- transform(dietswap, "compositional")

4 Ecosystem indices

4.1 Alpha diversity, richness, evenness, dominance, and rarity

Commonly used ecosystem state variables include various indices to quantify alpha diversities, richness, evenness, dominance, and rarity (see functions with similar names). The microbiome package provides a comprehensive set of such indices via a standardized interface.

The function global calls these indicators with default parameters. For further options, see tutorial.

g <- global(atlas1006, index = "gini")

Visually-Weighted Regression curve with smoothed error bars is based on the can be used to visualize sample variables (1), here the relation between age and diversity. This function operates on standard data frames.

# Estimate Shannon diversity and add it to the phyloseq object
sample_data(atlas1006)$diversity <- global(atlas1006, index = "shannon")[,1]

# Compare age and microbiome diversity
plot_regression(diversity ~ age, meta(atlas1006))