aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2023-06-19 18:52:53 +0000
committerzsloan2023-06-20 17:46:38 +0000
commit9a3d761cbde705204db64bc7e70e2defc02f2c64 (patch)
tree20e92d50a0a852596fef48808a097e88c4fb4ac9 /wqflask
parentb236e6896abdf0e23ff1630e67d0954d1e9ee535 (diff)
downloadgenenetwork2-9a3d761cbde705204db64bc7e70e2defc02f2c64.tar.gz
Change getSampleTableData function to include a includeNAs parameter
This is so the export function can show all rows, including ones with no value. Previously it only fetched the rows with values (which is fine for correlations/mapping, but not export).
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js61
1 files changed, 32 insertions, 29 deletions
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index 0f923181..90c6015c 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -1072,7 +1072,7 @@ switchQNormData = function() {
};
$('#qnorm').click(switchQNormData);
-getSampleTableData = function(tableName, attributesAsList) {
+getSampleTableData = function(tableName, attributesAsList, includeNAs=false) {
var samples = [];
if ($('#' + tableName).length){
@@ -1110,38 +1110,41 @@ getSampleTableData = function(tableName, attributesAsList) {
sampleName = $.trim(nameNodes[_j].childNodes[0].textContent)
if (isNumber(sampleVal) && sampleVal !== "") {
sampleVal = parseFloat(sampleVal);
- if (typeof varNodes == 'undefined'){
- sampleVar = null;
+ } else {
+ sampleVal = 'x'
+ }
+ if (typeof varNodes == 'undefined'){
+ sampleVar = null;
+ } else {
+ sampleVar = varNodes[_j].childNodes[0].value;
+ if (isNumber(sampleVar)) {
+ sampleVar = parseFloat(sampleVar);
} else {
- sampleVar = varNodes[_j].childNodes[0].value;
- if (isNumber(sampleVar)) {
- sampleVar = parseFloat(sampleVar);
- } else {
- sampleVar = null;
- }
+ sampleVar = 'x';
}
- if (typeof nNodes == 'undefined'){
- sampleN = null;
+ }
+ if (typeof nNodes == 'undefined'){
+ sampleN = null;
+ } else {
+ sampleN = nNodes[_j].childNodes[0].value;
+ if (isNumber(sampleN)) {
+ sampleN = parseInt(sampleN);
} else {
- sampleN = nNodes[_j].childNodes[0].value;
- if (isNumber(sampleN)) {
- sampleN = parseInt(sampleN);
- } else {
- sampleN = null;
- }
- }
-
- rowDict = {
- name: sampleName,
- value: sampleVal,
- se: sampleVar,
- num_cases: sampleN
+ sampleN = 'x';
}
+ }
- for (_k = 0; _k < attributeNodes.length; _k++){
- rowDict[attributesAsList[_k]] = attributeNodes[_k][_j].textContent;
- }
+ rowDict = {
+ name: sampleName,
+ value: sampleVal,
+ se: sampleVar,
+ num_cases: sampleN
+ }
+ for (_k = 0; _k < attributeNodes.length; _k++){
+ rowDict[attributesAsList[_k]] = attributeNodes[_k][_j].textContent;
+ }
+ if (includeNAs || sampleVal != 'x') {
samples.push(rowDict)
}
}
@@ -1157,8 +1160,8 @@ exportSampleTableData = function() {
});
sample_data = {};
- sample_data.primary_samples = getSampleTableData('samples_primary', attributesAsList);
- sample_data.other_samples = getSampleTableData('samples_other', attributesAsList);
+ sample_data.primary_samples = getSampleTableData('samples_primary', attributesAsList, true);
+ sample_data.other_samples = getSampleTableData('samples_other', attributesAsList, true);
sample_data.attributes = attributesAsList;
json_sample_data = JSON.stringify(sample_data);
$('input[name=export_data]').val(json_sample_data);