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

VA/VRS quality measures #1610

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions graphql-api/src/graphql/resolvers/va.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ describe('resolveVACohortAlleleFrequency', () => {
homozygote_count: 3,
faf95: { popmax: 0.123, popmax_population: 'afr' },
ancestry_groups: [],
filters: ['AC0'],
flags: ['monoallelic'],
quality_metrics: {
allele_balance: {
alt: { bin_freq: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] },
},
},
}

const genomeEsDocument = {
Expand All @@ -67,7 +74,19 @@ describe('resolveVACohortAlleleFrequency', () => {
hemizygote_count: 4,
homozygote_count: 5,
faf95: { popmax: 0.234, popmax_population: 'eas' },
filters: ['AC0'],
ancestry_groups: [],
flags: ['monoallelic'],
quality_metrics: {
allele_balance: {
alt: {
bin_freq: [
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
117, 118, 119,
],
},
},
},
}

const variantESDocument = {
Expand All @@ -76,6 +95,8 @@ describe('resolveVACohortAlleleFrequency', () => {
exome: exomeEsDocument,
genome: genomeEsDocument,
joint: { fafmax: { faf95_max: 0.234, faf95_max_gen_anc: 'amr' } },
coverage: { exome: { mean: 0.345, over_20: 0.456 }, genome: { mean: 0.111, over_20: 0.222 } },
flags: ['lcr', 'lc_lof', 'lof_flag'],
}

test('parses a single CohortAlleleFrequency exome correctly', async () => {
Expand Down Expand Up @@ -103,6 +124,16 @@ describe('resolveVACohortAlleleFrequency', () => {
hemizygotes: 2,
},
subcohortFrequency: [],
qualityMeasures: {
meanDepth: 0.345,
fractionCoverage20x: 0.456,
qcFilters: ['AC0'],
monoallelic: true,
lowComplexityRegion: true,
lowConfidenceLossOfFunctionError: true,
lossOfFunctionWarning: true,
heterozygousSkewedAlleleCount: 37,
},
},
]

Expand Down Expand Up @@ -134,6 +165,16 @@ describe('resolveVACohortAlleleFrequency', () => {
hemizygotes: 4,
},
subcohortFrequency: [],
qualityMeasures: {
meanDepth: 0.111,
fractionCoverage20x: 0.222,
monoallelic: true,
qcFilters: ['AC0'],
lowComplexityRegion: true,
lowConfidenceLossOfFunctionError: true,
lossOfFunctionWarning: true,
heterozygousSkewedAlleleCount: 237,
},
},
]

Expand Down
46 changes: 46 additions & 0 deletions graphql-api/src/graphql/resolvers/va.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ type AncillaryResults = {
hemizygotes: number | null
}

type QualityMeasures = {
meanDepth: number | null
fractionCoverage20x: number | null
qcFilters: string[] | null
monoallelic: boolean | null
lowComplexityRegion: boolean | null
lowConfidenceLossOfFunctionError: boolean | null
lossOfFunctionWarning: boolean | null
heterozygousSkewedAlleleCount: number | null
}

export type CohortAlleleFrequency = {
id: string
type: string
Expand All @@ -104,6 +115,7 @@ export type CohortAlleleFrequency = {
alleleFrequency: number
cohort: Cohort
ancillaryResults: AncillaryResults | null
qualityMeasures: QualityMeasures | null
subcohortFrequency: CohortAlleleFrequency[]
}

Expand Down Expand Up @@ -187,6 +199,7 @@ type Subset = {
homozygote_count: number
grpMax?: GrpMaxFAF95
jointGrpMax?: GrpMaxFAF95
qualityMeasures: QualityMeasures
}

const GNOMAD_V4_DERIVATION = {
Expand Down Expand Up @@ -279,6 +292,7 @@ const resolveVACohortAlleleFrequency = (
alleleFrequency: subset.ac / subset.an,
cohort,
ancillaryResults,
qualityMeasures: subset.qualityMeasures,
}
}

Expand Down Expand Up @@ -367,6 +381,25 @@ const addSubcohorts = (
return Object.values(subcohortMap)
}

type ESFrequencies = {
quality_metrics: {
allele_balance: {
alt?: {
bin_freq: number[]
}
}
}
}

const calculateHeterozygousSkewedAlleleCount = (frequencies: ESFrequencies): number | null => {
const { alt } = frequencies.quality_metrics.allele_balance
if (!alt) {
return null
}

return alt.bin_freq[18] + alt.bin_freq[19]
}

const resolveVACohortAlleleFrequencies = async (
obj: any,
args: any,
Expand All @@ -382,6 +415,18 @@ const resolveVACohortAlleleFrequencies = async (
if (!frequencies) {
return null
}
const coverage = obj.coverage[frequencyField]

const qualityMeasures = {
meanDepth: coverage && coverage.mean ? coverage.mean : null,
fractionCoverage20x: coverage && coverage.over_20 ? coverage.over_20 : null,
qcFilters: frequencies.filters,
monoallelic: frequencies.flags.includes('monoallelic'),
lowComplexityRegion: obj.flags.includes('lcr'),
lowConfidenceLossOfFunctionError: obj.flags.includes('lc_lof'),
lossOfFunctionWarning: obj.flags.includes('lof_flag'),
heterozygousSkewedAlleleCount: calculateHeterozygousSkewedAlleleCount(frequencies),
}

const fullSet: Subset = {
ac: frequencies.ac,
Expand All @@ -401,6 +446,7 @@ const resolveVACohortAlleleFrequencies = async (
confidenceInterval: 0.95,
}
: undefined,
qualityMeasures,
}
const subsets = [fullSet, ...(frequencies.ancestry_groups as Subset[])]
const cohortsWithoutSubcohorts = subsets.map((subset) =>
Expand Down
3 changes: 2 additions & 1 deletion graphql-api/src/graphql/types/va.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ type VAQualityMeasures {
lowComplexityRegion: Boolean
lowConfidenceLossOfFunctionError: Boolean
lossOfFunctionWarning: Boolean
noncodingTranscriptError: Boolean
heterozygousSkewedAlleleCount: Int
}

Expand All @@ -118,6 +117,8 @@ type VACohortAlleleFrequencyData {
cohort: VACohort!
"Ancillary results that may be associated with the CohortAlleleFrequency, providing additional context or information."
ancillaryResults: VAAncillaryResults
"Metrics of quality of, or confidence in, the CohortAlleleFrequency."
qualityMeasures: VAQualityMeasures
"""
A list of CohortAlleleFrequency objects describing subcohorts of the cohort currently being described.
This creates a recursive relationship and subcohorts can be further subdivided into more subcohorts.
Expand Down
Loading