Arts-of-coding commited on
Commit
d8aa475
·
verified ·
1 Parent(s): 330e25b

Update pages/DLC_corg_scVI_integrated_week6-week16.py

Browse files
pages/DLC_corg_scVI_integrated_week6-week16.py CHANGED
@@ -54,7 +54,7 @@ storage_options={'account_name': AZURE_STORAGE_ACCOUNT, 'account_key': AZURE_STO
54
  # Load in multiple dataframes
55
  df = pl.read_parquet(f"az://{dataset}.parquet", storage_options=storage_options)
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"),
@@ -72,20 +72,20 @@ tab2_content = html.Div([
72
  "GAS2L3","CBX5","CENPA"]),
73
  ]),
74
  html.Div([
75
- dcc.Graph(id='scatter-plot_db2-5', figure={}, className='three columns',config=config_fig)
76
  ]),
77
  html.Div([
78
- dcc.Graph(id='scatter-plot_db2-6', figure={}, className='three columns',config=config_fig)
79
  ]),
80
  html.Div([
81
- dcc.Graph(id='scatter-plot_db2-7', figure={}, className='three columns',config=config_fig)
82
  ]),
83
  html.Div([
84
- dcc.Graph(id='scatter-plot_db2-8', figure={}, className='three columns',config=config_fig)
85
  ]),
86
  ])
87
 
88
- # Create the second tab content with scatter-plot_db2-5 and scatter-plot_db2-6
89
  tab3_content = html.Div([
90
  html.Div([
91
  html.Label("UMAP condition 1"),
@@ -95,16 +95,16 @@ tab3_content = html.Div([
95
  dcc.Dropdown(id='dpdn6', value="PAX6", multi=False,
96
  options=df.columns),
97
  html.Div([
98
- dcc.Graph(id='scatter-plot_db2-9', figure={}, className='four columns', hoverData=None ,config=config_fig)
99
  ]),
100
  html.Div([
101
- dcc.Graph(id='scatter-plot_db2-10', figure={}, className='four columns', hoverData=None, config=config_fig)
102
  ]),
103
  html.Div([
104
- dcc.Graph(id='scatter-plot_db2-11', figure={}, className='four columns',config=config_fig)
105
  ]),
106
  html.Div([
107
- dcc.Graph(id='my-graph_db22', figure={}, clickData=None, hoverData=None,
108
  className='four columns',config=config_fig
109
  )
110
  ]),
@@ -124,7 +124,7 @@ tab4_content = html.Div([
124
  options=df.columns),
125
  ]),
126
  html.Div([
127
- dcc.Graph(id='scatter-plot_db2-12', figure={}, className='row',style={'width': '100vh', 'height': '90vh'})
128
  ]),
129
  ])
130
 
@@ -143,15 +143,15 @@ layout = html.Div([
143
  ])
144
 
145
  @callback(
146
- Output(component_id='scatter-plot_db2-5', component_property='figure'),
147
- Output(component_id='scatter-plot_db2-6', component_property='figure'),
148
- Output(component_id='scatter-plot_db2-7', component_property='figure'),
149
- Output(component_id='scatter-plot_db2-8', component_property='figure'),
150
- Output(component_id='scatter-plot_db2-9', component_property='figure'),
151
- Output(component_id='scatter-plot_db2-10', component_property='figure'),
152
- Output(component_id='scatter-plot_db2-11', component_property='figure'),
153
- Output(component_id='scatter-plot_db2-12', component_property='figure'),
154
- Output(component_id='my-graph_db22', component_property='figure'),
155
  Input(component_id='dpdn2', component_property='value'),
156
  Input(component_id='dpdn3', component_property='value'),
157
  Input(component_id='dpdn4', component_property='value'),
@@ -205,55 +205,55 @@ def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chos
205
  # Final part to join the percentage expressed and mean expression levels
206
  expression_means = expression_means.join(dff_5, on=[col_chosen,"Gene"], how="inner")
207
 
208
- fig_scatter_db2_5 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=s_chosen,
209
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
210
  hover_name=None, title="S-cycle gene:",template="seaborn")
211
 
212
- fig_scatter_db2_6 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=g2m_chosen,
213
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
214
  hover_name='sample', title="G2M-cycle gene:",template="seaborn")
215
 
216
- fig_scatter_db2_7 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="S_score",
217
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
218
  hover_name='sample', title="S score:",template="seaborn")
219
 
220
- fig_scatter_db2_8 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="G2M_score",
221
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
222
  hover_name='sample', title="G2M score:",template="seaborn")
223
 
224
  # Sort values of custom in-between
225
  dff = dff.sort(condition1_chosen)
226
 
227
- fig_scatter_db2_9 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition1_chosen,
228
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
229
  hover_name=None,hover_data = None, template="seaborn",category_orders=cat_ord)
230
- fig_scatter_db2_9.update_traces(hoverinfo='none', hovertemplate=None)
231
- fig_scatter_db2_9.update_layout(hovermode=False)
232
 
233
- fig_scatter_db2_10 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition2_chosen,
234
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
235
  hover_name='sample',template="seaborn")
236
 
237
- fig_scatter_db2_11 = px.scatter(data_frame=dff, x=condition1_chosen, y=condition2_chosen, color=condition1_chosen,
238
  #labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
239
  hover_name='sample',template="seaborn",category_orders=cat_ord)
240
 
241
  # Reorder categories on natural sorting or on the integrated cell state order of the paper
242
  if col_chosen == "integrated_cell_states":
243
- fig_scatter_db2_12 = px.scatter(data_frame=expression_means, x="Gene", y=col_chosen, color="Mean expression",
244
  size="percentage", size_max = 20,
245
  #labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
246
  hover_name=col_chosen,template="seaborn",category_orders={col_chosen: natsorted(expression_means[col_chosen].unique()),"Gene": condition3_chosen})
247
  else:
248
- fig_scatter_db2_12 = px.scatter(data_frame=expression_means, x="Gene", y=col_chosen, color="Mean expression",
249
  size="percentage", size_max = 20,
250
  #labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
251
  hover_name=col_chosen,template="seaborn",category_orders={col_chosen: natsorted(expression_means[col_chosen].unique()),"Gene": condition3_chosen})
252
 
253
- fig_violin_db22 = px.violin(data_frame=dff, x=condition1_chosen, y=condition2_chosen, box=True, points="all",
254
  color=condition1_chosen, hover_name=condition1_chosen,template="seaborn",category_orders=cat_ord)
255
 
256
 
257
- return fig_scatter_db2_5, fig_scatter_db2_6, fig_scatter_db2_7, fig_scatter_db2_8, fig_scatter_db2_9, fig_scatter_db2_10, fig_scatter_db2_11, fig_scatter_db2_12, fig_violin_db22 #fig_violin_db2, fig_pie_db2, fig_scatter_db2, fig_scatter_db2_2, fig_scatter_db2_3, fig_scatter_db2_4,
258
 
259
  # Set http://localhost:5000/ in web browser
 
54
  # Load in multiple dataframes
55
  df = pl.read_parquet(f"az://{dataset}.parquet", storage_options=storage_options)
56
 
57
+ # Create the second tab content with scatter-plot_db10-5 and scatter-plot_db10-6
58
  tab2_content = html.Div([
59
  html.Div([
60
  html.Label("S-cycle genes"),
 
72
  "GAS2L3","CBX5","CENPA"]),
73
  ]),
74
  html.Div([
75
+ dcc.Graph(id='scatter-plot_db10-5', figure={}, className='three columns',config=config_fig)
76
  ]),
77
  html.Div([
78
+ dcc.Graph(id='scatter-plot_db10-6', figure={}, className='three columns',config=config_fig)
79
  ]),
80
  html.Div([
81
+ dcc.Graph(id='scatter-plot_db10-7', figure={}, className='three columns',config=config_fig)
82
  ]),
83
  html.Div([
84
+ dcc.Graph(id='scatter-plot_db10-8', figure={}, className='three columns',config=config_fig)
85
  ]),
86
  ])
87
 
88
+ # Create the second tab content with scatter-plot_db10-5 and scatter-plot_db10-6
89
  tab3_content = html.Div([
90
  html.Div([
91
  html.Label("UMAP condition 1"),
 
95
  dcc.Dropdown(id='dpdn6', value="PAX6", multi=False,
96
  options=df.columns),
97
  html.Div([
98
+ dcc.Graph(id='scatter-plot_db10-9', figure={}, className='four columns', hoverData=None ,config=config_fig)
99
  ]),
100
  html.Div([
101
+ dcc.Graph(id='scatter-plot_db10-10', figure={}, className='four columns', hoverData=None, config=config_fig)
102
  ]),
103
  html.Div([
104
+ dcc.Graph(id='scatter-plot_db10-11', figure={}, className='four columns',config=config_fig)
105
  ]),
106
  html.Div([
107
+ dcc.Graph(id='my-graph_db102', figure={}, clickData=None, hoverData=None,
108
  className='four columns',config=config_fig
109
  )
110
  ]),
 
124
  options=df.columns),
125
  ]),
126
  html.Div([
127
+ dcc.Graph(id='scatter-plot_db10-12', figure={}, className='row',style={'width': '100vh', 'height': '90vh'})
128
  ]),
129
  ])
130
 
 
143
  ])
144
 
145
  @callback(
146
+ Output(component_id='scatter-plot_db10-5', component_property='figure'),
147
+ Output(component_id='scatter-plot_db10-6', component_property='figure'),
148
+ Output(component_id='scatter-plot_db10-7', component_property='figure'),
149
+ Output(component_id='scatter-plot_db10-8', component_property='figure'),
150
+ Output(component_id='scatter-plot_db10-9', component_property='figure'),
151
+ Output(component_id='scatter-plot_db10-10', component_property='figure'),
152
+ Output(component_id='scatter-plot_db10-11', component_property='figure'),
153
+ Output(component_id='scatter-plot_db10-12', component_property='figure'),
154
+ Output(component_id='my-graph_db102', component_property='figure'),
155
  Input(component_id='dpdn2', component_property='value'),
156
  Input(component_id='dpdn3', component_property='value'),
157
  Input(component_id='dpdn4', component_property='value'),
 
205
  # Final part to join the percentage expressed and mean expression levels
206
  expression_means = expression_means.join(dff_5, on=[col_chosen,"Gene"], how="inner")
207
 
208
+ fig_scatter_db10_5 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=s_chosen,
209
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
210
  hover_name=None, title="S-cycle gene:",template="seaborn")
211
 
212
+ fig_scatter_db10_6 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=g2m_chosen,
213
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
214
  hover_name='sample', title="G2M-cycle gene:",template="seaborn")
215
 
216
+ fig_scatter_db10_7 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="S_score",
217
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
218
  hover_name='sample', title="S score:",template="seaborn")
219
 
220
+ fig_scatter_db10_8 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="G2M_score",
221
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
222
  hover_name='sample', title="G2M score:",template="seaborn")
223
 
224
  # Sort values of custom in-between
225
  dff = dff.sort(condition1_chosen)
226
 
227
+ fig_scatter_db10_9 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition1_chosen,
228
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
229
  hover_name=None,hover_data = None, template="seaborn",category_orders=cat_ord)
230
+ fig_scatter_db10_9.update_traces(hoverinfo='none', hovertemplate=None)
231
+ fig_scatter_db10_9.update_layout(hovermode=False)
232
 
233
+ fig_scatter_db10_10 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition2_chosen,
234
  labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
235
  hover_name='sample',template="seaborn")
236
 
237
+ fig_scatter_db10_11 = px.scatter(data_frame=dff, x=condition1_chosen, y=condition2_chosen, color=condition1_chosen,
238
  #labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
239
  hover_name='sample',template="seaborn",category_orders=cat_ord)
240
 
241
  # Reorder categories on natural sorting or on the integrated cell state order of the paper
242
  if col_chosen == "integrated_cell_states":
243
+ fig_scatter_db10_12 = px.scatter(data_frame=expression_means, x="Gene", y=col_chosen, color="Mean expression",
244
  size="percentage", size_max = 20,
245
  #labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
246
  hover_name=col_chosen,template="seaborn",category_orders={col_chosen: natsorted(expression_means[col_chosen].unique()),"Gene": condition3_chosen})
247
  else:
248
+ fig_scatter_db10_12 = px.scatter(data_frame=expression_means, x="Gene", y=col_chosen, color="Mean expression",
249
  size="percentage", size_max = 20,
250
  #labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
251
  hover_name=col_chosen,template="seaborn",category_orders={col_chosen: natsorted(expression_means[col_chosen].unique()),"Gene": condition3_chosen})
252
 
253
+ fig_violin_db102 = px.violin(data_frame=dff, x=condition1_chosen, y=condition2_chosen, box=True, points="all",
254
  color=condition1_chosen, hover_name=condition1_chosen,template="seaborn",category_orders=cat_ord)
255
 
256
 
257
+ return fig_scatter_db10_5, fig_scatter_db10_6, fig_scatter_db10_7, fig_scatter_db10_8, fig_scatter_db10_9, fig_scatter_db10_10, fig_scatter_db10_11, fig_scatter_db10_12, fig_violin_db102 #fig_violin_db10, fig_pie_db10, fig_scatter_db10, fig_scatter_db10_2, fig_scatter_db10_3, fig_scatter_db10_4,
258
 
259
  # Set http://localhost:5000/ in web browser