Skip to content

Commit

Permalink
Merge pull request #93 from FHIR/mendelian
Browse files Browse the repository at this point in the history
Mendelian Screening App
  • Loading branch information
mihaitodor authored Sep 5, 2024
2 parents ef1266e + a1d97db commit 3e18ec4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions genomics-apps/mendelianScreening.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@


# Retrieve patient information
@st.cache_data
def fetch_patient_info(subject):
url = f"https://api.logicahealth.org/MTB/open/Patient?identifier={subject}"
response = requests.get(url)
Expand Down Expand Up @@ -219,6 +220,7 @@ def fetch_patient_info(subject):


# Retrieve patient conditions
@st.cache_data
def fetch_condition(patient_id):
url = f"https://api.logicahealth.org/MTB/open/Condition?patient={patient_id}"
response = requests.get(url)
Expand Down Expand Up @@ -246,6 +248,7 @@ def fetch_condition(patient_id):


# Retrieve medications
@st.cache_data
def fetch_medication(patient_id):
url = f"https://api.logicahealth.org/MTB/open/MedicationRequest?patient={patient_id}"
response = requests.get(url)
Expand All @@ -269,6 +272,7 @@ def fetch_medication(patient_id):


# Retrieve patient allergies
@st.cache_data
def fetch_allergy(patient_id):
url = f"https://api.logicahealth.org/MTB/open/AllergyIntolerance?patient={patient_id}"
response = requests.get(url)
Expand All @@ -291,6 +295,7 @@ def fetch_allergy(patient_id):


# Retrieve variant information
@st.cache_data
def fetch_variants(subject, gene):
url = ("https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-variants?"
f"subject={subject}&ranges={gene_ranges[gene]['range']}&includeVariants=true&includePhasing=true")
Expand Down Expand Up @@ -332,6 +337,7 @@ def fetch_variants(subject, gene):


# Retrieve molecular consequences
@st.cache_data
def fetch_molecular_consequences(subject, gene):
url = f"https://fhir-gen-ops.herokuapp.com/subject-operations/phenotype-operations/$find-subject-molecular-consequences?subject={subject}&ranges={gene_ranges[gene]['range']}"

Expand Down Expand Up @@ -406,6 +412,7 @@ def fetch_molecular_consequences(subject, gene):


# Define function to get level of evidence
@st.cache_data
def get_level_of_evidence(components):
evidence_dict = {
"practice guideline": 4,
Expand All @@ -428,6 +435,7 @@ def get_level_of_evidence(components):


# Retrieve pathogenicity based on clinical significance and review status
@st.cache_data
def fetch_clinical_significance(subject, gene):
url = f"https://fhir-gen-ops.herokuapp.com/subject-operations/phenotype-operations/$find-subject-dx-implications?subject={subject}&ranges={gene_ranges[gene]['range']}"

Expand Down Expand Up @@ -533,6 +541,7 @@ def fetch_clinical_significance(subject, gene):


# Decorating conditions based on pathogenic variants
@st.cache_data
def decorate_conditions(condition_df, df_final, selected_genes):
# Reading the Excel file
valueset_df = pd.read_excel(r"genomics-apps/data/conditions.xlsx")
Expand Down Expand Up @@ -594,7 +603,14 @@ def decorate_conditions(condition_df, df_final, selected_genes):

# Streamlit sidebar for user inputs
st.sidebar.title("Genetic Variant Information")
subject = st.sidebar.text_input("Enter Subject ID")
subject_ids = ['HG00403', 'HG00406', 'HG02657', 'NA18498', 'NA18499', 'NA18871', 'NA19210', 'NA19247', 'NB6TK329']
selected_subjects = st.sidebar.multiselect("Enter Subject ID", subject_ids, default=None)

# Check if exactly one subject is selected
if len(selected_subjects) == 1:
subject = selected_subjects[0]
elif len(selected_subjects) > 1:
st.warning("Please select only one Subject ID.")

genes = list(gene_ranges.keys())
selected_genes = st.sidebar.multiselect("Select Genes", genes, default=None)
Expand Down Expand Up @@ -780,7 +796,7 @@ def decorate_conditions(condition_df, df_final, selected_genes):
st.warning("Please enter both Subject ID \
and select at least one Gene.")
else:
st.write("Please enter a Subject ID, select Genes, \
st.write("Please select a Subject ID, select Genes, \
and click 'Run' in the sidebar to start the analysis.")

st.markdown("---")
1 change: 1 addition & 0 deletions genomics-apps/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pyliftover==0.4
requests==2.32.0
streamlit==1.34.0
streamlit-aggrid==1.0.5
openpyxl==3.1.5

0 comments on commit 3e18ec4

Please sign in to comment.