2

I am trying to perform Anosim {vegan} on my ecological data and I keep getting the same error message. I don't think this is a duplicate question from another one already posted and would like to fully show what's happening.

I have got my numeric dataframe ("sps") consisting of 17 rows (sites) and 313 columns (species), and a second dataframe ("env.data") containing a column with 17 factors. I would therefore want to test if there are any significant differences between my 17 groups.

Here is a sample of my data:

> sps[,2:5]
                A. faranauti A. tecta A. lyra A. arbuscula 
Sargasso Sea              0         0       2            0
Equatorial Brazil         0         0       0            0
Canarias Sea              0         0       0            0
Corner Seamounts          0         0       0            2
Gulf of Mexico            0         0       0            0
Labrador Sea              0         0       0            0
Equatorial Africa         0         0       0            0
Tropic Seamount           0         0       0          107
NewEngland Seamount Chain 0         0       0            0
Norwegian Basin           0         0       0            0
Eastern North Atlantic    0         0       3            0
Logachev and BritishIsles 0         0       0            4
Reykjanes Ridge           0         0       0            0
MAR North                 0         0       0           14
Flemish Cap               0         0       0          217
MAR South                 1         1       0            0
Azores Seamount Chain     0         0       0           12

> class(sps)
[1] "data.frame"

> head(env.data)
  idcell          geo_area
1      1      Sargasso Sea
2      2 Equatorial Brazil
3      3      Canarias Sea
4      4  Corner Seamounts
5      5    Gulf of Mexico
6      6      Labrador Sea

> str(env.data)
'data.frame':   17 obs. of  2 variables:
$ idcell  : Factor w/ 17 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
$ geo_area: Factor w/ 17 levels "Canarias Sea",..: 15 5 1 2 7 8 4 17 12 13..  

Following {vegan}, I have first calculated a dissimilarity matrix with Sorensen as the distance method. I then use this dissimilarity matrix as my input for anosim:

dist.sorensen <- vegdist(sps, method= "bray", binary = TRUE, na.rm= TRUE, 
diag = TRUE)
sorensen.anosim <- anosim(dat=dist.sorensen, env.data$geo_area, permutations 
= 999)
> summary(sorensen.anosim )
Call:
anosim(dat = dist.sorensen, grouping = env.data$geo_area, permutations = 
999) 
Dissimilarity: binary bray 
ANOSIM statistic R:  
Significance: 0.001 
Permutation: free
Number of permutations: 999
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 
'x' must be atomic

I have also tried anosim with the raw species data and I get the same error:

raw.anosim <- anosim(sps, env.data$geo_area, permutations = 999, distance = 
"bray")

Any ideas? My "sps" dataframe (x) is numeric. My "env.data" dataset (groupings) has a factor column with 17 levels. I can't see where the error comes from, unless it's intrinsic to my data. Many of the 313 species listed in my original dataframe have been recorded only once across my 17 sites (very probably due to sampling bias). However, I get clusters after performing "vegdist (Sorensen index)" and "hclust".

| |
  • 1
    Hi Berta. Welcome to Stack Overflow. I haven't checked in detail, but you have 17 observations and a factor with 17 levels. If so, you are basically asking the impossible from ANOSIM as you are trying to estimate group differences with a single observation per group. There is no replication at the group level, which I would expect to see here. If that is the issue, and I'll need to check once I write a reproducible example, we could include a more informative error message, but if this is the issue it suggests that ANOSIM is not the correct tool for your problem. – Gavin Simpson Aug 29 '18 at 22:15
  • Hi @GavinSimpson, thank you for getting back to me. It seems to be what you mention: no replication at the group level. I checked it by adding a new factor with three levels and replication at two of the levels. The function worked only when I removed the level with no replication (and hence some species data!) as, like documentation suggests, anosim doesn't work well with unbalanced designs. – Berta Aug 30 '18 at 13:35
  • 1
    @Berta, this has nothing to do with balanced or unbalanced design, but the reason really seems to be that there is no replication at the group level. The ANOSIM statistic is based on comparing among-group and within-group variation, and there is no within-group variation, hence we get NULL. Actually, there are no within-group dissimilarities. I think we should detect such a mistaken model and give an error message. – Jari Oksanen Aug 30 '18 at 21:44
  • @JariOksanen, thank you for your clarification. Clearly I need a better understanding of the analysis, but I agree that a more informative error message would help. – Berta Aug 31 '18 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.