r - phyloseq - ordination of taxa other than species (family, order, etc.)

435 views Asked by At

I have reviewed the phyloseq tutorials, but I can't determine how to determine the stress level and plot the ordination of a specific taxa (other than species), such as family or other classifications.

In order to illustrate my point, here is the following R code:

library("phyloseq")

data(GlobalPatterns)

GP <- GlobalPatterns

This is an attempt to isolate the family taxa only

GPtaxa <- tax_table(GP)[, "Family"]

GPotu <- otu_table(GP)

GPsd <- sample_data(GP)

GPpt <- phy_tree(GP)

GPnew <- phyloseq(GPotu, GPsd, GPtaxa, GPpt)

Using the default GlobalPatterns data set

GP1 <- ordinate(GP, "NMDS", engine = "monoMDS", maxit = 200, try = 100)

GP1$stress

# [1] 0.1612348

Using the revised GlobalPatterns data set with family as the only taxa

GP2 <- ordinate(GPnew, "NMDS", engine = "monoMDS", maxit = 200, try = 100)

GP2$stress

# [1] 0.1612348

How do you perform ordination of a taxa other than species using phyloseq?

I know how to do this in vegan, but I need a phyloseq solution.

Thank you.

1

There are 1 answers

0
Paul 'Joey' McMurdie On BEST ANSWER

Your call to tax_table() accessor method did not subset or agglomerate as you suggested in the post. It merely returned the taxonomy table alone, subsetted to the "Family" column in common matrix bracket notation.

What you are looking for is tax_glom first to do the agglomeration.

library("phyloseq")
data(GlobalPatterns)
GPnew <- tax_glom(GlobalPatterns, "Family")

And now the ordination

ord1 <- ordinate(GPnew, "NMDS", "bray")
plot_ordination(GPnew, ord1, color="SampleType")