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

error in membership.plot: Faceting variables must have at least one value #10

Open D-A-Smith opened 4 years ago

D-A-Smith commented 4 years ago

Hi I'm getting an error when trying to produce a membership plot. Using the following code:

results1 <- file.path(outdir, paste0(analysis_name,"_Assign_kfold//"))

k.folds <- assign.kfold(assign, k.fold=c(2,3,4), train.loci=c(0.05, 0.1, 0.25, 0.5), 
             loci.sample="fst", model="svm", dir= results1)

accuKF <- accuracy.kfold(dir = results1)

accuracy.plot(accuKF, pop = c("all", "1", "2"))+
  annotate("segment",x=0.4,xend=3.6,y=0.33,yend=0.33,colour="red",size=1)

membership.plot(dir = results1, style = 2)

I get the error: Error: Faceting variables must have at least one value

Which led me to the facet_grid() argument in ggplot. Style = 1 or Style=3 work fine The problem appears with both style =2 and =4, I suspect that ndf$origin.pop might be empty for some reason, but I'm not confident enough with how functions work to try anything else, sorry.

Deane.

R version 3.6.2 (2019-12-12) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

assignPOP_1.1.7

D-A-Smith commented 4 years ago

Okay, I dug deeper, my populations were integers, eg. 1, 2 and 3. when I changed them to a, b and c, it worked fine.

alexkychen commented 4 years ago

Yea, that's the first thing I would try. Somehow the codes were not able to manage integers as population name. Will try to fix the bug in the future version. Thank you for your report.