forked from samtools/bcftools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbcftools.txt
937 lines (677 loc) · 32.1 KB
/
bcftools.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
// This is asciidoc template for the bcftools man page and html.
// Please do not modify bcftools.1 or bcftools.html directly,
// edit this file and convert using the following commands:
//
// a2x --doctype manpage --format manpage bcftools.txt
// a2x --doctype manpage --format xhtml bcftools.txt
//
bcftools(1)
===========
:doctype: manpage
NAME
----
bcftools - utilities for variant calling and manipulating VCFs and BCFs
SYNOPSIS
--------
*bcftools* ['COMMAND'] ['OPTIONS']
DESCRIPTION
-----------
Bcftools is a set of utilities that manipulate variant calls in the Variant
Call Format (VCF) and its binary counterpart BCF. All commands work
transparently with both VCFs and BCFs, both uncompressed and BGZF-compressed.
Bcftools is designed to work on a stream. It regards an input file "-" as the
standard input (stdin) and outputs to the standard output (stdout). Several
commands can thus be combined with Unix pipes.
LIST OF COMMANDS
----------------
For a full list of available commands, run *bcftools* without arguments. For a full
list of available options, run *bcftools* 'COMMAND' without arguments.
- *index* .. index VCF/BCF
- *<<annotate,annotate>>* .. edit VCF files, add or remove annotations, apply user plugins
- *<<call,call>>* .. SNP/indel calling (former "view")
- *<<filter,filter>>* .. filter VCF/BCF files using fixed thresholds
- *<<gtcheck,gtcheck>>* .. check sample concordance, detect sample swaps and contamination
- *<<isec,isec>>* .. intersections of VCF/BCF files
- *<<merge,merge>>* .. merge VCF/BCF files to create multi-sample file
- *<<norm,norm>>* .. normalize indels
- *<<query,query>>* .. transform VCF/BCF into user-defined formats
- *<<roh,roh>>* .. identify runs of homo/auto-zygosity
- *<<stats,stats>>* .. produce VCF/BCF stats (former vcfcheck)
- *<<view,view>>* .. subset, filter and convert VCF and BCF files
- *<<plot-vcfstats,plot-vcfstats>>* .. plots the output of *<<stats,stats>>*
OPTIONS
-------
[[common_options]]
=== Common Options
'FILE'::
Files can be both VCF or BCF, uncompressed or BGZF-compressed. The file "-"
is interpreted as standard input. Some tools may require tabix- or
CSI-indexed files.
*-c, --collapse* 'snps'|'indels'|'both'|'all'|'some'|'none'::
Controls how to treat records with duplicate positions and defines compatible
records across multiple input files. Here by "compatible" we mean records which
should be considered as identical by the tools. For example, when performing
line intersections, the desire may be to consider as identical all sites with
matching positions (*bcftools isec -c* 'all'), or only sites with matching variant
type (*bcftools isec -c* 'snps'{nbsp} *-c* 'indels'), or only sites with all alleles
identical (*bcftools isec -c* 'none').
'none';;
only records with identical REF and ALT alleles are compatible
'some';;
only records where some subset of ALT alleles match are compatible
'all';;
all records are compatible, regardless of whether the ALT alleles
match or not. In the case of records with the same position, only
the first will be considered and appear on output.
'snps';;
any SNP records are compatible, regardless of whether the ALT
alleles match or not. For duplicate positions, only the first SNP
record will be considered and appear on output.
'indels';;
all indel records are compatible, regardless of whether the REF
and ALT alleles match or not. For duplicate positions, only the
first indel record will be considered and appear on output.
'both';;
abbreviation of "*-c* 'indels'{nbsp} *-c* 'snps'"
*-f, --apply-filters* 'LIST'::
Skip sites where FILTER column does not contain any of the strings listed
in 'LIST'. For example, to include only sites which have no filters set,
use *-f* '.,PASS'.
*-O, --output-type* 'b'|'u'|'z'|'v'::
Output compressed BCF ('b'), uncompressed BCF ('u'), compressed VCF ('z'), uncompressed VCF ('v').
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
Regions can be specified either on command line or in a VCF, BED, or
tab-delimited file (the default). The columns of the tab-delimited file
are: CHROM, POS, and, optionally, POS_TO, where positions are 1-based
and inclusive. Uncompressed files are stored in memory, while
bgzip-compressed and tabix-indexed region files are streamed. Note that
sequence names must match exactly, "chr20" is not the same as "20". This
option requires indexed VCF/BCF files.
*-s, --samples* 'LIST'|':FILE'::
Comma-separated list of samples to include or, when prefixed with colon
':', read sample names from 'FILE' with one sample per line.
The command *<<call,bcftools call>>* accepts an optional second
column indicating ploidy (0, 1 or 2) and can parse also PED files.
With *<<call,bcftools call>> -C* 'trio', PED file is expected.
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
Same as *-r, --regions*, but the next position is accessed by streaming the
whole VCF/BCF rather than using the tbi/csi index. Both *-r* and *-t* options
can be applied simultaneously: *-r* uses the index to jump to a region
and *-t* discards positions which are not in the targets. Another difference
between the two is that *-r* checks both start and end positions of indels,
whereas *-t* checks start positions only. With the call *-C* 'alleles' command,
third column of the targets file must be comma-separated list of alleles,
starting with the reference allele. Such a file can be easily created from
a VCF with:
----
bcftools query -f'%CHROM\t%POS\t%REF,%ALT\n' file.vcf
----
[[annotate]]
=== bcftools annotate '[OPTIONS]' 'FILE'
This command allows to add or remove annotations and apply user-written plugins.
*-a, --annotations* 'file'::
Bgzip-compressed and tabix-indexed file with annotations. The file
can be VCF, BED, or a tab-delimited file with mandatory columns CHROM, POS
(or, alternatively, FROM, TO), optional columns REF and ALT, and arbitrary
number of annotation columns. In case of tab-delimited file, the
coordinates POS, FROM and TO are one-based and inclusive.
When REF and ALT are present, only matching VCF records will be annotated.
When multiple ALT alleles are present in the annotation file (given as
comma-separated list of alleles), at least one must match one of the
alleles in the corresponding VCF record.
See also *-c, --columns* and *-h, --header-lines*.
*-c, --columns* 'list'::
Comma-separated list of columns present in the annotation file and defined
in the header file (see also *-a, --annotations* and *-h, --header-lines*).
INFO tags can be written both as INFO/TAG or simply TAG. Unused columns can
be indicated by '-'. For example:
----
CHROM,FROM,TO,REF,ALT,-,INFO/TAG
----
*-h, --header-lines* 'file'::
Header lines to appended to the VCF header.
*-l, --list-plugins*::
List of available plugins. The BCFTOOLS_PLUGINS environment variable tells
the program which directories to search:
missing2ref;; Sets missing genotypes ("./.") to ref allele ("0/0").
fill-AN-AC;; Fills INFO fields AN and AC.
*-O, --output-type* 'b'|'u'|'z'|'v'::
see *<<common_options,Common Options>>*
*-p, --plugins* 'name'[,...]::
Comma-separated list of plugins to run. The BCFTOOLS_PLUGINS environment
variable tells the program which directories to search.
See the examples in plugins/\*.c coming with this distribution for further
details and examples. See *-l, --list-plugins* to get a list of installed
plugins.
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-R, --remove* 'list'::
List of annotations to remove. Use 'FILTER' to remove all filters or
'FILTER/SomeFilter' to remove a specific filter. More examples:
----
ID,INFO/DP,FORMAT/DP
----
[[call]]
=== bcftools call '[OPTIONS]' 'FILE'
This command replaces the former *bcftools view* caller. Some of the original
functionality has been temporarily lost in the process of transition under
http://github.com/samtools/htslib[htslib], but will be added back on popular
demand. The original calling model can be invoked with the *-c* option.
==== File format options:
*-O, --output-type* 'b'|'u'|'z'|'v'::
see *<<common_options,Common Options>>*
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-s, --samples* 'FILE'|'LIST'::
see *<<common_options,Common Options>>*
==== Input/output options:
*-A, --keep-alts*::
output all alternate alleles present in the alignments even if they do not
appear in any of the genotypes
*-M, --keep-masked-ref*::
output sites where REF allele is N
*-S, --skip* 'snps'|'indels'::
skip indel/SNP sites
*-v, --variants-only*::
output variant sites only
==== Consensus/variant calling options:
*-c, --consensus-caller*::
the original *samtools*/*bcftools* calling method (conflicts with *-m*)
*-C, --constrain* 'alleles'|'trio'::
'alleles';;
call genotypes given alleles. See also *-t, --targets*.
'trio';;
call genotypes given the father-mother-child constraint. See also
*-s, --samples* and *-n, --novel-rate*.
*-m, --multiallelic-caller*::
alternative modelfor multiallelic and rare-variant calling designed to
overcome known limitations in *-c* calling model (conflicts with *-c*)
*-n, --novel-rate* 'float'[,...]::
likelihood of novel mutation for constrained *-C* 'trio' calling. The trio
genotype calling maximizes likelihood of a particular combination of
genotypes for father, mother and the child
P(F=i,M=j,C=k) = P(unconstrained) * Pn + P(constrained) * (1-Pn).
By providing three values, the mutation rate Pn is set explictly for SNPs,
deletions and insertions, respectively. If two values are given, the first
is interpreted as the mutation rate of SNPs and the second is used to
calculate the mutation rate of indels according to their length as
Pn='float'*exp(-a-b*len), where a=22.8689, b=0.2994 for insertions and
a=21.9313, b=0.2856 for deletions [pubmed:23975140]. If only one value is
given, the same mutation rate Pn is used for SNPs and indels.
*-p, --pval-threshold* 'float'::
with *-c*, accept variant if P(ref|D) < 'float'. With *-m*, accept another ALT allele if P(chi^2)>=1-'float'
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-X, --chromosome-X*::
haploid output for male samples (requires PED file with *-s*)
*-Y, --chromosome-Y*::
haploid output for males and skips females (requires PED file with *-s*)
[[filter]]
=== bcftools filter '[OPTIONS]' 'FILE'
Apply fixed-threshold filters.
*-e, --exclude* 'EXPRESSION'::
exclude sites for which 'EXPRESSION' is true. For valid expressions see
*<<expressions,EXPRESSIONS>>*.
*-g, --SnpGap* 'INT'::
filter SNPs within 'INT' base pairs of an indel. The following example
demonstrates the logic of *--SnpGap* '3' applied on a deletion and
an insertion:
----
The SNPs at positions 1 and 7 are filtered, positions 0 and 8 are not:
0123456789
ref .G.GT..G..
del .A.G-..A..
Here the positions 1 and 6 are filtered, 0 and 7 are not:
0123-456789
ref .G.G-..G..
ins .A.GT..A..
----
*-G, --IndelGap* 'INT'::
filter clusters of indels separated by 'INT' or fewer base pairs allowing
only one to pass. The following example demonstrates the logic of
*--IndelGap* '2' applied on a deletion and an insertion:
----
The second indel is filtered:
012345678901
ref .GT.GT..GT..
del .G-.G-..G-..
And similarly here, the second is filtered:
01 23 456 78
ref .A-.A-..A-..
ins .AT.AT..AT..
----
*-i, --include* 'EXPRESSION'::
include only sites for which 'EXPRESSION' is true. For valid expressions see
*<<expressions,EXPRESSIONS>>*.
*-m, --mode* '+'|'x'::
what to do with the existing FILTER annotations: use '+' for appending
to FILTER instead of replacing the existing annotations, and 'x' to
reset filters at sites which pass.
*-O, --output-type* 'b'|'u'|'z'|'v'::
see *<<common_options,Common Options>>*
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-s, --soft-filter* 'STRING'|'+'::
annotate FILTER column with 'STRING' or, with '+', a unique filter name generated
by the program ("Filter%d").
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
[[gtcheck]]
=== bcftools gtcheck ['OPTIONS'] [*-g* 'genotypes.vcf.gz'] 'query.vcf.gz'
Checks sample identity or, without *-g*, multi-sample cross-check is performed.
*-a, --all-sites*::
output for all sites
*-g, --genotypes* 'genotypes.vcf.gz'::
reference genotypes to compare against
*-G, --GTs-only* 'INT'::
ignore PLs, use GTs, setting 'INT' for the unseen genotypes
*-H, --homs-only*::
consider only genotypes which are homozygous in both 'genotypes' and
'query' VCF. This may be useful with low coverage data.
*-p, --plot* 'PREFIX'::
produce plots
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-s, --query-sample* 'STRING'::
query sample in 'query.vcf.gz'. By default, the first sample is checked.
*-S, --target-sample* 'STRING'::
target sample in the *-g* file, used only for plotting, not for analysis
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
==== Output files format:
CN;;
This field lists pairwise discordance for all possible sample pairs.
It is calculated as
----
\sum_s { min_{G} \{ PL_i + PL_j \} },
----
;;
where the sum is over all sites 's' and genotype 'G' is selected
to maximize likelihood for samples 'i' and 'j'. When PL field is not
present, a constant value '99' is used for the unseen genotypes.
With *-G*, the value '1' can be used instead, the discordance value
then gives exactly the number of differing genotypes.
[[index]]
=== bcftools index ['OPTIONS'] '<in.bcf>|<in.vcf.gz>'
Creates index for bgzip compressed VCF/BCF files for random access. Note
that the old tabix (.tbi) index can be invoked by setting -m0. Otherwise
the new coordinate-sorted (.csi) index is created.
*-f, --force*::
overwrite index if it already exists
*-m, --min-shift 'INT'*::
set the minimal interval size to 1<<INT; default: 14
[[isec]]
=== bcftools isec ['OPTIONS'] 'A.vcf.gz' 'B.vcf.gz' [...]
Creates intersections, unions and complements of VCF files. Depending
on the options, the program can output records from one (or more) files
which have (or do not have) corresponding records with the same position
in the other files.
*-c, --collapse* 'snps'|'indels'|'both'|'all'|'some'|'none'::
see *<<common_options,Common Options>>*
*-C, --complement*::
output positions present only in the first file but missing in the others
*-f, --apply-filters* 'LIST'::
see *<<common_options,Common Options>>*
*-n, --nfiles* \[+-=]'INT'::
output positions present in this many (=), this many or more (+), or this
many or fewer (-) files
*-O, --output-type* 'b'|'u'|'z'|'v'::
see *<<common_options,Common Options>>*
*-p, --prefix* 'DIR'::
if given, subset each of the input files accordingly. See also *-w*.
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-w, --write* 'LIST'::
list of input files to output given as 1-based indices. With *-p* and no
*-w*, all files are written.
==== Examples:
Create intersection and complements of two sets saving the output in dir/*
----
bcftools isec -p dir A.vcf.gz B.vcf.gz
----
Extract and write records from A shared by both A and B using exact allele match
----
bcftools isec -p dir -n=2 -w1 A.vcf.gz B.vcf.gz
----
Extract records private to A or B comparing by position only
----
bcftools isec -p dir -n-1 -c all A.vcf.gz B.vcf.gz
----
[[merge]]
=== bcftools merge ['OPTIONS'] 'A.vcf.gz' 'B.vcf.gz' [...]
Merge multiple VCF or BCF files to create one multi-sample file. For example,
when merging file 'A.vcf.gz' containing samples 'S1', 'S2' and 'S3' and file
'B.vcf.gz' containing samples 'S3' and 'S4', the output file will contain
four samples named 'S1', 'S2', 'S3', '2:S3' and 'S4'.
Note that it is responsibility of the user to ensure that the sample names are
unique across all files. If they are not, the program will create a unique
sample name by prepending index of the file as it appeared on the command line
to the conflicting sample name (see '2:S3' in the above example). Sample names
can be also given explicitly using the *--print-header* and
*--use-header* options.
*--use-header* 'FILE'::
use the VCF header in the provided text 'FILE'
*--print-header*::
print only merged header and exit
*-f, --apply-filters* 'LIST'::
see *<<common_options,Common Options>>*
*-i, --info-rules* '-'|'TAG:METHOD'[,...]::
Rules for merging INFO fields (scalars or vectors) or '-' to disable the
default rules. 'METHOD' is one of 'sum', 'avg', 'min', 'max', 'join'.
*-m, --merge* 'snps'|'indels'|'both'|'all'|'none'::
Defines merging behaviour, similar to *-c, --collapse*. For example, to
prevent merging of SNPs and indels into one record, use *-m* 'both'. To
prevent creation of multi-allelic records altogether, use *-m* 'none'.
*-O, --output-type* 'b'|'u'|'z'|'v'::
see *<<common_options,Common Options>>*
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
[[norm]]
=== bcftools norm ['OPTIONS'] *-f* 'ref.fa' 'file.vcf.gz'
Left-align and normalize indels.
*-D, --remove-duplicates*::
remove duplicate lines of the same type
*-f, --fasta-ref* 'FILE'::
reference sequence
*-O, --output-type* 'b'|'u'|'z'|'v'::
see *<<common_options,Common Options>>*
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-w, --win* 'INT','INT'::
alignment window and buffer window [50,1000]
[[query]]
=== bcftools query ['OPTIONS'] 'file.vcf.gz' ['file.vcf.gz' [...]]
Extracts fields from VCF or BCF files and outputs them in user-defined format.
*-a, --annots* 'LIST'::
alias for -f '%CHROM\t%POS\t%MASK\t%REF\t%ALT\t%TYPE\t' and tab-separated
'LIST' of tags
*-c, --collapse* 'snps'|'indels'|'both'|'all'|'some'|'none'::
see *<<common_options,Common Options>>*
*-f, --format* 'FORMAT'::
learn by example, see below
*-H, --print-header*::
print header
*-l, --list-samples*::
list sample names and exit
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-s, --samples* 'LIST'|':FILE'::
see *<<common_options,Common Options>>*
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-v, --vcf-list* 'FILE'::
process multiple VCFs listed in the file
==== Format:
%CHROM The CHROM column (similarly also other columns, such as POS, ID, QUAL, etc.)
%INFO/TAG Any tag in the INFO column
%TYPE Variant type (REF, SNP, MNP, INDEL, OTHER)
%MASK Indicates presence of the site in other files (with multiple files)
%TAG{INT} Curly brackets to subscript vectors (0-based)
[] The brackets loop over all samples
%GT Genotype (e.g. 0/1)
%TGT Translated genotype (e.g. C/A)
%LINE Prints the whole line
%SAMPLE Sample name
==== Examples:
bcftools query -f '%CHROM\t%POS\t%REF\t%ALT[\t%SAMPLE=%GT]\n' file.vcf.gz
[[roh]]
=== bcftools roh 'OPTIONS' 'FILE'
A program for detecting runs of homo/autozygosity.
==== The HMM model:
--------------------------------------
Notation:
D = Data, AZ = autozygosity, HW = Hardy-Weinberg (non-autozygosity),
f = non-ref allele frequency
Emission probabilities:
oAZ = P_i(D|AZ) = (1-f)*P(D|RR) + f*P(D|AA)
oHW = P_i(D|HW) = (1-f)^2 * P(D|RR) + f^2 * P(D|AA) + 2*f*(1-f)*P(D|RA)
Transition probabilities:
tAZ = P(AZ|HW) .. from HW to AZ, the -a parameter
tHW = P(HW|AZ) .. from AZ to HW, the -H parameter
P(AZ|AZ) = 1 - P(HW|AZ) = 1 - tHW
P(HW|HW) = 1 - P(AZ|HW) = 1 - tAZ
ci = P_i(C) .. probability of cross-over at site i, from genetic map
AZi = P_i(AZ) .. probability of site i being AZ/non-AZ, scaled so that AZi+HWi = 1
HWi = P_i(HW)
P_{i+1}(AZ) = oAZ * max[(1-tHW) * (1-ci) * AZ{i-1} , tAZ * ci * (1-AZ{i-1})]
P_{i+1}(HW) = oHW * max[(1-tAZ) * (1-ci) * (1-AZ{i-1}) , tHW * ci * AZ{i-1}]
--------------------------------------
==== General Options:
*-b, --biallelic-sites*::
skip multi-allelic sites, consider only bi-allelic sites
*-e, --estimate-AF* 'all'|'subset'::
recalculate INFO/AC and INFO/AN on the fly, using either all samples
('all') or samples specified via the *-s* option ('subset'). By default,
allele frequency is estimated from AC and AN counts which are already
present in the INFO field.
*-F, --AF-tag* 'TAG'|':FILE'::
use the specified INFO tag 'TAG' as an allele frequency estimate
instead of the defaul AC and AN tags. Optionally, if prefixed with ':',
allele frequencies will be read from a tab-delimited file containing
the columns: CHROM\tPOS\tREF,ALT\tAF. The file can be compressed with
*bgzip* and indexed with tabix -s1 -b2 -e2. Sites which do not have the
'TAG' or are not present in the 'FILE' or have different reference or
alternate allele will be skipped.
*-f, --fwd-bwd*::
run forward-backward algorithm instead of Viterbi
*-G, --GTs-only* 'FLOAT'::
use genotypes (FORMAT/GT fields) ignoring genotype likelihoods (FORMAT/PL),
setting PL of unseen genotypes to 'FLOAT'. Safe value to use is 30 to
account for GT errors.
*-I, --skip-indels*::
skip indels as their genotypes are usually enriched for errors
*-m, --genetic-map* 'FILE'::
genetic map in the format required also by IMPUTE2. Only the first and
third column are used (position and Genetic_Map(cM)). The 'FILE' can
be a single file or a file mask, where string "{CHROM}" is replaced with
chromosome name.
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-s, --samples* 'LIST'|':FILE'::
see *<<common_options,Common Options>>*
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-w, --win* 'INT'::
maximum number of sites to keep in memory
==== HMM Options:
*-a, --hw-to-az* 'FLOAT'::
P(AZ|HW) transition probability from AZ (autozygous) to HW (Hardy-Weinberg) state
*-H, --az-to-hw* 'FLOAT'::
P(HW|AZ) transition probability from HW to AZ state
[[stats]]
=== bcftools stats 'OPTIONS' 'A.vcf.gz' ['B.vcf.gz']
Parses VCF or BCF and produces text file stats which is suitable for machine
processing and can be plotted using *<<plot-vcfstats,plot-vcfstats>>*. When two files are given,
the program generates separate stats for intersection and the complements.
*-1, --1st-allele-only*::
consider only 1st allele at multiallelic sites
*-c, --collapse* 'snps'|'indels'|'both'|'all'|'some'|'none'::
see *<<common_options,Common Options>>*
*-d, --depth* 'INT','INT','INT'::
ranges of depth distribution: min, max, and size of the bin
*--debug*::
produce verbose per-site and per-sample output
*-e, --exons* 'file.gz'::
tab-delimited file with exons for indel frameshifts statistics. The columns
of the file are CHR, FROM, TO, with 1-based, inclusive, positions. The file
is BGZF-compressed and indexed with tabix
----
tabix -s1 -b2 -e3 file.gz
----
*-f, --apply-filters* 'LIST'::
see *<<common_options,Common Options>>*
*-F, --fasta-ref* 'ref.fa'::
faidx indexed reference sequence file to determine INDEL context
*-i, --split-by-ID*::
collect stats separately for sites which have the ID column set ("known
sites") or which do not have the ID column set ("novel sites").
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-s, --samples* 'LIST'|':FILE'::
see *<<common_options,Common Options>>*
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
[[view]]
=== bcftools view 'OPTIONS' 'file.vcf.gz' ['REGION' [...]]
View, subset and filter VCF or BCF files by position and filtering expression.
Convert between VCF and BCF. Former *bcftools subset*.
==== Output options
*-G, --drop-genotypes*::
drop individual genotype information (after subsetting if *-s* option is set)
*-h, --header-only*::
output the VCF header only
*-H, --no-header*::
suppress the header in VCF output
*-l, --compression-level* ['0-9']::
compression level. 0 stands for uncompressed, 1 for best speed and 9 for
best compression.
*-O, --output-type* 'b'|'u'|'z'|'v'::
see *<<common_options,Common Options>>*
*-o, --output-file* 'FILE':
output file name. If not present, the default is to print to standard output (stdout).
*-r, --regions* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
*-t, --targets* 'file'|'chr'|'chr:pos'|'chr:from-to'|'chr:from-'[,...]::
see *<<common_options,Common Options>>*
==== Subset options:
*-a, --trim-alt-alleles*::
trim alternate alleles not seen in subset. Type A, G and R INFO and FORMAT fields will also be trimmed
*-I, --no-update*::
do not (re)calculate INFO fields for the subset (currently INFO/AC and INFO/AN)
*-s, --samples* 'FILE'|'LIST'::
see *<<common_options,Common Options>>*
==== Filter options:
*-c, --min-ac* 'INT'[':nref'|':alt1'|':minor']::
minimum allele count (INFO/AC) of sites to be printed. Specifying the
type of allele is optional and can be set to non-reference ('nref', the
default), 1st alternate ('alt1') or minor ('minor') alleles.
*-C, --max-ac* 'INT'[':nref'|':alt1'|':minor']::
maximum allele count (INFO/AC) of sites to be printed. Specifying the
type of allele is optional and can be set to non-reference ('nref', the
default), 1st alternate ('alt1') or minor ('minor') alleles.
*-e, --exclude* 'EXPRESSION'::
exclude sites for which 'EXPRESSION' is true. For valid expressions see
*<<expressions,EXPRESSIONS>>*.
*-f, --apply-filters* 'LIST'::
see *<<common_options,Common Options>>*
*-i, --include* 'EXPRESSION'::
include sites for which 'EXPRESSION' is true. For valid expressions see
*<<expressions,EXPRESSIONS>>*.
*-k, --known*::
print known sites only (ID column is not ".")
*-m, --min-alleles* 'INT'::
print sites with at least 'INT' alleles listed in REF and ALT columns
*-M, --max-alleles* 'INT'::
print sites with at most 'INT' alleles listed in REF and ALT columns
*-n, --novel*::
print novel sites only (ID column is ".")
*-p, --phased*::
print sites where not all samples are phased. Haploid genotypes are
considered phased. Missing genotypes considered unphased unless the
phased bit is set.
*-P, --exclude-phased*::
exclude sites where not all samples are phased
*-q, --min-af* 'FLOAT'[':nref'|':alt1'|':minor']::
minimum allele frequency (INFO/AC / INFO/AN) of sites to be printed.
Specifying the type of allele is optional and can be set to non-reference
('nref', the default), 1st alternate ('alt1') or minor ('minor') alleles.
*-Q, --max-af* 'FLOAT'[':nref'|':alt1'|':minor']::
maximum allele frequency (INFO/AC / INFO/AN) of sites to be printed.
Specifying the type of allele is optional and can be set to non-reference
('nref', the default), 1st alternate ('alt1') or minor ('minor') alleles.
*-u, --uncalled*::
print sites without a called genotype
*-U, --exclude-uncalled*::
exclude sites without a called genotype
*-v, --types* 'snps'|'indels'|'mnps'|'other'::
comma-separated list of variant types to select
*-V, --exclude-types* 'snps'|'indels'|'mnps'|'other'::
comma-separated list of variant types to exclude
*-x, --private*::
print sites where only the subset samples carry an non-reference allele
*-X, --exclude-private*::
exclude sites where only the subset samples carry an non-reference allele
[[plot-vcfstats]]
=== plot-vcfstats 'OPTIONS' 'file.vchk' [...]
Script for processing output of *<<stats,bcftools stats>>*. It can merge
results from multiple outputs (useful when running the stats for each
chromosome separately), plots graphs and creates a PDF presentation.
*-m, --merge*::
Merge vcfstats files to STDOUT, skip plotting.
*-p, --prefix* 'PATH'::
The output files prefix, add a slash to create new directory.
*-P, --no-PDF*::
Skip the PDF creation step.
*-r, --rasterize*::
Rasterize PDF images for faster rendering.
*-s, --sample-names*::
Use sample names for xticks rather than numeric IDs.
*-t, --title* 'STRING'::
Identify files by these titles in plots. The option can be given multiple
times, for each ID in the *<<stats,bcftools stats>>* output. If not
present, the script will use abbreviated source file names for the titles.
*-T, --main-title* 'STRING'::
Main title for the PDF.
[[expressions]]
EXPRESSIONS
-----------
These filtering expressions are accepted by *<<filter,filter>>* and
*<<view,view>>* commands.
.Valid expressions may contain:
arithmetic perators: ::
+, *, -, /
logical operators: ::
&& (same as &), || (same as |)
comparison operators: ::
== (same as =), >, >=, <=, <, !=
parentheses: ::
(, )
array subscripts to access vector subfields: ::
e.g. AC[0]
double quotes for string values: ::
e.g. %FILTER="PASS"
'1' (or '0') for testing the presence (or absence) of a flag: ::
e.g. FlagA=1 && FlagB=0
'TAG' or INFO/'TAG' for INFO fields: ::
e.g. DP<800 or INFO/DP<800
%'COLUMN' for column names (not all columns are supported yet): ::
e.g. %QUAL>10 && %FILTER="PASS"
%TYPE for testing variant type ('indel', 'snp', 'mnp', 'other'): ::
e.g. %TYPE="snp"
%'FUNC'('TAG') where 'FUNC' is one of 'MAX', 'MIN', 'AVG' and 'TAG' is one of the FORMAT fields: ::
e.g. %MIN(DP)>10 && %MIN(DV)>3
A few more examples:
%TYPE="snp" && %QUAL>=10 && (DP4[2]+DP4[3] > 2)
%MIN(DP)>35 && %AVG(GQ)>50
...
PERFORMANCE
-----------
HTSlib was designed with BCF format in mind. When parsing VCF files, all records
are internally converted into BCF representation. Simple operations, like removing
a single column from a VCF file, can be therefore done much faster with standard
UNIX commands, such as *awk* or *cut*.
Therefore it is recommended to use BCF as input/output format whenever possible to avoid
large overhead of the VCF -> BCF -> VCF conversion.
BUGS
----
Please report any bugs you encounter on the github website: <http://github.com/samtools/bcftools>
AUTHORS
-------
Heng Li from the Sanger Institute wrote the original C version of htslib,
samtools and bcftools. Bob Handsaker from the Broad Institute implemented the
BGZF library. Petr Danecek, Shane McCarthy and John Marshall are maintaining
and further developing bcftools. Many other people contributed to the program
and to the file format specifications, both directly and indirectly by
providing patches, testing and reporting bugs. We thank them all.
RESOURCES
---------
Bcftools GitHub website: <http://github.com/samtools/bcftools>
Samtools GitHub website: <http://github.com/samtools/samtools>
HTSlib GitHub website: <http://github.com/samtools/htslib>
File format specifications: <http://samtools.github.io/hts-specs>
Bcftools documentation: <http://samtools.github.io/bcftools>
COPYING
-------
The MIT License. Copyright (c) Genome Research Ltd.