I have a several VCFs which are VCF which only contain information by chromosome. That is, there's a chromosome 1 VCF (with only chr1), a chromosome 2 VCF (with only chr2), etc.
I checked to make sure that these VCFs were valid via VCFtools, i.e.
$ vcf-validator chr1.vcf
which works---these are valid VCFs I was given.
Now, I would like to combine these VCFs into one VCF.
I naïvely tried the following cat operation:
$ cat chr1.vcf chr2.vcf chr3.vcf ... chrX.vcf > total_chroms.vcf
This doesn't work properly though
$ vcf-validator total_chroms.vcf
The header tag 'contig' not present for CHROM=chr1. (Not required but highly recommended.)
Could not parse the line, wrong number of columns: [##fileformat=VCFv4.2\n]
at /path/vcftools-0.1.14/perl/Vcf.pm line 172, <__ANONIO__> line 191016.
Vcf::throw('Vcf4_2=HASH(0x1ae7208)', 'Could not parse the line, wrong number of columns: [##filefor...') called at /path/vcftools-0.1.14/perl/Vcf.pm line 335
Vcf::next_data_array('Vcf4_2=HASH(0x1ae7208)') called at /path/vcftools-0.1.14/perl/Vcf.pm line 3457
Vcf4_1::next_data_array('Vcf4_2=HASH(0x1ae7208)') called at /path/vcftools-0.1.14/perl/Vcf.pm line 2574
VcfReader::run_validation('Vcf4_2=HASH(0x1ae7208)') called at /path/vcftools-0.1.14//bin/vcf-validator line 60
main::do_validation('HASH(0x16ada68)') called at /path/vcftools-0.1.14//bin/vcf-validator line 14
$
What tools are available to merge these VCF's together into a total VCF?
vcf-validator chr1.vcfshows no problems. I believe the output ofbcftools concat -o chroms12.vcf chr1.vcf chr2.vcfshows an error:FIXME: sequence name chr1 in chr1.vcf– ShanZhengYang Jan 15 '18 at 03:27chr1in the CHROM field for some rows, but no corresponding line in the header. Can you check if that is true in thechr1.vcffile? Maybe the validator somehow is missing this error? – juod Jan 15 '18 at 15:09#CHROM POS ID REF ALT QUAL FILTER INFO– ShanZhengYang Jan 15 '18 at 19:06##contig=<ID=20,length=62435964,assembly=B36,md5=f126cdf8a6e0c7f379d618ff66beb2da,species="Homo sapiens",taxonomy=x>– Bioathlete Jan 16 '18 at 00:58##contig=<ID=chr1,length=248956422>, etc. to the VCFs in question? I would just take the chromosome lengths from hg38 – ShanZhengYang Jan 16 '18 at 02:05