summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2011-08-04 13:55:58 +0000
committerChristoph Helma <helma@in-silico.ch>2011-08-04 13:55:58 +0000
commit304c4c484a062077bad08ca9fe3ed44d138c9416 (patch)
tree17ecb7dfa918e5c35acf2979899fd195985c45d2
parent4f83500afb33612cadd7084470ab9b42dfa59cf2 (diff)
feature highlighting and significant features fixed for generic classes and regression
-rw-r--r--application.rb13
-rw-r--r--helper.rb35
-rw-r--r--views/feature_table.haml12
-rw-r--r--views/lazar.haml2
-rw-r--r--views/lazar_algorithm.haml20
-rw-r--r--views/neighbors.haml2
-rw-r--r--views/prediction.haml4
-rw-r--r--views/significant_fragments.haml2
8 files changed, 70 insertions, 20 deletions
diff --git a/application.rb b/application.rb
index 21030aa..c155d1f 100644
--- a/application.rb
+++ b/application.rb
@@ -372,9 +372,14 @@ post '/predict/?' do # post chemical name to model
confidence = nil
title = nil
db_activities = []
- lazar = OpenTox::Model::Lazar.new model.uri
+ lazar = OpenTox::Model::Lazar.find model.uri
prediction_dataset_uri = lazar.run({:compound_uri => @compound.uri, :subjectid => subjectid})
LOGGER.debug "Prediction dataset_uri: #{prediction_dataset_uri}"
+ if lazar.value_map
+ @value_map = lazar.value_map
+ else
+ @value_map = nil
+ end
prediction_dataset = OpenTox::LazarPrediction.find(prediction_dataset_uri, subjectid)
if prediction_dataset.metadata[OT.hasSource].match(/dataset/)
@predictions << {
@@ -415,7 +420,11 @@ post "/lazar/?" do # get detailed prediction
@model_uri = params[:model_uri]
lazar = OpenTox::Model::Lazar.find @model_uri
prediction_dataset_uri = lazar.run(:compound_uri => params[:compound_uri], :subjectid => session[:subjectid])
- @value_map = lazar.value_map
+ if lazar.value_map
+ @value_map = lazar.value_map
+ else
+ @value_map = nil
+ end
@prediction = OpenTox::LazarPrediction.find(prediction_dataset_uri, session[:subjectid])
@compound = OpenTox::Compound.new(params[:compound_uri])
haml :lazar
diff --git a/helper.rb b/helper.rb
index 943a182..698fd3e 100644
--- a/helper.rb
+++ b/helper.rb
@@ -54,10 +54,15 @@ helpers do
def sort(descriptors,value_map)
features = {:activating => [], :deactivating => []}
descriptors.each do |d|
- if value_map[d[OT.effect]] =~ TRUE_REGEXP
- features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]}
- elsif value_map[d[OT.effect]] =~ FALSE_REGEXP
- features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]}
+ if !value_map.empty?
+ features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} if d[OT.effect] == 2
+ features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} if d[OT.effect] == 1
+ else
+ if d[OT.effect] =~ TRUE_REGEXP
+ features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]}
+ elsif d[OT.effect] =~ FALSE_REGEXP
+ features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]}
+ end
end
end
features
@@ -67,7 +72,26 @@ helpers do
haml :compound_image, :locals => {:compound => compound, :features => sort(descriptors,value_map)}, :layout => false
end
- def activity_markup(activity)
+ def activity_markup(activity,value_map)
+ if value_map and !value_map.empty?
+ if value_map.size == 2
+ activity = value_map.index(activity) if value_map.has_value? activity
+ if activity.to_i == 2
+ haml ".active #{value_map[activity]}", :layout => false
+ elsif activity.to_i == 1
+ haml ".inactive #{value_map[activity]}", :layout => false
+ else
+ haml ".other #{activity.to_s}", :layout => false
+ end
+ else
+ haml ".other #{activity.to_s}", :layout => false
+ end
+ elsif OpenTox::Algorithm::numeric? activity
+ haml ".other #{sprintf('%.03g', activity.to_f)}", :layout => false
+ else
+ haml ".other #{activity.to_s}", :layout => false
+ end
+=begin
case activity.class.to_s
when /Float/
haml ".other #{sprintf('%.03g', activity)}", :layout => false
@@ -89,6 +113,7 @@ helpers do
haml ".other #{activity.to_s}", :layout => false
end
end
+=end
end
def neighbors_navigation
diff --git a/views/feature_table.haml b/views/feature_table.haml
index a8a153f..e75c818 100644
--- a/views/feature_table.haml
+++ b/views/feature_table.haml
@@ -2,7 +2,11 @@
- unless features[:activating].empty?
%tr
%th
- activating
+ - if @value_map.empty?
+ activating
+ - else
+ predominatly in compounds with activity
+ = "\"#{@value_map[2]}\""
(
%a{:href => "http://www.daylight.com/dayhtml/doc/theory/theory.smarts.html", :rel => "external"} SMARTS
)
@@ -15,7 +19,11 @@
- unless features[:deactivating].empty?
%tr
%th
- deactivating
+ - if @value_map.empty?
+ deactivating
+ - else
+ predominatly in compounds with activity
+ = "\"#{@value_map[1]}\""
(
%a{:href => "http://www.daylight.com/dayhtml/doc/theory/theory.smarts.html", :rel => "external"} SMARTS
)
diff --git a/views/lazar.haml b/views/lazar.haml
index 2912567..870fcab 100644
--- a/views/lazar.haml
+++ b/views/lazar.haml
@@ -19,7 +19,7 @@
%tr
%td.image= compound_image(@compound,@prediction.descriptors(@compound),@value_map)
- %td= activity_markup(@prediction.value(@compound))
+ %td= activity_markup(@prediction.value(@compound), @value_map)
%td= sprintf('%.03g', @prediction.confidence(@compound))
%td
%ul
diff --git a/views/lazar_algorithm.haml b/views/lazar_algorithm.haml
index 85823b5..e5b70f6 100644
--- a/views/lazar_algorithm.haml
+++ b/views/lazar_algorithm.haml
@@ -33,12 +33,20 @@
= toggle_link "#significant_fragments", "Significant fragments"
are highlighted in the structure display as follows:
%ul
- %li
- .active activating fragments
- %li
- .inactive deactivating fragments
- %li
- .inconclusive regions, where activating and deactivating fragments overlap
+ - if @value_map.empty?
+ %li
+ .active activating fragments
+ %li
+ .inactive deactivating fragments
+ %li
+ .inconclusive regions, where activating and deactivating fragments overlap
+ - else
+ %li
+ .active= "features that occur predominately in compounds with activity: \"#{@value_map[2]}\""
+ %li
+ .inactive= "features that occur predominately in compounds with activity: \"#{@value_map[1]}\""
+ %li
+ .inconclusive regions, where fragments from different classes overlap
%li
.other inert parts
diff --git a/views/neighbors.haml b/views/neighbors.haml
index 3f1dccd..e2d65fa 100644
--- a/views/neighbors.haml
+++ b/views/neighbors.haml
@@ -14,7 +14,7 @@
- compound = OpenTox::Compound.new(neighbor[OT.compound])
%tr
%td.image= compound_image(compound,@prediction.descriptors(compound),@value_map)
- %td= activity_markup(@value_map[neighbor[OT.measuredActivity].to_i])
+ %td= activity_markup(neighbor[OT.measuredActivity], @value_map)
%td= sprintf('%.03g', neighbor[OT.similarity])
%td
%ul
diff --git a/views/prediction.haml b/views/prediction.haml
index 9bb3f76..682b979 100644
--- a/views/prediction.haml
+++ b/views/prediction.haml
@@ -16,7 +16,7 @@
- if p[:measured_activities]
%br
- p[:measured_activities].each do |a|
- = activity_markup(a)
+ = activity_markup(a, @value_map)
%br
(
%a{:href => "#", :id => "linkTrainingData#{p.object_id}"} Measured activity
@@ -29,7 +29,7 @@
- elsif p[:error]
%br= p[:error]
- else
- = activity_markup(p[:prediction])
+ = activity_markup(p[:prediction], @value_map)
- if p[:confidence]
%br
(
diff --git a/views/significant_fragments.haml b/views/significant_fragments.haml
index bd39826..8cddf43 100644
--- a/views/significant_fragments.haml
+++ b/views/significant_fragments.haml
@@ -5,6 +5,6 @@
= hide_link "#significant_fragments"
)
%dd
- Substructures that occur (statistically significant) more frequently in active or inactive compounds. Substuctures can take any shape (without cycles) and are determined with the
+ Substructures that occur (statistically significant) more frequently in one of the toxicity classes or correlate with quantitative toxicity values. Substuctures can take any shape (without cycles) and are determined with the
%a{:href => "http://www.maunz.de/libfminer2-bbrc-doc/", :rel => "external"} fminer
algorithm.