joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
584 stars 187 forks source link

Where to find CAP1 and CAP2 values in phyloseq::ordinate with method "CAP" #1772

Open msconstante opened 1 month ago

msconstante commented 1 month ago

Hi,

I am trying to get the CAP1, CAP2 and bacterial loading values from a capscale.phyloseq ordination object and look at bacterial contributions to beta-diversity.

ord<-phyloseq::ordinate(phyloclr, method="CAP", distance="euclidean", formula= ~ Group)
ordPlotDefault` <- plot(ord)
ordPlotOrdination` <- phyloseq::plot_ordination(phyloclr, ord)

The above two plots are consistent (see attached), but I get a different scale (but the same pattern) using:

dfo <- data.frame(ord[["CCA"]][["wa"]])
waPlot <- ggplot() + 
  geom_point(data=dfo, aes(x=dfo[,1], y= dfo[,2]), color="black")

I assume "wa" values are being multiplied by a specific value, but I cannot find which. This is relevant as I am interested in the bacterial contributions to CAP1 and CAP2 by using the values in: ord[["CCA"]][["v"]]

I am wondering whether the "v" values are compared to "wa" values or to those obtained from phyloseq::plot_ordination.

ordPlotDefault ordPlotDefault

ordPlotOrdination ordPlotOrdination

waPlot waPlot

msconstante commented 1 month ago

Nevermind.

This seems to be a vegan question and it seems you can get the CAP and bacterial contributions using:

as.data.frame(scores(ord, display = "sites"))
as.data.frame(scores(ord, display = "species"))