Created
May 28, 2010 21:02
-
-
Save drio/417750 to your computer and use it in GitHub Desktop.
map mapping mapq plot gnuplot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat plot_dist_mapq.rb | |
#!/usr/bin/env ruby19 | |
# | |
# time samtools view -F 4 ./0.bam | ./plot_dist_mapq.rb | |
h = Hash.new(0) | |
i = 0 | |
STDIN.each do |l| | |
$stderr.printf("\r%d", i) if i % 50000 == 0 | |
mq = l.split[4].to_i | |
h[mq]= h[mq] + 1 | |
i = i + 1 | |
end | |
$stderr.puts "" | |
File.open("data.txt", "w") do |df| | |
h.sort{|a,b| a[0]<=>b[0]}.each do |v| | |
df.puts "#{v[0]}\t#{v[1]}" | |
end | |
end | |
File.open("cfg.txt", "w") {|cfg| cfg.puts DATA.read } | |
`cat ./cfg.txt | gnuplot` | |
#`rm -f cfg.txt data.txt && ls -lach output.png` | |
__END__ | |
#set terminal png nocrop size 750,450 | |
#set key left top | |
set nokey | |
set xtics 2 | |
set grid x y | |
#set datafile separator "," | |
set t png | |
#set xrange [0:800] | |
#set yrange [0:100] | |
set output "output.png" | |
set xlabel "# aligments" | |
set ylabel "Mapping quality" | |
set title "Mapping quality distribution" | |
plot "./data.txt" notitle with lines | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment