subtract-bed
Quick Start
- Command:
subtractBed -a <bed/gff/vcf> -b <bed/gff/vcf> - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/subtractBed - Full reference: references/help.md
When To Use This Tool
- Remove blacklist, repeat, or exclusion intervals from a target interval set.
- Trim only the overlapping segments from A while keeping the remaining pieces.
- Drop entire A features on qualifying overlap with
-Aor-N. - Apply strand-aware and fraction-aware subtraction rules before downstream counting or annotation.
Common Patterns
# 1) Remove blacklist segments from peaks
subtractBed \
-a peaks.bed \
-b blacklist.bed \
> peaks.clean.bed
# 2) Remove whole A features if at least half the feature overlaps B
subtractBed \
-a exons.bed \
-b repeats.bed \
-A \
-f 0.5 \
> exons.filtered.bed
# 3) Subtract only same-strand overlaps, treating BED12/BAM splits separately
subtractBed \
-a transcripts.bed12 \
-b antisense-mask.bed \
-s \
-split \
> transcripts.trimmed.bed
Recommended Workflow
- Decide whether you want partial trimming of A (default) or whole-record removal with
-A/-N. - Add overlap thresholds and strand rules deliberately with
-f,-F,-r,-e,-s, or-S. - For large datasets, coordinate-sort the inputs first and then use
-sortedwith-gwhen a stable chromosome order matters. - If you need to inspect why intervals were altered, rerun with
-woor-wbas a diagnostic pass rather than as the final cleaned output.
Guardrails
- Default subtraction can split one A interval into multiple output fragments; that is expected behavior, not duplication.
-Aremoves the whole A feature on qualifying overlap, while-Nwith-fuses the summed overlap across all B features.-woand-wbchange the output layout for overlap inspection; do not treat those outputs like plain trimmed BED intervals.-sortedrequires truly coordinate-sorted inputs and may need-nonamecheckif naming conventions differ (chr1vschr01).- If you use BAM as input A, add
-bedwhen the downstream consumer expects BED-style output rather than alignment output.