Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error while calculating profiled samples count #3041

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ import {
getUniqueKey,
StudyWithSamples,
UniqueKey,
getUniqueKeyFromMolecularProfileIds,
ChartMetaDataTypeEnum,
} from 'pages/studyView/StudyViewUtils';
import {
FRACTION_GENOME_ALTERED,
Expand All @@ -206,6 +208,7 @@ import {
fetchTreatmentByMolecularProfileIds,
Treatment,
} from 'shared/lib/GenericAssayUtils/TreatmentUtils';
import { ChartTypeEnum } from 'pages/studyView/StudyViewConfig';

type Optional<T> =
| { isApplicable: true; value: T }
Expand Down Expand Up @@ -2378,28 +2381,38 @@ export class ResultsViewPageStore {
);

if (!_.isEmpty(this.mutationProfiles.result!)) {
_chartMetaSet[UniqueKey.MUTATED_GENES_TABLE] = {
uniqueKey: UniqueKey.MUTATED_GENES_TABLE,
dataType: getChartMetaDataType(UniqueKey.MUTATED_GENES_TABLE),
const uniqueKey = getUniqueKeyFromMolecularProfileIds(
this.mutationProfiles.result.map(
profile => profile.molecularProfileId
)
);
_chartMetaSet[uniqueKey] = {
uniqueKey: uniqueKey,
dataType: ChartMetaDataTypeEnum.GENOMIC,
patientAttribute: false,
displayName: 'Mutated Genes',
priority: getDefaultPriorityByUniqueKey(
UniqueKey.MUTATED_GENES_TABLE
ChartTypeEnum.MUTATED_GENES_TABLE
),
renderWhenDataChange: false,
description: '',
};
}

if (!_.isEmpty(this.cnaProfiles.result)) {
_chartMetaSet[UniqueKey.CNA_GENES_TABLE] = {
uniqueKey: UniqueKey.CNA_GENES_TABLE,
dataType: getChartMetaDataType(UniqueKey.CNA_GENES_TABLE),
const uniqueKey = getUniqueKeyFromMolecularProfileIds(
this.cnaProfiles.result.map(
profile => profile.molecularProfileId
)
);
_chartMetaSet[uniqueKey] = {
uniqueKey: uniqueKey,
dataType: ChartMetaDataTypeEnum.GENOMIC,
patientAttribute: false,
displayName: 'CNA Genes',
renderWhenDataChange: false,
priority: getDefaultPriorityByUniqueKey(
UniqueKey.CNA_GENES_TABLE
ChartTypeEnum.CNA_GENES_TABLE
),
description: '',
};
Expand All @@ -2424,9 +2437,7 @@ export class ResultsViewPageStore {
scatterRequiredParams[FRACTION_GENOME_ALTERED]
) {
_chartMetaSet[UniqueKey.MUTATION_COUNT_CNA_FRACTION] = {
dataType: getChartMetaDataType(
UniqueKey.MUTATION_COUNT_CNA_FRACTION
),
dataType: ChartMetaDataTypeEnum.GENOMIC,
patientAttribute: false,
uniqueKey: UniqueKey.MUTATION_COUNT_CNA_FRACTION,
displayName: 'Mutation Count vs Fraction of Genome Altered',
Expand Down
56 changes: 35 additions & 21 deletions src/pages/studyView/StudyViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import {
getMolecularProfileIdsFromUniqueKey,
getClinicalDataBySamples,
updateSavedUserPreferenceChartIds,
ChartMetaDataTypeEnum,
} from './StudyViewUtils';
import MobxPromise from 'mobxpromise';
import { SingleGeneQuery } from 'shared/lib/oql/oql-parser';
Expand Down Expand Up @@ -2936,11 +2937,11 @@ export class StudyViewPageStore {
);
_chartMetaSet[uniqueKey] = {
uniqueKey: uniqueKey,
dataType: getChartMetaDataType(UniqueKey.MUTATED_GENES_TABLE),
dataType: ChartMetaDataTypeEnum.GENOMIC,
patientAttribute: false,
displayName: 'Mutated Genes',
priority: getDefaultPriorityByUniqueKey(
UniqueKey.MUTATED_GENES_TABLE
ChartTypeEnum.MUTATED_GENES_TABLE
),
renderWhenDataChange: false,
description: '',
Expand All @@ -2955,11 +2956,11 @@ export class StudyViewPageStore {
);
_chartMetaSet[uniqueKey] = {
uniqueKey: uniqueKey,
dataType: getChartMetaDataType(UniqueKey.FUSION_GENES_TABLE),
dataType: ChartMetaDataTypeEnum.GENOMIC,
patientAttribute: false,
displayName: 'Fusion Genes',
priority: getDefaultPriorityByUniqueKey(
UniqueKey.FUSION_GENES_TABLE
ChartTypeEnum.FUSION_GENES_TABLE
),
renderWhenDataChange: true,
description: '',
Expand All @@ -2974,12 +2975,12 @@ export class StudyViewPageStore {
);
_chartMetaSet[uniqueKey] = {
uniqueKey: uniqueKey,
dataType: getChartMetaDataType(UniqueKey.CNA_GENES_TABLE),
dataType: ChartMetaDataTypeEnum.GENOMIC,
patientAttribute: false,
displayName: 'CNA Genes',
renderWhenDataChange: false,
priority: getDefaultPriorityByUniqueKey(
UniqueKey.CNA_GENES_TABLE
ChartTypeEnum.CNA_GENES_TABLE
),
description: '',
};
Expand All @@ -3004,9 +3005,7 @@ export class StudyViewPageStore {
scatterRequiredParams[FRACTION_GENOME_ALTERED]
) {
_chartMetaSet[UniqueKey.MUTATION_COUNT_CNA_FRACTION] = {
dataType: getChartMetaDataType(
UniqueKey.MUTATION_COUNT_CNA_FRACTION
),
dataType: ChartMetaDataTypeEnum.GENOMIC,
patientAttribute: false,
uniqueKey: UniqueKey.MUTATION_COUNT_CNA_FRACTION,
displayName: 'Mutation Count vs Fraction of Genome Altered',
Expand Down Expand Up @@ -3273,19 +3272,19 @@ export class StudyViewPageStore {
}

switch (chartUserSettings.chartType) {
case UniqueKey.MUTATED_GENES_TABLE:
case ChartTypeEnum.MUTATED_GENES_TABLE:
this._filterMutatedGenesTableByCancerGenes =
chartUserSettings.filterByCancerGenes === undefined
? true
: chartUserSettings.filterByCancerGenes;
break;
case UniqueKey.FUSION_GENES_TABLE:
case ChartTypeEnum.FUSION_GENES_TABLE:
this._filterFusionGenesTableByCancerGenes =
chartUserSettings.filterByCancerGenes === undefined
? true
: chartUserSettings.filterByCancerGenes;
break;
case UniqueKey.CNA_GENES_TABLE:
case ChartTypeEnum.CNA_GENES_TABLE:
this._filterCNAGenesTableByCancerGenes =
chartUserSettings.filterByCancerGenes === undefined
? true
Expand Down Expand Up @@ -4843,9 +4842,14 @@ export class StudyViewPageStore {
{}
);

if (UniqueKey.MUTATED_GENES_TABLE in this.chartMetaSet) {
ret[UniqueKey.MUTATED_GENES_TABLE] = this
.molecularProfileSampleCounts.result
if (!_.isEmpty(this.mutationProfiles.result)) {
const uniqueKey = getUniqueKeyFromMolecularProfileIds(
this.mutationProfiles.result.map(
profile => profile.molecularProfileId
)
);

ret[uniqueKey] = this.molecularProfileSampleCounts.result
? this.molecularProfileSampleCounts.result
.numberOfMutationProfiledSamples
: 0;
Expand All @@ -4856,9 +4860,14 @@ export class StudyViewPageStore {
: 0;
}

if (UniqueKey.FUSION_GENES_TABLE in this.chartMetaSet) {
ret[UniqueKey.FUSION_GENES_TABLE] = this
.molecularProfileSampleCounts.result
if (!_.isEmpty(this.structuralVariantProfiles.result)) {
const uniqueKey = getUniqueKeyFromMolecularProfileIds(
this.structuralVariantProfiles.result.map(
profile => profile.molecularProfileId
)
);

ret[uniqueKey] = this.molecularProfileSampleCounts.result
? this.molecularProfileSampleCounts.result
.numberOfFusionProfiledSamples
: 0;
Expand All @@ -4869,9 +4878,14 @@ export class StudyViewPageStore {
: 0;
}

if (UniqueKey.CNA_GENES_TABLE in this.chartMetaSet) {
ret[UniqueKey.CNA_GENES_TABLE] = this
.molecularProfileSampleCounts.result
if (!_.isEmpty(this.cnaProfiles.result)) {
const uniqueKey = getUniqueKeyFromMolecularProfileIds(
this.cnaProfiles.result.map(
profile => profile.molecularProfileId
)
);

ret[uniqueKey] = this.molecularProfileSampleCounts.result
? this.molecularProfileSampleCounts.result
.numberOfCNAProfiledSamples
: 0;
Expand Down
12 changes: 3 additions & 9 deletions src/pages/studyView/StudyViewUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ export type ChartType =
| 'NONE';

export enum UniqueKey {
MUTATED_GENES_TABLE = 'MUTATED_GENES_TABLE',
FUSION_GENES_TABLE = 'FUSION_GENES_TABLE',
CNA_GENES_TABLE = 'CNA_GENES_TABLE',
CUSTOM_SELECT = 'CUSTOM_SELECT',
SELECTED_COMPARISON_GROUPS = 'SELECTED_COMPARISON_GROUPS',
MUTATION_COUNT_CNA_FRACTION = 'MUTATION_COUNT_CNA_FRACTION',
Expand Down Expand Up @@ -1258,14 +1255,11 @@ export function toFixedDigit(value: number, fractionDigits: number = 2) {
export function getChartMetaDataType(uniqueKey: string): ChartMetaDataType {
const GENOMIC_DATA_TYPES = [
UniqueKey.MUTATION_COUNT_CNA_FRACTION,
UniqueKey.CNA_GENES_TABLE,
UniqueKey.MUTATED_GENES_TABLE,
UniqueKey.MUTATION_COUNT,
UniqueKey.FRACTION_GENOME_ALTERED,
UniqueKey.WITH_MUTATION_DATA,
UniqueKey.WITH_CNA_DATA,
UniqueKey.WITH_FUSION_DATA,
UniqueKey.FUSION_GENES_TABLE,
];
return _.includes(GENOMIC_DATA_TYPES, uniqueKey)
? ChartMetaDataTypeEnum.GENOMIC
Expand Down Expand Up @@ -2193,15 +2187,15 @@ export function getChartSettingsMap(
chartType,
patientAttribute: attribute.patientAttribute, // add chart attribute type
};
if (chartType === UniqueKey.MUTATED_GENES_TABLE) {
if (chartType === ChartTypeEnum.MUTATED_GENES_TABLE) {
chartSettingsMap[
attribute.uniqueKey
].filterByCancerGenes = filterMutatedGenesTableByCancerGenes;
} else if (chartType === UniqueKey.FUSION_GENES_TABLE) {
} else if (chartType === ChartTypeEnum.FUSION_GENES_TABLE) {
chartSettingsMap[
attribute.uniqueKey
].filterByCancerGenes = filterFusionGenesTableByCancerGenes;
} else if (chartType === UniqueKey.CNA_GENES_TABLE) {
} else if (chartType === ChartTypeEnum.CNA_GENES_TABLE) {
chartSettingsMap[
attribute.uniqueKey
].filterByCancerGenes = filterCNAGenesTableByCancerGenes;
Expand Down
8 changes: 4 additions & 4 deletions src/pages/studyView/UserSelections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { PillTag } from '../../shared/components/PillTag/PillTag';
import { GroupLogic } from './filters/groupLogic/GroupLogic';
import classnames from 'classnames';
import { STUDY_VIEW_CONFIG } from './StudyViewConfig';
import { STUDY_VIEW_CONFIG, ChartTypeEnum } from './StudyViewConfig';
import {
DEFAULT_NA_COLOR,
MUT_COLOR_FUSION,
Expand Down Expand Up @@ -319,13 +319,13 @@ export default class UserSelections extends React.Component<
switch (
chartMeta.chartType
) {
case UniqueKey.MUTATED_GENES_TABLE:
case ChartTypeEnum.MUTATED_GENES_TABLE:
color = MUT_COLOR_MISSENSE;
break;
case UniqueKey.FUSION_GENES_TABLE:
case ChartTypeEnum.FUSION_GENES_TABLE:
color = MUT_COLOR_FUSION;
break;
case UniqueKey.CNA_GENES_TABLE: {
case ChartTypeEnum.CNA_GENES_TABLE: {
const oqlParts = oql
.trim()
.split(':');
Expand Down