Arts-of-coding commited on
Commit
d899476
·
verified ·
1 Parent(s): 2999709

Update dash_plotly_QC_scRNA.py

Browse files
Files changed (1) hide show
  1. dash_plotly_QC_scRNA.py +7 -1
dash_plotly_QC_scRNA.py CHANGED
@@ -396,7 +396,13 @@ def update_graph_and_pie_chart(batch_chosen, s_chosen, g2m_chosen, condition1_ch
396
  # Melt wide format DataFrame into long format
397
  dff_pre = dff.with_columns(["batch","Cdc45","Uhrf1","Mcm2","Slbp","Mcm5","Pola1","Gmnn","Cdc6","Rrm2","Atad2"])
398
  #dff_pre = dff_pre.with_columns(dff_pre['batch'].cast(pl.Utf8))
399
- dff_long = dff_pre.with_columns(pl.col('batch').cast(pl.Categorical)).melt(id_vars="batch", variable_name="Gene", value_name="Expression")
 
 
 
 
 
 
400
  expression_means = dff_long.group_by(["Region", "Gene"]).agg(pl.mean("Expression"))
401
 
402
  fig_pie = px.pie(names=labels, values=values, title=pie_title,template="seaborn")
 
396
  # Melt wide format DataFrame into long format
397
  dff_pre = dff.with_columns(["batch","Cdc45","Uhrf1","Mcm2","Slbp","Mcm5","Pola1","Gmnn","Cdc6","Rrm2","Atad2"])
398
  #dff_pre = dff_pre.with_columns(dff_pre['batch'].cast(pl.Utf8))
399
+ dff_pre = dff.with_columns(pl.lit(None).cast(pl.String).alias("batch"), pl.col("*"))
400
+
401
+ # Cast Cdc45, Uhrf1, Mcm2, Slbp, Mcm5, Pola1, Gmnn, Cdc6, Rrm2, Atad2 columns to float type
402
+ for gene in ["Cdc45", "Uhrf1", "Mcm2", "Slbp", "Mcm5", "Pola1", "Gmnn", "Cdc6", "Rrm2", "Atad2"]:
403
+ dff_pre = dff_pre.with_columns(pl.col(gene).cast(pl.Float64))
404
+
405
+ #dff_long = dff_pre.with_columns(pl.col('batch').cast(pl.Categorical)).melt(id_vars="batch", variable_name="Gene", value_name="Expression")
406
  expression_means = dff_long.group_by(["Region", "Gene"]).agg(pl.mean("Expression"))
407
 
408
  fig_pie = px.pie(names=labels, values=values, title=pie_title,template="seaborn")