taxa_map: Map OTUs names to taxa names at a given rank.

taxa_mapR Documentation

Map OTUs names to taxa names at a given rank.

Description

Map OTUs names to taxa names at a given rank.

Usage

taxa_map(biom, rank = NULL, unc = "singly", lineage = FALSE)

Arguments

biom

An rbiom object, such as from as_rbiom(). Any value accepted by as_rbiom() can also be given here.

rank

When NULL, the entire biom$taxonomy data.frame is returned, transformed as per unc. Alternatively, a single taxonomic rank (rank name or integer position in biom$ranks) which returns a named character vector for mapping OTUs to taxa names.

unc

How to handle unclassified, uncultured, and similarly ambiguous taxa names. Options are:

  • "singly" - Replaces them with the OTU name.

  • "grouped" - Replaces them with a higher rank's name.

  • "drop" - Excludes them from the result.

  • "asis" - To not check/modify any taxa names.

Default: "singly"

Abbreviations are allowed.

lineage

Include all ranks in the name of the taxa. For instance, setting to TRUE will produce ⁠Bacteria; Actinobacteria; Coriobacteriia; Coriobacteriales⁠. Otherwise the taxa name will simply be Coriobacteriales. You want to set this to TRUE when unc = "asis" and you have taxa names (such as Incertae_Sedis) that map to multiple higher level ranks. Default: FALSE

Value

A tibble data.frame when rank=NULL, or a character vector named with the OTU names.

See Also

pull.rbiom()

Examples

    library(rbiom)
    library(dplyr, warn.conflicts = FALSE)
    
    # In $taxonomy, .otu is the first column (like a row identifier)  -----
    hmp50$taxonomy %>% head(4)
    
    # In taxa_map, .otu is the last column (most precise rank)  -----------
    taxa_map(hmp50) %>% head(4)
    
    # Generate an OTU to Genus mapping  -----------------------------------
    taxa_map(hmp50, "Genus") %>% head(4)
    
    # Sometimes taxonomic names are incomplete ----------------------------
    otus <- c('GemAsacc', 'GcbBacte', 'Unc58411')
    taxa_map(hmp50) %>% filter(.otu %in% otus) %>% select(Phylum:.otu)
    
    # rbiom can replace them with unique placeholders ---------------------
    taxa_map(hmp50, unc = "singly") %>% filter(.otu %in% otus) %>% select(Class:.otu)
    
    # Or collapse them into groups ----------------------------------------
    taxa_map(hmp50, unc = "grouped") %>% filter(.otu %in% otus) %>% select(Class:Genus)


cmmr/rbiom documentation built on April 28, 2024, 6:38 a.m.