"reads not sorted" in a sorted bam file

164 views
Skip to first unread message

Toby Hocking

unread,
Jul 10, 2014, 3:41:01 PM7/10/14
to rseg-s...@googlegroups.com
Hi, thanks for making your RSEG software publicly available! I tried running it on some bam files, but it said "reads not sorted" so I did a samtools sort and it still says that. Can you please explain how I can use rseg-diff on bam files?

thocking@silene:~/projects/chip-seq(master*)$ rseg-0.4.8/src/rseg/rseg-diff -B -c chroms_hg19.bed -m 2 BCU1053_TC_ChIP_H3K4me3_1.merged.nodups.mapq15.bam BCU1053_TC_ChIP_Input_1.merged.nodups.mapq15.bam
ERROR: reads not sorted in BCU1053_TC_ChIP_H3K4me3_1.merged.nodups.mapq15.bam
chr1    14917    15017    DJG63NM1:273:D2307ACXX:7:1105:17902:133701    46    -
chr1    14918    15018    DJG63NM1:273:D2307ACXX:7:1202:12211:106288    23    +
thocking@silene:~/projects/chip-seq(master*)$ samtools sort BCU1053_TC_ChIP_H3K4me3_1.merged.nodups.mapq15.bam BCU1053_TC_ChIP_H3K4me3_1.merged.nodups.mapq15.sorted.bam
[bam_sort_core] merging from 43 files...
thocking@silene:~/projects/chip-seq(master*)$ rseg-0.4.8/src/rseg/rseg-diff -B -c chroms_hg19.bed -m 2 BCU1053_TC_ChIP_H3K4me3_1.merged.nodups.mapq15.sorted.bam.bam BCU1053_TC_ChIP_Input_1.merged.nodups.mapq15.bam
ERROR: reads not sorted in BCU1053_TC_ChIP_H3K4me3_1.merged.nodups.mapq15.sorted.bam.bam
chr1    14917    15017    DJG63NM1:273:D2307ACXX:7:1105:17902:133701    46    -
chr1    14918    15018    DJG63NM1:273:D2307ACXX:7:1202:12211:106288    23    +
thocking@silene:~/projects/chip-seq(master*)$

Song, Qiang

unread,
Jul 11, 2014, 6:51:27 PM7/11/14
to RSEG Users
Hi Toby,

Thanks for your interest in RSEG. The problem with bam input files is
due to that samtoolsvdoes not use the strand information when sorting.
But rseg uses the strand to determine whether reads are duplicates. I
would suggest that you first convert bam files to bed file and that
sort the bed files as described in the manual.

Best,
Song Qiang


--
You received this message because you are subscribed to the Google Groups "RSEG Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rseg-support...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Toby Hocking

unread,
Jul 31, 2014, 10:11:03 AM7/31/14
to rseg-s...@googlegroups.com
Thanks for the helpful reply. I eventually got rseg-diff to work by first converting the bam files to bed

bamToBed -i unsorted.bam > unsorted.bed

and then sorting it with

LC_ALL=C sort -k1,1 -k3,3n -k2,2n -k6,6 -o sorted.bed unsorted.bed

(note that the -k6,6 option is required to sort by strand, but is not mentioned in the RSEG manual)
Reply all
Reply to author
Forward
0 new messages