From a669616e5e94a3722bea4e50c7dab64b84ef85f9 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 27 Nov 2012 07:03:54 +0000 Subject: [PATCH] added relative count to plot_nucleotide_distribution git-svn-id: http://biopieces.googlecode.com/svn/trunk@2000 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/plot_nucleotide_distribution | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bp_bin/plot_nucleotide_distribution b/bp_bin/plot_nucleotide_distribution index 3970299..ea9b0db 100755 --- a/bp_bin/plot_nucleotide_distribution +++ b/bp_bin/plot_nucleotide_distribution @@ -30,6 +30,7 @@ require 'narray' require 'pp' VEC_MAX = 10_000 +Y_MAX = 100 terminals = "dumb,x11,aqua,post,pdf,png,svg" title = "Nucleotide Distribution" @@ -38,6 +39,7 @@ ylabel = "Nucleotide distribution (%)" casts = [] casts << {:long=>'no_stream', :short=>'x', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} +casts << {:long=>'count', :short=>'c', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} casts << {:long=>'data_out', :short=>'o', :type=>'file', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} casts << {:long=>'terminal', :short=>'t', :type=>'string', :mandatory=>false, :default=>'dumb', :allowed=>terminals, :disallowed=>nil} casts << {:long=>'title', :short=>'T', :type=>'string', :mandatory=>false, :default=>title, :allowed=>nil, :disallowed=>nil} @@ -85,6 +87,9 @@ c = ((vec_c / vec_tot) * 100)[0 ... max_len].to_a g = ((vec_g / vec_tot) * 100)[0 ... max_len].to_a n = ((vec_n / vec_tot) * 100)[0 ... max_len].to_a +vec_tot *= (Y_MAX / vec_tot.max(0).to_f) +y = vec_tot.to_a + a.unshift 0.0 t.unshift 0.0 c.unshift 0.0 @@ -100,7 +105,7 @@ Gnuplot.open do |gp| plot.output options[:data_out] if options[:data_out] plot.ytics "out" plot.xtics "out" - plot.yrange "[0:100]" + plot.yrange "[0:#{Y_MAX}]" plot.xrange "[0:#{max_len}]" plot.auto "fix" plot.offsets "1" @@ -140,6 +145,13 @@ Gnuplot.open do |gp| ds.with = "histogram lt rgb \"red\"" ds.title = "A" end + + if options[:count] + plot.data << Gnuplot::DataSet.new([x, y]) do |ds| + ds.with = "lines lt rgb \"black\"" + ds.title = "relative count" + end + end end end -- 2.39.2