I have made ordination plots of microbiome data using the R phyloseq
functions ordinate and plot_ordination
with a phyloseq
object and a previously calculated distance matrix (unweighted UniFrac distances) as inputs. I would like to add some arrows that indicate which species relative abundances mainly drive the distance between the samples along the axes.
Adding scores using the function scores or specscores.dbrda
has not worked. Is there another way to add these arrows/vectors?
Here's the code I used:
MDS <- ordinate(physeqobject, "MDS", distance=unifracmatrix)
plot <- plot_ordination(physeqobject, MDS, color = "variable1")
speciesscores <- scores(MDS, display = "species")
The first part works fine, the scores function returns this error:
Error in scores.default(MDS, display = "species") :
cannot find scores
I also tried it without a separate distance matrix with the (default) Bray-Curtis distances calculated within ordinate, but I still get the same error:
MDS <- ordinate(physeqobject, "MDS")