Arts-of-coding commited on
Commit
aa683d0
·
verified ·
1 Parent(s): 0fbe7d1

Update dash_plotly_QC_scRNA.py

Browse files
Files changed (1) hide show
  1. dash_plotly_QC_scRNA.py +11 -15
dash_plotly_QC_scRNA.py CHANGED
@@ -361,22 +361,18 @@ def update_slider_values(min_1, max_1, min_2, max_2, min_3, max_3):
361
  )
362
 
363
  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):
364
- batch_col = dff['batch']
365
- batch_cat = batch_col.cast(pl.Categorical)
366
- feature_cols = pl.col(cols)
367
- count_cols = pl.col(col_counts)
368
- mt_cols = pl.col(col_mt)
369
-
370
- # Perform filtering on all features simultaneously
371
- filter_expr = (batch_cat.is_in(batch_chosen)) & \
372
- (feature_cols >= range_value_1[0]) & \
373
- (feature_cols <= range_value_1[1]) & \
374
- (count_cols >= range_value_2[0]) & \
375
- (count_cols <= range_value_2[1]) & \
376
- (mt_cols >= range_value_3[0]) & \
377
- (mt_cols <= range_value_3[1])
378
 
379
- dff = dff.filter(filter_expr)
 
380
 
381
  # Plot figures
382
  fig_violin = px.violin(data_frame=dff, x='batch', y=col_features, box=True, points="all",
 
361
  )
362
 
363
  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):
364
+ dff = df.filter(
365
+ (pl.col('batch').cast(str).is_in(batch_chosen)) &
366
+ (pl.col(col_features) >= range_value_1[0]) &
367
+ (pl.col(col_features) <= range_value_1[1]) &
368
+ (pl.col(col_counts) >= range_value_2[0]) &
369
+ (pl.col(col_counts) <= range_value_2[1]) &
370
+ (pl.col(col_mt) >= range_value_3[0]) &
371
+ (pl.col(col_mt) <= range_value_3[1])
372
+ )
 
 
 
 
 
373
 
374
+ #Drop categories that are not in the filtered data
375
+ dff = dff.with_columns(dff['batch'].cast(pl.Categorical))
376
 
377
  # Plot figures
378
  fig_violin = px.violin(data_frame=dff, x='batch', y=col_features, box=True, points="all",