bed_to_rasbin: Convert a PLINK 1 .bed/.bim/.fam Fileset to .rasbin

View source: R/plink_fast.R

bed_to_rasbinR Documentation

Convert a PLINK 1 .bed/.bim/.fam Fileset to .rasbin

Description

Converts a PLINK 1 binary fileset directly into the chunked .rasbin format, without ever materializing a dense genotype matrix in R. Both the read from .bed and the write to .rasbin are done in fixed-size SNP chunks in C (see src/plink_io.c), so peak memory is O(\text{n\_samples} \times \text{chunk\_snps}) regardless of how many samples or SNPs the fileset contains.

Usage

bed_to_rasbin(bed_path, out_path, chunk_snps = 2000)

Arguments

bed_path

Character. Path to the .bed file. The companion .bim and .fam files are expected alongside it with the same stem (standard PLINK convention, e.g. --bfile prefix).

out_path

Character. Destination path for the .rasbin file. A companion <out_path>.meta.rds is written alongside it holding sample and SNP identifiers, parsed from .fam/.bim.

chunk_snps

Integer. Number of SNPs read from .bed and written to .rasbin per chunk. Only affects peak memory and throughput, not the resulting file. Default 2000, matching geno_to_rasbin's chunk_write_size default.

Details

Only SNP-major .bed files are supported (the only mode any current PLINK version writes). Genotype dosage counts copies of the A1 allele (the fourth column of .bim), matching PLINK's own --recode A / plink2's --export A convention: 2 = homozygous A1, 1 = heterozygous, 0 = homozygous A2, NA = missing.

Unlike geno_to_rasbin (dtype 0, double, 8 bytes/genotype), this writes dtype 1 (int8, 1 byte/genotype) – 8x smaller on disk, though still ~4x larger than .bed's 2-bit packing (see src/rasbin.h for why byte-per-genotype was chosen over bit-packing). Both dtypes are read transparently by rasbin_read_chunk and every ⁠_fast⁠ pipeline function.

Value

Invisibly, the out_path that was written.


RAS documentation built on Nov. 3, 2026, 1:07 a.m.