Skip to content

Commit

Permalink
Incorporate exome/genome flags into frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
phildarnowsky-broad committed Sep 5, 2024
1 parent fefd197 commit 2293dff
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 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
2 changes: 2 additions & 0 deletions browser/src/VariantPage/VariantPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ query ${operationName}($variantId: String!, $datasetId: DatasetId!, $referenceGe
value
}
}
flags
}
genome {
ac
Expand Down Expand Up @@ -665,6 +666,7 @@ query ${operationName}($variantId: String!, $datasetId: DatasetId!, $referenceGe
value
}
}
flags
}
joint {
ac
Expand Down

0 comments on commit 2293dff

Please sign in to comment.