jgx65 / hierfstat

the hierfstat package
24 stars 14 forks source link

boot.ppfst #43

Closed jwwhale closed 3 years ago

jwwhale commented 3 years ago

Hello,

I'm trying to gather CIs on my GBS-like SNP dataset. I'm using a genind object, and am using the following code:
data <- read.genepop("data.gen", code =2L) data.CI<- boot.ppfst(data, nboot = 100, quant = c(0.025, 0.975), diploid = T)

But receiving this error: Error in i + 1 : non-numeric argument to binary operator

I have also run data1 <- genind2hierfstat(data) and still get the same error. My populations are all organised together.

I can calculate the global Fst on the dataset using the wc function, and can get the lsiga, lsigb, and lsigw values from performing wc(data)$sigma.loc but not perform the boot.ppfst function.

Any assistance would be hugely grateful.

Cheers, John

jgx65 commented 3 years ago

could you send a (small) example reproducing the behavior? Cheers

jwwhale commented 3 years ago

Hopefully you mean the following... data <- read.genepop("medtest.gen", ncode = 2L) Converting data from a Genepop .gen file to a genind object... File description: Mediana_7773SNPs_12Pops ...done. medtest <- boot.ppfst(data, nboot = 100, quant = c(0.025, 0.975), diploid = TRUE) Error in i + 1 : non-numeric argument to binary operator wc(data)$sigma.loc SNP lsiga lsigb lsigw M00001 2.566286e-02 3.802011e-03 0.47457627 M00002 6.928440e-02 4.692108e-02 0.34745763 M00003 3.936859e-02 2.079705e-01 0.13131313 ...

Then when converting the genind object

data1 <- genind2hierfstat(data) class(data1) [1] "data.frame" medtest<- boot.ppfst(data1, nboot = 100, quant = c(0.025, 0.975), diploid = TRUE) Error in i + 1 : non-numeric argument to binary operator

jgx65 commented 3 years ago

Sorry, what I meant was a small dataset reproducing the error you are getting. I suspect it is due to some loci being missing for whole populations, but would need to see the data to be sure. Cheers

jgx65 commented 3 years ago

alternatively you can share the data via PM if you can't reproduce the behavior

jgx65 commented 3 years ago

The issue seems to be with your population naming scheme, I have to dig further (I was able to reproduce your error once, but then the function ran smoothly). A quick fix is to rename populations using the following;

data1<-genind2hierfstat(data)
data1[,1]<-as.integer(data1[,1])
data.ci<-boot.ppfst(data1,...)

Will investigate

jwwhale commented 3 years ago

Awesome!! Thanks Jerome!