Learn R Programming

plinkFile (version 0.1.0)

scanBED: Scan genotypes in PLINK BED(s)

Description

Go through a BED file set and visit one variant at a time. This is meant for out-of-memory screening of huge genotype, such as a GWAS study.

Usage

scanBED(pfx, FUN, ..., simplify = TRUE)

Value

an array with each row corresponding to a variant if simplify is set to TRUE; otherwise, a list with each element corresponding to a variant is returned.

A context vaiable ".i" is assigned to the environment of FUN, therefore, one can access the index of variant current being processed from within the body of FUN.

Arguments

pfx

prefix of PLINK BED.

FUN

the function to process each variant.

...

additional argument to pass to FUN.

simplify

TRUE to simplify the result as an array.

Details

To read an entire BED into a R matrix, see readBED instead.

A BED (binary biallelic genotype table) is comprised of three files (usually) sharing identical prefix:

  • pfx.fam: table of N typed individuals

  • pfx.bim: table of P typed genomic variants (i.e., SNPs);

  • pfx.bed: genotype matrix of N rows and P columns stored in condensed binary format.

The three files are commonly referred by their common prefix, e.g.:

chrX.bed, chrX.fam, and chrX.bim, are jointly specified by "chrX".

See Also

readBED

Examples

Run this code
pfx <- file.path(system.file("extdata", package="plinkFile"), "000")
ret <- scanBED(pfx, function(g)
{
    af <- mean(g, na.rm=TRUE) / 2
    maf <- min(af, 1 - af)
    c(idx=.i, mu=mean(g, na.rm=TRUE), maf=maf, nas=sum(is.na(g)))
})
print(ret[1:5, ])

Run the code above in your browser using DataLab