Question: Question on 'gdsSubset' function
0
gravatar for yasuhito.nannya
22 months ago by
yasuhito.nannya0 wrote:

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

gwastools • 373 views
ADD COMMENTlink modified 22 months ago • written 22 months ago by yasuhito.nannya0
Answer: Question on 'gdsSubset' function
0
gravatar for Stephanie M. Gogarten
22 months ago by
University of Washington
Stephanie M. Gogarten670 wrote:

You can use put.attr.gdsn to define the genotype node as "snp.order" (snp x sample) or "sample.order" (sample x snp).

library(gdsfmt)
gfile <- createfn.gds("test.gds")
gen_node <- add.gdsn(gfile, "genotype", storage="bit2", valdim=c(20, 10)) #20 snps, 10 scans=samples
put.attr.gdsn(gen_node, "snp.order")
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)

library(GWASTools)
(gds <- GdsGenotypeReader("test.gds"))
close(gds)

sub.file <- tempfile()
gdsSubset("test.gds", sub.file, sample.include=c(1:5))
(gds <- GdsGenotypeReader(sub.file))
close(gds)
unlink(c(sub.file, "test.gds"))
ADD COMMENTlink modified 22 months ago • written 22 months ago by Stephanie M. Gogarten670
Answer: Question on 'gdsSubset' function
0
gravatar for yasuhito.nannya
22 months ago by
yasuhito.nannya0 wrote:

Thanks!

It worked!

ADD COMMENTlink written 22 months ago by yasuhito.nannya0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 126 users visited in the last hour