Skip to content

Commit

Permalink
ENH: display # of NaN-balance samples in a <div>
Browse files Browse the repository at this point in the history
Progress towards #92. I guess this is ~ 1/4 of the work there.
  • Loading branch information
fedarko committed Jun 2, 2019
1 parent f349613 commit ba6291a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
28 changes: 22 additions & 6 deletions qurro/support_files/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,28 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function(
)
)
.run();
console.log(
String(numSamplesWithNaNBalance) +
" / " +
String(this.sampleCount) +
" sample(s) dropped due to NaN balance."
);
if (numSamplesWithNaNBalance > 0) {
var sampleNoun = "samples";
if (numSamplesWithNaNBalance === 1) {
sampleNoun = "sample";
}
dom_utils.setDivText(
"balanceSamplesDroppedDiv",
String(numSamplesWithNaNBalance) +
" / " +
String(this.sampleCount) +
" " +
sampleNoun +
" can't be shown due to having an undefined log ratio."
);
document
.getElementById("balanceSamplesDroppedDiv")
.classList.remove("invisible");
} else {
document
.getElementById("balanceSamplesDroppedDiv")
.classList.add("invisible");
}
// Update rank plot based on the new log ratio
// Storing this within changeSamplePlot() is a (weak) safeguard that
// changes to the state of the sample plot (at least enacted using the UI
Expand Down
8 changes: 8 additions & 0 deletions qurro/support_files/js/dom_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ define(function() {
}
}

/* Just reassigns the innerHTML attribute of a <div> (or really any HTML
* element, I guess).
*/
function setDivText(divID, text) {
document.getElementById(divID).innerHTML = text;
}

/* Downloads a string (either plain text or already a data URI) defining
* the contents of a file.
*
Expand All @@ -101,6 +108,7 @@ define(function() {
populateSelect: populateSelect,
changeElementsEnabled: changeElementsEnabled,
clearDiv: clearDiv,
setDivText: setDivText,
downloadDataURI: downloadDataURI
};
});

0 comments on commit ba6291a

Please sign in to comment.