Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cli/call_peaks_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ pub struct CallPeaksOptions {
/// Include nucleosome and MSP coverage in pileup (default: only FIRE coverage)
#[clap(long)]
pub include_nuc_msp: bool,

/// Include haplotype-specific calls
#[clap(long)]
pub haps: bool,
}

/// The knobs of the shared peak caller. Flattened into `CallPeaksOptions` for the
Expand Down Expand Up @@ -81,6 +77,10 @@ pub struct PeakCallingParams {
/// Minimum FIRE coverage required to calculate a score (default: 4)
#[clap(long, default_value = "4", hide = true)]
pub min_fire_coverage: i32,

/// Include haplotype-specific calls
#[clap(long)]
pub haps: bool,
}

/// Local-max window and merge geometry: meaningful for any element source, so
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/call_peaks/peaks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ pub fn call_peaks_for_chrom(
track_fire_elements: true, // Enable FIRE element tracking for peak calling
},
rolling_max: Some(params.merge.window_size),
haps: false,
haps: params.haps,
per_base: false,
keep_zeros: false,
min_fire_coverage: Some(params.min_fire_coverage),
Expand Down
10 changes: 8 additions & 2 deletions src/subcommands/pileup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,19 +699,25 @@ impl<'a> FiberseqPileup<'a> {
&None,
);
let (hap1_data, hap2_data) = if pileup_opts.haps {
// Only all_data's FIRE elements are ever read (peak boundaries in
// call-peaks), so do not pay for them on the haplotype tracks.
let hap_opts = FireTrackOptions {
track_fire_elements: false,
..fire_track_opts.clone()
};
(
Some(FireTrack::new(
chrom.to_string(),
chrom_start,
chrom_end,
fire_track_opts.clone(),
hap_opts.clone(),
&None,
)),
Some(FireTrack::new(
chrom.to_string(),
chrom_start,
chrom_end,
fire_track_opts.clone(),
hap_opts,
&None,
)),
)
Expand Down
1 change: 1 addition & 0 deletions src/subcommands/union_peaks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ pub fn run_union_peaks(opts: &UnionPeaksOptions) -> Result<()> {
max_fdr: 1.0,
min_fire_frac: Some(0.0),
min_fire_frac_filter: 0.0,
haps: false, // BED intervals carry no HP tag
};

let mut writer = bio_io::writer(&opts.out)?;
Expand Down
19 changes: 19 additions & 0 deletions tests/regression/call_peaks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,22 @@ fn call_peaks_ctcf_snapshot() {
]);
insta::assert_snapshot!(out);
}

/// `--haps` must fill the H1/H2 columns from HP tags (issue #140: the flag was
/// parsed but never reached the pileup, so every haplotype column was zero).
#[test]
fn call_peaks_haps_fills_haplotype_columns() {
let out = run(&[
"call-peaks",
fixture("NAPA.bam").to_str().unwrap(),
"--haps",
"--min-fire-frac",
"0.5",
]);
let peak = out.lines().find(|l| !l.starts_with('#')).expect("one peak");
let cols: Vec<&str> = peak.split('\t').collect();
// coverage, coverage_H1, coverage_H2
assert_eq!(cols[5], "95");
assert_eq!(cols[10], "45");
assert_eq!(cols[15], "14");
}
Loading