Generate Wig File With Snp Density
2
1
Entering edit mode
11.0 years ago
soosus ▴ 90

I need to write a simple script or use single line script (can use pipe) to create a WIG file with SNP density (SNPs/KB) for human chromosome 22 (from UCSC hg19 snp132). I'm using Fedora and have perl at my behest. Help?

wiggle snp ucsc genome browser • 2.5k views
ADD COMMENT
4
Entering edit mode
11.0 years ago

generate a bedgraph with

$ mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -D hg19 -N -e 'select chrom,ROUND(chromStart/1E3)*1E3 as chromStart ,(1+ROUND(chromStart/1E3))*1E3 as chromEnd,count(*) as count from snp132 where chrom="chr22" group by ROUND(chromStart/1E3) '> chr22.bed

convert to bedgraph to bigwig with bedgraphtobigwig http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/

ADD COMMENT
0
Entering edit mode
11.0 years ago
soosus ▴ 90
$ mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -e '
                            USE hg19;
                            SELECT distinct chrom,chromStart,chromEnd,name
                                FROM snp132
                                WHERE chrom = "chr22";
                            ' |\
                            tail -n+2 |\
                            perl -ne '
                            {
                                chomp;
                                @a = split (/\t/, $_);
                                $kb = int($a[2] / 1000);
                                $h{$kb}++;
                                if (eof) {
                                    print "browser position chr22\nbrowser hide all\ntrack type=wiggle_0 name=\"SNPdensity\" description=\"SNPdensity\"  visibility=full autoScale=off viewLimits=0:50 color=0,0,255 yLineMark=25 yLineOnOff=on priority=10\nvariableStep chrom=chr22 span=1000\n";
                                    foreach $kb (sort {$a<=>$b} keys %h) {
                                        $post = $kb *1000;
                                        print "$post\t$h{$kb}\n";
                                    }
                                }
                            }' | gzip > hg19.snp132.chr22.wig.gz &

This way, no additional tools are needed.

ADD COMMENT

Login before adding your answer.

Traffic: 3212 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6