bedtools Command Examples

A swiss-army knife of tools for genomic-analysis tasks. Used to intersect, group, convert and count data in BAM, BED, GFF/GTF, VCF format. More information: https://bedtools.readthedocs.io.

bedtools intersect -a {{path/to/file_A}} -b {{path/to/file_B1 path/to/file_B2 ...}} -s > {{path/to/output_file}}

bedtools intersect -a {{path/to/file1}} -b {{path/to/file2}} -loj > {{path/to/output_file}}

bedtools intersect -a {{path/to/file1}} -b {{path/to/file2}} -sorted > {{path/to/output_file}}

bedtools groupby -i {{path/to/file}} -c 1-3,5 -g 6 -o sum

bedtools bamtobed -i {{path/to/file.bam}} > {{path/to/file.bed}}

bedtools closest -a {{path/to/file1.bed}} -b {{path/to/file2.bed}} -d