vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
449 stars 97 forks source link

species scores in wcmdscale #438

Open aguilart opened 3 years ago

aguilart commented 3 years ago

Hi, I was comparing the outputs from a PCA (using rda ), PCoA (using the combo vegdist and wcmdscale) and NMDS (using metaMDS). Then when using scores to extract the species and site scores I realized that PCoA does not give you species scores.

Example:

Performing each ordination method

pca<-rda(dune) 

d <- vegdist(dune);  ord <- wcmdscale(d, eig = TRUE)

sol <- metaMDS(dune)

Extracting the species scores works only for the pca and NMDS . I mean, there are 30 species in the dataset dune, and those are exactly the ones that correspond to the species scores in PCA and NMDS

For PCA:

rownames(as.data.frame(scores(pca,display="species")))
 [1] "Achimill" "Agrostol" "Airaprae" "Alopgeni" "Anthodor" "Bellpere" "Bromhord"
 [8] "Chenalbu" "Cirsarve" "Comapalu" "Eleopalu" "Elymrepe" "Empenigr" "Hyporadi"
[15] "Juncarti" "Juncbufo" "Lolipere" "Planlanc" "Poaprat"  "Poatriv"  "Ranuflam"
[22] "Rumeacet" "Sagiproc" "Salirepe" "Scorautu" "Trifprat" "Trifrepe" "Vicilath"
[29] "Bracruta" "Callcusp"

For NMDS:

rownames(as.data.frame(scores(sol,display="species")))

[1] "Achimill" "Agrostol" "Airaprae" "Alopgeni" "Anthodor" "Bellpere" "Bromhord"
 [8] "Chenalbu" "Cirsarve" "Comapalu" "Eleopalu" "Elymrepe" "Empenigr" "Hyporadi"
[15] "Juncarti" "Juncbufo" "Lolipere" "Planlanc" "Poaprat"  "Poatriv"  "Ranuflam"
[22] "Rumeacet" "Sagiproc" "Salirepe" "Scorautu" "Trifprat" "Trifrepe" "Vicilath"
[29] "Bracruta" "Callcusp"

But for PCoA, I what I get are the site scores (20):

rownames(as.data.frame(scores(ord,display="species")))
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15" "16"
[17] "17" "18" "19" "20"

Digging into the output of wcmdscale I could not find anywhere sth like species scores, so I understand these are not given at all. So my question is, why? why out of these tree techniques, in PCoA species scores are not given?

Aside from knowing why this is the case, the reason for this question is because I want to ordinate multivarite count data (thus PCA is not well suited) and I want to also to know which variable drives most of the ordination. Thus, I want to have species scores. I thought that PCoA would be an option as I can use bray distances, but I did not know species scores are not given. So, should I use NMDS instead?

jarioksa commented 3 years ago

There are no species scores in the wcmdscale result because there is no way of calculating those with the input: in rda and metaMDS the input was data frame dune, but in wcmdscale the input was distance data d, and there are is no information on species in distances. You will neither have species scores if you submit dissimilarities instead of community data to metaMDS.

Current vegan has function sppscores<- that adds species scores to an ordination object (or replaces old scores) for some methods. However, it is not implemented for wcmdscale. It is implemented for dbrda though, and if you do not use weights, dbrda and wcmdscale will be identical. So the following will work:

d <- vegdist(dune)
ord <- dbrda(d ~ 1)    # no species scores in ord 
sppscores(ord) <- dune # add species scores based on dune

Adding species scores was discussed in issue #254.

aguilart commented 3 years ago

Aha! Thanks a lot for the reply! Tha makes sense, to wcmdscale is fed the distance matrix, thus no way of having scores. I will try dbrda.

aguilart commented 3 years ago

Sorry, one more question. What do weights refers to? I feel this is a very basic question but I got right away confused on what weights are.

jarioksa commented 3 years ago

If you do not know what are the weights for, you do not need them.

The Example section in the wcmdscale help shows one example where you need weights, but other users may have various needs for weights, starting from duplicated sampling units, different sizes of sampling units etc.

aguilart commented 3 years ago

Thansk a lot for taking the time in answering these questions! It really helps a lot!