Question: Finding SNPs per gene for SNP Density in UNIX
0
gravatar for crawlthrutacos
3.7 years ago by
United States
crawlthrutacos0 wrote:

I am attempting find out which gene harbors the most variation by using SNP density in a particular isolate. I am at a loss to figure out SNPs per gene, however. There's 445 SNPs present in the isolate with 9 genes. I used VarScan for that. I know their exact lengths but figuring out SNPs per gene is tripping me up. I can supposedly grep for patterns in UNIX (ssh shell) and then use an option to count the number of occurrences, but so far I'm not seeing what command to use/what pattern to grep for.  Can anyone make sense of what grep pattern I'm looking for or lead me to an alternative way of figuring out SNPs per gene in unix...

snp unix grep varscan • 1.6k views
ADD COMMENTlink modified 12 weeks ago by Biostar ♦♦ 20 • written 3.7 years ago by crawlthrutacos0
2
gravatar for Alex Reynolds
2.9 years ago by
Alex Reynolds28k
Seattle, WA USA
Alex Reynolds28k wrote:

Via a combination of BEDOPS vcf2bed conversion and bedmap --count operation:

$ vcf2bed < snps.vcf | bedmap --echo --count --delim '\t' genes.bed - > genes_with_number_of_overlapping_snps.bed

You'll need a file called snps.vcf containing your SNPs, and a sorted file called genes.bed containing gene annotations of interest.

To calculate SNPs per gene, you sum all the counts and divide by the number of genes:

$ awk 'BEGIN { s = 0; } \
             { s += $NF; } \
         END { print (s / NR); }' genes_with_number_of_overlapping_snps.bed
ADD COMMENTlink modified 2.9 years ago • written 2.9 years ago by Alex Reynolds28k
0
gravatar for Irsan
3.7 years ago by
Irsan6.9k
Amsterdam
Irsan6.9k wrote:
I guess you have a table/text file containing the information you need but not in the snp per gene format you are seekong. Use data aggregation. If you are not that into command line approaches, use pivot tables from microsoft excel. Learning pivot tables (or any other way to do data aggregation) will make your life easier
ADD COMMENTlink modified 3.7 years ago • written 3.7 years ago by Irsan6.9k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 960 users visited in the last hour