16 <& '/util/import_javascript.mas', classes => ['jquery', 'jqueryui', 'CXGN.Login', 'd3.d3v4Min.js', 'CXGN.BreedersToolbox.HTMLSelect'] &>
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 <& /page/page_title.mas, title=>"SolGWAS" &>
24 <&| /page/info_section.mas, id=>"input_dataset_section", title=>"Select Input Data", 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>' &>
25 <input type="hidden" name="outformat" value="0" />
28 <div class="form-group form-inline">
29 <label for="dataset_select">Available Datasets: </label><div id="dataset_select"></div>
32 <button class="btn btn-info" id="createDataset"><span class="glyphicon glyphicon-plus"></span> Create Dataset</button>
33 <button class="btn btn-primary" id="selectDataset" type="submit" name="selectDataset" value="selectDataset">Select Dataset</button>
40 <div class="form-group form-inline">
41 <label class="blast_select_label" for="pheno_select">Available Traits: </label>
42 <& /page/html_select.mas, name=>'pheno_select', id=>'pheno_select', params=>"class\=\"form-control input-sm blast_select_box\"", choices=>"" &>
43 <button class="btn btn-primary" id="preview_trait_histogram_btn" type="submit" name="preview_trait_histogram_btn" value="preview_trait_histogram_btn">View Trait Histogram</button>
48 <div id="trait_histogram_plot">
53 <div class="form-group form-inline">
54 <input type="checkbox" id="kinshipmat" />
55 <label>Include kinship matrix in model </label>
57 <input type="checkbox" id="princomp" />
58 <label>Include principal components in model </label>
59 <button class="btn btn-primary" id="preview_pca" type="submit" name="preview_pca" value="preview_pca">View PCA Plot</button>
65 <div id="pca_output"></div>
72 <!-- <label class="blast_select_label" for="geno_select">Genotypes </label>
73 <& /page/html_select.mas, name=>'geno_select', id=>'geno_select', params=>"class\=\"form-control input-sm blast_select_box\"", choices=>"" &> -->
78 <div style="text-align: center">
79 <button class="btn btn-primary" id="runGWA" name="runGWA">Run SolGWAS</button>
83 <div id="tempfile" style="display:none" >
95 <&| /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>' &>
100 <div id="sgn_blast_graph" style="display:none">
102 Your browser does not support the HTML5 canvas
108 <div id="Solgwas_output"></div>
110 <div id="Overview_output"></div>
111 <div id="Coverage_output"></div>
112 <div id="Table_output" style="min-width:900px;"></div>
113 <div id="Bioperl_output"></div>
114 <div id="Basic_output"></div>
125 jQuery(document).ready(function() {
127 get_select_box("datasets", "dataset_select", {"checkbox_name":"dataset_select_checkbox"});
130 alert('You must be logged in to use SolGWAS');
132 $('#pheno_select').attr("disabled",true).html('');
134 jQuery("#createDataset").click(function(e) {
135 window.location = "/breeders/search/?dsp=genotyping_protocols,trials|traits,accessions&dsr=/tools/solgwas";
138 jQuery('#dataset_select').click(function() {
139 $('#pheno_select').attr("disabled",true).html('');
140 $('#trait_histogram_plot').html('');
141 $('#pca_output').empty();
142 $('#Solgwas_output').empty();
143 $('#princomp').attr('checked', false);
144 $('#kinshipmat').attr('checked', false);
146 jQuery('#selectDataset').click(function() {
147 var dataset_id = get_dataset_id();
149 url: '/ajax/solgwas/shared_phenotypes',
150 data: {'dataset_id': dataset_id},
151 success: function(response) {
152 if (response.error) {
153 $('#dataset_select').val('ERROR');
156 // alert(response.options);
157 // alert(response.options.length);
158 var option_html = '<option selected="selected" value=""> </option>';
159 for (var i = 0; i < response.options.length; i++) {
160 option_html += '<option value="'+response.options[i][1]+'">'+(response.options[i][1])+'</option>';
162 $('#pheno_select').attr("disabled",false).html(option_html);
163 jQuery('#tempfile').html(response.tempfile);
169 error: function(response) {
170 alert("An error occurred, the service may temporarily be unavailable");
176 jQuery('#preview_trait_histogram_btn').on('click', function() {
177 if (!jQuery('#pheno_select').val()) {
178 alert("Please select a dataset and trait.")
180 //alert("Inside trait preview");
181 var tempfile = jQuery('#tempfile').html();
182 var trait = jQuery('#pheno_select').val();
185 url: '/ajax/solgwas/getdata',
186 data: { 'file' : tempfile },
187 success: function(r) {
188 //alert("data grabbed "+JSON.stringify(r.data));
190 "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
194 "data": { 'values': r.data },
200 "type": "quantitative"
203 "aggregate": "count",
204 "type": "quantitative"
209 //alert("embedding"+ JSON.stringify(v));
210 vegaEmbed("#trait_histogram_plot", v);
215 error: function(e) { alert('error!'); }
221 jQuery('#preview_pca').click( function () {
222 if (!jQuery('#pheno_select').val()) {
223 alert("Please select a dataset and trait.")
225 $('#pca_output').empty();
226 if ($('#pheno_select').val() != ""){
227 var dataset_id = get_dataset_id();
228 var trait_id = $('#pheno_select').val();
230 url: '/ajax/solgwas/generate_pca',
232 data: {'dataset_id': dataset_id, 'trait_id': trait_id},
233 beforeSend: function() {
234 jQuery("#working_modal").modal("show");
236 success: function(response) {
237 jQuery("#working_modal").modal("hide");
238 if (response.error) {
239 $('#dataset_select').val('ERROR');
242 var fig2_response = response.figure2;
243 $('#pca_output').append("<img id='SolGWAS_Figure2' src='"+ fig2_response + "'/>");
246 error: function(response) {
247 alert("An error occurred, the service may temporarily be unavailable");
254 jQuery('#runGWA').click( function () {
255 if (!jQuery('#pheno_select').val()) {
256 alert("Please select a dataset and trait.")
257 $('#Solgwas_output').empty();
259 $('#Solgwas_output').empty();
260 if ($('#pheno_select').val() != ""){
261 var dataset_id = get_dataset_id();
262 var trait_id = $('#pheno_select').val();
264 var kinship_check = 0;
265 if ($('#princomp').is(':checked')) {
268 if ($('#kinshipmat').is(':checked')) {
269 var kinship_check = 1;
272 //alert(kinship_check);
273 //alert("Dataset ID: "+dataset_id);
274 //alert("Pheno ID: "+trait_id);
276 url: '/ajax/solgwas/generate_results',
277 data: {'dataset_id': dataset_id, 'trait_id': trait_id, 'pc_check': pc_check, 'kinship_check': kinship_check},
278 beforeSend: function() {
279 jQuery("#working_modal").modal("show");
282 success: function(response) {
283 jQuery("#working_modal").modal("hide");
284 if (response.error) {
285 alert(response.error);
288 var fig3_response = response.figure3;
289 var fig4_response = response.figure4;
290 //alert("Response ID: "+temp_response);
291 //alert("Response ID: "+fig3_response);
293 $('#Solgwas_output').append("<img id='SolGWAS_Figure3' src='"+ fig3_response + "'/>");
294 $('#Solgwas_output').append("<img id='SolGWAS_Figure4' src='"+ fig4_response + "'/>");
297 error: function(xhr, status, error) {
298 var err = eval("(" + xhr.responseText + ")");
306 function get_dataset_id() {
307 var selected_datasets = [];
308 jQuery('input[name="dataset_select_checkbox"]:checked').each(function() {
309 selected_datasets.push(jQuery(this).val());
311 if (selected_datasets.length < 1){
312 alert('Please select at least one dataset!');
314 } else if (selected_datasets.length > 1){
315 alert('Please select only one dataset!');
318 var dataset_id=selected_datasets[0];
349 .blast_select_label {
361 vertical-align:middle;
372 background-color:#EEEEFE;
384 /* min-width: 700px;*/
392 /* BLAST canvas Graph */
404 /* border-style: solid;*/
405 /* border-width: 1px;*/
406 /* border-color: #ddd;*/
407 /* border-width:0px 1px 1px 1px;*/