Backward-compatible 2-population (AFR/EUR) wrapper around ancestry_split (Step 1, mode = "haplotype") and, when write_vcf = TRUE, write_ancestry_gds (Step 2). For K > 2 populations or to keep the split and GDS-writing steps separate, call ancestry_split() and write_ancestry_gds() directly.

ancestry_split_phased(
  vcf_path,
  msp_path,
  out_path,
  chrom = NULL,
  write_vcf = TRUE,
  verbose = TRUE
)

Arguments

vcf_path

Path to phased VCF/BCF file (plain or gzipped). Read with bcftools if it is on PATH (fastest; required for BCF), otherwise with SeqArray. Set options(lantern.vcf_reader = "bcftools") or "seqarray" to force one.

msp_path

Path to RFMix MSP file (plain text or gzipped TSV).

out_path

Output directory for GDS and cache files.

chrom

Chromosome to process (e.g., "chr19" or "19"). If NULL, all chromosomes present in the VCF are used.

write_vcf

Logical; if TRUE, materialize ancestry-specific GDS files via write_ancestry_gds (Step 2).

verbose

Print step-by-step progress messages.

Value

Invisibly, a list with elements:

african

Numeric matrix (variants x samples) of African dosages.

european

Numeric matrix (variants x samples) of European dosages.

variant_info

data.frame with columns chrom, pos, ref, alt.

sample_ids

Character vector of common sample IDs.

tract_info

data.frame of ancestry tracts from the MSP file.

overlap

List of intersection statistics.

vcf_paths

(when write_vcf = TRUE) Named list with african_gds/european_gds paths.

Examples

vcf <- system.file("extdata", "toy.vcf.gz", package = "lantern")
msp <- system.file("extdata", "toy.msp.tsv", package = "lantern")
out_dir <- tempfile()
result <- ancestry_split_phased(vcf, msp, out_path = out_dir,
                                chrom = "chr19", write_vcf = FALSE,
                                verbose = FALSE)
head(result$variant_info)
#>   chrom     pos ref alt
#> 1 chr19 1168394   T   A
#> 2 chr19 1240171   T   C
#> 3 chr19 2252809   A   G
#> 4 chr19 2330989   C   T
#> 5 chr19 2436455   A   G
#> 6 chr19 2459485   C   G
unlink(out_dir, recursive = TRUE)