HaploVar defines local haplotypes and is designed to be used as part of a GWAS or genomic selection pipeline. HaploVar takes a VCF file and a LD matrix, calculates local haplotypes, identifies haplotype variants and formats the output to be compatible with a wide range of GWAS and genomic selection tools. Halotypes improve the ability of GWAS to detect QTLs and increase the trait prediction accuracy of genomic selection studies.
When using HaploVar, please cite the following publication.
MacNish, T. R., Al-Mamun, H. A., Bergmann, T., Bestry, M. S., Marsh, J. I., & Edwards, D. (2025). HaploVar: An R package for defining local haplotype variants for trait association and trait prediction analyses. Bioinformatics, 41(12), btaf602. https://doi.org/10.1093/bioinformatics/btaf602
HaploVar can be installed using the following code:
#Install the development version from github
install.packages("devtools")
# devtools::install_github("TessaMacNish/HaploVar")
install.packages("HaploVar", repos = c('https://tessamacnish.r-universe.dev', 'https://cloud.r-project.org'))
#or install directly from CRAN
install.packages("HaploVar")
library(HaploVar)
For a tutorial on how to use HaploVar please refer to introduction This tutorial describes how and when to use each function. Each parameter is explained, and example code is provided.
There is now a Nextflow pipline to help you run HaploVar. This pipeline will prepare the VCF for you and give you the final haplotype file. For example the pipeline will calculate the linkage disequilibrium matrices for you. Please access the Nextflow pipeline here.
An example of a HaploVar workflow for preparing for genomic prediction is below:
plink --allow-extra-chr --r2 square --vcf vcf --out output.ld
crosshap has an inbuilt function for this purpose (Marsh et al. 2023).install.packages("crosshap")
library(crosshap)
VCF <- read_vcf("vcf")
LD <- read_LD("output.ld",vcf = VCF)
haplotype_list <- define_haplotypes(VCF, LD, epsilon = 0.8)
format3 <- haplotype_variants(VCF, LD, epsilon = 0.8, format = 3)
write.csv(format3, "output.csv", row.names=TRUE, quote = FALSE )
NOTE: If you want to prepare haplotype variants for GWAS instead of genomic selection change format to equal 6 and save the data with the following code:
write.table(format6, "output.vcf", sep = "\t", row.names = FALSE, col.names = TRUE, quote = FALSE)
Clayton D. snpStats: SnpMatrix and XSnpMatrix classes and methods. R pack-age version 1.59.2. 2025. https://bioconductor.org/packages/snpStats
Marsh JI, Petereit J, Johnston BA et al. crosshap: R package for local haplotype visualization for trait association analysis. Bioinformatics 2023;39. https://doi.org/10.1093/bioinformatics/btad518
Purcell S, Neale B, Todd-Brown K et al. PLINK: A tool set for whole-genome association and population-based linkage analyses. Am J Hum Genet 2007;81:559–575. https://doi.org/10.1086/519795