summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2016-09-23 12:26:08 +0000
committergebele <gebele@in-silico.ch>2016-09-23 12:26:08 +0000
commitf4b457653ae3aa2001e2edb178a61e246fa90009 (patch)
treee8c6803c0b182bbfdfc3d08e2758227e97b55dbe
parentf2912140b930dbedd4dde5dfbf955a47e32e84a3 (diff)
example selection by training dataset and relevant features;added links for core, coating and keywords
-rw-r--r--application.rb20
-rw-r--r--views/predict.haml4
-rw-r--r--views/prediction.haml60
3 files changed, 47 insertions, 37 deletions
diff --git a/application.rb b/application.rb
index 5df466c..ea0684e 100644
--- a/application.rb
+++ b/application.rb
@@ -22,14 +22,18 @@ get '/predict/?' do
prediction_models = OpenTox::Model::NanoPrediction.all
prediction_models.each{|m| m.model[:feature_selection_algorithm_parameters]["category"] == "P-CHEM" ? @prediction_models[0] = m : @prediction_models[1] = m}
@prediction_models.each_with_index{|m,idx| idx == 0 ? m[:pc_model] = true : m[:pcp_model] = true}
- nanoparticles = OpenTox::Nanoparticle.all.select{|n| n.core["name"] == "Au" || n.core["name"] == "Ag"}
- ## helper for preselect nanos with more than 12 pc_descriptors but take too much time for now
- #example = nanoparticles.collect{|n| n if n.physchem_descriptors.size > 16 && (arr = n.physchem_descriptors.collect{|k,v| OpenTox::Feature.find(k).category == "P-CHEM"}; arr.size > 12 )}.compact
- example = nanoparticles.collect{|n| n if n.physchem_descriptors.size > 16}.compact
- pcp = example.sample
+
+ # collect nanoparticles by training dataset (Ag + Au)
+ dataset = OpenTox::Dataset.find_by(:name=> "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles")
+ nanoparticles = dataset.nanoparticles
+ # select physchem_parameters by relevant_features out of each model
+ @@pc_relevant_features = @prediction_models[0].model.relevant_features.collect{|id, v| OpenTox::Feature.find(id)}
+ @@pcp_relevant_features = @prediction_models[1].model.relevant_features.collect{|id, v| OpenTox::Feature.find(id)}
+ pcp = nanoparticles.sample
+ pcp.physchem_descriptors.delete_if{|id,v| !@@pcp_relevant_features.include?(OpenTox::Feature.find(id))}
@example_pcp = pcp
- pc = example.sample
- pc.physchem_descriptors.delete_if{|k,v| feature = OpenTox::Feature.find_by(:id => k); feature.category != "P-CHEM"}
+ pc = nanoparticles.sample
+ pc.physchem_descriptors.delete_if{|id,v| !@@pc_relevant_features.include?(OpenTox::Feature.find(id))}
@example_pc = pc
haml :predict
@@ -41,6 +45,8 @@ get '/license' do
end
post '/predict/?' do
+
+ # choose the right prediction model
prediction_model = OpenTox::Model::NanoPrediction.find(params[:prediction_model])
size = params[:size].to_i
@type = params[:type]
diff --git a/views/predict.haml b/views/predict.haml
index 9dc0d97..e4fba65 100644
--- a/views/predict.haml
+++ b/views/predict.haml
@@ -89,8 +89,8 @@
%option{:selected => ("selected" if example.core["name"] == "Ag")} Ag
%option{:selected => ("selected" if example.core["name"] == "Au")} Au
%input{:id=>"input_core",:type=>"hidden",:name=>"in_core",:value=>"#{example.core}"}
- %h5 Coating
- %input.input-sm.form-control{:id=>"coating",:type=>"text",:disabled=>"disabled",:name=>"coating",:value=>example.coating[0]["name"]}
+ //%h5 Coating
+ //%input.input-sm.form-control{:id=>"coating",:type=>"text",:disabled=>"disabled",:name=>"coating",:value=>example.coating[0]["name"]}
%input.input-sm.form-control{:id=>"coating",:type=>"hidden",:name=>"input_coating",:value=>example.coating[0]["name"]}
%input{:id=>"input_coating",:type=>"hidden",:name=>"in_coating",:value=>example.coating}
// prediction model id
diff --git a/views/prediction.haml b/views/prediction.haml
index 3913b3e..8f72a23 100644
--- a/views/prediction.haml
+++ b/views/prediction.haml
@@ -25,7 +25,8 @@
#neighbors.table-responsive
- %table.tablesorter{:style => "max-width:100%;white-space:nowrap;"}
+ /%table.tablesorter{:style => "max-width:100%;white-space:nowrap;"}
+ %table.tablesorter
%thead
%tr
%th
@@ -34,10 +35,12 @@
Similarity
%th
Composition
- %th.tox
+ %th.tox{:style => "max-width:100%;white-space:nowrap;"}
Toxicity
%br
- Net cell association [mL/ug(Mg)]
+ Net cell association
+ %br
+ [mL/ug(Mg)]
- @input.sort_by{|d| OpenTox::Feature.find(d[0]).category}.each do |key|
- feature = OpenTox::Feature.find_by(:id=>key[0])
- name = feature.name
@@ -54,31 +57,31 @@
%td
- if @match
%a{:href=> $ambit_search+@name, :rel=>"external"}
- %h5= @name
+ %h5.th5= @name
- else
- %h5 Query
+ %h5.th5 Query
/ similarity
%td
- if @match
- %h5 1
+ %h5.th5 1
- else
- %h5 x
+ %h5.th5 x
/ composition
%td
- if @match
%h5.th5 Core:
- = "["+@nanoparticle[:core]["name"]+"]"
- %br
- %h5.th5 Coating:
- = @nanoparticle[:coating][0]["name"]
- %br
+ %a{:href=>@nanoparticle[:core]["uri"], :rel=>"external"}= "["+@nanoparticle[:core]["name"]+"]"
+ /%br
+ /%h5.th5 Coating:
+ /= @nanoparticle[:coating][0]["name"]
+ /%br
- else
%h5.th5 Core:
= "["+@nanoparticle[:core]["name"]+"]"
- %br
- %h5.th5 Coating:
- = @nanoparticle[:coating][0]["name"]
- %br
+ /%br
+ /%h5.th5 Coating:
+ /= @nanoparticle[:coating][0]["name"]
+ /%br
/ tox
%td.tox
- if @prediction[:value]
@@ -86,20 +89,22 @@
= @prediction[:value].round(3)
%br
- if @prediction[:rmse]
- %h5.th5 Rmse:
+ %h5.th5
+ %a{:href=>"https://en.wikipedia.org/wiki/Root-mean-square_deviation", :rel=>"external"} RMSE:
= @prediction[:rmse].round(3)
%br
- if @prediction[:r_squared]
- %h5.th5 R_squared:
+ %h5.th5
+ %a{:href=>"https://en.wikipedia.org/wiki/Coefficient_of_determination", :rel=>"external"}= "R"+"<sup>2</sup>"+":"
= @prediction[:r_squared].round(3)
%br
- if @prediction[:prediction_interval]
- %h5 95% Prediction interval:
- - interval = @prediction[:prediction_interval].nil? ? " - - " : @prediction[:prediction_interval].collect{|i| i.round(2)}
+ %h5
+ %a{:href=>"https://en.wikipedia.org/wiki/Prediction_interval", :rel=>"external"} 95% Prediction interval:
+ - interval = @prediction[:prediction_interval].nil? ? " - - " : @prediction[:prediction_interval].collect{|i| i.round(2)}
= "#{interval[0]} - #{interval[1]}"
- if @prediction[:measurements]
%br
- %br
%h5.th5 Measurement:
- @prediction[:measurements].each do |m|
= m
@@ -118,29 +123,28 @@
- if @prediction[:neighbors]
- @prediction[:neighbors].each_with_index do |neighbor,idx|
- nano = OpenTox::Nanoparticle.find(neighbor["_id"])
- - pc_descriptors = nano.physchem_descriptors.delete_if{|k,v| feature = OpenTox::Feature.find_by(:id => k); feature.category != "P-CHEM"} if @type == "pc"
+ - pc_descriptors = nano.physchem_descriptors.delete_if{|id,v| OpenTox::Feature.find(id).category != "P-CHEM"} if @type == "pc"
%tr
/ ID
%td
%a{:href=> $ambit_search+nano.name, :rel=>"external"}
- %h5= nano.name
+ %h5.th5= nano.name
/ Similarity
%td
- %h5= neighbor["similarity"].round(3)
+ %h5.th5= neighbor["similarity"].round(3)
/ Composition
%td
%h5.th5 Core:
- = "["+nano[:core]["name"]+"]"
+ %a{:href=>nano[:core]["uri"], :rel=> "external"}= "["+nano[:core]["name"]+"]"
%br
%h5.th5 Coating:
- = nano[:coating][0]["name"]
+ %a{:href=>nano[:coating][0]["uri"], :rel=>"external"}= nano[:coating][0]["name"]
/ Tox
%td.tox
%h5.th5 Measurement:
= neighbor["measurements"][0]
/ Physchem
- -#- @input.each do |k,v|
- - nano.physchem_descriptors.sort_by{|d| OpenTox::Feature.find(d[0]).category}.each do |k,v|
+ - nano.physchem_descriptors.delete_if{|id,v| @type == "pc" ? !@@pc_relevant_features.include?(OpenTox::Feature.find(id)) : !@@pcp_relevant_features.include?(OpenTox::Feature.find(id))}.sort_by{|id,v| OpenTox::Feature.find(id).category}.each do |k,v|
%td.physchem
%div
%div{:style=>"display:inline-block;padding-right:20px;"}