DaliangNing / iCAMP1

Infer Community Assembly Mechanisms by Phylogenetic bin-based null model analysis (Version 1)
GNU General Public License v2.0
68 stars 25 forks source link

Error in 1:ncol(bMNTD.randm) : argument of length 0 #7

Closed pyspider closed 3 years ago

pyspider commented 3 years ago

When I set detail.null= TRUE using bNTIn.p. I encountered this error: Error in 1:ncol(bMNTD.randm) : argument of length 0. But if I set detail.null= FALSE (default) using bNTIn.p, It's working smothly. And I can get the beltaNTI value. I am not sure whether I may use this result. Qpen also have same error. Here is the dataset I used. comm_and_phydist.zip

bNTI_placement.location=bNTIn.p(comm=OTU.location, dis=phydist, nworker = 4, weighted = TRUE, rand = 1000,output.bMNTD=TRUE,detail.null=TRUE) Now calculating observed betaMNTD. Begin at Thu Mar 25 13:01:14 2021. Please wait... Now randomizing by parallel computing. Begin at Thu Mar 25 13:01:16 2021. Please wait... Error in 1:ncol(bMNTD.randm) : argument of length 0 bNTI_placement.location=bNTIn.p(comm=OTU.location, dis=phydist, nworker = 4, weighted = TRUE, rand = 1000,output.bMNTD=TRUE) Now calculating observed betaMNTD. Begin at Thu Mar 25 13:02:41 2021. Please wait... Now randomizing by parallel computing. Begin at Thu Mar 25 13:02:43 2021. Please wait... qpen(comm=OTU.location, pd=phydist,rand.time = 1000,ab.weight = TRUE) The names are re-ranked. Now calculating observed betaMNTD. Begin at Thu Mar 25 13:10:56 2021. Please wait... Now randomizing by parallel computing. Begin at Thu Mar 25 13:10:57 2021. Please wait... Error in 1:ncol(bMNTD.randm) : argument of length 0

.

DaliangNing commented 3 years ago

@pyspider it is mainly because your data table only has two samples. I did not expect this before. It is fixed in the latest version of iCAMP (version >= 1.4.3, can be download from /RPackage/AllVersion). Please try. However, I would not suggest applying iCAMP to a dataset with only two samples, since the null model results would not be quite reliable when sample number is too low.

Another issue in your data: phydist.csv is not a square matrix. Some taxa may be lost when you preparing the data file.

Besides, the taxa IDs are too complicated and may cause unexpected error in R.

Please see the following code.

comf="OTU.location.csv" pdf="phydist.csv"

library(iCAMP) com=read.csv(comf,row.names = 1) dim(com)

pd=read.csv(pdf,row.names = 1) dim(pd) # your phydist is not a square matrix.

sampc=match.name(cn.list=list(com=com),both.list = list(pd=pd)) com=sampc$com pd=sampc$pd

oldid=colnames(com) colnames(com)=paste0("Taxon",1:ncol(com)) rownames(pd)<-colnames(pd)<-colnames(com) write.csv(data.frame(OldID=oldid,NewID=colnames(com)),file = "IDchange.csv")

bnti=iCAMP::bNTIn.p(comm = com,dis = pd,nworker = 2,weighted = TRUE, exclude.consp = FALSE, rand = 4, output.bMNTD = FALSE, sig.index = 'SES', unit.sum = NULL, correct.special = FALSE, detail.null=FALSE)

bnti2=bNTIn.p(comm = com,dis = pd,nworker = 2,weighted = TRUE, exclude.consp = FALSE, rand = 4, output.bMNTD = FALSE, sig.index = 'SES', unit.sum = NULL, correct.special = FALSE, detail.null=TRUE)

qpout=qpen(comm = com, pd = pd, rand.time = 4, ab.weight = TRUE)

pyspider commented 3 years ago

Many thanks for you help! Sorry. I uploaded a not square dissimilarity matrix here because I exported this file is incomplete. But this matrix is square in the previous analysis.

It is fixed in the latest version of iCAMP (version >= 1.4.3, can be download from /RPackage/AllVersion). Please try.

Yes. I repeated all analysis by iCAMP (version 1.4.3). The results are the same. Sure, a comparison of only two smaples can be allowed using iCAMP (version 1.4.3). But this caused some errors on iCAMP (version 1.3.4).

However, I would not suggest applying iCAMP to a dataset with only two samples, since the null model results would not be quite reliable when sample number is too low.

Thanks for your suggestion. Yes. Two samples are not quite reliable. Actually, they are pooled assemblages here. I did same analysis for many subgroupings too. But this error is caused by only two sample.

DaliangNing commented 3 years ago

Has the problem been solved? I am confused when you said 'the results are the same.' Do you mean you still get any error with version 1.4.3?

pyspider commented 3 years ago

Yes. This problem has been solved on iCAMP version 1.4.3... The results for only two samples are the same in comparison with the results from iCAMP version 1.3.4 (using bNTIn.p under detail.null=FALSE). Sorry for this confusion. Many thanks for your help again.

DaliangNing commented 3 years ago

Thank you for letting me know the issue. Feel free to contact me if any other issue shows up.