readBED: Read BED file

View source: R/bed.R

readBEDR Documentation

Read BED file

Description

Read a PLINK BED file into a R matrix.

Usage

readBED(pfx, iid = 1, vid = 1, vfr = NULL, vto = NULL, quiet = TRUE)

Arguments

pfx

prefix of PLINK file set, or the fullname of a BED file.

iid

option to read N IID as row names. (def=1, see readIID())

vid

option to read P VID as col names. (def=1, see readVID())

vfr

variant-wise, from where to read? (number/proportion, def=1)

vto

varinat-wise, to where then stop? (number/proportion, def=P)

quiet

suppress screen printing? (def=TRUE)

Details

This is meant for genotype that can fit into system memory; the size of R matrix is 16 times the BED file. To traverse a huge BED several varants at time without loading it entirely into the memoty, see scanBED() and loopBED().

A PLINK1 binary fileset has three files,

pfx.fam:

text table of N individuals.

pfx.bim:

text table of P genomic variants (i.e., SNPs).

pfx.bed:

N x P genotype matrix in condensed binary format.

The three files comprising a genotype data are typically referred by their common prefix, for example, the X chromosome genotype represented by chrX.bed, chrX.fam, and chrX.bim are jointly refered by chrX.

Value

genotype matrix with N row individuals and P column variants.

See Also

readBED

Examples

## read an entire small data
bed <- system.file("extdata", 'm20.bed', package="plinkFile")
gmx <- readBED(bed, quiet=FALSE)

## read part of a large data
bed <- system.file("extdata", '000.bed', package="plinkFile")
U <- readBED(bed, vfr=01, vto=10, quiet=FALSE)
V <- readBED(bed, vfr=11, vto=20, quiet=FALSE)
W <- cbind(U, V)
X <- readBED(bed, vfr=01, vto=20, quiet=FALSE)
all.equal(W, X)


plinkFile documentation built on Nov. 24, 2023, 5:10 p.m.

Related to readBED in plinkFile...