Skip to content

Commit 43d954e

Browse files
committed
Add flexibility to FILTER column transfers
Allow transfers within the same file, across files, and in combination: # transfer FILTER column to INFO tag NewTag; notice that the -a option is not present, therefore # B.bcf/FILTER is the source annotation bcftools annotate -c INFO/NewTag:=FILTER B.bcf # transfer FILTER column from A.bcf to INFO/NewTag in B.bcf; notice that the -a option is present, # therefore A.bcf/FILTER is the source annotation bcftools annotate -c INFO/NewTag:=FILTER -a A.bcf B.bcf # transfer B.bcf/FILTER column to INFO tag NewTag; notice that although the -a option is present, # the notation "./FILTER" tells the program to transfer the annotation locally and make B.bcf/FILTER # the source annotation bcftools annotate -c INFO/NewTag:=./FILTER -a A.bcf B.bcf # transfer B.bcf/FILTER column to INFO/NewTag, then A.bcf/FILTER to B.bcf/FILTER bcftools annotate -c INFO/NewTag:=./FILTER,FILTER -a A.bcf B.bcf # transfer A.bcf/FILTER to B.bcf/FILTER, then the new B.bcf/FILTER value to INFO/NewTag; notice # that due to the order of operation, FILTER and INFO/NewTag will be identical bcftools annotate -c FILTER,INFO/NewTag:=./FILTER -a A.bcf B.bcf Resolves #1187 (comment) #1187 (comment)
1 parent 752ce93 commit 43d954e

File tree

12 files changed

+133
-11
lines changed

12 files changed

+133
-11
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Changes affecting specific commands:
2121
- Fix `bcftools annotate --mark-sites`, VCF sites overlapping regions in a BED file
2222
were not annotated (#1989)
2323

24+
- Add flexibility to FILTER column transfers and allow transfers within the same file,
25+
across files, and in combination. For examples see
26+
http://samtools.github.io/bcftools/howtos/annotate.html#transfer_filter_to_info
27+
2428
* bcftools call
2529

2630
- Output MIN_DP rather than MinDP in gVCF mode

doc/bcftools.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ Add or remove annotations.
542542
# that INFO/END is already present in the VCF header.
543543
bcftools annotate -a annots.tab.gz -c CHROM,POS,~ID,REF,ALT,INFO/END input.vcf
544544

545-
# For more examples see http://samtools.github.io/bcftools/howtos/annotate.html
545+
# For (many) more examples see http://samtools.github.io/bcftools/howtos/annotate.html
546546
----
547547

548548

test/annotate19.1.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
##FILTER=<ID=PASS,Description="All filters passed">
33
##contig=<ID=1,assembly=b37,length=249250621>
44
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
5+
##FILTER=<ID=ori_filter,Description="Test">
56
##INFO=<ID=ID,Number=1,Type=String,Description="Transferred ID column">
67
##INFO=<ID=INFO_ID,Number=1,Type=String,Description="Test">
78
#CHROM POS ID REF ALT QUAL FILTER INFO
8-
1 3000001 id_id;info_id C T . . ID=id_id;INFO_ID=info_id
9+
1 3000001 id_id;info_id C T . ori_filter ID=id_id;INFO_ID=info_id

test/annotate19.2.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
##FILTER=<ID=PASS,Description="All filters passed">
33
##contig=<ID=1,assembly=b37,length=249250621>
44
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
5+
##FILTER=<ID=ori_filter,Description="Test">
56
##FILTER=<ID=filter_filter,Description="Test">
67
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
78
##INFO=<ID=INFO_FILTER,Number=1,Type=String,Description="Test">

test/annotate19.3.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
##fileformat=VCFv4.1
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##contig=<ID=1,assembly=b37,length=249250621>
4+
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
5+
##FILTER=<ID=ori_filter,Description="Test">
6+
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
7+
##INFO=<ID=INFO_FILTER,Number=1,Type=String,Description="Test">
8+
#CHROM POS ID REF ALT QUAL FILTER INFO
9+
1 3000001 ori_id C T . ori_filter FILTER=filter_filter;INFO_FILTER=info_filter

test/annotate19.4.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
##fileformat=VCFv4.1
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##contig=<ID=1,assembly=b37,length=249250621>
4+
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
5+
##FILTER=<ID=ori_filter,Description="Test">
6+
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
7+
#CHROM POS ID REF ALT QUAL FILTER INFO
8+
1 3000001 ori_id C T . ori_filter FILTER=ori_filter

test/annotate19.5.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
##fileformat=VCFv4.1
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##contig=<ID=1,assembly=b37,length=249250621>
4+
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
5+
##FILTER=<ID=ori_filter,Description="Test">
6+
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
7+
#CHROM POS ID REF ALT QUAL FILTER INFO
8+
1 3000001 ori_id C T . ori_filter FILTER=filter_filter

test/annotate19.6.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
##fileformat=VCFv4.1
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##contig=<ID=1,assembly=b37,length=249250621>
4+
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
5+
##FILTER=<ID=ori_filter,Description="Test">
6+
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
7+
##FILTER=<ID=filter_filter,Description="Test">
8+
#CHROM POS ID REF ALT QUAL FILTER INFO
9+
1 3000001 ori_id C T . filter_filter FILTER=ori_filter

test/annotate19.7.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
##fileformat=VCFv4.1
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##contig=<ID=1,assembly=b37,length=249250621>
4+
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
5+
##FILTER=<ID=ori_filter,Description="Test">
6+
##FILTER=<ID=filter_filter,Description="Test">
7+
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
8+
#CHROM POS ID REF ALT QUAL FILTER INFO
9+
1 3000001 ori_id C T . filter_filter FILTER=filter_filter

test/annotate19.dst.vcf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
##fileformat=VCFv4.1
22
##contig=<ID=1,assembly=b37,length=249250621>
33
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
4+
##FILTER=<ID=ori_filter,Description="Test">
45
#CHROM POS ID REF ALT QUAL FILTER INFO
5-
1 3000001 ori_id C T . . .
6+
1 3000001 ori_id C T . ori_filter .

0 commit comments

Comments
 (0)