Spaces:
Sleeping
Sleeping
import streamlit as st | |
import re | |
import numpy as np | |
import pandas as pd | |
import sklearn | |
import xgboost | |
seed=42 | |
data = pd.read_csv("annotations_dataset.csv") | |
data = data.set_index("Gene") | |
training_data = pd.read_csv("./selected_features_training_data.csv", header=0) | |
training_data.columns = [ | |
regex.sub("_", col) if any(x in str(col) for x in set(("[", "]", "<"))) else col | |
for col in training_data.columns.values | |
] | |
training_data["BPlabel_encoded"] = training_data["BPlabel"].map( | |
{"most likely": 1, "probable": 0.75, "least likely": 0.1} | |
) | |
Y = training_data["BPlabel_encoded"] | |
X = training_data.drop(columns=["BPlabel_encoded","BPlabel"]) | |
xgb = xgboost.XGBRegressor( | |
n_estimators=40, | |
learning_rate=0.2, | |
max_depth=4, | |
reg_alpha=1, | |
reg_lambda=1, | |
random_state=seed, | |
objective="reg:squarederror", | |
) | |
xgb.fit(X, Y) | |
predictions = list(xgb.predict(data)) | |
predictions = [round(item, 2) for item in predictions] | |
output = pd.Series(data=predictions, index=data.index, name="XGB_Score") | |
df_total = pd.concat([data, output], axis=1) | |
df_total.rename_axis('Gene').reset_index() | |
df_total = df_total[['XGB_Score', 'mousescore_Exomiser', | |
'SDI', 'Liver_GTExTPM', 'pLI_ExAC', | |
'HIPred', | |
'Cells - EBV-transformed lymphocytes_GTExTPM', | |
'Pituitary_GTExTPM', | |
'IPA_BP_annotation']] | |
st.title('Blood Pressure Gene Prioritisation Post-GWAS') | |
st.markdown(""" | |
A machine learning pipeline for predicting disease-causing genes post-genome-wide association study in blood pressure. | |
""") | |
#gene_input = st.text_input('Input Single HGNC Gene:') | |
#df = df_total[df_total.index == gene_input] | |
#st.dataframe(df) | |
collect_genes = lambda x : [int(i) for i in re.split(",", x) if i != ""] | |
input_genes = st.text_input("List of HGNC Genes (enter comma separated)") | |
gene_list = st.write(collect_genes(input_genes)) | |
df = df_total[df_total.index.isin(gene_list)] | |
st.dataframe(df) | |
st.markdown(""" | |
Total Gene Prioritisation Results: | |
""") | |
st.dataframe(df_total) | |