Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Species accumulation curves ("exact") with a single inventoried species: confusion between sites and richness? #501

Closed
luroy opened this issue Mar 9, 2022 · 6 comments
Labels

Comments

@luroy
Copy link

luroy commented Mar 9, 2022

Dear all,
I’ve just started using the “specaccum” function with the “exact” method to plot species accumulation curve, so I apologize in advance if my following comment is due to my unfamiliarity with this method.
I want to make species accumulation curves for several forests that I have inventoried with 8 quadrats.
In one of these forests, I recorded only one species, which is present in three of the eight quadrats.
However, when I use the "specaccum" function for this forest as follows:
specaccum(data,method="exact")
I get the following result and error message:

no actual accumulation since only one site provided
Species Accumulation Curve
Accumulation method: exact
Call: specaccum(comm = data, method = "exact") 
Sites     1
Richness  3
sd       NA

The "data" object is a matrix with the quadrats (sites) as rownames and the species names as colnames.

<style> </style>
  SpeciesA SpeciesB SpeciesC SpeciesD SpeciesE SpeciesF
X1 0 3 0 0 0 0
X2 0 0 0 0 0 0
X3 0 0 0 0 0 0
X4 0 0 0 0 0 0
X5 0 2 0 0 0 0
X6 0 12 0 0 0 0
X7 0 0 0 0 0 0
X8 0 0 0 0 0 0

Therefore, I don't understand why the error message says that only one site is provided, nor why the richness is three. There seems to be a kind of inversion between sites and richness, while the community matrix seems correct.

Thank you for your attention to this matter,

Léa

@jarioksa
Copy link
Contributor

jarioksa commented Mar 10, 2022

Confirmed.

There are numerous reproducible ways of getting this:

## only one non-zero species
x <- matrix(0, 1000, 1000) # matrix of zeros
x[c(125, 618), 413] <- 1 # add two occurrences for species 413, still 999998 zeros
specaccum(x)
## take only one species from a data set
specaccum(dune[,2])
## one sampling unit should be OK with the message
specaccum(dune[2,])

I think this happens because of an implicit assumption that a vector (column or row) can only come from a single sampling unit. I don't remember why I assumed so: the function was released in 2003 (vegan 1.6-0) with this assumption which pre-dates using version control systems. Similar assumption was made in diversity indices as well, and it may just been carried over here without much thinking.

I'll see what to do.

jarioksa added a commit that referenced this issue Mar 10, 2022
If some sampling units have zero species, accumulated richness can
be < 1. This happens with one-species communities of issue #501.
@jarioksa
Copy link
Contributor

The branch one-species-accumulation changes the behaviour, and seems to work with data frames. However, this will change the behaviour of input vectors: earlier they were regarded as data for one sampling unit and several species, but now they are regarded as data for one species and several sampling units. This also happens if input data are a matrix which drops dimensions when one row is selected (unless drop = FALSE was used). However, data frames do not drop dimensions and there distinction is maintained between rows and columns.

There is a thin possibility that this breaks some other package that expected the old behaviour. I don't expect so, but better check before merging.

@luroy
Copy link
Author

luroy commented Mar 11, 2022

Dear @jarioksa
Thanks for responding so quickly!
I'm sorry, I'm not sure that I understand the implication of your comment. I ran the code of the specaccum R. function you modified and tried again. But I get the same result and error message. I don't know if other implementations to fix the bug are necessary. Let me know if I can help.

@jarioksa
Copy link
Contributor

Try with the reproducible examples in my earlier messages. They work with me. If they don't work with me, you probably did not use the updated function from the github.

@luroy
Copy link
Author

luroy commented Mar 11, 2022

@jarioksa, I had accidentally forgotten to detach the vegan package from R., so it was the old function that was running... I'm really sorry for the inconvenience. Thank you very much for your help and for your reactivity and availability !!!

@jarioksa
Copy link
Contributor

Fixed with 6a5f9b3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants