Can A Bam File Be Sorted By The Read Names
2
3
Entering edit mode
11.3 years ago
ivivek_ngs ★ 5.2k

Hi

Can we sort BAM files according to the read name? As the normal sorting happens on the co-ordinates, can anyone tell how to sort a BAM file on read names? I am trying to run HT-Seq count on paired end SAM files but receiving warnings for which I have to sort the BAM in read names and then create its SAM and then run HT-Seq

RNA-seq • 25k views
ADD COMMENT
13
Entering edit mode
11.3 years ago

pass the -n flag to samtools

samtools sort -n inputfile output

http://samtools.sourceforge.net/samtools.shtml

ADD COMMENT
0
Entering edit mode

Can samtools sort sort a sam file by name directly? If I want to sort the sam file, what can I do?

ADD REPLY
0
Entering edit mode

You can sort a samfile with unix sort like so:

  1. remove the headers
  2. sort on the coordinate field
  3. put back the headers
ADD REPLY
2
Entering edit mode
11.3 years ago

See Picard's SortSam command below. You can sort a sam or bam file using queryname or readname.

http://picard.sourceforge.net/command-line-overview.shtml#SortSam

ADD COMMENT

Login before adding your answer.

Traffic: 2105 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