BEDMatrix {BEDMatrix} | R Documentation |
Create a BEDMatrix Object from a PLINK .bed File
Description
This function constructs a new BEDMatrix
object by mapping the
specified PLINK
.bed file into memory.
Usage
BEDMatrix(path, n = NULL, p = NULL, simple_names = FALSE)
Arguments
path |
Path to the .bed file (with or without extension). |
n |
The number of samples. If |
p |
The number of variants. If |
simple_names |
Whether to simplify the format of the dimension names. If |
Details
.bed files must be accompanied by .fam and .bim files: .fam files contain sample information, and .bim files contain variant information. If the name of the .bed file is plink.bed then the names of the .fam and .bim files have to be plink.fam and plink.bim, respectively. The .fam and .bim files are used to extract the number and names of samples and variants.
For very large .bed files, reading the .fam and .bim files can take a long
time. If n
and p
are provided, these files are not read and
dimnames
have to be provided manually.
Currently, only the variant-major mode of .bed files is supported. PLINK2 "dropped" support for the sample-major mode by automatically converting files in this format to the variant-major mode. Therefore, it is recommended to run files in sample-major mode through PLINK2 first.
Value
A BEDMatrix
object.
See Also
BEDMatrix-package
to learn more about the BEDMatrix
package, BEDMatrix-class
to learn more about the
BEDMatrix
class.
Examples
# Get the path to the example .bed file
path <- system.file("extdata", "example.bed",
package = "BEDMatrix")
# Create a BEDMatrix object the example .bed file
m1 <- BEDMatrix(path)
# Create a BEDMatrix object the example .bed file without loading
# the .fam and .bim files
m2 <- BEDMatrix(path, n = 50, p = 1000)