how to modify sam file sort order
1
0
Entering edit mode
9.6 years ago
i19870503 ▴ 10

I got the error when I run cuffdiff

Error: sort order of reads in BAMs must be the same

so I use samtools view find that in this bam file, the others are sorted as chr1,chr2....not like this one.

How to modify the order to make it as other file?

@HD    VN:1.0    SO:coordinate
@SQ    SN:chr10    LN:66736929    UR:file:/home/group1/corona/ucsc2.fa    M5:171e7a3f72ba195f457720406be3604b
@SQ    SN:chr11    LN:79814395    UR:file:/home/group1/corona/ucsc2.fa    M5:feeab3090c18a3cab9547f99d35052a8
@SQ    SN:chr12    LN:57431344    UR:file:/home/group1/corona/ucsc2.fa    M5:f3309f09ea225f9a191b5d0d9eee961d
@SQ    SN:chr13    LN:145235301    UR:file:/home/group1/corona/ucsc2.fa    M5:3a4b8ac5120541c225eb870fa4a2b501
@SQ    SN:chr14    LN:148510138    UR:file:/home/group1/corona/ucsc2.fa    M5:c607e774abadba7ed0b0185f18e3f9d5
@SQ    SN:chr15    LN:134541103    UR:file:/home/group1/corona/ucsc2.fa    M5:08f26a29f88b39bff614cd6fbfa7d2ef
@SQ    SN:chr16    LN:77435658    UR:file:/home/group1/corona/ucsc2.fa    M5:0f5873a922aa3327b4523def56cad5e6
@SQ    SN:chr17    LN:64395339    UR:file:/home/group1/corona/ucsc2.fa    M5:ac533e777ca34fe996fdf58598266b98
@SQ    SN:chr18    LN:54309914    UR:file:/home/group1/corona/ucsc2.fa    M5:1cc33aec4862e0d56e691e5dc5960501
@SQ    SN:chr1    LN:295529705    UR:file:/home/group1/corona/ucsc2.fa    M5:2cf1f3b70031dc473022a5a5893e8edb
@SQ    SN:chr2    LN:140133492    UR:file:/home/group1/corona/ucsc2.fa    M5:b709bf0683d1abdca4f6236a45524577
@SQ    SN:chr3    LN:123599780    UR:file:/home/group1/corona/ucsc2.fa    M5:2e896d4cc99e908405eb690a71467e37
@SQ    SN:chr4    LN:136254946    UR:file:/home/group1/corona/ucsc2.fa    M5:32ceede4917f4ea64a7ab93040211d21
@SQ    SN:chr5    LN:100516970    UR:file:/home/group1/corona/ucsc2.fa    M5:50bd953e6de61fb729390a122f830653
@SQ    SN:chr6    LN:123305171    UR:file:/home/group1/corona/ucsc2.fa    M5:2ed43939ee3490a30cbe40e96cf33289
@SQ    SN:chr7    LN:136409062    UR:file:/home/group1/corona/ucsc2.fa    M5:57ed74ddd703b537d8fece561887bcf4
@SQ    SN:chr8    LN:119985671    UR:file:/home/group1/corona/ucsc2.fa    M5:deadaedc161e58bf8c8d6b3ea1c25eba
@SQ    SN:chr9    LN:132468591    UR:file:/home/group1/corona/ucsc2.fa    M5:89eae5d26c774408170957bb006efbbd
@SQ    SN:chrM    LN:16770    UR:file:/home/group1/corona/ucsc2.fa    M5:c32d2133c7327cc9e47776c5eed17977
@SQ    SN:chrX    LN:125871292    UR:file:/home/group1/corona/ucsc2.fa    M5:d09f454e7e0e413bdd5e65af386c581d
@RG    ID:20121127154622665    LB:50F    SM:1CM
RNA-Seq • 3.4k views
ADD COMMENT
1
Entering edit mode
9.6 years ago

If you have a reference fasta file that contains chromosomes in your order of interest (i.e. chr1, chr2, ...) , you can use Picard's ReorderSam tools to sort your bam file. You will have to generate .dict file for your reference genome. Please go to https://broadinstitute.github.io/picard/command-line-overview.html and Ctrl+F for ReorderSam.

ADD COMMENT
0
Entering edit mode

Ok, got it. Thanks very much.

ADD REPLY
0
Entering edit mode

One more question, if I convert the bam file to sam, could I modfiy the order munually.

ADD REPLY
0
Entering edit mode

Yes, SAM is a tab delimited text file. You should be able to process it but I am not sure what would be your approach.

ADD REPLY

Login before adding your answer.

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