2 <!--button class="btn btn-primary" id="nirs_analysis_prediction_dialog_show">Predict Phenotypes From Spectral Model</button-->
4 <div class="modal fade" id="nirs_analysis_prediction_dialog" name="nirs_analysis_prediction_dialog" tabindex="-1" role="dialog" aria-labelledby="nirsAnalysisPredictionDialog" data-backdrop="static">
5 <div class="modal-dialog modal-xl" role="document">
6 <div class="modal-content">
7 <div class="modal-header">
8 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
9 <h4 class="modal-title" id="nirsAnalysisPredictionDialog">Predict Phenotypes From Spectral Model</h4>
11 <div class="modal-body">
12 <div class="container-fluid">
14 <&| /util/workflow.mas, id=> "nirs_analysis_prediction_workflow" &>
15 <&| /util/workflow.mas:step, title=> "Intro" &>
16 <& /page/page_title.mas, title=>"This workflow will guide you through predicting phenotypes from trained spectral models in the database." &>
19 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
22 <&| /util/workflow.mas:step, title=> "Test Dataset" &>
23 <& /page/page_title.mas, title=>"Select the dataset you are interested in predicting phenotypes for (the accessions or plots or tissues samples in the dataset need to have spectra uploaded):" &>
25 <form class="form-horizontal">
26 <div class="form-group">
27 <label class="col-sm-1 control-label">Dataset: </label>
28 <div class="col-sm-11" >
29 <div id="nirs_analysis_prediction_dataset_select_div"></div>
34 <button class="btn btn-primary" id="nirs_analysis_prediction_dataset_select_step">Go to Next Step</button>
37 <&| /util/workflow.mas:step, title=> "Spectral Model" &>
38 <& /page/page_title.mas, title=>"Select the spectral model to use in predictions" &>
41 <button class="btn btn-info" id="nirs_analysis_prediction_dataset_info">More Info</button>
45 <div id="nirs_analysis_prediction_model_select_div"></div>
48 <button class="btn btn-primary" id="nir_analysis_prediction_model_step">Predict</button>
51 <&| /util/workflow.mas:step, title=> "Summary" &>
52 <& /page/page_title.mas, title=>"Summary of the predictions" &>
54 <div class="form-horizontal">
55 <div class="form-group">
56 <label class="col-sm-3 control-label">Do you want to save the prediction results?: </label>
57 <div class="col-sm-9" >
58 <button class="btn btn-primary" id="nir_analysis_prediction_analysis_save_step">Save the Results</button>
63 <div id="nir_analysis_prediction_analysis_predictions"></div>
71 <div class="modal-footer">
72 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
78 <div class="modal fade" id="nirs_analysis_prediction_dialog_info" name="nirs_analysis_prediction_dialog_info" tabindex="-1" role="dialog" aria-labelledby="nirsAnalysisPredictionInfoDialog" data-backdrop="static">
79 <div class="modal-dialog" role="document">
80 <div class="modal-content">
81 <div class="modal-header">
82 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
83 <h4 class="modal-title" id="nirsAnalysisPredictionInfoDialog">Predict Phenotypes from Spectral Model</h4>
85 <div class="modal-body">
86 <div class="container-fluid">
92 <div class="modal-footer">
93 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
100 jQuery(document).ready(function(){
102 jQuery('#nirs_analysis_prediction_dataset_info').click(function(){
103 jQuery('#nirs_analysis_prediction_dialog_info').modal('show');
106 jQuery('#nirs_analysis_prediction_dialog_show').click(function(){
107 jQuery('#nirs_analysis_prediction_dialog').modal('show');
109 get_select_box('datasets','nirs_analysis_prediction_dataset_select_div', {'checkbox_name':'nirs_analysis_prediction_dataset_select_id'});
112 var nirs_analysis_prediction_dataset_id;
113 jQuery('#nirs_analysis_prediction_dataset_select_step').click(function(){
115 jQuery('input[name="nirs_analysis_prediction_dataset_select_id"]:checked').each(function() {
116 selected.push(jQuery(this).val());
119 if(selected.length > 1 || selected.length == 0) {
120 alert('Please select one dataset!');
124 nirs_analysis_prediction_dataset_id = selected[0];
126 get_select_box('trained_nirs_models','nirs_analysis_prediction_model_select_div', {'checkbox_name':'nirs_analysis_prediction_model_select_id'});
128 Workflow.complete("#nirs_analysis_prediction_dataset_select_step");
129 Workflow.focus('#nirs_analysis_prediction_workflow', 2);
130 window.scrollTo(0,0);
134 var nirs_analysis_prediction_model_id;
135 jQuery('#nir_analysis_prediction_model_step').click(function(){
137 jQuery('input[name="nirs_analysis_prediction_model_select_id"]:checked').each(function() {
138 selected.push(jQuery(this).val());
141 if(selected.length > 1 || selected.length == 0) {
142 alert('Please select one model!');
146 nirs_analysis_prediction_model_id = selected[0];
149 url : '/ajax/Nirs/generate_predictions',
152 'model_id' : nirs_analysis_prediction_model_id,
153 'dataset_id' : nirs_analysis_prediction_dataset_id,
155 beforeSend: function(){
156 jQuery('#working_modal').modal('show');
158 success: function(response){
159 console.log(response);
160 jQuery('#working_modal').modal('hide');
162 if (response.error) {
163 alert(response.error);
167 var html = "<table class='table table-bordered table-hover'><thead><tr><th>Stock</th><th>Prediction</th></tr></thead><tbody>";
168 for (var i=0; i<response.unique_plots.length; i++) {
169 html = html + '<tr><td>'+response.unique_plots[i]+'</td><td>'+response.result_predictions[response.unique_plots[i]][response.unique_traits[0]][0]+'</td></tr>';
171 html = html + "</tbody></table>";
172 jQuery('#nir_analysis_prediction_analysis_predictions').html(html);
174 jQuery('#generic_save_analysis_protocol').val(response.protocol);
175 jQuery('#generic_save_analysis_dataset_id').val(nirs_analysis_prediction_dataset_id);
176 jQuery('#generic_save_analysis_accession_names').val(JSON.stringify(response.unique_accessions));
177 jQuery('#generic_save_analysis_trait_names').val(JSON.stringify(response.unique_traits));
178 jQuery('#generic_save_analysis_statistical_ontology_term').val(response.stat_term);
179 jQuery('#generic_save_analysis_design').val(JSON.stringify(response.analysis_design));
180 jQuery('#generic_save_analysis_result_values').val(JSON.stringify(response.result_predictions));
181 jQuery('#generic_save_analysis_result_values_type').val('analysis_result_values_match_precomputed_design');
182 jQuery('#generic_save_analysis_result_summary_values').val(JSON.stringify(response.result_summary));
183 jQuery('#generic_save_analysis_model_type').val('waves_nirs_spectral_predictions');
185 jQuery('#generic_save_analysis_model_select_form').hide();
186 jQuery('#generic_save_analysis_model_name_div').hide();
187 jQuery('#generic_save_analysis_model_description_div').hide();
188 jQuery('#generic_save_analysis_model_is_public_div').hide();
189 jQuery('#generic_save_analysis_model_id').val(nirs_analysis_prediction_model_id);
191 jQuery('#generic_save_analysis_model_training_data_file').val(response.training_data_file);
192 jQuery('#generic_save_analysis_model_archived_training_data_file_type').val(response.training_data_file_type);
194 Workflow.complete("#nir_analysis_prediction_model_step");
195 Workflow.focus('#nirs_analysis_prediction_workflow', 3);
196 window.scrollTo(0,0);
198 error: function(response){
199 alert('Error predicting phenotypes from NIRS!');
200 jQuery('#working_modal').modal('hide');
206 jQuery('#nir_analysis_prediction_analysis_save_step').click(function(){
207 jQuery('#generic_save_analysis_dialog').modal('show');