Skip to content

Commit

Permalink
Fix CSV export of non-UKB v4 variants
Browse files Browse the repository at this point in the history
  • Loading branch information
phildarnowsky-broad committed May 10, 2024
1 parent 4503a94 commit 75286a0
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 37 deletions.
6 changes: 6 additions & 0 deletions browser/src/GenePage/VariantsInGene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ query ${operationName}($geneId: String!, $datasetId: DatasetId!, $referenceGenom
ac_hemi
ac_hom
}
fafmax {
faf95_max
faf95_max_gen_anc
faf99_max
faf99_max_gen_anc
}
}
genome {
ac
Expand Down
6 changes: 6 additions & 0 deletions browser/src/RegionPage/VariantsInRegion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ query ${operationName}($chrom: String!, $start: Int!, $stop: Int!, $datasetId: D
ac_hemi
ac_hom
}
fafmax {
faf95_max
faf95_max_gen_anc
faf99_max
faf99_max_gen_anc
}
}
genome {
ac
Expand Down
6 changes: 6 additions & 0 deletions browser/src/TranscriptPage/VariantsInTranscript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ query ${operationName}($transcriptId: String!, $datasetId: DatasetId!, $referenc
ac_hemi
ac_hom
}
fafmax {
faf95_max
faf95_max_gen_anc
faf99_max
faf99_max_gen_anc
}
}
genome {
ac
Expand Down
34 changes: 19 additions & 15 deletions browser/src/VariantList/ExportVariantsButton.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import {
getJointFAFFreq,
getJointFilters,
getJointFAFGroup,
getExomeFAFFreq,
getExomeFAFGroup,
getExomeFilters,
getV4ExomeFAFFreq,
getV4ExomeFAFGroup,
getV2ExomeFAFFreq,
getV2ExomeFAFGroup,
getGenomeFAFFreq,
getGenomeFAFGroup,
getCadd,
Expand Down Expand Up @@ -94,6 +97,7 @@ const PANGOLIN_LARGEST_DS_LABEL = 'pangolin_largest_ds'
const PHYLOP_LABEL = 'phylop'
const SIFT_MAX_LABEL = 'sift_max'
const POLYPHEN_MAX_LABEL = 'polyphen_max'
const EXOME_FILTERS_LABEL = 'Filters - exome'
const EXOME_GROUPMAX_GROUP_LABEL = 'Exome GroupMax FAF group'
const EXOME_GROUPMAX_FREQ_LABEL = 'Exome GroupMax FAF frequency'
const GENOME_GROUPMAX_GROUP_LABEL = 'Genome GroupMax FAF group'
Expand All @@ -102,32 +106,32 @@ const GENOME_GROUPMAX_FREQ_LABEL = 'Genome GroupMax FAF frequency'
const expectedVersionSpecificColumns: Record<DatasetId, Column[]> = {
exac: [],
gnomad_r2_1: [
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getExomeFAFFreq },
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getV2ExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getV2ExomeFAFFreq },
{ label: GENOME_GROUPMAX_GROUP_LABEL, getValue: getGenomeFAFGroup },
{ label: GENOME_GROUPMAX_FREQ_LABEL, getValue: getGenomeFAFFreq },
],
gnomad_r2_1_controls: [
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getExomeFAFFreq },
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getV2ExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getV2ExomeFAFFreq },
{ label: GENOME_GROUPMAX_GROUP_LABEL, getValue: getGenomeFAFGroup },
{ label: GENOME_GROUPMAX_FREQ_LABEL, getValue: getGenomeFAFFreq },
],
gnomad_r2_1_non_cancer: [
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getExomeFAFFreq },
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getV2ExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getV2ExomeFAFFreq },
{ label: GENOME_GROUPMAX_GROUP_LABEL, getValue: getGenomeFAFGroup },
{ label: GENOME_GROUPMAX_FREQ_LABEL, getValue: getGenomeFAFFreq },
],
gnomad_r2_1_non_neuro: [
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getExomeFAFFreq },
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getV2ExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getV2ExomeFAFFreq },
{ label: GENOME_GROUPMAX_GROUP_LABEL, getValue: getGenomeFAFGroup },
{ label: GENOME_GROUPMAX_FREQ_LABEL, getValue: getGenomeFAFFreq },
],
gnomad_r2_1_non_topmed: [
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getExomeFAFFreq },
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getV2ExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getV2ExomeFAFFreq },
{ label: GENOME_GROUPMAX_GROUP_LABEL, getValue: getGenomeFAFGroup },
{ label: GENOME_GROUPMAX_FREQ_LABEL, getValue: getGenomeFAFFreq },
],
Expand Down Expand Up @@ -177,9 +181,9 @@ const expectedVersionSpecificColumns: Record<DatasetId, Column[]> = {
{ label: POLYPHEN_MAX_LABEL, getValue: getPolyphen },
],
gnomad_r4_non_ukb: [
{ label: JOINT_FILTERS_LABEL, getValue: getJointFilters },
{ label: JOINT_GROUPMAX_GROUP_LABEL, getValue: getJointFAFGroup },
{ label: JOINT_GROUPMAX_FREQ_LABEL, getValue: getJointFAFFreq },
{ label: EXOME_FILTERS_LABEL, getValue: getExomeFilters },
{ label: EXOME_GROUPMAX_GROUP_LABEL, getValue: getV4ExomeFAFGroup },
{ label: EXOME_GROUPMAX_FREQ_LABEL, getValue: getV4ExomeFAFFreq },
{ label: CADD_LABEL, getValue: getCadd },
{ label: REVEL_MAX_LABEL, getValue: getRevel },
{ label: SPLICEAI_DS_MAX_LABEL, getValue: getSpliceAI },
Expand Down
100 changes: 78 additions & 22 deletions browser/src/VariantList/ExportVariantsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import {
PopulationId,
populationsInDataset,
} from '@gnomad/dataset-metadata/gnomadPopulations'
import { DatasetId, isExac, isV2, isV3, isV4 } from '@gnomad/dataset-metadata/metadata'
import {
DatasetId,
isExac,
isV2,
isV3,
isV4,
hasJointFrequencyData,
} from '@gnomad/dataset-metadata/metadata'

type ColumnGetter = (variant: VariantTableVariant) => string

Expand Down Expand Up @@ -91,14 +98,35 @@ export const getJointFAFFreq: ColumnGetter = (variant: VariantTableVariant) => {
: ''
}

export const getExomeFAFGroup = (variant: VariantTableVariant) => {
export const getExomeFilters: ColumnGetter = (variant: VariantTableVariant) => {
const v4Variant = variant as V4VariantTableVariant
return !v4Variant.exome || v4Variant.exome.filters.length === 0
? 'PASS'
: v4Variant.exome!.filters.join(',')
}

export const getV4ExomeFAFGroup = (variant: VariantTableVariant) => {
const v4Variant = variant as V4VariantTableVariant
return v4Variant.exome && v4Variant.exome.fafmax.faf95_max_gen_anc !== null
? v4Variant.exome.fafmax.faf95_max_gen_anc
: ''
}

export const getV4ExomeFAFFreq = (variant: VariantTableVariant) => {
const v4Variant = variant as V4VariantTableVariant
return v4Variant.exome && v4Variant.exome.fafmax.faf95_max !== null
? JSON.stringify(v4Variant.exome.fafmax.faf95_max)
: ''
}

export const getV2ExomeFAFGroup = (variant: VariantTableVariant) => {
const v2Variant = variant as V2VariantTableVariant
return v2Variant.exome && v2Variant.exome.faf95.popmax_population !== null
? v2Variant.exome.faf95.popmax_population
: ''
}

export const getExomeFAFFreq = (variant: VariantTableVariant) => {
export const getV2ExomeFAFFreq = (variant: VariantTableVariant) => {
const v2Variant = variant as V2VariantTableVariant
return v2Variant.exome && v2Variant.exome.faf95.popmax !== null
? JSON.stringify(v2Variant.exome.faf95.popmax)
Expand Down Expand Up @@ -147,40 +175,62 @@ export const getSift: ColumnGetter = (variant: VariantTableVariant) =>
export const getPolyphen: ColumnGetter = (variant: VariantTableVariant) =>
getPredictorValue(variant, 'polyphen_max')

const inSilicoColumns: Column[] = [
{ label: 'cadd', getValue: getCadd },
{ label: 'revel_max', getValue: getRevel },
{ label: 'spliceai_ds_max', getValue: getSpliceAI },
{ label: 'pangolin_largest_ds', getValue: getPangolin },
{ label: 'phylop', getValue: getPhylop },
{ label: 'sift_max', getValue: getSift },
{ label: 'polyphen_max', getValue: getPolyphen },
]

export const createVersionSpecificColumns = (datasetId: DatasetId): Column[] => {
if (isV4(datasetId)) {
if (hasJointFrequencyData(datasetId)) {
return [
{
label: 'Filters - joint',
getValue: getJointFilters,
},
{
label: 'GroupMax FAF group',
getValue: getJointFAFGroup,
},
{
label: 'GroupMax FAF frequency',
getValue: getJointFAFFreq,
},
...inSilicoColumns,
]
}

return [
{
label: 'Filters - joint',
getValue: getJointFilters,
label: 'Filters - exome',
getValue: getExomeFilters,
},
{
label: 'GroupMax FAF group',
getValue: getJointFAFGroup,
label: 'Exome GroupMax FAF group',
getValue: getV4ExomeFAFGroup,
},
{
label: 'GroupMax FAF frequency',
getValue: getJointFAFFreq,
label: 'Exome GroupMax FAF frequency',
getValue: getV4ExomeFAFFreq,
},
{ label: 'cadd', getValue: getCadd },
{ label: 'revel_max', getValue: getRevel },
{ label: 'spliceai_ds_max', getValue: getSpliceAI },
{ label: 'pangolin_largest_ds', getValue: getPangolin },
{ label: 'phylop', getValue: getPhylop },
{ label: 'sift_max', getValue: getSift },
{ label: 'polyphen_max', getValue: getPolyphen },
...inSilicoColumns,
]
}

if (isV2(datasetId)) {
return [
{
label: 'Exome GroupMax FAF group',
getValue: getExomeFAFGroup,
getValue: getV2ExomeFAFGroup,
},
{
label: 'Exome GroupMax FAF frequency',
getValue: getExomeFAFFreq,
getValue: getV2ExomeFAFFreq,
},
{
label: 'Genome GroupMax FAF group',
Expand Down Expand Up @@ -402,14 +452,20 @@ type V2VariantTableVariant = VariantTableVariant & {
}
}

type Fafmax = {
faf95_max: number | null
faf95_max_gen_anc: string | null
}

type V4VariantTableVariant = VariantTableVariant & {
joint: {
filters: string[]
fafmax: {
faf95_max: number | null
faf95_max_gen_anc: string | null
}
fafmax: Fafmax
}
exome: {
filters: string[]
fafmax: Fafmax
} | null
in_silico_predictors: {
id: string
value: string
Expand Down
Loading

0 comments on commit 75286a0

Please sign in to comment.