Question: How to find the mean inter-marker distance between SNPs from a vcf file?
0
gravatar for vineethmails
9 weeks ago by
vineethmails0 wrote:

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 ?

snp vcf • 124 views
ADD COMMENTlink modified 9 weeks ago by Pierre Lindenbaum117k • written 9 weeks ago by vineethmails0
2
gravatar for Pierre Lindenbaum
9 weeks ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum117k wrote:
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 COMMENTlink modified 9 weeks ago • written 9 weeks ago by Pierre Lindenbaum117k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1897 users visited in the last hour