This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Investigating frequency of multiple SNPs within a txt file

Here I've got a text file containing a list of SNPs called at a particular locus from a set of ~1000 .var files. I'd like to investigate the frequency of each SNP within the file, but have zero knowledge of shell programming or python. I was wondering if someone can help me with this!

snp python shell

Short answer? Get a bioinformatician near you to help you out and observe them, especially the questions they ask. When you're just starting, you're better off with in-person help.

Ram,

Thank you for your reply. I'm just seeking a shell script (or sth similar in python) that I can mess with it to get the job done!

Sth to start with!

I appreciate that - that is a good approach. This will take some time, but I can help you with this. I'll add the rest of my reply to an answer and update it as you progress.

2 answers

First off, I personally prefer shell scripts unless the situation gets complicated. File IO is super easy when you're working on the shell. Can you show me what a .var file looks like? I am not sure which tools generate .var files and I do not wish to assume anything. Just give me the output to this:

head -n 25 <sample.var>

where <sample.var> is any random .var file.

This is where I got so far:

awk '{print $(my target column)}' var.txt | uniq -c

This lists all the variants and their respective frequency per line, but I want their overall frequency.

Ended up with this:

awk -F '\t' '{print$18}' output.txt|sort|uniq -c|sort -nr

Thank you for the moral support Ram and suggesting the shell script

Glad it helped and you got it working. Enjoy the world of shell scripting!

Log in to answer this question.