filter_taxa: Filter taxa based on across-sample OTU abundance criteria

Description Usage Arguments Value See Also Examples

View source: R/transform_filter-methods.R

Description

This function is directly analogous to the genefilter function for microarray filtering, but is used for filtering OTUs from phyloseq objects. It applies an arbitrary set of functions — as a function list, for instance, created by filterfun — as across-sample criteria, one OTU at a time. It takes as input a phyloseq object, and returns a logical vector indicating whether or not each OTU passed the criteria. Alternatively, if the "prune" option is set to FALSE, it returns the already-trimmed version of the phyloseq object.

Usage

1
filter_taxa(physeq, flist, prune=FALSE)

Arguments

physeq

(Required). A phyloseq-class object that you want to trim/filter.

flist

(Required). A function or list of functions that take a vector of abundance values and return a logical. Some canned useful function types are included in the genefilter-package.

prune

(Optional). A logical. Default FALSE. If TRUE, then the function returns the pruned phyloseq-class object, rather than the logical vector of taxa that passed the filter.

Value

A logical vector equal to the number of taxa in physeq. This can be provided directly to prune_taxa as first argument. Alternatively, if prune==TRUE, the pruned phyloseq-class object is returned instead.

See Also

filterfun, genefilter_sample, filterfun_sample

Examples

1
2
3
4
5
6
7
8
 data("enterotype")
 require("genefilter")
 flist    <- filterfun(kOverA(5, 2e-05))
 ent.logi <- filter_taxa(enterotype, flist)
 ent.trim <- filter_taxa(enterotype, flist, TRUE)
 identical(ent.trim, prune_taxa(ent.logi, enterotype)) 
 identical(sum(ent.logi), ntaxa(ent.trim))
 filter_taxa(enterotype, flist, TRUE)

Example output

Loading required package: genefilter
[1] TRUE
[1] TRUE
phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 416 taxa and 280 samples ]
sample_data() Sample Data:       [ 280 samples by 9 sample variables ]
tax_table()   Taxonomy Table:    [ 416 taxa by 1 taxonomic ranks ]
Warning message:
system call failed: Cannot allocate memory 

phyloseq documentation built on Nov. 8, 2020, 6:41 p.m.