Question: Comparing rsids in two VCF
0
gravatar for BAGeno
3.0 years ago by
BAGeno170
BAGeno170 wrote:

Hi

I have two VCF and I want to find common rsids in those two files. For this purpose I have used grep command by taking list of rsids from one file and running it on other file, but it gave me some extra rsids as well which were not present in the list. I have also used bcftools isec command but it did not give me anything in intersected file. I have also used vcf-isec but it is giving me error of mixed vcf formats. I have checked my files, one file is in v4.1 and other is in v4.2.

Please tell me what should I do to find common rsids in both files?

rsid vcf • 917 views
ADD COMMENTlink modified 3.0 years ago by Pierre Lindenbaum128k • written 3.0 years ago by BAGeno170

Since you haven't showed what you did to extract rs ids but said you extracted with grep, following will work to find common rs ids in two files

  • prepare 2 files containing rs ids from 2 input files

    grep -Fwf file1_rs_ids.txt file2_rs_ids.txt

P.S: Please post what you have tried so it would be easy to direct you towards a solution.

ADD REPLYlink modified 3.0 years ago • written 3.0 years ago by venu6.6k

How about bedtools intersect function?

http://bedtools.readthedocs.io/en/latest/content/tools/intersect.html

ADD REPLYlink modified 3.0 years ago • written 3.0 years ago by cpad011213k
1
gravatar for Pierre Lindenbaum
3.0 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum128k wrote:

use comm:

comm  \
  <(cat input1.vcf | grep -v "^#" | cut -f 3 | sort | uniq)  \
  <(cat input2.vcf | grep -v "^#" | cut -f 3 | sort | uniq)

will produce 3 columns: rs uniq to file1, rs uniq to file2, rs common to both files.

ADD COMMENTlink modified 3.0 years ago • written 3.0 years ago by Pierre Lindenbaum128k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1587 users visited in the last hour