Commit
·
42ffbc5
1
Parent(s):
0b3c509
Update pages/Cornea_v1_integrated_scVI.py
Browse files
pages/Cornea_v1_integrated_scVI.py
CHANGED
@@ -318,27 +318,11 @@ def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chos
|
|
318 |
#(pl.col(col_mt) >= range_value_3[0]) &
|
319 |
#(pl.col(col_mt) <= range_value_3[1])
|
320 |
)
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
# # Plot figures
|
328 |
-
# fig_violin_db2 = px.violin(data_frame=dff, x=col_chosen, y=col_features, box=True, points="all",
|
329 |
-
# color=col_chosen, hover_name=col_chosen,template="seaborn")
|
330 |
-
|
331 |
-
# # Cache commonly used subexpressions
|
332 |
-
# total_count = pl.lit(len(dff))
|
333 |
-
# category_counts = dff.group_by(col_chosen).agg(pl.col(col_chosen).count().alias("count"))
|
334 |
-
# category_counts = category_counts.with_columns(((pl.col("count") / total_count * 100).round(decimals=2)).alias("normalized_count"))
|
335 |
-
|
336 |
-
# # Sort the dataframe
|
337 |
-
# #category_counts = category_counts.sort(col_chosen) does not work check if the names are different ...
|
338 |
-
|
339 |
-
# # Display the result
|
340 |
-
# total_cells = total_count # Calculate total number of cells
|
341 |
-
# pie_title = f'Percentage of Total Cells: {total_cells}' # Include total cells in the title
|
342 |
|
343 |
# Calculate the mean expression
|
344 |
|
@@ -373,35 +357,6 @@ def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chos
|
|
373 |
# Final part to join the percentage expressed and mean expression levels
|
374 |
# TO DO
|
375 |
expression_means = expression_means.join(dff_5, on=[col_chosen,"Gene"], how="inner")
|
376 |
-
|
377 |
-
# Order the dataframe on ascending categories
|
378 |
-
#expression_means = expression_means.sort(col_chosen, descending=False)
|
379 |
-
|
380 |
-
#expression_means = expression_means.select(["batch", "Gene", "Expression"] + condition3_chosen)
|
381 |
-
# category_counts = category_counts.sort(col_chosen)
|
382 |
-
|
383 |
-
# fig_pie_db2 = px.pie(category_counts, values="normalized_count", names=col_chosen, labels=col_chosen, hole=.3, title=pie_title, template="seaborn")
|
384 |
-
|
385 |
-
# #labels = category_counts[col_chosen].to_list()
|
386 |
-
# #values = category_counts["normalized_count"].to_list()
|
387 |
-
|
388 |
-
# # Create the scatter plots
|
389 |
-
# fig_scatter_db2 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_chosen,
|
390 |
-
# labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
391 |
-
# hover_name='batch',template="seaborn")
|
392 |
-
|
393 |
-
# fig_scatter_db2_2 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_mt,
|
394 |
-
# labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
395 |
-
# hover_name='batch',template="seaborn")
|
396 |
-
|
397 |
-
# fig_scatter_db2_3 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_features,
|
398 |
-
# labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
399 |
-
# hover_name='batch',template="seaborn")
|
400 |
-
|
401 |
-
|
402 |
-
# fig_scatter_db2_4 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_counts,
|
403 |
-
# labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
404 |
-
# hover_name='batch',template="seaborn")
|
405 |
|
406 |
fig_scatter_db2_5 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=s_chosen,
|
407 |
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
@@ -424,7 +379,7 @@ def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chos
|
|
424 |
|
425 |
fig_scatter_db2_9 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition1_chosen,
|
426 |
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
427 |
-
hover_name='studies',template="seaborn")
|
428 |
|
429 |
fig_scatter_db2_10 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition2_chosen,
|
430 |
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
@@ -432,7 +387,7 @@ def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chos
|
|
432 |
|
433 |
fig_scatter_db2_11 = px.scatter(data_frame=dff, x=condition1_chosen, y=condition2_chosen, color=condition1_chosen,
|
434 |
#labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
435 |
-
hover_name='studies',template="seaborn")
|
436 |
|
437 |
if col_chosen == "integrated_cell_states":
|
438 |
fig_scatter_db2_12 = px.scatter(data_frame=expression_means, x="Gene", y=col_chosen, color="Mean expression",
|
|
|
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 col_chosen == "integrated_cell_states":
|
323 |
+
cat_ord= {condition1_chosen: ["LSC-1","LSC-2","LE","CE","Cj","qSK","SK","TSK","CF","EC","Ves","Mel","IC","nm-cSC","MC"]}
|
324 |
+
else:
|
325 |
+
cat_ord= {condition1_chosen: natsorted(dff[condition1_chosen].unique())}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
|
327 |
# Calculate the mean expression
|
328 |
|
|
|
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,
|
362 |
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
|
|
379 |
|
380 |
fig_scatter_db2_9 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition1_chosen,
|
381 |
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
382 |
+
hover_name='studies',template="seaborn",category_orders=cat_ord)
|
383 |
|
384 |
fig_scatter_db2_10 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition2_chosen,
|
385 |
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
|
|
387 |
|
388 |
fig_scatter_db2_11 = px.scatter(data_frame=dff, x=condition1_chosen, y=condition2_chosen, color=condition1_chosen,
|
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",
|