| name | subtract-bed |
| description | Use when you need to remove overlapping portions of one interval set from another, such as subtracting blacklist, repeat, or annotation regions from BED, GFF, VCF, or BAM-like inputs. |
| disable-model-invocation | true |
| user-invocable | true |
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
-A or -N.
- Apply strand-aware and fraction-aware subtraction rules before downstream counting or annotation.
Common Patterns
subtractBed \
-a peaks.bed \
-b blacklist.bed \
> peaks.clean.bed
subtractBed \
-a exons.bed \
-b repeats.bed \
-A \
-f 0.5 \
> exons.filtered.bed
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
-sorted with -g when a stable chromosome order matters.
- If you need to inspect why intervals were altered, rerun with
-wo or -wb as 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.
-A removes the whole A feature on qualifying overlap, while -N with -f uses the summed overlap across all B features.
-wo and -wb change the output layout for overlap inspection; do not treat those outputs like plain trimmed BED intervals.
-sorted requires truly coordinate-sorted inputs and may need -nonamecheck if naming conventions differ (chr1 vs chr01).
- If you use BAM as input A, add
-bed when the downstream consumer expects BED-style output rather than alignment output.