hlnicholls commited on
Commit
33c190e
1 Parent(s): 3e03787

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -6,6 +6,18 @@ import sklearn
6
  import xgboost
7
  import shap
8
  st.set_option('deprecation.showPyplotGlobalUse', False)
 
 
 
 
 
 
 
 
 
 
 
 
9
  seed=42
10
 
11
  annotations = pd.read_csv("annotations_dataset.csv")
@@ -33,7 +45,6 @@ xgb = xgboost.XGBRegressor(
33
 
34
 
35
  xgb.fit(X, Y)
36
-
37
  prediction_list = list(xgb.predict(annotations))
38
  predictions = [round(prediction, 2) for prediction in prediction_list]
39
 
@@ -98,16 +109,18 @@ else:
98
 
99
  input_gene = st.text_input("Input individual HGNC gene:")
100
  df2 = df_total[df_total.index == input_gene]
 
 
101
  st.dataframe(df2)
102
  df2.drop(columns='XGB_Score', inplace=True)
103
 
104
  if input_gene:
105
- shap_values = explainer.shap_values(df2)
106
  shap.getjs()
107
  force_plot = shap.force_plot(
108
  explainer.expected_value,
109
  shap_values,
110
- df2,
111
  matplotlib = True,show=False)
112
  st.pyplot(fig=force_plot)
113
  else:
@@ -117,4 +130,5 @@ st.markdown("""
117
  Total Gene Prioritisation Results:
118
  """)
119
 
 
120
  st.dataframe(df_total)
 
6
  import xgboost
7
  import shap
8
  st.set_option('deprecation.showPyplotGlobalUse', False)
9
+
10
+ # CSS to inject contained in a string
11
+ hide_table_row_index = """
12
+ <style>
13
+ thead tr th:first-child {display:none}
14
+ tbody th {display:none}
15
+ </style>
16
+ """
17
+
18
+ # Inject CSS with Markdown
19
+ st.markdown(hide_table_row_index, unsafe_allow_html=True)
20
+
21
  seed=42
22
 
23
  annotations = pd.read_csv("annotations_dataset.csv")
 
45
 
46
 
47
  xgb.fit(X, Y)
 
48
  prediction_list = list(xgb.predict(annotations))
49
  predictions = [round(prediction, 2) for prediction in prediction_list]
50
 
 
109
 
110
  input_gene = st.text_input("Input individual HGNC gene:")
111
  df2 = df_total[df_total.index == input_gene]
112
+ df2_shap = df_total[df_total.index == input_gene]
113
+ df2['Gene'] = df2.index
114
  st.dataframe(df2)
115
  df2.drop(columns='XGB_Score', inplace=True)
116
 
117
  if input_gene:
118
+ shap_values = explainer.shap_values(df2_shap)
119
  shap.getjs()
120
  force_plot = shap.force_plot(
121
  explainer.expected_value,
122
  shap_values,
123
+ df2_shap ,
124
  matplotlib = True,show=False)
125
  st.pyplot(fig=force_plot)
126
  else:
 
130
  Total Gene Prioritisation Results:
131
  """)
132
 
133
+ df_total['Gene'] = df_total.index
134
  st.dataframe(df_total)