summaryrefslogtreecommitdiff
path: root/lib/validation-statistics.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-05-27 19:16:16 +0200
committerChristoph Helma <helma@in-silico.ch>2016-05-27 19:16:16 +0200
commitf46ba3b7262f5b551c81fc9396c5b7f0cac7f030 (patch)
tree2fb5efc12c70d62e2befb5ffdd6415656fd9f309 /lib/validation-statistics.rb
parentcc08e6beda7f7d70ebf6c6929a22d1a0cd7c1a20 (diff)
first correlation of nanoparticle predictions
Diffstat (limited to 'lib/validation-statistics.rb')
-rw-r--r--lib/validation-statistics.rb13
1 files changed, 5 insertions, 8 deletions
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