A tool to merge VCF files that have the exact same number of (data) rows, chromosomes, positions, and ref/alt alleles. It takes a list of "genotying" VCF files from STDIN and outputs plain-text VCF, consisting of the first VCF file in the list, with sample columns from all the other VCF files appended.
Caution: This only works if all VCF files have the exact same CHROM
, POS
, ID
, REF
, and ALT
columns. You can enforce these checks using the --check
option, at a slight performance cost. The command will fail if the number of data rows is not exactly the same in all files.
- Install Rust.
git clone https://github.com/magnusmanske/merge_gt_vcf.git
RUSTFLAGS="-C target-cpu=native" cargo build --release
# Get help
merge_gt_vcf --help
# For plain-text VCF:
merge_gt_vcf < FILE_WITH_VCF_FILENAMES > OUTPUT.vcf
# For bgzipped VCF:
merge_gt_vcf --bgzip < FILE_WITH_VCF_FILENAMES > OUTPUT.vcf.gz
# or, if samtools is installed:
merge_gt_vcf < FILE_WITH_VCF_FILENAMES | bgzip > OUTPUT.vcf.gz
# For plain-text VCF with CROM/POS/ID/REF/ALT checks:
merge_gt_vcf --check < FILE_WITH_VCF_FILENAMES > OUTPUT.vcf
# For plain-text VCF with few VCF input files and/or few CPU cores:
merge_gt_vcf --serial < FILE_WITH_VCF_FILENAMES > OUTPUT.vcf