How tessamacnish/haplovar works
Purpose and runtime
HaploVar is an R package for converting SNP genotype data plus linkage disequilibrium (LD) information into local haplotypes and haplotype-variant encodings for GWAS or genomic-selection pipelines. It runs in R as a library package; package exports are defined in NAMESPACE, with package metadata and dependencies in DESCRIPTION.
Input boundary
The pipeline consumes an in-memory VCF-like genotype object and an LD matrix. Example packaged inputs are data/vcf.rda and data/LD.rda; input structure/access is represented by R/vcf.R and R/LD.R. VCF and LD generation/import are external concerns: the README identifies crosshap for reading data and PLINK or snpStats for LD calculation.
Local haplotype definition
R/define_haplotypes.R is the primary local-haplotype entry point. It groups SNPs into haplotypes using the LD matrix and an epsilon threshold. R/collate_define_haplotypes.R is the consolidation stage that assembles or normalizes haplotype definitions into output tables suitable for downstream variant construction.
Global haplotype definition
R/define_haplotypes_globally.R provides an alternate global-definition path, likely applying haplotype logic across the full data scope rather than the standard local workflow. Its result remains a haplotype grouping boundary before genotype/variant encoding.
Haplotype variant construction
R/haplotype_variants.R is the main end-to-end variant-generation entry point: it takes VCF, LD, and haplotype parameters, derives haplotype states, and formats them for downstream analysis. R/collate_haplotype_variants.R performs the assembly/collation stage between haplotype calls and final encoded output.
Global variant path
R/haplotype_variants_global.R parallels the standard variant workflow for globally defined haplotypes. Together with R/define_haplotypes_globally.R, it forms a separate control path for callers needing global rather than local haplotype treatment.
Output boundary and consumers
The principal output is a sample-by-haplotype-variant representation. Format selection in R/haplotype_variants.R supports genomic-selection-oriented output (README example: format 3, saved as CSV) and GWAS-oriented VCF-like output (format 6, tab-delimited). HaploVar itself does not run association or prediction models; those are downstream external pipelines.
Main entry points: vcf.R VCF-like genotypes · LD.R LD matrix · haplotype_variants.R Generate haplotype variants · haplotype_variants_global.R Generate global variants
Components 15
R Package
- Exports
NAMESPACE - Package metadata
DESCRIPTION
Input Boundary
- External genotype / LD tools · crosshap imports genotypes; PLINK or snpStats calculate LD.
- VCF-like genotypes
R/vcf.R - LD matrix
R/LD.R - Example genotypes
data/vcf.rda - Example LD
data/LD.rda
Local Haplotype Path
- Define local haplotypes · Groups SNPs using LD and epsilon.
R/define_haplotypes.R - Collate haplotype definitions
R/collate_define_haplotypes.R - Generate haplotype variants · Main end-to-end local variant entry point.
R/haplotype_variants.R - Collate variant encoding
R/collate_haplotype_variants.R
Global Haplotype Path
- Define global haplotypes
R/define_haplotypes_globally.R - Generate global variants
R/haplotype_variants_global.R
Output & Consumers
- Sample × haplotype variants · Supports genomic-selection CSV and GWAS-oriented VCF-like tabular output.
- GWAS / genomic selection · Association and prediction models run outside HaploVar.
Connections 23
- Exports → Define local haplotypes: exports
- Exports → Generate haplotype variants: exports
- Exports → Define global haplotypes: exports
- Exports → Generate global variants: exports
- External genotype / LD tools → VCF-like genotypes: supplies
- External genotype / LD tools → LD matrix: calculates
- Example genotypes → VCF-like genotypes: example
- Example LD → LD matrix: example
- VCF-like genotypes → Define local haplotypes: genotypes
- LD matrix → Define local haplotypes: LD + epsilon
- Define local haplotypes → Collate haplotype definitions: haplotype calls
- VCF-like genotypes → Generate haplotype variants: genotypes
- LD matrix → Generate haplotype variants: LD
- Collate haplotype definitions → Generate haplotype variants: definitions
- Generate haplotype variants → Collate variant encoding: haplotype states
- Collate variant encoding → Sample × haplotype variants: encoded variants
- VCF-like genotypes → Define global haplotypes: genotypes
- LD matrix → Define global haplotypes: LD
- Define global haplotypes → Generate global variants: global definitions
- VCF-like genotypes → Generate global variants: genotypes
- LD matrix → Generate global variants: LD
- Generate global variants → Sample × haplotype variants: global encoding
- Sample × haplotype variants → GWAS / genomic selection: consumed by