vegan icon indicating copy to clipboard operation
vegan copied to clipboard

Error in adonis: dissimilarities must be non-negative

Open otaviolovison opened this issue 11 months ago • 1 comments

Hello!

I am trying to perform PERMANOVA on a Jensen-Shannon divergence matrix calculated from normalized data (clr and tss) and getting this error (title). When I use non-normalized data, the adonis2 function runs without error.

Anyone has an idea why this is happening?

When I run the same process for Bray-Curtis and Jaccard, or even for the JSD from non-normalized data, I have no error, besides the fact that these 3 matrices has negative dissimilarities values in the matrix.

Thanks in advance!

otaviolovison avatar Jul 18 '23 19:07 otaviolovison

Obviously your dissimilarities are negative. There is a threshold of −10-7 for negative values regarded as zeros, but more negative ones are regarded as an error. If you are sure that these negative values should be regarded as zero, make them so with something like d[d<0] <- 0 for dissimilarities d. This is not bullying, but adonis2 just cannot cope with negative dissimilarities.

I do not know how you got your dissimilarities. It is sure that Jaccard and Bray-Curtis from vegan cannot be negative for non-negative data – and they do not make sense with negative data. If the thing that you call normalization produces negative data, you should carefully consider what kind of indices work with them.

jarioksa avatar Jul 18 '23 20:07 jarioksa