-
Notifications
You must be signed in to change notification settings - Fork 18
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
Include alpha scale individual-based rarefaction curves? #209
Comments
Hey @T-Engel thanks for pointing this difference in usage out between the packages. It is possible to do this using |
Hi @dmcglinn, |
That may be a good suggestion. One question we're confronted with is what do we want to return to the user if they don't specify |
I agree that it would be nice to have the functions behave in the same way (i.e. output up to the plot-specific n). But I guess it will be a little tricky to change the output of |
This is not as easy as it probably should be but we are a little closer to a simple implementation with library(mobr)
#load data and select only the first 3 sites as an example
data(inv_comm)
inv_comm<-inv_comm[1:3,]
# rarefy with vegan for 5 and 10 individuals
vegan::rarefy(inv_comm, c(5,10))
# trying to achieve the same with mobr
calc_comm_biodiv(inv_comm, scales = 'alpha', index = "S_n", effort = c(5,10))
#as before it is stills simpler to use:
apply(inv_comm, 1, rarefaction, 'IBR', c(5,10)) |
I noticed that it is a little tricky for users to calculate individual-based rarefaction curves at the site level. By that, I mean the basic functionality of the vegan function
rarefy()
, where you input a site-by-species matrix and a vector of desired sample sizes and what you get is a site-by-S_rare matrix for all sites and sample sizes that you plugged in.I think there is currently no straightforward way to do this in mobr. As our
rarefaction(method='indiv')
function is designed for the allscales analysis, it automatically pools all sites to draw the individual-based rarefaction curve at the gamma level. However, users who supply a site-by-species-matrix torarefaction(method='indiv')
might also wish to compute the curves at the alpha/site level, as they know it from vegan or iNext.Currently, it seems that the only way to get close to this is using
calc_biodiv(index = "S_n")
. But here, it looks like the function doesn't work if you supply a vector of efforts as opposed to a single value. Although it calculates all the right values, they appear to be assigned to the wrong sites.Here is some code that shows you what I mean
And here you can compare the outputs. Vegan uses a wide format where rows correspond to a sites, mobr uses a long format where the group column codes for the sites.
vegan:
mobr:
As you see, the values got mixed up.
I suggest the following fixes:
calc_biodiv(index = "S_n")
to properly match values to sites.rarefaction()
so that it explicitly says that for the individual-based rarefaction curve the sites will be pooled to a gamma. Furthermore, we should give directions as to how to calculate the alpha rarefaction curves by referring tovegan::rarefy()
,iNext::iNext()
, or the debuggedcalc_biodiv(index = "S_n")
.Any opinions? Do you think this is important?
The text was updated successfully, but these errors were encountered: