Skip to content

Commit

Permalink
MAINT: Log # of NaN balance samples selection #92
Browse files Browse the repository at this point in the history
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 :)
  • Loading branch information
fedarko committed May 30, 2019
1 parent 0b54c39 commit 56aee22
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 9 deletions.
13 changes: 12 additions & 1 deletion docs/demos/byrd/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion docs/demos/matching_test/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion docs/demos/q2_byrd/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion docs/demos/q2_moving_pictures/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion docs/demos/q2_red_sea/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion docs/demos/q2_sleep_apnea/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion docs/demos/red_sea/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion docs/demos/sleep_apnea/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion qurro/support_files/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 56aee22

Please sign in to comment.