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

update genotype display for multiple sample types #4437

Merged
merged 22 commits into from
Oct 28, 2024
Merged

update genotype display for multiple sample types #4437

merged 22 commits into from
Oct 28, 2024

Conversation

jklugherz
Copy link
Contributor

@jklugherz jklugherz commented Oct 16, 2024

image

Screenshot 2024-10-21 at 5 37 17 PM

@jklugherz jklugherz marked this pull request as ready for review October 16, 2024 21:02
ui/shared/components/panel/variants/VariantIndividuals.jsx Outdated Show resolved Hide resolved
ui/shared/components/panel/variants/VariantIndividuals.jsx Outdated Show resolved Hide resolved
ui/shared/components/panel/variants/VariantIndividuals.jsx Outdated Show resolved Hide resolved
ui/shared/components/panel/variants/VariantIndividuals.jsx Outdated Show resolved Hide resolved
<Popup
header="Additional Sample Type"
trigger={<Icon name="plus circle" color={hasConflictingNumAlt ? 'red' : 'green'} />}
trigger={<Icon name="plus circle" color={firstGenotype.hasConflictingNumAlt ? 'red' : 'green'} />}
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add a screenshot for this

Copy link
Collaborator

Choose a reason for hiding this comment

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

bump

ui/shared/components/panel/variants/VariantIndividuals.jsx Outdated Show resolved Hide resolved
<Popup
header="Additional Sample Type"
trigger={<Icon name="plus circle" color={hasConflictingNumAlt ? 'red' : 'green'} />}
trigger={<Icon name="plus circle" color={firstGenotype.hasConflictingNumAlt ? 'red' : 'green'} />}
Copy link
Collaborator

Choose a reason for hiding this comment

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

bump

ui/shared/components/panel/variants/VariantIndividuals.jsx Outdated Show resolved Hide resolved
ui/shared/components/panel/variants/VariantIndividuals.jsx Outdated Show resolved Hide resolved
// Temporarily use the first genotype for an individual until blended es/gs are supported in UI - https://github.com/broadinstitute/seqr/issues/4269
genotype = Array.isArray(genotype) ? genotype[0] : genotype

const getAllGenotypeDetails = (genotype, variant, individual, isCompoundHet, genesById) => {
const hasCnCall = isCalled(genotype.cn)
if (!hasCnCall && !isCalled(genotype.numAlt)) {
return <b>NO CALL</b>
Copy link
Collaborator

Choose a reason for hiding this comment

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

this will definitely break with the way this is abstracted into a helper

Copy link
Collaborator

Choose a reason for hiding this comment

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

this is still a problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh I see why it's a problem now.. return <b>NO CALL</b> is supposed to be a return value of Genotypes

ui/shared/components/panel/variants/VariantIndividuals.jsx Outdated Show resolved Hide resolved
genotypeInfo => genotypeInfo.genotype.numAlt !== firstGenotype.genotype.numAlt,
)

return (
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should use the Alleles class here instead of recreating its behavior. While the prop type for warning in that calls is currently a string, changing that proptype definition to node with no other changes to the class itself and then creating a react node for the warning content here and passing that as the warning prop will work totally fine, as the warning prop is rendered directly in that class

export const Alleles = React.memo(({ genotype, variant, isHemiX, warning }) => (
<AlleleContainer>
{warning && (
<Popup
wide
trigger={<WarningIcon />}
content={
Copy link
Collaborator

Choose a reason for hiding this comment

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

so as mentioned on a previous PR, this is an exported component so its better to its behavior alone. I also think it actually better for us to say "warning" one time in the popup, not once per warningas repeating the word multiple time reduces readability

// Temporarily use the first genotype for an individual until blended es/gs are supported in UI - https://github.com/broadinstitute/seqr/issues/4269
genotype = Array.isArray(genotype) ? genotype[0] : genotype

const getAllGenotypeDetails = (genotype, variant, individual, isCompoundHet, genesById) => {
const hasCnCall = isCalled(genotype.cn)
if (!hasCnCall && !isCalled(genotype.numAlt)) {
return <b>NO CALL</b>
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is still a problem

variant: PropTypes.object,
}

const LegacyAdditionalSampleTypePopup = ({ genotype, variant, isHemiX, genesById }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should never be maintaining a special legacy UI unless there is an overwhelming reason not to use the new UI. You should be transforming the otherSample into an array of genotypes with both samples and using the new, supported UI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added otherSample to the genotypes array, screenshot incoming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

otherSample is not part of any saved variant json, it is added to the genotype inside of the es_utils code path. Is this something I can test?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm okay so not easy to test but we should keep support for it, but we do not need to keep the current UI for it. I think changing the code to move it into the the genotypes array is sufficient here, no screenshot needed

</div>
))}
{hasDifferentNumAlt && (
<span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is going to look weird if you have a sample-type specific warnings and also different number of genotypes - it will be something like

WES: Potential UPD/ Hemizygosity
WGS: Potential UPD/ Hemizygosity. Variant absent in parents
Genotypes differ across sample types
WES:
  G/C
WGS:
  C/C

I think the differing genotypes warning belongs at the top, and also that rather than combining all the warnings per sample type, we should show each warning on each own row, with an indicator if its only foor some sample types:

Genotypes differ across sample types
WES:
  G/C
WGS:
  C/C
Potential UPD/ Hemizygosity
Variant absent in parents (WGS)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2024-10-23 at 4 22 43 PM

I agree here!

<div key={genotype.sampleType}>
{genotype.sampleType}
:
<AlleleContainer>
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can just use the Alleles class here, as without a warning prop or an SV (which can't have multiple sample types) this is just the same code as that class

warning={
<div>
<b>Warning: </b>
{getWarningsForGenotype(genotypes[0], variant, individual, isHemiX, isCompoundHet)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned above warning formatting needs to be left the same in the Alleles class instead of moving it here. One key problem with this current approach is that even if getWarningsForGenotype returns nothing this will still show a warning icon on every genotype. Whenever I change the variant UI based on changes from search, I always make sure to also open up a saved variant page for an unchanged family, to make sure that legacy saved variants still look right

/>
</span>
) : (
<MultiSampleTypeAlleles
Copy link
Collaborator

Choose a reason for hiding this comment

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

So in the end MultiSampleTypeAlleles returns Alleles using the same props as for a single-sample genotype - the only difference is the warning. Rather than have a helper class and a ternary here, it would be much neater to have a getWarningsForGenotypes method that handles constructing the correct warning for all the genotypes and leave this rendering much simpler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed MultiSampleTypeAlleles and conditionally set the warning prop on Alleles based on genotypes length.

@jklugherz jklugherz requested a review from hanars October 24, 2024 14:16
(a, b) => SAMPLE_TYPE_DISPLAY_ORDER.indexOf(a.sampleType) - SAMPLE_TYPE_DISPLAY_ORDER.indexOf(b.sampleType),
)

if (!isCalled(genotypes[0].cn) && !isCalled(genotypes[0].numAlt)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpcik, but shouldn't you check that all the genotypes are not called for this, not just the first one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking that since cn is an SV-only annotation and there will only be one genotype per SV, there would only be one genotype in the list here but I could be wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

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

its true for now but if this ever changes its unlikely we would think to go back to this spot in the UI code and fix it. Building the UI to generically work with multiple sample types is better as it means we are unlikely to introduce bugs in the future, as long as it doesn't make the code to complex/ unreadable for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that makes sense, I updated the code to return no call if all genotypes fail that check


const sampleTypeWarnings = genotypes.reduce((acc, genotype) => {
const warnings = getWarningsForGenotype(genotype, variant, individual, isHemiX, isCompoundHet)
warnings.forEach((warning) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this reduction is not used in the case where theres only one sample type, so it would be neater to just do a genotypes.map here to get an array of warnings. Then for the single sample case your warnings would just be genotypeWarnings[0].join('. ') and in getWarningsForGenotypes you could do this grouping,
something like

`genotypeWarnings.reduce((acc, [warnings, index]) => {
  const { sampleType } = genotypes[index]
  warnings.forEach((warning) => {
    ...
}, {})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, done!

@jklugherz jklugherz merged commit 91ad846 into dev Oct 28, 2024
7 checks passed
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