Tag Archives: gatk vcf

gatk: How to Merge vcf Files

001. Test data

[root@PC1 test]# ls                            ## test data
seg1_1.vcf seg1_2.vcf seg1_3.vcf
[root@PC1 test]# ll - h
total 1 .2G
 -rw-r--r--. 1 root root 392M Dec   1  18 : 14 seg1_1.vcf
 -rw-r--r--. 1 root root 410M Dec   1  18 : 15 seg1_2.vcf
 -rw -r--r--. 1 root root 386M Dec   1  18 : 14 seg1_3.vcf

 

 

002. Merge vcf files

g atk MergeVcfs -I seg1_1.vcf -I seg1_2.vcf -I seg1_3.vcf -O xxx.vcf ## merge command

 

The combined result is as follows:

[root@PC1 test]# ls
seg1_1.vcf seg1_2.vcf seg1_3.vcf xxx.vcf xxx.vcf.idx
[root@PC1 test]# ll - h 
total 2 .4G
 -rw-r--r--. 1 root root 392M Dec   1  18 : 14 seg1_1.vcf
 -rw-r--r--. 1 root root 410M Dec   1  18 : 15 seg1_2.vcf
 -rw-r--r--. 1 root root 386M Dec   1  18 : 14 seg1_3.vcf
 -rw-r--r--. 1 root root 1 .2G Dec   1  19 : 16 xxx.vcf
 -rw-r--r--. 1 root root 6.2K Dec   1  19 : 16 xxx.vcf.idx

 

 

003. Generate a list of vcf files that need to be merged

[root@PC1 test]# ls
seg1_1.vcf seg1_2.vcf seg1_3.vcf vcf.list
[root@PC1 test]# cat vcf.list ## Vcf list file to be merged
seg1_1.vcf
seg1_2.vcf
seg1_3.vcf
[root@PC1 test]# java -jar /home/software/picard/picard.jar MergeVcfs I=vcf.list O=xxx.vcf ## merge command

 

 

004. Merge result

[root@PC1 test]# ls
seg1_1.vcf seg1_2.vcf seg1_3.vcf vcf.list xxx.vcf xxx.vcf.idx
[root@PC1 test]# ll - h 
total 2 .4G
 -rw-r--r--. 1 root root 392M Dec   1  18 : 14 seg1_1.vcf
 -rw-r--r--. 1 root root 410M Dec   1  18 : 15 seg1_2.vcf
 -rw-r--r--. 1 root root 386M Dec   1  18 : 14 seg1_3.vcf
 -rw-r--r--. 1 root root    33 Dec   1  19 : 24 vcf .list
 -rw-r--r--. 1 root root 1.2G Dec   1  19 : 24 xxx.vcf
 -rw-r--r--. 1 root root 6 .2K Dec   1  19 : 24 xxx.vcf.idx