Comparison between two files with chromosomes and positions
1
0
Entering edit mode
2.8 years ago

Hi I am trying to compare two files with chromosome numbers and positions.

For example;

File 1:

I 1000 
I 9009
I 187902

File 2:

I 1080
I 8995
II 578022

I would like to check if the positions of file1 are present in file2 in and around the range of +/- 100 bases and add a third column with "YES/NO".

I tried using awk but i am able to only compare the exact positions.

My output file should look like

I 1080 Yes 
I 8995 Yes
II 578022 No

Any help would be appreciated. Thanks in advance.

AWK • 497 views
ADD COMMENT
0
Entering edit mode
2.8 years ago

convert both file to bed using awk, and sort on chrom/pos e.g.:

awk '{X=100;P=int($2);printf("%s\t%d\t%d\t%s\n",$1,(P<X?0:P-X),P+X,$0);}' input.txt | sort -t $'\t' -k1,1 -k2,2n > sorted1.bed

and then find the intersection using bedtools intersect

ADD COMMENT

Login before adding your answer.

Traffic: 1983 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6