Recently, I was doing an RNA-seq project, and I used spike-in control sequences in my experiment. So I mapped the reads to both human genome and spike-in sequences. And I successfully got the bam file, but when I tried to use the command samtools sort -o aa_sorted.bam aa.bam
to sort the bam file according to the chromosome name, and got those confused order, here is the sorted bam file's header:
As you can see, The chromosomes marked with a red frame are placed in front of the chromosome 1. This result is really confusing. Can anyone help me here, thanks in advance.
Oh, so it is. Thanks a lot. So I just need to change the header and it can sort as I want it to, is that what you mean ?
Yes, but don't reheader the BAM file (this will completely screw things up), use something like I outlined where there's a SAM file produced and then piped into
samtools sort
.