mergebd: Merge Format 5 binary dosage files

View source: R/mergebd.R

mergebdR Documentation

Merge Format 5 binary dosage files

Description

Merges two or more Format 5 binary dosage files into a single Format 5 output file. The merge type is determined automatically:

Usage

mergebd(bdose_files, bdose_file)

Arguments

bdose_files

Character vector of paths to the input .bdose files. Must contain at least two entries. The companion .bdi file for each is expected at paste0(bdose_files[i], ".bdi").

bdose_file

Path for the output .bdose file. The companion .bdi metadata file is written to paste0(bdose_file, ".bdi").

Details

  • If subject IDs do not overlap across files, a subject merge is performed: the output contains all subjects from every file and the SNPs common to all files.

  • If SNP IDs do not overlap across files, a SNP merge is performed: the output contains all SNPs from every file and the subjects common to all files.

If both subject IDs and SNP IDs overlap across files the merge cannot be performed and an error is returned.

SNPs are identified by chromosome, position, reference allele, and alternate allele.

Value

NULL (invisibly)

Examples

bdfile <- system.file("extdata", "vcf1a.bdose", package = "BinaryDosage")
bdinfo_src <- getbdinfo(bdfile)

# Create two format 5 files with non-overlapping subjects
bdose_a   <- tempfile(fileext = ".bdose")
bdose_b   <- tempfile(fileext = ".bdose")
bdose_tmp <- tempfile(fileext = ".bdose")
updatebd(bdfiles = bdfile, bdose_file = bdose_tmp)
subsetbd(bdfiles    = bdose_tmp,
         bdose_file = bdose_a,
         subjectids = bdinfo_src$samples$sid[1:30])
subsetbd(bdfiles    = bdose_tmp,
         bdose_file = bdose_b,
         subjectids = bdinfo_src$samples$sid[31:60])

bdose_out <- tempfile(fileext = ".bdose")
mergebd(bdose_files = c(bdose_a, bdose_b),
        bdose_file  = bdose_out)

BinaryDosage documentation built on April 30, 2026, 1:09 a.m.