Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('CancerSummaryChart', () => {
],
countsByGroup: {
'Lung Adenocarcinoma': {
profiledSampleTotal: 660,
profiledTotal: 660,
alterationTotal: 547,
alterationTypeCounts: {
mutated: 280,
Expand All @@ -180,11 +180,11 @@ describe('CancerSummaryChart', () => {
protExpressionLow: 0,
multiple: 87,
},
alteredSampleCount: 460,
alteredCount: 460,
parentCancerType: 'Non-Small Cell Lung Cancer',
},
'Lung Squamous Cell Carcinoma': {
profiledSampleTotal: 484,
profiledTotal: 484,
alterationTotal: 574,
alterationTypeCounts: {
mutated: 292,
Expand All @@ -199,7 +199,7 @@ describe('CancerSummaryChart', () => {
protExpressionLow: 0,
multiple: 131,
},
alteredSampleCount: 443,
alteredCount: 443,
parentCancerType: 'Non-Small Cell Lung Cancer',
},
},
Expand Down
79 changes: 50 additions & 29 deletions src/pages/resultsView/cancerSummary/CancerSummaryChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface CancerSummaryChartProps {
countsByGroup: { [groupName: string]: IAlterationData };
xLabels: string[];
xAxisString: string;
countAlterationsBy: string;
representedAlterations: { [alterationType: string]: boolean };
isPercentage: boolean;
showLinks: boolean;
Expand Down Expand Up @@ -111,6 +112,43 @@ export function mergeAlterationDataAcrossAlterationTypes(
});
}

export function formatGeneAlteredText(
useSampleCounts: boolean,
tooltipModel: ITooltipModel
) {
const alteredPercentage = percentageRounder(
tooltipModel.alterationData.alteredCount /
tooltipModel.alterationData.profiledTotal
);

const profiledTotal = tooltipModel.alterationData.profiledTotal;

const casesOrSamples = useSampleCounts ? 'samples' : 'cases';

return `Gene altered in ${alteredPercentage}% of ${profiledTotal} ${casesOrSamples}`;
}

export function formatFrequencyText(
useSampleCounts: boolean,
tooltipModel: ITooltipModel,
alterationType: string
) {
const alterationCount = (tooltipModel!.alterationData
.alterationTypeCounts as any)[alterationType];
const profiledTotal = tooltipModel!.alterationData.profiledTotal;

const alteredPercentage = percentageRounder(
alterationCount / profiledTotal
);

const casesOrSamples = useSampleCounts ? 'sample' : 'case';

return `${alteredPercentage}% (${alterationCount} ${pluralize(
casesOrSamples,
alterationCount
)})`;
}

@observer
export class CancerSummaryChart extends React.Component<
CancerSummaryChartProps,
Expand Down Expand Up @@ -208,7 +246,9 @@ export class CancerSummaryChart extends React.Component<
let tooltipMessage = 'Not profiled';
if (profiledCount > 0) {
tooltipMessage = `${profiledCount} ${pluralize(
'sample',
this.props.countAlterationsBy === 'sampleCounts'
? 'sample'
: 'patient',
profiledCount
)} profiled`;
}
Expand Down Expand Up @@ -248,6 +288,8 @@ export class CancerSummaryChart extends React.Component<
if (!this.barPlotTooltipModel) {
return null;
} else {
const useSampleCounts =
this.props.countAlterationsBy === 'sampleCounts';
const tooltipModel = this.barPlotTooltipModel;
const maxWidth = 400;
let tooltipPlacement =
Expand Down Expand Up @@ -303,15 +345,10 @@ export class CancerSummaryChart extends React.Component<
</Else>
</If>
<p>
Gene altered in{' '}
{percentageRounder(
tooltipModel.alterationData.alteredSampleCount /
tooltipModel.alterationData
.profiledSampleTotal
{formatGeneAlteredText(
useSampleCounts,
tooltipModel
)}
% of{' '}
{tooltipModel.alterationData.profiledSampleTotal}{' '}
cases
</p>
<table className="table table-striped">
<thead>
Expand All @@ -333,31 +370,15 @@ export class CancerSummaryChart extends React.Component<
key
] > 0
) {
const alterationCount = (tooltipModel!
.alterationData
.alterationTypeCounts as any)[
key
];
memo.push(
<tr>
<td>{name}</td>
<td>
{percentageRounder(
(tooltipModel!
.alterationData
.alterationTypeCounts as any)[
key
] /
tooltipModel!
.alterationData
.profiledSampleTotal
)}
% ({alterationCount}{' '}
{pluralize(
'case',
alterationCount
{formatFrequencyText(
useSampleCounts,
tooltipModel,
key
)}
)
</td>
</tr>
);
Expand Down
20 changes: 18 additions & 2 deletions src/pages/resultsView/cancerSummary/CancerSummaryContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class CancerSummaryContainer extends React.Component<
@observable private activeTab: string = CANCER_SUMMARY_ALL_GENES;
@observable private resultsViewPageWidth: number = 1150;
@observable private groupAlterationsBy_userSelection: keyof ExtendedSample;
@observable private countAlterationsBy_userSelection: string;

private resultsViewPageContent: HTMLElement;

Expand All @@ -45,6 +46,7 @@ export default class CancerSummaryContainer extends React.Component<
makeObservable(this);
this.handleTabClick = this.handleTabClick.bind(this);
this.pivotData = this.pivotData.bind(this);
this.pivotCountData = this.pivotCountData.bind(this);
this.mapStudyIdToName = this.mapStudyIdToName.bind(this);
}

Expand All @@ -60,6 +62,10 @@ export default class CancerSummaryContainer extends React.Component<
this.groupAlterationsBy_userSelection = str;
}

public pivotCountData(str: string) {
this.countAlterationsBy_userSelection = str;
}

public get groupAlterationsBy(): keyof ExtendedSample {
if (this.groupAlterationsBy_userSelection === undefined) {
if (this.props.store.studies.result!.length > 1) {
Expand All @@ -81,6 +87,10 @@ export default class CancerSummaryContainer extends React.Component<
}
}

public get countAlterationsBy(): string {
return this.countAlterationsBy_userSelection ?? 'patientCounts';
}

// this is used to map study id to study name
private mapStudyIdToName(str: string) {
if (str in this.props.store.physicalStudySet) {
Expand All @@ -106,7 +116,8 @@ export default class CancerSummaryContainer extends React.Component<
this.groupAlterationsBy,
this.props.store.selectedMolecularProfileIdsByAlterationType
.result!,
this.props.store.coverageInformation.result!
this.props.store.coverageInformation.result!,
this.countAlterationsBy
);

const geneTabs = _.map(this.props.store.genes.result!, (gene: Gene) => {
Expand Down Expand Up @@ -142,9 +153,11 @@ export default class CancerSummaryContainer extends React.Component<
}
handleStudyLinkout={this.handleStudyLinkout}
groupAlterationsBy={this.groupAlterationsBy}
countAlterationsBy={this.countAlterationsBy}
gene={gene.hugoGeneSymbol}
labelTransformer={labelTransformer}
handlePivotChange={this.pivotData}
handlePivotCountChange={this.pivotCountData}
width={this.resultsViewPageWidth}
/>
</MSKTab>
Expand All @@ -161,7 +174,8 @@ export default class CancerSummaryContainer extends React.Component<
this.groupAlterationsBy,
this.props.store.selectedMolecularProfileIdsByAlterationType
.result!,
this.props.store.coverageInformation.result!
this.props.store.coverageInformation.result!,
this.countAlterationsBy
);
geneTabs.unshift(
<MSKTab
Expand All @@ -174,8 +188,10 @@ export default class CancerSummaryContainer extends React.Component<
width={this.resultsViewPageWidth}
groupedAlterationData={groupedAlterationDataForAllGenes}
handlePivotChange={this.pivotData}
handlePivotCountChange={this.pivotCountData}
labelTransformer={labelTransformer}
groupAlterationsBy={this.groupAlterationsBy}
countAlterationsBy={this.countAlterationsBy}
handleStudyLinkout={this.handleStudyLinkout}
/>
</MSKTab>
Expand Down
Loading