I have just properly tested these on the complete VCF, and they work. Can you verify in your own time? - thanks.
Hello everyone, I am trying to use snpsift to annotate my .vcf files using rsid in dbSNP. I am able to do so. But the output file is coming like this: 2 19477 snp_2_19477;rs138566047 Its not updating the id coloumn in .vcf files with rsid. But adding one more coloumn to the file with rsid value. Does anyone has any idea how to modify this?
1 answer
Thanks very much for providing the VCF that you're using. For others, it's
This VCF is corrupt and does not conform to the VCF specification. It has the following issues:
- whitespace in 'INFO' column
- contig '2' not defined in header
- 'FORMAT/GL' should be declared as Number
- 'FORMAT/PP' not defined in header
- 'FORMAT/BD' not defined in header
I was able to fix the VCF with these commands (below). Unfortunately, the 'FORMAT' field is a complete mess, so, I made an 'executive' decision to remove it, leaving just 'FORMAT/GT'. This loses some info, but leaves you with a validated VCF for anything else that you may want to do.
1, remove whitespace from column 8 ('INFO'), then zip via bgzip
zcat GEUVADIS.chr2.PH1PH2_465.IMPFRQFILT_BIALLELIC_PH.annotv2.genotypes.vcf.gz |\
sed 's/ damaging/_damaging/g' |\
bgzip > test.vcf.gz ;
2, tab-index (fixes contig '2' issue)
tabix -p vcf test.vcf.gz ;
3, BCFtools to remove all 'FORMAT' tags except GT
bcftools annotate -x 'FORMAT' --force test.vcf.gz -Oz > test.fixed.vcf.gz ;
This will initially show the warnings relating to 'FORMAT', but the use of --force allows us to skip these warnings. Also, by removing the problematic 'FORMAT' tags, we avoid the subsequent segmentation fault that occurs.
4, BCFtools to remove 'ID' field
bcftools annotate -x ID test.fixed.vcf.gz -Oz > test.fixed.noID.vcf.gz ;
5, SnpSift
java -jar SnpSift.jar annotate dbSnp144.vcf test.fixed.noID.vcf.gz
Kevin
Hello kevin, thank you so much for such a great detail reply.
I am doing this step but its showing error.
the command: bcftools annotate -x 'FORMAT' -force test.vcf.gz -Oz > test.fixed.vcf.g
the error:
annotate: unrecognized option '--force'
Hi, there should be 2 hyphens there: --force (- - force)
Hello kevin, I am writing this command:
bcftools annotate -x 'FORMAT' - - force test.vcf.gz -Oz > test.fixed.vcf.g
but its taking a lot of time. Its been almost 18-20 hours and still the output hasn't been made.
Hey, oh, no, that should be:
bcftools annotate -x 'FORMAT' --force test.vcf.gz -Oz > test.fixed.vcf.gz
hey, when I am using the above command the command:
bcftools annotate -x 'FORMAT' --force test.vcf.gz -Oz > test.fixed.vcf.gz
I am getting an error: annotate: unrecognized option '--force
That is strange. Is --force listed when you just run this:
bcftools annotate
?
Which version are you using? - type bcftools --version
I am using version bcftools 1.9 and htslib 1.9 And also when i use bcftools annotate --format function is not lister
I am using the same version, and --force is listed:
bcftools annotate
About: Annotate and edit VCF/BCF files.
Usage: bcftools annotate [options] <in.vcf.gz>
Options:
-a, --annotations <file> VCF file or tabix-indexed file with annotations: CHR\tPOS[\tVALUE]+
--collapse <string> matching records by <snps|indels|both|all|some|none>, see man page for details [some]
-c, --columns <list> list of columns in the annotation file, e.g. CHROM,POS,REF,ALT,-,INFO/TAG. See man page for details
-e, --exclude <expr> exclude sites for which the expression is true (see man page for details)
--force continue despite parsing error (at your own risk!)
-h, --header-lines <file> lines which should be appended to the VCF header
-I, --set-id [+]<format> set ID column, see man page for details
-i, --include <expr> select sites for which the expression is true (see man page for details)
-k, --keep-sites leave -i/-e sites unchanged instead of discarding them
-l, --merge-logic <tag:type> merge logic for multiple overlapping regions (see man page for details), EXPERIMENTAL
-m, --mark-sites [+-]<tag> add INFO/tag flag to sites which are ("+") or are not ("-") listed in the -a file
--no-version do not append version and command line to the header
-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]
-r, --regions <region> restrict to comma-separated list of regions
-R, --regions-file <file> restrict to regions listed in a file
--rename-chrs <file> rename sequences according to map file: from\tto
-s, --samples [^]<list> comma separated list of samples to annotate (or exclude with "^" prefix)
-S, --samples-file [^]<file> file of samples to annotate (or exclude with "^" prefix)
-x, --remove <list> list of annotations (e.g. ID,INFO/DP,FORMAT/DP,FILTER) to remove (or keep with "^" prefix). See man page for details
--threads <int> number of extra output compression threads [0]
bcftools --version
bcftools 1.9-152-g27033c6
Using htslib 1.9-149-gf5b75ff
Copyright (C) 2018 Genome Research Ltd.
License Expat: The MIT/Expat license
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
In my case its not mentioned.
-a, --annotations <file> VCF file or tabix-indexed file with annotations: CHR\tPOS[\tVALUE]+
--collapse <string> matching records by <snps|indels|both|all|some|none>, see man page for details [some]
-c, --columns <list> list of columns in the annotation file, e.g. CHROM,POS,REF,ALT,-,INFO/TAG. See man page for details
-e, --exclude <expr> exclude sites for which the expression is true (see man page for details)
-h, --header-lines <file> lines which should be appended to the VCF header
-I, --set-id [+]<format> set ID column, see man page for details
-i, --include <expr> select sites for which the expression is true (see man page for details)
-k, --keep-sites leave -i/-e sites unchanged instead of discarding them
-m, --mark-sites [+-]<tag> add INFO/tag flag to sites which are ("+") or are not ("-") listed in the -a file
--no-version do not append version and command line to the header
-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]
-r, --regions <region> restrict to comma-separated list of regions
-R, --regions-file <file> restrict to regions listed in a file
--rename-chrs <file> rename sequences according to map file: from\tto
-s, --samples [^]<list> comma separated list of samples to annotate (or exclude with "^" prefix)
-S, --samples-file [^]<file> file of samples to annotate (or exclude with "^" prefix)
-x, --remove <list> list of annotations (e.g. ID,INFO/DP,FORMAT/DP,FILTER) to remove (or keep with "^" prefix). See man page for details
--threads <int>
Interesting, can you confirm the exact version 1.9 build, basically, please show the output of bcftools --version?
Also, which operating system are you using?
Hey Kevin, its working now. Earlier I use conda to install the software. But that is not working. So I went to bcftools site and downloaded the software. and now when I do bcftools annotate --force option is coming as a parameter. Thank you so much for your help.
I have one question related to earlier step where you are formating the .vcf file. You are removing white space and removing format tags except GT. Is there any specific format for header files for vcf? Also how do we know when is the header file wrong? and how do we modify that so that we do not remove necessary information from .vcf files?
As with many things in bioinformatics, the VCF specification has been misused over the years. Take into account, also, that different programs check for different things when parsing / reading a VCF. For example, we see this in your case, whereby BCFtools encountered warnings and errors when reading your VCF, while SnpSift tolerated these.
You can regard this as the 'ground truth' of what should be in a 'minimal' VCF: https://samtools.github.io/hts-specs/VCFv4.2.pdf
By minimal, we mean the minimum amount of information [and in which format] such that it meets the VCF specification.
In this case, the FORMAT field in your VCF was a complete mess. Not your fault, of course. The information that we eliminated was unimportant, being just the GL, DS, PP, and BD tags. GT is most important.
Oh, regarding the whitespace, we are actually just replacing all instances of ' damaging' with '_damaging'. This was what caused that particular issue.
ohh okay. now i get it. Thank you so much Kevin for helping me out.
Hi kevin, I have one more doubt. When I am annotating vcf file with rsid. some of them are not getting rsid. like this: 4 53498 . A C 100.0 PASS In case of rsid its showing one dot. Should I use some other dbSNP file probably to annotate?
Hi rheab, this is hg19 / GRCh37, right? There is no known SNP at this position; so, you can consider this variant as 'novel' (new). You can check for updated information at UCSC Genome Browser: https://genome.ucsc.edu/cgi-bin/hgTracks?db=hg19&lastVirtModeType=default&lastVirtModeExtraState=&virtModeType=default&virtMode=0&nonVirtPosition=&position=chr4%3A53498%2D53498&hgsid=1135020491_Hv9A4wACeqSQbQINUU3ItFLnaCpA
Log in to answer this question.
Hi, please show:
the command:
I am getting no error. the input file use is .vcf file for chr2.
The output file is:
As you can see the in output file its adding rsid. but its still has previous ID from .vcf file snp_2_10133. What I want is to remove the id from .vcf file and update it to just rsid
I see - thanks. I am not sure that
SnpSift annotatecan do this, but you can first remove the original ID viabcftools, as follows:There is no variant at that position, by the way - all entries are just
0|0(?)I actually just added one part of the input file. 8,-0.48:0.150:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.350:.:. 0|0:-0.48,-0.48,-0.48:0.150:.:. 0|0:-0.48,-0.48,-0.48:0.400:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.050:.:. 0|0:-0.48,-0.48,-0.48:0.150:.:. 0|0:-0.48,-0.48,-0.48:0.250:.:. 0|0:-0.48,-0.48,-0.48:0.100:.:. 0|0:-0.48,-0.48,-0.48:0.150:.:. 0|0:-0.36,-0.41,-0.76:0.250:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.250:.:. 0|0:-0.48,-0.48,-0.48:0.050:.:. 0|0:-0.48,-0.48,-0.48:0.400:.:. 0|0:-0.19,-0.46,-2.06:0.100:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.100:.:. 0|0:-0.48,-0.48,-0.48:0.450:.:. 0|0:-0.48,-0.48,-0.48:0.450:.:. 0|0:-0.48,-0.48,-0.48:0.250:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.250:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.100:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.35,-0.41,-0.78:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.050:.:. 0|0:-0.48,-0.48,-0.48:0.400:.:. 0|0:-0.48,-0.48,-0.48:0.450:.:. 0|1:-2.82,-0.45,-0.19:1.000:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.350:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.150:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 1|0:-2.38,-0.43,-0.20:1.100:.:. 0|0:-0.48,-0.48,-0.48:0.400:.:. 0|0:-0.02,-1.46,-5.00:0.000:.:. 0|0:-0.00,-4.10,-5.00:0.000:.:. 0|0:-0.00,-2.30,-5.00:0.000:.:. 0|1:-2.69,-0.44,-0.20:1.000:.:. 0|0:-0.00,-3.02,-5.00:0.000:.:. 0|0:-0.00,-3.32,-5.00:0.000:.:. 0|0:-0.05,-0.97,-4.22:0.000:.:. 0|0:-0.00,-2.98,-5.00:0.000:.:. 0|0:-0.00,-2.15,-5.00:0.000:.:. 0|0:-0.48,-0.48,-0.48:0.050:.:. 0|0:-0.477139,-0.477113,-0.477113:0.150:.:. 0|0:-0.00,-2.68,-5.00:0.000:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.050:.:. 0|0:-0.48,-0.48,-0.48:0.350:.:. 0|0:-0.48,-0.48,-0.48:0.300:.:. 0|0:-0.48,-0.48,-0.48:0.350:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.48:0.200:.:. 0|0:-0.48,-0.48,-0.4: It has some variants.
I use the above command as mentioned by you. the commands:
Hi again, have you tried to index the VCF as suggested?
Actually, you may need this sequence of commands:
Hi, I use the above command But I am getting error the error:
Please paste the entire header of the file file_chr2.vcf
hint:
bcftools view -h file_chr2.vcfi use the command;
This is the output:
the command:
the output: [W::bcf_hdr_check_sanity] GL should be declared as Number=G [W::vcf_parse] Contig '2' is not defined in the header. (Quick workaround: index the file with tabix.)
fileformat=VCFv4.1
FILTER=<ID=PASS,Description="All filters passed">
INFO=<ID=LDAF,Number=1,Type=Float,Description="MLE Allele Frequency Accounting for LD">
INFO=<ID=AVGPOST,Number=1,Type=Float,Description="Average posterior probability from MaCH/Thunder">
INFO=<ID=RSQ,Number=1,Type=Float,Description="Genotype imputation quality from MaCH/Thunder">
INFO=<ID=ERATE,Number=1,Type=Float,Description="Per-marker Mutation rate from MaCH/Thunder">
INFO=<ID=THETA,Number=1,Type=Float,Description="Per-marker Transition rate from MaCH/Thunder">
INFO=<ID=CIEND,Number=2,Type=Integer,Description="Confidence interval around END for imprecise variants">
INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants">
INFO=<ID=END,Number=1,Type=Integer,Description="End position of the variant described in this record">
[W::vcf_parse_format] FORMAT 'PP' is not defined in the header, assuming Type=String [W::vcf_parse_format] FORMAT 'BD' is not defined in the header, assuming Type=String Encountered error, cannot proceed. Please check the error output above.
Can you please make your file available somewhere so that I can download it and try it myself?
the command: bgzip file_chr2.vcf ; tabix -p vcf file_chr2.vcf.gz ;
the output: unrecognized preset file_chr2.vcf
Sure. this is the link to download the .vcf file for chr2. curl -o $SCRATCH/GEUVADIS/vcf_files/orig_vcfs/GEUVADIS.chr2.genotype.vcf.gz https://www.ebi.ac.uk/arrayexpress/files/E-GEUV-1/GEUVADIS.chr2.PH1PH2_465.IMPFRQFILT_BIALLELIC_PH.annotv2.genotypes.vcf.gz