# the GDS file
(gds.fn <- seqExampleFileName("gds"))
# display
(f <- seqOpen(gds.fn))
# output the first 10 samples
samp.id <- seqGetData(f, "sample.id")
seqSetFilter(f, sample.id=samp.id[1:5])
# convert
seqGDS2VCF(f, "tmp.vcf.gz")
# no INFO and FORMAT
seqGDS2VCF(f, "tmp1.vcf.gz", info.var=character(0), fmt.var=character(0))
# output BN,GP,AA,DP,HM2 in INFO (the variables are in this order), no FORMAT
seqGDS2VCF(f, "tmp2.vcf.gz", info.var=c("BN","GP","AA","DP","HM2"), fmt.var=character(0))
# read
(txt <- readLines("tmp.vcf.gz", n=20))
(txt <- readLines("tmp1.vcf.gz", n=20))
(txt <- readLines("tmp2.vcf.gz", n=20))
#########################################################################
# Users could compare the new VCF file with the original VCF file
# call "diff" in Unix (a command line tool comparing files line by line)
# using all samples and variants
seqResetFilter(f)
# convert
seqGDS2VCF(f, "tmp.vcf.gz")
# file.copy(seqExampleFileName("vcf"), "old.vcf.gz", overwrite=TRUE)
# system("diff <(gunzip -c old.vcf.gz) <(gunzip -c tmp.vcf.gz)")
# 1a2,3
# > ##fileDate=20130309
# > ##source=SeqArray_RPackage_v1.0
# LOOK GOOD!
# delete temporary files
unlink(c("tmp.vcf.gz", "tmp1.vcf.gz", "tmp2.vcf.gz"))
# close the GDS file
seqClose(f)
Run the code above in your browser using DataLab