ChiLiubio / microeco

An R package for data analysis in microbial community ecology
GNU General Public License v3.0
198 stars 56 forks source link

PCoA axes scores - Question #150

Closed StephTs closed 2 years ago

StephTs commented 2 years ago

Hello,

Thank you very much for this amazing package!

I'm interested in doing Spearman's correlation on the PCoA coordinates but I'm not sure how to extract the scores - Is there a way of doing it? I'm sorry if this is obvious, I'm a bioinformatics newbie.

My current code is: `A3 <- trans_beta$new(dataset = A_dataset, group = "Treatment", measure = "bray")

A3$cal_ordination(ordination = "PCoA")

A3$plot_ordination(plot_color = "Treatment", plot_shape = "Location", plot_type = c("point", "ellipse"))`

Thank you!

ChiLiubio commented 2 years ago

Hi. I use the example data to show the operation.

library(microeco)
data(dataset)
t1 <- trans_beta$new(dataset = dataset, measure = "bray", group = "Group")
t1$cal_ordination(ordination = "PCoA")
View(t1$res_ordination$scores)

The PCo1, PCo2 and ... in t1$res_ordination$scores may be the scores you need. So you can directly access the t1$res_ordination$scores to extract them.

StephTs commented 2 years ago

That's great, thank you so much - works perfectly!