Converts a dosage matrix (rows = variants, columns = samples) to a SeqArray GDS file via a temporary VCF with a DS FORMAT field. The resulting GDS can be passed directly to GMMAT::SMMAT() via the gds.fn argument with is.dosage = TRUE.

write_dosage_gds(dosage_mat, variant_info, sample_ids, gds_path)

Arguments

dosage_mat

Numeric matrix; rows = variants, columns = samples. Values should be in \([0, 2]\).

variant_info

Data frame with columns chrom, pos, ref, alt (one row per variant in the same order as rows of dosage_mat). Returned directly by ancestry_split.

sample_ids

Character vector of sample identifiers, length equal to ncol(dosage_mat).

gds_path

Output file path for the GDS file (e.g. "afr.gds").

Value

Invisibly returns gds_path.

Examples

vcf <- system.file("extdata", "toy.vcf.gz", package = "lantern")
msp <- system.file("extdata", "toy.msp.tsv", package = "lantern")
split <- ancestry_split(vcf, msp, mode = "haplotype", chrom = "chr19",
                        verbose = FALSE)
afr_gds <- tempfile(fileext = ".gds")
write_dosage_gds(split$AFR, split$variant_info, split$sample_ids, afr_gds)
unlink(afr_gds)