-
Notifications
You must be signed in to change notification settings - Fork 89
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
Conversation
jklugherz
commented
Oct 16, 2024
•
edited
Loading
edited
<Popup | ||
header="Additional Sample Type" | ||
trigger={<Icon name="plus circle" color={hasConflictingNumAlt ? 'red' : 'green'} />} | ||
trigger={<Icon name="plus circle" color={firstGenotype.hasConflictingNumAlt ? 'red' : 'green'} />} |
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.
can you add a screenshot for this
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.
bump
<Popup | ||
header="Additional Sample Type" | ||
trigger={<Icon name="plus circle" color={hasConflictingNumAlt ? 'red' : 'green'} />} | ||
trigger={<Icon name="plus circle" color={firstGenotype.hasConflictingNumAlt ? 'red' : 'green'} />} |
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.
bump
// 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> |
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 will definitely break with the way this is abstracted into a helper
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 still a problem
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.
oh I see why it's a problem now.. return <b>NO CALL</b>
is supposed to be a return value of Genotypes
genotypeInfo => genotypeInfo.genotype.numAlt !== firstGenotype.genotype.numAlt, | ||
) | ||
|
||
return ( |
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.
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={ |
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 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> |
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 still a problem
variant: PropTypes.object, | ||
} | ||
|
||
const LegacyAdditionalSampleTypePopup = ({ genotype, variant, isHemiX, genesById }) => { |
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 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
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.
I added otherSample to the genotypes array, screenshot incoming.
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.
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?
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.
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> |
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 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)
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.
<div key={genotype.sampleType}> | ||
{genotype.sampleType} | ||
: | ||
<AlleleContainer> |
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.
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)} |
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.
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 |
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 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
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.
I removed MultiSampleTypeAlleles
and conditionally set the warning
prop on Alleles
based on genotypes length.
(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)) { |
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.
nitpcik, but shouldn't you check that all the genotypes are not called for this, not just the first one
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.
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.
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.
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
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.
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) => { |
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 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) => {
...
}, {})
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.
agree, done!