Skip to contents

Package overview

Main documentation entry point for LDxBlocks.

LDxBlocks-package LDxBlocks
LDxBlocks: Genome-Wide LD Block Detection and Haplotype Analysis

Main workflows

High-level functions covering the full LDxBlocks pipeline, from genotype input to LD block detection, haplotype construction, and genomic prediction.

run_ldx_pipeline()
End-to-End Haplotype Block Pipeline
run_Big_LD_all_chr()
Genome-Wide LD Block Detection by Chromosome
tune_LD_params()
Auto-Tune LD Block Detection Parameters

Genotype input and backend

Import genotype data from multiple formats and manage the LDxBlocks memory-efficient backend for large genomic datasets.

read_geno()
Read Genotype Data into an LDxBlocks Backend
read_geno_bigmemory()
Open a bigmemory-backed Genotype Store
read_chunk()
Extract a Genotype Slice from an LDxBlocks Backend
prepare_geno()
Prepare Genotype Matrix for LD Computation
close_backend()
Close an LDxBlocks Backend and Release File Handles
print(<LDxBlocks_backend>)
Print Method for LDxBlocks Backend
summary(<LDxBlocks_backend>)
Summary Method for LDxBlocks Backend

LD computation and block detection

Core algorithms for LD estimation, LD decay analysis, and genome-wide LD block segmentation using clique-based and community-detection approaches.

compute_r2()
Compute Standard r^2 LD Matrix
compute_rV2()
Compute Kinship-Adjusted rV^2 LD Matrix
get_V_inv_sqrt()
Compute the Inverse Square Root (Whitening Factor) of a Kinship Matrix
compute_ld_decay()
Compute LD Decay and Chromosome-Specific Decay Distances
plot_ld_decay()
Plot LD Decay Curve
summarise_blocks()
Summarise LD Block Characteristics
plot_ld_blocks()
Plot LD Block Structure Across Chromosomes

Phasing tools

Functions for obtaining gametic phase from WGS data (Beagle) or pre-phased VCF files.

read_phased_vcf()
Read Pre-Phased VCF
phase_with_beagle()
Statistical Phasing via Beagle 5.x

Haplotype construction and diversity

Extract haplotypes within LD blocks, decode nucleotide sequences, compute haplotype diversity statistics, and construct genomic prediction features.

extract_haplotypes()
Extract Haplotype Dosage Strings from LD Blocks
decode_haplotype_strings()
Decode Haplotype Strings to Nucleotide Sequences
compute_haplotype_diversity()
Compute Haplotype Diversity Per Block
build_haplotype_feature_matrix()
Build Haplotype Dosage Matrix for Genomic Prediction
compute_haplotype_grm()
Compute Haplotype-Based Genomic Relationship Matrix
define_qtl_regions()
Map GWAS Hits to LD Blocks (Post-GWAS QTL Region Definition)

Haplotype harmonisation

Harmonise haplotypes across populations, infer diplotypes, and collapse rare alleles into biologically meaningful groups.

infer_block_haplotypes()
Infer Structured Block-Level Diplotypes Per Individual
collapse_haplotypes()
Collapse Rare Haplotype Alleles Into Biologically Meaningful Groups
harmonize_haplotypes()
Harmonize Haplotype Allele Labels Across Panels or Analysis Runs

Haplotype export

Export haplotype dosage matrices and diversity summaries for downstream statistical analyses.

write_haplotype_numeric()
Write Haplotype Feature Matrix as Numeric Dosage Table
write_haplotype_character()
Write Haplotype Character (Nucleotide) Matrix
write_haplotype_diversity()
Write Haplotype Diversity Table

Association and QTL interpretation

Block-level association tests (Q+K mixed model with simpleM multiple-testing correction), diplotype effect decomposition, cross-population effect concordance from haplotype association results (compare_block_effects) or external GWAS tools (compare_gwas_effects), GWAS integration, and epistasis detection.

test_block_haplotypes()
Block-Level Haplotype Association Testing (Q+K Mixed Linear Model with simpleM Multiple-Testing Correction)
estimate_diplotype_effects()
Estimate Diplotype Effects and Dominance Deviations Per LD Block
compare_block_effects()
Cross-Population Haplotype Effect Concordance
compare_gwas_effects()
Cross-Population GWAS Effect Concordance from External Results
integrate_gwas_haplotypes()
Integrate GWAS QTL Regions with Haplotype Prediction Results

Genomic prediction

Haplotype-based genomic prediction following Tong et al. (2024-2025), including GBLUP integration and local GEBV estimation.

prepare_gblup_inputs()
Prepare Genomic Prediction Inputs for External GBLUP Software
run_haplotype_prediction()
Haplotype Prediction and Block Importance from Pre-Adjusted Phenotypes
compute_local_gebv()
Compute Local Haplotype GEBV per Block (Tong et al. 2025)
backsolve_snp_effects()
Backsolve SNP Effects from GEBV (Tong et al. 2025)

Epistasis detection

Within-block pairwise SNP interaction scan (scan_block_epistasis), trans-haplotype between-block epistasis scan (scan_block_by_block_epistasis), and single-block fine-mapping with pairwise or LASSO dispatch (fine_map_epistasis_block). All functions operate on GRM-corrected REML residuals from test_block_haplotypes().

scan_block_epistasis()
Within-Block Pairwise SNP Epistasis Scan
scan_block_by_block_epistasis()
Between-Block Haplotype Allele Epistasis Scan
fine_map_epistasis_block()
Fine-Map Epistatic SNP Pairs Within a Single Block

Breeding decision support

Identify favourable haplotypes and rank LD blocks for haplotype stacking strategies.

rank_haplotype_blocks()
Rank Haplotype Blocks by Evidence Strength
score_favorable_haplotypes()
Score Individual Haplotype Portfolios Against Known Allele Effects
summarize_parent_haplotypes()
Summarise Haplotype Allele Inventory Per Candidate Parent

Population and stability analysis

Compare haplotype distributions across populations and evaluate stability across environments.

compare_haplotype_populations()
Compare Haplotype Allele Frequencies Between Two Population Groups
run_haplotype_stability()
Finlay-Wilkinson Stability Analysis of Haplotype Effects Across Environments
scan_diversity_windows()
Sliding-Window Genome-Wide Diversity Scan
decompose_block_effects()
Decompose Per-SNP Effects into Per-Haplotype-Allele Effect Table
export_candidate_regions()
Export Candidate Gene Regions to BED, CSV, or biomaRt Format

Cross-validation

Evaluate predictive ability of haplotype-based genomic models.

cv_haplotype_prediction()
K-Fold Cross-Validation for Haplotype-Based Genomic Prediction

Visualisation

Plot LD structure and haplotype relationships.

plot_haplotype_network()
Plot a Minimum-Spanning Haplotype Network for One LD Block

Example datasets

Simulated datasets for tutorials and reproducible examples.

ldx_geno
Example Genotype Matrix
ldx_snp_info
Example SNP Information Table
ldx_blocks
Example LD Block Table
ldx_gwas
Example GWAS Marker Table
ldx_blues
Pre-Adjusted Phenotype Means (BLUEs) for Genomic Prediction Examples
ldx_blues_list
Per-Environment BLUEs for Stability Analysis Examples