JohnsonHsieh / iNEXT

R package for interpolation and extrapolation
https://JohnsonHsieh.github.com/iNEXT
57 stars 26 forks source link

estimateD error due to invChat dropping samples with incidence data and base="coverage" #51

Open aureliendejode opened 4 years ago

aureliendejode commented 4 years ago

I have a list of matrix containin incidence raw data and I run estimateD like below.

estimateD(list_asv.incidence.no.myr.no.rownames, datatype="incidence_raw", base="coverage", level=NULL, conf=0.95)

And I got this error

estimateD Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 177, 168

By using the function available in git I noticed that the error comes from the final cbind step:

"nam <- names(x) if(is.null(nam)){ tmp }else if(ncol(tmp)==6){ tmp <- cbind(site=nam, tmp) }else{ tmp <- cbind(site=rep(nam, each=3), tmp) } rownames(tmp) <- NULL tmp"

And this is because invChat function dropped 3 samples for some reason and I don't know why. Some there is a discrepency between the number of names(x) and the number of row in tmp.

Do you have any idea what could have happened to those 3 samples ?

kfeilich commented 4 years ago

I've been having the same issue. From what I can tell, it occurs when the number of species in a locality is < 3, or when there is a serious imbalance in the number of specimens per species. But I don't know why that would be the case, and it's becoming a problem for my analysis. Any fix for this?

davidcerny commented 3 years ago

I can confirm that the issue persists, and that it occurs when the number of species per bin is < 3. Interestingly, for my dataset, it also depends on the sample coverage (the level argument of estimateD()): it occurs at very low values (e.g., 0.1) but not higher ones.