EricArcher / strataG

strataG is a toolkit for haploid sequence and multilocus genetic data summaries, and analyses of population structure.
25 stars 12 forks source link

Troubles running the ldNe function #47

Closed ChrystelleDelord closed 3 years ago

ChrystelleDelord commented 3 years ago

Dear Eric and strataG users,

I tried to run the ldNe function on a gtypes object consisting of 312 diploid individuals and 42826 SNP loci, converted from a genind object with the following characteristics:

/// GENIND OBJECT /////////

 // 312 individuals; 42,826 loci; 85,652 alleles; size: 135.5 Mb

 // Basic content
   @tab:  312 x 85652 matrix of allele counts
   @loc.n.all: number of alleles per locus (range: 2-2)
   @loc.fac: locus factor for the 85652 columns of @tab
   @all.names: list of allele names for each locus
   @ploidy: ploidy of each individual  (range: 2-2)
   @type:  codom
   @call: df2genind(X = xx[, ], sep = "/", ncode = 1, ind.names = gl@ind.names, 
    pop = gl@pop, NA.char = "-", ploidy = 2)

 // Optional content
   @pop: population of each individual (group size range: 8-105)
   @other: a list containing: ind.metrics  loc.metrics  latlong  history

Here is what the gtypes object looks like after conversion using the genind2gtypes function:

<<< gtypes created on 2021-02-01 15:48:21 >>>

Contents: 312 samples, 42826 loci, 8 strata
Other info: genind

Strata summary:
          stratum num.ind num.missing num.alleles
1      Atlantic-N      42  0.57327325    1.891748
2     Atlantic-NE      21  0.47190959    1.757367
3     Atlantic-SE     105  1.43382525    1.966165
4 Indian_Ocean-EC       8  0.07605193    1.547308
5  Indian_Ocean-N      16  0.15123990    1.687059
6 Indian_Ocean-SW      22  0.29995797    1.750595
7   Mediterranean      45  0.60131696    1.876617
8      Pacific-SW      53  0.84348293    1.899827

Everything seems to be going well, unfortunately when I try to run the ldNe function I get the following error:

> LDNe_bystrata <- ldNe(dat1, maf.threshold = 0.05, by.strata = FALSE, ci = 0.95, drop.missing = FALSE, num.cores = 16)
Error in which() : argument "x" is missing, with no default

Traceback:

8. which()
7. eval(lhs, parent, parent)
6. eval(lhs, parent, parent)
5. which() %>% names()
4. FUN(X[[i]], ...)
3. lapply(X = ans[index], FUN = FUN, ...) 
2. tapply(1:nrow(mat), st, function(i) {
        mat.st <- mat[i, ]
        if (maf.threshold > 0) {
              above.thresh <- (colMeans(mat.st)/2) >= maf.threshold ...
1. ldNe(dat1, maf.threshold = 0.05, by.strata = FALSE, ci = 0.95, drop.missing = FALSE, num.cores = 16)

I am working with strataG v2.4.905, which is not the latest version indeed but apparently ldNe from strataG v2.4.910 was corrected for an error when 1 individual is present, which is not the case in my dataset (always >1 individuals). I tried getting into the code source but could not figure out what I was doing wrong?

Thank you very much in advance for your feedback, All the best!

Chrystelle

EricArcher commented 3 years ago

Thanks for the heads up on this. It was due to a typo that didn't get caught in checks. I've fixed it in the most recent push to the version on GitHub, which also makes some sweeping changes to the population structure functions. I have a few more of those to add, then I will do a CRAN release.

Cheers, Eric

ChrystelleDelord commented 3 years ago

Thank you so much Eric for your prompt answer, I was able to install the devel version 2.5.1 and it is now working perfectly!

Thank you so much again for strataG which is an awesome package!

Cheers, Chrystelle

EricArcher commented 3 years ago

Thanks for the report back. Glad it is working for you.

Cheers, Eric