Commit
·
00aa299
1
Parent(s):
ddd0630
Update pages/Cornea_v1_integrated_scVI.py
Browse files- pages/Cornea_v1_integrated_scVI.py +12 -167
pages/Cornea_v1_integrated_scVI.py
CHANGED
@@ -50,128 +50,26 @@ col_mt = config.get("col_mt")
|
|
50 |
#filepath = f"az://{path_parquet}"
|
51 |
|
52 |
storage_options={'account_name': AZURE_STORAGE_ACCOUNT, 'account_key': AZURE_STORAGE_ACCESS_KEY} #,'anon': False
|
53 |
-
#azfs = AzureBlobFileSystem(**storage_options )
|
54 |
|
55 |
-
# Load in multiple dataframes
|
56 |
# Load in multiple dataframes
|
57 |
df = pl.scan_parquet(f"./data/{dataset}.parquet", storage_options=storage_options).collect()
|
58 |
|
59 |
-
# Setup the app
|
60 |
-
#external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
|
61 |
-
#app = dash.Dash(__name__, use_pages=True) #, requests_pathname_prefix='/dashboard1/'
|
62 |
-
|
63 |
-
#df = pl.read_parquet(filepath,storage_options=storage_options)
|
64 |
-
#df = pl.DataFrame()
|
65 |
-
#abfs = AzureBlobFileSystem(account_name=accountname,account_key=accountkey)
|
66 |
-
#df = df.rename({"__index_level_0__": "Unnamed: 0"})
|
67 |
-
|
68 |
-
#df1 = pl.read_parquet(filepath, storage_options=storage_options)
|
69 |
-
|
70 |
-
#df2 = pl.read_parquet(f"az://data10xflex/{dataset_chosen}.parquet", storage_options=storage_options)
|
71 |
-
|
72 |
-
#tab0_content = html.Div([
|
73 |
-
# html.Label("Dataset chosen"),
|
74 |
-
# dcc.Dropdown(id='dpdn1', value="corg/10xflexcorg_umap_clusres", multi=False,
|
75 |
-
# options=["corg/10xflexcorg_umap_clusres","d1011/10xflexd1011_umap_clusres"])
|
76 |
-
#])
|
77 |
-
|
78 |
-
#@app.callback(
|
79 |
-
# Input(component_id='dpdn1', component_property='value')
|
80 |
-
#)
|
81 |
-
|
82 |
-
#def update_filepath(dpdn1):
|
83 |
-
# global df
|
84 |
-
# if str(f"az://data10xflex/{dpdn1}.parquet") != str(filepath):
|
85 |
-
# print("not identical filepath, chosing other")
|
86 |
-
# df2 = pl.read_parquet(f"az://data10xflex/{dpdn1}.parquet", storage_options=storage_options)
|
87 |
-
# df = df2
|
88 |
-
# return
|
89 |
-
|
90 |
-
#df = pl.read_parquet(filepath, storage_options=storage_options)
|
91 |
-
#min_value = df[col_features].min()
|
92 |
-
#max_value = df[col_features].max()
|
93 |
-
|
94 |
-
#min_value_2 = df[col_counts].min()
|
95 |
-
#min_value_2 = round(min_value_2)
|
96 |
-
#max_value_2 = df[col_counts].max()
|
97 |
-
#max_value_2 = round(max_value_2)
|
98 |
-
|
99 |
-
#min_value_3 = df[col_mt].min()
|
100 |
-
#min_value_3 = round(min_value_3, 1)
|
101 |
-
#max_value_3 = df[col_mt].max()
|
102 |
-
#max_value_3 = round(max_value_3, 1)
|
103 |
-
|
104 |
-
# Loads in the conditions specified in the yaml file
|
105 |
-
|
106 |
-
# Note: Future version perhaps all values from a column in the dataframe of the parquet file
|
107 |
-
# Note 2: This could also be a tsv of the categories and own specified colors
|
108 |
-
#conditions = df[col_batch].unique().to_list()
|
109 |
-
# Create the first tab content
|
110 |
-
# Add Sliders for three QC params: N genes by counts, total amount of reads and pct MT reads
|
111 |
-
|
112 |
-
# tab1_content = html.Div([
|
113 |
-
# html.Label("Column chosen"),
|
114 |
-
# dcc.Dropdown(id='dpdn2', value="batch", multi=False,
|
115 |
-
# options=df.columns),
|
116 |
-
# html.Label("N Genes by Counts"),
|
117 |
-
# dcc.RangeSlider(
|
118 |
-
# id='range-slider_db2-1',
|
119 |
-
# step=250,
|
120 |
-
# value=[min_value, max_value],
|
121 |
-
# marks={i: str(i) for i in range(min_value, max_value + 1, 250)},
|
122 |
-
# ),
|
123 |
-
# dcc.Input(id='min-slider_db2-1', type='number', value=min_value, debounce=True),
|
124 |
-
# dcc.Input(id='max-slider_db2-1', type='number', value=max_value, debounce=True),
|
125 |
-
# html.Label("Total Counts"),
|
126 |
-
# dcc.RangeSlider(
|
127 |
-
# id='range-slider_db2-2',
|
128 |
-
# step=7500,
|
129 |
-
# value=[min_value_2, max_value_2],
|
130 |
-
# marks={i: str(i) for i in range(min_value_2, max_value_2 + 1, 7500)},
|
131 |
-
# ),
|
132 |
-
# dcc.Input(id='min-slider_db2-2', type='number', value=min_value_2, debounce=True),
|
133 |
-
# dcc.Input(id='max-slider_db2-2', type='number', value=max_value_2, debounce=True),
|
134 |
-
# html.Label("Percent Mitochondrial Genes"),
|
135 |
-
# dcc.RangeSlider(
|
136 |
-
# id='range-slider_db2-3',
|
137 |
-
# step=5,
|
138 |
-
# min=0,
|
139 |
-
# max=100,
|
140 |
-
# value=[min_value_3, max_value_3],
|
141 |
-
# ),
|
142 |
-
# dcc.Input(id='min-slider_db2-3', type='number', value=min_value_3, debounce=True),
|
143 |
-
# dcc.Input(id='max-slider_db2-3', type='number', value=max_value_3, debounce=True),
|
144 |
-
# html.Div([
|
145 |
-
# dcc.Graph(id='pie-graph_db2', figure={}, className='four columns',config=config_fig),
|
146 |
-
# dcc.Graph(id='my-graph_db2', figure={}, clickData=None, hoverData=None,
|
147 |
-
# className='four columns',config=config_fig
|
148 |
-
# ),
|
149 |
-
# dcc.Graph(id='scatter-plot_db2', figure={}, className='four columns',config=config_fig)
|
150 |
-
# ]),
|
151 |
-
# html.Div([
|
152 |
-
# dcc.Graph(id='scatter-plot_db2-2', figure={}, className='four columns',config=config_fig)
|
153 |
-
# ]),
|
154 |
-
# html.Div([
|
155 |
-
# dcc.Graph(id='scatter-plot_db2-3', figure={}, className='four columns',config=config_fig)
|
156 |
-
# ]),
|
157 |
-
# html.Div([
|
158 |
-
# dcc.Graph(id='scatter-plot_db2-4', figure={}, className='four columns',config=config_fig)
|
159 |
-
# ]),
|
160 |
-
# ])
|
161 |
-
|
162 |
# Create the second tab content with scatter-plot_db2-5 and scatter-plot_db2-6
|
163 |
tab2_content = html.Div([
|
164 |
html.Div([
|
165 |
html.Label("S-cycle genes"),
|
166 |
-
dcc.Dropdown(id='dpdn3', value="
|
167 |
-
options=[
|
168 |
-
|
169 |
-
|
|
|
170 |
html.Label("G2M-cycle genes"),
|
171 |
-
dcc.Dropdown(id='dpdn4', value="
|
172 |
-
options=[
|
173 |
-
|
174 |
-
|
|
|
|
|
175 |
]),
|
176 |
html.Div([
|
177 |
dcc.Graph(id='scatter-plot_db2-5', figure={}, className='three columns',config=config_fig)
|
@@ -212,10 +110,6 @@ tab3_content = html.Div([
|
|
212 |
]),
|
213 |
]),
|
214 |
])
|
215 |
-
# html.Div([
|
216 |
-
# dcc.Graph(id='scatter-plot_db2-12', figure={}, className='four columns',config=config_fig)
|
217 |
-
# ]),
|
218 |
-
|
219 |
|
220 |
tab4_content = html.Div([
|
221 |
html.Label("Column chosen"),
|
@@ -245,47 +139,7 @@ layout = html.Div([
|
|
245 |
]),
|
246 |
])
|
247 |
|
248 |
-
# Define the circular callback
|
249 |
-
#@callback(
|
250 |
-
#Output("min-slider_db2-1", "value"),
|
251 |
-
#Output("max-slider_db2-1", "value"),
|
252 |
-
#Output("min-slider_db2-2", "value"),
|
253 |
-
#Output("max-slider_db2-2", "value"),
|
254 |
-
#Output("min-slider_db2-3", "value"),
|
255 |
-
#Output("max-slider_db2-3", "value"),
|
256 |
-
#Input("min-slider_db2-1", "value"),
|
257 |
-
#Input("max-slider_db2-1", "value"),
|
258 |
-
#Input("min-slider_db2-2", "value"),
|
259 |
-
#Input("max-slider_db2-2", "value"),
|
260 |
-
#Input("min-slider_db2-3", "value"),
|
261 |
-
#Input("max-slider_db2-3", "value"),
|
262 |
-
|
263 |
-
#)
|
264 |
-
# def circular_callback(min_1, max_1, min_2, max_2, min_3, max_3):
|
265 |
-
# return min_1, max_1, min_2, max_2, min_3, max_3
|
266 |
-
|
267 |
-
# @callback(
|
268 |
-
# Output('range-slider_db2-1', 'value'),
|
269 |
-
# Output('range-slider_db2-2', 'value'),
|
270 |
-
# Output('range-slider_db2-3', 'value'),
|
271 |
-
# Input('min-slider_db2-1', 'value'),
|
272 |
-
# Input('max-slider_db2-1', 'value'),
|
273 |
-
# Input('min-slider_db2-2', 'value'),
|
274 |
-
# Input('max-slider_db2-2', 'value'),
|
275 |
-
# Input('min-slider_db2-3', 'value'),
|
276 |
-
# Input('max-slider_db2-3', 'value'),
|
277 |
-
|
278 |
-
# )
|
279 |
-
# def update_slider_values(min_1, max_1, min_2, max_2, min_3, max_3):
|
280 |
-
# return [min_1, max_1], [min_2, max_2], [min_3, max_3]
|
281 |
-
|
282 |
@callback(
|
283 |
-
#Output(component_id='my-graph_db2', component_property='figure'),
|
284 |
-
#Output(component_id='pie-graph_db2', component_property='figure'),
|
285 |
-
#Output(component_id='scatter-plot_db2', component_property='figure'),
|
286 |
-
#Output(component_id='scatter-plot_db2-2', component_property='figure'),
|
287 |
-
#Output(component_id='scatter-plot_db2-3', component_property='figure'),
|
288 |
-
#Output(component_id='scatter-plot_db2-4', component_property='figure'), # Add this new scatter plot
|
289 |
Output(component_id='scatter-plot_db2-5', component_property='figure'),
|
290 |
Output(component_id='scatter-plot_db2-6', component_property='figure'),
|
291 |
Output(component_id='scatter-plot_db2-7', component_property='figure'),
|
@@ -301,9 +155,6 @@ layout = html.Div([
|
|
301 |
Input(component_id='dpdn5', component_property='value'),
|
302 |
Input(component_id='dpdn6', component_property='value'),
|
303 |
Input(component_id='dpdn7', component_property='value'),
|
304 |
-
#Input(component_id='range-slider_db2-1', component_property='value'),
|
305 |
-
#Input(component_id='range-slider_db2-2', component_property='value'),
|
306 |
-
#Input(component_id='range-slider_db2-3', component_property='value'),
|
307 |
|
308 |
)
|
309 |
|
@@ -311,12 +162,6 @@ def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chos
|
|
311 |
batch_chosen = df[col_chosen].unique().to_list()
|
312 |
dff = df.filter(
|
313 |
(pl.col(col_chosen).cast(str).is_in(batch_chosen)) #&
|
314 |
-
#(pl.col(col_features) >= range_value_1[0]) &
|
315 |
-
#(pl.col(col_features) <= range_value_1[1]) &
|
316 |
-
#(pl.col(col_counts) >= range_value_2[0]) &
|
317 |
-
#(pl.col(col_counts) <= range_value_2[1]) &
|
318 |
-
#(pl.col(col_mt) >= range_value_3[0]) &
|
319 |
-
#(pl.col(col_mt) <= range_value_3[1])
|
320 |
)
|
321 |
# Select ordering of plots
|
322 |
if condition1_chosen == "integrated_cell_states":
|
@@ -355,7 +200,6 @@ def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chos
|
|
355 |
dff_5 = dff_5.select(pl.col(col_chosen,"Gene","percentage"))
|
356 |
|
357 |
# Final part to join the percentage expressed and mean expression levels
|
358 |
-
# TO DO
|
359 |
expression_means = expression_means.join(dff_5, on=[col_chosen,"Gene"], how="inner")
|
360 |
|
361 |
fig_scatter_db2_5 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=s_chosen,
|
@@ -389,6 +233,7 @@ def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chos
|
|
389 |
#labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
390 |
hover_name='studies',template="seaborn",category_orders=cat_ord)
|
391 |
|
|
|
392 |
if col_chosen == "integrated_cell_states":
|
393 |
fig_scatter_db2_12 = px.scatter(data_frame=expression_means, x="Gene", y=col_chosen, color="Mean expression",
|
394 |
size="percentage", size_max = 20,
|
|
|
50 |
#filepath = f"az://{path_parquet}"
|
51 |
|
52 |
storage_options={'account_name': AZURE_STORAGE_ACCOUNT, 'account_key': AZURE_STORAGE_ACCESS_KEY} #,'anon': False
|
|
|
53 |
|
|
|
54 |
# Load in multiple dataframes
|
55 |
df = pl.scan_parquet(f"./data/{dataset}.parquet", storage_options=storage_options).collect()
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
# Create the second tab content with scatter-plot_db2-5 and scatter-plot_db2-6
|
58 |
tab2_content = html.Div([
|
59 |
html.Div([
|
60 |
html.Label("S-cycle genes"),
|
61 |
+
dcc.Dropdown(id='dpdn3', value="MCM5", multi=False,
|
62 |
+
options=["MCM5","PCNA","TYMS","FEN1","MCM2","MCM4","RRM1","UNG","GINS2","MCM6","CDCA7","DTL",
|
63 |
+
"PRIM1","UHRF1","HELLS","RFC2","RPA2","NASP","RAD51AP1","GMNN","WDR76","SLBP","CCNE2","UBR7",
|
64 |
+
"POLD3","MSH2","ATAD2","RAD51","RRM2","CDC45","CDC6","EXO1","TIPIN","DSCC1","BLM","CASP8AP2",
|
65 |
+
"USP1","CLSPN","POLA1","CHAF1B","BRIP1","E2F8"]),
|
66 |
html.Label("G2M-cycle genes"),
|
67 |
+
dcc.Dropdown(id='dpdn4', value="TOP2A", multi=False,
|
68 |
+
options=["HMGB2","CDK1","NUSAP1","UBE2C","BIRC5","TPX2","TOP2A","NDC80","CKS2","NUF2","CKS1B","MKI67",
|
69 |
+
"TMPO","CENPF","TACC3","SMC4","CCNB2","CKAP2L","CKAP2","AURKB","BUB1","KIF11","ANP32E","TUBB4B",
|
70 |
+
"GTSE1","KIF20B","HJURP","CDCA3","CDC20","TTK","CDC25C","KIF2C","RANGAP1","NCAPD2","DLGAP5","CDCA2",
|
71 |
+
"CDCA8","ECT2","KIF23","HMMR","AURKA","PSRC1","ANLN","LBR","CKAP5","CENPE","CTCF","NEK2","G2E3",
|
72 |
+
"GAS2L3","CBX5","CENPA"]),
|
73 |
]),
|
74 |
html.Div([
|
75 |
dcc.Graph(id='scatter-plot_db2-5', figure={}, className='three columns',config=config_fig)
|
|
|
110 |
]),
|
111 |
]),
|
112 |
])
|
|
|
|
|
|
|
|
|
113 |
|
114 |
tab4_content = html.Div([
|
115 |
html.Label("Column chosen"),
|
|
|
139 |
]),
|
140 |
])
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
@callback(
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
Output(component_id='scatter-plot_db2-5', component_property='figure'),
|
144 |
Output(component_id='scatter-plot_db2-6', component_property='figure'),
|
145 |
Output(component_id='scatter-plot_db2-7', component_property='figure'),
|
|
|
155 |
Input(component_id='dpdn5', component_property='value'),
|
156 |
Input(component_id='dpdn6', component_property='value'),
|
157 |
Input(component_id='dpdn7', component_property='value'),
|
|
|
|
|
|
|
158 |
|
159 |
)
|
160 |
|
|
|
162 |
batch_chosen = df[col_chosen].unique().to_list()
|
163 |
dff = df.filter(
|
164 |
(pl.col(col_chosen).cast(str).is_in(batch_chosen)) #&
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
)
|
166 |
# Select ordering of plots
|
167 |
if condition1_chosen == "integrated_cell_states":
|
|
|
200 |
dff_5 = dff_5.select(pl.col(col_chosen,"Gene","percentage"))
|
201 |
|
202 |
# Final part to join the percentage expressed and mean expression levels
|
|
|
203 |
expression_means = expression_means.join(dff_5, on=[col_chosen,"Gene"], how="inner")
|
204 |
|
205 |
fig_scatter_db2_5 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=s_chosen,
|
|
|
233 |
#labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
234 |
hover_name='studies',template="seaborn",category_orders=cat_ord)
|
235 |
|
236 |
+
# Reorder categories on natural sorting or on the integrated cell state order of the paper
|
237 |
if col_chosen == "integrated_cell_states":
|
238 |
fig_scatter_db2_12 = px.scatter(data_frame=expression_means, x="Gene", y=col_chosen, color="Mean expression",
|
239 |
size="percentage", size_max = 20,
|