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

MDE/merge-lovd-gnomad #16

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 4 additions & 1 deletion data_collection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@
# Functions for refactoring data
convert_lovd_to_datatype,
parse_lovd,
from_clinvar_name_to_cdna_position
from_clinvar_name_to_cdna_position,

# Functions for data merging
merge_lovd_with_gnomad,
)
11 changes: 3 additions & 8 deletions data_collection/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import pandas as pd

from .collection import store_database_for_eys_gene
from .refactoring import parse_lovd, convert_lovd_to_datatype, from_clinvar_name_to_cdna_position
from .refactoring import (parse_lovd, convert_lovd_to_datatype,
from_clinvar_name_to_cdna_position, merge_lovd_with_gnomad)
from .constants import (DATA_PATH,
LOVD_PATH,
GNOMAD_PATH,
Expand Down Expand Up @@ -89,13 +90,7 @@ def main():
on=["VariantOnTranscript/DNA"]).drop("Name(clinvar)", axis=1)

# MERGING GnomAd
main_frame = (pd.merge(main_frame,
gnomad_data,
how="left",
left_on="VariantOnTranscript/DNA",
right_on="HGVS Consequence(gnomad)").
drop("HGVS Consequence(gnomad)",
axis=1))
main_frame = merge_lovd_with_gnomad(main_frame, gnomad_data)

# Calculating frequencies
lovd_without_association_in_gnomad = pd.isnull(main_frame["Hemizygote Count Remaining(gnomad)"])
Expand Down
16 changes: 16 additions & 0 deletions data_collection/refactoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,19 @@ def from_clinvar_name_to_cdna_position(name):
break

return name[start:end]

def merge_lovd_with_gnomad(lovd_data, gnomad_data):
"""
Merges LOVD and GNOMAD data based on DNA variant.

:param DataFrame lovd_data: LOVD data
:param DataFrame gnomad_data: GNOMAD data
:returns: merged data
:rtype: DataFrame
"""

return pd.merge(lovd_data,
gnomad_data,
how="outer",
left_on="VariantOnTranscript/DNA",
right_on="Transcript Consequence(gnomad)")
Loading