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

Constraint for mitochondrial genes #1451

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

phildarnowsky-broad
Copy link
Contributor

@phildarnowsky-broad phildarnowsky-broad commented Mar 20, 2024

This adds a table and a region plot of constraint for mitochondrial genes. One unusual thing I've done here is to keep this data in memory on the API server, rather than create a data pipeline. There's so little data--just over 100 rows--that a pipeline felt like massive overkill.

Here's a typical track. Note that, per discussion with Nicole, there aren't really different degrees of constrained regions, it's more a binary choice of "is constrained" or "isn't constrained". Hence just the one kind of block in the track.

Screenshot 2024-05-01 at 3 43 23 PM

@phildarnowsky-broad
Copy link
Contributor Author

phildarnowsky-broad commented Mar 20, 2024

Resolves: #1409

@phildarnowsky-broad
Copy link
Contributor Author

Building a demo did fail for me so there will be at least one more fixup to come

@phildarnowsky-broad
Copy link
Contributor Author

Note to self: need to get copy for both info buttons from Nicole

Copy link
Contributor

@rileyhgrant rileyhgrant left a comment

Choose a reason for hiding this comment

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

Nicely done on the whole, one main comment with requested changes about a regression in what the RMC tooltip now displays, and a few minor thoughts. Apart from that lots of great things in here.

The refactoring of the merge regions function in particular is great to see an example of that, it's way more comprehensible now.

Also the work towards unifying the constraint tracks is excellent.

Comment on lines 219 to 217
<dd>{`${region.chrom}:${region.region_start}-${region.region_stop}`}</dd>
<dd>{`${region.chrom}:${region.start}-${region.stop}`}</dd>
Copy link
Contributor

@rileyhgrant rileyhgrant May 2, 2024

Choose a reason for hiding this comment

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

region_start and region_stop are, while in hindsight probably poorly named, not redundant. Also in hindsight this may have been a good place for a comment in the code discussing this, since it was a specific request and a bit subtle.

The track renders and colors each exon or portion of an exon based on the start and stop coordinates output from finding the overlap of the two passed in region arrays, but the RMC team wanted the hover over text to reflect the coordinates of the constrained region (region_start and region_stop), not the coordinates of the exon or portion of the exon (start and stop).

The RMC team had reached out to us to change the behavior to be this way, and at that time passing the region_start and region_stop coordinates so that each output overlapping region would have those values was my solution.


Screenshots

In production, since these two exons are part of the same constrained region, the tooltips show the start and stop coordinates for the region:

  • Screenshot 2024-05-02 at 09 18 04
    -Screenshot 2024-05-02 at 09 18 08

With this change, this behavior has reverted to displaying the coordinates for the block thats rendered:

  • Screenshot 2024-05-02 at 09 17 22
  • Screenshot 2024-05-02 at 09 17 25

Comment on lines 56 to 96
export const regionsInExons = <R extends GenericRegion>(regions: R[], exons: Exon[]): R[] => {
const sortedRegions = regions.sort((a, b) => a.start - b.start)
const sortedExons = exons.sort((a, b) => a.start - b.start)

Copy link
Contributor

Choose a reason for hiding this comment

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

Woohoo, very nicely done.

I honestly avoided touching that function after extending the tests for it since it was a bit unreadable to my eyes at that time, this goes a long way towards making it approachable -- kudos.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactoring this bit was very satisfying

<RegionAttributeList>
<div>
<dt>Coordinates:</dt>
<dd>{`m:${region.start}-${region.stop}`}</dd>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very minor -- it appears as though regions and variants use a capital M to denote a region in mitochondrial DNA, rather than a lowercase.

https://gnomad.broadinstitute.org/gene/ENSG00000198899?dataset=gnomad_r4

<td>{expected.toFixed(1)}</td>
<td>{observed.toFixed(1)}</td>
<td>
{oe.toFixed(2)} ({oeLower.toFixed(2)}-{oeUpper.toFixed(2)})
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could label this with o/e = ... to be more in line with the non-mito gene constraint table, or since there's only one 'contraint metric' in this cell, just label the column 'Observed/Expected'. It took me a few seconds to understand what that cell was showing without the context of some sort of label.

There are also a few other bells and whistles (that visual indication of o/e) that could be added to be more in line, but this may be getting into more of a question for Matt or KC type territory.

Mito gene constraint table

  • Screenshot 2024-05-02 at 09 51 57

Non-mito gene constraint table

  • Screenshot 2024-05-02 at 09 51 52

@phildarnowsky-broad phildarnowsky-broad force-pushed the mito_constraint branch 3 times, most recently from a452ba1 to 4d7f00c Compare May 3, 2024 19:24
@phildarnowsky-broad
Copy link
Contributor Author

@rileyhgrant this latest push should address all your feedback. I came up with a solution to the region_start/stop (now called unclamped_start/stop) conundrum that I like pretty well, and attempted to make it clearer what that was about.

@rileyhgrant rileyhgrant self-requested a review May 4, 2024 14:25
Copy link
Contributor

@rileyhgrant rileyhgrant left a comment

Choose a reason for hiding this comment

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

Nice, lgtm!

I like the solution on how to neatly keep unclamped start and stop around for rendering tooltips as needed.

We're about to extend this type so it's a good juncture to catch up on some small fixes in this area.
Here we extract a generic `ConstraintTrack` component from `RegionalMissenseConstraintTrack` so that we can build a mitochondrial constraint track on the new generic component.
@rileyhgrant rileyhgrant self-requested a review June 5, 2024 16:00
Copy link
Contributor

@rileyhgrant rileyhgrant left a comment

Choose a reason for hiding this comment

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

Nice, went through commit by commit and checked out the new fixup commits, as well as poked around on a local browser pointing to a local API -- looking good! Nicely done.

LGTM

@phildarnowsky-broad
Copy link
Contributor Author

phildarnowsky-broad commented Jun 5, 2024

@rileyhgrant this should address all your feedback, just needed a bit of light post-rebase cleanup. Ready for another look.

@phildarnowsky-broad
Copy link
Contributor Author

@rileyhgrant please disregard earlier comment, meant to post that on a different PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants