tax_select | R Documentation |
Convenient name-based taxa selection/filtering of phyloseq object, including approximate name matching. Takes a phyloseq with tax table and a (partial) taxonomic name, or a list/vector of taxonomic names (full or partial matches).
tax_select(
ps,
tax_list,
ranks_searched = "all",
strict_matches = FALSE,
n_typos = 1,
deselect = FALSE
)
ps |
phyloseq object |
tax_list |
e.g. c('g__Bifidobacterium', 'g__Akkermansia', 'g__Bacteroides', 'g__Streptococcus') |
ranks_searched |
'all' or a list of which taxonomic ranks should be searched for the names in tax_list? |
strict_matches |
only perfect full name matches allowed if TRUE |
n_typos |
how many typos to allow in each name? uses agrep approximate matching if > 0 |
deselect |
if TRUE, the matching taxa will be REMOVED instead! |
tax_select will also search the otu names/rownames, BUT only for perfect matches.
phyloseq object with fewer taxa
ps_select
for selecting variables in phyloseq sample_data
agrep
for the function that powers the approximate matching in tax_select
# Get example phyloseq object data
data("dietswap", package = "microbiome")
pSeq <- dietswap
# SELECTION EXAMPLES #
a <- pSeq %>% tax_select(tax_list = "Bif", n_typos = 0, ranks_searched = "Genus")
b <- pSeq %>% tax_select(tax_list = "Bifidobacterium", n_typos = 0)
c <- pSeq %>% tax_select(tax_list = "Bif", n_typos = 1)
identical(a, b) # TRUE
identical(a, c) # FALSE
pSeq %>% tax_select(tax_list = "Bifidobactrium") # default 1 typo allowed
one <- pSeq %>% tax_select(tax_list = "Akkarmensia", n_typos = 2)
two <- pSeq %>% tax_select(tax_list = "Akkermansia", n_typos = 0)
identical(one, two) # TRUE
# DESELECTION EXAMPLE # #
pSeq %>% tax_select(tax_list = "Bif", strict_matches = FALSE, deselect = TRUE)
# Incorrect example
# pSeq %>% tax_select(tax_list = "Bif", strict_matches = TRUE) # fails
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.