Skip to content
Draft
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
45 changes: 45 additions & 0 deletions src/pages/patientView/PatientViewPageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { HelpWidget } from 'shared/components/HelpWidget/HelpWidget';
import MutationTableWrapper from './mutation/MutationTableWrapper';
import { PatientViewPageInner } from 'pages/patientView/PatientViewPage';
import { Else, If } from 'react-if';
import ExpressionTableWrapper from './expression/ExpressionTableWrapper';

export enum PatientViewPageTabs {
Summary = 'summary',
Expand All @@ -49,6 +50,7 @@ export enum PatientViewPageTabs {
TrialMatchTab = 'trialMatchTab',
MutationalSignatures = 'mutationalSignatures',
PathwayMapper = 'pathways',
Expression = 'expression',
}

export const PatientViewResourceTabPrefix = 'openResource_';
Expand Down Expand Up @@ -488,6 +490,49 @@ export function tabs(
</MSKTab>
);

pageComponent.patientViewPageStore.isExpressionProfiledForPatient
.isComplete &&
pageComponent.patientViewPageStore.isExpressionProfiledForPatient
.result &&
tabs.push(
<MSKTab
key={9}
id={PatientViewPageTabs.Expression}
linkText={'Expression'}
>
{pageComponent.patientViewPageStore
.mrnaExpressionDataByGeneThenProfile.isComplete &&
pageComponent.patientViewPageStore
.proteinExpressionDataByGeneThenProfile.isComplete &&
pageComponent.patientViewPageStore.mutationData.isComplete &&
pageComponent.patientViewPageStore.structuralVariantData
.isComplete &&
pageComponent.patientViewPageStore.cnaDataByGeneThenProfile
.isComplete &&
pageComponent.patientViewPageStore.allEntrezGeneIdsToGene
.isComplete &&
pageComponent.patientViewPageStore.allHugoGeneSymbolsToGene
.isComplete &&
pageComponent.patientViewPageStore
.analysisMrnaExpressionProfiles.isComplete &&
pageComponent.patientViewPageStore
.analysisProteinExpressionProfiles.isComplete ? (
<ExpressionTableWrapper
store={pageComponent.patientViewPageStore}
mergeOncoKbIcons={
pageComponent.mergeMutationTableOncoKbIcons
}
/>
) : (
<LoadingIndicator
isLoading={true}
size={'big'}
center={true}
/>
)}
</MSKTab>
);

tabs.push(
<MSKTab
key={8}
Expand Down
25 changes: 25 additions & 0 deletions src/pages/patientView/PatientViewPageUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import {
MutationalSignatureLabelMap,
MutationalSignatureCount,
} from '/shared/model/MutationalSignature';
import {
CNA_COLOR_AMP,
CNA_COLOR_DEFAULT,
CNA_COLOR_GAIN,
CNA_COLOR_HETLOSS,
CNA_COLOR_HOMDEL,
} from 'cbioportal-frontend-commons';
import { DEFAULT_GREY } from 'shared/lib/Colors';

export function getMutationalSignaturesVersionFromProfileId(
inputProfileId: string
Expand Down Expand Up @@ -121,3 +129,20 @@ export function createMutationalCountsObjects(
}));
return result;
}

export function getCNAColorByAlteration(alteration: string): string {
switch (alteration) {
case 'HOMDEL':
return CNA_COLOR_HOMDEL;
case 'HETLOSS':
return '#2aced4';
case 'DIPLOID':
return DEFAULT_GREY;
case 'GAIN':
return '#ff8c9f';
case 'AMP':
return CNA_COLOR_AMP;
default:
return CNA_COLOR_DEFAULT;
}
}
266 changes: 265 additions & 1 deletion src/pages/patientView/clinicalInformation/PatientViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
GenericAssayMeta,
GenericAssayDataMultipleStudyFilter,
GenericAssayMetaFilter,
MolecularDataFilter,
} from 'cbioportal-ts-api-client';
import { getClient } from '../../../shared/api/cbioportalClientInstance';
import internalClient from '../../../shared/api/cbioportalInternalClientInstance';
Expand Down Expand Up @@ -195,7 +196,10 @@ import {
} from 'shared/lib/GenericAssayUtils/MutationalSignaturesUtils';
import { getServerConfig } from 'config/config';
import { StructuralVariantFilter } from 'cbioportal-ts-api-client';
import { IGenePanelDataByProfileIdAndSample } from 'shared/lib/isSampleProfiled';
import {
IGenePanelDataByProfileIdAndSample,
isPatientProfiledInMultiple,
} from 'shared/lib/isSampleProfiled';
import { NamespaceColumnConfig } from 'shared/components/namespaceColumns/NamespaceColumnConfig';
import { buildNamespaceColumnConfig } from 'shared/components/namespaceColumns/namespaceColumnsUtils';
import { SiteError } from 'shared/model/appMisc';
Expand Down Expand Up @@ -470,6 +474,256 @@ export class PatientViewPageStore {
@observable
public patientIdsInCohort: string[] = [];

readonly allGenes = remoteData({
invoke: () => {
return getClient().getAllGenesUsingGET({
projection: 'SUMMARY',
});
},
});

readonly allEntrezGeneIdsToGene = remoteData<{
[entrezGeneId: number]: {
hugoGeneSymbol: string;
entrezGeneId: number;
};
}>({
await: () => [this.allGenes],
invoke: () =>
Promise.resolve(
_.keyBy(this.allGenes.result, gene => gene.entrezGeneId)
),
default: {},
});

readonly allHugoGeneSymbolsToGene = remoteData<{
[hugoGeneSymbol: string]: {
hugoGeneSymbol: string;
entrezGeneId: number;
};
}>({
await: () => [this.allGenes],
invoke: () =>
Promise.resolve(
_.keyBy(this.allGenes.result, gene => gene.hugoGeneSymbol)
),
default: {},
});

readonly cnaDataByGeneThenProfile = remoteData({
await: () => [this.cnaProfiles],
invoke: async () => {
const cnaMap: Record<
number,
Record<string, NumericGeneMolecularData[]>
> = {};
await Promise.all(
this.cnaProfiles.result.map(async p => {
let data = await getClient().fetchAllMolecularDataInMolecularProfileUsingPOST(
{
projection: 'DETAILED',
molecularProfileId: p.molecularProfileId,
molecularDataFilter: {
sampleIds: this.sampleIds,
} as MolecularDataFilter,
}
);
data.map(d => {
if (!cnaMap[d.entrezGeneId]) {
cnaMap[d.entrezGeneId] = {};
}
if (!cnaMap[d.entrezGeneId][d.molecularProfileId]) {
cnaMap[d.entrezGeneId][d.molecularProfileId] = [];
}
cnaMap[d.entrezGeneId][d.molecularProfileId].push(d);
});
})
);
return cnaMap;
},
default: {},
});

readonly cnaProfiles = remoteData(
{
await: () => [this.molecularProfilesInStudy],
invoke: () => {
return Promise.resolve(
this.molecularProfilesInStudy.result.filter(
p =>
p.molecularAlterationType ===
'COPY_NUMBER_ALTERATION'
)
);
},
},
[]
);

readonly mrnaExpressionDataByGeneThenProfile = remoteData({
await: () => [this.mrnaExpressionProfiles],
invoke: async () => {
const mrnaExpressionMap: Record<
number,
Record<string, NumericGeneMolecularData[]>
> = {};
await Promise.all(
this.mrnaExpressionProfiles.result.map(async p => {
let data = await getClient().fetchAllMolecularDataInMolecularProfileUsingPOST(
{
projection: 'DETAILED',
molecularProfileId: p.molecularProfileId,
molecularDataFilter: {
sampleIds: this.sampleIds,
} as MolecularDataFilter,
}
);
data.map(d => {
if (!mrnaExpressionMap[d.entrezGeneId]) {
mrnaExpressionMap[d.entrezGeneId] = {};
}
if (
!mrnaExpressionMap[d.entrezGeneId][
d.molecularProfileId
]
) {
mrnaExpressionMap[d.entrezGeneId][
d.molecularProfileId
] = [];
}
mrnaExpressionMap[d.entrezGeneId][
d.molecularProfileId
].push(d);
});
})
);
return mrnaExpressionMap;
},
default: {},
});

readonly mrnaExpressionProfiles = remoteData(
{
await: () => [this.molecularProfilesInStudy],
invoke: () => {
return Promise.resolve(
this.molecularProfilesInStudy.result.filter(
p => p.molecularAlterationType === 'MRNA_EXPRESSION'
)
);
},
},
[]
);

readonly analysisMrnaExpressionProfiles = remoteData(
{
await: () => [this.mrnaExpressionProfiles],
invoke: () => {
return Promise.resolve(
this.mrnaExpressionProfiles.result.filter(
p => p.showProfileInAnalysisTab
)
);
},
},
[]
);

readonly proteinExpressionDataByGeneThenProfile = remoteData({
await: () => [this.proteinExpressionProfiles],
invoke: async () => {
const proteinExpressionMap: Record<
number,
Record<string, NumericGeneMolecularData[]>
> = {};
await Promise.all(
this.proteinExpressionProfiles.result.map(async p => {
let data = await getClient().fetchAllMolecularDataInMolecularProfileUsingPOST(
{
projection: 'DETAILED',
molecularProfileId: p.molecularProfileId,
molecularDataFilter: {
sampleIds: this.sampleIds,
} as MolecularDataFilter,
}
);
data.map(d => {
if (!proteinExpressionMap[d.entrezGeneId]) {
proteinExpressionMap[d.entrezGeneId] = {};
}
if (
!proteinExpressionMap[d.entrezGeneId][
d.molecularProfileId
]
) {
proteinExpressionMap[d.entrezGeneId][
d.molecularProfileId
] = [];
}
proteinExpressionMap[d.entrezGeneId][
d.molecularProfileId
].push(d);
});
})
);
return proteinExpressionMap;
},
default: {},
});

readonly proteinExpressionProfiles = remoteData(
{
await: () => [this.molecularProfilesInStudy],
invoke: () => {
return Promise.resolve(
this.molecularProfilesInStudy.result.filter(
p => p.molecularAlterationType === 'PROTEIN_LEVEL'
)
);
},
},
[]
);

readonly analysisProteinExpressionProfiles = remoteData(
{
await: () => [this.proteinExpressionProfiles],
invoke: () => {
return Promise.resolve(
this.proteinExpressionProfiles.result.filter(
p => p.showProfileInAnalysisTab
)
);
},
},
[]
);

readonly isExpressionProfiledForPatient = remoteData({
await: () => [
this.mrnaExpressionProfiles,
this.proteinExpressionProfiles,
this.derivedUniquePatientKey,
this.coverageInformation,
],
invoke: () => {
const expressionProfileIds = [
...this.mrnaExpressionProfiles.result,
...this.proteinExpressionProfiles.result,
].map(p => p.molecularProfileId);
return Promise.resolve(
_.some(
isPatientProfiledInMultiple(
this.derivedUniquePatientKey.result,
expressionProfileIds,
this.coverageInformation.result
)
)
);
},
});

// public set patientIdsInCohort(cohortIds: string[]) {
// // cannot put action on setter
// runInAction(() => (this._patientIdsInCohort = cohortIds || []));
Expand Down Expand Up @@ -819,6 +1073,16 @@ export class PatientViewPageStore {
default: '',
});

readonly derivedUniquePatientKey = remoteData<string>({
await: () => [this.samples],
invoke: async () => {
for (let sample of this.samples.result)
return sample.uniquePatientKey;
return '';
},
default: '',
});

readonly clinicalDataPatient = remoteData({
await: () =>
this.pageMode === 'patient' ? [] : [this.derivedPatientId],
Expand Down
Loading