Skip to contents

Keep or remove taxa using values in a taxonomy column from variable_info.

Usage

filter_taxa_by_rank(
  object,
  taxonomic_rank = c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species"),
  taxa,
  keep = TRUE,
  na_keep = FALSE
)

Arguments

object

A microbiome_dataset object.

taxonomic_rank

A taxonomy rank in variable_info.

taxa

Character vector of taxa labels used for filtering.

keep

Should the provided taxa be kept? Defaults to TRUE.

na_keep

Should taxa with missing rank be kept? Defaults to FALSE.

Value

A microbiome_dataset object.

Examples

data("global_patterns", package = "microbiomedataset")

x <- filter_taxa_by_rank(
  global_patterns,
  taxonomic_rank = "Phylum",
  taxa = c("Bacteroidetes", "Firmicutes")
)
dim(x@expression_data)
#> [1] 6738   26