snp_readBed {bigsnpr} | R Documentation |
Read PLINK files into a "bigSNP"
Description
Functions to read bed/bim/fam files into a bigSNP.
Usage
snp_readBed(bedfile, backingfile = sub_bed(bedfile))
snp_readBed2(
bedfile,
backingfile = sub_bed(bedfile),
ind.row = rows_along(obj.bed),
ind.col = cols_along(obj.bed),
ncores = 1
)
Arguments
bedfile |
Path to file with extension ".bed" to read. You need the corresponding ".bim" and ".fam" in the same directory. |
backingfile |
The path (without extension) for the backing files for the cache of the bigSNP object. Default takes the bedfile without the ".bed" extension. |
ind.row |
An optional vector of the row indices (individuals) that
are used. If not specified, all rows are used. |
ind.col |
An optional vector of the column indices (SNPs) that are used.
If not specified, all columns are used. |
ncores |
Number of cores used. Default doesn't use parallelism. You may use nb_cores. |
Details
For more information on these formats, please visit
PLINK webpage.
For other formats, please use PLINK to convert them in bedfiles,
which require minimal space to store and are faster to read. For example,
to convert from a VCF file, use the --vcf
option. See snp_plinkQC.
Value
The path to the RDS file that stores the bigSNP
object.
Note that this function creates one other file which stores the values of
the Filebacked Big Matrix.
You shouldn't read from PLINK files more than once. Instead, use
snp_attach to load the "bigSNP" object in any R session from backing files.
Examples
(bedfile <- system.file("extdata", "example.bed", package = "bigsnpr"))
# Reading the bedfile and storing the data in temporary directory
rds <- snp_readBed(bedfile, backingfile = tempfile())
# Loading the data from backing files
test <- snp_attach(rds)
str(test)
dim(G <- test$genotypes)
G[1:8, 1:8]