Learn R Programming

theseus (version 0.1.0)

pstoveg_otu: converts the otu_table slot of a phyloseq object to a vegan-compatible matrix

Description

physeq2veg_otu is a helper function intended to convert the species/taxa count slot of a phyloseq object to a vegan-friendly matrix. This function ensures that sites/samples are rows and species are columns.

Usage

pstoveg_otu(PS)

Arguments

PS

(required) a phyloseq object

Value

A matrix containing a phyloseq object's otu_table slot.

See Also

phyloseq-class otu_table-class otu_table

Examples

Run this code
# NOT RUN {
library(theseus)
library(phyloseq)
data(WWTP_Impact, package='theseus')
dim(otu_table(WWTP_Impact))
taxa_are_rows(WWTP_Impact)
otu <- pstoveg_otu(WWTP_Impact)
dim(otu)

data(GlobalPatterns, package='phyloseq')
dim(otu_table(GlobalPatterns))
taxa_are_rows(GlobalPatterns)
otu.gp <-pstoveg_otu(GlobalPatterns)
dim(otu.gp)

# move transformed OTU table back to phyloseq
wwtp <- WWTP_Impact
otu.ra <- vegan::decostand(otu, method='total')
otu_table(wwtp) <- otu_table(otu.ra,
                             taxa_are_rows = taxa_are_rows(WWTP_Impact))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab