jgx65 / hierfstat

the hierfstat package
24 stars 14 forks source link

basic.stats does not work with only a single locus #7

Closed mijter closed 8 years ago

mijter commented 8 years ago

I'm doing some single-locus simulations and wanted to use basic.stats, but ran into the problem that this does not work with only a single locus. See following test script:

library(hierfstat)

make a genotype array

Pop = rep(c(1,2), each=20) Loc1 = sample(c(11,12,21,22),40, replace=TRUE) dats = cbind(Pop, Loc1) basic.stats(dats) #gives error: Error in apply(data[, -1], 2, dum) : dim(X) must have a positive length

to verify, now with two loci

Loc2 = sample(c(11,12,21,22),40, replace=TRUE) dats2 = cbind(Pop, Loc1, Loc2) basic.stats(dats2) #no problem

jgx65 commented 8 years ago

Thanks @mijter. Fixed: a dummy locus, copy of data[,2] is added when only one locus.