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>
24 <!-- temporarily comment out <& /page/page_title.mas, title=>"Genomic Prediction of Cross Performance (GPCP)" &> -->
25 <h2 style="text-align: center;font-size:20px;"> Genomic Prediction of Cross Performance (GPCP)</h2>
28 <b style="font-size:15px; color: #254117">Select a Genotyped Dataset</b>
31 <&| /page/info_section.mas, id=>"input_dataset_section", title=>"Available Datasets", collapsible=>1, collapsed=>0 &>
32 <input type="hidden" name="outformat" value="0" />
35 <div class="form-group form-inline">
36 <div id="dataset_select"></div>
39 <div style="border-top: 1px solid #DEDEDE;">
40 <h4>Choose Selection Index values</h4>
41 <i style="font-size:13px">This is a drop-down menu showing your pre-constructed selection indices.</i>
42 <div style= "display: flex;flex-direction: row;">
43 <div id="sin_list"></div>
44 <p style="margin-left: 30px;margin-right: 30px;">OR</p>
45 <button class="btn btn-success" >
46 <a href="http://localhost:8080/selection/index" target="_blank" rel="noopener noreferrer" style="color: white">Create a new one here</a>
54 <div style="border-top: 1px solid #DEDEDE;">
56 <button class="btn btn-success" id="select_dataset" type="submit" name="select_dataset" value="select_dataset">Proceed to Factor Selection</button>
62 <div class="col" style="background-color:MintCream; padding: 10px 20px 25px" id="fixed_and_random_factors">
63 <div class="text-center">Factors will appear here..</div>
70 <div id="trait_histogram_plot">
75 <div style="text-align: center">
76 <button class="btn btn-success" id="runGCPC" type="submit" name="runGCPC" value="runGCPC">Run GPCP</button>
80 <div id="tempfile" style="display:none" >
85 <div style= "display: flex;justify-content: space-evenly;align-items: center;">
86 <div id="cross_predicted_merit_histogram" ></div>
87 <div id="gcpc_results_download_link"></div>
90 <&| /page/info_section.mas, title=>"", 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>' &>
91 <div id="plant_sex_legend"></div>
93 <table id="gcpc_output">
96 <script src="https://cdn.datatables.net/buttons/2.3.2/js/dataTables.buttons.min.js"></script>
97 <script src="https://cdn.datatables.net/buttons/2.3.2/js/buttons.print.min.js"></script>
98 <script src="https://cdn.datatables.net/select/1.5.0/js/dataTables.select.min.js"></script>
99 <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
100 <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
101 <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
102 <script src="https://cdn.datatables.net/buttons/2.3.2/js/buttons.html5.min.js"></script>
117 jQuery(document).ready(function() {
119 get_select_box("datasets", "dataset_select", {"checkbox_name":"dataset_select_checkbox"});
122 alert('Login required!');
125 $('#pheno_select').attr("disabled",true).html('');
126 jQuery('#dataset_select').click(function() {
127 $('#pheno_select').attr("disabled",true).html('');
128 $('#trait_histogram_plot').html('');
129 $('#stability_output').empty();
131 jQuery('#select_dataset').click(function() {
132 $('html, body').animate({scrollTop:$(document).height()}, 'slow');
133 var dataset_id = get_dataset_id();
134 jQuery('#working_modal').modal('show');
136 url: '/ajax/gcpc/factors',
137 data: {'dataset_id': dataset_id},
138 success: function(response) {
139 if (response.error) {
140 jQuery('#working_modal').modal('hide');
141 $('#dataset_select').val('ERROR');
144 jQuery('#working_modal').modal('hide');
145 jQuery('#fixed_and_random_factors').html(response.html);
146 //alert("factors successfully retrieved!");
149 error: function(response) {
150 alert("An error occurred, the service may be temporarily unavailable. Please try again later.");
155 var lo = new CXGN.List();
156 jQuery('#sin_list').html(lo.listSelect('sin_list', ['dataset'], 'Select a formula', 'refresh', undefined));
157 jQuery('#sin_list_list_select').change(
164 jQuery('#preview_trait_histogram_btn').on('click', function() {
165 if (!jQuery('#pheno_select').val()) {
166 alert("Please select a dataset and trait.")
168 //alert("Inside trait preview");
169 var tempfile = jQuery('#tempfile').html();
170 var trait = jQuery('#pheno_select').val();
173 url: '/ajax/gcpc/getdata',
174 data: { 'file' : tempfile },
175 success: function(r) {
178 "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
182 "data": { 'values': r.data },
188 "type": "quantitative"
191 "aggregate": "count",
192 "type": "quantitative"
197 //alert("embedding"+ JSON.stringify(v));
198 vegaEmbed("#trait_histogram_plot", v);
203 error: function(e) { alert('error!'); }
210 jQuery('#runGCPC').click( function () {
211 $('html, body').animate({scrollTop:$(document).height()}, 'slow');
212 $('#gcpc_files').empty();
213 var factors = ["studyYear", "programName" , "studyName", "studyDesign" , "plantingDate", "locationName", "replicate" , "rowNumber", "colNumber" , "germplasmName"];
214 var factor_param = "";
215 for (var n=0; n<factors.length; n++) {
216 var value = jQuery('input[name="'+factors[n]+ '_factor"]:checked').val();
217 factor_param+='&'+factors[n]+'_factor='+value;
223 var sin_list_id = jQuery('#sin_list_list_select option:selected').val();
224 //alert("SIN LIST ID "+sin_list_id);
225 if (! sin_list_id || sin_list_id == "") {
226 alert("Please select a selection index.")
227 $('#gcpc_files').empty();
230 var dataset_id = get_dataset_id();
233 jQuery('#working_modal').modal('show');
235 'url': '/ajax/gcpc/generate_results?dataset_id='+dataset_id+'&sin_list_id='+sin_list_id+'&method_id='+method_id+factor_param,
238 'contentType': 'application/json',
239 error: function(error) {
240 jQuery('#working_modal').modal('hide');
241 alert("An error occured" +error.responseText);
243 success:function(data) {
244 jQuery('#working_modal').modal('hide');
245 if (!data.histogram || data.histogram == "") {
246 alert("An error occured. Possible causes include: \n - The factors included have less than 2 levels. \n - No genotypic data. \n - Phenotypic data has a lot of missing data.");
248 if (data.download_link) {
249 jQuery('#gcpc_results_download_link').html(data.download_link);
251 var headers = data.header;
252 var column_headers = [];
254 for (var i in headers) {
256 column_headers += `{ "data": ${headers[i]} },`
258 //alert (column_headers);
260 var histogram_html = '<img src="'+data.histogram+'"/>';
261 jQuery('#cross_predicted_merit_histogram').html(histogram_html);
264 jQuery('#working_modal').modal('hide');
265 jQuery('#gcpc_output').DataTable( {
279 text: 'Print all (not just selected)',
291 "order": [[ 3, "desc" ]]
294 //error: function(data) {
295 //alert("An error occurred, the service may be temporarily unavailable. Please try again later.");
301 function get_dataset_id() {
302 var selected_datasets = [];
303 jQuery('input[name="dataset_select_checkbox"]:checked').each(function() {
304 selected_datasets.push(jQuery(this).val());
306 if (selected_datasets.length < 1){
307 alert('Please select at least one dataset!');
309 } else if (selected_datasets.length > 1){
310 alert('Please select only one dataset!');
313 var dataset_id=selected_datasets[0];
334 background-color: #68889E;
336 border-color: #2F3E48;
356 .blast_select_label {
368 vertical-align:middle;
379 background-color:#EEEEFE;
391 /* min-width: 700px;*/
399 /* BLAST canvas Graph */
411 /* border-style: solid;*/
412 /* border-width: 1px;*/
413 /* border-color: #ddd;*/
414 /* border-width:0px 1px 1px 1px;*/