# open an example dataset (HapMap)
(genofile <- snpgdsOpen(snpgdsExampleFileName()))
# + [ ] *
# |--+ sample.id { FStr8 279 ZIP(23.10%) }
# |--+ snp.id { Int32 9088 ZIP(34.76%) }
# |--+ snp.rs.id { FStr8 9088 ZIP(42.66%) }
# |--+ snp.position { Int32 9088 ZIP(94.73%) }
# |--+ snp.chromosome { UInt8 9088 ZIP(0.94%) } *
# |--+ snp.allele { FStr8 9088 ZIP(14.45%) }
# |--+ genotype { Bit2 9088x279 } *
# |--+ sample.annot [ data.frame ] *
# | |--+ sample.id { FStr8 279 ZIP(23.10%) }
# | |--+ family.id { FStr8 279 ZIP(28.37%) }
# | |--+ geneva.id { Int32 279 ZIP(80.29%) }
# | |--+ father.id { FStr8 279 ZIP(12.98%) }
# | |--+ mother.id { FStr8 279 ZIP(12.86%) }
# | |--+ plate.id { FStr8 279 ZIP(1.29%) }
# | |--+ sex { FStr8 279 ZIP(28.32%) }
# | |--+ pop.group { FStr8 279 ZIP(7.89%) }
set.seed(1000)
snpset <- unlist(snpgdsLDpruning(genofile))
length(snpset)
# 6547
# close the file
snpgdsClose(genofile)
snpgdsCreateGenoSet(snpgdsExampleFileName(), "test.gds", snp.id=snpset)
####################################################
# check
(gfile <- snpgdsOpen("test.gds"))
# + [ ] *
# |--+ sample.id { VStr8 279 ZIP(29.89%) }
# |--+ snp.id { Int32 6547 ZIP(34.89%) }
# |--+ snp.rs.id { VStr8 6547 ZIP(40.52%) }
# |--+ snp.position { Int32 6547 ZIP(94.85%) }
# |--+ snp.chromosome { Int32 6547 ZIP(0.41%) }
# |--+ snp.allele { VStr8 6547 ZIP(11.51%) }
# |--+ genotype { Bit2 6547x279 } *
# close the file
snpgdsClose(gfile)
unlink("test.gds", force=TRUE)
Run the code above in your browser using DataLab