Description Usage Arguments Value Author(s) Examples
To get a genotype matrix from a specified GDS file
1 2 |
gdsobj |
an object of 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 |
.snpread |
internal use |
with.id |
if |
verbose |
if TRUE, show information |
The function returns an integer matrix with values 0, 1, 2 or NA
representing the number of reference allele when 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.
Xiuwen Zheng
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.