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 = NULL,
chrom = NULL,
write_vcf = TRUE,
verbose = TRUE
)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.
Path to RFMix MSP file (plain text or gzipped TSV).
Output directory for the GDS files. Only needed (and
then required) when write_vcf = TRUE.
Chromosome to process (e.g., "chr19" or "19").
If NULL, all chromosomes present in the VCF are used.
Logical; if TRUE, materialize ancestry-specific
GDS files via write_ancestry_gds (Step 2).
Print step-by-step progress messages.
Invisibly, a list with elements:
Numeric matrix (variants x samples) of African dosages.
Numeric matrix (variants x samples) of European dosages.
data.frame with columns chrom, pos, ref, alt.
Character vector of common sample IDs.
data.frame of ancestry tracts from the MSP file.
List of intersection statistics.
(when write_vcf = TRUE) Named list with
african_gds/european_gds paths.
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)