-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewCNVAndImprovementStatus.blade.php
163 lines (141 loc) · 8.67 KB
/
viewCNVAndImprovementStatus.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
@php
include resource_path() . '/views/system/config.blade.php';
$organism = $info['organism'];
$chromosome = $info['chromosome'];
$position_start = $info['position_start'];
$position_end = $info['position_end'];
$data_option = $info['cnv_data_option'];
if($organism == "Osativa"){
$div_text = "subpopulation";
} elseif($organism == "Athaliana"){
$div_text = "admixture group";
} elseif($organism == "Zmays"){
$div_text = "improvement status";
} else {
$div_text = "improvement status";
}
@endphp
<head>
<title>{{ $config_organism }}-KB</title>
<link rel="shortcut icon" href="{{ asset('css/images/Header/kbcommons_icon.ico') }}">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.plot.ly/plotly-2.12.1.min.js"></script>
</head>
<body>
<h3>Figure:</h3>
<div>
<div id="cn_and_improvement_status_summary_plot_div">Loading CN and {{ $div_text }} summary plot...</div>
<div id="cn_and_improvement_status_summary_table_div">Loading CN and {{ $div_text }} summary table...</div>
<div>
<hr>
<h3>Full Table:</h3>
<div id="cn_and_improvement_status_table_div">Loading CN and {{ $div_text }} table...</div>
</body>
<script src="{{ asset('system/home/GenVarX/js/viewCNVAndImprovementStatus.js') }}" type="text/javascript"></script>
<script type="text/javascript">
var organism = <?php if(isset($organism)) {echo json_encode($organism, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var chromosome = <?php if(isset($chromosome)) {echo json_encode($chromosome, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var position_start = <?php if(isset($position_start)) {echo json_encode($position_start, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var position_end = <?php if(isset($position_end)) {echo json_encode($position_end, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var data_option = <?php if(isset($data_option)) {echo json_encode($data_option, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var div_text = <?php if(isset($div_text)) {echo json_encode($div_text, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
if (organism && chromosome && position_start && position_end && data_option) {
$.ajax({
url: 'queryCNVAndImprovementStatus/'+organism,
type: 'GET',
contentType: 'application/json',
data: {
Organism: organism,
Chromosome: chromosome,
Start: position_start,
End: position_end,
Data_Option: data_option
},
success: function (response) {
res = JSON.parse(response);
if (res) {
document.getElementById("cn_and_improvement_status_summary_plot_div").style.minHeight = "800px";
// Render data
document.getElementById('cn_and_improvement_status_table_div').innerText = "";
document.getElementById('cn_and_improvement_status_table_div').innerHTML = "";
document.getElementById('cn_and_improvement_status_table_div').appendChild(
constructInfoTable(JSON.parse(JSON.stringify(res)))
);
document.getElementById('cn_and_improvement_status_table_div').style.maxHeight = '1000px';
document.getElementById('cn_and_improvement_status_table_div').style.display = 'inline-block';
document.getElementById('cn_and_improvement_status_table_div').style.overflow = 'scroll';
// Summarize data
var phenotype = "";
if(organism == "Osativa"){
phenotype = "Subpopulation";
} else if(organism == "Athaliana"){
phenotype = "Admixture_Group";
} else if(organism == "Zmays"){
phenotype = "Improvement_Status";
} else {
phenotype = "Improvement_Status";
}
var result_dict = summarizeQueriedData(
JSON.parse(JSON.stringify(res)),
phenotype,
'CN'
);
var result_arr = result_dict['Data'];
var summary_array = result_dict['Summary'];
for (let i = 0; i < summary_array.length; i++) {
if(summary_array[i].hasOwnProperty('Number_of_Accession_with_Phenotype')){
delete summary_array[i]['Number_of_Accession_with_Phenotype']
}
if(summary_array[i].hasOwnProperty('Number_of_Accession_without_Phenotype')){
delete summary_array[i]['Number_of_Accession_without_Phenotype']
}
}
// Make plot
var cnAndImprovementStatusData = collectDataForFigure(result_arr, phenotype, 'CN');
plotFigure(cnAndImprovementStatusData, 'CN', phenotype+'_Summary', 'cn_and_improvement_status_summary_plot_div');
// Render data
document.getElementById('cn_and_improvement_status_summary_table_div').innerText = "";
document.getElementById('cn_and_improvement_status_summary_table_div').innerHTML = "";
document.getElementById('cn_and_improvement_status_summary_table_div').appendChild(
constructInfoTable(summary_array)
);
document.getElementById('cn_and_improvement_status_summary_table_div').style.overflow = 'scroll';
}
},
error: function (xhr, status, error) {
console.log('Error with code ' + xhr.status + ': ' + xhr.statusText);
document.getElementById('cn_and_improvement_status_summary_plot_div').innerText="";
document.getElementById('cn_and_improvement_status_summary_plot_div').innerHTML="";
var p_tag = document.createElement('p');
p_tag.innerHTML = "CN and " + div_text + " distribution summary figure is not available due to lack of data!!!";
document.getElementById('cn_and_improvement_status_summary_plot_div').appendChild(p_tag);
document.getElementById('cn_and_improvement_status_summary_table_div').innerText="";
document.getElementById('cn_and_improvement_status_summary_table_div').innerHTML="";
var p_tag = document.createElement('p');
p_tag.innerHTML = "CN and " + div_text + " distribution summary figure is not available due to lack of data!!!";
document.getElementById('cn_and_improvement_status_summary_table_div').appendChild(p_tag);
document.getElementById('cn_and_improvement_status_table_div').innerText="";
document.getElementById('cn_and_improvement_status_table_div').innerHTML="";
var p_tag = document.createElement('p');
p_tag.innerHTML = "CN and " + div_text + " distribution table is not available due to lack of data!!!";
document.getElementById('cn_and_improvement_status_table_div').appendChild(p_tag);
}
});
} else {
document.getElementById('cn_and_improvement_status_summary_plot_div').innerText="";
document.getElementById('cn_and_improvement_status_summary_plot_div').innerHTML="";
var p_tag = document.createElement('p');
p_tag.innerHTML = "CN and " + div_text + " distribution summary figure is not available due to lack of data!!!";
document.getElementById('cn_and_improvement_status_summary_plot_div').appendChild(p_tag);
document.getElementById('cn_and_improvement_status_summary_table_div').innerText="";
document.getElementById('cn_and_improvement_status_summary_table_div').innerHTML="";
var p_tag = document.createElement('p');
p_tag.innerHTML = "CN and " + div_text + " distribution summary figure is not available due to lack of data!!!";
document.getElementById('cn_and_improvement_status_summary_table_div').appendChild(p_tag);
document.getElementById('cn_and_improvement_status_table_div').innerText="";
document.getElementById('cn_and_improvement_status_table_div').innerHTML="";
var p_tag = document.createElement('p');
p_tag.innerHTML = "CN and " + div_text + " distribution table is not available due to lack of data!!!";
document.getElementById('cn_and_improvement_status_table_div').appendChild(p_tag);
}
</script>