Answers.Body: <p><a href="https://www.biostars.org/p/379586/#379589" rel="nofollow noreferrer" title="Biostars&#39; answer">Answer</a> I received on Biostars that appears to work as expected:</p>
  
  <p><code>bcftools norm -Ob --check-ref wx -f &lt;reference_fasta&gt; &lt;vcf.gz&gt; -o &lt;output_name&gt;</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-14T13:11:20.400Z
Answers.Text: I would throw away this VCF. The command line only fixes obvious issues but you can never be sure to fix everything without understanding the error source. Those remaining issues may bite you and lead to false conclusions.
Answers.UserDisplayName: user172818
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-14T13:16:36.173Z
Answers.Text: While in general I would agree with you, I need the vcf to get started on our analysis. We're working on getting the genotype array calls vcf that does not have the imputed data, and hopefully these issues will not exist in that vcf.
Answers.UserDisplayName: John Rouhana
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-14T13:22:52.907Z
Answers.Text: That chr19 example indicates something deeply wrong with the VCF. This could be due to inconsistent genome versions or low-level bioinformatics errors. The frequency, the alleles and even the positions could be all messed up. bcftools can't fix these for you. You may need to redo all analyses again. Ignoring the errors is not saving time; it is wasting time. Anyway, it is your call.
Answers.UserDisplayName: user172818
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-14T13:09:57.213Z
Answers.LastActivityDate: 2019-05-14T13:22:46.807Z
Answers.LastEditDate: 2019-05-14T13:22:46.807Z
Answers.UserDisplayName: John Rouhana
Body: <p><em>[This question was also asked on <a href="https://www.biostars.org/p/379586" rel="nofollow noreferrer">Biostars</a>]</em></p>
  <p>I received an hg38 VCF file that's had variants imputed with 1000 genomes. I've encountered some issues with the VCF; REF alleles that do not align to a reference genome, ALT alleles that do not appear to be reported anywhere in the literature, and, most recently, variants that flat-out do not align to the human genome (variants on chr19 with bp-pos 100 million+ when the whole chromosome is in the 50 million bp range).</p>
  <p>I've worked out hack-y solutions to most of the issues that I've encountered, but this latest one has been an issue for me. I only detected these variants when I ran VEP and it flagged them as not mapping to the genome. As such, I'm more or less removing these variants one at a time using <code>grep -v</code>. I'd like a solution where I can just remove any variants from the vcf that appear to map to regions that do not exist in the human genome. Bonus points if the solution also encompasses some of the other issues I mentioned, although I think I've already found solutions to those. Is there anything out there that does this?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-14T13:29:36.550Z
Comments.Text: *"ALT alleles that do not appear to be reported anywhere in the literature"*: this isn't necessarily a problem, of course. It's entirely likely that you will find novel variants in any real life sample.
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-14T13:34:07.793Z
Comments.Text: While I do agree with you, I've seen enough issues with the VCF that I'm skeptical of anything 'novel' reported in there. I've taken the conservative route and removed these variants, at least until I can get the original genotyped calls from our collaborator and verify that these calls were truly there.
Comments.UserDisplayName: John Rouhana
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-14T13:38:41.747Z
Comments.Text: Oh sure, depending on what data you expect it might be an issue. I only pointed out it doesn't _have_ to be one. For example, I work with clinical "real world" samples and I expect several hundred, or thousand novel variants with no frequency data, let alone any mention in the literature.
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-07T21:47:10.443Z
Comments.Text: I would return this VCF to whoever gave it to you and ask them why the positions on chromosome 19 aren’t anywhere near the reference positions. There is virtually no point in proceeding with any kind of analysis if you don’t even know whether the positions are correct.
Comments.UserDisplayName: user438383
Tags: <vcf><variant-calling><variation><quality-control>
Title: Remove variants that do not map to human genome
ThreadText: # Remove variants that do not map to human genome
  
  (Asked by: username_0 on 2019-05-14)
  
  *[This question was also asked on [Biostars](https://www.biostars.org/p/379586)]*
  
  I received an hg38 VCF file that's had variants imputed with 1000 genomes. I've encountered some issues with the VCF; REF alleles that do not align to a reference genome, ALT alleles that do not appear to be reported anywhere in the literature, and, most recently, variants that flat-out do not align to the human genome (variants on chr19 with bp-pos 100 million+ when the whole chromosome is in the 50 million bp range).
  
  I've worked out hack-y solutions to most of the issues that I've encountered, but this latest one has been an issue for me. I only detected these variants when I ran VEP and it flagged them as not mapping to the genome. As such, I'm more or less removing these variants one at a time using `grep -v`. I'd like a solution where I can just remove any variants from the vcf that appear to map to regions that do not exist in the human genome. Bonus points if the solution also encompasses some of the other issues I mentioned, although I think I've already found solutions to those. Is there anything out there that does this?
  
  **Tags:** vcf, variant-calling, variation, quality-control
  
  > **Comments:**
  > **username_1**: *"ALT alleles that do not appear to be reported anywhere in the literature"*: this isn't necessarily a problem, of course. It's entirely likely that you will find novel variants in any real life sample.  
  > **username_0**: While I do agree with you, I've seen enough issues with the VCF that I'm skeptical of anything 'novel' reported in there. I've taken the conservative route and removed these variants, at least until I can get the original genotyped calls from our collaborator and verify that these calls were truly there.  
  > **username_1**: Oh sure, depending on what data you expect it might be an issue. I only pointed out it doesn't _have_ to be one. For example, I work with clinical "real world" samples and I expect several hundred, or thousand novel variants with no frequency data, let alone any mention in the literature.  
  > **username_2**: I would return this VCF to whoever gave it to you and ask them why the positions on chromosome 19 aren’t anywhere near the reference positions. There is virtually no point in proceeding with any kind of analysis if you don’t even know whether the positions are correct.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-05-14. Score: 1
  
  [Answer](https://www.biostars.org/p/379586/#379589 "Biostars' answer") I received on Biostars that appears to work as expected:
  
  `bcftools norm -Ob --check-ref wx -f <reference_fasta> <vcf.gz> -o <output_name>`
  
  > **Comments:**
  > **username_3**: I would throw away this VCF. The command line only fixes obvious issues but you can never be sure to fix everything without understanding the error source. Those remaining issues may bite you and lead to false conclusions.  
  > **username_0**: While in general I would agree with you, I need the vcf to get started on our analysis. We're working on getting the genotype array calls vcf that does not have the imputed data, and hopefully these issues will not exist in that vcf.  
  > **username_3**: That chr19 example indicates something deeply wrong with the VCF. This could be due to inconsistent genome versions or low-level bioinformatics errors. The frequency, the alleles and even the positions could be all messed up. bcftools can't fix these for you. You may need to redo all analyses again. Ignoring the errors is not saving time; it is wasting time. Anyway, it is your call.  
  
  ---
  
  