Skip to content

Commit

Permalink
Merge branch 'main' into ea-loglabel-240906
Browse files Browse the repository at this point in the history
  • Loading branch information
elissa-alarmani committed Sep 12, 2024
2 parents 33f8b1e + fa15c6a commit cd0d23b
Show file tree
Hide file tree
Showing 14 changed files with 638 additions and 489 deletions.
2 changes: 2 additions & 0 deletions browser/src/GenePage/VariantsInGene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ query ${operationName}($geneId: String!, $datasetId: DatasetId!, $referenceGenom
faf99_max
faf99_max_gen_anc
}
flags
}
genome {
ac
Expand All @@ -265,6 +266,7 @@ query ${operationName}($geneId: String!, $datasetId: DatasetId!, $referenceGenom
ac_hemi
ac_hom
}
flags
}
joint {
ac
Expand Down
2 changes: 2 additions & 0 deletions browser/src/RegionPage/VariantsInRegion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ query ${operationName}($chrom: String!, $start: Int!, $stop: Int!, $datasetId: D
faf99_max
faf99_max_gen_anc
}
flags
}
genome {
ac
Expand All @@ -174,6 +175,7 @@ query ${operationName}($chrom: String!, $start: Int!, $stop: Int!, $datasetId: D
ac_hemi
ac_hom
}
flags
}
joint {
ac
Expand Down
13 changes: 12 additions & 1 deletion browser/src/VariantList/VariantFlag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ type Flag = {
formatTooltip: (input: any) => string
}

const formatMonoallelicFlag = (variant: any) => {
if (variant.exome && variant.exome.flags && variant.exome.flags.includes('monoallelic')) {
if (variant.genome && variant.genome.flags && variant.genome.flags.includes('monoallelic')) {
return 'All samples are homozygous alternate for the variant in both the exome and genome data'
}
return 'All samples are homozygous alternate for the variant in the exome data'
}

return 'All samples are homozygous alternate for the variant in the genome data'
}

export const FLAGS_CONFIG: Record<string, Flag> = {
lcr: {
label: 'LCR',
Expand Down Expand Up @@ -46,7 +57,7 @@ export const FLAGS_CONFIG: Record<string, Flag> = {
monoallelic: {
label: 'Monoallelic',
level: 'info',
formatTooltip: () => 'All samples are homozygous alternate for the variant',
formatTooltip: formatMonoallelicFlag,
},
// Mitochondrial variants
common_low_heteroplasmy: {
Expand Down
36 changes: 25 additions & 11 deletions browser/src/VariantList/variantTableColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ const getConsequenceDescription = (contextType: any) => {
return ' for consequence in this transcript'
}
}

const consolidatedFlags = (row: any) => {
const variantFlags = row.flags || []
const exomeFlags = row.exome?.flags || []
const genomeFlags = row.genome?.flags || []
const allFlags = Array.from(new Set([...variantFlags, ...exomeFlags, ...genomeFlags]))
return allFlags.sort()
}

export type VariantTableColumn = {
key: string
heading: string
Expand Down Expand Up @@ -163,11 +172,16 @@ const variantTableColumns: VariantTableColumn[] = [
description: 'Flags that may affect annotation and/or confidence',
grow: 0,
minWidth: 140,
compareFunction: makeNumericCompareFunction((variant: any) => variant.flags.length || null),
render: (row: any, key: any) =>
row[key]
.filter((flag: any) => flag !== 'segdup' && flag !== 'par')
.map((flag: any) => <VariantFlag key={flag} type={flag} variant={row} />),
compareFunction: makeNumericCompareFunction(
(variant: any) => consolidatedFlags(variant).length || null
),
render: (row: any) => (
<>
{consolidatedFlags(row).map((flag: any) => (
<VariantFlag key={flag} type={flag} variant={row} />
))}
</>
),
},

{
Expand Down Expand Up @@ -208,7 +222,7 @@ const variantTableColumns: VariantTableColumn[] = [
minWidth: 160,
compareFunction: makeStringCompareFunction('hgvs'),
getSearchTerms: (variant: any) => [variant.hgvs],
render: (variant: any, key: any, { highlightWords }: any) => (
render: (variant: any, _: any, { highlightWords }: any) => (
<Cell>
<Highlighter autoEscape searchWords={highlightWords} textToHighlight={variant.hgvs || ''} />
</Cell>
Expand All @@ -225,7 +239,7 @@ const variantTableColumns: VariantTableColumn[] = [
minWidth: 160,
compareFunction: makeStringCompareFunction('hgvsc'),
getSearchTerms: (variant: any) => [variant.hgvsc],
render: (variant: any, key: any, { highlightWords }: any) => (
render: (variant: any, _: any, { highlightWords }: any) => (
<Cell>
<Highlighter
autoEscape
Expand All @@ -246,7 +260,7 @@ const variantTableColumns: VariantTableColumn[] = [
minWidth: 160,
compareFunction: makeStringCompareFunction('hgvsp'),
getSearchTerms: (variant: any) => [variant.hgvsp],
render: (variant: any, key: any, { highlightWords }: any) => (
render: (variant: any, _: any, { highlightWords }: any) => (
<Cell>
<Highlighter
autoEscape
Expand Down Expand Up @@ -315,7 +329,7 @@ const variantTableColumns: VariantTableColumn[] = [
rsids1[0].localeCompare(rsids2[0])
),
getSearchTerms: (variant: any) => variant.rsids || [],
render: (variant: any, key: any, { highlightWords }: any) => (
render: (variant: any, _: any, { highlightWords }: any) => (
<Cell>
<Highlighter
autoEscape
Expand Down Expand Up @@ -366,7 +380,7 @@ const variantTableColumns: VariantTableColumn[] = [
grow: 1,
compareFunction: makeNumericCompareFunction('pos'),
getSearchTerms: (variant: any) => [variant.variant_id].concat(variant.rsids || []),
render: (row: any, key: any, { highlightWords }: any) => (
render: (row: any, _: any, { highlightWords }: any) => (
<Cell>
<Link target="_blank" to={`/variant/${row.variant_id}`}>
<Highlighter autoEscape searchWords={highlightWords} textToHighlight={row.variant_id} />
Expand Down Expand Up @@ -409,7 +423,7 @@ export const getColumnsForContext = (context: any) => {
: context.canonical_transcript_id

// @ts-expect-error TS(2339) Property 'hgvs' does not exist on type '{}'.
columns.hgvs.render = (variant: any, key: any, { highlightWords }: any) => (
columns.hgvs.render = (variant: any, _: any, { highlightWords }: any) => (
<Cell>
<Highlighter autoEscape searchWords={highlightWords} textToHighlight={variant.hgvs || ''} />
{primaryTranscriptId && variant.transcript_id !== primaryTranscriptId && ' †'}
Expand Down
3 changes: 3 additions & 0 deletions browser/src/VariantPage/VariantPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export type SequencingType = BaseSequencingType & {
ac_hom: number
ac_hemi: number
af?: number
flags: string[] | null
}

export type JointSequencingType = BaseSequencingType & {
Expand Down Expand Up @@ -585,6 +586,7 @@ query ${operationName}($variantId: String!, $datasetId: DatasetId!, $referenceGe
value
}
}
flags
}
genome {
ac
Expand Down Expand Up @@ -664,6 +666,7 @@ query ${operationName}($variantId: String!, $datasetId: DatasetId!, $referenceGe
value
}
}
flags
}
joint {
ac
Expand Down
4 changes: 4 additions & 0 deletions browser/src/__factories__/Variant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ export const variantTableVariantFactory = Factory.define<VariantTableVariant>(
const {
exome = {
filters: [],
flags: [],
},
genome = {
filters: [],
flags: [],
},
} = associations

Expand Down Expand Up @@ -228,6 +230,7 @@ export const sequencingFactory = Factory.define<SequencingType>(({ params, assoc
homozygote_count = 0,
hemizygote_count = 0,
filters = [],
flags = [],
populations = [],
local_ancestry_populations = [],
ac_hemi = 1,
Expand Down Expand Up @@ -256,6 +259,7 @@ export const sequencingFactory = Factory.define<SequencingType>(({ params, assoc
homozygote_count,
hemizygote_count,
filters,
flags,
populations,
local_ancestry_populations,
age_distribution,
Expand Down
2 changes: 2 additions & 0 deletions graphql-api/src/graphql/types/variant.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type VariantSequencingTypeData {
populations: [VariantPopulation]
faf95: VariantFilteringAlleleFrequency
fafmax: Fafmax
flags: [String!]

# Deprecated - calculate from AC and AN
# Preserved for compatibility with existing browser queries
Expand Down Expand Up @@ -222,6 +223,7 @@ type VariantDetailsSequencingTypeData {
faf95: VariantFilteringAlleleFrequency
faf99: VariantFilteringAlleleFrequency
filters: [String!]
flags: [String!]
populations: [VariantPopulation]
local_ancestry_populations: [VariantLocalAncestryPopulation]!
age_distribution: VariantAgeDistribution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ const fetchMitochondrialVariantById = async (esClient: any, variantIdOrRsid: any
const variant = response.body.hits.hits[0]._source.value

// Remove nc_transcript flag due to issues with LOFTEE on mitochondrial variants
const flags = getFlagsForContext({ type: 'region' })(variant).filter(
(f: any) => f !== 'nc_transcript'
)
const { variantFlags } = getFlagsForContext({ type: 'region' }, variant)
const flags = variantFlags.filter((f: any) => f !== 'nc_transcript')

return {
...variant,
Expand Down Expand Up @@ -73,12 +72,12 @@ const FIELDS_TO_FETCH = [

const shapeMitochondrialVariantSummary = (context: any) => {
const getConsequence = getConsequenceForContext(context)
const getFlags = getFlagsForContext(context)

return (variant: any) => {
const transcriptConsequence = getConsequence(variant) || {}
// Remove nc_transcript flag due to issues with LOFTEE on mitochondrial variants
const flags = getFlags(variant).filter((f: any) => f !== 'nc_transcript')
const { variantFlags } = getFlagsForContext(context, variant)
const flags = variantFlags.filter((f: any) => f !== 'nc_transcript')

return {
...omit(variant, 'transcript_consequences', 'locus', 'alleles'), // Omit full transcript consequences list to avoid caching it
Expand Down
10 changes: 5 additions & 5 deletions graphql-api/src/queries/variant-datasets/exac-variant-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const fetchVariantById = async (esClient: any, variantIdOrRsid: any) => {

const variant = response.body.hits.hits[0]._source.value

const flags = getFlagsForContext({ type: 'region' })(variant)
const { variantFlags, exomeFlags } = getFlagsForContext({ type: 'region' }, variant)

const lofCurationResults = await fetchLofCurationResultsByVariant(esClient, variant.variant_id)

Expand All @@ -97,9 +97,10 @@ export const fetchVariantById = async (esClient: any, variantIdOrRsid: any) => {
},
site_quality_metrics: variant.exome.quality_metrics.site_quality_metrics,
},
flags: exomeFlags,
},
genome: null,
flags,
flags: variantFlags,
lof_curations: lofCurationResults,
transcript_consequences: variant.transcript_consequences || [],
}
Expand All @@ -111,16 +112,15 @@ export const fetchVariantById = async (esClient: any, variantIdOrRsid: any) => {

const shapeVariantSummary = (context: any) => {
const getConsequence = getConsequenceForContext(context)
const getFlags = getFlagsForContext(context)

return (variant: any) => {
const transcriptConsequence = getConsequence(variant) || {}
const flags = getFlags(variant)
const { variantFlags } = getFlagsForContext(context, variant)

return {
...variant,
reference_genome: 'GRCh37',
flags,
flags: variantFlags,
transcript_consequence: transcriptConsequence,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const fetchVariantById = async (esClient: any, variantIdOrRsid: any, subset: any
genomeFilters.push('AC0')
}

const flags = getFlagsForContext({ type: 'region' })(variant)
const { variantFlags, exomeFlags, genomeFlags } = getFlagsForContext({ type: 'region' }, variant)

const lofCurationResults = await fetchLofCurationResultsByVariant(esClient, variant.variant_id)

Expand All @@ -131,6 +131,7 @@ const fetchVariantById = async (esClient: any, variantIdOrRsid: any, subset: any
quality_metrics: formatVariantQualityMetrics(variant.exome.quality_metrics),
age_distribution: variant.exome.age_distribution[exomeSubset],
filters: exomeFilters,
flags: exomeFlags,
}
: null,
genome: variant.genome.freq[genomeSubset].ac_raw
Expand All @@ -140,9 +141,10 @@ const fetchVariantById = async (esClient: any, variantIdOrRsid: any, subset: any
quality_metrics: formatVariantQualityMetrics(variant.genome.quality_metrics),
age_distribution: variant.genome.age_distribution[genomeSubset],
filters: genomeFilters,
flags: genomeFlags,
}
: null,
flags,
flags: variantFlags,
lof_curations: lofCurationResults,
transcript_consequences: variant.transcript_consequences || [],
}
Expand All @@ -154,11 +156,10 @@ const fetchVariantById = async (esClient: any, variantIdOrRsid: any, subset: any

const shapeVariantSummary = (exomeSubset: any, genomeSubset: any, context: any) => {
const getConsequence = getConsequenceForContext(context)
const getFlags = getFlagsForContext(context)

return (variant: any) => {
const transcriptConsequence = getConsequence(variant) || {}
const flags = getFlags(variant)
const { variantFlags, exomeFlags, genomeFlags } = getFlagsForContext(context, variant)

const exomeFilters = variant.exome.filters || []
const genomeFilters = variant.genome.filters || []
Expand All @@ -181,6 +182,7 @@ const shapeVariantSummary = (exomeSubset: any, genomeSubset: any, context: any)
(pop: any) => !(pop.id.includes('_') || pop.id === 'XX' || pop.id === 'XY')
),
filters: exomeFilters,
flags: exomeFlags,
}
: null,
genome: variant.genome.freq[genomeSubset].ac_raw
Expand All @@ -191,9 +193,10 @@ const shapeVariantSummary = (exomeSubset: any, genomeSubset: any, context: any)
(pop: any) => !(pop.id.includes('_') || pop.id === 'XX' || pop.id === 'XY')
),
filters: genomeFilters,
flags: genomeFlags,
}
: null,
flags,
flags: variantFlags,
transcript_consequence: transcriptConsequence,
}
}
Expand Down Expand Up @@ -238,6 +241,8 @@ const fetchVariantsByGene = async (esClient: any, gene: any, subset: any) => {
`value.genome.freq.${genomeSubset}`,
'value.exome.filters',
'value.genome.filters',
'value.exome.flags',
'value.genome.flags',
'value.alt',
'value.caid',
'value.chrom',
Expand Down
Loading

0 comments on commit cd0d23b

Please sign in to comment.