3 * breeding values vs phenotypic deviation
5 * Isaak Y Tecle <iyt2@cornell.edu>
10 var solGS = solGS || function solGS() {};
12 solGS.gebvPhenoRegression = {
14 gebvPhenoRegCanvasId: '#gebv_pheno_regression_canvas',
15 gebvPhenoRegPlotDivId: '#gebv_pheno_regression_plot',
17 checkDataExists: function(args) {
19 var regArgs = JSON.stringify(args);
20 var checkData = jQuery.ajax({
23 data: {'arguments': regArgs},
24 url: '/solgs/check/regression/data/',
32 getRegressionData: function(args) {
34 var regArgs = JSON.stringify(args);
36 var regData = jQuery.ajax({
39 data: {'arguments': regArgs},
40 url: '/solgs/get/regression/data/',
46 createGebvPhenoDownloadLinks: function () {
48 var gebvPhenoRegPlotDivId = this.gebvPhenoRegPlotDivId.replace(/#/, '');
49 var regDownloadBtn = "download_" + gebvPhenoRegPlotDivId;
50 var regPlotLink = "<a href='#' onclick='event.preventDefault();' id='" + regDownloadBtn + "'> Regression plot</a>";
51 var downloadLinks = `Download: ${regPlotLink}`;
58 jQuery(document).ready( function() {
59 var args = solGS.getModelArgs();
60 solGS.gebvPhenoRegression.getRegressionData(args).done(function(res){
63 var gebvPhenoRegPlotDivId = solGS.gebvPhenoRegression.gebvPhenoRegPlotDivId;
64 var canvas = solGS.gebvPhenoRegression.gebvPhenoRegCanvasId;
65 var downloadLinks = solGS.gebvPhenoRegression.createGebvPhenoDownloadLinks();
67 var regressionData = {
68 'breeding_values' : res.gebv_data,
69 'phenotype_values' : res.pheno_data,
70 'phenotype_deviations': res.pheno_deviations,
71 'heritability' : res.heritability,
72 'gebv_pheno_regression_div_id':gebvPhenoRegPlotDivId,
74 'download_links': downloadLinks
77 jQuery("#gebv_pheno_regression_message").empty();
78 solGS.scatterPlot.plotRegression(regressionData);
80 jQuery("#gebvs_pheno_regression_message").html('There is no GEBVs vs observed phenotypes regression data.');
84 solGS.gebvPhenoRegression.getRegressionData(args).fail(function(res){
85 jQuery("#gebvs_pheno_regression_message").html('Error occured requesting for theGEBVs vs observed phenotypes regression data.');
89 jQuery("#gebv_pheno_regression_canvas").on('click' , 'a', function(e) {
90 var buttonId = e.target.id;
91 var regPlotId = buttonId.replace(/download_/, '');
92 saveSvgAsPng(document.getElementById("#" + regPlotId), regPlotId + ".png", {scale:1});