
snpgdsGetGeno(gdsobj, sample.id=NULL, snp.id=NULL, snpfirstdim=NA, .snpread=NA, with.id=FALSE, verbose=TRUE)
SNPGDSFileClass
,
a SNP GDS file; or characters to specify the file name of SNP GDSTRUE
, genotypes are stored in the
individual-major mode, (i.e, list all SNPs for the first individual,
and then list all SNPs for the second individual, etc); FALSE
for snp-major mode; if NA
, determine automaticallyTRUE
, return sample.id
and snp.id
with.id=FALSE
;
or list(genotype, sample.id, snp.id)
when with.id=TRUE
. The
orders of sample and SNP IDs in the genotype matrix are actually consistent
with sample.id
and snp.id
in the GDS file, which may not be
as the same as the arguments sampel.id
and snp.id
specified
by users.
# 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