Diempy: fast and reference-free genome polarization and chromosome painting
Abstrakt
Most ancestry inference methods rely on putatively pure reference panels to define ancestry informative variants. This approach is often unrealistic and can bias inference. The genome polarization algorithm diem, introduced previously by Baird et al., avoids reference panels by jointly inferring the polarity of common allelic states and quantifying variant diagnosticity via an expectation-maximization procedure. Importantly, we use polarization strictly to mean the assignment of alleles to opposing sides of a barrier to gene flow, rather than the assignment of ancestral versus derived states. Here, we present diempy, an efficient python implementation of diem coupled with tools that turn polarized calls into analysis-ready outputs. diempy offers lossless VCF-to-diem BED conversion, ploidy-aware handling of individuals and chromosomes, flexible masking of sites, regions, and individuals, and interactive visualization of polarized genomes, hybrid indices, clines, and ternary plots. Postprocessing functions include thresholding via the diagnostic index, kernel smoothing, and automatic detection and run-length encoding of contiguous ancestry tracts. BED-based I/O facilitates integration with population-genomic workflows (e.g. filtering by annotation or ploidy). These features make reference-panel-free genome polarization with diempy practical and reproducible for studies of population structure, admixture and species barriers.