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

Add group percentages to oncoprint #4756

Merged
merged 4 commits into from
Nov 14, 2023
Merged

Conversation

alisman
Copy link
Collaborator

@alisman alisman commented Oct 17, 2023

  • Show group percentages in Oncoprint when gaps are turned on
  • Show labels in SVG download
  • Should also work in Oncoprinter
  • Should work in merged tracks

@alisman alisman force-pushed the onco-groups branch 2 times, most recently from 7472799 to 507542a Compare October 26, 2023 19:40
@alisman alisman requested a review from onursumer November 2, 2023 14:34
Copy link
Member

@onursumer onursumer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Thanks, Aaron! 🥇

Just added a few minor suggestions.

Comment on lines 2093 to 2095
// aaron
// aaron
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove/replace these comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Comment on lines 643 to 649
const percentagesForGroups = groupsByTrackMap[gene][0].map(
groupData => {
return getPercentAltered(
groupData as OncoprinterGeneticTrackDatum[]
);
}
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be simpler if we could do something like

Suggested change
const percentagesForGroups = groupsByTrackMap[gene][0].map(
groupData => {
return getPercentAltered(
groupData as OncoprinterGeneticTrackDatum[]
);
}
);
const percentagesForGroups = groupsByTrackMap[gene][0].map(getPercentAltered);

Comment on lines +849 to +876
sequencedPatientKeysForGroup = _(
geneSymbolArray
)
.keyBy(gene => gene)
.mapValues(gene => {
// you want to return only the patient ids which are listed as
// sequenced for the gene(s) in this track (plural in case of merged tracks)
return _.intersection(
_.flatMap(
geneSymbolArray,
gene =>
sequencedPatientKeysByGene[
gene
]
),
groupData.map((d: any) => d.uid)
);
})
.value();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this else block is almost identical to the if block above except the variables sequencedSampleKeysByGene vs sequencedPatientKeysByGene. probably better to extract the logic to a function and reuse.

Comment on lines +315 to +347
const overlappingGap = self.gapTooltipTargets.find(
(t: any) => {
return (
_.inRange(mouseX - t.origin_x, 0, 20) &&
_.inRange(t.origin_y - mouseY, -10, 15)
);
}
);

// if there is no gap, turn
if (overlappingGap === undefined) {
self.hoveredGap = undefined;
} else if (self.hoveredGap === overlappingGap) {
// tooltip should already be showing, so do nothing
} else {
// we have a new hovered gap, so show a tooltip
const clientRect = self.$overlay_canvas[0].getBoundingClientRect();
self.hoveredGap = overlappingGap;
tooltip.center = false;
tooltip.show(
250,
clientRect.left + overlappingGap.origin_x,
clientRect.top + overlappingGap.origin_y - 20,
$(
`<span>${overlappingGap.data.tooltipFormatter()}</span>`
),
false
);
}

if (!overlapping_data && !overlappingGap) {
tooltip.hideIfNotAlreadyGoingTo(150);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so much work to show a tooltip but I guess we have no other choice 😞

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@onursumer I think It's been said the hardest problems in computer science are 1) knowing when to clear a cache and 2) making a tooltip over an HTML canvas.

Comment on lines 434 to 444
//ctx.clearColor(1.0, 1.0, 1.0, 1.0);
//ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
// ctx.viewportWidth = canvas.width;
// ctx.viewportHeight = canvas.height;
// ctx.viewport(0, 0, ctx.viewportWidth, ctx.viewportHeight);
//ctx.enable(ctx.DEPTH_TEST);
//ctx.enable(ctx.BLEND);
//ctx.blendEquation(ctx.FUNC_ADD);
//ctx.blendFunc(ctx.SRC_ALPHA, ctx.ONE_MINUS_SRC_ALPHA);
//ctx.depthMask(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove this or add a comment why we commented it out?

Comment on lines 634 to 644
//ctx.clearColor(1.0, 1.0, 1.0, 1.0);
//ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
//ctx. = canvas.width;
//ctx.viewportHeight = canvas.height;
//ctx.viewport(0, 0, ctx.viewportWidth, ctx.viewportHeight);
//ctx.enable(ctx.DEPTH_TEST);
//ctx.enable(ctx.BLEND);
//ctx.blendEquation(ctx.FUNC_ADD);
//ctx.blendFunc(ctx.SRC_ALPHA, ctx.ONE_MINUS_SRC_ALPHA);
//ctx.depthMask(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, except here we have a syntax error ctx. = canvas.width; :)

Comment on lines +2071 to +2037
const gaps = _.isEmpty(model.ids_after_a_gap.get())
? undefined
: custom.find(t => !!t.gapLabelsFn)?.gapLabelsFn(model);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate code segment. should we define a getGaps function? we can probably include this one as well const custom = model.getTrackCustomOptions(track_id);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@alisman alisman force-pushed the onco-groups branch 6 times, most recently from 55adeb6 to 1e2ff1d Compare November 10, 2023 20:16
@alisman alisman merged commit 6735e78 into cBioPortal:master Nov 14, 2023
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants