Skip to content

Commit

Permalink
PR for issue #10669 number at risk table (cBioPortal#4862)
Browse files Browse the repository at this point in the history
* Recalculate the inital group size and keep labels

Update number at risk and hazard ratio when exclude/include overlapping samples

update code

* Update config.yml

Update deprecated image

---------

Co-authored-by: alisman <[email protected]>
  • Loading branch information
TJMKuijpers and alisman authored Mar 4, 2024
1 parent 001fea2 commit 60b8f22
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ jobs:
working_directory: /tmp/repo
machine:
enabled: true
image: ubuntu-2004:202201-02
image: default
resource_class: large
steps:
- when:
Expand Down
46 changes: 33 additions & 13 deletions src/pages/resultsView/survival/SurvivalChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export default class SurvivalChartExtended
this.props.sortedGroupedSurvivals,
(survivals, group) => {
const survivalSummaries = this.survivalSummaries[group];

const groupName = this.analysisGroupsMap[group].name;
return {
numOfCases: survivals.length,
Expand Down Expand Up @@ -791,15 +792,25 @@ export default class SurvivalChartExtended
}

@computed get landmarkInformation() {
const initialGroupSize = Object.keys(
this.props.sortedGroupedSurvivals
).map(item => this.props.sortedGroupedSurvivals[item].length);
// Calculate group size at time point 0
const initialGroupSampleSize = this.calculateGroupSize([0]);
// get the order of the groups
const orderOfLabels = this.analysisGroupsWithData.map(
item => item.value
);

const groupSizeAtTimePoint = this.calculateGroupSize(
this.landmarkPoint.map(item => item.xStart)
).sort(
(a, b) =>
orderOfLabels.indexOf(a.groupName) -
orderOfLabels.indexOf(b.groupName)
);
const landmarkPointInformation = _.groupBy(
this.calculateGroupSize(
this.landmarkPoint.map(item => item.xStart)
),
groupSizeAtTimePoint,
'timePoint'
);

const point = Object.keys(landmarkPointInformation).map(key =>
landmarkPointInformation[key].map((value, i) => {
if (
Expand All @@ -813,7 +824,12 @@ export default class SurvivalChartExtended
(
(landmarkPointInformation[key][i]
.aliveSamples /
initialGroupSize[i]) *
initialGroupSampleSize.filter(
x =>
x.groupName ==
landmarkPointInformation[key][i]
.groupName
)[0].aliveSamples) *
100
).toFixed(1) + '%'
}
Expand Down Expand Up @@ -848,16 +864,22 @@ export default class SurvivalChartExtended
return point;
}
@computed get numberOfSamplesAtRisk() {
var timePoints = scaleLinear()
const orderOfLabels = this.analysisGroupsWithData.map(
item => item.value
);
const definedTimePoints: number[] = scaleLinear()
.domain([0, this.sliderValue])
.ticks(18);

const numberAtRisk = _.groupBy(
this.calculateGroupSize(timePoints.map(item => item)),
this.calculateGroupSize(definedTimePoints).sort(
(a, b) =>
orderOfLabels.indexOf(a.groupName) -
orderOfLabels.indexOf(b.groupName)
),
'timePoint'
);

const valueAtAxis = Object.keys(numberAtRisk).map(item =>
return Object.keys(numberAtRisk).map(item =>
numberAtRisk[item].map((grp, i) => {
return (
<VictoryLabel
Expand All @@ -882,8 +904,6 @@ export default class SurvivalChartExtended
);
})
);

return valueAtAxis;
}
@observable _latestLandMarkPoint: number = 0;
@action updatelatestLandMarkPoint(value: number) {
Expand Down

0 comments on commit 60b8f22

Please sign in to comment.