hlnicholls commited on
Commit
a2e3d4b
1 Parent(s): bd5c918

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -4,6 +4,7 @@ import numpy as np
4
  import pandas as pd
5
  import sklearn
6
  import xgboost
 
7
  seed=42
8
 
9
  data = pd.read_csv("annotations_dataset.csv")
@@ -60,12 +61,33 @@ A machine learning pipeline for predicting disease-causing genes post-genome-wid
60
 
61
  collect_genes = lambda x : [str(i) for i in re.split(",|, ", x) if i != ""]
62
 
63
- input_genes = st.text_input("List of HGNC Genes (enter comma separated)")
64
- gene_list = collect_genes(input_genes)
 
65
 
66
  if len(gene_list) > 1:
67
  df = df_total[df_total.index.isin(gene_list)]
68
  st.dataframe(df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  else:
70
  pass
71
 
 
4
  import pandas as pd
5
  import sklearn
6
  import xgboost
7
+ import shap
8
  seed=42
9
 
10
  data = pd.read_csv("annotations_dataset.csv")
 
61
 
62
  collect_genes = lambda x : [str(i) for i in re.split(",|, ", x) if i != ""]
63
 
64
+ input_gene_list = st.text_input("Input list of HGNC genes (enter comma separated):")
65
+ gene_list = collect_genes(input_gene_list)
66
+ explainer = shap.TreeExplainer(xgb)
67
 
68
  if len(gene_list) > 1:
69
  df = df_total[df_total.index.isin(gene_list)]
70
  st.dataframe(df)
71
+ shap_values = explainer.shap_values(df)
72
+ summary_plot = shap.summary_plot(shap_values, df)
73
+ st.caption("SHAP Summary Plot of All Input Genes")
74
+ components.html(summary_plot, height = output_height, width = output_width, scrolling = True)
75
+
76
+ else:
77
+ pass
78
+
79
+
80
+ input_gene = st.text_input("Input individual HGNC gene:")
81
+ df2 = df_total[df_total.index == input_gene]
82
+ st.dataframe(df2)
83
+ if len(input_gene) == 1:
84
+ shap_values = explainer.shap_values(df2)
85
+ shap.initjs()
86
+ force_plot = shap.force_plot(
87
+ explainer.expected_value,
88
+ shap_values.values,
89
+ df2)
90
+ components.html(force_plot, height = output_height, width = output_width, scrolling = True)
91
  else:
92
  pass
93