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, unc = "asis") %>% 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)
Run the code above in your browser using DataLab