-
Notifications
You must be signed in to change notification settings - Fork 307
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
Conversation
alisman
commented
Oct 17, 2023
•
edited
Loading
edited
- 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
7472799
to
507542a
Compare
There was a problem hiding this 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.
// aaron | ||
// aaron |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
const percentagesForGroups = groupsByTrackMap[gene][0].map( | ||
groupData => { | ||
return getPercentAltered( | ||
groupData as OncoprinterGeneticTrackDatum[] | ||
); | ||
} | ||
); |
There was a problem hiding this comment.
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
const percentagesForGroups = groupsByTrackMap[gene][0].map( | |
groupData => { | |
return getPercentAltered( | |
groupData as OncoprinterGeneticTrackDatum[] | |
); | |
} | |
); | |
const percentagesForGroups = groupsByTrackMap[gene][0].map(getPercentAltered); |
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(); |
There was a problem hiding this comment.
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.
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); | ||
} |
There was a problem hiding this comment.
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 😞
There was a problem hiding this comment.
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.
//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); |
There was a problem hiding this comment.
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?
//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); |
There was a problem hiding this comment.
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;
:)
const gaps = _.isEmpty(model.ids_after_a_gap.get()) | ||
? undefined | ||
: custom.find(t => !!t.gapLabelsFn)?.gapLabelsFn(model); |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
55adeb6
to
1e2ff1d
Compare