Skip to content

Commit

Permalink
Merge pull request #5 from eastgenomics/fix_things
Browse files Browse the repository at this point in the history
simplify de novo filtering (#5)
  • Loading branch information
chrispyatt authored Jun 28, 2024
2 parents 599d2a3 + 5a8f0ae commit b438e23
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 91 deletions.
59 changes: 21 additions & 38 deletions resources/home/dnanexus/make_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,20 +622,6 @@ def create_gel_tiering_variant_page(self):
else:
summary_sheet[key] = 0

def get_de_novo_threshold(self, variant):
'''
The de novo quality score thresholds are different for indels or SNVs
This function works out if a variant is an indel based on having either
a ref or an alt sequence > 1
'''
if (len(variant["variantCoordinates"]["reference"]) > 1 or
len(variant["variantCoordinates"]["alternate"]) > 1):
threshold = self.config['denovo_quality_scores']['indel']
else:
threshold = self.config['denovo_quality_scores']['snv']

return threshold

def create_additional_analysis_page(self):
'''
Get Tier3/Null SNVs for Exomiser/deNovo analysis
Expand Down Expand Up @@ -700,35 +686,32 @@ def create_additional_analysis_page(self):
variant_list.append(var_dict)

# Get variants with high de novo quality score (these are either SNVs
# or indels)
# or indels). These variants only appear in the JSON if the quality
# score is above the threshold
for snv in self.wgs_data["interpretedGenomes"][
self.gel_index
]["interpretedGenomeData"]["variants"]:
for event in snv["reportEvents"]:
if event['deNovoQualityScore'] is not None:
if (
event['deNovoQualityScore'] >
self.get_de_novo_threshold(snv)
):
event_index = snv["reportEvents"].index(event)
var_dict = VariantUtils.get_snv_info(
if event['segregationPattern'] == 'deNovo':
event_index = snv["reportEvents"].index(event)
var_dict = VariantUtils.get_snv_info(
snv,
self.proband,
event_index,
self.column_list,
self.mother,
self.father,
self.proband_sex
)
var_dict["Priority"] = "De novo"
var_dict["Inheritance"] = "De novo"
var_dict["HGVSc"], var_dict["HGVSp"] = (
VariantNomenclature.get_hgvs_gel(
snv,
self.proband,
event_index,
self.column_list,
self.mother,
self.father,
self.proband_sex
)
var_dict["Priority"] = "De novo"
var_dict["Inheritance"] = "De novo"
var_dict["HGVSc"], var_dict["HGVSp"] = (
VariantNomenclature.get_hgvs_gel(
snv,
self.mane,
self.refseq_tsv)
)
variant_list.append(var_dict)
self.mane,
self.refseq_tsv)
)
variant_list.append(var_dict)

ex_df = pd.DataFrame(variant_list)
ex_df = ex_df.drop_duplicates()
Expand Down
53 changes: 0 additions & 53 deletions resources/home/dnanexus/tests/test_make_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,56 +253,3 @@ def test_get_ensp(self):
assert VariantNomenclature.get_ensp(
refseq_tsv, "ENST0000033"
) == "ENSP0000044"


class TestDeNovoThresholds():
'''
Tests for function that gets the de novo quality score threshold based on
the ref and alt of the variant. The threshold should be different for
indels and SNVs, so this test assumes that a ref or alt longer than one
base is an indel.
'''
variants = [
{
"variantCoordinates": {
"reference": "GT",
"alternate": "G"
},
},
{
"variantCoordinates": {
"reference": "C",
"alternate": "G"
},
},
{
"variantCoordinates": {
"reference": "A",
"alternate": "AC"
},
},
]
config = {
"denovo_quality_scores": {
"indel": 0.02,
"snv": 0.0013
}
}

def test_deletion_de_novo_threshold_correct(self):
'''
Test that get_de_novo_threshold gets correct threshold for an deletion
'''
assert excel.get_de_novo_threshold(self, self.variants[0]) == 0.02

def test_snv_de_novo_threshold_correct(self):
'''
Test that get_de_novo_threshold gets correct threshold for an SNV
'''
assert excel.get_de_novo_threshold(self, self.variants[1]) == 0.0013

def test_insertion_de_novo_threshold_correct(self):
'''
Test that get_de_novo_threshold gets correct threshold for an insertion
'''
assert excel.get_de_novo_threshold(self, self.variants[2]) == 0.02

0 comments on commit b438e23

Please sign in to comment.