pybedtools comes with several scripts that illustrate common use-cases.

In Python 2.7, you can use:

python -m pybedtools

to get a list of scripts and their description.

Venn diagram scripts

There are two scripts for making Venn diagrams, depending on how you’d like the diagrams to look. Both simply take 3 BED files as input. uses the Google Chart API, while uses matplotlib if you have it installed.

Upon installing pybedtools, these scripts should be available on your path. Calling them with the -h option will print the help, and using the --test option will run a test, creating a new file out.png in the current working directory.


Above: using --test with results in this figure


Above: Result of using --test with

Intron/exon classification

The script accepts a GFF file (with introns and exons annotated) and a BAM file. When complete, it prints out the number of exonic, intronic, and both intronic and exonic (i.e., from overlapping genes or isoforms). This script is also a good example of how to do use Python’s multiprocessing for parallel computation.

The script extends closestBed by classifying features (intron, exon) that are a distance of 0 away from the query features.