1) Installation
Bedtools offers 3 mounting options
- Download source code from Google code to install
- Install using the package management tools in the system, such as Yum under Cnetos, Apt-get under Ubuntu, homebrew under Mac
- Download the source code from GitHub for installation
Since you can't access Google code and want to compile the installation, download the latest version from GitHub: HTTPS://GITHUB.COM/ARQ5X/BEDTOOLS2
Download the v2.25.0 version of the source code for installation
wget https://github.com/arq5x/bedtools2/archive/v2.25.0.tar.gztar XZVF v2. 25.0 CD BEDTOOLS2-2.25. 0/makeCD bin/export PATH= $PWD: $PATH
2) Use
Intersect: Ask for the intersection of two intervals, the input file can be BED,GFF,VCF
Prepare two test files,
Cpg.bed, the contents of which are
Chr12070cpg_1chr1100120cpg_2chr1150250cpg_3
Exon.bed, the contents of which are
Chr11040exon_1chr15060exon_2chr1130180exon_3chr1200280exon_4
Using the default parameters, please overlap the file, run
Bedtools intersect-a cpg.bed- b exon.bed
Result is
Chr12040cpg_1chr15060cpg_1chr1150180cpg_3chr1200250cpg_3
As you can see, by default only the area of overlap in a is output
Add the-wa parameter and run it again
Bedtools intersect-a cpg.bed- b Exon.bed-wa
The result is:
Chr12070cpg_1chr12070cpg_1chr1150250cpg_3chr1150250cpg_3
As can be seen, with the-wa parameter, as long as the area in A and B in the area has a intersection, the output, and overlap several times, the output several times
Add-WB parameter, run
Bedtools intersect-a cpg.bed- b EXON.BED-WB
The result is:
Chr12040cpg_1chr11040exon_1chr15060cpg_1chr15060exon_2chr1150180cpg_3chr1130180exon_3chr1200250cpg_ 3chr1200280exon_4
As you can see, with the-WB parameter, the entire range in B is output in addition to the overlap area in output a.
Add-wa,-WB parameters, run again
Bedtools intersect-a cpg.bed- b EXON.BED-WA-WB
The result is:
Chr12070cpg_1chr11040exon_1chr12070cpg_1chr15060exon_2chr1150250cpg_3chr1130180exon_3chr1150250cpg_ 3chr1200280exon_4
As you can see, adding the-wa and-WB parameters at the same time will output the overlap area in pairs
-C parameter, count the number of each region and Boverlap in a
Bedtools intersect-a cpg.bed- b exon.bed-c
The result is:
Chr12070cpg_12chr1100120cpg_20chr1150250cpg_32
-V parameter: only outputs a zone with no boverlap in a
Bedtools intersect-a cpg.bed- b exon.bed-v
The result is:
Chr1100120cpg_2
As you can see, as long as the overlap with B is not output.
Installation and use of Bedtools