From f46ba3b7262f5b551c81fc9396c5b7f0cac7f030 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 27 May 2016 19:16:16 +0200 Subject: first correlation of nanoparticle predictions --- lib/validation-statistics.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/validation-statistics.rb') diff --git a/lib/validation-statistics.rb b/lib/validation-statistics.rb index 156353a..e61543b 100644 --- a/lib/validation-statistics.rb +++ b/lib/validation-statistics.rb @@ -83,7 +83,7 @@ module OpenTox end R.assign "measurement", x R.assign "prediction", y - R.eval "r <- cor(measurement,prediction,use='complete')" + R.eval "r <- cor(measurement,prediction,use='pairwise')" r = R.eval("r").to_ruby mae = mae/predictions.size @@ -99,11 +99,7 @@ module OpenTox } end - end - - module Plot - - def plot_id + def self.correlation_plot id, predictions tmpfile = "/tmp/#{id.to_s}_correlation.png" x = [] y = [] @@ -115,10 +111,11 @@ module OpenTox R.assign "prediction", y R.eval "all = c(measurement,prediction)" R.eval "range = c(min(all), max(all))" - R.eval "image = qplot(prediction,measurement,main='',asp=1,xlim=range, ylim=range)" + # TODO units + R.eval "image = qplot(prediction,measurement,main='',xlab='Prediction',ylab='Measurement',asp=1,xlim=range, ylim=range)" R.eval "image = image + geom_abline(intercept=0, slope=1)" R.eval "ggsave(file='#{tmpfile}', plot=image)" - file = Mongo::Grid::File.new(File.read(tmpfile), :filename => "#{self.id.to_s}_correlation_plot.png") + file = Mongo::Grid::File.new(File.read(tmpfile), :filename => "#{id.to_s}_correlation_plot.png") plot_id = $gridfs.insert_one(file) plot_id end -- cgit v1.2.3