Hi!
I have an alignment (.bam) of reads to mm9 genome. I sorted it with samtools sort
, so that later I can use -sorted
key with bedtools. I also created a .bed-file with regions of interest, in which I want to count number of reads, that mapped to them. I tried this: converted .bam to .bed with bedtools bamtobed
, and then intersected them counting number of hits (bedtools intersect -a regions_of_interest.bed -b alignment_sorted.bed -c -sorted > Neg2H_counts.bedgraph
). The problem is, it looks fine for all chromosomes with numbers from 0 to 9 (and X), but all counts for all regions of interest of chromosomes with higher number (chr10, chr11, etc) are 0. There is no biological reason for that, in fact the highest signal should be on chr11. What could be wrong here? I am fairly new to all these tools.
UPDATE
I tried to do the same intersection with bedmap and the result is identical... So there probably is something wrong with my files - what could it be?
I also tried sorting the alignment-derived bed-file in the same way, as I did with the files with regions of interest and it doesn't help.
I think that it would return an error in that case, wouldn't it? I sorted my files, the alignment with
samtools sort
before converting to bed, and the file with region of interest withsort
.In other words, I suggest the following:
Thank you! It seems that it doesn't expect the file to be sorted as chr1, chr2, chr3, but rather as chr1, chr10, chr11, etc. I was sorting them to get the first, logical order, but after sorting as you suggested it worked!