merge_taxa {phyloseq} | R Documentation

## Merge a subset of the species in `x` into one species/taxa/OTU.

### Description

Takes as input an object that describes species/taxa (e.g. `phyloseq-class`, `otu_table-class`, `phylo-class`, `taxonomyTable-class`), as well as a vector of species that should be merged. It is intended to be able to operate at a low-level such that related methods, such as `tip_glom` and `tax_glom` can both reliably call `merge_taxa` for their respective purposes.

### Usage

    merge_taxa(x, eqtaxa, archetype=1)

    ## S4 method for signature 'phyloseq'
    merge_taxa(x, eqtaxa,
      archetype = eqtaxa[which.max(taxa_sums(x)[eqtaxa])])

    ## S4 method for signature 'sample_data'
    merge_taxa(x, eqtaxa, archetype = 1L)

    ## S4 method for signature 'otu_table'
    merge_taxa(x, eqtaxa,
      archetype = eqtaxa[which.max(taxa_sums(x)[eqtaxa])])

    ## S4 method for signature 'phylo'
    merge_taxa(x, eqtaxa, archetype = 1L)

    ## S4 method for signature 'XStringSet'
    merge_taxa(x, eqtaxa, archetype = 1L)

    ## S4 method for signature 'taxonomyTable'
    merge_taxa(x, eqtaxa, archetype = 1L)

### Arguments

`x` | (Required). An object that describes species (taxa). This includes `phyloseq-class`, `otu_table-class`, `taxonomyTable-class`, `phylo`.
`eqtaxa` | (Required). The species names, or indices, that should be merged together. If `length(eqtaxa) < 2`, then the object `x` will be returned safely unchanged.
`archetype` | (Optional). A single-length numeric or character. The index of `eqtaxa`, or OTU ID, indicating the species that should be kept to represent the summed/merged group of species/taxa/OTUs. The default is to use the OTU with the largest count total if counts are available, or to use `1` (the first OTU in `eqtaxa`) otherwise. If `archetype` is not a valid index or index-name in `eqtaxa`, the first will be used, and the value in archetype will be used as the index-name for the new species.

### Value

The object, `x`, in its original class, but with the specified species merged into one entry in all relevant components.

### See Also

`tip_glom`, `tax_glom`, `merge_phyloseq`, `merge_samples`

### Examples

    #
    data(esophagus)
    tree <- phy_tree(esophagus)
    otu  <- otu_table(esophagus)
    otutree0 <- phyloseq(otu, tree)
    # plot_tree(otutree0)
    otutree1 <- merge_taxa(otutree0, 1:8, 2)
    # plot_tree(esophagus, ladderize="left")

[Package phyloseq version 1.32.0 Index]