diff --git a/browser/src/GenePage/VariantsInGene.tsx b/browser/src/GenePage/VariantsInGene.tsx index e5c425e23..714c3c84c 100644 --- a/browser/src/GenePage/VariantsInGene.tsx +++ b/browser/src/GenePage/VariantsInGene.tsx @@ -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 diff --git a/browser/src/RegionPage/VariantsInRegion.tsx b/browser/src/RegionPage/VariantsInRegion.tsx index 96dd99539..2a3d28864 100644 --- a/browser/src/RegionPage/VariantsInRegion.tsx +++ b/browser/src/RegionPage/VariantsInRegion.tsx @@ -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 diff --git a/browser/src/TranscriptPage/VariantsInTranscript.tsx b/browser/src/TranscriptPage/VariantsInTranscript.tsx index 16140d4cc..2f9a65361 100644 --- a/browser/src/TranscriptPage/VariantsInTranscript.tsx +++ b/browser/src/TranscriptPage/VariantsInTranscript.tsx @@ -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 diff --git a/browser/src/VariantList/ExportVariantsButton.spec.tsx b/browser/src/VariantList/ExportVariantsButton.spec.tsx index 849547ae8..526015549 100644 --- a/browser/src/VariantList/ExportVariantsButton.spec.tsx +++ b/browser/src/VariantList/ExportVariantsButton.spec.tsx @@ -8,8 +8,11 @@ import { getJointFAFFreq, getJointFilters, getJointFAFGroup, - getExomeFAFFreq, - getExomeFAFGroup, + getExomeFilters, + getV4ExomeFAFFreq, + getV4ExomeFAFGroup, + getV2ExomeFAFFreq, + getV2ExomeFAFGroup, getGenomeFAFFreq, getGenomeFAFGroup, getCadd, @@ -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' @@ -102,32 +106,32 @@ const GENOME_GROUPMAX_FREQ_LABEL = 'Genome GroupMax FAF frequency' const expectedVersionSpecificColumns: Record = { 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 }, ], @@ -177,9 +181,9 @@ const expectedVersionSpecificColumns: Record = { { 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 }, diff --git a/browser/src/VariantList/ExportVariantsButton.tsx b/browser/src/VariantList/ExportVariantsButton.tsx index f4fb468ed..e31f8e64a 100644 --- a/browser/src/VariantList/ExportVariantsButton.tsx +++ b/browser/src/VariantList/ExportVariantsButton.tsx @@ -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 @@ -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) @@ -147,28 +175,50 @@ 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, ] } @@ -176,11 +226,11 @@ export const createVersionSpecificColumns = (datasetId: DatasetId): Column[] => return [ { label: 'Exome GroupMax FAF group', - getValue: getExomeFAFGroup, + getValue: getV2ExomeFAFGroup, }, { label: 'Exome GroupMax FAF frequency', - getValue: getExomeFAFFreq, + getValue: getV2ExomeFAFFreq, }, { label: 'Genome GroupMax FAF group', @@ -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 diff --git a/dataset-metadata/metadata.ts b/dataset-metadata/metadata.ts index 1ed2120e4..6f810c050 100644 --- a/dataset-metadata/metadata.ts +++ b/dataset-metadata/metadata.ts @@ -72,6 +72,7 @@ export type DatasetMetadata = { shortVariantDatasetId: DatasetId structuralVariantDatasetId: DatasetId copyNumberVariantDatasetId: DatasetId + hasJointFrequencyData: boolean } const metadata: Record = { @@ -122,6 +123,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r2_1: { isSubset: false, @@ -170,6 +172,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r2_1_controls: { isSubset: true, @@ -218,6 +221,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r2_1_non_cancer: { isSubset: true, @@ -266,6 +270,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r2_1_non_neuro: { isSubset: true, @@ -314,6 +319,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r2_1_non_topmed: { isSubset: true, @@ -362,6 +368,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r3: { isSubset: false, @@ -410,6 +417,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r3_controls_and_biobanks: { isSubset: true, @@ -458,6 +466,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r3_non_cancer: { isSubset: true, @@ -506,6 +515,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r3_non_neuro: { isSubset: true, @@ -554,6 +564,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r3_non_topmed: { isSubset: true, @@ -602,6 +613,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_r3_non_v2: { isSubset: true, @@ -650,6 +662,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_sv_r2_1: { isSubset: false, @@ -698,6 +711,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_sv_r2_1_controls: { isSubset: true, @@ -746,6 +760,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_sv_r2_1_non_neuro: { isSubset: true, @@ -794,6 +809,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: false, }, gnomad_sv_r4: { isSubset: false, @@ -842,6 +858,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: true, }, gnomad_cnv_r4: { isSubset: false, @@ -890,6 +907,7 @@ const metadata: Record = { isV4CNVs: true, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: true, + hasJointFrequencyData: true, }, gnomad_r4: { isSubset: false, @@ -938,6 +956,7 @@ const metadata: Record = { isV4CNVs: false, copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, + hasJointFrequencyData: true, }, gnomad_r4_non_ukb: { isSubset: true, @@ -986,6 +1005,7 @@ const metadata: Record = { copyNumberVariantDatasetId: 'gnomad_cnv_r4', hasCopyNumberVariantCoverage: false, hasRelatedVariants: true, + hasJointFrequencyData: false, }, } @@ -1116,3 +1136,6 @@ export const hasCopyNumberVariantCoverage = (datasetId: DatasetId) => export const baseDatasetForReferenceGenome = (genome: ReferenceGenome): DatasetId => genome === 'GRCh37' ? 'gnomad_r2_1' : 'gnomad_r4' + +export const hasJointFrequencyData = (datasetId: DatasetId): boolean => + getMetadata(datasetId, 'hasJointFrequencyData')