This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Filterout biallelic SNPs from multiple VCF files.

Hi, I have a list of vcf files, one per each individual with the variants called for HLA genes. HLA has a lot of multi allelic SNPs but in this case I need to filter out only the biallelic SNPs, scanning through all vcf files. Is there any specific tool for this?

Ex: sample 1 rs-xx G C sample 1 rs-yy T C sample 2 rs-xx A C sample 2 rs-yy TC. In this case I want to get only rs-yy as the result.

Thanks a lot in advance.

hla vcf bi allelic snp

3 answers

I suggest first merging your VCF files into a single file. Once this is done, there are multiple tools that could do the filtering you require (e.g. vcftools --max-alleles 2)

Thanks a lot. Is merging over 500 samples feasible?

Yes, although htslib is likely to be much faster for such a task.

GATK SelectVariants has a BIALLELIC filter flag:

java -Xmx2g -jar GenomeAnalysisTK.jar -T SelectVariants \
-R human_g1k_v37.fasta \
-o out_biallelic.vcf \
--variant in.vcf \
-restrictAllelesTo BIALLELIC

You could put together a bash script to loop through an array of sample vcf file names and output the separate biallelic VCFs.

Something like:

batch=("sample_1" "sample_2" "sample_3") 
for sample in "${batch[@]}"
do  

     java -Xmx2g -jar GenomeAnalysisTK.jar -T SelectVariants \
     -R human_g1k_v37.fasta \
     -o ${sample}_out_biallelic.vcf \
     --variant ${sample}_in.vcf \
     -restrictAllelesTo BIALLELIC &
done

Is it something like this you want?

awk '/T    C       / {print $0}' file.vcf

Log in to answer this question.