This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to calculate distribution of SNP-Indel/complex events distances from a vcf

Hi All,

Hope you are safe and well!

I'm currently filtering vcf (non-human) and want to remove SNPs that are very near to indels and complex events, as these are usually considered spurious.

Rather than using an arbitrary cutoff, id like to choose one based on the empirical distribution of SNP-indel distances. Does anyone have an efficient way to calculate the distance to the nearest Indel or complex event (in bp) for each SNP in a VCF?

Thanks in advance!

Sean

snp vcf filter

1 answer

convert the INDEL vcf to bed using bcftools

convert the SNP vcf to bed using bcftools

use "bedtools closest" to select the coordinates of the SNPS close to an INDEL .

remove the resulting bed from the original vcf using bcftools.

Thanks for your suggestion. I can see that 'bedtools closest' will do the job, but looking at the bcftools manual, I don't see a direct way to go from VCF to bed. Am I missing something?

I don't see a direct way to go from VCF to bed

bcftools view -O u --types snps in.vcf | bcftools query -f '%CHROM\t%POS0\t%END\n' > snps.bed

Log in to answer this question.