How to find the mean inter-marker distance between SNPs from a vcf file?
1
0
Entering edit mode
3.8 years ago

I have got a vcf file with only SNPs as variants. How can i find the average distance between SNPs and the largest gap between two SNPs ?

vcf SNP • 1.7k views
ADD COMMENT
5
Entering edit mode
3.8 years ago
awk 'BEGIN{C="";P=-1;M=0;T=0.0;N=0;} /^#/{next} {if(C==$1) {L=int($2)-P;T+=L;N++;M=(M>L?M:L);}C=$1;P=int($2);}END{if(N>0) printf("avg=%f max=%d\n",T/N,M);}' in.vcf

with:

C = prev contig
P = prev position
M = max length
T=  total length
N= num variants
L = current distance
ADD COMMENT

Login before adding your answer.

Traffic: 898 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