Collapses taxa according to the taxonomy object or a given factor
collapse_by_taxonomy(...) # S3 method for default collapse_by_taxonomy(Tab, Tax, Group = NULL, level = 4, FUN = sum, sepchar = ";") # S3 method for Dataset collapse_by_taxonomy(Dat, Group = NULL, level = 4, FUN = sum, sepchar = ";")
Tab | An abundance matrix with samples as columns and taxa as rows |
---|---|
Tax | A Taxonomy data.frame as defined by create_dataset |
Group | If NULL, then the "Taxonomy" column of the Taxonomy data.frame will be used. If not NULL, it can be either a column number or name (i.e. character string), indicating which column of the Taxonomy data.frame to use as grouping factor. It can also be a factor or vector that can be coerced into factor. |
level | If Group is NULL, the taxonomy level to use from the Taxonomy column. |
FUN | Which function to use to aggregate |
sepchar | Separator character for taxonomy levels. |
The default method returns a numeric matrix.
The Dataset method returns a Dataset object when Dat includes a Map
element (see create_dataset
). When the Map element is
missing it returns a matrix
object.
library(AMOR) data(Rhizo) data(Rhizo.map) data(Rhizo.tax) Dat <- create_dataset(Tab = Rhizo, Map = Rhizo.map, Tax = Rhizo.tax) Dat.phyl <- collapse_by_taxonomy(Dat = Dat, level = 4) # The followwing returns a matrix Dat.collapsed1 <- collapse_by_taxonomy(Dat$Tab, Dat$Tax) # The following returns a dataset object Dat.collapsed2 <- collapse_by_taxonomy(Dat=Dat)