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-primary" id="selectDataset" type="submit" name="selectDataset" value="selectDataset">Select Dataset</button>
39 <div class="form-group form-inline">
40 <label class="blast_select_label" for="pheno_select">Available Traits: </label>
41 <& /page/html_select.mas, name=>'pheno_select', id=>'pheno_select', params=>"class\=\"form-control input-sm blast_select_box\"", choices=>"" &>
42 <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>
47 <div id="trait_histogram_plot">
52 <div class="form-group form-inline">
53 <input type="checkbox" id="kinshipmat" />
54 <label>Include kinship matrix in model </label>
56 <input type="checkbox" id="princomp" />
57 <label>Include principal components in model </label>
58 <button class="btn btn-primary" id="preview_pca" type="submit" name="preview_pca" value="preview_pca">View PCA Plot</button>
64 <div id="pca_output"></div>
71 <!-- <label class="blast_select_label" for="geno_select">Genotypes </label>
72 <& /page/html_select.mas, name=>'geno_select', id=>'geno_select', params=>"class\=\"form-control input-sm blast_select_box\"", choices=>"" &> -->
77 <div style="text-align: center">
78 <button class="btn btn-primary" id="runGWA" name="runGWA">Run SolGWAS</button>
82 <div id="tempfile" style="display:none" >
94 <&| /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>' &>
99 <div id="sgn_blast_graph" style="display:none">
101 Your browser does not support the HTML5 canvas
107 <div id="Solgwas_output"></div>
109 <div id="Overview_output"></div>
110 <div id="Coverage_output"></div>
111 <div id="Table_output" style="min-width:900px;"></div>
112 <div id="Bioperl_output"></div>
113 <div id="Basic_output"></div>
124 jQuery(document).ready(function() {
126 get_select_box("datasets", "dataset_select");
129 alert('You must be logged in to use SolGWAS');
131 $('#pheno_select').attr("disabled",true).html('');
132 jQuery('#dataset_select').click(function() {
133 $('#pheno_select').attr("disabled",true).html('');
134 $('#trait_histogram_plot').html('');
135 $('#pca_output').empty();
136 $('#Solgwas_output').empty();
137 $('#princomp').attr('checked', false);
138 $('#kinshipmat').attr('checked', false);
140 jQuery('#selectDataset').click(function() {
141 var dataset_id = jQuery('#available_datasets').val();
142 // alert("Dataset ID: "+dataset_id);
144 url: '/ajax/solgwas/shared_phenotypes',
145 data: {'dataset_id': dataset_id},
146 success: function(response) {
147 if (response.error) {
148 $('#dataset_select').val('ERROR');
151 // alert(response.options);
152 // alert(response.options.length);
153 var option_html = '<option selected="selected" value=""> </option>';
154 for (var i = 0; i < response.options.length; i++) {
155 option_html += '<option value="'+response.options[i][1]+'">'+(response.options[i][1])+'</option>';
157 $('#pheno_select').attr("disabled",false).html(option_html);
158 jQuery('#tempfile').html(response.tempfile);
164 error: function(response) {
165 alert("An error occurred, the service may temporarily be unavailable");
171 jQuery('#preview_trait_histogram_btn').on('click', function() {
172 if (!jQuery('#pheno_select').val()) {
173 alert("Please select a dataset and trait.")
175 //alert("Inside trait preview");
176 var tempfile = jQuery('#tempfile').html();
177 var trait = jQuery('#pheno_select').val();
180 url: '/ajax/solgwas/getdata',
181 data: { 'file' : tempfile },
182 success: function(r) {
183 //alert("data grabbed "+JSON.stringify(r.data));
185 "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
189 "data": { 'values': r.data },
195 "type": "quantitative"
198 "aggregate": "count",
199 "type": "quantitative"
204 //alert("embedding"+ JSON.stringify(v));
205 vegaEmbed("#trait_histogram_plot", v);
210 error: function(e) { alert('error!'); }
216 jQuery('#preview_pca').click( function () {
217 if (!jQuery('#pheno_select').val()) {
218 alert("Please select a dataset and trait.")
220 $('#pca_output').empty();
221 if ($('#pheno_select').val() != ""){
222 var dataset_id = $('#available_datasets').val();
223 var trait_id = $('#pheno_select').val();
225 url: '/ajax/solgwas/generate_pca',
227 data: {'dataset_id': dataset_id, 'trait_id': trait_id},
228 beforeSend: function() {
229 jQuery("#working_modal").modal("show");
231 success: function(response) {
232 jQuery("#working_modal").modal("hide");
233 if (response.error) {
234 $('#dataset_select').val('ERROR');
237 var fig2_response = response.figure2;
238 $('#pca_output').append("<img id='SolGWAS_Figure2' src='"+ fig2_response + "'/>");
241 error: function(response) {
242 alert("An error occurred, the service may temporarily be unavailable");
249 jQuery('#runGWA').click( function () {
250 if (!jQuery('#pheno_select').val()) {
251 alert("Please select a dataset and trait.")
252 $('#Solgwas_output').empty();
254 $('#Solgwas_output').empty();
255 if ($('#pheno_select').val() != ""){
256 var dataset_id = $('#available_datasets').val();
257 var trait_id = $('#pheno_select').val();
259 var kinship_check = 0;
260 if ($('#princomp').is(':checked')) {
263 if ($('#kinshipmat').is(':checked')) {
264 var kinship_check = 1;
267 //alert(kinship_check);
268 //alert("Dataset ID: "+dataset_id);
269 //alert("Pheno ID: "+trait_id);
271 url: '/ajax/solgwas/generate_results',
272 data: {'dataset_id': dataset_id, 'trait_id': trait_id, 'pc_check': pc_check, 'kinship_check': kinship_check},
273 beforeSend: function() {
274 jQuery("#working_modal").modal("show");
277 success: function(response) {
278 jQuery("#working_modal").modal("hide");
279 if (response.error) {
280 alert(response.error);
283 var fig3_response = response.figure3;
284 var fig4_response = response.figure4;
285 //alert("Response ID: "+temp_response);
286 //alert("Response ID: "+fig3_response);
288 $('#Solgwas_output').append("<img id='SolGWAS_Figure3' src='"+ fig3_response + "'/>");
289 $('#Solgwas_output').append("<img id='SolGWAS_Figure4' src='"+ fig4_response + "'/>");
292 error: function(xhr, status, error) {
293 var err = eval("(" + xhr.responseText + ")");
329 .blast_select_label {
341 vertical-align:middle;
352 background-color:#EEEEFE;
364 /* min-width: 700px;*/
372 /* BLAST canvas Graph */
384 /* border-style: solid;*/
385 /* border-width: 1px;*/
386 /* border-color: #ddd;*/
387 /* border-width:0px 1px 1px 1px;*/