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 STR page allele size histogram to show colors based on genotype quality or other values #1649

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9de862e
Update STR data pipeline for new data
phildarnowsky-broad Jul 15, 2024
628d091
DONTMERGE rig index
phildarnowsky-broad Jul 15, 2024
9c5b169
Update GraphQL schema for STRs to reflect new ES schema
phildarnowsky-broad Jul 15, 2024
9fddb7a
WIP pop options refactored
phildarnowsky-broad Jul 17, 2024
0ddf11b
WIP that should be the allele size plot
phildarnowsky-broad Jul 22, 2024
3920bc2
WIP genotype select
phildarnowsky-broad Jul 22, 2024
0aa206e
WIP age dist
phildarnowsky-broad Jul 22, 2024
6ce43c6
WIP more refactor
phildarnowsky-broad Jul 24, 2024
341a79f
WIP typechecks
phildarnowsky-broad Jul 25, 2024
6d38633
WIP flush any's, flush bugs
phildarnowsky-broad Jul 26, 2024
2f78e91
WIP update query in frontend
phildarnowsky-broad Jul 26, 2024
48ea41b
WIP restoring classification
phildarnowsky-broad Jul 26, 2024
3ee8e06
WIP fixing query
phildarnowsky-broad Jul 26, 2024
cc36d31
DONTMERGE nerf reads
phildarnowsky-broad Jul 26, 2024
bc31b65
fixup fix ancestry and sex selectors
phildarnowsky-broad Jul 29, 2024
936d478
fixup: fix allele size plot when no selected repunit
phildarnowsky-broad Jul 29, 2024
16baef3
misc. updates to TR page in preparation for new release
bw2 Oct 10, 2024
18fca96
renamed 'AncestryGroup' to 'Population' and 'frequnecy' to 'count'
bw2 Oct 30, 2024
eea53ff
reverted variable names to match API
bw2 Oct 30, 2024
e4baf4d
finished initial implementation of adding colors to histogram
bw2 Oct 31, 2024
e3fd20d
renamed ancestryGroupId to populationId to match the main branch
bw2 Oct 31, 2024
247582b
updated shortTandemRepeatFactory
bw2 Oct 31, 2024
679e560
fixup: update snapshots
phildarnowsky-broad Nov 4, 2024
8127b8c
added 'Linear: Truncated' scale option
bw2 Nov 8, 2024
7de2f25
fixed logic for switching to 'linear-truncated' scale when color-by s…
bw2 Nov 8, 2024
d5efc44
Fixed STR pages for loci without a disease association
bw2 Nov 8, 2024
106fab3
Updated histogram colors
bw2 Nov 8, 2024
3f20577
WIP beginning of STR reads fix
phildarnowsky-broad Nov 13, 2024
300314e
WIP stackedbar plot
phildarnowsky-broad Dec 2, 2024
a3dae51
Prevent use of log scale with broken-down STR data
phildarnowsky-broad Dec 3, 2024
5109782
Add legend to allele size plot
phildarnowsky-broad Dec 3, 2024
070e807
WIP tooltips
phildarnowsky-broad Dec 6, 2024
3608f50
fixup: un-rig API query location
phildarnowsky-broad Dec 9, 2024
b54d531
fixup: fixed order for keys
phildarnowsky-broad Dec 9, 2024
9bc9300
updated Q legend labels
bw2 Dec 10, 2024
ca378af
added more options to y-scale drop down
bw2 Dec 10, 2024
e430b33
fix display of 0 bins
phildarnowsky-broad Dec 10, 2024
f4200e9
show subset in tooltips
phildarnowsky-broad Dec 10, 2024
8213175
fixup: short and long allele count transposed
phildarnowsky-broad Jan 14, 2025
ba1892e
fixup: quality description in readviz
phildarnowsky-broad Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ hail-*.log
# Playright test dirs
/tests/playwright/
/playwright/.cache/

# Reads metadata databases
reads/*.db
3 changes: 3 additions & 0 deletions browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"@gnomad/ui": "2.0.0",
"@hot-loader/react-dom": "^17.0.0",
"@visx/axis": "^3.0.0",
"@visx/legend": "^3.12.0",
"@visx/scale": "^3.12.0",
"@visx/shape": "^3.12.0",
"core-js": "3.5.0",
"css-loader": "^6.7.3",
"d3-array": "^1.2.4",
Expand Down
2 changes: 1 addition & 1 deletion browser/src/GenePage/GenePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const GenePage = ({ datasetId, gene, geneId }: Props) => {
<Link to={`/short-tandem-repeat/${gene.short_tandem_repeats[0].id}`}>
tandem repeat locus
</Link>{' '}
in this gene.
in this gene
</p>
)}
</GeneInfoColumn>
Expand Down
1 change: 0 additions & 1 deletion browser/src/GenePage/GenePageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ query ${operationName}($geneId: String, $geneSymbol: String, $referenceGenome: R
}
}
`

type Props = {
datasetId: DatasetId
geneIdOrSymbol: string
Expand Down
1 change: 1 addition & 0 deletions browser/src/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
loadData() {
const { operationName, query, url, variables } = this.props

console.log('Loading url:', url)

Check warning on line 87 in browser/src/Query.tsx

View workflow job for this annotation

GitHub Actions / Checks

Unexpected console statement
this.setState({
loading: true,
error: null,
Expand Down
1 change: 0 additions & 1 deletion browser/src/RegionPage/RegionPageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const query = `
}
}
`

type Props = {
datasetId: DatasetId
regionId: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { max, min } from 'd3-array'
import React, { useState } from 'react'
import React, { SetStateAction, useState, Dispatch } from 'react'

import { Modal, Select } from '@gnomad/ui'

import ControlSection from '../VariantPage/ControlSection'

import ShortTandemRepeatPopulationOptions from './ShortTandemRepeatPopulationOptions'
import { ShortTandemRepeatAdjacentRepeat } from './ShortTandemRepeatPage'
import { ScaleType, Sex, ColorBy } from './ShortTandemRepeatAlleleSizeDistributionPlot'

Check failure on line 9 in browser/src/ShortTandemRepeatPage/ShortTandemRepeatAdjacentRepeatSection.tsx

View workflow job for this annotation

GitHub Actions / Checks

'./ShortTandemRepeatAlleleSizeDistributionPlot' imported multiple times
import ShortTandemRepeatAlleleSizeDistributionPlot from './ShortTandemRepeatAlleleSizeDistributionPlot'

Check failure on line 10 in browser/src/ShortTandemRepeatPage/ShortTandemRepeatAdjacentRepeatSection.tsx

View workflow job for this annotation

GitHub Actions / Checks

'./ShortTandemRepeatAlleleSizeDistributionPlot' imported multiple times
import ShortTandemRepeatGenotypeDistributionPlot from './ShortTandemRepeatGenotypeDistributionPlot'

Check failure on line 11 in browser/src/ShortTandemRepeatPage/ShortTandemRepeatAdjacentRepeatSection.tsx

View workflow job for this annotation

GitHub Actions / Checks

'./ShortTandemRepeatGenotypeDistributionPlot' imported multiple times
import ShortTandemRepeatGenotypeDistributionBinDetails from './ShortTandemRepeatGenotypeDistributionBinDetails'
import ShortTandemRepeatGenotypeDistributionRepeatUnitsSelect from './ShortTandemRepeatGenotypeDistributionRepeatUnitsSelect'
import ShortTandemRepeatAdjacentRepeatAttributes from './ShortTandemRepeatAdjacentRepeatAttributes'
Expand All @@ -16,37 +16,52 @@
getSelectedAlleleSizeDistribution,
getSelectedGenotypeDistribution,
getGenotypeDistributionPlotAxisLabels,
genotypeRepunitPairs,
maxAlleleSizeDistributionRepeats,
maxGenotypeDistributionRepeats,
} from './shortTandemRepeatHelpers'
import { PopulationId } from '@gnomad/dataset-metadata/gnomadPopulations'
import { Bin as GenotypeBin } from './ShortTandemRepeatGenotypeDistributionPlot'

Check failure on line 24 in browser/src/ShortTandemRepeatPage/ShortTandemRepeatAdjacentRepeatSection.tsx

View workflow job for this annotation

GitHub Actions / Checks

'./ShortTandemRepeatGenotypeDistributionPlot' imported multiple times

type Props = {
adjacentRepeat: ShortTandemRepeatAdjacentRepeat
populationIds: string[]
selectedPopulationId: string
onSelectPopulationId: (...args: any[]) => any
selectedScaleType: string
onSelectScaleType: (...args: any[]) => any
selectedScaleType: ScaleType
selectedPopulation: PopulationId | ''
selectedSex: Sex | ''
selectedColorBy: ColorBy | ''
populations: PopulationId[]
selectedGenotypeDistributionBin: GenotypeBin | null
setSelectedGenotypeDistributionBin: Dispatch<SetStateAction<GenotypeBin | null>>
setSelectedScaleType: Dispatch<SetStateAction<ScaleType>>
setSelectedPopulation: Dispatch<SetStateAction<PopulationId | ''>>
setSelectedSex: Dispatch<SetStateAction<Sex | ''>>
setSelectedColorBy: (newColorBy: ColorBy | '') => void
}

const ShortTandemRepeatAdjacentRepeatSection = ({
adjacentRepeat,
populationIds,
selectedPopulationId,
onSelectPopulationId,
populations,
selectedScaleType,
onSelectScaleType,
selectedPopulation,
selectedSex,
selectedColorBy,
setSelectedScaleType,
setSelectedPopulation,
setSelectedSex,
setSelectedColorBy,

Check failure on line 51 in browser/src/ShortTandemRepeatPage/ShortTandemRepeatAdjacentRepeatSection.tsx

View workflow job for this annotation

GitHub Actions / Checks

'setSelectedColorBy' is defined but never used. Allowed unused args must match /^_/u
}: Props) => {
const [selectedRepeatUnit, setSelectedRepeatUnit] = useState(
adjacentRepeat.repeat_units.length === 1 ? adjacentRepeat.repeat_units[0] : ''
)

const genotypeDistributionPairs = genotypeRepunitPairs(adjacentRepeat)
const defaultGenotypeDistributionRepeatUnits =
genotypeDistributionPairs.length === 1 ? genotypeDistributionPairs[0] : ''
const [selectedGenotypeDistributionRepeatUnits, setSelectedGenotypeDistributionRepeatUnits] =
useState(
adjacentRepeat.genotype_distribution.repeat_units.length === 1
? adjacentRepeat.genotype_distribution.repeat_units[0].repeat_units.join(' / ')
: ''
)
useState<string[] | ''>(defaultGenotypeDistributionRepeatUnits)

const [selectedGenotypeDistributionBin, setSelectedGenotypeDistributionBin] = useState(null)
const [selectedGenotypeDistributionBin, setSelectedGenotypeDistributionBin] =
useState<GenotypeBin | null>(null)

return (
<section style={{ marginBottom: '3em' }}>
Expand All @@ -55,33 +70,33 @@

<h4 style={{ marginBottom: '0.66em' }}>Allele Size Distribution</h4>
<ShortTandemRepeatAlleleSizeDistributionPlot
// @ts-expect-error TS(2322) FIXME: Type '{ maxRepeats: number; alleleSizeDistribution... Remove this comment to see the full error message
maxRepeats={
adjacentRepeat.allele_size_distribution.distribution[
adjacentRepeat.allele_size_distribution.distribution.length - 1
][0]
}
maxRepeats={maxAlleleSizeDistributionRepeats(adjacentRepeat)}
alleleSizeDistribution={getSelectedAlleleSizeDistribution(adjacentRepeat, {
selectedPopulationId,
selectedPopulation,
selectedSex,
selectedColorBy,
selectedRepeatUnit,
})}
colorBy={selectedColorBy}
repeatUnitLength={selectedRepeatUnit ? selectedRepeatUnit.length : null}
scaleType={selectedScaleType}
/>
<ControlSection>
<ShortTandemRepeatPopulationOptions
id={`${adjacentRepeat.id}-repeat-counts`}
populationIds={populationIds}
selectedPopulationId={selectedPopulationId}
onSelectPopulationId={onSelectPopulationId}
populations={populations}
selectedPopulation={selectedPopulation}
selectedSex={selectedSex}
setSelectedPopulation={setSelectedPopulation}
setSelectedSex={setSelectedSex}
/>

<label htmlFor={`short-tandem-repeat-${adjacentRepeat.id}-repeat-unit`}>
Repeat unit: {/* @ts-expect-error TS(2769) FIXME: No overload matches this call. */}
<Select
id={`short-tandem-repeat-${adjacentRepeat.id}-repeat-unit`}
value={selectedRepeatUnit}
onChange={(e: any) => {
onChange={(e: { target: { value: string } }) => {
setSelectedRepeatUnit(e.target.value)
}}
>
Expand All @@ -98,59 +113,63 @@
</label>

<label htmlFor={`short-tandem-repeat-${adjacentRepeat.id}-repeat-counts-scale`}>
Scale: {/* @ts-expect-error TS(2769) FIXME: No overload matches this call. */}
y-scale: {/* @ts-expect-error TS(2769) FIXME: No overload matches this call. */}
<Select
id={`short-tandem-repeat-${adjacentRepeat.id}-repeat-counts-scale`}
value={selectedScaleType}
onChange={(e: any) => {
onSelectScaleType(e.target.value)
onChange={(e: { target: { value: ScaleType } }) => {
setSelectedScaleType(e.target.value)
}}
>
<option value="linear">Linear</option>
<option value="log">Log</option>
<option value="linear-truncated-50">Linear: Truncated at 50</option>
<option value="linear-truncated-200">Linear: Truncated at 200</option>
<option value="linear-truncated-1000">Linear: Truncated at 1000</option>
</Select>
</label>
</ControlSection>

<h4 style={{ marginBottom: '0.66em' }}>Genotype Distribution</h4>
<ShortTandemRepeatGenotypeDistributionPlot
// @ts-expect-error TS(2322) FIXME: Type '{ axisLabels: any; maxRepeats: (string | und... Remove this comment to see the full error message
axisLabels={getGenotypeDistributionPlotAxisLabels(adjacentRepeat, {
selectedRepeatUnits: selectedGenotypeDistributionRepeatUnits,
})}
maxRepeats={[
max(adjacentRepeat.genotype_distribution.distribution, (d: any) => max(d.slice(0, 2))),
max(adjacentRepeat.genotype_distribution.distribution, (d: any) => min(d.slice(0, 2))),
]}
maxRepeats={maxGenotypeDistributionRepeats(adjacentRepeat)}
genotypeDistribution={getSelectedGenotypeDistribution(adjacentRepeat, {
selectedRepeatUnits: selectedGenotypeDistributionRepeatUnits,
selectedPopulationId,
selectedPopulation: selectedPopulation,

Check failure on line 141 in browser/src/ShortTandemRepeatPage/ShortTandemRepeatAdjacentRepeatSection.tsx

View workflow job for this annotation

GitHub Actions / Checks

Expected property shorthand
selectedSex: selectedSex,

Check failure on line 142 in browser/src/ShortTandemRepeatPage/ShortTandemRepeatAdjacentRepeatSection.tsx

View workflow job for this annotation

GitHub Actions / Checks

Expected property shorthand
})}
onSelectBin={(bin: any) => {
onSelectBin={(bin: GenotypeBin) => {
if (bin.xRange[0] !== bin.xRange[1] || bin.yRange[0] !== bin.yRange[1]) {
setSelectedGenotypeDistributionBin(bin)
}
}}
xRanges={[]}
yRanges={[]}
/>

<ControlSection>
<ShortTandemRepeatPopulationOptions
id={`${adjacentRepeat.id}-genotype-distribution`}
populationIds={populationIds}
selectedPopulationId={selectedPopulationId}
onSelectPopulationId={onSelectPopulationId}
populations={populations}
selectedPopulation={selectedPopulation}
selectedSex={selectedSex}
setSelectedPopulation={setSelectedPopulation}
setSelectedSex={setSelectedSex}
/>

<ShortTandemRepeatGenotypeDistributionRepeatUnitsSelect
shortTandemRepeatOrAdjacentRepeat={adjacentRepeat}
value={selectedGenotypeDistributionRepeatUnits}
onChange={setSelectedGenotypeDistributionRepeatUnits}
selectedRepeatUnits={selectedGenotypeDistributionRepeatUnits}
setSelectedRepeatUnits={setSelectedGenotypeDistributionRepeatUnits}
/>
</ControlSection>

{selectedGenotypeDistributionBin && (
<Modal
title={(selectedGenotypeDistributionBin as any).label}
title={selectedGenotypeDistributionBin.label}
size="large"
// @ts-expect-error TS(2322) FIXME: Type '{ children: Element; title: any; size: "larg... Remove this comment to see the full error message
initialFocusOnButton={false}
Expand All @@ -160,9 +179,11 @@
>
<ShortTandemRepeatGenotypeDistributionBinDetails
shortTandemRepeatOrAdjacentRepeat={adjacentRepeat}
selectedPopulationId={selectedPopulationId}
selectedRepeatUnits={selectedGenotypeDistributionRepeatUnits}
bin={selectedGenotypeDistributionBin}
selectedPopulation={selectedPopulation}
selectedSex={selectedSex}
repeatUnitPairs={genotypeDistributionPairs}
/>
</Modal>
)}
Expand Down
Loading
Loading