Entering edit mode
3.7 years ago
Nyksubuz
▴
10
I have a VCF file, and I need to calculate allele frequency for each variant by using code/script, I have the values for AN and AC within the file.
What have you tried on your own? Why do you want to use perl?
Can you give us a list of tools you've looked at that can manipulate VCF files? You've been given this advice before - google as much as you can.
I don't want to use a tool, i want to write a script to do the same
Use a tool. Do not reinvent the wheel. If you insist on scripting it yourself, read the VCF documentation and figure out how to calculate AF from AC and AN.
it is possible to calculate allele frequency by dividing AC/AN, I just need help with writing the script to do the same
What exactly have you tried? Show us your script and where you need help specifically - we are not going to do your homework for you.
first of all its not a home work question, im learning variant analysis, idk why you are getting so offended
I apologize - questions need to be more specific and show that the asker has invested effort in trying to solve things themselves, which this post lacks. Add that and we're all open to helping you.
I did this much, it's pretty long, i need modify it or find any other way to calculate AF
You should replace your
awk
withbcftools query
. That will make this simple.Of course, the above can be used to maybe generate a histogram of AF, not map anything back to any locus, because you're literally just calculating the AF, not storing it in any meaningful way.
ok, thank you, that helps a lot
I tried using grep and awk to extract the vaues from the columns, im stuck with the division of column by column
awk
can do division (see example below). Show us your script and an example where it fails.