R/write_ancestry_gds.R
write_dosage_gds.RdConverts 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)Numeric matrix; rows = variants, columns = samples. Values should be in \([0, 2]\).
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.
Character vector of sample identifiers, length equal to
ncol(dosage_mat).
Output file path for the GDS file (e.g. "afr.gds").
Invisibly returns gds_path.
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)