How can I compare two columns of a two VCF files
How can I compare two columns of a VCF file (i.e. chromosome number and position) and return the entire row if both the position and chromosome number match in two diffrent VCF files? The following awk command works to compare one column what changes can I make in it to make it compare two columns together.
awk 'FNR==NR{a[$1]=$0;next}{if(b=a[$1]){print b}}' fileA fileB > out
• 4,966 views
•
link
2 answers
Looks like you want to intersect two VCF files. There's already software to do it and its much cleaner to use them than write a messy one-liner. Check Bedtools intersectBed.
http://bedtools.readthedocs.org/en/latest/content/tools/intersect.html
• 0 views
•
link
Log in to answer this question.
Can you please post an example of the input and desired output? Thanks.
so for example if File A and B are as following the code with match the 1st column (#CHROM) and the 2nd column(POS) and return the output from A which is matching
File A
File B
OUTPUT
Return from which file? FileA or FileB?
May be this vcftools solution will work for you.