# the VCF file
vcf.fn <- seqExampleFileName("vcf")
# the number of variants
total.count <- seqVCF_Header(vcf.fn, getnum=TRUE)$num.variant
split.cnt <- 5
start <- integer(split.cnt)
count <- integer(split.cnt)
s <- (total.count+1) / split.cnt
st <- 1L
for (i in 1:split.cnt)
{
z <- round(s * i)
start[i] <- st
count[i] <- z - st
st <- z
}
fn <- paste0("tmp", 1:split.cnt, ".gds")
# convert to 5 gds files
for (i in 1:split.cnt)
seqVCF2GDS(vcf.fn, fn[i], start=start[i], count=count[i])
# merge
seqMerge(fn, "tmp.gds")
seqSummary("tmp.gds")
####
vcf.fn <- seqExampleFileName("gds")
file.copy(vcf.fn, "test.gds", overwrite=TRUE)
# modify 'sample.id'
f <- openfn.gds("test.gds", FALSE)
sid <- read.gdsn(index.gdsn(f, "sample.id"))
add.gdsn(f, "sample.id", paste("S", 1:length(sid)), replace=TRUE)
closefn.gds(f)
# merging
seqMerge(c(vcf.fn, "test.gds"), "output.gds")
# delete the temporary files
unlink(c("tmp.gds", "test.gds", "output.gds"), force=TRUE)
unlink(fn, force=TRUE)
Run the code above in your browser using DataLab