Skip to content

Commit

Permalink
fixed mutation type filter counts
Browse files Browse the repository at this point in the history
Signed-off-by: Onur Sumer <s.onur.sumer@gmail.com>
  • Loading branch information
onursumer committed Oct 28, 2019
1 parent be828dd commit 10b09f3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"react-markdown": "^3.4.1",
"react-mfb": "^0.6.0",
"react-motion": "^0.4.7",
"react-mutation-mapper": "^0.3.0-beta.5",
"react-mutation-mapper": "^0.3.0-beta.11",
"react-overlays": "0.7.4",
"react-portal": "^4.2.0",
"react-rangeslider": "^2.1.0",
Expand Down
41 changes: 18 additions & 23 deletions src/shared/components/mutationMapper/MutationMapperDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as _ from 'lodash';
import {action, computed, observable} from "mobx";
import autobind from "autobind-decorator";
import {
applyDataFiltersOnDatum,
DataFilter,
DataFilterType,
DataStore,
Expand Down Expand Up @@ -43,7 +44,7 @@ export default class MutationMapperDataStore

@computed
public get sortedFilteredGroupedData(): GroupedData {
return groupDataByGroupFilters(this.groupFilters, this, this.applyFilter);
return groupDataByGroupFilters(this.groupFilters, this.sortedFilteredData, this.applyFilter);
}

@computed
Expand Down Expand Up @@ -105,15 +106,15 @@ export default class MutationMapperDataStore
{
super.setFilter((d:Mutation[], filterString?:string, filterStringUpper?:string, filterStringLower?:string) =>
(!fn || fn(d, filterString, filterStringUpper, filterStringLower)) &&
(this.dataFilters.length === 0 || this.dataMainFilter(d[0]))
(this.dataFilters.length === 0 || this.dataMainFilter(d))
);
}

// override the parent method to always keep the default main filter
@action
public resetFilter() {
super.resetFilter();
this.dataFilter = (d:Mutation[]) => (this.dataFilters.length === 0 || this.dataMainFilter(d[0]));
this.dataFilter = (d:Mutation[]) => (this.dataFilters.length === 0 || this.dataMainFilter(d));
}

@action
Expand Down Expand Up @@ -160,41 +161,28 @@ export default class MutationMapperDataStore
}

@autobind
public dataMainFilter(mutation: Mutation): boolean
public dataMainFilter(d: Mutation[]): boolean
{
return (
this.dataFilters.length > 0 &&
!this.dataFilters
.map(dataFilter => this.applyFilter(dataFilter, mutation))
.includes(false)
);
return applyDataFiltersOnDatum(d, this.dataFilters, this.applyFilter);
}

@autobind
public dataSelectFilter(d: Mutation[]): boolean
{
return (
this.selectionFilters.length > 0 &&
!this.selectionFilters
.map(dataFilter => this.applyFilter(dataFilter, d[0]))
.includes(false)
);
return applyDataFiltersOnDatum(d, this.selectionFilters, this.applyFilter);
}

@autobind
public dataHighlightFilter(d: Mutation[]): boolean
{
return (
this.highlightFilters.length > 0 &&
!this.highlightFilters
.map(dataFilter => this.applyFilter(dataFilter, d[0]))
.includes(false)
);
return applyDataFiltersOnDatum(d, this.highlightFilters, this.applyFilter);
}

@autobind
public applyFilter(filter: DataFilter, mutation: Mutation): boolean
public applyFilter(filter: DataFilter, d: Mutation | Mutation[]): boolean
{
const mutation = _.flatten([d])[0];

if (this.customFilterApplier) {
// let the custom filter applier decide how to apply the given filter
return this.customFilterApplier.applyFilter(filter, mutation);
Expand All @@ -204,4 +192,11 @@ export default class MutationMapperDataStore
return filter.type !== DataFilterType.POSITION || filter.values.includes(mutation.proteinPosStart);
}
}

@autobind
public applyLazyMobXTableFilter(d: Mutation | Mutation[]): boolean
{
return !this.filterString || this.dataFilter(
[_.flatten([d])[0]], this.filterString.toLowerCase(), this.filterString.toUpperCase());
}
}
25 changes: 22 additions & 3 deletions src/shared/components/mutationMapper/MutationMapperStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import {computed} from "mobx";
import MobxPromise, {cached, labelMobxPromises} from "mobxpromise";

import {
DataFilter, defaultHotspotFilter,
applyDataFilters,
DataFilterType,
DefaultMutationMapperDataFetcher,
DefaultMutationMapperStore, defaultOncoKbFilter,
DefaultMutationMapperStore,
getMutationsToTranscriptId,
groupDataByProteinImpactType,
groupOncoKbIndicatorDataByMutations,
IHotspotIndex, isHotspot
IHotspotIndex
} from "react-mutation-mapper";

import genomeNexusClient from "shared/api/genomeNexusClientInstance";
Expand Down Expand Up @@ -153,6 +155,23 @@ export default class MutationMapperStore extends DefaultMutationMapperStore
}
}

@computed
protected get mutationsGroupedByProteinImpactType()
{
const filtersWithoutProteinImpactTypeFilter =
this.dataStore.dataFilters.filter(f => f.type !== DataFilterType.PROTEIN_IMPACT_TYPE);

// apply filters excluding the protein impact type filters
// this prevents number of unchecked protein impact types from being counted as zero
let sortedFilteredData = applyDataFilters(
this.dataStore.allData, filtersWithoutProteinImpactTypeFilter, this.dataStore.applyFilter);

// also apply lazy mobx table search filter
sortedFilteredData = sortedFilteredData.filter(m => this.dataStore.applyLazyMobXTableFilter(m));

return groupDataByProteinImpactType(sortedFilteredData);
}

@computed get processedMutationData(): Mutation[][] {
// just convert Mutation[] to Mutation[][]
return (this.mutationData.result || []).map(mutation => [mutation]);
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3472,10 +3472,10 @@ caseless@~0.12.0:
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=

cbioportal-frontend-commons@^0.0.22:
version "0.0.22"
resolved "https://registry.yarnpkg.com/cbioportal-frontend-commons/-/cbioportal-frontend-commons-0.0.22.tgz#6a547913adadf2ae2de08c2ca31f4d5103a409ed"
integrity sha512-ECWVbXvkqF0msXcrcDXN1MmQ1f1cfi6/++IkE4ThpSuxNmK08/BsXbYZCqDof42v70yN1auXEbhs3jWNDjHk1g==
cbioportal-frontend-commons@^0.0.23:
version "0.0.23"
resolved "https://registry.yarnpkg.com/cbioportal-frontend-commons/-/cbioportal-frontend-commons-0.0.23.tgz#1bd3f2d2a59f5b9b718eb66e862e9ca374a22cf8"
integrity sha512-6jdSgduNDCiJuXW05Of/eC6V3JVrEUcOWtao/tex0PdG6nAV0F5H+QeVIkiQ6GVF21LSrB9Loc+vrVklXOmWXQ==
dependencies:
autobind-decorator "^2.1.0"
babel-polyfill "^6.22.0"
Expand Down Expand Up @@ -12623,13 +12623,13 @@ react-motion@^0.5.2:
prop-types "^15.5.8"
raf "^3.1.0"

react-mutation-mapper@^0.3.0-beta.5:
version "0.3.0-beta.5"
resolved "https://registry.yarnpkg.com/react-mutation-mapper/-/react-mutation-mapper-0.3.0-beta.5.tgz#eea4d9a94414a3e43a1251d2b5cbe95c93de5514"
integrity sha512-MqcFrFSwCfYcQFjxS581X3D+XKCqSYural4dS1OUVnLPIennmHAUVzx0usZAXX1vh1ykI7ZbEumuWJ17knrRFA==
react-mutation-mapper@^0.3.0-beta.11:
version "0.3.0-beta.11"
resolved "https://registry.yarnpkg.com/react-mutation-mapper/-/react-mutation-mapper-0.3.0-beta.11.tgz#7a7f876e574b593943b2e98435b31f0a061c0ef8"
integrity sha512-Whx0gJrw3ivs3wYsamvwpSYO4EeLsZXlGQdfNy3Npz7kINcM+Kthzup6JIxDhMs/5PDSyBsVeVWvlgxQ0YEnfQ==
dependencies:
autobind-decorator "^2.4.0"
cbioportal-frontend-commons "^0.0.21"
cbioportal-frontend-commons "^0.0.23"
classnames "^2.2.6"
jquery "^3.3.1"
lodash "^4.17.11"
Expand Down

0 comments on commit 10b09f3

Please sign in to comment.