Skip to content

Commit

Permalink
Merge pull request #1459 from adamabeshouse/profiled-in
Browse files Browse the repository at this point in the history
fix bug where profiled in tracks were appearing when they shouldnt
  • Loading branch information
adamabeshouse authored Sep 18, 2018
2 parents 78126de + 4c731d1 commit a5bf7b1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/shared/components/oncoprint/ResultsViewOncoprintUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ describe("ResultsViewOncoprintUtils",()=>{
"multiple study"
);
});
it("does not create any if all samples profiled in every selected alteration type, special case sample is not profiled for one gene but profiled for another", ()=>{
const coverageInformation = {
"sample1":{
byGene:{"BRCA1":[{ molecularProfileId: "mutations" } as GenePanelData]},
allGenes: [],
notProfiledByGene: {"KRAS":[{ molecularProfileId: "mutations" } as GenePanelData]},
notProfiledAllGenes:[]
}
};
const selectedMolecularProfiles = [molecularProfileIdToMolecularProfile.mutations];
assert.deepEqual(
makeProfiledInClinicalAttributes(coverageInformation, molecularProfileIdToMolecularProfile, selectedMolecularProfiles, 1, true),
[],
"single study"
);
assert.deepEqual(
makeProfiledInClinicalAttributes(coverageInformation, molecularProfileIdToMolecularProfile, selectedMolecularProfiles, 1, false),
[],
"multiple study"
);
});
it("creates an attribute for one selected alteration type in which not all samples profiled", ()=>{
const coverageInformation = {
"sample1":{
Expand Down
27 changes: 23 additions & 4 deletions src/shared/components/oncoprint/ResultsViewOncoprintUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export function makeProfiledInClinicalAttributes(

const existsUnprofiledCount:{[alterationType:string]:number} = _.reduce(coverageInformation, (map, sampleCoverage)=>{
const isUnprofiled:{[alterationType:string]:boolean} = {};

// if a sample is not profiled in all genes, its certainly unprofiled for this profile
for (const gpData of sampleCoverage.notProfiledAllGenes) {
if (gpData.molecularProfileId in selectedMolecularProfilesMap) {
// mark isUnprofiled for this type because this is a selected profile
Expand All @@ -42,6 +44,8 @@ export function makeProfiledInClinicalAttributes(
] = true;
}
}

// if a sample is not profiled in some gene, then it is maybe unprofiled
_.forEach(sampleCoverage.notProfiledByGene, (geneInfo)=>{
for (const gpData of geneInfo) {
if (gpData.molecularProfileId in selectedMolecularProfilesMap) {
Expand All @@ -52,11 +56,26 @@ export function makeProfiledInClinicalAttributes(
}
}
});

// if a sample is profiled in some gene, then it is not unprofiled
_.forEach(sampleCoverage.byGene, geneInfo=>{
for (const gpData of geneInfo) {
if (gpData.molecularProfileId in selectedMolecularProfilesMap) {
// unmark isUnprofiled
isUnprofiled[
molecularProfileIdToMolecularProfile[gpData.molecularProfileId].molecularAlterationType
] = false;
}
}
});

// increment counts
for (const alterationType of Object.keys(isUnprofiled)) {
map[alterationType] = map[alterationType] || 0;
map[alterationType] += 1;
}
_.forEach(isUnprofiled, (_isUnprofiled, alterationType)=>{
if (_isUnprofiled) {
map[alterationType] = map[alterationType] || 0;
map[alterationType] += 1;
}
});
return map;
}, {} as {[alterationType:string]:number});

Expand Down

0 comments on commit a5bf7b1

Please sign in to comment.