I tried "GWASTools" R package, and I would be happy if you help me out of a problem.
When I tried 'gdsSubset' function, an error occurred with the following message;
"gds nodegenotypemust have 'snp.order' or 'sample.order' as an attribute".
My question is how to put 'snp.order' or 'sample.order' attribute to a 'gds' substance.
The following is the sample code I am using.
library(gdsfmt)
# construct gds file and put data
gfile<-createfn.gds("test.gds")
gen_node<-add.gdsn(gfile, "genotype", storage="bit2", valdim=c(20, 10)) #20 snps, 10 scans=samples
add.gdsn(gfile, "snp.id", val=c(1:20))
add.gdsn(gfile, "sample.id", val=c(1:10))
add.gdsn(gfile, "snp.chromosome", val=c(1:20))
add.gdsn(gfile, "snp.position", val=c(1:20)*100)
write.gdsn(gen_node, matrix(rep(c(0:3),50), nrow=20), start=c(1,1), count=(c(20,10)))
closefn.gds(gfile)
# read gds file and subset the file
library(GWASTools)
gds <- GdsGenotypeReader("test.gds", "snp,scan")
sub.file<- tempfile()
close(gds)
gdsSubset("test.gds", sub.file, sample.include=c(1:5))
# HERE! error occures! saying...
#Error in gdsSubset("test.gds", sub.file, sample.include = c(1:5)) :
#gds nodegenotypemust have 'snp.order' or 'sample.order' as an attribute