Last data update: 2014.03.03

R: Prune unwanted OTUs / taxa from a phylogenetic object.
prune_taxaR Documentation

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 prune.sample.

Usage

prune_taxa(taxa, x)

## S4 method for signature ''NULL',ANY'
prune_taxa(taxa, x)

## S4 method for signature 'logical,ANY'
prune_taxa(taxa, x)

## S4 method for signature 'character,phylo'
prune_taxa(taxa, x)

## S4 method for signature 'character,otu_table'
prune_taxa(taxa, x)

## S4 method for signature 'character,sample_data'
prune_taxa(taxa, x)

## S4 method for signature 'character,phyloseq'
prune_taxa(taxa, x)

## S4 method for signature 'character,taxonomyTable'
prune_taxa(taxa, x)

## S4 method for signature '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

prune.sample

Examples

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)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(phyloseq)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/phyloseq/prune_taxa-methods.Rd_%03d_medium.png", width=480, height=480)
> ### Name: prune_taxa
> ### Title: Prune unwanted OTUs / taxa from a phylogenetic object.
> ### Aliases: prune_taxa prune_taxa,NULL,ANY-method
> ###   prune_taxa,character,XStringSet-method
> ###   prune_taxa,character,otu_table-method
> ###   prune_taxa,character,phylo-method
> ###   prune_taxa,character,phyloseq-method
> ###   prune_taxa,character,sample_data-method
> ###   prune_taxa,character,taxonomyTable-method
> ###   prune_taxa,logical,ANY-method
> 
> ### ** Examples
> 
> data("esophagus")
> esophagus
phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 58 taxa and 3 samples ]
phy_tree()    Phylogenetic Tree: [ 58 tips and 57 internal nodes ]
> 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)
[1] TRUE
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>