Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -34,10 +34,12 @@ st.markdown("""
|
|
34 |
body {
|
35 |
background-color: #CCFFFF;
|
36 |
# color: #ffffff;
|
|
|
37 |
}
|
38 |
.stApp {
|
39 |
background-color: #CCFFFF;
|
40 |
# color: #ffffff;
|
|
|
41 |
}
|
42 |
</style>
|
43 |
""", unsafe_allow_html=True)
|
@@ -123,16 +125,23 @@ if query:
|
|
123 |
# print(table.head(10)["SIMILARITY"])
|
124 |
# # display the treemap in Streamlit
|
125 |
table2["SIMILARITY"] = 'Similarity Score ' + table2.head(10)["SIMILARITY"].round(2).astype(str)
|
126 |
-
|
127 |
# avg_size = sum(sizes) / len(short_table.index)
|
128 |
-
|
129 |
# print(sizes)
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
fig.update(layout_coloraxis_showscale=False)
|
132 |
fig.update_layout(autosize=True, paper_bgcolor="#CCFFFF")
|
133 |
fig.update_annotations(visible=False)
|
134 |
fig.update_traces(marker=dict(cornerradius=5), root_color="#CCFFFF", hovertemplate=None,
|
135 |
-
hoverlabel_bgcolor="lightgreen", hoverlabel_bordercolor="#000000")
|
136 |
fig.update_layout(uniformtext=dict(minsize=15, mode='hide'), treemapcolorway=["lightgreen"])
|
137 |
|
138 |
|
@@ -181,19 +190,43 @@ if query:
|
|
181 |
fig2 = plt.gcf()
|
182 |
fig2.patch.set_facecolor('#CCFFFF')
|
183 |
#
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
fig.update(layout_coloraxis_showscale=False)
|
190 |
fig.update_layout(autosize=True, paper_bgcolor="#CCFFFF")
|
191 |
fig.update_annotations(visible=False)
|
192 |
fig.update_traces(marker=dict(cornerradius=5), root_color="#CCFFFF", hovertemplate=None,
|
193 |
-
hoverlabel_bgcolor="lightblue", hoverlabel_bordercolor="#000000"
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
197 |
# # display the treemap in Streamlit
|
198 |
# with treemap2:
|
199 |
st.subheader(f"Top 10 Genes closely related to {query}")
|
@@ -241,7 +274,8 @@ if query:
|
|
241 |
st.video("https://www.youtube.com/watch?v=" + video_ids[2])
|
242 |
st.markdown("---")
|
243 |
|
244 |
-
|
|
|
245 |
|
246 |
|
247 |
|
|
|
34 |
body {
|
35 |
background-color: #CCFFFF;
|
36 |
# color: #ffffff;
|
37 |
+
# font-size: 1px
|
38 |
}
|
39 |
.stApp {
|
40 |
background-color: #CCFFFF;
|
41 |
# color: #ffffff;
|
42 |
+
# font-size: 1px
|
43 |
}
|
44 |
</style>
|
45 |
""", unsafe_allow_html=True)
|
|
|
125 |
# print(table.head(10)["SIMILARITY"])
|
126 |
# # display the treemap in Streamlit
|
127 |
table2["SIMILARITY"] = 'Similarity Score ' + table2.head(10)["SIMILARITY"].round(2).astype(str)
|
128 |
+
rank_num = list(short_table.index.tolist())
|
129 |
# avg_size = sum(sizes) / len(short_table.index)
|
130 |
+
print(rank_num)
|
131 |
# print(sizes)
|
132 |
+
# '{0} in {1}'.format(unicode(self.author, 'utf-8'), unicode(self.publication, 'utf-8'))
|
133 |
+
TEMPLATE = """
|
134 |
+
<br>
|
135 |
+
{0}: <a href='https://pubmed.ncbi.nlm.nih.gov/?term={1}%5Bmh%5D+%20%20%20%20%20NOT
|
136 |
+
+review%5Bpt%5D+AND+english%5Bla%5D+AND+hasabstract+AND+1990%253A2022%252F12%252F31%5Bdp%5D+AND+%22{2}%22'>google</a>
|
137 |
+
""".format(database_name,database_name, database_name)
|
138 |
+
fig = px.treemap(names=rank_num, path=[short_table.index], values=sizes, hover_name=(table2.head(10)['SIMILARITY']))
|
139 |
+
|
140 |
fig.update(layout_coloraxis_showscale=False)
|
141 |
fig.update_layout(autosize=True, paper_bgcolor="#CCFFFF")
|
142 |
fig.update_annotations(visible=False)
|
143 |
fig.update_traces(marker=dict(cornerradius=5), root_color="#CCFFFF", hovertemplate=None,
|
144 |
+
hoverlabel_bgcolor="lightgreen", hoverlabel_bordercolor="#000000", texttemplate=TEMPLATE)
|
145 |
fig.update_layout(uniformtext=dict(minsize=15, mode='hide'), treemapcolorway=["lightgreen"])
|
146 |
|
147 |
|
|
|
190 |
fig2 = plt.gcf()
|
191 |
fig2.patch.set_facecolor('#CCFFFF')
|
192 |
#
|
193 |
+
df3 = df1.copy()
|
194 |
+
df3.reset_index(inplace=True)
|
195 |
+
df3 = df3.rename(columns={'Human Gene': 'symbol2'})
|
196 |
+
# Use df.query to get a subset of df1 based on ids in df2
|
197 |
+
subset = df3.head(10).query('symbol2 in @df2.symbol2')
|
198 |
+
# Use merge to join the two DataFrames on id
|
199 |
+
result = pd.merge(subset, df2, on='symbol2')
|
200 |
+
# Show the result
|
201 |
+
# print(result)
|
202 |
+
|
203 |
+
df = df10
|
204 |
+
|
205 |
+
# Define the `text` column for labels and `href` column for links
|
206 |
+
df['text'] = df10.index
|
207 |
+
df['href'] = [f'https://pubmed.ncbi.nlm.nih.gov/?term={database_name}%5Bmh%5D+NOT+review%5Bpt%5D' \
|
208 |
+
'+AND+english%5Bla%5D+AND+hasabstract+AND+1990:2022%5Bdp%5D+AND+' + c for c in df10.index]
|
209 |
+
df['href2'] = [f'https://www.ncbi.nlm.nih.gov/gene/?term=' + c for c in df10.index]
|
210 |
+
df['name'] = [c for c in result['Approved name']]
|
211 |
+
df['database'] = database_name
|
212 |
+
# print(df['name'])
|
213 |
+
|
214 |
+
# Create the treemap using `px.treemap`
|
215 |
+
fig = px.treemap(df, path=[df10.index], values=sizes, hover_data=['SIMILARITY'],
|
216 |
+
custom_data=['href', 'name', 'database', 'href2'])
|
217 |
+
# fig.update_traces(texttemplate="Gene: <b>%{label}</b><br>Gene "
|
218 |
+
# "name: %{customdata[1]}<br><a href='%{customdata[0]}'>PubMed Abstracts with %{label} "
|
219 |
+
# "in %{customdata[2]}</a><br><a href='%{customdata[3]}'>NCBI gene information for %{label} "
|
220 |
+
# "in %{customdata[2]}</a>")
|
221 |
fig.update(layout_coloraxis_showscale=False)
|
222 |
fig.update_layout(autosize=True, paper_bgcolor="#CCFFFF")
|
223 |
fig.update_annotations(visible=False)
|
224 |
fig.update_traces(marker=dict(cornerradius=5), root_color="#CCFFFF", hovertemplate=None,
|
225 |
+
hoverlabel_bgcolor="lightblue", hoverlabel_bordercolor="#000000",
|
226 |
+
texttemplate="<b>%{label}</b><br>%{customdata[1]}<br><a href='%{customdata[0]}'>PubMed"
|
227 |
+
"</a><br><a href='%{customdata[3]}'>NCBI"
|
228 |
+
"</a>")
|
229 |
+
fig.update_layout(uniformtext=dict(minsize=10, mode='hide'), treemapcolorway=["lightblue"])
|
230 |
# # display the treemap in Streamlit
|
231 |
# with treemap2:
|
232 |
st.subheader(f"Top 10 Genes closely related to {query}")
|
|
|
274 |
st.video("https://www.youtube.com/watch?v=" + video_ids[2])
|
275 |
st.markdown("---")
|
276 |
|
277 |
+
|
278 |
+
|
279 |
|
280 |
|
281 |
|