From 86ad35c41a0cac0c5b074d239cb7104f046ebb75 Mon Sep 17 00:00:00 2001 From: Yiming Yang Date: Tue, 11 Jun 2024 19:59:21 +0000 Subject: [PATCH] Fix bug in writing GSEA results to file --- pegasus/tools/gsea.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pegasus/tools/gsea.py b/pegasus/tools/gsea.py index 38397b6..f0d4c81 100644 --- a/pegasus/tools/gsea.py +++ b/pegasus/tools/gsea.py @@ -175,6 +175,7 @@ def _run_gseapy( res_df = res.res2d res_df.rename(columns={"FDR q-val": "padj", "Term": "pathway"}, inplace=True) + res_df["ES"] = res_df["ES"].astype(np.float64) res_df["NES"] = res_df["NES"].astype(np.float64) res_df["NES abs"] = np.abs(res_df["NES"]) res_df["padj"] = res_df["padj"].astype(np.float64) @@ -298,11 +299,7 @@ def format_short_output_cols( """ df = pd.DataFrame(df_orig, copy = True) # copy must be true, otherwise the passed df_orig will be modified. - cols = [] - for name in df.columns: - if (not name.endswith("pval")) and (not name.endswith("qval")): - cols.append(name) - + cols = ["ES", "NES"] df.loc[:, cols] = df.loc[:, cols].round(ndigits) return df