2.6 years ago by
I suggests a combination of
bedtools merge or cluster, depending on what is the final goal. For instance, using
## code untested
bamToBed -i my.bam \ # converts bam to bed. Ensures that read ID is kept which will be useful for counting
| mergeBed -i stdin -c 4 -o count \ # merges reads within 100 base pairs and counts the number of reads in each merged interval using the read ID in col4
| head # peek results before saving
Keep in mind that will not account for strandness of reads. Use the options
-S for that. Well read the tool documentation for fine tuning.
cluster should also work, but it would require a little more work and a
merge wnayway. The only advantage I see over
mergeis that it would allow you to keep the read IDs for each cluster.