Question: Counting Number Of Bam Reads Directly Within Set Of Intervals With Bedtools
2
gravatar for User 9996
7.7 years ago by
User 9996800
User 9996800 wrote:

how can I count the number of BAM reads falling directly within a set of intervals, given in a GFF format? Note that I do not want reads overlapping the intervals, but ones that fall directly within them.

I tried the following:

intersectBed -abam reads.bam -b exons.gff -wb -f 1

this has redundancies, so I pipe it into coverageBed as follows:

intersectBed -abam reads.bam -b exons.gff -wb -f 1 | coverageBed -abam stdin -b exons.gff

Is this correct? Thanks.

bedtools bed gff bam rna • 3.1k views
ADD COMMENTlink modified 7.7 years ago by Pierre Lindenbaum120k • written 7.7 years ago by User 9996800
2

Yes, that is correct. I suggest using version 2.13.1 and use the -counts option in coverageBed. This will use less memory and run much more quickly than the default coverageBed.

ADD REPLYlink written 7.7 years ago by Aaronquinlan11k
1

Both BAM (not SAM, which is 1-based) and BED are zero-based, half open. BEDTools handles this automatically anyway.

ADD REPLYlink written 7.7 years ago by Aaronquinlan11k

is there a caveat about 0-based versus 1-based coordinates of SAM and BED format?

ADD REPLYlink written 7.7 years ago by User 9996800

How can this be extended to get all mapped pairs that land in the boundaries of a certain intervals from BAM?

ADD REPLYlink written 7.7 years ago by User 9996800
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 869 users visited in the last hour