前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >bcftools其实很好用

bcftools其实很好用

作者头像
用户7625144
发布2020-10-27 10:08:08
1.4K0
发布2020-10-27 10:08:08
举报
文章被收录于专栏:生信开发者

*bcftools filter

*Filter variants per region (in this example, print out only variants mapped to chr1 and chr2)

bcftools filter -r1,2 ALL.chip.omni_broad_sanger_combined.20140818.snps.genotypes.hg38.vcf.gz

*printing out info for only 2 samples:

bcftools view -s NA20818,NA20819 filename.vcf.gz

*printing stats only for variants passing the filter:

bcftools view -f PASS filename.vcf.gz

*printing variants withoud header:

bcftools view -H

*printing variants on a particular region:

bcftools view -r chr20:1-200000 -s NA20818,NA20819 filename.vcf.gz

*print all variants except for the ones falling within region:

bcftools view -t ^chr20:1-30000000 ex_bams.samtools.20161231.vcf.gz >out.vcf

*view the positions passed in a file (accepted files are .vcf and .bed):

bcftools view -R 0002.vcf in.vcf.gz

*view the positions passed in a tsv file:

bcftools view -R 0002.tsv in.vcf.gz

# The format of 0002.tsv:

20 79000 80000

20 90000 100000

*printing out only the chr info:

bcftools query -f '%CHROM\n' filename.vcf

/

*now, print out the chr\tpos

bcftools query -f '%CHROM\t%POS\n' filename.vcf

/

*now, print out the AF INFO field

bcftools query -f '%INFO/AF\n'

/

#getting a particular annotation from the VCF

bcftools query -f '%QUAL\n' 0002.vcf

/

#printing chr pos and a particular annotation from a VCF:

bcftools query -f '%CHROM\t%POS\t%INFO/DP\n' in.vcf.gz

/

#printing out the sets assigned by GATK CombineVariants

~/bin/bcftools-1.6/bcftools query -f '%set\n' out_combine.vcf.gz |sort |uniq

/

0#printing a list of samples from a VCF:

bcftools query -l test.vcf

/

#also, the FORMAT annotations can be obtained by:

~/bin/bcftools/bcftools query -f '[%GT]\n' ../0002.vcf |wc -l #the GT in this case

/

*selecting snps from file:

~/bin/bcftools/bcftools view -v snps lc_bams.bcftools.20170319.NA12878.vcf.gz

/

*selecting the variants from a VCF (excluding 0|0 genotypes)

bcftools view -c1 input.vcf

/

*selecting the non-variants from a VCF(AC=0)

bcftools view -H -C0 concat.allchrs.sites.vcf.gz

/

#filtering:

/

#using one of the INFO annotations (IDV)

bcftools filter -sFilterName -e'IDV<5' input.vcf

/

#OR logical operator:

bcftools filter -sFilterName -e'DP>50000 | IDV<9' input.vcf

/

#filtering on FORMAT annotation:

bcftools filter -sFilterName -e'FORMAT/DP<5' input.vcf

/

#filtering on INFO annotation:

bcftools filter -sFilterName -e'INFO/DP<5' input.vcf

/

#printing out variants that pass the filter:

~/bin/bcftools/bcftools view -f.,PASS lc_bams.bcftools.20170411.exc.norm.SNP.filtered.vcf.gz

/

#bcftools stats and filtering:

~/bin/bcftools/bcftools stats -f "PASS,." file.vcf

/

#select only biallelic (excluding multiallelic) snps

bcftools view -m2 -M2 -v snps input.vcf.gz

/

#select only the multiallelic snps

bcftools view -m3 -v snps input.vcf.gz

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-10-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 生信开发者 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档