tidy_micro: A function to merge multiple OTU tables and meta data into a...

Description Usage Arguments Details Value Author(s) Examples

View source: R/tidy_micro.R

Description

A function to take any number of OTU tables (or other sequencing data tables), calculate taxa prevalence, relative abundance, and a CLR transformation, and finally merges meta data

Usage

1
2
3
4
5
6
7
8
9
tidy_micro(
  otu_tabs,
  tab_names,
  meta,
  prev_cutoff = 0,
  ra_cutoff = 0,
  exclude_taxa = NULL,
  complete_meta = T
)

Arguments

otu_tabs

A single table or list of metagenomic sequencing data. Tables should have a first column of OTU Names and following columns of OTU counts. Column names should be sequencing library names

tab_names

names for otu_tabs. These will become the "Tables" column. It is also an option to simply name the OTU tables in the list supplied to otu_tabs

meta

Subject level meta data. Must have a column names "Lib" with unique names for subject sequences

prev_cutoff

A prevalence cutoff where *X* percent of subjects must have this taxa or it will be included in the "Other" category

ra_cutoff

A relative abundance (RA) cutoff where at least one subject must have a RA above the cutoff or the taxa will be included in the "Other" category

exclude_taxa

A character vector used to specify any taxa that you would like to included in the "Other" category. Taxa specified will be included in "Other" for every OTU table provided

complete_meta

Logical; only include libraries whose Lib name is in the supplied meta data

Details

Column names of the OTU tables must be the same for each table, and these should be the the library names inside of your meta data column, "Lib". Please see the vignette for a detailed description.

The CLR transformation adds (1 / sequencing depth) to each OTU count for each subject before centering and log transforming in order to avoid issues with 0 counts.

The list of OTU tables are split, manipulated, and stacked into a data frame using the ldply function from the plyr package. Names of OTU tables supplied will be the name of their "Table" in the final tidy_micro set

Value

A data.frame in the tidy_micro format

Author(s)

Charlie Carpenter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(phy); data(cla); data(ord); data(fam); data(met)

## Multiple OTU tables with named list
otu_tabs <- list(Phylum = phy, Class = cla, Order = ord, Family = fam)
set <- tidy_micro(otu_tabs = otu_tabs, meta = met)

## Multiple OTU tables with unnamed list
unnamed_tabs <- list(phy,cla,ord,fam)
set <- tidy_micro(otu_tabs = unnamed_tabs,
                  tab_names = c("Phylum", "Class", "Order", "Family"), meta = met)

## Single OTU table
set <- tidy_micro(otu_tabs = cla, tab_names = "Class", meta = met)

## Filtering out low abundance or uninteresting taxa right away
## WARNING: Only do this if you do not want to calculate alpha diversities with this micro_set

filter_set <- tidy_micro(otu_tabs = otu_tabs, meta = met,
              prev_cutoff = 5, ## 5\% of subjects must have this bug, or it is filtered
              ra_cutoff = 1, ## At least 1 subject must have RA of 1, or it is filtered
              excluted_taxa = c("Unclassified", "Bacteria") ## Unclassified taxa we don't want
              )

CharlieCarpenter/tidy.micro documentation built on Jan. 19, 2020, 6:28 p.m.