snpgdsGetGeno: To get a genotype matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/SNPRelate_Main.r

Description

To get a genotype matrix from a specified GDS file

Usage

1
snpgdsGetGeno(gdsobj, sample.id=NULL, snp.id=NULL, snpfirstdim=NULL, verbose=TRUE)

Arguments

gdsobj

a GDS file object (gds.class)

sample.id

a vector of sample id specifying selected samples; if NULL, all samples are used

snp.id

a vector of snp id specifying selected SNPs; if NULL, all SNPs are used

snpfirstdim

if TRUE, 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); if NULL, determine automatically

verbose

if TRUE, show information

Value

Return an integer matrix.

Author(s)

Xiuwen Zheng

See Also

snpgdsCreateGeno, snpgdsCreateGenoSet, snpgdsCombineGeno

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# open an example dataset (HapMap)
genofile <- openfn.gds(snpgdsExampleFileName())

snpset <- sample(read.gdsn(index.gdsn(genofile, "snp.id")), 1000)
mat <- snpgdsGetGeno(genofile, snp.id=snpset)
mat[!is.element(mat, c(0,1,2))] <- NA
dim(mat)

# close the file
closefn.gds(genofile)

SNPRelate documentation built on May 2, 2019, 4:56 p.m.