Skip to content

Commit

Permalink
Updates based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kalletlak committed Nov 20, 2019
1 parent d8637d8 commit bf2861e
Show file tree
Hide file tree
Showing 14 changed files with 352 additions and 309 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/pages/groupComparison/ClinicalData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export default class ClinicalData extends React.Component<IClinicalDataProps, {}
}
});

public readonly groupSampleAxisData = remoteData({
private readonly groupMembershipAxisData = remoteData({
await: () => [this.props.store.sampleSet, this.props.store.activeGroups],
invoke: async () => {
const categoryOrder = _.map(this.props.store.activeGroups.result!, group => group.nameWithOrdinal);
Expand Down Expand Up @@ -286,11 +286,11 @@ export default class ClinicalData extends React.Component<IClinicalDataProps, {}
});

@computed get vertAxisDataPromise() {
return this.swapAxes ? this.groupSampleAxisData : this.clinicalDataPromise;
return this.swapAxes ? this.groupMembershipAxisData : this.clinicalDataPromise;
}

@computed get horzAxisDataPromise() {
return this.swapAxes ? this.clinicalDataPromise : this.groupSampleAxisData;
return this.swapAxes ? this.clinicalDataPromise : this.groupMembershipAxisData;
}

@computed get horzLabel() {
Expand Down
25 changes: 12 additions & 13 deletions src/pages/groupComparison/CopyNumberEnrichments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {MolecularProfile} from "../../shared/api/generated/CBioPortalAPI";
import {MakeMobxView} from "../../shared/components/MobxView";
import LoadingIndicator from "../../shared/components/loadingIndicator/LoadingIndicator";
import ErrorMessage from "../../shared/components/ErrorMessage";
import {MakeEnrichmentsTabUI, getNumSamples} from "./GroupComparisonUtils";
import {MakeEnrichmentsTabUI} from "./GroupComparisonUtils";
import { remoteData } from "public-lib/api/remoteData";
import _ from "lodash";
import { AlterationContainerType } from "pages/resultsView/enrichments/EnrichmentsUtil";
Expand All @@ -26,27 +26,26 @@ export default class CopyNumberEnrichments extends React.Component<ICopyNumberEn

readonly tabUI = MakeEnrichmentsTabUI(()=>this.props.store, ()=>this.enrichmentsUI, "copy-number", true, true, true);

private readonly enrichmentAnalysisGroups = remoteData({
await:()=>[this.props.store.activeGroups],
invoke:()=>{
const groups = _.map(this.props.store.activeGroups.result, group => {
private readonly copyNumberEnrichmentAnalysisGroups = remoteData({
await: () => [this.props.store.enrichmentAnalysisGroups],
invoke: () => {
return Promise.resolve(_.map(this.props.store.enrichmentAnalysisGroups.result, group => {
return {
name:group.nameWithOrdinal,
description:`Number (percentage) of ${this.props.store.usePatientLevelEnrichments ? "patients" : "samples"} in ${group.nameWithOrdinal} that have the listed alteration in the listed gene.`,
count: getNumSamples(group),
name: group.name,
description: `Number (percentage) of ${this.props.store.usePatientLevelEnrichments ? "patients" : "samples"} in ${group.name} that have the listed alteration in the listed gene.`,
count: group.count,
color: group.color
}
})
return Promise.resolve(groups);
}));
}
});

readonly enrichmentsUI = MakeMobxView({
await:()=>[
this.props.store.copyNumberEnrichmentData,
this.enrichmentAnalysisGroups,
this.copyNumberEnrichmentAnalysisGroups,
this.props.store.selectedStudyCopyNumberEnrichmentProfileMap,
this.enrichmentAnalysisGroups,
this.copyNumberEnrichmentAnalysisGroups,
this.props.store.studies
],
render:()=>{
Expand All @@ -65,7 +64,7 @@ export default class CopyNumberEnrichments extends React.Component<ICopyNumberEn
/>

<AlterationEnrichmentContainer data={this.props.store.copyNumberEnrichmentData.result!}
groups={this.enrichmentAnalysisGroups.result}
groups={this.copyNumberEnrichmentAnalysisGroups.result}
alteredVsUnalteredMode={false}
headerName={headerName}
showCNAInTable={true}
Expand Down
30 changes: 29 additions & 1 deletion src/pages/groupComparison/GroupComparisonStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
GroupComparisonTab,
IOverlapComputations,
isGroupEmpty,
partitionCasesByGroupMembership
partitionCasesByGroupMembership,
getNumSamples
} from "./GroupComparisonUtils";
import {remoteData} from "../../public-lib/api/remoteData";
import {
Expand Down Expand Up @@ -360,6 +361,33 @@ export default class GroupComparisonStore {
invoke:()=>Promise.resolve(this.availableGroups.result!.filter(group=>this.isGroupSelected(group.uid) && !isGroupEmpty(group)))
});

readonly enrichmentAnalysisGroups = remoteData({
await: () => [this.activeGroups, this.sampleSet],
invoke: () => {
const sampleSet = this.sampleSet.result || new ComplexKeyMap<Sample>();
const groups = this.activeGroups.result!.map(group => {
const samples: Sample[] = [];
group.studies.forEach(studyEntry => {
const studyId = studyEntry.id;
studyEntry.samples.forEach(sampleId => {
if (sampleSet.has({ studyId: studyId, sampleId })) {
const sample = sampleSet.get({ studyId: studyId, sampleId })!;
samples.push(sample);
}
});
});
return {
name: group.nameWithOrdinal,
description: "",
count: getNumSamples(group),
color: group.color,
samples
}
});
return Promise.resolve(groups);
}
});

readonly _originalGroupsOverlapRemoved = remoteData<ComparisonGroup[]>({
await:()=>[this.overlapComputations, this._originalGroups],
invoke:()=>Promise.resolve(this.overlapComputations.result!.groups)
Expand Down
37 changes: 11 additions & 26 deletions src/pages/groupComparison/MRNAEnrichments.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as React from "react";
import {observer} from "mobx-react";
import autobind from "autobind-decorator";
import {MolecularProfile, Sample} from "../../shared/api/generated/CBioPortalAPI";
import {MolecularProfile} from "../../shared/api/generated/CBioPortalAPI";
import {MakeMobxView} from "../../shared/components/MobxView";
import EnrichmentsDataSetDropdown from "../resultsView/enrichments/EnrichmentsDataSetDropdown";
import LoadingIndicator from "../../shared/components/loadingIndicator/LoadingIndicator";
import ErrorMessage from "../../shared/components/ErrorMessage";
import GroupComparisonStore from "./GroupComparisonStore";
import ExpressionEnrichmentContainer from "../resultsView/enrichments/ExpressionEnrichmentsContainer";
import {MakeEnrichmentsTabUI, getNumSamples} from "./GroupComparisonUtils";
import {MakeEnrichmentsTabUI} from "./GroupComparisonUtils";
import { remoteData } from "cbioportal-frontend-commons";
import ComplexKeyMap from "shared/lib/complexKeyDataStructures/ComplexKeyMap";
import * as _ from "lodash";

export interface IMRNAEnrichmentsProps {
store: GroupComparisonStore
Expand All @@ -23,30 +23,15 @@ export default class MRNAEnrichments extends React.Component<IMRNAEnrichmentsPro
this.props.store.setMRNAEnrichmentProfileMap(profileMap);
}

private readonly enrichmentAnalysisGroups = remoteData({
await: () => [this.props.store.activeGroups, this.props.store.sampleSet],
private readonly mrnaEnrichmentAnalysisGroups = remoteData({
await: () => [this.props.store.enrichmentAnalysisGroups],
invoke: () => {
const sampleSet = this.props.store.sampleSet.result || new ComplexKeyMap<Sample>();
const groups = this.props.store.activeGroups.result!.map(group => {
const uniqueSampleKeys: string[] = [];
group.studies.forEach(studyEntry => {
const studyId = studyEntry.id;
studyEntry.samples.forEach(sampleId => {
if (sampleSet.has({ studyId: studyId, sampleId })) {
const uniqueSampleKey = sampleSet.get({ studyId: studyId, sampleId })!.uniqueSampleKey;
uniqueSampleKeys.push(uniqueSampleKey);
}
});
});
return Promise.resolve(_.map(this.props.store.enrichmentAnalysisGroups.result, group => {
return {
name: group.nameWithOrdinal,
description: `samples in ${group.nameWithOrdinal}`,
count: getNumSamples(group),
color: group.color,
uniqueSampleKeys
...group,
description: `samples in ${group.name}`
}
});
return Promise.resolve(groups);
}));
}
});

Expand All @@ -56,7 +41,7 @@ export default class MRNAEnrichments extends React.Component<IMRNAEnrichmentsPro
await:()=>[
this.props.store.mRNAEnrichmentData,
this.props.store.selectedmRNAEnrichmentProfileMap,
this.enrichmentAnalysisGroups,
this.mrnaEnrichmentAnalysisGroups,
this.props.store.studies,
this.props.store.sampleKeyToSample
],
Expand All @@ -76,7 +61,7 @@ export default class MRNAEnrichments extends React.Component<IMRNAEnrichmentsPro
/>
<ExpressionEnrichmentContainer
data={this.props.store.mRNAEnrichmentData.result!}
groups={this.enrichmentAnalysisGroups.result}
groups={this.mrnaEnrichmentAnalysisGroups.result}
selectedProfile={selectedProfile}
alteredVsUnalteredMode={false}
sampleKeyToSample={this.props.store.sampleKeyToSample.result!}
Expand Down
24 changes: 11 additions & 13 deletions src/pages/groupComparison/MutationEnrichments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import EnrichmentsDataSetDropdown from "../resultsView/enrichments/EnrichmentsDa
import AlterationEnrichmentContainer from "../resultsView/enrichments/AlterationEnrichmentsContainer";
import autobind from "autobind-decorator";
import { MakeMobxView } from "../../shared/components/MobxView";
import { MakeEnrichmentsTabUI, getNumSamples } from "./GroupComparisonUtils";
import { MakeEnrichmentsTabUI } from "./GroupComparisonUtils";
import { remoteData } from "public-lib/api/remoteData";
import { ResultsViewPageStore } from "../resultsView/ResultsViewPageStore";
import _ from "lodash";
import { AlterationContainerType } from "pages/resultsView/enrichments/EnrichmentsUtil";

Expand All @@ -28,26 +27,25 @@ export default class MutationEnrichments extends React.Component<IMutationEnrich

readonly tabUI = MakeEnrichmentsTabUI(()=>this.props.store, ()=>this.enrichmentsUI, "mutation", true, true, true);

private readonly enrichmentAnalysisGroups = remoteData({
await:()=>[this.props.store.activeGroups],
invoke:()=>{
const groups = _.map(this.props.store.activeGroups.result, group => {
private readonly mutationEnrichmentAnalysisGroups = remoteData({
await: () => [this.props.store.enrichmentAnalysisGroups],
invoke: () => {
return Promise.resolve(_.map(this.props.store.enrichmentAnalysisGroups.result, group => {
return {
name:group.nameWithOrdinal,
description:`Number (percentage) of ${this.props.store.usePatientLevelEnrichments ? "patients" : "samples"} in ${group.nameWithOrdinal} that have a mutation in the listed gene.`,
count: getNumSamples(group),
name: group.name,
description:`Number (percentage) of ${this.props.store.usePatientLevelEnrichments ? "patients" : "samples"} in ${group.name} that have a mutation in the listed gene.`,
count: group.count,
color: group.color
}
})
return Promise.resolve(groups);
}));
}
});

readonly enrichmentsUI = MakeMobxView({
await:()=>[
this.props.store.mutationEnrichmentData,
this.props.store.selectedStudyMutationEnrichmentProfileMap,
this.enrichmentAnalysisGroups,
this.mutationEnrichmentAnalysisGroups,
this.props.store.studies
],
render:()=>{
Expand All @@ -65,7 +63,7 @@ export default class MutationEnrichments extends React.Component<IMutationEnrich
studies={this.props.store.studies.result!}
/>
<AlterationEnrichmentContainer data={this.props.store.mutationEnrichmentData.result!}
groups={this.enrichmentAnalysisGroups.result}
groups={this.mutationEnrichmentAnalysisGroups.result}
alteredVsUnalteredMode={false}
headerName={headerName}
containerType={AlterationContainerType.MUTATION}
Expand Down
36 changes: 10 additions & 26 deletions src/pages/groupComparison/ProteinEnrichments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import ExpressionEnrichmentContainer from "../resultsView/enrichments/Expression
import Loader from "../../shared/components/loadingIndicator/LoadingIndicator";
import ErrorMessage from "../../shared/components/ErrorMessage";
import GroupComparisonStore from "./GroupComparisonStore";
import {MakeEnrichmentsTabUI, getNumSamples} from "./GroupComparisonUtils";
import {MakeEnrichmentsTabUI} from "./GroupComparisonUtils";
import { remoteData } from "cbioportal-frontend-commons";
import ComplexKeyMap from "shared/lib/complexKeyDataStructures/ComplexKeyMap";
import { Sample } from "shared/api/generated/CBioPortalAPIInternal";
import * as _ from "lodash";

export interface IProteinEnrichmentsProps {
store: GroupComparisonStore
Expand All @@ -24,30 +23,15 @@ export default class ProteinEnrichments extends React.Component<IProteinEnrichme
this.props.store.setProteinEnrichmentProfileMap(profileMap);
}

private readonly enrichmentAnalysisGroups = remoteData({
await: () => [this.props.store.activeGroups, this.props.store.sampleSet],
private readonly proteinEnrichmentAnalysisGroups = remoteData({
await: () => [this.props.store.enrichmentAnalysisGroups],
invoke: () => {
const sampleSet = this.props.store.sampleSet.result || new ComplexKeyMap<Sample>();
const groups = this.props.store.activeGroups.result!.map(group => {
const uniqueSampleKeys: string[] = [];
group.studies.forEach(studyEntry => {
const studyId = studyEntry.id;
studyEntry.samples.forEach(sampleId => {
if (sampleSet.has({ studyId: studyId, sampleId })) {
const uniqueSampleKey = sampleSet.get({ studyId: studyId, sampleId })!.uniqueSampleKey;
uniqueSampleKeys.push(uniqueSampleKey);
}
});
});
return Promise.resolve(_.map(this.props.store.enrichmentAnalysisGroups.result, group => {
return {
name: group.nameWithOrdinal,
description: `samples in ${group.nameWithOrdinal}`,
count: getNumSamples(group),
color: group.color,
uniqueSampleKeys
...group,
description: `samples in ${group.name}`
}
});
return Promise.resolve(groups);
}));
}
});

Expand All @@ -57,7 +41,7 @@ export default class ProteinEnrichments extends React.Component<IProteinEnrichme
await:()=>[
this.props.store.proteinEnrichmentData,
this.props.store.selectedProteinEnrichmentProfileMap,
this.enrichmentAnalysisGroups,
this.proteinEnrichmentAnalysisGroups,
this.props.store.studies
],
render:()=>{
Expand All @@ -76,7 +60,7 @@ export default class ProteinEnrichments extends React.Component<IProteinEnrichme
/>
<ExpressionEnrichmentContainer
data={this.props.store.proteinEnrichmentData.result!}
groups={this.enrichmentAnalysisGroups.result}
groups={this.proteinEnrichmentAnalysisGroups.result}
selectedProfile={selectedProfile}
alteredVsUnalteredMode={false}
sampleKeyToSample={this.props.store.sampleKeyToSample.result!}
Expand Down

0 comments on commit bf2861e

Please sign in to comment.