How to use bedtools to calculate number of reads in windows
1
0
Entering edit mode
2.1 years ago
Dacheng • 0

Hi I want to calculate how many reads from a BAM file (150bp paired end illumina) are in each 20kb non-overlapping windows across the genome. I have constructed the bed files of 20kb windows using bedtools makewindows. I am using bedtools intersect to calculate the number of reads from the bam files. Here is the exact command that I use:

bedtools intersect -a myBAMfile  -b my bedfile of 20kb windows  -c -bed  > output.bed  

I used - c to output the counts and -bed to force output a bed file basically. I wanted some result like this

chr  start end counts 

1      a      b     n

however  the results output was a huge (45GB) file that looks something like this 
1       9999    10047   HWI-ST208:510:C2PKUACXX:1:1307:7971:38840/2     0       +       9999    10047   0,0,0   1       48,     0,      0
1       10000   10051   HWI-ST208:510:C2PKUACXX:1:1101:10183:165157/2   0       +       10000   10051   0,0,0   1       51,     0,      0
1       10001   10052   HWI-ST208:510:C2PKUACXX:1:1105:4675:14114/2     0       +       10001   10052   0,0,0   1       51,     0,      0
1       10001   10052   HWI-ST208:510:C2PKUACXX:1:2108:19598:121982/1   0       +       10001   10052   0,0,0   1       51,     0,      0
1       10002   10053   HWI-ST208:510:C2PKUACXX:1:1302:15349:25257/2    0       +       10002   10053   0,0,0   1       51,     0,      0
1       10003   10054   HWI-ST208:510:C2PKUACXX:1:1104:15953:82940/2    0       +       10003   10054   0,0,0   1       51,     0,      0
1       10003   10054   HWI-ST208:510:C2PKUACXX:1:1306:9147:59251/1     0       +       10003   10054   0,0,0   1       51,     0,      0
1       10004   10055   HWI-ST208:510:C2PKUACXX:1:1202:10485:85215/1    0       +       10004   10055   0,0,0   1       51,     0,      0
1       10004   10054   HWI-ST208:510:C2PKUACXX:1:1303:7159:34459/2     0       +       10004   10054   0,0,0   1       50,     0,      0
1       10004   10039   HWI-ST208:510:C2PKUACXX:1:2103:9398:104872/2    0       +       10004   10039   0,0,0   1       35,     0,      0

Can anyone tell me what I went wrong using bedtools?

bedtools • 1.5k views
ADD COMMENT
0
Entering edit mode

enter image description here

Hi sorry this is the output I have from running my command

ADD REPLY
1
Entering edit mode
2.1 years ago

switch -a and -b

bedtools intersect -a my.bed  -b my.bam -c   > output.bed  
ADD COMMENT
0
Entering edit mode

This is counting the times bed files are present in the BAM files? It only gives me zero at the end at all windows

ADD REPLY
0
Entering edit mode

check the intervals, check the chromosome notation (chr1 vs 1)

ADD REPLY

Login before adding your answer.

Traffic: 2832 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6