Skip to content

Commit

Permalink
Add more support for customizing coverage plot
Browse files Browse the repository at this point in the history
  • Loading branch information
dfornika committed Jul 5, 2024
1 parent d3faa52 commit 383c566
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/plot-coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def plot_coverage(depths: pd.DataFrame, bed: dict, sample_name: str="Sample", th
longest_chrom_length = depths[depths.chrom == longest_chrom].pos.max()
longest_chrom_length_mb = longest_chrom_length / 1_000_000
sns.set_style("whitegrid")
dpi = 100
dpi = 300
width_pixels = round(longest_chrom_length_mb * width_inches_per_mb * dpi)
height_pixels = round(height_inches_per_chrom * num_chroms * dpi)
logging.info(f"Plot size: {width_pixels} x {height_pixels} pixels")
Expand Down
6 changes: 6 additions & 0 deletions modules/alignment_variants.nf
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,18 @@ process plot_coverage {
tuple val(sample_id), path("${sample_id}_${short_long}_coverage.png"), optional: true

script:
log_scale = params.coverage_plot_log_scale ? "--log-scale" : ""
"""
plot-coverage.py \
--sample-id ${sample_id} \
--ref ${ref} \
--depths ${depths} \
--threshold ${params.min_depth} \
--y-limit ${params.coverage_plot_y_limit} \
--width-inches-per-mb ${params.coverage_plot_width_inches_per_mb} \
--height-inches-per-chrom ${params.coverage_plot_height_inches_per_chrom} \
--window ${params.coverage_plot_window_size} \
${log_scale} \
--output ${sample_id}_${short_long}_coverage.png
"""
Expand Down
5 changes: 5 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ params {
min_alternate_fraction_for_variant_calling = 0.1
qualimap_coverage_histogram_limit = 100
coverage_by_depth_limit = 500
coverage_plot_y_limit = 500
coverage_plot_log_scale = false
coverage_plot_width_inches_per_mb = 3
coverage_plot_height_inches_per_chrom = 2
coverage_plot_window_size = 1000
qualimap_memory = '4G'
skip_alignment_cleaning = false
align_long_reads = false
Expand Down

0 comments on commit 383c566

Please sign in to comment.