Takes the list returned by ancestry_split (or the backward-compatible ancestry_split_dosage / ancestry_split_phased output, which has the same per-population matrix + variant_info + sample_ids shape) and writes one GDS file per population via write_dosage_gds, printing progress as it goes. This is Step 2 of the package's Step1/Step2/Step3 workflow: most users only need to call it so they have GDS paths to pass to ancestry_smmat (Step 3); it's exported mainly for standalone use (e.g. caching GDS files between SLURM jobs).

write_ancestry_gds(split_result, out_path, verbose = TRUE)

Arguments

split_result

List as returned by ancestry_split: named per-population dosage matrices plus variant_info and sample_ids.

out_path

Output directory (created if it doesn't exist). One file <population>.gds is written per population.

verbose

Print per-population progress messages.

Value

Named list of GDS file paths, one per population, e.g. list(AFR = "out/AFR.gds", EUR = "out/EUR.gds"). Pass this directly as gds_paths to ancestry_smmat.

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 = "dosage", chrom = "chr19",
                        verbose = FALSE)
out_dir <- tempfile()
gds <- write_ancestry_gds(split, out_dir, verbose = FALSE)
gds   # one GDS file per population
#> $AFR
#> [1] "/tmp/RtmpISWUUu/file3fd665dff227/AFR.gds"
#> 
#> $EUR
#> [1] "/tmp/RtmpISWUUu/file3fd665dff227/EUR.gds"
#> 
unlink(out_dir, recursive = TRUE)