LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

bcftools

Variant calling and VCF/BCF file manipulation

TLDR

View a VCF/BCF file
$ bcftools view [input.vcf.gz]
copy
Filter variants by region
$ bcftools view -r [chr1:1000000-2000000] [input.vcf.gz]
copy
Convert VCF to BCF
$ bcftools view -Ob -o [output.bcf] [input.vcf.gz]
copy
Call variants from aligned reads
$ bcftools mpileup -f [reference.fa] [aligned.bam] | bcftools call -mv -Oz -o [calls.vcf.gz]
copy
Merge multiple VCF files
$ bcftools merge [file1.vcf.gz] [file2.vcf.gz] -Oz -o [merged.vcf.gz]
copy
Filter variants by quality
$ bcftools filter -i 'QUAL>30 && DP>10' [input.vcf.gz] -Oz -o [filtered.vcf.gz]
copy
Extract sample genotypes
$ bcftools query -f '%CHROM\t%POS\t%REF\t%ALT[\t%GT]\n' [input.vcf.gz]
copy
Index a VCF/BCF file
$ bcftools index [input.vcf.gz]
copy

SYNOPSIS

bcftools subcommand [options] [file]

DESCRIPTION

bcftools is a suite of utilities for variant calling and manipulating files in the Variant Call Format (VCF) and its binary counterpart BCF. It is part of the SAMtools/HTSlib project and is widely used in bioinformatics for genomic variant analysis.All commands work transparently with both VCF and BCF files, compressed or uncompressed. The tools are designed to work in pipelines, reading from stdin and writing to stdout.

PARAMETERS

-Ob

Output compressed BCF
-Oz
Output compressed VCF (bgzipped)
-Ov
Output uncompressed VCF
-Ou
Output uncompressed BCF (fastest for piping)
-r region
Restrict to comma-separated regions (chr:from-to format), requires an index
-R file
Restrict to regions listed in a file (VCF, BED, or tab-delimited)
-t region
Restrict to targets, streamed without an index
-T file
Restrict to targets listed in a file
-s samples
Comma-separated list of samples to include (prefix ^ to exclude)
-S file
Read the sample list from a file
--threads int
Number of extra worker threads used for output compression
-W, --write-index [fmt]
Automatically index the output (tbi or csi)
-i expression
Include sites matching filter expression
-e expression
Exclude sites matching filter expression
-o file
Output file name

SUBCOMMANDS

Variant Calling

mpileup, call
File Operations
view, merge, concat, sort, index, convert
Filtering & Querying
filter, query, norm
Statistics
stats, roh, gtcheck
Annotation
annotate, csq, fill-tags
Manipulation
reheader, isec, head, cnv, polysomy
Consensus
consensus
Plugins
plugin (e.g. +split, +scatter, +fill-tags, +setGT)

INSTALL

sudo apt install bcftools
copy
sudo dnf install bcftools
copy
yay -S bcftools
copy
sudo zypper install bcftools
copy
brew install bcftools
copy
nix profile install nixpkgs#bcftools
copy

CAVEATS

Use -Ou when piping between bcftools subcommands to avoid unnecessary compression overhead. Indexed files are required for random access and some operations. VCF/BCF files should be sorted by chromosome and position for most operations.

HISTORY

bcftools was developed as part of the SAMtools project, initially created by Heng Li at the Wellcome Sanger Institute. It became a separate project around 2014 with the HTSlib library rewrite, gaining significant functionality for variant analysis.

SEE ALSO

samtools(1), tabix(1), bgzip(1), vcftools(1)

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid