From 56aee22ca87120ba52c0bd8aee3a8870de7c7fed Mon Sep 17 00:00:00 2001 From: Marcus Fedarko Date: Thu, 30 May 2019 16:05:33 -0700 Subject: [PATCH] MAINT: Log # of NaN balance samples selection #92 This is a solid start. We'd want to also log the number of samples dropped due to having a non-numeric value on a quantitative scale (either for color or x-axis). I *think* we could do that by running some similar code in updateSamplePlotField()/updateSamplePlotScale(), and maybe adding some logic to ensure that each sample is just counted once (i.e. both null and non-numeric-metadata-on-a-quant-scale samples would be dropped), but I'm not sure. Should be doable tho :) --- docs/demos/byrd/js/display.js | 13 ++++++++++++- docs/demos/matching_test/js/display.js | 13 ++++++++++++- docs/demos/q2_byrd/js/display.js | 13 ++++++++++++- docs/demos/q2_moving_pictures/js/display.js | 13 ++++++++++++- docs/demos/q2_red_sea/js/display.js | 13 ++++++++++++- docs/demos/q2_sleep_apnea/js/display.js | 13 ++++++++++++- docs/demos/red_sea/js/display.js | 13 ++++++++++++- docs/demos/sleep_apnea/js/display.js | 13 ++++++++++++- qurro/support_files/js/display.js | 13 ++++++++++++- 9 files changed, 108 insertions(+), 9 deletions(-) diff --git a/docs/demos/byrd/js/display.js b/docs/demos/byrd/js/display.js index 028395ba..a4ea7328 100644 --- a/docs/demos/byrd/js/display.js +++ b/docs/demos/byrd/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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 diff --git a/docs/demos/matching_test/js/display.js b/docs/demos/matching_test/js/display.js index 028395ba..a4ea7328 100644 --- a/docs/demos/matching_test/js/display.js +++ b/docs/demos/matching_test/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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 diff --git a/docs/demos/q2_byrd/js/display.js b/docs/demos/q2_byrd/js/display.js index 028395ba..a4ea7328 100644 --- a/docs/demos/q2_byrd/js/display.js +++ b/docs/demos/q2_byrd/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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 diff --git a/docs/demos/q2_moving_pictures/js/display.js b/docs/demos/q2_moving_pictures/js/display.js index 028395ba..a4ea7328 100644 --- a/docs/demos/q2_moving_pictures/js/display.js +++ b/docs/demos/q2_moving_pictures/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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 diff --git a/docs/demos/q2_red_sea/js/display.js b/docs/demos/q2_red_sea/js/display.js index 028395ba..a4ea7328 100644 --- a/docs/demos/q2_red_sea/js/display.js +++ b/docs/demos/q2_red_sea/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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 diff --git a/docs/demos/q2_sleep_apnea/js/display.js b/docs/demos/q2_sleep_apnea/js/display.js index 028395ba..a4ea7328 100644 --- a/docs/demos/q2_sleep_apnea/js/display.js +++ b/docs/demos/q2_sleep_apnea/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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 diff --git a/docs/demos/red_sea/js/display.js b/docs/demos/red_sea/js/display.js index 028395ba..a4ea7328 100644 --- a/docs/demos/red_sea/js/display.js +++ b/docs/demos/red_sea/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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 diff --git a/docs/demos/sleep_apnea/js/display.js b/docs/demos/sleep_apnea/js/display.js index 028395ba..a4ea7328 100644 --- a/docs/demos/sleep_apnea/js/display.js +++ b/docs/demos/sleep_apnea/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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 diff --git a/qurro/support_files/js/display.js b/qurro/support_files/js/display.js index 028395ba..a4ea7328 100644 --- a/qurro/support_files/js/display.js +++ b/qurro/support_files/js/display.js @@ -333,6 +333,7 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( changeSamplePlot(updateBalanceFunc, updateRankColorFunc) { var dataName = this.samplePlotJSON.data.name; var parentDisplay = this; + var numSamplesWithNaNBalance = 0; this.samplePlotView .change( dataName, @@ -350,14 +351,24 @@ define(["./feature_computation", "./dom_utils", "vega", "vega-embed"], function( "qurro_balance", // function to run to determine what the new balances are function(sampleRow) { - return updateBalanceFunc.call( + var sampleBalance = updateBalanceFunc.call( parentDisplay, sampleRow ); + // We use Number.isNaN() instead of isNaN() because + // the latter can have weird undesirable behavior. + if (Number.isNaN(sampleBalance)) { + numSamplesWithNaNBalance++; + } + return sampleBalance; } ) ) .run(); + console.log( + String(numSamplesWithNaNBalance) + + " sample(s) dropped due to NaN balance." + ); // 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