Spaces:
Running
Running
Update dash_plotly_QC_scRNA.py
Browse files- dash_plotly_QC_scRNA.py +8 -2
dash_plotly_QC_scRNA.py
CHANGED
@@ -396,12 +396,18 @@ def update_graph_and_pie_chart(batch_chosen, s_chosen, g2m_chosen, condition1_ch
|
|
396 |
# Melt wide format DataFrame into long format
|
397 |
# Specify batch column as string type and gene columns as float type
|
398 |
dff_pre = dff.select(["batch","Cdc45","Mcm5"])
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
|
400 |
# Melt wide format DataFrame into long format
|
401 |
-
dff_long =
|
402 |
|
403 |
# Calculate the mean expression levels for each gene in each region
|
404 |
-
expression_means = dff_long.group_by(["
|
405 |
|
406 |
fig_pie = px.pie(names=labels, values=values, title=pie_title,template="seaborn")
|
407 |
|
|
|
396 |
# Melt wide format DataFrame into long format
|
397 |
# Specify batch column as string type and gene columns as float type
|
398 |
dff_pre = dff.select(["batch","Cdc45","Mcm5"])
|
399 |
+
|
400 |
+
#cols_to_cast = ["Cdc45", "Mcm5", "batch"] # add more column names here as needed
|
401 |
+
|
402 |
+
# Dynamically select and cast the specified columns to f64, except for "batch" which is cast to Utf8
|
403 |
+
#dff_pre = dff.select([pl.col(c).cast(pl.Float64) if c != "batch" else pl.col(c).cast(pl.Utf8) for c in dff.columns])
|
404 |
+
|
405 |
|
406 |
# Melt wide format DataFrame into long format
|
407 |
+
dff_long = dff_pre.melt(id_vars="batch", variable_name="Gene", value_name="Expression")
|
408 |
|
409 |
# Calculate the mean expression levels for each gene in each region
|
410 |
+
expression_means = dff_long.group_by(["batch", "Gene"]).agg(pl.mean("Expression"))
|
411 |
|
412 |
fig_pie = px.pie(names=labels, values=values, title=pie_title,template="seaborn")
|
413 |
|