Skip to content

Commit

Permalink
Merge pull request #232 from Clinical-Genomics/fix_mean_cov
Browse files Browse the repository at this point in the history
Do not multiply mean coverage values by 100 on coverage reports
  • Loading branch information
northwestwitch authored Feb 27, 2024
2 parents e4f7423 + 28c35f7 commit ad70341
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- pyd4 lib must be installed separately when chanjo2 is installed installed locally - Docs updated accordingly
### 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
Expand Down
24 changes: 10 additions & 14 deletions src/chanjo2/meta/handle_report_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +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():
completeness_row[completeness_key] = (
round((mean(completeness_values) * 100), 2)
if completeness_values
else 0
)
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 or 0, 2)

completeness_rows.append((sample, completeness_row))

Expand Down

0 comments on commit ad70341

Please sign in to comment.