From 84ad683563abcbdbd48016acc06146e0abbcdcff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20M=C3=B6lder?= Date: Fri, 27 Oct 2023 08:39:13 +0200 Subject: [PATCH] fine tuning --- workflow/scripts/coverage_table.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/workflow/scripts/coverage_table.py b/workflow/scripts/coverage_table.py index 4989a1d59..d7da7d562 100644 --- a/workflow/scripts/coverage_table.py +++ b/workflow/scripts/coverage_table.py @@ -1,7 +1,15 @@ import pandas as pd +import numpy as np sys.stderr = open(snakemake.log[0], "w") + +def add_missing_columns(df, samples): + missing_columns = set(samples).difference(df.columns) + df[list(missing_columns)] = np.nan + return df + + group_regions = dict() samples = [] for bed in snakemake.input: @@ -23,6 +31,7 @@ df = pd.DataFrame.from_dict(group_regions).T df.index.names = ("chromosome", "gene") df.reset_index(inplace=True) + df = add_missing_columns(samples) else: df = pd.DataFrame(columns=["chromosome", "gene"] + samples)