Answers.Body: <p>I'd advise against using <code>grep</code>, <code>sed</code>, <code>awk</code> for processing vcfs unless you really know what you're doing - there's almost always an easier way using <code>bcftools</code>.</p>
  <p><code>bcftools view -i'ID=@snplist.txt' in.vcf</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-27T12:12:00.847Z
Answers.LastActivityDate: 2022-01-27T12:12:00.847Z
Answers.UserDisplayName: user438383
Body: <p>I have a vcf file containing an ID field with a snps and a list of human SNPs from dbSNP.I want to remove whatever in dbSNP from vcf file. The text file is like this:</p>
  <pre><code>rs978760828
  rs1008829651
  rs1052373574
  rs1326880612
  rs768019142
  rs892501864
  rs1010989343
  rs1489251879
  rs1022805358
  rs1322538365
  </code></pre>
  <p>How to remove the common snps from dbSNP and my vcf?</p>
  
Tags: <vcf><snp><bcftools>
Title: Filtering a vcf with a text file of SNP rsIDs
ThreadText: # Filtering a vcf with a text file of SNP rsIDs
  
  (Asked by: username_0 on 2022-01-27)
  
  I have a vcf file containing an ID field with a snps and a list of human SNPs from dbSNP.I want to remove whatever in dbSNP from vcf file. The text file is like this:
  
  ```
  rs978760828
  rs1008829651
  rs1052373574
  rs1326880612
  rs768019142
  rs892501864
  rs1010989343
  rs1489251879
  rs1022805358
  rs1322538365
  
  ```
  
  How to remove the common snps from dbSNP and my vcf?
  
  **Tags:** vcf, snp, bcftools
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-01-27. Score: 1 | Accepted answer
  
  I'd advise against using `grep`, `sed`, `awk` for processing vcfs unless you really know what you're doing - there's almost always an easier way using `bcftools`.
  
  `bcftools view -i'ID=@snplist.txt' in.vcf`
  
  
  ---
  
  