gbradburd / conStruct

method for modeling continuous and discrete population genetic structure
35 stars 14 forks source link

structure2conStruct error #51

Closed TannerMyers closed 1 year ago

TannerMyers commented 1 year ago

Hi Gideon, I am having an issue using the "structure2conStruct" file conversion function. I have two species I want to run conStruct on, one with 40 and another with over 200. The one with more specimens works without errors, but when I attempt to run the following command (the only differences are the file prefixes between this command and the one that worked): structure2conStruct(infile = "brevirostris-nohead.str", onerowperind = TRUE, start.loci = 3, missing.datum = 0, outfile = "brev-conStuct-input") and I received this error message: "Error in sample.int(length(x), size, replace, prob) : invalid first argument construct". I've used this function before this too and not had any issues after getting the flags specifying where loci start, etc., correct. The only difference I can think of between the file I'm recovering errors with and the other files is that it happens to have far fewer specimens in it than any other.

I have attached the .structure files in question and please let me know if you have any follow-up questions: brevirostris-nohead.str.txt distichus-nohead.str.txt

Thanks, Tanner

gbradburd commented 1 year ago

Hi Tanner,

It looks like the issue is that the 5457th locus* in the brevirostris dataset is entirely composed of missing data. conStruct is supposed to catch that and spit an informative error message, but the class of missing data is numeric, while the class of the alleles is integer, so conStruct (via the identical function) isn't catching that they're the same.

If you drop loci that are all missing data, that should take care of the issue. In the meanwhile, I'll fix this function so that it'll give future users an informative error message.

Hope that helps!

TannerMyers commented 1 year ago

Hi Gideon,

Thanks for the quick reply, that's very helpful!

gbradburd commented 1 year ago

Hi Tanner,

Just a quick update - the current version of conStruct on github should work for you now in the sense that it gives you an informative error if you have all missing data. You can install it using:

library(devtools)
install_github("gbradburd/conStruct",build_vignettes=TRUE)

If you run into more related issues, please continue them in this issue. If this issue is resolved, you can close it (and open a new issue for other things that come up down the line).

good luck!

TannerMyers commented 1 year ago

This worked, thanks for the help!