Question: How to find the mean inter-marker distance between SNPs from a vcf file?
0
gravatar for vineethmails
8 months 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 • 357 views
ADD COMMENTlink modified 8 months ago by Pierre Lindenbaum122k • written 8 months ago by vineethmails0
2
gravatar for Pierre Lindenbaum
8 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum122k 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 8 months ago • written 8 months ago by Pierre Lindenbaum122k
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: 542 users visited in the last hour