Learn R Programming

phyloseq (version 1.16.2)

prune_taxa: Prune unwanted OTUs / taxa from a phylogenetic object.

Description

An S4 Generic method for removing (pruning) unwanted OTUs/taxa from phylogenetic objects, including phylo-class trees, as well as native phyloseq package objects. This is particularly useful for pruning a phyloseq object that has more than one component that describes OTUs. Credit: the phylo-class version is adapted from http://cran.at.r-project.org/web/packages/picante/index.html{prune.sample}.

Usage

prune_taxa(taxa, x)

## S3 method for class '`NULL`,ANY': prune_taxa(taxa, x)

## S3 method for class 'logical,ANY': prune_taxa(taxa, x)

## S3 method for class 'character,phylo': prune_taxa(taxa, x)

## S3 method for class 'character,otu_table': prune_taxa(taxa, x)

## S3 method for class 'character,sample_data': prune_taxa(taxa, x)

## S3 method for class 'character,phyloseq': prune_taxa(taxa, x)

## S3 method for class 'character,taxonomyTable': prune_taxa(taxa, x)

## S3 method for class 'character,XStringSet': prune_taxa(taxa, x)

Arguments

taxa
(Required). A character vector of the taxa in object x that you want to keep -- OR alternatively -- a logical vector where the kept taxa are TRUE, and length is equal to the number of taxa in object x. If taxa is a named logical, the taxa retained are based on those names. Make sure they are compatible with the taxa_names of the object you are modifying (x).
x
(Required). A phylogenetic object, including phylo trees, as well as all phyloseq classes that represent taxa. If the function taxa_names returns a non-NULL value, then your object can be pruned by this function.

Value

  • The class of the object returned by prune_taxa matches the class of the argument, x.

See Also

prune_samples

http://cran.at.r-project.org/web/packages/picante/index.html{prune.sample}

Examples

Run this code
data("esophagus")
esophagus
plot(sort(taxa_sums(esophagus), TRUE), type="h", ylim=c(0, 50))
x1 = prune_taxa(taxa_sums(esophagus) > 10, esophagus) 
x2 = prune_taxa(names(sort(taxa_sums(esophagus), TRUE))[1:9], esophagus) 
identical(x1, x2)

Run the code above in your browser using DataLab