genotype must be a matrix with dimensions ('snp','scan') containing the number of A alleles : 2=AA, 1=AB, 0=BB.
snp must be a unique integer vector of SNP ids.
chromosome must be an integer vector of chromosomes.
Default values for chromosome codes are 1-22=autosome, 23=X, 24=XY, 25=Y,
26=M. The defaults may be changed with the arguments autosomeCode,
XchromCode, XYchromCode, YchromCode, and
MchromCode.
position must be an integer vector of base positions
scanID must be a unique integer vector of scan ids .
The MatrixGenotypeReader constructor creates and returns a
MatrixGenotypeReader instance.
Accessors
In the code snippets below, object is a MatrixGenotypeReader object.
nsnp(object): The number of SNPs.
nscan(object): The number of scans.
getSnpID(object, index): A unique integer vector of snp
IDs. The optional index is a logical or
integer vector specifying elements to extract.
getChromosome(object, index, char=FALSE): A vector of
chromosomes. The optional index is a logical or
integer vector specifying elements to extract.
If char=FALSE (default), returns an integer vector.
If char=TRUE, returns a character vector with elements in
(1:22,X,XY,Y,M,U). "U" stands for "Unknown" and is the value
given to any chromosome code not falling in the other categories.
getPosition(object, index): An integer vector of base pair
positions. The optional index is a logical or
integer vector specifying elements to extract.
getScanID(object, index): A unique integer vector of scan
IDs. The optional index is a logical or
integer vector specifying elements to extract.
getGenotype(object, snp=c(1,-1), scan=c(1,-1), drop=TRUE, use.names=FALSE):
Extracts genotype values (number of A alleles).
snp and scan indicate which elements to return along the snp and
scan dimensions. They must be integer vectors of the form (start,
count), where start is the index of the first data element to read
and count is the number of elements to read. A value of '-1' for
count indicates that the entire dimension should be read.
If drop=TRUE, the result is coerced to the lowest possible dimension.
If use.names=TRUE, names of the resulting vector or matrix are set to the SNP and scan IDs.
Missing values are represented as NA.
getGenotypeSelection(object, snp=NULL, scan=NULL, snpID=NULL, scanID=NULL,
drop=TRUE, use.names=TRUE):
Extracts genotype values (number of A alleles).
snp and scan may be integer or logical vectors indicating which elements
to return along the snp and scan dimensions.
snpID and scanID allow section by values of snpID and scanID.
Unlike getGenotype, the values requested need not be in contiguous blocks.
Other arguments are identical to getGenotype.
autosomeCode(object): Returns the integer codes for the
autosomes.
XchromCode(object): Returns the integer code for the X
chromosome.
XYchromCode(object): Returns the integer code for the
pseudoautosomal region.
YchromCode(object): Returns the integer code for the Y
chromosome.
MchromCode(object): Returns the integer code for
mitochondrial SNPs.
Author(s)
Stephanie Gogarten
See Also
NcdfGenotypeReader,
GenotypeData
Examples
snpID <- 1:100
chrom <- rep(1:20, each=5)
pos <- 1001:1100
scanID <- 1:20
geno <- matrix(sample(c(0,1,2,NA), 2000, replace=TRUE), nrow=100, ncol=20)
mgr <- MatrixGenotypeReader(genotype=geno, snpID=snpID,
chromosome=chrom, position=pos, scanID=scanID)
# dimensions
nsnp(mgr)
nscan(mgr)
# get snpID and chromosome
snpID <- getSnpID(mgr)
chrom <- getChromosome(mgr)
# get positions only for chromosome 10
pos10 <- getPosition(mgr, index=(chrom == 10))
# get all snps for first scan
geno <- getGenotype(mgr, snp=c(1,-1), scan=c(1,1))
# starting at snp 50, get 10 snps for the first 5 scans
geno <- getGenotype(mgr, snp=c(50,10), scan=c(1,5))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(GWASTools)
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/GWASTools/MatrixGenotypeReader-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: MatrixGenotypeReader
> ### Title: Class MatrixGenotypeReader
> ### Aliases: MatrixGenotypeReader-class MatrixGenotypeReader
> ### getSnpID,MatrixGenotypeReader-method
> ### getChromosome,MatrixGenotypeReader-method
> ### getPosition,MatrixGenotypeReader-method
> ### getScanID,MatrixGenotypeReader-method
> ### getGenotype,MatrixGenotypeReader-method
> ### getGenotypeSelection,MatrixGenotypeReader-method
> ### nsnp,MatrixGenotypeReader-method nscan,MatrixGenotypeReader-method
> ### show,MatrixGenotypeReader-method
> ### autosomeCode,MatrixGenotypeReader-method
> ### XchromCode,MatrixGenotypeReader-method
> ### XYchromCode,MatrixGenotypeReader-method
> ### YchromCode,MatrixGenotypeReader-method
> ### MchromCode,MatrixGenotypeReader-method
> ### Keywords: methods classes
>
> ### ** Examples
>
> snpID <- 1:100
> chrom <- rep(1:20, each=5)
> pos <- 1001:1100
> scanID <- 1:20
> geno <- matrix(sample(c(0,1,2,NA), 2000, replace=TRUE), nrow=100, ncol=20)
>
> mgr <- MatrixGenotypeReader(genotype=geno, snpID=snpID,
+ chromosome=chrom, position=pos, scanID=scanID)
>
> # dimensions
> nsnp(mgr)
[1] 100
> nscan(mgr)
[1] 20
>
> # get snpID and chromosome
> snpID <- getSnpID(mgr)
> chrom <- getChromosome(mgr)
>
> # get positions only for chromosome 10
> pos10 <- getPosition(mgr, index=(chrom == 10))
>
> # get all snps for first scan
> geno <- getGenotype(mgr, snp=c(1,-1), scan=c(1,1))
>
> # starting at snp 50, get 10 snps for the first 5 scans
> geno <- getGenotype(mgr, snp=c(50,10), scan=c(1,5))
>
>
>
>
>
> dev.off()
null device
1
>