syedislamuddin commited on
Commit
400a76d
·
1 Parent(s): 4350e0b

Upload 17 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ megan_pathways/GO_Biological_Process_2021.csv filter=lfs diff=lfs merge=lfs -text
37
+ new_multiregion_brainaging_annotated.h5ad filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9.12
2
+
3
+ WORKDIR /code
4
+
5
+ #RUN pip install --upgrade pip
6
+ #RUN apt-get update && apt-get install build-essential -y
7
+ #RUN apt-get update && apt-get install default-jdk -y
8
+
9
+ COPY ./requirements.txt /code/requirements.txt
10
+
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
+
13
+ EXPOSE 8080
14
+
15
+ COPY . .
16
+
17
+ CMD ["streamlit", "run", "/code/app.py","address","0.0.0.0","--port", "7860","--allow-websocket-origin", "syedislamuddin-agexp.hf.space"]
18
+
aging.glmmtmb_age_diffs_fdr.csv ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,512 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #All Plots in THIS APP ARE BASED ON pegasus (As opposed to scanpy in previous versions)
2
+ import os
3
+ import numpy as np
4
+ import streamlit as st
5
+ #from st_aggrid import AgGrid, GridOptionsBuilder,GridUpdateMode,DataReturnMode
6
+
7
+ #import scanpy as sc
8
+ import pegasus as pg
9
+ from pandas import read_csv, pivot
10
+ import seaborn as sns
11
+ from seaborn import clustermap
12
+ import matplotlib.pyplot as plt
13
+ from matplotlib.pyplot import rc_context
14
+ from matplotlib import rcParams
15
+ #import matplotlib as mpl
16
+ #import pandas as pd
17
+ #import matplotlib.font_manager as fm
18
+
19
+
20
+
21
+
22
+ import matplotlib.pyplot as plt
23
+
24
+ plt.rcParams.update({'figure.autolayout': True})
25
+ plt.rcParams['axes.linewidth'] = 0.001
26
+
27
+
28
+ #from functions import pathway_analyses
29
+
30
+ #sc.settings.set_figure_params(dpi=80, facecolor='white',fontsize=12)
31
+ @st.cache_data
32
+ def get_data():
33
+ if 'adata_annot' not in st.session_state or 'cell_type' not in st.session_state or 'broad_type' not in st.session_state or 'cluster_table' not in st.session_state or 'go_table' not in st.session_state or 'all_pwaydata' not in st.session_state:
34
+ adata_annot = pg.read_input(cwd+'new_multiregion_brainaging_annotated.h5ad')
35
+ st.session_state['adata_annot'] = adata_annot
36
+ if 'genes_list' not in st.session_state:
37
+ genes=adata_annot.var.index
38
+ #genes_list=sorted(genes.unique())
39
+ st.session_state['genes_list'] = sorted(genes.unique())
40
+ if 'cell_type' not in st.session_state:
41
+ anno=adata_annot.obs.new_anno
42
+ st.session_state['cell_type'] = sorted(anno.unique())
43
+
44
+ #Also load Go Terms
45
+ if 'go_table' not in st.session_state or 'all_pwaydata' not in st.session_state:
46
+
47
+ ###new
48
+ #All pathways database
49
+ go_table=['Aging_Perturbations_from_GEO_DOWN','Aging_Perturbations_from_GEO_UP','Disease_Perturbations_from_GEO_down','Disease_Perturbations_from_GEO_up','GO_Biological_Process_2021','GO_Cellular_Component_2021','GO_Molecular_Function_2021','KEGG 2021 Human','Wiki 2021 Human']
50
+ all_pwaydata={}
51
+ #get pathways
52
+ import pandas as pd
53
+ for f in go_table:
54
+ all_pwaydata[f]=pd.read_csv("megan_pathways/"+f+".csv")
55
+ st.session_state['go_table']=go_table
56
+ st.session_state['all_pwaydata']=all_pwaydata
57
+ ###new
58
+ #Also get clustermap data set
59
+ if 'cluster_table' not in st.session_state:
60
+ st.session_state['cluster_table'] = pd.read_csv('aging.glmmtmb_age_diffs_fdr.csv',index_col=0)
61
+ #done load Data
62
+ #disable st.pyplot warning
63
+ st.set_page_config(layout="wide")
64
+ st.markdown(
65
+ """
66
+ <style>
67
+ .streamlit-expanderHeader {
68
+ font-size: x-large;
69
+ }
70
+ </style>
71
+ """,
72
+ unsafe_allow_html=True,
73
+ )
74
+ m=st.markdown("""
75
+
76
+ <style>
77
+
78
+ div.stTitle {
79
+
80
+ font-size:40px;
81
+
82
+ }
83
+
84
+ </style>"""
85
+ ,unsafe_allow_html=True)
86
+
87
+ st.set_option('deprecation.showPyplotGlobalUse', False)
88
+
89
+ #load Data
90
+ cwd=os.getcwd()+'/'#+'data/'
91
+
92
+ def convert_df(df):
93
+ return df.to_csv().encode('utf-8')
94
+
95
+ def disp_table(data_table):
96
+ if data_table.shape[0]>0:
97
+ #df = transform(data_table,'Please Select columns to save whole table')
98
+ #fname = st_keyup("Please input file name to save Table", value='temp') #st.text_input('Please input file name to save Table', 'temp', live=True)
99
+
100
+ csv = convert_df(data_table)
101
+
102
+ st.download_button(
103
+ label="Download Table as CSV file",
104
+ data=csv,
105
+ #file_name=fname+'.csv',
106
+ file_name='download_gene_list.csv',
107
+ mime='text/csv',
108
+ )
109
+
110
+
111
+
112
+ #st.title('Single nuclei atlas of human aging in brain regions')
113
+
114
+ get_data()
115
+ st.title('Brain Age Browser')
116
+ txt="In the event of APP CRASH, Please Press Reset Button below"
117
+ st.markdown(f'<p style=color:red;font-size:24px;border-radius:2%;">{txt}</p>', unsafe_allow_html=True)
118
+
119
+ #st.header("In the event of **APP CRASH**, Please Press Reset Button below")
120
+ m = st.markdown("""
121
+ <style>
122
+ div.stButton > button:first-child {
123
+ background-color: #0099ff;
124
+ color:#ffffff;
125
+ }
126
+ div.stButton > button:hover {
127
+ background-color: #00ff00;
128
+ color:#ff0000;
129
+ }
130
+ </style>""", unsafe_allow_html=True)
131
+
132
+ #b = st.button("点我开始运行程序")
133
+ clear=st.button('Reset')
134
+ if clear:
135
+ st.cache_data.clear()
136
+ #st.runtime.legacy_caching.clear_cache()
137
+
138
+ #tab1, tab2,readme = st.tabs(["Gene Expression by CellType", "Age associations for multiple genes", "README"])
139
+ st.write('<style>div.row-widget.stRadio > div{flex-direction:row;justify-content: center;} </style>', unsafe_allow_html=True)
140
+
141
+ opt_selected = st.radio(
142
+ "**Please select an option**",
143
+ ("Gene Expression by CellType", "Age associations for Multiple genes", "Age associations with GoTerms", "README"))
144
+
145
+ if opt_selected == 'Gene Expression by CellType':
146
+ #tab1, tab2,tab3,readme = st.tabs(["Gene Expression by CellType", "Age associations for Multiple genes", "Age associations with GoTerms", "README"])
147
+ #data = np.random.randn(10, 1)
148
+ #with tab1:
149
+ with st.form(key='columns_in_form'):
150
+ #c1, c2, c3 = st.columns([4,4,2])
151
+ c1, c2 = st.columns(2)
152
+ with c1:
153
+ selected_gene = st.selectbox(
154
+ 'Please select a gene',
155
+ st.session_state['genes_list'])
156
+ with c2:
157
+ selected_celltype = st.selectbox(
158
+ 'Please select CellType',
159
+ st.session_state['cell_type']
160
+ )
161
+ Updated=st.form_submit_button(label = 'Go')
162
+ if not isinstance(selected_gene, type(None)) and not isinstance(selected_celltype, type(None)) and Updated:
163
+ ### NEW CODE
164
+ tita="155,192 annotated nuclei from four brain regions"
165
+ #st.write(tit)
166
+ html_stra = f"""
167
+ <style>
168
+ p.a {{
169
+ font: bold {16}px Courier;
170
+ text-align: center;
171
+ }}
172
+ </style>
173
+ <p class="a">{tita}</p>
174
+ """
175
+ st.markdown(html_stra, unsafe_allow_html=True)
176
+
177
+ cc1,cc2=st.columns([1,1])
178
+ with cc1:
179
+ dot10=pg.scatter(st.session_state['adata_annot'],attrs=['new_anno'],basis='umap', wspace=.02,legend_loc='on data',legend_fontsize=7,return_fig=True)
180
+ dot10.get_figure().gca().set_title("")
181
+ dot10.get_figure().gca().axis('off')
182
+
183
+ xmin, xmax = dot10.get_figure().gca().get_xaxis().get_view_interval()
184
+ ymin, ymax = dot10.get_figure().gca().get_yaxis().get_view_interval()
185
+ dot10.get_figure().gca().arrow(xmin, ymin, xmax/4, 0, head_width=0.2, head_length=0.3, linewidth=.5, color='k', length_includes_head=True)
186
+ dot10.get_figure().gca().text(x=.1*xmin, y=ymin, s="UMAP1", rotation=0, fontsize=5, color='k')
187
+ dot10.get_figure().gca().arrow(xmin, ymin, 0,ymax/4, head_width=0.2, head_length=0.3, linewidth=.5, color='k', length_includes_head=True)
188
+ dot10.get_figure().gca().text(x=1.1*xmin, y=.1*ymin, s="UMAP2", rotation=0, fontsize=5, color='k')
189
+ st.pyplot(dot10)
190
+ with cc2:
191
+ dot11=pg.scatter(st.session_state['adata_annot'],attrs=selected_gene,basis='umap', wspace=.02,legend_loc='on data',legend_fontsize=7,return_fig=True)
192
+ dot11.get_figure().gca().set_title("")
193
+ #dot11.get_figure().gca().axis('off')
194
+ st.pyplot(dot11)
195
+ #Subset Young and Old
196
+ adata_Young = st.session_state['adata_annot'][st.session_state['adata_annot'].obs['Age_group']=='young']
197
+ adata_Old = st.session_state['adata_annot'][st.session_state['adata_annot'].obs['Age_group']=='old']
198
+ #Young/Old but for cell_type
199
+ adata_YoungAst = adata_Young[adata_Young.obs['new_anno']==selected_celltype]
200
+ adata_OldAst = adata_Old[adata_Old.obs['new_anno']==selected_celltype]
201
+ #tit=selected_gene+": coefficient estimate: 0.24 | BH-FDR p=7.91x$10^{-3}$"
202
+ tit="Expression of "+selected_gene+" across old and young age groups"
203
+ #st.write(tit)
204
+ html_str = f"""
205
+ <style>
206
+ p.a {{
207
+ font: bold {16}px Courier;
208
+ text-align: center;
209
+ }}
210
+ </style>
211
+ <p class="a">{tit}</p>
212
+ """
213
+ st.markdown(html_str, unsafe_allow_html=True)
214
+ cc1,cc2=st.columns([1,1])
215
+ with cc1:
216
+ ########
217
+ dot12=pg.scatter_groups(st.session_state['adata_annot'], attr=selected_gene, basis='umap', groupby='Age_group', cmap='BuPu', vmin=0, vmax=6,show_full=False,nrows=2,return_fig=True)
218
+ allaxes = dot12.get_figure().get_axes()
219
+
220
+
221
+ allaxes[0].set_title("All",fontsize=20)
222
+ allaxes[0].set_ylabel("old",fontsize=20)
223
+ allaxes[0].set_xlabel("")
224
+ allaxes[1].set_title("")
225
+ allaxes[1].set_ylabel("young",fontsize=20)
226
+ allaxes[1].set_xlabel("")
227
+ #allaxes[2].set_visible(False)
228
+ #allaxes[3].set_visible(False)
229
+ allaxes[2].remove() #.set_visible(False)
230
+ allaxes[3].remove() #set_visible(False)
231
+
232
+ ##########
233
+
234
+ ###### SWAP THE PLOTS
235
+ # pos1 = allaxes[0].get_position()
236
+ # allaxes[0].set_position(allaxes[1].get_position())
237
+ # allaxes[1].set_position(pos1)
238
+ # pos1 = allaxes[2].get_position()
239
+ # allaxes[2].set_position(allaxes[3].get_position())
240
+ # allaxes[3].set_position(pos1)
241
+ #######
242
+
243
+ fig_width, fig_height = dot12.get_size_inches()
244
+ st.pyplot(dot12)
245
+ with cc2:
246
+ adata_Ast = st.session_state['adata_annot'][st.session_state['adata_annot'].obs['new_anno']==selected_celltype]
247
+ #### New
248
+ dot13=pg.scatter_groups(adata_Ast, attr=selected_gene, basis='umap', groupby='Age_group', cmap='BuPu', vmin=0, vmax=6,show_full=False,nrows=2,return_fig=True,legend_loc='right margin')
249
+ allaxes1 = dot13.get_figure().get_axes()
250
+ allaxes1[0].set_title("")
251
+ allaxes1[0].set_title(selected_celltype,fontsize=20)
252
+ allaxes1[0].set_xlabel("")
253
+ allaxes1[0].set_ylabel("")
254
+ allaxes1[1].set_title("")
255
+ allaxes1[1].set_xlabel("")
256
+ allaxes1[1].set_ylabel("")
257
+
258
+ chartBox1 = allaxes1[2].get_position()
259
+ chartBox2 = allaxes1[3].get_position()
260
+
261
+
262
+ allaxes1[2].set_position([chartBox1.x0+.2, chartBox1.y0,chartBox1.width,chartBox1.height])
263
+ allaxes1[3].set_position([chartBox2.x0+.2, chartBox2.y0,chartBox2.width,chartBox2.height])
264
+
265
+ #dot13.set_size_inches(fig_width+5, fig_height+5)
266
+
267
+
268
+ ####
269
+ st.pyplot(dot13)
270
+ #with tab2:
271
+ elif opt_selected == 'Age associations for Multiple genes':
272
+ #set plot theme
273
+ blupink = sns.palplot(sns.diverging_palette(h_neg=234,h_pos=342,n=9,s=75,l=30,sep=10,center='light'))
274
+ sns.set_context("paper", font_scale=1)
275
+ cmap = sns.diverging_palette(h_neg=234,h_pos=342,n=9,s=75,l=30,sep=7,center='light', as_cmap=True)
276
+ with st.form(key='multi_genes_form'):
277
+ c1, c2= st.columns([9.9,.1])
278
+ with c1:
279
+ multi_genes = st.multiselect(
280
+ 'Select Genes List',
281
+ st.session_state['genes_list'])
282
+ Updated_tab2=st.form_submit_button(label = 'Show GeneSet Results')
283
+ if not isinstance(multi_genes, type(None)) and Updated_tab2:
284
+ multi_genes = np.sort(multi_genes)
285
+
286
+ #####NEW CODE
287
+ tit="expression per cell type"
288
+ #st.write(tit)
289
+ html_str1 = f"""
290
+ <style>
291
+ p.a {{
292
+ font: bold {16}px Courier;
293
+ text-align: center;
294
+ }}
295
+ </style>
296
+ <p class="a">{tit}</p>
297
+ """
298
+
299
+ cc1,cc2=st.columns([1,1])
300
+ with cc1:
301
+ try:
302
+
303
+ dot21=pg.dotplot(st.session_state['adata_annot'], genes=multi_genes, groupby='new_anno',switch_axes=True,return_fig=True,cmap='BuPu')
304
+ dot21.set_figheight(len(multi_genes)*.5)
305
+ allaxes21 = dot21.get_figure().get_axes()
306
+ #allaxes21[0].set_title("expression per cell type")
307
+ allaxes21[0].set_xlabel("")
308
+
309
+ st.markdown(html_str1, unsafe_allow_html=True)
310
+ st.pyplot(dot21)
311
+ except:
312
+ st.write("**An exception has occurred, Please check the GeneSet**")
313
+
314
+ with cc2:
315
+ # now cluster_map
316
+ celltype_DAGS = st.session_state['cluster_table'][st.session_state['cluster_table'].eval("type.str.endswith('cell_type').values")]
317
+ celltype_DAGS = celltype_DAGS.pivot(index='feature', columns='tissue')['estimate']
318
+ #replace NaN with zeroes
319
+ celltype_DAGS.fillna(0, inplace=True)
320
+
321
+ #query which cell type DAGs are in ad gene set
322
+ celltype_ad_genes = celltype_DAGS.loc[celltype_DAGS.index.isin(multi_genes)]
323
+ lst=list(celltype_ad_genes.index)
324
+
325
+ tit="age association per cell type"
326
+ #st.write(tit)
327
+ html_str1 = f"""
328
+ <style>
329
+ p.a {{
330
+ font: bold {16}px Courier;
331
+ text-align: center;
332
+ }}
333
+ </style>
334
+ <p class="a">{tit}</p>
335
+ """
336
+
337
+ st.markdown(html_str1, unsafe_allow_html=True)
338
+
339
+ if celltype_ad_genes.shape[0] > 1:
340
+ kws = dict(cbar_kws=dict(label='coefficient estimates', orientation='vertical',shrink='.05'))
341
+ with sns.axes_style({"axes.edgecolor": "black"}):
342
+ if len(lst)>50:
343
+ g = sns.clustermap(celltype_ad_genes, figsize=(6,len(lst)*.2), linewidth=0.05, cmap=cmap, col_cluster=True, dendrogram_ratio=0.1, row_cluster=True, vmin=-1, vmax=1, center= 0, linecolor= 'white', clip_on=False,
344
+ xticklabels=True, yticklabels=True, square=False,cbar_kws={"orientation": "vertical","label": "coefficient estimates"})
345
+
346
+ x0, _y0, _w, _h = g.cbar_pos
347
+ g.ax_cbar.set_position([x0+.95, 0.75, .02, len(lst)*.0005])
348
+ else:
349
+ g = sns.clustermap(celltype_ad_genes, figsize=(6,6), linewidth=0.05, cmap=cmap, col_cluster=True, dendrogram_ratio=0.1, row_cluster=True, vmin=-1, vmax=1, center= 0, linecolor= 'white', clip_on=False,
350
+ xticklabels=True, yticklabels=True, square=False,cbar_kws={"orientation": "vertical","label": "coefficient estimates"})
351
+
352
+ x0, _y0, _w, _h = g.cbar_pos
353
+
354
+ g.ax_cbar.set_position([x0+.95, 0.6, .02, .25])
355
+ #g.ax_cbar.set_title('coefficient estimates')
356
+ g.ax_cbar.tick_params(axis='x', length=10)
357
+ ax = g.ax_heatmap
358
+ #ax.title("age association per cell type")
359
+ ax.set_ylabel("")
360
+ ax.set_xlabel("")
361
+ #ax.set_title("age association per cell type")
362
+ st.pyplot(g)
363
+ disp_table(celltype_ad_genes)
364
+ st.dataframe(celltype_ad_genes)
365
+
366
+ #
367
+ else:
368
+ st.write('**Got Empty Data Set (from aging.glmmtmb_age_diffs_fdr.csv), Please select a different set of genes**')
369
+ ######END NEW CODE
370
+ #with tab3:
371
+ elif opt_selected == 'Age associations with GoTerms':
372
+ #set plot theme
373
+ blupink = sns.palplot(sns.diverging_palette(h_neg=234,h_pos=342,n=9,s=75,l=30,sep=10,center='light'))
374
+ sns.set_context("paper", font_scale=1)
375
+ cmap = sns.diverging_palette(h_neg=234,h_pos=342,n=9,s=75,l=30,sep=7,center='light', as_cmap=True)
376
+
377
+ with st.form(key='GoDatabase_form'):
378
+
379
+ selected_go_database = st.selectbox(
380
+ 'Please select Pathway Database',st.session_state['go_table'])
381
+ selected_pway_data=st.session_state['all_pwaydata'][selected_go_database]
382
+
383
+ change = st.form_submit_button("Updata")
384
+ c1, c2 = st.columns([9.999,.001])
385
+ with c1:
386
+ selected_pway_data=st.session_state['all_pwaydata'][selected_go_database]
387
+ #st.write(selected_go_database)
388
+
389
+ go_term = st.selectbox(
390
+ 'Select GO Term',
391
+ list(selected_pway_data.columns))
392
+
393
+ Updated_tab3=st.form_submit_button(label = 'Show Pathway Results')
394
+
395
+ #if not isinstance(multi_genes, type(None)) and Updated_tab3:# and Updated_tab4:
396
+ if not isinstance(go_term, type(None)) and Updated_tab3:# and Updated_tab4:
397
+
398
+ multi_genes = [x for x in selected_pway_data[go_term] if str(x) != 'nan']
399
+ multi_genes = list(set(multi_genes))
400
+ multi_genes=np.sort(multi_genes)
401
+ #####NEW CODE
402
+ cc1,cc2=st.columns([1,1])
403
+ with cc1:
404
+
405
+ st.markdown('**Pathway Database:** '+selected_go_database) #+'\n**Pathway Selected:** '+go_term)
406
+ st.markdown('**Pathway Selected:** '+go_term)
407
+ fig = plt.figure(figsize=(1, 1))
408
+ try:
409
+ dot21=pg.dotplot(st.session_state['adata_annot'], genes=multi_genes, groupby='new_anno',switch_axes=True,return_fig=True,cmap='BuPu')#, dpi=300.0)
410
+ dot21.set_figheight(len(multi_genes)*.3)
411
+ allaxes21 = dot21.get_figure().get_axes()
412
+ allaxes21[0].set_title("expression per cell type")
413
+ allaxes21[0].set_xlabel("")
414
+ st.pyplot(dot21)
415
+ except:
416
+ st.write("**An exception has occurred, Please check the GeneSet**")
417
+
418
+ with cc2:
419
+ # now cluster_map
420
+ celltype_DAGS = st.session_state['cluster_table'][st.session_state['cluster_table'].eval("type.str.endswith('cell_type').values")]
421
+ celltype_DAGS = celltype_DAGS.pivot(index='feature', columns='tissue')['estimate']
422
+ #replace NaN with zeroes
423
+ celltype_DAGS.fillna(0, inplace=True)
424
+
425
+ #query which cell type DAGs are in ad gene set
426
+ celltype_ad_genes = celltype_DAGS.loc[celltype_DAGS.index.isin(multi_genes)]
427
+
428
+ st.markdown('Please note that **number of Genes in Pathway are:** '+str(len(multi_genes))) #+' \nAnd Genes **in aging.glmmtmb_age_diffs_fdr.csv file are:** '+str(len(celltype_ad_genes)))
429
+ st.markdown('Genes **in aging.glmmtmb_age_diffs_fdr.csv file are:** '+str(len(celltype_ad_genes)))
430
+ #st.write('**Common List Is:** ')
431
+ tit="age association per cell type"
432
+ #st.write(tit)
433
+ html_str1 = f"""
434
+ <style>
435
+ p.a {{
436
+ font: bold {16}px Courier;
437
+ text-align: center;
438
+ }}
439
+ </style>
440
+ <p class="a">{tit}</p>
441
+ """
442
+
443
+
444
+
445
+ lst=list(celltype_ad_genes.index)
446
+ if celltype_ad_genes.shape[0] > 1:
447
+ st.markdown(html_str1, unsafe_allow_html=True)
448
+ kws = dict(cbar_kws=dict(label='coefficient estimates', orientation='vertical',shrink='.05'))
449
+ with sns.axes_style({"axes.edgecolor": "black"}):
450
+ if len(lst)>50:
451
+ g = sns.clustermap(celltype_ad_genes, figsize=(6,len(lst)*.2), linewidth=0.05, cmap=cmap, col_cluster=True, dendrogram_ratio=0.1, row_cluster=True, vmin=-1, vmax=1, center= 0, linecolor= 'white', clip_on=False,
452
+ xticklabels=True, yticklabels=True, square=False,cbar_kws={"orientation": "vertical","label": "coefficient estimates"})
453
+
454
+ x0, _y0, _w, _h = g.cbar_pos
455
+ #g.ax_cbar.set_position([x0+.9, 0.3, g.ax_row_dendrogram.get_position().width, 0.5])
456
+ g.ax_cbar.set_position([x0+.95, 0.75, .02, len(lst)*.0005])
457
+ else:
458
+ g = sns.clustermap(celltype_ad_genes, figsize=(6,6), linewidth=0.05, cmap=cmap, col_cluster=True, dendrogram_ratio=0.1, row_cluster=True, vmin=-1, vmax=1, center= 0, linecolor= 'white', clip_on=False,
459
+ xticklabels=True, yticklabels=True, square=False,cbar_kws={"orientation": "vertical","label": "coefficient estimates"})
460
+
461
+ x0, _y0, _w, _h = g.cbar_pos
462
+ #g.ax_cbar.set_position([x0+.9, 0.3, g.ax_row_dendrogram.get_position().width, 0.5])
463
+ g.ax_cbar.set_position([x0+.95, 0.6, .02, .25])
464
+ #g.ax_cbar.set_title('coefficient estimates')
465
+ g.ax_cbar.tick_params(axis='x', length=10)
466
+ ax = g.ax_heatmap
467
+ #ax.title("age association per cell type")
468
+ ax.set_ylabel("")
469
+ ax.set_xlabel("")
470
+ #ax.set_title("age association per cell type")
471
+ #g.fig.suptitle('age association per cell type')
472
+ st.pyplot(g)
473
+
474
+ disp_table(celltype_ad_genes)
475
+ st.dataframe(celltype_ad_genes)
476
+
477
+
478
+ else:
479
+ st.write('**Got Empty Data Set (aging.glmmtmb_age_diffs_fdr.csv), Please select a different set of genes**')
480
+ ######END NEW CODE
481
+
482
+ #with readme:
483
+ else:
484
+ expander = st.expander("How to use this app")
485
+ #st.header('How to use this app')
486
+ expander.markdown('This app consists of 3-Tabs')
487
+ expander.markdown('**Tab1: Gene Expression by CellType:** Two dropdown lists are provided where user can select a gene and celltype of interest. After making selection, Please press Go Button')
488
+ expander.markdown('**Tabe2: Age assosciation for Multiple genes: ** A multiselect drop down list is provided to select geens of interest. A dotplot showing expression per cell type for the selected genes is shown on the left. Right plot shows age association per cell type as clustermap for the selected genes.')
489
+ expander.markdown('**Tab3: Age assosciations with GoTerms: Here user can select a pathway database from a dropdown list of pathway databaass. Once a pathway database is selected (after pressing Update button), another drowdown list shows all pathwys(GoTerms) for the selected database. After selecting a pathway of choice, Please press Show Pathway Results button.')
490
+ expander.markdown('**README: This tab**')
491
+
492
+ expander1 = st.expander('Introduction')
493
+
494
+ expander1.markdown(
495
+ """ Coming Soon.
496
+ """
497
+ )
498
+ expander1.markdown('Coming soon')
499
+ expander1.markdown('- ')
500
+ expander1.markdown('- ')
501
+ expander1.markdown('- ')
502
+ expander1.markdown('Coming soon')
503
+
504
+ css = '''
505
+ <style>
506
+ .stTabs [data-baseweb="tab-list"] button [data-testid="stMarkdownContainer"] p {
507
+ font-size:1.5rem;
508
+ }
509
+ </style>
510
+ '''
511
+
512
+ st.markdown(css, unsafe_allow_html=True)
megan_pathways/.DS_Store ADDED
Binary file (6.15 kB). View file
 
megan_pathways/AD GWAS - Sheet1.csv ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ABCA1
2
+ ABCA7
3
+ ABI3
4
+ ACE
5
+ ADAM10
6
+ ADAM17
7
+ ADAMTS1
8
+ ADAMTS4
9
+ AGRN
10
+ ALPK2
11
+ ANK3
12
+ ANKH
13
+ APH1B
14
+ APOE
15
+ APP
16
+ BCKDK
17
+ BIN1
18
+ BLNK
19
+ CASS4
20
+ CD2AP
21
+ CD33
22
+ CELF1
23
+ CLNK
24
+ CLU
25
+ CNN2
26
+ CNTNAP2
27
+ COX7C
28
+ CR1
29
+ CSTF1
30
+ CTSB
31
+ CTSH
32
+ CYB561
33
+ DOC2A
34
+ ECHDC3
35
+ EED
36
+ EPDR1
37
+ EPHA1
38
+ FAM171A2
39
+ FERMT2
40
+ FOXF1
41
+ GPR141
42
+ GRN
43
+ HAVCR2
44
+ HESX1
45
+ HLA-DQA1
46
+ HLA-DRB1
47
+ HS3ST5
48
+ ICA1
49
+ IDUA
50
+ IL34
51
+ INPP5D
52
+ IQCK
53
+ JAZF1
54
+ KAT8
55
+ KLF16
56
+ LILRA5
57
+ LILRB2
58
+ MAF
59
+ MAMSTR
60
+ MEF2C
61
+ MEIOSIN
62
+ MINDY2
63
+ MME
64
+ MS4A4A
65
+ MS4A6A
66
+ MYO15A
67
+ NCK2
68
+ NECTIN2
69
+ NYAP1
70
+ OARD1
71
+ OPLAH
72
+ PICALM
73
+ PILRA
74
+ PLCG2
75
+ PLEKHA1
76
+ PRDM7
77
+ PRKD3
78
+ PSMC3
79
+ PTK2B
80
+ RASGEF1C
81
+ RBCK1
82
+ RHOH
83
+ SCIMP
84
+ SEC61G
85
+ SHARPIN
86
+ SIGLEC11
87
+ SLC24A4
88
+ SLC2A4RG
89
+ SNX1
90
+ SORL1
91
+ SORT1
92
+ SPDYE3
93
+ SPI1
94
+ SPPL2A
95
+ TMEM106B
96
+ TMEM121
97
+ TNIP1
98
+ TPCN1
99
+ TREM2
100
+ TREML2
101
+ TSPAN14
102
+ TSPOAP1
103
+ UMAD1
104
+ UNC5CL
105
+ USP6NL
106
+ WDR12
107
+ WDR81
108
+ WNT3
109
+ WWOX
110
+ ZCWPW1
111
+ ZFP3
112
+ ZNF652
megan_pathways/Aging_Perturbations_from_GEO_DOWN.csv ADDED
The diff for this file is too large to render. See raw diff
 
megan_pathways/Aging_Perturbations_from_GEO_UP.csv ADDED
The diff for this file is too large to render. See raw diff
 
megan_pathways/Disease_Perturbations_from_GEO_down.csv ADDED
The diff for this file is too large to render. See raw diff
 
megan_pathways/Disease_Perturbations_from_GEO_up.csv ADDED
The diff for this file is too large to render. See raw diff
 
megan_pathways/GO_Biological_Process_2021.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a9ff0f5c1c41c1f7aa108d79b28e918ee533980ed4a39a389ba97fb6561636e
3
+ size 14874779
megan_pathways/GO_Cellular_Component_2021.csv ADDED
The diff for this file is too large to render. See raw diff
 
megan_pathways/GO_Molecular_Function_2021.csv ADDED
The diff for this file is too large to render. See raw diff
 
megan_pathways/KEGG 2021 Human.csv ADDED
The diff for this file is too large to render. See raw diff
 
megan_pathways/PD GWAS.xlsx - Sheet1.csv ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ASXL3
2
+ BAG3
3
+ BIN3
4
+ BST1
5
+ C5ORF24
6
+ CAB39L
7
+ CAMK2D
8
+ CASC16
9
+ CD19
10
+ CHD9
11
+ CHRNB1
12
+ CLCN3
13
+ CRHR1
14
+ CRLS1
15
+ CTSB
16
+ DLG2
17
+ DNAH17
18
+ DYRK1A
19
+ ELOVL7
20
+ FAM47E
21
+ FAM47E-STBD1
22
+ FAM49B
23
+ FBRSL1
24
+ FCGR2A
25
+ FGF20
26
+ FYN
27
+ GAK
28
+ GALC
29
+ GBA
30
+ GBF1
31
+ GCH1
32
+ GPNMB
33
+ GRN
34
+ GS1-124K5.11
35
+ HLA-DRB5
36
+ IGSF9B
37
+ INPP5F
38
+ IP6K2
39
+ ITGA8
40
+ ITPKB
41
+ HIP1R
42
+ KCNIP3
43
+ KCNS3
44
+ KPNA1
45
+ KRTCAP2
46
+ L0C100131289
47
+ LCORL
48
+ LINC00693
49
+ LRRK2
50
+ MAP4K4
51
+ MBNL2
52
+ MCCC1
53
+ MED12L
54
+ MED13
55
+ MEX3C
56
+ MIPOL1
57
+ NOD2
58
+ NUCKS1
59
+ PAM
60
+ PMVK
61
+ RAB29
62
+ RETREG3
63
+ RIMS1
64
+ RIT2
65
+ RNF141
66
+ RPS12
67
+ RPS6KL1
68
+ SATB1
69
+ SCAF11
70
+ SCARB2
71
+ SETD1A
72
+ SH3GL2
73
+ SIPA1L2
74
+ SNCA
75
+ SPPL2B
76
+ SPTSSB
77
+ STBD1
78
+ STK39
79
+ SYT17
80
+ TMEM163
81
+ TMEM175
82
+ TRIM40
83
+ UBAP2
84
+ UBTF
85
+ VAMP4
86
+ VPS13C
87
+ WNT3
megan_pathways/Wiki 2021 Human.csv ADDED
The diff for this file is too large to render. See raw diff
 
new_multiregion_brainaging_annotated.h5ad ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7af1f58b193083f71b55215a008db6ad24c1dccb629a9df96e21ad79c16daace
3
+ size 9755245688
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ numpy
4
+ cython
5
+ pegasuspy
6
+ matplotlib
7
+ seaborn
8
+ decoupler
9
+ scipy
10
+ anndata
11
+ typing
12
+ #streamlit-aggrid