# open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())
set.seed(1000)
snpset <- sample(read.gdsn(index.gdsn(genofile, "snp.id")), 1000)
mat1 <- snpgdsGetGeno(genofile, snp.id=snpset, snpfirstdim=TRUE)
dim(mat1)
# 1000 279
table(c(mat1), exclude=NULL)
mat2 <- snpgdsGetGeno(genofile, snp.id=snpset, snpfirstdim=FALSE)
dim(mat2)
# 279 1000
table(c(mat2), exclude=NULL)
identical(t(mat1), mat2)
# TRUE
# close the file
snpgdsClose(genofile)
Run the code above in your browser using DataLab