【Bcftools】合并不同sample的vcf文件,通过bcftools

通过GATK calling出来的SNP如果使用UnifiedGenotype获得的SNP文件是分sample的,但是如果使用vcftools或者ANGSD则需要Vcf文件是multi-sample的,这里就需要我们将不同samples的文件进行合并,可以通过vcftools的perl模块进行,但是这种方式对perl的要求较高,且操作比较复杂,这里我们选择使用Bcftools,操作简便。

 

分三步:

 

  1. 将vcf进行压缩,批量压缩的方法:
bgzip -c -f -@ 10 merge.vcf > merge.vcf.gz

-c, --stdout            write on standard output, keep original files unchanged
-f, --force             overwrite files without asking
-@, --threads INT       number of compression threads to use [1]

 

2. 对生成的vcf.gz进行index:

bcftools index [options] <in.bcf>|<in.vcf.gz>

-t, --tbi            generate TBI-format index for VCF files

 

3.合并操作:

bcftools merge [options] <A.vcf.gz> <B.vcf.gz> [...]

-m, --merge <string>               allow multiallelic records for <snps|indels|both|all|none|id>, see man page for details [both]
-o, --output <file>                write output to a file [standard output]
-O, --output-type <b|u|z|v>        'b' compressed BCF; 'u' uncompressed BCF; 'z' compressed VCF; 'v' uncompressed VCF [v]
-l, --file-list <file>             read file names from the file

 

posted @ 2018-07-13 15:07  xjce  阅读(8299)  评论(0编辑  收藏  举报