zhengxwen / SNPRelate

R package: parallel computing toolset for relatedness and principal component analysis of SNP data (Development version only)
http://www.bioconductor.org/packages/SNPRelate
98 stars 25 forks source link

snpgdsSlidingWindow brings up "Error in .CheckFile(gdsobj) : `gdsobj' should be a GDS file." #24

Closed SebVen closed 7 years ago

SebVen commented 7 years ago

When executing the snpgdsSlidingWindow on a GDS file loaded with snpgdsOpen() I receive the message "Error in .CheckFile(gdsobj) : `gdsobj' should be a GDS file."

This may be related to Check whether SNP GDS file or not

.CheckFile <- function(gdsobj) { if (!inherits(gdsobj, "gds.class")) stop("gdsobj' should be a GDS file.")

I'm unsure why the error gets generated as running the inherits(genofile, "gds.class") renders TRUE. I had a look at the snpgdsSlidingWindow code, but I'm afraid this is pushing the limits of my R experience

zhengxwen commented 7 years ago

Show me the R session information sessionInfo()

SebVen commented 7 years ago

Of course:

sessionInfo() R version 3.3.3 (2017-03-06) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

locale: [1] LC_COLLATE=English_Ireland.1252 LC_CTYPE=English_Ireland.1252 LC_MONETARY=English_Ireland.1252 LC_NUMERIC=C LC_TIME=English_Ireland.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] SNPRelate_1.8.0 gdsfmt_1.10.1 PopGenome_2.2.2 ff_2.2-13 bit_1.1-12

loaded via a namespace (and not attached): [1] tools_3.3.3

zhengxwen commented 7 years ago

You are using "SNPRelate_1.8.0". Please install the latest SNPRelate from github. It may have solved your problem.

SebVen commented 7 years ago

I'll do that, thanks

SebVen commented 7 years ago

Installed the gdsfmt and SNPRelate fo latest versions from GitHub repository, unfortunately the issue is still occurring.

Sliding Window Analysis: Excluding 1,048,138 SNPs (monomorphic: FALSE, MAF: 0.45, missing rate: NaN) Working space: 2,261 samples, 7,316 SNPs using 1 (CPU) core window size: 100000, shift: 10000 (basepair) Chromosome Set: 22 Thu Mar 30 11:07:23 2017, Chromosome 22 (7316 SNPs), 3507 windows Error in .CheckFile(gdsobj) : gdsobj' should be a GDS file.

sessionInfo() R version 3.3.3 (2017-03-06) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

locale: [1] LC_COLLATE=English_Ireland.1252 LC_CTYPE=English_Ireland.1252 LC_MONETARY=English_Ireland.1252 LC_NUMERIC=C LC_TIME=English_Ireland.1252

attached base packages: [1] parallel stats graphics grDevices utils datasets methods base

other attached packages: [1] SNPRelate_1.9.6 gdsfmt_1.11.6 plyr_1.8.4 WhopGenome_0.9.7 data.table_1.10.4 BASIX_1.1 PopGenome_2.2.2 ff_2.2-13 bit_1.1-12

loaded via a namespace (and not attached): [1] tools_3.3.3 Rcpp_0.12.10

My goal is to essentially get an global Fst value for each SNP in my GDS file and I believe snpgdsSlidingWindow is probably the only way to do it. Correct me if I'm wrong.

Thanks a lot

SebVen commented 7 years ago

This issue is reproducible with genofile <- snpgdsOpen(snpgdsExampleFileName()), so not specific to particular gds files

SebVen commented 7 years ago

Debugged the issue. Was a mistake on my part. Set the variable FUN=snpgdsFst instead of FUN="snpgdsFst". However, I'm afraid that tracing the admittedly dumb issue was not made easier by the error code that this mistake calls. I tested a bit and any function without "" makes it through the validation procedure in Line 1903-1938 of AllUtilities.R

zhengxwen commented 7 years ago

I should detect FUN=snpgdsFst and show a warning or error message.

SebVen commented 7 years ago

Any valid function without the quotation marks makes it through if/else statements in your script and executes leading to diversity of odd results. A solution would perhaps be to detect FUN=[function] ([function] = any valid function without quotation marks) and provide the user with the standard Error: object '[function]' not found. This should make the user's mistake clear to him