How to find the mean inter-marker distance between SNPs from a vcf file?
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 ?
• 2,865 views
•
link
1 answer
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
• 0 views
•
link
Log in to answer this question.