From bb00eb5aa71e34e51bc31d4eae5136116ea23ad3 Mon Sep 17 00:00:00 2001 From: Chiara Rasi Date: Mon, 26 Feb 2024 07:38:13 +0100 Subject: [PATCH 1/6] Do not multiply mean coverage values by 100 on coverage reports --- CHANGELOG.md | 1 + src/chanjo2/meta/handle_report_contents.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 713d5cd3..076cb8b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Reformat report sample' sex rows and coverage.get_samples_predicted_sex endpoint to use d4tools and not pyd4 for evaluating sample sex ### Fixed - `coverage.d4_interval_coverage` endpoint crashing trying to computer coverage completeness over an entire chromosome +- Samples mean coverage values a hundredfold higher on coverage reports ## [1.4] ### Changed diff --git a/src/chanjo2/meta/handle_report_contents.py b/src/chanjo2/meta/handle_report_contents.py index 21896ea6..1a084459 100644 --- a/src/chanjo2/meta/handle_report_contents.py +++ b/src/chanjo2/meta/handle_report_contents.py @@ -218,11 +218,12 @@ def get_report_completeness_rows( completeness_row: Dict[str, float] = {} for completeness_key, completeness_values in sample_stats.items(): - completeness_row[completeness_key] = ( - round((mean(completeness_values) * 100), 2) - if completeness_values - else 0 - ) + if completeness_key != "mean_coverage": + completeness_row[completeness_key] = ( + round((mean(completeness_values) * 100), 2) + if completeness_values + else 0 + ) completeness_rows.append((sample, completeness_row)) From 3d39e51ea6c59b0cf2eee702d80d206679ed0987 Mon Sep 17 00:00:00 2001 From: Chiara Rasi Date: Mon, 26 Feb 2024 07:54:12 +0100 Subject: [PATCH 2/6] Add also mean cov values to report --- src/chanjo2/meta/handle_report_contents.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/chanjo2/meta/handle_report_contents.py b/src/chanjo2/meta/handle_report_contents.py index 1a084459..aaa7a2b2 100644 --- a/src/chanjo2/meta/handle_report_contents.py +++ b/src/chanjo2/meta/handle_report_contents.py @@ -224,6 +224,8 @@ def get_report_completeness_rows( if completeness_values else 0 ) + else: + completeness_row[completeness_key] = round(mean(completeness_values), 2) completeness_rows.append((sample, completeness_row)) From a3e5dcce3ce4a2fe6e7bf72e9813254fb2f0dc2f Mon Sep 17 00:00:00 2001 From: Chiara Rasi Date: Mon, 26 Feb 2024 08:16:22 +0100 Subject: [PATCH 3/6] Final fix --- src/chanjo2/meta/handle_report_contents.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/chanjo2/meta/handle_report_contents.py b/src/chanjo2/meta/handle_report_contents.py index aaa7a2b2..47a01f44 100644 --- a/src/chanjo2/meta/handle_report_contents.py +++ b/src/chanjo2/meta/handle_report_contents.py @@ -218,14 +218,12 @@ def get_report_completeness_rows( completeness_row: Dict[str, float] = {} for completeness_key, completeness_values in sample_stats.items(): + column_value = mean(completeness_values) if completeness_key != "mean_coverage": - completeness_row[completeness_key] = ( - round((mean(completeness_values) * 100), 2) - if completeness_values - else 0 - ) - else: - completeness_row[completeness_key] = round(mean(completeness_values), 2) + column_value = column_value * 100 + completeness_row[completeness_key] = ( + round(column_value, 2) if column_value else 0 + ) completeness_rows.append((sample, completeness_row)) From de8155d22264659210bf5da6f49aaac63789f606 Mon Sep 17 00:00:00 2001 From: Chiara Rasi Date: Mon, 26 Feb 2024 08:21:17 +0100 Subject: [PATCH 4/6] Update docker push action --- .github/workflows/build_and_push_docker_stage.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_push_docker_stage.yml b/.github/workflows/build_and_push_docker_stage.yml index d38aeeb0..0ea399f6 100644 --- a/.github/workflows/build_and_push_docker_stage.yml +++ b/.github/workflows/build_and_push_docker_stage.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out git repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Extract branch name and remove illegal chars id: get_branch_name @@ -15,18 +15,18 @@ jobs: run: echo "branch=$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")" >>$GITHUB_OUTPUT - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push id: docker_build - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: ./ file: ./Dockerfile From 8d2f3c6b9f43ff9bfbdabab07ee2fa6be09a9b6c Mon Sep 17 00:00:00 2001 From: Chiara Rasi Date: Mon, 26 Feb 2024 08:32:34 +0100 Subject: [PATCH 5/6] Simplify and fix test --- src/chanjo2/meta/handle_report_contents.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/chanjo2/meta/handle_report_contents.py b/src/chanjo2/meta/handle_report_contents.py index 47a01f44..cc23f1b1 100644 --- a/src/chanjo2/meta/handle_report_contents.py +++ b/src/chanjo2/meta/handle_report_contents.py @@ -205,25 +205,20 @@ def get_report_completeness_rows( completeness_rows: List[str, Dict[str, float]] = [] for sample, interval_stats in samples_coverage_stats.items(): - sample_stats: Dict[str, List[float]] = {"mean_coverage": []} + sample_stats: Dict[str, List[float]] = { + "mean_coverage": [interval.mean_coverage for interval in interval_stats] + } for level in levels: - sample_stats[f"completeness_{level}"]: List[float] = [] - - for interval in interval_stats: - sample_stats["mean_coverage"].append(interval.mean_coverage) - for level in levels: - sample_stats[f"completeness_{level}"].append( - interval.completeness[level] - ) + sample_stats[f"completeness_{level}"]: List[float] = [ + interval.completeness[level] for interval in interval_stats + ] completeness_row: Dict[str, float] = {} for completeness_key, completeness_values in sample_stats.items(): - column_value = mean(completeness_values) + column_value = mean(completeness_values) if completeness_values else 0 if completeness_key != "mean_coverage": column_value = column_value * 100 - completeness_row[completeness_key] = ( - round(column_value, 2) if column_value else 0 - ) + completeness_row[completeness_key] = round(column_value or 0, 2) completeness_rows.append((sample, completeness_row)) From 9ed5fd6337f1bee85ee3bf752e9f16f248aa2503 Mon Sep 17 00:00:00 2001 From: Chiara Rasi Date: Mon, 26 Feb 2024 08:44:29 +0100 Subject: [PATCH 6/6] Revert action --- .github/workflows/build_and_push_docker_stage.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_push_docker_stage.yml b/.github/workflows/build_and_push_docker_stage.yml index 0ea399f6..d38aeeb0 100644 --- a/.github/workflows/build_and_push_docker_stage.yml +++ b/.github/workflows/build_and_push_docker_stage.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out git repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Extract branch name and remove illegal chars id: get_branch_name @@ -15,18 +15,18 @@ jobs: run: echo "branch=$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")" >>$GITHUB_OUTPUT - name: Login to Docker Hub - uses: docker/login-action@v3 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v2 - name: Build and push id: docker_build - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v4 with: context: ./ file: ./Dockerfile