Generate Wig File With Snp Density
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?
• 3,066 views
•
link
2 answers
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/
• 182 views
•
link
$ 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.
• 0 views
•
link
Log in to answer this question.