Spaces:
Running
Running
Update dash_plotly_QC_scRNA.py
Browse files- dash_plotly_QC_scRNA.py +6 -6
dash_plotly_QC_scRNA.py
CHANGED
@@ -301,7 +301,7 @@ def update_slider_values(min_1, max_1, min_2, max_2, min_3, max_3):
|
|
301 |
|
302 |
def update_graph_and_pie_chart(batch_chosen, s_chosen, g2m_chosen, condition1_chosen, condition2_chosen, condition3_chosen, range_value_1, range_value_2, range_value_3):
|
303 |
dff = df.filter(
|
304 |
-
(pl.col(
|
305 |
(pl.col(col_features) >= range_value_1[0]) &
|
306 |
(pl.col(col_features) <= range_value_1[1]) &
|
307 |
(pl.col(col_counts) >= range_value_2[0]) &
|
@@ -311,19 +311,19 @@ def update_graph_and_pie_chart(batch_chosen, s_chosen, g2m_chosen, condition1_ch
|
|
311 |
)
|
312 |
|
313 |
#Drop categories that are not in the filtered data
|
314 |
-
dff = dff.with_columns(dff[
|
315 |
|
316 |
# Plot figures
|
317 |
-
fig_violin = px.violin(data_frame=dff, x=
|
318 |
-
color=
|
319 |
|
320 |
# Cache commonly used subexpressions
|
321 |
total_count = pl.lit(len(dff))
|
322 |
-
category_counts = dff.group_by(
|
323 |
category_counts = category_counts.with_columns(((pl.col("count") / total_count * 100).round(decimals=2)).alias("normalized_count"))
|
324 |
|
325 |
# Display the result
|
326 |
-
labels = category_counts[
|
327 |
values = category_counts["normalized_count"].to_list()
|
328 |
|
329 |
total_cells = total_count # Calculate total number of cells
|
|
|
301 |
|
302 |
def update_graph_and_pie_chart(batch_chosen, s_chosen, g2m_chosen, condition1_chosen, condition2_chosen, condition3_chosen, range_value_1, range_value_2, range_value_3):
|
303 |
dff = df.filter(
|
304 |
+
(pl.col(condition1_chosen).cast(str).is_in(batch_chosen)) &
|
305 |
(pl.col(col_features) >= range_value_1[0]) &
|
306 |
(pl.col(col_features) <= range_value_1[1]) &
|
307 |
(pl.col(col_counts) >= range_value_2[0]) &
|
|
|
311 |
)
|
312 |
|
313 |
#Drop categories that are not in the filtered data
|
314 |
+
dff = dff.with_columns(dff[condition1_chosen].cast(pl.Categorical))
|
315 |
|
316 |
# Plot figures
|
317 |
+
fig_violin = px.violin(data_frame=dff, x=condition1_chosen, y=col_features, box=True, points="all",
|
318 |
+
color=condition1_chosen, hover_name=condition1_chosen,template="seaborn")
|
319 |
|
320 |
# Cache commonly used subexpressions
|
321 |
total_count = pl.lit(len(dff))
|
322 |
+
category_counts = dff.group_by(condition1_chosen).agg(pl.col(condition1_chosen).count().alias("count"))
|
323 |
category_counts = category_counts.with_columns(((pl.col("count") / total_count * 100).round(decimals=2)).alias("normalized_count"))
|
324 |
|
325 |
# Display the result
|
326 |
+
labels = category_counts[condition1_chosen].to_list()
|
327 |
values = category_counts["normalized_count"].to_list()
|
328 |
|
329 |
total_cells = total_count # Calculate total number of cells
|