intersect-bed
Quick Start
- Command:
intersectBed -a <A> -b <B> [options] - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/intersectBed - Full reference: See
references/help.md
When To Use This Tool
- Find overlaps between genomic intervals in BED, GFF, VCF, or BAM-like inputs.
- Filter A features to keep only overlapping records or only non-overlapping records.
- Count overlaps per A feature with
-c/-C. - Retain joined context from both files with
-wa -wb,-wo,-wao, or-loj. - Apply strand-aware and fraction-aware overlap rules before downstream annotation or QC.
Common Patterns
# 1) Basic interval overlap
intersectBed \
-a peaks.bed \
-b promoters.bed
# 2) Keep both records plus overlap length
intersectBed \
-a peaks.bed \
-b promoters.bed \
-wa -wb -wo
# 3) Count overlaps per A interval with reciprocal overlap filtering
intersectBed \
-a peaks.bed \
-b enhancers.bed \
-c \
-f 0.5 \
-r
Recommended Workflow
- Decide whether you need filtering (
-u,-v), joining (-wa,-wb,-wo,-wao,-loj), or counting (-c,-C) before you run the command. - Confirm chromosome naming conventions match across files before trusting an empty result.
- Add
-s/-Sand-f/-F/-r/-edeliberately instead of assuming bedtools defaults fit the biology. - Use
-sortedonly when the inputs are truly sorted, and provide-gif you need a fixed chromosome order.
Guardrails
- Both
-aand-bare required, and-bcan contain multiple files or wildcards. - With BAM as
-a, the default output is BAM-like alignment output unless you request-bedor-ubam. -waoreports non-overlapping A records with a NULL B feature and overlap0;-wodoes not.-Creports counts per B file on distinct lines, which is easy to misread if you expected one line per A feature.- Prefer
-hfor help; some--help/--versionpatterns on these bedtools wrappers emit errors before exiting.