Split OTU Tables By Taxonomic Rank

Description

This function consumes an OTU table and splits its taxonomy columns into the seven major taxonomic ranks. It returns a data frame preserving all numerical data, but changing the 'taxonomy' column to the name of the appropriate rank, and preserving only the classifications at that rank.

Usage

1
tax.split(otu1, otu2 = NULL, rank = NULL)

Arguments

otu1

the first OTU table to be used.

otu2

the second OTU table to be used.

rank

the (optional) rank to split at and return (see ?RAM.rank.formatting for formatting details).

Value

The value returned by this function may become nested lists, so for convenience, any nested lists have been given descriptive items names to make accessing its elements simple (see Examples).

  • If otu2 is given:

    • If rank is given: a list containing two data frames (otu1 and otu2 split at the given rank).

    • If rank is not given: a list containing two lists. The first sublist represents otu1, the second otu2. The sublists contain seven data frames, which are the data split at each taxonomic rank (see Examples).

  • If otu2 is not given:

    • If rank is given: a single data frame (otu1 split at the given rank).

    • If rank is not given: a list containing seven data frames (otu1 split at each taxonomic rank).

Note

This function may seem similar to get.rank, but they are distinct. get.rank only returns the entries classified at that taxonomic rank, and so some OTUs might be omitted in the returned data frame. With tax.split, it is guaranteed that all OTUs will be preserved in the returned data table (although they may be missing taxonomic classification at that rank). If no OTUs are classified at the given rank, the taxonomy column for that rank will be filled with empty strings.

Author(s)

Wen Chen and Joshua Simpson.

See Also

get.rank

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(ITS1, ITS2)
# split only ITS1 data at a single rank
ITS1.tax.p <- tax.split(ITS1, rank="phylum")
# split only ITS1 data at all ranks
ITS1.tax.all <- tax.split(ITS1)
# split ITS1 and IST2 data at a given rank
lst <- tax.split(ITS1, ITS2, rank="c")
# split ITS1 and ITS2 at every rank
lst.all <- tax.split(ITS1, ITS2)
stopifnot(identical(lst.all$otu1$phylum, ITS1.tax.p))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.