bwringe / hybriddetective

13 stars 7 forks source link

freqbasedsim_GTFreq error: Error in GenePop[-1, ] : incorrect number of dimensions #12

Closed KealanH closed 1 year ago

KealanH commented 2 years ago

Hey all having some issues progressing with the example data,

I was able to proceed with the first part fine: getTopLoc(GPD = your_example_data_path, panel.size = 50, where.PLINK = your_plink_path, where.PGDspider = your_pgdspider_path)

The file "SimPurePops_50_Loci_Panel.txt" was produced into the right folder and appears fine. Note: I have also tried your example file "SimPurePops_50_Loci_Panel.txt" file from a previous issue on github and still come up with the following issue.

However when I proceed with the next part: freqbasedsim_GTFreq(GenePopData = "~/hybriddetective/SimPurePops_50_Loci_Panel.txt", sample.sizePure = 100, sample.sizeF1 = 50, sample.sizeF2 = 10, sample.sizeBC = 10, NumSims = 3, NumReps = 3)

I recieve the error: Error in GenePop[-1, ] : incorrect number of dimensions In addition: Warning message: In stri_extract_first_regex(string, pattern, opts_regex = opts(pattern)) : argument is not an atomic vector; coercing

Any clues as to what I'm doing wrong?

Kind regards, Kealan

stevemussmann commented 1 year ago

I'm not the program author, but I ran into this problem today and think I fixed it.

Lines 40 and 41 of freqbasedsim_GTFreq.R read:

  GenePop <- as.vector(GenePop)
  GenePop <- GenePop[-1,]

I switched the order of these two lines so that the removal of the first record in the input GenePop file occurs before GenePop is converted to a vector. There was a similar problem in freqbasedsim_AlleleSample.R, and I made the same change there as well.

I don't know why this suddenly became a problem now, given that this R package hasn't been updated in 6 years and I have never encountered this problem previously. Anyways, I forked this repository and applied the fixes. It can be installed with the command devtools::install_github("stevemussmann/hybriddetective")

rystanley commented 1 year ago

I am also trying to figure out why this is an issue. But @stevemussmann is correct that simple indexing syntax seems to be the error. We will rebuild the package soon to try to fix that issue. In the interim hopefully the forked that Steve made works.

rystanley commented 1 year ago

I have started to work through the fix on this indexing bug so will close the issue here. Apologies for the slow reply, I am not the primary owner of the package and so wasn't getting notifications of these issues.