alexkychen / assignPOP

Population Assignment using Genetic, Non-genetic or Integrated Data in a Machine-learning Framework. Methods in Ecology and Evolution. 2018;9:439–446.
http://alexkychen.github.io/assignPOP/
GNU General Public License v3.0
17 stars 4 forks source link

assign.X error, Error in data.frame #13

Open Farhad63 opened 3 years ago

Farhad63 commented 3 years ago

Hi Alex I have problem with performing assign.X when I run assign.X (x1=x1, x2=x2, dir="unknown assign/", model="naiveBayes") it gives below error but I dont see any problem in data-frame.

Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 218, 0

I have successfully read both x1 and x2 SNP data (in structure format) into R following the assignPOP instruction in github. Even when I use two data with same number of rows it gives me this error, the number of rows in x2 is not zero but it says zero here. any comment please

alexkychen commented 3 years ago

Hi, does it prompt a message like "Known and unknown datasets have identical (or unequal) features" when you ran the assign.X?

Farhad63 commented 3 years ago

Hi Alex, Thank you for your reply. yes it does as below. Known and unknown datasets have identical features. Performing PCA on genetic data for dimensionality reduction...Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 218, 0

alexkychen commented 3 years ago

Could you try to set the argument pca.PCs="broken-stick" or a certain number (e.g., pca.PCs=10) and see if the error goes away?

If you still get the error message, then I may need the entire R script you used and a sample of your data so I can try to reproduce the error message from my side and take a deeper look.

Farhad63 commented 3 years ago

Hi Alex I set Pca.PCs to "broken-stick" and also to 10, but I still got the error. the code I use is as below;

myStructure <- read.Structure( "strct.stru", haploid = FALSE)
yStrUnknown <- read.Structure( "strct.stru", haploid = FALSE)
assign.X( x1=myStructure, x2=myStrUnknown, dir="unknown assign/", model="naiveBayes",  pca.PCs=12)
alexkychen commented 3 years ago

Could you send me a subset of your data (strct.stru) to my email, alexkychen@gmail.com? Thanks.
Also, have you tried to use model="svm" or model="lda" and still got errors?

Update: Are you currently using R 4.0? If so, that might be the issue. I got similar errors after I updated my R to 4.0.2. I am going to see if I can fix from my side to work with R 4.0. Otherwise, it could be that those associated packages haven't updated to work with R 4.0. At this point, I would suggest you use R 3.6 and see if it works. (I was using R 3.4 and had no issue).

PS. There's a change about data frame format when R updates from version 3 to 4.