Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Move NA values to end of table #124

Merged
merged 7 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions workflow/rules/meta_comparisons.smk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rule meta_compare_diffexp:
"results/tables/diffexp/meta_compare_{meta_comp}.tsv",
"results/meta_comparison/diffexp/{meta_comp}.json",
log:
notebook="logs/meta_compare_diffexp/{meta_comp}.ipynb",
"logs/meta_compare_diffexp/{meta_comp}.log",
params:
labels=lookup(
dpath="meta_comparisons/comparisons/{meta_comp}/items",
Expand Down Expand Up @@ -42,7 +42,7 @@ rule meta_compare_enrichment:
"results/tables/go_terms/meta_compare_{meta_comp}.tsv",
"results/meta_comparison/go_terms/{meta_comp}.json",
log:
notebook="logs/meta_compare_enrichment/{meta_comp}.ipynb",
"logs/meta_compare_enrichment/{meta_comp}.log",
params:
labels=lookup(
dpath="meta_comparisons/comparisons/{meta_comp}/items",
Expand All @@ -67,7 +67,7 @@ rule meta_compare_pathways:
"results/tables/pathways/meta_compare_{meta_comp}.tsv",
"results/meta_comparison/pathways/{meta_comp}.json",
log:
notebook="logs/meta_compare_pathways/{meta_comp}.ipynb",
"logs/meta_compare_pathways/{meta_comp}.log",
params:
labels=lookup(
dpath="meta_comparisons/comparisons/{meta_comp}/items",
Expand Down
10 changes: 9 additions & 1 deletion workflow/scripts/compare_diffexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ def prepare(df):
combined.with_columns(
(-pl.col("pval_min").log(base=10) * pl.col("difference")).alias("pi_value")
)
.sort(pl.col("pi_value").abs(), descending=True)
.with_columns(
pl.col("pi_value").fill_nan(None),
pl.col("difference").fill_nan(None),
)
Comment on lines +53 to +56
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems convoluted, but at least it's well documented:
https://docs.pola.rs/user-guide/expressions/missing-data/#notanumber-or-nan-values

.sort(
pl.col("pi_value").abs(),
descending=True,
nulls_last=True,
)
.select(
pl.col(
"ext_gene",
Expand Down
Loading