subset_taxa_pq: Subset taxa using a conditional named boolean vector.

View source: R/dada_phyloseq.R

subset_taxa_pqR Documentation

Subset taxa using a conditional named boolean vector.

Description

lifecycle-experimental

The main objective of this function is to complete the phyloseq::subset_taxa() function by propose a more easy way of subset_taxa using a named boolean vector. Names must match taxa_names.

Usage

subset_taxa_pq(
  physeq,
  condition,
  verbose = TRUE,
  clean_pq = TRUE,
  taxa_names_from_physeq = FALSE
)

Arguments

physeq

(required): a phyloseq-class object obtained using the phyloseq package.

condition

A named boolean vector to subset taxa. Length must fit the number of taxa and names must match taxa_names. Can also be a condition using a column of the tax_table slot (see examples). If the order of condition is the same as taxa_names(physeq), you can use the parameter taxa_names_from_physeq = TRUE.

verbose

(logical) Informations are printed

clean_pq

(logical) If set to TRUE, empty samples are discarded after subsetting ASV

taxa_names_from_physeq

(logical) If set to TRUE, rename the condition vector using taxa_names(physeq). Carefully check the result of this function if you use this parameter. No effect if the condition is of class tax_table.

Value

a new phyloseq object

Examples


subset_taxa_pq(data_fungi, data_fungi@tax_table[, "Phylum"] == "Ascomycota")

cond_taxa <- grepl("Endophyte", data_fungi@tax_table[, "Guild"])
names(cond_taxa) <- taxa_names(data_fungi)
subset_taxa_pq(data_fungi, cond_taxa)

subset_taxa_pq(data_fungi, grepl("mycor", data_fungi@tax_table[, "Guild"]),
  taxa_names_from_physeq = TRUE
)


MiscMetabar documentation built on Oct. 8, 2024, 1:07 a.m.