Comparing rsids in two VCF
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?
• 2,288 views
•
link
1 answer
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.
• 0 views
•
link
Log in to answer this question.
Since you haven't showed what you did to extract
rsids but said you extracted withgrep, following will work to find commonrsids in two filesprepare 2 files containing
rsids from 2 input filesgrep -Fwf file1_rs_ids.txt file2_rs_ids.txtP.S: Please post what you have tried so it would be easy to direct you towards a solution.
How about bedtools intersect function?
http://bedtools.readthedocs.io/en/latest/content/tools/intersect.html