- 参考染色体大小文件
chrom.size
chr1 100
chr2 150
- 将染色体划分为20bp为一个bin的区间
$ bedtools makewindows -g chrom.size -w 20
chr1 0 20
chr1 20 40
chr1 40 60
chr1 60 80
chr1 80 100
chr2 0 20
chr2 20 40
chr2 40 60
chr2 60 80
chr2 80 100
chr2 100 120
chr2 120 140
chr2 140 150
- 将染色体划分成20bp为一个bin滑动距离为10bp的区间
$ bedtools makewindows -g chrom.size -w 20 -s 10
chr1 0 20
chr1 10 30
chr1 20 40
chr1 30 50
chr1 40 60
chr1 50 70
chr1 60 80
chr1 70 90
chr1 80 100
chr1 90 100
chr2 0 20
chr2 10 30
chr2 20 40
chr2 30 50
chr2 40 60
chr2 50 70
chr2 60 80
chr2 70 90
chr2 80 100
chr2 90 110
chr2 100 120
chr2 110 130
chr2 120 140
chr2 130 150
chr2 140 150
- 将每条染色体划分为5个相同大小的窗口
$ bedtools makewindows -g chrom.size -n 5
chr1 0 20
chr1 20 40
chr1 40 60
chr1 60 80
chr1 80 100
chr2 0 30
chr2 30 60
chr2 60 90
chr2 90 120
chr2 120 150
- 将给定BED文件中的每个间隔划分为5个大小相等的窗口
$ cat chrom.size.bed
chr1 1 100
chr2 1 150
$ bedtools makewindows -b chrom.size.bed -n 5
chr1 1 20
chr1 20 39
chr1 39 58
chr1 58 77
chr1 77 100
chr2 1 30
chr2 30 59
chr2 59 88
chr2 88 117
chr2 117 150
- 将给定BED文件中的每个间隔划分为3个大小相等的窗口, 并且在最后一列加上属于第几个bin,这对于
ChIP-seq
、BS-seq
等这种需要绘制metaplot
的图时候,作用特别好。
$ cat chrom.size_3col.bed
chr1 1 100 A
chr1 200 300 B
chr1 350 400 C
$ bedtools makewindows -b chrom.size_3col.bed -n 3 -i winnum
chr1 1 34 1
chr1 34 67 2
chr1 67 100 3
chr1 200 233 1
chr1 233 266 2
chr1 266 300 3
chr1 350 366 1
chr1 366 382 2
chr1 382 400 3
$ bedtools makewindows -b chrom.size_3col.bed -n 3 -i srcwinnum
chr1 1 34 A_1
chr1 34 67 A_2
chr1 67 100 A_3
chr1 200 233 B_1
chr1 233 266 B_2
chr1 266 300 B_3
chr1 350 366 C_1
chr1 366 382 C_2
chr1 382 400 C_3
- 有时候需要区分正负方向呢?
$ bedtools makewindows -b chrom.size_3col.bed -n 3 -i winnum -reverse
chr1 1 34 3
chr1 34 67 2
chr1 67 100 1
chr1 200 233 3
chr1 233 266 2
chr1 266 300 1
chr1 350 366 3
chr1 366 382 2
chr1 382 400 1
- 结合上面生成以下?一般这种方式感觉作用不大。
$ bedtools makewindows -b chrom.size.bed -w 20 -s 10 -i winnum
chr1 1 21 1
chr1 11 31 2
chr1 21 41 3
chr1 31 51 4
chr1 41 61 5
chr1 51 71 6
chr1 61 81 7
chr1 71 91 8
chr1 81 100 9
chr1 91 100 10
chr2 1 21 1
chr2 11 31 2
chr2 21 41 3
chr2 31 51 4
chr2 41 61 5
chr2 51 71 6
chr2 61 81 7
chr2 71 91 8
chr2 81 101 9
chr2 91 111 10
chr2 101 121 11
chr2 111 131 12
chr2 121 141 13
chr2 131 150 14
chr2 141 150 15
- 使用awk进行均分
[qliu@node9 bedtools_test]$ awk -v num_win=5 '{len = $3-$2; size = len/num_win; \
> for (start=$2; start<$3; start+=size) \
> print $1"\t"start"\t"start+size}' chrom.size.bed
-
bedtools makewindows
参数:
Transcriptome analysis and bedtools
Question: Sliding window using gene position file
generating BED with sliding-windows intervals
strand-aware makewindows?
bedtools intersect -u -a $featureBED -b $signalBED | \
cat <(awk '($6 == "+")' | bedtools makewindows -b - -w $windowBin -i srcwinnum) \
<(awk '($6 == "-")' | bedtools makewindows -b - -w $windowBin -i srcwinnum -reverse) > out.bed