This method merges species that have the same taxonomy at a certain
taxonomic rank. Its approach is analogous to tip_glom()
, but
uses categorical data instead of a tree. In principal, other categorical
data known for all taxa could also be used in place of taxonomy, but for the
moment, this must be stored in the taxonomyTable
of the data. Also,
columns/ranks to the right of the rank chosen to use for agglomeration will
be replaced with NA
, because they should be meaningless following
agglomeration.
tax_glom( physeq, taxrank = rank_names(physeq)[1], NArm = TRUE, bad_empty = c(NA, "", " ", "\t"), reorder = FALSE )
physeq | (Required). |
---|---|
taxrank | A character string specifying the taxonomic level that you
want to agglomerate over. Should be among the results of
|
NArm | (Optional). Logical, length equal to one. Default is |
bad_empty | (Optional). Character vector. Default: |
reorder | Logical specifying whether to reorder the taxa by taxonomy
strings or keep initial order. Ignored if |
A taxonomically-agglomerated, optionally-pruned, object with class
matching the class of physeq
.
This is the speedyseq reimplementation of phyloseq::tax_glom()
. It should
produce results that are identical to phyloseq up to taxon order.
If x
is a phyloseq object with a phylogenetic tree, then the new taxa will
be ordered as they are in the tree. Otherwise, the taxa order can be
controlled by the reorder
argument, which behaves like the reorder
argument in base::rowsum()
. reorder = FALSE
will keep taxa in
the original order determined by when the member of each group first appears
in taxa_names(x)
; reorder = TRUE
will order new taxa alphabetically
according to taxonomy (string of concatenated rank values).
Acknowledgements: Documentation and general strategy derived from
phyloseq::tax_glom()
.
#> [1] "Kingdom" "Phylum" "Class" "Order" "Family" "Genus" "Species"# agglomerate at the Family taxonomic rank (x1 <- tax_glom(GlobalPatterns, taxrank="Family"))#> phyloseq-class experiment-level object #> otu_table() OTU Table: [ 341 taxa and 26 samples ]: #> sample_data() Sample Data: [ 26 samples by 7 sample variables ]: #> tax_table() Taxonomy Table: [ 341 taxa by 7 taxonomic ranks ]: #> phy_tree() Phylogenetic Tree: [ 341 tips and 340 internal nodes ]: #> taxa are rows#> [1] 19216#> [1] 341