This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Variant calling analysis

I am trying to filter a VCF file so that the filtered file has a VAF of less than 50% and a depth of at least 200 for variant supporting bases. The output VCF file should be sorted by chromosome and should retain the VCF header, so that it can be used as input for other tools that accept VCF files.

So far, I have tried running this code using Pandas library, but that only resulted in an empty dataframe.

Could you please let me know what I am doing wrong?

Thank you so much!

I am also attaching the format of my VCF file here.

My input file is in this format

My code snippet

vcf variant-calling wgs

Did you try bcftools view ?

E.g.,

bcftools view -i 'INFO/AF < 0.5 & FORMAT/DP >= 200' input.vcf > filtered.vcf

Or, use SnpEff

java -jar snpEff/SnpSift.jar filter "(AF < 0.5) & (DP >= 200)" input.vcf > filtered.vcf

Note: This is just an example I did not test the command myself.

There must be tools which would do the job easily, but I was just wondering if I could do that using Python.

There are already Python packages for that, as an example cyvcf2

0 answers

No answers yet.

Log in to answer this question.