README.md

April 7, 2020 · View on GitHub

FEAST - a scalable algorithm for quantifying the origins of complex microbial communities

A major challenge of analyzing the compositional structure of microbiome data is identifying its potential origins. Here, we introduce Fast Expectation-mAximization microbial Source Tracking (FEAST), a ready-to-use scalable framework that can simultaneously estimate the contribution of thousands of potential source environments in a timely manner, thereby helping unravel the origins of complex microbial communities. The information gained from FEAST may provide insight into quantifying contamination, tracking the formation of developing microbial communities, as well as distinguishing and characterizing bacteria-related health conditions. For more details see Shenhav et al., Nature Methods 2019 (https://www.nature.com/articles/s41592-019-0431-x).

Support

For support using FEAST, please email: liashenhav@gmail.com. This is our new beta version - your comments/insights would be greatly appreciated.

Software Requirements and dependencies

FEAST is implemented in R (>= 3.4.4) and requires the following dependencies: Rcpp, RcppArmadillo, vegan, dplyr, reshape2, gridExtra, ggplot2, ggthemes. Please install and load them prior to trying to install FEAST. If you are using a mac and having installation issues with Rcpp and or RcppArmadillo, try installing homebrew or xcode then reinstalling Rcpp and RcppArmadillo.

Packages <- c("Rcpp", "RcppArmadillo", "vegan", "dplyr", "reshape2", "gridExtra", "ggplot2", "ggthemes")
install.packages(Packages)
lapply(Packages, library, character.only = TRUE)

Installation

FEAST will be available on QIIME 2 very soon. Until then you can you can simply install FEAST using devtools:

devtools::install_github("cozygene/FEAST")

Usage

As input, FEAST takes mandatory arguments:

  • C - An m by n count matrix, where m is the number samples and n is the number of taxa.
  • metadata - An m by 3 table, where m is the number of samples. The metadata table has three columns (i.e., 'Env', 'SourceSink', 'id'). The first column is a description of the sampled environment (e.g., human gut), the second column indicates if this sample is a source or a sink (can take the value 'Source' or 'Sink'). The third column is the Sink-Source id. When using multiple sinks, each tested with the same group of sources, only the rows with 'SourceSink' = Sink will get an id (between 1 - number of sinks in the data). In this scenario, the sources’ ids are blank. When using multiple sinks, each tested with a distinct group of sources, each combination of sink and its corresponding sources should get the same id (between 1 - number of sinks in the data). Note that these names must be respected.
  • EM_iterations - A numeric value indicating the number of EM iterations (default 1000).
  • COVERAGE - A numeric value indicating the rarefaction depth (default = minimal sequencing depth within each group of sink and its corresponding sources).
  • different_sources_flag - A Boolean value indicating the source-sink assignment. different_sources_flag = 1 if different sources are assigned to each sink , otherwise = 0.
  • dir_path - A path to an output.txt file.
  • outfile - the prefix for saving the output file.

Value:

FEAST returns an S1 by S2 matrix P, where S1 is the number sinks and S2 is the number of sources (including an unknown source). Each row in matrix P sums to 1. Pij is the contribution of source j to sink i. If Pij == NA it indicates that source j was not used in the analysis of sink i. FEAST will save the file "demo_FEAST.txt" (a file containing matrix P) .

Demo

We provide a dataset for an example of FEAST usage. Download the demo files here.

First load the FEAST packages into R:

library(FEAST)

Then, load the datasets:

metadata <- Load_metadata(metadata_path = "~/FEAST/Data_files/metadata_example_multi.txt")
otus <- Load_CountMatrix(CountMatrix_path = "~/FEAST/Data_files/otu_example_multi.txt")

Run FEAST, saving the output with prefix "demo":

FEAST_output <- FEAST(C = otus, metadata = metadata, different_sources_flag = 1, dir_path = "~/FEAST/Data_files/",
                      outfile="demo")

FEAST will then save the file demo_FEAST.txt - A file containing an S1 by S2 matrix P, where S1 is the number sinks and S2 is the number of sources (including an unknown source). Each row in matrix P sums to 1.

Graphical representation:

As input, PlotSourceContribution takes mandatory arguments:

  • SinkNames - A vector with the sink names to plot.
  • SourceNames - A vector with all the sources' names.
  • Same_sources_flag - A Boolean value indicating the source-sink plotting assignment. Same_sources_flag = 1 if the same sources are assigned to the pre-defined sink samples , otherwise = 0.
  • dir_path - A path to an output .png file.
  • mixing_proportions - A list of vectors, where entry i corresponds to the vector of source contributions (summing to 1) to sink i.
  • Plot_title - Plot's title and output .png file's name.
  • N - Number of barplots in each output .png file.
PlotSourceContribution(SinkNames = rownames(FEAST_output)[c(5:8)],
                       SourceNames = colnames(FEAST_output), dir_path = "~/FEAST/Data_files/",
                       mixing_proportions = FEAST_output, Plot_title = "Test_",Same_sources_flag = 0, N = 4)

Input format

The input to FEAST is composed of two tab-delimited ASCII text files:

(1) count table - An m by n count matrix, where m is the number samples and n is the number of taxa. Row names are the sample ids ('SampleID'). Column names are the taxa ids. Every consecutive column contains read counts for each sample. Note that this order must be respected.

count matrix (first 4 rows and columns):

ERR525698ERR525693ERR525688ERR525699
taxa_105020
taxa_215500
taxa_30132000
taxa_44500

(2) metadata - An m by 3 table, where m is the number of samples. The metadata table has three columns (i.e., 'Env', 'SourceSink', 'id'). The first column is a description of the sampled environment (e.g., human gut), the second column indicates if this sample is a source or a sink (can take the value 'Source' or 'Sink'). The third column is the Sink-Source id. When using multiple sinks, each tested with the same group of sources, only the rows with 'SourceSink' = Sink will get an id (between 1 - number of sinks in the data). In this scenario, the sources’ ids are blank. When using multiple sinks, each tested with a distinct group of sources, each combination of sink and its corresponding sources should get the same id (between 1 - number of sinks in the data). Note that these names must be respected.

*using multiple sinks, each tested with the same group of sources:

SampleIDEnvSourceSinkid
ERR525698infant gut 1Sink1
ERR525693infant gut 2Sink2
ERR525688Adult gut 1SourceNA
ERR525699Adult gut 2SourceNA
ERR525697Adult gut 3SourceNA

*using multiple sinks, each tested with a different group of sources:

SampleIDEnvSourceSinkid
ERR525698infant gut 1Sink1
ERR525688Adult gut 1Source1
ERR525691Adult gut 2Source1
ERR525699infant gut 2Sink2
ERR525697Adult gut 3Source2
ERR525696Adult gut 4Source2

Output -

infant gut 2Adult gut 1Adult gut 2Adult gut 3Adult skin 1Adult skin 2Adult skin 3Soil 1Soil 2unknown
5.108461e-019.584116e-234.980321e-122.623358e-025.043635e-138.213667e-591.773058e-102.704118e-143.460067e-024.283196e-01