Filter Phyloseq Object
filterSampleData(x, ...)
filterTaxaData(x, ...)
filterTaxaByNames(x, ids = NULL, keep = TRUE)
filterSampleByNames(x, ids = NULL, keep = TRUE)
phyloseq
object
Option to pass on to filter
. Only when using
filterSampleData
or filterTaxaData
sample data or taxonomy table as tibble.
A list of sample ids or taxa ids to filter. Only when using
filterSampleByNames
or filterTaxaByNames
Logical. Default is TRUE. Only when using
filterSampleByNames
or filterTaxaByNames
Either filtered phyloseq
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.
Shetty SA (2020). Utilities for microbiome analytics. https://github.com/RIVM-IIV-Microbiome/biomeUtils
library(biomeUtils)
data("FuentesIliGutData")
# Filter from tables subset_*
ps.filtered.samples <- filterSampleData(FuentesIliGutData,
ILI == "C" & BMI < 26)
ps.filtered.samples
#> phyloseq-class experiment-level object
#> otu_table() OTU Table: [ 901 taxa and 91 samples ]
#> sample_data() Sample Data: [ 91 samples by 61 sample variables ]
#> tax_table() Taxonomy Table: [ 901 taxa by 7 taxonomic ranks ]
#> phy_tree() Phylogenetic Tree: [ 901 tips and 900 internal nodes ]
ps.filtered.taxa <- filterTaxaData(FuentesIliGutData,
Phylum=="Firmicutes")
ps.filtered.taxa
#> phyloseq-class experiment-level object
#> otu_table() OTU Table: [ 758 taxa and 589 samples ]
#> sample_data() Sample Data: [ 589 samples by 61 sample variables ]
#> tax_table() Taxonomy Table: [ 758 taxa by 7 taxonomic ranks ]
#> phy_tree() Phylogenetic Tree: [ 758 tips and 757 internal nodes ]
# 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)