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
Changes from 3 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
13 changes: 12 additions & 1 deletion workflow/scripts/compare_diffexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,20 @@ def prepare(df):
combined = combined.with_columns(
abs(pl.col(effect_x) - pl.col(effect_y)).alias("difference")
)
print(combined)
combined = (
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 All @@ -64,6 +73,8 @@ def prepare(df):
)
.to_pandas()
)
)
print(combined)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Syntax error and additional print statement

There are two issues in this segment:

  1. There's an extra closing parenthesis at line 76, which is causing a syntax error. This needs to be removed.
  2. Another print statement is added at line 77, which might be useful for debugging but could clutter output in production.

To fix the syntax error and address the print statement, apply the following changes:

-)
-print(combined)
+print(combined)  # Consider removing or wrapping in a debug condition

This will resolve the syntax error and maintain the print statement. However, consider removing the print statement or wrapping it in a debug condition for production use.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
)
print(combined)
print(combined) # Consider removing or wrapping in a debug condition
🧰 Tools
🪛 Ruff

76-76: SyntaxError: Expected a statement


76-77: SyntaxError: Expected a statement

combined.to_csv(snakemake.output[0], sep="\t", index=False)


Expand Down
Loading