Skip to content

Commit

Permalink
plots tab - filter out nan data
Browse files Browse the repository at this point in the history
Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <abeshoua@mskcc.org>
  • Loading branch information
Abeshouse, Adam A./Sloan Kettering Institute committed Aug 15, 2018
1 parent af53431 commit 48633b5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
43 changes: 43 additions & 0 deletions src/pages/resultsView/plots/PlotsTabUtils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {assert} from "chai";
import {makeScatterPlotData} from "./PlotsTabUtils";
import {Sample} from "../../../shared/api/generated/CBioPortalAPI";

describe("PlotsTabUtils", ()=>{
describe("makeScatterPlotData", ()=>{
it ("does not create data for NaN values", ()=>{
const data = makeScatterPlotData(
{
datatype:"number",
data:[
{ uniqueSampleKey:"sample1", value:NaN}, { uniqueSampleKey:"sample2", value:3},
{ uniqueSampleKey:"sample3", value:1}
],
},
{
datatype:"number",
data:[
{ uniqueSampleKey:"sample1", value:0}, { uniqueSampleKey:"sample2", value:NaN},
{ uniqueSampleKey:"sample3", value:4}
],
},
{ sample1: {sampleId:"sample1", studyId:"study"} as Sample,
sample2: {sampleId:"sample2", studyId:"study"} as Sample,
sample3: {sampleId:"sample3", studyId:"study"} as Sample
},
{}
);
assert.equal(data.length, 1, "only one datum - others have NaN");
const datum:any = data[0];
const target:any = {
uniqueSampleKey:"sample3",
sampleId:"sample3",
studyId:"study",
x:1,
y:4,
};
for (const key of ["uniqueSampleKey", "sampleId", "studyId", "x", "y"]) {
assert.equal(target[key], datum[key], key);
}
});
});
});
10 changes: 7 additions & 3 deletions src/pages/resultsView/plots/PlotsTabUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,8 @@ export function makeScatterPlotData(
dispMutationType = selectDisplayValue(counts, mutationRenderPriority) as OncoprintMutationType;
}
const sampleCoverageInfo = coverageInformation[d.uniqueSampleKey];
let profiledMutations = true;
let profiledCna = true;
let profiledMutations = undefined;
let profiledCna = undefined;
if (mutations || copyNumberAlterations) {
const profiledReport = makeScatterPlotData_profiledReport(
horzData.hugoGeneSymbol,
Expand Down Expand Up @@ -1126,7 +1126,11 @@ export function makeScatterPlotData(
datum.y = d.value;
datum.value = d.value;
datum.jitter = getJitterForCase(d.uniqueSampleKey);
data.push(datum);

// filter out NaN number values
if (!Number.isNaN(datum.x as any) && !Number.isNaN(datum.y as any)) {
data.push(datum);
}
}
}
return data;
Expand Down

0 comments on commit 48633b5

Please sign in to comment.