Skip to content

Commit

Permalink
Adding distinct de novo genotype setting (#562)
Browse files Browse the repository at this point in the history
Closes: #562
Related-Issue: #562
Projected-Results-Impact: require-revalidation
  • Loading branch information
holtgrewe committed Aug 26, 2022
1 parent bc37b6c commit a3f43db
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 36 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Expand Up @@ -44,6 +44,7 @@ End-User Summary
Alternatively, you can use ``python manage.py svs_sv_fill_nulls`` to update the records on the fly.
- Implement new in-house background database for structural variants (#32).
- Allow to exclude cases from in-house database through project settings (#579).
- Adding distinct de novo genotype setting (#562).

Full Change List
================
Expand Down Expand Up @@ -83,6 +84,7 @@ Full Change List
- Making ``keyvalue`` more robust to failure (#613).
- Implement new in-house background database for structural variants (#32).
- Allow to exclude cases from in-house database through project settings (#579).
- Adding distinct de novo genotype setting (#562).

------
v1.2.0
Expand Down
40 changes: 30 additions & 10 deletions varfish/static/js/filter_form.js
Expand Up @@ -501,8 +501,11 @@ const presets = {
},
"inheritance-dominant": {
"ids": {},
// dom-denovo doesn't exist in the select. this triggers a function
"classes": {"genotype-field-gt": "dom-denovo"},
"classes": {"genotype-field-gt": "dominant"},
},
"inheritance-de-novo": {
"ids": {},
"classes": {"genotype-field-gt": "de-novo"},
},
"inheritance-hom-recessive": {
"ids": {},
Expand Down Expand Up @@ -1469,7 +1472,21 @@ function enableHomRecessiveMode(target) {
}


function enableDomDenovoMode() {
function enableDeNovoMode() {
// Index will be set to variant, all others to ref
$("[id^=id_][id$=_gt]").each(
function () {
console.log($(this), $(this).data("default-index"))
if ($(this).data("default-index") === 1) {
$(this).val("variant")
} else {
$(this).val("ref")
}
}
)
}

function enableDominantMode() {
// All affected will be set to het
$("[id^=id_][id$=_gt].affected").val("het");
// All unaffected will be set to ref
Expand Down Expand Up @@ -1637,18 +1654,13 @@ function applyPresetsToSettings(presets, name) {
(
val == "index"
|| val == "recessive-index"
|| val == "dom-denovo"
|| val == "hom-recessive"
|| val == "mitochondrial"
|| val == "x-recessive"
) && tag.data("default-index") != "1"
) {
continue;
}
// Dominant denovo is not an option in the genotype select, so let a function do the change.
if (val == "dom-denovo") {
enableDomDenovoMode();
}
// Homozygous recessive is not an option in the genotype select, so let a function do the change.
else if (val == "hom-recessive") {
enableHomRecessiveMode(tag);
Expand All @@ -1661,6 +1673,14 @@ function applyPresetsToSettings(presets, name) {
else if (val == "x-recessive") {
enableXRecessiveMode(tag);
}
// X recessive is not an option in the genotype select, so let a function do the change.
else if (val == "de-novo") {
enableDeNovoMode();
}
// X recessive is not an option in the genotype select, so let a function do the change.
else if (val == "dominant") {
enableDominantMode();
}
// Default change behaviour for all others
else {
tag.val(val);
Expand Down Expand Up @@ -1698,7 +1718,7 @@ function updateQuickPresets(settings) {
}
const quickPresetCategories = ["inheritance", "frequency", "impact", "quality", "region", "flags"];
const quickPresetCandidates = {
"inheritance": ["any", "dominant", "hom-recessive", "comp-het", "recessive", "mitochondrial", "x-recessive"],
"inheritance": ["any", "dominant", "de-novo", "hom-recessive", "comp-het", "recessive", "mitochondrial", "x-recessive"],
"frequency": ["super-strict", "strict", "relaxed", "recessive-strict", "recessive-relaxed", "all"],
"impact": ["null-variant", "aa-change", "all-coding-deep-intronic", "whole-transcript", "any"],
"quality": ["super-strict", "strict", "relaxed", "ignore"],
Expand Down Expand Up @@ -1852,7 +1872,7 @@ function loadPresets(element) {
$("#input-presets-region").val("region-whole-genome")
$("#input-presets-flags").val("flags-default")
} else if (presetsName == "de-novo") {
$("#input-presets-inheritance").val("inheritance-dominant")
$("#input-presets-inheritance").val("inheritance-de-novo")
$("#input-presets-frequency").val("frequency-strict")
$("#input-presets-impact").val("impact-aa-change")
$("#input-presets-quality").val("quality-relaxed")
Expand Down
5 changes: 1 addition & 4 deletions variants/forms.py
Expand Up @@ -442,10 +442,7 @@ def clean(self):
result["compound_recessive_indices"][family] = name
elif result[self.get_genotype_field_names()[name]["gt"]] == "recessive-index":
result["recessive_indices"][family] = name
elif result[self.get_genotype_field_names()[name]["gt"]] in (
"hom-recessive-index",
"dom-denovo-index",
):
elif result[self.get_genotype_field_names()[name]["gt"]] == "hom-recessive-index":
self.add_error(
self.get_genotype_field_names()[name]["gt"],
"This option value shouldn't be passed. Selecting it should trigger JS code which changes the value.",
Expand Down
14 changes: 13 additions & 1 deletion variants/query_presets.py
Expand Up @@ -77,6 +77,7 @@ class GenotypeChoice(Enum):
class Inheritance(Enum):
"""Preset options for category inheritance"""

DE_NOVO = "de_novo"
DOMINANT = "dominant"
HOMOZYGOUS_RECESSIVE = "homozygous_recessive"
COMPOUND_HETEROZYGOUS = "compound_heterozygous"
Expand Down Expand Up @@ -204,6 +205,17 @@ def to_settings(
for s in samples
},
}
elif self == Inheritance.DE_NOVO:
return {
"recessive_index": None,
"recessive_mode": None,
"genotype": {
s.name: GenotypeChoice.VARIANT.value
if s.name == index_candidates[0].name
else GenotypeChoice.REF.value
for s in samples
},
}
elif self == Inheritance.DOMINANT:
return {
"recessive_index": None,
Expand Down Expand Up @@ -998,7 +1010,7 @@ class _QuickPresetList:
)
#: *de novo* presets
de_novo: QuickPresets = QuickPresets(
inheritance=Inheritance.DOMINANT,
inheritance=Inheritance.DE_NOVO,
frequency=Frequency.DOMINANT_STRICT,
impact=Impact.AA_CHANGE_SPLICING,
quality=Quality.RELAXED,
Expand Down
3 changes: 0 additions & 3 deletions variants/query_schemas.py
Expand Up @@ -243,7 +243,6 @@ class CaseQueryV1:

recessive_mode: typing.Optional[RecessiveModeV1] = None
recessive_index: typing.Optional[str] = None
denovo_index: typing.Optional[str] = None

exac_frequency: typing.Optional[float] = None
exac_heterozygous: typing.Optional[int] = None
Expand Down Expand Up @@ -406,8 +405,6 @@ def convert(self, case: Case, query: CaseQueryV1) -> typing.Dict[str, typing.Any
result["%s_gt" % sample] = "recessive-index"
elif sample in result["compound_recessive_indices"].values():
result["%s_gt" % sample] = "index"
elif sample == query.denovo_index:
result["%s_gt" % sample] = "dom-denovo-index"
else:
gt = query.genotype.get(sample, GenotypeChoiceV1.ANY)
if gt:
Expand Down
16 changes: 0 additions & 16 deletions variants/schemas/case-query-v1.json
Expand Up @@ -1293,22 +1293,6 @@
}
]
},
"denovo_index": {
"anyOf": [
{
"type": "null"
},
{
"$id": "#/properties/denovo_index",
"type": "string",
"title": "Select the denovo index",
"description": "Set to the identifier of the de novo index",
"examples": [
"CHILD-NAME"
]
}
]
},
"quality": {
"$id": "#/properties/quality",
"type": "object",
Expand Down
3 changes: 2 additions & 1 deletion variants/templates/variants/filter_form/presets.html
Expand Up @@ -28,7 +28,8 @@
<label for="input-presets-inheritance" class="font-weight-bold small">Inheritance</label>
<select id="input-presets-inheritance" class="form-control form-control-sm">
<option value="inheritance-any" selected="selected">any (default)</option>
<option value="inheritance-dominant" >dominant / de novo</option>
<option value="inheritance-de-novo" >de novo</option>
<option value="inheritance-dominant" >dominant</option>
<option value="inheritance-hom-recessive" >hom. recessive</option>
<option value="inheritance-comp-het" >comp. heterozygous</option>
<option value="inheritance-recessive" >recessive</option>
Expand Down
75 changes: 74 additions & 1 deletion variants/tests/test_query_presets.py
Expand Up @@ -230,6 +230,7 @@ def setUp(self):

class TestEnumInheritance(PedigreesMixin, TestCase):
def testValues(self):
self.assertEqual(query_presets.Inheritance.DE_NOVO.value, "de_novo")
self.assertEqual(query_presets.Inheritance.DOMINANT.value, "dominant")
self.assertEqual(
query_presets.Inheritance.HOMOZYGOUS_RECESSIVE.value, "homozygous_recessive"
Expand All @@ -243,6 +244,78 @@ def testValues(self):
self.assertEqual(query_presets.Inheritance.CUSTOM.value, "custom")
self.assertEqual(query_presets.Inheritance.ANY.value, "any")

def testToSettingsDeNovo(self):
# singleton
actual = query_presets.Inheritance.DE_NOVO.to_settings(self.singleton, self.singleton[0])
self.assertEqual(
actual,
{
"genotype": {"index": query_presets.GenotypeChoice.VARIANT.value},
"recessive_index": None,
"recessive_mode": None,
},
)
# child with father
actual = query_presets.Inheritance.DE_NOVO.to_settings(
self.child_father, self.child_father[0].name
)
self.assertEqual(
actual,
{
"recessive_index": None,
"recessive_mode": None,
"genotype": {
"index": query_presets.GenotypeChoice.VARIANT.value,
"father": query_presets.GenotypeChoice.REF.value,
},
},
)
# child with mother
actual = query_presets.Inheritance.DE_NOVO.to_settings(
self.child_mother, self.child_mother[0].name
)
self.assertEqual(
actual,
{
"recessive_index": None,
"recessive_mode": None,
"genotype": {
"index": query_presets.GenotypeChoice.VARIANT.value,
"mother": query_presets.GenotypeChoice.REF.value,
},
},
)
# trio denovo
actual = query_presets.Inheritance.DE_NOVO.to_settings(self.trio_denovo, self.singleton[0])
self.assertEqual(
actual,
{
"recessive_index": None,
"recessive_mode": None,
"genotype": {
"index": query_presets.GenotypeChoice.VARIANT.value,
"father": query_presets.GenotypeChoice.REF.value,
"mother": query_presets.GenotypeChoice.REF.value,
},
},
)
# trio dominant inherited
actual = query_presets.Inheritance.DE_NOVO.to_settings(
self.trio_dominant, self.trio_dominant[0].name
)
self.assertEqual(
actual,
{
"recessive_index": None,
"recessive_mode": None,
"genotype": {
"index": query_presets.GenotypeChoice.VARIANT.value,
"father": query_presets.GenotypeChoice.REF.value,
"mother": query_presets.GenotypeChoice.REF.value,
},
},
)

def testToSettingsDominant(self):
# singleton
actual = query_presets.Inheritance.DOMINANT.to_settings(self.singleton, self.singleton[0])
Expand Down Expand Up @@ -1469,7 +1542,7 @@ def testValueDefaults(self):
def testValueDeNovo(self):
self.assertEqual(
str(query_presets.QUICK_PRESETS.de_novo),
"QuickPresets(inheritance=<Inheritance.DOMINANT: 'dominant'>, "
"QuickPresets(inheritance=<Inheritance.DE_NOVO: 'de_novo'>, "
"frequency=<Frequency.DOMINANT_STRICT: 'dominant_strict'>, "
"impact=<Impact.AA_CHANGE_SPLICING: 'aa_change_splicing'>, "
"quality=<Quality.RELAXED: 'relaxed'>, chromosomes=<Chromosomes.WHOLE_GENOME: 'whole_genome'>, "
Expand Down

0 comments on commit a3f43db

Please sign in to comment.