16 <& '/util/import_javascript.mas', classes => ['jquery', 'jqueryui', 'CXGN.Login', 'CXGN.List', 'd3.d3v4Min.js', 'CXGN.BreedersToolbox.HTMLSelect', 'CXGN.SelectionIndex' ] &>
18 <script src="https://cdn.jsdelivr.net/npm/vega@3"></script>
19 <script src="https://cdn.jsdelivr.net/npm/vega-lite@2"></script>
20 <script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script>
22 <!-- temporarily comment out <& /page/page_title.mas, title=>"Genomic Prediction of Cross Performance (GCPC)" &> -->
23 <h2 style="text-align: center;font-size:20px;"> Genomic Prediction of Cross Performance (GCPC)</h2>
26 <b style="font-size:15px; color: #254117">Select a Genotyped Dataset</b>
29 <&| /page/info_section.mas, id=>"input_dataset_section", title=>"Available Datasets", collapsible=>1, collapsed=>0, subtitle=>'<a class="btn btn-link pull-right" href="/help/solgwas" target="_blank">Help <span class="glyphicon glyphicon-question-sign"></span></a>' &>
30 <input type="hidden" name="outformat" value="0" />
33 <div class="form-group form-inline">
34 <div id="dataset_select"></div>
37 <button class="btn btn-success" id="select_dataset" type="submit" name="select_dataset" value="select_dataset">Proceed to Factor Selection</button>
43 <div class="col" style="background-color:MintCream; padding: 10px 20px 25px" id="fixed_and_random_factors">
44 <div class="text-center">Factors will appear here..</div>
57 <i style="font-size:13px">This is a drop-down menu showing your pre-constructed selection indices. Select one and proceed to run the model.</i>
61 <div id="trait_histogram_plot">
68 <div style="text-align: center">
69 <button class="btn btn-success" id="runGCPC" type="submit" name="runGCPC" value="runGCPC">Run GCPC</button>
73 <div id="tempfile" style="display:none" >
78 <div id="gcpc_results_download_link"></div>
80 <&| /page/info_section.mas, title=>"Output", collapsible=>1, collapsed=>0, subtitle=>'<a id="download_table" class="download_tag" target="_blank" href="javascript:download_table();" title="Download results in tabular format">Table⇣</a> <a id="download_basic" class="download_tag" target="_blank" href="javascript:download();" title="Download results in basic format">Basic⇣</a>' &>
81 <div> <p> Plant Sex info: 1= Male, 2=Female, 3= Monoecious male (m>f) and 4= Monoecious female(f>m)</p> </div>
82 <table id="gcpc_output">
84 <tr><th>Cross #</th><th>Parent 1</th><th>Parent 2</th><th>Cross Predicted Merit</th><th>Parent1 Sex</th><th>Parent2 Sex</th></tr>
100 jQuery(document).ready(function() {
102 get_select_box("datasets", "dataset_select", {"checkbox_name":"dataset_select_checkbox"});
105 alert('Login required!');
108 $('#pheno_select').attr("disabled",true).html('');
109 jQuery('#dataset_select').click(function() {
110 $('#pheno_select').attr("disabled",true).html('');
111 $('#trait_histogram_plot').html('');
112 $('#stability_output').empty();
114 jQuery('#select_dataset').click(function() {
115 var dataset_id = get_dataset_id();
116 jQuery('#working_modal').modal('show');
118 url: '/ajax/gcpc/factors',
119 data: {'dataset_id': dataset_id},
120 success: function(response) {
121 if (response.error) {
122 jQuery('#working_modal').modal('hide');
123 $('#dataset_select').val('ERROR');
126 jQuery('#working_modal').modal('hide');
127 jQuery('#fixed_and_random_factors').html(response.html);
128 //alert("factors successfully retrieved!");
133 error: function(response) {
134 alert("An error occurred, the service may be temporarily unavailable. Please try again later.");
139 var lo = new CXGN.List();
140 jQuery('#sin_list').html(lo.listSelect('sin_list', ['dataset'], 'Select a formula', 'refresh', undefined));
141 jQuery('#sin_list_list_select').change(
146 // jQuery('#method_btn').on('click', function() {
147 // var method_id = jQuery('#select_method').val();
149 // url: '/ajax/Stability/get_method',
150 // data: {'method_id': method_id },
151 // }); // end .ajax // }; // end else statement
155 jQuery('#preview_trait_histogram_btn').on('click', function() {
156 if (!jQuery('#pheno_select').val()) {
157 alert("Please select a dataset and trait.")
159 //alert("Inside trait preview");
160 var tempfile = jQuery('#tempfile').html();
161 var trait = jQuery('#pheno_select').val();
164 url: '/ajax/gcpc/getdata',
165 data: { 'file' : tempfile },
166 success: function(r) {
167 //alert("data grabbed "+JSON.stringify(r.data));
169 "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
173 "data": { 'values': r.data },
179 "type": "quantitative"
182 "aggregate": "count",
183 "type": "quantitative"
188 //alert("embedding"+ JSON.stringify(v));
189 vegaEmbed("#trait_histogram_plot", v);
194 error: function(e) { alert('error!'); }
199 //if (!jQuery('#sin_list_list_select').val()) {
200 // alert("Please select a selection index.")
201 // $('#gcpc_files').empty();
203 //if ($('#sin_list_list_select').val() != ""){
204 // var method_id = $('#select_method').val();
207 jQuery('#runGCPC').click( function () {
208 $('#gcpc_files').empty();
209 var factors = ["studyYear", "programName" , "studyName", "studyDesign" , "plantingDate", "locationName", "replicate" , "rowNumber", "colNumber" , "germplasmName"];
210 var factor_param = "";
211 for (var n=0; n<factors.length; n++) {
212 var value = jQuery('input[name="'+factors[n]+ '_factor"]:checked').val();
213 factor_param+='&'+factors[n]+'_factor='+value;
219 var sin_list_id = jQuery('#sin_list_list_select option:selected').val();
220 //alert("SIN LIST ID "+sin_list_id);
221 if (! sin_list_id || sin_list_id == "") {
222 alert("Please select a selection index.")
223 $('#gcpc_files').empty();
226 var dataset_id = get_dataset_id();
229 jQuery('#working_modal').modal('show');
231 'url': '/ajax/gcpc/generate_results?dataset_id='+dataset_id+'&sin_list_id='+sin_list_id+'&method_id='+method_id+factor_param,
234 'contentType': 'application/json'
235 }).done( function(data) {
237 jQuery('#working_modal').modal('hide');
241 jQuery('#working_modal').modal('hide');
242 alert(data.error); return;
245 //alert('Download link = '+data.download_link);
246 if (data.download_link) {
247 jQuery('#gcpc_results_download_link').html(data.download_link);
251 //alert('JSON data retrieved: '+JSON.stringify(data));
252 jQuery('#working_modal').modal('hide');
253 jQuery('#gcpc_output').DataTable( {
258 "order": [[ 3, "desc" ]]
260 // { "data": "Cross #" },
261 // { "data": "Parent 1" },
262 // { "data": "Parent 2" },
263 // { "data": "Cross Predicted Merit" },
270 function get_dataset_id() {
271 var selected_datasets = [];
272 jQuery('input[name="dataset_select_checkbox"]:checked').each(function() {
273 selected_datasets.push(jQuery(this).val());
275 if (selected_datasets.length < 1){
276 alert('Please select at least one dataset!');
278 } else if (selected_datasets.length > 1){
279 alert('Please select only one dataset!');
282 var dataset_id=selected_datasets[0];
304 background-color: #68889E;
306 border-color: #2F3E48;
326 .blast_select_label {
338 vertical-align:middle;
349 background-color:#EEEEFE;
361 /* min-width: 700px;*/
369 /* BLAST canvas Graph */
381 /* border-style: solid;*/
382 /* border-width: 1px;*/
383 /* border-color: #ddd;*/
384 /* border-width:0px 1px 1px 1px;*/