filterPhyloseq: Filter Phyloseq Object

filterPhyloseqR Documentation

Filter Phyloseq Object

Description

Filter Phyloseq Object

Usage

filterSampleData(x, ...)

filterTaxaData(x, ...)

filterTaxaByNames(x, ids = NULL, keep = TRUE)

filterSampleByNames(x, ids = NULL, keep = TRUE)

Arguments

x

phyloseq object

...

Option to pass on to filter. Only when using filterSampleData or filterTaxaData sample data or taxonomy table as tibble.

ids

A list of sample ids or taxa ids to filter. Only when using filterSampleByNames or filterTaxaByNames

keep

Logical. Default is TRUE. Only when using filterSampleByNames or filterTaxaByNames

Details

These are alternative to subset and prune functions in phyloseq.

The filterSampleData does subsetting similar to phyloseq::subset_samples. The filterTaxaData does subsetting similar to phyloseq::subset_taxa.

The filterSampleByNames does pruning similar to phyloseq::prune_samples. The filterTaxaByNames does pruning similar to phyloseq::prune_taxa.

The naming is using filter because it uses the dplyr::filter function.

Note: filterSampleData will additionally remove any taxa that are zero across all samples i.e. not present is any remaining samples after filtering. filterTaxaData will additionally remove samples that do not have any of the selected taxa, i.e. samples that sum to zero. filterSampleByNames will additionally remove any taxa that are not present is any remaining samples after filtering. filterTaxaByNames will additionally remove samples that do not have any of the selected taxa, i.e. samples that sum to zero.

Value

Either filtered phyloseq

Author(s)

Sudarshan A. Shetty

References

Shetty SA (2020). Utilities for microbiome analytics. https://github.com/RIVM-IIV-Microbiome/biomeUtils

Examples


library(biomeUtils)
data("FuentesIliGutData")

# Filter from tables subset_*
ps.filtered.samples  <- filterSampleData(FuentesIliGutData,
                                         ILI == "C" & BMI < 26)

ps.filtered.samples

ps.filtered.taxa  <- filterTaxaData(FuentesIliGutData,
                                    Phylum=="Firmicutes")

ps.filtered.taxa

# Filter by names like prune_*
sams.select <- sample_names(FuentesIliGutData)[1:10]
ps.filter.by.sam.names <- filterSampleByNames(FuentesIliGutData,
                                              ids = sams.select,
                                              keep = TRUE)

tax.select <- taxa_names(FuentesIliGutData)[1:10]
ps.filter.by.tax.names <- filterTaxaByNames(FuentesIliGutData,
                                            ids = tax.select,
                                            keep = TRUE)


RIVM-IIV-Microbiome/biomeUtils documentation built on July 20, 2023, 10:29 a.m.